News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Brent Meshier's Blog:
Blocking visitors by country using PHP & MySQL
April 23, 2007 @ 16:38:00

In a quick new post from Brent Meshier today, he shows us how, with the help of a database CVS file, to block visitors to your site from certain locales.

A client asked me last night if it was possible to block certain countries from accessing his website. He's concerned about the "axis of evil" and their comrades downloading his software. The task is easily accomplished, although it's like using a sledge hammer to tap in a finishing nail. He didn't seem too concerned that we could accidentally block Uzbekistan in the process. Unfortunately his entire site uses plain .html files, no dynamic scripting. This led me to using a slightly creative solution with .htaccess.

Broken up into five simple steps, he makes a light function to drop into an output buffering function to tell it to either show the normal content or return a 401 Unauthorized header to the visitor.

0 comments voice your opinion now!
mysql block visitor country download csv database htaccess mysql block visitor country download csv database htaccess


blog comments powered by Disqus

Similar Posts

PHP.net: PHP 5.6.0RC1 is available

Melvin Rivera's Blog: Creating a custom WordPress database error page

Job Posting: 65media Seeks PHP/MySQL Developer (Marina del Rey, CA)

Edin Kadribasic's Blog: PHP 4.4.3 for Windows with 5.0.22 MySQL libraries

Jeremy Cook's Blog: Handling Binary Data with PDO


Community Events





Don't see your event here?
Let us know!


introduction language update opinion library security tool interview community package framework composer symfony release podcast install laravel version series voicesoftheelephpant

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework