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