Project

General

Profile

Download (22.6 KB) Statistics
| Branch: | Tag: | Revision:
1 37285f69 Scott Ullrich
<?php
2
/* $Id$ */
3
/*
4
	status_rrd_graph.php
5
	Part of pfSense
6 6216690b smos
	Copyright (C) 2007 Seth Mos <seth.mos@dds.nl>
7 37285f69 Scott Ullrich
	All rights reserved.
8
9
	Redistribution and use in source and binary forms, with or without
10
	modification, are permitted provided that the following conditions are met:
11
12
	1. Redistributions of source code must retain the above copyright notice,
13
	   this list of conditions and the following disclaimer.
14
15
	2. Redistributions in binary form must reproduce the above copyright
16
	   notice, this list of conditions and the following disclaimer in the
17
	   documentation and/or other materials provided with the distribution.
18
19
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
20
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
21
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
23
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
	POSSIBILITY OF SUCH DAMAGE.
29
*/
30 1d333258 Scott Ullrich
/*	
31
	pfSense_MODULE:	system
32
*/
33 37285f69 Scott Ullrich
34 6b07c15a Matthew Grooms
##|+PRIV
35
##|*IDENT=page-status-rrdgraphs
36
##|*NAME=Status: RRD Graphs page
37
##|*DESCR=Allow access to the 'Status: RRD Graphs' page.
38
##|*MATCH=status_rrd_graph.php*
39
##|-PRIV
40
41 37285f69 Scott Ullrich
require("guiconfig.inc");
42 5208e648 Ermal Lu?i
require_once("filter.inc");
43
require("shaper.inc");
44 483e6de8 Scott Ullrich
require_once("rrd.inc");
45 37285f69 Scott Ullrich
46 59418cee Darren Embry
unset($input_errors);
47
48 70281b3a Seth Mos
/* if the rrd graphs are not enabled redirect to settings page */
49
if(! isset($config['rrd']['enable'])) {
50
	header("Location: status_rrd_graph_settings.php");
51
}
52
53 329bb764 Seth Mos
$rrddbpath = "/var/db/rrd/";
54 002bc4ab smos
chdir($rrddbpath);
55
$databases = glob("*.rrd");
56
57 329bb764 Seth Mos
58 89d25faf Seth Mos
if ($_GET['cat']) {
59 034f08e7 Scott Ullrich
	$curcat = htmlspecialchars($_GET['cat']);
60 37285f69 Scott Ullrich
} else {
61 69487053 Seth Mos
	if(! empty($config['rrd']['category'])) {
62
		$curcat = $config['rrd']['category'];
63
	} else {
64
		$curcat = "system";
65
	}
66 89d25faf Seth Mos
}
67
68 7d906758 smos
if ($_GET['period']) {
69
	$curperiod = $_GET['period'];
70
} else {
71 97acf646 Erik Fonnesbeck
	if(! empty($config['rrd']['period'])) {
72
		$curperiod = $config['rrd']['period'];
73
	} else {
74
		$curperiod = "absolute";
75
	}
76 7d906758 smos
}
77
78 89d25faf Seth Mos
if ($_GET['option']) {
79
	$curoption = $_GET['option'];
80
} else {
81 329bb764 Seth Mos
	switch($curcat) {
82
		case "system":
83
			$curoption = "processor";
84
			break;
85
		case "queues":
86
			$curoption = "queues";
87
			break;
88
		case "queuedrops":
89
			$curoption = "queuedrops";
90 7432ce7b Seth Mos
			break;
91
		case "quality":
92
			foreach($databases as $database) {
93
				if(preg_match("/[-]quality\.rrd/i", $database)) {
94
					/* pick off the 1st database we find that matches the quality graph */
95
					$name = explode("-", $database);
96
					$curoption = "$name[0]";
97
					continue 2;
98
				}
99
			}
100
		case "wireless":
101
			foreach($databases as $database) {
102
				if(preg_match("/[-]wireless\.rrd/i", $database)) {
103
					/* pick off the 1st database we find that matches the wireless graph */
104
					$name = explode("-", $database);
105
					$curoption = "$name[0]";
106
					continue 2;
107
				}
108
			}
109
		case "cellular":
110
			foreach($databases as $database) {
111
				if(preg_match("/[-]cellular\.rrd/i", $database)) {
112
					/* pick off the 1st database we find that matches the celullar graph */
113
					$name = explode("-", $database);
114
					$curoption = "$name[0]";
115
					continue 2;
116
				}
117 329bb764 Seth Mos
			}
118 edd2d8b7 smos
		case "vpnusers":
119 6b0c5ae6 smos
			foreach($databases as $database) {
120 edd2d8b7 smos
				if(preg_match("/[-]vpnusers\.rrd/i", $database)) {
121 6b0c5ae6 smos
					/* pick off the 1st database we find that matches the VPN graphs */
122
					$name = explode("-", $database);
123
					$curoption = "$name[0]";
124
					continue 2;
125
				}
126
			}
127 20413b72 Warren Baker
		case "captiveportal":
128
			$curoption = "allgraphs";
129
			break;
130 329bb764 Seth Mos
		default:
131
			$curoption = "wan";
132
			break;
133 89d25faf Seth Mos
	}
134 37285f69 Scott Ullrich
}
135
136 6b0c5ae6 smos
$now = time();
137 47e68f48 smos
if($curcat == "custom") {
138
	if (is_numeric($_GET['start'])) {
139 59418cee Darren Embry
		if($start < ($now - (3600 * 24 * 365 * 5))) {
140
			$start = $now - (8 * 3600);
141
		}
142
		$start = $_GET['start'];
143
	} else if ($_GET['start']) {
144
		$start = strtotime($_GET['start']);
145
		if ($start === FALSE || $start === -1) {
146
			$input_errors[] = gettext("Invalid start date/time:") . " '{$_GET['start']}'";
147 c7cfbbd8 smos
			$start = $now - (8 * 3600);
148 59418cee Darren Embry
		}
149
	} else {
150
		$start = $now - (8 * 3600);
151 47e68f48 smos
	}
152
}
153
154
if (is_numeric($_GET['end'])) {
155
        $end = $_GET['end'];
156 59418cee Darren Embry
} else if ($_GET['end']) {
157
	$end = strtotime($_GET['end']);
158
	if ($end === FALSE || $end === -1) {
159
		$input_errors[] = gettext("Invalid end date/time:") . " '{$_GET['end']}'";
160
		$end = $now;
161
	}
162 47e68f48 smos
} else {
163
        $end = $now;
164
}
165
166
/* this should never happen */
167
if($end < $start) {
168 c7cfbbd8 smos
	log_error("start $start is smaller than end $end");
169 47e68f48 smos
        $end = $now;
170
}
171
172
$seconds = $end - $start;
173 5d7791a2 Scott Ullrich
174
$styles = array('inverse' => gettext('Inverse'),
175
		'absolute' => gettext('Absolute'));
