diff options
-rw-r--r-- | src/usr/local/www/services_dhcp_edit.php | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/usr/local/www/services_dhcp_edit.php b/src/usr/local/www/services_dhcp_edit.php index c347630..9b5df91 100644 --- a/src/usr/local/www/services_dhcp_edit.php +++ b/src/usr/local/www/services_dhcp_edit.php @@ -385,8 +385,19 @@ if ($_POST) { // Get our MAC address $ip = $_SERVER['REMOTE_ADDR']; -$mymac = `/usr/sbin/arp -an | grep '('{$ip}')' | cut -d" " -f4`; -$mymac = str_replace("\n", "", $mymac); + +switch (is_ipaddr($ip)) { + case 4: + $mymac = exec("/usr/sbin/arp -an | grep '('{$ip}')' | head -n 1 | cut -d' ' -f4"); + $mymac = str_replace("\n", "", $mymac); + break; + case 6: + $mymac = exec("/usr/sbin/ndp -na | /usr/bin/grep '{$ip}' | /usr/bin/head -n 1 | /usr/bin/awk '{ print $2 }'"); + $mymac = str_replace("\n", "", $mymac); + break; + default: + unset($mymac); +} $iflist = get_configured_interface_with_descr(); $ifname = ''; @@ -415,7 +426,6 @@ $macaddress = new Form_Input( $pconfig['mac'], ['placeholder' => 'xx:xx:xx:xx:xx:xx'] ); - $btnmymac = new Form_Button( 'btnmymac', 'Copy My MAC', @@ -424,10 +434,11 @@ $btnmymac = new Form_Button( ); $btnmymac->setAttribute('type','button')->removeClass('btn-primary')->addClass('btn-success btn-sm'); - $group = new Form_Group('MAC Address'); $group->add($macaddress); -$group->add($btnmymac); +if (!empty($mymac)) { + $group->add($btnmymac); +} $group->setHelp('MAC address (6 hex octets separated by colons)'); $section->add($group); |