status_rrd_graph.php 22.5 KB
Newer Older
Ad Schellevis's avatar
Ad Schellevis committed
1 2
<?php
/*
3
	Copyright (C) 2014-2015 Deciso B.V.
Ad Schellevis's avatar
Ad Schellevis committed
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
	Copyright (C) 2007 Seth Mos <seth.mos@dds.nl>
	All rights reserved.

	Redistribution and use in source and binary forms, with or without
	modification, are permitted provided that the following conditions are met:

	1. Redistributions of source code must retain the above copyright notice,
	   this list of conditions and the following disclaimer.

	2. Redistributions in binary form must reproduce the above copyright
	   notice, this list of conditions and the following disclaimer in the
	   documentation and/or other materials provided with the distribution.

	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
	POSSIBILITY OF SUCH DAMAGE.
*/

29
require_once("guiconfig.inc");
Ad Schellevis's avatar
Ad Schellevis committed
30
require_once("filter.inc");
31
require_once("shaper.inc");
Ad Schellevis's avatar
Ad Schellevis committed
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
require_once("rrd.inc");

unset($input_errors);

/* if the rrd graphs are not enabled redirect to settings page */
if(! isset($config['rrd']['enable'])) {
	header("Location: status_rrd_graph_settings.php");
}

$rrddbpath = "/var/db/rrd/";
chdir($rrddbpath);
$databases = glob("*.rrd");


if ($_GET['cat']) {
	$curcat = htmlspecialchars($_GET['cat']);
} else {
	if(! empty($config['rrd']['category'])) {
		$curcat = $config['rrd']['category'];
	} else {
		$curcat = "system";
	}
}

if ($_GET['zone'])
	$curzone = $_GET['zone'];
else
	$curzone = '';

if ($_GET['period']) {
	$curperiod = $_GET['period'];
} else {
	if(! empty($config['rrd']['period'])) {
		$curperiod = $config['rrd']['period'];
	} else {
		$curperiod = "absolute";
	}
}

if ($_GET['option']) {
	$curoption = $_GET['option'];
} else {
	switch($curcat) {
		case "system":
			$curoption = "processor";
			break;
		case "queues":
			$curoption = "queues";
			break;
		case "queuedrops":
			$curoption = "queuedrops";
			break;
		case "quality":
			foreach($databases as $database) {
				if(preg_match("/[-]quality\.rrd/i", $database)) {
					/* pick off the 1st database we find that matches the quality graph */
					$name = explode("-", $database);
					$curoption = "$name[0]";
					continue 2;
				}
			}
		case "wireless":
			foreach($databases as $database) {
				if(preg_match("/[-]wireless\.rrd/i", $database)) {
					/* pick off the 1st database we find that matches the wireless graph */
					$name = explode("-", $database);
					$curoption = "$name[0]";
					continue 2;
				}
			}
		case "cellular":
			foreach($databases as $database) {
				if(preg_match("/[-]cellular\.rrd/i", $database)) {
					/* pick off the 1st database we find that matches the celullar graph */
					$name = explode("-", $database);
					$curoption = "$name[0]";
					continue 2;
				}
			}
		case "vpnusers":
			foreach($databases as $database) {
				if(preg_match("/[-]vpnusers\.rrd/i", $database)) {
					/* pick off the 1st database we find that matches the VPN graphs */
					$name = explode("-", $database);
					$curoption = "$name[0]";
					continue 2;
				}
			}
		case "captiveportal":
			$curoption = "allgraphs";
			break;
		case "ntpd":
			if(isset($config['ntpd']['statsgraph'])) {
				$curoption = "allgraphs";
			} else {
				$curoption = "processor";
				$curcat = "system";
			}
			break;
		default:
			$curoption = "wan";
			break;
	}
}

$now = time();
if($curcat == "custom") {
	if (is_numeric($_GET['start'])) {
		if($start < ($now - (3600 * 24 * 365 * 5))) {
			$start = $now - (8 * 3600);
		}
		$start = $_GET['start'];
	} else if ($_GET['start']) {
		$start = strtotime($_GET['start']);
		if ($start === FALSE || $start === -1) {
			$input_errors[] = gettext("Invalid start date/time:") . " '{$_GET['start']}'";
			$start = $now - (8 * 3600);
		}
	} else {
		$start = $now - (8 * 3600);
	}
}

