I want to get a mac address from a client's computer which are using my web application.
I did exec('netstat -ie');
but I can't get anything and I want to know the right way.
I want to get a mac address from a client's computer which are using my web application.
I did exec('netstat -ie');
but I can't get anything and I want to know the right way.
Try using the following:
$ipAddress=$_SERVER['REMOTE_ADDR'];
$arp=`arp -a $ipAddress`;
$output = shell_exec($arp);
Keep in mind this only works with clients on the same ethernet segment
$ipAddress=$_SERVER['REMOTE_ADDR'];
$macAddr=false;
#run the external command, break output into lines
$arp=`arp -a $ipAddress`;
$lines=explode("\n", $arp);
#look for the output line describing our IP address
foreach($lines as $line)
{
$cols=preg_split('/\s+/', trim($line));
if ($cols[0]==$ipAddress)
{
$macAddr=$cols[1];
}
}