PHP编程:巧妙获得网站访客的真实IP

WBOY
Release: 2016-05-19 14:05:30
Original
1013 people have browsed it
在php中要得到访客的ip其实是非常容易的,但是有些人会使用PRoxy这个方法来避开系统得到真实IP。而如果有心人士用来攻击网站,又走proxy的话,这时就可以透过侦测得到访客的真实IP。
   而以下程序就可以获得真实IP:
if (!empty($_SERVER['HTTP_CLIENT_IP']))
$ip=$_SERVER['HTTP_CLIENT_IP'];
else if (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
else
$ip=$_SERVER['REMOTE_ADDR'];
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template