What up man... I used this script a while ago when I had a teenager fourm up. I had to check for bad words and someone from here actually helped me quite a bit with this script. I put everything that is used for the database. Make sure that you run the field where they put in their comment for the guestbook through a htmlspecialchars($string)! That will cut out all the <?php phpinfo(); ?> kids.
Here is the script that I used below with the bad words already in it. It works for a large amount of time but there are ways around it.
<?
function checkBadWords($thought_thought) {
$badWords = array('fuck', 'cunt', 'whore','hoe','gay','homosexual','homo','gayism','faggot','lesbian','lesbo','lessie','lessy','chad smith','melanie perry','chris crothers','matt brainard','flaming','porno','stupid','slut','g a y','pics','pictures','butt','ass','bastard','dick','dike','crack','pipe','maryj','pcp','alcohol','speed','drugs','druggie','drugy','shot','heneiken','beer','loser','penis','vagina','fucker','fuckster','fucking','fuckalot','fuckingman','asshole','@$$','hole','fker','cuntbreaker','butthole','butt','butts','jackass','jack whore','f u c k','f uc k','fu ck','fk','a s s','as s','fuc k','f uck','fkuc','nieps','hunter','holman','thompson','damn','Mr. Hunter','Mr. Holman','Mr. thompson','mr.hunter','mr.holman','mr.thompson','shit','$hit','mother fucker','mother fuckster','mother fuck','mother ass hole','motherfucker','bull','bull shit','pu$$y LickKer','brest','breast','sh1t','fckin','pu$$y','raper','di-ck','tits','tit','midget','short person','cum','sex','sexual','sexy','sexist','petifile','punami','pootey tang','pootey','A-sS-h-ole','f_u_c_k','f_uc_k','f_uck','f_u_c_k','rape','pubic','pubic hair','hard on','hard-on','hard-onn','haard-on','clit','nipples','errect','erect','f-u-c-k','f-uc-k','fu-ck','anal','oral','penetration','arse','analyst','sex lover','same sex lover','chad r. smith','weed','bluws','goats','fking','anus','G-A-Y','gayy','porn','kiddie','se><','SNORTS','FECES','faggat','fagget','nipple','g_ay','ga_y','g_A_Y','_gay','g_ya');
foreach ($badWords as $badWord) {
if (eregi($badWord, $thought_thought)) {
$theword = $badWord;
print("<h1>Bad Word Is: $theword</h1>");
return false;
}
}
return true;
}
if (!checkBadWords($thought_thought)) {
print("<h1>You used the word $theword...Which is bad! Try again!</h1>");
print("<meta http-equiv='refresh' content='3; url=randomthoughts.php'>");
print("</head><body><a href='randomthoughts.php'><font face='arial,helvetica'><b>If it does not come up. Please click here. This will take you back.</b></font></a></body></html>");
exit;
}
$thought_date = date("Y-m-d G:i:s");
$ip = $GLOBALS['REMOTE_ADDR'];
$db = mysql_connect("localhost");
mysql_select_db("olentangy", $db);
$sql = "INSERT INTO thought
VALUES(NULL,'$thought_name','$thought_grade','$thought_thought','$ip','$thought_date')";
mysql_query($sql);
?>
That is the script I used with all the information from mysql still in it! So just modify it. Thought_thought was the box they put stuff in. Hope this helps. If not then its all good.
Chad