View file XCMS_ver_1_0/system/antimat.php

File size: 2.42Kb
<?
/********************************************/
/*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=======================================>*/
?>