1
|
<?php
|
2
|
/*
|
3
|
guiconfig.inc
|
4
|
by Scott Ullrich, Copyright 2004, All rights reserved.
|
5
|
originally based on of m0n0wall (http://m0n0.ch/wall)
|
6
|
|
7
|
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
8
|
All rights reserved.
|
9
|
|
10
|
Redistribution and use in source and binary forms, with or without
|
11
|
modification, are permitted provided that the following conditions are met:
|
12
|
|
13
|
1. Redistributions of source code must retain the above copyright notice,
|
14
|
this list of conditions and the following disclaimer.
|
15
|
|
16
|
2. Redistributions in binary form must reproduce the above copyright
|
17
|
notice, this list of conditions and the following disclaimer in the
|
18
|
documentation and/or other materials provided with the distribution.
|
19
|
|
20
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
21
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
22
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
23
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
24
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
25
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
26
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
27
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29
|
POSSIBILITY OF SUCH DAMAGE.
|
30
|
*/
|
31
|
/*
|
32
|
pfSense_MODULE: base
|
33
|
*/
|
34
|
|
35
|
/* Include authentication routines */
|
36
|
/* THIS MUST BE ABOVE ALL OTHER CODE */
|
37
|
if(!$nocsrf) {
|
38
|
function csrf_startup() {
|
39
|
csrf_conf('rewrite-js', '/csrf/csrf-magic.js');
|
40
|
}
|
41
|
require_once("csrf/csrf-magic.php");
|
42
|
}
|
43
|
require_once("authgui.inc");
|
44
|
|
45
|
/* make sure nothing is cached */
|
46
|
if (!$omit_nocacheheaders) {
|
47
|
header("Expires: 0");
|
48
|
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
|
49
|
header("Cache-Control: no-store, no-cache, must-revalidate");
|
50
|
header("Cache-Control: post-check=0, pre-check=0", false);
|
51
|
header("Pragma: no-cache");
|
52
|
}
|
53
|
|
54
|
/* parse the configuration and include all configuration functions */
|
55
|
require_once("functions.inc");
|
56
|
|
57
|
/* Pull in all the gui related display classes) */
|
58
|
foreach (scandir("/usr/local/www/classes/") as $file) {
|
59
|
if (stristr($file, ".inc") !== false) {
|
60
|
require_once("classes/{$file}");
|
61
|
}
|
62
|
}
|
63
|
/*
|
64
|
* if user has selected a custom template, use it.
|
65
|
* otherwise default to pfsense template
|
66
|
*/
|
67
|
if($config['theme'] <> "")
|
68
|
$g['theme'] = $config['theme'];
|
69
|
else
|
70
|
$g['theme'] = "pfsense";
|
71
|
|
72
|
/*
|
73
|
* If this device is an apple ipod/iphone
|
74
|
* switch the theme to one that works with it.
|
75
|
*/
|
76
|
$apple_ua = array("iPhone","iPod", "iPad");
|
77
|
foreach($apple_ua as $useragent)
|
78
|
if(strstr($_SERVER['HTTP_USER_AGENT'], $useragent))
|
79
|
$g['theme'] = "pfsense";
|
80
|
|
81
|
/* Set the default interface language */
|
82
|
if($config['system']['language'] <> "") {
|
83
|
$g['language'] = $config['system']['language'];
|
84
|
} elseif ($g['language'] == "") {
|
85
|
$g['language'] = 'en_US';
|
86
|
}
|
87
|
|
88
|
set_language($g['language']);
|
89
|
|
90
|
/* used by progress bar */
|
91
|
$lastseen = "-1";
|
92
|
|
93
|
$navlevelsep = ": "; /* navigation level separator string */
|
94
|
$mandfldhtml = ""; /* display this before mandatory input fields */
|
95
|
$mandfldhtmlspc = ""; /* same as above, but with spacing */
|
96
|
|
97
|
/* Some ajax scripts still need access to GUI */
|
98
|
if(!$ignorefirmwarelock) {
|
99
|
if (is_subsystem_dirty('firmwarelock')) {
|
100
|
if (!$d_isfwfile) {
|
101
|
header("Location: system_firmware.php");
|
102
|
exit;
|
103
|
} else {
|
104
|
return;
|
105
|
}
|
106
|
}
|
107
|
}
|
108
|
|
109
|
$firewall_rules_dscp_types = array("af11",
|
110
|
"af12",
|
111
|
"af13",
|
112
|
"af21",
|
113
|
"af22",
|
114
|
"af23",
|
115
|
"af31",
|
116
|
"af32",
|
117
|
"af33",
|
118
|
"af41",
|
119
|
"af42",
|
120
|
"af43",
|
121
|
"EF",
|
122
|
"1-64",
|
123
|
"0x10",
|
124
|
"0x04-0xfc");
|
125
|
|
126
|
$auth_server_types = array(
|
127
|
'ldap' => "LDAP",
|
128
|
'radius' => "Radius");
|
129
|
|
130
|
$ldap_urltypes = array(
|
131
|
'TCP - Standard' => 389,
|
132
|
'SSL - Encrypted' => 636);
|
133
|
|
134
|
$ldap_scopes = array(
|
135
|
'one' => "One Level",
|
136
|
'subtree' => "Entire Subtree");
|
137
|
|
138
|
$ldap_protvers = array(
|
139
|
2,
|
140
|
3);
|
141
|
|
142
|
$ldap_templates = array(
|
143
|
|
144
|
'open' => array(
|
145
|
'desc' => "OpenLDAP",
|
146
|
'attr_user' => "cn",
|
147
|
'attr_group' => "cn",
|
148
|
'attr_member' => "member"),
|
149
|
|
150
|
'msad' => array(
|
151
|
'desc' => "Microsoft AD",
|
152
|
'attr_user' => "samAccountName",
|
153
|
'attr_group' => "cn",
|
154
|
'attr_member' => "memberOf"),
|
155
|
|
156
|
'edir' => array(
|
157
|
'desc' => "Novell eDirectory",
|
158
|
'attr_user' => "cn",
|
159
|
'attr_group' => "cn",
|
160
|
'attr_member' => "uniqueMember"));
|
161
|
|
162
|
$radius_srvcs = array(
|
163
|
'both' => "Authentication and Accounting",
|
164
|
'auth' => "Authentication",
|
165
|
'acct' => "Accounting");
|
166
|
|
167
|
$netbios_nodetypes = array(
|
168
|
'0' => "none",
|
169
|
'1' => "b-node",
|
170
|
'2' => "p-node",
|
171
|
'4' => "m-node",
|
172
|
'5' => "h-node");
|
173
|
|
174
|
/* some well knows ports */
|
175
|
$wkports = array(
|
176
|
5999 => "CVSup",
|
177
|
53 => "DNS",
|
178
|
21 => "FTP",
|
179
|
3000 => "HBCI",
|
180
|
80 => "HTTP",
|
181
|
443 => "HTTPS",
|
182
|
5190 => "ICQ",
|
183
|
113 => "IDENT/AUTH",
|
184
|
143 => "IMAP",
|
185
|
993 => "IMAP/S",
|
186
|
4500 => "IPsec NAT-T",
|
187
|
500 => "ISAKMP",
|
188
|
1701 => "L2TP",
|
189
|
389 => "LDAP",
|
190
|
1755 => "MMS/TCP",
|
191
|
7000 => "MMS/UDP",
|
192
|
445 => "MS DS",
|
193
|
3389 => "MS RDP",
|
194
|
1512 => "MS WINS",
|
195
|
1863 => "MSN",
|
196
|
119 => "NNTP",
|
197
|
123 => "NTP",
|
198
|
138 => "NetBIOS-DGM",
|
199
|
137 => "NetBIOS-NS",
|
200
|
139 => "NetBIOS-SSN",
|
201
|
1194 => "OpenVPN",
|
202
|
110 => "POP3",
|
203
|
995 => "POP3/S",
|
204
|
1723 => "PPTP",
|
205
|
1812 => "RADIUS",
|
206
|
1813 => "RADIUS accounting",
|
207
|
5004 => "RTP",
|
208
|
5060 => "SIP",
|
209
|
25 => "SMTP",
|
210
|
465 => "SMTP/S",
|
211
|
161 => "SNMP",
|
212
|
162 => "SNMP-Trap",
|
213
|
22 => "SSH",
|
214
|
3478 => "STUN",
|
215
|
587 => "SUBMISSION",
|
216
|
3544 => "Teredo",
|
217
|
23 => "Telnet",
|
218
|
69 => "TFTP",
|
219
|
5900 => "VNC");
|
220
|
|
221
|
/* TCP flags */
|
222
|
$tcpflags = array("fin", "syn", "rst", "psh", "ack", "urg");
|
223
|
|
224
|
$specialnets = array("pptp" => "PPTP clients", "pppoe" => "PPPoE clients", "l2tp" => "L2TP clients");
|
225
|
|
226
|
$spiflist = get_configured_interface_with_descr(false, true);
|
227
|
foreach ($spiflist as $ifgui => $ifdesc) {
|
228
|
$specialnets[$ifgui] = $ifdesc . " net";
|
229
|
$specialnets[$ifgui . 'ip'] = $ifdesc . " address";
|
230
|
}
|
231
|
|
232
|
$medias = array("auto" => "autoselect", "100full" => "100BASE-TX full-duplex",
|
233
|
"100half" => "100BASE-TX half-duplex", "10full" => "10BASE-T full-duplex",
|
234
|
"10half" => "10BASE-T half-duplex");
|
235
|
|
236
|
$wlan_modes = array("bss" => "Infrastructure (BSS)", "adhoc" => "Ad-hoc (IBSS)",
|
237
|
"hostap" => "Access Point");
|
238
|
|
239
|
/* platforms that support firmware updating */
|
240
|
$fwupplatforms = array('pfSense', 'net45xx', 'net48xx', 'generic-pc', 'embedded', 'wrap', 'nanobsd');
|
241
|
|
242
|
function do_input_validation($postdata, $reqdfields, $reqdfieldsn, $input_errors) {
|
243
|
|
244
|
/* check for bad control characters */
|
245
|
foreach ($postdata as $pn => $pd) {
|
246
|
if (is_string($pd) && preg_match("/[\\x00-\\x08\\x0b\\x0c\\x0e-\\x1f]/", $pd)) {
|
247
|
$input_errors[] = "The field '" . $pn . "' contains invalid characters.";
|
248
|
}
|
249
|
}
|
250
|
|
251
|
for ($i = 0; $i < count($reqdfields); $i++) {
|
252
|
if ($_POST[$reqdfields[$i]] == "" && $_REQUEST[$reqdfields[$i]] == "") {
|
253
|
$input_errors[] = "The field '" . $reqdfieldsn[$i] . "' is required.";
|
254
|
}
|
255
|
}
|
256
|
}
|
257
|
|
258
|
function print_input_errors($input_errors) {
|
259
|
global $g;
|
260
|
|
261
|
print <<<EOF
|
262
|
<div id='inputerrorsdiv' name='inputerrorsdiv'>
|
263
|
<p>
|
264
|
<table border="0" cellspacing="0" cellpadding="4" width="100%">
|
265
|
<tr>
|
266
|
<td class="inputerrorsleft">
|
267
|
<img src="/themes/{$g['theme']}/images/icons/icon_error.gif">
|
268
|
</td>
|
269
|
<td class="inputerrorsright">
|
270
|
<span class="errmsg"><p>
|
271
|
The following input errors were detected:
|
272
|
<ul>
|
273
|
EOF;
|
274
|
foreach ($input_errors as $ierr) {
|
275
|
echo "<li>" . htmlspecialchars($ierr) . "</li>";
|
276
|
}
|
277
|
|
278
|
print <<<EOF2
|
279
|
</ul>
|
280
|
</span>
|
281
|
</td></tr>
|
282
|
</table>
|
283
|
</div>
|
284
|
</p> <br>
|
285
|
EOF2;
|
286
|
|
287
|
}
|
288
|
|
289
|
function verify_gzip_file($fname) {
|
290
|
|
291
|
$returnvar = mwexec("/usr/bin/gzip -t " . escapeshellarg($fname));
|
292
|
if ($returnvar != 0)
|
293
|
return 0;
|
294
|
else
|
295
|
return 1;
|
296
|
}
|
297
|
|
298
|
function print_info_box_np($msg, $name="apply",$value="", $showapply=false) {
|
299
|
global $g, $nifty_redbox, $nifty_blackbox, $nifty_background;
|
300
|
|
301
|
if(empty($value)) {
|
302
|
$value = gettext("Apply changes");
|
303
|
}
|
304
|
|
305
|
// Set the Nifty background color if one is not set already (defaults to white)
|
306
|
if($nifty_background == "")
|
307
|
$nifty_background = "#FFF";
|
308
|
|
309
|
if(stristr($msg, gettext("apply")) != false || stristr($msg, gettext("save")) != false || stristr($msg, gettext("create")) != false || $showapply) {
|
310
|
$savebutton = "<td class='infoboxsave'>";
|
311
|
$savebutton .= "<input name=\"{$name}\" type=\"submit\" class=\"formbtn\" id=\"${name}\" value=\"{$value}\">";
|
312
|
if($_POST['if'])
|
313
|
$savebutton .= "<input type='hidden' name='if' value='{$_POST['if']}'>";
|
314
|
$savebutton.="</td>";
|
315
|
}
|
316
|
$nifty_redbox = "#990000";
|
317
|
$nifty_blackbox = "#000000";
|
318
|
|
319
|
$themename = $g['theme'];
|
320
|
|
321
|
if(file_exists("/usr/local/www/themes/{$themename}/tabcontrols.php")) {
|
322
|
$toeval = file_get_contents("/usr/local/www/themes/{$themename}/tabcontrols.php");
|
323
|
eval($toeval);
|
324
|
}
|
325
|
|
326
|
if(file_exists("/usr/local/www/themes/{$themename}/infobox.php")) {
|
327
|
$toeval = file_get_contents("/usr/local/www/themes/{$themename}/infobox.php");
|
328
|
eval($toeval);
|
329
|
}
|
330
|
|
331
|
if(!$savebutton) {
|
332
|
$savebutton = '<td class="infoboxsave"><input value="Close" type="button" onClick="jQuery(\'#redboxtable\').hide();"></td>';
|
333
|
}
|
334
|
|
335
|
echo <<<EOFnp
|
336
|
<table class='infobox' id='redboxtable'>
|
337
|
<tr>
|
338
|
<td>
|
339
|
<div class='infoboxnp' id='redbox'>
|
340
|
<table class='infoboxnptable2'>
|
341
|
<tr>
|
342
|
<td class='infoboxnptd'>
|
343
|
<img class='infoboxnpimg' src="/themes/{$g['theme']}/images/icons/icon_exclam.gif" >
|
344
|
</td>
|
345
|
<td class='infoboxnptd2'>
|
346
|
<b>{$msg}</b>
|
347
|
</td>
|
348
|
{$savebutton}
|
349
|
</tr>
|
350
|
</table>
|
351
|
</div>
|
352
|
<div>
|
353
|
<p/>
|
354
|
</div>
|
355
|
</td>
|
356
|
</tr>
|
357
|
</table>
|
358
|
<script type="text/javascript">
|
359
|
NiftyCheck();
|
360
|
Rounded("div#redbox","all","{$nifty_background}","{$nifty_redbox}","smooth");
|
361
|
Rounded("td#blackbox","all","{$nifty_background}","{$nifty_blackbox}","smooth");
|
362
|
</script>
|
363
|
EOFnp;
|
364
|
|
365
|
}
|
366
|
|
367
|
function print_info_box_np_undo($msg, $name="apply",$value="Apply changes", $undo) {
|
368
|
global $g;
|
369
|
|
370
|
if(stristr($msg, "apply") != false || stristr($msg, "save") != false || stristr($msg, "create") != false) {
|
371
|
$savebutton = "<td class='infoboxsave'><nobr>";
|
372
|
$savebutton .= " <input type=\"button\" value=\"Undo\" onClick=\"document.location='{$undo}'\">";
|
373
|
$savebutton .= " <input name=\"{$name}\" type=\"submit\" class=\"formbtn\" id=\"${name}\" value=\"{$value}\">";
|
374
|
$savebutton.="</nobr></td>";
|
375
|
if($_POST['if'])
|
376
|
$savebutton .= "<input type='hidden' name='if' value='{$_POST['if']}'>";
|
377
|
}
|
378
|
$nifty_redbox = "#990000";
|
379
|
$nifty_blackbox = "#000000";
|
380
|
|
381
|
$themename = $g['theme'];
|
382
|
|
383
|
if(file_exists("/usr/local/www/themes/{$themename}/tabcontrols.php")) {
|
384
|
$toeval = file_get_contents("/usr/local/www/themes/{$themename}/tabcontrols.php");
|
385
|
eval($toeval);
|
386
|
}
|
387
|
|
388
|
if(file_exists("/usr/local/www/themes/{$themename}/infobox.php")) {
|
389
|
$toeval = file_get_contents("/usr/local/www/themes/{$themename}/infobox.php");
|
390
|
eval($toeval);
|
391
|
}
|
392
|
|
393
|
|
394
|
if(!$savebutton) {
|
395
|
$savebutton = '<td class="infoboxsave"><input value="Close" type="button" onClick="jQuery(\'#redboxtable\').hide();"></td>';
|
396
|
}
|
397
|
|
398
|
echo <<<EOFnp
|
399
|
<table class='infobox' id='redboxtable'>
|
400
|
<tr>
|
401
|
<td>
|
402
|
<div class='infoboxnp' id='redbox'>
|
403
|
<table class='infoboxnptable2'>
|
404
|
<tr>
|
405
|
<td class='infoboxnptd'>
|
406
|
<img class='infoboxnpimg' src="/themes/{$g['theme']}/images/icons/icon_exclam.gif" >
|
407
|
</td>
|
408
|
<td class='infoboxnptd2'>
|
409
|
<b>{$msg}</b>
|
410
|
</td>
|
411
|
{$savebutton}
|
412
|
{$undobutton}
|
413
|
</tr>
|
414
|
</table>
|
415
|
</div>
|
416
|
<div>
|
417
|
<p/>
|
418
|
</div>
|
419
|
</td>
|
420
|
</tr>
|
421
|
</table>
|
422
|
<script type="text/javascript">
|
423
|
NiftyCheck();
|
424
|
Rounded("div#redbox","all","#FFF","{$nifty_redbox}","smooth");
|
425
|
Rounded("td#blackbox","all","#FFF","{$nifty_blackbox}","smooth");
|
426
|
</script>
|
427
|
EOFnp;
|
428
|
|
429
|
}
|
430
|
|
431
|
function print_info_box($msg) {
|
432
|
print_info_box_np($msg);
|
433
|
}
|
434
|
|
435
|
function get_std_save_message($ok) {
|
436
|
global $d_sysrebootreqd_path;
|
437
|
$filter_related = false;
|
438
|
$filter_pages = array("nat", "filter");
|
439
|
$to_return = "The changes have been applied successfully.";
|
440
|
foreach($filter_pages as $fp)
|
441
|
if(stristr($_SERVER['SCRIPT_FILENAME'], $fp))
|
442
|
$filter_related = true;
|
443
|
if($filter_related)
|
444
|
$to_return .= "<br/>You can also <a href='status_filter_reload.php'>monitor</a> the filter reload progress.";
|
445
|
return $to_return;
|
446
|
}
|
447
|
|
448
|
function pprint_address($adr) {
|
449
|
global $specialnets;
|
450
|
|
451
|
if (isset($adr['any'])) {
|
452
|
$padr = "*";
|
453
|
} else if ($adr['network']) {
|
454
|
$padr = $specialnets[$adr['network']];
|
455
|
} else {
|
456
|
$padr = $adr['address'];
|
457
|
}
|
458
|
|
459
|
if (isset($adr['not']))
|
460
|
$padr = "! " . $padr;
|
461
|
|
462
|
return $padr;
|
463
|
}
|
464
|
|
465
|
function pprint_port($port) {
|
466
|
global $wkports;
|
467
|
|
468
|
$pport = "";
|
469
|
|
470
|
if (!$port)
|
471
|
return "*";
|
472
|
else {
|
473
|
$srcport = explode("-", $port);
|
474
|
if ((!$srcport[1]) || ($srcport[0] == $srcport[1])) {
|
475
|
$pport = $srcport[0];
|
476
|
if ($wkports[$srcport[0]]) {
|
477
|
$pport .= " (" . $wkports[$srcport[0]] . ")";
|
478
|
}
|
479
|
} else
|
480
|
$pport .= $srcport[0] . " - " . $srcport[1];
|
481
|
}
|
482
|
|
483
|
return $pport;
|
484
|
}
|
485
|
|
486
|
function firewall_check_for_advanced_options(&$item) {
|
487
|
$item_set = "";
|
488
|
if($item['max'])
|
489
|
$item_set .= "max {$item['max']} ";
|
490
|
if($item['max-src-nodes'])
|
491
|
$item_set .= "max-src-nodes {$item['max-src-nodes']} ";
|
492
|
if($item['max-src-conn'])
|
493
|
$item_set .= "max-src-conn {$item['max-src-conn']} ";
|
494
|
if($item['max-src-states'])
|
495
|
$item_set .= "max-src-states {$item['max-src-states']} ";
|
496
|
if($item['statetype'] != "keep state" && $item['statetype'] != "")
|
497
|
$item_set .= "statetype {$item['statetype']} ";
|
498
|
if($item['statetimeout'])
|
499
|
$item_set .= "statetimeout {$item['statetimeout']} ";
|
500
|
if($item['nosync'])
|
501
|
$item_set .= "nosync ";
|
502
|
if($item['max-src-conn-rate'])
|
503
|
$item_set .= "max-src-conn-rate {$item['max-src-conn-rate']} ";
|
504
|
if($item['max-src-conn-rates'])
|
505
|
$item_set .= "max-src-conn-rates {$item['max-src-conn-rates']} ";
|
506
|
if($item['gateway'])
|
507
|
$item_set .= "gateway {$item['gateway']} ";
|
508
|
if($item['dnpipe'])
|
509
|
$item_set .= "limiter {$item['dnpipe']} ";
|
510
|
if($item['pdnpipe'])
|
511
|
$item_set .= "limiter {$item['pdnpipe']} ";
|
512
|
if($item['l7container'])
|
513
|
$item_set .= "layer7 {$item['l7container']} ";
|
514
|
if($item['tag'])
|
515
|
$item_set .= "tag {$item['tag']} ";
|
516
|
if($item['tagged'])
|
517
|
$item_set .= "tagged {$item['tagged']} ";
|
518
|
if(isset($item['allowopts']))
|
519
|
$item_set .= "allowopts ";
|
520
|
if(isset($item['disablereplyto']))
|
521
|
$item_set .= "disable reply-to ";
|
522
|
if($item['tcpflags_any'] || $item['tcpflags1'] || $item['tcpflags2'])
|
523
|
$item_set .= "tcpflags set";
|
524
|
|
525
|
return $item_set;
|
526
|
}
|
527
|
|
528
|
function gentitle($title) {
|
529
|
global $navlevelsep;
|
530
|
if(!is_array($title))
|
531
|
return $title;
|
532
|
else
|
533
|
return join($navlevelsep, $title);
|
534
|
}
|
535
|
|
536
|
function genhtmltitle($title) {
|
537
|
global $config;
|
538
|
return gentitle($title);
|
539
|
}
|
540
|
|
541
|
/* update the changedesc and changecount(er) variables */
|
542
|
function update_changedesc($update) {
|
543
|
global $changedesc;
|
544
|
global $changecount;
|
545
|
|
546
|
$changedesc .= " {$update}";
|
547
|
$changecount++;
|
548
|
}
|
549
|
|
550
|
function clear_log_file($logfile = "/var/log/system.log") {
|
551
|
global $config, $g;
|
552
|
exec("/usr/bin/killall syslogd");
|
553
|
if(isset($config['system']['disablesyslogclog'])) {
|
554
|
unlink($logfile);
|
555
|
touch($logfile);
|
556
|
} else {
|
557
|
if(isset($config['system']['usefifolog']))
|
558
|
exec("/usr/sbin/fifolog_create -s 511488 {$logfile}");
|
559
|
else
|
560
|
exec("/usr/sbin/clog -i -s 511488 {$logfile}");
|
561
|
}
|
562
|
system_syslogd_start();
|
563
|
}
|
564
|
|
565
|
function dump_clog($logfile, $tail, $withorig = true, $grepfor = "", $grepinvert = "") {
|
566
|
global $g, $config;
|
567
|
$sor = isset($config['syslog']['reverse']) ? "-r" : "";
|
568
|
$logarr = "";
|
569
|
$grepline = " ";
|
570
|
if(is_array($grepfor))
|
571
|
foreach($grepfor as $agrep)
|
572
|
$grepline .= " | grep \"$agrep\"";
|
573
|
if(is_array($grepinvert))
|
574
|
foreach($grepinvert as $agrep)
|
575
|
$grepline .= " | grep -v \"$agrep\"";
|
576
|
if(file_exists($logfile) && filesize($logfile) == 0) {
|
577
|
$logarr = array("Log file started.");
|
578
|
} else {
|
579
|
if($config['system']['disablesyslogclog']) {
|
580
|
exec("cat {$logfile}{$grepline} | /usr/bin/tail {$sor} -n {$tail}", $logarr);
|
581
|
} else {
|
582
|
if(isset($config['system']['usefifolog']))
|
583
|
exec("/usr/sbin/fifolog_reader {$logfile}{$grepline} | /usr/bin/tail {$sor} -n {$tail}", $logarr);
|
584
|
else
|
585
|
exec("/usr/sbin/clog {$logfile}{$grepline}| grep -v \"CLOG\" | grep -v \"\033\" | /usr/bin/tail {$sor} -n {$tail}", $logarr);
|
586
|
}
|
587
|
}
|
588
|
foreach ($logarr as $logent) {
|
589
|
$logent = preg_split("/\s+/", $logent, 6);
|
590
|
echo "<tr valign=\"top\">\n";
|
591
|
if ($withorig) {
|
592
|
if(isset($config['system']['usefifolog'])) {
|
593
|
$entry_date_time = htmlspecialchars(date("F j, Y, g:i a","" . $logent[1] . ""));
|
594
|
$entry_text = htmlspecialchars($logent[5]);
|
595
|
} else {
|
596
|
$entry_date_time = htmlspecialchars(join(" ", array_slice($logent, 0, 3)));
|
597
|
$entry_text = htmlspecialchars($logent[4] . " " . $logent[5]);
|
598
|
}
|
599
|
echo "<td class=\"listlr\" nowrap>{$entry_date_time}</td>\n";
|
600
|
echo "<td class=\"listr\">{$entry_text}</td>\n";
|
601
|
|
602
|
} else {
|
603
|
echo "<td class=\"listlr\" colspan=\"2\">" . htmlspecialchars($logent[5]) . "</td>\n";
|
604
|
}
|
605
|
echo "</tr>\n";
|
606
|
}
|
607
|
}
|
608
|
|
609
|
function return_clog($logfile, $tail, $withorig = true, $grepfor = "", $grepinvert = "", $grepreverse = false) {
|
610
|
global $g, $config;
|
611
|
$sor = (isset($config['syslog']['reverse']) || $grepreverse) ? "-r" : "";
|
612
|
$logarr = "";
|
613
|
$grepline = " ";
|
614
|
if(is_array($grepfor))
|
615
|
foreach($grepfor as $agrep)
|
616
|
$grepline .= " | grep \"$agrep\"";
|
617
|
if(is_array($grepinvert))
|
618
|
foreach($grepinvert as $agrep)
|
619
|
$grepline .= " | grep -v \"$agrep\"";
|
620
|
if($config['system']['disablesyslogclog']) {
|
621
|
exec("cat {$logfile}{$grepline} | /usr/bin/tail {$sor} -n {$tail}", $logarr);
|
622
|
} else {
|
623
|
if(isset($config['system']['usefifolog'])) {
|
624
|
exec("/usr/sbin/fifolog_reader {$logfile}{$grepline} | /usr/bin/tail {$sor} -n {$tail}", $logarr);
|
625
|
} else {
|
626
|
exec("/usr/sbin/clog {$logfile}{$grepline}| grep -v \"CLOG\" | grep -v \"\033\" | /usr/bin/tail {$sor} -n {$tail}", $logarr);
|
627
|
}
|
628
|
}
|
629
|
return($logarr);
|
630
|
}
|
631
|
|
632
|
/* Check if variable has changed, update and log if it has
|
633
|
* returns true if var changed
|
634
|
* varname = variable name in plain text
|
635
|
* orig = original value
|
636
|
* new = new value
|
637
|
*/
|
638
|
function update_if_changed($varname, & $orig, $new) {
|
639
|
if (is_array($orig) && is_array($new)) {
|
640
|
$a_diff = array_diff($orig, $new);
|
641
|
foreach ($a_diff as $diff) {
|
642
|
update_changedesc("removed {$varname}: \"{$diff}\"");
|
643
|
}
|
644
|
$a_diff = array_diff($new, $orig);
|
645
|
foreach ($a_diff as $diff) {
|
646
|
update_changedesc("added {$varname}: \"{$diff}\"");
|
647
|
}
|
648
|
$orig = $new;
|
649
|
return true;
|
650
|
|
651
|
} else {
|
652
|
if ($orig != $new) {
|
653
|
update_changedesc("{$varname}: \"{$orig}\" -> \"{$new}\"");
|
654
|
$orig = $new;
|
655
|
return true;
|
656
|
}
|
657
|
}
|
658
|
return false;
|
659
|
}
|
660
|
|
661
|
function address_to_pconfig($adr, &$padr, &$pmask, &$pnot, &$pbeginport, &$pendport) {
|
662
|
|
663
|
if (isset($adr['any']))
|
664
|
$padr = "any";
|
665
|
else if ($adr['network'])
|
666
|
$padr = $adr['network'];
|
667
|
else if ($adr['address']) {
|
668
|
list($padr, $pmask) = explode("/", $adr['address']);
|
669
|
if (!$pmask)
|
670
|
$pmask = 32;
|
671
|
}
|
672
|
|
673
|
if (isset($adr['not']))
|
674
|
$pnot = 1;
|
675
|
else
|
676
|
$pnot = 0;
|
677
|
|
678
|
if ($adr['port']) {
|
679
|
list($pbeginport, $pendport) = explode("-", $adr['port']);
|
680
|
if (!$pendport)
|
681
|
$pendport = $pbeginport;
|
682
|
} else if (!is_alias($pbeginport) && !is_alias($pendport)) {
|
683
|
$pbeginport = "any";
|
684
|
$pendport = "any";
|
685
|
}
|
686
|
}
|
687
|
|
688
|
function pconfig_to_address(&$adr, $padr, $pmask, $pnot=false, $pbeginport=0, $pendport=0) {
|
689
|
|
690
|
$adr = array();
|
691
|
|
692
|
if ($padr == "any")
|
693
|
$adr['any'] = true;
|
694
|
else if (is_specialnet($padr))
|
695
|
$adr['network'] = $padr;
|
696
|
else {
|
697
|
$adr['address'] = $padr;
|
698
|
if ($pmask != 32)
|
699
|
$adr['address'] .= "/" . $pmask;
|
700
|
}
|
701
|
|
702
|
if ($pnot)
|
703
|
$adr['not'] = true;
|
704
|
else
|
705
|
unset($adr['not']);
|
706
|
|
707
|
if (($pbeginport != 0) && ($pbeginport != "any")) {
|
708
|
if ($pbeginport != $pendport)
|
709
|
$adr['port'] = $pbeginport . "-" . $pendport;
|
710
|
else
|
711
|
$adr['port'] = $pbeginport;
|
712
|
}
|
713
|
|
714
|
if(is_alias($pbeginport)) {
|
715
|
$adr['port'] = $pbeginport;
|
716
|
}
|
717
|
}
|
718
|
|
719
|
function is_specialnet($net) {
|
720
|
global $specialsrcdst;
|
721
|
|
722
|
if(!$net)
|
723
|
return false;
|
724
|
if (in_array($net, $specialsrcdst))
|
725
|
return true;
|
726
|
else
|
727
|
return false;
|
728
|
}
|
729
|
|
730
|
//function to create widget tabs when called
|
731
|
function display_widget_tabs(& $tab_array) {
|
732
|
echo "<div id='tabs'>";
|
733
|
$tabscounter = 0;
|
734
|
foreach ($tab_array as $ta) {
|
735
|
$dashpos = strpos($ta[2],'-');
|
736
|
$tabname = $ta[2] . "-tab";
|
737
|
$tabclass = substr($ta[2],0,$dashpos);
|
738
|
$tabclass = $tabclass . "-class";
|
739
|
if ($ta[1] == true) {
|
740
|
$tabActive = "table-cell";
|
741
|
$tabNonActive = "none";
|
742
|
}
|
743
|
else {
|
744
|
$tabActive = "none";
|
745
|
$tabNonActive = "table-cell";
|
746
|
}
|
747
|
echo "<div id='{$ta[2]}-active' class='{$tabclass}-tabactive' style='display:{$tabActive}; background-color:#EEEEEE; color:black;'>";
|
748
|
echo "<B> {$ta[0]}";
|
749
|
echo " </B>";
|
750
|
echo "</div>";
|
751
|
|
752
|
echo "<div id='{$ta[2]}-deactive' class='{$tabclass}-tabdeactive' style='display:{$tabNonActive}; background-color:#777777; color:white; cursor: pointer;' onClick=\"return changeTabDIV('{$ta[2]}')\">";
|
753
|
echo "<B> {$ta[0]}";
|
754
|
echo " </B>";
|
755
|
echo "</div>";
|
756
|
}
|
757
|
|
758
|
echo "<script type=\"text/javascript\">";
|
759
|
echo "NiftyCheck();\n";
|
760
|
echo "Rounded(\"div.{$tabclass}-tabactive\",\"top\",\"#CCCCCC\",\"#EEEEEE\",\"smooth\");\n";
|
761
|
echo "Rounded(\"div.{$tabclass}-tabdeactive\",\"top\",\"#CCCCCC\",\"#777777\",\"smooth\");\n";
|
762
|
echo "</script>";
|
763
|
echo "</div>";
|
764
|
}
|
765
|
|
766
|
|
767
|
// Return inline javascript file or CSS to minimizie
|
768
|
// request count going back to server.
|
769
|
function outputJavaScriptFileInline($javascript) {
|
770
|
if(file_exists($javascript)) {
|
771
|
echo "\n<script type=\"text/javascript\">\n";
|
772
|
include($javascript);
|
773
|
echo "\n</script>\n";
|
774
|
} else {
|
775
|
echo "\n\n<!-- Could not location file: {$javascript} -->\n\n";
|
776
|
}
|
777
|
}
|
778
|
|
779
|
|
780
|
|
781
|
function outputCSSPrintFileInline($css) {
|
782
|
if(file_exists($css)) {
|
783
|
echo "\n<style media=\"print\" type=\"text/css\">\n";
|
784
|
include($css);
|
785
|
echo "\n</style>\n";
|
786
|
} else {
|
787
|
echo "\n\n<!-- Could not location file: {$css} -->\n\n";
|
788
|
}
|
789
|
}
|
790
|
|
791
|
|
792
|
function outputCSSFileInline($css) {
|
793
|
if(file_exists($css)) {
|
794
|
echo "\n<style type=\"text/css\">\n";
|
795
|
include($css);
|
796
|
echo "\n</style>\n";
|
797
|
} else {
|
798
|
echo "\n\n<!-- Could not location file: {$css} -->\n\n";
|
799
|
}
|
800
|
}
|
801
|
|
802
|
$rfc2616 = array(
|
803
|
100 => "100 Continue",
|
804
|
101 => "101 Switching Protocols",
|
805
|
200 => "200 OK",
|
806
|
201 => "201 Created",
|
807
|
202 => "202 Accepted",
|
808
|
203 => "203 Non-Authoritative Information",
|
809
|
204 => "204 No Content",
|
810
|
205 => "205 Reset Content",
|
811
|
206 => "206 Partial Content",
|
812
|
300 => "300 Multiple Choices",
|
813
|
301 => "301 Moved Permanently",
|
814
|
302 => "302 Found",
|
815
|
303 => "303 See Other",
|
816
|
304 => "304 Not Modified",
|
817
|
305 => "305 Use Proxy",
|
818
|
306 => "306 (Unused)",
|
819
|
307 => "307 Temporary Redirect",
|
820
|
400 => "400 Bad Request",
|
821
|
401 => "401 Unauthorized",
|
822
|
402 => "402 Payment Required",
|
823
|
403 => "403 Forbidden",
|
824
|
404 => "404 Not Found",
|
825
|
405 => "405 Method Not Allowed",
|
826
|
406 => "406 Not Acceptable",
|
827
|
407 => "407 Proxy Authentication Required",
|
828
|
408 => "408 Request Timeout",
|
829
|
409 => "409 Conflict",
|
830
|
410 => "410 Gone",
|
831
|
411 => "411 Length Required",
|
832
|
412 => "412 Precondition Failed",
|
833
|
413 => "413 Request Entity Too Large",
|
834
|
414 => "414 Request-URI Too Long",
|
835
|
415 => "415 Unsupported Media Type",
|
836
|
416 => "416 Requested Range Not Satisfiable",
|
837
|
417 => "417 Expectation Failed",
|
838
|
500 => "500 Internal Server Error",
|
839
|
501 => "501 Not Implemented",
|
840
|
502 => "502 Bad Gateway",
|
841
|
503 => "503 Service Unavailable",
|
842
|
504 => "504 Gateway Timeout",
|
843
|
505 => "505 HTTP Version Not Supported"
|
844
|
);
|
845
|
|
846
|
function is_rfc2616_code($code) {
|
847
|
global $rfc2616;
|
848
|
if (isset($rfc2616[$code]))
|
849
|
return true;
|
850
|
else
|
851
|
return false;
|
852
|
}
|
853
|
|
854
|
function print_rfc2616_select($tag, $current){
|
855
|
global $rfc2616;
|
856
|
|
857
|
/* Default to 200 OK if not set */
|
858
|
if ($current == "")
|
859
|
$current = 200;
|
860
|
|
861
|
echo "<select id=\"{$tag}\" name=\"{$tag}\">\n";
|
862
|
foreach($rfc2616 as $code => $message) {
|
863
|
if ($code == $current) {
|
864
|
$sel = " selected";
|
865
|
} else {
|
866
|
$sel = "";
|
867
|
}
|
868
|
echo "<option value=\"{$code}\"{$sel}>{$message}</option>\n";
|
869
|
}
|
870
|
}
|
871
|
|
872
|
// Useful debugging function, much cleaner than print_r
|
873
|
function echo_array($array,$return_me=false){
|
874
|
if(is_array($array) == false){
|
875
|
$return = "The provided variable is not an array.";
|
876
|
}else{
|
877
|
foreach($array as $name=>$value){
|
878
|
if(is_array($value)){
|
879
|
$return .= "";
|
880
|
$return .= "['<b>$name</b>'] {<div style='margin-left:10px;'>\n";
|
881
|
$return .= echo_array($value,true);
|
882
|
$return .= "</div>}";
|
883
|
$return .= "\n\n";
|
884
|
}else{
|
885
|
if(is_string($value)){
|
886
|
$value = "\"$value\"";
|
887
|
}
|
888
|
$return .= "['<b>$name</b>'] = $value\n\n";
|
889
|
}
|
890
|
}
|
891
|
}
|
892
|
if($return_me == true){
|
893
|
return $return;
|
894
|
}else{
|
895
|
echo "<pre>".$return."</pre>";
|
896
|
}
|
897
|
}
|
898
|
|
899
|
/****f* pfsense-utils/display_top_tabs
|
900
|
* NAME
|
901
|
* display_top_tabs - display tabs with rounded edges
|
902
|
* INPUTS
|
903
|
* $text - array of tabs
|
904
|
* RESULT
|
905
|
* null
|
906
|
******/
|
907
|
function display_top_tabs(& $tab_array, $no_drop_down = false) {
|
908
|
global $HTTP_SERVER_VARS;
|
909
|
global $config;
|
910
|
global $g;
|
911
|
global $tab_array_indent;
|
912
|
global $tab_array_space;
|
913
|
global $tab_array_char_limit;
|
914
|
|
915
|
/* does the user have access to this tab?
|
916
|
* master user has access to everything.
|
917
|
* if the user does not have access, simply
|
918
|
* unset the tab item.
|
919
|
*/
|
920
|
|
921
|
/* empty string code */
|
922
|
if ($tab_array_indent == '') {
|
923
|
$tab_array_indent = 0;
|
924
|
}
|
925
|
|
926
|
if ($tab_array_space == '') {
|
927
|
$tab_array_space = 1;
|
928
|
}
|
929
|
|
930
|
if ($tab_array_char_limit == '') {
|
931
|
$tab_array_char_limit = 92;
|
932
|
}
|
933
|
|
934
|
foreach ($tab_array as $tab_id => $ta){
|
935
|
if(!isAllowedPage($ta[2]))
|
936
|
unset ($tab_array[$tab_id]);
|
937
|
}
|
938
|
|
939
|
$tab_active_bg = "#EEEEEE";
|
940
|
$tab_inactive_bg = "#777777";
|
941
|
$nifty_tabs_corners = "#FFF";
|
942
|
$font_color = "white";
|
943
|
|
944
|
/* if tabcontrols.php exist for a theme, allow it to be overriden */
|
945
|
$themename = $config['theme'];
|
946
|
$filename = "/usr/local/www/themes/{$themename}/tabcontrols.php";
|
947
|
if(file_exists($filename)) {
|
948
|
$eval_code = file_get_contents($filename);
|
949
|
eval($eval_code);
|
950
|
}
|
951
|
|
952
|
$tabcharcount = 0;
|
953
|
foreach ($tab_array as $ta)
|
954
|
$tabcharcount = $tabcharcount + strlen($ta[0]);
|
955
|
|
956
|
if($no_drop_down == true) {
|
957
|
$tabcharcount = 0;
|
958
|
unset($tab_array_char_limit);
|
959
|
}
|
960
|
|
961
|
// If the character count of the tab names is > 670
|
962
|
// then show a select item dropdown menubox.
|
963
|
if($tabcharcount > $tab_array_char_limit) {
|
964
|
echo "Currently viewing: ";
|
965
|
echo "<select name='TabSelect' onchange='tabs_will_go(this)'>\n";
|
966
|
foreach ($tab_array as $ta) {
|
967
|
if($ta[1]=="true")
|
968
|
$selected = " SELECTED";
|
969
|
else
|
970
|
$selected = "";
|
971
|
// Onclick in option will not work in some browser
|
972
|
// echo "<option onClick=\"document.location='{$ta[2]}';\"{$selected}>{$ta['0']}</option>\n";
|
973
|
echo "<option value=\"{$ta[2]}\"{$selected}>{$ta['0']}</option>\n";
|
974
|
}
|
975
|
echo "</select>\n<p/>";
|
976
|
echo "<script type=\"text/javascript\">";
|
977
|
echo " function tabs_will_go(obj){ document.location = obj.value; }";
|
978
|
echo "</script>";
|
979
|
} else {
|
980
|
echo "<div class=\"newtabmenu\" style=\"margin:{$tab_array_space}px {$tab_array_indent}px; width:775px;\">\n";
|
981
|
echo "<!-- Tabbed bar code-->\n";
|
982
|
echo "<ul class=\"newtabmenu\">\n";
|
983
|
$tabscounter = 0;
|
984
|
foreach ($tab_array as $ta) {
|
985
|
if ($ta[1] == true) {
|
986
|
echo " <li class=\"newtabmenu_active\"><a href=\"{$ta[2]}\"><span>{$ta[0]}</span></a></li>\n";
|
987
|
} else {
|
988
|
echo " <li><a href=\"{$ta[2]}\"><span>{$ta[0]}</span></a></li>\n";
|
989
|
}
|
990
|
$tabscounter++;
|
991
|
}
|
992
|
echo "</ul>\n</div>\n";
|
993
|
}
|
994
|
}
|
995
|
|
996
|
function add_package_tabs($tabgroup, & $tab_array) {
|
997
|
global $config, $g;
|
998
|
|
999
|
if(!is_array($config['installedpackages']))
|
1000
|
return;
|
1001
|
if(!is_array($config['installedpackages']['tab']))
|
1002
|
return;
|
1003
|
|
1004
|
foreach($config['installedpackages']['tab'] as $tab) {
|
1005
|
if ($tab['group'] !== $group)
|
1006
|
continue;
|
1007
|
$tab_entry = array();
|
1008
|
if($tab['name']) {
|
1009
|
$tab_entry[] = $tab['name'];
|
1010
|
$tab_entry[] = false;
|
1011
|
$tab_entry[] = $tab['url'];
|
1012
|
$tab_array[] = $tab_entry;
|
1013
|
}
|
1014
|
}
|
1015
|
}
|
1016
|
|
1017
|
function alias_info_popup($alias_id){
|
1018
|
global $config;
|
1019
|
$maxlength = 60;
|
1020
|
$close_title="title='".gettext('move mouse out this alias to hide')."'";
|
1021
|
if (is_array($config['aliases']['alias'][$alias_id])){
|
1022
|
$alias_name=$config['aliases']['alias'][$alias_id];
|
1023
|
$alias_objects_with_details = "<table width='100%' border='0' cellpadding='2' cellspacing='0'>";
|
1024
|
if ($alias_name['url']) {
|
1025
|
exec("/sbin/pfctl -t {$alias_name['name']} -T show | wc -l", $total_entries);
|
1026
|
$counter=preg_replace("/\D/","",$total_entries[0]);
|
1027
|
exec("/sbin/pfctl -t {$alias_name['name']} -T show | head -10002", $alias_addresses);
|
1028
|
$alias_objects_with_details .= "<tr><td colspan='3' $close_title class='vncell'>{$alias_name['url']}</td></tr>";
|
1029
|
$x=0;
|
1030
|
foreach ($alias_addresses as $alias_ports_address ){
|
1031
|
switch ($x){
|
1032
|
case 0:
|
1033
|
$x++;
|
1034
|
$alias_objects_with_details .= "<tr><td $close_title class='vncell' width='33%' style='background: #FFFFFF;color: #000000;'>{$alias_ports_address}</td>";
|
1035
|
break;
|
1036
|
case 1:
|
1037
|
$x++;
|
1038
|
$alias_objects_with_details .= "<td $close_title class='vncell' width='33%' style='background: #FFFFFF;color: #000000;'>{$alias_ports_address}</td>";
|
1039
|
break;
|
1040
|
default:
|
1041
|
$x=0;
|
1042
|
$alias_objects_with_details .= "<td $close_title class='vncell' width='33%' style='background: #FFFFFF;color: #000000;'>{$alias_ports_address}</td><tr>";
|
1043
|
break;
|
1044
|
}
|
1045
|
}
|
1046
|
for ($y=$x;$y<=$x;$y++){
|
1047
|
$alias_objects_with_details .= "<td $close_title class='vncell' width='33%'> </td>";
|
1048
|
}
|
1049
|
if ($x > 0)
|
1050
|
$alias_objects_with_details .= "</tr>";
|
1051
|
if ($counter > 10002){
|
1052
|
$alias_objects_with_details .= "<tr><td colspan='3'> listing only first 10k items</td><tr>";
|
1053
|
}
|
1054
|
}
|
1055
|
else{
|
1056
|
$alias_addresses = explode (" ", $alias_name['address']);
|
1057
|
$alias_details = explode ("||", $alias_name['detail']);
|
1058
|
$counter=0;
|
1059
|
foreach($alias_addresses as $alias_ports_address)
|
1060
|
{
|
1061
|
$alias_objects_with_details .= "<tr><td $close_title width='5%' class='vncell' style='background: #FFFFFF;color: #000000;'>{$alias_addresses[$counter]}</td>";
|
1062
|
$alias_detail_default = strpos ($alias_details[$counter],"Entry added");
|
1063
|
if ($alias_details[$counter] != "" && $alias_detail_default === False)
|
1064
|
$alias_objects_with_details .="<td $close_title width='95%' class='vncell' style='background: #FFFFFF;color: #000000;'>{$alias_details[$counter]}</td>";
|
1065
|
else
|
1066
|
$alias_objects_with_details .="<td $close_title width='95%' class='vncell' style='background: #FFFFFF;color: #000000;'> </td>";
|
1067
|
$alias_objects_with_details .= "</tr>";
|
1068
|
$counter++;
|
1069
|
}
|
1070
|
|
1071
|
}
|
1072
|
$alias_objects_with_details .="</table>";
|
1073
|
}
|
1074
|
$alias_descr_substr = $alias_name['descr'];
|
1075
|
if ($strlength >= $maxlength)
|
1076
|
$alias_descr_substr = substr($alias_descr_substr, 0, $maxlength) . "...";
|
1077
|
$item_text=($counter > 1 ? "items" : "item");
|
1078
|
$alias_caption = "{$alias_descr_substr} - {$counter} {$item_text}<a href='/firewall_aliases_edit.php?id={$alias_id}' title='".gettext('edit this alias')."'> edit </a>";
|
1079
|
$strlength = strlen ($alias_caption);
|
1080
|
print "<h1>{$alias_caption}</h1>".$alias_objects_with_details;
|
1081
|
}
|
1082
|
|
1083
|
function rule_popup($src,$srcport,$dst,$dstport){
|
1084
|
global $config,$g;
|
1085
|
$aliases_array = array();
|
1086
|
if($config['aliases']['alias'] <> "" and is_array($config['aliases']['alias']))
|
1087
|
{
|
1088
|
$descriptions = array ();
|
1089
|
foreach($config['aliases']['alias'] as $alias_id=>$alias_name){
|
1090
|
$loading_image="<a><img src=\'/themes/{$g['theme']}/images/misc/loader.gif\'> " .gettext("loading...")."</a>";
|
1091
|
switch ($alias_name['type']){
|
1092
|
case "port":
|
1093
|
$width="250";
|
1094
|
break;
|
1095
|
case "urltable":
|
1096
|
$width="500";
|
1097
|
break;
|
1098
|
default:
|
1099
|
$width="350";
|
1100
|
break;
|
1101
|
}
|
1102
|
$span_begin = "<span style=\"cursor: help;\" onmouseover=\"var response_html=domTT_activate(this, event, 'id','ttalias_{$alias_id}','content','{$loading_image}', 'trail', true, 'delay', 300, 'fade', 'both', 'fadeMax', 93, 'styleClass', 'niceTitle','type','velcro','width',{$width});alias_popup('{$alias_id}','{$g["theme"]}','".gettext('loading...')."');\" onmouseout=\"this.style.color = ''; domTT_mouseout(this, event);\"><U>";
|
1103
|
if ($alias_name['name'] == $src)
|
1104
|
$descriptions['src']= $span_begin;
|
1105
|
if ($alias_name['name'] == $srcport)
|
1106
|
$descriptions['srcport'] = $span_begin;
|
1107
|
if ($alias_name['name'] == $dst )
|
1108
|
$descriptions['dst'] = $span_begin;
|
1109
|
if ($alias_name['name'] == $dstport)
|
1110
|
$descriptions['dstport'] = $span_begin;
|
1111
|
}
|
1112
|
return $descriptions;
|
1113
|
}
|
1114
|
}
|
1115
|
|
1116
|
$timezone = $config['system']['timezone'];
|
1117
|
if (!$timezone)
|
1118
|
$timezone = "Etc/UTC";
|
1119
|
|
1120
|
date_default_timezone_set($timezone);
|
1121
|
|
1122
|
?>
|