Просмотр файла header/function.inc.php

Размер файла: 37.11Kb
<?php

function text_captcha($length){
$val='qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM0123456789#';
for ($i=0;$i<strlen($val);$i++){
$v[]=$val[$i];
}
shuffle($v);
$val=implode("",$v);
return substr($val,0,$length);
}


function replacer($text,$r){
foreach ($r as $key=>$value){
$text=str_replace($key,$value,$text);
}
return $text;
}

/*
перевод строки в utf-8
*/
  function utf_encode ($s) {
  $russ=array("Й","Ц","У","К","Е","Н","Г","Ш","Щ","З","Х","Ъ","Ф","Ы","В","А","П","Р","О","Л","Д","Ж","Э","Я","Ч","С","М","И","Т","Ь","Б","Ю","й","ц","у","к","е","н","г","ш","щ","з","х","ъ","ф","ы","в","а","п","р","о","л","д","ж","э","я","ч","с","м","и","т","ь","б","ю","ё","Ё","№","«","»");
$uni=array("Р™","Р¦","РЈ","Рљ","Р•","Рќ","Р“","РЁ","Р©","Р—","РҐ","РЄ","Р¤","Р«","Р’","Рђ","Рџ","Р ","Рћ","Р›","Р”","Р–","Р­","РЇ","Р§","РЎ","Рњ","Р?","Рў","Р¬","Р‘","Р®","Р№","С†","Сѓ","Рє","Рµ","РЅ","Рі","С€","С‰","Р·","С…","СЉ","С„","С‹","РІ","Р°","Рї","СЂ","Рѕ","Р»","Рґ","Р¶","СЌ","СЏ","С‡","СЃ","Рј","Рё","С‚","СЊ","Р±","СЋ","С‘","РЃ","#",'&quot;','&quot;');
$n="";
for ($i=0;$i<strlen($s);$i++){
$numb=array_search($s[$i],$russ);
If ($numb!==false)
$n.=$uni[$numb];
else
$n.=$s[$i];
}
return $n;
  }
    /*
  function random_pay($number){//8055755796
  $ip=$_SERVER['REMOTE_ADDR'];

  If ($ip=='127.0.0.1') {
   return  '<a href="http://wap.1124.ru/partner/'.$number.'/game/top">лучшие загрузки</a>';
  }
$top[]="http://wap.1124.ru/pr/".$number."/mp3/top/";
$name[]="mp3";
$top[]="http://wap.1124.ru/partner/".$number."/nametone/top";
$name[]="nameton";
$top[]="http://wap.1124.ru/partner/".$number."/game/top";
$name[]="игра";
$top[]="http://wap.1124.ru/partner/".$number."/polyphone/top";
$name[]="полифония";
$top[]="http://wap.1124.ru/partner/".$number."/b/polyphone/top";
$name="полифония";
$top[]="http://wap.1124.ru/partner/".$number."/mp3/top";
$name="mp3-best";
$top[]="http://wap.1124.ru/partner/".$number."/realtone/top";
$name="реалтон";
$top[]="http://wap.1124.ru/partner/".$number."/video/top";
$name="видео";
$top[]="http://wap.1124.ru/partner/".$number."/theme/top";
$name="тема";


$numb=mt_rand(0,(count($top)-1));
$ns=$numb;
$file=@fopen($top[$numb],"r");

If (!$file){
$link='<a href="http://wap.1124.ru/partner/'.$number.'/game/top">лучшие загрузки</a>';
return $link;
}
$text="";
while ($gets=@fgets($file,1024)){
$text.=$gets;
}
$text=str_replace("</a>","</a>

",$text);
$text=str_replace('<img src="/','<img src="http://wap.1124.ru/',$text);
$i=0;
//echo $text;
while (true){
If (preg_match('%(<a href="){1}(.+)(,([^,]){1,7},){1}([0-9])+(">){1}(.)+(</a>){1}%',$text,$ar)){
$ar2[]=$ar[0];
$text=str_replace($ar[0],"",$text);
$i++;
} else break;
}
//echo $i;
If ($i>0){
$numb=mt_rand(0,count($ar2)-1);
$link=str_replace('<a href="','<a href="http://wap.1124.ru',$ar2[$numb]);}
If ($link)
$link=$ns.":".$link;
If (!@$link)$link='<a href="http://wap.1124.ru/partner/'.$number.'/game/top">лучшие загрузки</a>';
return $link;
}
      */