176
177
// Set default and override later
178
$curstyle = "inverse";
179
180 6ab7ae50 Seth Mos
if ($_GET['style']) {
181 5d7791a2 Scott Ullrich
	foreach($styles as $style) 
182 4ec48253 Scott Ullrich
		if(strtoupper($style) == strtoupper($_GET['style'])) 
183 5d7791a2 Scott Ullrich
			$curstyle = $_GET['style'];
184 37285f69 Scott Ullrich
} else {
185 69487053 Seth Mos
	if(! empty($config['rrd']['style'])) {
186
		$curstyle = $config['rrd']['style'];
187
	} else {
188
		$curstyle = "inverse";
189
	}
190 37285f69 Scott Ullrich
}
191
192 329bb764 Seth Mos
/* sort names reverse so WAN comes first */
193 6ab7ae50 Seth Mos
rsort($databases);
194 37285f69 Scott Ullrich
195 9850b625 Seth Mos
/* these boilerplate databases are required for the other menu choices */
196
$dbheader = array("allgraphs-traffic.rrd",
197
		"allgraphs-quality.rrd",
198 2f80d451 Seth Mos
		"allgraphs-wireless.rrd",
199 ec51a222 thompsa
		"allgraphs-cellular.rrd",
200 edd2d8b7 smos
		"allgraphs-vpnusers.rrd",
201 20413b72 Warren Baker
		"captiveportal-allgraphs.rrd",
202 9850b625 Seth Mos
		"allgraphs-packets.rrd",
203
		"system-allgraphs.rrd",
204 e3d7c123 Seth Mos
		"system-throughput.rrd",
205 9850b625 Seth Mos
		"outbound-quality.rrd",
206
		"outbound-packets.rrd",
207
		"outbound-traffic.rrd");
