Jump to content


Photo

Converting from Blacklist to whitlist


  • Please log in to reply
No replies to this topic

#1 weeder

weeder
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 04 July 2006 - 01:55 PM

I'm new into php and have a script that uses a blacklist and would like to convert it to a whitelist but i can't seem to get it work
The code is two files the config file

function blacklist($url) {
$fil = @file("blacklist.txt");
$go = false;
for ($i=0; $i<count($fil); $i++) {
if (eregi(substr($fil[$i], 0, strlen($fil[$i])-3), $url)) {
$go = true;
break;
}
}
if ($go)
return true;
else
return false;
}
}


And then in the file that inserts the info into the dasbase

if ($HTTP_POST_VARS && (!$HTTP_POST_VARS[sname] || !$HTTP_POST_VARS[surl] || !$HTTP_POST_VARS[title][0] || !$HTTP_POST_VARS[url][0] || !$HTTP_POST_VARS[type][0])) {
include "wrong.html";
die();
} elseif ($HTTP_POST_VARS) {
$c->open();
if ($c->blacklist($surl))
$dont = true;
else
$dont = false;
if (!$dont) {
for ($i=0; $i<count($HTTP_POST_VARS[title]); $i++) {
if (!$title[$i] || !$url[$i] || !$type[$i] || $c->blacklist($url[$i]))
break;
else {


$dato = $c->dato();
@mysql_query("INSERT INTO $c->mysql_tb_que (type, title, url, sname, surl, date, email) "
."VALUES ('$type[$i]','$title[$i]','$url[$i]','$sname','$surl','$dato','$email')");


}
}
include "thanks.html";
die();
$inc = true;
} else
$inc = false;


Can anybody give me some help on how to convert this to use a whitelist

Many thanks in advance




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users