Project

General

Profile

Download (24.6 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	status_rrd_graph.php
5
	Part of pfSense
6
	Copyright (C) 2007 Seth Mos <seth.mos@dds.nl>
7
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
8
	All rights reserved.
9

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

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

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

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

    
35
##|+PRIV
36
##|*IDENT=page-status-rrdgraphs
37
##|*NAME=Status: RRD Graphs page
38
##|*DESCR=Allow access to the 'Status: RRD Graphs' page.
39
##|*MATCH=status_rrd_graph.php*
40
##|-PRIV
41

    
42
require("guiconfig.inc");
43
require_once("filter.inc");
44
require("shaper.inc");
45
require_once("rrd.inc");
46

    
47
unset($input_errors);
48

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

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

    
58

    
59
if ($_GET['cat']) {
60
	$curcat = htmlspecialchars($_GET['cat']);
61
} else {
62
	if(! empty($config['rrd']['category'])) {
63
		$curcat = $config['rrd']['category'];
64
	} else {
65
		$curcat = "system";
66
	}
67
}
68

    
69
if ($_GET['zone'])
70
	$curzone = $_GET['zone'];
71
else
72
	$curzone = '';
73

    
74
if ($_GET['period']) {
75
	$curperiod = $_GET['period'];
76
} else {
77
	if(! empty($config['rrd']['period'])) {
78
		$curperiod = $config['rrd']['period'];
79
	} else {
80
		$curperiod = "absolute";
81
	}
82
}
83

    
84
if ($_GET['option']) {
85
	$curoption = $_GET['option'];
86
} else {
87
	switch($curcat) {
88
		case "system":
89
			$curoption = "processor";
90
			break;
91
		case "queues":
92
			$curoption = "queues";
93
			break;
94
		case "queuedrops":
95
			$curoption = "queuedrops";
96
			break;
97
		case "quality":
98
			foreach($databases as $database) {
99
				if(preg_match("/[-]quality\.rrd/i", $database)) {
100
					/* pick off the 1st database we find that matches the quality graph */
101
					$name = explode("-", $database);
102
					$curoption = "$name[0]";
103
					continue 2;
104
				}
105
			}
106
		case "wireless":
107
			foreach($databases as $database) {
108
				if(preg_match("/[-]wireless\.rrd/i", $database)) {
109
					/* pick off the 1st database we find that matches the wireless graph */
110
					$name = explode("-", $database);
111
					$curoption = "$name[0]";
112
					continue 2;
113
				}
114
			}
115
		case "cellular":
116
			foreach($databases as $database) {
117
				if(preg_match("/[-]cellular\.rrd/i", $database)) {
118
					/* pick off the 1st database we find that matches the celullar graph */
119
					$name = explode("-", $database);
120
					$curoption = "$name[0]";
121
					continue 2;
122
				}
123
			}
124
		case "vpnusers":
125
			foreach($databases as $database) {
126
				if(preg_match("/[-]vpnusers\.rrd/i", $database)) {
127
					/* pick off the 1st database we find that matches the VPN graphs */
128
					$name = explode("-", $database);
129
					$curoption = "$name[0]";
130
					continue 2;
131
				}
132
			}
133
		case "captiveportal":
134
			$curoption = "allgraphs";
135
			break;
136
		case "ntpd":
137
			if(isset($config['ntpd']['statsgraph'])) {
138
				$curoption = "allgraphs";
139
			} else {
140
				$curoption = "processor";
141
				$curcat = "system";
142
			}
143
			break;
144
		default:
145
			$curoption = "wan";
146
			break;
147
	}
148
}
149

    
150
$now = time();
151
if($curcat == "custom") {
152
	if (is_numeric($_GET['start'])) {
153
		if($start < ($now - (3600 * 24 * 365 * 5))) {
154
			$start = $now - (8 * 3600);
155
		}
156
		$start = $_GET['start'];
157
	} else if ($_GET['start']) {
158
		$start = strtotime($_GET['start']);
159
		if ($start === FALSE || $start === -1) {
160
			$input_errors[] = gettext("Invalid start date/time:") . " '{$_GET['start']}'";
161
			$start = $now - (8 * 3600);
162
		}
163
	} else {
164
		$start = $now - (8 * 3600);
165
	}
166
}
167

    
168
if (is_numeric($_GET['end'])) {
169
        $end = $_GET['end'];
170
} else if ($_GET['end']) {
171
	$end = strtotime($_GET['end']);
172
	if ($end === FALSE || $end === -1) {
173
		$input_errors[] = gettext("Invalid end date/time:") . " '{$_GET['end']}'";
174
		$end = $now;
175
	}
176
} else {
177
        $end = $now;
178
}
179

    
180
/* this should never happen */
181
if($end < $start) {
182
	log_error("start $start is smaller than end $end");
183
        $end = $now;
184
}
185

    
186
$seconds = $end - $start;
187

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

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

    
194
if ($_GET['style']) {
195
	foreach($styles as $style) 
196
		if(strtoupper($style) == strtoupper($_GET['style'])) 
197
			$curstyle = $_GET['style'];
198
} else {
199
	if(! empty($config['rrd']['style'])) {
200
		$curstyle = $config['rrd']['style'];
201
	} else {
202
		$curstyle = "inverse";
203
	}
204
}
205

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

    
209
/* these boilerplate databases are required for the other menu choices */
210
$dbheader = array("allgraphs-traffic.rrd",
211
		"allgraphs-quality.rrd",
212
		"allgraphs-wireless.rrd",
213
		"allgraphs-cellular.rrd",
214
		"allgraphs-vpnusers.rrd",
215
		"allgraphs-packets.rrd",
216
		"system-allgraphs.rrd",
217
		"system-throughput.rrd",
218
		"outbound-quality.rrd",
219
		"outbound-packets.rrd",
220
		"outbound-traffic.rrd");
221

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

    
225
foreach($databases as $database) {
226
	if(stristr($database, "-wireless")) {
227
		$wireless = true;
228
	}
229
	if(stristr($database, "-queues")) {
230
		$queues = true;
231
	}
232
	if(stristr($database, "-cellular") && !empty($config['ppps'])) {
233
		$cellular = true;
234
	}
235
	if(stristr($database, "-vpnusers")) {
236
		$vpnusers = true;
237
	}
238
	if(stristr($database, "captiveportal-") && is_array($config['captiveportal'])) {
239
		$captiveportal = true;
240
	}
241
	if(stristr($database, "ntpd") && isset($config['ntpd']['statsgraph'])) {
242
		$ntpd = true;
243
	}
244
}
245
/* append the existing array to the header */
246
$ui_databases = array_merge($dbheader, $databases);
247
$custom_databases = array_merge($dbheader_custom, $databases);
248

    
249
$graphs = array("eighthour", "day", "week", "month", "quarter", "year", "fouryear");
250
$periods = array("absolute" => gettext("Absolute Timespans"), "current" => gettext("Current Period"), "previous" => gettext("Previous Period"));
251
$graph_length = array(
252
	"eighthour" => 28800,
253
	"day" => 86400,
254
	"week" => 604800,
255
	"month" => 2678400,
256
	"quarter" => 7948800,
257
	"year" => 31622400,
258
	"fouryear" => 126230400);
259

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

    
262
$closehead = false;
263

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

    
271
		if ($curzone == '') {
272
			$tabactive = true;
273
			$curzone = $cpkey;
274
		} elseif ($curzone == $cpkey) {
275
			$tabactive = true;
276
		} else {
277
			$tabactive = false;
278
		}
279

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

    
284
include("head.inc");
285
?>
286

    
287
<?php if ($curcat === "custom") { ?>
288
	<link rel="stylesheet" type="text/css" href="/javascript/jquery-ui-timepicker-addon/css/jquery-ui-timepicker-addon.css" />
289
	<?php if (file_exists("{$g['www_path']}/themes/{$g['theme']}/jquery-ui-1.11.1.css")) { ?>
290
		<link rel="stylesheet" type="text/css" href="/themes/<?= $g['theme'] ?>/jquery-ui-1.11.1.css" />
291
	<?php } else { ?>
292
		<link rel="stylesheet" type="text/css" href="/javascript/jquery/jquery-ui-1.11.1.css" />
293
	<?php } ?>
294
	<script type="text/javascript" src="/javascript/jquery-ui-timepicker-addon/js/jquery-ui-timepicker-addon.js"></script>
295
	<script type="text/javascript">
296
	//<![CDATA[
297
		jQuery(function ($) {
298
			var options = {
299
				dateFormat: 'mm/dd/yy',
300
				timeFormat: 'hh:mm:ss',
301
				showSecond: true
302
			};
303
			$("#startDateTime").datetimepicker(options);
304
			$("#endDateTime").datetimepicker(options);
305
		});
306
	//]]>
307
	</script>
308
<?php } ?>
309

    
310
<?php
311

    
312
function get_dates($curperiod, $graph) {
313
	global $graph_length;
314
	$now = time();
315
	$end = $now;
316

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

    
327
		switch($curperiod) {
328
			case "previous":
329
				$offset = -1;
330
				break;
331
			default:
332
				$offset = 0;
333
		}
334
		switch($graph) {
335
			case "eighthour":
336
				if($curhour < 24)
337
					$starthour = 16;
338
				if($curhour < 16)
339
					$starthour = 8;
340
				if($curhour < 8)
341
					$starthour = 0;
342

    
343
				switch($offset) {
344
					case 0:
345
						$houroffset = $starthour;
346
						break;
347
					default:
348
						$houroffset = $starthour + ($offset * 8);
349
						break;
350
				}
351
				$start = mktime($houroffset, 0, 0, $curmonth, $curday, $curyear);
352
				if($offset != 0) {
353
					$end = mktime(($houroffset + 8), 0, 0, $curmonth, $curday, $curyear);
354
				}
355
				break;
356
			case "day":
357
				$start = mktime(0, 0, 0, $curmonth, ($curday + $offset), $curyear);
358
				if($offset != 0)
359
					$end = mktime(0, 0, 0, $curmonth, (($curday + $offset) + 1), $curyear);
360
				break;
361
			case "week":
362
				switch($offset) {
363
					case 0:
364
						$weekoffset = 0;
365
						break;
366
					default:
367
						$weekoffset = ($offset * 7) - 7;
368
						break;
369
				}
370
				$start = mktime(0, 0, 0, $curmonth, (($curday - $curweekday) + $weekoffset), $curyear);
371
				if($offset != 0)
372
					$end = mktime(0, 0, 0, $curmonth, (($curday - $curweekday) + $weekoffset + 7), $curyear);
373
				break;
374
			case "month":
375
				$start = mktime(0, 0, 0, ($curmonth + $offset), 0, $curyear);
376
				if($offset != 0)
377
					$end = mktime(0, 0, 0, (($curmonth + $offset) + 1), 0, $curyear);
378
				break;
379
			case "quarter":
380
				$start = mktime(0, 0, 0, (($curmonth - 2) + $offset), 0, $curyear);
381
				if($offset != 0)
382
					$end = mktime(0, 0, 0, (($curmonth + $offset) + 1), 0, $curyear);
383
				break;
384
			case "year":
385
				$start = mktime(0, 0, 0, 1, 0, ($curyear + $offset));
386
				if($offset != 0)
387
					$end = mktime(0, 0, 0, 1, 0, (($curyear + $offset) +1));
388
				break;
389
			case "fouryear":
390
				$start = mktime(0, 0, 0, 1, 0, (($curyear - 3) + $offset));
391
				if($offset != 0)
392
					$end = mktime(0, 0, 0, 1, 0, (($curyear + $offset) +1));
393
				break;
394
		}
395
	}
396
	// 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 />";
397
	$dates = array();
398
	$dates['start'] = $start;
399
	$dates['end'] = $end;
400
	return $dates;
401
}
402

    
403
?>
404
</head>
405
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
406
<?php include("fbegin.inc"); ?>
407
<?php if ($input_errors && count($input_errors)) { print_input_errors($input_errors); } ?>
408
<form name="form1" action="status_rrd_graph.php" method="get">
409
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="rrd graphs">
410
        <tr>