if (is_numeric($_GET['end'])) {
        $end = $_GET['end'];
} else if ($_GET['end']) {
	$end = strtotime($_GET['end']);
	if ($end === FALSE || $end === -1) {
		$input_errors[] = gettext("Invalid end date/time:") . " '{$_GET['end']}'";
		$end = $now;
	}
} else {
        $end = $now;
}

/* this should never happen */
if($end < $start) {
	log_error("start $start is smaller than end $end");
        $end = $now;
}

$seconds = $end - $start;

$styles = array('inverse' => gettext('Inverse'),
		'absolute' => gettext('Absolute'));

// Set default and override later
$curstyle = "inverse";

if ($_GET['style']) {
182 183
	foreach($styles as $style)
		if(strtoupper($style) == strtoupper($_GET['style']))
Ad Schellevis's avatar
Ad Schellevis committed
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
			$curstyle = $_GET['style'];
} else {
	if(! empty($config['rrd']['style'])) {
		$curstyle = $config['rrd']['style'];
	} else {
		$curstyle = "inverse";
	}
}

/* sort names reverse so WAN comes first */
rsort($databases);

/* these boilerplate databases are required for the other menu choices */
$dbheader = array("allgraphs-traffic.rrd",
		"allgraphs-quality.rrd",
		"allgraphs-wireless.rrd",
		"allgraphs-cellular.rrd",
		"allgraphs-vpnusers.rrd",
		"allgraphs-packets.rrd",
		"system-allgraphs.rrd",
		"system-throughput.rrd",
		"outbound-quality.rrd",
		"outbound-packets.rrd",
		"outbound-traffic.rrd");

/* additional menu choices for the custom tab */
$dbheader_custom = array("system-throughput.rrd");

foreach($databases as $database) {
	if(stristr($database, "-wireless")) {
		$wireless = true;
	}
	if(stristr($database, "-queues")) {
		$queues = true;
	}
	if(stristr($database, "-cellular") && !empty($config['ppps'])) {
		$cellular = true;
	}
	if(stristr($database, "-vpnusers")) {
		$vpnusers = true;
	}
	if(stristr($database, "captiveportal-") && is_array($config['captiveportal'])) {
		$captiveportal = true;
	}
	if(stristr($database, "ntpd") && isset($config['ntpd']['statsgraph'])) {
		$ntpd = true;
	}
}
/* append the existing array to the header */
$ui_databases = array_merge($dbheader, $databases);
$custom_databases = array_merge($dbheader_custom, $databases);

$graphs = array("eighthour", "day", "week", "month", "quarter", "year", "fouryear");
$periods = array("absolute" => gettext("Absolute Timespans"), "current" => gettext("Current Period"), "previous" => gettext("Previous Period"));
$graph_length = array(
	"eighthour" => 28800,
	"day" => 86400,
	"week" => 604800,
	"month" => 2678400,
	"quarter" => 7948800,
	"year" => 31622400,
	"fouryear" => 126230400);

$pgtitle = array(gettext("Status"),gettext("RRD Graphs"));

$closehead = false;

/* Load all CP zones */
if ($captiveportal && is_array($config['captiveportal'])) {
	$cp_zones_tab_array = array();
	foreach($config['captiveportal'] as $cpkey => $cp) {
		if (!isset($cp['enable']))
			continue;

		if ($curzone == '') {
			$tabactive = true;
			$curzone = $cpkey;
		} elseif ($curzone == $cpkey) {
			$tabactive = true;
		} else {
			$tabactive = false;
		}

		$cp_zones_tab_array[] = array($cp['zone'], $tabactive, "status_rrd_graph.php?cat=captiveportal&zone=$cpkey");
	}
}

include("head.inc");
?>

Ad Schellevis's avatar
Ad Schellevis committed
274 275
<body>

Ad Schellevis's avatar
Ad Schellevis committed
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
<?php

