From: ptaylor
Date: Mon, 6 Feb 2006 22:06:24 +0000 (+0000)
Subject: git-svn-id: https://svn.m0n0.ch/wall/trunk@50 e36fee2c-cc09-0410-a7cc-ebac5c6737de
X-Git-Url: https://git.gsnw.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=59877bd1e25d7ac0ed1a6f995c6a8403ed309d4c;p=m0n0chwall.git
git-svn-id: https://svn.m0n0.ch/wall/trunk@50 e36fee2c-cc09-0410-a7cc-ebac5c6737de
---
diff --git a/phpconf/inc/pear.inc b/phpconf/inc/pear.inc
index 5383e00..74fc18d 100644
--- a/phpconf/inc/pear.inc
+++ b/phpconf/inc/pear.inc
@@ -1,5 +1,5 @@
$userdata) {
+ fwrite($fd, $user . ":"
+ . $userdata['password'] . "\n");
+ }
+ }
+
fclose($fd);
chmod("{$g['varrun_path']}/htpasswd", 0600);
diff --git a/phpconf/inc/xmlparse.inc b/phpconf/inc/xmlparse.inc
index ea829b4..229f333 100644
--- a/phpconf/inc/xmlparse.inc
+++ b/phpconf/inc/xmlparse.inc
@@ -30,7 +30,7 @@
*/
/* tags that are always to be handled as lists */
-$listtags = explode(" ", "rule user key dnsserver winsserver " .
+$listtags = explode(" ", "rule user key dnsserver winsserver pages " .
"encryption-algorithm-option hash-algorithm-option hosts tunnel onetoone " .
"staticmap route alias pipe queue shellcmd cacert earlyshellcmd mobilekey " .
"servernat proxyarpnet passthrumac allowedip wolentry vlan domainoverrides element");
diff --git a/webgui/auth.inc b/webgui/auth.inc
new file mode 100644
index 0000000..26a4831
--- /dev/null
+++ b/webgui/auth.inc
@@ -0,0 +1,67 @@
+
+/*
+ auth.inc
+ part of m0n0wall (http://m0n0.ch/wall)
+
+ Copyright (C) 2006 Paul Taylor .
+ All rights reserved.
+ Copyright (C) 2003-2006 Manuel Kasper .
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+// Once here, the user has authenticated with the web server.
+// Now, we give them access only to the appropriate pages for their group.
+if (!($_SERVER['REMOTE_USER'] === $config['system']['username'])) {
+ $allowed[] = '';
+ if (isset($config['system']['groups'][$config['system']['users'][$_SERVER['REMOTE_USER']]['group']]['pages'])) {
+ $allowed = &$config['system']['groups'][$config['system']['users'][$_SERVER['REMOTE_USER']]['group']]['pages'];
+ }
+
+ // If the user is attempting to hit the default page, set it to specifically look for /index.php.
+ // Without this, any user would have access to the index page.
+ if ($_SERVER['PHP_SELF'] == '/')
+ $_SERVER['PHP_SELF'] = '/index.php';
+
+ // Strip the leading / from the currently requested PHP page
+ if (!in_array(basename($_SERVER['PHP_SELF']),$allowed)) {
+ // The currently logged in user is not allowed to access the page
+ // they are attempting to go to. Redirect them to an allowed page.
+
+ if (in_array("index.php",$allowed)) {
+ header("Location: /index.php");
+ exit;
+ }
+ else {
+ header("HTTP/1.0 401 Unauthorized");
+ header("Status: 401 Unauthorized");
+
+ echo "401 Unauthorized
401 Unauthorized
Authorization required.";
+ exit;
+ }
+ }
+}
+
+
+
+?>
\ No newline at end of file
diff --git a/webgui/diag_ipsec_sad.php b/webgui/diag_ipsec_sad.php
index 3d3e8a3..ae2b401 100644
--- a/webgui/diag_ipsec_sad.php
+++ b/webgui/diag_ipsec_sad.php
@@ -1,129 +1,132 @@
-#!/usr/local/bin/php
-.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-*/
-
-$pgtitle = array("Diagnostics", "IPsec");
-
-require("guiconfig.inc");
-?>
-
-
-
+#!/usr/local/bin/php
+.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array("Diagnostics", "IPsec");
+
+require("guiconfig.inc");
+?>
+
+
+
diff --git a/webgui/diag_ipsec_spd.php b/webgui/diag_ipsec_spd.php
index aabdb3a..6056625 100644
--- a/webgui/diag_ipsec_spd.php
+++ b/webgui/diag_ipsec_spd.php
@@ -1,145 +1,148 @@
-#!/usr/local/bin/php
-.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-*/
-
-$pgtitle = array("Diagnostics", "IPsec");
-
-require("guiconfig.inc");
-?>
-
-
-
+#!/usr/local/bin/php
+.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array("Diagnostics", "IPsec");
+
+require("guiconfig.inc");
+?>
+
+
+
diff --git a/webgui/diag_logs.php b/webgui/diag_logs.php
index 2acea3e..5577649 100644
--- a/webgui/diag_logs.php
+++ b/webgui/diag_logs.php
@@ -1,95 +1,98 @@
-#!/usr/local/bin/php
-.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-*/
-
-$pgtitle = array("Diagnostics", "Logs");
-require("guiconfig.inc");
-
-$nentries = $config['syslog']['nentries'];
-if (!$nentries)
- $nentries = 50;
-
-if ($_POST['clear']) {
- exec("/usr/sbin/clog -i -s 262144 /var/log/system.log");
- /* redirect to avoid reposting form data on refresh */
- header("Location: diag_logs.php");
- exit;
-}
-
-function dump_clog($logfile, $tail, $withorig = true) {
- global $g, $config;
-
- $sor = isset($config['syslog']['reverse']) ? "-r" : "";
-
- exec("/usr/sbin/clog " . $logfile . " | tail {$sor} -n " . $tail, $logarr);
-
- foreach ($logarr as $logent) {
- $logent = preg_split("/\s+/", $logent, 6);
- echo "
-
+#!/usr/local/bin/php
+.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array("Diagnostics", "Logs");
+require("guiconfig.inc");
+
+$nentries = $config['syslog']['nentries'];
+if (!$nentries)
+ $nentries = 50;
+
+if ($_POST['clear']) {
+ exec("/usr/sbin/clog -i -s 262144 /var/log/system.log");
+ /* redirect to avoid reposting form data on refresh */
+ header("Location: diag_logs.php");
+ exit;
+}
+
+function dump_clog($logfile, $tail, $withorig = true) {
+ global $g, $config;
+
+ $sor = isset($config['syslog']['reverse']) ? "-r" : "";
+
+ exec("/usr/sbin/clog " . $logfile . " | tail {$sor} -n " . $tail, $logarr);
+
+ foreach ($logarr as $logent) {
+ $logent = preg_split("/\s+/", $logent, 6);
+ echo "
+
diff --git a/webgui/diag_logs_dhcp.php b/webgui/diag_logs_dhcp.php
index 2577ef3..31b0af8 100644
--- a/webgui/diag_logs_dhcp.php
+++ b/webgui/diag_logs_dhcp.php
@@ -1,95 +1,98 @@
-#!/usr/local/bin/php
-.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-*/
-
-$pgtitle = array("Diagnostics", "Logs");
-require("guiconfig.inc");
-
-$nentries = $config['syslog']['nentries'];
-if (!$nentries)
- $nentries = 50;
-
-if ($_POST['clear']) {
- exec("/usr/sbin/clog -i -s 32768 /var/log/dhcpd.log");
- /* redirect to avoid reposting form data on refresh */
- header("Location: diag_logs_dhcp.php");
- exit;
-}
-
-function dump_clog($logfile, $tail, $withorig = true) {
- global $g, $config;
-
- $sor = isset($config['syslog']['reverse']) ? "-r" : "";
-
- exec("/usr/sbin/clog " . $logfile . " | tail {$sor} -n " . $tail, $logarr);
-
- foreach ($logarr as $logent) {
- $logent = preg_split("/\s+/", $logent, 6);
- echo "
-
+#!/usr/local/bin/php
+.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array("Diagnostics", "Logs");
+require("guiconfig.inc");
+
+$nentries = $config['syslog']['nentries'];
+if (!$nentries)
+ $nentries = 50;
+
+if ($_POST['clear']) {
+ exec("/usr/sbin/clog -i -s 32768 /var/log/dhcpd.log");
+ /* redirect to avoid reposting form data on refresh */
+ header("Location: diag_logs_dhcp.php");
+ exit;
+}
+
+function dump_clog($logfile, $tail, $withorig = true) {
+ global $g, $config;
+
+ $sor = isset($config['syslog']['reverse']) ? "-r" : "";
+
+ exec("/usr/sbin/clog " . $logfile . " | tail {$sor} -n " . $tail, $logarr);
+
+ foreach ($logarr as $logent) {
+ $logent = preg_split("/\s+/", $logent, 6);
+ echo "
+
diff --git a/webgui/diag_logs_filter.php b/webgui/diag_logs_filter.php
index d75cece..6c40e0a 100644
--- a/webgui/diag_logs_filter.php
+++ b/webgui/diag_logs_filter.php
@@ -1,289 +1,292 @@
-#!/usr/local/bin/php
-.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-*/
-
-$pgtitle = array("Diagnostics", "Logs");
-require("guiconfig.inc");
-
-$protocols = explode(" ", "TCP UDP TCP/UDP ICMP ESP AH GRE IPv6 IGMP any");
-
-$nentries = $config['syslog']['nentries'];
-$resolve = isset($config['syslog']['resolve']);
-
-if (!$nentries)
- $nentries = 50;
-
-if ($_POST['clear']) {
- exec("/usr/sbin/clog -i -s 262144 /var/log/filter.log");
- /* redirect to avoid reposting form data on refresh */
- header("Location: diag_logs_filter.php");
- exit;
-}
-
-
-if (isset($_GET['act']) && preg_match("/^[pb]+$/", $_GET['act'])) {
- $action = $_GET['act'];
- $ifstring .= "&act=$action";
- $srcstring .= "&act=$action";
- $dststring .= "&act=$action";
- $prstring .= "&act=$action";
-}
-
-if (isset($_GET['if']) && ($_GET['if'] != "")) {
- $iface = $_GET['if'];
- $actstring .= "&if=$iface";
- $srcstring .= "&if=$iface";
- $dststring .= "&if=$iface";
- $prstring .= "&if=$iface";
-}
-
-if (isset($_GET['pr']) && in_array($_GET['pr'], $protocols)) {
- $proto = $_GET['pr'];
- $actstring .= "&pr=$proto";
- $ifstring .= "&pr=$proto";
- $srcstring .= "&pr=$proto";
- $dststring .= "&pr=$proto";
-}
-
-if (isset($_GET['sp']) && (is_numeric($_GET['sp']))) {
- $srcport = $_GET['sp'];
- $actstring .= "&sp=$srcport";
- $ifstring .= "&sp=$srcport";
- $dststring .= "&sp=$srcport";
- $prstring .= "&sp=$srcport";
-}
-
-if (isset($_GET['dp']) && (is_numeric($_GET['dp']))) {
- $dstport = $_GET['dp'];
- $actstring .= "&dp=$dstport";
- $ifstring .= "&dp=$dstport";
- $srcstring .= "&dp=$dstport";
- $prstring .= "&dp=$dstport";
-}
-
-
-function dump_clog($logfile, $tail, $withorig = true) {
- global $g, $config;
-
- $sor = isset($config['syslog']['reverse']) ? "-r" : "";
-
- exec("/usr/sbin/clog " . $logfile . " | tail {$sor} -n " . $tail, $logarr);
-
- foreach ($logarr as $logent) {
- $logent = preg_split("/\s+/", $logent, 6);
- echo "
-
+#!/usr/local/bin/php
+.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array("Diagnostics", "Logs");
+require("guiconfig.inc");
+
+$protocols = explode(" ", "TCP UDP TCP/UDP ICMP ESP AH GRE IPv6 IGMP any");
+
+$nentries = $config['syslog']['nentries'];
+$resolve = isset($config['syslog']['resolve']);
+
+if (!$nentries)
+ $nentries = 50;
+
+if ($_POST['clear']) {
+ exec("/usr/sbin/clog -i -s 262144 /var/log/filter.log");
+ /* redirect to avoid reposting form data on refresh */
+ header("Location: diag_logs_filter.php");
+ exit;
+}
+
+
+if (isset($_GET['act']) && preg_match("/^[pb]+$/", $_GET['act'])) {
+ $action = $_GET['act'];
+ $ifstring .= "&act=$action";
+ $srcstring .= "&act=$action";
+ $dststring .= "&act=$action";
+ $prstring .= "&act=$action";
+}
+
+if (isset($_GET['if']) && ($_GET['if'] != "")) {
+ $iface = $_GET['if'];
+ $actstring .= "&if=$iface";
+ $srcstring .= "&if=$iface";
+ $dststring .= "&if=$iface";
+ $prstring .= "&if=$iface";
+}
+
+if (isset($_GET['pr']) && in_array($_GET['pr'], $protocols)) {
+ $proto = $_GET['pr'];
+ $actstring .= "&pr=$proto";
+ $ifstring .= "&pr=$proto";
+ $srcstring .= "&pr=$proto";
+ $dststring .= "&pr=$proto";
+}
+
+if (isset($_GET['sp']) && (is_numeric($_GET['sp']))) {
+ $srcport = $_GET['sp'];
+ $actstring .= "&sp=$srcport";
+ $ifstring .= "&sp=$srcport";
+ $dststring .= "&sp=$srcport";
+ $prstring .= "&sp=$srcport";
+}
+
+if (isset($_GET['dp']) && (is_numeric($_GET['dp']))) {
+ $dstport = $_GET['dp'];
+ $actstring .= "&dp=$dstport";
+ $ifstring .= "&dp=$dstport";
+ $srcstring .= "&dp=$dstport";
+ $prstring .= "&dp=$dstport";
+}
+
+
+function dump_clog($logfile, $tail, $withorig = true) {
+ global $g, $config;
+
+ $sor = isset($config['syslog']['reverse']) ? "-r" : "";
+
+ exec("/usr/sbin/clog " . $logfile . " | tail {$sor} -n " . $tail, $logarr);
+
+ foreach ($logarr as $logent) {
+ $logent = preg_split("/\s+/", $logent, 6);
+ echo "
+
diff --git a/webgui/diag_logs_portal.php b/webgui/diag_logs_portal.php
index 916a253..fc70dbb 100644
--- a/webgui/diag_logs_portal.php
+++ b/webgui/diag_logs_portal.php
@@ -1,90 +1,93 @@
-#!/usr/local/bin/php
-.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-*/
-
-$pgtitle = array("Diagnostics", "Logs");
-require("guiconfig.inc");
-
-$nentries = $config['syslog']['nentries'];
-if (!$nentries)
- $nentries = 50;
-
-if ($_POST['clear']) {
- exec("/usr/sbin/clog -i -s 32768 /var/log/portalauth.log");
- /* redirect to avoid reposting form data on refresh */
- header("Location: diag_logs_portal.php");
- exit;
-}
-
-function dump_clog($logfile, $tail) {
- global $g, $config;
-
- $sor = isset($config['syslog']['reverse']) ? "-r" : "";
-
- exec("/usr/sbin/clog " . $logfile . " | tail {$sor} -n " . $tail, $logarr);
-
- foreach ($logarr as $logent) {
- $logent = preg_split("/\s+/", $logent, 6);
- echo "
-
+#!/usr/local/bin/php
+.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array("Diagnostics", "Logs");
+require("guiconfig.inc");
+
+$nentries = $config['syslog']['nentries'];
+if (!$nentries)
+ $nentries = 50;
+
+if ($_POST['clear']) {
+ exec("/usr/sbin/clog -i -s 32768 /var/log/portalauth.log");
+ /* redirect to avoid reposting form data on refresh */
+ header("Location: diag_logs_portal.php");
+ exit;
+}
+
+function dump_clog($logfile, $tail) {
+ global $g, $config;
+
+ $sor = isset($config['syslog']['reverse']) ? "-r" : "";
+
+ exec("/usr/sbin/clog " . $logfile . " | tail {$sor} -n " . $tail, $logarr);
+
+ foreach ($logarr as $logent) {
+ $logent = preg_split("/\s+/", $logent, 6);
+ echo "
+
diff --git a/webgui/diag_logs_settings.php b/webgui/diag_logs_settings.php
index 51c0233..254b9a0 100644
--- a/webgui/diag_logs_settings.php
+++ b/webgui/diag_logs_settings.php
@@ -1,211 +1,214 @@
-#!/usr/local/bin/php
-.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-*/
-
-$pgtitle = array("Diagnostics", "Logs");
-require("guiconfig.inc");
-
-$pconfig['reverse'] = isset($config['syslog']['reverse']);
-$pconfig['nentries'] = $config['syslog']['nentries'];
-$pconfig['remoteserver'] = $config['syslog']['remoteserver'];
-$pconfig['filter'] = isset($config['syslog']['filter']);
-$pconfig['dhcp'] = isset($config['syslog']['dhcp']);
-$pconfig['portalauth'] = isset($config['syslog']['portalauth']);
-$pconfig['vpn'] = isset($config['syslog']['vpn']);
-$pconfig['system'] = isset($config['syslog']['system']);
-$pconfig['enable'] = isset($config['syslog']['enable']);
-$pconfig['logdefaultblock'] = !isset($config['syslog']['nologdefaultblock']);
-$pconfig['rawfilter'] = isset($config['syslog']['rawfilter']);
-$pconfig['resolve'] = isset($config['syslog']['resolve']);
-
-if (!$pconfig['nentries'])
- $pconfig['nentries'] = 50;
-
-if ($_POST) {
-
- unset($input_errors);
- $pconfig = $_POST;
-
- /* input validation */
- if ($_POST['enable'] && !is_ipaddr($_POST['remoteserver'])) {
- $input_errors[] = "A valid IP address must be specified.";
- }
- if (($_POST['nentries'] < 5) || ($_POST['nentries'] > 1000)) {
- $input_errors[] = "Number of log entries to show must be between 5 and 1000.";
- }
-
- if (!$input_errors) {
- $config['syslog']['reverse'] = $_POST['reverse'] ? true : false;
- $config['syslog']['nentries'] = (int)$_POST['nentries'];
- $config['syslog']['remoteserver'] = $_POST['remoteserver'];
- $config['syslog']['filter'] = $_POST['filter'] ? true : false;
- $config['syslog']['dhcp'] = $_POST['dhcp'] ? true : false;
- $config['syslog']['portalauth'] = $_POST['portalauth'] ? true : false;
- $config['syslog']['vpn'] = $_POST['vpn'] ? true : false;
- $config['syslog']['system'] = $_POST['system'] ? true : false;
- $config['syslog']['enable'] = $_POST['enable'] ? true : false;
- $oldnologdefaultblock = isset($config['syslog']['nologdefaultblock']);
- $config['syslog']['nologdefaultblock'] = $_POST['logdefaultblock'] ? false : true;
- $config['syslog']['rawfilter'] = $_POST['rawfilter'] ? true : false;
- $config['syslog']['resolve'] = $_POST['resolve'] ? true : false;
-
- write_config();
-
- $retval = 0;
- if (!file_exists($d_sysrebootreqd_path)) {
- config_lock();
- $retval = system_syslogd_start();
- if ($oldnologdefaultblock !== isset($config['syslog']['nologdefaultblock']))
- $retval |= filter_configure();
- config_unlock();
- }
- $savemsg = get_std_save_message($retval);
- }
-}
-
-?>
-
-
-
-
-
+#!/usr/local/bin/php
+.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array("Diagnostics", "Logs");
+require("guiconfig.inc");
+
+$pconfig['reverse'] = isset($config['syslog']['reverse']);
+$pconfig['nentries'] = $config['syslog']['nentries'];
+$pconfig['remoteserver'] = $config['syslog']['remoteserver'];
+$pconfig['filter'] = isset($config['syslog']['filter']);
+$pconfig['dhcp'] = isset($config['syslog']['dhcp']);
+$pconfig['portalauth'] = isset($config['syslog']['portalauth']);
+$pconfig['vpn'] = isset($config['syslog']['vpn']);
+$pconfig['system'] = isset($config['syslog']['system']);
+$pconfig['enable'] = isset($config['syslog']['enable']);
+$pconfig['logdefaultblock'] = !isset($config['syslog']['nologdefaultblock']);
+$pconfig['rawfilter'] = isset($config['syslog']['rawfilter']);
+$pconfig['resolve'] = isset($config['syslog']['resolve']);
+
+if (!$pconfig['nentries'])
+ $pconfig['nentries'] = 50;
+
+if ($_POST) {
+
+ unset($input_errors);
+ $pconfig = $_POST;
+
+ /* input validation */
+ if ($_POST['enable'] && !is_ipaddr($_POST['remoteserver'])) {
+ $input_errors[] = "A valid IP address must be specified.";
+ }
+ if (($_POST['nentries'] < 5) || ($_POST['nentries'] > 1000)) {
+ $input_errors[] = "Number of log entries to show must be between 5 and 1000.";
+ }
+
+ if (!$input_errors) {
+ $config['syslog']['reverse'] = $_POST['reverse'] ? true : false;
+ $config['syslog']['nentries'] = (int)$_POST['nentries'];
+ $config['syslog']['remoteserver'] = $_POST['remoteserver'];
+ $config['syslog']['filter'] = $_POST['filter'] ? true : false;
+ $config['syslog']['dhcp'] = $_POST['dhcp'] ? true : false;
+ $config['syslog']['portalauth'] = $_POST['portalauth'] ? true : false;
+ $config['syslog']['vpn'] = $_POST['vpn'] ? true : false;
+ $config['syslog']['system'] = $_POST['system'] ? true : false;
+ $config['syslog']['enable'] = $_POST['enable'] ? true : false;
+ $oldnologdefaultblock = isset($config['syslog']['nologdefaultblock']);
+ $config['syslog']['nologdefaultblock'] = $_POST['logdefaultblock'] ? false : true;
+ $config['syslog']['rawfilter'] = $_POST['rawfilter'] ? true : false;
+ $config['syslog']['resolve'] = $_POST['resolve'] ? true : false;
+
+ write_config();
+
+ $retval = 0;
+ if (!file_exists($d_sysrebootreqd_path)) {
+ config_lock();
+ $retval = system_syslogd_start();
+ if ($oldnologdefaultblock !== isset($config['syslog']['nologdefaultblock']))
+ $retval |= filter_configure();
+ config_unlock();
+ }
+ $savemsg = get_std_save_message($retval);
+ }
+}
+
+?>
+
+
+
+
+
diff --git a/webgui/diag_logs_vpn.php b/webgui/diag_logs_vpn.php
index 056430b..569efe8 100644
--- a/webgui/diag_logs_vpn.php
+++ b/webgui/diag_logs_vpn.php
@@ -1,104 +1,107 @@
-#!/usr/local/bin/php
-.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-*/
-
-$pgtitle = array("Diagnostics", "Logs");
-require("guiconfig.inc");
-
-$nentries = $config['syslog']['nentries'];
-if (!$nentries)
- $nentries = 50;
-
-if ($_POST['clear']) {
- exec("/usr/sbin/clog -i -s 65536 /var/log/vpn.log");
- /* redirect to avoid reposting form data on refresh */
- header("Location: diag_logs_vpn.php");
- exit;
-}
-
-function dump_clog($logfile, $tail) {
- global $g, $config;
-
- $sor = isset($config['syslog']['reverse']) ? "-r" : "";
-
- exec("/usr/sbin/clog " . $logfile . " | tail {$sor} -n " . $tail, $logarr);
-
- foreach ($logarr as $logent) {
- $logent = preg_split("/\s+/", $logent, 6);
- $llent = explode(",", $logent[5]);
-
- echo "
-
+#!/usr/local/bin/php
+.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array("Diagnostics", "Logs");
+require("guiconfig.inc");
+
+$nentries = $config['syslog']['nentries'];
+if (!$nentries)
+ $nentries = 50;
+
+if ($_POST['clear']) {
+ exec("/usr/sbin/clog -i -s 65536 /var/log/vpn.log");
+ /* redirect to avoid reposting form data on refresh */
+ header("Location: diag_logs_vpn.php");
+ exit;
+}
+
+function dump_clog($logfile, $tail) {
+ global $g, $config;
+
+ $sor = isset($config['syslog']['reverse']) ? "-r" : "";
+
+ exec("/usr/sbin/clog " . $logfile . " | tail {$sor} -n " . $tail, $logarr);
+
+ foreach ($logarr as $logent) {
+ $logent = preg_split("/\s+/", $logent, 6);
+ $llent = explode(",", $logent[5]);
+
+ echo "
+
diff --git a/webgui/diag_ping.php b/webgui/diag_ping.php
index 5452f5b..8729074 100644
--- a/webgui/diag_ping.php
+++ b/webgui/diag_ping.php
@@ -1,157 +1,160 @@
-#!/usr/local/bin/php
-.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-*/
-
-$pgtitle = array("Diagnostics", "Ping/Traceroute");
-require("guiconfig.inc");
-
-define('MAX_COUNT', 10);
-define('DEFAULT_COUNT', 3);
-
-if ($_POST) {
- unset($input_errors);
- unset($do_ping);
-
- /* input validation */
- $reqdfields = explode(" ", "host count");
- $reqdfieldsn = explode(",", "Host,Count");
- do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
-
- if (($_POST['count'] < 1) || ($_POST['count'] > MAX_COUNT)) {
- $input_errors[] = "Count must be between 1 and {MAX_COUNT}";
- }
-
- if (!$input_errors) {
- $do_ping = true;
- $host = $_POST['host'];
- $interface = $_POST['interface'];
- $count = $_POST['count'];
- }
-}
-if (!isset($do_ping)) {
- $do_ping = false;
- $host = '';
- $count = DEFAULT_COUNT;
-}
-
-function get_interface_addr($ifdescr) {
-
- global $config, $g;
-
- /* find out interface name */
- if ($ifdescr == "wan")
- $if = get_real_wan_interface();
- else
- $if = $config['interfaces'][$ifdescr]['if'];
-
- /* try to determine IP address and netmask with ifconfig */
- unset($ifconfiginfo);
- exec("/sbin/ifconfig " . $if, $ifconfiginfo);
-
- foreach ($ifconfiginfo as $ici) {
- if (preg_match("/inet (\S+)/", $ici, $matches)) {
- return $matches[1];
- }
- }
-
- return false;
-}
-?>
-
-
-
+#!/usr/local/bin/php
+.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array("Diagnostics", "Ping");
+require("guiconfig.inc");
+
+define('MAX_COUNT', 10);
+define('DEFAULT_COUNT', 3);
+
+if ($_POST) {
+ unset($input_errors);
+ unset($do_ping);
+
+ /* input validation */
+ $reqdfields = explode(" ", "host count");
+ $reqdfieldsn = explode(",", "Host,Count");
+ do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
+
+ if (($_POST['count'] < 1) || ($_POST['count'] > MAX_COUNT)) {
+ $input_errors[] = "Count must be between 1 and {MAX_COUNT}";
+ }
+
+ if (!$input_errors) {
+ $do_ping = true;
+ $host = $_POST['host'];
+ $interface = $_POST['interface'];
+ $count = $_POST['count'];
+ }
+}
+if (!isset($do_ping)) {
+ $do_ping = false;
+ $host = '';
+ $count = DEFAULT_COUNT;
+}
+
+function get_interface_addr($ifdescr) {
+
+ global $config, $g;
+
+ /* find out interface name */
+ if ($ifdescr == "wan")
+ $if = get_real_wan_interface();
+ else
+ $if = $config['interfaces'][$ifdescr]['if'];
+
+ /* try to determine IP address and netmask with ifconfig */
+ unset($ifconfiginfo);
+ exec("/sbin/ifconfig " . $if, $ifconfiginfo);
+
+ foreach ($ifconfiginfo as $ici) {
+ if (preg_match("/inet (\S+)/", $ici, $matches)) {
+ return $matches[1];
+ }
+ }
+
+ return false;
+}
+?>
+
+
+
diff --git a/webgui/diag_traceroute.php b/webgui/diag_traceroute.php
index ccf3823..524bdbc 100644
--- a/webgui/diag_traceroute.php
+++ b/webgui/diag_traceroute.php
@@ -1,121 +1,124 @@
-#!/usr/local/bin/php
-.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-*/
-
-$pgtitle = array("Diagnostics", "Ping/Traceroute");
-require("guiconfig.inc");
-
-
-define('MAX_TTL', 64);
-define('DEFAULT_TTL', 18);
-
-if ($_POST) {
- unset($input_errors);
- unset($do_traceroute);
-
- /* input validation */
- $reqdfields = explode(" ", "host ttl");
- $reqdfieldsn = explode(",", "Host,ttl");
- do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
-
- if (($_POST['ttl'] < 1) || ($_POST['ttl'] > MAX_TTL)) {
- $input_errors[] = "Maximum number of hops must be between 1 and {MAX_TTL}";
- }
-
- if (!$input_errors) {
- $do_traceroute = true;
- $host = $_POST['host'];
- $ttl = $_POST['ttl'];
- $resolve = $_POST['resolve'];
- }
-}
-if (!isset($do_traceroute)) {
- $do_traceroute = false;
- $host = '';
- $ttl = DEFAULT_TTL;
- $resolve = false;
-}
-?>
-
-
-
+#!/usr/local/bin/php
+.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array("Diagnostics", "Traceroute");
+require("guiconfig.inc");
+
+
+define('MAX_TTL', 64);
+define('DEFAULT_TTL', 18);
+
+if ($_POST) {
+ unset($input_errors);
+ unset($do_traceroute);
+
+ /* input validation */
+ $reqdfields = explode(" ", "host ttl");
+ $reqdfieldsn = explode(",", "Host,ttl");
+ do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
+
+ if (($_POST['ttl'] < 1) || ($_POST['ttl'] > MAX_TTL)) {
+ $input_errors[] = "Maximum number of hops must be between 1 and {MAX_TTL}";
+ }
+
+ if (!$input_errors) {
+ $do_traceroute = true;
+ $host = $_POST['host'];
+ $ttl = $_POST['ttl'];
+ $resolve = $_POST['resolve'];
+ }
+}
+if (!isset($do_traceroute)) {
+ $do_traceroute = false;
+ $host = '';
+ $ttl = DEFAULT_TTL;
+ $resolve = false;
+}
+?>
+
+
+
diff --git a/webgui/exec.php b/webgui/exec.php
index 0a76d55..6ff8e4b 100644
--- a/webgui/exec.php
+++ b/webgui/exec.php
@@ -1,290 +1,291 @@
-#!/usr/local/bin/php
-.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-*/
-
-if (($_POST['submit'] == "Download") && file_exists($_POST['dlPath'])) {
- session_cache_limiter('public');
- $fd = fopen($_POST['dlPath'], "rb");
- header("Content-Type: application/octet-stream");
- header("Content-Length: " . filesize($_POST['dlPath']));
- header("Content-Disposition: attachment; filename=\"" .
- trim(htmlentities(basename($_POST['dlPath']))) . "\"");
-
- fpassthru($fd);
- exit;
-} else if (($_POST['submit'] == "Upload") && is_uploaded_file($_FILES['ulfile']['tmp_name'])) {
- move_uploaded_file($_FILES['ulfile']['tmp_name'], "/tmp/" . $_FILES['ulfile']['name']);
- $ulmsg = "Uploaded file to /tmp/" . htmlentities($_FILES['ulfile']['name']);
- unset($_POST['txtCommand']);
-}
-?>
-
-
-
-)
-*/
-
-// Function: is Blank
-// Returns true or false depending on blankness of argument.
-
-function isBlank( $arg ) { return ereg( "^\s*$", $arg ); }
-
-
-// Function: Puts
-// Put string, Ruby-style.
-
-function puts( $arg ) { echo "$arg\n"; }
-
-
-// "Constants".
-
-$Version = '';
-$ScriptName = $HTTP_SERVER_VARS['SCRIPT_NAME'];
-$Title = 'm0n0wall: execute command';
-
-// Get year.
-
-$arrDT = localtime();
-$intYear = $arrDT[5] + 1900;
-
-?>
-
-=$Title ?>
-
-
-
-
->
-
=$Title ?>
-
-
Note: this function is unsupported. Use it
-on your own risk!
-
-" . $ulmsg . "
\n"; ?>
-");
- puts("\$ " . htmlspecialchars($_POST['txtCommand']));
- putenv("PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin");
- putenv("SCRIPT_FILENAME=" . strtok($_POST['txtCommand'], " ")); /* PHP scripts */
- $ph = popen($_POST['txtCommand'], "r" );
- while ($line = fgets($ph)) echo htmlspecialchars($line);
- pclose($ph);
- puts("");
-}
-
-?>
-
-
-
-
+#!/usr/local/bin/php
+.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+require("guiconfig.inc");
+
+if (($_POST['submit'] == "Download") && file_exists($_POST['dlPath'])) {
+ session_cache_limiter('public');
+ $fd = fopen($_POST['dlPath'], "rb");
+ header("Content-Type: application/octet-stream");
+ header("Content-Length: " . filesize($_POST['dlPath']));
+ header("Content-Disposition: attachment; filename=\"" .
+ trim(htmlentities(basename($_POST['dlPath']))) . "\"");
+
+ fpassthru($fd);
+ exit;
+} else if (($_POST['submit'] == "Upload") && is_uploaded_file($_FILES['ulfile']['tmp_name'])) {
+ move_uploaded_file($_FILES['ulfile']['tmp_name'], "/tmp/" . $_FILES['ulfile']['name']);
+ $ulmsg = "Uploaded file to /tmp/" . htmlentities($_FILES['ulfile']['name']);
+ unset($_POST['txtCommand']);
+}
+?>
+
+
+
+)
+*/
+
+// Function: is Blank
+// Returns true or false depending on blankness of argument.
+
+function isBlank( $arg ) { return ereg( "^\s*$", $arg ); }
+
+
+// Function: Puts
+// Put string, Ruby-style.
+
+function puts( $arg ) { echo "$arg\n"; }
+
+
+// "Constants".
+
+$Version = '';
+$ScriptName = $HTTP_SERVER_VARS['SCRIPT_NAME'];
+$Title = 'm0n0wall: execute command';
+
+// Get year.
+
+$arrDT = localtime();
+$intYear = $arrDT[5] + 1900;
+
+?>
+
+=$Title ?>
+
+
+
+
+>
+
=$Title ?>
+
+
Note: this function is unsupported. Use it
+on your own risk!
+
+" . $ulmsg . "\n"; ?>
+");
+ puts("\$ " . htmlspecialchars($_POST['txtCommand']));
+ putenv("PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin");
+ putenv("SCRIPT_FILENAME=" . strtok($_POST['txtCommand'], " ")); /* PHP scripts */
+ $ph = popen($_POST['txtCommand'], "r" );
+ while ($line = fgets($ph)) echo htmlspecialchars($line);
+ pclose($ph);
+ puts("");
+}
+
+?>
+
+
+
+
diff --git a/webgui/exec_raw.php b/webgui/exec_raw.php
index a51b4e9..f27ae71 100644
--- a/webgui/exec_raw.php
+++ b/webgui/exec_raw.php
@@ -1,38 +1,39 @@
-#!/usr/local/bin/php
-.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-*/
-
-header("Content-Type: text/plain");
-
-putenv("PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin");
-passthru($_GET['cmd']);
-
-exit(0);
+#!/usr/local/bin/php
+.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+require("guiconfig.inc");
+
+header("Content-Type: text/plain");
+
+putenv("PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin");
+passthru($_GET['cmd']);
+
+exit(0);
?>
\ No newline at end of file
diff --git a/webgui/fbegin.inc b/webgui/fbegin.inc
index 833fd76..cbcb73d 100644
--- a/webgui/fbegin.inc
+++ b/webgui/fbegin.inc
@@ -41,7 +41,135 @@ function genhtmltitle($title) {
global $config;
return $config['system']['hostname'] . "." . $config['system']['domain'] . " - " . gentitle($title);
}
+
+function dynamic_menu(&$menu, $menu_title) {
+ global $allowed, $config;
+
+ // Make sure the admin can see everything
+ if ($_SERVER['REMOTE_USER'] === $config['system']['username']) {
+ unset($allowed);
+ foreach ($menu as $item) {
+ $allowed[] = $item[0];
+ }
+ }
+
+ foreach ($menu as $desc => $links) {
+ if ($intersect = array_intersect($menu[$desc],$allowed)) {
+ if (!isset($header_displayed) && !($menu_title=='Diagnostics')) {
+ echo "\n ".$menu_title.' ';
+ $header_displayed = true;
+ }
+ else {
+ if (!isset($header_displayed)) {
+ if (isset($config['system']['webgui']['expanddiags']) || strstr($_SERVER['SCRIPT_FILENAME'], "diag_") || strstr($_SERVER['SCRIPT_FILENAME'], "reboot")): ?>
+ Diagnostics
+
+
+ Diagnostics
+
+
+
+ =$desc?>
+ // Only need the first one, so break out of foreach
+ break;
+ }
+ }
+ }
+}
+
+// Check for issues when changing the web admin username
+// $allowed is set in auth.inc *IF* the user is not the webGUI admin
+// so, if it's not set here, they were the admin user when they submited the admin username change.
+if ((!is_array($allowed)) and
+ ($_SERVER['PHP_SELF'] == '/system.php') and
+ ($_SERVER['REMOTE_USER'] != $config['system']['username'])) {
+ // webGUI username was just changed, let us change what PHP sees the remote user as so
+ // the menu will build properly. When user hits next link, they will be prompted to reauthenticate.
+ $_SERVER['REMOTE_USER'] = $config['system']['username'];
+}
+
+$menu['System']['General setup'] = array('system.php');
+$menu['System']['Static routes'] = array('system_routes.php');
+$menu['System']['Firmware'] = array('system_firmware.php');
+$menu['System']['Advanced'] = array('system_advanced.php');
+if ($_SERVER['REMOTE_USER'] === $config['system']['username']) {
+ $menu['System']['User manager'] = array('system_usermanager.php');
+}
+else {
+ $menu['System']['User password'] = array('system_usermanager.php');
+}
+
+$menu['Firewall']['Rules'] = array('firewall_rules.php');
+$menu['Firewall']['NAT'] = array('firewall_nat.php',
+ 'firewall_nat_server.php',
+ 'firewall_nat_1to1.php',
+ 'firewall_nat_out.php');
+$menu['Firewall']['Traffic shaper'] = array('firewall_shaper.php',
+ 'firewall_shaper_pipes.php',
+ 'firewall_shaper_queues.php',
+ 'firewall_shaper_magic.php');
+$menu['Firewall']['Aliases'] = array('firewall_aliases.php');
+
+$menu['Services']['DNS forwarder'] = array('services_dnsmasq.php');
+$menu['Services']['Dynamic DNS'] = array('services_dyndns.php');
+$menu['Services']['DHCP server'] = array('services_dhcp.php');
+$menu['Services']['DHCP relay'] = array('services_dhcp_relay.php');
+$menu['Services']['SNMP'] = array('services_snmp.php');
+$menu['Services']['Proxy ARP'] = array('services_proxyarp.php');
+$menu['Services']['Captive portal'] = array('services_captiveportal.php',
+ 'services_captiveportal_mac.php',
+ 'services_captiveportal_ip.php',
+ 'services_captiveportal_users.php',
+ 'services_captiveportal_elementmanager.php');
+$menu['Services']['Wake on LAN'] = array('services_wol.php');
+
+$menu['VPN']['IPsec'] = array('vpn_ipsec.php',
+ 'vpn_ipsec_mobile.php',
+ 'vpn_ipsec_keys.php',
+ 'vpn_ipsec_ca.php');
+$menu['VPN']['PPTP'] = array('vpn_pptp.php',
+ 'vpn_pptp_users.php');
+
+$menu['Status']['System'] = array('index.php');
+$menu['Status']['Interfaces'] = array('status_interfaces.php');
+
+$menu['Status']['Traffic graph'] = array('status_graph.php');
+$menu['Status']['Wireless'] = array('status_wireless.php');
+if (isset($config['captiveportal']['enable'])) {
+ $menu['Status']['Captive portal'] = array('status_captiveportal.php');
+}
+
+$menu['Diagnostics']['Logs'] = array('diag_logs.php',
+ 'diag_logs_filter.php',
+ 'diag_logs_dhcp.php',
+ 'diag_logs_portal.php',
+ 'diag_logs_vpn.php',
+ 'diag_logs_settings.php');
+$menu['Diagnostics']['DHCP Leases'] = array('diag_dhcp_leases.php');
+$menu['Diagnostics']['IPsec'] = array('diag_ipsec_sad.php',
+ 'diag_ipsec_spd.php');
+$menu['Diagnostics']['Ping/Traceroute'] = array('diag_ping.php',
+ 'diag_traceroute.php');
+$menu['Diagnostics']['ARP Table'] = array('diag_arp.php');
+$menu['Diagnostics']['NS Lookup'] = array('diag_nslookup.php');
+$menu['Diagnostics']['Whois'] = array('diag_whois.php');
+$menu['Diagnostics']['Firewall states'] = array('diag_ipfstat.php');
+$menu['Diagnostics']['Reset state'] = array('diag_resetstate.php');
+$menu['Diagnostics']['Backup/Restore'] = array('diag_backup.php');
+$menu['Diagnostics']['Factory Defaults']= array('diag_defaults.php');
+$menu['Diagnostics']['Reboot system'] = array('reboot.php');
+
?>
+
@@ -96,51 +224,47 @@ function showhide(tspan, tri) {
diff --git a/webgui/firewall_nat.php b/webgui/firewall_nat.php
index 0518810..2dd94e9 100644
--- a/webgui/firewall_nat.php
+++ b/webgui/firewall_nat.php
@@ -1,160 +1,163 @@
-#!/usr/local/bin/php
-.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-*/
-
-$pgtitle = array("Firewall", "NAT");
-require("guiconfig.inc");
-
-if (!is_array($config['nat']['rule'])) {
- $config['nat']['rule'] = array();
-}
-nat_rules_sort();
-$a_nat = &$config['nat']['rule'];
-
-if ($_POST) {
-
- $pconfig = $_POST;
-
- if ($_POST['apply']) {
- $retval = 0;
- if (!file_exists($d_sysrebootreqd_path)) {
- config_lock();
- $retval |= filter_configure();
- config_unlock();
- }
- $savemsg = get_std_save_message($retval);
-
- if ($retval == 0) {
- if (file_exists($d_natconfdirty_path))
- unlink($d_natconfdirty_path);
- if (file_exists($d_filterconfdirty_path))
- unlink($d_filterconfdirty_path);
- }
- }
-}
-
-if ($_GET['act'] == "del") {
- if ($a_nat[$_GET['id']]) {
- unset($a_nat[$_GET['id']]);
- write_config();
- touch($d_natconfdirty_path);
- header("Location: firewall_nat.php");
- exit;
- }
-}
-?>
-
-
-
+#!/usr/local/bin/php
+.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array("Firewall", "NAT", "Inbound");
+require("guiconfig.inc");
+
+if (!is_array($config['nat']['rule'])) {
+ $config['nat']['rule'] = array();
+}
+nat_rules_sort();
+$a_nat = &$config['nat']['rule'];
+
+if ($_POST) {
+
+ $pconfig = $_POST;
+
+ if ($_POST['apply']) {
+ $retval = 0;
+ if (!file_exists($d_sysrebootreqd_path)) {
+ config_lock();
+ $retval |= filter_configure();
+ config_unlock();
+ }
+ $savemsg = get_std_save_message($retval);
+
+ if ($retval == 0) {
+ if (file_exists($d_natconfdirty_path))
+ unlink($d_natconfdirty_path);
+ if (file_exists($d_filterconfdirty_path))
+ unlink($d_filterconfdirty_path);
+ }
+ }
+}
+
+if ($_GET['act'] == "del") {
+ if ($a_nat[$_GET['id']]) {
+ unset($a_nat[$_GET['id']]);
+ write_config();
+ touch($d_natconfdirty_path);
+ header("Location: firewall_nat.php");
+ exit;
+ }
+}
+?>
+
+
+
diff --git a/webgui/firewall_nat_1to1.php b/webgui/firewall_nat_1to1.php
index 41f3594..b148684 100644
--- a/webgui/firewall_nat_1to1.php
+++ b/webgui/firewall_nat_1to1.php
@@ -1,138 +1,141 @@
-#!/usr/local/bin/php
-.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-*/
-
-$pgtitle = array("Firewall", "NAT");
-require("guiconfig.inc");
-
-if (!is_array($config['nat']['onetoone'])) {
- $config['nat']['onetoone'] = array();
-}
-$a_1to1 = &$config['nat']['onetoone'];
-nat_1to1_rules_sort();
-
-if ($_POST) {
-
- $pconfig = $_POST;
-
- if ($_POST['apply']) {
- $retval = 0;
- if (!file_exists($d_sysrebootreqd_path)) {
- config_lock();
- $retval |= filter_configure();
- $retval |= services_proxyarp_configure();
- config_unlock();
- }
- $savemsg = get_std_save_message($retval);
-
- if ($retval == 0) {
- if (file_exists($d_natconfdirty_path))
- unlink($d_natconfdirty_path);
- if (file_exists($d_filterconfdirty_path))
- unlink($d_filterconfdirty_path);
- if (file_exists($d_proxyarpdirty_path))
- unlink($d_proxyarpdirty_path);
- }
- }
-}
-
-if ($_GET['act'] == "del") {
- if ($a_1to1[$_GET['id']]) {
- unset($a_1to1[$_GET['id']]);
- write_config();
- touch($d_natconfdirty_path);
- header("Location: firewall_nat_1to1.php");
- exit;
- }
-}
-?>
-
-
-
+#!/usr/local/bin/php
+.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array("Firewall", "NAT", "1:1");
+require("guiconfig.inc");
+
+if (!is_array($config['nat']['onetoone'])) {
+ $config['nat']['onetoone'] = array();
+}
+$a_1to1 = &$config['nat']['onetoone'];
+nat_1to1_rules_sort();
+
+if ($_POST) {
+
+ $pconfig = $_POST;
+
+ if ($_POST['apply']) {
+ $retval = 0;
+ if (!file_exists($d_sysrebootreqd_path)) {
+ config_lock();
+ $retval |= filter_configure();
+ $retval |= services_proxyarp_configure();
+ config_unlock();
+ }
+ $savemsg = get_std_save_message($retval);
+
+ if ($retval == 0) {
+ if (file_exists($d_natconfdirty_path))
+ unlink($d_natconfdirty_path);
+ if (file_exists($d_filterconfdirty_path))
+ unlink($d_filterconfdirty_path);
+ if (file_exists($d_proxyarpdirty_path))
+ unlink($d_proxyarpdirty_path);
+ }
+ }
+}
+
+if ($_GET['act'] == "del") {
+ if ($a_1to1[$_GET['id']]) {
+ unset($a_1to1[$_GET['id']]);
+ write_config();
+ touch($d_natconfdirty_path);
+ header("Location: firewall_nat_1to1.php");
+ exit;
+ }
+}
+?>
+
+
+
diff --git a/webgui/firewall_nat_out.php b/webgui/firewall_nat_out.php
index c0a79c4..4b2610c 100644
--- a/webgui/firewall_nat_out.php
+++ b/webgui/firewall_nat_out.php
@@ -1,175 +1,178 @@
-#!/usr/local/bin/php
-.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-*/
-
-$pgtitle = array("Firewall", "NAT");
-require("guiconfig.inc");
-
-if (!is_array($config['nat']['advancedoutbound']['rule']))
- $config['nat']['advancedoutbound']['rule'] = array();
-
-$a_out = &$config['nat']['advancedoutbound']['rule'];
-nat_out_rules_sort();
-
-if ($_POST) {
-
- $pconfig = $_POST;
-
- $config['nat']['advancedoutbound']['enable'] = ($_POST['enable']) ? true : false;
- write_config();
-
- $retval = 0;
-
- if (!file_exists($d_sysrebootreqd_path)) {
- config_lock();
- $retval |= filter_configure();
- config_unlock();
- }
- $savemsg = get_std_save_message($retval);
-
- if ($retval == 0) {
- if (file_exists($d_natconfdirty_path))
- unlink($d_natconfdirty_path);
- if (file_exists($d_filterconfdirty_path))
- unlink($d_filterconfdirty_path);
- }
-}
-
-if ($_GET['act'] == "del") {
- if ($a_out[$_GET['id']]) {
- unset($a_out[$_GET['id']]);
- write_config();
- touch($d_natconfdirty_path);
- header("Location: firewall_nat_out.php");
- exit;
- }
-}
-?>
-
-
-
+#!/usr/local/bin/php
+.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array("Firewall", "NAT", "Outbound");
+require("guiconfig.inc");
+
+if (!is_array($config['nat']['advancedoutbound']['rule']))
+ $config['nat']['advancedoutbound']['rule'] = array();
+
+$a_out = &$config['nat']['advancedoutbound']['rule'];
+nat_out_rules_sort();
+
+if ($_POST) {
+
+ $pconfig = $_POST;
+
+ $config['nat']['advancedoutbound']['enable'] = ($_POST['enable']) ? true : false;
+ write_config();
+
+ $retval = 0;
+
+ if (!file_exists($d_sysrebootreqd_path)) {
+ config_lock();
+ $retval |= filter_configure();
+ config_unlock();
+ }
+ $savemsg = get_std_save_message($retval);
+
+ if ($retval == 0) {
+ if (file_exists($d_natconfdirty_path))
+ unlink($d_natconfdirty_path);
+ if (file_exists($d_filterconfdirty_path))
+ unlink($d_filterconfdirty_path);
+ }
+}
+
+if ($_GET['act'] == "del") {
+ if ($a_out[$_GET['id']]) {
+ unset($a_out[$_GET['id']]);
+ write_config();
+ touch($d_natconfdirty_path);
+ header("Location: firewall_nat_out.php");
+ exit;
+ }
+}
+?>
+
+
+
diff --git a/webgui/firewall_nat_server.php b/webgui/firewall_nat_server.php
index 0740ed1..da3dbfd 100644
--- a/webgui/firewall_nat_server.php
+++ b/webgui/firewall_nat_server.php
@@ -1,133 +1,136 @@
-#!/usr/local/bin/php
-.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-*/
-
-$pgtitle = array("Firewall", "NAT");
-require("guiconfig.inc");
-
-if (!is_array($config['nat']['servernat'])) {
- $config['nat']['servernat'] = array();
-}
-$a_snat = &$config['nat']['servernat'];
-nat_server_rules_sort();
-
-if ($_POST) {
-
- $pconfig = $_POST;
-
- if ($_POST['apply']) {
- $retval = 0;
- if (!file_exists($d_sysrebootreqd_path)) {
- config_lock();
- $retval |= filter_configure();
- config_unlock();
- }
- $savemsg = get_std_save_message($retval);
-
- if ($retval == 0) {
- if (file_exists($d_natconfdirty_path))
- unlink($d_natconfdirty_path);
- if (file_exists($d_filterconfdirty_path))
- unlink($d_filterconfdirty_path);
- }
- }
-}
-
-if ($_GET['act'] == "del") {
- if ($a_snat[$_GET['id']]) {
- /* make sure no inbound NAT mappings reference this entry */
- if (is_array($config['nat']['rule'])) {
- foreach ($config['nat']['rule'] as $rule) {
- if ($rule['external-address'] == $a_snat[$_GET['id']]['ipaddr']) {
- $input_errors[] = "This entry cannot be deleted because it is still referenced by at least one inbound NAT mapping.";
- break;
- }
- }
- }
-
- if (!$input_errors) {
- unset($a_snat[$_GET['id']]);
- write_config();
- touch($d_natconfdirty_path);
- header("Location: firewall_nat_server.php");
- exit;
- }
- }
-}
-?>
-
-
-
+#!/usr/local/bin/php
+.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array("Firewall", "NAT", "Server NAT");
+require("guiconfig.inc");
+
+if (!is_array($config['nat']['servernat'])) {
+ $config['nat']['servernat'] = array();
+}
+$a_snat = &$config['nat']['servernat'];
+nat_server_rules_sort();
+
+if ($_POST) {
+
+ $pconfig = $_POST;
+
+ if ($_POST['apply']) {
+ $retval = 0;
+ if (!file_exists($d_sysrebootreqd_path)) {
+ config_lock();
+ $retval |= filter_configure();
+ config_unlock();
+ }
+ $savemsg = get_std_save_message($retval);
+
+ if ($retval == 0) {
+ if (file_exists($d_natconfdirty_path))
+ unlink($d_natconfdirty_path);
+ if (file_exists($d_filterconfdirty_path))
+ unlink($d_filterconfdirty_path);
+ }
+ }
+}
+
+if ($_GET['act'] == "del") {
+ if ($a_snat[$_GET['id']]) {
+ /* make sure no inbound NAT mappings reference this entry */
+ if (is_array($config['nat']['rule'])) {
+ foreach ($config['nat']['rule'] as $rule) {
+ if ($rule['external-address'] == $a_snat[$_GET['id']]['ipaddr']) {
+ $input_errors[] = "This entry cannot be deleted because it is still referenced by at least one inbound NAT mapping.";
+ break;
+ }
+ }
+ }
+
+ if (!$input_errors) {
+ unset($a_snat[$_GET['id']]);
+ write_config();
+ touch($d_natconfdirty_path);
+ header("Location: firewall_nat_server.php");
+ exit;
+ }
+ }
+}
+?>
+
+
+
diff --git a/webgui/firewall_shaper.php b/webgui/firewall_shaper.php
index bddfadc..459b576 100644
--- a/webgui/firewall_shaper.php
+++ b/webgui/firewall_shaper.php
@@ -1,257 +1,260 @@
-#!/usr/local/bin/php
-.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-*/
-
-$pgtitle = array("Firewall", "Traffic shaper");
-require("guiconfig.inc");
-
-if (!is_array($config['shaper']['rule'])) {
- $config['shaper']['rule'] = array();
-}
-if (!is_array($config['shaper']['pipe'])) {
- $config['shaper']['pipe'] = array();
-}
-if (!is_array($config['shaper']['queue'])) {
- $config['shaper']['queue'] = array();
-}
-$a_shaper = &$config['shaper']['rule'];
-$a_pipe = &$config['shaper']['pipe'];
-$a_queue = &$config['shaper']['queue'];
-
-$pconfig['enable'] = isset($config['shaper']['enable']);
-
-if ($_POST) {
-
- if ($_POST['submit']) {
- $pconfig = $_POST;
- $config['shaper']['enable'] = $_POST['enable'] ? true : false;
- write_config();
- }
-
- if ($_POST['apply'] || $_POST['submit']) {
- $retval = 0;
- if (!file_exists($d_sysrebootreqd_path)) {
- config_lock();
- $retval = shaper_configure();
- config_unlock();
- }
- $savemsg = get_std_save_message($retval);
- if ($retval == 0) {
- if (file_exists($d_shaperconfdirty_path))
- unlink($d_shaperconfdirty_path);
- }
- }
-}
-
-if ($_GET['act'] == "del") {
- if ($a_shaper[$_GET['id']]) {
- unset($a_shaper[$_GET['id']]);
- write_config();
- touch($d_shaperconfdirty_path);
- header("Location: firewall_shaper.php");
- exit;
- }
-} else if ($_GET['act'] == "down") {
- if ($a_shaper[$_GET['id']] && $a_shaper[$_GET['id']+1]) {
- $tmp = $a_shaper[$_GET['id']+1];
- $a_shaper[$_GET['id']+1] = $a_shaper[$_GET['id']];
- $a_shaper[$_GET['id']] = $tmp;
- write_config();
- touch($d_shaperconfdirty_path);
- header("Location: firewall_shaper.php");
- exit;
- }
-} else if ($_GET['act'] == "up") {
- if (($_GET['id'] > 0) && $a_shaper[$_GET['id']]) {
- $tmp = $a_shaper[$_GET['id']-1];
- $a_shaper[$_GET['id']-1] = $a_shaper[$_GET['id']];
- $a_shaper[$_GET['id']] = $tmp;
- write_config();
- touch($d_shaperconfdirty_path);
- header("Location: firewall_shaper.php");
- exit;
- }
-} else if ($_GET['act'] == "toggle") {
- if ($a_shaper[$_GET['id']]) {
- $a_shaper[$_GET['id']]['disabled'] = !isset($a_shaper[$_GET['id']]['disabled']);
- write_config();
- touch($d_shaperconfdirty_path);
- header("Location: firewall_shaper.php");
- exit;
- }
-}
-?>
-
-
-
+#!/usr/local/bin/php
+.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array("Firewall", "Traffic shaper", "Rules");
+require("guiconfig.inc");
+
+if (!is_array($config['shaper']['rule'])) {
+ $config['shaper']['rule'] = array();
+}
+if (!is_array($config['shaper']['pipe'])) {
+ $config['shaper']['pipe'] = array();
+}
+if (!is_array($config['shaper']['queue'])) {
+ $config['shaper']['queue'] = array();
+}
+$a_shaper = &$config['shaper']['rule'];
+$a_pipe = &$config['shaper']['pipe'];
+$a_queue = &$config['shaper']['queue'];
+
+$pconfig['enable'] = isset($config['shaper']['enable']);
+
+if ($_POST) {
+
+ if ($_POST['submit']) {
+ $pconfig = $_POST;
+ $config['shaper']['enable'] = $_POST['enable'] ? true : false;
+ write_config();
+ }
+
+ if ($_POST['apply'] || $_POST['submit']) {
+ $retval = 0;
+ if (!file_exists($d_sysrebootreqd_path)) {
+ config_lock();
+ $retval = shaper_configure();
+ config_unlock();
+ }
+ $savemsg = get_std_save_message($retval);
+ if ($retval == 0) {
+ if (file_exists($d_shaperconfdirty_path))
+ unlink($d_shaperconfdirty_path);
+ }
+ }
+}
+
+if ($_GET['act'] == "del") {
+ if ($a_shaper[$_GET['id']]) {
+ unset($a_shaper[$_GET['id']]);
+ write_config();
+ touch($d_shaperconfdirty_path);
+ header("Location: firewall_shaper.php");
+ exit;
+ }
+} else if ($_GET['act'] == "down") {
+ if ($a_shaper[$_GET['id']] && $a_shaper[$_GET['id']+1]) {
+ $tmp = $a_shaper[$_GET['id']+1];
+ $a_shaper[$_GET['id']+1] = $a_shaper[$_GET['id']];
+ $a_shaper[$_GET['id']] = $tmp;
+ write_config();
+ touch($d_shaperconfdirty_path);
+ header("Location: firewall_shaper.php");
+ exit;
+ }
+} else if ($_GET['act'] == "up") {
+ if (($_GET['id'] > 0) && $a_shaper[$_GET['id']]) {
+ $tmp = $a_shaper[$_GET['id']-1];
+ $a_shaper[$_GET['id']-1] = $a_shaper[$_GET['id']];
+ $a_shaper[$_GET['id']] = $tmp;
+ write_config();
+ touch($d_shaperconfdirty_path);
+ header("Location: firewall_shaper.php");
+ exit;
+ }
+} else if ($_GET['act'] == "toggle") {
+ if ($a_shaper[$_GET['id']]) {
+ $a_shaper[$_GET['id']]['disabled'] = !isset($a_shaper[$_GET['id']]['disabled']);
+ write_config();
+ touch($d_shaperconfdirty_path);
+ header("Location: firewall_shaper.php");
+ exit;
+ }
+}
+?>
+
+
+
diff --git a/webgui/firewall_shaper_magic.php b/webgui/firewall_shaper_magic.php
index a25b3da..930d169 100644
--- a/webgui/firewall_shaper_magic.php
+++ b/webgui/firewall_shaper_magic.php
@@ -1,410 +1,413 @@
-#!/usr/local/bin/php
-
- Copyright (C) 2004 Dinesh Nair
-
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-*/
-
-$pgtitle = array("Firewall", "Traffic shaper");
-require("guiconfig.inc");
-
-function wipe_magic () {
- global $config;
-
- /* wipe previous */
- $types=array("pipe","queue","rule");
- foreach ($types as $type) {
- foreach (array_keys($config['shaper'][$type]) as $num) {
- if (substr($config['shaper'][$type][$num]['descr'],0,2) == "m_") {
- unset($config['shaper'][$type][$num]);
- }
- }
- }
- /* Although we don't delete user-defined rules, it's probably best to
- disable the shaper to prevent bad things from happening */
- $config['shaper']['enable'] = FALSE;
-}
-
-function populate_p2p(&$rulei) {
- global $config;
-
- /* To add p2p clients, push Descr,Protocol,Start,End,src/dest/both onto p2plist */
- $p2plist[] = array('BitTorrent','tcp','6881','6999','both');
- $p2plist[] = array('DirectConnect','','412','412','both');
- $p2plist[] = array('DirectFileExpress','','1044','1045','both');
- $p2plist[] = array('FastTrack','','1214','1214','both');
- $p2plist[] = array('CuteMX','','2340','2340','both');
- $p2plist[] = array('iMest','','4329','4329','both');
- $p2plist[] = array('EDonkey2000','','4661','4665','both');
- $p2plist[] = array('SongSpy','','5190','5190','both');
- $p2plist[] = array('HotlineConnect','','5500','5503','both');
- $p2plist[] = array('Gnutella','','6346','6346','both');
- $p2plist[] = array('dcc','','6666','6668','both');
- $p2plist[] = array('Napster','','6699','6701','both');
- $p2plist[] = array('Aimster','','7668','7668','both');
- $p2plist[] = array('BuddyShare','','7788','7788','both');
- $p2plist[] = array('Scour','','8311','8311','both');
- $p2plist[] = array('OpenNap','','8888','8889','both');
- $p2plist[] = array('hotComm','','28864','28865','both');
-
- /* Set up/down p2p as lowest weight */
- $direction = array("in","out");
- foreach ($p2plist as $p2pclient) {
- foreach ($direction as $dir) {
- foreach (array('source','destination') as $srcdest) {
- if (($p2pclient[4] == $srcdest) || ($p2pclient[4] == 'both')) {
- $config['shaper']['rule'][$rulei]['descr'] = "m_P2P $p2pclient[0]";
- $config['shaper']['rule'][$rulei]['interface'] = "wan";
- $config['shaper']['rule'][$rulei]['direction'] = "$dir";
- $config['shaper']['rule'][$rulei]['source']['any'] = 1;
- $config['shaper']['rule'][$rulei]['destination']['any'] = 1;
- $config['shaper']['rule'][$rulei][$srcdest]['port'] = $p2pclient[2]."-".$p2pclient[3];
- if($p2pclient[1] != '')
- $config['shaper']['rule'][$rulei]['protocol'] = $p2pclient[1];
- if ($dir == "out") {
- $config['shaper']['rule'][$rulei]['targetqueue'] = 4;
- } else {
- $config['shaper']['rule'][$rulei]['targetqueue'] = 6;
- }
- $rulei++;
- }
- }
- }
- }
-}
-
-function create_magic ($maxup, $maxdown, $p2plow,$maskq) {
- global $config;
-
- $config['shaper']['enable'] = TRUE;
- $pipei = 0;
- $queuei = 0;
- $rulei = 0;
-
- /* Create new pipes */
- $config['shaper']['pipe'][$pipei]['descr'] = "m_Total Upload";
- $config['shaper']['pipe'][$pipei]['bandwidth'] = round($maxup * .90);
- $pipei++;
- $config['shaper']['pipe'][$pipei]['descr'] = "m_Total Download";
- $config['shaper']['pipe'][$pipei]['bandwidth'] = round($maxdown * .95);
- $pipei++;
-
- /* Create new queues */
- $config['shaper']['queue'][$queuei]['descr'] = "m_High Priority #1 Upload";
- $config['shaper']['queue'][$queuei]['targetpipe'] = 0;
- $config['shaper']['queue'][$queuei]['weight'] = 50;
- $queuei++;
- $config['shaper']['queue'][$queuei]['descr'] = "m_High Priority #2 Upload";
- $config['shaper']['queue'][$queuei]['targetpipe'] = 0;
- $config['shaper']['queue'][$queuei]['weight'] = 30;
- $queuei++;
- $config['shaper']['queue'][$queuei]['descr'] = "m_High Priority #3 Upload";
- $config['shaper']['queue'][$queuei]['targetpipe'] = 0;
- $config['shaper']['queue'][$queuei]['weight'] = 15;
- $queuei++;
- $config['shaper']['queue'][$queuei]['descr'] = "m_Bulk Upload";
- $config['shaper']['queue'][$queuei]['targetpipe'] = 0;
- $config['shaper']['queue'][$queuei]['weight'] = 4;
- $queuei++;
- $config['shaper']['queue'][$queuei]['descr'] = "m_Hated Upload";
- $config['shaper']['queue'][$queuei]['targetpipe'] = 0;
- $config['shaper']['queue'][$queuei]['weight'] = 1;
- $queuei++;
- $config['shaper']['queue'][$queuei]['descr'] = "m_Bulk Download";
- $config['shaper']['queue'][$queuei]['targetpipe'] = 1;
- $config['shaper']['queue'][$queuei]['weight'] = 30;
- $queuei++;
- $config['shaper']['queue'][$queuei]['descr'] = "m_Hated Download";
- $config['shaper']['queue'][$queuei]['targetpipe'] = 1;
- $config['shaper']['queue'][$queuei]['weight'] = 10;
- $queuei++;
- $config['shaper']['queue'][$queuei]['descr'] = "m_High Priority Download";
- $config['shaper']['queue'][$queuei]['targetpipe'] = 1;
- $config['shaper']['queue'][$queuei]['weight'] = 60;
- $queuei++;
- if ($maskq) {
- for ($i = 0; $i < $queuei; $i++) {
- if (stristr($config['shaper']['queue'][$i]['descr'],"upload")) {
- $config['shaper']['queue'][$i]['mask'] = 'source';
- } else if (stristr($config['shaper']['queue'][$i]['descr'],"download")) {
- $config['shaper']['queue'][$i]['mask'] = 'destination';
- }
- }
- }
-
- /* Create new rules */
- if ($p2plow)
- populate_p2p($rulei);
-
- $config['shaper']['rule'][$rulei]['descr'] = "m_TCP ACK Upload";
- $config['shaper']['rule'][$rulei]['targetqueue'] = 2;
- $config['shaper']['rule'][$rulei]['interface'] = "wan";
- $config['shaper']['rule'][$rulei]['direction'] = "out";
- $config['shaper']['rule'][$rulei]['source']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['destination']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['iplen'] = "0-80";
- $config['shaper']['rule'][$rulei]['protocol'] = "tcp";
- $config['shaper']['rule'][$rulei]['tcpflags'] = "ack";
- $rulei++;
- $config['shaper']['rule'][$rulei]['descr'] = "m_Small Pkt Upload";
- $config['shaper']['rule'][$rulei]['targetqueue'] = 0;
- $config['shaper']['rule'][$rulei]['interface'] = "wan";
- $config['shaper']['rule'][$rulei]['direction'] = "out";
- $config['shaper']['rule'][$rulei]['source']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['destination']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['iplen'] = "0-100";
- $rulei++;
- $config['shaper']['rule'][$rulei]['descr'] = "m_Outbound DNS Query";
- $config['shaper']['rule'][$rulei]['targetqueue'] = 0;
- $config['shaper']['rule'][$rulei]['interface'] = "wan";
- $config['shaper']['rule'][$rulei]['direction'] = "out";
- $config['shaper']['rule'][$rulei]['source']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['destination']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['destination']['port'] = 53;
- $config['shaper']['rule'][$rulei]['protocol'] = "udp";
- $rulei++;
- $config['shaper']['rule'][$rulei]['descr'] = "m_AH Upload";
- $config['shaper']['rule'][$rulei]['targetqueue'] = 0;
- $config['shaper']['rule'][$rulei]['interface'] = "wan";
- $config['shaper']['rule'][$rulei]['direction'] = "out";
- $config['shaper']['rule'][$rulei]['source']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['destination']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['protocol'] = "ah";
- $rulei++;
- $config['shaper']['rule'][$rulei]['descr'] = "m_ESP Upload";
- $config['shaper']['rule'][$rulei]['targetqueue'] = 0;
- $config['shaper']['rule'][$rulei]['interface'] = "wan";
- $config['shaper']['rule'][$rulei]['direction'] = "out";
- $config['shaper']['rule'][$rulei]['source']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['destination']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['protocol'] = "esp";
- $rulei++;
- $config['shaper']['rule'][$rulei]['descr'] = "m_GRE Upload";
- $config['shaper']['rule'][$rulei]['targetqueue'] = 0;
- $config['shaper']['rule'][$rulei]['interface'] = "wan";
- $config['shaper']['rule'][$rulei]['direction'] = "out";
- $config['shaper']['rule'][$rulei]['source']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['destination']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['protocol'] = "gre";
- $rulei++;
- $config['shaper']['rule'][$rulei]['descr'] = "m_ICMP Upload";
- $config['shaper']['rule'][$rulei]['targetqueue'] = 1;
- $config['shaper']['rule'][$rulei]['interface'] = "wan";
- $config['shaper']['rule'][$rulei]['direction'] = "out";
- $config['shaper']['rule'][$rulei]['source']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['destination']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['protocol'] = "icmp";
- $rulei++;
- $config['shaper']['rule'][$rulei]['descr'] = "m_Catch-All Upload";
- $config['shaper']['rule'][$rulei]['targetqueue'] = 3;
- $config['shaper']['rule'][$rulei]['interface'] = "wan";
- $config['shaper']['rule'][$rulei]['direction'] = "out";
- $config['shaper']['rule'][$rulei]['source']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['destination']['any'] = TRUE;
- $rulei++;
- $config['shaper']['rule'][$rulei]['descr'] = "m_ICMP Download";
- $config['shaper']['rule'][$rulei]['targetqueue'] = 7;
- $config['shaper']['rule'][$rulei]['interface'] = "wan";
- $config['shaper']['rule'][$rulei]['direction'] = "in";
- $config['shaper']['rule'][$rulei]['source']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['destination']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['protocol'] = "icmp";
- $rulei++;
- $config['shaper']['rule'][$rulei]['descr'] = "m_Small Pkt Download";
- $config['shaper']['rule'][$rulei]['targetqueue'] = 7;
- $config['shaper']['rule'][$rulei]['interface'] = "wan";
- $config['shaper']['rule'][$rulei]['direction'] = "in";
- $config['shaper']['rule'][$rulei]['source']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['destination']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['iplen'] = "0-100";
- $rulei++;
- $config['shaper']['rule'][$rulei]['descr'] = "m_AH Download";
- $config['shaper']['rule'][$rulei]['targetqueue'] = 7;
- $config['shaper']['rule'][$rulei]['interface'] = "wan";
- $config['shaper']['rule'][$rulei]['direction'] = "in";
- $config['shaper']['rule'][$rulei]['source']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['destination']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['protocol'] = "ah";
- $rulei++;
- $config['shaper']['rule'][$rulei]['descr'] = "m_ESP Download";
- $config['shaper']['rule'][$rulei]['targetqueue'] = 7;
- $config['shaper']['rule'][$rulei]['interface'] = "wan";
- $config['shaper']['rule'][$rulei]['direction'] = "in";
- $config['shaper']['rule'][$rulei]['source']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['destination']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['protocol'] = "esp";
- $rulei++;
- $config['shaper']['rule'][$rulei]['descr'] = "m_GRE Download";
- $config['shaper']['rule'][$rulei]['targetqueue'] = 7;
- $config['shaper']['rule'][$rulei]['interface'] = "wan";
- $config['shaper']['rule'][$rulei]['direction'] = "in";
- $config['shaper']['rule'][$rulei]['source']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['destination']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['protocol'] = "gre";
- $rulei++;
- $config['shaper']['rule'][$rulei]['descr'] = "m_Catch-All Download";
- $config['shaper']['rule'][$rulei]['targetqueue'] = 5;
- $config['shaper']['rule'][$rulei]['interface'] = "wan";
- $config['shaper']['rule'][$rulei]['direction'] = "in";
- $config['shaper']['rule'][$rulei]['source']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['destination']['any'] = TRUE;
- $rulei++;
-}
-
-if (!is_array($config['shaper']['rule'])) {
- $config['shaper']['rule'] = array();
-}
-if (!is_array($config['shaper']['pipe'])) {
- $config['shaper']['pipe'] = array();
-}
-if (!is_array($config['shaper']['queue'])) {
- $config['shaper']['queue'] = array();
-}
-
-$a_shaper = &$config['shaper']['rule'];
-$a_queues = &$config['shaper']['queue'];
-$a_pipes = &$config['shaper']['pipe'];
-
-$pconfig['p2plow'] = isset($config['shaper']['magic']['p2plow']);
-$pconfig['maskq'] = isset($config['shaper']['magic']['maskq']);
-$pconfig['maxup'] = $config['shaper']['magic']['maxup'];
-$pconfig['maxdown'] = $config['shaper']['magic']['maxdown'];
-
-if ($_POST) {
-
- if ($_POST['install']) {
- unset($input_errors);
- $pconfig = $_POST;
- $reqdfields = explode(" ", "maxup maxdown");
- $reqdfieldsn = explode(",", "Max. Upload,Max.Download");
- do_input_validation($_POST,$reqdfields, $reqdfieldsn, &$input_errors);
- if (($_POST['maxup'] && !is_numericint($_POST['maxup']))) {
- $input_errors[] = "The max upload bandwidth must be an integer.";
- }
- if (($_POST['maxdown'] && !is_numericint($_POST['maxdown']))) {
- $input_errors[] = "The max download bandwidth must be an integer.";
- }
- if (!$input_errors) {
- if ($_POST['install']) {
- unset ($config['shaper']);
- create_magic($_POST['maxup'],$_POST['maxdown'],$_POST['p2plow']?TRUE:FALSE,$_POST['maskq']?TRUE:FALSE);
- touch($d_shaperconfdirty_path);
- }
- $config['shaper']['magic']['p2plow'] = $_POST['p2plow'] ? TRUE : FALSE;
- $config['shaper']['magic']['maskq'] = $_POST['maskq'] ? TRUE : FALSE;
- $config['shaper']['magic']['maxup'] = $_POST['maxup'];
- $config['shaper']['magic']['maxdown'] = $_POST['maxdown'];
- write_config();
- }
- }
- if ($_POST['remove']) {
- wipe_magic();
- $note = '
Note: The traffic shaper has been disabled. All of your user-defined rules/pipes/queues are still intact. ';
- touch($d_shaperconfdirty_path);
- write_config();
- }
- if ($_POST['apply']) {
- $retval = 0;
- if (!file_exists($d_sysrebootreqd_path)) {
- config_lock();
- $retval = shaper_configure();
- config_unlock();
- }
- $savemsg = get_std_save_message($retval);
- if ($retval == 0) {
- if (file_exists($d_shaperconfdirty_path))
- unlink($d_shaperconfdirty_path);
- }
- }
-}
-
-?>
-
-
-
+#!/usr/local/bin/php
+
+ Copyright (C) 2004 Dinesh Nair
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array("Firewall", "Traffic shaper", "Magic shaper wizard");
+require("guiconfig.inc");
+
+function wipe_magic () {
+ global $config;
+
+ /* wipe previous */
+ $types=array("pipe","queue","rule");
+ foreach ($types as $type) {
+ foreach (array_keys($config['shaper'][$type]) as $num) {
+ if (substr($config['shaper'][$type][$num]['descr'],0,2) == "m_") {
+ unset($config['shaper'][$type][$num]);
+ }
+ }
+ }
+ /* Although we don't delete user-defined rules, it's probably best to
+ disable the shaper to prevent bad things from happening */
+ $config['shaper']['enable'] = FALSE;
+}
+
+function populate_p2p(&$rulei) {
+ global $config;
+
+ /* To add p2p clients, push Descr,Protocol,Start,End,src/dest/both onto p2plist */
+ $p2plist[] = array('BitTorrent','tcp','6881','6999','both');
+ $p2plist[] = array('DirectConnect','','412','412','both');
+ $p2plist[] = array('DirectFileExpress','','1044','1045','both');
+ $p2plist[] = array('FastTrack','','1214','1214','both');
+ $p2plist[] = array('CuteMX','','2340','2340','both');
+ $p2plist[] = array('iMest','','4329','4329','both');
+ $p2plist[] = array('EDonkey2000','','4661','4665','both');
+ $p2plist[] = array('SongSpy','','5190','5190','both');
+ $p2plist[] = array('HotlineConnect','','5500','5503','both');
+ $p2plist[] = array('Gnutella','','6346','6346','both');
+ $p2plist[] = array('dcc','','6666','6668','both');
+ $p2plist[] = array('Napster','','6699','6701','both');
+ $p2plist[] = array('Aimster','','7668','7668','both');
+ $p2plist[] = array('BuddyShare','','7788','7788','both');
+ $p2plist[] = array('Scour','','8311','8311','both');
+ $p2plist[] = array('OpenNap','','8888','8889','both');
+ $p2plist[] = array('hotComm','','28864','28865','both');
+
+ /* Set up/down p2p as lowest weight */
+ $direction = array("in","out");
+ foreach ($p2plist as $p2pclient) {
+ foreach ($direction as $dir) {
+ foreach (array('source','destination') as $srcdest) {
+ if (($p2pclient[4] == $srcdest) || ($p2pclient[4] == 'both')) {
+ $config['shaper']['rule'][$rulei]['descr'] = "m_P2P $p2pclient[0]";
+ $config['shaper']['rule'][$rulei]['interface'] = "wan";
+ $config['shaper']['rule'][$rulei]['direction'] = "$dir";
+ $config['shaper']['rule'][$rulei]['source']['any'] = 1;
+ $config['shaper']['rule'][$rulei]['destination']['any'] = 1;
+ $config['shaper']['rule'][$rulei][$srcdest]['port'] = $p2pclient[2]."-".$p2pclient[3];
+ if($p2pclient[1] != '')
+ $config['shaper']['rule'][$rulei]['protocol'] = $p2pclient[1];
+ if ($dir == "out") {
+ $config['shaper']['rule'][$rulei]['targetqueue'] = 4;
+ } else {
+ $config['shaper']['rule'][$rulei]['targetqueue'] = 6;
+ }
+ $rulei++;
+ }
+ }
+ }
+ }
+}
+
+function create_magic ($maxup, $maxdown, $p2plow,$maskq) {
+ global $config;
+
+ $config['shaper']['enable'] = TRUE;
+ $pipei = 0;
+ $queuei = 0;
+ $rulei = 0;
+
+ /* Create new pipes */
+ $config['shaper']['pipe'][$pipei]['descr'] = "m_Total Upload";
+ $config['shaper']['pipe'][$pipei]['bandwidth'] = round($maxup * .90);
+ $pipei++;
+ $config['shaper']['pipe'][$pipei]['descr'] = "m_Total Download";
+ $config['shaper']['pipe'][$pipei]['bandwidth'] = round($maxdown * .95);
+ $pipei++;
+
+ /* Create new queues */
+ $config['shaper']['queue'][$queuei]['descr'] = "m_High Priority #1 Upload";
+ $config['shaper']['queue'][$queuei]['targetpipe'] = 0;
+ $config['shaper']['queue'][$queuei]['weight'] = 50;
+ $queuei++;
+ $config['shaper']['queue'][$queuei]['descr'] = "m_High Priority #2 Upload";
+ $config['shaper']['queue'][$queuei]['targetpipe'] = 0;
+ $config['shaper']['queue'][$queuei]['weight'] = 30;
+ $queuei++;
+ $config['shaper']['queue'][$queuei]['descr'] = "m_High Priority #3 Upload";
+ $config['shaper']['queue'][$queuei]['targetpipe'] = 0;
+ $config['shaper']['queue'][$queuei]['weight'] = 15;
+ $queuei++;
+ $config['shaper']['queue'][$queuei]['descr'] = "m_Bulk Upload";
+ $config['shaper']['queue'][$queuei]['targetpipe'] = 0;
+ $config['shaper']['queue'][$queuei]['weight'] = 4;
+ $queuei++;
+ $config['shaper']['queue'][$queuei]['descr'] = "m_Hated Upload";
+ $config['shaper']['queue'][$queuei]['targetpipe'] = 0;
+ $config['shaper']['queue'][$queuei]['weight'] = 1;
+ $queuei++;
+ $config['shaper']['queue'][$queuei]['descr'] = "m_Bulk Download";
+ $config['shaper']['queue'][$queuei]['targetpipe'] = 1;
+ $config['shaper']['queue'][$queuei]['weight'] = 30;
+ $queuei++;
+ $config['shaper']['queue'][$queuei]['descr'] = "m_Hated Download";
+ $config['shaper']['queue'][$queuei]['targetpipe'] = 1;
+ $config['shaper']['queue'][$queuei]['weight'] = 10;
+ $queuei++;
+ $config['shaper']['queue'][$queuei]['descr'] = "m_High Priority Download";
+ $config['shaper']['queue'][$queuei]['targetpipe'] = 1;
+ $config['shaper']['queue'][$queuei]['weight'] = 60;
+ $queuei++;
+ if ($maskq) {
+ for ($i = 0; $i < $queuei; $i++) {
+ if (stristr($config['shaper']['queue'][$i]['descr'],"upload")) {
+ $config['shaper']['queue'][$i]['mask'] = 'source';
+ } else if (stristr($config['shaper']['queue'][$i]['descr'],"download")) {
+ $config['shaper']['queue'][$i]['mask'] = 'destination';
+ }
+ }
+ }
+
+ /* Create new rules */
+ if ($p2plow)
+ populate_p2p($rulei);
+
+ $config['shaper']['rule'][$rulei]['descr'] = "m_TCP ACK Upload";
+ $config['shaper']['rule'][$rulei]['targetqueue'] = 2;
+ $config['shaper']['rule'][$rulei]['interface'] = "wan";
+ $config['shaper']['rule'][$rulei]['direction'] = "out";
+ $config['shaper']['rule'][$rulei]['source']['any'] = TRUE;
+ $config['shaper']['rule'][$rulei]['destination']['any'] = TRUE;
+ $config['shaper']['rule'][$rulei]['iplen'] = "0-80";
+ $config['shaper']['rule'][$rulei]['protocol'] = "tcp";
+ $config['shaper']['rule'][$rulei]['tcpflags'] = "ack";
+ $rulei++;
+ $config['shaper']['rule'][$rulei]['descr'] = "m_Small Pkt Upload";
+ $config['shaper']['rule'][$rulei]['targetqueue'] = 0;
+ $config['shaper']['rule'][$rulei]['interface'] = "wan";
+ $config['shaper']['rule'][$rulei]['direction'] = "out";
+ $config['shaper']['rule'][$rulei]['source']['any'] = TRUE;
+ $config['shaper']['rule'][$rulei]['destination']['any'] = TRUE;
+ $config['shaper']['rule'][$rulei]['iplen'] = "0-100";
+ $rulei++;
+ $config['shaper']['rule'][$rulei]['descr'] = "m_Outbound DNS Query";
+ $config['shaper']['rule'][$rulei]['targetqueue'] = 0;
+ $config['shaper']['rule'][$rulei]['interface'] = "wan";
+ $config['shaper']['rule'][$rulei]['direction'] = "out";
+ $config['shaper']['rule'][$rulei]['source']['any'] = TRUE;
+ $config['shaper']['rule'][$rulei]['destination']['any'] = TRUE;
+ $config['shaper']['rule'][$rulei]['destination']['port'] = 53;
+ $config['shaper']['rule'][$rulei]['protocol'] = "udp";
+ $rulei++;
+ $config['shaper']['rule'][$rulei]['descr'] = "m_AH Upload";
+ $config['shaper']['rule'][$rulei]['targetqueue'] = 0;
+ $config['shaper']['rule'][$rulei]['interface'] = "wan";
+ $config['shaper']['rule'][$rulei]['direction'] = "out";
+ $config['shaper']['rule'][$rulei]['source']['any'] = TRUE;
+ $config['shaper']['rule'][$rulei]['destination']['any'] = TRUE;
+ $config['shaper']['rule'][$rulei]['protocol'] = "ah";
+ $rulei++;
+ $config['shaper']['rule'][$rulei]['descr'] = "m_ESP Upload";
+ $config['shaper']['rule'][$rulei]['targetqueue'] = 0;
+ $config['shaper']['rule'][$rulei]['interface'] = "wan";
+ $config['shaper']['rule'][$rulei]['direction'] = "out";
+ $config['shaper']['rule'][$rulei]['source']['any'] = TRUE;
+ $config['shaper']['rule'][$rulei]['destination']['any'] = TRUE;
+ $config['shaper']['rule'][$rulei]['protocol'] = "esp";
+ $rulei++;
+ $config['shaper']['rule'][$rulei]['descr'] = "m_GRE Upload";
+ $config['shaper']['rule'][$rulei]['targetqueue'] = 0;
+ $config['shaper']['rule'][$rulei]['interface'] = "wan";
+ $config['shaper']['rule'][$rulei]['direction'] = "out";
+ $config['shaper']['rule'][$rulei]['source']['any'] = TRUE;
+ $config['shaper']['rule'][$rulei]['destination']['any'] = TRUE;
+ $config['shaper']['rule'][$rulei]['protocol'] = "gre";
+ $rulei++;
+ $config['shaper']['rule'][$rulei]['descr'] = "m_ICMP Upload";
+ $config['shaper']['rule'][$rulei]['targetqueue'] = 1;
+ $config['shaper']['rule'][$rulei]['interface'] = "wan";
+ $config['shaper']['rule'][$rulei]['direction'] = "out";
+ $config['shaper']['rule'][$rulei]['source']['any'] = TRUE;
+ $config['shaper']['rule'][$rulei]['destination']['any'] = TRUE;
+ $config['shaper']['rule'][$rulei]['protocol'] = "icmp";
+ $rulei++;
+ $config['shaper']['rule'][$rulei]['descr'] = "m_Catch-All Upload";
+ $config['shaper']['rule'][$rulei]['targetqueue'] = 3;
+ $config['shaper']['rule'][$rulei]['interface'] = "wan";
+ $config['shaper']['rule'][$rulei]['direction'] = "out";
+ $config['shaper']['rule'][$rulei]['source']['any'] = TRUE;
+ $config['shaper']['rule'][$rulei]['destination']['any'] = TRUE;
+ $rulei++;
+ $config['shaper']['rule'][$rulei]['descr'] = "m_ICMP Download";
+ $config['shaper']['rule'][$rulei]['targetqueue'] = 7;
+ $config['shaper']['rule'][$rulei]['interface'] = "wan";
+ $config['shaper']['rule'][$rulei]['direction'] = "in";
+ $config['shaper']['rule'][$rulei]['source']['any'] = TRUE;
+ $config['shaper']['rule'][$rulei]['destination']['any'] = TRUE;
+ $config['shaper']['rule'][$rulei]['protocol'] = "icmp";
+ $rulei++;
+ $config['shaper']['rule'][$rulei]['descr'] = "m_Small Pkt Download";
+ $config['shaper']['rule'][$rulei]['targetqueue'] = 7;
+ $config['shaper']['rule'][$rulei]['interface'] = "wan";
+ $config['shaper']['rule'][$rulei]['direction'] = "in";
+ $config['shaper']['rule'][$rulei]['source']['any'] = TRUE;
+ $config['shaper']['rule'][$rulei]['destination']['any'] = TRUE;
+ $config['shaper']['rule'][$rulei]['iplen'] = "0-100";
+ $rulei++;
+ $config['shaper']['rule'][$rulei]['descr'] = "m_AH Download";
+ $config['shaper']['rule'][$rulei]['targetqueue'] = 7;
+ $config['shaper']['rule'][$rulei]['interface'] = "wan";
+ $config['shaper']['rule'][$rulei]['direction'] = "in";
+ $config['shaper']['rule'][$rulei]['source']['any'] = TRUE;
+ $config['shaper']['rule'][$rulei]['destination']['any'] = TRUE;
+ $config['shaper']['rule'][$rulei]['protocol'] = "ah";
+ $rulei++;
+ $config['shaper']['rule'][$rulei]['descr'] = "m_ESP Download";
+ $config['shaper']['rule'][$rulei]['targetqueue'] = 7;
+ $config['shaper']['rule'][$rulei]['interface'] = "wan";
+ $config['shaper']['rule'][$rulei]['direction'] = "in";
+ $config['shaper']['rule'][$rulei]['source']['any'] = TRUE;
+ $config['shaper']['rule'][$rulei]['destination']['any'] = TRUE;
+ $config['shaper']['rule'][$rulei]['protocol'] = "esp";
+ $rulei++;
+ $config['shaper']['rule'][$rulei]['descr'] = "m_GRE Download";
+ $config['shaper']['rule'][$rulei]['targetqueue'] = 7;
+ $config['shaper']['rule'][$rulei]['interface'] = "wan";
+ $config['shaper']['rule'][$rulei]['direction'] = "in";
+ $config['shaper']['rule'][$rulei]['source']['any'] = TRUE;
+ $config['shaper']['rule'][$rulei]['destination']['any'] = TRUE;
+ $config['shaper']['rule'][$rulei]['protocol'] = "gre";
+ $rulei++;
+ $config['shaper']['rule'][$rulei]['descr'] = "m_Catch-All Download";
+ $config['shaper']['rule'][$rulei]['targetqueue'] = 5;
+ $config['shaper']['rule'][$rulei]['interface'] = "wan";
+ $config['shaper']['rule'][$rulei]['direction'] = "in";
+ $config['shaper']['rule'][$rulei]['source']['any'] = TRUE;
+ $config['shaper']['rule'][$rulei]['destination']['any'] = TRUE;
+ $rulei++;
+}
+
+if (!is_array($config['shaper']['rule'])) {
+ $config['shaper']['rule'] = array();
+}
+if (!is_array($config['shaper']['pipe'])) {
+ $config['shaper']['pipe'] = array();
+}
+if (!is_array($config['shaper']['queue'])) {
+ $config['shaper']['queue'] = array();
+}
+
+$a_shaper = &$config['shaper']['rule'];
+$a_queues = &$config['shaper']['queue'];
+$a_pipes = &$config['shaper']['pipe'];
+
+$pconfig['p2plow'] = isset($config['shaper']['magic']['p2plow']);
+$pconfig['maskq'] = isset($config['shaper']['magic']['maskq']);
+$pconfig['maxup'] = $config['shaper']['magic']['maxup'];
+$pconfig['maxdown'] = $config['shaper']['magic']['maxdown'];
+
+if ($_POST) {
+
+ if ($_POST['install']) {
+ unset($input_errors);
+ $pconfig = $_POST;
+ $reqdfields = explode(" ", "maxup maxdown");
+ $reqdfieldsn = explode(",", "Max. Upload,Max.Download");
+ do_input_validation($_POST,$reqdfields, $reqdfieldsn, &$input_errors);
+ if (($_POST['maxup'] && !is_numericint($_POST['maxup']))) {
+ $input_errors[] = "The max upload bandwidth must be an integer.";
+ }
+ if (($_POST['maxdown'] && !is_numericint($_POST['maxdown']))) {
+ $input_errors[] = "The max download bandwidth must be an integer.";
+ }
+ if (!$input_errors) {
+ if ($_POST['install']) {
+ unset ($config['shaper']);
+ create_magic($_POST['maxup'],$_POST['maxdown'],$_POST['p2plow']?TRUE:FALSE,$_POST['maskq']?TRUE:FALSE);
+ touch($d_shaperconfdirty_path);
+ }
+ $config['shaper']['magic']['p2plow'] = $_POST['p2plow'] ? TRUE : FALSE;
+ $config['shaper']['magic']['maskq'] = $_POST['maskq'] ? TRUE : FALSE;
+ $config['shaper']['magic']['maxup'] = $_POST['maxup'];
+ $config['shaper']['magic']['maxdown'] = $_POST['maxdown'];
+ write_config();
+ }
+ }
+ if ($_POST['remove']) {
+ wipe_magic();
+ $note = '
Note: The traffic shaper has been disabled. All of your user-defined rules/pipes/queues are still intact. ';
+ touch($d_shaperconfdirty_path);
+ write_config();
+ }
+ if ($_POST['apply']) {
+ $retval = 0;
+ if (!file_exists($d_sysrebootreqd_path)) {
+ config_lock();
+ $retval = shaper_configure();
+ config_unlock();
+ }
+ $savemsg = get_std_save_message($retval);
+ if ($retval == 0) {
+ if (file_exists($d_shaperconfdirty_path))
+ unlink($d_shaperconfdirty_path);
+ }
+ }
+}
+
+?>
+
+
+
diff --git a/webgui/firewall_shaper_pipes.php b/webgui/firewall_shaper_pipes.php
index 098dc1b..4369864 100644
--- a/webgui/firewall_shaper_pipes.php
+++ b/webgui/firewall_shaper_pipes.php
@@ -1,167 +1,170 @@
-#!/usr/local/bin/php
-.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-*/
-
-$pgtitle = array("Firewall", "Traffic shaper");
-require("guiconfig.inc");
-
-if (!is_array($config['shaper']['pipe'])) {
- $config['shaper']['pipe'] = array();
-}
-if (!is_array($config['shaper']['queue'])) {
- $config['shaper']['queue'] = array();
-}
-$a_pipes = &$config['shaper']['pipe'];
-
-if ($_GET['act'] == "del") {
- if ($a_pipes[$_GET['id']]) {
- /* check that no rule references this pipe */
- if (is_array($config['shaper']['rule'])) {
- foreach ($config['shaper']['rule'] as $rule) {
- if (isset($rule['targetpipe']) && ($rule['targetpipe'] == $_GET['id'])) {
- $input_errors[] = "This pipe cannot be deleted because it is still referenced by a rule.";
- break;
- }
- }
- }
-
- /* check that no queue references this pipe */
- if (is_array($config['shaper']['queue'])) {
- foreach ($config['shaper']['queue'] as $queue) {
- if ($queue['targetpipe'] == $_GET['id']) {
- $input_errors[] = "This pipe cannot be deleted because it is still referenced by a queue.";
- break;
- }
- }
- }
-
- if (!$input_errors) {
- unset($a_pipes[$_GET['id']]);
-
- /* renumber all rules and queues */
- if (is_array($config['shaper']['rule'])) {
- for ($i = 0; isset($config['shaper']['rule'][$i]); $i++) {
- $currule = &$config['shaper']['rule'][$i];
- if (isset($currule['targetpipe']) && ($currule['targetpipe'] > $_GET['id']))
- $currule['targetpipe']--;
- }
- }
- if (is_array($config['shaper']['queue'])) {
- for ($i = 0; isset($config['shaper']['queue'][$i]); $i++) {
- $curqueue = &$config['shaper']['queue'][$i];
- if ($curqueue['targetpipe'] > $_GET['id'])
- $curqueue['targetpipe']--;
- }
- }
-
- write_config();
- touch($d_shaperconfdirty_path);
- header("Location: firewall_shaper_pipes.php");
- exit;
- }
- }
-}
-?>
-
-
-
+#!/usr/local/bin/php
+.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array("Firewall", "Traffic shaper", "Pipes");
+require("guiconfig.inc");
+
+if (!is_array($config['shaper']['pipe'])) {
+ $config['shaper']['pipe'] = array();
+}
+if (!is_array($config['shaper']['queue'])) {
+ $config['shaper']['queue'] = array();
+}
+$a_pipes = &$config['shaper']['pipe'];
+
+if ($_GET['act'] == "del") {
+ if ($a_pipes[$_GET['id']]) {
+ /* check that no rule references this pipe */
+ if (is_array($config['shaper']['rule'])) {
+ foreach ($config['shaper']['rule'] as $rule) {
+ if (isset($rule['targetpipe']) && ($rule['targetpipe'] == $_GET['id'])) {
+ $input_errors[] = "This pipe cannot be deleted because it is still referenced by a rule.";
+ break;
+ }
+ }
+ }
+
+ /* check that no queue references this pipe */
+ if (is_array($config['shaper']['queue'])) {
+ foreach ($config['shaper']['queue'] as $queue) {
+ if ($queue['targetpipe'] == $_GET['id']) {
+ $input_errors[] = "This pipe cannot be deleted because it is still referenced by a queue.";
+ break;
+ }
+ }
+ }
+
+ if (!$input_errors) {
+ unset($a_pipes[$_GET['id']]);
+
+ /* renumber all rules and queues */
+ if (is_array($config['shaper']['rule'])) {
+ for ($i = 0; isset($config['shaper']['rule'][$i]); $i++) {
+ $currule = &$config['shaper']['rule'][$i];
+ if (isset($currule['targetpipe']) && ($currule['targetpipe'] > $_GET['id']))
+ $currule['targetpipe']--;
+ }
+ }
+ if (is_array($config['shaper']['queue'])) {
+ for ($i = 0; isset($config['shaper']['queue'][$i]); $i++) {
+ $curqueue = &$config['shaper']['queue'][$i];
+ if ($curqueue['targetpipe'] > $_GET['id'])
+ $curqueue['targetpipe']--;
+ }
+ }
+
+ write_config();
+ touch($d_shaperconfdirty_path);
+ header("Location: firewall_shaper_pipes.php");
+ exit;
+ }
+ }
+}
+?>
+
+
+
diff --git a/webgui/firewall_shaper_queues.php b/webgui/firewall_shaper_queues.php
index eb7a700..057c265 100644
--- a/webgui/firewall_shaper_queues.php
+++ b/webgui/firewall_shaper_queues.php
@@ -1,140 +1,143 @@
-#!/usr/local/bin/php
-.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-*/
-
-$pgtitle = array("Firewall", "Traffic shaper");
-require("guiconfig.inc");
-
-if (!is_array($config['shaper']['pipe'])) {
- $config['shaper']['pipe'] = array();
-}
-if (!is_array($config['shaper']['queue'])) {
- $config['shaper']['queue'] = array();
-}
-$a_queues = &$config['shaper']['queue'];
-$a_pipe = &$config['shaper']['pipe'];
-
-if ($_GET['act'] == "del") {
- if ($a_queues[$_GET['id']]) {
- /* check that no rule references this queue */
- if (is_array($config['shaper']['rule'])) {
- foreach ($config['shaper']['rule'] as $rule) {
- if (isset($rule['targetqueue']) && ($rule['targetqueue'] == $_GET['id'])) {
- $input_errors[] = "This queue cannot be deleted because it is still referenced by a rule.";
- break;
- }
- }
- }
-
- if (!$input_errors) {
- unset($a_queues[$_GET['id']]);
-
- /* renumber all rules */
- if (is_array($config['shaper']['rule'])) {
- for ($i = 0; isset($config['shaper']['rule'][$i]); $i++) {
- $currule = &$config['shaper']['rule'][$i];
- if (isset($currule['targetqueue']) && ($currule['targetqueue'] > $_GET['id']))
- $currule['targetqueue']--;
- }
- }
-
- write_config();
- touch($d_shaperconfdirty_path);
- header("Location: firewall_shaper_queues.php");
- exit;
- }
- }
-}
-?>
-
-
-
+#!/usr/local/bin/php
+.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array("Firewall", "Traffic shaper", "Queues");
+require("guiconfig.inc");
+
+if (!is_array($config['shaper']['pipe'])) {
+ $config['shaper']['pipe'] = array();
+}
+if (!is_array($config['shaper']['queue'])) {
+ $config['shaper']['queue'] = array();
+}
+$a_queues = &$config['shaper']['queue'];
+$a_pipe = &$config['shaper']['pipe'];
+
+if ($_GET['act'] == "del") {
+ if ($a_queues[$_GET['id']]) {
+ /* check that no rule references this queue */
+ if (is_array($config['shaper']['rule'])) {
+ foreach ($config['shaper']['rule'] as $rule) {
+ if (isset($rule['targetqueue']) && ($rule['targetqueue'] == $_GET['id'])) {
+ $input_errors[] = "This queue cannot be deleted because it is still referenced by a rule.";
+ break;
+ }
+ }
+ }
+
+ if (!$input_errors) {
+ unset($a_queues[$_GET['id']]);
+
+ /* renumber all rules */
+ if (is_array($config['shaper']['rule'])) {
+ for ($i = 0; isset($config['shaper']['rule'][$i]); $i++) {
+ $currule = &$config['shaper']['rule'][$i];
+ if (isset($currule['targetqueue']) && ($currule['targetqueue'] > $_GET['id']))
+ $currule['targetqueue']--;
+ }
+ }
+
+ write_config();
+ touch($d_shaperconfdirty_path);
+ header("Location: firewall_shaper_queues.php");
+ exit;
+ }
+ }
+}
+?>
+
+
+
diff --git a/webgui/guiconfig.inc b/webgui/guiconfig.inc
index ab0ddbe..77d125a 100644
--- a/webgui/guiconfig.inc
+++ b/webgui/guiconfig.inc
@@ -41,6 +41,9 @@ if (!$omit_nocacheheaders) {
require_once("config.inc");
require_once("functions.inc");
+/* ensure the user is authorized to view the current page */
+require_once("auth.inc");
+
$d_natconfdirty_path = $g['varrun_path'] . "/nat.conf.dirty";
$d_filterconfdirty_path = $g['varrun_path'] . "/filter.conf.dirty";
$d_ipsecconfdirty_path = $g['varrun_path'] . "/ipsec.conf.dirty";
@@ -477,4 +480,40 @@ function ipsec_ca_sort() {
usort($config['ipsec']['cacert'], "ipseccacmp");
}
+function dynamic_tab_menu(&$tabs) {
+ global $allowed, $config;
+
+ if ($_SERVER['REMOTE_USER'] == $config['system']['username']) {
+ $authorized = &$tabs;
+ } else {
+ $authorized = &$allowed;
+ }
+
+ // Below needed to add the "1" onto the end of the class name for the first tab, if it is inactive.
+ $linkStyle = '1';
+ foreach ($tabs as $desc => $link) {
+ if (in_array($link,$authorized)) {
+ if ($link == str_replace('/','',$_SERVER['PHP_SELF'])) {
+ // special handling for diagnostic Logs tabs.
+ if ((strpos($link,'diag_logs') > -1) && ($link != 'diag_logs_settings.php')) {
+ if ($desc == "Firewall") {
+ echo '
';
+ $linkStyle = '';
+ }
+ }
+ }
+ }
+
?>
diff --git a/webgui/services_captiveportal.php b/webgui/services_captiveportal.php
index 91aae6a..7c60c59 100644
--- a/webgui/services_captiveportal.php
+++ b/webgui/services_captiveportal.php
@@ -1,566 +1,569 @@
-#!/usr/local/bin/php
-.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-*/
-
-$pgtitle = array("Services", "Captive portal");
-require("guiconfig.inc");
-
-if (!is_array($config['captiveportal'])) {
- $config['captiveportal'] = array();
- $config['captiveportal']['page'] = array();
- $config['captiveportal']['timeout'] = 60;
-}
-
-if ($_GET['act'] == "viewhtml") {
- echo base64_decode($config['captiveportal']['page']['htmltext']);
- exit;
-} else if ($_GET['act'] == "viewerrhtml") {
- echo base64_decode($config['captiveportal']['page']['errtext']);
- exit;
-}
-
-$pconfig['cinterface'] = $config['captiveportal']['interface'];
-$pconfig['maxproc'] = $config['captiveportal']['maxproc'];
-$pconfig['maxprocperip'] = $config['captiveportal']['maxprocperip'];
-$pconfig['timeout'] = $config['captiveportal']['timeout'];
-$pconfig['idletimeout'] = $config['captiveportal']['idletimeout'];
-$pconfig['enable'] = isset($config['captiveportal']['enable']);
-$pconfig['auth_method'] = $config['captiveportal']['auth_method'];
-$pconfig['radacct_enable'] = isset($config['captiveportal']['radacct_enable']);
-$pconfig['radmac_enable'] = isset($config['captiveportal']['radmac_enable']);
-$pconfig['radmac_secret'] = $config['captiveportal']['radmac_secret'];
-$pconfig['reauthenticate'] = isset($config['captiveportal']['reauthenticate']);
-$pconfig['reauthenticateacct'] = $config['captiveportal']['reauthenticateacct'];
-$pconfig['httpslogin_enable'] = isset($config['captiveportal']['httpslogin']);
-$pconfig['httpsname'] = $config['captiveportal']['httpsname'];
-$pconfig['cert'] = base64_decode($config['captiveportal']['certificate']);
-$pconfig['key'] = base64_decode($config['captiveportal']['private-key']);
-$pconfig['logoutwin_enable'] = isset($config['captiveportal']['logoutwin_enable']);
-$pconfig['nomacfilter'] = isset($config['captiveportal']['nomacfilter']);
-$pconfig['noconcurrentlogins'] = isset($config['captiveportal']['noconcurrentlogins']);
-$pconfig['redirurl'] = $config['captiveportal']['redirurl'];
-$pconfig['radiusip'] = $config['captiveportal']['radiusip'];
-$pconfig['radiusip2'] = $config['captiveportal']['radiusip2'];
-$pconfig['radiusport'] = $config['captiveportal']['radiusport'];
-$pconfig['radiusport2'] = $config['captiveportal']['radiusport2'];
-$pconfig['radiusacctport'] = $config['captiveportal']['radiusacctport'];
-$pconfig['radiuskey'] = $config['captiveportal']['radiuskey'];
-$pconfig['radiuskey2'] = $config['captiveportal']['radiuskey2'];
-$pconfig['radiusvendor'] = $config['captiveportal']['radiusvendor'];
-$pconfig['radiussession_timeout'] = isset($config['captiveportal']['radiussession_timeout']);
-
-if ($_POST) {
-
- unset($input_errors);
- $pconfig = $_POST;
-
- /* input validation */
- if ($_POST['enable']) {
- $reqdfields = explode(" ", "cinterface");
- $reqdfieldsn = explode(",", "Interface");
-
- do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
-
- /* make sure no interfaces are bridged */
- for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
- $coptif = &$config['interfaces']['opt' . $i];
- if (isset($coptif['enable']) && $coptif['bridge']) {
- $input_errors[] = "The captive portal cannot be used when one or more interfaces are bridged.";
- break;
- }
- }
-
- if ($_POST['httpslogin_enable']) {
- if (!$_POST['cert'] || !$_POST['key']) {
- $input_errors[] = "Certificate and key must be specified for HTTPS login.";
- } else {
- if (!strstr($_POST['cert'], "BEGIN CERTIFICATE") || !strstr($_POST['cert'], "END CERTIFICATE"))
- $input_errors[] = "This certificate does not appear to be valid.";
- if (!strstr($_POST['key'], "BEGIN RSA PRIVATE KEY") || !strstr($_POST['key'], "END RSA PRIVATE KEY"))
- $input_errors[] = "This key does not appear to be valid.";
- }
-
- if (!$_POST['httpsname'] || !is_domain($_POST['httpsname'])) {
- $input_errors[] = "The HTTPS server name must be specified for HTTPS login.";
- }
- }
- }
-
- if ($_POST['timeout'] && (!is_numeric($_POST['timeout']) || ($_POST['timeout'] < 1))) {
- $input_errors[] = "The timeout must be at least 1 minute.";
- }
- if ($_POST['idletimeout'] && (!is_numeric($_POST['idletimeout']) || ($_POST['idletimeout'] < 1))) {
- $input_errors[] = "The idle timeout must be at least 1 minute.";
- }
- if (($_POST['radiusip'] && !is_ipaddr($_POST['radiusip']))) {
- $input_errors[] = "A valid IP address must be specified. [".$_POST['radiusip']."]";
- }
- if (($_POST['radiusip2'] && !is_ipaddr($_POST['radiusip2']))) {
- $input_errors[] = "A valid IP address must be specified. [".$_POST['radiusip2']."]";
- }
- if (($_POST['radiusport'] && !is_port($_POST['radiusport']))) {
- $input_errors[] = "A valid port number must be specified. [".$_POST['radiusport']."]";
- }
- if (($_POST['radiusport2'] && !is_port($_POST['radiusport2']))) {
- $input_errors[] = "A valid port number must be specified. [".$_POST['radiusport2']."]";
- }
- if (($_POST['radiusacctport'] && !is_port($_POST['radiusacctport']))) {
- $input_errors[] = "A valid port number must be specified. [".$_POST['radiusacctport']."]";
- }
- if ($_POST['maxproc'] && (!is_numeric($_POST['maxproc']) || ($_POST['maxproc'] < 4) || ($_POST['maxproc'] > 100))) {
- $input_errors[] = "The total maximum number of concurrent connections must be between 4 and 100.";
- }
- $mymaxproc = $_POST['maxproc'] ? $_POST['maxproc'] : 16;
- if ($_POST['maxprocperip'] && (!is_numeric($_POST['maxprocperip']) || ($_POST['maxprocperip'] > $mymaxproc))) {
- $input_errors[] = "The maximum number of concurrent connections per client IP address may not be larger than the global maximum.";
- }
-
- if (!$input_errors) {
- $config['captiveportal']['interface'] = $_POST['cinterface'];
- $config['captiveportal']['maxproc'] = $_POST['maxproc'];
- $config['captiveportal']['maxprocperip'] = $_POST['maxprocperip'] ? $_POST['maxprocperip'] : false;
- $config['captiveportal']['timeout'] = $_POST['timeout'];
- $config['captiveportal']['idletimeout'] = $_POST['idletimeout'];
- $config['captiveportal']['enable'] = $_POST['enable'] ? true : false;
- $config['captiveportal']['auth_method'] = $_POST['auth_method'];
- $config['captiveportal']['radacct_enable'] = $_POST['radacct_enable'] ? true : false;
- $config['captiveportal']['reauthenticate'] = $_POST['reauthenticate'] ? true : false;
- $config['captiveportal']['radmac_enable'] = $_POST['radmac_enable'] ? true : false;
- $config['captiveportal']['radmac_secret'] = $_POST['radmac_secret'] ? $_POST['radmac_secret'] : false;
- $config['captiveportal']['reauthenticateacct'] = $_POST['reauthenticateacct'];
- $config['captiveportal']['httpslogin'] = $_POST['httpslogin_enable'] ? true : false;
- $config['captiveportal']['httpsname'] = $_POST['httpsname'];
- $config['captiveportal']['certificate'] = base64_encode($_POST['cert']);
- $config['captiveportal']['private-key'] = base64_encode($_POST['key']);
- $config['captiveportal']['logoutwin_enable'] = $_POST['logoutwin_enable'] ? true : false;
- $config['captiveportal']['nomacfilter'] = $_POST['nomacfilter'] ? true : false;
- $config['captiveportal']['noconcurrentlogins'] = $_POST['noconcurrentlogins'] ? true : false;
- $config['captiveportal']['redirurl'] = $_POST['redirurl'];
- $config['captiveportal']['radiusip'] = $_POST['radiusip'];
- $config['captiveportal']['radiusip2'] = $_POST['radiusip2'];
- $config['captiveportal']['radiusport'] = $_POST['radiusport'];
- $config['captiveportal']['radiusport2'] = $_POST['radiusport2'];
- $config['captiveportal']['radiusacctport'] = $_POST['radiusacctport'];
- $config['captiveportal']['radiuskey'] = $_POST['radiuskey'];
- $config['captiveportal']['radiuskey2'] = $_POST['radiuskey2'];
- $config['captiveportal']['radiusvendor'] = $_POST['radiusvendor'] ? $_POST['radiusvendor'] : false;
- $config['captiveportal']['radiussession_timeout'] = $_POST['radiussession_timeout'] ? true : false;
-
- /* file upload? */
- if (is_uploaded_file($_FILES['htmlfile']['tmp_name']))
- $config['captiveportal']['page']['htmltext'] = base64_encode(file_get_contents($_FILES['htmlfile']['tmp_name']));
- if (is_uploaded_file($_FILES['errfile']['tmp_name']))
- $config['captiveportal']['page']['errtext'] = base64_encode(file_get_contents($_FILES['errfile']['tmp_name']));
-
- write_config();
-
- $retval = 0;
- if (!file_exists($d_sysrebootreqd_path)) {
- config_lock();
- $retval = captiveportal_configure();
- config_unlock();
- }
- $savemsg = get_std_save_message($retval);
- }
-}
-?>
-
-
-
-
-
-
-
+#!/usr/local/bin/php
+.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array("Services", "Captive portal");
+require("guiconfig.inc");
+
+if (!is_array($config['captiveportal'])) {
+ $config['captiveportal'] = array();
+ $config['captiveportal']['page'] = array();
+ $config['captiveportal']['timeout'] = 60;
+}
+
+if ($_GET['act'] == "viewhtml") {
+ echo base64_decode($config['captiveportal']['page']['htmltext']);
+ exit;
+} else if ($_GET['act'] == "viewerrhtml") {
+ echo base64_decode($config['captiveportal']['page']['errtext']);
+ exit;
+}
+
+$pconfig['cinterface'] = $config['captiveportal']['interface'];
+$pconfig['maxproc'] = $config['captiveportal']['maxproc'];
+$pconfig['maxprocperip'] = $config['captiveportal']['maxprocperip'];
+$pconfig['timeout'] = $config['captiveportal']['timeout'];
+$pconfig['idletimeout'] = $config['captiveportal']['idletimeout'];
+$pconfig['enable'] = isset($config['captiveportal']['enable']);
+$pconfig['auth_method'] = $config['captiveportal']['auth_method'];
+$pconfig['radacct_enable'] = isset($config['captiveportal']['radacct_enable']);
+$pconfig['radmac_enable'] = isset($config['captiveportal']['radmac_enable']);
+$pconfig['radmac_secret'] = $config['captiveportal']['radmac_secret'];
+$pconfig['reauthenticate'] = isset($config['captiveportal']['reauthenticate']);
+$pconfig['reauthenticateacct'] = $config['captiveportal']['reauthenticateacct'];
+$pconfig['httpslogin_enable'] = isset($config['captiveportal']['httpslogin']);
+$pconfig['httpsname'] = $config['captiveportal']['httpsname'];
+$pconfig['cert'] = base64_decode($config['captiveportal']['certificate']);
+$pconfig['key'] = base64_decode($config['captiveportal']['private-key']);
+$pconfig['logoutwin_enable'] = isset($config['captiveportal']['logoutwin_enable']);
+$pconfig['nomacfilter'] = isset($config['captiveportal']['nomacfilter']);
+$pconfig['noconcurrentlogins'] = isset($config['captiveportal']['noconcurrentlogins']);
+$pconfig['redirurl'] = $config['captiveportal']['redirurl'];
+$pconfig['radiusip'] = $config['captiveportal']['radiusip'];
+$pconfig['radiusip2'] = $config['captiveportal']['radiusip2'];
+$pconfig['radiusport'] = $config['captiveportal']['radiusport'];
+$pconfig['radiusport2'] = $config['captiveportal']['radiusport2'];
+$pconfig['radiusacctport'] = $config['captiveportal']['radiusacctport'];
+$pconfig['radiuskey'] = $config['captiveportal']['radiuskey'];
+$pconfig['radiuskey2'] = $config['captiveportal']['radiuskey2'];
+$pconfig['radiusvendor'] = $config['captiveportal']['radiusvendor'];
+$pconfig['radiussession_timeout'] = isset($config['captiveportal']['radiussession_timeout']);
+
+if ($_POST) {
+
+ unset($input_errors);
+ $pconfig = $_POST;
+
+ /* input validation */
+ if ($_POST['enable']) {
+ $reqdfields = explode(" ", "cinterface");
+ $reqdfieldsn = explode(",", "Interface");
+
+ do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
+
+ /* make sure no interfaces are bridged */
+ for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
+ $coptif = &$config['interfaces']['opt' . $i];
+ if (isset($coptif['enable']) && $coptif['bridge']) {
+ $input_errors[] = "The captive portal cannot be used when one or more interfaces are bridged.";
+ break;
+ }
+ }
+
+ if ($_POST['httpslogin_enable']) {
+ if (!$_POST['cert'] || !$_POST['key']) {
+ $input_errors[] = "Certificate and key must be specified for HTTPS login.";
+ } else {
+ if (!strstr($_POST['cert'], "BEGIN CERTIFICATE") || !strstr($_POST['cert'], "END CERTIFICATE"))
+ $input_errors[] = "This certificate does not appear to be valid.";
+ if (!strstr($_POST['key'], "BEGIN RSA PRIVATE KEY") || !strstr($_POST['key'], "END RSA PRIVATE KEY"))
+ $input_errors[] = "This key does not appear to be valid.";
+ }
+
+ if (!$_POST['httpsname'] || !is_domain($_POST['httpsname'])) {
+ $input_errors[] = "The HTTPS server name must be specified for HTTPS login.";
+ }
+ }
+ }
+
+ if ($_POST['timeout'] && (!is_numeric($_POST['timeout']) || ($_POST['timeout'] < 1))) {
+ $input_errors[] = "The timeout must be at least 1 minute.";
+ }
+ if ($_POST['idletimeout'] && (!is_numeric($_POST['idletimeout']) || ($_POST['idletimeout'] < 1))) {
+ $input_errors[] = "The idle timeout must be at least 1 minute.";
+ }
+ if (($_POST['radiusip'] && !is_ipaddr($_POST['radiusip']))) {
+ $input_errors[] = "A valid IP address must be specified. [".$_POST['radiusip']."]";
+ }
+ if (($_POST['radiusip2'] && !is_ipaddr($_POST['radiusip2']))) {
+ $input_errors[] = "A valid IP address must be specified. [".$_POST['radiusip2']."]";
+ }
+ if (($_POST['radiusport'] && !is_port($_POST['radiusport']))) {
+ $input_errors[] = "A valid port number must be specified. [".$_POST['radiusport']."]";
+ }
+ if (($_POST['radiusport2'] && !is_port($_POST['radiusport2']))) {
+ $input_errors[] = "A valid port number must be specified. [".$_POST['radiusport2']."]";
+ }
+ if (($_POST['radiusacctport'] && !is_port($_POST['radiusacctport']))) {
+ $input_errors[] = "A valid port number must be specified. [".$_POST['radiusacctport']."]";
+ }
+ if ($_POST['maxproc'] && (!is_numeric($_POST['maxproc']) || ($_POST['maxproc'] < 4) || ($_POST['maxproc'] > 100))) {
+ $input_errors[] = "The total maximum number of concurrent connections must be between 4 and 100.";
+ }
+ $mymaxproc = $_POST['maxproc'] ? $_POST['maxproc'] : 16;
+ if ($_POST['maxprocperip'] && (!is_numeric($_POST['maxprocperip']) || ($_POST['maxprocperip'] > $mymaxproc))) {
+ $input_errors[] = "The maximum number of concurrent connections per client IP address may not be larger than the global maximum.";
+ }
+
+ if (!$input_errors) {
+ $config['captiveportal']['interface'] = $_POST['cinterface'];
+ $config['captiveportal']['maxproc'] = $_POST['maxproc'];
+ $config['captiveportal']['maxprocperip'] = $_POST['maxprocperip'] ? $_POST['maxprocperip'] : false;
+ $config['captiveportal']['timeout'] = $_POST['timeout'];
+ $config['captiveportal']['idletimeout'] = $_POST['idletimeout'];
+ $config['captiveportal']['enable'] = $_POST['enable'] ? true : false;
+ $config['captiveportal']['auth_method'] = $_POST['auth_method'];
+ $config['captiveportal']['radacct_enable'] = $_POST['radacct_enable'] ? true : false;
+ $config['captiveportal']['reauthenticate'] = $_POST['reauthenticate'] ? true : false;
+ $config['captiveportal']['radmac_enable'] = $_POST['radmac_enable'] ? true : false;
+ $config['captiveportal']['radmac_secret'] = $_POST['radmac_secret'] ? $_POST['radmac_secret'] : false;
+ $config['captiveportal']['reauthenticateacct'] = $_POST['reauthenticateacct'];
+ $config['captiveportal']['httpslogin'] = $_POST['httpslogin_enable'] ? true : false;
+ $config['captiveportal']['httpsname'] = $_POST['httpsname'];
+ $config['captiveportal']['certificate'] = base64_encode($_POST['cert']);
+ $config['captiveportal']['private-key'] = base64_encode($_POST['key']);
+ $config['captiveportal']['logoutwin_enable'] = $_POST['logoutwin_enable'] ? true : false;
+ $config['captiveportal']['nomacfilter'] = $_POST['nomacfilter'] ? true : false;
+ $config['captiveportal']['noconcurrentlogins'] = $_POST['noconcurrentlogins'] ? true : false;
+ $config['captiveportal']['redirurl'] = $_POST['redirurl'];
+ $config['captiveportal']['radiusip'] = $_POST['radiusip'];
+ $config['captiveportal']['radiusip2'] = $_POST['radiusip2'];
+ $config['captiveportal']['radiusport'] = $_POST['radiusport'];
+ $config['captiveportal']['radiusport2'] = $_POST['radiusport2'];
+ $config['captiveportal']['radiusacctport'] = $_POST['radiusacctport'];
+ $config['captiveportal']['radiuskey'] = $_POST['radiuskey'];
+ $config['captiveportal']['radiuskey2'] = $_POST['radiuskey2'];
+ $config['captiveportal']['radiusvendor'] = $_POST['radiusvendor'] ? $_POST['radiusvendor'] : false;
+ $config['captiveportal']['radiussession_timeout'] = $_POST['radiussession_timeout'] ? true : false;
+
+ /* file upload? */
+ if (is_uploaded_file($_FILES['htmlfile']['tmp_name']))
+ $config['captiveportal']['page']['htmltext'] = base64_encode(file_get_contents($_FILES['htmlfile']['tmp_name']));
+ if (is_uploaded_file($_FILES['errfile']['tmp_name']))
+ $config['captiveportal']['page']['errtext'] = base64_encode(file_get_contents($_FILES['errfile']['tmp_name']));
+
+ write_config();
+
+ $retval = 0;
+ if (!file_exists($d_sysrebootreqd_path)) {
+ config_lock();
+ $retval = captiveportal_configure();
+ config_unlock();
+ }
+ $savemsg = get_std_save_message($retval);
+ }
+}
+?>
+
+
+
+
+
+
+
diff --git a/webgui/services_captiveportal_filemanager.php b/webgui/services_captiveportal_filemanager.php
index 0c0ac27..f6a8f7e 100644
--- a/webgui/services_captiveportal_filemanager.php
+++ b/webgui/services_captiveportal_filemanager.php
@@ -1,165 +1,168 @@
-#!/usr/local/bin/php
- $g['captiveportal_element_sizelimit']) {
- $input_errors[] = "The total size of all files uploaded may not exceed " .
- format_bytes($g['captiveportal_element_sizelimit']) . ".";
- }
-
- if (!$input_errors) {
- $element = array();
- $element['name'] = $name;
- $element['size'] = $size;
- $element['content'] = base64_encode(file_get_contents($_FILES['new']['tmp_name']));
-
- $a_element[] = $element;
-
- write_config();
- captiveportal_write_elements();
- header("Location: services_captiveportal_filemanager.php");
- exit;
- }
- }
-} else {
- if (($_GET['act'] == "del") && $a_element[$_GET['id']]) {
- unset($a_element[$_GET['id']]);
- write_config();
- captiveportal_write_elements();
- header("Location: services_captiveportal_filemanager.php");
- exit;
- }
-}
-
-?>
-
-
-
+#!/usr/local/bin/php
+ $g['captiveportal_element_sizelimit']) {
+ $input_errors[] = "The total size of all files uploaded may not exceed " .
+ format_bytes($g['captiveportal_element_sizelimit']) . ".";
+ }
+
+ if (!$input_errors) {
+ $element = array();
+ $element['name'] = $name;
+ $element['size'] = $size;
+ $element['content'] = base64_encode(file_get_contents($_FILES['new']['tmp_name']));
+
+ $a_element[] = $element;
+
+ write_config();
+ captiveportal_write_elements();
+ header("Location: services_captiveportal_filemanager.php");
+ exit;
+ }
+ }
+} else {
+ if (($_GET['act'] == "del") && $a_element[$_GET['id']]) {
+ unset($a_element[$_GET['id']]);
+ write_config();
+ captiveportal_write_elements();
+ header("Location: services_captiveportal_filemanager.php");
+ exit;
+ }
+}
+
+?>
+
+
+
diff --git a/webgui/services_captiveportal_ip.php b/webgui/services_captiveportal_ip.php
index 2859029..ad7a570 100644
--- a/webgui/services_captiveportal_ip.php
+++ b/webgui/services_captiveportal_ip.php
@@ -1,143 +1,146 @@
-#!/usr/local/bin/php
-
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-*/
-
-$pgtitle = array("Services", "Captive portal");
-require("guiconfig.inc");
-
-if (!is_array($config['captiveportal']['allowedip']))
- $config['captiveportal']['allowedip'] = array();
-
-allowedips_sort();
-$a_allowedips = &$config['captiveportal']['allowedip'] ;
-
-if ($_POST) {
-
- $pconfig = $_POST;
-
- if ($_POST['apply']) {
- $retval = 0;
- if (!file_exists($d_sysrebootreqd_path)) {
- $retval = captiveportal_allowedip_configure();
- }
- $savemsg = get_std_save_message($retval);
- if ($retval == 0) {
- if (file_exists($d_allowedipsdirty_path)) {
- config_lock();
- unlink($d_allowedipsdirty_path);
- config_unlock();
- }
- }
- }
-}
-
-if ($_GET['act'] == "del") {
- if ($a_allowedips[$_GET['id']]) {
- unset($a_allowedips[$_GET['id']]);
- write_config();
- touch($d_allowedipsdirty_path);
- header("Location: services_captiveportal_ip.php");
- exit;
- }
-}
-?>
-
-
-
+#!/usr/local/bin/php
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array("Services", "Captive portal", "Allowed IP Addresses");
+require("guiconfig.inc");
+
+if (!is_array($config['captiveportal']['allowedip']))
+ $config['captiveportal']['allowedip'] = array();
+
+allowedips_sort();
+$a_allowedips = &$config['captiveportal']['allowedip'] ;
+
+if ($_POST) {
+
+ $pconfig = $_POST;
+
+ if ($_POST['apply']) {
+ $retval = 0;
+ if (!file_exists($d_sysrebootreqd_path)) {
+ $retval = captiveportal_allowedip_configure();
+ }
+ $savemsg = get_std_save_message($retval);
+ if ($retval == 0) {
+ if (file_exists($d_allowedipsdirty_path)) {
+ config_lock();
+ unlink($d_allowedipsdirty_path);
+ config_unlock();
+ }
+ }
+ }
+}
+
+if ($_GET['act'] == "del") {
+ if ($a_allowedips[$_GET['id']]) {
+ unset($a_allowedips[$_GET['id']]);
+ write_config();
+ touch($d_allowedipsdirty_path);
+ header("Location: services_captiveportal_ip.php");
+ exit;
+ }
+}
+?>
+
+
+
diff --git a/webgui/services_captiveportal_mac.php b/webgui/services_captiveportal_mac.php
index 5303215..fe82ab2 100644
--- a/webgui/services_captiveportal_mac.php
+++ b/webgui/services_captiveportal_mac.php
@@ -1,124 +1,127 @@
-#!/usr/local/bin/php
-
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-*/
-
-$pgtitle = array("Services", "Captive portal");
-require("guiconfig.inc");
-
-if (!is_array($config['captiveportal']['passthrumac']))
- $config['captiveportal']['passthrumac'] = array();
-
-passthrumacs_sort();
-$a_passthrumacs = &$config['captiveportal']['passthrumac'] ;
-
-if ($_POST) {
-
- $pconfig = $_POST;
-
- if ($_POST['apply']) {
- $retval = 0;
- if (!file_exists($d_sysrebootreqd_path)) {
- $retval = captiveportal_passthrumac_configure();
- }
- $savemsg = get_std_save_message($retval);
- if ($retval == 0) {
- if (file_exists($d_passthrumacsdirty_path)) {
- config_lock();
- unlink($d_passthrumacsdirty_path);
- config_unlock();
- }
- }
- }
-}
-
-if ($_GET['act'] == "del") {
- if ($a_passthrumacs[$_GET['id']]) {
- unset($a_passthrumacs[$_GET['id']]);
- write_config();
- touch($d_passthrumacsdirty_path);
- header("Location: services_captiveportal_mac.php");
- exit;
- }
-}
-?>
-
-
-
+#!/usr/local/bin/php
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array("Services", "Captive portal", "Pass-through MAC");
+require("guiconfig.inc");
+
+if (!is_array($config['captiveportal']['passthrumac']))
+ $config['captiveportal']['passthrumac'] = array();
+
+passthrumacs_sort();
+$a_passthrumacs = &$config['captiveportal']['passthrumac'] ;
+
+if ($_POST) {
+
+ $pconfig = $_POST;
+
+ if ($_POST['apply']) {
+ $retval = 0;
+ if (!file_exists($d_sysrebootreqd_path)) {
+ $retval = captiveportal_passthrumac_configure();
+ }
+ $savemsg = get_std_save_message($retval);
+ if ($retval == 0) {
+ if (file_exists($d_passthrumacsdirty_path)) {
+ config_lock();
+ unlink($d_passthrumacsdirty_path);
+ config_unlock();
+ }
+ }
+ }
+}
+
+if ($_GET['act'] == "del") {
+ if ($a_passthrumacs[$_GET['id']]) {
+ unset($a_passthrumacs[$_GET['id']]);
+ write_config();
+ touch($d_passthrumacsdirty_path);
+ header("Location: services_captiveportal_mac.php");
+ exit;
+ }
+}
+?>
+
+
+
diff --git a/webgui/services_captiveportal_users.php b/webgui/services_captiveportal_users.php
index ce422ce..de4db34 100644
--- a/webgui/services_captiveportal_users.php
+++ b/webgui/services_captiveportal_users.php
@@ -1,110 +1,113 @@
-#!/usr/local/bin/php
-.
- All rights reserved.
- Copyright (C) 2005 Pascal Suter .
- All rights reserved.
- (files was created by Pascal based on the source code of services_captiveportal.php from Manuel)
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-*/
-$pgtitle = array("Services", "Captive portal");
-require("guiconfig.inc");
-
-if (!is_array($config['captiveportal']['user'])) {
- $config['captiveportal']['user'] = array();
-}
-captiveportal_users_sort();
-$a_user = &$config['captiveportal']['user'];
-
-if ($_GET['act'] == "del") {
- if ($a_user[$_GET['id']]) {
- unset($a_user[$_GET['id']]);
- write_config();
- header("Location: services_captiveportal_users.php");
- exit;
- }
-}
-
-//erase expired accounts
-$changed = false;
-for ($i = 0; $i < count($a_user); $i++) {
- if ($a_user[$i]['expirationdate'] && (strtotime("-1 day") > strtotime($a_user[$i]['expirationdate']))) {
- unset($a_user[$i]);
- $changed = true;
- }
-}
-if ($changed) {
- write_config();
- header("Location: services_captiveportal_users.php");
- exit;
-}
-
-?>
-
-
-
+#!/usr/local/bin/php
+.
+ All rights reserved.
+ Copyright (C) 2005 Pascal Suter .
+ All rights reserved.
+ (files was created by Pascal based on the source code of services_captiveportal.php from Manuel)
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+$pgtitle = array("Services", "Captive portal", "Users");
+require("guiconfig.inc");
+
+if (!is_array($config['captiveportal']['user'])) {
+ $config['captiveportal']['user'] = array();
+}
+captiveportal_users_sort();
+$a_user = &$config['captiveportal']['user'];
+
+if ($_GET['act'] == "del") {
+ if ($a_user[$_GET['id']]) {
+ unset($a_user[$_GET['id']]);
+ write_config();
+ header("Location: services_captiveportal_users.php");
+ exit;
+ }
+}
+
+//erase expired accounts
+$changed = false;
+for ($i = 0; $i < count($a_user); $i++) {
+ if ($a_user[$i]['expirationdate'] && (strtotime("-1 day") > strtotime($a_user[$i]['expirationdate']))) {
+ unset($a_user[$i]);
+ $changed = true;
+ }
+}
+if ($changed) {
+ write_config();
+ header("Location: services_captiveportal_users.php");
+ exit;
+}
+
+?>
+
+
+
diff --git a/webgui/system_groupmanager.php b/webgui/system_groupmanager.php
new file mode 100644
index 0000000..be5c075
--- /dev/null
+++ b/webgui/system_groupmanager.php
@@ -0,0 +1,316 @@
+#!/usr/local/bin/php
+.
+ All rights reserved.
+
+ Copyright (C) 2003-2005 Manuel Kasper .
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+require("guiconfig.inc");
+
+$pgtitle = array("System", "Group manager");
+
+// Returns an array of pages with their descriptions
+function getAdminPageList() {
+ global $g;
+
+ $tmp = Array();
+
+ if ($dir = opendir($g['www_path'])) {
+ while($file = readdir($dir)) {
+ // Make sure the file exists
+ if($file != "." && $file != ".." && $file[0] != '.') {
+ // Is this a .php file?
+ if (fnmatch('*.php',$file)) {
+ // Read the description out of the file
+ $contents = file_get_contents($file);
+ // Looking for a line like:
+ // $pgtitle = array("System", "Group manager");
+ $offset = strpos($contents,'$pgtitle');
+ $titlepos = strpos($contents,'(',$offset);
+ $titleendpos = strpos($contents,')',$titlepos);
+ if (($offset > 0) && ($titlepos > 0) && ($titleendpos > 0)) {
+ // Title found, extract it
+ $title = str_replace(',',':',str_replace(array('"'),'',substr($contents,++$titlepos,($titleendpos - $titlepos))));
+ $tmp[$file] = trim($title);
+ }
+ else {
+ $tmp[$file] = '';
+ }
+
+ }
+ }
+ }
+
+ closedir($dir);
+
+ // Sets Interfaces:Optional page that didn't read in properly with the above method,
+ // and pages that don't have descriptions.
+ $tmp['interfaces_opt.php'] = "Interfaces: Optional";
+ $tmp['graph.php'] = "Diagnostics: Interface Traffic";
+ $tmp['graph_cpu.php'] = "Diagnostics: CPU Utilization";
+ $tmp['exec.php'] = "Hidden: Exec";
+ $tmp['exec_raw.php'] = "Hidden: Exec Raw";
+ $tmp['status.php'] = "Hidden: Detailed Status";
+ $tmp['uploadconfig.php'] = "Hidden: Upload Configuration";
+ $tmp['index.php'] = "*Landing Page after Login";
+ $tmp['system_usermanager.php'] = "*User Password";
+ $tmp['diag_logs_settings.php'] = "Diagnostics: Logs: Settings";
+ $tmp['diag_logs_vpn.php'] = "Diagnostics: Logs: PPTP VPN";
+ $tmp['diag_logs_filter.php'] = "Diagnostics: Logs: Firewall";
+ $tmp['diag_logs_portal.php'] = "Diagnostics: Logs: Captive Portal";
+ $tmp['diag_logs_dhcp.php'] = "Diagnostics: Logs: DHCP";
+ $tmp['diag_logs.php'] = "Diagnostics: Logs: System";
+
+
+ asort($tmp);
+ return $tmp;
+ }
+}
+
+?>
+
+
+ $user) {
+ if ($user['group'] == $_GET['groupname']) {
+ $ok_to_delete = false;
+ $input_errors[] = "users still exist who are members of this group!";
+ break;
+ }
+ }
+ }
+
+ if ($ok_to_delete) {
+ unset($config['system']['groups'][$_GET['groupname']]);
+ write_config();
+ $retval = system_password_configure();
+ $savemsg = get_std_save_message($retval);
+ $savemsg="Group ".$_GET['groupname']." successfully deleted ";
+ }
+}
+
+if(isset($_POST['save'])) {
+ //value-checking
+ if($_POST['groupname']==""){
+ $input_errors[] = "group name must not be empty!";
+ }
+ if($_POST['old_groupname'] != $_POST['groupname']) {
+ // Either a new group, or one with a group name change
+ if (isset($config['system']['groups'][$_POST['groupname']])) {
+ $input_errors[] = "group name can not match an existing group!";
+ }
+ }
+
+ //check groupname: only allow letters from A-Z and a-z, _, -, . and numbers from 0-9 (note: groupname can
+ //not contain characters which are not allowed in an xml-token. i.e. if you'd use @ in a groupname, config.xml
+ //could not be parsed anymore!
+ if(!preg_match('/^[a-zA-Z0-9_\-\.]*$/',$_POST['groupname'])){
+ $input_errors[] = "groupname contains illegal characters, only letters from A-Z and a-z, _, -, . and numbers are allowed";
+ }
+ if(!empty($input_errors)){
+ //there are illegal inputs --> print out error message and show formula again
+ //and fill in all recently entered values except passwords
+ $_GET['act']="new";
+ $_POST['old_groupname']=($_POST['old_groupname'] ? $_POST['old_groupname'] : $_POST['groupname']);
+ $_GET['groupname']=$_POST['old_groupname'];
+
+ $group['description']=$_POST['description'];
+
+ foreach ($pages as $fname => $title) {
+ $id = str_replace('.php','',$fname);
+ if ($_POST[$id] == 'yes') {
+ $group['pages'][] = $fname;
+ }
+ }
+
+ } else {
+ //all values are okay --> saving changes
+ $_POST['groupname']=trim($_POST['groupname']);
+ if($_POST['old_groupname']!="" && $_POST['old_groupname']!=$_POST['groupname']){
+ //change the groupname (which is used as array-index)
+ $config['system']['groups'][$_POST['groupname']]=$config['system']['groups'][$_POST['old_groupname']];
+ unset($config['system']['groups'][$_POST['old_groupname']]);
+
+ // Group name was changed. Update all users that are members of this group to point to the new groupname.
+ foreach ($config['system']['users'] as $key => $user) {
+ if ($user['group'] == $_POST['old_groupname'])
+ $config['system']['users'][$key]['group'] = $_POST['groupname'];
+ }
+ }
+ $config['system']['groups'][$_POST['groupname']]['description']=trim($_POST['description']);
+ // Clear pages info and read pages from POST
+ if (isset($config['system']['groups'][$_POST['groupname']]['pages']))
+ unset($config['system']['groups'][$_POST['groupname']]['pages']);
+ foreach ($pages as $fname => $title) {
+ $id = str_replace('.php','',$fname);
+ if ($_POST[$id] == 'yes') {
+ $config['system']['groups'][$_POST['groupname']]['pages'][] = $fname;
+ }
+ }
+ write_config();
+ $retval = system_password_configure();
+ $savemsg = get_std_save_message($retval);
+ $savemsg="Group ".$_POST['groupname']." successfully saved ";
+ }
+}
+
+?>
+
+
+
+ Additional webGui admin groups can be added here. Each group can be restricted to specific portions of the webGUI. Individually select the desired web pages each group may access. For example, a troubleshooting group could be created which has access only to selected Status and Diagnostics pages.
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/webgui/system_usermanager.php b/webgui/system_usermanager.php
new file mode 100644
index 0000000..6e0b581
--- /dev/null
+++ b/webgui/system_usermanager.php
@@ -0,0 +1,325 @@
+#!/usr/local/bin/php
+.
+ All rights reserved.
+
+ Copyright (C) 2003-2005 Manuel Kasper .
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+require("guiconfig.inc");
+
+// The page title for non-admins
+$pgtitle = array("System", "User password");
+if ($_SERVER['REMOTE_USER'] === $config['system']['username']) {
+ $pgtitle = array("System", "User manager");
+}
+
+?>
+
+";
+ }
+
+ if(isset($_POST['save'])) {
+ //value-checking
+ if(trim($_POST['password1'])!="********" &&
+ trim($_POST['password1'])!="" &&
+ trim($_POST['password1'])!=trim($_POST['password2'])){
+ //passwords are to be changed but don't match
+ $input_errors[]="passwords don't match";
+ }
+ if((trim($_POST['password1'])=="" || trim($_POST['password1'])=="********") &&
+ (trim($_POST['password2'])=="" || trim($_POST['password2'])=="********")){
+ //assume password should be left as is if a password is set already.
+ if(!empty($config['system']['users'][$_POST['old_username']]['password'])){
+ $_POST['password1']="********";
+ $_POST['password2']="********";
+ } else {
+ $input_errors[]="password must not be empty";
+ }
+ } else {
+ if(trim($_POST['password1'])!=trim($_POST['password2'])){
+ //passwords are to be changed or set but don't match
+ $input_errors[]="passwords don't match";
+ } else {
+ //check password for invalid characters
+ if(!preg_match('/^[a-zA-Z0-9_\-\.@\~\(\)\&\*\+§?!\$£°\%;:]*$/',$_POST['username'])){
+ $input_errors[] = "password contains illegal characters, only letters from A-Z and a-z, _, -, .,@,~,(,),&,*,+,§,?,!,$,£,°,%,;,: and numbers are allowed";
+ //test pw: AZaz_-.@~()&*+§?!$£°%;:
+ }
+ }
+ }
+ if($_POST['username']==""){
+ $input_errors[] = "username must not be empty!";
+ }
+ if($_POST['username']==$config['system']['username']) {
+ $input_errors[] = "username can not match the administrator username!";
+ }
+ if($_POST['old_username'] != $_POST['username']) {
+ // Either a new user, or one with a username change
+ if (isset($config['system']['users'][$_POST['username']])) {
+ $input_errors[] = "username can not match an existing user!";
+ }
+ }
+ if(!isset($config['system']['groups'][$_POST['group']])) {
+ $input_errors[] = "group does not exist, please define the group before assigning users.";
+ }
+
+ //check username: only allow letters from A-Z and a-z, _, -, . and numbers from 0-9 (note: username can
+ //not contain characters which are not allowed in an xml-token. i.e. if you'd use @ in a username, config.xml
+ //could not be parsed anymore!
+ if(!preg_match('/^[a-zA-Z0-9_\-\.]*$/',$_POST['username'])){
+ $input_errors[] = "username contains illegal characters, only letters from A-Z and a-z, _, -, . and numbers are allowed";
+ }
+ if(!empty($input_errors)){
+ //there are illegal inputs --> print out error message and show formula again
+ //and fill in all recently entered values except passwords
+ $_GET['act']="new";
+ $_POST['old_username']=($_POST['old_username'] ? $_POST['old_username'] : $_POST['username']);
+ $_GET['username']=$_POST['old_username'];
+
+ $user['fullname']=$_POST['fullname'];
+
+ } else {
+ //all values are okay --> saving changes
+ $_POST['username']=trim($_POST['username']);
+ if($_POST['old_username']!="" && $_POST['old_username']!=$_POST['username']){
+ //change the username (which is used as array-index)
+ $config['system']['users'][$_POST['username']]=$config['system']['users'][$_POST['old_username']];
+ unset($config['system']['users'][$_POST['old_username']]);
+ }
+ $config['system']['users'][$_POST['username']]['fullname']=trim($_POST['fullname']);
+ if(trim($_POST['password1'])!="********" && trim($_POST['password1'])!=""){
+ $config['system']['users'][$_POST['username']]['password']=crypt(trim($_POST['password1']));
+ }
+ $config['system']['users'][$_POST['username']]['group']=trim($_POST['group']);
+ // Remove config information from old way of handling sub-admin users.
+ if (isset($config['system']['users'][$_POST['username']]['pages']))
+ unset($config['system']['users'][$_POST['username']]['pages']);
+ write_config();
+ $retval = system_password_configure();
+ $savemsg = get_std_save_message($retval);
+ $savemsg="User ".$_POST['username']." successfully saved ";
+ }
+ }
+
+?>
+
+
+
+ Additional webGui users can be added here. User permissions are determined by the admin group they are a member of.
+
+
+
+
+
+
+
+
+ saving changes
+ if(trim($_POST['password1'])!="********" && trim($_POST['password1'])!=""){
+ $config['system']['users'][$_SERVER['REMOTE_USER']]['password']=crypt(trim($_POST['password1']));
+ }
+ write_config();
+ $retval = system_password_configure();
+ $savemsg = get_std_save_message($retval);
+ $savemsg = "Password successfully changed ";
+ }
+ }
+
+
+?>
+
+
+
+
+
+
diff --git a/webgui/vpn_ipsec.php b/webgui/vpn_ipsec.php
index fc26a4c..65739bc 100644
--- a/webgui/vpn_ipsec.php
+++ b/webgui/vpn_ipsec.php
@@ -1,181 +1,184 @@
-#!/usr/local/bin/php
-.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-*/
-
-$pgtitle = array("VPN", "IPsec");
-require("guiconfig.inc");
-
-if (!is_array($config['ipsec']['tunnel'])) {
- $config['ipsec']['tunnel'] = array();
-}
-$a_ipsec = &$config['ipsec']['tunnel'];
-$wancfg = &$config['interfaces']['wan'];
-
-$pconfig['enable'] = isset($config['ipsec']['enable']);
-
-if ($_POST) {
-
- if ($_POST['apply']) {
- $retval = 0;
- if (!file_exists($d_sysrebootreqd_path))
- $retval = vpn_ipsec_configure();
- $savemsg = get_std_save_message($retval);
- if ($retval == 0) {
- if (file_exists($d_ipsecconfdirty_path))
- unlink($d_ipsecconfdirty_path);
- }
- } else if ($_POST['submit']) {
- $pconfig = $_POST;
-
- $config['ipsec']['enable'] = $_POST['enable'] ? true : false;
-
- write_config();
-
- $retval = 0;
- if (!file_exists($d_sysrebootreqd_path)) {
- config_lock();
- $retval = vpn_ipsec_configure();
- config_unlock();
- }
- $savemsg = get_std_save_message($retval);
- if ($retval == 0) {
- if (file_exists($d_ipsecconfdirty_path))
- unlink($d_ipsecconfdirty_path);
- }
- }
-}
-
-if ($_GET['act'] == "del") {
- if ($a_ipsec[$_GET['id']]) {
- unset($a_ipsec[$_GET['id']]);
- write_config();
- touch($d_ipsecconfdirty_path);
- header("Location: vpn_ipsec.php");
- exit;
- }
-}
-?>
-
-
-
+#!/usr/local/bin/php
+.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array("VPN", "IPsec", "Tunnels");
+require("guiconfig.inc");
+
+if (!is_array($config['ipsec']['tunnel'])) {
+ $config['ipsec']['tunnel'] = array();
+}
+$a_ipsec = &$config['ipsec']['tunnel'];
+$wancfg = &$config['interfaces']['wan'];
+
+$pconfig['enable'] = isset($config['ipsec']['enable']);
+
+if ($_POST) {
+
+ if ($_POST['apply']) {
+ $retval = 0;
+ if (!file_exists($d_sysrebootreqd_path))
+ $retval = vpn_ipsec_configure();
+ $savemsg = get_std_save_message($retval);
+ if ($retval == 0) {
+ if (file_exists($d_ipsecconfdirty_path))
+ unlink($d_ipsecconfdirty_path);
+ }
+ } else if ($_POST['submit']) {
+ $pconfig = $_POST;
+
+ $config['ipsec']['enable'] = $_POST['enable'] ? true : false;
+
+ write_config();
+
+ $retval = 0;
+ if (!file_exists($d_sysrebootreqd_path)) {
+ config_lock();
+ $retval = vpn_ipsec_configure();
+ config_unlock();
+ }
+ $savemsg = get_std_save_message($retval);
+ if ($retval == 0) {
+ if (file_exists($d_ipsecconfdirty_path))
+ unlink($d_ipsecconfdirty_path);
+ }
+ }
+}
+
+if ($_GET['act'] == "del") {
+ if ($a_ipsec[$_GET['id']]) {
+ unset($a_ipsec[$_GET['id']]);
+ write_config();
+ touch($d_ipsecconfdirty_path);
+ header("Location: vpn_ipsec.php");
+ exit;
+ }
+}
+?>
+
+
+
diff --git a/webgui/vpn_ipsec_ca.php b/webgui/vpn_ipsec_ca.php
index 829978d..01fded3 100644
--- a/webgui/vpn_ipsec_ca.php
+++ b/webgui/vpn_ipsec_ca.php
@@ -1,93 +1,96 @@
-#!/usr/local/bin/php
-.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-*/
-
-$pgtitle = array("VPN", "IPsec");
-require("guiconfig.inc");
-
-if (!is_array($config['ipsec']['cacert'])) {
- $config['ipsec']['cacert'] = array();
-}
-ipsec_ca_sort();
-$a_secret = &$config['ipsec']['cacert'];
-
-if ($_GET['act'] == "del") {
- if ($a_secret[$_GET['id']]) {
- unset($a_secret[$_GET['id']]);
- write_config();
- touch($d_ipsecconfdirty_path);
- header("Location: vpn_ipsec_ca.php");
- exit;
- }
-}
-
-?>
-
-
-
+#!/usr/local/bin/php
+.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array("VPN", "IPsec", "CAs");
+require("guiconfig.inc");
+
+if (!is_array($config['ipsec']['cacert'])) {
+ $config['ipsec']['cacert'] = array();
+}
+ipsec_ca_sort();
+$a_secret = &$config['ipsec']['cacert'];
+
+if ($_GET['act'] == "del") {
+ if ($a_secret[$_GET['id']]) {
+ unset($a_secret[$_GET['id']]);
+ write_config();
+ touch($d_ipsecconfdirty_path);
+ header("Location: vpn_ipsec_ca.php");
+ exit;
+ }
+}
+
+?>
+
+
+
diff --git a/webgui/vpn_ipsec_keys.php b/webgui/vpn_ipsec_keys.php
index 77e3f65..eaae0ae 100644
--- a/webgui/vpn_ipsec_keys.php
+++ b/webgui/vpn_ipsec_keys.php
@@ -1,97 +1,100 @@
-#!/usr/local/bin/php
-.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-*/
-
-$pgtitle = array("VPN", "IPsec");
-require("guiconfig.inc");
-
-if (!is_array($config['ipsec']['mobilekey'])) {
- $config['ipsec']['mobilekey'] = array();
-}
-ipsec_mobilekey_sort();
-$a_secret = &$config['ipsec']['mobilekey'];
-
-if ($_GET['act'] == "del") {
- if ($a_secret[$_GET['id']]) {
- unset($a_secret[$_GET['id']]);
- write_config();
- touch($d_ipsecconfdirty_path);
- header("Location: vpn_ipsec_keys.php");
- exit;
- }
-}
-
-?>
-
-
-
+#!/usr/local/bin/php
+.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array("VPN", "IPsec", "Pre-shared keys");
+require("guiconfig.inc");
+
+if (!is_array($config['ipsec']['mobilekey'])) {
+ $config['ipsec']['mobilekey'] = array();
+}
+ipsec_mobilekey_sort();
+$a_secret = &$config['ipsec']['mobilekey'];
+
+if ($_GET['act'] == "del") {
+ if ($a_secret[$_GET['id']]) {
+ unset($a_secret[$_GET['id']]);
+ write_config();
+ touch($d_ipsecconfdirty_path);
+ header("Location: vpn_ipsec_keys.php");
+ exit;
+ }
+}
+
+?>
+
+
+
diff --git a/webgui/vpn_ipsec_mobile.php b/webgui/vpn_ipsec_mobile.php
index 90358ea..173e969 100644
--- a/webgui/vpn_ipsec_mobile.php
+++ b/webgui/vpn_ipsec_mobile.php
@@ -1,381 +1,384 @@
-#!/usr/local/bin/php
-.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-*/
-
-$pgtitle = array("VPN", "IPsec");
-require("guiconfig.inc");
-
-if (!is_array($config['ipsec']['mobileclients'])) {
- $config['ipsec']['mobileclients'] = array();
-}
-$a_ipsec = &$config['ipsec']['mobileclients'];
-
-if (count($a_ipsec) == 0) {
- /* defaults */
- $pconfig['p1mode'] = "aggressive";
- $pconfig['p1myidentt'] = "myaddress";
- $pconfig['p1ealgo'] = "3des";
- $pconfig['p1halgo'] = "sha1";
- $pconfig['p1dhgroup'] = "2";
- $pconfig['p1authentication_method'] = "pre_shared_key";
- $pconfig['p2proto'] = "esp";
- $pconfig['p2ealgos'] = explode(",", "3des,blowfish,cast128,rijndael");
- $pconfig['p2halgos'] = explode(",", "hmac_sha1,hmac_md5");
- $pconfig['p2pfsgroup'] = "0";
-} else {
- $pconfig['enable'] = isset($a_ipsec['enable']);
- $pconfig['p1mode'] = $a_ipsec['p1']['mode'];
-
- if (isset($a_ipsec['p1']['myident']['myaddress']))
- $pconfig['p1myidentt'] = 'myaddress';
- else if (isset($a_ipsec['p1']['myident']['address'])) {
- $pconfig['p1myidentt'] = 'address';
- $pconfig['p1myident'] = $a_ipsec['p1']['myident']['address'];
- } else if (isset($a_ipsec['p1']['myident']['fqdn'])) {
- $pconfig['p1myidentt'] = 'fqdn';
- $pconfig['p1myident'] = $a_ipsec['p1']['myident']['fqdn'];
- } else if (isset($a_ipsec['p1']['myident']['ufqdn'])) {
- $pconfig['p1myidentt'] = 'user_fqdn';
- $pconfig['p1myident'] = $a_ipsec['p1']['myident']['ufqdn'];
- }
-
- $pconfig['p1ealgo'] = $a_ipsec['p1']['encryption-algorithm'];
- $pconfig['p1halgo'] = $a_ipsec['p1']['hash-algorithm'];
- $pconfig['p1dhgroup'] = $a_ipsec['p1']['dhgroup'];
- $pconfig['p1lifetime'] = $a_ipsec['p1']['lifetime'];
- $pconfig['p1authentication_method'] = $a_ipsec['p1']['authentication_method'];
- $pconfig['p1cert'] = base64_decode($a_ipsec['p1']['cert']);
- $pconfig['p1privatekey'] = base64_decode($a_ipsec['p1']['private-key']);
- $pconfig['p2proto'] = $a_ipsec['p2']['protocol'];
- $pconfig['p2ealgos'] = $a_ipsec['p2']['encryption-algorithm-option'];
- $pconfig['p2halgos'] = $a_ipsec['p2']['hash-algorithm-option'];
- $pconfig['p2pfsgroup'] = $a_ipsec['p2']['pfsgroup'];
- $pconfig['p2lifetime'] = $a_ipsec['p2']['lifetime'];
-}
-
-if ($_POST) {
- unset($input_errors);
- $pconfig = $_POST;
-
- /* input validation */
- $reqdfields = explode(" ", "p2ealgos p2halgos");
- $reqdfieldsn = explode(",", "P2 Encryption Algorithms,P2 Hash Algorithms");
-
- do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
-
- if ($_POST['p1authentication_method']== "rsasig") {
- if (!strstr($_POST['p1cert'], "BEGIN CERTIFICATE") || !strstr($_POST['p1cert'], "END CERTIFICATE"))
- $input_errors[] = "This certificate does not appear to be valid.";
- if (!strstr($_POST['p1privatekey'], "BEGIN RSA PRIVATE KEY") || !strstr($_POST['p1privatekey'], "END RSA PRIVATE KEY"))
- $input_errors[] = "This key does not appear to be valid.";
- }
-
- if (($_POST['p1lifetime'] && !is_numeric($_POST['p1lifetime']))) {
- $input_errors[] = "The P1 lifetime must be an integer.";
- }
- if (($_POST['p2lifetime'] && !is_numeric($_POST['p2lifetime']))) {
- $input_errors[] = "The P2 lifetime must be an integer.";
- }
- if ((($_POST['p1myidentt'] == "address") && !is_ipaddr($_POST['p1myident']))) {
- $input_errors[] = "A valid IP address for 'My identifier' must be specified.";
- }
- if ((($_POST['p1myidentt'] == "fqdn") && !is_domain($_POST['p1myident']))) {
- $input_errors[] = "A valid domain name for 'My identifier' must be specified.";
- }
- if ($_POST['p1myidentt'] == "user_fqdn") {
- $ufqdn = explode("@",$_POST['p1myident']);
- if (!is_domain($ufqdn[1]))
- $input_errors[] = "A valid User FQDN in the form of user@my.domain.com for 'My identifier' must be specified.";
- }
-
- if ($_POST['p1myidentt'] == "myaddress")
- $_POST['p1myident'] = "";
-
- if (!$input_errors) {
- $ipsecent = array();
- $ipsecent['enable'] = $_POST['enable'] ? true : false;
- $ipsecent['p1']['mode'] = $_POST['p1mode'];
-
- $ipsecent['p1']['myident'] = array();
- switch ($_POST['p1myidentt']) {
- case 'myaddress':
- $ipsecent['p1']['myident']['myaddress'] = true;
- break;
- case 'address':
- $ipsecent['p1']['myident']['address'] = $_POST['p1myident'];
- break;
- case 'fqdn':
- $ipsecent['p1']['myident']['fqdn'] = $_POST['p1myident'];
- break;
- case 'user_fqdn':
- $ipsecent['p1']['myident']['ufqdn'] = $_POST['p1myident'];
- break;
- }
-
- $ipsecent['p1']['encryption-algorithm'] = $_POST['p1ealgo'];
- $ipsecent['p1']['hash-algorithm'] = $_POST['p1halgo'];
- $ipsecent['p1']['dhgroup'] = $_POST['p1dhgroup'];
- $ipsecent['p1']['lifetime'] = $_POST['p1lifetime'];
- $ipsecent['p1']['private-key'] = base64_encode($_POST['p1privatekey']);
- $ipsecent['p1']['cert'] = base64_encode($_POST['p1cert']);
- $ipsecent['p1']['authentication_method'] = $_POST['p1authentication_method'];
- $ipsecent['p2']['protocol'] = $_POST['p2proto'];
- $ipsecent['p2']['encryption-algorithm-option'] = $_POST['p2ealgos'];
- $ipsecent['p2']['hash-algorithm-option'] = $_POST['p2halgos'];
- $ipsecent['p2']['pfsgroup'] = $_POST['p2pfsgroup'];
- $ipsecent['p2']['lifetime'] = $_POST['p2lifetime'];
-
- $a_ipsec = $ipsecent;
-
- write_config();
- touch($d_ipsecconfdirty_path);
-
- header("Location: vpn_ipsec_mobile.php");
- exit;
- }
-}
-?>
-
-
-
-
-
-
+#!/usr/local/bin/php
+.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array("VPN", "IPsec", "Mobile clients");
+require("guiconfig.inc");
+
+if (!is_array($config['ipsec']['mobileclients'])) {
+ $config['ipsec']['mobileclients'] = array();
+}
+$a_ipsec = &$config['ipsec']['mobileclients'];
+
+if (count($a_ipsec) == 0) {
+ /* defaults */
+ $pconfig['p1mode'] = "aggressive";
+ $pconfig['p1myidentt'] = "myaddress";
+ $pconfig['p1ealgo'] = "3des";
+ $pconfig['p1halgo'] = "sha1";
+ $pconfig['p1dhgroup'] = "2";
+ $pconfig['p1authentication_method'] = "pre_shared_key";
+ $pconfig['p2proto'] = "esp";
+ $pconfig['p2ealgos'] = explode(",", "3des,blowfish,cast128,rijndael");
+ $pconfig['p2halgos'] = explode(",", "hmac_sha1,hmac_md5");
+ $pconfig['p2pfsgroup'] = "0";
+} else {
+ $pconfig['enable'] = isset($a_ipsec['enable']);
+ $pconfig['p1mode'] = $a_ipsec['p1']['mode'];
+
+ if (isset($a_ipsec['p1']['myident']['myaddress']))
+ $pconfig['p1myidentt'] = 'myaddress';
+ else if (isset($a_ipsec['p1']['myident']['address'])) {
+ $pconfig['p1myidentt'] = 'address';
+ $pconfig['p1myident'] = $a_ipsec['p1']['myident']['address'];
+ } else if (isset($a_ipsec['p1']['myident']['fqdn'])) {
+ $pconfig['p1myidentt'] = 'fqdn';
+ $pconfig['p1myident'] = $a_ipsec['p1']['myident']['fqdn'];
+ } else if (isset($a_ipsec['p1']['myident']['ufqdn'])) {
+ $pconfig['p1myidentt'] = 'user_fqdn';
+ $pconfig['p1myident'] = $a_ipsec['p1']['myident']['ufqdn'];
+ }
+
+ $pconfig['p1ealgo'] = $a_ipsec['p1']['encryption-algorithm'];
+ $pconfig['p1halgo'] = $a_ipsec['p1']['hash-algorithm'];
+ $pconfig['p1dhgroup'] = $a_ipsec['p1']['dhgroup'];
+ $pconfig['p1lifetime'] = $a_ipsec['p1']['lifetime'];
+ $pconfig['p1authentication_method'] = $a_ipsec['p1']['authentication_method'];
+ $pconfig['p1cert'] = base64_decode($a_ipsec['p1']['cert']);
+ $pconfig['p1privatekey'] = base64_decode($a_ipsec['p1']['private-key']);
+ $pconfig['p2proto'] = $a_ipsec['p2']['protocol'];
+ $pconfig['p2ealgos'] = $a_ipsec['p2']['encryption-algorithm-option'];
+ $pconfig['p2halgos'] = $a_ipsec['p2']['hash-algorithm-option'];
+ $pconfig['p2pfsgroup'] = $a_ipsec['p2']['pfsgroup'];
+ $pconfig['p2lifetime'] = $a_ipsec['p2']['lifetime'];
+}
+
+if ($_POST) {
+ unset($input_errors);
+ $pconfig = $_POST;
+
+ /* input validation */
+ $reqdfields = explode(" ", "p2ealgos p2halgos");
+ $reqdfieldsn = explode(",", "P2 Encryption Algorithms,P2 Hash Algorithms");
+
+ do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
+
+ if ($_POST['p1authentication_method']== "rsasig") {
+ if (!strstr($_POST['p1cert'], "BEGIN CERTIFICATE") || !strstr($_POST['p1cert'], "END CERTIFICATE"))
+ $input_errors[] = "This certificate does not appear to be valid.";
+ if (!strstr($_POST['p1privatekey'], "BEGIN RSA PRIVATE KEY") || !strstr($_POST['p1privatekey'], "END RSA PRIVATE KEY"))
+ $input_errors[] = "This key does not appear to be valid.";
+ }
+
+ if (($_POST['p1lifetime'] && !is_numeric($_POST['p1lifetime']))) {
+ $input_errors[] = "The P1 lifetime must be an integer.";
+ }
+ if (($_POST['p2lifetime'] && !is_numeric($_POST['p2lifetime']))) {
+ $input_errors[] = "The P2 lifetime must be an integer.";
+ }
+ if ((($_POST['p1myidentt'] == "address") && !is_ipaddr($_POST['p1myident']))) {
+ $input_errors[] = "A valid IP address for 'My identifier' must be specified.";
+ }
+ if ((($_POST['p1myidentt'] == "fqdn") && !is_domain($_POST['p1myident']))) {
+ $input_errors[] = "A valid domain name for 'My identifier' must be specified.";
+ }
+ if ($_POST['p1myidentt'] == "user_fqdn") {
+ $ufqdn = explode("@",$_POST['p1myident']);
+ if (!is_domain($ufqdn[1]))
+ $input_errors[] = "A valid User FQDN in the form of user@my.domain.com for 'My identifier' must be specified.";
+ }
+
+ if ($_POST['p1myidentt'] == "myaddress")
+ $_POST['p1myident'] = "";
+
+ if (!$input_errors) {
+ $ipsecent = array();
+ $ipsecent['enable'] = $_POST['enable'] ? true : false;
+ $ipsecent['p1']['mode'] = $_POST['p1mode'];
+
+ $ipsecent['p1']['myident'] = array();
+ switch ($_POST['p1myidentt']) {
+ case 'myaddress':
+ $ipsecent['p1']['myident']['myaddress'] = true;
+ break;
+ case 'address':
+ $ipsecent['p1']['myident']['address'] = $_POST['p1myident'];
+ break;
+ case 'fqdn':
+ $ipsecent['p1']['myident']['fqdn'] = $_POST['p1myident'];
+ break;
+ case 'user_fqdn':
+ $ipsecent['p1']['myident']['ufqdn'] = $_POST['p1myident'];
+ break;
+ }
+
+ $ipsecent['p1']['encryption-algorithm'] = $_POST['p1ealgo'];
+ $ipsecent['p1']['hash-algorithm'] = $_POST['p1halgo'];
+ $ipsecent['p1']['dhgroup'] = $_POST['p1dhgroup'];
+ $ipsecent['p1']['lifetime'] = $_POST['p1lifetime'];
+ $ipsecent['p1']['private-key'] = base64_encode($_POST['p1privatekey']);
+ $ipsecent['p1']['cert'] = base64_encode($_POST['p1cert']);
+ $ipsecent['p1']['authentication_method'] = $_POST['p1authentication_method'];
+ $ipsecent['p2']['protocol'] = $_POST['p2proto'];
+ $ipsecent['p2']['encryption-algorithm-option'] = $_POST['p2ealgos'];
+ $ipsecent['p2']['hash-algorithm-option'] = $_POST['p2halgos'];
+ $ipsecent['p2']['pfsgroup'] = $_POST['p2pfsgroup'];
+ $ipsecent['p2']['lifetime'] = $_POST['p2lifetime'];
+
+ $a_ipsec = $ipsecent;
+
+ write_config();
+ touch($d_ipsecconfdirty_path);
+
+ header("Location: vpn_ipsec_mobile.php");
+ exit;
+ }
+}
+?>
+
+
+
+
+
+
diff --git a/webgui/vpn_pptp.php b/webgui/vpn_pptp.php
index a8ac37f..024b21c 100644
--- a/webgui/vpn_pptp.php
+++ b/webgui/vpn_pptp.php
@@ -1,296 +1,299 @@
-#!/usr/local/bin/php
-.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-*/
-
-$pgtitle = array("VPN", "PPTP");
-require("guiconfig.inc");
-
-if (!is_array($config['pptpd']['radius'])) {
- $config['pptpd']['radius'] = array();
-}
-$pptpcfg = &$config['pptpd'];
-
-$pconfig['remoteip'] = $pptpcfg['remoteip'];
-$pconfig['localip'] = $pptpcfg['localip'];
-$pconfig['redir'] = $pptpcfg['redir'];
-$pconfig['mode'] = $pptpcfg['mode'];
-$pconfig['req128'] = isset($pptpcfg['req128']);
-$pconfig['radiusenable'] = isset($pptpcfg['radius']['enable']);
-$pconfig['radacct_enable'] = isset($pptpcfg['radius']['accounting']);
-$pconfig['radiusserver'] = $pptpcfg['radius']['server'];
-$pconfig['radiussecret'] = $pptpcfg['radius']['secret'];
-
-if ($_POST) {
-
- unset($input_errors);
- $pconfig = $_POST;
-
- /* input validation */
- if ($_POST['mode'] == "server") {
- $reqdfields = explode(" ", "localip remoteip");
- $reqdfieldsn = explode(",", "Server address,Remote start address");
-
- if ($_POST['radiusenable']) {
- $reqdfields = array_merge($reqdfields, explode(" ", "radiusserver radiussecret"));
- $reqdfieldsn = array_merge($reqdfieldsn,
- explode(",", "RADIUS server address,RADIUS shared secret"));
- }
-
- do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
-
- if (($_POST['localip'] && !is_ipaddr($_POST['localip']))) {
- $input_errors[] = "A valid server address must be specified.";
- }
- if (($_POST['subnet'] && !is_ipaddr($_POST['remoteip']))) {
- $input_errors[] = "A valid remote start address must be specified.";
- }
- if (($_POST['radiusserver'] && !is_ipaddr($_POST['radiusserver']))) {
- $input_errors[] = "A valid RADIUS server address must be specified.";
- }
-
- if (!$input_errors) {
- $_POST['remoteip'] = $pconfig['remoteip'] = gen_subnet($_POST['remoteip'], $g['pptp_subnet']);
- $subnet_start = ip2long($_POST['remoteip']);
- $subnet_end = ip2long($_POST['remoteip']) + $g['n_pptp_units'] - 1;
-
- if ((ip2long($_POST['localip']) >= $subnet_start) &&
- (ip2long($_POST['localip']) <= $subnet_end)) {
- $input_errors[] = "The specified server address lies in the remote subnet.";
- }
- if ($_POST['localip'] == $config['interfaces']['lan']['ipaddr']) {
- $input_errors[] = "The specified server address is equal to the LAN interface address.";
- }
- }
- } else if ($_POST['mode'] == "redir") {
- $reqdfields = explode(" ", "redir");
- $reqdfieldsn = explode(",", "PPTP redirection target address");
-
- do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
-
- if (($_POST['redir'] && !is_ipaddr($_POST['redir']))) {
- $input_errors[] = "A valid target address must be specified.";
- }
- }
-
- if (!$input_errors) {
- $pptpcfg['remoteip'] = $_POST['remoteip'];
- $pptpcfg['redir'] = $_POST['redir'];
- $pptpcfg['localip'] = $_POST['localip'];
- $pptpcfg['mode'] = $_POST['mode'];
- $pptpcfg['req128'] = $_POST['req128'] ? true : false;
- $pptpcfg['radius']['enable'] = $_POST['radiusenable'] ? true : false;
- $pptpcfg['radius']['accounting'] = $_POST['radacct_enable'] ? true : false;
- $pptpcfg['radius']['server'] = $_POST['radiusserver'];
- $pptpcfg['radius']['secret'] = $_POST['radiussecret'];
-
- write_config();
-
- $retval = 0;
- if (!file_exists($d_sysrebootreqd_path)) {
- config_lock();
- $retval = vpn_pptpd_configure();
- config_unlock();
- }
- $savemsg = get_std_save_message($retval);
- }
-}
-?>
-
-
-
-
-
+#!/usr/local/bin/php
+.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array("VPN", "PPTP", "Configuration");
+require("guiconfig.inc");
+
+if (!is_array($config['pptpd']['radius'])) {
+ $config['pptpd']['radius'] = array();
+}
+$pptpcfg = &$config['pptpd'];
+
+$pconfig['remoteip'] = $pptpcfg['remoteip'];
+$pconfig['localip'] = $pptpcfg['localip'];
+$pconfig['redir'] = $pptpcfg['redir'];
+$pconfig['mode'] = $pptpcfg['mode'];
+$pconfig['req128'] = isset($pptpcfg['req128']);
+$pconfig['radiusenable'] = isset($pptpcfg['radius']['enable']);
+$pconfig['radacct_enable'] = isset($pptpcfg['radius']['accounting']);
+$pconfig['radiusserver'] = $pptpcfg['radius']['server'];
+$pconfig['radiussecret'] = $pptpcfg['radius']['secret'];
+
+if ($_POST) {
+
+ unset($input_errors);
+ $pconfig = $_POST;
+
+ /* input validation */
+ if ($_POST['mode'] == "server") {
+ $reqdfields = explode(" ", "localip remoteip");
+ $reqdfieldsn = explode(",", "Server address,Remote start address");
+
+ if ($_POST['radiusenable']) {
+ $reqdfields = array_merge($reqdfields, explode(" ", "radiusserver radiussecret"));
+ $reqdfieldsn = array_merge($reqdfieldsn,
+ explode(",", "RADIUS server address,RADIUS shared secret"));
+ }
+
+ do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
+
+ if (($_POST['localip'] && !is_ipaddr($_POST['localip']))) {
+ $input_errors[] = "A valid server address must be specified.";
+ }
+ if (($_POST['subnet'] && !is_ipaddr($_POST['remoteip']))) {
+ $input_errors[] = "A valid remote start address must be specified.";
+ }
+ if (($_POST['radiusserver'] && !is_ipaddr($_POST['radiusserver']))) {
+ $input_errors[] = "A valid RADIUS server address must be specified.";
+ }
+
+ if (!$input_errors) {
+ $_POST['remoteip'] = $pconfig['remoteip'] = gen_subnet($_POST['remoteip'], $g['pptp_subnet']);
+ $subnet_start = ip2long($_POST['remoteip']);
+ $subnet_end = ip2long($_POST['remoteip']) + $g['n_pptp_units'] - 1;
+
+ if ((ip2long($_POST['localip']) >= $subnet_start) &&
+ (ip2long($_POST['localip']) <= $subnet_end)) {
+ $input_errors[] = "The specified server address lies in the remote subnet.";
+ }
+ if ($_POST['localip'] == $config['interfaces']['lan']['ipaddr']) {
+ $input_errors[] = "The specified server address is equal to the LAN interface address.";
+ }
+ }
+ } else if ($_POST['mode'] == "redir") {
+ $reqdfields = explode(" ", "redir");
+ $reqdfieldsn = explode(",", "PPTP redirection target address");
+
+ do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
+
+ if (($_POST['redir'] && !is_ipaddr($_POST['redir']))) {
+ $input_errors[] = "A valid target address must be specified.";
+ }
+ }
+
+ if (!$input_errors) {
+ $pptpcfg['remoteip'] = $_POST['remoteip'];
+ $pptpcfg['redir'] = $_POST['redir'];
+ $pptpcfg['localip'] = $_POST['localip'];
+ $pptpcfg['mode'] = $_POST['mode'];
+ $pptpcfg['req128'] = $_POST['req128'] ? true : false;
+ $pptpcfg['radius']['enable'] = $_POST['radiusenable'] ? true : false;
+ $pptpcfg['radius']['accounting'] = $_POST['radacct_enable'] ? true : false;
+ $pptpcfg['radius']['server'] = $_POST['radiusserver'];
+ $pptpcfg['radius']['secret'] = $_POST['radiussecret'];
+
+ write_config();
+
+ $retval = 0;
+ if (!file_exists($d_sysrebootreqd_path)) {
+ config_lock();
+ $retval = vpn_pptpd_configure();
+ config_unlock();
+ }
+ $savemsg = get_std_save_message($retval);
+ }
+}
+?>
+
+
+
+
+
diff --git a/webgui/vpn_pptp_users.php b/webgui/vpn_pptp_users.php
index acc2941..187ed68 100644
--- a/webgui/vpn_pptp_users.php
+++ b/webgui/vpn_pptp_users.php
@@ -1,115 +1,118 @@
-#!/usr/local/bin/php
-.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-*/
-
-$pgtitle = array("VPN", "PPTP");
-require("guiconfig.inc");
-
-if (!is_array($config['pptpd']['user'])) {
- $config['pptpd']['user'] = array();
-}
-pptpd_users_sort();
-$a_secret = &$config['pptpd']['user'];
-
-if ($_POST) {
-
- $pconfig = $_POST;
-
- if ($_POST['apply']) {
- $retval = 0;
- if (!file_exists($d_sysrebootreqd_path)) {
- config_lock();
- $retval = vpn_pptpd_configure();
- config_unlock();
- }
- $savemsg = get_std_save_message($retval);
- if ($retval == 0) {
- if (file_exists($d_pptpuserdirty_path))
- unlink($d_pptpuserdirty_path);
- }
- }
-}
-
-if ($_GET['act'] == "del") {
- if ($a_secret[$_GET['id']]) {
- unset($a_secret[$_GET['id']]);
- write_config();
- touch($d_pptpuserdirty_path);
- header("Location: vpn_pptp_users.php");
- exit;
- }
-}
-?>
-
-
-
+#!/usr/local/bin/php
+.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array("VPN", "PPTP", "Users");
+require("guiconfig.inc");
+
+if (!is_array($config['pptpd']['user'])) {
+ $config['pptpd']['user'] = array();
+}
+pptpd_users_sort();
+$a_secret = &$config['pptpd']['user'];
+
+if ($_POST) {
+
+ $pconfig = $_POST;
+
+ if ($_POST['apply']) {
+ $retval = 0;
+ if (!file_exists($d_sysrebootreqd_path)) {
+ config_lock();
+ $retval = vpn_pptpd_configure();
+ config_unlock();
+ }
+ $savemsg = get_std_save_message($retval);
+ if ($retval == 0) {
+ if (file_exists($d_pptpuserdirty_path))
+ unlink($d_pptpuserdirty_path);
+ }
+ }
+}
+
+if ($_GET['act'] == "del") {
+ if ($a_secret[$_GET['id']]) {
+ unset($a_secret[$_GET['id']]);
+ write_config();
+ touch($d_pptpuserdirty_path);
+ header("Location: vpn_pptp_users.php");
+ exit;
+ }
+}
+?>
+
+
+