<?php
#Network Traffic Monitor is an application to monitor the network traffic on all SNMP managable devices.
#
#Copyright (c) 2004, Daimler Trust nv <hide@address.com> - Jan Van Hees <hide@address.com>
#
#This file is part of Network Traffic Monitor.
#
# Network Traffic Monitor is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# Network Traffic Monitor is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Network Traffic Monitor; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/*
* This script is the main page after logging in
*/
require_once("../auth.php");
require_once ("../config.php");
require_once ("HTML/Template/IT.php");
if($_POST['port']){
header("Location: error.php");
exit;
}
$tpl = new HTML_Template_IT(TEMPLATEDIR);
$tpl->loadTemplatefile("home.html");
$sql = "SELECT fullname FROM users WHERE users.uid=$_SESSION[uid] ORDER BY fullname";
$db = dbLogin();
$fullname = $db->getOne($sql);
$tpl->setVariable("USERNAME", $fullname);
$logtype = $_SESSION[logtype];
$uid = $_SESSION[uid];
$gid = $_SESSION[gid];
if($logtype=="Administrator" || $logtype=="Finance"){
$sql="SELECT ports.portname, ports.pid, groups.groupname FROM ports
INNER JOIN portgroups ON ports.pid=portgroups.pid
INNER JOIN groups ON portgroups.gid=groups.gid ORDER BY ports.portname";
}
else{
$gid=$db->getOne("SELECT groups.gid from groups INNER JOIN groupmember ON groups.gid=groupmember.gid INNER JOIN users ON users.uid=groupmember.uid WHERE users.uid=$uid");
$sql="SELECT ports.portname, ports.pid, groups.groupname FROM ports
INNER JOIN portgroups ON ports.pid=portgroups.pid
INNER JOIN groups ON portgroups.gid=groups.gid
INNER JOIN groupmember ON groupmember.gid=portgroups.gid
WHERE groupmember.uid=$uid ORDER BY ports.portname";
}
$temp = $db->query($sql);
$i = 0;
$size = $temp->numRows();
$graphs="";
while ($row = $temp->fetchrow()){
if($logtype == "Administrator" || $logtype=="Finance"){
$title="$row[2] $row[0]";
}
else if($logtype =="User"){
$title="$row[0]";
}
$iface = $row[1];
$row = $temp->fetchrow();
if($logtype == "Administrator" || $logtype=="Finance"){
$title2="$row[2] $row[0]";
}
else if($logtype=="User"){
$title2="$row[0]";
}
$iface2 = $row[1];
$graphs .="<tr><td><h4>$title</h4></td><td><h4>$title2</h4></td></tr>";
$graphs .="<tr><td><a href=\"graphs.php?i=$iface\">
<img src=\"24h.php?graph=24h&i=$iface&h=0\" border=\"0\"></a></td>";
if($row[1]){
$graphs.="<td><a href=\"graphs.php?i=$iface2\"><img src=\"24h.php?graph=24h&i=$iface2&h=0\" border=\"0\"></a></td></tr>";
}
else{
$graphs .="<td> </td></tr>";
}
}
$tpl->setVariable("graphs", $graphs);
$content = $tpl->get();
fillFrame($db, $content);
?>