<? PHP/
* *
access to network card MAC address of the original code; Currently supported Windows/LINUX system
get the machine card physical (MAC) address
/
* * class GetMacAddr {
var $return_array=array ();//returns an array of strings with the MAC address
var $mac_addr;
function GetMacAddr ($os_type) {
the switch (strtolower ($os_type)) {
case "Linux" :
$this - >ForLinux ();
break;
case "solaris" :
break;
case "Unix" :
break;
case "aix" :
break;
default:
$this - >ForWindows ();
break;

} $temp_array=array ();
foreach ($this - >return_array as $value) {
if (
preg_match ("/[0-9 a - f] [0-9] a - f [-] ". "[0-9 a - f] [0-9] a - f [-]". "[0-9 a - f] [0-9] a - f [-]". "[0-9 a - f] [0-9] a - f [-]". "[0-9 a - f] [0-9] a - f [-]". "[0-9 a - f] [0-9] a - f/I", $value,
$temp_array)) {
$this - >Mac_addr=$temp_array [0].
break;

}}
the unset ($temp_array);
return $this - >Mac_addr;

} function forWindows () {
@ the exec (" ipconfig/all ", $this - >return_array);
if ($this - >return_array)
return $this - >Return_array;
the else {
$ipconfig=$_SERVER [r]. "WINDIR" "\ system32 \ ipconfig exe";
if (is_file ($ipconfig))
@ the exec ($ipconfig. "/", $this - >return_array);
the else
@ the exec ($_SERVER [" WINDIR "] "exe \ system \ ipconfig/all", $this - >return_array);
return $this - >Return_array;

}}
function forLinux () {
@ the exec (" ifconfig -a ", $this - >return_array);
return $this - >Return_array;

}}
//method using the
//$MAC=new GetMacAddr (PHP_OS);
//echo $MAC - >Mac_addr;
? >

you might be interested in the article:

  • for the client network card MAC address and IP address implementation JS code
  • Java small example through IP access to the client MAC address
  • use JS get IE client IP and MAC can't seem to
  • PHP in Intranet user's MAC address (WINDOWS/Linux) the implementation of the code
  • PHP through the exec computer under a unique identifier (CPU, network card MAC address)
  • PHP/JS to get the client MAC address the implementation of the code


This concludes the body part