411
                <td>
412
			<input type="hidden" name="cat" value="<?php echo "$curcat"; ?>" />
413
			<?php
414
			        $tab_array = array();
415
				if($curcat == "system") { $tabactive = True; } else { $tabactive = False; }
416
			        $tab_array[] = array(gettext("System"), $tabactive, "status_rrd_graph.php?cat=system");
417
				if($curcat == "traffic") { $tabactive = True; } else { $tabactive = False; }
418
			        $tab_array[] = array(gettext("Traffic"), $tabactive, "status_rrd_graph.php?cat=traffic");
419
				if($curcat == "packets") { $tabactive = True; } else { $tabactive = False; }
420
			        $tab_array[] = array(gettext("Packets"), $tabactive, "status_rrd_graph.php?cat=packets");
421
				if($curcat == "quality") { $tabactive = True; } else { $tabactive = False; }
422
			        $tab_array[] = array(gettext("Quality"), $tabactive, "status_rrd_graph.php?cat=quality");
423
				if($queues) {
424
					if($curcat == "queues") { $tabactive = True; } else { $tabactive = False; }
425
						$tab_array[] = array(gettext("Queues"), $tabactive, "status_rrd_graph.php?cat=queues");
426
					if($curcat == "queuedrops") { $tabactive = True; } else { $tabactive = False; }
427
						$tab_array[] = array(gettext("QueueDrops"), $tabactive, "status_rrd_graph.php?cat=queuedrops");
428
				}
