diff options
-rw-r--r-- | etc/inc/captiveportal.inc | 16 | ||||
-rwxr-xr-x | usr/local/www/services_captiveportal_mac.php | 12 | ||||
-rwxr-xr-x | usr/local/www/services_captiveportal_mac_edit.php | 4 |
3 files changed, 19 insertions, 13 deletions
diff --git a/etc/inc/captiveportal.inc b/etc/inc/captiveportal.inc index da55c89..d76f5a0 100644 --- a/etc/inc/captiveportal.inc +++ b/etc/inc/captiveportal.inc @@ -959,31 +959,29 @@ function captiveportal_passthrumac_configure_entry($macent) { } function captiveportal_passthrumac_delete_entry($macent) { - global $cpzone; + $rules = ""; $ruleno = captiveportal_get_ipfw_passthru_ruleno($macent['mac']); if (!$ruleno) - return false; + return $rules; - $cmd = "/sbin/ipfw -x {$cpzone} delete {$ruleno}"; + $rules .= "delete {$ruleno}\n"; captiveportal_free_ipfw_ruleno($ruleno, ($macent['action'] == 'block')); if ($macent['action'] == 'pass') { - $cmd .= "; /sbin/ipfw -x {$cpzone} delete " . ++$ruleno; + $rules .= "delete " . ++$ruleno . "\n"; $pipeno = captiveportal_get_dn_passthru_ruleno($macent['mac']); if (!empty($pipeno)) { captiveportal_free_dn_ruleno($pipeno); - $cmd .= "; /sbin/ipfw -x {$cpzone} pipe delete " . $pipeno; - $cmd .= "; /sbin/ipfw -x {$cpzone} pipe delete " . ++$pipeno; + $rules .= "pipe delete " . $pipeno . "\n"; + $rules .= "pipe delete " . ++$pipeno . "\n"; } } - mwexec($cmd); - - return true; + return $rules; } function captiveportal_passthrumac_configure($lock = false) { diff --git a/usr/local/www/services_captiveportal_mac.php b/usr/local/www/services_captiveportal_mac.php index 08e62d5..68084a6 100755 --- a/usr/local/www/services_captiveportal_mac.php +++ b/usr/local/www/services_captiveportal_mac.php @@ -102,7 +102,11 @@ if ($_POST) { } } if ($found == true) { - captiveportal_passthrumac_delete_entry($a_passthrumacs[$idx]); + $rules = captiveportal_passthrumac_delete_entry($a_passthrumacs[$idx]); + $uniqid = uniqid("{$cpzone}_mac"); + file_put_contents("{$g['tmp_path']}/{$uniqid}_tmp", $rules); + mwexec("/sbin/ipfw -x {$cpzone} -q {$g['tmp_path']}/{$uniqid}_tmp"); + @unlink("{$g['tmp_path']}/{$uniqid}_tmp"); unset($a_passthrumacs[$idx]); write_config(); echo gettext("The entry was sucessfully deleted") . "\n"; @@ -116,7 +120,11 @@ if ($_POST) { if ($_GET['act'] == "del") { $a_passthrumacs =& $a_cp[$cpzone]['passthrumac']; if ($a_passthrumacs[$_GET['id']]) { - captiveportal_passthrumac_delete_entry($a_passthrumacs[$_GET['id']]); + $rules = captiveportal_passthrumac_delete_entry($a_passthrumacs[$_GET['id']]); + $uniqid = uniqid("{$cpzone}_mac"); + file_put_contents("{$g['tmp_path']}/{$uniqid}_tmp", $rules); + mwexec("/sbin/ipfw -x {$cpzone} -q {$g['tmp_path']}/{$uniqid}_tmp"); + @unlink("{$g['tmp_path']}/{$uniqid}_tmp"); unset($a_passthrumacs[$_GET['id']]); write_config(); header("Location: services_captiveportal_mac.php?zone={$cpzone}"); diff --git a/usr/local/www/services_captiveportal_mac_edit.php b/usr/local/www/services_captiveportal_mac_edit.php index b4c1ec8..095e36d 100755 --- a/usr/local/www/services_captiveportal_mac_edit.php +++ b/usr/local/www/services_captiveportal_mac_edit.php @@ -142,8 +142,8 @@ if ($_POST) { write_config(); if (isset($config['captiveportal'][$cpzone]['enable'])) { - captiveportal_passthrumac_delete_entry($mac); - $rules = captiveportal_passthrumac_configure_entry($mac); + $rules = captiveportal_passthrumac_delete_entry($mac); + $rules .= captiveportal_passthrumac_configure_entry($mac); $uniqid = uniqid("{$cpzone}_macedit"); file_put_contents("{$g['tmp_path']}/{$uniqid}_tmp", $rules); mwexec("/sbin/ipfw -x {$cpzone} -q {$g['tmp_path']}/{$uniqid}_tmp"); |