hi i want to know what code should i use to block certain Ip addresses from accessing my site.?? i do not want to use .htaccess for it as it is currently disabled and i cannot use it therefore a php code doing that work would be fine?? can somebody help me out?
<?php $banned = array( '127.0.0.1', '192.168.0.1' ); if( in_array( $_SERVER['REMOTE_ADDR'], $banned ) ) { die("Your banned, fuck off"); } ?> PHP: NEVER ban 127.0.0.1
thanks.. will give it a try by taking the IP addresses from a text file. i will edit that code reps for u
1. Make a table in database with banned IPs. 2. Insert a script @ beginning of web page which checks the ip is already listed as banned in the table and if exists show "you are banned" This is the traditional way.
Champrock... I was also facing this problem try my script i worked a lot on it. http://www.blogofwebmasters.com/free-php-ip-ban-script-gban/ Thanks. Guys also review it
thanks a lot but the thing is that i was not looking for a database script. i was looking for something which i can use without any hassles