tags and replace them with a link to # a place on the internet with a definition of the term. Written by me, Terrence Cox (BDKR). function jarg_filter($string) { # I think the first thing we need to do is pull the word out of the jarg tags. if(preg_match_all("|(.*)|U", $string, $regs, PREG_PATTERN_ORDER) || preg_match_all("|<jarg>(.*)</jarg>|U", $string, $regs, PREG_PATTERN_ORDER) ) { $x=sizeof($regs[0]); // Get the size of the first array. Very important! for($z=0; $z<$x; ++$z) // I remeber these... { $regs[1][$z]=str_replace(" ", "+", $regs[1][$z]); // Deal with spaces $url=""; // Build the url (above) $url.=str_replace("+", " ", $regs[1][$z]).''; // Deal with the '+''s $string=str_replace($regs[0][$z], $url, $string); // Commit the string } } return $string; } # The idea of this filter is to take some tags and replace them with highlighted code in a table. # Ultimately, I will reduce the number of str_replace calls to 4. It has allready been reduced by a # significant amount. Written by me, Terrence Cox (BDKR). function php_filter($string) { $table_open="<table border=\"1\" width=\"70%\"><tr><td bgcolor=\"white\"><span class=\"source\"></span></td></tr></table>"; // Table information $str_array1=explode("\n", $string); // Make an array of the string unset($string); // We won't need it anymore $new_string=''; // Where the new string will be created $x=sizeof($str_array1); // number of lines in existing string $y=0; // loop counter $write_flag='s'; // It's all in the name $buffer=array(); // The work area $table_open_array=array('', ''); // Arrays for string replace $table_close_array=array('', ''); $code_array=array('', ''); $n=0; for($y=0; $y<$x; ++$y) { if(stristr($str_array1[$y], '')) // Start building the buffer { $write_flag='y'; } if($write_flag=='y') { @$buffer[$n].=$str_array1[$y]."\n"; } // Keep building the buffer if(stristr($str_array1[$y], '')) { $buffer[$n]=str_replace($table_open_array, $table_open, $buffer[$n]); // Deal with tags $buffer[$n]=str_replace($table_close_array, $table_close, $buffer[$n]); $buffer[$n]=str_replace('\\', '\\\\', $buffer[$n]); // Prep $buffer[$n]=@highlight_string($buffer[$n], true); // Highlight the code $buffer[$n]=str_replace('\\\\', '\\', $buffer[$n]); // Cleanup work $buffer[$n]=str_replace($code_array, "", $buffer[$n]); $buffer[$n]=str_replace("&lt;", "<", $buffer[$n]); $buffer[$n]=str_replace("&gt;", ">", $buffer[$n]); $write_flag='append'; // Set the write flag to append. Duh! } if($write_flag=='n' || $write_flag=='s') // Write information to string { $new_string.=$str_array1[$y]; } elseif($write_flag=='append') // Append the highlighted code to the string { $new_string.=$buffer[$n]; $write_flag='n'; ++$n; } } return $new_string; } # Return true if an author is on the spam list function check_author_terms($author) { static $terms; $terms=file('comment_spam_terms.txt'); foreach($terms as $term) { if( strtolower(trim($term)) == strtolower(trim($author)) ) { return true; } } return false; } # Return true if the url is on the spam list function check_url_terms($url) { static $terms; $x=strlen($url); if($url[$x-1]=='/') { $url2=$url; $url2[$x-1]=' '; } $terms=file('comment_spam_urls.txt'); foreach($terms as $term) { if( strtolower(trim($term)) == strtolower(trim($url)) ) { return true; } elseif( strtolower(trim($term)) == strtolower(trim($url2)) ) // elseif( strtolower(trim($term)) == strtolower(trim($url.'/n')) ) { return true; } } return false; } /* For testing the filters */ // error_reporting(0); /* The php filter */ // $string = 'Like this? !empty($juju) ? $juju=$bland : $juju=$sweet; Let me know. Maybe something like... echo md5("doh!");'; // $string = php_filter(&$string); /* The jargon filter */ // $string = 'This is a foobar test! I hope it doesn\'nt fall over.'; // $string = jarg_filter(&$string); /* The bad word filter */ // $string = 'This is a fucked up test! I hope it doesn\'nt shit all over.'; // $string = bw_filter(&$string); // echo $string."\n"; /* The author and url filters */ // check_author_terms('xanax'); //if(check_url_terms('http://www.vegasluckycasino.net/')==true) // { echo "It's a spam link!\n"; } //if(check_url_terms('http://www.top-e-site.info/')==true) // { echo "It's a spam link!\n"; } ?>