<?php
function bb_b($str){
return preg_replace('/\[b](.*)\[\/b\]/i', '<strong>\\1</strong>',
$str);
}
function bb_i($str){
return preg_replace('/\[i](.*)\[\/i\]/i', '<em>\\1</em>',
$str);
}
function bb_u($str){
return preg_replace('/\[u](.*)\[\/u\]/i',
'<u>\\1</u>', $str);
}
function bb_url($str){
return preg_replace('/\[url=(.*)\](.*)\[\/url\]/i',
'<a href="\\1" target=_blank>\\2</a>', $str);
}
function bb_url1($str){
return preg_replace('/\[url\](.*)\[\/url\]/i',
'<a href="\\1" target=_blank>\\1</a>', $str);
}
function bb_php($str){
$str = str_replace("]\n", "]",
$str);
$str = str_replace("%spitzauf%",
"<", $str);
$str = str_replace("%spitzzu%",
">", $str);
$str = str_replace("<?php",
"", $str);
$str = str_replace("<?",
"", $str);
$str = str_replace("?>",
"", $str);
$match = array('#\[php\](.*?)\[\/php\]#se');
$replace = array("'<pre><table width=\"90%\"
border=\"0\" align=\"center\" cellpadding=\"0\"
cellspacing=\"0\"><tr><td><b>PHP-Code:</b></td></tr><tr><td
style=\"border: 1px solid #000000; background-color: #FFFFFF;\">'.highlight_string(stripslashes('<?php\n$1\n?>'),
true).'</td></tr></table></pre>'");
return preg_replace($match, $replace, $str);
}
function bb_code($str){
$str = str_replace("]\n", "]",
$str);
$match = array('#\[code\](.*?)\[\/code\]#se');
$replace = array("'<pre><table width=\"90%\"
border=\"0\" align=\"center\" cellpadding=\"0\"
cellspacing=\"0\"><tr><td><b>Code:</b></td></tr><tr><td
style=\"border: 1px solid #000000; background-color: #FFFFFF;\">'.nl2br(stripslashes('$1')).'</td></tr></table></pre>'");
return preg_replace($match, $replace, $str);
}
function bb_img($str){
return preg_replace('/\[img](.*)\[\/img\]/i',
'<img src="\\1" />', $str);
}
function bb_color($str){
return preg_replace('/\[color=(.*)\](.*)\[\/color\]/i',
'<font color=\\1>\\2</font>', $str);
}
function bb_email($str){
return preg_replace('/\[email](.*)\[\/email\]/i',
'<a href=mailto:\\1>\\1</a>', $str);
}
function bb_flash($str){
return preg_replace('/\[flash=(.*)x(.*)\](.*)\[\/flash\]/i',
'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/ shockwave/cabs/flash/swflash.cab#version=7,0,19,0"
width="\\1" height="\\2"><param name="movie"
value="\\3"><param name="quality" value="high"><embed
src="\\3" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer"
type="application/x-shockwave-flash" width="\\1"
height="\\2"></embed></object>', $str);
}
function bb_parse($str){
$str = str_replace("<", "%spitzauf%",
$str);
$str = str_replace(">", "%spitzzu%",
$str);
$str = nl2br($str);
$str = bb_code($str);
$str = bb_b($str);
$str = bb_i($str);
$str = bb_u($str);
$str = bb_url($str);
$str = bb_url1($str);
$str = bb_php($str);
$str = bb_img($str);
$str = bb_color($str);
$str = bb_email($str);
$str = bb_flash($str);
$str = str_replace("%spitzauf%",
"<", $str);
$str = str_replace("%spitzzu%",
">", $str);
return $str;
}
/* Beispiel
$string = "[b]fett[/b]";
echo bb_parse($string)
*/
?>
|