Jump to content

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
Link to comment
https://forums.phpfreaks.com/topic/13639-converting-from-blacklist-to-whitlist/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.