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 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661
|
#! /bin/sh /usr/share/dpatch/dpatch-run
## 61_php_fix_html_and_input_validation.dpatch by Andreas Henriksson <andreas@fatal.se>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Make HTML output valid and prevent sql injection in php code.
@DPATCH@
diff -urNad bandwidthd-2.0.1+cvs20071208~/phphtdocs/details.php bandwidthd-2.0.1+cvs20071208/phphtdocs/details.php
--- bandwidthd-2.0.1+cvs20071208~/phphtdocs/details.php 2005-11-17 17:31:04.000000000 +0100
+++ bandwidthd-2.0.1+cvs20071208/phphtdocs/details.php 2007-12-08 21:54:26.000000000 +0100
@@ -2,19 +2,21 @@
include("include.php");
include("header.php");
-if (isset($_GET['sensor_id']))
+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 = $_GET['ip'];
+ $ip = pg_escape_string($_GET['ip']);
else
{
echo "<br>Please provide an ip address";
+ include('footer.php');
exit(1);
}
@@ -26,7 +28,7 @@
$db = ConnectDb();
-if ($ip == "0.0.0.0/0")
+if ($ip == pg_escape_string("0.0.0.0/0"))
{
$rxtable = "bd_rx_total_log";
$txtable = "bd_tx_total_log";
@@ -62,38 +64,54 @@
where tx.ip = rx.ip;";
//echo "</center><pre>$sql</pre><center>";exit(0);
$result = pg_query($sql);
-echo "<table width=100% border=1 cellspacing=0><tr><td>Ip<td>Name<td>Total<td>Sent<td>Received<td>tcp<td>udp<td>icmp<td>http<td>p2p<td>ftp";
+?>
+
+<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>".gethostbyaddr($ip);
+ echo "$ip</td><td>".gethostbyaddr($ip) . "</td>";
else
- echo "Total<td>$ip";
+ 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></center>";
+echo "</table>";
-echo "<center><h4>Daily</h4></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>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><h4>Weekly</h4></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>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><h4>Monthly</h4></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>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><h4>Yearly</h4></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>";
\ No newline at end of file
+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');
+?>
diff -urNad bandwidthd-2.0.1+cvs20071208~/phphtdocs/failures.php bandwidthd-2.0.1+cvs20071208/phphtdocs/failures.php
--- bandwidthd-2.0.1+cvs20071208~/phphtdocs/failures.php 2007-09-04 22:14:25.000000000 +0200
+++ bandwidthd-2.0.1+cvs20071208/phphtdocs/failures.php 2007-12-08 21:54:26.000000000 +0100
@@ -1,5 +1,7 @@
<?
include("include.php");
+$subtitle = "Failure Report";
+include("header.php");
$db = ConnectDb();
@@ -11,15 +13,7 @@
header("Location: $PHP_SELF");
}
?>
-<HTML>
-<HEAD>
-<TITLE>Failure Report</TITLE>
-<link href="bandwidthd.css" rel="stylesheet" type="text/css">
-</HEAD>
-<BODY>
-<?
-include("header.php");
-?>
+
<h3>Failed Routers</h3>
<?
$res = pg_query("
@@ -105,5 +99,8 @@
}
echo "</TABLE>";
}
+
+include("footer.php");
?>
-</BODY>
\ No newline at end of file
+
+
diff -urNad bandwidthd-2.0.1+cvs20071208~/phphtdocs/footer.php bandwidthd-2.0.1+cvs20071208/phphtdocs/footer.php
--- bandwidthd-2.0.1+cvs20071208~/phphtdocs/footer.php 2005-01-01 00:01:21.000000000 +0100
+++ bandwidthd-2.0.1+cvs20071208/phphtdocs/footer.php 2007-12-08 21:54:26.000000000 +0100
@@ -1,3 +1,6 @@
-<?
-echo("Page load completed in ". (time() - $starttime) ." seconds");
-?>
\ No newline at end of file
+<?php
+echo("<p>Page load completed in ". (time() - $starttime) ." seconds</p>");
+?>
+
+</BODY>
+</HTML>
diff -urNad bandwidthd-2.0.1+cvs20071208~/phphtdocs/graph.php bandwidthd-2.0.1+cvs20071208/phphtdocs/graph.php
--- bandwidthd-2.0.1+cvs20071208~/phphtdocs/graph.php 2005-11-17 17:31:04.000000000 +0100
+++ bandwidthd-2.0.1+cvs20071208/phphtdocs/graph.php 2007-12-08 21:54:26.000000000 +0100
@@ -1,4 +1,4 @@
-<?
+<?php
require("include.php");
// Returns x location of any given timestamp
@@ -59,44 +59,52 @@
// Get parameters
-if (isset($_GET['width']))
+if (isset($_GET['width']) && is_numeric($_GET['width']))
$width = $_GET['width'];
else
$width = DFLT_WIDTH;
-if (isset($_GET['height']))
+if (isset($_GET['height']) && is_numeric($_GET['height']))
$height = $_GET['height'];
else
$height = DFLT_HEIGHT;
-if (isset($_GET['interval']))
+if (isset($_GET['interval']) && is_numeric($_GET['interval']))
$interval = $_GET['interval'];
else
$interval = DFLT_INTERVAL;
if (isset($_GET['ip']))
{
$ip = $_GET['ip'];
#optionall call using underscore instead of slash to seperate subnet from bits
$ip = str_replace("_", "/", $ip);
+ $ip = pg_escape_string($ip);
}
else
exit(1);
-if (isset($_GET['sensor_id']))
+if (isset($_GET['sensor_id']) && is_numeric($_GET['sensor_id']))
$sensor_id = $_GET['sensor_id'];
else
exit(1);
-if (isset($_GET['timestamp']))
+if (isset($_GET['timestamp']) && is_numeric($_GET['timestamp']))
$timestamp = $_GET['timestamp'];
else
$timestamp = time() - $interval + (0.05*$interval);
-if (isset($_GET['table']))
- $table = $_GET['table'];
-else
- $table = "bd_rx_log";
+switch ($_GET['table']) {
+ case 'bd_rx_total_log':
+ case 'bd_tx_total_log':
+ case 'bd_rx_log':
+ case 'bd_tx_log':
+ $table = $_GET['table'];
+ break;
+ default: /* invalid value in table argument! */
+ exit(1);
+ break;
+}
if (isset($_GET['yscale']))
$yscale = $_GET['yscale'];
@@ -490,4 +497,6 @@
}
imagepng($im);
-imagedestroy($im);
\ No newline at end of file
+imagedestroy($im);
+
+?>
diff -urNad bandwidthd-2.0.1+cvs20071208~/phphtdocs/header.php bandwidthd-2.0.1+cvs20071208/phphtdocs/header.php
--- bandwidthd-2.0.1+cvs20071208~/phphtdocs/header.php 2005-06-16 22:24:52.000000000 +0200
+++ bandwidthd-2.0.1+cvs20071208/phphtdocs/header.php 2007-12-08 21:54:26.000000000 +0100
@@ -1,3 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TS/html4/loose.dtd">
<html>
+<HEAD>
+<TITLE>BandwidthD<?php if (isset($subtitle)) { echo ' - ' . $subtitle; } ?></TITLE>
+<link href="bandwidthd.css" rel="stylesheet" type="text/css">
+</HEAD>
+
+<BODY>
<center>
-<img src=logo.gif>
+<img src="logo.gif" alt="BandwidthD Logo">
+</center>
+
diff -urNad bandwidthd-2.0.1+cvs20071208~/phphtdocs/include.php bandwidthd-2.0.1+cvs20071208/phphtdocs/include.php
--- bandwidthd-2.0.1+cvs20071208~/phphtdocs/include.php 2005-06-16 22:24:52.000000000 +0200
+++ bandwidthd-2.0.1+cvs20071208/phphtdocs/include.php 2007-12-08 21:54:26.000000000 +0100
@@ -60,9 +60,9 @@
$Suffix = 'T';
}
- return(sprintf("<td align=right><tt>%.1f%s</td>", $Output, $Suffix));
+ return(sprintf("<td align=right><tt>%.1f%s</tt></td>", $Output, $Suffix));
}
$starttime = time();
set_time_limit(300);
-?>
\ No newline at end of file
+?>
diff -urNad bandwidthd-2.0.1+cvs20071208~/phphtdocs/location_statistics.php bandwidthd-2.0.1+cvs20071208/phphtdocs/location_statistics.php
--- bandwidthd-2.0.1+cvs20071208~/phphtdocs/location_statistics.php 2007-09-04 22:14:25.000000000 +0200
+++ bandwidthd-2.0.1+cvs20071208/phphtdocs/location_statistics.php 2007-12-08 21:54:26.000000000 +0100
@@ -1,14 +1,9 @@
-<HEAD>
-<TITLE>Location Statistics</TITLE>
-</HEAD>
<?
include("include.php");
+$subtitle = "Location Statistics";
include("header.php");
-?></CENTER>
-<HEAD>
-<link href="bandwidthd.css" rel="stylesheet" type="text/css">
-</head>
-<center><img src=legend.gif></center>
+?>
+<center><img src="legend.gif"></center>
<?
$db = ConnectDb();
@@ -93,4 +88,8 @@
<BR>
<BR>
<BR>
-<BR>
\ No newline at end of file
+<BR>
+
+<?php
+include("footer.php");
+?>
diff -urNad bandwidthd-2.0.1+cvs20071208~/phphtdocs/sensors.php bandwidthd-2.0.1+cvs20071208/phphtdocs/sensors.php
--- bandwidthd-2.0.1+cvs20071208~/phphtdocs/sensors.php 2007-09-04 22:14:25.000000000 +0200
+++ bandwidthd-2.0.1+cvs20071208/phphtdocs/sensors.php 2007-12-08 21:54:26.000000000 +0100
@@ -1,34 +1,35 @@
-<?
+<?php
include("include.php");
+$subtitle = "Sensors";
include("header.php");
// Get variables from url
-if (isset($_GET['sensor_id']) && $_GET['sensor_id'] != "none")
+if (isset($_GET['sensor_id']) && is_numeric($_GET['sensor_id']))
$sensor_id = $_GET['sensor_id'];
-if (isset($_GET['interval']) && $_GET['interval'] != "none")
+if (isset($_GET['interval']) && is_numeric($_GET['interval']))
$interval = $_GET['interval'];
-if (isset($_GET['timestamp']) && $_GET['timestamp'] != "none")
+if (isset($_GET['timestamp']) && is_numeric($_GET['timestamp']))
$timestamp = $_GET['timestamp'];
-if (isset($_GET['subnet']) && $_GET['subnet'] != "none")
- $subnet = $_GET['subnet'];
+if (isset($_GET['subnet']) && $_GET['subnet'] != "none" && $_GET['subnet'] != "" )
+ $subnet = pg_escape_string($_GET['subnet']);
-if (isset($_GET['limit']) && $_GET['limit'] != "none")
+if (isset($_GET['limit']) && ($_GET['limit'] == "all" || is_numeric($_GET['limit'])))
$limit = $_GET['limit'];
+$graphs = false;
if (isset($_GET['graphs']))
- $graphs = $_GET['graphs'];
+ $graphs = true;
$db = ConnectDb();
?>
-<HEAD>
-<link href="bandwidthd.css" rel="stylesheet" type="text/css">
-</head>
-<FORM name="navigation" method=get action=<?=$PHP_SELF?>>
-<table width=100% cellspacing=0 cellpadding=5 border=1>
+
+<FORM name="navigation" method=get action="<?=$_SERVER['PHP_SELF']?>">
+
+<table width="100%" cellspacing=0 cellpadding=5 border=1>
<tr>
<td>
<?
@@ -37,42 +38,65 @@
if (!$result)
{
echo "<center>Collecting data...</center>";
- exit;
+ include('footer.php');
+ exit();
}
?>
+
<SELECT name="sensor_id">
-<OPTION value="none">--Select A Sensor--
-<?
-while ($r = pg_fetch_array($result))
- echo "<option value=\"".$r['sensor_id']."\" ".($sensor_id==$r['sensor_id']?"SELECTED":"").">".$r['sensor_name']." - ".$r['interface']."\n";
+<OPTION value="none">--Select A Sensor--</OPTION>
+<?php
+while ($r = pg_fetch_array($result)) {
+ echo '<OPTION value="' . $r['sensor_id'] .'" '
+ . ($sensor_id==$r['sensor_id']?"SELECTED":"") . '>'
+ . $r['sensor_name'] . ' - ' . $r['interface'] . "</OPTION>\n";
+}
?>
</SELECT>
-<td><SELECT name="interval">
-<OPTION value="none">--Select An Interval--
-<OPTION value=<?=INT_DAILY?> <?=$interval==INT_DAILY?"SELECTED":""?>>Daily
-<OPTION value=<?=INT_WEEKLY?> <?=$interval==INT_WEEKLY?"SELECTED":""?>>Weekly
-<OPTION value=<?=INT_MONTHLY?> <?=$interval==INT_MONTHLY?"SELECTED":""?>>Monthly
-<OPTION value=<?=INT_YEARLY?> <?=$interval==INT_YEARLY?"SELECTED":""?>>Yearly
-<OPTION value=<?=24*60*60?> <?=$interval==24*60*60?"SELECTED":""?>>24hrs
-<OPTION value=<?=30*24*60*60?> <?=$interval==30*24*60*60?"SELECTED":""?>>30days
+
+</td>
+<td>
+
+<SELECT name="interval">
+<OPTION value="none">--Select An Interval--</OPTION>
+<OPTION value=<?=INT_DAILY?> <?=$interval==INT_DAILY?"SELECTED":""?>>Daily</OPTION>
+<OPTION value=<?=INT_WEEKLY?> <?=$interval==INT_WEEKLY?"SELECTED":""?>>Weekly</OPTION>
+<OPTION value=<?=INT_MONTHLY?> <?=$interval==INT_MONTHLY?"SELECTED":""?>>Monthly</OPTION>
+<OPTION value=<?=INT_YEARLY?> <?=$interval==INT_YEARLY?"SELECTED":""?>>Yearly</OPTION>
+<OPTION value=<?=24*60*60?> <?=$interval==24*60*60?"SELECTED":""?>>24hrs</OPTION>
+<OPTION value=<?=30*24*60*60?> <?=$interval==30*24*60*60?"SELECTED":""?>>30days</OPTION>
</select>
-<td><SELECT name="limit">
-<OPTION value="none">--How Many Results--
-<OPTION value=20 <?=$limit==20?"SELECTED":""?>>20
-<OPTION value=50 <?=$limit==50?"SELECTED":""?>>50
-<OPTION value=100 <?=$limit==100?"SELECTED":""?>>100
-<OPTION value=all <?=$limit=="all"?"SELECTED":""?>>All
+</td>
+<td>
+
+<SELECT name="limit">
+<OPTION value="none">--How Many Results--</OPTION>
+<OPTION value=20 <?=$limit==20?"SELECTED":""?>>20</OPTION>
+<OPTION value=50 <?=$limit==50?"SELECTED":""?>>50</OPTION>
+<OPTION value=100 <?=$limit==100?"SELECTED":""?>>100</OPTION>
+<OPTION value=all <?=$limit=="all"?"SELECTED":""?>>All</OPTION>
</select>
-<? if ($graphs != "") $GraphsChecked = "Checked"; else $GraphsChecked = ""; ?>
-<td><input type="checkbox" name="graphs" <?=$GraphsChecked?>>Display Graphs</a>
+</td>
+<td>
-<td>Subnet Filter:<input name=subnet value="<?=isset($subnet)?$subnet:"0.0.0.0/0"?>">
+<?php if ($graphs) $GraphsChecked = "CHECKED"; else $GraphsChecked = ""; ?>
+<input type="checkbox" name="graphs" <?=$GraphsChecked?>>Display Graphs
+
+</td>
+<td>
+
+Subnet Filter:<input name=subnet value="<?=isset($subnet)?$subnet:"0.0.0.0/0"?>">
<input type=submit value="Go">
+
+</td>
+</tr>
+
</table>
</FORM>
-<?
+
+<?php
// Set defaults
if (!isset($interval))
$interval = DFLT_INTERVAL;
@@ -84,10 +108,12 @@
$limit = 20;
// Validation
-if (!isset($sensor_id))
- exit(0);
+if (!isset($sensor_id)) {
+ include('footer.php');
+ exit();
+}
-$sql = "SELECT sensor_name, interface, sensor_id from sensors where sensor_id = $sensor_id;";
+$sql = "SELECT sensor_name, interface, sensor_id FROM sensors WHERE sensor_id = '$sensor_id';";
$result = @pg_query($sql);
$r = pg_fetch_array($result);
$sensor_name = $r['sensor_name'];
@@ -133,7 +158,6 @@
where tx.ip = rx.ip
order by total desc;";
-//echo "</center><pre>$sql</pre><center>"; exit(0);
pg_query("SET sort_mem TO 30000;");
pg_send_query($db, $sql);
@@ -156,18 +181,28 @@
if ($limit == "all")
$limit = pg_num_rows($result);
-echo "<a name=top><table width=100% border=1 cellspacing=0><tr><td>Ip<td>Name<td>Total<td>Sent<td>Received<td>tcp<td>udp<td>icmp<td>http<td>mail<td>p2p<td>ftp";
+?>
+<a name="top"></a>
+<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>mail</th><th>p2p</th><th>ftp</th>
+</tr>
+
+<?php
if (!isset($subnet)) // Set this now for total graphs
$subnet = "0.0.0.0/0";
// Output Total Line
-if ($graphs == "")
- $url = "<a href=# onclick=\"window.open('details.php?sensor_id=$sensor_id&ip=$subnet','_blank', 'scrollbars=yes,width=930,height=768,resizable=yes,left=20,top=20')\">";
+if (!$graphs)
+ $url = "<a href=\"#\" onclick=\"window.open('details.php?sensor_id=$sensor_id&ip=$subnet','_blank', 'scrollbars=yes,width=930,height=768,resizable=yes,left=20,top=20')\">";
else
- $url = "<a href=#Total>";
+ $url = '<a href="#Total">';
-echo "\n<TR><TD>".$url."Total</a><TD>$subnet";
+echo "<TR><TD>".$url."Total</a></TD><TD>$subnet</TD>";
foreach (array("total", "sent", "received", "tcp", "udp", "icmp", "http", "mail", "p2p", "ftp") as $key)
{
for($Counter=0, $Total = 0; $Counter < pg_num_rows($result); $Counter++)
@@ -183,22 +217,22 @@
for($Counter=0; $Counter < pg_num_rows($result) && $Counter < $limit; $Counter++)
{
$r = pg_fetch_array($result, $Counter);
- if ($graphs == "")
- $url = "<a href=# onclick=\"window.open('details.php?sensor_id=$sensor_id&ip=".$r['ip']."','_blank', 'scrollbars=yes,width=930,height=768,resizable=yes,left=20,top=20')\">";
+ if (!$graphs)
+ $url = "<a href=\"#\" onclick=\"window.open('details.php?sensor_id=$sensor_id&ip=".$r['ip']."','_blank', 'scrollbars=yes,width=930,height=768,resizable=yes,left=20,top=20')\">";
else
- $url = "<a href=#".$r['ip'].">";
- echo "<tr><td>".$url;
- echo $r['ip']."<td>".gethostbyaddr($r['ip']);
- echo "</a>";
+ $url = '<a href="#' . $r['ip'] . '">';
+ echo "<tr><td>" . $url . $r['ip'] . "</a></td><td>" . gethostbyaddr($r['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['mail']).
- fmtb($r['p2p']).fmtb($r['ftp'])."\n";
+ fmtb($r['p2p']).fmtb($r['ftp'])."</tr>\n";
}
-echo "</table></center>";
+echo "</table>";
// Stop here
-if ($graphs == "")
+if (!$graphs) {
+ include('footer.php');
exit();
+}
// Output Total Graph
for($Counter=0, $Total = 0; $Counter < pg_num_rows($result); $Counter++)
@@ -212,37 +246,38 @@
$total_table = "bd_tx_total_log";
else
$total_table = "bd_tx_log";
$sn = str_replace("/", "_", $subnet);
-echo "<a name=Total><h3><a href=details.php?sensor_id=$sensor_id&ip=$subnet>";
-echo "Total - Total of $subnet</h3>";
-echo "</a>";
-echo "Send:<br><img src=graph.php?ip=$sn&interval=$interval&sensor_id=".$sensor_id."&table=$total_table><br>";
-echo "<img src=legend.gif><br>\n";
+echo "<h3><a name=\"Total\"></a><a href=\"details.php?sensor_id=$sensor_id&ip=$subnet\">";
+echo "Total - Total of $subnet</a></h3>";
+echo "Send:<br><img src=\"graph.php?ip=$sn&interval=$interval&sensor_id=".$sensor_id."&table=$total_table\"><br>";
+echo '<img src="legend.gif"><br>' . "\n";
if ($subnet == "0.0.0.0/0")
$total_table = "bd_rx_total_log";
else
$total_table = "bd_rx_log";
-echo "Receive:<br><img src=graph.php?ip=$sn&interval=$interval&sensor_id=".$sensor_id."&table=$total_table><br>";
-echo "<img src=legend.gif><br>\n";
-echo "<a href=#top>[Return to Top]</a>";
+echo "Receive:<br><img src=\"graph.php?ip=$sn&interval=$interval&sensor_id=".$sensor_id."&table=$total_table\"><br>";
+echo '<img src="legend.gif"><br>' . "\n";
+echo '<a href="#top">[Return to Top]</a>';
// Output Other Graphs
for($Counter=0; $Counter < pg_num_rows($result) && $Counter < $limit; $Counter++)
{
$r = pg_fetch_array($result, $Counter);
- echo "<a name=".$r['ip']."><h3><a href=details.php?sensor_id=$sensor_id&ip=".$r['ip'].">";
+ echo "<h3><a name=".$r['ip']."></a><a href=\"details.php?sensor_id=$sensor_id&ip=".$r['ip']."\">";
if ($r['ip'] == "0.0.0.0")
- echo "Total - Total of all subnets</h3>";
+ echo "Total - Total of all subnets";
else
- echo $r['ip']." - ".gethostbyaddr($r['ip'])."</h3>";
- echo "</a>";
- echo "Send:<br><img src=graph.php?ip=".$r['ip']."&interval=$interval&sensor_id=".$sensor_id."&table=bd_tx_log&yscale=".(max($r['txscale'], $r['rxscale']))."><br>";
- echo "<img src=legend.gif><br>\n";
- echo "Receive:<br><img src=graph.php?ip=".$r['ip']."&interval=$interval&sensor_id=".$sensor_id."&table=bd_rx_log&yscale=".(max($r['txscale'], $r['rxscale']))."><br>";
- echo "<img src=legend.gif><br>\n";
- echo "<a href=#top>[Return to Top]</a>";
+ echo $r['ip']." - ".gethostbyaddr($r['ip']);
+ echo "</a></h3>";
+ echo "Send:<br><img src=\"graph.php?ip=".$r['ip']."&interval=$interval&sensor_id=".$sensor_id."&table=bd_tx_log&yscale=".(max($r['txscale'], $r['rxscale']))."\"><br>";
+ echo '<img src="legend.gif"><br>' . "\n";
+ echo "Receive:<br><img src=\"graph.php?ip=".$r['ip']."&interval=$interval&sensor_id=".$sensor_id."&table=bd_rx_log&yscale=".(max($r['txscale'], $r['rxscale']))."\"><br>";
+ echo '<img src="legend.gif"><br>' . "\n";
+ echo '<a href="#top">[Return to Top]</a>';
}
-include('footer.php');
\ No newline at end of file
+
+include('footer.php');
+?>
diff -urNad bandwidthd-2.0.1+cvs20071208~/phphtdocs/signal_level.php bandwidthd-2.0.1+cvs20071208/phphtdocs/signal_level.php
--- bandwidthd-2.0.1+cvs20071208~/phphtdocs/signal_level.php 2007-09-04 22:19:39.000000000 +0200
+++ bandwidthd-2.0.1+cvs20071208/phphtdocs/signal_level.php 2007-12-08 21:54:26.000000000 +0100
@@ -1,11 +1,6 @@
-<HTML>
-<HEAD>
-<TITLE>Signal Level Report</TITLE>
-<link href="bandwidthd.css" rel="stylesheet" type="text/css">
-</HEAD>
-<BODY>
-<?
+<?php
include("include.php");
+$subtitle = "Signal Level Report";
include("header.php");
$db = ConnectDb();
@@ -49,5 +44,6 @@
}
echo "</TABLE>";
}
+
+include("footer.php");
?>
-</BODY>
\ No newline at end of file
diff -urNad bandwidthd-2.0.1+cvs20071208~/phphtdocs/uptime.php bandwidthd-2.0.1+cvs20071208/phphtdocs/uptime.php
--- bandwidthd-2.0.1+cvs20071208~/phphtdocs/uptime.php 2007-09-04 22:14:25.000000000 +0200
+++ bandwidthd-2.0.1+cvs20071208/phphtdocs/uptime.php 2007-12-08 21:54:26.000000000 +0100
@@ -1,11 +1,6 @@
-<HTML>
-<HEAD>
-<TITLE>Uptime Report</TITLE>
-<link href="bandwidthd.css" rel="stylesheet" type="text/css">
-</HEAD>
-<BODY>
<?
include("include.php");
+$subtitle = "Uptime Report";
include("header.php");
$db = ConnectDb();
@@ -37,5 +32,6 @@
}
echo "</TABLE>";
}
+
+include("footer.php");
?>
-</BODY>
\ No newline at end of file
|