News Feed
Jobs Feed
Sections

Recent Jobs

News Archive
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



Similar Posts

Sebastian Bergmann's Blog: Ideas for PHPUnit Projects

DevShed: Introduction to the CodeIgniter PHP Framework

Christian Spanning\'s Blog: PHP development on Mac OS X

Matthew Turland's Blog: PHP 5.2 and SQL Server 2000 on Windows XP

DevShed: Completing a Blogger with PHP


Community Events







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


application conference database PEAR zend PHP5 releases security example zendframework job package code release mysql book developer framework ajax cakephp

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