参数$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中文网,转载请注明出处,感谢您的尊重!