参数$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 = "";
Pause;
Fall 1:
$sResult = $ip;
Pause;
Fall 2:
$sResult = $sMac;
Pause;
Fall 3:
$sResult = $ip . " " . $sMac;
Pause;
Standard:
$sResult = "";
Pause;
}
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 = "";
Pause;
Fall 1:
$sResult = $ip;
Pause;
Fall 2:
$sResult = $sMac;
Pause;
Fall 3:
$sResult = $ip . " " . $sMac;
Pause;
Standard:
$sResult = "";
Pause;
}
return $sResult;
}
?>
以上就是php获取IP、MAC地址函数的内容,更多相关内容请关注PHP中文网(m.sbmmt.com )!