208
209 9cd5e6f5 Erik Fonnesbeck
/* additional menu choices for the custom tab */
210
$dbheader_custom = array("system-throughput.rrd");
211
212 7432ce7b Seth Mos
foreach($databases as $database) {
213 edd2d8b7 smos
	if(stristr($database, "-wireless")) {
214 7432ce7b Seth Mos
		$wireless = true;
215
	}
216 edd2d8b7 smos
	if(stristr($database, "-queues")) {
217 7432ce7b Seth Mos
		$queues = true;
218
	}
219 17a71003 Ermal
	if(stristr($database, "-cellular") && !empty($config['ppps'])) {
220 7432ce7b Seth Mos
		$cellular = true;
221
	}
222 edd2d8b7 smos
	if(stristr($database, "-vpnusers")) {
223
		$vpnusers = true;
224 6b0c5ae6 smos
	}
225 20413b72 Warren Baker
	if(stristr($database, "captiveportal-") && isset($config['captiveportal']['enable'])) {
226
		$captiveportal = true;
227
	}
228 7432ce7b Seth Mos
}
229 9850b625 Seth Mos
/* append the existing array to the header */
230 a927edff Seth Mos
$ui_databases = array_merge($dbheader, $databases);
231 9cd5e6f5 Erik Fonnesbeck
$custom_databases = array_merge($dbheader_custom, $databases);
232 9850b625 Seth Mos
233 c7cfbbd8 smos
$graphs = array("8hour", "day", "week", "month", "quarter", "year", "4year");
234 97acf646 Erik Fonnesbeck
$periods = array("absolute" => gettext("Absolute Timespans"), "current" => gettext("Current Period"), "previous" => gettext("Previous Period"));
235
$graph_length = array(
236
	"8hour" => 28800,
237
	"day" => 86400,
238
	"week" => 604800,
239
	"month" => 2764800,
240
	"quarter" => 8035200,
241
	"year" => 31622400,
242
	"4year" => 126489600);
