|
 |
|
การตัดคำหยาบในเว็บบอร์ดเราควรทำไงดีครับ คือผมเป็นคนหนึ่งที่ไม่ได้จบและเรียนมาทางคอมพิวเตอร์ |
|
 |
|
|
 |
 |
|
function CheckRude( $temp )
{
$wordrude = array( "ก.กุ๊กกุ๊ก","ข.ไข","แบนทำไม","จะไปรู้เหรอ" ) ; //คำหยาบ
$wordchange = "<font class=\"red\">xxx</font>"; //ข้อความที่ต้องการให้เปลี่ยนเป็น
for ( $i = 0 ; $i < sizeof( $wordrude ) ; $i++ )
{
$temp = eregi_replace ( $wordrude[$i] , $wordchange , $temp );
};
return $temp;
}
ส่วนการเอาไปใช้ก็เหมือน fucntion อื่นๆแหละครับ
เว็บไซต์ไม่มีไร comment ครับอิอิ
สู้ๆ
|
 |
 |
 |
 |
Date :
2009-03-25 23:28:40 |
By :
teez1232002 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
สร้างไฟล์ *.txt ชื่อ rude.txt ในไฟล์ ก็ใส่คำหยาบที่ต้องการตัดเอาไว้นะครับ
ลองเอาไปประยุกต์ใช้กันดูครับ
Code (PHP)
<?php
/* --------------- เริ่มเช็คคำหยาบ --------------- */
$filename="config/rude.txt";
$fp=fopen($filename,"r");
$data=fread($fp,filesize($filename));
fclose($fp);
$rudeword=explode("\n",trim($data));
$replace="<FONT COLOR='RED'>***</FONT>";
for($ii=0;$ii<count($rudeword);$ii++) {
$board_detail=str_replace(trim($rudeword[$ii]),$replace,$board_detail);
$board_topic=$rs[board_topic];
$board_topic=str_replace(trim($rudeword[$ii]),$replace,$board_topic);
$board_name=$rs[board_name];
$board_name=str_replace(trim($rudeword[$ii]),$replace,$board_name);
}
/* --------------- จบเช็คคำหยาบ --------------- */
?>
|
 |
 |
 |
 |
Date :
2009-03-25 23:32:14 |
By :
pokultra |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
             
|
 |
 |
 |
 |
Date :
2011-01-29 16:28:03 |
By :
ดี |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|