";
$return_value = TRUE;
$outputPhrase = "";
$sentence = trim($inputPhrase);
if ( $sentence == "" ) return !$return_value;
$BadWordArray = array();
dbconnect();
$query = "SELECT BadWord FROM $badwordtable";
$query_result = @mysql_query( $query );
if( !$query_result )
error("ERROR in statement:
$query
prevented successful execution of query");
$lengthstr = strlen($sentence);
$currlocinstr = 0;
$outputPhrase = "";
while ($row = mysql_fetch_array($query_result, MYSQL_NUM)) {
// go through the input phrase and locate every occurance of
// this bad word
$partstr = stristr($sentence,$row[0]);
$lenpartstr = strlen($partstr);
while ( $lenpartstr && $lengthstr = strlen($sentence) ) {
// at least one bad word in phrase
// get length of string starting at first bad word
$lenpartstr = strlen($partstr);
// is length of partstr = length remaining sentence?
if ( $lenpartstr < $lengthstr ) {
// bad word found at beginning?
// no - bad word is inside of sentence
// get first part of sentence and add it to
// end of output phrase
$outputPhrase .=
substr($sentence,0,$lengthstr-$lenpartstr);
// strip off part of sentence before bad word
$sentence =
substr($sentence,$lengthstr-$lenpartstr);
}
// add highlighted bad word to end of output phrase
$outputPhrase .=
$start_highlight . $row[0] . $end_highlight;
// strip bad word from sentence
$sentence = substr($sentence,strlen($row[0]));
$return_value = FALSE;
$partstr = stristr($sentence,$row[0]);
$lenpartstr = strlen($partstr);
}
// add remainder of sentence to the output phrase
$outputPhrase .= $sentence;
$sentence = $outputPhrase;
$outputPhrase = "";
}
$outputPhrase = $sentence;
return $return_value;
}
function displayFooter()
{
echo "http://www.TheMuralsOfWinnipeg.com
\n";
echo "