243 6ab7ae50 Seth Mos
244 1d80829e Carlos Eduardo Ramos
$pgtitle = array(gettext("Status"),gettext("RRD Graphs"));
245 ce49a7c9 Darren Embry
246
$closehead = false;
247 89d25faf Seth Mos
include("head.inc");
248 ce49a7c9 Darren Embry
?>
249
250
<?php if ($curcat === "custom") { ?>
251
	<link rel="stylesheet" type="text/css" href="/javascript/jquery-ui-timepicker-addon/css/jquery-ui-timepicker-addon.css" />
252 31d6f24b Darren Embry
	<?php if (file_exists("{$g['www_path']}/themes/{$g['theme']}/jquery-ui.custom.css")) { ?>
253
		<link rel="stylesheet" type="text/css" href="/themes/<?= $g['theme'] ?>/jquery-ui.custom.css" />
254
	<?php } else { ?>
255
		<link rel="stylesheet" type="text/css" href="/javascript/jquery/jquery-ui.custom.css" />
256
	<?php } ?>
257 ce49a7c9 Darren Embry
	<script type="text/javascript" src="/javascript/jquery-ui-timepicker-addon/js/jquery-ui-timepicker-addon.js"></script>
258
	<script type="text/javascript">
259
		jQuery(function ($) {
260
			var options = {
261
				dateFormat: 'mm/dd/yy',
262
				timeFormat: 'hh:mm:ss',
263
				showSecond: true
264
			};
265
			$("#startDateTime").datetimepicker(options);
266
			$("#endDateTime").datetimepicker(options);
267
		});
268
	</script>
269
	</head>
270
<?php } ?>
271
272
<?php
273 6ab7ae50 Seth Mos
274 7d906758 smos
function get_dates($curperiod, $graph) {
275 97acf646 Erik Fonnesbeck
	global $graph_length;
276 7d906758 smos
	$now = time();
277
	$end = $now;
278
279 97acf646 Erik Fonnesbeck
	if($curperiod == "absolute") {
280
		$start = $end - $graph_length[$graph];
281
	} else {
282
		$curyear = date('Y', $now);
283
		$curmonth = date('m', $now);
284
		$curweek = date('W', $now);
285
		$curweekday = date('N', $now) - 1; // We want to start on monday
286
		$curday = date('d', $now);
287
		$curhour = date('G', $now);
288 c7cfbbd8 smos
289 97acf646 Erik Fonnesbeck
		switch($curperiod) {
290
			case "previous":
291
				$offset = -1;
292
				break;
293
			default:
294
				$offset = 0;
295
		}
296
		switch($graph) {
297
			case "8hour":
298
				if($curhour < 24)
299
					$starthour = 16;
300
				if($curhour < 16)
301
					$starthour = 8;
302
				if($curhour < 8)
303
					$starthour = 0;
304
305
				switch($offset) {
306
					case 0:
307
						$houroffset = $starthour;
308
						break;
309
					default:
310
						$houroffset = $starthour + ($offset * 8);
311
						break;
312
				}
313
				$start = mktime($houroffset, 0, 0, $curmonth, $curday, $curyear);
314
				if($offset != 0) {
315
					$end = mktime(($houroffset + 8), 0, 0, $curmonth, $curday, $curyear);
316
				}
317
				break;
318
			case "day":
319
				$start = mktime(0, 0, 0, $curmonth, ($curday + $offset), $curyear);
320
				if($offset != 0)
321
					$end = mktime(0, 0, 0, $curmonth, (($curday + $offset) + 1), $curyear);
322
				break;
323
			case "week":
324
				switch($offset) {
325
					case 0:
326
						$weekoffset = 0;
327
						break;
328
					default:
329
						$weekoffset = ($offset * 7) - 7;
330
						break;
331
				}
332
				$start = mktime(0, 0, 0, $curmonth, (($curday - $curweekday) + $weekoffset), $curyear);
333
				if($offset != 0)
334
					$end = mktime(0, 0, 0, $curmonth, (($curday - $curweekday) + $weekoffset + 7), $curyear);
335
				break;
336
			case "month":
337
				$start = mktime(0, 0, 0, ($curmonth + $offset), 0, $curyear);
338
				if($offset != 0)
339
					$end = mktime(0, 0, 0, (($curmonth + $offset) + 1), 0, $curyear);
340
				break;
341
			case "quarter":
342
				$start = mktime(0, 0, 0, (($curmonth - 2) + $offset), 0, $curyear);
343
				if($offset != 0)
344
					$end = mktime(0, 0, 0, (($curmonth + $offset) + 1), 0, $curyear);
345
				break;
346
			case "year":
347
				$start = mktime(0, 0, 0, 1, 0, ($curyear + $offset));
348
				if($offset != 0)
349
					$end = mktime(0, 0, 0, 1, 0, (($curyear + $offset) +1));
350
				break;
351
			case "4year":
352
				$start = mktime(0, 0, 0, 1, 0, (($curyear - 3) + $offset));
353
				if($offset != 0)
354
					$end = mktime(0, 0, 0, 1, 0, (($curyear + $offset) +1));
355
				break;
356
		}
357 7d906758 smos
	}
358 6a8cf738 smos
	// 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>";
359 7d906758 smos
	$dates = array();
360
	$dates['start'] = $start;
361
	$dates['end'] = $end;
362
	return $dates;
363
}
364
365 6ab7ae50 Seth Mos
?>
366 37285f69 Scott Ullrich
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
367
<?php include("fbegin.inc"); ?>
368 59418cee Darren Embry
<?php if ($input_errors && count($input_errors)) { print_input_errors($input_errors); } ?>
369 89d25faf Seth Mos
<table width="100%" border="0" cellpadding="0" cellspacing="0">
370
        <tr>
371
                <td>
372
			<form name="form1" action="status_rrd_graph.php" method="get">
373
			<input type="hidden" name="cat" value="<?php echo "$curcat"; ?>">
374
			<?php
375
			        $tab_array = array();
376
				if($curcat == "system") { $tabactive = True; } else { $tabactive = False; }
377 4dea46ee Rafael Lucas
			        $tab_array[] = array(gettext("System"), $tabactive, "status_rrd_graph.php?cat=system");
378 89d25faf Seth Mos
				if($curcat == "traffic") { $tabactive = True; } else { $tabactive = False; }
