Say goodbye to proxy offender!

Version: 11.1
Revision: 23 Build 9

Say goodbye to proxy offender!


On the 9th of June, 2010, my website was bombarded by a suspicious hacker. They managed to access my server without my consent. Therefore, I have to shutdown / block any users from accessing my account / site. Anyway, when I arrived home, it was sorted and I can now write more articles for my readers.

In this article, we are going to show you how to implement a ‘proxy blocker’ for WordPress. However, if you implement this script, it will also block legit viewers and commentators. So, if I were you, I would think about it before implementing this script.

1.] Login to Cpanel and locate your WordPress directory.
2.] Find your ‘theme’ directory and open this file: “functions.php”

Tips: I would suggest you to backup your “functions.php” file before adding anymore scripts / codes.

3.] Copy this source and place them inside. But, don’t forget your PHP tags!

<?php
/**
 * Block Proxies - PHP
 * Copyright 2010 - Lair360
 */

function checkProxy {
if($_SERVER['HTTP_X_FORWARDED_FOR'] || $_SERVER['HTTP_X_FORWARDED'] || $_SERVER['HTTP_FORWARDED_FOR'] || $_SERVER['HTTP_CLIENT_IP'] || $_SERVER['HTTP_VIA']) {
die('No proxies allowed');
	}
}
?>

4.] Save the changes and refresh your webpage.

Notes: this script will check your browser if the user is behind a proxy / proxy provider. After that, it will block the offending users (proxy users) from accessing your webpage or specific page. However, please be aware that this script can also block you if your workplace utilize proxies.

Leave a Reply

You must be logged in to post a comment.