include("include.php"); include("header.php"); // Get variables from url $sensor_name = ""; if (isset($_GET['sensor_name']) && $_GET['sensor_name'] != "none") $sensor_name = $_GET['sensor_name']; if (isset($_GET['interval']) && $_GET['interval'] != "none") $interval = $_GET['interval']; if (isset($_GET['timestamp']) && $_GET['timestamp'] != "none") $timestamp = $_GET['timestamp']; if (isset($_GET['subnet']) && $_GET['subnet'] != "none") $subnet = $_GET['subnet']; if (isset($_GET['limit']) && $_GET['limit'] != "none") $limit = $_GET['limit']; $db = ConnectDb(); ?>
// Validation if (!isset($sensor_name) || !$sensor_name) exit(0); if(!isset($sensor_id)) { echo "$my_sql
Ip | Name | Total | Sent | Received | tcp | udp | icmp | http | p2p | ftp"; if (!isset($subnet)) // Set this now for total graphs $subnet = "0.0.0.0/0"; // Output Total Line echo " |
Total | $subnet"; foreach (array("total", "sent", "received", "tcp", "udp", "icmp", "http", "p2p", "ftp") as $key) { if($dbtype == DB_PGSQL) { for($Counter=0, $Total = 0; $Counter < pg_num_rows($result); $Counter++) { $r = pg_fetch_array($result, $Counter); $Total += $r[$key]; } } else if($dbtype == DB_MYSQL) { if(mysql_num_rows($result) > 0) mysql_data_seek($result, 0); for($Counter = 0, $Total = 0; $Counter < mysql_num_rows($result); $Counter++) { $r = mysql_fetch_array($result); $Total += $r[$key]; } } echo fmtb($Total); } echo "\n"; // Output Other Lines if($dbtype == DB_PGSQL) { for($Counter=0; $Counter < pg_num_rows($result) && $Counter < $limit; $Counter++) { $r = pg_fetch_array($result, $Counter); echo " | |||||||||
"; echo $r['ip']." | ".gethostbyaddr($r['ip']); echo ""; echo fmtb($r['total']).fmtb($r['sent']).fmtb($r['received']). fmtb($r['tcp']).fmtb($r['udp']).fmtb($r['icmp']).fmtb($r['http']). fmtb($r['p2p']).fmtb($r['ftp'])."\n"; } } else if($dbtype == DB_MYSQL) { if(mysql_num_rows($result) > 0) mysql_data_seek($result, 0); for($Counter=0; $Counter < mysql_num_rows($result) && $Counter < $limit; $Counter++) { $r = mysql_fetch_array($result); echo " | |||||||||
"; echo $r['ip']." | ".gethostbyaddr($r['ip']); echo ""; echo fmtb($r['total']).fmtb($r['sent']).fmtb($r['received']). fmtb($r['tcp']).fmtb($r['udp']).fmtb($r['icmp']).fmtb($r['http']). fmtb($r['p2p']).fmtb($r['ftp'])."\n"; } } echo " |