Форум: Форум PHPФорум ApacheФорум Регулярные ВыраженияФорум MySQLHTML+CSS+JavaScriptФорум FlashРазное
Новые темы: 0000000
Самоучитель PHP 5 / 6 (3 издание). Авторы: Кузнецов М.В., Симдянов И.В. Самоучитель MySQL 5. Авторы: Кузнецов М.В., Симдянов И.В. PHP Puzzles. Авторы: Кузнецов М.В., Симдянов И.В. PHP 5/6. В подлиннике. Авторы: Кузнецов М.В., Симдянов И.В. PHP 5. На примерах. Авторы: Кузнецов М.В., Симдянов И.В., Голышев С.В.
ВСЕ НАШИ КНИГИ
Консультационный центр SoftTime

Форум PHP

Выбрать другой форум

 

Здравствуйте, Посетитель!

вид форума:
Линейный форум Структурный форум

тема: фильтр матов в гостивой книге
 
 автор: Maloi   (11.04.2007 в 15:59)   письмо автору
 
 

Подскажите новичку как сделать фильтор матов в гостивой книге?

   
 
 автор: Nemesis   (11.04.2007 в 16:53)   письмо автору
 
   для: Maloi   (11.04.2007 в 15:59)
 

Можно попробовать такой класс:

<?
/********************************************/
/*Welcome to Anti Mate PHP Class source-code!*/
/*The Anti Mate PHP Class and its functions, contexture are copyrighted by s1ayer [www.spg.arbse.net]*/
/*Current file: anti_mate.php*/
/*Optimized for PHP 4.3.6, Apache 1.3.27*/
/********************************************/

setlocale (LC_ALL"ru_RU.CP1251");
/*<=====================Describing anti_mate class==============================>*/
class anti_mate {
    
//latin equivalents for russian letters
    
var $let_matches = array (
    
"a" => "а",
    
"c" => "с",
    
"e" => "е",
    
"k" => "к",
    
"m" => "м",
    
"o" => "о",
    
"x" => "х",
    
"y" => "у",
    
"ё" => "е"
                             
);
    
//bad words array. Regexp's symbols are readable !
    
var $bad_words = array (".*ху(й|и|я|е|л(и|е)).*"".*пизд.*""бл(я|т|д).*""(с|сц)ук(а|о|и).*""еб.*"".*уеб.*"".*пид(о|е)р.*"".*хер.*");
    
//if script will find bad word, it replace word to package of symbols below
    
var $rand_sym = array ("#""@""&""*");

function 
rand_replace (){
        for (
$i=0$i<5$i++)
        @
$output .= $this->rand_sym[rand(0,count($this->rand_sym)-1)];
        return 
$output;
}
function 
filter ($string){
            
$counter 0;
            
$elems explode (" "$string); //here we explode string to words
            
$count_elems count($elems);
            for (
$i=0$i<$count_elems$i++)
            {
            
$blocked 0;
            
/*formating word...*/
            
$str_rep eregi_replace ("[^a-zA-Zа-яА-Яё]"""strtolower($elems[$i]));
                for (
$j=0$j<strlen($str_rep); $j++)
                {
                    foreach (
$this->let_matches as $key => $value)
                    {
                        if (
$str_rep[$j] == $key)
                        
$str_rep[$j] = $value;

                    }
                }
            
/*done*/

            /*here we are trying to find bad word*/
            /*match in the special array*/
                
for ($k=0$k<count($this->bad_words); $k++)
                {
                    if (
ereg("\*$"$this->bad_words[$k]))
                    {
                        if (
ereg("^".$this->bad_words[$k], $str_rep))
                        {
                        
$elems[$i] = $this->rand_replace();
                        
$blocked 1;
                        
$counter++;
                        break;
                        }
                    
                    }
                    if (
$str_rep == $this->bad_words[$k]){
                    
$elems[$i] = $this->rand_replace();
                    
$blocked 1;
                    
$counter++;
                    break;
                    }

                }
            }
            if (
$counter != 0)
            
$string implode (" "$elems); //here we implode words in the whole string
return $string;
}
}
/*<===================================END=======================================>*/
?>

   
 
 автор: Саня   (11.04.2007 в 17:54)   письмо автору
 
   для: Maloi   (11.04.2007 в 15:59)
 

http://softtime.ru/forum/read.php?id_forum=1&id_theme=28859
http://softtime.ru/forum/read.php?id_forum=1&id_theme=14529
http://www.softtime.ru/info/matu_net.php

   
Rambler's Top100
вверх

Rambler's Top100 Яндекс.Метрика Яндекс цитирования