獲取網(wǎng)卡的MAC地址原碼;目前支持WIN/LINUX系統(tǒng) 獲取機器網(wǎng)卡的物理(MAC)地址
09 |
var $return_array = array (); |
12 |
function GetMacAddr( $os_type ){ |
13 |
switch ( strtolower ( $os_type ) ){ |
30 |
$temp_array = array (); |
31 |
foreach ( $this ->return_array as $value ){ |
34 |
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 , |
36 |
$this ->mac_addr = $temp_array [0]; |
42 |
return $this ->mac_addr; |
46 |
function forWindows(){ |
47 |
@ exec ( "ipconfig /all" , $this ->return_array); |
48 |
if ( $this ->return_array ) |
49 |
return $this ->return_array; |
51 |
$ipconfig = $_SERVER [ "WINDIR" ]. "\system32\ipconfig.exe" ; |
52 |
if ( is_file ( $ipconfig ) ) |
53 |
@ exec ( $ipconfig . " /all" , $this ->return_array); |
55 |
@ exec ( $_SERVER [ "WINDIR" ]. "\system\ipconfig.exe /all" , $this ->return_array); |
56 |
return $this ->return_array; |
63 |
@ exec ( "ifconfig -a" , $this ->return_array); |
64 |
return $this ->return_array; |
該文章在 2012/6/5 11:54:51 編輯過