最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

php獲取服務器端mac和客戶端mac的地址支持WIN/LINUX

 更新時間:2014年05月15日 09:36:10   作者:  
這篇文章主要介紹了php獲取服務器端mac和客戶端mac地址的方法,需要的朋友可以參考下
獲取服務器mac
復制代碼 代碼如下:

<?php
/**
獲取網(wǎng)卡的MAC地址原碼;目前支持WIN/LINUX系統(tǒng)
獲取機器網(wǎng)卡的物理(MAC)地址
**/
class GetmacAddr{
var $result = array(); // 返回帶有MAC地址的字串數(shù)組
var $macAddr;
/*構造*/
function __construct($osType){
switch ( strtolower($osType) ){
case "unix": break;
case "solaris": break;
case "aix": break;
case "linux": {
$this->for_linux_os();
}break;
default: {
$this->for_windows_os();
}break;
}
$temp_array = array();
foreach($this->result 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 ) ){
$this->macAddr = $temp_array[0];
break;
}
}
unset($temp_array);
return $this->macAddr;
}
/*linux系統(tǒng)中獲取方法*/
function for_linux_os(){
@exec("ifconfig -a", $this->result);
return $this->result;
}
/*win系統(tǒng)中的獲取方法*/
function for_windows_os(){
@exec("ipconfig /all", $this->result);
if ( $this->result ) {
return $this->result;
} else {
$ipconfig = $_SERVER["WINDIR"]."\system32\ipconfig.exe";
if(is_file($ipconfig)) {
@exec($ipconfig." /all", $this->result);
} else {
@exec($_SERVER["WINDIR"]."\system\ipconfig.exe /all", $this->result);
return $this->result;
}
}
}
}
?>

獲取客戶端mac地址:
復制代碼 代碼如下:

@exec("arp -a",$array); //執(zhí)行arp -a命令,結果放到數(shù)組$array中
foreach($array as $value){
//匹配結果放到數(shù)組$mac_array
if(strpos($value,$_SERVER["REMOTE_ADDR"]) && preg_match("/(:?[0-9A-F]{2}[:-]){5}[0-9A-F]{2}/i",$value,$mac_array)){
$mac = $mac_array[0];
break;
}
}
echo $mac;

注:客戶端獲取的mac不能在本機測試,只能用別的電腦訪問才能輸出

相關文章

最新評論

博罗县| 宝应县| 西平县| 扎鲁特旗| 嘉峪关市| 昭苏县| 毕节市| 弋阳县| 成安县| 明光市| 竹北市| 蓝山县| 冀州市| 射阳县| 罗江县| 麦盖提县| 吴江市| 南澳县| 广安市| 故城县| 莱州市| 浦北县| 祥云县| 新竹县| 邯郸县| 兰坪| 新源县| 白山市| 神池县| 盱眙县| 迭部县| 隆回县| 开封市| 巨野县| 绥中县| 敦煌市| 江油市| 栾川县| 塘沽区| 都江堰市| 保靖县|