Project

General

Profile

Download (20.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
$home = getcwd();
55
$rrddbpath = "/var/db/rrd/";
56
chdir($rrddbpath);
57
$databases = glob("*.rrd");
58
chdir($home);
59

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

    
70
if ($_POST['cat']) {
71
	$curcat = htmlspecialchars($_POST['cat']);
72
}
73

    
74
if ($_GET['zone'])
75
	$curzone = $_GET['zone'];
76
else
77
	$curzone = '';
78

    
79
if ($_POST['period']) {
80
	$curperiod = $_POST['period'];
81
} else {
82
	if (!empty($config['rrd']['period'])) {
83
		$curperiod = $config['rrd']['period'];
84
	} else {
85
		$curperiod = "absolute";
86
	}
87
}
88

    
89
if ($_POST['style']) {
90
	$curstyle = $_POST['style'];
91
} else {
92
	if(! empty($config['rrd']['style'])) {
93
		$curstyle = $config['rrd']['style'];
94
	} else {
95
		$curstyle = "absolute";
96
	}
97
}
98

    
99
if ($_POST['option']) {
100
	$curoption = $_POST['option'];
101
} else {
102
	switch($curcat) {
103
		case "system":
104
			$curoption = "processor";
105
			break;
106
		case "queues":
107
			$curoption = "queues";
108
			break;
109
		case "queuedrops":
110
			$curoption = "queuedrops";
111
			break;
112
		case "quality":
113
			foreach ($databases as $database) {
114
				if (preg_match("/[-]quality\.rrd/i", $database)) {
115
					/* pick off the 1st database we find that matches the quality graph */
116
					$name = explode("-", $database);
117
					$curoption = "$name[0]";
118
					continue 2;
119
				}
120
			}
121
		case "wireless":
122
			foreach ($databases as $database) {
123
				if (preg_match("/[-]wireless\.rrd/i", $database)) {
124
					/* pick off the 1st database we find that matches the wireless graph */
125
					$name = explode("-", $database);
126
					$curoption = "$name[0]";
127
					continue 2;
128
				}
129
			}
130
		case "cellular":
131
			foreach ($databases as $database) {
132
				if (preg_match("/[-]cellular\.rrd/i", $database)) {
133
					/* pick off the 1st database we find that matches the celullar graph */
134
					$name = explode("-", $database);
135
					$curoption = "$name[0]";
136
					continue 2;
137
				}
138
			}
139
		case "vpnusers":
140
			foreach ($databases as $database) {
141
				if (preg_match("/[-]vpnusers\.rrd/i", $database)) {
142
					/* pick off the 1st database we find that matches the VPN graphs */
143
					$name = explode("-", $database);
144
					$curoption = "$name[0]";
145
					continue 2;
146
				}
147
			}
148
		case "captiveportal":
149
			$curoption = "allgraphs";
150
			break;
151
		case "ntpd":
152
			if (isset($config['ntpd']['statsgraph'])) {
153
				$curoption = "allgraphs";
154
			} else {
155
				$curoption = "processor";
156
				$curcat = "system";
157
			}
158
			break;
159
		default:
160
			$curoption = "wan";
161
			break;
162
	}
163
}
164

    
165
$now = time();
166
if ($curcat == "custom") {
167
	if (is_numeric($_GET['start'])) {
168
		if ($start < ($now - (3600 * 24 * 365 * 5))) {
169
			$start = $now - (8 * 3600);
170
		}
171

    
172
		$start = $_POST['start'];
173
	} else if ($_POST['start']) {
174
		$start = strtotime($_POST['start']);
175

    
176
		if ($start === FALSE || $start === -1) {
177
			$input_errors[] = gettext("Invalid start date/time:") . " '{$_POST['start']}'";
178

    
179
		$start = $now - (8 * 3600);
180
		}
181
	} else {
182
		$start = $now - (8 * 3600);
183
	}
184
}
185

    
186
if (is_numeric($_GET['end'])) {
187
	$end = $_GET['end'];
188
} else if ($_GET['end']) {
189
	$end = strtotime($_GET['end']);
190
	if ($end === FALSE || $end === -1) {
191
		$input_errors[] = gettext("Invalid end date/time:") . " '{$_POST['end']}'";
192

    
193
	$end = $now;
194
	}
195
} else {
196
	$end = $now;
197
}
198

    
199
/* this should never happen */
200
if ($end < $start) {
201
	log_error("start $start is smaller than end $end");
202
	$end = $now;
203
}
204

    
205
$seconds = $end - $start;
206

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

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

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

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

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

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

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

    
266
$closehead = false;
267

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

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

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

    
289
function get_dates($curperiod, $graph) {
290
	global $graph_length;
291
	$now = time();
292
	$end = $now;
293

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

    
304
		switch ($curperiod) {
305
			case "previous":
306
				$offset = -1;
307
				break;
308
			default:
309
				$offset = 0;
310
		}
311
		switch ($graph) {
312
			case "eighthour":
313
				if ($curhour < 24) {
314
					$starthour = 16;
315
				}
316
				if ($curhour < 16) {
317
					$starthour = 8;
318
				}
319
				if ($curhour < 8) {
320
					$starthour = 0;
321
				}
322

    
323
				switch ($offset) {
324
					case 0:
325
						$houroffset = $starthour;
326
						break;
327
					default:
328
						$houroffset = $starthour + ($offset * 8);
329
						break;
330
				}
331
				$start = mktime($houroffset, 0, 0, $curmonth, $curday, $curyear);
332
				if ($offset != 0) {
333
					$end = mktime(($houroffset + 8), 0, 0, $curmonth, $curday, $curyear);
334
				}
335
				break;
336
			case "day":
337
				$start = mktime(0, 0, 0, $curmonth, ($curday + $offset), $curyear);
338
				if ($offset != 0) {
339
					$end = mktime(0, 0, 0, $curmonth, (($curday + $offset) + 1), $curyear);
340
				}
341
				break;
342
			case "week":
343
				switch ($offset) {
344
					case 0:
345
						$weekoffset = 0;
346
						break;
347
					default:
348
						$weekoffset = ($offset * 7) - 7;
349
						break;
350
				}
351
				$start = mktime(0, 0, 0, $curmonth, (($curday - $curweekday) + $weekoffset), $curyear);
352
				if ($offset != 0) {
353
					$end = mktime(0, 0, 0, $curmonth, (($curday - $curweekday) + $weekoffset + 7), $curyear);
354
				}
355
				break;
356
			case "month":
357
				$start = mktime(0, 0, 0, ($curmonth + $offset), 0, $curyear);
358
				if ($offset != 0) {
359
					$end = mktime(0, 0, 0, (($curmonth + $offset) + 1), 0, $curyear);
360
				}
361
				break;
362
			case "quarter":
363
				$start = mktime(0, 0, 0, (($curmonth - 2) + $offset), 0, $curyear);
364
				if ($offset != 0) {
365
					$end = mktime(0, 0, 0, (($curmonth + $offset) + 1), 0, $curyear);
366
				}
367
				break;
368
			case "year":
369
				$start = mktime(0, 0, 0, 1, 0, ($curyear + $offset));
370
				if ($offset != 0) {
371
					$end = mktime(0, 0, 0, 1, 0, (($curyear + $offset) +1));
372
				}
373
				break;
374
			case "fouryear":
375
				$start = mktime(0, 0, 0, 1, 0, (($curyear - 3) + $offset));
376
				if ($offset != 0) {
377
					$end = mktime(0, 0, 0, 1, 0, (($curyear + $offset) +1));
378
				}
379
				break;
380
		}
381
	}
382
	// 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 />";
383
	$dates = array();
384
	$dates['start'] = $start;
385
	$dates['end'] = $end;
386
	return $dates;
387
}
388

    
389
function make_tabs() {
390
	global $curcat;
391

    
392
	$tab_array = array();
393
	$tab_array[] = array(gettext("System"), ($curcat == "system"), "status_rrd_graph.php?cat=system");
394
	$tab_array[] = array(gettext("Traffic"), ($curcat == "traffic"), "status_rrd_graph.php?cat=traffic");
395
	$tab_array[] = array(gettext("Packets"), ($curcat == "packets"), "status_rrd_graph.php?cat=packets");
396
	$tab_array[] = array(gettext("Quality"), ($curcat == "quality"), "status_rrd_graph.php?cat=quality");
397

    
398
	if($queues) {
399
		$tab_array[] = array(gettext("Queues"), ($curcat == "queues"), "status_rrd_graph.php?cat=queues");
400
		$tab_array[] = array(gettext("QueueDrops"), ($curcat == "queuedrops"), "status_rrd_graph.php?cat=queuedrops");
401
	}
402

    
403
	if($wireless) {
404
		$tab_array[] = array(gettext("Wireless"), ($curcat == "wireless"), "status_rrd_graph.php?cat=wireless");
405
	}
406

    
407
	if($cellular) {
408
		$tab_array[] = array(gettext("Cellular"), ($curcat == "cellular"), "status_rrd_graph.php?cat=cellular");
409
	}
410

    
411
	if($vpnusers) {
412
		$tab_array[] = array(gettext("VPN"), ($curcat == "vpnusers"), "status_rrd_graph.php?cat=vpnusers");
413
	}
414

    
415
	if($captiveportal) {
416
		$tab_array[] = array(gettext("Captive Portal"), ($curcat == "captiveportal"), "status_rrd_graph.php?cat=captiveportal");
417
	}
418

    
419
	if(isset($config['ntpd']['statsgraph'])) {
420
		$tab_array[] = array("NTP", ($curcat == "ntpd"), "status_rrd_graph.php?cat=ntpd");
421
	}
422

    
423
	$tab_array[] = array(gettext("Custom"), ($curcat == "custom"), "status_rrd_graph.php?cat=custom");
424
	$tab_array[] = array(gettext("Settings"), ($curcat == "settings"), "status_rrd_graph_settings.php");
425

    
426
	return($tab_array);
427
}
428

    
429
// Create the selectable list of graphs
430
function build_options() {
431
	global $curcat, $custom_databases, $ui_databases;
432

    
433
	$optionslist = array();
434

    
435
	if($curcat == "custom") {
436
		foreach ($custom_databases as $db => $database) {
437
			$optionc = explode("-", $database);
438
			$friendly = convert_friendly_interface_to_friendly_descr(strtolower($optionc[0]));
439
			if (empty($friendly)) {
440
				$friendly = $optionc[0];
441
			}
442

    
443
			$search = array("-", ".rrd", $optionc[0]);
444
			$replace = array(" :: ", "", $friendly);
445
			$prettyprint = ucwords(str_replace($search, $replace, $database));
446
			$optionslist[$database] = htmlspecialchars($prettyprint);
447
			}
448
		}
449

    
450
	foreach ($ui_databases as $db => $database) {
451
		if(! preg_match("/($curcat)/i", $database))
452
			continue;
453

    
454
		if (($curcat == "captiveportal") && !empty($curzone) && !preg_match("/captiveportal-{$curzone}/i", $database))
455
			continue;
456

    
457
		$optionc = explode("-", $database);
458
		$search = array("-", ".rrd", $optionc);
459
		$replace = array(" :: ", "", $friendly);
460

    
461
		switch($curcat) {
462
			case "captiveportal":
463
				$optionc = str_replace($search, $replace, $optionc[2]);
464
				$prettyprint = ucwords(str_replace($search, $replace, $optionc));
465
				$optionslist[$optionc] = htmlspecialchars($prettyprint);
466
				break;
467
			case "system":
468
				$optionc = str_replace($search, $replace, $optionc[1]);
469
				$prettyprint = ucwords(str_replace($search, $replace, $optionc));
470
				$optionslist[$optionc] = htmlspecialchars($prettyprint);
471
				break;
472
			default:
473
				/* Deduce an interface if possible and use the description */
474
				$optionc = "$optionc[0]";
475
				$friendly = convert_friendly_interface_to_friendly_descr(strtolower($optionc));
476
				if(empty($friendly)) {
477
					$friendly = $optionc;
478
				}
479
				$search = array("-", ".rrd", $optionc);
480
				$replace = array(" :: ", "", $friendly);
481
				$prettyprint = ucwords(str_replace($search, $replace, $friendly));
482
				$optionslist[$optionc] = htmlspecialchars($prettyprint);
483
		}
484
	}
485

    
486
	return($optionslist);
487
}
488
include("head.inc");
489

    
490
display_top_tabs(make_tabs());
491

    
492
if ($input_errors && count($input_errors))
493
	print_input_errors($input_errors);
