欢迎访问 生活随笔!

凯发k8官方网

当前位置: 凯发k8官方网 > 编程语言 > php >内容正文

php

php 获取ip mac,php获取ip、mac地址函数 -凯发k8官方网

发布时间:2024/10/14 php 45 豆豆
凯发k8官方网 收集整理的这篇文章主要介绍了 php 获取ip mac,php获取ip、mac地址函数 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

参数$aitype取值:1:ip,2:mac,3:ip mac

返回 return string:地址串

function getclientaddr($aitype=0)

{

$smac = "";

$ip= getenv("remote_addr");

$ip1 = getenv("http_x_forwarded_for");

$ip2 = getenv("http_client_ip");

($ip1) ? $ip = $ip1 : null;

($ip2) ? $ip = $ip2 : null;

if ($aitype > 1)

{

$scmd = "nbtstat -a " . $ip;

$sstring = shell_exec($scmd);

$atemp = split("=",$sstring);

$smac = trim($atemp[count($atemp)-1]);

}

switch($aitype)

{

case 0:

$sresult = "";

break;

case 1:

$sresult = $ip;

break;

case 2:

$sresult = $smac;

break;

case 3:

$sresult = $ip . " " . $smac;

break;

default:

$sresult = "";

break;

}

return $sresult;

}

?>

参数$aitype取值:1:ip,2:mac,3:ip mac

返回 return string:地址串

function getclientaddr($aitype=0)

{

$smac = "";

$ip= getenv("remote_addr");

$ip1 = getenv("http_x_forwarded_for");

$ip2 = getenv("http_client_ip");

($ip1) ? $ip = $ip1 : null;

($ip2) ? $ip = $ip2 : null;

if ($aitype > 1)

{

$scmd = "nbtstat -a " . $ip;

$sstring = shell_exec($scmd);

$atemp = split("=",$sstring);

$smac = trim($atemp[count($atemp)-1]);

}

switch($aitype)

{

case 0:

$sresult = "";

break;

case 1:

$sresult = $ip;

break;

case 2:

$sresult = $smac;

break;

case 3:

$sresult = $ip . " " . $smac;

break;

default:

$sresult = "";

break;

}

return $sresult;

}

?>

以上就是php获取ip、mac地址函数的内容,更多相关内容请关注php中文网(www.php.cn)!

本文原创发布php中文网,转载请注明出处,感谢您的尊重!

总结

以上是凯发k8官方网为你收集整理的php 获取ip mac,php获取ip、mac地址函数的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得凯发k8官方网网站内容还不错,欢迎将凯发k8官方网推荐给好友。

网站地图