PHP获取MAC地址
|
admin
2012年6月5日 11:54
本文热度 4537
|
获取网卡的MAC地址原码;目前支持WIN/LINUX系统 获取机器网卡的物理(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 编辑过