379 4dea46ee Rafael Lucas
			        $tab_array[] = array(gettext("Traffic"), $tabactive, "status_rrd_graph.php?cat=traffic");
380 89d25faf Seth Mos
				if($curcat == "packets") { $tabactive = True; } else { $tabactive = False; }
381 4dea46ee Rafael Lucas
			        $tab_array[] = array(gettext("Packets"), $tabactive, "status_rrd_graph.php?cat=packets");
382 89d25faf Seth Mos
				if($curcat == "quality") { $tabactive = True; } else { $tabactive = False; }
383 4dea46ee Rafael Lucas
			        $tab_array[] = array(gettext("Quality"), $tabactive, "status_rrd_graph.php?cat=quality");
384 7432ce7b Seth Mos
				if($queues) {
385
					if($curcat == "queues") { $tabactive = True; } else { $tabactive = False; }
386 d9a0c4b8 Vinicius Coque
						$tab_array[] = array(gettext("Queues"), $tabactive, "status_rrd_graph.php?cat=queues");
387 7432ce7b Seth Mos
					if($curcat == "queuedrops") { $tabactive = True; } else { $tabactive = False; }
388 d9a0c4b8 Vinicius Coque
						$tab_array[] = array(gettext("QueueDrops"), $tabactive, "status_rrd_graph.php?cat=queuedrops");
389 7432ce7b Seth Mos
				}
390
				if($wireless) {
391
					if($curcat == "wireless") { $tabactive = True; } else { $tabactive = False; }
392 4dea46ee Rafael Lucas
				        $tab_array[] = array(gettext("Wireless"), $tabactive, "status_rrd_graph.php?cat=wireless");
393 7432ce7b Seth Mos
				}
394
				if($cellular) {
395
					if($curcat == "cellular") { $tabactive = True; } else { $tabactive = False; }
396 4dea46ee Rafael Lucas
				        $tab_array[] = array(gettext("Cellular"), $tabactive, "status_rrd_graph.php?cat=cellular");
397 7432ce7b Seth Mos
				}
398 edd2d8b7 smos
				if($vpnusers) {
399
					if($curcat == "vpnusers") { $tabactive = True; } else { $tabactive = False; }
400
				        $tab_array[] = array("VPN", $tabactive, "status_rrd_graph.php?cat=vpnusers");
401 6b0c5ae6 smos
				}
402 20413b72 Warren Baker
				if($captiveportal) {
403
					if($curcat == "captiveportal") { $tabactive = True; } else { $tabactive = False; }
404
				        $tab_array[] = array("Captive Portal", $tabactive, "status_rrd_graph.php?cat=captiveportal");
405
				}
406 47e68f48 smos
				if($curcat == "custom") { $tabactive = True; } else { $tabactive = False; }
407 4dea46ee Rafael Lucas
			        $tab_array[] = array(gettext("Custom"), $tabactive, "status_rrd_graph.php?cat=custom");
408 69487053 Seth Mos
				if($curcat == "settings") { $tabactive = True; } else { $tabactive = False; }
409 4dea46ee Rafael Lucas
			        $tab_array[] = array(gettext("Settings"), $tabactive, "status_rrd_graph_settings.php");
410 89d25faf Seth Mos
			        display_top_tabs($tab_array);
411
			?>
412
                </td>
413
        </tr>
414
        <tr>
415
                <td>
416
                        <div id="mainarea">
417
                        <table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="0">
418
                                <tr>
419
                                        <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>
420
				</tr>
421
				<tr>
422
                                        <td colspan="2" class="list">
423 3e6ec5df Renato Botelho
					<?=gettext("Graphs:");?>
424 89d25faf Seth Mos
					<select name="option" class="formselect" style="z-index: -10;" onchange="document.form1.submit()">
425
					<?php
426
427 47e68f48 smos
					if($curcat == "custom") {
428 9cd5e6f5 Erik Fonnesbeck
						foreach ($custom_databases as $db => $database) {
429 cfbfd941 smos
							$optionc = explode("-", $database);
430 47e68f48 smos
							$search = array("-", ".rrd", $optionc);
431
							$replace = array(" :: ", "", $friendly);
432
							echo "<option value=\"{$database}\"";
433
							$prettyprint = ucwords(str_replace($search, $replace, $database));
434
							if($curoption == $database) {
435 1d80829e Carlos Eduardo Ramos
								echo " selected";
436 47e68f48 smos
							}
437
							echo ">" . htmlspecialchars($prettyprint) . "</option>\n";
438
						}
439
					}