494

    
495
require('classes/Form.class.php');
496

    
497
$form = new Form(new Form_Button(
498
	'submit',
499
	'Go!'
500
	));
501

    
502
$form->addClass('auto-submit');
503

    
504
$section = new Form_Section('Graph settings');
505

    
506
$group = new Form_Group('Options');
507

    
508
$group->add(new Form_Select(
509
	'option',
510
	'Graphs',
511
	$curoption,
512
	build_options()
513
))->setHelp('Graph');
514

    
515
$group->add(new Form_Select(
516
	'style',
517
	'Style',
518
	$curstyle,
519
	$styles
520
))->setHelp('Style');
521

    
522
$group->add(new Form_Select(
523
	'period',
524
	'Period',
525
	$curperiod,
526
	$periods
527
))->setHelp('Period');
528

    
529
if($curcat == 'custom')
530
	$group->setHelp('Any changes to these option may not take affect until the next auto-refresh.');
531

    
532
$section->add($group);
533

    
534
if($curcat == 'custom') {
535

    
536
	$section->addInput(new Form_Input(
537
		'cat',
538
		null,
539
		'hidden',
540
		'custom'
541
	 ));
542

    
543
	$tz = date_default_timezone_get();
544
	$tz_msg = gettext("Enter date and/or time. Current timezone:") . " $tz";
545
	$start_fmt = strftime("%m/%d/%Y %H:%M:%S", $start);
546
	$end_fmt   = strftime("%m/%d/%Y %H:%M:%S", $end);
547

    
548
	$group = new Form_Group('');
549

    
550
	$group->add(new Form_Input(
551
		'start',
552
		'Start',
553
		'datetime',
554
		$start_fmt
555
	))->setHelp('Start');
556

    
557
	$group->add(new Form_Input(
558
		'end',
559
		'End',
560
		'datetime',
561
		$end_fmt
562
	))->setHelp('End');
563

    
564
	if($curcat != 'custom')
565
		$group->setHelp('Any changes to these option may not take affect until the next auto-refresh');
566

    
567
	$section->add($group);
568

    
569
	$form->add($section);
570
	print($form);
571

    
572
	$curdatabase = $curoption;
573
	$graph = "custom-$curdatabase";
574
	if(in_array($curdatabase, $custom_databases)) {
575
		$id = "{$graph}-{$curoption}-{$curdatabase}";
576
		$id = preg_replace('/\./', '_', $id);
577
?>
578
		<div class="panel panel-default">
579
			<img align="center" name="<?=$id?>" id="<?=$id?>" alt="<?=$prettydb?> Graph" src="status_rrd_graph_img.php?start=<?=$start?>&amp;end={<?=$end?>&amp;database=<?=$curdatabase?>&amp;style=<?=$curstyle?>&amp;graph=<?=$graph?>" />
580
		</div>
581
<?php
582

    
583
	}
584
} else {
585
	$form->add($section);
586
	print($form);
587

    
588
	foreach($graphs as $graph) {
589
		/* check which databases are valid for our category */
590
		foreach($ui_databases as $curdatabase) {
591
			if(! preg_match("/($curcat)/i", $curdatabase))
592
				continue;
593

    
594
			if (($curcat == "captiveportal") && !empty($curzone) && !preg_match("/captiveportal-{$curzone}/i", $curdatabase))
595
				continue;
596

    
597
			$optionc = explode("-", $curdatabase);
598
			$search = array("-", ".rrd", $optionc);
599
			$replace = array(" :: ", "", $friendly);
600

    
601
			switch($curoption) {
602
				case "outbound":
603
					/* make sure we do not show the placeholder databases in the outbound view */
604
					if((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) {
605
						continue 2;
606
					}
607
					/* only show interfaces with a gateway */
608
					$optionc = "$optionc[0]";
609
					if(!interface_has_gateway($optionc)) {
610
						if(!isset($gateways_arr)) {
611
							if(preg_match("/quality/i", $curdatabase))
612
								$gateways_arr = return_gateways_array();
613
							else
614
								$gateways_arr = array();
615
						}
616
						$found_gateway = false;
617
						foreach ($gateways_arr as $gw) {
618
							if ($gw['name'] == $optionc) {
619
								$found_gateway = true;
620
								break;
621
							}
622
						}
623
						if(!$found_gateway) {
624
							continue 2;
625
						}
626
					}
627

    
628
					if(! preg_match("/(^$optionc-|-$optionc\\.)/i", $curdatabase)) {
629
						continue 2;
630
					}
631
					break;
632
				case "allgraphs":
633
					/* make sure we do not show the placeholder databases in the all view */
634
					if((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) {
635
						continue 2;
636
					}
637
					break;
638
				default:
639
					/* just use the name here */
640
					if(! preg_match("/(^$curoption-|-$curoption\\.)/i", $curdatabase)) {
641
						continue 2;
642
					}
643
			}
644

    
645
			if(in_array($curdatabase, $ui_databases)) {
646
				$id = "{$graph}-{$curoption}-{$curdatabase}";
647
				$id = preg_replace('/\./', '_', $id);
648

    
649
				$dates = get_dates($curperiod, $graph);
650
				$start = $dates['start'];
651
				$end = $dates['end'];
652
?>
653
				<div class="panel panel-default" align="center">
654
					<img name="<?=$id?>" id="<?=$id?>" alt="<?=$prettydb?> Graph" src="status_rrd_graph_img.php?start=<?=$start?>&amp;end={<?=$end?>&amp;database=<?=$curdatabase?>&amp;style=<?=$curstyle?>&amp;graph=<?=$graph?>" />
655
				</div>
656
<?php
657
			}
658
		}
659
	}
660
}
661

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

    
728
				echo "\n";
729
				echo "\t\tjQuery('#{$id}').attr('src','status_rrd_graph_img.php?start={$start}&graph={$graph}&database={$curdatabase}&style={$curstyle}&tmp=' + randomid);\n";
730
				}
731
			}
732
		?>
733
		window.setTimeout('update_graph_images()', 355000);
734
	}
735
	window.setTimeout('update_graph_images()', 355000);
736
//]]>
737
</script>
738

    
739
<script>
740
events.push(function(){
741
	$('.auto-submit').on('change', function(){
742
		$(this).submit();
743
	});
744
});
745
</script>
746

    
747
<?php include("foot.inc");
(181-181/238)