Project

General

Profile

Download (23.9 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
	//<![CDATA[
285
		jQuery(function ($) {
286
			var options = {
287
				dateFormat: 'mm/dd/yy',
288
				timeFormat: 'hh:mm:ss',
289
				showSecond: true
290
			};
291
			$("#startDateTime").datetimepicker(options);
292
			$("#endDateTime").datetimepicker(options);
293
		});
294
	//]]>
295
	</script>
296
<?php } ?>
297

    
298
<?php
299

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

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

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

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

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

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

    
481
						if (($curcat == "captiveportal") && !empty($curzone) && !preg_match("/captiveportal-{$curzone}/i", $database))
482
							continue;
483

    
484
						$optionc = explode("-", $database);
485
						$search = array("-", ".rrd", $optionc);
486
						$replace = array(" :: ", "", $friendly);
487

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

    
517
					?>
518
					</select>
519

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

    
548
					if($curcat == "custom") {
549
						$tz = date_default_timezone_get();
550
						$tz_msg = gettext("Enter date and/or time. Current timezone:") . " $tz";
551
						$start_fmt = strftime("%m/%d/%Y %H:%M:%S", $start);
552
						$end_fmt   = strftime("%m/%d/%Y %H:%M:%S", $end);
553
						?>
554
						<?=gettext("Start:");?>
555
						<input id="startDateTime" title="<?= htmlentities($tz_msg); ?>." type="text" name="start" class="formfldunknown" size="24" value="<?= htmlentities($start_fmt); ?>" />
556
						<?=gettext("End:");?>
557
						<input id="endDateTime" title="<?= htmlentities($tz_msg); ?>." type="text" name="end" class="formfldunknown" size="24" value="<?= htmlentities($end_fmt); ?>" />
558
						<input type="submit" name="Submit" value="<?=gettext("Go"); ?>" />
559
						</td></tr>
560
						<?php
561
						$curdatabase = $curoption;
562
						$graph = "custom-$curdatabase";
563
						if(in_array($curdatabase, $custom_databases)) {
564
							$id = "{$graph}-{$curoption}-{$curdatabase}";
565
							$id = preg_replace('/\./', '_', $id);
566

    
567
							echo "<tr><td colspan=\"2\" class=\"list\">\n";
568
							echo "<img border=\"0\" name=\"{$id}\" ";
569
							echo "id=\"{$id}\" alt=\"$prettydb Graph\" ";
570
							echo "src=\"status_rrd_graph_img.php?start={$start}&amp;end={$end}&amp;database={$curdatabase}&amp;style={$curstyle}&amp;graph={$graph}\" />\n";
571
							echo "<br /><hr /><br />\n";
572
							echo "</td></tr>\n";
573
						}
574
					} else {
575
						foreach($graphs as $graph) {
576
							/* check which databases are valid for our category */
577
							foreach($ui_databases as $curdatabase) {
578
								if(! preg_match("/($curcat)/i", $curdatabase))
579
									continue;
580

    
581
								if (($curcat == "captiveportal") && !empty($curzone) && !preg_match("/captiveportal-{$curzone}/i", $curdatabase))
582
									continue;
583

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

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

    
714
									echo "\n";
715
									echo "\t\tjQuery('#{$id}').attr('src','status_rrd_graph_img.php?start={$start}&graph={$graph}&database={$curdatabase}&style={$curstyle}&tmp=' + randomid);\n";
716
									}
717
								}
718
							?>
719
							window.setTimeout('update_graph_images()', 355000);
720
						}
721
						window.setTimeout('update_graph_images()', 355000);
722
					//]]>
723
					</script>
724
					</td>
725
				</tr>
726
			</table>
727
		</div>
728
		</td>
729
	</tr>
730
</table>
731
</form>
732
<?php include("fend.inc"); ?>
733
</body>
734
</html>
(189-189/246)