/var/lib/bandwidthd/htdocs/details.php is in bandwidthd-pgsql 2.0.1+cvs20090917-7.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | <?
include("include.php");
include("header.php");
if (isset($_GET['sensor_id']) && is_numeric($_GET['sensor_id']))
$sensor_id = $_GET['sensor_id'];
else
{
echo "<br>Please provide a sensor_id";
include('footer.php');
exit(1);
}
if (isset($_GET['ip']))
$ip = pg_escape_string($_GET['ip']);
else
{
echo "<br>Please provide an ip address";
include('footer.php');
exit(1);
}
echo "<h3>";
if (strpos($ip, "/") === FALSE)
echo "$ip - ".gethostbyaddr($ip)."</h3>";
else
echo "Total - $ip</h3>";
$db = ConnectDb();
if ($ip == pg_escape_string("0.0.0.0/0"))
{
$rxtable = "bd_rx_total_log";
$txtable = "bd_tx_total_log";
}
else
{
$rxtable = "bd_rx_log";
$txtable = "bd_tx_log";
}
$sql = "select rx.scale as rxscale, tx.scale as txscale, tx.total+rx.total as total, tx.total as sent,
rx.total as received, tx.tcp+rx.tcp as tcp, tx.udp+rx.udp as udp,
tx.icmp+rx.icmp as icmp, tx.http+rx.http as http,
tx.p2p+rx.p2p as p2p, tx.ftp+rx.ftp as ftp
from
(SELECT ip, max(total/sample_duration)*8 as scale, sum(total) as total, sum(tcp) as tcp, sum(udp) as udp, sum(icmp) as icmp,
sum(http) as http, sum(p2p) as p2p, sum(ftp) as ftp
from sensors, $txtable
where sensors.sensor_id = '$sensor_id'
and sensors.sensor_id = ".$txtable.".sensor_id
and ip <<= '$ip'
group by ip) as tx,
(SELECT ip, max(total/sample_duration)*8 as scale, sum(total) as total, sum(tcp) as tcp, sum(udp) as udp, sum(icmp) as icmp,
sum(http) as http, sum(p2p) as p2p, sum(ftp) as ftp
from sensors, $rxtable
where sensors.sensor_id = '$sensor_id'
and sensors.sensor_id = ".$rxtable.".sensor_id
and ip <<= '$ip'
group by ip) as rx
where tx.ip = rx.ip;";
//echo "</center><pre>$sql</pre><center>";exit(0);
$result = pg_query($sql);
?>
<table width="100%" border=1 cellspacing=0>
<tr>
<th>Ip</th><th>Name</th>
<th>Total</th><th>Sent</th><th>Received</th>
<th>tcp</th><th>udp</th><th>icmp</th>
<th>http</th><th>p2p</th><th>ftp</th>
</tr>
<?php
$r = pg_fetch_array($result);
echo "<tr><td>";
if (strpos($ip, "/") === FALSE)
echo "$ip</td><td>".gethostbyaddr($ip) . "</td>";
else
echo "Total</td><td>$ip</td>";
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']);
echo "</table>";
echo "<center><h3>Daily</h3></center>";
echo "Send:<br><img src=\"graph.php?ip=$ip&sensor_id=".$sensor_id."&table=$txtable&yscale=".(max($r['txscale'], $r['rxscale']))."\"><br>";
echo '<img src="legend.gif"><br>';
echo "Receive:<br><img src=\"graph.php?ip=$ip&sensor_id=".$sensor_id."&table=$rxtable&yscale=".(max($r['txscale'], $r['rxscale']))."\"><br>";
echo '<img src="legend.gif"><br>';
echo "<center><h3>Weekly</h3></center>";
echo "Send:<br><img src=\"graph.php?interval=".INT_WEEKLY."&ip=$ip&sensor_id=$sensor_id&table=$txtable&yscale=".(max($r['txscale'], $r['rxscale']))."\"><br>";
echo '<img src="legend.gif"><br>';
echo "Receive:<br><img src=\"graph.php?interval=".INT_WEEKLY."&ip=$ip&sensor_id=$sensor_id&table=$rxtable&yscale=".(max($r['txscale'], $r['rxscale']))."\"><br>";
echo '<img src="legend.gif"><br>';
echo "<center><h3>Monthly</h3></center>";
echo "Send:<br><img src=\"graph.php?interval=".INT_MONTHLY."&ip=$ip&sensor_id=$sensor_id&table=$txtable&yscale=".(max($r['txscale'], $r['rxscale']))."\"><br>";
echo '<img src="legend.gif"><br>';
echo "Receive:<br><img src=\"graph.php?interval=".INT_MONTHLY."&ip=$ip&sensor_id=$sensor_id&table=$rxtable&yscale=".(max($r['txscale'], $r['rxscale']))."\"><br>";
echo '<img src="legend.gif"><br>';
echo "<center><h3>Yearly</h3></center>";
echo "Send:<br><img src=\"graph.php?interval=".INT_YEARLY."&ip=$ip&sensor_id=$sensor_id&table=$txtable&yscale=".(max($r['txscale'], $r['rxscale']))."\"><br>";
echo '<img src="legend.gif"><br>';
echo "Receive:<br><img src=\"graph.php?interval=".INT_YEARLY."&ip=$ip&sensor_id=$sensor_id&table=$rxtable&yscale=".(max($r['txscale'], $r['rxscale']))."\"><br>";
echo '<img src="legend.gif"><br>';
include('footer.php');
?>
|