function get_dates($curperiod, $graph) {
	global $graph_length;
	$now = time();
	$end = $now;

	if($curperiod == "absolute") {
		$start = $end - $graph_length[$graph];
	} else {
		$curyear = date('Y', $now);
		$curmonth = date('m', $now);
		$curweek = date('W', $now);
		$curweekday = date('N', $now) - 1; // We want to start on monday
		$curday = date('d', $now);
		$curhour = date('G', $now);

		switch($curperiod) {
			case "previous":
				$offset = -1;
				break;
			default:
				$offset = 0;
		}
		switch($graph) {
			case "eighthour":
				if($curhour < 24)
					$starthour = 16;
				if($curhour < 16)
					$starthour = 8;
				if($curhour < 8)
					$starthour = 0;

				switch($offset) {
					case 0:
						$houroffset = $starthour;
						break;
					default:
						$houroffset = $starthour + ($offset * 8);
						break;
				}
				$start = mktime($houroffset, 0, 0, $curmonth, $curday, $curyear);
				if($offset != 0) {
					$end = mktime(($houroffset + 8), 0, 0, $curmonth, $curday, $curyear);
				}
				break;
			case "day":
				$start = mktime(0, 0, 0, $curmonth, ($curday + $offset), $curyear);
				if($offset != 0)
					$end = mktime(0, 0, 0, $curmonth, (($curday + $offset) + 1), $curyear);
				break;
			case "week":
				switch($offset) {
					case 0:
						$weekoffset = 0;
						break;
					default:
						$weekoffset = ($offset * 7) - 7;
						break;
				}
				$start = mktime(0, 0, 0, $curmonth, (($curday - $curweekday) + $weekoffset), $curyear);
				if($offset != 0)
					$end = mktime(0, 0, 0, $curmonth, (($curday - $curweekday) + $weekoffset + 7), $curyear);
				break;
			case "month":
				$start = mktime(0, 0, 0, ($curmonth + $offset), 0, $curyear);
				if($offset != 0)
					$end = mktime(0, 0, 0, (($curmonth + $offset) + 1), 0, $curyear);
				break;
			case "quarter":
				$start = mktime(0, 0, 0, (($curmonth - 2) + $offset), 0, $curyear);
				if($offset != 0)
					$end = mktime(0, 0, 0, (($curmonth + $offset) + 1), 0, $curyear);
				break;
			case "year":
				$start = mktime(0, 0, 0, 1, 0, ($curyear + $offset));
				if($offset != 0)
					$end = mktime(0, 0, 0, 1, 0, (($curyear + $offset) +1));
				break;
			case "fouryear":
				$start = mktime(0, 0, 0, 1, 0, (($curyear - 3) + $offset));
				if($offset != 0)
					$end = mktime(0, 0, 0, 1, 0, (($curyear + $offset) +1));
				break;
		}
	}
	// echo "start $start ". date('l jS \of F Y h:i:s A', $start) .", end $end ". date('l jS \of F Y h:i:s A', $end) ."<br />";
	$dates = array();
	$dates['start'] = $start;
	$dates['end'] = $end;
	return $dates;
}

?>
370

Ad Schellevis's avatar
Ad Schellevis committed
371
<?php include("fbegin.inc"); ?>
372 373

	<section class="page-content-main">
374
		<div class="container-fluid">
375
			<div class="row">
376

377
				<?php if ($input_errors && count($input_errors)) print_input_errors($input_errors);  ?>
378

379
			    <section class="col-xs-12">
380

381
				<? include("status_rrd_graph_tabs.inc"); ?>
382 383 384 385 386 387

					<div class="tab-content content-box col-xs-12">



					    <?php if ($curcat == "captiveportal") : ?>
388 389
							<?php display_top_tabs($cp_zones_tab_array); ?>
							<?php endif; ?>
390 391 392



393 394
							<form name="form1" action="status_rrd_graph.php" method="get">
								<input type="hidden" name="cat" value="<?php echo "$curcat"; ?>" />
Ad Schellevis's avatar
Ad Schellevis committed
395
								<div class="container-fluid">
396
								<p><b><?=gettext("Note: Change of color and/or style may not take effect until the next refresh");?></b></p>
Ad Schellevis's avatar
Ad Schellevis committed
397
								</div>
