Project

General

Profile

Download (25.1 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

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

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

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

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

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

    
187
$seconds = $end - $start;
188

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

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

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

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

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

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

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

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

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

    
265
$closehead = false;
266

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

    
275
		if ($curzone == '') {
276
			$tabactive = true;
277
			$curzone = $cpkey;
278
		} elseif ($curzone == $cpkey) {
279
			$tabactive = true;
280
		} else {
281
			$tabactive = false;
282
		}
283

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

    
288
include("head.inc");
289
?>
290

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

    
314
<?php
315

    
316
function get_dates($curperiod, $graph) {
317
	global $graph_length;
318
	$now = time();
319
	$end = $now;
320

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

    
331
		switch ($curperiod) {
332
			case "previous":
333
				$offset = -1;
334
				break;
335
			default:
336
				$offset = 0;
337
		}
338
		switch ($graph) {
339
			case "eighthour":
340
				if ($curhour < 24) {
341
					$starthour = 16;
342
				}
343
				if ($curhour < 16) {
344
					$starthour = 8;
345
				}
346
				if ($curhour < 8) {
347
					$starthour = 0;
348
				}
349

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

    
416
?>
417
</head>
418
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
419
<?php include("fbegin.inc"); ?>
420
<?php if ($input_errors && count($input_errors)) { print_input_errors($input_errors); } ?>
421
<form name="form1" action="status_rrd_graph.php" method="get">
422
	<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="rrd graphs">
423
		<tr>
424
			<td>
425
				<input type="hidden" name="cat" value="<?php echo "$curcat"; ?>" />
426
				<?php
427
					$tab_array = array();
428
					if ($curcat == "system") {
429
						$tabactive = True;
430
					} else {
431
						$tabactive = False;
432
					}
433
					$tab_array[] = array(gettext("System"), $tabactive, "status_rrd_graph.php?cat=system");
434
					if ($curcat == "traffic") {
435
						$tabactive = True;
436
					} else {
437
						$tabactive = False;
438
					}
439
					$tab_array[] = array(gettext("Traffic"), $tabactive, "status_rrd_graph.php?cat=traffic");
440
					if ($curcat == "packets") {
441
						$tabactive = True;
442
					} else {
443
						$tabactive = False;
444
					}
445
					$tab_array[] = array(gettext("Packets"), $tabactive, "status_rrd_graph.php?cat=packets");
446
					if ($curcat == "quality") {
447
						$tabactive = True;
448
					} else {
449
						$tabactive = False;
450
					}
451
					$tab_array[] = array(gettext("Quality"), $tabactive, "status_rrd_graph.php?cat=quality");
452
					if ($queues) {
453
						if ($curcat == "queues") {
454
							$tabactive = True;
455
						} else {
456
							$tabactive = False;
457
						}
458
						$tab_array[] = array(gettext("Queues"), $tabactive, "status_rrd_graph.php?cat=queues");
459
						if ($curcat == "queuedrops") {
460
							$tabactive = True;
461
						} else {
462
							$tabactive = False;
463
						}
464
						$tab_array[] = array(gettext("QueueDrops"), $tabactive, "status_rrd_graph.php?cat=queuedrops");
465
					}
466
					if ($wireless) {
467
						if ($curcat == "wireless") {
468
							$tabactive = True;
469
						} else {
470
							$tabactive = False;
471
						}
472
						$tab_array[] = array(gettext("Wireless"), $tabactive, "status_rrd_graph.php?cat=wireless");
473
					}
474
					if ($cellular) {
475
						if ($curcat == "cellular") {
476
							$tabactive = True;
477
						} else {
478
							$tabactive = False;
479
						}
480
						$tab_array[] = array(gettext("Cellular"), $tabactive, "status_rrd_graph.php?cat=cellular");
481
					}
482
					if ($vpnusers) {
483
						if ($curcat == "vpnusers") {
484
							$tabactive = True;
485
						} else {
486
							$tabactive = False;
487
						}
488
						$tab_array[] = array("VPN", $tabactive, "status_rrd_graph.php?cat=vpnusers");
489
					}
490
					if ($captiveportal) {
491
						if ($curcat == "captiveportal") {
492
							$tabactive = True;
493
						} else {
494
							$tabactive = False;
495
						}
496
						$tab_array[] = array("Captive Portal", $tabactive, "status_rrd_graph.php?cat=captiveportal");
497
					}
498
					if ($ntpd) {
499
						if ($curcat == "ntpd") {
500
							$tabactive = True;
501
						} else {
502
							$tabactive = False;
503
						}
504
						$tab_array[] = array("NTP", $tabactive, "status_rrd_graph.php?cat=ntpd");
505
					}
506
					if ($curcat == "custom") {
507
						$tabactive = True;
508
					} else {
509
						$tabactive = False;
510
					}
511
					$tab_array[] = array(gettext("Custom"), $tabactive, "status_rrd_graph.php?cat=custom");
512
					if ($curcat == "settings") {
513
						$tabactive = True;
514
					} else {
515
						$tabactive = False;
516
					}
517
					$tab_array[] = array(gettext("Settings"), $tabactive, "status_rrd_graph_settings.php");
518
					display_top_tabs($tab_array);
519
				?>
520
			</td>
521
		</tr>
522
<?php if ($curcat == "captiveportal") : ?>
523
		<tr>
524
			<td class="tabnavtbl">
525
				<?php display_top_tabs($cp_zones_tab_array); ?>
526
			</td>
527
		</tr>
528
<?php endif; ?>
529
		<tr>
530
			<td>
531
				<div id="mainarea">
532
				<table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="0" summary="main area">
533
					<tr>
534
						<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>
535
					</tr>
536
					<tr>
537
						<td colspan="2" class="list">
538
							<?=gettext("Graphs:");?>
539
							<?php if (!empty($curzone)): ?>
540
								<input type="hidden" name="zone" value="<?= htmlspecialchars($curzone) ?>" />
541
							<?php endif; ?>
542
							<select name="option" class="formselect" style="z-index: -10;" onchange="document.form1.submit()">
543
							<?php
544
								if ($curcat == "custom") {
545
									foreach ($custom_databases as $db => $database) {
546
										$optionc = explode("-", $database);
547
										$friendly = convert_friendly_interface_to_friendly_descr(strtolower($optionc[0]));
548
										if (empty($friendly)) {
549
											$friendly = $optionc[0];
550
										}
551
										$search = array("-", ".rrd", $optionc[0]);
552
										$replace = array(" :: ", "", $friendly);
553
										echo "<option value=\"{$database}\"";
554
										$prettyprint = ucwords(str_replace($search, $replace, $database));
555
										if ($curoption == $database) {
556
											echo " selected=\"selected\"";
557
										}
558
										echo ">" . htmlspecialchars($prettyprint) . "</option>\n";
559
									}
560
								}
561
								foreach ($ui_databases as $db => $database) {
562
									if (!preg_match("/($curcat)/i", $database)) {
563
										continue;
564
									}
565

    
566
									if (($curcat == "captiveportal") && !empty($curzone) && !preg_match("/captiveportal-{$curzone}/i", $database)) {
567
										continue;
568
									}
569

    
570
									$optionc = explode("-", $database);
571
									$search = array("-", ".rrd", $optionc);
572
									$replace = array(" :: ", "", $friendly);
573

    
574
									switch ($curcat) {
575
										case "captiveportal":
576
											$optionc = str_replace($search, $replace, $optionc[2]);
577
											echo "<option value=\"$optionc\"";
578
											$prettyprint = ucwords(str_replace($search, $replace, $optionc));
579
											break;
580
										case "system":
581
											$optionc = str_replace($search, $replace, $optionc[1]);
582
											echo "<option value=\"$optionc\"";
583
											$prettyprint = ucwords(str_replace($search, $replace, $optionc));
584
											break;
585
										default:
586
											/* Deduce a interface if possible and use the description */
587
											$optionc = "$optionc[0]";
588
											$friendly = convert_friendly_interface_to_friendly_descr(strtolower($optionc));
589
											if (empty($friendly)) {
590
												$friendly = $optionc;
591
											}
592
											$search = array("-", ".rrd", $optionc);
593
											$replace = array(" :: ", "", $friendly);
594
											echo "<option value=\"$optionc\"";
595
											$prettyprint = ucwords(str_replace($search, $replace, $friendly));
596
									}
597
									if ($curoption == $optionc) {
598
										echo " selected=\"selected\"";
599
									}
600
									echo ">" . htmlspecialchars($prettyprint) . "</option>\n";
601
								}
602
							?>
603
							</select>
604

    
605
							<?=gettext("Style:");?>
606
							<select name="style" class="formselect" style="z-index: -10;" onchange="document.form1.submit()">
607
							<?php
608
								foreach ($styles as $style => $styled) {
609
									echo "<option value=\"$style\"";
610
									if ($style == $curstyle) {
611
										echo " selected=\"selected\"";
612
									}
613
									echo ">" . htmlspecialchars($styled) . "</option>\n";
614
								}
615
							?>
616
							</select>
617

    
618
<?php
619
	if ($curcat == "custom") {
620
		// Custom tab displays start and end time selectors.
621
		$tz = date_default_timezone_get();
622
		$tz_msg = gettext("Enter date and/or time. Current timezone:") . " $tz";
623
		$start_fmt = strftime("%m/%d/%Y %H:%M:%S", $start);
624
		$end_fmt   = strftime("%m/%d/%Y %H:%M:%S", $end);
625
?>
626
							<?=gettext("Start:");?>
627
							<input id="startDateTime" title="<?= htmlentities($tz_msg); ?>." type="text" name="start" class="formfld unknown" size="24" value="<?= htmlentities($start_fmt); ?>" />
628
							<?=gettext("End:");?>
629
							<input id="endDateTime" title="<?= htmlentities($tz_msg); ?>." type="text" name="end" class="formfld unknown" size="24" value="<?= htmlentities($end_fmt); ?>" />
630
							<input type="submit" name="Submit" value="<?=gettext("Go"); ?>" />
631
<?php
632
	} else {
633
		// Not on the custom tab - show the Period selector
634
?>
635
							<?=gettext("Period:");?>
636
							<select name="period" class="formselect" style="z-index: -10;" onchange="document.form1.submit()">
637
							<?php
638
								foreach ($periods as $period => $value) {
639
									echo "<option value=\"$period\"";
640
									if ($period == $curperiod) {
641
										echo " selected=\"selected\"";
642
									}
643
									echo ">" . htmlspecialchars($value) . "</option>\n";
644
								}
645
							?>
646
							</select>
647
<?php
648
	}
649
?>
650
						</td>
651
					</tr>
652
<?php
653
	if ($curcat == "custom") {
654
		// Insert the chosen graph
655
		$curdatabase = $curoption;
656
		$graph = "custom-$curdatabase";
657
		if (in_array($curdatabase, $custom_databases)) {
658
			$id = "{$graph}-{$curoption}-{$curdatabase}";
659
			$id = preg_replace('/\./', '_', $id);
660

    
661
			echo "<tr><td colspan=\"2\" class=\"list\">\n";
662
			echo "<img border=\"0\" name=\"{$id}\" ";
663
			echo "id=\"{$id}\" alt=\"$prettydb Graph\" ";
664
			echo "src=\"status_rrd_graph_img.php?start={$start}&amp;end={$end}&amp;database={$curdatabase}&amp;style={$curstyle}&amp;graph={$graph}\" />\n";
665
			echo "<br /><hr /><br />\n";
666
			echo "</td></tr>\n";
667
		}
668
	} else {
669
		// Insert each of the graphs for the various set time periods
670
		foreach ($graphs as $graph) {
671
			/* check which databases are valid for our category */
672
			foreach ($ui_databases as $curdatabase) {
673
				if (!preg_match("/($curcat)/i", $curdatabase)) {
674
					continue;
675
				}
676

    
677
				if (($curcat == "captiveportal") && !empty($curzone) && !preg_match("/captiveportal-{$curzone}/i", $curdatabase)) {
678
					continue;
679
				}
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
								}
699
							}
700
							$found_gateway = false;
701
							foreach ($gateways_arr as $gw) {
702
								if ($gw['name'] == $optionc) {
703
									$found_gateway = true;
704
									break;
705
								}
706
							}
707
							if (!$found_gateway) {
708
								continue 2;
709
							}
710
						}
711
						if (!preg_match("/(^$optionc-|-$optionc\\.)/i", $curdatabase)) {
712
							continue 2;
713
						}
714
						break;
715
					case "allgraphs":
716
						/* make sure we do not show the placeholder databases in the all view */
717
						if ((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) {
718
							continue 2;
719
						}
720
						break;
721
					default:
722
						/* just use the name here */
723
						if (!preg_match("/(^$curoption-|-$curoption\\.)/i", $curdatabase)) {
724
							continue 2;
725
						}
726
				}
727
				if (in_array($curdatabase, $ui_databases)) {
728
					$id = "{$graph}-{$curoption}-{$curdatabase}";
729
					$id = preg_replace('/\./', '_', $id);
730

    
731
					$dates = get_dates($curperiod, $graph);
732
					$start = $dates['start'];
733
					$end = $dates['end'];
734
					echo "<tr><td colspan=\"2\" class=\"list\">\n";
735
					echo "<img border=\"0\" name=\"{$id}\" ";
736
					echo "id=\"{$id}\" alt=\"$prettydb Graph\" ";
737
					echo "src=\"status_rrd_graph_img.php?start={$start}&amp;end={$end}&amp;database={$curdatabase}&amp;style={$curstyle}&amp;graph={$graph}\" />\n";
738
					echo "<br /><hr /><br />\n";
739
					echo "</td></tr>\n";
740
				}
741
			}
742
		}
743
	}
744
?>
745
					<tr>
746
						<td colspan="2" class="list">
747
							<script type="text/javascript">
748
							//<![CDATA[
749
								function update_graph_images() {
750
									//alert('updating');
751
									var randomid = Math.floor(Math.random()*11);
752
									<?php
753
									foreach ($graphs as $graph) {
754
										/* check which databases are valid for our category */
755
										foreach ($ui_databases as $curdatabase) {
756
											if (!stristr($curdatabase, $curcat)) {
757
												continue;
758
											}
759
											$optionc = explode("-", $curdatabase);
760
											$search = array("-", ".rrd", $optionc);
761
											$replace = array(" :: ", "", $friendly);
762
											switch ($curoption) {
763
												case "outbound":
764
													/* make sure we do not show the placeholder databases in the outbound view */
765
													if ((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) {
766
														continue 2;
767
													}
768
													/* only show interfaces with a gateway */
769
													$optionc = "$optionc[0]";
770
													if (!interface_has_gateway($optionc)) {
771
														if (!isset($gateways_arr)) {
772
															if (preg_match("/quality/i", $curdatabase)) {
773
																$gateways_arr = return_gateways_array();
774
															} else {
775
																$gateways_arr = array();
776
															}
777
														}
778
														$found_gateway = false;
779
														foreach ($gateways_arr as $gw) {
780
															if ($gw['name'] == $optionc) {
781
																$found_gateway = true;
782
																break;
783
															}
784
														}
785
														if (!$found_gateway) {
786
															continue 2;
787
														}
788
													}
789
													if (!preg_match("/(^$optionc-|-$optionc\\.)/i", $curdatabase)) {
790
														continue 2;
791
													}
792
													break;
793
												case "allgraphs":
794
													/* make sure we do not show the placeholder databases in the all view */
795
													if ((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) {
796
														continue 2;
797
													}
798
													break;
799
												default:
800
													/* just use the name here */
801
													if (!preg_match("/(^$curoption-|-$curoption\\.)/i", $curdatabase)) {
802
														continue 2;
803
													}
804
											}
805
											$dates = get_dates($curperiod, $graph);
806
											$start = $dates['start'];
807
											if ($curperiod == "current") {
808
												$end = $dates['end'];
809
											}
810
											/* generate update events utilizing jQuery('') feature */
811
											$id = "{$graph}-{$curoption}-{$curdatabase}";
812
											$id = preg_replace('/\./', '_', $id);
813

    
814
											echo "\n";
815
											echo "\t\tjQuery('#{$id}').attr('src','status_rrd_graph_img.php?start={$start}&graph={$graph}&database={$curdatabase}&style={$curstyle}&tmp=' + randomid);\n";
816
										}
817
									}
818
									?>
819
									window.setTimeout('update_graph_images()', 355000);
820
								}
821
								window.setTimeout('update_graph_images()', 355000);
822
							//]]>
823
							</script>
824
						</td>
825
					</tr>
826
				</table>
827
				</div>
828
			</td>
829
		</tr>
830
	</table>
831
</form>
832
<?php include("fend.inc"); ?>
833
</body>
834
</html>
(194-194/252)