linux下使用php获取客户端mac地址(注:不是服务器端的) 急…… 望高人指点……

linux下使用php获取客户端mac地址(注:不是服务器端的) 急…… 望高人指点……,第1张

网上找的类。你参考吧。

>

<php

/

获取Mac地址,支持windows,linux

/

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\ipconfigexe";

if (is_file($ipconfig))

@exec($ipconfig  " /all", $this->return_array);

else

@exec($_SERVER["WINDIR"]  "\system\ipconfigexe /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;

>

sybase_connect连上数据库

语法: int sybase_connect(string [servername], string [username], string [password]);

返回值: 整数函数种类: 数据库功能 本函数用来打开与 Sybase 数据库的连接。

参数 servername 为欲连上的数据库服务器名称。

参数 username 及 password 可省略,分别为连接使用的帐号及密码。

使用本函数需注意早点关闭数据库,以减少系统的负担。

连接成功则返回数据库的连接代号,失败返回 false 值。

能!如php获取mac地址:<php

@exec("ipconfig /all",$array);

for($Tmpa;$Tmpa<count($array);$Tmpa++){

if(eregi("Physical",$array[$Tmpa])){

$mac=explode(":",$array[$Tmpa]);

echo $mac[1];

}

}

>

还能获取ip,访问端口,浏览当前页面用户的主机名等信息。至于js我不是很了解,但是也是可以获取和php差不多的信息。

具体的php的实现方法可以看:>

PHP程序可以获取服务器的硬盘序列号、MAC地址这些数据,原理是调用外部命令检测结果,具体方法与系统的类型有关,但是肯定不可能获取浏览者的信息,因为PHP只在服务器上执行。

你的第二段代码获取MAC值,在Windows是成功的,如果你是需要在UNIX下使用,需要根据你的 *** 作系统类型来修改程序代码。

以上就是关于linux下使用php获取客户端mac地址(注:不是服务器端的) 急…… 望高人指点……全部的内容,包括:linux下使用php获取客户端mac地址(注:不是服务器端的) 急…… 望高人指点……、PHP能否获取客户端唯一标识(cpu序列号,mac地址等)、PHP怎么获取本地硬盘ID或者MAC地址,需要下载什么扩展吗等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/9354884.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-27
下一篇2023-04-27

发表评论

登录后才能评论

评论列表(0条)

    保存