Projet

Général

Profil

Télécharger (23,9 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / usr / local / www / status_rrd_graph.php @ 7e736f38

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("eight_hour", "day", "week", "month", "quarter", "year", "four_year");
238
$periods = array("absolute" => gettext("Absolute Timespans"), "current" => gettext("Current Period"), "previous" => gettext("Previous Period"));
239
$graph_length = array(
240
	"eight_hour" => 28800,
241
	"day" => 86400,
242
	"week" => 604800,
243
	"month" => 2678400,
244
	"quarter" => 7948800,
245
	"year" => 31622400,
246
	"four_year" => 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
<?php }
295
if (isset($closehead))
296
	echo "</head>";
297
?>
298

    
299
<?php
300

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

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

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

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

    
392
?>
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">
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">
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
						?>
543
						</select>
544
					<?php
545
					}
546
					?>
547

    
548
					<?php
549
					if($curcat == "custom") {
550
						$tz = date_default_timezone_get();
551
						$tz_msg = gettext("Enter date and/or time. Current timezone:") . " $tz";
552
						$start_fmt = strftime("%m/%d/%Y %H:%M:%S", $start);
553
						$end_fmt   = strftime("%m/%d/%Y %H:%M:%S", $end);
554
						?>
555
						<?=gettext("Start:");?>
556
						<input id="startDateTime" title="<?= htmlentities($tz_msg); ?>." type="text" name="start" class="formfldunknown" size="24" maxlength="32" value="<?= htmlentities($start_fmt); ?>"/>
557
						<?=gettext("End:");?>
558
						<input id="endDateTime" title="<?= htmlentities($tz_msg); ?>." type="text" name="end" class="formfldunknown" size="24" maxlength="32" value="<?= htmlentities($end_fmt); ?>"/>
559
						<input type="submit" name="Submit" value="<?=gettext("Go"); ?>"/>
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 "<table><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></table>\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 "<table><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></table>\n";
642
								}
643
							}
644
						}
645
					}
646
					?>
647
					</td>
648
				</tr>
649
				<tr>
650
					<td colspan="2" class="list">
651
					<script type="text/javascript">
652
//					<![CDATA[
653
						function update_graph_images() {
654
							//alert('updating');
655
							var randomid = Math.floor(Math.random()*11);
656
							<?php
657
							foreach($graphs as $graph) {
658
								/* check which databases are valid for our category */
659
								foreach($ui_databases as $curdatabase) {
660
									if(! stristr($curdatabase, $curcat)) {
661
										continue;
662
									}
663
									$optionc = explode("-", $curdatabase);
664
									$search = array("-", ".rrd", $optionc);
665
									$replace = array(" :: ", "", $friendly);
666
									switch($curoption) {
667
										case "outbound":
668
											/* make sure we do not show the placeholder databases in the outbound view */
669
											if((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) {
670
												continue 2;
671
											}
672
											/* only show interfaces with a gateway */
673
											$optionc = "$optionc[0]";
674
											if(!interface_has_gateway($optionc)) {
675
												if(!isset($gateways_arr))
676
													if(preg_match("/quality/i", $curdatabase))
677
														$gateways_arr = return_gateways_array();
678
													else
679
														$gateways_arr = array();
680
												$found_gateway = false;
681
												foreach ($gateways_arr as $gw) {
682
													if ($gw['name'] == $optionc) {
683
														$found_gateway = true;
684
														break;
685
													}
686
												}
687
												if(!$found_gateway) {
688
													continue 2;
689
												}
690
											}
691
											if(! preg_match("/(^$optionc-|-$optionc\\.)/i", $curdatabase)) {
692
												continue 2;
693
											}
694
											break;
695
										case "allgraphs":
696
											/* make sure we do not show the placeholder databases in the all view */
697
											if((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) {
698
												continue 2;
699
											}
700
											break;
701
										default:
702
											/* just use the name here */
703
											if(! preg_match("/(^$curoption-|-$curoption\\.)/i", $curdatabase)) {
704
												continue 2;
705
											}
706
									}
707
									$dates = get_dates($curperiod, $graph);
708
									$start = $dates['start'];
709
									if($curperiod == "current") {
710
										$end = $dates['end'];
711
									}
712
									/* generate update events utilizing jQuery('') feature */
713
									$id = "{$graph}-{$curoption}-{$curdatabase}";
714
									$id = preg_replace('/\./', '_', $id);
715

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

    
735
<?php include("fend.inc"); ?>
736
</body>
737
</html>
(189-189/246)