429
				if($wireless) {
430
					if($curcat == "wireless") { $tabactive = True; } else { $tabactive = False; }
431
				        $tab_array[] = array(gettext("Wireless"), $tabactive, "status_rrd_graph.php?cat=wireless");
432
				}
433
				if($cellular) {
434
					if($curcat == "cellular") { $tabactive = True; } else { $tabactive = False; }
435
				        $tab_array[] = array(gettext("Cellular"), $tabactive, "status_rrd_graph.php?cat=cellular");
436
				}
437
				if($vpnusers) {
438
					if($curcat == "vpnusers") { $tabactive = True; } else { $tabactive = False; }
439
				        $tab_array[] = array("VPN", $tabactive, "status_rrd_graph.php?cat=vpnusers");
440
				}
441
				if($captiveportal) {
442
					if($curcat == "captiveportal") { $tabactive = True; } else { $tabactive = False; }
443
				        $tab_array[] = array("Captive Portal", $tabactive, "status_rrd_graph.php?cat=captiveportal");
444
				}
445
				if($ntpd) {
446
					if($curcat == "ntpd") { $tabactive = True; } else { $tabactive = False; }
447
				        $tab_array[] = array("NTP", $tabactive, "status_rrd_graph.php?cat=ntpd");
448
				}
449
				if($curcat == "custom") { $tabactive = True; } else { $tabactive = False; }
450
			        $tab_array[] = array(gettext("Custom"), $tabactive, "status_rrd_graph.php?cat=custom");
451
				if($curcat == "settings") { $tabactive = True; } else { $tabactive = False; }
452
			        $tab_array[] = array(gettext("Settings"), $tabactive, "status_rrd_graph_settings.php");
453
			        display_top_tabs($tab_array);
454
			?>
455
                </td>
456
        </tr>
457
	<?php if ($curcat == "captiveportal") : ?>
458
	<tr>
459
		<td class="tabnavtbl">
460
			<?php display_top_tabs($cp_zones_tab_array); ?>
461
		</td>
462
	</tr>
463
	<?php endif; ?>
464
        <tr>
465
                <td>
466
                        <div id="mainarea">
467
                        <table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="0" summary="main area">
468
                                <tr>
469
                                        <td colspan="2" class="list"><p><b><?=gettext("Note: Change of color and/or style may not take effect until the next refresh");?></b></p></td>
470
				</tr>
471
				<tr>
472
                                        <td colspan="2" class="list">
473
					<?=gettext("Graphs:");?>
474
					<?php if (!empty($curzone)): ?>
475
					<input type="hidden" name="zone" value="<?= htmlspecialchars($curzone) ?>" />
476
					<?php endif; ?>
