PHP File existence check vs MySQL SELECT server load

VannaNiezg58

New Member
i'm implementing in a project of mine an ip banning functionality.First of all, i'd like to avoid .htaccess for this purpose 'cause the CMS probably would reset it upon modifications, so i have to use a PHP-send-header-and-die solution.Obviously every HTTP request will be checked.Considering an highly trafficated site, i have two solutions to store ip ban infos :1 - In a directory, let's say /bans/, i can create N files where N = number of banned ips, so :/bans/23.23.23.23.ban would ban 23.23.23.23, in this case all i have to do from my script is to check with file_exists, for instance :\[code\]<?php if( file_exists("bans/".$_SERVER['REMOTE_ADDR'].".ban"){ header("HTTP/1.0 403 Forbidden"); die(); } else{ // Continue surfing .... }?>\[/code\]2 - Use a MySQL table, let's say cms_bans, and execute a SELECT for every HTTP request to check if the ip is in the ban list.Considering those 2 solutions, which one has less overload impact (filesystem vs mysql :D), assuming MySQL query caching is disabled ?Please only motivated answers, not just personal preferences.Thanks
 
Back
Top