Hi; I have this script - which checks if the user whom access
the page have the IP registered to a database, that he uses
when accessing my page. It works great at static IP's, but
when I try to make it support dynamic IP's (adding wildcard to it)
it just return an error.
The idea is that if the user does not have the correct IP, then
he/she will be directed to another page; and as I said, this works
great when its a STATIC ip, but when it comes to a dynamic
one, then it got major problems.
Heres a short snippet;
if ($TotalRows == 0) {
echo "<meta http-equiv=\"refresh\" content=\"0;URL=http://www.microsoft.com/\">";
} elseif ($TotalRows > 0) {
while ($Row = mysql_fetch_object($Result)) {
$USERIPs = array(0=>$Row->USERIP0, 1=>$Row->USERIP1, 2=>$Row->USERIP2, 3=>$Row->USERIP3, 4=>$Row->USERIP4, 5=>$Row->USERIP5, 6=>$Row->USERIP6, 7=>$Row->USERIP7, 8=>$Row->USERIP8, 9=>$Row->USERIP9);
}
$checksum = 0;
$star = "*";
foreach ($USERIPs as $key1 => $value) {
if ($value > "") {
$localipsplit = explode(".", $checkip);
$dbipsplit = explode(".", $value);
foreach ($dbipsplit as $key2 => $splittedip) {
if ($dbipsplit[$key2] == $localipsplit[$key2] or $dbipsplit[key2] == $star) {
$checksum = ($checksum + 1);
} // end if
} // end foreach
} // end if
} // end foreach
if ($checksum == 4) {
echo "<meta http-equiv=\"refresh\" content=\"0;URL=index2.php\">";
} else {
echo "<meta http-equiv=\"refresh\" content=\"0;URL=http://www.microsoft.com/\">";
} // end if
} // end if
I do know that its the wildcard that is the problem, and also
if I try to use anything else than numbers, it return error, and
NO, the database is not set to be integer ;P
Hopefully someone can help me out here.
Sincerely;
Mr. Red