<?
function bbcodehightlight($arr)
{
$arr[0]=html_entity_decode($arr[0], ENT_QUOTES, 'UTF-8');
return '<div class="cit" style="overflow:scroll;clip:auto;max-width:480px;">'.preg_replace('#<code>(.*?)</code>#si', '\\1' ,highlight_string($arr[0],1)).'</div>'."\n";
}



function BBcode($msg)
{




    $bbcode = array(
	'/\[i\](.+)\[\/i\]/isU' => '<em>$1</em>',
	'/\[b\](.+)\[\/b\]/isU' => '<strong>$1</strong>',
	'/\[u\](.+)\[\/u\]/isU' => '<span style="text-decoration:underline;">$1</span>',
	'/\[big\](.+)\[\/big\]/isU' => '<span style="font-size:large;">$1</span>',
	'/\[small\](.+)\[\/small\]/isU' => '<span style="font-size:small;">$1</span>',
	'/\[code\](.+)\[\/code\]/isU' => '<code>$1</code>',
	'/\[red\](.+)\[\/red\]/isU' => '<span style="color:#ff0000;">$1</span>',
	'/\[yellow\](.+)\[\/yellow\]/isU' => '<span style="color:#ffff22;">$1</span>',
	'/\[green\](.+)\[\/green\]/isU' => '<span style="color:#00bb00;">$1</span>',
	'/\[blue\](.+)\[\/blue\]/isU' => '<span style="color:#0000bb;">$1</span>',
	'/\[white\](.+)\[\/white\]/isU' => '<span style="color:#ffffff;">$1</span>',
	'/\[size=([0-9]+)\](.+)\[\/size\]/isU' => '<span style="font-size:$1px;">$2</span>',
	'/\[img\](.+)\[\/img\]/isU' => '<img src="$1" alt="" />'
	);
    $msg= preg_replace(array_keys($bbcode), array_values($bbcode), $msg);


$msg=preg_replace_callback('#&lt;\?(.*?)\?&gt;#sui', 'bbcodehightlight', $msg);
$msg=preg_replace('#\[code\](.*?)\[/code\]#si', '\1', $msg);

return $msg;
}
?>