관리-도구
편집 파일: class-badwords.php
<?php $badwords = array ( //"ass", "asshole", "ballsack", "bitch", "bastard", "clit", "cock", //"cum", "cunt", //"dick", "dike", "dildo", "fuck", "fucker", "fuckers", "fuckin", "fucking", "fucken", //"gay", "god damn", "goddamn", "hoe", "nigger", "jackoff", "jack-off", "jism", "jizm", "pussy", "shit", "shitting", "slut", "twat", "vagina", //"wack", //"whore" ); $wordreplace = array ( "!", "#", "%", "^", "&", "*" ); class badword { function word_filter($content) { global $badwords, $wordreplace; $count = count($badwords); $countfilter = count($wordreplace); // Loop through the badwords array for ($n = 0; $n < $count; ++$n, next ($badwords)) { //Create random replace characters $x = 2; $y = rand(4,7); $filter = ""; while ($x<="$y") { $f = rand(0,$countfilter); $filter .="$wordreplace[$f]"; $x++; } //Search for badwords in content $search = "$badwords[$n]"; //$content = preg_replace("'$search'i","$filter",$content); //$content = preg_replace("/(\w+)\s+$search\b/i","$filter",$content); $content = preg_replace("/$search\b/i","$filter",$content); } return $content; } function clean_badwords( $process_info ){ if (!is_array($process_info)){ // Process the data as array of info foreach ($process_info as $id => $result){ $process_info["$id"] = $this->word_filter($result); } }else{ // process as a string $process_info = $this->word_filter($process_info); } return $process_info; } // End clean_badwords function --------------------------------- } // End Class ?>