Filter a Query
Posted: Fri Apr 15, 2005 9:21 am
I have a meta search engine that displays recent search queries:
http://www.sodora.com/queries.html
As you can tell, there are a lot of 'naughty' searches being submitted.
I fear that Google will assume my site to be adult-related and cut off my adwords stream.
I'm trying to remove words from a predefined list, but I can't seem to be able to get it done. Any thoughts?
http://www.sodora.com/queries.html
As you can tell, there are a lot of 'naughty' searches being submitted.
I fear that Google will assume my site to be adult-related and cut off my adwords stream.
I'm trying to remove words from a predefined list, but I can't seem to be able to get it done. Any thoughts?
Code: Select all
<?
function format_term($term) {
$term = str_replace('-','~~',$term);
return str_replace(' ','-',$term);
}
$res = mysql_query("SELECT * FROM $querytable ORDER BY q_id DESC") or die(mysql_error());
$bad_words = array('pthc rompl ranchi pthc pthc ranchi board', 'melissa midwest', 'melissa midwest movies');
$pattern = '%'.preg_quote(implode('|', $bad_words)).'%i';
if (preg_match($pattern, $searchstring)) {
do_insert();
}
while (($line = mysql_fetch_assoc($res)) && strlen(ob_get_contents()) < 95*1024) {
echo "<a href='".constant('dir')."search/".format_term($line['q_query'])."'>".$line['q_query']."</a><br>";
}
?>
</div>