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.


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

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

```<br />
<br />
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