Phpjs obtains the implementation code of the client's mac address. Don't talk nonsense. just go to the code! Copy the code as follows :? PhpclassMacAddr {public $ returnArrayarray (); public $ macAddr; function _ contruct ($ OS _typenull) {if (is_nu doesn't talk much about it, just go to the code!
The code is as follows:
Class MacAddr
{
Public $ returnArray = array ();
Public $ macAddr;
Function _ contruct ($ OS _type = null ){
If (is_null ($ OS _type) $ OS _type = PHP_ OS;
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-> returnArray 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-> macAddr = $ temp_array [0];
Break;
}
}
Unset ($ temp_array );
Return $ this-> macAddr;
}
Function forWindows (){
@ Exec ("ipconfig/all", $ this-> returnArray );
If ($ this-> returnArray)
Return $ this-> returnArray;
Else {
$ Ipconfig = $ _ SERVER ["WINDIR"]. "system32ipconfig.exe ";
If (is_file ($ ipconfig ))
@ Exec ($ ipconfig. "/all", $ this-> returnArray );
Else
@ Exec ($ _ SERVER ["WINDIR"]. "systemipconfig.exe/all", $ this-> returnArray );
Return $ this-> returnArray;
}
}
Function forLinux (){
@ Exec ("ifconfig-a", $ this-> returnArray );
Return $ this-> returnArray;
}
}
$ Mac = new MacAddr (PHP_ OS );
Echo $ mac-> macAddr;
Echo"
";
// Obtain the client
// Linux
$ Command = "arp-a {$ _ SERVER ['remote _ ADDR ']}";
Echo $ command;
Echo"
";
$ Result = '{$ command }';
// Windows
$ Command = "nbtstat-a {$ _ SERVER ['remote _ ADDR ']}";
Echo $ command;
Echo"
";
$ Result = '{$ command }';
Print_r ($ result );
?>
There is no major problem in obtaining the server logic, and there may be permission issues.
When obtaining the client, it may be slow, and arp/nbstat command execution will be slow.
The code is as follows: