Skip to main content

Posts

Showing posts with the label MAC

PHP function to get MAC and IP address

PHP function to obtain the machine MAC and IP address. By this function, you will be able to get the physical address of the machine. function getMAC(){ ob_start(); system('ipconfig /all'); $mycom=ob_get_contents(); ob_clean(); $findme = "Physical"; $pmac = strpos($mycom, $findme); $mac=substr($mycom,($pmac+36),17); return $mac; } function getIP(){ $ip=$_SERVER['REMOTE_ADDR']; if (!empty($_SERVER['HTTP_CLIENT_IP'])) { $ip=$_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip=$_SERVER['HTTP_X_FORWARDED_FOR']; } $ips = explode(",", $ip); $ipss=$ips[0]; return $ipss; }