Jump to content

Archived

This topic is now archived and is closed to further replies.

weeder

Converting from Blacklist to whitlist

Recommended Posts

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
[quote]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;
}
}[/quote]

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

[quote]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;[/quote]

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

Many thanks in advance

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.