<?
function bbcodex($text){
$text=preg_replace('#\[url\=http://(.*)\](.*)\[/url\]#Ui','<a href="http://\\1">\\2</a>',$text);//для ссылок
$text=preg_replace('#\[u](.*)\[\/u\]#Ui','<u>\\1</u>',$text);//Подчеркнутый текст
$text=preg_replace('#\[i](.*)\[\/i\]#Ui','<i>\\1</i>',$text);
$text=preg_replace('#\[b](.*)\[\/b\]#Ui','<b>\\1</b>',$text);
$text=preg_replace('#\[big](.*)\[\/big\]#Ui','<big>\\1</big>',$text);//Большой
$text=preg_replace('#\[col\=(\#[0-9A-F]{3,6}|[a-z\-]+)\](.*)\[/col\]#Ui', '<font color="\\1">\\2</font>', $text);//для цветов
return($text);
}
function smilex($text){
$text=str_replace(':acute:', '<img src="/smile/acute.gif" alt=":acute:">',$text);
$text=str_replace(':blush2:', '<img src="/smile/blush2.gif" alt=":blush2:">',$text);
$text=str_replace(':aggressive:', '<img src="/smile/aggressive.gif" alt=":agressive:">',$text);
$text=str_replace(':agree:', '<img src="/smile/agree.gif" alt=":agree:">',$text);
$text=str_replace(':air_kiss:', '<img src="/smile/air_kiss.gif" alt=":air_kiss:">',$text);
$text=str_replace(':beee:', '<img src="/smile/beee.gif" alt=":beee:">',$text);
$text=str_replace(':black_eye:', '<img src="/smile/black_eye.gif" alt=":black_eye:">',$text);
$text=str_replace(':blum2:', '<img src="/smile/blum2.gif" alt=":blum2:">',$text);
$text=str_replace(':blum3:', '<img src="/smile/blum3.gif" alt=":blum3:">',$text);
$text=str_replace(':blush2:', '<img src="/smile/blush2.gif" alt=":blush2:">',$text);
$text=str_replace(':blush:', '<img src="/smile/blush.gif" alt=":blush:">',$text);
$text=str_replace(':boast:', '<img src="/smile/boast.gif" alt=":boast:">',$text);
$text=str_replace(':boredom:', '<img src="/smile/boredom.gif" alt=":boredom:">',$text);
$text=str_replace(':censored:', '<img src="/smile/censored.gif" alt=":censored:">',$text);
$text=str_replace(':clapping:', '<img src="/smile/clapping.gif" alt=":clapping:">',$text);
$text=str_replace(':cray:', '<img src="/smile/cray.gif" alt=":cray:">',$text);
$text=str_replace(':clapping:', '<img src="/smile/clapping.gif" alt=":clapping:">',$text);
$text=str_replace(':dance2:', '<img src="/smile/dance2.gif" alt=":dance2:">',$text);
$text=str_replace(':dance3:', '<img src="/smile/dance3.gif" alt=":dance3:">',$text);
$text=str_replace(':dance4:', '<img src="/smile/dance4.gif" alt=":dance4:">',$text);
$text=str_replace(':dance:', '<img src="/smile/dance.gif" alt=":dance:">',$text);
$text=str_replace(':declare:', '<img src="/smile/declare.gif" alt=":declare:">',$text);
$text=str_replace(':derisive:', '<img src="/smile/derisive.gif" alt=":derisive:">',$text);
$text=str_replace(':dirol:', '<img src="/smile/dirol.gif" alt=":dirol:">',$text);
$text=str_replace(':dntknw:', '<img src="/smile/dntknw.gif" alt=":dntknw:">',$text);
$text=str_replace(':don-t_mention:', '<img src="/smile/don-t_mention.gif" alt=":don-t_mention:">',$text);
$text=str_replace(':drinks.gif:', '<img src="/smile/drinks.gif" alt=":drinks:">',$text);
$text=str_replace(':fool:', '<img src="/smile/fool.gif" alt=":fool:">',$text);
$text=str_replace(':friends:', '<img src="/smile/friends.gif" alt=":friends:">',$text);
$text=str_replace(':good2:', '<img src="/smile/good2.gif" alt=":good2:">',$text);
$text=str_replace(':good3:', '<img src="/smile/good3.gif" alt=":good3.:">',$text);
$text=str_replace(':good:', '<img src="/smile/good.gif" alt=":good:">',$text);
$text=str_replace(':grin:', '<img src="/smile/grin.gif" alt=":grin:">',$text);
$text=str_replace(':heat:', '<img src="/smile/heat.gif" alt=":heat:">',$text);
$text=str_replace(':help:', '<img src="/smile/help.gif" alt=":help:">',$text);
$text=str_replace(':i-m_so_happy:', '<img src="/smile/i-m_so_happy.gif" alt=":i-m_so_happy:">',$text);
$text=str_replace(':ireful1:', '<img src="/smile/ireful1.gif" alt=":ireful1:">',$text);
$text=str_replace(':ireful2:', '<img src="/smile/ireful2.gif" alt=":ireful2:">',$text);
$text=str_replace(':laugh1:', '<img src="/smile/laugh1.gif" alt=":laugh1:">',$text);
$text=str_replace(':bad:', '<img src="/smile/bad.gif" alt=":bad:">',$text);
return($text);
}
function filtrx($text){
$text=htmlspecialchars(trim($text));
$text=stripslashes($text);
$text=str_replace("alert","_",$text);
$text=str_replace("%","pr",$text);
$text=str_replace("<","",$text);
$text=str_replace(">","",$text);
$text=str_replace("script","",$text);
$text=mysql_real_escape_string($text);
return($text);
}
?>