<?php
// Zeilenumbrüche verschiedener Betriebsysteme vereinheitlichen
function convertlinebreaks ($text) {
return preg_replace ("/\015\012|\015|\012/", "\n", $text);
}
// Alles bis auf Neuezeile-Zeichen entfernen
function bbcode_stripcontents ($text) {
return preg_replace ("/[^\n]/", '', $text);
}
function do_bbcode_url ($action, $attributes, $content, $params, $node_object) {
if (!isset ($attributes['default'])) {
$url = $content;
$text = htmlspecialchars ($content);
} else {
$url = $attributes['default'];
$text = $content;
}
if ($action == 'validate') {
if (substr ($url, 0, 5) == 'data:' || substr ($url, 0, 5) == 'file:'|| substr ($url, 0, 11) == 'javascript:' || substr ($url, 0, 4) == 'jar:') {
return false;
}
return true;
}
return '<a href="'.htmlspecialchars ($url).'">'.$text.'</a>';
}
// Funktion zum Einbinden von Bildern
function do_bbcode_img ($action, $attributes, $content, $params, $node_object) {
if ($action == 'validate') {
if (substr ($content, 0, 5) == 'data:' || substr ($content, 0, 5) == 'file:'|| substr ($content, 0, 11) == 'javascript:' || substr ($content, 0, 4) == 'jar:') {
return false;
}
return true;
}
return '<img src="'.htmlspecialchars($content).'" alt="">';
}
function smiley_replace($content){
$content = str_replace(':arrow:', '<img src="Picture/icon_arrow.gif">', $content);
$content = str_replace('8-)', '<img src="Picture/icon_cool.gif">', $content);
$content = str_replace(':cry:', '<img src="Picture/icon_cry.gif">', $content);
$content = str_replace(':D', '<img src="Picture/icon_e_biggrin.gif">', $content);
$content = str_replace(':?', '<img src="Picture/icon_e_confused.gif">', $content);
$content = str_replace(':geek:', '<img src="Picture/icon_e_geek.gif">', $content);
$content = str_replace(':(', '<img src="Picture/icon_e_sad.gif">', $content);
$content = str_replace(':)', '<img src="Picture/icon_e_smile.gif">', $content);
$content = str_replace(':o', '<img src="Picture/icon_e_surprised.gif">', $content);
$content = str_replace(':ugeek:', '<img src="Picture/icon_e_ugeek.gif">', $content);
$content = str_replace(';)', '<img src="Picture/icon_e_wink.gif">', $content);
$content = str_replace(':shock:', '<img src="Picture/icon_ekk.gif">', $content);
$content = str_replace(':evil:', '<img src="Picture/icon_evil.gif">', $content);
$content = str_replace(':!:', '<img src="Picture/icon_exclaim.gif">', $content);
$content = str_replace(':idea:', '<img src="Picture/icon_idea.gif">', $content);
$content = str_replace(':lol:', '<img src="Picture/icon_lol.gif">', $content);
$content = str_replace(':x', '<img src="Picture/icon_mad.gif">', $content);
$content = str_replace(':mrgreen:', '<img src="Picture/icon_mrgreen.gif">', $content);
$content = str_replace(':|', '<img src="Picture/icon_neutral.gif">', $content);
$content = str_replace(':?:', '<img src="Picture/icon_question.gif">', $content);
$content = str_replace(':P', '<img src="Picture/icon_razz.gif">', $content);
$content = str_replace(':oops:', '<img src="Picture/icon_redface.gif">', $content);
$content = str_replace(':roll:', '<img src="Picture/icon_rolleyes.gif">', $content);
$content = str_replace(':twisted:', '<img src="Picture/icon_twisted.gif">', $content);
return $content;
}
//$bbcode->addParser (':arrow:', 'simple_replace', null, array ('start_tag' => '<img src="Picture/icon_arrow.gif">', 'end_tag' => ''),'inline', array ('list'), array ());
//$bbcode->addParser ('8-)', 'simple_replace', null, array ('start_tag' => '<img src="Picture/icon_cool.gif">', 'end_tag' => ''),'inline', array ('list'), array ());
//$bbcode->addParser (':cry:', 'simple_replace', null, array ('start_tag' => '<img src="Picture/icon_cry.gif">', 'end_tag' => ''),'inline', array ('list'), array ());
//$bbcode->addParser (':D', 'simple_replace', null, array ('start_tag' => '<img src="Picture/icon_e_biggrin.gif">', 'end_tag' => ''),'inline', array ('list'), array ());
//$bbcode->addParser (':?', 'simple_replace', null, array ('start_tag' => '<img src="Picture/icon_e_confused.gif">', 'end_tag' => ''),'inline', array ('list'), array ());
//$bbcode->addParser (':geek:', 'simple_replace', null, array ('start_tag' => '<img src="Picture/icon_e_geek.gif">', 'end_tag' => ''),'inline', array ('list'), array ());
//$bbcode->addParser (':(', 'simple_replace', null, array ('start_tag' => '<img src="Picture/icon_e_sad.gif">', 'end_tag' => ''),'inline', array ('list'), array ());
//$bbcode->addParser (':)', 'simple_replace_single', null, array ('start_tag' => '<img src="Picture/icon_e_smile.gif">'),'inline', array ('list'), array ());
//$bbcode->addParser (':o', 'simple_replace', null, array ('start_tag' => '<img src="Picture/icon_e_surprised.gif">', 'end_tag' => ''),'inline', array ('list'), array ());
//$bbcode->addParser (':ugeek:', 'simple_replace', null, array ('start_tag' => '<img src="Picture/icon_e_ugeek.gif">', 'end_tag' => ''),'inline', array ('list'), array ());
//$bbcode->addParser (';)', 'simple_replace', null, array ('start_tag' => '<img src="Picture/icon_e_wink.gif">', 'end_tag' => ''),'inline', array ('list'), array ());
//$bbcode->addParser (':shock:', 'simple_replace', null, array ('start_tag' => '<img src="Picture/icon_ekk.gif">', 'end_tag' => ''),'inline', array ('list'), array ());
//$bbcode->addParser (':evil:', 'simple_replace', null, array ('start_tag' => '<img src="Picture/icon_evil.gif">', 'end_tag' => ''),'inline', array ('list'), array ());
//$bbcode->addParser (':!:', 'simple_replace', null, array ('start_tag' => '<img src="Picture/icon_exclaim.gif">', 'end_tag' => ''),'inline', array ('list'), array ());
//$bbcode->addParser (':idea:', 'simple_replace', null, array ('start_tag' => '<img src="Picture/icon_idea.gif">', 'end_tag' => ''),'inline', array ('list'), array ());
//$bbcode->addParser (':lol:', 'simple_replace', null, array ('start_tag' => '<img src="Picture/icon_lol.gif">', 'end_tag' => ''),'inline', array ('list'), array ());
//$bbcode->addParser (':x', 'simple_replace', null, array ('start_tag' => '<img src="Picture/icon_mad.gif">', 'end_tag' => ''),'inline', array ('list'), array ());
//$bbcode->addParser (':mrgreen:', 'simple_replace', null, array ('start_tag' => '<img src="Picture/icon_mrgreen.gif">', 'end_tag' => ''),'inline', array ('list'), array ());
//$bbcode->addParser (':|', 'simple_replace', null, array ('start_tag' => '<img src="Picture/icon_neutral.gif">', 'end_tag' => ''),'inline', array ('list'), array ());
//$bbcode->addParser (':?:', 'simple_replace', null, array ('start_tag' => '<img src="Picture/icon_question.gif">', 'end_tag' => ''),'inline', array ('list'), array ());
//$bbcode->addParser (':P', 'simple_replace', null, array ('start_tag' => '<img src="Picture/icon_razz.gif">', 'end_tag' => ''),'inline', array ('list'), array ());
//$bbcode->addParser (':oops:', 'simple_replace', null, array ('start_tag' => '<img src="Picture/icon_redface.gif">', 'end_tag' => ''),'inline', array ('list'), array ());
//$bbcode->addParser (':roll:', 'simple_replace', null, array ('start_tag' => '<img src="Picture/icon_rolleyes.gif">', 'end_tag' => ''),'inline', array ('list'), array ());
//$bbcode->addParser (':twisted:', 'simple_replace', null, array ('start_tag' => '<img src="Picture/icon_twisted.gif">', 'end_tag' => ''),'inline', array ('list'), array ());
//neue classe setzten
$bbcode = new StringParser_BBCode ();
//neuer Filter
$bbcode->addFilter (STRINGPARSER_FILTER_PRE, 'convertlinebreaks');
$bbcode->addParser('inline', 'smiley_replace');
$bbcode->addParser (array ('block', 'inline', 'link', 'listitem'), 'htmlspecialchars');
$bbcode->addParser (array ('block', 'inline', 'link', 'listitem'), 'nl2br');
$bbcode->addParser ('list', 'bbcode_stripcontents');
// alles replace
$bbcode->addCode ('b', 'simple_replace', null, array ('start_tag' => '<b>', 'end_tag' => '</b>'),'inline', array ('listitem', 'block', 'inline', 'link'), array ());
$bbcode->addCode ('i', 'simple_replace', null, array ('start_tag' => '<i>', 'end_tag' => '</i>'),'inline', array ('listitem', 'block', 'inline', 'link'), array ());
$bbcode->addCode ('u', 'simple_replace', null, array ('start_tag' => '<u>', 'end_tag' => '</u>'),'inline', array ('listitem', 'block', 'inline', 'link'), array ());
$bbcode->addCode ('sup', 'simple_replace', null, array ('start_tag' => '<sup>', 'end_tag' => '</sup>'),'inline', array ('listitem', 'block', 'inline', 'link'), array ());
$bbcode->addCode ('sub', 'simple_replace', null, array ('start_tag' => '<sub>', 'end_tag' => '</sub>'),'inline', array ('listitem', 'block', 'inline', 'link'), array ());
$bbcode->addCode ('small', 'simple_replace', null, array ('start_tag' => '<small>', 'end_tag' => '</small>'),'inline', array ('listitem', 'block', 'inline', 'link'), array ());
$bbcode->addCode ('big', 'simple_replace', null, array ('start_tag' => '<big>', 'end_tag' => '</big>'),'inline', array ('listitem', 'block', 'inline', 'link'), array ());
$bbcode->addCode ('center', 'simple_replace', null, array ('start_tag' => '<center>', 'end_tag' => '</center>'),'inline', array ('listitem', 'block', 'inline', 'link'), array ());
$bbcode->setOccurrenceType ('img', 'image');
$bbcode->setMaxOccurrences ('image', 2);
//smilies
//end smilies
$bbcode->addCode ('list', 'simple_replace', null, array ('start_tag' => '<ul>', 'end_tag' => '</ul>'),'list', array ('block', 'listitem'), array ());
$bbcode->addCode ('*', 'simple_replace', null, array ('start_tag' => '<li>', 'end_tag' => '</li>'),'listitem', array ('list'), array ());
$bbcode->addCode ('url', 'usecontent?', 'do_bbcode_url', array ('usecontent_param' => 'default'),'link', array ('listitem', 'block', 'inline'), array ('link'));
$bbcode->addCode ('img', 'usecontent', 'do_bbcode_img', array (),'image', array ('listitem', 'block', 'inline', 'link'), array ());
$bbcode->setCodeFlag ('*', 'closetag', BBCODE_CLOSETAG_OPTIONAL);
$bbcode->setCodeFlag (':)', 'closetag', BBCODE_CLOSETAG_OPTIONAL);
$bbcode->setCodeFlag ('*', 'paragraphs', true);
$bbcode->setCodeFlag ('list', 'paragraph_type', BBCODE_PARAGRAPH_BLOCK_ELEMENT);
$bbcode->setCodeFlag ('list', 'opentag.before.newline', BBCODE_NEWLINE_DROP);
$bbcode->setCodeFlag ('list', 'closetag.before.newline', BBCODE_NEWLINE_DROP);
$bbcode->setRootParagraphHandling (false);
?>