Project

General

Profile

Download (22.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['period']) {
69
	$curperiod = $_GET['period'];
70
} else {
71
	if(! empty($config['rrd']['period'])) {
72
		$curperiod = $config['rrd']['period'];
73
	} else {
74
		$curperiod = "absolute";
75
	}
76
}
77

    
78
if ($_GET['option']) {
79
	$curoption = $_GET['option'];
80
} else {
81
	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
			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
			}
118
		case "vpnusers":
119
			foreach($databases as $database) {
120
				if(preg_match("/[-]vpnusers\.rrd/i", $database)) {
121
					/* 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
		case "captiveportal":
128
			$curoption = "allgraphs";
129
			break;
130
		default:
131
			$curoption = "wan";
132
			break;
133
	}
134
}
135

    
136
$now = time();
137
if($curcat == "custom") {
138
	if (is_numeric($_GET['start'])) {
139
		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
			$start = $now - (8 * 3600);
148
		}
149
	} else {
150
		$start = $now - (8 * 3600);
151
	}
152
}
153

    
154
if (is_numeric($_GET['end'])) {
155
        $end = $_GET['end'];
156
} 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
} else {
163
        $end = $now;
164
}
165

    
166
/* this should never happen */
167
if($end < $start) {
168
	log_error("start $start is smaller than end $end");
169
        $end = $now;
170
}
171

    
172
$seconds = $end - $start;
173

    
174
$styles = array('inverse' => gettext('Inverse'),
175
		'absolute' => gettext('Absolute'));
176

    
177
// Set default and override later
178
$curstyle = "inverse";
179

    
180
if ($_GET['style']) {
181
	foreach($styles as $style) 
182
		if(strtoupper($style) == strtoupper($_GET['style'])) 
183
			$curstyle = $_GET['style'];
184
} else {
185
	if(! empty($config['rrd']['style'])) {
186
		$curstyle = $config['rrd']['style'];
187
	} else {
188
		$curstyle = "inverse";
189
	}
190
}
191

    
192
/* sort names reverse so WAN comes first */
193
rsort($databases);
194

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

    
209
/* additional menu choices for the custom tab */
210
$dbheader_custom = array("system-throughput.rrd");
211

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

    
233
$graphs = array("8hour", "day", "week", "month", "quarter", "year", "4year");
234
$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

    
244
$pgtitle = array(gettext("Status"),gettext("RRD Graphs"));
245

    
246
$closehead = false;
247
include("head.inc");
248
?>
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
	<?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
	<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

    
274
function get_dates($curperiod, $graph) {
275
	global $graph_length;
276
	$now = time();
277
	$end = $now;
278

    
279
	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

    
289
		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
	}
358
	// 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
	$dates = array();
360
	$dates['start'] = $start;
361
	$dates['end'] = $end;
362
	return $dates;
363
}
364

    
365
?>
366
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
367
<?php include("fbegin.inc"); ?>
368
<?php if ($input_errors && count($input_errors)) { print_input_errors($input_errors); } ?>
369
<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
			        $tab_array[] = array(gettext("System"), $tabactive, "status_rrd_graph.php?cat=system");
378
				if($curcat == "traffic") { $tabactive = True; } else { $tabactive = False; }
379
			        $tab_array[] = array(gettext("Traffic"), $tabactive, "status_rrd_graph.php?cat=traffic");
380
				if($curcat == "packets") { $tabactive = True; } else { $tabactive = False; }
381
			        $tab_array[] = array(gettext("Packets"), $tabactive, "status_rrd_graph.php?cat=packets");
382
				if($curcat == "quality") { $tabactive = True; } else { $tabactive = False; }
383
			        $tab_array[] = array(gettext("Quality"), $tabactive, "status_rrd_graph.php?cat=quality");
384
				if($queues) {
385
					if($curcat == "queues") { $tabactive = True; } else { $tabactive = False; }
386
						$tab_array[] = array(gettext("Queues"), $tabactive, "status_rrd_graph.php?cat=queues");
387
					if($curcat == "queuedrops") { $tabactive = True; } else { $tabactive = False; }
388
						$tab_array[] = array(gettext("QueueDrops"), $tabactive, "status_rrd_graph.php?cat=queuedrops");
389
				}
390
				if($wireless) {
391
					if($curcat == "wireless") { $tabactive = True; } else { $tabactive = False; }
392
				        $tab_array[] = array(gettext("Wireless"), $tabactive, "status_rrd_graph.php?cat=wireless");
393
				}
394
				if($cellular) {
395
					if($curcat == "cellular") { $tabactive = True; } else { $tabactive = False; }
396
				        $tab_array[] = array(gettext("Cellular"), $tabactive, "status_rrd_graph.php?cat=cellular");
397
				}
398
				if($vpnusers) {
399
					if($curcat == "vpnusers") { $tabactive = True; } else { $tabactive = False; }
400
				        $tab_array[] = array("VPN", $tabactive, "status_rrd_graph.php?cat=vpnusers");
401
				}
402
				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
				if($curcat == "custom") { $tabactive = True; } else { $tabactive = False; }
407
			        $tab_array[] = array(gettext("Custom"), $tabactive, "status_rrd_graph.php?cat=custom");
408
				if($curcat == "settings") { $tabactive = True; } else { $tabactive = False; }
409
			        $tab_array[] = array(gettext("Settings"), $tabactive, "status_rrd_graph_settings.php");
410
			        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
					<?=gettext("Graphs:");?>
424
					<select name="option" class="formselect" style="z-index: -10;" onchange="document.form1.submit()">
425
					<?php
426

    
427
					if($curcat == "custom") {
428
						foreach ($custom_databases as $db => $database) {
429
							$optionc = explode("-", $database);
430
							$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
								echo " selected";
436
							}
437
							echo ">" . htmlspecialchars($prettyprint) . "</option>\n";
438
						}
439
					}
