Ich könnte dir meinen BBCode-Auszug anbieten. Der sollte eigentlich valide sein...
Die Templates für die Code-Reihe sind auch anpassbar...
Wennde es verwenden kannst is gut, wenn nicht...ignoriers einfach
//edit: Sorry for Spam, aber spoiler gibbet hier nich^^
Zitier am besten den Post, wegen den ganzen in BBCode enthaltenen Tags ^^
PHP-Code:
<?php
function code_tpl($type,$src_code,$desc='')
{
$t_code['type']= "Code:";
$t_code['rgb'] = "dda";
$t_html['type']= "HTML-Code:";
$t_html['rgb'] = "ada";
$t_php['type'] = "PHP-Code:";
$t_php['rgb'] = "aad";
$t_svg['type'] = "SVG-Code:";
$t_svg['rgb'] = "dad";
$t_xml['type'] = "XML-Code:";
$t_xml['rgb'] = "daa";
$code_style = "
<ul><li style=\"background-color:#{rgb};\">{type}";
if(!empty($desc))
{ $code_style.="<li style=\"background-color:#{rgb};\">{desc}"; }
$code_style.="[*]{code}[/list]";
$code=eregi_replace("{type}",${"t_".$type}['type'],$code_style);
$code=eregi_replace("{rgb}", ${"t_".$type}['rgb'], $code);
$code=eregi_replace("{code}",$src_code, $code);
$code=eregi_replace("{desc}",$desc, $code);
return $code;
}
function TT_Code($string)
{
// $string = htmlspecialchars($string);
// [html=Info]HTML Code: Info[/html]
// [php=Info]PHP Code: Info[/___dummy___php]
$string = preg_replace("#\[code\](.*)\[\/code\]#Use", "code_tpl('code',highlight_string(stripslashes('$1'),true))", $string);
$string = preg_replace("#\[code=(.*)\](.*)\[\/code\]#Use","code_tpl('code',highlight_string(stripslashes('$2'),true),'$1')",$string);
$string = preg_replace("#\[html\](.*)\[\/html\]#Use", "code_tpl('html',highlight_string(stripslashes('$1'),true))", $string);
$string = preg_replace("#\[html=(.*)\](.*)\[\/html\]#Use","code_tpl('html',highlight_string(stripslashes('$2'),true),'$1')",$string);
$string = preg_replace("#\[php\](.*)\[\/php\]#Use", "code_tpl('php',highlight_string(stripslashes('$1'), true))", $string);
$string = preg_replace("#\[php=(.*)\](.*)\[\/php\]#Use", "code_tpl('php',highlight_string(stripslashes('$2'), true),'$1')",$string);
$string = preg_replace("#\[svg\](.*)\[\/svg\]#Use", "code_tpl('svg',highlight_string(stripslashes('$1'), true))", $string);
$string = preg_replace("#\[svg=(.*)\](.*)\[\/svg\]#Use", "code_tpl('svg',highlight_string(stripslashes('$2'), true),'$1')",$string);
$string = preg_replace("#\[xml\](.*)\[\/xml\]#Use", "code_tpl('xml',highlight_string(stripslashes('$1'),true))", $string);
$string = preg_replace("#\[xml=(.*)\](.*)\[\/xml\]#Use", "code_tpl('xml',highlight_string(stripslashes('$2'),true),'$1')", $string);
// \n durch ersetzen
$string = nl2br($string);
// [b]...[/b]
$string = preg_replace("~\[b\](.*)\[/b\]~Uis","[b]\\1[/b]",$string);
// [i]...[/i]
$string = preg_replace("~\[i\](.*)\[/i\]~Uis","[i]\\1[/i]",$string);
// [u]...[/u]
$string = preg_replace("~\[u\](.*)\[/u\]~Uis","<u>\\1</u>",$string);
//[list]...[/list] $string = preg_replace("~\[list\](.*)\[/list\]~Uis","<ul>\\1[/list]",$string);
// [item]...[/item]
$string = preg_replace("~\[item\](.*)\[/item\]~Uis","[*]\\1",$string);
// [center]...[/center]
$string = preg_replace("~\[center\](.*)\[/center\]~Uis","<center>\\1</center>",$string);
// [div=class_name]...[/div]
$string = preg_replace("~\[div=(.*)\](.*)\[/div\]~Uis","<div style=\"vertical-align:top\" class=\"\\1\">\\2</div>",$string);
// [float=clear]
$string = preg_replace("~\[float=clear\]~Uis","<br style=\"clear:both\" />",$string);
// [img]http://url[/img]
$string = preg_replace("~\[img\](.*)\[/img\]~Uis","<img src=\"\\1\" border=\"0\" alt=\"\" />",$string);
// [img-width]http://url[/img]
$string = preg_replace("~\[img-(.*){0,3}\](.*)\[/img\]~Uis","<img style=\"width]http://url[/img]
$string = preg_replace("~\[img-(.*){0,3}:(.*){0,3}\](.*)\[/img\]~Uis","<img style=\"width:\\1px;height:\\2px\" src=\"\\3\" border=\"0\" alt=\"\" />",$string);
// [img=svg]http://url[/img]
$string = preg_replace("~\[img=svg\](.*)\[/img\]~Uis","<object style=\"border:1px solid #f00;width:100%;height:100%\" data=\"\\1\" type=\"image/svg+xml\" codebase=\"http]http://url[/img]
$string = preg_replace("~\[img=svg-(.*){0,3}:(.*){0,3}\](.*)\[/img\]~Uis","<object style=\"border:1px solid #f00;\" width=\"\\1\" height=\"\\2\" data=\"\\3\" type=\"image/svg+xml\" codebase=\"http://www.adobe.com/svg/viewer/install/\"></object>",$string);
// [url]http://url[/url]
$string = preg_replace("~\[url\](.*)\[/url\]~Uis","<a href=\"\\1\">\\1</a>",$string);
// [url=http://url]Text[/url]
$string = preg_replace("~\[url=(.*)\](.*)\[/url\]~Uis","<a href=\"\\1\">\\2</a>",$string);
// [pre]Quelltext[/pre]
$string = preg_replace("~\[pre\](.*)\[/pre\]~Uis","<pre>\\1</pre>",$string);
// [abbr=Beschreibung]Kürzel[/abbr]
$string = preg_replace("~\[abbr=(.*)\](.*)\[/abbr\]~Uis","<abbr title=\"\\1\">\\2</abbr>",$string);
// & durch &
$string = eregi_replace(" & ", " & ",$string);
return $string;
}
?>
MfG,
Unsk1ll3d
__________________
Ich bin keine Signatur, ich putz hier nur
|