#131 IP Blocker (With sample code)

1.3.x
open
nobody
None
5
2012-10-11
2005-09-10
Scott Auge
No

Seeing the note on the demo getting spammed, I see I am
not the only one dealing with it.

To help control this, I have added the following code
to index.php (with existing code around it to aid with
context):


Foundation, Inc., 59 Temple Place, Suite 330, Boston,
MA 02111-1307 USA
*/

// Check if this IP address is on the banned list
require_once ("banned.php");
if (banned($_SERVER["REMOTE_ADDR"]) == 1) exit("Your
banned!");

require_once (dirname(FILE).'/lib/prepend.php');


In banned.php is:

// Determine if the user is on the banned list

function banned($IPAddr) {

if ($IPAddr == "69.50.187.82") return 1;

return 0;

} // function banned ()

?>

I am sure there is a more elegant way of doing it - but
works good enough for me!

Discussion