<?
function BBcode($msg)
{
global $ank;
$bbcode=array();$bbcode['/\[br\]/isU']='<br />';
function img_preg($arr)
{
if (@imagecreatefromstring(file_get_contents($arr[1])))
{
return '<img style="max-width:240px;" src="'.$arr[1].'" alt="img" /></a>';		
}
else
{
return '<img style="max-width:240px;" src="/style/no_image.png" alt="No Image" />';	
}
}
function links_preg1($arr)
{
global $ank;
return '<a target=_blank href="' . $arr[1] . '">' . $arr[2] . '</a>';
}
global $ank;
if($ank[prava] == 5)$bbcode['/\[center\](.+)\[\/center\]/isU'] = '<center>$1</center>';
if($ank[prava] == 5)$msg = preg_replace_callback('/\[img\](.+)\[\/img\]/isU', 'img_preg', $msg);
if($ank[prava] == 5)$msg = preg_replace_callback('/\[url=(.+)\](.+)\[\/url\]/isU', 'links_preg1', $msg);
if (count($bbcode))$msg = preg_replace(array_keys($bbcode), array_values($bbcode), $msg);
return $msg;
}
?>