Hi guys
I have been reading up and see that ereg isn't wise to use now; and that it's being dumped soon
I used my favorite WinGREP program to find all instances of it, and I only use it in once place. I have no idea what I should use instead though as I always seem to make the script stop working
Basically, I'm using this on a form for a IRC bot lending channel to submit a request for a bot to be added in their channel. We use a 'badword' table with "type=0" for bad words, or type=1 for exceptions which are allowed through
I want to get all the type=0 words from the table and compare it against the $_POST['CHANNEL'], and if found (and no type=1 to except it), then it should block...
Currently we use:
$words=mysql_query2("Select * from badwords where type=0");
$counter_badlist=0;
while ($word=mysql_fetch_array($words))
{
$badlist[$counter_badlist]=$word['badword'];
$counter_badlist++;
}
$words=mysql_query2("Select * from badwords where type=1");
$counter_exception=0;
while ($word=mysql_fetch_array($words))
{
$exception[$counter_exception]=$word['badword'];
$counter_exception++;
}
$count=count($badlist);
for ($x=0;$x<$count;$x++) {
if (ereg("".strtolower($badlist[$x])."",strtolower($_POST['CHANNEL'])) ) {
$found=0;
for ($y=0;$y<count($exception);$y++) // we found it in badlist array
{
if (ereg("".strtolower($exception[$y])."",strtolower($_POST['CHANNEL'])) ) {
$found=1; // we found it in exception
}
}
if ($found==0)
$msg .= " <li><span>Your channel name is bad, no thanks</span></li>\n";
}
}
I'm sure there is a much tidier easier way to do it with in_array. We've used this for ages, and a long time ago I posted regarding it when we didn't use a database, instead we had a hardcoded list.
Any help in sorting this out would be appreciated