* @link http://www.pioder.pl/
* @license see LICENSE.txt
**/
function BBCode($content)
{
$pattern = array(
'/\:\)/s', # :)
'/\:\|/s', # :|
'/\:\(/s', # :(
'/\;\(/s', # ;(
'/\:D/is', # :D
'/\:o/is', # :o
'/\;\)/s', # ;)
'/\:p/is', # :p
'/\:curve:/is', # :curve:
'/\:!:/is', # :!:
'/\:lol\:/is', # :lol:
'/\:evil\:/is', # :evil:
'/\:mad\:/is', # :mad:
'/\:roll\:/is', # :roll:
'/\:cool\:/is', # :cool:
'/\:redface\:/is', # :redface:
'/\[b\](.*?)\[\/b\]/is', # [b]
'/\[i\](.*?)\[\/i\]/is', # [i]
'/\[u\](.*?)\[\/u\]/is', # [u]
'/\[s\](.*?)\[\/s\]/is', # [s]
'/\[center\](.*?)\[\/center\]/is', # [center]
'/\[url=((http:\/\/)[-a-zA-Z0-9@:%_\+.~#?&\/\/=]+)\](.*?)\[\/url\]/is', # [url=]
'/\[url]((http:\/\/)[-a-zA-Z0-9@:%_\+.~#?&\/\/=]+)\[\/url\]/is', # [url]
'/\[color=#?([A-F0-9]{3}|[A-F0-9]{6})\](.*?)\[\/color\]/is', # [color] (hex)
'/\[color=?([A-Z]+)\](.*?)\[\/color\]/is', # [color] (text)
'/\[list\](.*?)\[\/list\]/is', # [list]
'/\[\*\](.*?)(\n|\r\n)/is', # [*]
'/\[quote\](.*?)\[\/quote\]/is', # [quote]
'/\[quote=(.+?)\](.*?)\[\/quote\]/is', # [quote=]
'/\[code\](.*?)\[\/code\]/is', # [code]
'/\\n/', # \n
'/\\r/', # \r
'/(^|[^"])((http:\/\/)[-a-zA-Z0-9@:%_\+.~#?&\/\/=]+)/i',
);
$replace = array(
'', # :)
'', # :|
'', # :(
'', # ;(
'', # :D
'', # :o
'', # ;)
'', # :p
'', # :curve:
'', # :!:
'', # :lol:
'', # :evil:
'', # :mad:
'', # :roll:
'', # :cool:
'', # :redface:
'\1', # [b]
'\1', # [i]
'\1', # [u]
'\1', # [s]
'\1
', # [center]
'\3', # [url=]
'\1', # [url]
'\2', # [color] (hex)
'\2', # [color] (text)
'', # [list]
'\1', # [*]
'Quote:
\1
', # [quote]
'\1 wrote:
\2
', # [quote=]
'Code:
\1
', # [code]
'
', # \n
'', # \r
'\\1\\2',
);
return preg_replace($pattern, $replace, $content);
}
?>