bad word filter – dremi.INFO https://www.dremi.info Software Development, Digital Marketing and News Mon, 28 Jul 2008 06:13:52 +0000 en-US hourly 1 https://wordpress.org/?v=6.5.2 https://www.dremi.info/wp-content/uploads/2020/12/cropped-icon-32x32.png bad word filter – dremi.INFO https://www.dremi.info 32 32 BAD Word Filter with PHP https://www.dremi.info/tutorials/php/bad-word-filter-with-php.html https://www.dremi.info/tutorials/php/bad-word-filter-with-php.html#respond Mon, 28 Jul 2008 06:13:52 +0000 https://www.dremi.info/?p=783 […]]]> bad word mang nyEbelin kalo di komen2 ada karakter2 berbahaya kaya petik dua petik satu dan slash.
Sebenernye kalo nyang pernah gw baca di forum phpbuilder.com
dengan 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

 

Code:

function wordFilter($strToFilter)
{
$strToFilter = str_replace("'", "", $strToFilter);
$strToFilter = str_replace("  ", " ", $strToFilter);
$strToFilter = str_replace('"', "", $strToFilter);
$strToFilter = str_replace("|", "", $strToFilter);
$strToFilter = str_replace("\'", "", $strToFilter);
$strToFilter = str_replace("\"", "", $strToFilter);
$strToFilter = str_replace("\\", "", $strToFilter);
$strToFilter = str_replace("/", "", $strToFilter);
return $strToFilter;
}

contoh penggunaan:
Code:

echo 'String lu: ';
echo $str = "Thank\"s   'Brother' !";
echo '<BR> Dengan Filter akan menjadi: ';
echo wordFilter($str); //hasilna: Thanks Brother !
]]>
https://www.dremi.info/tutorials/php/bad-word-filter-with-php.html/feed 0