How to block IP addresses
This script uses PHP so you need a web host that supports PHP to use this script.
Also, the script will only work when the visitors browser has Javascript enabled which most will.
Edit the list of IP addresses in the ip blocker script to suit your needs.
Replace "ip1","ip2" etc. with full or partial ip addesses (from the leftmost digit onwards) such as: "198.168.01.01", "201","92.101.01" etc.
Save the code as blocker.php to your web site. Then add the calling code to your web pages.
The calling code, calls the ip blocker to check the visitors ip address against your list. If they are not wanted, the blocker script returns a javascript command telling the web browser to divert to another page such as error.html
Step 1 - Install blocker code
First ensure your site supports php scripting.
Then, after editing the list of IP addresses, copy the code below to a file on your website called "blocker.php"
The old version of the code required complete ip addresses:
Step 2 - Add the calling code to your web pages
Add the following code in the head section of your web pages e.g. before the </head> tag.
Step 3 - Create the diversion page
In the script, the unwanted visitors to your site are diverted to the page error.html You could change this to any other page or create your own custom error.html page. Alternatively, just let the error 404 (page not found) message appear. However, this may well reveal your web hosting company to them.
p.s. don't forget to add your site to our members website directory for free traffic and search-engine exposure.
|
Testimonial
Hi Andy,
Your program to block unwanted users is GREAT!!
It installed in about 3 minutes, and works like a miracle.
THANK YOU!!!
One question ...... how can I use wildcards in the addresses? Ie; 123.34.??? ...... this fails to work, and I don't know what to try. I tried an "*" .... didn't work. Can you help me?
Thanks a million!
Steve
Thanks to Steve's comments, The new code has this feature - Andy
|