PHP restricts IP segment access, prevents IP from submitting the form's code
Recently, the small series found that there is a Yunnan netizen often in help the home to publish some rubbish information comment, because www.bkjia.com system dedecms frame, systems itself does not prohibit the IP function, every day see these rubbish comment, although not many, but let people feel uncomfortable, then how to limit it? We just need to add the following code in the feedback.php to judge it.
Note: The following is just a PHP restricted IP instance code, if you intend to apply to the CMS, please modify it yourself, or if you are using DEDECMS, you can contact the site.
Copy to ClipboardWhat to refer to: [www.bkjia.com] Add IP Access Restrictions
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 _arr = Explode ('. ', $userip);
#限制的ip段, suppose it's 192.168.*.*.
if (! ( ($ip _arr[0] = = ' 192 ' && $ip _arr[1]== ' 168 '))) {
Header ("http://www.liehuo.org");//is forbidden to jump to the help of the home site navigation
Exit
}else
{
Header ("http://www.bkjia.com");//normal IP direct access to the home of the help guest
Exit
}
?>
http://www.bkjia.com/PHPjc/364763.html www.bkjia.com true http://www.bkjia.com/PHPjc/364763.html techarticle PHP restricted IP segment access, prohibit IP submission Form code recently, small series found that there is a Yunnan netizen often in the fire net published some spam comments, because www.veryhuo.com system dede ...