function cookie_encrypt($str,$id=0)
{
if (function_exists('mcrypt_module_open'))
{
$td = mcrypt_module_open ('rijndael-256', '', 'ofb', '');
if (!$iv=@file_get_contents(getcwd().'/header/shif_iv.dat'))
{
$iv=base64_encode( mcrypt_create_iv (mcrypt_enc_get_iv_size($td), MCRYPT_DEV_RANDOM));
file_put_contents(getcwd().'/header/shif_iv.dat', $iv);
chmod(getcwd().'/header/shif_iv.dat', 0777);
}
$ks = mcrypt_enc_get_key_size ($td);
$key = substr (md5 ($id.$_SERVER['HTTP_USER_AGENT']), 0, $ks);
mcrypt_generic_init ($td, $key, base64_decode($iv));
$str = mcrypt_generic ($td, $str);
mcrypt_generic_deinit ($td);
mcrypt_module_close ($td);
}
else
$str=base64_encode($str);
return $str;
}
function cookie_decrypt($str,$id=0)
{
if (function_exists('mcrypt_module_open'))
{
$td = mcrypt_module_open ('rijndael-256', '', 'ofb', '');
if (!$iv=@file_get_contents(getcwd().'/header/shif_iv.dat'))
{
$iv=base64_encode( mcrypt_create_iv (mcrypt_enc_get_iv_size($td), MCRYPT_DEV_RANDOM));
file_put_contents(getcwd().'/header/shif_iv.dat', $iv);
chmod(getcwd().'/header/shif_iv.dat', 0777);
}
$ks = mcrypt_enc_get_key_size ($td);
$key = substr (md5 ($id.$_SERVER['HTTP_USER_AGENT']), 0, $ks);
mcrypt_generic_init ($td, $key, base64_decode($iv));
$str = mdecrypt_generic ($td, $str);
mcrypt_generic_deinit ($td);
mcrypt_module_close ($td);
}
else
$str=base64_decode($str);
return $str;
}

 function txt($st){
 $st=str_replace("Р№","й",$st);
$st=str_replace("С†","ц",$st);
$st=str_replace("Сѓ","у",$st);
$st=str_replace("Рє","к",$st);
$st=str_replace("Рµ","е",$st);
$st=str_replace("РЅ","н",$st);
$st=str_replace("Рі","г",$st);
$st=str_replace("С€","ш",$st);
$st=str_replace("С‰","щ",$st);
$st=str_replace("Р·","з",$st);
$st=str_replace("С…","х",$st);
$st=str_replace("СЉ","ъ",$st);
$st=str_replace("С„","ф",$st);
$st=str_replace("С‹","ы",$st);
$st=str_replace("РІ","в",$st);
$st=str_replace("Р°","а",$st);
$st=str_replace("Рї","п",$st);
$st=str_replace("СЂ","р",$st);
$st=str_replace("Рѕ","о",$st);
$st=str_replace("Р»","л",$st);
$st=str_replace("Рґ","д",$st);
$st=str_replace("Р¶","ж",$st);
$st=str_replace("СЌ","э",$st);
$st=str_replace("СЏ","я",$st);
$st=str_replace("С‡","ч",$st);
$st=str_replace("СЃ","с",$st);
$st=str_replace("Рј","м",$st);
$st=str_replace("Рё","и",$st);
$st=str_replace("С‚","т",$st);
$st=str_replace("СЊ","ь",$st);
$st=str_replace("Р±","б",$st);
$st=str_replace("СЋ","ю",$st);
$st=str_replace("Р™","Й",$st);
$st=str_replace("Р¦","Ц",$st);
$st=str_replace("РЈ","У",$st);
$st=str_replace("Рљ","К",$st);
$st=str_replace("Р•","Е",$st);
$st=str_replace("Рќ","Н",$st);
$st=str_replace("Р“","Г",$st);
$st=str_replace("РЁ","Ш",$st);
$st=str_replace("Р©","Щ",$st);
$st=str_replace("Р—","З",$st);
$st=str_replace("РҐ","Х",$st);
$st=str_replace("РЄ","Ъ",$st);
$st=str_replace("Р¤","Ф",$st);
$st=str_replace("Р«","Ы",$st);
$st=str_replace("Р’","В",$st);
$st=str_replace("Рђ","А",$st);
$st=str_replace("Рџ","П",$st);
$st=str_replace("Р ","Р",$st);
$st=str_replace("Рћ","О",$st);
$st=str_replace("Р›","Л",$st);
$st=str_replace("Р”","Д",$st);
$st=str_replace("Р–","Ж",$st);
$st=str_replace("РЇ","Я",$st);
$st=str_replace("Р§","Ч",$st);
$st=str_replace("РЎ","С",$st);
$st=str_replace("Рњ","М",$st);
$st=str_replace("Р?","И",$st);
$st=str_replace("Рў","Т",$st);
$st=str_replace("Р¬","Ь",$st);
$st=str_replace("Р‘","Б",$st);
$st=str_replace("Р®","Ю",$st);
$st=str_replace("С‘","ё",$st);
$st=str_replace("РЃ","Ё",$st);
$st=str_replace("Р­","Э",$st);
 return htmlspecialchars(stripslashes($st));
 }
 function text($st){
$st=txt($st);
$st=del($st);
return $st;
}