398

399
								<div id="responsive-table">
Ad Schellevis's avatar
Ad Schellevis committed
400
									<table class="table table-striped table-sort __nomb">
401

402 403 404 405 406 407 408 409 410 411
										<tr>
						                    <td>
											<?=gettext("Graphs:");?>
						                    </td>
						                    <td>
											<?php if (!empty($curzone)): ?>
											<input type="hidden" name="zone" value="<?= htmlspecialchars($curzone) ?>" />
											<?php endif; ?>
											<select name="option" class="form-control" style="z-index: -10;" onchange="document.form1.submit()">
											<?php
412

413 414 415 416 417 418 419 420 421 422 423 424
											if($curcat == "custom") {
												foreach ($custom_databases as $db => $database) {
													$optionc = explode("-", $database);
													$search = array("-", ".rrd", $optionc);
													$replace = array(" :: ", "", $friendly);
													echo "<option value=\"{$database}\"";
													$prettyprint = ucwords(str_replace($search, $replace, $database));
													if($curoption == $database) {
														echo " selected=\"selected\"";
													}
													echo ">" . htmlspecialchars($prettyprint) . "</option>\n";
												}
Ad Schellevis's avatar
Ad Schellevis committed
425
											}
426 427 428
											foreach ($ui_databases as $db => $database) {
												if(! preg_match("/($curcat)/i", $database))
													continue;
429

430 431
												if (($curcat == "captiveportal") && !empty($curzone) && !preg_match("/captiveportal-{$curzone}/i", $database))
													continue;
432

433 434 435
												$optionc = explode("-", $database);
												$search = array("-", ".rrd", $optionc);
												$replace = array(" :: ", "", $friendly);
436

437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458
												switch($curcat) {
													case "captiveportal":
														$optionc = str_replace($search, $replace, $optionc[2]);
														echo "<option value=\"$optionc\"";
														$prettyprint = ucwords(str_replace($search, $replace, $optionc));
														break;
													case "system":
														$optionc = str_replace($search, $replace, $optionc[1]);
														echo "<option value=\"$optionc\"";
														$prettyprint = ucwords(str_replace($search, $replace, $optionc));
														break;
													default:
														/* Deduce a interface if possible and use the description */
														$optionc = "$optionc[0]";
														$friendly = convert_friendly_interface_to_friendly_descr(strtolower($optionc));
														if(empty($friendly)) {
															$friendly = $optionc;
														}
														$search = array("-", ".rrd", $optionc);
														$replace = array(" :: ", "", $friendly);
														echo "<option value=\"$optionc\"";
														$prettyprint = ucwords(str_replace($search, $replace, $friendly));
Ad Schellevis's avatar
Ad Schellevis committed
459
												}
460 461 462 463
												if($curoption == $optionc) {
													echo " selected=\"selected\"";
												}
												echo ">" . htmlspecialchars($prettyprint) . "</option>\n";
Ad Schellevis's avatar
Ad Schellevis committed
464
											}
465

466 467 468 469 470 471 472 473 474 475 476 477 478
											?>
											</select>
						                    </td>
						                    <td>
											<?=gettext("Style:");?>
						                    </td>
						                    <td>
											<select name="style" class="form-control" style="z-index: -10;" onchange="document.form1.submit()">
											<?php
											foreach ($styles as $style => $styled) {
												echo "<option value=\"$style\"";
												if ($style == $curstyle) echo " selected=\"selected\"";
												echo ">" . htmlspecialchars($styled) . "</option>\n";
Ad Schellevis's avatar
Ad Schellevis committed
479
											}
480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495
											?>
											</select>
											</td>
											<?php
											if($curcat <> "custom") {
											?>
												<td><?=gettext("Period:");?></td>
												<td><select name="period" class="form-control" style="z-index: -10;" onchange="document.form1.submit()">
												<?php
												foreach ($periods as $period => $value) {
													echo "<option value=\"$period\"";
													if ($period == $curperiod) echo " selected=\"selected\"";
													echo ">" . htmlspecialchars($value) . "</option>\n";
												}
												echo "</select>\n";
												echo "</td></tr>\n";
Ad Schellevis's avatar
Ad Schellevis committed
496
											}
