Project

General

Profile

Download (24.4 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 cba9d7d9 Renato Botelho
if ($_GET['zone'])
69
	$curzone = $_GET['zone'];
70
else
71
	$curzone = '';
72
73 7d906758 smos
if ($_GET['period']) {
74
	$curperiod = $_GET['period'];
75
} else {
76 97acf646 Erik Fonnesbeck
	if(! empty($config['rrd']['period'])) {
77
		$curperiod = $config['rrd']['period'];
78
	} else {
79
		$curperiod = "absolute";
80
	}
81 7d906758 smos
}
82
83 89d25faf Seth Mos
if ($_GET['option']) {
84
	$curoption = $_GET['option'];
85
} else {
86 329bb764 Seth Mos
	switch($curcat) {
87
		case "system":
88
			$curoption = "processor";
89
			break;
90
		case "queues":
91
			$curoption = "queues";
92
			break;
93
		case "queuedrops":
94
			$curoption = "queuedrops";
95 7432ce7b Seth Mos
			break;
96
		case "quality":
97
			foreach($databases as $database) {
98
				if(preg_match("/[-]quality\.rrd/i", $database)) {
99
					/* pick off the 1st database we find that matches the quality graph */
100
					$name = explode("-", $database);
101
					$curoption = "$name[0]";
102
					continue 2;
103
				}
104
			}
105
		case "wireless":
106
			foreach($databases as $database) {
107
				if(preg_match("/[-]wireless\.rrd/i", $database)) {
108
					/* pick off the 1st database we find that matches the wireless graph */
109
					$name = explode("-", $database);
110
					$curoption = "$name[0]";
111
					continue 2;
112
				}
113
			}
114
		case "cellular":
115
			foreach($databases as $database) {
116
				if(preg_match("/[-]cellular\.rrd/i", $database)) {
117
					/* pick off the 1st database we find that matches the celullar graph */
118
					$name = explode("-", $database);
119
					$curoption = "$name[0]";
120
					continue 2;
121
				}
122 329bb764 Seth Mos
			}
123 edd2d8b7 smos
		case "vpnusers":
124 6b0c5ae6 smos
			foreach($databases as $database) {
125 edd2d8b7 smos
				if(preg_match("/[-]vpnusers\.rrd/i", $database)) {
126 6b0c5ae6 smos
					/* pick off the 1st database we find that matches the VPN graphs */
127
					$name = explode("-", $database);
128
					$curoption = "$name[0]";
129
					continue 2;
130
				}
131
			}
132 20413b72 Warren Baker
		case "captiveportal":
133
			$curoption = "allgraphs";
134
			break;
135 2cdb75f8 nagyrobi
		case "ntpd":
136
			if(isset($config['ntpd']['statsgraph'])) {
137
				$curoption = "allgraphs";
138
			} else {
139
				$curoption = "processor";
140
				$curcat = "system";
141
			}
142
			break;
143 329bb764 Seth Mos
		default:
144
			$curoption = "wan";
145
			break;
146 89d25faf Seth Mos
	}
147 37285f69 Scott Ullrich
}
148
149 6b0c5ae6 smos
$now = time();
150 47e68f48 smos
if($curcat == "custom") {
151
	if (is_numeric($_GET['start'])) {
152 59418cee Darren Embry
		if($start < ($now - (3600 * 24 * 365 * 5))) {
153
			$start = $now - (8 * 3600);
154
		}
155
		$start = $_GET['start'];
156
	} else if ($_GET['start']) {
157
		$start = strtotime($_GET['start']);
158
		if ($start === FALSE || $start === -1) {
159
			$input_errors[] = gettext("Invalid start date/time:") . " '{$_GET['start']}'";
160 c7cfbbd8 smos
			$start = $now - (8 * 3600);
161 59418cee Darren Embry
		}
162
	} else {
163
		$start = $now - (8 * 3600);
164 47e68f48 smos
	}
165
}
166
167
if (is_numeric($_GET['end'])) {
168
        $end = $_GET['end'];
169 59418cee Darren Embry
} else if ($_GET['end']) {
170
	$end = strtotime($_GET['end']);
171
	if ($end === FALSE || $end === -1) {
172
		$input_errors[] = gettext("Invalid end date/time:") . " '{$_GET['end']}'";
173
		$end = $now;
174
	}
175 47e68f48 smos
} else {
176
        $end = $now;
177
}
178
179
/* this should never happen */
180
if($end < $start) {
181 c7cfbbd8 smos
	log_error("start $start is smaller than end $end");
182 47e68f48 smos
        $end = $now;
183
}
184
185
$seconds = $end - $start;
186 5d7791a2 Scott Ullrich
187
$styles = array('inverse' => gettext('Inverse'),
188
		'absolute' => gettext('Absolute'));
189
190
// Set default and override later
191
$curstyle = "inverse";
192
193 6ab7ae50 Seth Mos
if ($_GET['style']) {
194 5d7791a2 Scott Ullrich
	foreach($styles as $style) 
195 4ec48253 Scott Ullrich
		if(strtoupper($style) == strtoupper($_GET['style'])) 
196 5d7791a2 Scott Ullrich
			$curstyle = $_GET['style'];
197 37285f69 Scott Ullrich
} else {
198 69487053 Seth Mos
	if(! empty($config['rrd']['style'])) {
199
		$curstyle = $config['rrd']['style'];
200
	} else {
201
		$curstyle = "inverse";
202
	}
203 37285f69 Scott Ullrich
}
204
205 329bb764 Seth Mos
/* sort names reverse so WAN comes first */
206 6ab7ae50 Seth Mos
rsort($databases);
207 37285f69 Scott Ullrich
208 9850b625 Seth Mos
/* these boilerplate databases are required for the other menu choices */
209
$dbheader = array("allgraphs-traffic.rrd",
210
		"allgraphs-quality.rrd",
211 2f80d451 Seth Mos
		"allgraphs-wireless.rrd",
212 ec51a222 thompsa
		"allgraphs-cellular.rrd",
213 edd2d8b7 smos
		"allgraphs-vpnusers.rrd",
214 9850b625 Seth Mos
		"allgraphs-packets.rrd",
215
		"system-allgraphs.rrd",
216 e3d7c123 Seth Mos
		"system-throughput.rrd",
217 9850b625 Seth Mos
		"outbound-quality.rrd",
218
		"outbound-packets.rrd",
219
		"outbound-traffic.rrd");
220
221 9cd5e6f5 Erik Fonnesbeck
/* additional menu choices for the custom tab */
222
$dbheader_custom = array("system-throughput.rrd");
223
224 7432ce7b Seth Mos
foreach($databases as $database) {
225 edd2d8b7 smos
	if(stristr($database, "-wireless")) {
226 7432ce7b Seth Mos
		$wireless = true;
227
	}
228 edd2d8b7 smos
	if(stristr($database, "-queues")) {
229 7432ce7b Seth Mos
		$queues = true;
230
	}
231 17a71003 Ermal
	if(stristr($database, "-cellular") && !empty($config['ppps'])) {
232 7432ce7b Seth Mos
		$cellular = true;
233
	}
234 edd2d8b7 smos
	if(stristr($database, "-vpnusers")) {
235
		$vpnusers = true;
236 6b0c5ae6 smos
	}
237 cba9d7d9 Renato Botelho
	if(stristr($database, "captiveportal-") && is_array($config['captiveportal'])) {
238 20413b72 Warren Baker
		$captiveportal = true;
239
	}
240 2cdb75f8 nagyrobi
	if(stristr($database, "ntpd") && isset($config['ntpd']['statsgraph'])) {
241
		$ntpd = true;
242
	}
243 7432ce7b Seth Mos
}
244 9850b625 Seth Mos
/* append the existing array to the header */
245 a927edff Seth Mos
$ui_databases = array_merge($dbheader, $databases);
246 9cd5e6f5 Erik Fonnesbeck
$custom_databases = array_merge($dbheader_custom, $databases);
247 9850b625 Seth Mos
248 c7cfbbd8 smos
$graphs = array("8hour", "day", "week", "month", "quarter", "year", "4year");
249 97acf646 Erik Fonnesbeck
$periods = array("absolute" => gettext("Absolute Timespans"), "current" => gettext("Current Period"), "previous" => gettext("Previous Period"));
250
$graph_length = array(
251
	"8hour" => 28800,
252
	"day" => 86400,
253
	"week" => 604800,
254 a35c1cdf N0YB
	"month" => 2678400,
255
	"quarter" => 7948800,
256 97acf646 Erik Fonnesbeck
	"year" => 31622400,
257 a35c1cdf N0YB
	"4year" => 126230400);
258 6ab7ae50 Seth Mos
259 1d80829e Carlos Eduardo Ramos
$pgtitle = array(gettext("Status"),gettext("RRD Graphs"));
260 ce49a7c9 Darren Embry
261
$closehead = false;
262 cba9d7d9 Renato Botelho
263
/* Load all CP zones */
264 52034432 Renato Botelho
if ($captiveportal && is_array($config['captiveportal'])) {
265 cba9d7d9 Renato Botelho
	$cp_zones_tab_array = array();
266
	foreach($config['captiveportal'] as $cpkey => $cp) {
267
		if (!isset($cp['enable']))
268
			continue;
269
270
		if ($curzone == '') {
271
			$tabactive = true;
272
			$curzone = $cpkey;
273
		} elseif ($curzone == $cpkey) {
274
			$tabactive = true;
275
		} else {
276
			$tabactive = false;
277
		}
278
279
		$cp_zones_tab_array[] = array($cp['zone'], $tabactive, "status_rrd_graph.php?cat=captiveportal&zone=$cpkey");
280
	}
281
}
282
283 89d25faf Seth Mos
include("head.inc");
284 ce49a7c9 Darren Embry
?>
285
286
<?php if ($curcat === "custom") { ?>
287
	<link rel="stylesheet" type="text/css" href="/javascript/jquery-ui-timepicker-addon/css/jquery-ui-timepicker-addon.css" />
288 31d6f24b Darren Embry
	<?php if (file_exists("{$g['www_path']}/themes/{$g['theme']}/jquery-ui.custom.css")) { ?>
289
		<link rel="stylesheet" type="text/css" href="/themes/<?= $g['theme'] ?>/jquery-ui.custom.css" />
290
	<?php } else { ?>
291
		<link rel="stylesheet" type="text/css" href="/javascript/jquery/jquery-ui.custom.css" />
292
	<?php } ?>
293 ce49a7c9 Darren Embry
	<script type="text/javascript" src="/javascript/jquery-ui-timepicker-addon/js/jquery-ui-timepicker-addon.js"></script>
294
	<script type="text/javascript">
295 c2cc1721 Colin Fleming
	//<![CDATA[
296 ce49a7c9 Darren Embry
		jQuery(function ($) {
297
			var options = {
298
				dateFormat: 'mm/dd/yy',
299
				timeFormat: 'hh:mm:ss',
300
				showSecond: true
301
			};
302
			$("#startDateTime").datetimepicker(options);
303
			$("#endDateTime").datetimepicker(options);
304
		});
305 c2cc1721 Colin Fleming
	//]]>
306 ce49a7c9 Darren Embry
	</script>
307
<?php } ?>
308
309
<?php
310 6ab7ae50 Seth Mos
311 7d906758 smos
function get_dates($curperiod, $graph) {
312 97acf646 Erik Fonnesbeck
	global $graph_length;
313 7d906758 smos
	$now = time();
314
	$end = $now;
315
316 97acf646 Erik Fonnesbeck
	if($curperiod == "absolute") {
317
		$start = $end - $graph_length[$graph];
318
	} else {
319
		$curyear = date('Y', $now);
320
		$curmonth = date('m', $now);
321
		$curweek = date('W', $now);
322
		$curweekday = date('N', $now) - 1; // We want to start on monday
323
		$curday = date('d', $now);
324
		$curhour = date('G', $now);
325 c7cfbbd8 smos
326 97acf646 Erik Fonnesbeck
		switch($curperiod) {
327
			case "previous":
328
				$offset = -1;
329
				break;
330
			default:
331
				$offset = 0;
332
		}
333
		switch($graph) {
334
			case "8hour":
335
				if($curhour < 24)
336
					$starthour = 16;
337
				if($curhour < 16)
338
					$starthour = 8;
339
				if($curhour < 8)
340
					$starthour = 0;
341
342
				switch($offset) {
343
					case 0:
344
						$houroffset = $starthour;
345
						break;
346
					default:
347
						$houroffset = $starthour + ($offset * 8);
348
						break;
349
				}
350
				$start = mktime($houroffset, 0, 0, $curmonth, $curday, $curyear);
351
				if($offset != 0) {
352
					$end = mktime(($houroffset + 8), 0, 0, $curmonth, $curday, $curyear);
353
				}
354
				break;
355
			case "day":
356
				$start = mktime(0, 0, 0, $curmonth, ($curday + $offset), $curyear);
357
				if($offset != 0)
358
					$end = mktime(0, 0, 0, $curmonth, (($curday + $offset) + 1), $curyear);
359
				break;
360
			case "week":
361
				switch($offset) {
362
					case 0:
363
						$weekoffset = 0;
364
						break;
365
					default:
366
						$weekoffset = ($offset * 7) - 7;
367
						break;
368
				}
369
				$start = mktime(0, 0, 0, $curmonth, (($curday - $curweekday) + $weekoffset), $curyear);
370
				if($offset != 0)
371
					$end = mktime(0, 0, 0, $curmonth, (($curday - $curweekday) + $weekoffset + 7), $curyear);
372
				break;
373
			case "month":
374
				$start = mktime(0, 0, 0, ($curmonth + $offset), 0, $curyear);
375
				if($offset != 0)
376
					$end = mktime(0, 0, 0, (($curmonth + $offset) + 1), 0, $curyear);
377
				break;
378
			case "quarter":
379
				$start = mktime(0, 0, 0, (($curmonth - 2) + $offset), 0, $curyear);
380
				if($offset != 0)
381
					$end = mktime(0, 0, 0, (($curmonth + $offset) + 1), 0, $curyear);
382
				break;
383
			case "year":
384
				$start = mktime(0, 0, 0, 1, 0, ($curyear + $offset));
385
				if($offset != 0)
386
					$end = mktime(0, 0, 0, 1, 0, (($curyear + $offset) +1));
387
				break;
388
			case "4year":
389
				$start = mktime(0, 0, 0, 1, 0, (($curyear - 3) + $offset));
390
				if($offset != 0)
391
					$end = mktime(0, 0, 0, 1, 0, (($curyear + $offset) +1));
392
				break;
393
		}
394 7d906758 smos
	}
395 8cd558b6 ayvis
	// 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 />";
396 7d906758 smos
	$dates = array();
397
	$dates['start'] = $start;
398
	$dates['end'] = $end;
399
	return $dates;
400
}
401
402 6ab7ae50 Seth Mos
?>
403 c2cc1721 Colin Fleming
</head>
404 37285f69 Scott Ullrich
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
405
<?php include("fbegin.inc"); ?>
406 59418cee Darren Embry
<?php if ($input_errors && count($input_errors)) { print_input_errors($input_errors); } ?>
407 c2cc1721 Colin Fleming
<form name="form1" action="status_rrd_graph.php" method="get">
408
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="rrd graphs">
409 89d25faf Seth Mos
        <tr>
410
                <td>
411 c2cc1721 Colin Fleming
			<input type="hidden" name="cat" value="<?php echo "$curcat"; ?>" />
412 89d25faf Seth Mos
			<?php
413
			        $tab_array = array();
414
				if($curcat == "system") { $tabactive = True; } else { $tabactive = False; }
415 4dea46ee Rafael Lucas
			        $tab_array[] = array(gettext("System"), $tabactive, "status_rrd_graph.php?cat=system");
416 89d25faf Seth Mos
				if($curcat == "traffic") { $tabactive = True; } else { $tabactive = False; }
417 4dea46ee Rafael Lucas
			        $tab_array[] = array(gettext("Traffic"), $tabactive, "status_rrd_graph.php?cat=traffic");
418 89d25faf Seth Mos
				if($curcat == "packets") { $tabactive = True; } else { $tabactive = False; }
419 4dea46ee Rafael Lucas
			        $tab_array[] = array(gettext("Packets"), $tabactive, "status_rrd_graph.php?cat=packets");
420 89d25faf Seth Mos
				if($curcat == "quality") { $tabactive = True; } else { $tabactive = False; }
421 4dea46ee Rafael Lucas
			        $tab_array[] = array(gettext("Quality"), $tabactive, "status_rrd_graph.php?cat=quality");
422 7432ce7b Seth Mos
				if($queues) {
423
					if($curcat == "queues") { $tabactive = True; } else { $tabactive = False; }
424 d9a0c4b8 Vinicius Coque
						$tab_array[] = array(gettext("Queues"), $tabactive, "status_rrd_graph.php?cat=queues");
425 7432ce7b Seth Mos
					if($curcat == "queuedrops") { $tabactive = True; } else { $tabactive = False; }
426 d9a0c4b8 Vinicius Coque
						$tab_array[] = array(gettext("QueueDrops"), $tabactive, "status_rrd_graph.php?cat=queuedrops");
427 7432ce7b Seth Mos
				}
428
				if($wireless) {
429
					if($curcat == "wireless") { $tabactive = True; } else { $tabactive = False; }
430 4dea46ee Rafael Lucas
				        $tab_array[] = array(gettext("Wireless"), $tabactive, "status_rrd_graph.php?cat=wireless");
431 7432ce7b Seth Mos
				}
432
				if($cellular) {
433
					if($curcat == "cellular") { $tabactive = True; } else { $tabactive = False; }
434 4dea46ee Rafael Lucas
				        $tab_array[] = array(gettext("Cellular"), $tabactive, "status_rrd_graph.php?cat=cellular");
435 7432ce7b Seth Mos
				}
436 edd2d8b7 smos
				if($vpnusers) {
437
					if($curcat == "vpnusers") { $tabactive = True; } else { $tabactive = False; }
438
				        $tab_array[] = array("VPN", $tabactive, "status_rrd_graph.php?cat=vpnusers");
439 6b0c5ae6 smos
				}
440 20413b72 Warren Baker
				if($captiveportal) {
441
					if($curcat == "captiveportal") { $tabactive = True; } else { $tabactive = False; }
442
				        $tab_array[] = array("Captive Portal", $tabactive, "status_rrd_graph.php?cat=captiveportal");
443
				}
444 2cdb75f8 nagyrobi
				if($ntpd) {
445
					if($curcat == "ntpd") { $tabactive = True; } else { $tabactive = False; }
446
				        $tab_array[] = array("NTP", $tabactive, "status_rrd_graph.php?cat=ntpd");
447
				}
448 47e68f48 smos
				if($curcat == "custom") { $tabactive = True; } else { $tabactive = False; }
449 4dea46ee Rafael Lucas
			        $tab_array[] = array(gettext("Custom"), $tabactive, "status_rrd_graph.php?cat=custom");
450 69487053 Seth Mos
				if($curcat == "settings") { $tabactive = True; } else { $tabactive = False; }
451 4dea46ee Rafael Lucas
			        $tab_array[] = array(gettext("Settings"), $tabactive, "status_rrd_graph_settings.php");
452 89d25faf Seth Mos
			        display_top_tabs($tab_array);
453
			?>
454
                </td>
455
        </tr>
456 cba9d7d9 Renato Botelho
	<?php if ($curcat == "captiveportal") : ?>
457
	<tr>
458
		<td class="tabnavtbl">
459
			<?php display_top_tabs($cp_zones_tab_array); ?>
460
		</td>
461
	</tr>
462
	<?php endif; ?>
463 89d25faf Seth Mos
        <tr>
464
                <td>
465
                        <div id="mainarea">
466 c2cc1721 Colin Fleming
                        <table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="0" summary="main area">
467 89d25faf Seth Mos
                                <tr>
468
                                        <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>
469
				</tr>
470
				<tr>
471
                                        <td colspan="2" class="list">
472 3e6ec5df Renato Botelho
					<?=gettext("Graphs:");?>
473 c4877616 jim-p
					<?php if (!empty($curzone)): ?>
474 c2cc1721 Colin Fleming
					<input type="hidden" name="zone" value="<?= htmlspecialchars($curzone) ?>" />
475 c4877616 jim-p
					<?php endif; ?>
476 89d25faf Seth Mos
					<select name="option" class="formselect" style="z-index: -10;" onchange="document.form1.submit()">
477
					<?php
478
479 47e68f48 smos
					if($curcat == "custom") {
480 9cd5e6f5 Erik Fonnesbeck
						foreach ($custom_databases as $db => $database) {
481 cfbfd941 smos
							$optionc = explode("-", $database);
482 47e68f48 smos
							$search = array("-", ".rrd", $optionc);
483
							$replace = array(" :: ", "", $friendly);
484
							echo "<option value=\"{$database}\"";
485
							$prettyprint = ucwords(str_replace($search, $replace, $database));
486
							if($curoption == $database) {
487 c2cc1721 Colin Fleming
								echo " selected=\"selected\"";
488 47e68f48 smos
							}
489
							echo ">" . htmlspecialchars($prettyprint) . "</option>\n";
490
						}
491
					}
492 a927edff Seth Mos
					foreach ($ui_databases as $db => $database) {
493 cba9d7d9 Renato Botelho
						if(! preg_match("/($curcat)/i", $database))
494 89d25faf Seth Mos
							continue;
495 cba9d7d9 Renato Botelho
496 8878f4bb Renato Botelho
						if (($curcat == "captiveportal") && !empty($curzone) && !preg_match("/captiveportal-{$curzone}/i", $database))
497 cba9d7d9 Renato Botelho
							continue;
498
499 cfbfd941 smos
						$optionc = explode("-", $database);
500 89d25faf Seth Mos
						$search = array("-", ".rrd", $optionc);
501 35551994 Seth Mos
						$replace = array(" :: ", "", $friendly);
502 47e68f48 smos
503 9850b625 Seth Mos
						switch($curcat) {
504 20413b72 Warren Baker
							case "captiveportal":
505 cba9d7d9 Renato Botelho
								$optionc = str_replace($search, $replace, $optionc[2]);
506 20413b72 Warren Baker
								echo "<option value=\"$optionc\"";
507
								$prettyprint = ucwords(str_replace($search, $replace, $optionc));
508
								break;
509 9850b625 Seth Mos
							case "system":
510 85a4aab6 Erik Fonnesbeck
								$optionc = str_replace($search, $replace, $optionc[1]);
511
								echo "<option value=\"$optionc\"";
512
								$prettyprint = ucwords(str_replace($search, $replace, $optionc));
513 9850b625 Seth Mos
								break;
514
							default:
515
								/* Deduce a interface if possible and use the description */
516
								$optionc = "$optionc[0]";
517
								$friendly = convert_friendly_interface_to_friendly_descr(strtolower($optionc));
518 d9699f96 Seth Mos
								if(empty($friendly)) {
519
									$friendly = $optionc;
520
								}
521 9850b625 Seth Mos
								$search = array("-", ".rrd", $optionc);
522
								$replace = array(" :: ", "", $friendly);
523
								echo "<option value=\"$optionc\"";
524
								$prettyprint = ucwords(str_replace($search, $replace, $friendly));
525
						}
526
						if($curoption == $optionc) {
527 c2cc1721 Colin Fleming
							echo " selected=\"selected\"";
528 89d25faf Seth Mos
						}
529
						echo ">" . htmlspecialchars($prettyprint) . "</option>\n";
530
					}
531
532
					?>
533
					</select>
534
535 3e6ec5df Renato Botelho
					<?=gettext("Style:");?>
536 89d25faf Seth Mos
					<select name="style" class="formselect" style="z-index: -10;" onchange="document.form1.submit()">
537
					<?php
538
					foreach ($styles as $style => $styled) {
539
						echo "<option value=\"$style\"";
540 c2cc1721 Colin Fleming
						if ($style == $curstyle) echo " selected=\"selected\"";
541 89d25faf Seth Mos
						echo ">" . htmlspecialchars($styled) . "</option>\n";
542
					}
543
					?>
544 7d906758 smos
					</select>
545
					
546 e4b57d26 Renato Botelho
					<?php
547 47e68f48 smos
					if($curcat <> "custom") {
548
					?>
549 3e6ec5df Renato Botelho
						<?=gettext("Period:");?>
550 47e68f48 smos
						<select name="period" class="formselect" style="z-index: -10;" onchange="document.form1.submit()">
551
						<?php
552
						foreach ($periods as $period => $value) {
553
							echo "<option value=\"$period\"";
554 c2cc1721 Colin Fleming
							if ($period == $curperiod) echo " selected=\"selected\"";
555 47e68f48 smos
							echo ">" . htmlspecialchars($value) . "</option>\n";
556
						}
557 c2cc1721 Colin Fleming
						echo "</select>\n";
558
						echo "</td></tr>\n";
559 7d906758 smos
					}
560
					?>
561 89d25faf Seth Mos
					<?php
562
563 47e68f48 smos
					if($curcat == "custom") {
564 59418cee Darren Embry
						$tz = date_default_timezone_get();
565
						$tz_msg = gettext("Enter date and/or time. Current timezone:") . " $tz";
566 ce49a7c9 Darren Embry
						$start_fmt = strftime("%m/%d/%Y %H:%M:%S", $start);
567
						$end_fmt   = strftime("%m/%d/%Y %H:%M:%S", $end);
568 6b0c5ae6 smos
						?>
569
						<?=gettext("Start:");?>
570 c2cc1721 Colin Fleming
						<input id="startDateTime" title="<?= htmlentities($tz_msg); ?>." type="text" name="start" class="formfldunknown" size="24" value="<?= htmlentities($start_fmt); ?>" />
571 6b0c5ae6 smos
						<?=gettext("End:");?>
572 c2cc1721 Colin Fleming
						<input id="endDateTime" title="<?= htmlentities($tz_msg); ?>." type="text" name="end" class="formfldunknown" size="24" value="<?= htmlentities($end_fmt); ?>" />
573
						<input type="submit" name="Submit" value="<?=gettext("Go"); ?>" />
574
						</td></tr>
575 3e6ec5df Renato Botelho
						<?php
576 6b0c5ae6 smos
						$curdatabase = $curoption;
577
						$graph = "custom-$curdatabase";
578 9cd5e6f5 Erik Fonnesbeck
						if(in_array($curdatabase, $custom_databases)) {
579 3a83296f Darren Embry
							$id = "{$graph}-{$curoption}-{$curdatabase}";
580
							$id = preg_replace('/\./', '_', $id);
581
582 c2cc1721 Colin Fleming
							echo "<tr><td colspan=\"2\" class=\"list\">\n";
583
							echo "<img border=\"0\" name=\"{$id}\" ";
584
							echo "id=\"{$id}\" alt=\"$prettydb Graph\" ";
585
							echo "src=\"status_rrd_graph_img.php?start={$start}&amp;end={$end}&amp;database={$curdatabase}&amp;style={$curstyle}&amp;graph={$graph}\" />\n";
586
							echo "<br /><hr /><br />\n";
587 6b0c5ae6 smos
							echo "</td></tr>\n";
588
						}
589
					} else {
590
						foreach($graphs as $graph) {
591
							/* check which databases are valid for our category */
592
							foreach($ui_databases as $curdatabase) {
593 cba9d7d9 Renato Botelho
								if(! preg_match("/($curcat)/i", $curdatabase))
594 6b0c5ae6 smos
									continue;
595 cba9d7d9 Renato Botelho
596 8878f4bb Renato Botelho
								if (($curcat == "captiveportal") && !empty($curzone) && !preg_match("/captiveportal-{$curzone}/i", $curdatabase))
597 cba9d7d9 Renato Botelho
									continue;
598
599 cfbfd941 smos
								$optionc = explode("-", $curdatabase);
600 6b0c5ae6 smos
								$search = array("-", ".rrd", $optionc);
601
								$replace = array(" :: ", "", $friendly);
602
								switch($curoption) {
603
									case "outbound":
604 2103b252 Erik Fonnesbeck
										/* make sure we do not show the placeholder databases in the outbound view */
605
										if((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) {
606
											continue 2;
607
										}
608 6b0c5ae6 smos
										/* only show interfaces with a gateway */
609
										$optionc = "$optionc[0]";
610
										if(!interface_has_gateway($optionc)) {
611 2103b252 Erik Fonnesbeck
											if(!isset($gateways_arr)) {
612
												if(preg_match("/quality/i", $curdatabase))
613
													$gateways_arr = return_gateways_array();
614
												else
615
													$gateways_arr = array();
616
											}
617 44aef543 Erik Fonnesbeck
											$found_gateway = false;
618
											foreach ($gateways_arr as $gw) {
619
												if ($gw['name'] == $optionc) {
620
													$found_gateway = true;
621
													break;
622
												}
623
											}
624
											if(!$found_gateway) {
625 6b0c5ae6 smos
												continue 2;
626
											}
627
										}
628 44aef543 Erik Fonnesbeck
										if(! preg_match("/(^$optionc-|-$optionc\\.)/i", $curdatabase)) {
629 a927edff Seth Mos
											continue 2;
630
										}
631 6b0c5ae6 smos
										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 44aef543 Erik Fonnesbeck
										if(! preg_match("/(^$curoption-|-$curoption\\.)/i", $curdatabase)) {
641 6b0c5ae6 smos
											continue 2;
642
										}
643
								}
644 9cd5e6f5 Erik Fonnesbeck
								if(in_array($curdatabase, $ui_databases)) {
645 3a83296f Darren Embry
									$id = "{$graph}-{$curoption}-{$curdatabase}";
646
									$id = preg_replace('/\./', '_', $id);
647
648 6b0c5ae6 smos
									$dates = get_dates($curperiod, $graph);
649
									$start = $dates['start'];
650
									$end = $dates['end'];
651 c2cc1721 Colin Fleming
									echo "<tr><td colspan=\"2\" class=\"list\">\n";
652
									echo "<img border=\"0\" name=\"{$id}\" ";
653
									echo "id=\"{$id}\" alt=\"$prettydb Graph\" ";
654
									echo "src=\"status_rrd_graph_img.php?start={$start}&amp;end={$end}&amp;database={$curdatabase}&amp;style={$curstyle}&amp;graph={$graph}\" />\n";
655
									echo "<br /><hr /><br />\n";
656 6b0c5ae6 smos
									echo "</td></tr>\n";
657
								}
658 89d25faf Seth Mos
							}
659
						}
660
					}
661
					?>
662
				<tr>
663 c2cc1721 Colin Fleming
					<td colspan="2" class="list">
664
					<script type="text/javascript">
665
					//<![CDATA[
666 89d25faf Seth Mos
						function update_graph_images() {
667
							//alert('updating');
668
							var randomid = Math.floor(Math.random()*11);
669
							<?php
670 7d906758 smos
							foreach($graphs as $graph) {
671 683bf031 Seth Mos
								/* check which databases are valid for our category */
672 9cd5e6f5 Erik Fonnesbeck
								foreach($ui_databases as $curdatabase) {
673 683bf031 Seth Mos
									if(! stristr($curdatabase, $curcat)) {
674
										continue;
675
									}
676 cfbfd941 smos
									$optionc = explode("-", $curdatabase);
677 683bf031 Seth Mos
									$search = array("-", ".rrd", $optionc);
678
									$replace = array(" :: ", "", $friendly);
679
									switch($curoption) {
680
										case "outbound":
681 2103b252 Erik Fonnesbeck
											/* make sure we do not show the placeholder databases in the outbound view */
682
											if((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) {
683
												continue 2;
684
											}
685
											/* only show interfaces with a gateway */
686 44aef543 Erik Fonnesbeck
											$optionc = "$optionc[0]";
687 2e76e612 Seth Mos
											if(!interface_has_gateway($optionc)) {
688 44aef543 Erik Fonnesbeck
												if(!isset($gateways_arr))
689 2103b252 Erik Fonnesbeck
													if(preg_match("/quality/i", $curdatabase))
690
														$gateways_arr = return_gateways_array();
691
													else
692
														$gateways_arr = array();
693 44aef543 Erik Fonnesbeck
												$found_gateway = false;
694
												foreach ($gateways_arr as $gw) {
695
													if ($gw['name'] == $optionc) {
696
														$found_gateway = true;
697
														break;
698
													}
699
												}
700
												if(!$found_gateway) {
701 683bf031 Seth Mos
													continue 2;
702 44aef543 Erik Fonnesbeck
												}
703
											}
704
											if(! preg_match("/(^$optionc-|-$optionc\\.)/i", $curdatabase)) {
705
												continue 2;
706 683bf031 Seth Mos
											}
707 9850b625 Seth Mos
											break;
708 683bf031 Seth Mos
										case "allgraphs":
709 9850b625 Seth Mos
											/* make sure we do not show the placeholder databases in the all view */
710
											if((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) {
711
												continue 2;
712
											}
713
											break;
714 683bf031 Seth Mos
										default:
715
											/* just use the name here */
716 44aef543 Erik Fonnesbeck
											if(! preg_match("/(^$curoption-|-$curoption\\.)/i", $curdatabase)) {
717 683bf031 Seth Mos
												continue 2;
718
											}
719
									}
720 7d906758 smos
									$dates = get_dates($curperiod, $graph);
721
									$start = $dates['start'];
722 d60f510a smos
									if($curperiod == "current") {
723
										$end = $dates['end'];
724
									}
725 78d84a88 Vinicius Coque
									/* generate update events utilizing jQuery('') feature */
726 3a83296f Darren Embry
									$id = "{$graph}-{$curoption}-{$curdatabase}";
727
									$id = preg_replace('/\./', '_', $id);
728
729 683bf031 Seth Mos
									echo "\n";
730 3a83296f Darren Embry
									echo "\t\tjQuery('#{$id}').attr('src','status_rrd_graph_img.php?start={$start}&graph={$graph}&database={$curdatabase}&style={$curstyle}&tmp=' + randomid);\n";
731 683bf031 Seth Mos
									}
732
								}
733 89d25faf Seth Mos
							?>
734
							window.setTimeout('update_graph_images()', 355000);
735
						}
736
						window.setTimeout('update_graph_images()', 355000);
737 c2cc1721 Colin Fleming
					//]]>
738 89d25faf Seth Mos
					</script>
739
					</td>
740
				</tr>
741
			</table>
742
		</div>
743
		</td>
744
	</tr>
745
</table>
746 c2cc1721 Colin Fleming
</form>
747 37285f69 Scott Ullrich
<?php include("fend.inc"); ?>
748
</body>
749
</html>