<?php
//加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://www.jb200.com");//被禁止后跳转到
脚本学堂
exit;
}
//限制ip段
$ip_arr = explode('.', $userip);
#限制的ip段,假设是192.168.*.*
if (!(($ip_arr[0] == '192' && $ip_arr[1]=='168') )){
header("location:http://www.jb200.com");//被禁止后跳转到脚本学堂
exit;
}else{
header("location:http://www.jb51.net");//正常IP则直接访问脚本学堂
exit;
}
?>