440 a927edff Seth Mos
					foreach ($ui_databases as $db => $database) {
441 2ab73e04 Seth Mos
						if(! preg_match("/($curcat)/i", $database)) {
442 89d25faf Seth Mos
							continue;
443
						}
444 cfbfd941 smos
						$optionc = explode("-", $database);
445 89d25faf Seth Mos
						$search = array("-", ".rrd", $optionc);
446 35551994 Seth Mos
						$replace = array(" :: ", "", $friendly);
447 47e68f48 smos
448 9850b625 Seth Mos
						switch($curcat) {
449 20413b72 Warren Baker
							case "captiveportal":
450
								$optionc = str_replace($search, $replace, $optionc[1]);
451
								echo "<option value=\"$optionc\"";
452
								$prettyprint = ucwords(str_replace($search, $replace, $optionc));
453
								break;
454 9850b625 Seth Mos
							case "system":
455 85a4aab6 Erik Fonnesbeck
								$optionc = str_replace($search, $replace, $optionc[1]);
456
								echo "<option value=\"$optionc\"";
457
								$prettyprint = ucwords(str_replace($search, $replace, $optionc));
458 9850b625 Seth Mos
								break;
459
							default:
460
								/* Deduce a interface if possible and use the description */
461
								$optionc = "$optionc[0]";
462
								$friendly = convert_friendly_interface_to_friendly_descr(strtolower($optionc));
463 d9699f96 Seth Mos
								if(empty($friendly)) {
464
									$friendly = $optionc;
465
								}
466 9850b625 Seth Mos
								$search = array("-", ".rrd", $optionc);
467
								$replace = array(" :: ", "", $friendly);
468
								echo "<option value=\"$optionc\"";
469
								$prettyprint = ucwords(str_replace($search, $replace, $friendly));
470
						}
471
						if($curoption == $optionc) {
472 1d80829e Carlos Eduardo Ramos
							echo " selected";
473 89d25faf Seth Mos
						}
474
						echo ">" . htmlspecialchars($prettyprint) . "</option>\n";
475
					}
476
477
					?>
478
					</select>
479
480 3e6ec5df Renato Botelho
					<?=gettext("Style:");?>
481 89d25faf Seth Mos
					<select name="style" class="formselect" style="z-index: -10;" onchange="document.form1.submit()">
482
					<?php
483
					foreach ($styles as $style => $styled) {
484
						echo "<option value=\"$style\"";
485
						if ($style == $curstyle) echo " selected";
486
						echo ">" . htmlspecialchars($styled) . "</option>\n";
487
					}
488
					?>
489 7d906758 smos
					</select>
490
					
491 e4b57d26 Renato Botelho
					<?php
492 47e68f48 smos
					if($curcat <> "custom") {
493
					?>
494 3e6ec5df Renato Botelho
						<?=gettext("Period:");?>
495 47e68f48 smos
						<select name="period" class="formselect" style="z-index: -10;" onchange="document.form1.submit()">
496
						<?php
497
						foreach ($periods as $period => $value) {
498
							echo "<option value=\"$period\"";
499 1d80829e Carlos Eduardo Ramos
							if ($period == $curperiod) echo " selected";
500 47e68f48 smos
							echo ">" . htmlspecialchars($value) . "</option>\n";
501
						}
502 7d906758 smos
					}
503
					?>
504 89d25faf Seth Mos
					</select>
505
					<?php