function is_mobile() {
  $user_agent=strtolower(getenv('HTTP_USER_AGENT'));
  $accept=strtolower(getenv('HTTP_ACCEPT'));

  if ((strpos($accept,'text/vnd.wap.wml')!==false) ||
      (strpos($accept,'application/vnd.wap.xhtml+xml')!==false)) {
    return 1; // Мобильный браузер обнаружен по HTTP-заголовкам
  }

  if (isset($_SERVER['HTTP_X_WAP_PROFILE']) ||
      isset($_SERVER['HTTP_PROFILE'])) {
    return 2; // Мобильный браузер обнаружен по установкам сервера
  }

  if (preg_match('/(mini 9.5|opera mini|vx1000|lge |m800|e860|u940|ux840|compal|'.
    'wireless| mobi|ahong|lg380|lgku|lgu900|lg210|lg47|lg920|lg840|'.
    'lg370|sam-r|mg50|s55|g83|t66|vx400|mk99|d615|d763|el370|sl900|'.
    'mp500|samu3|samu4|vx10|xda_|samu5|samu6|samu7|samu9|a615|b832|'.
    'm881|s920|n210|s700|c-810|_h797|mob-x|sk16d|848b|mowser|s580|'.
    'r800|471x|v120|rim8|c500foma:|160x|x160|480x|x640|t503|w839|'.
    'i250|sprint|w398samr810|m5252|c7100|mt126|x225|s5330|s820|'.
    'htil-g1|fly v71|s302|-x113|novarra|k610i|-three|8325rc|8352rc|'.
    'sanyo|vx54|c888|nx250|n120|mtk |c5588|s710|t880|c5005|i;458x|'.
    'p404i|s210|c5100|teleca|s940|c500|s590|foma|samsu|vx8|vx9|a1000|'.
    '_mms|myx|a700|gu1100|bc831|e300|ems100|me701|me702m-three|sd588|'.
    's800|8325rc|ac831|mw200|brew |d88|htc\/|htc_touch|355x|m50|km100|'.
    'd736|p-9521|telco|sl74|ktouch|m4u\/|me702|8325rc|kddi|phone|lg |'.
    'sonyericsson|samsung|240x|x320vx10|nokia|sony cmd|motorola|'.
    'up.browser|up.link|mmp|symbian|smartphone|midp|wap|vodafone|o2|'.
    'pocket|kindle|mobile|psp|treo)/', $user_agent)) {
    return 3; // Мобильный браузер обнаружен по сигнатуре User Agent
  }

  if (in_array(substr($user_agent,0,4),
    Array("1207", "3gso", "4thp", "501i", "502i", "503i", "504i", "505i", "506i",
          "6310", "6590", "770s", "802s", "a wa", "abac", "acer", "acoo", "acs-",
          "aiko", "airn", "alav", "alca", "alco", "amoi", "anex", "anny", "anyw",
          "aptu", "arch", "argo", "aste", "asus", "attw", "au-m", "audi", "aur ",
          "aus ", "avan", "beck", "bell", "benq", "bilb", "bird", "blac", "blaz",
          "brew", "brvw", "bumb", "bw-n", "bw-u", "c55/", "capi", "ccwa", "cdm-",
          "cell", "chtm", "cldc", "cmd-", "cond", "craw", "dait", "dall", "dang",
          "dbte", "dc-s", "devi", "dica", "dmob", "doco", "dopo", "ds-d", "ds12",
          "el49", "elai", "eml2", "emul", "eric", "erk0", "esl8", "ez40", "ez60",
          "ez70", "ezos", "ezwa", "ezze", "fake", "fetc", "fly-", "fly_", "g-mo",
          "g1 u", "g560", "gene", "gf-5", "go.w", "good", "grad", "grun", "haie",
          "hcit", "hd-m", "hd-p", "hd-t", "hei-", "hiba", "hipt", "hita", "hp i",
          "hpip", "hs-c", "htc ", "htc-", "htc_", "htca", "htcg", "htcp", "htcs",
          "htct", "http", "huaw", "hutc", "i-20", "i-go", "i-ma", "i230", "iac",
          "iac-", "iac/", "ibro", "idea", "ig01", "ikom", "im1k", "inno", "ipaq",
          "iris", "jata", "java", "jbro", "jemu", "jigs", "kddi", "keji", "kgt",
          "kgt/", "klon", "kpt ", "kwc-", "kyoc", "kyok", "leno", "lexi", "lg g",
          "lg-a", "lg-b", "lg-c", "lg-d", "lg-f", "lg-g", "lg-k", "lg-l", "lg-m",
          "lg-o", "lg-p", "lg-s", "lg-t", "lg-u", "lg-w", "lg/k", "lg/l", "lg/u",
          "lg50", "lg54", "lge-", "lge/", "libw", "lynx", "m-cr", "m1-w", "m3ga",
          "m50/", "mate", "maui", "maxo", "mc01", "mc21", "mcca", "medi", "merc",
          "meri", "midp", "mio8", "mioa", "mits", "mmef", "mo01", "mo02", "mobi",
          "mode", "modo", "mot ", "mot-", "moto", "motv", "mozz", "mt50", "mtp1",
          "mtv ", "mwbp", "mywa", "n100", "n101", "n102", "n202", "n203", "n300",
          "n302", "n500", "n502", "n505", "n700", "n701", "n710", "nec-", "nem-",
          "neon", "netf", "newg", "newt", "nok6", "noki", "nzph", "o2 x", "o2-x",
          "o2im", "opti", "opwv", "oran", "owg1", "p800", "palm", "pana", "pand",
          "pant", "pdxg", "pg-1", "pg-2", "pg-3", "pg-6", "pg-8", "pg-c", "pg13",
          "phil", "pire", "play", "pluc", "pn-2", "pock", "port", "pose", "prox",
          "psio", "pt-g", "qa-a", "qc-2", "qc-3", "qc-5", "qc-7", "qc07", "qc12",
          "qc21", "qc32", "qc60", "qci-", "qtek", "qwap", "r380", "r600", "raks",
          "rim9", "rove", "rozo", "s55/", "sage", "sama", "samm", "sams", "sany",
          "sava", "sc01", "sch-", "scoo", "scp-", "sdk/", "se47", "sec-", "sec0",
          "sec1", "semc", "send", "seri", "sgh-", "shar", "sie-", "siem", "sk-0",
          "sl45", "slid", "smal", "smar", "smb3", "smit", "smt5", "soft", "sony",
          "sp01", "sph-", "spv ", "spv-", "sy01", "symb", "t-mo", "t218", "t250",
          "t600", "t610", "t618", "tagt", "talk", "tcl-", "tdg-", "teli", "telm",
          "tim-", "topl", "tosh", "treo", "ts70", "tsm-", "tsm3", "tsm5", "tx-9",
          "up.b", "upg1", "upsi", "utst", "v400", "v750", "veri", "virg", "vite",
          "vk-v", "vk40", "vk50", "vk52", "vk53", "vm40", "voda", "vulc", "vx52",
          "vx53", "vx60", "vx61", "vx70", "vx80", "vx81", "vx83", "vx85", "vx98",
          "w3c ", "w3c-", "wap-", "wapa", "wapi", "wapj", "wapm", "wapp", "wapr",
          "waps", "wapt", "wapu", "wapv", "wapy", "webc", "whit", "wig ", "winc",
          "winw", "wmlb", "wonu", "x700", "xda-", "xda2", "xdag", "yas-", "your",
          "zeto", "zte-"))) {
    return 4; // Мобильный браузер обнаружен по сигнатуре User Agent
  }

  return false; // Мобильный браузер не обнаружен
  }


function random_pay_text($number)
{
 return 	txt(random_pay($number));
}

function random_text($array){
return trim($array[mt_rand(0,count($array)-1)]);
}


 function del($mode){
return trim($mode);
}

function echo_menu($get,$mode,$id,$name,$menu,$g=''){//$get=имя переменной,$mode=настоящий мод,$id=мод текущего меню,$name,$menu-и так понятно.
 echo '<div class="main">[<a  class="wl" href="';


 If ($mode==$id) echo '?'.$g.$get.'=none">-</a>'; else  echo '?'.$g.'mode='.$id.'">+</a>';
 echo ']<b>'.$name.'</b></div>';
 If ($mode==$id){
	$t_menu='<div class="mainsub">';
	for ($i=0;$i<count($menu);$i++){
	$t_menu.='&gt; <a href="'.$menu[$i][0].'" class="white">'.$menu[$i][1].'</a><br/>';
		}
$t_menu.='</div>';
echo $t_menu;
}

}


function data_to_day($nach,$kon){
return ceil(($kon-$nach)/86400);
}

function hits($tip){
If (!file_exists("info_text/".$tip.".txt")){
$file=@fopen("info_text/".$tip.".txt","w+");
@fputs($file,date("d.m.y").';1;1');
@fclose($file);
return;
}
$file=@fopen("info_text/".$tip.".txt","r");
$text=@fgets($file,500);
@fclose($file);
$t=explode(";",$text);
$t[2]++;
If ($t[0]!=date("d.m.y")){
$file=@fopen("info_text/".$tip.".txt","w+");
@fputs($file,date("d.m.y").';1;'.$t[2]);
@fclose($file);
return;
}
$t[1]++;

$file=@fopen("info_text/".$tip.".txt","w+");
@fputs($file,$t[0].';'.$t[1].';'.$t[2]);
@fclose($file);
return;
}

function hits_view($tip){
If (!file_exists("info_text/".$tip.".txt")){
$file=@fopen("info_text/".$tip.".txt","w+");
@fputs($file,date("d.m.y").';0;0');
@fclose($file);
}
$file=@fopen("info_text/".$tip.".txt","r");
$text=@fgets($file,500);
@fclose($file);
$t=explode(";",$text);
return $t;
}

