unfortunately, i needed to write a script keeping some people out of parts of a site...i did some reading on the subject and i came up with my own solution...however, i'm just a little nervous that maybe i've done something wrong here...it does seem though, that it works fine when i test it...
what i've done...was explode the users IP number and separate the first three xxx.xxx.xxx from the last xxx of the ip number...
then, in the database i've specified xxx.xxx.xxx and then separately one can either enter xxx for a specific IP or * to ban the complete range...
is this method ok? i haven't seen anybody mention this and it seems too simple...am i missing something?
thanks...just a little nervous this might not work all the time...jv
here's the code:
$banip=$_SERVER[REMOTE_ADDR];
$ips = explode(".", $banip);
$ipa = "$ips[0].$ips[1].$ips[2]";
$query_banned = mysql_query ("SELECT * FROM banned WHERE ip='$ipa'") or die ("Yo, it's not working! - Code1A.");
$row_banned = mysql_fetch_array($query_banned);
if ($row_banned[ip] == $ipa) {
if ($row_banned[ipv] == $ips[3] || $row_banned[ipv] == '*') {
mysql_query("INSERT into banned_attempts (attempt_id,ip) values ('','$banip')");
header('location: [url]http://www.yahoo.com[/url]'); } }