Project

General

Profile

Download (23.6 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
	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
/*	
31
	pfSense_MODULE:	system
32
*/
33

    
34
##|+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
require("guiconfig.inc");
42
require_once("filter.inc");
43
require("shaper.inc");
44
require_once("rrd.inc");
45

    
46
unset($input_errors);
47

    
48
/* 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
$rrddbpath = "/var/db/rrd/";
54
chdir($rrddbpath);
55
$databases = glob("*.rrd");
56

    
57

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

    
68
if ($_GET['zone'])
69
	$curzone = $_GET['zone'];
70
else
71
	$curzone = '';
72

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

    
83
if ($_GET['option']) {
84
	$curoption = $_GET['option'];
85
} else {
86
	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
			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
			}
123
		case "vpnusers":
124
			foreach($databases as $database) {
125
				if(preg_match("/[-]vpnusers\.rrd/i", $database)) {
126
					/* 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
		case "captiveportal":
133
			$curoption = "allgraphs";
134
			break;
135
		default:
136
			$curoption = "wan";
137
			break;
138
	}
139
}
140

    
141
$now = time();
142
if($curcat == "custom") {
143
	if (is_numeric($_GET['start'])) {
144
		if($start < ($now - (3600 * 24 * 365 * 5))) {
145
			$start = $now - (8 * 3600);
146
		}
147
		$start = $_GET['start'];
148
	} else if ($_GET['start']) {
149
		$start = strtotime($_GET['start']);
150
		if ($start === FALSE || $start === -1) {
151
			$input_errors[] = gettext("Invalid start date/time:") . " '{$_GET['start']}'";
152
			$start = $now - (8 * 3600);
153
		}
154
	} else {
155
		$start = $now - (8 * 3600);
156
	}
157
}
158

    
159
if (is_numeric($_GET['end'])) {
160
        $end = $_GET['end'];
161
} else if ($_GET['end']) {
162
	$end = strtotime($_GET['end']);
163
	if ($end === FALSE || $end === -1) {
164
		$input_errors[] = gettext("Invalid end date/time:") . " '{$_GET['end']}'";
165
		$end = $now;
166
	}
167
} else {
168
        $end = $now;
169
}
170

    
171
/* this should never happen */
172
if($end < $start) {
173
	log_error("start $start is smaller than end $end");
174
        $end = $now;
175
}
176

    
177
$seconds = $end - $start;
178

    
179
$styles = array('inverse' => gettext('Inverse'),
180
		'absolute' => gettext('Absolute'));
181

    
182
// Set default and override later
183
$curstyle = "inverse";
184

    
185
if ($_GET['style']) {
186
	foreach($styles as $style) 
187
		if(strtoupper($style) == strtoupper($_GET['style'])) 
188
			$curstyle = $_GET['style'];
189
} else {
190
	if(! empty($config['rrd']['style'])) {
191
		$curstyle = $config['rrd']['style'];
192
	} else {
193
		$curstyle = "inverse";
194
	}
195
}
196

    
197
/* sort names reverse so WAN comes first */
198
rsort($databases);
199

    
200
/* these boilerplate databases are required for the other menu choices */
201
$dbheader = array("allgraphs-traffic.rrd",
202
		"allgraphs-quality.rrd",
203
		"allgraphs-wireless.rrd",
204
		"allgraphs-cellular.rrd",
205
		"allgraphs-vpnusers.rrd",
206
		"allgraphs-packets.rrd",
207
		"system-allgraphs.rrd",
208
		"system-throughput.rrd",
209
		"outbound-quality.rrd",
210
		"outbound-packets.rrd",
211
		"outbound-traffic.rrd");
212

    
213
/* additional menu choices for the custom tab */
214
$dbheader_custom = array("system-throughput.rrd");
215

    
216
foreach($databases as $database) {
217
	if(stristr($database, "-wireless")) {
218
		$wireless = true;
219
	}
220
	if(stristr($database, "-queues")) {
221
		$queues = true;
222
	}
223
	if(stristr($database, "-cellular") && !empty($config['ppps'])) {
224
		$cellular = true;
225
	}
226
	if(stristr($database, "-vpnusers")) {
227
		$vpnusers = true;
228
	}
229
	if(stristr($database, "captiveportal-") && is_array($config['captiveportal'])) {
230
		$captiveportal = true;
231
	}
232
}
233
/* append the existing array to the header */
234
$ui_databases = array_merge($dbheader, $databases);
235
$custom_databases = array_merge($dbheader_custom, $databases);
236

    
237
$graphs = array("8hour", "day", "week", "month", "quarter", "year", "4year");
238
$periods = array("absolute" => gettext("Absolute Timespans"), "current" => gettext("Current Period"), "previous" => gettext("Previous Period"));
239
$graph_length = array(
240
	"8hour" => 28800,
241
	"day" => 86400,
242
	"week" => 604800,
243
	"month" => 2678400,
244
	"quarter" => 7948800,
245
	"year" => 31622400,
246
	"4year" => 126230400);
247

    
248
$pgtitle = array(gettext("Status"),gettext("RRD Graphs"));
249

    
250
$closehead = false;
251

    
252
/* Load all CP zones */
253
if ($captiveportal && is_array($config['captiveportal'])) {
254
	$cp_zones_tab_array = array();
255
	foreach($config['captiveportal'] as $cpkey => $cp) {
256
		if (!isset($cp['enable']))
257
			continue;
258

    
259
		if ($curzone == '') {
260
			$tabactive = true;
261
			$curzone = $cpkey;
262
		} elseif ($curzone == $cpkey) {
263
			$tabactive = true;
264
		} else {
265
			$tabactive = false;
266
		}
267

    
268
		$cp_zones_tab_array[] = array($cp['zone'], $tabactive, "status_rrd_graph.php?cat=captiveportal&zone=$cpkey");
269
	}
270
}
271

    
272
include("head.inc");
273
?>
274

    
275
<?php if ($curcat === "custom") { ?>
276
	<link rel="stylesheet" type="text/css" href="/javascript/jquery-ui-timepicker-addon/css/jquery-ui-timepicker-addon.css" />
277
	<?php if (file_exists("{$g['www_path']}/themes/{$g['theme']}/jquery-ui.custom.css")) { ?>
278
		<link rel="stylesheet" type="text/css" href="/themes/<?= $g['theme'] ?>/jquery-ui.custom.css" />
279
	<?php } else { ?>
280
		<link rel="stylesheet" type="text/css" href="/javascript/jquery/jquery-ui.custom.css" />
281
	<?php } ?>
282
	<script type="text/javascript" src="/javascript/jquery-ui-timepicker-addon/js/jquery-ui-timepicker-addon.js"></script>
283
	<script type="text/javascript">
284
		jQuery(function ($) {
285
			var options = {
286
				dateFormat: 'mm/dd/yy',
287
				timeFormat: 'hh:mm:ss',
288
				showSecond: true
289
			};
290
			$("#startDateTime").datetimepicker(options);
291
			$("#endDateTime").datetimepicker(options);
292
		});
293
	</script>
294
	</head>
295
<?php } ?>
296

    
297
<?php
298

    
299
function get_dates($curperiod, $graph) {
300
	global $graph_length;
301
	$now = time();
302
	$end = $now;
303

    
304
	if($curperiod == "absolute") {
305
		$start = $end - $graph_length[$graph];
306
	} else {
307
		$curyear = date('Y', $now);
308
		$curmonth = date('m', $now);
309
		$curweek = date('W', $now);
310
		$curweekday = date('N', $now) - 1; // We want to start on monday
311
		$curday = date('d', $now);
312
		$curhour = date('G', $now);
313

    
314
		switch($curperiod) {
315
			case "previous":
316
				$offset = -1;
317
				break;
318
			default:
319
				$offset = 0;
320
		}
321
		switch($graph) {
322
			case "8hour":
323
				if($curhour < 24)
324
					$starthour = 16;
325
				if($curhour < 16)
326
					$starthour = 8;
327
				if($curhour < 8)
328
					$starthour = 0;
329

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

    
390
?>
391
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
392
<?php include("fbegin.inc"); ?>
393
<?php if ($input_errors && count($input_errors)) { print_input_errors($input_errors); } ?>
394
<table width="100%" border="0" cellpadding="0" cellspacing="0">
395
        <tr>
396
                <td>
397
			<form name="form1" action="status_rrd_graph.php" method="get">
398
			<input type="hidden" name="cat" value="<?php echo "$curcat"; ?>">
399
			<?php
400
			        $tab_array = array();
401
				if($curcat == "system") { $tabactive = True; } else { $tabactive = False; }
402
			        $tab_array[] = array(gettext("System"), $tabactive, "status_rrd_graph.php?cat=system");
403
				if($curcat == "traffic") { $tabactive = True; } else { $tabactive = False; }
404
			        $tab_array[] = array(gettext("Traffic"), $tabactive, "status_rrd_graph.php?cat=traffic");
405
				if($curcat == "packets") { $tabactive = True; } else { $tabactive = False; }
406
			        $tab_array[] = array(gettext("Packets"), $tabactive, "status_rrd_graph.php?cat=packets");
407
				if($curcat == "quality") { $tabactive = True; } else { $tabactive = False; }
408
			        $tab_array[] = array(gettext("Quality"), $tabactive, "status_rrd_graph.php?cat=quality");
409
				if($queues) {
410
					if($curcat == "queues") { $tabactive = True; } else { $tabactive = False; }
411
						$tab_array[] = array(gettext("Queues"), $tabactive, "status_rrd_graph.php?cat=queues");
412
					if($curcat == "queuedrops") { $tabactive = True; } else { $tabactive = False; }
413
						$tab_array[] = array(gettext("QueueDrops"), $tabactive, "status_rrd_graph.php?cat=queuedrops");
414
				}
415
				if($wireless) {
416
					if($curcat == "wireless") { $tabactive = True; } else { $tabactive = False; }
417
				        $tab_array[] = array(gettext("Wireless"), $tabactive, "status_rrd_graph.php?cat=wireless");
418
				}
419
				if($cellular) {
420
					if($curcat == "cellular") { $tabactive = True; } else { $tabactive = False; }
421
				        $tab_array[] = array(gettext("Cellular"), $tabactive, "status_rrd_graph.php?cat=cellular");
422
				}
423
				if($vpnusers) {
424
					if($curcat == "vpnusers") { $tabactive = True; } else { $tabactive = False; }
425
				        $tab_array[] = array("VPN", $tabactive, "status_rrd_graph.php?cat=vpnusers");
426
				}
427
				if($captiveportal) {
428
					if($curcat == "captiveportal") { $tabactive = True; } else { $tabactive = False; }
429
				        $tab_array[] = array("Captive Portal", $tabactive, "status_rrd_graph.php?cat=captiveportal");
430
				}
431
				if($curcat == "custom") { $tabactive = True; } else { $tabactive = False; }
432
			        $tab_array[] = array(gettext("Custom"), $tabactive, "status_rrd_graph.php?cat=custom");
433
				if($curcat == "settings") { $tabactive = True; } else { $tabactive = False; }
434
			        $tab_array[] = array(gettext("Settings"), $tabactive, "status_rrd_graph_settings.php");
435
			        display_top_tabs($tab_array);
436
			?>
437
                </td>
438
        </tr>
439
	<?php if ($curcat == "captiveportal") : ?>
440
	<tr>
441
		<td class="tabnavtbl">
442
			<?php display_top_tabs($cp_zones_tab_array); ?>
443
		</td>
444
	</tr>
445
	<?php endif; ?>
446
        <tr>
447
                <td>
448
                        <div id="mainarea">
449
                        <table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="0">
450
                                <tr>
451
                                        <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>
452
				</tr>
453
				<tr>
454
                                        <td colspan="2" class="list">
455
					<?=gettext("Graphs:");?>
456
					<select name="option" class="formselect" style="z-index: -10;" onchange="document.form1.submit()">
457
					<?php
458

    
459
					if($curcat == "custom") {
460
						foreach ($custom_databases as $db => $database) {
461
							$optionc = explode("-", $database);
462
							$search = array("-", ".rrd", $optionc);
463
							$replace = array(" :: ", "", $friendly);
464
							echo "<option value=\"{$database}\"";
465
							$prettyprint = ucwords(str_replace($search, $replace, $database));
466
							if($curoption == $database) {
467
								echo " selected";
468
							}
469
							echo ">" . htmlspecialchars($prettyprint) . "</option>\n";
470
						}
471
					}
472
					foreach ($ui_databases as $db => $database) {
473
						if(! preg_match("/($curcat)/i", $database))
474
							continue;
475

    
476
						if (($curcat == "captiveportal") && !empty($curzone) && !preg_match("/captiveportal-{$curzone}/i", $database))
477
							continue;
478

    
479
						$optionc = explode("-", $database);
480
						$search = array("-", ".rrd", $optionc);
481
						$replace = array(" :: ", "", $friendly);
482

    
483
						switch($curcat) {
484
							case "captiveportal":
485
								$optionc = str_replace($search, $replace, $optionc[2]);
486
								echo "<option value=\"$optionc\"";
487
								$prettyprint = ucwords(str_replace($search, $replace, $optionc));
488
								break;
489
							case "system":
490
								$optionc = str_replace($search, $replace, $optionc[1]);
491
								echo "<option value=\"$optionc\"";
492
								$prettyprint = ucwords(str_replace($search, $replace, $optionc));
493
								break;
494
							default:
495
								/* Deduce a interface if possible and use the description */
496
								$optionc = "$optionc[0]";
497
								$friendly = convert_friendly_interface_to_friendly_descr(strtolower($optionc));
498
								if(empty($friendly)) {
499
									$friendly = $optionc;
500
								}
501
								$search = array("-", ".rrd", $optionc);
502
								$replace = array(" :: ", "", $friendly);
503
								echo "<option value=\"$optionc\"";
504
								$prettyprint = ucwords(str_replace($search, $replace, $friendly));
505
						}
506
						if($curoption == $optionc) {
507
							echo " selected";
508
						}
509
						echo ">" . htmlspecialchars($prettyprint) . "</option>\n";
510
					}
511

    
512
					?>
513
					</select>
514

    
515
					<?=gettext("Style:");?>
516
					<select name="style" class="formselect" style="z-index: -10;" onchange="document.form1.submit()">
517
					<?php
518
					foreach ($styles as $style => $styled) {
519
						echo "<option value=\"$style\"";
520
						if ($style == $curstyle) echo " selected";
521
						echo ">" . htmlspecialchars($styled) . "</option>\n";
522
					}
523
					?>
524
					</select>
525
					
526
					<?php
527
					if($curcat <> "custom") {
528
					?>
529
						<?=gettext("Period:");?>
530
						<select name="period" class="formselect" style="z-index: -10;" onchange="document.form1.submit()">
531
						<?php
532
						foreach ($periods as $period => $value) {
533
							echo "<option value=\"$period\"";
534
							if ($period == $curperiod) echo " selected";
535
							echo ">" . htmlspecialchars($value) . "</option>\n";
536
						}
537
					}
538
					?>
539
					</select>
540
					<?php
541

    
542
					if($curcat == "custom") {
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
						<?=gettext("Start:");?>
549
						<input id="startDateTime" title="<?= htmlentities($tz_msg); ?>." type="text" name="start" class="formfldunknown" size="24" length="32" value="<?= htmlentities($start_fmt); ?>">
550
						<?=gettext("End:");?>
551
						<input id="endDateTime" title="<?= htmlentities($tz_msg); ?>." type="text" name="end" class="formfldunknown" size="24" length="32" value="<?= htmlentities($end_fmt); ?>">
552
						<input type="submit" name="Submit" value="<?=gettext("Go"); ?>">
553
						<?php
554
						$curdatabase = $curoption;
555
						$graph = "custom-$curdatabase";
556
						if(in_array($curdatabase, $custom_databases)) {
557
							$id = "{$graph}-{$curoption}-{$curdatabase}";
558
							$id = preg_replace('/\./', '_', $id);
559

    
560
							echo "<tr><td colspan=2 class=\"list\">\n";
561
							echo "<IMG BORDER='0' name='{$id}' ";
562
							echo "id='{$id}' ALT=\"$prettydb Graph\" ";
563
							echo "SRC=\"status_rrd_graph_img.php?start={$start}&amp;end={$end}&amp;database={$curdatabase}&amp;style={$curstyle}&amp;graph={$graph}\" />\n";
564
							echo "<br /><hr><br />\n";								
565
							echo "</td></tr>\n";
566
						}
567
					} else {
568
						foreach($graphs as $graph) {
569
							/* check which databases are valid for our category */
570
							foreach($ui_databases as $curdatabase) {
571
								if(! preg_match("/($curcat)/i", $curdatabase))
572
									continue;
573

    
574
								if (($curcat == "captiveportal") && !empty($curzone) && !preg_match("/captiveportal-{$curzone}/i", $curdatabase))
575
									continue;
576

    
577
								$optionc = explode("-", $curdatabase);
578
								$search = array("-", ".rrd", $optionc);
579
								$replace = array(" :: ", "", $friendly);
580
								switch($curoption) {
581
									case "outbound":
582
										/* make sure we do not show the placeholder databases in the outbound view */
583
										if((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) {
584
											continue 2;
585
										}
586
										/* only show interfaces with a gateway */
587
										$optionc = "$optionc[0]";
588
										if(!interface_has_gateway($optionc)) {
589
											if(!isset($gateways_arr)) {
590
												if(preg_match("/quality/i", $curdatabase))
591
													$gateways_arr = return_gateways_array();
592
												else
593
													$gateways_arr = array();
594
											}
595
											$found_gateway = false;
596
											foreach ($gateways_arr as $gw) {
597
												if ($gw['name'] == $optionc) {
598
													$found_gateway = true;
599
													break;
600
												}
601
											}
602
											if(!$found_gateway) {
603
												continue 2;
604
											}
605
										}
606
										if(! preg_match("/(^$optionc-|-$optionc\\.)/i", $curdatabase)) {
607
											continue 2;
608
										}
609
										break;
610
									case "allgraphs":
611
										/* make sure we do not show the placeholder databases in the all view */
612
										if((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) {
613
											continue 2;
614
										}
615
										break;
616
									default:
617
										/* just use the name here */
618
										if(! preg_match("/(^$curoption-|-$curoption\\.)/i", $curdatabase)) {
619
											continue 2;
620
										}
621
								}
622
								if(in_array($curdatabase, $ui_databases)) {
623
									$id = "{$graph}-{$curoption}-{$curdatabase}";
624
									$id = preg_replace('/\./', '_', $id);
625

    
626
									$dates = get_dates($curperiod, $graph);
627
									$start = $dates['start'];
628
									$end = $dates['end'];
629
									echo "<tr><td colspan=2 class=\"list\">\n";
630
									echo "<IMG BORDER='0' name='{$id}' ";
631
									echo "id='{$id}' ALT=\"$prettydb Graph\" ";
632
									echo "SRC=\"status_rrd_graph_img.php?start={$start}&amp;end={$end}&amp;database={$curdatabase}&amp;style={$curstyle}&amp;graph={$graph}\" />\n";
633
									echo "<br /><hr><br />\n";								
634
									echo "</td></tr>\n";
635
								}
636
							}
637
						}
638
					}
639
					?>
640
					</td>
641
				</tr>
642
				<tr>
643
					<td colspan=2 class="list">
644
					<script language="javascript">
645
						function update_graph_images() {
646
							//alert('updating');
647
							var randomid = Math.floor(Math.random()*11);
648
							<?php
649
							foreach($graphs as $graph) {
650
								/* check which databases are valid for our category */
651
								foreach($ui_databases as $curdatabase) {
652
									if(! stristr($curdatabase, $curcat)) {
653
										continue;
654
									}
655
									$optionc = explode("-", $curdatabase);
656
									$search = array("-", ".rrd", $optionc);
657
									$replace = array(" :: ", "", $friendly);
658
									switch($curoption) {
659
										case "outbound":
660
											/* make sure we do not show the placeholder databases in the outbound view */
661
											if((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) {
662
												continue 2;
663
											}
664
											/* only show interfaces with a gateway */
665
											$optionc = "$optionc[0]";
666
											if(!interface_has_gateway($optionc)) {
667
												if(!isset($gateways_arr))
668
													if(preg_match("/quality/i", $curdatabase))
669
														$gateways_arr = return_gateways_array();
670
													else
671
														$gateways_arr = array();
672
												$found_gateway = false;
673
												foreach ($gateways_arr as $gw) {
674
													if ($gw['name'] == $optionc) {
675
														$found_gateway = true;
676
														break;
677
													}
678
												}
679
												if(!$found_gateway) {
680
													continue 2;
681
												}
682
											}
683
											if(! preg_match("/(^$optionc-|-$optionc\\.)/i", $curdatabase)) {
684
												continue 2;
685
											}
686
											break;
687
										case "allgraphs":
688
											/* make sure we do not show the placeholder databases in the all view */
689
											if((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) {
690
												continue 2;
691
											}
692
											break;
693
										default:
694
											/* just use the name here */
695
											if(! preg_match("/(^$curoption-|-$curoption\\.)/i", $curdatabase)) {
696
												continue 2;
697
											}
698
									}
699
									$dates = get_dates($curperiod, $graph);
700
									$start = $dates['start'];
701
									if($curperiod == "current") {
702
										$end = $dates['end'];
703
									}
704
									/* generate update events utilizing jQuery('') feature */
705
									$id = "{$graph}-{$curoption}-{$curdatabase}";
706
									$id = preg_replace('/\./', '_', $id);
707

    
708
									echo "\n";
709
									echo "\t\tjQuery('#{$id}').attr('src','status_rrd_graph_img.php?start={$start}&graph={$graph}&database={$curdatabase}&style={$curstyle}&tmp=' + randomid);\n";
710
									}
711
								}
712
							?>
713
							window.setTimeout('update_graph_images()', 355000);
714
						}
715
						window.setTimeout('update_graph_images()', 355000);
716
					</script>
717
					</form>
718
					</td>
719
				</tr>
720
			</table>
721
		</div>
722
		</td>
723
	</tr>
724
</table>
725

    
726
<?php include("fend.inc"); ?>
727
</body>
728
</html>
(189-189/246)