background image

 

    

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

 "<br />"; 

 

// 

 

获取客户端

// linux 

$command

 = "arp -a {$_SERVER['REMOTE_ADDR']}"; 

echo

 

$command

echo

 "<br />"; 

$result

=`{

$command

}`;  

 

// windows 

$command

 = "nbtstat -a {$_SERVER['REMOTE_ADDR']}"; 

echo

 

$command

echo

 "<br />"; 

$result

=`{

$command

}`;  

print_r(

$result

);   

?>
获取服务端的逻辑没什么大问题,可能会存在权限问题。
获取客户端的时候,可能会比较慢,arp/nbstat 命令执行会比较慢。
代码如下:
 
<script language="JScript" event="OnCompleted(hResult,pErrorObject, pAsyncContext)"