Langkah - langkah untuk membuat script penyaring kata kotor nya adalah
1. Buat Database dengan nama Buku dan Tabel dengan nama Tamu
Field | Type | Value | Extra |
id | int | 10 | Auto increamen (prymarykey) |
posting | text | ||
<?php mysql_connect("localhost","root",""); mysql_select_db("buku"); ?> |
2. Buat script index web( simpan dengan nama:index.php)
<html> <head> <?php define('IN_SCRIPT',true); require('katakotor.php'); ?> <meta http-equiv="Content-Language" conten="en-us> <form method="post" action="proses.php"><meta http-equiv="content-type"" content="text/html; charset=windows-1252"> <style type="text/css"> <!-- .style2 {color: #FFFFFF} .style3 {color: #000000} .style4 {color: #FF0000} --> </style> </head> <body> <h1 align="center">Posting</h1> <table width="100%" border="0" align="center" cellpadding="0" cellspacing="1"> <tr> <td><div align="center"> <textarea name="posting" cols="50" rows="5" id="posting"></textarea> </div></td> </tr> <tr> <td><div align="center"> <input type="submit" value="Submit" name="submit"> <input type="reset" value="reset" name="reset"> </div></td> </tr> </table> </form> <strong>Buku Tamu Sederhana</strong><br> <span class="style3"> <?php include("conn.inc.php"); $tampil=mysql_query("select*from tamu order by id desc"); while ($data=mysql_fetch_array($tampil)){ ?><hr> </span> <table width="500" align="center"> <tr> <td bgcolor="#006600"> <div align="right"></div> <span class="style2">:<?php echo $data['posting'];?></span></td> </tr> <tr> <td bgcolor="#FFFFFF"> <div align="left"></div> <?php echo "<a href=hapus.php?id=$data[id]>hapus</a>"; ?></td> </tr> </table> <br> <?php } ?> <p> </p> </body> </html> |
3. Buat proses untuk script( simpan dengan nama:proses.php)
<?php define('IN_SCRIPT',true); include("katakotor.php"); function filter_bad_words($text) { global $settings, $lang; $file =$settings['filter_lang']; if (file_exists($file)) { include_once($file); } foreach ($settings['badwords'] as $k => $v) { $text = preg_replace("/\b$k\b/i",$v,$text); } return $text; include("conn.inc.php");} if (isset($_POST['posting'])){ $posting=$_POST['posting']; $posting = filter_bad_words($posting); if (!empty($posting)){ $sql=mysql_query("INSERT INTO tamu(posting) VALUES('$posting')"); } if ($sql){ header ("location:index.php"); } else { echo "Proses input buku tamu,Gagal...."; } } ?> |
4. Buat script untuk kata - kata yang kita tidak ingin ada dalam website kita
<?php ?>$settings['badwords'] = array ( "p.o.y.o.k" => "* * *", "POYOK" => "Maaf kata ini tidak boleh ada di sini", "LONTE" => "* * *", "PELACUR" => "* * *", "AMAK KAU" => "* * *", "GACIK" => "* * *", "ANJIANG" => "* * *", "BARUAK" => "* * *", "GILO" => "* * *", "KONTOL" => "* * *", "PEPEK" => "* * *", "PANTEK" => "* * *", "TUMBUANG" => "* * *", "KONTUK" => "* * *", "KUNYUAK" => "* * *", "ANJIANG ANK" => "* * *", "POPOK" => "* * *", "KAMBIANG" => "* * *", "ANCUAK-ANCUAK" => "* * *", "KANTUIK" => "* * *", "KALEMPONG" => "* * *", "JALANG" => "* * *", "KUTANG" => "* * *", "KATIAK" => "* * *", "BONGAK" => "* * *", "ANDIA" => "* * *", "JABLAI" => "* * *", ); |
5. Selesai, jalankan script
{ 0 komentar... Views All / Send Comment! }
Posting Komentar