440
					foreach ($ui_databases as $db => $database) {
441
						if(! preg_match("/($curcat)/i", $database)) {
442
							continue;
443
						}
444
						$optionc = explode("-", $database);
445
						$search = array("-", ".rrd", $optionc);
446
						$replace = array(" :: ", "", $friendly);
447

    
448
						switch($curcat) {
449
							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
							case "system":
455
								$optionc = str_replace($search, $replace, $optionc[1]);
456
								echo "<option value=\"$optionc\"";
457
								$prettyprint = ucwords(str_replace($search, $replace, $optionc));
458
								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
								if(empty($friendly)) {
464
									$friendly = $optionc;
465
								}
466
								$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
							echo " selected";
473
						}
474
						echo ">" . htmlspecialchars($prettyprint) . "</option>\n";
475
					}
476

    
477
					?>
478
					</select>
479

    
480
					<?=gettext("Style:");?>
481
					<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
					</select>
490
					
491
					<?php
492
					if($curcat <> "custom") {
493
					?>
494
						<?=gettext("Period:");?>
495
						<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
							if ($period == $curperiod) echo " selected";
500
							echo ">" . htmlspecialchars($value) . "</option>\n";
501
						}
502
					}
503
					?>
504
					</select>
505
					<?php
506

    
507
					if($curcat == "custom") {
508
						$tz = date_default_timezone_get();
509
						$tz_msg = gettext("Enter date and/or time. Current timezone:") . " $tz";
510
						$start_fmt = strftime("%m/%d/%Y %H:%M:%S", $start);
511
						$end_fmt   = strftime("%m/%d/%Y %H:%M:%S", $end);
512
						?>
513
						<?=gettext("Start:");?>
514
						<input id="startDateTime" title="<?= htmlentities($tz_msg); ?>." type="text" name="start" class="formfldunknown" size="24" length="32" value="<?= htmlentities($start_fmt); ?>">
515
						<?=gettext("End:");?>
516
						<input id="endDateTime" title="<?= htmlentities($tz_msg); ?>." type="text" name="end" class="formfldunknown" size="24" length="32" value="<?= htmlentities($end_fmt); ?>">
517
						<input type="submit" name="Submit" value="<?=gettext("Go"); ?>">
518
						<?php
519
						$curdatabase = $curoption;
520
						$graph = "custom-$curdatabase";
521
						if(in_array($curdatabase, $custom_databases)) {
522
							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
								$optionc = explode("-", $curdatabase);
537
								$search = array("-", ".rrd", $optionc);
538
								$replace = array(" :: ", "", $friendly);
539
								switch($curoption) {
540
									case "outbound":
541
										/* 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
										/* only show interfaces with a gateway */
546
										$optionc = "$optionc[0]";
547
										if(!interface_has_gateway($optionc)) {
548
											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
											$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
												continue 2;
563
											}
564
										}
565
										if(! preg_match("/(^$optionc-|-$optionc\\.)/i", $curdatabase)) {
566
											continue 2;
567
										}
568
										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
										if(! preg_match("/(^$curoption-|-$curoption\\.)/i", $curdatabase)) {
578
											continue 2;
579
										}
580
								}
581
								if(in_array($curdatabase, $ui_databases)) {
582
									$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
							}
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
							foreach($graphs as $graph) {
606
								/* check which databases are valid for our category */
607
								foreach($ui_databases as $curdatabase) {
608
									if(! stristr($curdatabase, $curcat)) {
609
										continue;
610
									}
611
									$optionc = explode("-", $curdatabase);
612
									$search = array("-", ".rrd", $optionc);
613
									$replace = array(" :: ", "", $friendly);
614
									switch($curoption) {
615
										case "outbound":
616
											/* 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
											$optionc = "$optionc[0]";
622
											if(!interface_has_gateway($optionc)) {
623
												if(!isset($gateways_arr))
624
													if(preg_match("/quality/i", $curdatabase))
625
														$gateways_arr = return_gateways_array();
626
													else
627
														$gateways_arr = array();
628
												$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
													continue 2;
637
												}
638
											}
639
											if(! preg_match("/(^$optionc-|-$optionc\\.)/i", $curdatabase)) {
640
												continue 2;
641
											}
642
											break;
643
										case "allgraphs":
644
											/* 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
										default:
650
											/* just use the name here */
651
											if(! preg_match("/(^$curoption-|-$curoption\\.)/i", $curdatabase)) {
652
												continue 2;
653
											}
654
									}
655
									$dates = get_dates($curperiod, $graph);
656
									$start = $dates['start'];
657
									if($curperiod == "current") {
658
										$end = $dates['end'];
659
									}
660
									/* generate update events utilizing jQuery('') feature */
661
									echo "\n";
662
									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
									}
664
								}
665
							?>
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

    
679
<?php include("fend.inc"); ?>
680
</body>
681
</html>
(184-184/242)