<?php
function php_highlight($input)
{
$output = "<br><table cellspacing=0 cellpadding=0 border=0 width=100%>
<tr><td width=40><td class=Tekst>Code</td></tr>
<tr><td height=1><td bgcolor=808080 height=1></tr>
<tr><td><td align=left valign=top>";
$output .= highlight_string(base64_decode($input[1]), TRUE);
$output .= "</tr>
<tr><td height=1><td bgcolor=808080 height=1></tr>
</table><p>";
return $output;
}
function encodeer($string)
{
return '[base64]'.base64_encode($string[1]).'[/base64]';
}
function ubb($string)
{
// code blocken
$string = preg_replace_callback("#\[code\](.*?)\[/code\]#si", "encodeer", $string);
$string = nl2br($string);
$string = preg_replace("#\[b\](.*?)\[/b\]#is", "<b>\${1}</b>", $string);
$string = preg_replace("#\[u\](.*?)\[/u\]#is", "<u>\${1}</u>", $string);
$string = preg_replace("#\[i\](.*?)\[/i\]#is", "<em>\${1}</em>", $string);
$string = preg_replace("#\[s\](.*?)\[/s\]#is", "<s>\${1}</s>", $string);
// [url]
$string = eregi_replace("\[url\]www.([^\[]*)","<a href="http://www.\\1" target=_blank>\\1", $string);
$string = eregi_replace("\[url\]([^\[]*)","<a href="\\1" target=_blank>\\1", $string);
$string = eregi_replace("(\[url=)([A-Za-z0-9_~&=;\?:%@#./\-]+[A-Za-z0-9/])(\])", "<a href="http://\\2" target=_blank>", $string);
$string = eregi_replace("\[url](http://(.*))", "<a href="\\1" target="_blank">\\1", $string);
$string = eregi_replace("(\[/url\])", "</a>", $string);
$string = eregi_replace("http://http://", "http://", $string);
// [/url]
$string = preg_replace("#\[color=(.*?)\](.*?)\[/color\]#si","<font color="\\1">\\2</font>", $string);
$string = preg_replace("#\[align=(.*?)\](.*?)\[/align\]#si","<div align="\\1">\\2</div>", $string);
$string = preg_replace("#\[size=(.*?)\](.*?)\[/size\]#si","<font size="\\1">\\2</font>", $string);
$string = preg_replace("#\[img\](.*?)\[/img\]#si","<img src="\\1" border="0" OnLoad="if (this.width > 400) { this.width = 400; }">", $string);
$string = eregi_replace("http://http://", "http://", $string);
$string = preg_replace_callback("#\[base64\](.*?)\[/base64\]#si", 'php_highlight', $string);
return $string;
}