477
					<select name="option" class="formselect" style="z-index: -10;" onchange="document.form1.submit()">
478
					<?php
479

    
480
					if($curcat == "custom") {
481
						foreach ($custom_databases as $db => $database) {
482
							$optionc = explode("-", $database);
483
							$friendly = convert_friendly_interface_to_friendly_descr(strtolower($optionc[0]));
484
							if (empty($friendly)) {
485
								$friendly = $optionc[0];
486
							}
487
							$search = array("-", ".rrd", $optionc[0]);
488
							$replace = array(" :: ", "", $friendly);
489
							echo "<option value=\"{$database}\"";
490
							$prettyprint = ucwords(str_replace($search, $replace, $database));
491
							if($curoption == $database) {
492
								echo " selected=\"selected\"";
493
							}
494
							echo ">" . htmlspecialchars($prettyprint) . "</option>\n";
495
						}
496
					}
497
					foreach ($ui_databases as $db => $database) {
498
						if(! preg_match("/($curcat)/i", $database))
499
							continue;
500

    
501
						if (($curcat == "captiveportal") && !empty($curzone) && !preg_match("/captiveportal-{$curzone}/i", $database))
502
							continue;
503

    
504
						$optionc = explode("-", $database);
505
						$search = array("-", ".rrd", $optionc);
506
						$replace = array(" :: ", "", $friendly);
507

    
508
						switch($curcat) {
509
							case "captiveportal":
510
								$optionc = str_replace($search, $replace, $optionc[2]);
511
								echo "<option value=\"$optionc\"";
512
								$prettyprint = ucwords(str_replace($search, $replace, $optionc));
513
								break;
514
							case "system":
515
								$optionc = str_replace($search, $replace, $optionc[1]);
516
								echo "<option value=\"$optionc\"";
517
								$prettyprint = ucwords(str_replace($search, $replace, $optionc));
518
								break;
519
							default:
520
								/* Deduce a interface if possible and use the description */
521
								$optionc = "$optionc[0]";
522
								$friendly = convert_friendly_interface_to_friendly_descr(strtolower($optionc));
523
								if(empty($friendly)) {
524
									$friendly = $optionc;
525
								}
526
								$search = array("-", ".rrd", $optionc);
527
								$replace = array(" :: ", "", $friendly);
528
								echo "<option value=\"$optionc\"";
529
								$prettyprint = ucwords(str_replace($search, $replace, $friendly));
530
						}
531
						if($curoption == $optionc) {
532
							echo " selected=\"selected\"";
533
						}
534
						echo ">" . htmlspecialchars($prettyprint) . "</option>\n";
535
					}
536

    
537
					?>
538
					</select>
539

    
540
					<?=gettext("Style:");?>
541
					<select name="style" class="formselect" style="z-index: -10;" onchange="document.form1.submit()">
542
					<?php
543
					foreach ($styles as $style => $styled) {
544
						echo "<option value=\"$style\"";
545
						if ($style == $curstyle) echo " selected=\"selected\"";
546
						echo ">" . htmlspecialchars($styled) . "</option>\n";
547
					}
548
					?>
549
					</select>
550
					
551
					<?php
552
					if($curcat <> "custom") {
553
					?>
554
						<?=gettext("Period:");?>
555
						<select name="period" class="formselect" style="z-index: -10;" onchange="document.form1.submit()">
556
						<?php
557
						foreach ($periods as $period => $value) {
558
							echo "<option value=\"$period\"";
559
							if ($period == $curperiod) echo " selected=\"selected\"";
560
							echo ">" . htmlspecialchars($value) . "</option>\n";
561
						}
562
						echo "</select>\n";
563
						echo "</td></tr>\n";
564
					}
