How To Add Spam Blocker Code

I've been watching the live connection to my site this morning and found it's been killed by social-buttons.com 4webmaters. So I did a little search and found this code. not a coder so looking for info on where how to add it for best effect;



You create a flie then include the file.


```php

if(file_exists('no-refer-spam.php')){
require('no-refer-spam.php');
}
?>

```





no-refer-spam.php

```php

$spams = array (
"hardcore.anzwers.net",
"femmesdenudees.com",
"villagedusexe.com",
"gratuitbaise.com",
"inbabes.sexushost.com",
"mature.free-websites.com",
"simple-share-buttons.com",
"darodar.com",
"social-buttons.com",
"hulfingtonpost.com",
"get-free-traffic-now.com",
"buttons-for-website.com",
"4webmasters.org",
"4webmasters.com",
"ranksonic.org",
"ranksonic.com",
);
// array of evil spammers
$ref = $_SERVER["HTTP_REFERER"];
foreach ($spams as $site) {
$pattern = "/$site/i";
if (preg_match ($pattern, $ref)) {
header("Location: $ref"); exit();
}
}
?>

```



The code redirect the request back to itself.

You can use this code in the following file: app/addons/my_changes/controllers/frontend/init.pre.php



The My changes module should be enabled