diff options
author | Renato Botelho <garga@FreeBSD.org> | 2014-11-13 14:48:42 -0200 |
---|---|---|
committer | Renato Botelho <garga@FreeBSD.org> | 2014-11-13 14:50:23 -0200 |
commit | b4e0f02b89fa6b8e8b22f31ee4486df171ae5337 (patch) | |
tree | 82bfb5ba7a3e076f0063b673e0b9d04f28a5b78f | |
parent | 0cd7c91a29a88c3ac859be9ee9563e1737924128 (diff) | |
download | pfsense-b4e0f02b89fa6b8e8b22f31ee4486df171ae5337.zip pfsense-b4e0f02b89fa6b8e8b22f31ee4486df171ae5337.tar.gz |
Make sure $cpzoneid is defined and use it to call pfSense_ipfw_Tableaction() and pfSense_ipfw_getTablestats(). Also fix fieldnames for captiveportal_hostnames. It should fix #4001
-rw-r--r-- | usr/local/www/services_captiveportal_hostname.php | 19 | ||||
-rw-r--r-- | usr/local/www/services_captiveportal_ip.php | 11 | ||||
-rw-r--r-- | usr/local/www/status_captiveportal.php | 15 | ||||
-rw-r--r-- | usr/local/www/widgets/widgets/captive_portal_status.widget.php | 19 |
4 files changed, 41 insertions, 23 deletions
diff --git a/usr/local/www/services_captiveportal_hostname.php b/usr/local/www/services_captiveportal_hostname.php index d3a9b7e..964c2ba 100644 --- a/usr/local/www/services_captiveportal_hostname.php +++ b/usr/local/www/services_captiveportal_hostname.php @@ -61,27 +61,32 @@ if (!is_array($config['captiveportal'])) $config['captiveportal'] = array(); $a_cp =& $config['captiveportal']; +if (isset($cpzone) && !empty($cpzone) && isset($a_cp[$cpzone]['zoneid'])) + $cpzoneid = $a_cp[$cpzone]['zoneid']; + $pgtitle = array(gettext("Services"),gettext("Captive portal"), $a_cp[$cpzone]['zone']); $shortcut_section = "captiveportal"; -if ($_GET['act'] == "del" && !empty($cpzone)) { +if ($_GET['act'] == "del" && !empty($cpzone) && isset($cpzoneid)) { $a_allowedhostnames =& $a_cp[$cpzone]['allowedhostname']; if ($a_allowedhostnames[$_GET['id']]) { $ipent = $a_allowedhostnames[$_GET['id']]; if (isset($a_cp[$cpzone]['enable'])) { - if (!empty($ipent['sn'])) - $ipent['ip'] .= "/{$ipent['sn']}"; - $ip = gethostbyname($ipent['ip']); + if(is_ipaddr($ipent['hostname'])) + $ip = $ipent['hostname']; + else + $ip = gethostbyname($ipent['hostname']); + $sn = (is_ipaddrv6($ip)) ? 128 : 32; if(is_ipaddr($ip)) { - $ipfw = pfSense_ipfw_getTablestats($cpzone, 3, $ip); + $ipfw = pfSense_ipfw_getTablestats($cpzoneid, 3, $ip); if (is_array($ipfw)) { captiveportal_free_dn_ruleno($ipfw['dnpipe']); pfSense_pipe_action("pipe delete {$ipfw['dnpipe']}"); pfSense_pipe_action("pipe delete " . ($ipfw['dnpipe']+1)); } - pfSense_ipfw_Tableaction($cpzone, IP_FW_TABLE_XDEL, 3, $ip); - pfSense_ipfw_Tableaction($cpzone, IP_FW_TABLE_XDEL, 4, $ip); + pfSense_ipfw_Tableaction($cpzoneid, IP_FW_TABLE_XDEL, 3, $ip, $sn); + pfSense_ipfw_Tableaction($cpzoneid, IP_FW_TABLE_XDEL, 4, $ip, $sn); } } diff --git a/usr/local/www/services_captiveportal_ip.php b/usr/local/www/services_captiveportal_ip.php index 1ca876d..f08e861 100644 --- a/usr/local/www/services_captiveportal_ip.php +++ b/usr/local/www/services_captiveportal_ip.php @@ -59,10 +59,13 @@ if (!is_array($config['captiveportal'])) $config['captiveportal'] = array(); $a_cp =& $config['captiveportal']; +if (isset($cpzone) && !empty($cpzone) && isset($a_cp[$cpzone]['zoneid'])) + $cpzoneid = $a_cp[$cpzone]['zoneid']; + $pgtitle = array(gettext("Services"),gettext("Captive portal"), $a_cp[$cpzone]['zone']); $shortcut_section = "captiveportal"; -if ($_GET['act'] == "del") { +if ($_GET['act'] == "del" && !empty($cpzone) && isset($cpzoneid)) { $a_allowedips =& $config['captiveportal'][$cpzone]['allowedip']; if ($a_allowedips[$_GET['id']]) { $ipent = $a_allowedips[$_GET['id']]; @@ -70,9 +73,9 @@ if ($_GET['act'] == "del") { if (isset($config['captiveportal'][$cpzone]['enable'])) { $mask = (!empty($ipent['sn'])) ? $ipent['sn'] : 32; - $ipfw = pfSense_ipfw_getTablestats($cpzone, 3, $ipent['ip'], $mask); - pfSense_ipfw_Tableaction($cpzone, IP_FW_TABLE_XDEL, 3, $ipent['ip'], $mask); - pfSense_ipfw_Tableaction($cpzone, IP_FW_TABLE_XDEL, 4, $ipent['ip'], $mask); + $ipfw = pfSense_ipfw_getTablestats($cpzoneid, 3, $ipent['ip'], $mask); + pfSense_ipfw_Tableaction($cpzoneid, IP_FW_TABLE_XDEL, 3, $ipent['ip'], $mask); + pfSense_ipfw_Tableaction($cpzoneid, IP_FW_TABLE_XDEL, 4, $ipent['ip'], $mask); if (is_array($ipfw)) { captiveportal_free_dn_ruleno($ipfw['dnpipe']); diff --git a/usr/local/www/status_captiveportal.php b/usr/local/www/status_captiveportal.php index 0c279c3..06a3885 100644 --- a/usr/local/www/status_captiveportal.php +++ b/usr/local/www/status_captiveportal.php @@ -50,12 +50,6 @@ $cpzone = $_GET['zone']; if (isset($_POST['zone'])) $cpzone = $_POST['zone']; -if ($_GET['act'] == "del" && !empty($cpzone)) { - captiveportal_disconnect_client($_GET['id']); - header("Location: status_captiveportal.php?zone={$cpzone}"); - exit; -} - $pgtitle = array(gettext("Status: Captive portal")); $shortcut_section = "captiveportal"; @@ -66,6 +60,15 @@ $a_cp =& $config['captiveportal']; if (count($a_cp) == 1) $cpzone = current(array_keys($a_cp)); +if (isset($cpzone) && !empty($cpzone) && isset($a_cp[$cpzone]['zoneid'])) + $cpzoneid = $a_cp[$cpzone]['zoneid']; + +if ($_GET['act'] == "del" && !empty($cpzone) && isset($cpzoneid) && isset($_GET['id'])) { + captiveportal_disconnect_client($_GET['id']); + header("Location: status_captiveportal.php?zone={$cpzone}"); + exit; +} + include("head.inc"); ?> diff --git a/usr/local/www/widgets/widgets/captive_portal_status.widget.php b/usr/local/www/widgets/widgets/captive_portal_status.widget.php index 6c699ab..4726ba1 100644 --- a/usr/local/www/widgets/widgets/captive_portal_status.widget.php +++ b/usr/local/www/widgets/widgets/captive_portal_status.widget.php @@ -47,10 +47,21 @@ require_once("captiveportal.inc"); <?php -if (($_GET['act'] == "del") && (!empty($_GET['zone']))) { - $cpzone = $_GET['zone']; +if (!is_array($config['captiveportal'])) + $config['captiveportal'] = array(); +$a_cp =& $config['captiveportal']; + +$cpzone = $_GET['zone']; +if (isset($_POST['zone'])) + $cpzone = $_POST['zone']; + +if (isset($cpzone) && !empty($cpzone) && isset($a_cp[$cpzone]['zoneid'])) + $cpzoneid = $a_cp[$cpzone]['zoneid']; + +if (($_GET['act'] == "del") && !empty($cpzone) && isset($cpzoneid)) { captiveportal_disconnect_client($_GET['id']); } +unset($cpzone); flush(); @@ -59,10 +70,6 @@ function clientcmp($a, $b) { return strcmp($a[$order], $b[$order]); } -if (!is_array($config['captiveportal'])) - $config['captiveportal'] = array(); -$a_cp =& $config['captiveportal']; - $cpdb_all = array(); foreach ($a_cp as $cpzone => $cp) { |