brianlange Posted January 13, 2010 Share Posted January 13, 2010 I want to dynamically block pp addresses. So that if I enter one into a database it is block from my site. What's the easiest way to do this. Right now I am editing the .conf file every time I want to block an address. This process is too time consuming. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/188347-dynamically-block-ip-addresses/ Share on other sites More sharing options...
JonnoTheDev Posted January 13, 2010 Share Posted January 13, 2010 Add the addresses to a table. You will have to run the query on all pages of your site, so a common include is best: $res = mysql_query("SELECT * FROM table WHERE ip='".$_SERVER['REMOTE_ADDR']."'"); if(mysql_num_rows($res)) { // redirect user header("Location:http://www.google.com"); exit(); } However this query is going to have to run on every page access. You are far better just adding addresses to an .htaccess file rather than updating your httpd.conf and restarting apache. Quote Link to comment https://forums.phpfreaks.com/topic/188347-dynamically-block-ip-addresses/#findComment-994314 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.