A new, object-oriented, better vesion of μForum
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

86 lines
3.3 KiB

<?php
/**
* @package uForum2
* @file inc/bbcode.php
* @copyright 2007-2015 (c) PioDer
* @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(
'<img src="images/smiles/smile.gif" alt=":)">', # :)
'<img src="images/smiles/neutral.gif" alt=":|">', # :|
'<img src="images/smiles/sad.gif" alt=":(" >', # :(
'<img src="images/smiles/cry.png" alt=":(" >', # ;(
'<img src="images/smiles/big_smile.gif" alt=":D" >', # :D
'<img src="images/smiles/yikes.gif" alt=":o" >', # :o
'<img src="images/smiles/wink.gif" alt=";)" >', # ;)
'<img src="images/smiles/tongue.gif" alt=":p" >', # :p
'<img src="images/smiles/curve.gif" alt=":/" >', # :curve:
'<img src="images/smiles/exclaim.gif" alt=":!:" >', # :!:
'<img src="images/smiles/lol.gif" alt=":lol:" >', # :lol:
'<img src="images/smiles/evil.gif" alt=":evil:" >', # :evil:
'<img src="images/smiles/mad.gif" alt=":mad:" >', # :mad:
'<img src="images/smiles/roll.gif" alt=":roll:" >', # :roll:
'<img src="images/smiles/cool.gif" alt=":cool:" >', # :cool:
'<img src="images/smiles/redface.gif" alt=":redface:" >', # :redface:
'<span style="font-weight: bold;">\1</span>', # [b]
'<span style="font-style: italic;">\1</i>', # [i]
'<span style="text-decoration: underline;">\1</span>', # [u]
'<span style="text-decoration: line-through;">\1</span>', # [s]
'<p style="text-align: center;">\1</p>', # [center]
'<a href="\1">\3</a>', # [url=]
'<a href="\1">\1</a>', # [url]
'<span style="color: #\1;">\2</span>', # [color] (hex)
'<span style="color: \1;">\2</span>', # [color] (text)
'<ul>\1</ul>', # [list]
'<li>\1</li>', # [*]
'<div class="qpost"><span style="font-weight: bold">Quote:</span><br>\1</div>', # [quote]
'<div class="qpost"><span style="font-weight: bold">\1 wrote:</span><br>\2</div>', # [quote=]
'<div class="cpost"><span style="font-weight: bold">Code:</span><br>\1</div>', # [code]
'<br>', # \n
'', # \r
'\\1<a href="\\2">\\2</a>',
);
return preg_replace($pattern, $replace, $content);
}
?>