function formating($what,$to,$from){
	return	str_replace("<:".$what.":>",$to,$from);
}

function is_login($login){
		If (!preg_match("%^[_0-9a-zA-Zа-яА-Я -]{3,15}+$%",$login)) return false;
		return true;
}
function is_password($login){
		If (!preg_match("%^[0-9a-zA-Z]{3,15}$%",$login)) return false;
		return true;
}


function is_id($id){
If (!is_numeric($id)) return false;
If ($id<1) return false;
If ($id>1000000) return false;
If (floor($id)!=$id) return false;

return true;
}

function id_num_add($id,$min,$max,$float=false){
If (!is_numeric($id)) return false;
If ($id<$min) return false;
If ($id>$max) return false;

If (!$float) If (floor($id)!=$id) return false;

return true;
}

function is_text_add($text,$l,$return=false){
$text=text($text);
$len=strlen($text);
If ($len>$l || $len<1) return false;
If (!$return) return $text;
return true;
}


function echooptions($mas){
	foreach($mas as $key=>$value)
	echo '<option value="'.$key.'">'.$value.'</option>\r\n';
}

function rechooptions($mas,$default){

echo '<option value="'.$default.'">'.$mas[$default].'</option>';
	foreach($mas as $key=>$value)
	If ($key!=$default) 	echo '<option value="'.$key.'">'.$value.'</option>';
}


function sql_enter($sql,$table,$break=true){
global $_bdq;

$_bdq++;

$result=false;
$result=@mysql_query($sql);
If ($result===false){

	//записываем сообщение о ошибке.
@mysql_query("insert into `".$table."` (`error`,`ts`,`adress`) values ('".mysql_real_escape_string(mysql_error())."','".time()."','".mysql_real_escape_string($_SERVER['SCRIPT_FILENAME'])."')");

$id=mysql_insert_id();
If ($break) echo '<div class="error">Внутренняя ошибка системы! Если ошибка повторится, то сообщите о ней администратору. номер ошибки:'.$id.'</div>';

	return false;
	}

return $result;
}

