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();
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)){
unset($temp_array);
return $this->macAddr; ($this->returnArray)
return $this->returnArray;
else{
$ipconfig = $_SERVER["WINDIR"]."system32ipconfig.exe";
If (is_file ($ipconfig))
@exec($ipconfig." /all", $this->returnArray); all ", $ this- & gt; returnarray);
return $ this-& gt; reTurnArray;
}
}
Function forlinux () {
@exec (" iFconfig-" a", $this->returnArray);
returnArray;
}
}
$mac = new MacAddr(PHP_OS);
echo $ mac->macAddr;
echo "
";
// Get 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 big problem in getting the server-side logic, but there may be permission issues.
When obtaining the client, it may be slow, and the execution of the arp/nbstat command will be slow.
Copy code The code is as follows:
http://www.bkjia.com/PHPjc/328054.html
www.bkjia.com
truehttp: //www.bkjia.com/PHPjc/328054.htmlTechArticle Without further ado, let’s get straight to the code! Copy the code The code is as follows: ?php class MacAddr { public $returnArray = array(); public $macAddr; function __contruct($os_type=null){ if(is_nu...