/* Fetch the list of words that need to be filtered */
$result = mysql_query("SELECT filterwords FROM og_admin");
$rows = mysql_fetch_row($result);
$fwords = explode("\n",$rows[0]);
/* This code segment will determine words that need to be filtered then
replace it with "***" except if the word need to be filtered is in
an image tag so that the image included will be displayed correctly */
$fstr = explode("<",$msg);
for ($i=0;$i<count($fstr);$i++)
{
if (substr($fstr[$i],0,3) == 'img')
{
$pos = strpos($fstr[$i],">");
if ($pos !== FALSE)
{
$text = stristr($fstr[$i],">");
for ($h=0;$h<count($fwords);$h++)
{
$text = str_replace(trim($fwords[$h]),"***",$text);
}
$fstr[$i] = substr($fstr[$i],0,$pos);
$fstr[$i] .= $text;
}
}
else
{
for ($h=0;$h<count($fwords);$h++)
{
$fstr[$i] = str_replace(trim($fwords[$h]),"***",$fstr[$i]);
}
}
}
$msg = implode("<",$fstr);