PHP 怎么检测用户使用了高匿名代理访问
1个回答
展开全部
<?php
//获取用户真实ip
function getIp() {
if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIENT_IP"), "unknown"))
$ip = getenv("HTTP_CLIENT_IP");
else if (getenv("HTTP_X_FORWARDED_FOR") && strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown"))
$ip = getenv("HTTP_X_FORWARDED_FOR");
else if (getenv("REMOTE_ADDR") && strcasecmp(getenv("REMOTE_ADDR"), "unknown"))
$ip = getenv("REMOTE_ADDR");
else if (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], "unknown"))
$ip = $_SERVER['REMOTE_ADDR'];
else
$ip = "unknown";
return $ip;
}
$ip= getIp();
echo $ip;
//检测代理级别
if(!empty($_SERVER['HTTP_VIA']))
{
if(!isset($_SERVER['HTTP_X_FORWARDED_FOR']))
{
echo '<br>普通匿名代理服务器(Anonymous Proxies)';
}
else
{
echo '<br>透明代理服务器(Transparent Proxies )';
}
}
else
{
echo '<br>没有代理或者是高匿名代理';
}
?>
//获取用户真实ip
function getIp() {
if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIENT_IP"), "unknown"))
$ip = getenv("HTTP_CLIENT_IP");
else if (getenv("HTTP_X_FORWARDED_FOR") && strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown"))
$ip = getenv("HTTP_X_FORWARDED_FOR");
else if (getenv("REMOTE_ADDR") && strcasecmp(getenv("REMOTE_ADDR"), "unknown"))
$ip = getenv("REMOTE_ADDR");
else if (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], "unknown"))
$ip = $_SERVER['REMOTE_ADDR'];
else
$ip = "unknown";
return $ip;
}
$ip= getIp();
echo $ip;
//检测代理级别
if(!empty($_SERVER['HTTP_VIA']))
{
if(!isset($_SERVER['HTTP_X_FORWARDED_FOR']))
{
echo '<br>普通匿名代理服务器(Anonymous Proxies)';
}
else
{
echo '<br>透明代理服务器(Transparent Proxies )';
}
}
else
{
echo '<br>没有代理或者是高匿名代理';
}
?>
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询