php能读取访问者网卡的MAC地址吗? 要看你所谓的访问者使用的是什么机器了,如果就是你的WEB主机,那是可以地。如果不是的话,那是不行地 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 不好意思,看错了,只能确定服务器的网卡地址<?php echo "<pre>"; $cmd="ipconfig -all"; //$cmd=$_GET['cmd']; $cmd=StripSlashes($cmd); echo "".$cmd.""; $cc=system("$cmd"); $dd=explode("Physical Address",$cc); echo $cc; echo "</pre>"; ?> 问楼上的,网卡地址不就是MAC地址吗?~就是那个六字段(两位一段)的十六进制数啊~~ 我知道啊,但楼主想问的是客户端的MAC地址,我得到的是服务器MAC地址 在一个子网中,服务器还是可以通过各种手段取的客户机的MAC。如果不在同一子网内,除非客户机主动提供MAC信息,否则根本取不到客户机的MAC。这个是TCP/IP协议的限制。 class NtMacAddress { /** * Public method getMach. Returns client or server mac-address if is readable. * * NtMacAddress->getMac( $what:String ):String * * @param String Options: 'client' or 'server' * @return String Mac-Address if is readable, 'not found' otherwise */ function getMac( $what ) { $what = &strtolower( $what ); if( $what == 'server' ) { return $this->__server_macaddress(); } elseif( $what == 'client' ) { return $this->__client_macaddress(); } else { return '\'client\' or \'server\' ?'; } } /** * Private method __server_macaddress. Returns server mac-address if is readable. * * NtMacAddress->__server_macaddress():String * * @param no * @return String Server Mac-Address if is readable, 'not found' otherwise */ function __server_macaddress() { $output = Array(); exec( 'netstat -r', $output ); for( $a = 0, $b = &count( $output ); $a < $b; $a++ ) { if( preg_match( "/(?i)([a-z0-9]{2} ){6}/", $output[$a] ) == true ) { $macaddress = &$output[$a]; $uniquekey = &md5( $macaddress ); $output[$a] = &preg_replace( "/(?i)([^a-z0-9]*?)([a-z0-9]{2} ){6}/i", "\\1 {$uniquekey} ", $output[$a] ); $output[$a] = &explode( " {$uniquekey} ", $output[$a] ); $uniquekey = Array( trim( $output[$a][0] ), trim( $output[$a][1] ) ); $macaddress = &str_replace( $uniquekey, "", $macaddress ); return trim( $macaddress ); } } return 'not found'; } /** * Private method __client_macaddress. Returns client mac-address if is readable. * * NtMacAddress->__client_macaddress():String * * @param no * @return String Client Mac-Address if is readable, 'not found' otherwise */ function __client_macaddress() { $output = Array(); exec( 'nbtstat -A '.$_SERVER['REMOTE_ADDR'], $output ); $reg = '([a-f0-9]{2}\-){5}([a-f0-9]{2})'; for( $a = 0, $b = &count( $output ); $a < $b; $a++ ) { if( preg_match( "/(?i){$reg}/", $output[$a] ) == true ) { return preg_replace( "/(?iU)(.+)({$reg})(.*)/", "\\2", $output[$a] ); } } return 'not found'; }}限windows2000下运行,在win98和me下没试过...给分吧... MAC地址根本就不可能穿透路由器不可能的啦,楼主!不过,要是处在同一个网段内,也就是可以使用arp协议,可以得到 有没有人使用thinkphp的,有个问题请教下 php如何调用webservice, 中文文件名不可访问 关于 数组插入带键的项 PHP中的session超时如何设置呀,即是一个用户在一段时间内没有操作的话,就会自动提示超时,返回重新登陆,这个功能怎么搞?请高手帮帮我,谢谢 >>>> 表单内重名的input,能都得到它们的值吗 什么是工厂模式(factory)? 如何打开服务器上的word文挡,编辑后保存到服务器上,急救!! 把字符串转化成代码执行 mysqli异步查询mysqli_async不可用 在搜索结果中如何显示带关键字的那段字节 关于Zend调试的问题~
echo "<pre>";
$cmd="ipconfig -all";
//$cmd=$_GET['cmd'];
$cmd=StripSlashes($cmd);
echo "".$cmd.""; $cc=system("$cmd");
$dd=explode("Physical Address",$cc);
echo $cc;
echo "</pre>";
?>
* Public method getMach. Returns client or server mac-address if is readable.
*
* NtMacAddress->getMac( $what:String ):String
*
* @param String Options: 'client' or 'server'
* @return String Mac-Address if is readable, 'not found' otherwise
*/
function getMac( $what ) {
$what = &strtolower( $what );
if( $what == 'server' ) {
return $this->__server_macaddress();
}
elseif( $what == 'client' ) {
return $this->__client_macaddress();
}
else {
return '\'client\' or \'server\' ?';
}
} /**
* Private method __server_macaddress. Returns server mac-address if is readable.
*
* NtMacAddress->__server_macaddress():String
*
* @param no
* @return String Server Mac-Address if is readable, 'not found' otherwise
*/
function __server_macaddress() {
$output = Array();
exec( 'netstat -r', $output );
for( $a = 0, $b = &count( $output ); $a < $b; $a++ ) {
if( preg_match( "/(?i)([a-z0-9]{2} ){6}/", $output[$a] ) == true ) {
$macaddress = &$output[$a];
$uniquekey = &md5( $macaddress );
$output[$a] = &preg_replace( "/(?i)([^a-z0-9]*?)([a-z0-9]{2} ){6}/i", "\\1 {$uniquekey} ", $output[$a] );
$output[$a] = &explode( " {$uniquekey} ", $output[$a] );
$uniquekey = Array( trim( $output[$a][0] ), trim( $output[$a][1] ) );
$macaddress = &str_replace( $uniquekey, "", $macaddress );
return trim( $macaddress );
}
}
return 'not found';
} /**
* Private method __client_macaddress. Returns client mac-address if is readable.
*
* NtMacAddress->__client_macaddress():String
*
* @param no
* @return String Client Mac-Address if is readable, 'not found' otherwise
*/
function __client_macaddress() {
$output = Array();
exec( 'nbtstat -A '.$_SERVER['REMOTE_ADDR'], $output );
$reg = '([a-f0-9]{2}\-){5}([a-f0-9]{2})';
for( $a = 0, $b = &count( $output ); $a < $b; $a++ ) {
if( preg_match( "/(?i){$reg}/", $output[$a] ) == true ) {
return preg_replace( "/(?iU)(.+)({$reg})(.*)/", "\\2", $output[$a] );
}
}
return 'not found';
}
}限windows2000下运行,在win98和me下没试过...
给分吧...
不可能的啦,楼主!不过,要是处在同一个网段内,也就是可以使用arp协议,可以得到