php获取网卡MAC地址源码
<?php
/**
获取网卡的MAC地址原码;目前支持WIN/LINUX系统
获取机器网卡的物理(MAC)地址
**/ class GetMacAddr{
var $return_array = array(); // 返回带有MAC地址的字串数组
var $mac_addr;
function GetMacAddr($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 GetMacAddr(PHP_OS);
//echo $mac->mac_addr; // $mac = new GetMacAddr(PHP_OS);
// $macAddr = $mac->mac_addr;
// $arr = $mac->forWindows();
?>
php获取网卡MAC地址源码的更多相关文章
- Python 获取 网卡 MAC 地址
/*********************************************************************** * Python 获取 网卡 MAC 地址 * 说明: ...
- 使用WinPcap获取网卡MAC地址
关键字:WinPcap 网卡 MAC地址 作者:txw1958 在WpdPack_4_1_2\WpdPack\Examples-remote\PacketDriver\GetMacAddress\目录 ...
- 转: 通过WMI获取网卡MAC地址、硬盘序列号、主板序列号、CPU ID、BIOS序列号
最近由于项目的需要,需要在程序中获取机器的硬盘序列号和MAC地址等信息,在C#下,可以很容易的获得这些信息,但是在C++程序中感觉比较麻烦.经过百度,发现很多大虾都是通过WMI来获取这些硬件信息的,网 ...
- windows平台下获取网卡MAC地址、硬盘序列号、主板序列号、CPU ID、BIOS序列号
转自http://blog.csdn.net/jhqin/article/details/5548656,如有侵权,请联系本人删除,谢谢!! 头文件:WMI_DeviceQuery.h /* ---- ...
- (转)通过WMI获取网卡MAC地址、硬盘序列号、主板序列号、CPU ID、BIOS序列号
最近由于项目的需要,需要在程序中获取机器的硬盘序列号和MAC地址等信息,在C#下,可以很容易的获得这些信息,但是在C++程序中感觉比较麻烦.经过百度,发现很多大虾都是通过WMI来获取这些硬件信息的,网 ...
- 通过WMI获取网卡MAC地址、硬盘序列号、主板序列号、CPU ID、BIOS序列号
转载:https://www.cnblogs.com/tlduck/p/5132738.html #define _WIN32_DCOM #include<iostream> #inclu ...
- matlab 获取网卡MAC地址
输入命令 [sta,MACres] = dos('getmac'); 其中MACres 存储的信息即为网卡的 相关信息. 如果想判断读取的网卡信息是否有指定信息可以如下输入 USER1 = strf ...
- 获取CPU序列号、网卡MAC地址、硬盘序列号
<pre name="code" class="csharp"> using System; using System.Collections; u ...
- PHP获取网卡的MAC地址原码;目前支持WIN/LINUX系统 获取机器网卡的物理(MAC)地址
声明转换于其它博客当中的. <?php /** 获取网卡的MAC地址原码:目前支持WIN/LINUX系统 获取机器网卡的物理(MAC)地址 **/ class GetMacAddr{ var $ ...
随机推荐
- gradle
http://examples.javacodegeeks.com/core-java/gradle/gradle-hello-world-tutorial/
- Cnblogs自定义皮肤css样式-星空观测者
不知不觉来Cnblogs也这么久了,然而Blogs提供的主题还是依旧那么复古,总觉得阅读起来难免枯燥,虽然我认为做技术不可以太过浮躁,但是一个美观的主题终究是吸引人眼的第一要素. 毕竟这么久了,在博客 ...
- css-关于位置
当你设置一个你想要相对的模块为relative 你这个模块为absolute 则你的这个absolute会相对relative的那个模块进行移动.
- 编译osgEarth2.8+VS2013+CMake3.4.0在Release版本的问题
1>LINK : fatal error LNK1181: 无法打开输入文件"optimized.lib" 可以到http://forum.osgearth.org搜索相关帖 ...
- squid 2.7 配置与安装
1.准备安装包 2.准备编译环境 yum -y install gcc 3.编译安装squid ./configure \--prefix=/data/squid \--disable-interna ...
- Range Sum Query 2D - Immutable
https://leetcode.com/problems/range-sum-query-2d-immutable/ 条件说sumRegion 会调很多次,如果每次都用双for 循环去累加的话就有太 ...
- 函数式编程之柯里化(curry)
函数式编程curry的概念: 只传递给函数一部分参数来调用函数,然后返回一个函数去处理剩下的参数. var add = function(x) { return function(y) { retur ...
- 前端弹出层框架layer
http://www.layui.com/doc/modules/layer.html#layer.confirm
- ViewPager 简单实现左右无限滑动.
只需在在适配器中将getCount 给一个较大的值, 然后将currentItem 设为值的一半 就可以伪实现 无限循环. private static final int PAGE_COUNT = ...
- RadioGroup 和 ViewPager 绑定 实现切换
package com.jereh.helloworld.activity.day12; import android.app.Activity; import android.os.Bundle; ...