Personally, I've tested this with the "phpBB" and "Invision Power" message board software and found no problems. If you're running one of these forums, you can keep all the bad countries out. I've also tested it with the "x7chat" chat room software. So far, it seems to work fine. However, if you find something that doesn't work, you can make countrycheck.php ignore that part of your site. For this example, let's say there is a chat software package that doesn't work quite right with countrycheck.php. All you have to do is add a line to your .htaccess file. The following line will cause the directory called "chatroom" and every file and directory below it to be completely ignored. Simply add the following line:
RewriteCond %{REQUEST_URI} !^/chatroom/
With that line added, our .htaccess file now looks like this:
RewriteEngine On RewriteCond %{REQUEST_URI} ^.*\.htm [OR] RewriteCond %{REQUEST_URI} ^.*\.html [OR] RewriteCond %{REQUEST_URI} ^.*\.php [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteCond %{REQUEST_URI} !^/chatroom/ RewriteCond %{REQUEST_URI} !^/country1/countrycheck.php RewriteRule ^(.*)$ /country1/countrycheck.php [L]
You can have any directory ignored by countrycheck.php by adding similar lines. You can add as many of these lines as needed for any part of your web site that doesn't seem to work quite right.
So, why do some parts work while other parts do not? The problem is the way this has to work. The countrycheck.php can only be called through "rewriting" that takes place in the .htaccess file. The countrycheck.php program is then responsible for fetching the requested file and sending it to the user. This method works very well for normal html files. And it works quite well for most normal php files. But due to the way some php files are coded, this may not work in all cases. It all depends on what the php code is doing. I think you will find that most everything on most sites should work just fine. If you find something that doesn't work, add a line to ignore that directory or individual file. In the example above, an entire directory is being ignored. If you need to just ignore a file within a directory, something like the following works:
RewriteCond %{REQUEST_URI} !/myoldstuff/16yearsofjunk.php
Instead of having countrycheck.php being called through an .htaccess file and being responsible for delivering the content, it would have been better to just create a new Apache module and either continue or reject the request. However, this package is aimed at those running on shared servers and doing something like loading in new Apache modules isn't possible. This is the only method I've found that works for web sites running on shared servers at this point in time.
Now that you're quite sure everything is working good, you can make a few more minor changes to the .htaccess files if desired. So far, we have only been protecting the html, htm, and php files. Any other file requests are sent no matter what the IP address is. In most cases, this is all you really need to protect. After all, files such as jpg or gif images won't be requested unless an html or php file is first requested. But if you want to protect those image files, you can add additional lines to your .htaccess file.
So, let's add IP address checking for our jpg and gif images. Cut and paste the following two lines.
RewriteCond %{REQUEST_URI} ^.*\.gif [OR] RewriteCond %{REQUEST_URI} ^.*\.jpg [OR]
The .htaccess file should now look like this:
RewriteEngine On RewriteCond %{REQUEST_URI} ^.*\.gif [OR] RewriteCond %{REQUEST_URI} ^.*\.jpg [OR] RewriteCond %{REQUEST_URI} ^.*\.htm [OR] RewriteCond %{REQUEST_URI} ^.*\.html [OR] RewriteCond %{REQUEST_URI} ^.*\.php [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteCond %{REQUEST_URI} !^/country1/countrycheck.php RewriteRule ^(.+)$ /country1/countrycheck.php [L]
IMPORTANT: Notice how each line for the filetypes ends with "[OR]" all except for the -d line? The very last one of these lines must not have [OR] at the end of it. This is just like saying "Check the IP address if the requested file is a gif or jpg or htm or html or php or -d".
Note: The line with -d will protect the bad countries from attempting a directory access.
So, why not just have countrycheck.php be used for every file? Because as described previously, there are some files it just cannot deliver properly. Some files must be run completely through the full Apache handling. Until a better method comes along, I think you'll find a great benefit from this package.
Many popular filetypes are supported by countrycheck.php and you can add any or all of them to your .htaccess file. However, there's no point in adding a filetype if it doesn't exist on your website. Also, be sure to test your site after adding a new filetype in the .htaccess file to make sure it can be delivered properly.
Here's all the different filetypes you can add, just cut and paste the ones you wish to use. They are all listed here in alphabetical order including the ones we have already mentioned.
RewriteCond %{REQUEST_URI} ^.*\.avi [OR] RewriteCond %{REQUEST_URI} ^.*\.bin [OR] RewriteCond %{REQUEST_URI} ^.*\.bmp [OR] RewriteCond %{REQUEST_URI} ^.*\.cpio [OR] RewriteCond %{REQUEST_URI} ^.*\.csh [OR] RewriteCond %{REQUEST_URI} ^.*\.css [OR] RewriteCond %{REQUEST_URI} ^.*\.dll [OR] RewriteCond %{REQUEST_URI} ^.*\.doc [OR] RewriteCond %{REQUEST_URI} ^.*\.dvi [OR] RewriteCond %{REQUEST_URI} ^.*\.eps [OR] RewriteCond %{REQUEST_URI} ^.*\.exe [OR] RewriteCond %{REQUEST_URI} ^.*\.gif [OR] RewriteCond %{REQUEST_URI} ^.*\.gtar [OR] RewriteCond %{REQUEST_URI} ^.*\.gz [OR] RewriteCond %{REQUEST_URI} ^.*\.hdml [OR] RewriteCond %{REQUEST_URI} ^.*\.htm [OR] RewriteCond %{REQUEST_URI} ^.*\.html [OR] RewriteCond %{REQUEST_URI} ^.*\.ico [OR] RewriteCond %{REQUEST_URI} ^.*\.jpeg [OR] RewriteCond %{REQUEST_URI} ^.*\.jpg [OR] RewriteCond %{REQUEST_URI} ^.*\.lha [OR] RewriteCond %{REQUEST_URI} ^.*\.lzh [OR] RewriteCond %{REQUEST_URI} ^.*\.mid [OR] RewriteCond %{REQUEST_URI} ^.*\.mov [OR] RewriteCond %{REQUEST_URI} ^.*\.mp3 [OR] RewriteCond %{REQUEST_URI} ^.*\.mpeg [OR] RewriteCond %{REQUEST_URI} ^.*\.mpg [OR] RewriteCond %{REQUEST_URI} ^.*\.pdf [OR] RewriteCond %{REQUEST_URI} ^.*\.php [OR] RewriteCond %{REQUEST_URI} ^.*\.php3 [OR] RewriteCond %{REQUEST_URI} ^.*\.php4 [OR] RewriteCond %{REQUEST_URI} ^.*\.png [OR] RewriteCond %{REQUEST_URI} ^.*\.pot [OR] RewriteCond %{REQUEST_URI} ^.*\.pps [OR] RewriteCond %{REQUEST_URI} ^.*\.ppt [OR] RewriteCond %{REQUEST_URI} ^.*\.ps [OR] RewriteCond %{REQUEST_URI} ^.*\.qt [OR] RewriteCond %{REQUEST_URI} ^.*\.rtf [OR] RewriteCond %{REQUEST_URI} ^.*\.shtml [OR] RewriteCond %{REQUEST_URI} ^.*\.snd [OR] RewriteCond %{REQUEST_URI} ^.*\.tar [OR] RewriteCond %{REQUEST_URI} ^.*\.tif [OR] RewriteCond %{REQUEST_URI} ^.*\.tiff [OR] RewriteCond %{REQUEST_URI} ^.*\.tgz [OR] RewriteCond %{REQUEST_URI} ^.*\.txt [OR] RewriteCond %{REQUEST_URI} ^.*\.wav [OR] RewriteCond %{REQUEST_URI} ^.*\.wcm [OR] RewriteCond %{REQUEST_URI} ^.*\.wdb [OR] RewriteCond %{REQUEST_URI} ^.*\.wks [OR] RewriteCond %{REQUEST_URI} ^.*\.wps [OR] RewriteCond %{REQUEST_URI} ^.*\.wri [OR] RewriteCond %{REQUEST_URI} ^.*\.xla [OR] RewriteCond %{REQUEST_URI} ^.*\.xlc [OR] RewriteCond %{REQUEST_URI} ^.*\.xlm [OR] RewriteCond %{REQUEST_URI} ^.*\.xls [OR] RewriteCond %{REQUEST_URI} ^.*\.xlt [OR] RewriteCond %{REQUEST_URI} ^.*\.xlw [OR] RewriteCond %{REQUEST_URI} ^.*\.zip [OR]