2011/12/18 12:25:48
|
---|
|
Protector and blocking Bad IPs (proxy)On my ICMS 1.2.x website I use PHP-Stats as a counter. This is an old but still a good PHP counter which logs IP addresses, visiting time, visited pages, countries, etc.
For a long time I saw an IP address (109.173.122.122 from Russia) in PHP-Stats which visited my website a few times a day. In the server log files this IP couldn't be found, but instead I found other IPs which weren't any good according to sites as Stop Forum Spam and Honeypot. Unfortunately, adding the above IP address to Protector's Bad IP list didn't work. PHP-Stats uses HTTP_X_FORWARDED_FOR to determine the IP address of a visitor and assume Protector uses another method. Correct? At the moment I use the following 'solution' to stop this kind of bad IPs from visiting my website. At the beginning of mainfile.php I've added these lines: $ip = $_SERVER['HTTP_X_FORWARDED_FOR'] ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
$banned_ip = array('93.80.182.49','95.28.138.245','109.173.122.122','128.68.87.46');
if(in_array($ip,$banned_ip)) {
echo "<html><head><meta http-equiv=\"Refresh\" content=\"0; URL=http://www.projecthoneypot.org\"></meta></head><body></body></html>";
exit();
} Questions: a) Is this a correct way of stopping IPs in cases where Protector doesn't seem to work? b) If not, what's the correct way to do so? |
_________________
McDonalds Store |
2011/12/19 15:18:35
|
---|
|
Re: Protector and blocking Bad IPs (proxy)I might suggest adding those IP addresses to your htaccess file, instead.
|
2011/12/19 16:11:07
|
---|
|
Re: Protector and blocking Bad IPs (proxy)Sorry, my mistake, but adding these IPs to the htaccess file didn't help either. This was one of my first attempts to stop these IPs.
The above code seems to work when added to mainfile. Tried also by adding the code to index.php instead (before the line where mainfile is included), but this didn't work. |
_________________
McDonalds Store |