//php获取ip的算法
if(getenv(http_client个性化啤酒) )。
$onlineip=getenv(http_client个性化啤酒;
} else if (getenv (http _ x _ forwarded _ for ) ) )
$ onlineip=getenv (http _ x _ forwarded _ for );
}elseif(getenv(remotegddlq ) )
$onlineip=getenv(remotegddlq;
} else {
$ onlineip=$ http _ server _ vars [ ' remote _ addr ' ];
}
exec(ping$onlineip );
$MACaddress=exec(ARP-a|find/I '.'
$计算机名称=exec (' nbtstat-a '.' '.$ onlineip.'|find/I
$MACname=(preg_split(/(s/),Trim ) $ MAC地址);
$username=(preg_split ) (/) s/),
Trim($computername );
echo '计算机名称: '.$UserName[0].' --- '.'IP地址: '.$MacName[0].' ---
?
class jmdmj/p {
var $return_array=array (; 返回具有//MAC地址的字符串数组
var $mac_addr=array (;
函数get macaddr (
{
交换机(strtolower (PHP _ OS ) )
{
case 'linux':$this-forLinux (; 布雷克;
case 'solaris':break;
case 'unix':break;
case 'aix':break;
default:$this-forWindows (; 布雷克;
}
$temp_array=array (;
foreach $ this-return _ array as $ value
)
{
if(preg_match (
$value,$temp_array )
{
$this-mac_addr清爽的棘球蚴=$temp_array[0];
}
}
unset($temp_array;
return $this-mac_addr;
}
function forWindows (
{
@exec(ipconfig/all )是,
$this-return_array;
if ($this-return_array )
返回$ this-return _ array;
else{
$ipconfig=
$ _ server [ ' windir ' ].'system32ipconfig.exe ';
if(is_file($ipconfig ) )
@exec($ipconfig.'/all ',
$this-return_array;
else
@ exec ($ _ server [ ' windir ' ].'systemipconfig.exe/all ',
$this-return_array;
返回$ this-return _ array;
}
}
function forLinux (
{
@exec(ifconfig-a )是,
$this-return_array;
返回$ this-return _ array;
}
}
$mac=new GetMacAddr (;
echo '
'; print_r($MAC-MAC_addr;