Add a function to find the mac address on a passthrough mac entry by username(if present) in the <username> tag of the entry.

This commit is contained in:
Ermal 2010-05-28 18:38:41 +00:00
parent 4fc68c5aa4
commit fac13a5eb3
2 changed files with 21 additions and 2 deletions

View File

@ -785,6 +785,18 @@ function captiveportal_passthrumac_configure($lock = false) {
return $rules;
}
function captiveportal_passthrumac_findbyname($username) {
global $config;
if (is_array($config['captiveportal']['passthrumac'])) {
foreach ($config['captiveportal']['passthrumac'] as $macent) {
if ($macent['username'] == $username)
return $macent;
}
}
return NULL;
}
/*
* table (3=IN)/(4=OUT) hold allowed ip's without bw limits
* table (5=IN)/(6=OUT) hold allowed ip's with bw limit.

View File

@ -64,8 +64,15 @@ if ($_POST) {
clear_subsystem_dirty('passthrumac');
}
if ($_POST['delmac'] && $_POST['postafterlogin']) {
if (is_array($a_passthrumacs)) {
if ($_POST['postafterlogin']) {
if (!is_array($a_passthrumacs))
exit;
if ($_POST['username']) {
$mac = captiveportal_passthrumac_findbyname($_POST['username']);
if (!empty($mac))
$_POST['delmac'] = $mac['mac'];
}
if ($_POST['delmac']) {
$found = false;
foreach ($a_passthrumacs as $idx => $macent) {
if ($macent['mac'] == $_POST['delmac']) {