Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function parse_message($text)
- {
- global $pun_config, $lang_common, $pun_user;
- $text = pun_htmlspecialchars($text);
- if ($pun_config['o_censoring'] == '1')
- $text = censor_words($text);
- // Convert applicable characters to HTML entities
- //Protect ye father
- $string = "[img]";
- $paragraph = $text;
- if (preg_match_all("/" . preg_quote($string) . "/i", $paragraph, $matches)) {
- if (count($matches[0]) > 15){
- message("You have posted to many images, you are only allowed 15");
- exit;
- }
- }
- // If the message contains a code tag we have to split it up (text within [code][/code] shouldn't be touched)
- if (strpos($text, '[code]') !== false && strpos($text, '[/code]') !== false)
- list($inside, $text) = extract_blocks($text, '[code]', '[/code]');
- // Deal with newlines, tabs and multiple spaces
- $pattern = array("\n", "\t", ' ', ' ');
- $replace = array('<br />', '    ', '  ', '  ');
- $text = str_replace($pattern, $replace, $text);
- $RegEx = '%(\[quote(?:=[^\]]*)\].*?)?\[youtube\]http\://(.*?)youtube\.com/watch\?v\=(.*?)\[/youtube\](.*?\[/quote\])?%ie';
- if(preg_match_all($RegEx, $text, $matches,PREG_SET_ORDER)){
- foreach($matches as $match){
- if(!empty($match[0]) && empty($match[1]) && empty($match[4])){
- $text = str_replace($match[0], convert_youtube($match[2],$match[3]), $text);
- }else{
- $url = sprintf('http://%syoutube.com/watch?v=%s',$match[2],$match[3]);
- $text = str_replace($match[0], sprintf('%s<a href=\'%s\' target=\"_blank\">%s</a>%s',$match[1],$url,$url,$match[4]), $text);
- }
- }
- }
- $text = preg_replace( "`\[wshh\]http\://www\.worldstarhiphop\.com/videos/video\.php\?v\=(.*?)\[/wshh\]`ie","\convert_wshh('\\1')", $text);
- $text = preg_replace( "`\[vimeo\]http\://(.*?)vimeo\.com/(.*?)\[/vimeo\]`ie" , "\convert_vimeo('\\1','\\2')", $text );
- while ( preg_match( "#\[size=([^\]]+)\](.+?)\[/size\]#ies", $text ) )
- {
- $text = preg_replace( "#\[size=([^\]]+)\](.+?)\[/size\]#ies" , "\\regex_font_attr(array('s'=>'size','1'=>'\\1','2'=>'\\2'))", $text );
- }
- while ( preg_match( "#\[font=([^\]]+)\](.*?)\[/font\]#ies", $text ) )
- {
- $text = preg_replace( "#\[font=([^\]]+)\](.*?)\[/font\]#ies" , "\\regex_font_attr(array('s'=>'font','1'=>'\\1','2'=>'\\2'))", $text );
- }
- while( preg_match( "#\[color=([^\]]+)\](.+?)\[/color\]#ies", $text ) )
- {
- $text = preg_replace( "#\[color=([^\]]+)\](.+?)\[/color\]#ies" , "\\regex_font_attr(array('s'=>'col' ,'1'=>'\\1','2'=>'\\2'))", $text );
- }
- $quote_html = wrap_style( array( 'STYLE' => 'QUOTE' ) );
- //The Dirties
- $text = preg_replace( "#\[quote\]#ie" , "\\regex_simple_quote_tag()" , $text );
- $text = preg_replace( "#\[quote=([^\]]+?),([^\]]+?)\]#ie" , "\\regex_quote_tag('\\1', '\\2')" , $text );
- $text = preg_replace( "#\[quote=([^\]]+?)\]#ie" , "\\regex_quote_tag('\\1', '')" , $text );
- $text = preg_replace( "#\[/quote\]#ie" , "\\regex_close_quote()" , $text );
- $text = preg_replace( "#\[center\](.+?)\[/center\]#is", "<center>\\1</center>", $text );
- $text = preg_replace( "#\[url\](\S+?)\[/url\]#ie" , "\\regex_build_url(array('html' => '\\1', 'show' => '\\1'))", $text );
- $text = preg_replace( "#\[url\s*=\s*\"\;\s*(\S+?)\s*\"\;\s*\](.*?)\[\/url\]#ie" , "\\regex_build_url(array('html' => '\\1', 'show' => '\\2'))", $text );
- $text = preg_replace( "#\[url\s*=\s*(\S+?)\s*\](.*?)\[\/url\]#ie" , "\\regex_build_url(array('html' => '\\1', 'show' => '\\2'))", $text );
- $text = preg_replace( "#\[img\](.+?)\[/img\]#ie" , "\\regex_check_image('\\1')" , $text );
- //end Dirties
- $smilies=array
- (
- '#(?<!\w):\)(?!\w)#i' => '<img src=img/smileys/smile.gif alt=":)">',
- '#(?<!\w):\((?!\w)#i' => '<img src=img/smileys/sad.gif alt=":(">',
- '#(?<!\w);\)(?!\w)#i' => '<img src=img/smileys/wink.gif alt=";)">',
- '#(?<!\w):cool2:(?!\w)#i' => '<img src=img/smileys/cool2.gif alt=":cool2:">',
- '#(?<!\w):huh:(?!\w)#i' => '<img src=img/smileys/huh.gif alt=":huh:">',
- '#(?<!\w)\^_\^(?!\w)#i' => '<img src=img/smileys/happy.gif alt="^_^">',
- '#(?<!\w):o(?!\w)#i' => '<img src=img/smileys/ohmy.gif alt=":o">',
- '#(?<!\w):P(?!\w)#i' => '<img src=img/smileys/tongue.gif alt=":P">',
- '#(?<!\w):D(?!\w)#i' => '<img src=img/smileys/grin.gif alt=":D">',
- '#(?<!\w):lol:(?!\w)#i' => '<img src=img/smileys/laugh.gif alt=":lol:">',
- '#(?<!\w)B\)(?!\w)#i' => '<img src=img/smileys/cool.gif alt="B)">',
- '#(?<!\w):rolleyes:(?!\w)#i' => '<img src=img/smileys/rolleyes.gif alt=":rolleyes:">',
- '#(?<!\w)\-_\-(?!\w)#i' => '<img src=img/smileys/sleep.gif alt="-_-">',
- '#(?<!\w):wub:(?!\w)#i' => '<img src=img/smileys/wub.gif alt=":wub:">',
- '#(?<!\w):rofl:(?!\w)#i' => '<img src=img/smileys/rofl.gif alt=":rofl:">',
- '#(?<!\w):hail:(?!\w)#i' => '<img src=img/smileys/hail.gif alt=":hail:">',
- '#(?<!\w):blush:(?!\w)#i' => '<img src=img/smileys/blush.gif alt=":blush:">',
- '#(?<!\w):popcorn:(?!\w)#i' => '<img src=img/smileys/popcorn.gif alt=":popcorn:">',
- '#(?<!\w):yahoo:(?!\w)#i' => '<img src=img/smileys/yahoo.gif alt=":yahoo:">',
- '#(?<!\w):love:(?!\w)#i' => '<img src=img/smileys/love2.gif alt=":love:">',
- '#(?<!\w):unknow:(?!\w)#i' => '<img src=img/smileys/unknow.gif alt=":unknow:">',
- '#(?<!\w):drool:(?!\w)#i' => '<img src=img/smileys/drool.gif alt=":drool:">',
- '#(?<!\w):rifle:(?!\w)#i' => '<img src=img/smileys/rifle.gif alt=":rifle:">',
- '#(?<!\w):hi:(?!\w)#i' => '<img src=img/smileys/hi.gif alt=":hi:">',
- '#(?<!\w):negative:(?!\w)#i' => '<img src=img/smileys/negative.gif alt=":negative:">',
- '#(?<!\w):yoyo:(?!\w)#i' => '<img src=img/smileys/yo-yo.gif alt=":yoyo:">',
- '#(?<!\w):throat:(?!\w)#i' => '<img src=img/smileys/throat.gif alt=":throat:">',
- '#(?<!\w):cooldance:(?!\w)#i' => '<img src=img/smileys/CoolDance.gif alt=":cooldance:">',
- '#(?<!\w):wallbash:(?!\w)#i' => '<img src=img/smileys/headbash.gif alt=":wallbash:">',
- '#(?<!\w):fume:(?!\w)#i' => '<img src=img/smileys/ranting.gif alt=":fume:">',
- '#(?<!\w):pissed:(?!\w)#i' => '<img src=img/smileys/PissedOff.gif alt=":pissed:">',
- '#(?<!\w):evil:(?!\w)#i' => '<img src=img/smileys/devil.gif alt=":evil:">',
- '#(?<!\w):angel:(?!\w)#i' => '<img src=img/smileys/angel.gif alt=":angel:">',
- '#(?<!\w):finger:(?!\w)#i' => '<img src=img/smileys/finger.gif alt=":finger:">',
- '#(?<!\w):mgun:(?!\w)#i' => '<img src=img/smileys/machinegun.gif alt=":mgun:">',
- '#(?<!\w):banana:(?!\w)#i' => '<img src=img/smileys/banana.gif alt=":banana:">',
- '#(?<!\w):santa:(?!\w)#i' => '<img src=img/smileys/santa.gif alt=":santa:">',
- '#(?<!\w):heart2:(?!\w)#i' => '<img src=img/smileys/heart2.gif alt=":heart2:">',
- '#(?<!\w):cry:(?!\w)#i' => '<img src=img/smileys/cry3.gif alt=":cry:">',
- '#(?<!\w):unsure:(?!\w)#i' => '<img src=img/smileys/unsure.gif alt=":unsure:">',
- '#(?<!\w):hug:(?!\w)#i' => '<img src=img/smileys/hug.gif alt=":hug:">',
- '#(?<!\w):baby:(?!\w)#i' => '<img src=img/smileys/baby.gif alt=":baby:">',
- '#(?<!\w):ph34r:(?!\w)#i' => '<img src=img/smileys/ph34r.gif alt=":ph34r:">',
- '#(?<!\w):thumbsup:(?!\w)#i' => '<img src=img/smileys/thumbsup.gif alt=":thumbsup:">',
- '#(?<!\w):wacko:(?!\w)#i' => '<img src=img/smileys/wacko.gif alt=":wacko:">',
- '#<3#i' => '<img src=img/smileys/heart2.gif alt="<3">',
- '#<\_<#i' => '<img src=img/smileys/dry.gif alt="<_<">',
- );
- $text=preg_replace(array_keys($smilies), array_values($smilies), $text,7);
- $text = preg_replace( "#\[b\](.+?)\[/b\]#is", "<b>\\1</b>", $text );
- $text = preg_replace( "#\[i\](.+?)\[/i\]#is", "<i>\\1</i>", $text );
- $text = preg_replace( "#\[u\](.+?)\[/u\]#is", "<u>\\1</u>", $text );
- $text = preg_replace( "#\[desc\](.+?)\[/desc\]#is", "<div class='desc4'>\\1</div>", $text );
- return clean_paragraphs($text);
- }
Advertisement
Add Comment
Please, Sign In to add comment