首页 > 编程知识 正文

php获取用户ip,php获取用户ip并显示

时间:2023-05-06 15:56:39 阅读:15774 作者:908

//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;

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。