PHP获取网卡的MAC地址原码;目前支持WIN/LINUX系统 获取机器网卡的物理(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地址,访客的无法得到。
PHP获取网卡的MAC地址原码;目前支持WIN/LINUX系统 获取机器网卡的物理(MAC)地址的更多相关文章
- 获取网卡的MAC地址原码;目前支持WIN/LINUX系统 获取机器网卡的物理(MAC)地址(服务器端)
<?php class GetMacAddr{ var $return_array = array(); // 返回带有MAC地址的字串数组 var $mac_addr; function Ge ...
- Linux系统获取CPU温度
Linux系统获取CPU温度 摘自:https://jingyan.baidu.com/article/cbf0e500407d072eab289343.html 各位好,本篇将简单介绍如何在不同系列 ...
- java工具类,在Windows,Linux系统获取电脑的MAC地址、本地IP、电脑名
package com.cloudssaas.util; import java.io.BufferedReader; import java.io.IOException; import java. ...
- centos linux系统日常管理复习 CPU物理数逻辑核数,iftop ,iotop ,sar ,ps,netstat ,一网卡多IP,mii-tool 连接,ethtool速率,一个网卡配置多个IP,mii-tool 连接,ethtool速率 ,crontab备份, 第十八节课
centos linux系统日常管理复习 物理CPU和每颗CPU的逻辑核数,uptime ,w,vmstat,iftop ,iotop ,sar ,ps,netstat ,一个网卡配置多个IP,mii ...
- linux系统中重启网卡后网络不通(NetworkManager篇)
一.故障现象 RHEL7.6系统,使用nmcli绑定双网卡后,再使用以下命令重启network服务后主机网络异常,导致无法通过ssh远程登录系统. # systemctl restart networ ...
- linux系统ifconfig中网卡名和网卡配置文件名称不同的解决办法
比如我的配置文件, cd /etc/sysconfig/network-scripts/ifcfg-eth1是这个名称,但是我使用ifconfig显示的信息却是 eth0,很明显这不是我配置文件的名称 ...
- VMware虚拟机克隆Linux系统引起的网卡问题
1. 手动配置静态网卡地址不生效2. 网卡名变成了eth1[root@localhost network-scripts]# ls |grep ifcfg ifcfg-eth0 ifcfg-lo [r ...
- linux 系统获取网络ip, mask, gateway, dns信息小程序
net_util.c #define WIRED_DEV "eth0" #define WIRELESS_DEV ...
- Linux系统的安装(centos的下载地址:http://mirror.symnds.com/distributions/CentOS-vault/6.3/isos/i386/,选择:CentOS-6.3-i386-bin-DVD1.iso 这个下载并进行安装)
1.首先打开虚拟机: 在上面的那个按钮旁有一个下拉的符号,点开后会看到一个进入固件的按钮,直接点击进去. 便会进入这个界面: 在这个界面其实我们不需要该任何的东西,但是我们需要进入boot界面看一眼, ...
随机推荐
- mongodb集群故障转移实践
简介 NOSQL有这些优势: 大数据量,可以通过廉价服务器存储大量的数据,轻松摆脱传统mysql单表存储量级限制. 高扩展性,Nosql去掉了关系数据库的关系型特性,很容易横向扩展,摆脱了以往老是纵向 ...
- 获取Field成员变量类
位于java.lang.reflect.Field包中 getModifiers() 成员变量修饰符(public.private) getName() 成员变量名字 getType() 成员变量类型 ...
- vs widows服务的调试
1.使用.net 工具安装你开发好的服务 2.服务运行后在Vs中选择调试>附加到进程 4.选择安装好运行的服务,选择附加
- Saltstack windows可视化操作(十四)
在windows下通过Salt-Minion-xxxx.xx.x-AMD64-Setup.exe安装salt-minion的时候,默认是安装并开机启动salt-minion服务.但是如果以服务的方式启 ...
- C# 实现线段的编码裁剪算法(vs2010)
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- Javaweb学习笔记——(二)——————CSS概述,进入JavaScript
day02day01内容回顾 1.html操作思想 **使用标签把要操作的数据包起来,通过修改标签的属性值来是实现标签内数据样式的变化 ***<font size="5"&g ...
- 【文件】java生成PDF文件
package test; import java.awt.Color; import java.io.FileOutputStream; import org.junit.Test; import ...
- Spring+SpringMVC+Mybatis整合(二)
目录结构:
- mono修改配置
当前mono安装目录为:/home/mono,安装成功后修改配置需进入这个路径: cd /home/mono 1.修改TcpBinaryFrameManager.cs文件 cd /home/mono/ ...
- linux 高级字符设备驱动 ioctl操作介绍 例程分析实现【转】
转自:http://my.oschina.net/u/274829/blog/285014 1,ioctl介绍 ioctl控制设备读写数据以及关闭等. 用户空间函数原型:int ioctl(int f ...