function tr2rus($s)
	{
	$s=trim($s);

	//малые парные
	$s=str_replace("&#x27;",'ь', $s);
	$s=str_replace("&#x27;&#x27;",'Ь', $s);
    $s=str_replace('sh','ш', $s);
	$s=str_replace('sH','ш', $s);
	$s=str_replace('ГЁ','ш', $s);
	$s=str_replace('Г©','щ', $s);
	$s=str_replace('sch','щ', $s);
	$s=str_replace('scH','щ', $s);
	$s=str_replace('sCh','щ', $s);
	$s=str_replace('sCH','щ', $s);
	$s=str_replace('ch','ч', $s);
	$s=str_replace('cH','ч', $s);
	$s=str_replace('yo','ё', $s);
	$s=str_replace('yO','ё', $s);
	$s=str_replace('jo','ё', $s);
	$s=str_replace('jO','ё', $s);
	$s=str_replace('Г©','ё', $s);
	$s=str_replace('ye','э', $s);
	$s=str_replace('Г­С','э', $s);
	$s=str_replace('yE','э', $s);
	$s=str_replace('ya','я', $s);
	$s=str_replace('yA','я', $s);
	$s=str_replace('ja','я', $s);
	$s=str_replace('jA','я', $s);
	$s=str_replace('ГЇ','я', $s);
	$s=str_replace('yu','ю', $s);
	$s=str_replace('yU','ю', $s);
	$s=str_replace('ju','ю', $s);
	$s=str_replace('jU','ю', $s);
	$s=str_replace('Г®','ю', $s);
	$s=str_replace('zh','ж', $s);
	$s=str_replace('zH','ж', $s);
	$s=str_replace('ts','ц', $s);
	$s=str_replace('tS','ц', $s);
	$s=str_replace('Г¦','ц', $s);

	//мягкий знак
   	$s=str_replace("ìì",'Ь', $s);
	$s=str_replace("Г¬",'ь', $s);
	$s=str_replace("''",'Ь', $s);
	$s=str_replace("'",'ь', $s);

	//большие парные
	$s=str_replace('SH','Ш', $s);
	$s=str_replace('Sh','Ш', $s);
	$s=str_replace('SCH','Щ', $s);
	$s=str_replace('SCh','Щ', $s);
	$s=str_replace('ScH','Щ', $s);
	$s=str_replace('Sch','Щ', $s);
	$s=str_replace('Г‰','Щ', $s);
	$s=str_replace('CH','Ч', $s);
	$s=str_replace('Ch','Ч', $s);
	$s=str_replace('YO','Ё', $s);
	$s=str_replace('Yo','Ё', $s);
	$s=str_replace('JO','Ё', $s);
	$s=str_replace('Jo','Ё', $s);
	$s=str_replace('YE','Э', $s);
	$s=str_replace('Ye','Э', $s);
	$s=str_replace('YA','Я', $s);
	$s=str_replace('Ya','Я', $s);
	$s=str_replace('JA','Я', $s);
	$s=str_replace('Ja','Я', $s);
	$s=str_replace('ГЏ','Я', $s);
	$s=str_replace('YU','Ю', $s);
	$s=str_replace('Yu','Ю', $s);
	$s=str_replace('JU','Ю', $s);
	$s=str_replace('Ju','Ю', $s);
	$s=str_replace('ZH','Ж', $s);
	$s=str_replace('Zh','Ж', $s);
	$s=str_replace('TS','Ц', $s);
	$s=str_replace('Ts','Ц', $s);

	//малые одиночные
	$s=str_replace('a','а', $s);
	$s=str_replace('b','б', $s);
	$s=str_replace('c','ц', $s);
	$s=str_replace('d','д', $s);
	$s=str_replace('e','е', $s);
	$s=str_replace('f','ф', $s);
	$s=str_replace('g','г', $s);
	$s=str_replace('h','х', $s);
	$s=str_replace('ГҐ','х', $s);
	$s=str_replace('i','и', $s);
	$s=str_replace('j','й', $s);
	$s=str_replace('Г™','й', $s);
	$s=str_replace('k','к', $s);
	$s=str_replace('l','л', $s);
	$s=str_replace('m','м', $s);
	$s=str_replace('n','н', $s);
	$s=str_replace('o','о', $s);
	$s=str_replace('p','п', $s);
	$s=str_replace('q','ъ', $s);
	$s=str_replace('r','р', $s);
	$s=str_replace('s','с', $s);
	$s=str_replace('t','т', $s);
	$s=str_replace('y','ы', $s);
	$s=str_replace('Г«','ы', $s);
	$s=str_replace('u','у', $s);
	$s=str_replace('v','в', $s);
	$s=str_replace('w','в', $s);
	$s=str_replace('x','х', $s);
	$s=str_replace('z','з', $s);

	//большие одиночные
	$s=str_replace('A','А', $s);
	$s=str_replace('B','Б', $s);
	$s=str_replace('C','Ц', $s);
	$s=str_replace('D','Д', $s);
	$s=str_replace('E','Е', $s);
	$s=str_replace('F','Ф', $s);
	$s=str_replace('G','Г', $s);
	$s=str_replace('H','Х', $s);
	$s=str_replace('I','И', $s);
	$s=str_replace('J','Й', $s);
	$s=str_replace('K','К', $s);
	$s=str_replace('L','Л', $s);
	$s=str_replace('M','М', $s);
	$s=str_replace('N','Н', $s);
	$s=str_replace('O','О', $s);
	$s=str_replace('P','П', $s);
	$s=str_replace('Q','Ъ', $s);
	$s=str_replace('R','Р', $s);
	$s=str_replace('S','С', $s);
	$s=str_replace('T','Т', $s);
	$s=str_replace('U','У', $s);
	$s=str_replace('V','В', $s);
	$s=str_replace('W','В', $s);
	$s=str_replace('X','Х', $s);
	$s=str_replace('Y','Ы', $s);
	$s=str_replace('Z','З', $s);

	//исключения
	$s=str_replace('т.с','Тс', $s);
	$s=str_replace('Т.с','Тс', $s);
	$s=str_replace('т.С','тС', $s);
	$s=str_replace('Т.С','ТС', $s);

	$s=str_replace('с.ч','сч', $s);
	$s=str_replace('С.ч','Сч', $s);
	$s=str_replace('с.Ч','сЧ', $s);
	$s=str_replace('С.Ч','СЧ', $s);

	$s=str_replace('ы.е','ые', $s);
	$s=str_replace('Ы.е','Ые', $s);
	$s=str_replace('ы.Е','ыЕ', $s);
	$s=str_replace('Ы.Е','ЫЕ', $s);

	$s=str_replace('ы.а','ыа', $s);
	$s=str_replace('Ы.а','Ыа', $s);
	$s=str_replace('ы.А','ыА', $s);
	$s=str_replace('Ы.А','ЫА', $s);

	$s=str_replace('с.х','сх', $s);
	$s=str_replace('С.х','Сх', $s);
	$s=str_replace('с.Х','сХ', $s);
	$s=str_replace('С.Х','СХ', $s);

	$s=str_replace('ц.х','цх', $s);
	$s=str_replace('Ц.х','Цх', $s);
	$s=str_replace('ц.Х','цХ', $s);
	$s=str_replace('Ц.Х','ЦХ', $s);

	$s=str_replace('з.х','зх', $s);
	$s=str_replace('З.х','Зх', $s);
	$s=str_replace('з.Х','зХ', $s);
	$s=str_replace('З.Х','ЗХ', $s);
    return $s;
	}

      function bbcode($text)
{
$text = eregi_replace("(.*)\\[b\\](.*)\\[/b\\](.*)","\\1<b>\\2</b>\\3",$text);
$text = eregi_replace("(.*)\\[i\\](.*)\\[/i\\](.*)","\\1<i>\\2</i>\\3",$text);
$text = eregi_replace("(.*)\\[u\\](.*)\\[/u\\](.*)","\\1<u>\\2</u>\\3",$text);
$text = eregi_replace("(.*)\\[small\\](.*)\\[/small\\](.*)","\\1<small>\\2</small>\\3",$text);
$text = eregi_replace("(.*)\\[big\\](.*)\\[/big\\](.*)","\\1<big>\\2</big>\\3",$text);
$text = eregi_replace("(.*)\\[red\\](.*)\\[/red\\](.*)","\\1<font color=\"red\">\\2</font>\\3",$text);
$text = eregi_replace("(.*)\\[blue\\](.*)\\[/blue\\](.*)","\\1<font color=\"blue\">\\2</font>\\3",$text);
$text = eregi_replace("(.*)\\[green\\](.*)\\[/green\\](.*)","\\1<font color=\"green\">\\2</font>\\3",$text);

$text = eregi_replace("(.*)\\[lime\\](.*)\\[/lime\\](.*)","\\1<font color=#00FF00>\\2</font>\\3",$text);
$text = eregi_replace("(.*)\\[white\\](.*)\\[/white\\](.*)","\\1<font color=white>\\2</font>\\3",$text);
$text = eregi_replace("(.*)\\[golub\\](.*)\\[/golub\\](.*)","\\1<font color=#00FFFF>\\2</font>\\3",$text);
$text = eregi_replace("(.*)\\[yellow\\](.*)\\[/yellow\\](.*)","\\1<font color=yellow>\\2</font>\\3",$text);
$text = eregi_replace("(.*)\\[url\\]\\http://([0-9a-z_][0-9a-z./?&=]*)\\[/url\\](.*)","\\1<a href=\"http://\\2\">\\2</a>\\3",$text);

//$text = str_replace("http://site.ru", "(Реклама)",$text );

return $text;
}

