Mailinglisten-Archive |
schau dir mal die funktion an: (ist aus unserem forum - www.phpbb.com - hab mir aber nicht die mühe gemacht jetzt genau des was du brauchst rauszuschreiben, weil ich gleich weg muss) function bbencode($message, $is_html_disabled) { // pad it with a space so we can distinguish between FALSE and matching the 1st char (index 0). // This is important; bbencode_quote(), bbencode_list(), and bbencode_code() all depend on it. $message = " " . $message; // First: If there isn't a "[" and a "]" in the message, don't bother. if (! (strpos($message, "[") && strpos($message, "]")) ) { // Remove padding, return. $message = substr($message, 1); return $message; } // [CODE] and [/CODE] for posting code (HTML, PHP, C etc etc) in your posts. $message = bbencode_code($message, $is_html_disabled); // [QUOTE] and [/QUOTE] for posting replies with quote, or just for quoting stuff. $message = bbencode_quote($message); // [list] and [list=x] for (un)ordered lists. $message = bbencode_list($message); // [b] and [/b] for bolding text. $message = preg_replace("/\[b\](.*?)\[\/b\]/si", "<!-- BBCode Start --><B>\\1</B><!-- BBCode End -->", $message); // [i] and [/i] for italicizing text. $message = preg_replace("/\[i\](.*?)\[\/i\]/si", "<!-- BBCode Start --><I>\\1</I><!-- BBCode End -->", $message); // [img]image_url_here[/img] code.. $message = preg_replace("/\[img\]([^?]*?)\[\/img\]/si", "<!-- BBCode Start --><IMG SRC=\"\\1\" BORDER=\"0\"><!-- BBCode End -->", $message); // Patterns and replacements for URL and email tags.. $patterns = array(); $replacements = array(); // [url]xxxx://www.phpbb.com[/url] code.. $patterns[0] = "#\[url\]([a-z]+?://){1}(.*?)\[/url\]#si"; $replacements[0] = '<!-- BBCode u1 Start --><A HREF="\1\2" TARGET="_blank">\1\2</A><!-- BBCode u1 End -->'; // [url]www.phpbb.com[/url] code.. (no xxxx:// prefix). $patterns[1] = "#\[url\](.*?)\[/url\]#si"; $replacements[1] = '<!-- BBCode u1 Start --><A HREF="http://\1" TARGET="_blank">\1</A><!-- BBCode u1 End -->'; // [url=xxxx://www.phpbb.com]phpBB[/url] code.. $patterns[2] = "#\[url=([a-z]+?://){1}(.*?)\](.*?)\[/url\]#si"; $replacements[2] = '<!-- BBCode u2 Start --><A HREF="\1\2" TARGET="_blank">\3</A><!-- BBCode u2 End -->'; // [url=www.phpbb.com]phpBB[/url] code.. (no xxxx:// prefix). $patterns[3] = "#\[url=(.*?)\](.*?)\[/url\]#si"; $replacements[3] = '<!-- BBCode u2 Start --><A HREF="http://\1" TARGET="_blank">\2</A><!-- BBCode u2 End -->'; // [email]user_(at)_domain.tld[/email] code.. $patterns[4] = "#\[email\](.*?)\[/email\]#si"; $replacements[4] = '<!-- BBCode Start --><A HREF="mailto:\1">\1</A><!-- BBCode End -->'; $message = preg_replace($patterns, $replacements, $message); // Remove our padding from the string.. $message = substr($message, 1); return $message; } // bbencode() gruß, david
php::bar PHP Wiki - Listenarchive