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