<? PHP
/**
Obtain the physical (MAC) Address of the machine Nic
Wwa $ exp
**/
Class getmacaddr
{
VaR $ return_array = array (); // returns a string array with a MAC address.
VaR $ mac_addr;
Function getmacaddr ($ OS _type)
{
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-9a-f] [0-9a-f] [:-]". "[0-9a-f] [0-9a-f] [:-]". "[0-9a-f] [0-9a-f] [:-]". "[0-9a-f] [0-9a-f] [:-]". "[0-9a-f] [0-9a-f] [:-]". "[0-9a-f] [0-9a-f]/I", $ value, $ temp_array ))
{
$ This-> mac_addr = $ temp_array [0];
Break;
}
}
Unset ($ temp_array );
Return $ this-> mac_addr;
}
 
Function forwindows ()
{
@ Exec ("ipconfig/All", $ this-> return_array );
If ($ this-> return_array)
Return $ this-> return_array;
Else {
$ Ipconfig = $ _ server ["WINDIR"]. "/system32/ipconfig.exe ";
If (is_file ($ ipconfig ))
@ Exec ($ ipconfig. "/All", $ this-> return_array );
Else
@ Exec ($ _ server ["WINDIR"]. "/system/ipconfig.exe/All", $ this-> return_array );
Return $ this-> return_array;
}
}
 
Function forlinux ()
{
@ Exec ("ifconfig-a", $ this-> return_array );
Return $ this-> return_array;
}
}
?>
<?
// $ MAC = new getmacaddr (php_ OS );
// Echo $ Mac-> mac_addr;
?>