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 |
|
|
|
33 |
dd7a8309
|
Scott Ullrich
|
/* Include authentication routines */
|
34 |
|
|
/* THIS MUST BE ABOVE ALL OTHER CODE */
|
35 |
|
|
require_once("authgui.inc");
|
36 |
|
|
|
37 |
5b237745
|
Scott Ullrich
|
/* make sure nothing is cached */
|
38 |
|
|
if (!$omit_nocacheheaders) {
|
39 |
|
|
header("Expires: 0");
|
40 |
|
|
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
|
41 |
|
|
header("Cache-Control: no-store, no-cache, must-revalidate");
|
42 |
|
|
header("Cache-Control: post-check=0, pre-check=0", false);
|
43 |
|
|
header("Pragma: no-cache");
|
44 |
|
|
}
|
45 |
|
|
|
46 |
|
|
/* parse the configuration and include all configuration functions */
|
47 |
|
|
require_once("config.inc");
|
48 |
|
|
require_once("functions.inc");
|
49 |
|
|
|
50 |
50d86c13
|
Bill Marquette
|
/* Pull in all the gui related display classes) */
|
51 |
|
|
foreach (scandir("/usr/local/www/classes/") as $file) {
|
52 |
|
|
if (stristr($file, ".inc") !== false) {
|
53 |
|
|
require_once("classes/{$file}");
|
54 |
|
|
}
|
55 |
|
|
}
|
56 |
31977165
|
Colin Smith
|
/*
|
57 |
|
|
* if user has selected a custom template, use it.
|
58 |
|
|
* otherwise default to pfsense tempalte
|
59 |
|
|
*/
|
60 |
|
|
if($config['theme'] <> "")
|
61 |
|
|
$g['theme'] = $config['theme'];
|
62 |
|
|
else
|
63 |
|
|
$g['theme'] = "pfsense";
|
64 |
|
|
|
65 |
caf7d0bc
|
Scott Ullrich
|
/*
|
66 |
|
|
* If this device is an apple ipod/iphone
|
67 |
|
|
* switch the theme to one that works with it.
|
68 |
|
|
*/
|
69 |
e06f19fa
|
Scott Ullrich
|
$apple_ua = array("iPhone","iPod");
|
70 |
|
|
foreach($apple_ua as $useragent)
|
71 |
|
|
if(strstr($_SERVER['HTTP_USER_AGENT'], $useragent))
|
72 |
caf7d0bc
|
Scott Ullrich
|
$g['theme'] = "pfsense";
|
73 |
|
|
|
74 |
3e44d22a
|
Scott Ullrich
|
$d_landirty_path = $g['varrun_path'] . "/lan.conf.dirty";
|
75 |
8ede0ae8
|
Scott Ullrich
|
$d_pppoeuserdirty_path = $g['varrun_path'] . "/vpn-pppoe-users-edit.dirty";
|
76 |
ceca2719
|
Scott Ullrich
|
$d_hostsdirty_path = $g['varrun_path'] . "/hosts.dirty";
|
77 |
5b237745
|
Scott Ullrich
|
$d_natconfdirty_path = $g['varrun_path'] . "/nat.conf.dirty";
|
78 |
|
|
$d_filterconfdirty_path = $g['varrun_path'] . "/filter.conf.dirty";
|
79 |
|
|
$d_ipsecconfdirty_path = $g['varrun_path'] . "/ipsec.conf.dirty";
|
80 |
|
|
$d_shaperconfdirty_path = $g['varrun_path'] . "/shaper.conf.dirty";
|
81 |
|
|
$d_pptpuserdirty_path = $g['varrun_path'] . "/pptpd.user.dirty";
|
82 |
0c2b5df7
|
Scott Ullrich
|
$d_dnsmasqdirty_path = $g['varrun_path'] . "/dnsmasq.dirty";
|
83 |
5b237745
|
Scott Ullrich
|
$d_staticmapsdirty_path = $g['varrun_path'] . "/staticmaps.dirty";
|
84 |
|
|
$d_staticroutesdirty_path = $g['varrun_path'] . "/staticroutes.dirty";
|
85 |
|
|
$d_aliasesdirty_path = $g['varrun_path'] . "/aliases.dirty";
|
86 |
|
|
$d_proxyarpdirty_path = $g['varrun_path'] . "/proxyarp.dirty";
|
87 |
|
|
$d_fwupenabled_path = $g['varrun_path'] . "/fwup.enabled";
|
88 |
|
|
$d_firmwarelock_path = $g['varrun_path'] . "/firmware.lock";
|
89 |
|
|
$d_sysrebootreqd_path = $g['varrun_path'] . "/sysreboot.reqd";
|
90 |
|
|
$d_passthrumacsdirty_path = $g['varrun_path'] . "/passthrumacs.dirty";
|
91 |
|
|
$d_allowedipsdirty_path = $g['varrun_path'] . "/allowedips.dirty";
|
92 |
|
|
$d_ovpnclidirty_path = $g['varrun_path'] . "/ovpnclient.dirty";
|
93 |
1425e067
|
Bill Marquette
|
$d_vipconfdirty_path = $g['varrun_path'] . "/vip.conf.dirty";
|
94 |
6df9d7e3
|
Scott Ullrich
|
$d_sysctldirty_path = $g['varrun_path'] . "/sysctl.conf.dirty";
|
95 |
f8c08f21
|
Bill Marquette
|
$d_vsconfdirty_path = $g['varrun_path'] . "/vs.conf.dirty";
|
96 |
a32dea16
|
Scott Ullrich
|
$d_shaperconfdirty_path = $g['varrun_path'] . "/shaper.conf.dirty";
|
97 |
|
|
|
98 |
fb7860e0
|
Scott Ullrich
|
/* OpenVPN Directories */
|
99 |
|
|
$d_ovpnsrvdirty_path = "/tmp/ovpn-srv.dirty";
|
100 |
|
|
$d_ovpncrldirty_path = "/tmp/ovpn-crl.dirty";
|
101 |
|
|
$d_ovpnclidirty_path = "/tmp/ovpn-cli.dirty";
|
102 |
b005c738
|
Scott Ullrich
|
/* used by progress bar */
|
103 |
|
|
$lastseen = "-1";
|
104 |
5b237745
|
Scott Ullrich
|
|
105 |
9d9adc7f
|
Scott Ullrich
|
$navlevelsep = ": "; /* navigation level separator string */
|
106 |
|
|
$mandfldhtml = ""; /* display this before mandatory input fields */
|
107 |
|
|
$mandfldhtmlspc = ""; /* same as above, but with spacing */
|
108 |
|
|
|
109 |
5b237745
|
Scott Ullrich
|
if (file_exists($d_firmwarelock_path)) {
|
110 |
|
|
if (!$d_isfwfile) {
|
111 |
|
|
header("Location: system_firmware.php");
|
112 |
|
|
exit;
|
113 |
|
|
} else {
|
114 |
|
|
return;
|
115 |
|
|
}
|
116 |
|
|
}
|
117 |
|
|
|
118 |
fbf672cb
|
Matthew Grooms
|
$auth_server_types = array(
|
119 |
|
|
'ldap' => "LDAP",
|
120 |
|
|
'radius' => "Radius");
|
121 |
|
|
|
122 |
|
|
$ldap_urltypes = array(
|
123 |
|
|
'TCP - Standard' => 389,
|
124 |
|
|
'SSL - Encrypted' => 636);
|
125 |
|
|
|
126 |
|
|
$ldap_scopes = array(
|
127 |
|
|
'one' => "One Level",
|
128 |
|
|
'subtree' => "Entire Subtree");
|
129 |
|
|
|
130 |
|
|
$ldap_protvers = array(
|
131 |
|
|
2,
|
132 |
|
|
3);
|
133 |
|
|
|
134 |
|
|
$ldap_templates = array(
|
135 |
|
|
|
136 |
|
|
'open' => array(
|
137 |
|
|
'desc' => "OpenLDAP",
|
138 |
|
|
'attr_user' => "cn",
|
139 |
|
|
'attr_group' => "cn",
|
140 |
|
|
'attr_member' => "member"),
|
141 |
|
|
|
142 |
|
|
'msad' => array(
|
143 |
|
|
'desc' => "Microsoft AD",
|
144 |
|
|
'attr_user' => "samAccountNAme",
|
145 |
|
|
'attr_group' => "cn",
|
146 |
|
|
'attr_member' => "member"),
|
147 |
|
|
|
148 |
|
|
'edir' => array(
|
149 |
|
|
'desc' => "Novell eDirectory",
|
150 |
|
|
'attr_user' => "cn",
|
151 |
|
|
'attr_group' => "cn",
|
152 |
|
|
'attr_member' => "uniqueMember"));
|
153 |
|
|
|
154 |
|
|
$radius_srvcs = array(
|
155 |
|
|
'both' => "Authentication and Accounting",
|
156 |
|
|
'auth' => "Authentication",
|
157 |
|
|
'acct' => "Accounting");
|
158 |
|
|
|
159 |
d799787e
|
Matthew Grooms
|
$netbios_nodetypes = array(
|
160 |
|
|
'0' => "none",
|
161 |
|
|
'1' => "b-node",
|
162 |
|
|
'2' => "p-node",
|
163 |
|
|
'4' => "m-node",
|
164 |
|
|
'5' => "h-node");
|
165 |
|
|
|
166 |
5b237745
|
Scott Ullrich
|
/* some well knows ports */
|
167 |
fbf672cb
|
Matthew Grooms
|
$wkports = array(
|
168 |
0f01013a
|
Chris Buechler
|
5999 => "CVSup",
|
169 |
fb2abb3a
|
Scott Ullrich
|
53 => "DNS",
|
170 |
0f01013a
|
Chris Buechler
|
21 => "FTP",
|
171 |
|
|
3000 => "HBCI",
|
172 |
fb2abb3a
|
Scott Ullrich
|
80 => "HTTP",
|
173 |
0f01013a
|
Chris Buechler
|
443 => "HTTPS",
|
174 |
|
|
5190 => "ICQ",
|
175 |
fb2abb3a
|
Scott Ullrich
|
113 => "IDENT/AUTH",
|
176 |
0f01013a
|
Chris Buechler
|
143 => "IMAP",
|
177 |
|
|
993 => "IMAP/S",
|
178 |
|
|
4500 => "IPsec NAT-T",
|
179 |
|
|
500 => "ISAKMP",
|
180 |
|
|
1701 => "L2TP",
|
181 |
|
|
389 => "LDAP",
|
182 |
|
|
1755 => "MMS/TCP",
|
183 |
|
|
7000 => "MMS/UDP",
|
184 |
|
|
445 => "MS DS",
|
185 |
|
|
3389 => "MS RDP",
|
186 |
|
|
1512 => "MS WINS",
|
187 |
|
|
1863 => "MSN",
|
188 |
1d136eeb
|
Scott Ullrich
|
119 => "NNTP",
|
189 |
fb2abb3a
|
Scott Ullrich
|
123 => "NTP",
|
190 |
c736881c
|
Scott Ullrich
|
138 => "NetBIOS-DGM",
|
191 |
354f1f01
|
Chris Buechler
|
137 => "NetBIOS-NS",
|
192 |
c736881c
|
Scott Ullrich
|
139 => "NetBIOS-SSN",
|
193 |
1d136eeb
|
Scott Ullrich
|
1194 => "OpenVPN",
|
194 |
0f01013a
|
Chris Buechler
|
110 => "POP3",
|
195 |
|
|
995 => "POP3/S",
|
196 |
354f1f01
|
Chris Buechler
|
1723 => "PPTP",
|
197 |
0f01013a
|
Chris Buechler
|
1812 => "RADIUS",
|
198 |
|
|
1813 => "RADIUS accounting",
|
199 |
90b2b093
|
Martin Fuchs
|
5004 => "RTP",
|
200 |
|
|
5060 => "SIP",
|
201 |
0f01013a
|
Chris Buechler
|
25 => "SMTP",
|
202 |
|
|
465 => "SMTP/S",
|
203 |
|
|
161 => "SNMP",
|
204 |
|
|
162 => "SNMP-Trap",
|
205 |
|
|
22 => "SSH",
|
206 |
|
|
3478 => "STUN",
|
207 |
|
|
23 => "Telnet",
|
208 |
|
|
69 => "TFTP",
|
209 |
|
|
5900 => "VNC");
|
210 |
5b237745
|
Scott Ullrich
|
|
211 |
e825920f
|
Scott Ullrich
|
$specialnets = array("wanip" => "WAN address", "lanip" => "LAN address", "lan" => "LAN net", "pptp" => "PPTP clients");
|
212 |
5b237745
|
Scott Ullrich
|
|
213 |
b7391125
|
Ermal Luçi
|
$spiflist = get_configured_interface_with_descr(true, true);
|
214 |
fa550a17
|
Scott Ullrich
|
foreach ($spiflist as $ifgui => $ifdesc) {
|
215 |
|
|
$specialnets[$ifgui] = $ifdesc . " net";
|
216 |
5b237745
|
Scott Ullrich
|
}
|
217 |
be81829f
|
Scott Ullrich
|
|
218 |
5b237745
|
Scott Ullrich
|
$medias = array("auto" => "autoselect", "100full" => "100BASE-TX full-duplex",
|
219 |
|
|
"100half" => "100BASE-TX half-duplex", "10full" => "10BASE-T full-duplex",
|
220 |
|
|
"10half" => "10BASE-T half-duplex");
|
221 |
be81829f
|
Scott Ullrich
|
|
222 |
5b237745
|
Scott Ullrich
|
/* platforms that support firmware updating */
|
223 |
275cbd3f
|
Scott Ullrich
|
$fwupplatforms = array('pfSense', 'net45xx', 'net48xx', 'generic-pc', 'embedded', 'wrap');
|
224 |
5b237745
|
Scott Ullrich
|
|
225 |
|
|
function do_input_validation($postdata, $reqdfields, $reqdfieldsn, $input_errors) {
|
226 |
be81829f
|
Scott Ullrich
|
|
227 |
|
|
/* check for bad control characters */
|
228 |
5b237745
|
Scott Ullrich
|
foreach ($postdata as $pn => $pd) {
|
229 |
|
|
if (is_string($pd) && preg_match("/[\\x00-\\x08\\x0b\\x0c\\x0e-\\x1f]/", $pd)) {
|
230 |
|
|
$input_errors[] = "The field '" . $pn . "' contains invalid characters.";
|
231 |
|
|
}
|
232 |
|
|
}
|
233 |
be81829f
|
Scott Ullrich
|
|
234 |
5b237745
|
Scott Ullrich
|
for ($i = 0; $i < count($reqdfields); $i++) {
|
235 |
d1cfae7b
|
Scott Ullrich
|
if ($_POST[$reqdfields[$i]] == "") {
|
236 |
5b237745
|
Scott Ullrich
|
$input_errors[] = "The field '" . $reqdfieldsn[$i] . "' is required.";
|
237 |
|
|
}
|
238 |
be81829f
|
Scott Ullrich
|
}
|
239 |
5b237745
|
Scott Ullrich
|
}
|
240 |
|
|
|
241 |
|
|
function print_input_errors($input_errors) {
|
242 |
30af342f
|
Erik Kristensen
|
global $g;
|
243 |
be81829f
|
Scott Ullrich
|
|
244 |
a5ab2196
|
Scott Ullrich
|
print <<<EOF
|
245 |
|
|
<p>
|
246 |
|
|
<table border="0" cellspacing="0" cellpadding="4" width="100%">
|
247 |
|
|
<tr>
|
248 |
f68d11ec
|
Scott Ullrich
|
<td class="inputerrorsleft">
|
249 |
8fe7b598
|
Scott Ullrich
|
<img src="./themes/{$g['theme']}/images/icons/icon_error.gif">
|
250 |
a5ab2196
|
Scott Ullrich
|
</td>
|
251 |
f68d11ec
|
Scott Ullrich
|
<td class="inputerrorsright">
|
252 |
a5ab2196
|
Scott Ullrich
|
<span class="errmsg"><p>
|
253 |
|
|
The following input errors were detected:
|
254 |
|
|
<ul>
|
255 |
8fe7b598
|
Scott Ullrich
|
EOF;
|
256 |
|
|
foreach ($input_errors as $ierr) {
|
257 |
|
|
echo "<li>" . htmlspecialchars($ierr) . "</li>";
|
258 |
|
|
}
|
259 |
|
|
|
260 |
|
|
print <<<EOF2
|
261 |
a5ab2196
|
Scott Ullrich
|
</ul>
|
262 |
|
|
</span>
|
263 |
|
|
</td></tr>
|
264 |
|
|
</table>
|
265 |
|
|
</p> <br>
|
266 |
8fe7b598
|
Scott Ullrich
|
EOF2;
|
267 |
a5ab2196
|
Scott Ullrich
|
|
268 |
5b237745
|
Scott Ullrich
|
}
|
269 |
|
|
|
270 |
|
|
function exec_rc_script($scriptname) {
|
271 |
be81829f
|
Scott Ullrich
|
|
272 |
5b237745
|
Scott Ullrich
|
global $d_sysrebootreqd_path;
|
273 |
be81829f
|
Scott Ullrich
|
|
274 |
767a716e
|
Scott Ullrich
|
$execoutput = "";
|
275 |
|
|
$retval = "";
|
276 |
5b237745
|
Scott Ullrich
|
exec($scriptname . " >/dev/null 2>&1", $execoutput, $retval);
|
277 |
be81829f
|
Scott Ullrich
|
return $retval;
|
278 |
5b237745
|
Scott Ullrich
|
}
|
279 |
|
|
|
280 |
|
|
function exec_rc_script_async($scriptname) {
|
281 |
be81829f
|
Scott Ullrich
|
|
282 |
5b237745
|
Scott Ullrich
|
global $d_sysrebootreqd_path;
|
283 |
767a716e
|
Scott Ullrich
|
$execoutput = "";
|
284 |
|
|
$retval = "";
|
285 |
be81829f
|
Scott Ullrich
|
|
286 |
5b237745
|
Scott Ullrich
|
exec("nohup " . $scriptname . " >/dev/null 2>&1 &", $execoutput, $retval);
|
287 |
be81829f
|
Scott Ullrich
|
return $retval;
|
288 |
5b237745
|
Scott Ullrich
|
}
|
289 |
|
|
|
290 |
|
|
function verify_gzip_file($fname) {
|
291 |
|
|
|
292 |
1ba03d69
|
Scott Ullrich
|
$returnvar = mwexec("/usr/bin/gzip -t " . escapeshellarg($fname));
|
293 |
5b237745
|
Scott Ullrich
|
if ($returnvar != 0)
|
294 |
|
|
return 0;
|
295 |
|
|
else
|
296 |
|
|
return 1;
|
297 |
|
|
}
|
298 |
|
|
|
299 |
a2dab9bc
|
Bill Marquette
|
function print_info_box_np($msg, $name="apply",$value="Apply changes") {
|
300 |
30af342f
|
Erik Kristensen
|
global $g;
|
301 |
dfdfd0be
|
Scott Ullrich
|
|
302 |
22dde6eb
|
Scott Ullrich
|
if(stristr($msg, "apply") == true || stristr($msg, "save") || stristr($msg, "create")) {
|
303 |
|
|
$savebutton = "<td class='infoboxsave'>";
|
304 |
|
|
$savebutton .= "<input name=\"{$name}\" type=\"submit\" class=\"formbtn\" id=\"${name}\" value=\"{$value}\">";
|
305 |
|
|
if($_POST['if'])
|
306 |
|
|
$savebutton .= "<input type='hidden' name='if' value='{$_POST['if']}'>";
|
307 |
|
|
$savebutton.="</td>";
|
308 |
|
|
}
|
309 |
dfdfd0be
|
Scott Ullrich
|
$nifty_redbox = "#990000";
|
310 |
|
|
$nifty_blackbox = "#000000";
|
311 |
|
|
|
312 |
|
|
$themename = $g['theme'];
|
313 |
|
|
|
314 |
|
|
if(file_exists("/usr/local/www/themes/{$themename}/tabcontrols.php")) {
|
315 |
|
|
$toeval = file_get_contents("/usr/local/www/themes/{$themename}/tabcontrols.php");
|
316 |
|
|
eval($toeval);
|
317 |
541207da
|
Scott Ullrich
|
}
|
318 |
a74e21f7
|
Scott Ullrich
|
|
319 |
|
|
if(file_exists("/usr/local/www/themes/{$themename}/infobox.php")) {
|
320 |
|
|
$toeval = file_get_contents("/usr/local/www/themes/{$themename}/infobox.php");
|
321 |
|
|
eval($toeval);
|
322 |
|
|
}
|
323 |
dfdfd0be
|
Scott Ullrich
|
|
324 |
|
|
echo <<<EOFnp
|
325 |
e1813ec8
|
Scott Ullrich
|
<table class='infobox'>
|
326 |
dfdfd0be
|
Scott Ullrich
|
<tr>
|
327 |
|
|
<td>
|
328 |
8a220491
|
Scott Ullrich
|
<div class='infoboxnp' id='redbox'>
|
329 |
|
|
<table class='infoboxnptable2'>
|
330 |
dfdfd0be
|
Scott Ullrich
|
<tr>
|
331 |
8a220491
|
Scott Ullrich
|
<td class='infoboxnptd'>
|
332 |
|
|
<img class='infoboxnpimg' src="/themes/{$g['theme']}/images/icons/icon_exclam.gif" >
|
333 |
dfdfd0be
|
Scott Ullrich
|
</td>
|
334 |
8a220491
|
Scott Ullrich
|
<td class='infoboxnptd2'>
|
335 |
|
|
<b>{$msg}</b>
|
336 |
dfdfd0be
|
Scott Ullrich
|
</td>
|
337 |
|
|
{$savebutton}
|
338 |
|
|
</tr>
|
339 |
|
|
</table>
|
340 |
|
|
</div>
|
341 |
|
|
</td>
|
342 |
|
|
</tr>
|
343 |
|
|
</table>
|
344 |
|
|
<script type="text/javascript">
|
345 |
|
|
NiftyCheck();
|
346 |
|
|
Rounded("div#redbox","all","#FFF","{$nifty_redbox}","smooth");
|
347 |
|
|
Rounded("td#blackbox","all","#FFF","{$nifty_blackbox}","smooth");
|
348 |
|
|
</script>
|
349 |
1aa31c5d
|
Scott Ullrich
|
<br/>
|
350 |
dfdfd0be
|
Scott Ullrich
|
EOFnp;
|
351 |
|
|
|
352 |
5b237745
|
Scott Ullrich
|
}
|
353 |
|
|
|
354 |
|
|
function print_info_box($msg) {
|
355 |
|
|
echo "<p>";
|
356 |
|
|
print_info_box_np($msg);
|
357 |
|
|
echo "</p>";
|
358 |
|
|
}
|
359 |
|
|
|
360 |
|
|
function get_std_save_message($ok) {
|
361 |
|
|
global $d_sysrebootreqd_path;
|
362 |
|
|
|
363 |
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.";
|
364 |
5b237745
|
Scott Ullrich
|
}
|
365 |
|
|
|
366 |
|
|
function pprint_address($adr) {
|
367 |
|
|
global $specialnets;
|
368 |
|
|
|
369 |
|
|
if (isset($adr['any'])) {
|
370 |
|
|
$padr = "*";
|
371 |
|
|
} else if ($adr['network']) {
|
372 |
369578b1
|
Scott Ullrich
|
if (preg_match("/opt[0-999]ip/", $adr['network'])) {
|
373 |
|
|
$padr = "Interface IP address";
|
374 |
|
|
} else {
|
375 |
|
|
$padr = $specialnets[$adr['network']];
|
376 |
|
|
}
|
377 |
5b237745
|
Scott Ullrich
|
} else {
|
378 |
|
|
$padr = $adr['address'];
|
379 |
|
|
}
|
380 |
be81829f
|
Scott Ullrich
|
|
381 |
5b237745
|
Scott Ullrich
|
if (isset($adr['not']))
|
382 |
|
|
$padr = "! " . $padr;
|
383 |
be81829f
|
Scott Ullrich
|
|
384 |
5b237745
|
Scott Ullrich
|
return $padr;
|
385 |
|
|
}
|
386 |
|
|
|
387 |
|
|
function pprint_port($port) {
|
388 |
|
|
global $wkports;
|
389 |
|
|
|
390 |
|
|
$pport = "";
|
391 |
be81829f
|
Scott Ullrich
|
|
392 |
5b237745
|
Scott Ullrich
|
if (!$port)
|
393 |
3a54b6ca
|
Scott Dale
|
return "*";
|
394 |
5b237745
|
Scott Ullrich
|
else {
|
395 |
|
|
$srcport = explode("-", $port);
|
396 |
|
|
if ((!$srcport[1]) || ($srcport[0] == $srcport[1])) {
|
397 |
|
|
$pport = $srcport[0];
|
398 |
|
|
if ($wkports[$srcport[0]]) {
|
399 |
|
|
$pport .= " (" . $wkports[$srcport[0]] . ")";
|
400 |
|
|
}
|
401 |
|
|
} else
|
402 |
|
|
$pport .= $srcport[0] . " - " . $srcport[1];
|
403 |
|
|
}
|
404 |
be81829f
|
Scott Ullrich
|
|
405 |
5b237745
|
Scott Ullrich
|
return $pport;
|
406 |
|
|
}
|
407 |
|
|
|
408 |
7afb67e0
|
Scott Ullrich
|
function captiveportal_users_sort() {
|
409 |
|
|
global $g, $config;
|
410 |
d1cfae7b
|
Scott Ullrich
|
|
411 |
9fdb578d
|
Ermal Lu?i
|
if (!is_array($config['captiveportal']['user']))
|
412 |
|
|
return;
|
413 |
|
|
|
414 |
7afb67e0
|
Scott Ullrich
|
function cpusercmp($a, $b) {
|
415 |
|
|
return strcasecmp($a['name'], $b['name']);
|
416 |
|
|
}
|
417 |
d1cfae7b
|
Scott Ullrich
|
|
418 |
7afb67e0
|
Scott Ullrich
|
usort($config['captiveportal']['user'], "cpusercmp");
|
419 |
|
|
}
|
420 |
|
|
|
421 |
fab7ff44
|
Bill Marquette
|
function admin_groups_sort() {
|
422 |
|
|
global $g, $config;
|
423 |
|
|
|
424 |
9fdb578d
|
Ermal Lu?i
|
if (!is_array($config['system']['group']))
|
425 |
|
|
return;
|
426 |
|
|
|
427 |
fab7ff44
|
Bill Marquette
|
function cpusercmp($a, $b) {
|
428 |
|
|
return strcasecmp($a['name'], $b['name']);
|
429 |
|
|
}
|
430 |
|
|
|
431 |
|
|
usort($config['system']['group'], "cpusercmp");
|
432 |
|
|
}
|
433 |
|
|
|
434 |
|
|
function admin_users_sort() {
|
435 |
|
|
global $g, $config;
|
436 |
|
|
|
437 |
9fdb578d
|
Ermal Lu?i
|
if (!is_array($config['system']['user']))
|
438 |
|
|
return;
|
439 |
|
|
|
440 |
fab7ff44
|
Bill Marquette
|
function cpusercmp($a, $b) {
|
441 |
|
|
return strcasecmp($a['name'], $b['name']);
|
442 |
|
|
}
|
443 |
|
|
|
444 |
|
|
usort($config['system']['user'], "cpusercmp");
|
445 |
|
|
}
|
446 |
|
|
|
447 |
5b237745
|
Scott Ullrich
|
/* sort by interface only, retain the original order of rules that apply to
|
448 |
|
|
the same interface */
|
449 |
|
|
function filter_rules_sort() {
|
450 |
63637de9
|
Bill Marquette
|
global $config;
|
451 |
be81829f
|
Scott Ullrich
|
|
452 |
5b237745
|
Scott Ullrich
|
/* mark each rule with the sequence number (to retain the order while sorting) */
|
453 |
|
|
for ($i = 0; isset($config['filter']['rule'][$i]); $i++)
|
454 |
|
|
$config['filter']['rule'][$i]['seq'] = $i;
|
455 |
be81829f
|
Scott Ullrich
|
|
456 |
5b237745
|
Scott Ullrich
|
function filtercmp($a, $b) {
|
457 |
|
|
if ($a['interface'] == $b['interface'])
|
458 |
|
|
return $a['seq'] - $b['seq'];
|
459 |
|
|
else
|
460 |
|
|
return -strcmp($a['interface'], $b['interface']);
|
461 |
|
|
}
|
462 |
be81829f
|
Scott Ullrich
|
|
463 |
5b237745
|
Scott Ullrich
|
usort($config['filter']['rule'], "filtercmp");
|
464 |
be81829f
|
Scott Ullrich
|
|
465 |
5b237745
|
Scott Ullrich
|
/* strip the sequence numbers again */
|
466 |
|
|
for ($i = 0; isset($config['filter']['rule'][$i]); $i++)
|
467 |
|
|
unset($config['filter']['rule'][$i]['seq']);
|
468 |
|
|
}
|
469 |
|
|
|
470 |
|
|
function nat_rules_sort() {
|
471 |
63637de9
|
Bill Marquette
|
global $config;
|
472 |
be81829f
|
Scott Ullrich
|
|
473 |
9fdb578d
|
Ermal Lu?i
|
if (!is_array($config['nat']['rule']))
|
474 |
|
|
return;
|
475 |
|
|
|
476 |
5b237745
|
Scott Ullrich
|
function natcmp($a, $b) {
|
477 |
|
|
if ($a['external-address'] == $b['external-address']) {
|
478 |
|
|
if ($a['protocol'] == $b['protocol']) {
|
479 |
|
|
if ($a['external-port'] == $b['external-port']) {
|
480 |
|
|
return 0;
|
481 |
|
|
} else {
|
482 |
|
|
return ($a['external-port'] - $b['external-port']);
|
483 |
|
|
}
|
484 |
|
|
} else {
|
485 |
|
|
return strcmp($a['protocol'], $b['protocol']);
|
486 |
|
|
}
|
487 |
|
|
} else if (!$a['external-address'])
|
488 |
|
|
return 1;
|
489 |
|
|
else if (!$b['external-address'])
|
490 |
|
|
return -1;
|
491 |
|
|
else
|
492 |
|
|
return ipcmp($a['external-address'], $b['external-address']);
|
493 |
|
|
}
|
494 |
be81829f
|
Scott Ullrich
|
|
495 |
5b237745
|
Scott Ullrich
|
usort($config['nat']['rule'], "natcmp");
|
496 |
|
|
}
|
497 |
|
|
|
498 |
|
|
function nat_1to1_rules_sort() {
|
499 |
|
|
global $g, $config;
|
500 |
be81829f
|
Scott Ullrich
|
|
501 |
9fdb578d
|
Ermal Lu?i
|
if (!is_array($config['nat']['onetoone']))
|
502 |
|
|
return;
|
503 |
|
|
|
504 |
5b237745
|
Scott Ullrich
|
function nat1to1cmp($a, $b) {
|
505 |
|
|
return ipcmp($a['external'], $b['external']);
|
506 |
|
|
}
|
507 |
be81829f
|
Scott Ullrich
|
|
508 |
5b237745
|
Scott Ullrich
|
usort($config['nat']['onetoone'], "nat1to1cmp");
|
509 |
|
|
}
|
510 |
|
|
|
511 |
|
|
function nat_server_rules_sort() {
|
512 |
|
|
global $g, $config;
|
513 |
be81829f
|
Scott Ullrich
|
|
514 |
9fdb578d
|
Ermal Lu?i
|
if (!is_array($config['nat']['servernat']))
|
515 |
|
|
return;
|
516 |
|
|
|
517 |
5b237745
|
Scott Ullrich
|
function natservercmp($a, $b) {
|
518 |
|
|
return ipcmp($a['ipaddr'], $b['ipaddr']);
|
519 |
|
|
}
|
520 |
be81829f
|
Scott Ullrich
|
|
521 |
5b237745
|
Scott Ullrich
|
usort($config['nat']['servernat'], "natservercmp");
|
522 |
|
|
}
|
523 |
|
|
|
524 |
|
|
function nat_out_rules_sort() {
|
525 |
|
|
global $g, $config;
|
526 |
be81829f
|
Scott Ullrich
|
|
527 |
5b237745
|
Scott Ullrich
|
function natoutcmp($a, $b) {
|
528 |
|
|
return strcmp($a['source']['network'], $b['source']['network']);
|
529 |
|
|
}
|
530 |
be81829f
|
Scott Ullrich
|
|
531 |
5b237745
|
Scott Ullrich
|
usort($config['nat']['advancedoutbound']['rule'], "natoutcmp");
|
532 |
|
|
}
|
533 |
|
|
|
534 |
|
|
function pptpd_users_sort() {
|
535 |
|
|
global $g, $config;
|
536 |
be81829f
|
Scott Ullrich
|
|
537 |
9fdb578d
|
Ermal Lu?i
|
if (!is_array($config['ppptpd']['user']))
|
538 |
|
|
return;
|
539 |
|
|
|
540 |
5b237745
|
Scott Ullrich
|
function usercmp($a, $b) {
|
541 |
|
|
return strcasecmp($a['name'], $b['name']);
|
542 |
|
|
}
|
543 |
be81829f
|
Scott Ullrich
|
|
544 |
5b237745
|
Scott Ullrich
|
usort($config['pptpd']['user'], "usercmp");
|
545 |
|
|
}
|
546 |
|
|
|
547 |
9fdb578d
|
Ermal Lu?i
|
function l2tp_users_sort() {
|
548 |
|
|
global $g, $config;
|
549 |
|
|
|
550 |
|
|
if (!is_array($config['l2tp']['user']))
|
551 |
|
|
return;
|
552 |
|
|
|
553 |
|
|
function usercmp($a, $b) {
|
554 |
|
|
return strcasecmp($a['name'], $b['name']);
|
555 |
|
|
}
|
556 |
|
|
|
557 |
|
|
usort($config['l2tp']['user'], "usercmp");
|
558 |
|
|
}
|
559 |
|
|
|
560 |
a007827a
|
Scott Ullrich
|
function openvpn_users_sort() {
|
561 |
|
|
global $g, $config;
|
562 |
|
|
|
563 |
9fdb578d
|
Ermal Lu?i
|
if (!is_array($config['openvpn']['user']))
|
564 |
|
|
return;
|
565 |
|
|
|
566 |
a007827a
|
Scott Ullrich
|
function usercmp($a, $b) {
|
567 |
|
|
return strcasecmp($a['name'], $b['name']);
|
568 |
|
|
}
|
569 |
|
|
|
570 |
|
|
usort($config['openvpn']['user'], "usercmp");
|
571 |
|
|
}
|
572 |
|
|
|
573 |
4f1b515b
|
Scott Ullrich
|
function pppoe_users_sort() {
|
574 |
|
|
global $g, $config;
|
575 |
|
|
|
576 |
9fdb578d
|
Ermal Lu?i
|
if (!is_array($config['pppoe']['user']))
|
577 |
|
|
return;
|
578 |
|
|
|
579 |
4f1b515b
|
Scott Ullrich
|
function usercmp($a, $b) {
|
580 |
|
|
return strcasecmp($a['name'], $b['name']);
|
581 |
|
|
}
|
582 |
|
|
|
583 |
|
|
usort($config['pppoe']['user'], "usercmp");
|
584 |
|
|
}
|
585 |
|
|
|
586 |
5b237745
|
Scott Ullrich
|
function staticroutes_sort() {
|
587 |
|
|
global $g, $config;
|
588 |
|
|
|
589 |
9fdb578d
|
Ermal Lu?i
|
if (!is_array($config['staticroutes']['route']))
|
590 |
|
|
return;
|
591 |
|
|
|
592 |
5b237745
|
Scott Ullrich
|
function staticroutecmp($a, $b) {
|
593 |
|
|
return strcmp($a['network'], $b['network']);
|
594 |
|
|
}
|
595 |
|
|
|
596 |
|
|
usort($config['staticroutes']['route'], "staticroutecmp");
|
597 |
|
|
}
|
598 |
|
|
|
599 |
|
|
function hosts_sort() {
|
600 |
|
|
global $g, $config;
|
601 |
|
|
|
602 |
9fdb578d
|
Ermal Lu?i
|
if (!is_array($config['dnsmasq']['hosts']))
|
603 |
|
|
return;
|
604 |
|
|
|
605 |
5b237745
|
Scott Ullrich
|
function hostcmp($a, $b) {
|
606 |
|
|
return strcasecmp($a['host'], $b['host']);
|
607 |
|
|
}
|
608 |
|
|
|
609 |
|
|
usort($config['dnsmasq']['hosts'], "hostcmp");
|
610 |
|
|
}
|
611 |
|
|
|
612 |
fa550a17
|
Scott Ullrich
|
function staticmaps_sort($ifgui) {
|
613 |
5b237745
|
Scott Ullrich
|
global $g, $config;
|
614 |
|
|
|
615 |
|
|
function staticmapcmp($a, $b) {
|
616 |
|
|
return ipcmp($a['ipaddr'], $b['ipaddr']);
|
617 |
|
|
}
|
618 |
|
|
|
619 |
fa550a17
|
Scott Ullrich
|
usort($config['dhcpd'][$ifgui]['staticmap'], "staticmapcmp");
|
620 |
5b237745
|
Scott Ullrich
|
}
|
621 |
|
|
|
622 |
|
|
function aliases_sort() {
|
623 |
|
|
global $g, $config;
|
624 |
|
|
|
625 |
|
|
function aliascmp($a, $b) {
|
626 |
|
|
return strcmp($a['name'], $b['name']);
|
627 |
|
|
}
|
628 |
|
|
|
629 |
0dd69fb2
|
Scott Ullrich
|
if($config['aliases'])
|
630 |
|
|
usort($config['aliases']['alias'], "aliascmp");
|
631 |
5b237745
|
Scott Ullrich
|
}
|
632 |
|
|
|
633 |
615b27bc
|
Scott Dale
|
function schedule_sort(){
|
634 |
|
|
global $g, $config;
|
635 |
|
|
|
636 |
9fdb578d
|
Ermal Lu?i
|
if (!is_array($config['schedules']['schedule']))
|
637 |
|
|
return;
|
638 |
|
|
|
639 |
615b27bc
|
Scott Dale
|
function schedulecmp($a, $b) {
|
640 |
|
|
return strcmp($a['name'], $b['name']);
|
641 |
|
|
}
|
642 |
|
|
|
643 |
|
|
usort($config['schedules']['schedule'], "schedulecmp");
|
644 |
|
|
|
645 |
|
|
}
|
646 |
|
|
|
647 |
5b237745
|
Scott Ullrich
|
function ipsec_mobilekey_sort() {
|
648 |
|
|
global $g, $config;
|
649 |
|
|
|
650 |
|
|
function mobilekeycmp($a, $b) {
|
651 |
|
|
return strcmp($a['ident'][0], $b['ident'][0]);
|
652 |
|
|
}
|
653 |
|
|
|
654 |
|
|
usort($config['ipsec']['mobilekey'], "mobilekeycmp");
|
655 |
|
|
}
|
656 |
|
|
|
657 |
|
|
function proxyarp_sort() {
|
658 |
|
|
global $g, $config;
|
659 |
|
|
|
660 |
|
|
function proxyarpcmp($a, $b) {
|
661 |
|
|
if (isset($a['network']))
|
662 |
|
|
list($ast,$asn) = explode("/", $a['network']);
|
663 |
|
|
else if (isset($a['range'])) {
|
664 |
|
|
$ast = $a['range']['from'];
|
665 |
|
|
$asn = 32;
|
666 |
|
|
}
|
667 |
|
|
if (isset($b['network']))
|
668 |
|
|
list($bst,$bsn) = explode("/", $b['network']);
|
669 |
|
|
else if (isset($b['range'])) {
|
670 |
|
|
$bst = $b['range']['from'];
|
671 |
|
|
$bsn = 32;
|
672 |
|
|
}
|
673 |
|
|
if (ipcmp($ast, $bst) == 0)
|
674 |
|
|
return ($asn - $bsn);
|
675 |
|
|
else
|
676 |
|
|
return ipcmp($ast, $bst);
|
677 |
|
|
}
|
678 |
|
|
|
679 |
|
|
usort($config['proxyarp']['proxyarpnet'], "proxyarpcmp");
|
680 |
|
|
}
|
681 |
|
|
|
682 |
|
|
function passthrumacs_sort() {
|
683 |
|
|
global $g, $config;
|
684 |
|
|
|
685 |
|
|
function passthrumacscmp($a, $b) {
|
686 |
|
|
return strcmp($a['mac'], $b['mac']);
|
687 |
|
|
}
|
688 |
be81829f
|
Scott Ullrich
|
|
689 |
5b237745
|
Scott Ullrich
|
usort($config['captiveportal']['passthrumac'],"passthrumacscmp");
|
690 |
|
|
}
|
691 |
|
|
|
692 |
7afb67e0
|
Scott Ullrich
|
function cpelements_sort() {
|
693 |
|
|
global $g, $config;
|
694 |
|
|
|
695 |
|
|
function cpelementscmp($a, $b) {
|
696 |
|
|
return strcasecmp($a['name'], $b['name']);
|
697 |
|
|
}
|
698 |
d1cfae7b
|
Scott Ullrich
|
|
699 |
7afb67e0
|
Scott Ullrich
|
usort($config['captiveportal']['element'],"cpelementscmp");
|
700 |
|
|
}
|
701 |
|
|
|
702 |
5b237745
|
Scott Ullrich
|
function allowedips_sort() {
|
703 |
|
|
global $g, $config;
|
704 |
|
|
|
705 |
|
|
function allowedipscmp($a, $b) {
|
706 |
|
|
return strcmp($a['ip'], $b['ip']);
|
707 |
|
|
}
|
708 |
be81829f
|
Scott Ullrich
|
|
709 |
5b237745
|
Scott Ullrich
|
usort($config['captiveportal']['allowedip'],"allowedipscmp");
|
710 |
|
|
}
|
711 |
|
|
|
712 |
|
|
function wol_sort() {
|
713 |
|
|
global $g, $config;
|
714 |
|
|
|
715 |
|
|
function wolcmp($a, $b) {
|
716 |
|
|
return strcmp($a['descr'], $b['descr']);
|
717 |
|
|
}
|
718 |
be81829f
|
Scott Ullrich
|
|
719 |
5b237745
|
Scott Ullrich
|
usort($config['wol']['wolentry'], "wolcmp");
|
720 |
|
|
}
|
721 |
|
|
|
722 |
9d9adc7f
|
Scott Ullrich
|
function gentitle($title) {
|
723 |
|
|
global $navlevelsep;
|
724 |
c3deaf7f
|
Scott Ullrich
|
if(!is_array($title))
|
725 |
|
|
return $title;
|
726 |
|
|
else
|
727 |
|
|
return join($navlevelsep, $title);
|
728 |
9d9adc7f
|
Scott Ullrich
|
}
|
729 |
|
|
|
730 |
|
|
function genhtmltitle($title) {
|
731 |
|
|
global $config;
|
732 |
479628e6
|
Scott Ullrich
|
return gentitle($title);
|
733 |
5b237745
|
Scott Ullrich
|
}
|
734 |
|
|
|
735 |
d345bd39
|
Bill Marquette
|
/* update the changedesc and changecount(er) variables */
|
736 |
|
|
function update_changedesc($update) {
|
737 |
|
|
global $changedesc;
|
738 |
|
|
global $changecount;
|
739 |
|
|
|
740 |
|
|
$changedesc .= " {$update}";
|
741 |
|
|
$changecount++;
|
742 |
|
|
}
|
743 |
|
|
|
744 |
d6abaa18
|
Scott Ullrich
|
function clear_log_file($logfile = "/var/log/system.log") {
|
745 |
|
|
global $config, $g;
|
746 |
|
|
exec("/usr/bin/killall syslogd");
|
747 |
|
|
if(isset($config['system']['disablesyslogclog'])) {
|
748 |
|
|
unlink($logfile);
|
749 |
|
|
touch($logfile);
|
750 |
|
|
} else {
|
751 |
|
|
if(isset($config['system']['usefifolog']))
|
752 |
|
|
exec("/usr/sbin/fifolog_create -s 511488 {$logfile}");
|
753 |
|
|
else
|
754 |
|
|
exec("/usr/sbin/clog -i -s 511488 {$logfile}");
|
755 |
|
|
}
|
756 |
|
|
system_syslogd_start();
|
757 |
|
|
}
|
758 |
|
|
|
759 |
15c37284
|
Colin Smith
|
function dump_clog($logfile, $tail, $withorig = true, $grepfor = "", $grepinvert = "") {
|
760 |
23f1e22a
|
Colin Smith
|
global $g, $config;
|
761 |
ed8fab52
|
jim-p
|
$sor = isset($config['syslog']['reverse']) ? "-r" : "";
|
762 |
|
|
$logarr = "";
|
763 |
0fcfdd3d
|
Scott Ullrich
|
$grepline = " ";
|
764 |
fa626e70
|
Scott Ullrich
|
if(is_array($grepfor))
|
765 |
|
|
foreach($grepfor as $agrep)
|
766 |
|
|
$grepline .= " | grep \"$agrep\"";
|
767 |
|
|
if(is_array($grepinvert))
|
768 |
|
|
foreach($grepinvert as $agrep)
|
769 |
|
|
$grepline .= " | grep -v \"$agrep\"";
|
770 |
37c71b53
|
Scott Ullrich
|
if(file_exists($logfile) && filesize($logfile) == 0) {
|
771 |
330cbe3a
|
Scott Ullrich
|
$logarr = array("Log file started.");
|
772 |
|
|
} else {
|
773 |
b24358d1
|
Scott Ullrich
|
if($config['system']['disablesyslogclog']) {
|
774 |
330cbe3a
|
Scott Ullrich
|
exec("cat {$logfile}{$grepline} | /usr/bin/tail {$sor} -n {$tail}", $logarr);
|
775 |
b24358d1
|
Scott Ullrich
|
} else {
|
776 |
ed8fab52
|
jim-p
|
if(isset($config['system']['usefifolog']))
|
777 |
|
|
exec("/usr/sbin/fifolog_reader {$logfile}{$grepline} | /usr/bin/tail {$sor} -n {$tail}", $logarr);
|
778 |
b24358d1
|
Scott Ullrich
|
else
|
779 |
|
|
exec("/usr/sbin/clog {$logfile}{$grepline}| grep -v \"CLOG\" | grep -v \"\033\" | /usr/bin/tail {$sor} -n {$tail}", $logarr);
|
780 |
|
|
}
|
781 |
330cbe3a
|
Scott Ullrich
|
}
|
782 |
ed8fab52
|
jim-p
|
foreach ($logarr as $logent) {
|
783 |
|
|
$logent = preg_split("/\s+/", $logent, 6);
|
784 |
|
|
echo "<tr valign=\"top\">\n";
|
785 |
|
|
if ($withorig) {
|
786 |
|
|
if(isset($config['system']['usefifolog'])) {
|
787 |
|
|
$entry_date_time = htmlspecialchars(date("F j, Y, g:i a","" . $logent[1] . ""));
|
788 |
|
|
$entry_text = htmlspecialchars($logent[5]);
|
789 |
|
|
} else {
|
790 |
|
|
$entry_date_time = htmlspecialchars(join(" ", array_slice($logent, 0, 3)));
|
791 |
|
|
$entry_text = htmlspecialchars($logent[4] . " " . $logent[5]);
|
792 |
|
|
}
|
793 |
|
|
echo "<td class=\"listlr\" nowrap>{$entry_date_time}</td>\n";
|
794 |
|
|
echo "<td class=\"listr\">{$entry_text}</td>\n";
|
795 |
|
|
|
796 |
|
|
} else {
|
797 |
|
|
echo "<td class=\"listlr\" colspan=\"2\">" . htmlspecialchars($logent[5]) . "</td>\n";
|
798 |
|
|
}
|
799 |
|
|
echo "</tr>\n";
|
800 |
|
|
}
|
801 |
2c64eed7
|
Colin Smith
|
}
|
802 |
|
|
|
803 |
43e7c36c
|
Bill Marquette
|
function return_clog($logfile, $tail, $withorig = true, $grepfor = "", $grepinvert = "", $grepreverse = false) {
|
804 |
784c448c
|
Scott Ullrich
|
global $g, $config;
|
805 |
43e7c36c
|
Bill Marquette
|
$sor = (isset($config['syslog']['reverse']) || $grepreverse) ? "-r" : "";
|
806 |
784c448c
|
Scott Ullrich
|
$logarr = "";
|
807 |
a0e4bd9f
|
Scott Ullrich
|
$grepline = " ";
|
808 |
fa626e70
|
Scott Ullrich
|
if(is_array($grepfor))
|
809 |
|
|
foreach($grepfor as $agrep)
|
810 |
|
|
$grepline .= " | grep \"$agrep\"";
|
811 |
|
|
if(is_array($grepinvert))
|
812 |
|
|
foreach($grepinvert as $agrep)
|
813 |
|
|
$grepline .= " | grep -v \"$agrep\"";
|
814 |
b24358d1
|
Scott Ullrich
|
if($config['system']['disablesyslogclog']) {
|
815 |
2ff9980b
|
Scott Ullrich
|
exec("cat {$logfile}{$grepline} | /usr/bin/tail {$sor} -n {$tail}", $logarr);
|
816 |
b24358d1
|
Scott Ullrich
|
} else {
|
817 |
|
|
if(isset($config['system']['usefifolog'])) {
|
818 |
|
|
exec("/usr/sbin/fifolog_reader {$logfile}{$grepline} | /usr/bin/tail {$sor} -n {$tail}", $logarr);
|
819 |
|
|
} else {
|
820 |
|
|
exec("/usr/sbin/clog {$logfile}{$grepline}| grep -v \"CLOG\" | grep -v \"\033\" | /usr/bin/tail {$sor} -n {$tail}", $logarr);
|
821 |
|
|
}
|
822 |
|
|
}
|
823 |
fa626e70
|
Scott Ullrich
|
return($logarr);
|
824 |
784c448c
|
Scott Ullrich
|
}
|
825 |
|
|
|
826 |
4d762703
|
Bill Marquette
|
/* Check if variable has changed, update and log if it has
|
827 |
edf14245
|
Bill Marquette
|
* returns true if var changed
|
828 |
4d762703
|
Bill Marquette
|
* varname = variable name in plain text
|
829 |
|
|
* orig = original value
|
830 |
|
|
* new = new value
|
831 |
|
|
*/
|
832 |
9eab73da
|
Bill Marquette
|
function update_if_changed($varname, & $orig, $new) {
|
833 |
8b3ccf12
|
Bill Marquette
|
if (is_array($orig) && is_array($new)) {
|
834 |
|
|
$a_diff = array_diff($orig, $new);
|
835 |
|
|
foreach ($a_diff as $diff) {
|
836 |
|
|
update_changedesc("removed {$varname}: \"{$diff}\"");
|
837 |
|
|
}
|
838 |
|
|
$a_diff = array_diff($new, $orig);
|
839 |
|
|
foreach ($a_diff as $diff) {
|
840 |
|
|
update_changedesc("added {$varname}: \"{$diff}\"");
|
841 |
|
|
}
|
842 |
4d762703
|
Bill Marquette
|
$orig = $new;
|
843 |
edf14245
|
Bill Marquette
|
return true;
|
844 |
d1cfae7b
|
Scott Ullrich
|
|
845 |
|
|
} else {
|
846 |
8b3ccf12
|
Bill Marquette
|
if ($orig != $new) {
|
847 |
|
|
update_changedesc("{$varname}: \"{$orig}\" -> \"{$new}\"");
|
848 |
|
|
$orig = $new;
|
849 |
|
|
return true;
|
850 |
|
|
}
|
851 |
4d762703
|
Bill Marquette
|
}
|
852 |
edf14245
|
Bill Marquette
|
return false;
|
853 |
4d762703
|
Bill Marquette
|
}
|
854 |
|
|
|
855 |
9a4cb6b7
|
Scott Ullrich
|
function address_to_pconfig($adr, &$padr, &$pmask, &$pnot, &$pbeginport, &$pendport) {
|
856 |
|
|
|
857 |
|
|
if (isset($adr['any']))
|
858 |
|
|
$padr = "any";
|
859 |
|
|
else if ($adr['network'])
|
860 |
|
|
$padr = $adr['network'];
|
861 |
|
|
else if ($adr['address']) {
|
862 |
|
|
list($padr, $pmask) = explode("/", $adr['address']);
|
863 |
|
|
if (!$pmask)
|
864 |
|
|
$pmask = 32;
|
865 |
|
|
}
|
866 |
|
|
|
867 |
|
|
if (isset($adr['not']))
|
868 |
|
|
$pnot = 1;
|
869 |
|
|
else
|
870 |
|
|
$pnot = 0;
|
871 |
|
|
|
872 |
|
|
if ($adr['port']) {
|
873 |
|
|
list($pbeginport, $pendport) = explode("-", $adr['port']);
|
874 |
|
|
if (!$pendport)
|
875 |
|
|
$pendport = $pbeginport;
|
876 |
|
|
} else {
|
877 |
|
|
if(alias_expand($pbeginport) <> "" || alias_expand($pendport) <> "") {
|
878 |
|
|
/* Item is a port alias */
|
879 |
|
|
} else {
|
880 |
|
|
$pbeginport = "any";
|
881 |
|
|
$pendport = "any";
|
882 |
|
|
}
|
883 |
|
|
}
|
884 |
|
|
}
|
885 |
|
|
|
886 |
|
|
function pconfig_to_address(&$adr, $padr, $pmask, $pnot=false, $pbeginport=0, $pendport=0) {
|
887 |
|
|
|
888 |
|
|
$adr = array();
|
889 |
|
|
|
890 |
|
|
if ($padr == "any")
|
891 |
|
|
$adr['any'] = true;
|
892 |
|
|
else if (is_specialnet($padr))
|
893 |
|
|
$adr['network'] = $padr;
|
894 |
|
|
else {
|
895 |
|
|
$adr['address'] = $padr;
|
896 |
|
|
if ($pmask != 32)
|
897 |
|
|
$adr['address'] .= "/" . $pmask;
|
898 |
|
|
}
|
899 |
|
|
|
900 |
|
|
if ($pnot)
|
901 |
|
|
$adr['not'] = true;
|
902 |
|
|
else
|
903 |
63637de9
|
Bill Marquette
|
unset($adr['not']);
|
904 |
9a4cb6b7
|
Scott Ullrich
|
|
905 |
|
|
if (($pbeginport != 0) && ($pbeginport != "any")) {
|
906 |
|
|
if ($pbeginport != $pendport)
|
907 |
|
|
$adr['port'] = $pbeginport . "-" . $pendport;
|
908 |
|
|
else
|
909 |
|
|
$adr['port'] = $pbeginport;
|
910 |
|
|
}
|
911 |
|
|
|
912 |
|
|
if(alias_expand($pbeginport)) {
|
913 |
|
|
$adr['port'] = $pbeginport;
|
914 |
|
|
}
|
915 |
|
|
}
|
916 |
|
|
|
917 |
|
|
function is_specialnet($net) {
|
918 |
|
|
global $specialsrcdst;
|
919 |
8c984f57
|
Scott Ullrich
|
if(!$net)
|
920 |
|
|
return false;
|
921 |
9a4cb6b7
|
Scott Ullrich
|
if (in_array($net, $specialsrcdst) || strstr($net, "opt"))
|
922 |
|
|
return true;
|
923 |
|
|
else
|
924 |
|
|
return false;
|
925 |
|
|
}
|
926 |
|
|
|
927 |
c6a74fa1
|
Scott Ullrich
|
function ipsec_ca_sort() {
|
928 |
|
|
global $g, $config;
|
929 |
|
|
|
930 |
|
|
function ipseccacmp($a, $b) {
|
931 |
|
|
return strcmp($a['ident'], $b['ident']);
|
932 |
|
|
}
|
933 |
|
|
|
934 |
|
|
usort($config['ipsec']['cacert'], "ipseccacmp");
|
935 |
|
|
}
|
936 |
|
|
|
937 |
b93f9af4
|
Scott Dale
|
//function to create widget tabs when called
|
938 |
|
|
function display_widget_tabs(& $tab_array) {
|
939 |
|
|
echo "<div id='tabs'>";
|
940 |
|
|
$tabscounter = 0;
|
941 |
|
|
foreach ($tab_array as $ta) {
|
942 |
|
|
$dashpos = strpos($ta[2],'-');
|
943 |
|
|
$tabname = $ta[2] . "-tab";
|
944 |
|
|
$tabclass = substr($ta[2],0,$dashpos);
|
945 |
|
|
$tabclass = $tabclass . "-class";
|
946 |
|
|
if ($ta[1] == true) {
|
947 |
|
|
$tabActive = "table-cell";
|
948 |
|
|
$tabNonActive = "none";
|
949 |
|
|
}
|
950 |
|
|
else {
|
951 |
|
|
$tabActive = "none";
|
952 |
|
|
$tabNonActive = "table-cell";
|
953 |
|
|
}
|
954 |
|
|
echo "<div id='{$ta[2]}-active' class='{$tabclass}-tabactive' style='display:{$tabActive}; background-color:#EEEEEE; color:black;'>";
|
955 |
|
|
echo "<B> {$ta[0]}";
|
956 |
|
|
echo " </B>";
|
957 |
|
|
echo "</div>";
|
958 |
|
|
|
959 |
|
|
echo "<div id='{$ta[2]}-deactive' class='{$tabclass}-tabdeactive' style='display:{$tabNonActive}; background-color:#777777; color:white; cursor: pointer;' onClick=\"return changeTabDIV('{$ta[2]}')\">";
|
960 |
|
|
echo "<B> {$ta[0]}";
|
961 |
|
|
echo " </B>";
|
962 |
|
|
echo "</div>";
|
963 |
|
|
}
|
964 |
|
|
|
965 |
|
|
echo "<script type=\"text/javascript\">";
|
966 |
|
|
echo "NiftyCheck();\n";
|
967 |
|
|
echo "Rounded(\"div.{$tabclass}-tabactive\",\"top\",\"#CCCCCC\",\"#EEEEEE\",\"smooth\");\n";
|
968 |
|
|
echo "Rounded(\"div.{$tabclass}-tabdeactive\",\"top\",\"#CCCCCC\",\"#777777\",\"smooth\");\n";
|
969 |
|
|
echo "</script>";
|
970 |
|
|
echo "</div>";
|
971 |
|
|
}
|
972 |
|
|
|
973 |
06a9dc5a
|
Scott Ullrich
|
|
974 |
|
|
// Return inline javascript file or CSS to minimizie
|
975 |
|
|
// request count going back to server.
|
976 |
|
|
function outputJavaScriptFileInline($javascript) {
|
977 |
|
|
if(file_exists($javascript)) {
|
978 |
b77e126b
|
Scott Ullrich
|
echo "\n<script type=\"text/javascript\">\n";
|
979 |
06a9dc5a
|
Scott Ullrich
|
include($javascript);
|
980 |
b77e126b
|
Scott Ullrich
|
echo "\n</script>\n";
|
981 |
06a9dc5a
|
Scott Ullrich
|
} else {
|
982 |
fb673a31
|
Scott Ullrich
|
echo "\n\n<!-- Could not location file: {$javascript} -->\n\n";
|
983 |
06a9dc5a
|
Scott Ullrich
|
}
|
984 |
|
|
}
|
985 |
|
|
|
986 |
|
|
|
987 |
76cd0d89
|
Scott Ullrich
|
|
988 |
|
|
function outputCSSPrintFileInline($css) {
|
989 |
|
|
if(file_exists($css)) {
|
990 |
|
|
echo "\n<style media=\"print\" type=\"text/css\">\n";
|
991 |
|
|
include($css);
|
992 |
|
|
echo "\n</style>\n";
|
993 |
|
|
} else {
|
994 |
fb673a31
|
Scott Ullrich
|
echo "\n\n<!-- Could not location file: {$css} -->\n\n";
|
995 |
76cd0d89
|
Scott Ullrich
|
}
|
996 |
|
|
}
|
997 |
|
|
|
998 |
|
|
|
999 |
06a9dc5a
|
Scott Ullrich
|
function outputCSSFileInline($css) {
|
1000 |
|
|
if(file_exists($css)) {
|
1001 |
b77e126b
|
Scott Ullrich
|
echo "\n<style type=\"text/css\">\n";
|
1002 |
06a9dc5a
|
Scott Ullrich
|
include($css);
|
1003 |
b77e126b
|
Scott Ullrich
|
echo "\n</style>\n";
|
1004 |
06a9dc5a
|
Scott Ullrich
|
} else {
|
1005 |
fb673a31
|
Scott Ullrich
|
echo "\n\n<!-- Could not location file: {$css} -->\n\n";
|
1006 |
06a9dc5a
|
Scott Ullrich
|
}
|
1007 |
|
|
}
|
1008 |
|
|
|
1009 |
50d86c13
|
Bill Marquette
|
$rfc2616 = array(
|
1010 |
|
|
100 => "100 Continue",
|
1011 |
|
|
101 => "101 Switching Protocols",
|
1012 |
|
|
200 => "200 OK",
|
1013 |
|
|
201 => "201 Created",
|
1014 |
|
|
202 => "202 Accepted",
|
1015 |
|
|
203 => "203 Non-Authoritative Information",
|
1016 |
|
|
204 => "204 No Content",
|
1017 |
|
|
205 => "205 Reset Content",
|
1018 |
|
|
206 => "206 Partial Content",
|
1019 |
|
|
300 => "300 Multiple Choices",
|
1020 |
|
|
301 => "301 Moved Permanently",
|
1021 |
|
|
302 => "302 Found",
|
1022 |
|
|
303 => "303 See Other",
|
1023 |
|
|
304 => "304 Not Modified",
|
1024 |
|
|
305 => "305 Use Proxy",
|
1025 |
|
|
306 => "306 (Unused)",
|
1026 |
|
|
307 => "307 Temporary Redirect",
|
1027 |
|
|
400 => "400 Bad Request",
|
1028 |
|
|
401 => "401 Unauthorized",
|
1029 |
|
|
402 => "402 Payment Required",
|
1030 |
|
|
403 => "403 Forbidden",
|
1031 |
|
|
404 => "404 Not Found",
|
1032 |
|
|
405 => "405 Method Not Allowed",
|
1033 |
|
|
406 => "406 Not Acceptable",
|
1034 |
|
|
407 => "407 Proxy Authentication Required",
|
1035 |
|
|
408 => "408 Request Timeout",
|
1036 |
|
|
409 => "409 Conflict",
|
1037 |
|
|
410 => "410 Gone",
|
1038 |
|
|
411 => "411 Length Required",
|
1039 |
|
|
412 => "412 Precondition Failed",
|
1040 |
|
|
413 => "413 Request Entity Too Large",
|
1041 |
|
|
414 => "414 Request-URI Too Long",
|
1042 |
|
|
415 => "415 Unsupported Media Type",
|
1043 |
|
|
416 => "416 Requested Range Not Satisfiable",
|
1044 |
|
|
417 => "417 Expectation Failed",
|
1045 |
|
|
500 => "500 Internal Server Error",
|
1046 |
|
|
501 => "501 Not Implemented",
|
1047 |
|
|
502 => "502 Bad Gateway",
|
1048 |
|
|
503 => "503 Service Unavailable",
|
1049 |
|
|
504 => "504 Gateway Timeout",
|
1050 |
|
|
505 => "505 HTTP Version Not Supported"
|
1051 |
|
|
);
|
1052 |
|
|
|
1053 |
|
|
function is_rfc2616_code($code) {
|
1054 |
|
|
global $rfc2616;
|
1055 |
|
|
if (isset($rfc2616[$code]))
|
1056 |
|
|
return true;
|
1057 |
|
|
else
|
1058 |
|
|
return false;
|
1059 |
|
|
}
|
1060 |
|
|
|
1061 |
|
|
function print_rfc2616_select($tag, $current){
|
1062 |
|
|
global $rfc2616;
|
1063 |
6b07c15a
|
Matthew Grooms
|
|
1064 |
50d86c13
|
Bill Marquette
|
/* Default to 200 OK if not set */
|
1065 |
|
|
if ($current == "")
|
1066 |
|
|
$current = 200;
|
1067 |
|
|
|
1068 |
|
|
echo "<select id=\"{$tag}\" name=\"{$tag}\">\n";
|
1069 |
|
|
foreach($rfc2616 as $code => $message) {
|
1070 |
|
|
if ($code == $current) {
|
1071 |
|
|
$sel = " selected";
|
1072 |
|
|
} else {
|
1073 |
|
|
$sel = "";
|
1074 |
|
|
}
|
1075 |
|
|
echo "<option value=\"{$code}\"{$sel}>{$message}</option>\n";
|
1076 |
|
|
}
|
1077 |
|
|
}
|
1078 |
|
|
|
1079 |
0919224f
|
Bill Marquette
|
// Useful debugging function, much cleaner than print_r
|
1080 |
|
|
function echo_array($array,$return_me=false){
|
1081 |
|
|
if(is_array($array) == false){
|
1082 |
|
|
$return = "The provided variable is not an array.";
|
1083 |
|
|
}else{
|
1084 |
|
|
foreach($array as $name=>$value){
|
1085 |
|
|
if(is_array($value)){
|
1086 |
|
|
$return .= "";
|
1087 |
|
|
$return .= "['<b>$name</b>'] {<div style='margin-left:10px;'>\n";
|
1088 |
|
|
$return .= echo_array($value,true);
|
1089 |
|
|
$return .= "</div>}";
|
1090 |
|
|
$return .= "\n\n";
|
1091 |
|
|
}else{
|
1092 |
|
|
if(is_string($value)){
|
1093 |
|
|
$value = "\"$value\"";
|
1094 |
|
|
}
|
1095 |
|
|
$return .= "['<b>$name</b>'] = $value\n\n";
|
1096 |
|
|
}
|
1097 |
|
|
}
|
1098 |
|
|
}
|
1099 |
|
|
if($return_me == true){
|
1100 |
|
|
return $return;
|
1101 |
|
|
}else{
|
1102 |
|
|
echo "<pre>".$return."</pre>";
|
1103 |
|
|
}
|
1104 |
|
|
}
|
1105 |
|
|
|
1106 |
b63f2e8b
|
Matthew Grooms
|
function add_package_tabs($tabgroup, & $tab_array) {
|
1107 |
bddd43b4
|
Scott Ullrich
|
global $config, $g;
|
1108 |
b63f2e8b
|
Matthew Grooms
|
|
1109 |
|
|
if(!is_array($config['installedpackages']))
|
1110 |
|
|
return;
|
1111 |
|
|
if(!is_array($config['installedpackages']['tab']))
|
1112 |
|
|
return;
|
1113 |
|
|
|
1114 |
|
|
foreach($config['installedpackages']['tab'] as $tab) {
|
1115 |
|
|
if ($tab['group'] !== $group)
|
1116 |
|
|
continue;
|
1117 |
|
|
$tab_entry = array();
|
1118 |
5dbd65a3
|
Scott Ullrich
|
if($tab['name']) {
|
1119 |
|
|
$tab_entry[] = $tab['name'];
|
1120 |
|
|
$tab_entry[] = false;
|
1121 |
|
|
$tab_entry[] = $tab['url'];
|
1122 |
|
|
$tab_array[] = $tab_entry;
|
1123 |
|
|
}
|
1124 |
bddd43b4
|
Scott Ullrich
|
}
|
1125 |
|
|
}
|
1126 |
0919224f
|
Bill Marquette
|
|
1127 |
330cbe3a
|
Scott Ullrich
|
?>
|