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