Kick those spammers and give them a red ticket!

Version: 13.1c
Revision: 11 Build 31

Kick those spammers and give them a red ticket!

Introduction:
for the last three days, I was banging my head against the monitor – trying to create a powerful – php script that could block a bunch of idiotic spammers, by range.
But, here is the good news… you can use this script without any faults – from a single directory! This means, your “IP text file” can be placed into the same directory without writing its TRUE directory.

In this script you’ll only need to modify two lines: the url directory and the warning message for the naughty spammers. Also, if you want to use the “banned_warning” strings, you will need to keep the “banned_url”, empty.

Finally, before you use this script, the structure of the “IP address” file cannot have white spaces from the beginning, middle and the end. Also, the supported range are limited. It can only recognize these structure…

123.
123.56.
123.56.76.
123.56.76.44
255.255.255.255
0.0.0.0

1.] Login to your Cpanel and add this to the “header.php” file.

Notes: if you want to make this script as an “Include” file, then you’ll need to use this code. Just place this lines into your “header.php”. But, you must type the paths, clearly. Or else, there will be errors / faults with your Website.

<?php include ($_SERVER['DOCUMENT_ROOT']."/diectory-one/banned.php"); ?>

- replace the default directory (“/diectory-one/banned.php”) with your own directory that has the “blocking IP script”.

<?php
// Version: 13.4 Eagle
// Copyrighted By Lair360
// --------------------------------
$filelocation = "ips_blocker.txt";
$banned_warning = "You're banned from Spamming my website!
<br>If you are blocked by mistake, please contact the admin: [Email Address]";
// Url redirects ++ leave blank to use banned_warning ++
$banned_url = "";
// Modifications stops here!
function ShowBan() {global $banned_url, $banned_warning; if ($banned_url == "") exit($banned_warning);
  else header("Location: $banned_url"); exit;}
if ($_SESSION_['banned'] == 'TRUE') ShowBan();
// comment out the "Session" if you're using the include function.
	if (!isset($_SESSION)) session_start();
$ip = isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
	$banfile = file($filelocation);
foreach ($banfile as $list)
    {
        $list = rtrim($list); // trim the junk that is killing your website!
        if (strstr($ip, $list) && strpos($ip, $list)==0)
            { $_SESSION_['banned'] == 'TRUE';
                ShowBan();}
    }?>

2.] Save your file and input your offending IP addresses into your text file. But, don’t be a fool and block yourself from accessing your website, especially, adding the IP range.

3.] Finish!

Copyrighted By Lair360

Comments are closed.