0

I wanna get the mac Address of Server in php. I search and found this question that is helpful: How can I get the MAC and the IP address of a connected client in PHP?

and wrote these codes that is work in my local:

<?php 
$ip=$_SERVER['SERVER_ADDR'];
echo "Server IP: {$ip}<br />
Server Mac: ";
$conf=exec('netstat -ie');
$prots=explode("\n\n",$conf);
if($ip=='127.0.0.1')$ip='192.168.';
foreach($prots as $prot){
    if(strpos($prot,' addr:'.$ip) && preg_match('/(?:\s+)HWaddr(?:\s+)(?P<mac>[a-f0-9\:]+)/',$prot,$match)){
    echo $match['mac'];
    }
}
?>

but in many shared hosts exec,shell_exec,system functions are disabled and these codes not work. do you have any solutions for these kind hosts?

Community
  • 1
  • 1
IVIR3zaM
  • 559
  • 9
  • 22

0 Answers0