497 498
											?>
											<?php
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
											if($curcat == "custom") {
												$tz = date_default_timezone_get();
												$tz_msg = gettext("Enter date and/or time. Current timezone:") . " $tz";
												$start_fmt = strftime("%m/%d/%Y %H:%M:%S", $start);
												$end_fmt   = strftime("%m/%d/%Y %H:%M:%S", $end);
												?>
												<td><?=gettext("Start:");?></td>
												<td>
												<input id="startDateTime" title="<?= htmlentities($tz_msg); ?>." type="text" name="start" class="form-control" size="24" value="<?= htmlentities($start_fmt); ?>" />
												</td>
												<td>
												<?=gettext("End:");?>
												</td>
												<td>
												<input id="endDateTime" title="<?= htmlentities($tz_msg); ?>." type="text" name="end" class="form-control" size="24" value="<?= htmlentities($end_fmt); ?>" />
												</td>
												<td>
												<input type="submit" name="Submit" class="btn btn-primary value="<?=gettext("Go"); ?>" />
												</td></tr>
												<?php
												$curdatabase = $curoption;
												$graph = "custom-$curdatabase";
												if(in_array($curdatabase, $custom_databases)) {
													$id = "{$graph}-{$curoption}-{$curdatabase}";
													$id = preg_replace('/\./', '_', $id);
525
													$img_date = date('YmdGis'); /* Add a way to let the browser know we have refreshed the image */
Ad Schellevis's avatar
Ad Schellevis committed
526 527
													echo "<tr><td colspan=\"100%\" class=\"list\">\n";
													echo "<img border=\"0\" width=\"100%;\" name=\"{$id}\"";
528
													echo "id=\"{$id}\" alt=\"$prettydb Graph\" ";
529
													echo "src=\"status_rrd_graph_img.php?start={$start}&amp;end={$end}&amp;database={$curdatabase}&amp;style={$curstyle}&amp;graph={$graph}-{$img_date}\" />\n";
530 531
													echo "<br /><hr /><br />\n";
													echo "</td></tr>\n";
Ad Schellevis's avatar
Ad Schellevis committed
532
												}
533 534 535 536 537 538
											} else {
												foreach($graphs as $graph) {
													/* check which databases are valid for our category */
													foreach($ui_databases as $curdatabase) {
														if(! preg_match("/($curcat)/i", $curdatabase))
															continue;
539

540 541
														if (($curcat == "captiveportal") && !empty($curzone) && !preg_match("/captiveportal-{$curzone}/i", $curdatabase))
															continue;
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
														$optionc = explode("-", $curdatabase);
														$search = array("-", ".rrd", $optionc);
														$replace = array(" :: ", "", $friendly);
														switch($curoption) {
															case "outbound":
																/* make sure we do not show the placeholder databases in the outbound view */
																if((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) {
																	continue 2;
																}
																/* only show interfaces with a gateway */
																$optionc = "$optionc[0]";
																if(!interface_has_gateway($optionc)) {
																	if(!isset($gateways_arr)) {
																		if(preg_match("/quality/i", $curdatabase))
																			$gateways_arr = return_gateways_array();
																		else
																			$gateways_arr = array();
																	}
																	$found_gateway = false;
																	foreach ($gateways_arr as $gw) {
																		if ($gw['name'] == $optionc) {
																			$found_gateway = true;
																			break;
																		}
																	}
																	if(!$found_gateway) {
																		continue 2;
																	}
																}
																if(! preg_match("/(^$optionc-|-$optionc\\.)/i", $curdatabase)) {
																	continue 2;
																}
																break;
															case "allgraphs":
																/* make sure we do not show the placeholder databases in the all view */
																if((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) {
																	continue 2;
																}
																break;
															default:
																/* just use the name here */
																if(! preg_match("/(^$curoption-|-$curoption\\.)/i", $curdatabase)) {
																	continue 2;
																}
														}
														if(in_array($curdatabase, $ui_databases)) {
															$id = "{$graph}-{$curoption}-{$curdatabase}";
															$id = preg_replace('/\./', '_', $id);
591
															$img_date = date('YmdGis'); /* Add a way to let the browser know we have refreshed the image */
592 593 594
															$dates = get_dates($curperiod, $graph);
															$start = $dates['start'];
															$end = $dates['end'];
Ad Schellevis's avatar
Ad Schellevis committed
595 596
															echo "<tr><td colspan=\"100%\" class=\"list\">\n";
															echo "<img border=\"0\" width=\"100%;\" name=\"{$id}\" ";
597
															echo "id=\"{$id}\" alt=\"$prettydb Graph\" ";
598
															echo "src=\"status_rrd_graph_img.php?start={$start}&amp;end={$end}&amp;database={$curdatabase}&amp;style={$curstyle}&amp;graph={$graph}-{$img_date}\" />\n";
599 600 601 602
															echo "<br /><hr /><br />\n";
															echo "</td></tr>\n";
														}
													}
Ad Schellevis's avatar
Ad Schellevis committed
603 604
												}
											}
605 606 607 608 609 610
											?>
										</table>
								</form>
							</div>
						</div>
					</section>
611

612
					<section class="col-xs-12">
613 614
						<div class="content-box">

615 616 617 618 619 620 621 622 623 624 625
							<script type="text/javascript">
							//<![CDATA[
								function update_graph_images() {
									//alert('updating');
									var randomid = Math.floor(Math.random()*11);
									<?php
									foreach($graphs as $graph) {
										/* check which databases are valid for our category */
										foreach($ui_databases as $curdatabase) {
											if(! stristr($curdatabase, $curcat)) {
												continue;
Ad Schellevis's avatar
Ad Schellevis committed
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 662 663 664 665 666 667 668 669
											$optionc = explode("-", $curdatabase);
											$search = array("-", ".rrd", $optionc);
											$replace = array(" :: ", "", $friendly);
											switch($curoption) {
												case "outbound":
													/* make sure we do not show the placeholder databases in the outbound view */
													if((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) {
														continue 2;
													}
													/* only show interfaces with a gateway */
													$optionc = "$optionc[0]";
													if(!interface_has_gateway($optionc)) {
														if(!isset($gateways_arr))
															if(preg_match("/quality/i", $curdatabase))
																$gateways_arr = return_gateways_array();
															else
																$gateways_arr = array();
														$found_gateway = false;
														foreach ($gateways_arr as $gw) {
															if ($gw['name'] == $optionc) {
																$found_gateway = true;
																break;
															}
														}
														if(!$found_gateway) {
															continue 2;
														}
													}
													if(! preg_match("/(^$optionc-|-$optionc\\.)/i", $curdatabase)) {
														continue 2;
													}
													break;
												case "allgraphs":
													/* make sure we do not show the placeholder databases in the all view */
													if((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) {
														continue 2;
													}
													break;
												default:
													/* just use the name here */
													if(! preg_match("/(^$curoption-|-$curoption\\.)/i", $curdatabase)) {
														continue 2;
													}
Ad Schellevis's avatar
Ad Schellevis committed
670
											}
671 672 673 674
											$dates = get_dates($curperiod, $graph);
											$start = $dates['start'];
											if($curperiod == "current") {
												$end = $dates['end'];
Ad Schellevis's avatar
Ad Schellevis committed
675
											}
676 677 678
											/* generate update events utilizing jQuery('') feature */
											$id = "{$graph}-{$curoption}-{$curdatabase}";
											$id = preg_replace('/\./', '_', $id);
679

680 681 682 683 684 685
											echo "\n";
											echo "\t\tjQuery('#{$id}').attr('src','status_rrd_graph_img.php?start={$start}&graph={$graph}&database={$curdatabase}&style={$curstyle}&tmp=' + randomid);\n";
											}
										}
									?>
									window.setTimeout('update_graph_images()', 355000);
Ad Schellevis's avatar
Ad Schellevis committed
686
								}
687 688 689
								window.setTimeout('update_graph_images()', 355000);
							//]]>
							</script>
690

691 692 693
					</div>
				</section>
			</div>
Ad Schellevis's avatar
Ad Schellevis committed
694
		</div>
695
	</section>
696

697
<?php include("foot.inc"); ?>