Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include("./bbcode/stringparser_bbcode.class.php");
- include("bbcode.colors.php"); //Farbnamen, mit ihren zugehörigen Farbwerten.
- include("bbcode.functions.php");
- //BBcode-Objekt
- $bbcode = new StringParser_BBCode();
- //keine unterscheidung zwischen groß und kleinschreibung
- $bbcode->setGlobalCaseSensitive(false);
- //BBCodes hinzufügen mit $bbcode->addCode( ... )
- /*
- * void addCode(string $code,
- * string $type,
- * string $callback,
- * string $params,
- * string $content_type,
- * array $allowed_in,
- * array $not_allowed_in);
- */
- // [b], [i] und [u]
- $bbcode->addCode ('b', 'simple_replace', null, array ('start_tag' => '<span style="font-weight:bold;">', 'end_tag' => '</span>'), 'inline', array ('block', 'inline', 'url'), array ());
- $bbcode->addCode ('i', 'simple_replace', null, array ('start_tag' => '<span style="font-style:italic;">', 'end_tag' => '</span>'), 'inline', array ('block', 'inline', 'url'), array ());
- $bbcode->addCode ('u', 'simple_replace', null, array ('start_tag' => '<span style="text-decoration:underline;">', 'end_tag' => '</span>'), 'inline', array ('block', 'inline', 'url'), array ());
- // [color]
- $bbcode->addCode ('color', 'callback_replace', 'bbcode_color', null, 'inline', array('block', 'inline', 'url'), array());
- // [code]
- $bbcode->addCode ('code', 'usecontent', 'bbcode_code', null, 'code', array('block', 'inline'), array());
- // [url]
- $bbcode->addCode ('url', 'usecontent?', 'bbcode_url', array ('usecontent_param' => 'default'), 'url', array('block', 'inline'), array('url'));
- // [img]
- $bbcode->addCode ('img', 'usecontent', 'bbcode_img', null, 'img', array('block', 'inline', 'url'), array());
- //der text der nicht von einem bbcode umgeben ist.
- $bbcode->addParser('block', 'htmlentitiesutf8');
- $bbcode->addParser('block', 'nl2br');
- //der text zwischen [b], [i] und [u]
- $bbcode->addParser('inline', 'htmlentitiesutf8');
- $bbcode->addParser('inline', 'nl2br');
- //der text zwischen [url]
- $bbcode->addParser('url', 'htmlentitiesutf8');
- $bbcode->addParser('url', 'nl2br');
- $beispieltext = <<<POSTDATA
- [b]Fetter Text[/b]
- [i]Kursiver Text[/i]
- [u]Unterstrichener Text[/u]
- [b]Komb[i]inier[/i]ter [u]Te[i]xt[/i][/u][/b]
- [code]
- <?php
- for(\$n=0; \$n<strlen(\$array); \$n++){
- echo "blubb".\$n."\\n";
- }
- ?>
- [/code]
- [url]http://www.google.de/[/url]
- [url=http://www.google.de/]Google[/url]
- [color=#ff0000]rot[/color]
- [color=#00f]blau[/color]
- [color=lime]grün[/color]
- simpler Spoiler schutz mit "color": [color text=black bg=black] DARTH VADER IST DER VATER VON LUKE SKYWALKER!!! [/color]
- [url=http://www.google.de/][color=blue]G[/color][color=red]o[/color][color=yellow]o[/color][color=blue]g[/color][color=green]l[/color][color=red]e[/color][/url]
- [img]http://img225.imageshack.us/img225/223/4chanuniversemininoqualii6.jpg[/img]
- [URL=http://img442.imageshack.us/my.php?image=120442632591vl8.jpg][IMG]http://img442.imageshack.us/img442/5418/120442632591vl8.th.jpg[/IMG][/URL]
- POSTDATA;
- $beispieltext = $bbcode->parse($beispieltext);
- echo $beispieltext;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement