/**
* Encodes the string
* Removes all html tags and exchanges only the ubb tags and with html tags.
*
*
* @access public
* @param String $str
* @return String
*
*
* @author Lennart Groetzbach <lennartg@web.de>
* @copyright Lennart Groetzbach <lennartg@web.de> - distributed under the LGPL
* @version 1.1 - 2002/10/27
*
* modified by greg, extracted method from class UBBCode , old name was encode
*/
function ubb_decode($str) {
$str = stripslashes($str);
$str = strip_tags($str);
$str = eregi_replace('\\[b]([^\\[]*)\\[/b\\]','<b>\\1</b>',$str);
$str = eregi_replace('\\[i]([^\\[]*)\\[/i\\]','<i>\\1</i>',$str);
$str = eregi_replace('\\[u]([^\\[]*)\\[/u\\]','<u>\\1</u>',$str);
//$str = eregi_replace('\\[center]([^\\[]*)\\[/center\\]','<center>\\1</center>',$str);
$str = eregi_replace('\\[fixed]([^\\[]*)\\[/fixed\\]','<pre>\\1</pre>',$str);
$str = eregi_replace('\\[url]http://([^\\[]*)\\[/url\\]','<a href="http://\\1" target="_blank">\\1</a>',$str);
$str = eregi_replace('\\[url]([^\\[]*)\\[/url\\]','<a href="http://\\1" target="_blank">\\1</a>',$str);
$str = eregi_replace('\\[color=([^\\[]*)\\]([^\\[]*)\\[/color\\]','<font color="\\1">\\2</font>',$str);
$str = eregi_replace('\\[url=http://([^\\[]*)\\]([^\\[]*)\\[/url\\]','<a href="http://\\1" target="_blank">\\2</a>',$str);
$str = eregi_replace('\\[url=([^\\[]*)\\]([^\\[]*)\\[/url\\]','<a href="http://\\1" target="_blank">\\2</a>',$str);
$str = eregi_replace('\\[email=([^\\[]*)\\]([^\\[]*)\\[/email\\]','<a href="mailto:\\1">\\2</a>',$str);
$str = eregi_replace('\\[img]([^\\[]*)\\[/img\\]','<img src="\\1" border=0>',$str);
$str = eregi_replace('quote\\]','quote]',$str); // make lower case
$str = eregi_replace('\[quote\]\r\n', '<blockquote><smallfont>Quote:</smallfont><hr>', $str);
$str = eregi_replace('\[quote\]', '<blockquote><smallfont>Quote:</smallfont><hr>', $str);
$str = eregi_replace('\[/quote\]\r\n', '<hr></blockquote>', $str);
$str = eregi_replace('\[/quote\]', '<hr></blockquote>', $str);
return nl2br($str);
} |