Parameter $aitype value: 1:ip,2:mac,3:ip+mac
Returns the return string: address string
<?php
function getclientaddr ($AiType =0)
{
$sMac = "";
$ip = getenv ("REMOTE_ADDR");
$ip 1 = getenv ("Http_x_forwarded_for");
$ip 2 = getenv ("Http_client_ip");
($ip 1)? $ip = $ip 1:null;
($ip 2)? $ip = $ip 2: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;
}
?>
Parameter $aitype value: 1:ip,2:mac,3:ip+mac
Returns the return string: address string
<?php
function getclientaddr ($AiType =0)
{
$sMac = "";
$ip = getenv ("REMOTE_ADDR");
$ip 1 = getenv ("Http_x_forwarded_for");
$ip 2 = getenv ("Http_client_ip");
($ip 1)? $ip = $ip 1:null;
($ip 2)? $ip = $ip 2: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;
}
?>
The above is the PHP get IP, MAC address function content, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!