Hello, I am having a problem with my site, I'm getting tons of ratings from crawl bots, "visiting the star links", as you know these are not accurate ratings... I am trying to implement a blacklist, this blacklist checks your IP with the IPs in the blacklist, and if its not in there, it lets you rate. Well, the crawl bots IP changes and there are more then one, making for a big blacklist that needs to be update much to often. So, what I wanted to do was make it so it matched the first two sections of the IP address with all the IPs in the blacklist, this way, I don't have to update them "as often, if ever". If come into some problems, and I have no clue where to go or what to do... I pieced this much together...
CODE
$ip = getenv("REMOTE_ADDR");
$banlist = mysql_query('SELECT * FROM blacklist');
$ban = "False";
while($row = mysql_fetch_array($banlist))
{
$pattern = '/(d+).(d+)./';
preg_match($pattern, $ip, $matches, PREG_OFFSET_CAPTURE);
if(count($matches) > 0)
{
//don't toutch ban
}
else { $ban = "True"; }
}
I have no clue if I'm even on the right track. All I want is some code that can match the first two sections of a full ip with the first two sections of another ip and return true if its a match and false if it is not
Thank you! All Suggestions Welcome!
This post has been edited by Addiction2Code: 6 Jun, 2008 - 10:38 AM