Project

General

Profile

Download (24.4 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
							$search = array("-", ".rrd", $optionc);
484
							$replace = array(" :: ", "", $friendly);
485
							echo "<option value=\"{$database}\"";
486
							$prettyprint = ucwords(str_replace($search, $replace, $database));
487
							if($curoption == $database) {
488
								echo " selected=\"selected\"";
489
							}
490
							echo ">" . htmlspecialchars($prettyprint) . "</option>\n";
491
						}
492
					}
493
					foreach ($ui_databases as $db => $database) {
494
						if(! preg_match("/($curcat)/i", $database))
495
							continue;
496

    
497
						if (($curcat == "captiveportal") && !empty($curzone) && !preg_match("/captiveportal-{$curzone}/i", $database))
498
							continue;
499

    
500
						$optionc = explode("-", $database);
501
						$search = array("-", ".rrd", $optionc);
502
						$replace = array(" :: ", "", $friendly);
503

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

    
533
					?>
534
					</select>
535

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

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

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

    
597
								if (($curcat == "captiveportal") && !empty($curzone) && !preg_match("/captiveportal-{$curzone}/i", $curdatabase))
598
									continue;
599

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

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