PHP头条
热点:

php获取到两个ip解决方法


php获取到两个ip
下面是使用fsockopen伪造ip。
	  
$out = "POST $path HTTP/1.1\r\n";
$out .= "Accept: */*\r\n";
$out .= "Content-Type: application/x-www-form-urlencoded\r\n";
$out .= "User-Agent: $_SERVER[HTTP_USER_AGENT]\r\n";
$out.="X-Forwarded-For: ".$ip."\r\n"; //主要是这里来构造IP
$out .= "Host: ".$domain_ip."\r\n";
$out .= "Content-Length: ".$content_length."\r\n";
$out .= "Connection: close\r\n\r\n";
$out .= $content."\r\n\r\n"; //提交的内容

这个是获得客户端ip。本地可以获得伪造的ip,服务器上获得却是两个ip。比如变成这样116.7.54.78, 27.151.95.121。求帮忙

      if (getenv("HTTP_X_FORWARDED_FOR")) 

$ip = getenv("HTTP_X_FORWARDED_FOR"); 

elseif (getenv("HTTP_CLIENT_IP")) 

$ip = getenv("HTTP_CLIENT_IP"); 

elseif (getenv("REMOTE_ADDR"))

$ip = getenv("REMOTE_ADDR"); 

else 

$ip = ""; 


分享到:
------解决方案--------------------
取第一个,第二个是代理服务器的ip

www.phpzy.comtrue/phprm/10949.htmlTechArticlephp获取到两个ip解决方法 php获取到两个ip 下面是使用fsockopen伪造ip。 $out="POST$pathHTTP/1.1\r\n"; $out.="Accept:*/*\r\n"; $out.="Content-Type:application/x-www-form-urlencoded\r\n"; $out.="User-Agent:$_SERVER[HTTP_USER...

相关文章

相关频道:

PHP之友评论

今天推荐