October 23, 2015

PHP - Dynamic IP block script.



Please enter the following script in header file of your site which call in all pages for e.g. header.php file,

And also define IP addressed which you want to redirect to another page/link,

Example

<?php $blacklist = array("111.222.333", "444.555.666", "777.888.999");

if(in_array($_SERVER['REMOTE_ADDR'], $blacklist)) {

header("Location: http://sitename.com/404");

exit();
} ?>

Enjoy!

No comments:

Post a Comment

Integrating Google reCAPTCHA v3 in HTML Form with PHP

  What is Google reCAPTCHA v3? Google reCAPTCHA is a free service that helps protect websites from spam and abuse. reCAPTCHA v3 is the lates...