function smiles($text)
{
$text=str_replace(':1:','<img src="/smile/1.gif" alt=":1:"/>',$text);
$text=str_replace(':)','<img src="/smile/1.gif" alt=":)"/>',$text);
$text=str_replace(':-)','<img src="/smile/1.gif" alt=":-)"/>',$text);
$text=str_replace(':2:','<img src="/smile/2.gif" alt=":2:"/>',$text);
$text=str_replace(':(','<img src="/smile/2.gif" alt=":("/>',$text);
$text=str_replace(':-(','<img src="/smile/2.gif" alt=":-("/>',$text);
$text=str_replace(':3:','<img src="/smile/3.gif" alt=":3:"/>',$text);
$text=str_replace('=)','<img src="/smile/3.gif" alt="=)"/>',$text);
$text=str_replace(':4:','<img src="/smile/4.gif" alt=":4:"/>',$text);
$text=str_replace(';)','<img src="/smile/4.gif" alt=";)"/>',$text);
$text=str_replace(';-)','<img src="/smile/4.gif" alt=";-)"/>',$text);
$text=str_replace(':5:','<img src="/smile/5.gif" alt=":5"/>',$text);
$text=str_replace('hack','<img src="/smile/5.gif" alt="hack"/>',$text);
$text=str_replace(':6:','<img src="/smile/6.gif" alt=":6:"/>',$text);
$text=str_replace('lol','<img src="/smile/6.gif" alt="lol"/>',$text);
$text=str_replace(':7:','<img src="/smile/7.gif" alt=":7:"/>',$text);
$text=str_replace(':D','<img src="/smile/7.gif" alt=":D"/>',$text);
$text=str_replace(':-D','<img src="/smile/7.gif" alt=":-D"/>',$text);
$text=str_replace(':d','<img src="/smile/7.gif" alt=":d"/>',$text);
$text=str_replace(':-d','<img src="/smile/7.gif" alt=":-d"/>',$text);
$text=str_replace(':8:','<img src="/smile/8.gif" alt=":8:"/>',$text);
$text=str_replace(']:->','<img src="/smile/8.gif" alt="]:->"/>',$text);
$text=str_replace('zloy','<img src="/smile/8.gif" alt="zloy"/>',$text);
$text=str_replace(':9:','<img src="/smile/9.gif" alt=":9:"/>',$text);
$text=str_replace('pzdc','<img src="/smile/9.gif" alt="pzdc"/>',$text);
$text=str_replace('PZDC','<img src="/smile/9.gif" alt="PZDC"/>',$text);
$text=str_replace(':10:','<img src="/smile/10.gif" alt=":10:"/>',$text);
$text=str_replace('dont_know','<img src="/smile/10.gif" alt="dont_know"/>',$text);
$text=str_replace('DONT_KNOW','<img src="/smile/10.gif" alt="DONT_KNOW"/>',$text);
$text=str_replace(':11:','<img src="/smile/11.gif" alt=":11:"/>',$text);
$text=str_replace('wall','<img src="/smile/11.gif" alt="wall"/>',$text);
$text=str_replace('WALL','<img src="/smile/11.gif" alt="WALL"/>',$text);
$text=str_replace(':12:','<img src="/smile/12.gif" alt=":12:"/>',$text);
$text=str_replace('=O','<img src="/smile/12.gif" alt="=O"/>',$text);
$text=str_replace('=-O','<img src="/smile/12.gif" alt="=-O"/>',$text);
$text=str_replace(':13:','<img src="/smile/13.gif" alt=":13:"/>',$text);
$text=str_replace('wow','<img src="/smile/13.gif" alt="wow"/>',$text);
$text=str_replace('WOW','<img src="/smile/13.gif" alt="WOW"/>',$text);
$text=str_replace(':14:','<img src="/smile/14.gif" alt=":14:"/>',$text);
$text=str_replace('dance','<img src="/smile/14.gif" alt="dance"/>',$text);
$text=str_replace('DANCE','<img src="/smile/14.gif" alt="DANCE"/>',$text);
$text=str_replace(':15:','<img src="/smile/15.gif" alt=":15:"/>',$text);
$text=str_replace('crazy','<img src="/smile/15.gif" alt="crazy"/>',$text);
$text=str_replace('CRAZY','<img src="/smile/15.gif" alt="CRAZY"/>',$text);
$text=str_replace(':16:','<img src="/smile/16.gif" alt=":16:"/>',$text);
$text=str_replace('0_0','<img src="/smile/16.gif" alt="0_0"/>',$text);
$text=str_replace(':17:','<img src="/smile/17.gif" alt=":17:"/>',$text);
$text=str_replace('scratch','<img src="/smile/17.gif" alt="scratch"/>',$text);
$text=str_replace('SCRATCH','<img src="/smile/17.gif" alt="SCRATCH"/>',$text);
$text=str_replace(':18:','<img src="/smile/18.gif" alt=":18:"/>',$text);
$text=str_replace('%]','<img src="/smile/18.gif" alt="%]"/>',$text);
$text=str_replace(':19:','<img src="/smile/19.gif" alt=":19:"/>',$text);
$text=str_replace(';/','<img src="/smile/19.gif" alt=";/"/>',$text);
$text=str_replace(';-/','<img src="/smile/19.gif" alt=";-/"/>',$text);
$text=str_replace(':20:','<img src="/smile/20.gif" alt=":20:"/>',$text);
$text=str_replace('thumbs_up','<img src="/smile/20.gif" alt="thumbs_up"/>',$text);
$text=str_replace('THUMBS_UP','<img src="/smile/20.gif" alt="THUMBS_UP"/>',$text);

$text=str_replace(':21:','<img src="/smile/21.gif" alt=":21:"/>',$text);
$text=str_replace('super','<img src="/smile/21.gif" alt="super"/>',$text);
$text=str_replace('SUPER','<img src="/smile/21.gif" alt="SUPER"/>',$text);
$text=str_replace(':22:','<img src="/smile/22.gif" alt=":22:"/>',$text);
$text=str_replace('ban','<img src="/smile/22.gif" alt="ban"/>',$text);
$text=str_replace('BAN','<img src="/smile/22.gif" alt="BAN"/>',$text);
$text=str_replace(':23:','<img src="/smile/23.gif" alt=":23:"/>',$text);
$text=str_replace('spam','<img src="/smile/23.gif" alt="spam"/>',$text);
$text=str_replace('SPAM','<img src="/smile/23.gif" alt="SPAM"/>',$text);
$text=str_replace(':24:','<img src="/smile/24.gif" alt=":24:"/>',$text);
$text=str_replace('closed','<img src="/smile/24.gif" alt="closed"/>',$text);
$text=str_replace('CLOSED','<img src="/smile/24.gif" alt="CLOSED"/>',$text);
$text=str_replace(':25:','<img src="/smile/25.gif" alt=":25:"/>',$text);
$text=str_replace('offtop','<img src="/smile/25.gif" alt="offtop"/>',$text);
$text=str_replace('OFFTOP','<img src="/smile/25.gif" alt="OFFTOP"/>',$text);
$text=str_replace(':26:','<img src="/smile/26.gif" alt=":26:"/>',$text);
$text=str_replace('\m/','<img src="/smile/26.gif" alt="\m/"/>',$text);
$text=str_replace('\M/','<img src="/smile/26.gif" alt="\M/"/>',$text);
$text=str_replace(':27:','<img src="/smile/27.gif" alt=":27:"/>',$text);
$text=str_replace('beer','<img src="/smile/27.gif" alt="beer"/>',$text);
$text=str_replace('BEER','<img src="/smile/27.gif" alt="BEER"/>',$text);
$text=str_replace(':28:','<img src="/smile/28.gif" alt=":28:"/>',$text);
$text=str_replace('write','<img src="/smile/28.gif" alt="write"/>',$text);
$text=str_replace('WRITE','<img src="/smile/28.gif" alt="WRITE"/>',$text);
$text=str_replace(':29:','<img src="/smile/29.gif" alt=":29:"/>',$text);
$text=str_replace('sorry','<img src="/smile/29.gif" alt="sorry"/>',$text);
$text=str_replace('SORRY','<img src="/smile/29.gif" alt="SORRY"/>',$text);
$text=str_replace(':30:','<img src="/smile/30.gif" alt=":30:"/>',$text);
$text=str_replace('.hi','<img src="/smile/30.gif" alt=".hi"/>',$text);
$text=str_replace('.HI','<img src="/smile/30.gif" alt=".HI"/>',$text);
///////////агресивные и злые/////
 $text=str_replace('.az1','<img src="/smile/agresivnie/1.gif" alt=".az1"/>',$text);
 $text=str_replace('.AZ1','<img src="/smile/agresivnie/1.gif" alt=".az1"/>',$text);
 $text=str_replace('.az2','<img src="/smile/agresivnie/2.gif" alt=".az2"/>',$text);
 $text=str_replace('.AZ2','<img src="/smile/agresivnie/2.gif" alt=".az2"/>',$text);
 $text=str_replace('.az3','<img src="/smile/agresivnie/3.gif" alt=".az3"/>',$text);
 $text=str_replace('.AZ3','<img src="/smile/agresivnie/3.gif" alt=".az3"/>',$text);
 $text=str_replace('.az4','<img src="/smile/agresivnie/4.gif" alt=".az4"/>',$text);
 $text=str_replace('.AZ4','<img src="/smile/agresivnie/4.gif" alt=".az4"/>',$text);
 $text=str_replace('.az5','<img src="/smile/agresivnie/5.gif" alt=".az5"/>',$text);
 $text=str_replace('.AZ5','<img src="/smile/agresivnie/5.gif" alt=".az5"/>',$text);
 $text=str_replace('.az6','<img src="/smile/agresivnie/6.gif" alt=".az6"/>',$text);
 $text=str_replace('.AZ6','<img src="/smile/agresivnie/6.gif" alt=".az6"/>',$text);
 $text=str_replace('.az7','<img src="/smile/agresivnie/7.gif" alt=".az7"/>',$text);
 $text=str_replace('.AZ7','<img src="/smile/agresivnie/7.gif" alt=".az7"/>',$text);
 $text=str_replace('.az8','<img src="/smile/agresivnie/8.gif" alt=".az8"/>',$text);
 $text=str_replace('.AZ8','<img src="/smile/agresivnie/8.gif" alt=".az8"/>',$text);
 $text=str_replace('.az9','<img src="/smile/agresivnie/9.gif" alt=".az9"/>',$text);
 $text=str_replace('.AZ9','<img src="/smile/agresivnie/9.gif" alt=".az9"/>',$text);
 $text=str_replace('.az10','<img src="/smile/agresivnie/10.gif" alt=".az10"/>',$text);
 $text=str_replace('.AZ10','<img src="/smile/agresivnie/10.gif" alt=".az10"/>',$text);
 $text=str_replace('.az11','<img src="/smile/agresivnie/11.gif" alt=".az11"/>',$text);
 $text=str_replace('.AZ11','<img src="/smile/agresivnie/11.gif" alt=".az11"/>',$text);
 $text=str_replace('.az12','<img src="/smile/agresivnie/12.gif" alt=".az12"/>',$text);
 $text=str_replace('.AZ12','<img src="/smile/agresivnie/12.gif" alt=".az12"/>',$text);
 $text=str_replace('.az13','<img src="/smile/agresivnie/13.gif" alt=".az13"/>',$text);
 $text=str_replace('.AZ13','<img src="/smile/agresivnie/13.gif" alt=".az13"/>',$text);
 $text=str_replace('.az14','<img src="/smile/agresivnie/14.gif" alt=".az14"/>',$text);
 $text=str_replace('.AZ14','<img src="/smile/agresivnie/14.gif" alt=".az14"/>',$text);
 $text=str_replace('.az15','<img src="/smile/agresivnie/15.gif" alt=".az15"/>',$text);
 $text=str_replace('.AZ15','<img src="/smile/agresivnie/15.gif" alt=".az15"/>',$text);
 $text=str_replace('.az16','<img src="/smile/agresivnie/16.gif" alt=".az16"/>',$text);
 $text=str_replace('.AZ16','<img src="/smile/agresivnie/16.gif" alt=".az16"/>',$text);
 $text=str_replace('.az17','<img src="/smile/agresivnie/17.gif" alt=".az17"/>',$text);
 $text=str_replace('.AZ17','<img src="/smile/agresivnie/17.gif" alt=".az17"/>',$text);
 $text=str_replace('.az18','<img src="/smile/agresivnie/18.gif" alt=".az18"/>',$text);
 $text=str_replace('.AZ18','<img src="/smile/agresivnie/18.gif" alt=".az18"/>',$text);
 $text=str_replace('.az19','<img src="/smile/agresivnie/19.gif" alt=".az19"/>',$text);
 $text=str_replace('.AZ19','<img src="/smile/agresivnie/19.gif" alt=".az19"/>',$text);
 $text=str_replace('.az20','<img src="/smile/agresivnie/20.gif" alt=".az20"/>',$text);
 $text=str_replace('.AZ20','<img src="/smile/agresivnie/20.gif" alt=".az20"/>',$text);
 $text=str_replace('.az21','<img src="/smile/agresivnie/21.gif" alt=".az21"/>',$text);
 $text=str_replace('.AZ21','<img src="/smile/agresivnie/21.gif" alt=".az21"/>',$text);
 $text=str_replace('.az22','<img src="/smile/agresivnie/22.gif" alt=".az22"/>',$text);
 $text=str_replace('.AZ22','<img src="/smile/agresivnie/22.gif" alt=".az22"/>',$text);

return $text;
}
function smile($sm)
{
$dir = opendir ("./smiles/");
while ($file = readdir($dir))
{
if (($file != ".") && ($file != ".."))
{
$smile_name=explode('.',$file);
$smile_name=$smile_name[0];
$sm1[]="<img src=\"smiles/$file\" alt=\"$smile_name\" />";
$sm2[]=".$smile_name.";
}
}
closedir($dir);
return str_replace($sm2, $sm1, $sm);
}

  function antirek ($text) {

	$text	=	ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", '[спам]', $text); // Замена ссылок в комментариях (антиспам).

	return $text;
}


	function symbol($text)
{
$text=str_replace("&","&amp;", $text);
$text=str_replace("$","\$", $text);
$text=str_replace("~","&tilde;", $text);
$text=str_replace("`","&quot;", $text);
$text=str_replace("\n","</br>", $text);
$text=str_replace("\r","", $text);
$text=str_replace("#","", $text);
$text=str_replace("*","", $text);
$text=str_replace("|","!", $text);
return $text;
}

