All pastes #572323 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-06-17 16:45 UTC
rendered paste body
<?

if ( !function_exists('htmlspecialchars_decode') )
{
   function htmlspecialchars_decode($text)
   {
       return strtr($text, array_flip(get_html_translation_table(HTML_SPECIALCHARS)));
   }
}

function bbcode($value)
{
$value = nl2br($value);

        $match = array(
            '#\[b\](.*?)\[\/b\]#se',
			
            '#\[i\](.*?)\[\/i\]#se',
			
            '#\[u\](.*?)\[\/u\]#se',
			
            '#\[s\](.*?)\[\/s\]#se',
			
            '#\[url=(.*?)\](.*?)\[\/url\]#se',
			
            '#\[url\](.*?)\[\/url\]#se',
			
            '#\[img\](.*?)\[\/img\]#se',
			
			'#\[quote\](.*?)\[\/quote\]#se',
			
            '#\[code\](.*?)\[\/code\]#se',
			
            '#\[php\](.*?)\[\/php\]#se',
			
            '#\[print\](.*?)\[\/print\]#se',
			
			'#\[center\](.*?)\[\/center\]#se',
			
			'#\[left\](.*?)\[\/left\]#se',
			
			'#\[right\](.*?)\[\/right\]#se',
			
			'#\[color=(.*?)\](.*?)\[/color\]#si',
			
			'#\[size=(.*?)\](.*?)\[/size\]#si',
			
			'#\[marquee\](.*?)\[/marquee\]#si',
			
			'#\[email\](.*?)\[/email\]#si',
#####################Smilies######################################################################			
			'#\:\)#', //:)
			
			'#\;\)#', //;)
			
			'#\(h\)#', //(h)
			
			'#\:P#', //:P
			
			'#\:\@#', //:@
			
			'#\:\(#', //:(
			
               );
        
        $replace = array(
            "'<strong>\\1</strong>'",
			
            "'<em>\\1</em>'",
			
            "'<u>\\1</u>'",
			
            "'<strike>\\1</strike>'",
			
			"'<a href=\"\\1\" target=\"_BLANK\">\\2</a>'",
			
            "'<a href=\"\\1\" target=\"_BLANK\">\\1</a>'",
			
            "'<img border=\"0\" src=\"\\1\">'",
			
			"'<h3 class=\"code\">Quote</h3>
<div style=\"border: 1px dotted #000000; background-color: #CCCCCC; overflow: auto;\">
'.str_replace('<br />', '', '$1').'</div>'",

            "'<h3 class=\"code\">Code</h3>
<div class=\"php\">
'.highlight_string(stripslashes(htmlspecialchars_decode(str_replace('<br />', '', '$1'))), true).'</div>'",

            "'<h3 class=\"code\">PHP Code</h3>
<div class=\"php\"> '.highlight_string(stripslashes(htmlspecialchars_decode(str_replace('<br />', '', '$1'))), true).'</div>'",

            "'<h3 class=\"code\">Print</h3>
<div class=\"php\">
'.highlight_string(stripslashes(htmlspecialchars_decode(str_replace('<br />', '', '$1'))), true).'</div>'",

"'<div style=\"text-align: center;\">\\1</div>'",

"'<div style=\"text-align: left;\">\\1</div>'",

"'<div style=\"text-align: right;\">\\1</div>'",

"<font color=\"\\1\">\\2</font>",

"<font style=\"font-size: \\1em;\">\\2</font>",

"<marquee>\\1</marquee>",

"<a href=\"mailto:\\1\">\\1</a>",
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Start Smilies /////////////////////////////////////////////////////////
"<img src=\"http://www.fm-fusion.com/images/smile.gif\" border=\"0\" />",

"<img src=\"http://www.fm-fusion.com/images/wink.gif\" border=\"0\" />",

"<img src=\"http://www.fm-fusion.com/images/cool.gif\" border=\"0\" />",

"<img src=\"http://www.fm-fusion.com/images/tongue.gif\" border=\"0\" />",

"<img src=\"http://www.fm-fusion.com/images/angry.gif\" border=\"0\" />",

"<img src=\"http://www.fm-fusion.com/images/sad.gif\" border=\"0\" />",
                );
				
        return preg_replace($match, $replace, $value);
}
?>