565
					?>
566
					<?php
567

    
568
					if($curcat == "custom") {
569
						$tz = date_default_timezone_get();
570
						$tz_msg = gettext("Enter date and/or time. Current timezone:") . " $tz";
571
						$start_fmt = strftime("%m/%d/%Y %H:%M:%S", $start);
572
						$end_fmt   = strftime("%m/%d/%Y %H:%M:%S", $end);
573
						?>
574
						<?=gettext("Start:");?>
575
						<input id="startDateTime" title="<?= htmlentities($tz_msg); ?>." type="text" name="start" class="formfld unknown" size="24" value="<?= htmlentities($start_fmt); ?>" />
576
						<?=gettext("End:");?>
577
						<input id="endDateTime" title="<?= htmlentities($tz_msg); ?>." type="text" name="end" class="formfld unknown" size="24" value="<?= htmlentities($end_fmt); ?>" />
578
						<input type="submit" name="Submit" value="<?=gettext("Go"); ?>" />
579
						</td></tr>
580
						<?php
581
						$curdatabase = $curoption;
582
						$graph = "custom-$curdatabase";
583
						if(in_array($curdatabase, $custom_databases)) {
584
							$id = "{$graph}-{$curoption}-{$curdatabase}";
585
							$id = preg_replace('/\./', '_', $id);
586

    
587
							echo "<tr><td colspan=\"2\" class=\"list\">\n";
588
							echo "<img border=\"0\" name=\"{$id}\" ";
589
							echo "id=\"{$id}\" alt=\"$prettydb Graph\" ";
590
							echo "src=\"status_rrd_graph_img.php?start={$start}&amp;end={$end}&amp;database={$curdatabase}&amp;style={$curstyle}&amp;graph={$graph}\" />\n";
591
							echo "<br /><hr /><br />\n";
592
							echo "</td></tr>\n";
593
						}
594
					} else {
595
						foreach($graphs as $graph) {
596
							/* check which databases are valid for our category */
597
							foreach($ui_databases as $curdatabase) {
598
								if(! preg_match("/($curcat)/i", $curdatabase))
599
									continue;
600

    
601
								if (($curcat == "captiveportal") && !empty($curzone) && !preg_match("/captiveportal-{$curzone}/i", $curdatabase))
602
									continue;
603

    
604
								$optionc = explode("-", $curdatabase);
605
								$search = array("-", ".rrd", $optionc);
606
								$replace = array(" :: ", "", $friendly);
607
								switch($curoption) {
608
									case "outbound":
609
										/* make sure we do not show the placeholder databases in the outbound view */
610
										if((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) {
611
											continue 2;
612
										}
613
										/* only show interfaces with a gateway */
614
										$optionc = "$optionc[0]";
615
										if(!interface_has_gateway($optionc)) {
616
											if(!isset($gateways_arr)) {
617
												if(preg_match("/quality/i", $curdatabase))
618
													$gateways_arr = return_gateways_array();
619
												else
620
													$gateways_arr = array();
621
											}
622
											$found_gateway = false;
623
											foreach ($gateways_arr as $gw) {
624
												if ($gw['name'] == $optionc) {
625
													$found_gateway = true;
626
													break;
627
												}
628
											}
629
											if(!$found_gateway) {
630
												continue 2;
631
											}
632
										}
633
										if(! preg_match("/(^$optionc-|-$optionc\\.)/i", $curdatabase)) {
634
											continue 2;
635
										}
636
										break;
637
									case "allgraphs":
638
										/* make sure we do not show the placeholder databases in the all view */
639
										if((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) {
640
											continue 2;
641
										}
642
										break;
643
									default:
644
										/* just use the name here */
645
										if(! preg_match("/(^$curoption-|-$curoption\\.)/i", $curdatabase)) {
646
											continue 2;
647
										}
648
								}
649
								if(in_array($curdatabase, $ui_databases)) {
650
									$id = "{$graph}-{$curoption}-{$curdatabase}";
651
									$id = preg_replace('/\./', '_', $id);
652

    
653
									$dates = get_dates($curperiod, $graph);
654
									$start = $dates['start'];
655
									$end = $dates['end'];
656
									echo "<tr><td colspan=\"2\" class=\"list\">\n";
657
									echo "<img border=\"0\" name=\"{$id}\" ";
658
									echo "id=\"{$id}\" alt=\"$prettydb Graph\" ";
659
									echo "src=\"status_rrd_graph_img.php?start={$start}&amp;end={$end}&amp;database={$curdatabase}&amp;style={$curstyle}&amp;graph={$graph}\" />\n";
660
									echo "<br /><hr /><br />\n";
661
									echo "</td></tr>\n";
662
								}
663
							}
664
						}
665
					}
666
					?>
667
				<tr>
668
					<td colspan="2" class="list">
669
					<script type="text/javascript">
670
					//<![CDATA[
671
						function update_graph_images() {
672
							//alert('updating');
673
							var randomid = Math.floor(Math.random()*11);
674
							<?php
675
							foreach($graphs as $graph) {
676
								/* check which databases are valid for our category */
677
								foreach($ui_databases as $curdatabase) {
678
									if(! stristr($curdatabase, $curcat)) {
679
										continue;
680
									}
681
									$optionc = explode("-", $curdatabase);
682
									$search = array("-", ".rrd", $optionc);
683
									$replace = array(" :: ", "", $friendly);
684
									switch($curoption) {
685
										case "outbound":
686
											/* make sure we do not show the placeholder databases in the outbound view */
687
											if((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) {
688
												continue 2;
689
											}
690
											/* only show interfaces with a gateway */
691
											$optionc = "$optionc[0]";
692
											if(!interface_has_gateway($optionc)) {
693
												if(!isset($gateways_arr))
694
													if(preg_match("/quality/i", $curdatabase))
695
														$gateways_arr = return_gateways_array();
696
													else
697
														$gateways_arr = array();
698
												$found_gateway = false;
699
												foreach ($gateways_arr as $gw) {
700
													if ($gw['name'] == $optionc) {
701
														$found_gateway = true;
702
														break;
703
													}
704
												}
705
												if(!$found_gateway) {
706
													continue 2;
707
												}
708
											}
709
											if(! preg_match("/(^$optionc-|-$optionc\\.)/i", $curdatabase)) {
710
												continue 2;
711
											}
712
											break;
713
										case "allgraphs":
714
											/* make sure we do not show the placeholder databases in the all view */
715
											if((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) {
716
												continue 2;
717
											}
718
											break;
719
										default:
720
											/* just use the name here */
721
											if(! preg_match("/(^$curoption-|-$curoption\\.)/i", $curdatabase)) {
722
												continue 2;
723
											}
724
									}
725
									$dates = get_dates($curperiod, $graph);
726
									$start = $dates['start'];
727
									if($curperiod == "current") {
728
										$end = $dates['end'];
729
									}
730
									/* generate update events utilizing jQuery('') feature */
731
									$id = "{$graph}-{$curoption}-{$curdatabase}";
732
									$id = preg_replace('/\./', '_', $id);
733

    
734
									echo "\n";
735
									echo "\t\tjQuery('#{$id}').attr('src','status_rrd_graph_img.php?start={$start}&graph={$graph}&database={$curdatabase}&style={$curstyle}&tmp=' + randomid);\n";
736
									}
737
								}
738
							?>
739
							window.setTimeout('update_graph_images()', 355000);
740
						}
741
						window.setTimeout('update_graph_images()', 355000);
742
					//]]>
743
					</script>
744
					</td>
745
				</tr>
746
			</table>
747
		</div>
748
		</td>
749
	</tr>
750
</table>
751
</form>
752
<?php include("fend.inc"); ?>
753
</body>
754
</html>
(184-184/241)