-
-
Save taiar/4732398 to your computer and use it in GitHub Desktop.
<?php | |
/* | |
* Getting MAC Address using PHP | |
* Md. Nazmul Basher | |
*/ | |
ob_start(); // Turn on output buffering | |
system('ipconfig /all'); //Execute external program to display output | |
$mycom=ob_get_contents(); // Capture the output into a variable | |
ob_clean(); // Clean (erase) the output buffer | |
$findme = "Physical"; | |
$pmac = strpos($mycom, $findme); // Find the position of Physical text | |
$mac=substr($mycom,($pmac+36),17); // Get Physical Address | |
echo $mac; |
Working Fine...
Hi Taiar,
All the time, its returning the hosted server physical address but not the client it was initiated..
Do you have any idea on how to get the client physical address
This works:
<?php $ip_address = $_SERVER['REMOTE_ADDR']; $mac =
arp $ip_address | cut -d " " -f4; echo "<br />Seu Mac é: "; echo $mac; ?>
I thought I would just pitch in on this for anyone else looking for a MAC address solution. It's only possible on LAN(Local) to get a clients MAC address and you have to be on the same subnet. This will not work over the WAN (Internet). MAC address are part of LAN and is not transmitted over WAN so server side technology will not help, there is a Javascript solution available if you want to go down that route... Hope this helps someone down the line.
I thought I would just pitch in on this for anyone else looking for a MAC address solution. It's only possible on LAN(Local) to get a clients MAC address and you have to be on the same subnet. This will not work over the WAN (Internet). MAC address are part of LAN and is not transmitted over WAN so server side technology will not help, there is a Javascript solution available if you want to go down that route... Hope this helps someone down the line.
Agree, i found some solution if u want to get local ip address of your user, you can refer to this link https://stackoverflow.com/questions/20194722/can-you-get-a-users-local-lan-ip-address-via-javascript
Thanks
not working in Azure Web app PHP. any suggestions?
This is meant to get the physical address on the host server.
Hi Taiar,
All the time, its returning the hosted server physical address but not the client it was initiated..
Do you have any idea on how to get the client physical address
This is meant to get the physical address on the host server.
not working in Azure Web app PHP. any suggestions?