diff options
author | Renato Botelho <garga@FreeBSD.org> | 2013-09-09 09:09:49 -0300 |
---|---|---|
committer | Renato Botelho <garga@FreeBSD.org> | 2013-09-12 08:44:50 -0300 |
commit | 666f88e0c81465984be477eeb8de4b31d97875fa (patch) | |
tree | 2f11439028a8021c8f90c31fb74405083afb1e3d /usr | |
parent | cfd88fbc838ab0ab08c166ede807e866716fb11f (diff) | |
download | pfsense-666f88e0c81465984be477eeb8de4b31d97875fa.zip pfsense-666f88e0c81465984be477eeb8de4b31d97875fa.tar.gz |
Add actions (block or pass) to Captive Portal passtrumac
Diffstat (limited to 'usr')
-rwxr-xr-x | usr/local/www/services_captiveportal_mac.php | 36 | ||||
-rwxr-xr-x | usr/local/www/services_captiveportal_mac_edit.php | 53 |
2 files changed, 40 insertions, 49 deletions
diff --git a/usr/local/www/services_captiveportal_mac.php b/usr/local/www/services_captiveportal_mac.php index 4803f7e..1d66ff0 100755 --- a/usr/local/www/services_captiveportal_mac.php +++ b/usr/local/www/services_captiveportal_mac.php @@ -102,17 +102,7 @@ if ($_POST) { } } if ($found == true) { - $ruleno = captiveportal_get_ipfw_passthru_ruleno($_POST['delmac']); - if ($ruleno) { - captiveportal_free_ipfw_ruleno($ruleno); - $pipeno = captiveportal_get_dn_passthru_ruleno($_POST['delmac']); - if ($pipeno) - captiveportal_free_dn_ruleno($pipeno); - if (!empty($pipeno)) - mwexec("/sbin/ipfw -x {$cpzone} -q delete {$ruleno}; /sbin/ipfw -x {$cpzone} -q delete " . ++$ruleno . "; /sbin/ipfw -q pipe delete {$pipeno}; /sbin/ipfw -q pipe delete " . (++$pipeno)); - else - mwexec("/sbin/ipfw -x {$cpzone} -q delete {$ruleno}; /sbin/ipfw -x {$cpzone} -q delete " . ++$ruleno); - } + captiveportal_passthrumac_delete_entry($a_passthrumacs[$idx]); unset($a_passthrumacs[$idx]); write_config(); echo gettext("The entry was sucessfully deleted") . "\n"; @@ -126,17 +116,7 @@ if ($_POST) { if ($_GET['act'] == "del") { $a_passthrumacs =& $a_cp[$cpzone]['passthrumac']; if ($a_passthrumacs[$_GET['id']]) { - $ruleno = captiveportal_get_ipfw_passthru_ruleno($a_passthrumacs[$_GET['id']]['mac']); - if ($ruleno) { - captiveportal_free_ipfw_ruleno($ruleno); - $pipeno = captiveportal_get_dn_passthru_ruleno($a_passthrumacs[$_GET['id']]['mac']); - if ($pipeno) - captiveportal_free_dn_ruleno($pipeno); - if (!empty($pipeno)) - mwexec("/sbin/ipfw -x {$cpzone} -q delete {$ruleno}; /sbin/ipfw -x {$cpzone} -q delete " . ++$ruleno . "; /sbin/ipfw -q pipe delete {$pipeno}; /sbin/ipfw -q pipe delete " . (++$pipeno)); - else - mwexec("/sbin/ipfw -x {$cpzone} -q delete {$ruleno}; /sbin/ipfw -x {$cpzone} -q delete " . ++$ruleno); - } + captiveportal_passthrumac_delete_entry($a_passthrumacs[$_GET['id']]); unset($a_passthrumacs[$_GET['id']]); write_config(); header("Location: services_captiveportal_mac.php?zone={$cpzone}"); @@ -172,7 +152,8 @@ include("head.inc"); <td class="tabcont"> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> - <td width="40%" class="listhdrr"><?=gettext("MAC address"); ?></td> + <td width="3%" class="list"></td> + <td width="37%" class="listhdrr"><?=gettext("MAC address"); ?></td> <td width="50%" class="listhdr"><?=gettext("Description"); ?></td> <td width="10%" class="list"></td> </tr> @@ -182,6 +163,9 @@ include("head.inc"); foreach ($a_cp[$cpzone]['passthrumac'] as $mac): ?> <tr ondblclick="document.location='services_captiveportal_mac_edit.php?zone=<?=$cpzone;?>&id=<?=$i;?>'"> + <td valign="middle" nowrap class="list"> + <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_<?=$mac['action'];?>.gif" width="11" height="11" border="0" alt="icon" /> + </td> <td class="listlr"> <?=strtolower($mac['mac']);?> </td> @@ -204,7 +188,7 @@ include("head.inc"); endif; ?> <tr> - <td class="list" colspan="2"> </td> + <td class="list" colspan="3"> </td> <td class="list"> <a href="services_captiveportal_mac_edit.php?zone=<?=$cpzone;?>"> <img src="/themes/<?php echo $g['theme']; ?>/images/icons/icon_plus.gif" title="<?=gettext("add host"); ?>" width="17" height="17" border="0"> @@ -212,10 +196,10 @@ include("head.inc"); </td> </tr> <tr> - <td colspan="2" class="list"> + <td colspan="3" class="list"> <span class="vexpl"> <span class="red"><strong><?=gettext("Note:"); ?><br></strong></span> - <?=gettext("Adding MAC addresses as pass-through MACs allows them access through the captive portal automatically without being taken to the portal page."); ?> + <?=gettext("Adding MAC addresses as 'pass' MACs allows them access through the captive portal automatically without being taken to the portal page."); ?> </span> </td> <td class="list"> </td> diff --git a/usr/local/www/services_captiveportal_mac_edit.php b/usr/local/www/services_captiveportal_mac_edit.php index a27c683..f5d701f 100755 --- a/usr/local/www/services_captiveportal_mac_edit.php +++ b/usr/local/www/services_captiveportal_mac_edit.php @@ -79,6 +79,7 @@ if (!is_array($a_cp[$cpzone]['passthrumac'])) $a_passthrumacs = &$a_cp[$cpzone]['passthrumac']; if (isset($id) && $a_passthrumacs[$id]) { + $pconfig['action'] = $a_passthrumacs[$id]['action']; $pconfig['mac'] = $a_passthrumacs[$id]['mac']; $pconfig['bw_up'] = $a_passthrumacs[$id]['bw_up']; $pconfig['bw_down'] = $a_passthrumacs[$id]['bw_down']; @@ -92,16 +93,15 @@ if ($_POST) { $pconfig = $_POST; /* input validation */ - $reqdfields = explode(" ", "mac"); - $reqdfieldsn = array(gettext("MAC address")); + $reqdfields = explode(" ", "action mac"); + $reqdfieldsn = array(gettext("Action"), gettext("MAC address")); - do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); + do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors); $_POST['mac'] = str_replace("-", ":", $_POST['mac']); - if (($_POST['mac'] && !is_macaddr($_POST['mac']))) { + if (($_POST['mac'] && !is_macaddr($_POST['mac']))) $input_errors[] = sprintf("%s. [%s]", gettext("A valid MAC address must be specified"), $_POST['mac']); - } if ($_POST['bw_up'] && !is_numeric($_POST['bw_up'])) $input_errors[] = gettext("Upload speed needs to be an integer"); if ($_POST['bw_down'] && !is_numeric($_POST['bw_down'])) @@ -112,13 +112,14 @@ if ($_POST) { continue; if ($macent['mac'] == $_POST['mac']){ - $input_errors[] = sprintf("[%s] %s.", $_POST['mac'], gettext("already allowed")); + $input_errors[] = sprintf("[%s] %s.", $_POST['mac'], gettext("already exists")); break; } } if (!$input_errors) { $mac = array(); + $mac['action'] = $_POST['action']; $mac['mac'] = $_POST['mac']; if ($_POST['bw_up']) $mac['bw_up'] = $_POST['bw_up']; @@ -130,10 +131,10 @@ if ($_POST) { $mac['descr'] = $_POST['descr']; if (isset($id) && $a_passthrumacs[$id]) { - $oldmac = $a_passthrumacs[$id]['mac']; + $oldmac = $a_passthrumacs[$id]; $a_passthrumacs[$id] = $mac; } else { - $oldmac = $mac['mac']; + $oldmac = $mac; $a_passthrumacs[] = $mac; } passthrumacs_sort(); @@ -141,21 +142,8 @@ if ($_POST) { write_config(); if (isset($config['captiveportal'][$cpzone]['enable'])) { - $ruleno = captiveportal_get_ipfw_passthru_ruleno($oldmac); - if ($ruleno) { - captiveportal_free_ipfw_ruleno($ruleno); - $pipeno = captiveportal_get_dn_passthru_ruleno($oldmac); - if ($pipeno) { - captiveportal_free_dn_ruleno($pipeno); - $rules .= "pipe delete {$pipeno}\n"; - ++$pipeno; - $rules .= "pipe delete {$pipeno}\n"; - } - $rules = "delete {$ruleno}\n"; - $rules .= "delete " . ++$ruleno . "\n"; - } - - $rules .= captiveportal_passthrumac_configure_entry($mac); + 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"); @@ -177,6 +165,25 @@ include("head.inc"); <td colspan="2" valign="top" class="listtopic"><?=gettext("Edit Pass-through MAC address");?></td> </tr> <tr> + <td width="22%" valign="top" class="vncellreq"><?=gettext("Action"); ?></td> + <td width="78%" class="vtable"> + <select name="action" class="formselect"> +<?php + $actions = explode(" ", "Pass Block"); + foreach ($actions as $action): +?> + <option value="<?=strtolower($action);?>"<?php if (strtolower($action) == strtolower($pconfig['action'])) echo "selected=\"selected\""; ?>> + <?=htmlspecialchars($action);?> + </option> +<?php + endforeach; +?> + </select> + <br> + <span class="vexpl"><?=gettext("Choose what to do with packets coming from this MAC address"); ?>.</span> + </td> + </tr> + <tr> <td width="22%" valign="top" class="vncellreq"><?=gettext("MAC address"); ?></td> <td width="78%" class="vtable"> <?=$mandfldhtml;?><input name="mac" type="text" class="formfld unknown" id="mac" size="17" value="<?=htmlspecialchars($pconfig['mac']);?>"> |