mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-14 08:34:39 +00:00
captive portal: fix ip_to_mac()
This commit is contained in:
parent
a20b587660
commit
0518c44151
@ -90,22 +90,25 @@ $passthrumac = isset($cpcfg['passthrumacadd']);
|
||||
function ip_to_mac($addr)
|
||||
{
|
||||
$cmd = '/usr/sbin/arp -n ' . $addr;
|
||||
$ret = false;
|
||||
|
||||
exec($cmd, $out, $ret);
|
||||
if ($ret) {
|
||||
log_error('The command `' . $cmd . '\' failed to execute');
|
||||
} else {
|
||||
$mac = explode(' ', $out);
|
||||
$mac = explode(' ', $out[0]);
|
||||
if (isset($mac[3])) {
|
||||
return array('macaddr' => $mac[3]);
|
||||
$ret = $mac[3];
|
||||
}
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/* find MAC address for client */
|
||||
if ($macfilter || $passthrumac) {
|
||||
$tmpres = ip_to_mac($clientip);
|
||||
if (!is_array($tmpres)) {
|
||||
if (!$tmpres) {
|
||||
/* unable to find MAC address - shouldn't happen! - bail out */
|
||||
captiveportal_logportalauth("unauthenticated","noclientmac",$clientip,"ERROR");
|
||||
echo "An error occurred. Please check the system logs for more information.";
|
||||
@ -113,7 +116,7 @@ if ($macfilter || $passthrumac) {
|
||||
ob_flush();
|
||||
return;
|
||||
}
|
||||
$clientmac = $tmpres['macaddr'];
|
||||
$clientmac = $tmpres;
|
||||
unset($tmpres);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user