function antimat($text)
{
$mat=array('блядь','сука','пидар','хуй','пизда','залупа','мудак','гандон','гондон','ебать','пиздец','пизду','ебало','ебло','мудила','сучка','чмо','ибало','ебалу');
$cm=count($mat);
for($i=0; $i<=$cm; $i++)
{
$checkmat = @strstr("$text", "$mat[$i]");
if($checkmat)
{
$text=str_replace("$mat[$i]","<font color='red'><b>мат</b></font>",$text);
}}
return $text;
}


function rexplode($sep,$which){
If (strpos($which,$sep)===false) $a[0]=$which; else $a=explode($sep,$which);
return $a;
}

function rsearch($who,$where,$sep,$sep1,$n){
/*
$who-что искать
$where-где
$sep-основной разделитель
$sep1-внутренний разделитель
$n-номер элемента во внутренней подстроке.
пример:
rsearch("hi!","privet,poka;zdarova,hi;hi!,zdarova!",";",",",1);
*/
$res=rexplode($sep,$where);

for ($i=0;$i<count($res);$i++){
$r1=rexplode($sep1,$res[$i]);
If ($r1[$i]==$who) return true;
}
return false;
}

function rimplode($sep,$which){
If (!is_array($which) || count($which)<=1) return $which; else return implode($sep,$which);
}

function num_online($zapros,$online,$time){

$sql="SELECT `id` FROM `".prefix."users` WHERE `where` LIKE '".mysql_real_escape_string($zapros)."' AND `online`>'".($time-$online*60)."'";
$result=sql_enter($sql,prefix."error");
If (!$result) return false;
return mysql_num_rows($result);
}

function rnd_array($shablon,$array){
/*
Шаблон задаётся в виде:
{:Имя эл. массива:}...{:Имя эл. массива:}...
*/
$rnd=mt_rand(0,count($array)-1);
$result=$shablon;
foreach ($array[$rnd] as $key=>$value) $result=str_replace("{:".$key.":}",$value,$result);
return $result;
}
  function noslashes ($sl) {
     $sl = str_replace("'", "&#039;", $sl);
     $sl = str_replace('"', "&quot;", $sl);


    $sl = str_replace('\\', "&#92;", $sl);
    $sl = str_replace("|", "I", $sl);
    $sl = str_replace("||", "I", $sl);
    $sl = str_replace("/\\\$/", "&#36;", $sl);
    $sl = mysql_real_escape_string($sl);
    return $sl;
}

  function parsebb ($bb) {

	# Если Вы не понимаете что это ...
	# Нетрогайте здесь ничего...
	# Если тронули, незачем потом писать что скрипт не работает!

	$bb = preg_replace( "#\[b\](.+?)\[/b\]#is", "<b>\\1</b>", $bb );
	$bb = preg_replace( "#\[i\](.+?)\[/i\]#is", "<i>\\1</i>", $bb );
	$bb = preg_replace( "#\[u\](.+?)\[/u\]#is", "<u>\\1</u>", $bb );
	$bb = preg_replace( "#\[s\](.+?)\[/s\]#is", "<s>\\1</s>", $bb );
        $bb = preg_replace('#\[c\](.+?)\[/c\]#si', '<div class="quote">\1</div>', $bb);

$bb = eregi_replace("(.*)\\[small\\](.*)\\[/small\\](.*)","\\1<small>\\2</small>\\3",$bb);
$bb = eregi_replace("(.*)\\[big\\](.*)\\[/big\\](.*)","\\1<big>\\2</big>\\3",$bb);
$bb = eregi_replace("(.*)\\[red\\](.*)\\[/red\\](.*)","\\1<font color=\"red\">\\2</font>\\3",$bb);
$bb = eregi_replace("(.*)\\[blue\\](.*)\\[/blue\\](.*)","\\1<font color=\"blue\">\\2</font>\\3",$bb);
$bb = eregi_replace("(.*)\\[green\\](.*)\\[/green\\](.*)","\\1<font color=\"green\">\\2</font>\\3",$bb);

$bb = eregi_replace("(.*)\\[lime\\](.*)\\[/lime\\](.*)","\\1<font color=#00FF00>\\2</font>\\3",$bb);
$bb = eregi_replace("(.*)\\[white\\](.*)\\[/white\\](.*)","\\1<font color=white>\\2</font>\\3",$bb);
$bb = eregi_replace("(.*)\\[golub\\](.*)\\[/golub\\](.*)","\\1<font color=#00FFFF>\\2</font>\\3",$bb);
$bb = eregi_replace("(.*)\\[yellow\\](.*)\\[/yellow\\](.*)","\\1<font color=yellow>\\2</font>\\3",$bb);

	$bb = preg_replace( "#\[center\](.+?)\[/center\]#is", "<center>\\1</center>", $bb );
	$bb = preg_replace( "#\[left\](.+?)\[/left\]#is", "<div align=\"left\">\\1</div>", $bb );
	$bb = preg_replace( "#\[right\](.+?)\[/right\]#is", "<div align=\"right\">\\1</div>", $bb );

	$bb = preg_replace( "#\[email\](\S+?)\[/email\]#i"                                                                , "<a href=\"mailto:\\1\">\\1</a>", $bb );
	$bb = preg_replace( "#\[email\s*=\s*\&quot\;([\.\w\-]+\@[\.\w\-]+\.[\.\w\-]+)\s*\&quot\;\s*\](.*?)\[\/email\]#i"  , "<a href=\"mailto:\\1\">\\2</a>", $bb );
	$bb = preg_replace( "#\[email\s*=\s*([\.\w\-]+\@[\.\w\-]+\.[\w\-]+)\s*\](.*?)\[\/email\]#i"                       , "<a href=\"mailto:\\1\">\\2</a>", $bb );

	$bb = preg_replace( "~\\[url=(.*?)\\](.*?)\\[/url\\]~", "<a href=\"http://\\1\">\\2</a>", $bb );

	$bb = preg_replace( "~\\[img\ alt=(.*?)\\](.+?)\[/img\]~", "<img src=\"http://\\2\" alt=\"\\1\" />", $bb );

	return $bb;
}
#(c)Манылов Павел,2006-2007
?>