<?
# Транслит
function trans($str) {
$tr = array(
"А"=>"a","Б"=>"b","В"=>"v","Г"=>"g",
"Д"=>"d","Е"=>"e","Ж"=>"j","З"=>"z","И"=>"i",
"Й"=>"y","К"=>"k","Л"=>"l","М"=>"m","Н"=>"n",
"О"=>"o","П"=>"p","Р"=>"r","С"=>"s","Т"=>"t",
"У"=>"u","Ф"=>"f","Х"=>"h","Ц"=>"ts","Ч"=>"ch",
"Ш"=>"sh","Щ"=>"sch","Ъ"=>"","Ы"=>"yi","Ь"=>"",
"Э"=>"e","Ю"=>"yu","Я"=>"ya","а"=>"a","б"=>"b",
"в"=>"v","г"=>"g","д"=>"d","е"=>"e","ж"=>"j",
"з"=>"z","и"=>"i","й"=>"y","к"=>"k","л"=>"l",
"м"=>"m","н"=>"n","о"=>"o","п"=>"p","р"=>"r",
"с"=>"s","т"=>"t","у"=>"u","ф"=>"f","х"=>"h",
"ц"=>"ts","ч"=>"ch","ш"=>"sh","щ"=>"sch","ъ"=>"y",
"ы"=>"yi","ь"=>"","э"=>"e","ю"=>"yu","я"=>"ya",
" "=> "_", "."=> "", "/"=> "_"
);
return strtr($str,$tr);
}
# BB-code
$home = 'http://'.txt($_SERVER['HTTP_HOST']).'';
function code($var){
$var = preg_replace('#\[php\](.+?)\[\/php\]#e', 'highlight_code("\1")', $var);
//$var = preg_replace('#\[code\](.*?)\[/code\]#ie', 'highlight("\1")', $var);
$var = preg_replace('#\[b\](.*?)\[/b\]#si', '<b>\1</b>', $var);
$var = preg_replace('#\[i\](.*?)\[/i\]#si', '<i>\1</i>', $var);
$var = preg_replace('#\[u\](.*?)\[/u\]#si', '<u>\1</u>', $var);
$var = preg_replace('#\[s\](.*?)\[/s\]#si', '<s>\1</s>', $var);
$var = preg_replace('#\[red\](.*?)\[/red\]#si', '<span style="color:red">\1</span>', $var);
$var = preg_replace('#\[green\](.*?)\[/green\]#si', '<span style="color:green">\1</span>', $var);
$var = preg_replace('#\[blue\](.*?)\[/blue\]#si', '<span style="color:blue">\1</span>', $var);
$var = preg_replace( "#\[center\](.+?)\[/center\]#is", "<center>\\1</center>", $var);
$var = preg_replace('#\[url\=(http\://.+)\](.+)\[/url\]#i','<a href="\1">\2</a>',$var);
$var = preg_replace( "~\\[img\](.+?)\[/img\]~", "<a href=\"\\1\"><img src=\"".$home."/system/resize.php?image=\\1\" alt=\"Картинка\" /></a>", $var);
$var = preg_replace( "#(^|[\n ])([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $var);
$var = preg_replace( "#(^|[\n ])((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>", $var);
$var = preg_replace( array ('#\[code\](.*?)\[\/code\]#se'), array ("''.highlight('$1').''"), str_replace("]\n", "]", $var));
return $var;
}
# Ф-я для показа ошибок
function error($var) {
if (!empty($var)) echo '<div class="main"><div class="error">'. $var .'</div></div>';
}
?>