php 获取网卡mac
1 <?php 2 /** PHP类 3 获取机器网卡的物理(MAC)地址 4 Download by http://www.codefans.net 5 wwa $Exp 6 **/ 7 class GetMacAddr 8 { 9 var $return_array = array(); // 返回带有MAC地址的字串数组 10 var $mac_addr; 11 12 function GetMacAddr($os_type) 13 { 14 switch ( strtolower($os_type) ) 15 { 16 case "linux": 17 $this->forLinux(); 18 break; 19 case "solaris": 20 break; 21 case "unix": 22 break; 23 case "aix": 24 break; 25 default: 26 $this->forWindows(); 27 break; 28 } 29 30 $temp_array = array(); 31 foreach ( $this->return_array as $value ) 32 { 33 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 ) ) 34 { 35 $this->mac_addr = $temp_array[0]; 36 break; 37 } 38 } 39 unset($temp_array); 40 return $this->mac_addr; 41 } 42 43 function forWindows() 44 { 45 @exec("ipconfig /all", $this->return_array); 46 if ( $this->return_array ) 47 return $this->return_array; 48 else{ 49 $ipconfig = $_SERVER["WINDIR"]."\system32\ipconfig.exe"; 50 if ( is_file($ipconfig) ) 51 @exec($ipconfig." /all", $this->return_array); 52 else 53 @exec($_SERVER["WINDIR"]."\system\ipconfig.exe /all", $this->return_array); 54 return $this->return_array; 55 } 56 } 57 58 function forLinux() 59 { 60 @exec("ifconfig -a", $this->return_array); 61 return $this->return_array; 62 } 63 } 64 ?>
----走出会议室,只有执行力
解决问题是衡量能力的标准。