506
507 47e68f48 smos
					if($curcat == "custom") {
508 59418cee Darren Embry
						$tz = date_default_timezone_get();
509
						$tz_msg = gettext("Enter date and/or time. Current timezone:") . " $tz";
510 ce49a7c9 Darren Embry
						$start_fmt = strftime("%m/%d/%Y %H:%M:%S", $start);
511
						$end_fmt   = strftime("%m/%d/%Y %H:%M:%S", $end);
512 6b0c5ae6 smos
						?>
513
						<?=gettext("Start:");?>
514 ce49a7c9 Darren Embry
						<input id="startDateTime" title="<?= htmlentities($tz_msg); ?>." type="text" name="start" class="formfldunknown" size="24" length="32" value="<?= htmlentities($start_fmt); ?>">
515 6b0c5ae6 smos
						<?=gettext("End:");?>
516 ce49a7c9 Darren Embry
						<input id="endDateTime" title="<?= htmlentities($tz_msg); ?>." type="text" name="end" class="formfldunknown" size="24" length="32" value="<?= htmlentities($end_fmt); ?>">
517 b8219006 Carlos Eduardo Ramos
						<input type="submit" name="Submit" value="<?=gettext("Go"); ?>">
518 3e6ec5df Renato Botelho
						<?php
519 6b0c5ae6 smos
						$curdatabase = $curoption;
520
						$graph = "custom-$curdatabase";
521 9cd5e6f5 Erik Fonnesbeck
						if(in_array($curdatabase, $custom_databases)) {
522 6b0c5ae6 smos
							echo "<tr><td colspan=2 class=\"list\">\n";
523
							echo "<IMG BORDER='0' name='{$graph}-{$curoption}-{$curdatabase}' ";
524
							echo "id='{$graph}-{$curoption}-{$curdatabase}' ALT=\"$prettydb Graph\" ";
525
							echo "SRC=\"status_rrd_graph_img.php?start={$start}&amp;end={$end}&amp;database={$curdatabase}&amp;style={$curstyle}&amp;graph={$graph}\" />\n";
526
							echo "<br /><hr><br />\n";								
527
							echo "</td></tr>\n";
528
						}
529
					} else {
530
						foreach($graphs as $graph) {
531
							/* check which databases are valid for our category */
532
							foreach($ui_databases as $curdatabase) {
533
								if(! preg_match("/($curcat)/i", $curdatabase)) {
534
									continue;
535
								}
536 cfbfd941 smos
								$optionc = explode("-", $curdatabase);
537 6b0c5ae6 smos
								$search = array("-", ".rrd", $optionc);
538
								$replace = array(" :: ", "", $friendly);
539
								switch($curoption) {
540
									case "outbound":
541 2103b252 Erik Fonnesbeck
										/* make sure we do not show the placeholder databases in the outbound view */
542
										if((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) {
543
											continue 2;
544
										}
545 6b0c5ae6 smos
										/* only show interfaces with a gateway */
546
										$optionc = "$optionc[0]";
547
										if(!interface_has_gateway($optionc)) {
548 2103b252 Erik Fonnesbeck
											if(!isset($gateways_arr)) {
549
												if(preg_match("/quality/i", $curdatabase))
550
													$gateways_arr = return_gateways_array();
551
												else
552
													$gateways_arr = array();
553
											}
554 44aef543 Erik Fonnesbeck
											$found_gateway = false;
555
											foreach ($gateways_arr as $gw) {
556
												if ($gw['name'] == $optionc) {
557
													$found_gateway = true;
558
													break;
559
												}
560
											}
561
											if(!$found_gateway) {
562 6b0c5ae6 smos
												continue 2;
563
											}
564
										}
565 44aef543 Erik Fonnesbeck
										if(! preg_match("/(^$optionc-|-$optionc\\.)/i", $curdatabase)) {
566 a927edff Seth Mos
											continue 2;
567
										}
568 6b0c5ae6 smos
										break;
569
									case "allgraphs":
570
										/* make sure we do not show the placeholder databases in the all view */
571
										if((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) {
572
											continue 2;
573
										}
574
										break;
575
									default:
576
										/* just use the name here */
577 44aef543 Erik Fonnesbeck
										if(! preg_match("/(^$curoption-|-$curoption\\.)/i", $curdatabase)) {
578 6b0c5ae6 smos
											continue 2;
579
										}
580
								}
581 9cd5e6f5 Erik Fonnesbeck
								if(in_array($curdatabase, $ui_databases)) {
582 6b0c5ae6 smos
									$dates = get_dates($curperiod, $graph);
583
									$start = $dates['start'];
584
									$end = $dates['end'];
585
									echo "<tr><td colspan=2 class=\"list\">\n";
586
									echo "<IMG BORDER='0' name='{$graph}-{$curoption}-{$curdatabase}' ";
587
									echo "id='{$graph}-{$curoption}-{$curdatabase}' ALT=\"$prettydb Graph\" ";
588
									echo "SRC=\"status_rrd_graph_img.php?start={$start}&amp;end={$end}&amp;database={$curdatabase}&amp;style={$curstyle}&amp;graph={$graph}\" />\n";
589
									echo "<br /><hr><br />\n";								
590
									echo "</td></tr>\n";
591
								}
592 89d25faf Seth Mos
							}
593
						}
594
					}
595
					?>
596
					</td>
597
				</tr>
598
				<tr>
599
					<td colspan=2 class="list">
600
					<script language="javascript">
601
						function update_graph_images() {
602
							//alert('updating');
603
							var randomid = Math.floor(Math.random()*11);
604
							<?php
605 7d906758 smos
							foreach($graphs as $graph) {
606 683bf031 Seth Mos
								/* check which databases are valid for our category */
607 9cd5e6f5 Erik Fonnesbeck
								foreach($ui_databases as $curdatabase) {
608 683bf031 Seth Mos
									if(! stristr($curdatabase, $curcat)) {
609
										continue;
610
									}
611 cfbfd941 smos
									$optionc = explode("-", $curdatabase);
612 683bf031 Seth Mos
									$search = array("-", ".rrd", $optionc);
613
									$replace = array(" :: ", "", $friendly);
614
									switch($curoption) {
615
										case "outbound":
616 2103b252 Erik Fonnesbeck
											/* make sure we do not show the placeholder databases in the outbound view */
617
											if((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) {
618
												continue 2;
619
											}
620
											/* only show interfaces with a gateway */
621 44aef543 Erik Fonnesbeck
											$optionc = "$optionc[0]";
622 2e76e612 Seth Mos
											if(!interface_has_gateway($optionc)) {
623 44aef543 Erik Fonnesbeck
												if(!isset($gateways_arr))
624 2103b252 Erik Fonnesbeck
													if(preg_match("/quality/i", $curdatabase))
625
														$gateways_arr = return_gateways_array();
626
													else
627
														$gateways_arr = array();
628 44aef543 Erik Fonnesbeck
												$found_gateway = false;
629
												foreach ($gateways_arr as $gw) {
630
													if ($gw['name'] == $optionc) {
631
														$found_gateway = true;
632
														break;
633
													}
634
												}
635
												if(!$found_gateway) {
636 683bf031 Seth Mos
													continue 2;
637 44aef543 Erik Fonnesbeck
												}
638
											}
639
											if(! preg_match("/(^$optionc-|-$optionc\\.)/i", $curdatabase)) {
640
												continue 2;
641 683bf031 Seth Mos
											}
642 9850b625 Seth Mos
											break;
643 683bf031 Seth Mos
										case "allgraphs":
644 9850b625 Seth Mos
											/* make sure we do not show the placeholder databases in the all view */
645
											if((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) {
646
												continue 2;
647
											}
648
											break;
649 683bf031 Seth Mos
										default:
650
											/* just use the name here */
651 44aef543 Erik Fonnesbeck
											if(! preg_match("/(^$curoption-|-$curoption\\.)/i", $curdatabase)) {
652 683bf031 Seth Mos
												continue 2;
653
											}
654
									}
655 7d906758 smos
									$dates = get_dates($curperiod, $graph);
656
									$start = $dates['start'];
657 d60f510a smos
									if($curperiod == "current") {
658
										$end = $dates['end'];
659
									}
660 78d84a88 Vinicius Coque
									/* generate update events utilizing jQuery('') feature */
661 683bf031 Seth Mos
									echo "\n";
662 78d84a88 Vinicius Coque
									echo "\t\tjQuery('#{$graph}-{$curoption}-{$curdatabase}').attr('src','status_rrd_graph_img.php?start={$start}&graph={$graph}&database={$curdatabase}&style={$curstyle}&tmp=' + randomid);\n";
663 683bf031 Seth Mos
									}
664
								}
665 89d25faf Seth Mos
							?>
666
							window.setTimeout('update_graph_images()', 355000);
667
						}
668
						window.setTimeout('update_graph_images()', 355000);
669
					</script>
670
					</form>
671
					</td>
672
				</tr>
673
			</table>
674
		</div>
675
		</td>
676
	</tr>
677
</table>
678 37285f69 Scott Ullrich
679
<?php include("fend.inc"); ?>
680
</body>
681
</html>