News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Little AntiSpam solution

Started by ascanio, April 14, 2014, 02:09:08 PM

Previous topic - Next topic

ascanio

Hi,
I've made a Little antispam change on my installed SMF that Works for me with PHP 5.5, and MS IIS7 . Maybe, someone can add something similar as a mod or in the new versión, and if required the change for Linux.

The change is simple, add a two functions on the index.php that checks the remote user IP using DNS based internet BlackList servers, and if it is listed then return a simple/dummy error to the client.

Here are the two functions, added after the second '*/' on the index.php:

function isSpammer_A($remote) {
   preg_match_all("/(\d{1,3})/", $remote, $match);
   $buscar = $match[0][3].'.'.$match[0][2].'.'.$match[0][1].'.'.$match[0][0].'.bl.spamcop.net';
   $ips = `nslookup $buscar 8.8.8.8`;
   preg_match_all("/Address:  ((((\d{1,3}).){3})(\d{1,3}))/", $ips, $match);
   return (preg_match("/Address:  127.0.0.(\d{1,3})/",$match[0][1]));
}
function isSpammer_B($remote) {
   preg_match_all("/(\d{1,3})/", $remote, $match);
   $buscar = $match[0][3].'.'.$match[0][2].'.'.$match[0][1].'.'.$match[0][0].'.list.blogspambl.com';
   $ips = `nslookup $buscar 8.8.8.8`;
   preg_match_all("/Address:  ((((\d{1,3}).){3})(\d{1,3}))/", $ips, $match);
   return (preg_match("/Address:  127.0.0.(\d{1,3})/",$match[0][1]));
}

And this is added after the line with 'reloadSettings();'

// Check IP is from spammers
$remote = $_SERVER['REMOTE_ADDR'];
//uncomment next line to testit
//$remote = "91.236.75.58";
if (isSpammer_A($remote)||isSpammer_B($remote))
   die(log_error('Unknown Server Error... sorry.'));


Note that you can add new black lists as new funtions...
If some one could do a mod i think it could be usefull.

Best regards.

Deaks

why dont you make it into a mod yourself?  not hard to do :)
~~~~
Former SMF Project Manager
Former SMF Customizer

"For as lang as hunner o us is in life, in nae wey
will we thole the Soothron tae owergang us. In truth it isna for glory, or wealth, or
honours that we fecht, but for freedom alane, that nae honest cheil gies up but wi life
itsel."

ascanio


Roph

Doing two DNS lookups EVERY TIME index.php is hit? That sounds terrible for performance.

Advertisement: