本节分享的php代码,主要功能:
获取机器网卡的物理(MAC)地址。
代码:
复制代码 代码如下:
<?php
/**
* 获取机器网卡的物理(MAC)地址
* 目前支持WIN/LINUX系统
**/
class MacAddInfo {
var $return_array = array (); // 返回带有MAC地址的字串数组
var $mac_addr;
function MacAddInfo($os_type) {
switch (strtolower ( $os_type )) {
case "linux" :
$this->forLinux ();
break;
case "solaris" :
break;
case "unix" :
break;
case "aix" :
break;
default :
$this->forWindows ();
break;
}
$temp_array = array ();
foreach ( $this->return_array 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->mac_addr = $temp_array [0];
break;
}
}
unset ( $temp_array );
return $this->mac_addr;
}
function forWindows() {
@exec ( "ipconfig /all", $this->return_array );
if ($this->return_array)
return $this->return_array;
else {
$ipconfig = $_SERVER ["WINDIR"] . "/system32/ipconfig.exe";
if (is_file ( $ipconfig ))
@exec ( $ipconfig . " /all", $this->return_array );
else
@exec ( $_SERVER ["WINDIR"] . "/system/ipconfig.exe /all", $this->return_array );
return $this->return_array;
}
}
function forLinux() {
@exec ( "ifconfig -a", $this->return_array );
return $this->return_array;
}
}
//调用示例
//$mac = new MacAddInfo(PHP_OS);
//echo $mac->mac_addr;
?>
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
更新日志
- 梁静茹.2007-崇拜【相信音乐】【WAV+CUE】
- 金佩姗.1997-喜新恋旧【现代派】【WAV+CUE】
- 梁静茹.2007-崇拜【相信音乐】【WAV+CUE】
- 陈晓东.1997-在乎你感受(EP)【宝丽金】【WAV+CUE】
- 纯音入心系列纯音乐《云水禅心 - 佛曲古筝礼赞1-2》1CD[MP3][190MB]
- 纯音入心系列纯音乐《精心传神-古筝》1CD[MP3][363.1MB]
- 纯音入心系列纯音乐《琴瑟古风之古筝精选曲》1CD[MP3][354.1MB]
- 陈晓东.1997-在乎你感受(EP)【宝丽金】【WAV+CUE】
- 黄凯芹.1990-给你留念(2024环球MQA-UHQCD限量版)【环球】【WAV+CUE】
- 张学友.1999-有个人【宝丽金】【WAV+CUE】
- 纯音入心系列纯音乐《古筝佛曲》1CD[MP3][411.1MB]
- 纯音入心系列纯音乐《古筝世界名曲》1CD[MP3][38.9MB]
- 纯音入心系列纯音乐《古筝新奏-菩提妙音》1CD[MP3][112.3MB]
- 陈思安.1993-怀念福建金曲5CD【歌丽美】【WAV+CUE】
- 张学友.1999-有个人【宝丽金】【WAV+CUE】