{"id":811,"date":"2008-07-28T14:13:52","date_gmt":"2008-07-28T06:13:52","guid":{"rendered":"https:\/\/www.dremi.info\/?p=783"},"modified":"2008-07-28T14:13:52","modified_gmt":"2008-07-28T06:13:52","slug":"bad-word-filter-with-php","status":"publish","type":"post","link":"https:\/\/www.dremi.info\/tutorials\/php\/bad-word-filter-with-php.html","title":{"rendered":"BAD Word Filter with PHP"},"content":{"rendered":"
bad word mang nyEbelin kalo di komen2 ada karakter2 berbahaya kaya petik dua petik satu dan slash.
\nSebenernye kalo nyang pernah gw baca di forum phpbuilder.com
\ndengan menggunakan strip tags aja dah aman, tapi ada baikna kalo security form di lipatgandakan. mudah2an si berguna walopun fungsi bwatan gw ni cuma beberapa baris<\/p>\n
Code:<\/p>\n
\nfunction wordFilter($strToFilter)\n{\n$strToFilter = str_replace("'", "", $strToFilter);\n$strToFilter = str_replace(" ", " ", $strToFilter);\n$strToFilter = str_replace('"', "", $strToFilter);\n$strToFilter = str_replace("|", "", $strToFilter);\n$strToFilter = str_replace("\\'", "", $strToFilter);\n$strToFilter = str_replace("\\"", "", $strToFilter);\n$strToFilter = str_replace("\\\\", "", $strToFilter);\n$strToFilter = str_replace("\/", "", $strToFilter);\nreturn $strToFilter;\n}\n<\/pre>\ncontoh penggunaan:
\nCode:<\/p>\n\necho 'String lu: ';\necho $str = "Thank\\"s 'Brother' !";\necho '<BR> Dengan Filter akan menjadi: ';\necho wordFilter($str); \/\/hasilna: Thanks Brother !\n<\/pre>\n