我们只要在feedback.php中添加下面的代码进行判断就可以了。
注意:下边只是一个PHP限制IP的实例代码,如果您打算应用到CMS中,请自行修改,或者如果您正在使用DEDECMS,可以联系本站。
//加IP访问限制
if(getenv('HTTP_CLIENT_IP') && strcasecmp(getenv('HTTP_CLIENT_IP'), 'unknown')) {
$userip = getenv('HTTP_CLIENT_IP');
} elseif(getenv('HTTP_X_FORWARDED_FOR') && strcasecmp(getenv('HTTP_X_FORWARDED_FOR'), 'unknown')) {
$userip = getenv('HTTP_X_FORWARDED_FOR');
} elseif(getenv('REMOTE_ADDR') && strcasecmp(getenv('REMOTE_ADDR'), 'unknown')) {
$userip = getenv('REMOTE_ADDR');
} elseif(isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], 'unknown')) {
$userip = $_SERVER['REMOTE_ADDR'];
}
//限制ip
if ($userip=='27.37.188.128'){
header("location:http://sc.jb51.net");//被禁止后跳转到脚本之家站
exit;
}
//限制ip段
$ip_arr = explode('.', $userip);
#限制的ip段,假设是192.168.*.*
if (!(($ip_arr[0] == '192' && $ip_arr[1]=='168') )){
header("location:http://sc.jb51.net");//被禁止后跳转到脚本之家素材站
exit;
}else{
header("location:http://www.jb51.net");//正常IP则直接访问脚本之家首页
exit;
}
?>
Statement: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