Guest User

Untitled

a guest
Feb 27th, 2012
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.48 KB | None | 0 0
  1. function parse_message($text)
  2. {
  3. global $pun_config, $lang_common, $pun_user;
  4. $text = pun_htmlspecialchars($text);
  5. if ($pun_config['o_censoring'] == '1')
  6. $text = censor_words($text);
  7.  
  8. // Convert applicable characters to HTML entities
  9. //Protect ye father
  10. $string = "[img]";
  11. $paragraph = $text;
  12. if (preg_match_all("/" . preg_quote($string) . "/i", $paragraph, $matches)) {
  13. if (count($matches[0]) > 15){
  14. message("You have posted to many images, you are only allowed 15");
  15. exit;
  16. }
  17. }
  18.  
  19. // If the message contains a code tag we have to split it up (text within [code][/code] shouldn't be touched)
  20. if (strpos($text, '[code]') !== false && strpos($text, '[/code]') !== false)
  21. list($inside, $text) = extract_blocks($text, '[code]', '[/code]');
  22.  
  23. // Deal with newlines, tabs and multiple spaces
  24. $pattern = array("\n", "\t", ' ', ' ');
  25. $replace = array('<br />', '&#160; &#160; ', '&#160; ', ' &#160;');
  26. $text = str_replace($pattern, $replace, $text);
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37. $RegEx = '%(\[quote(?:=[^\]]*)\].*?)?\[youtube\]http\://(.*?)youtube\.com/watch\?v\=(.*?)\[/youtube\](.*?\[/quote\])?%ie';
  38. if(preg_match_all($RegEx, $text, $matches,PREG_SET_ORDER)){
  39. foreach($matches as $match){
  40. if(!empty($match[0]) && empty($match[1]) && empty($match[4])){
  41. $text = str_replace($match[0], convert_youtube($match[2],$match[3]), $text);
  42. }else{
  43. $url = sprintf('http://%syoutube.com/watch?v=%s',$match[2],$match[3]);
  44. $text = str_replace($match[0], sprintf('%s<a href=\'%s\' target=\"_blank\">%s</a>%s',$match[1],$url,$url,$match[4]), $text);
  45.  
  46. }
  47. }
  48. }
  49. $text = preg_replace( "`\[wshh\]http\://www\.worldstarhiphop\.com/videos/video\.php\?v\=(.*?)\[/wshh\]`ie","\convert_wshh('\\1')", $text);
  50. $text = preg_replace( "`\[vimeo\]http\://(.*?)vimeo\.com/(.*?)\[/vimeo\]`ie" , "\convert_vimeo('\\1','\\2')", $text );
  51.  
  52.  
  53.  
  54.  
  55.  
  56. while ( preg_match( "#\[size=([^\]]+)\](.+?)\[/size\]#ies", $text ) )
  57. {
  58. $text = preg_replace( "#\[size=([^\]]+)\](.+?)\[/size\]#ies" , "\\regex_font_attr(array('s'=>'size','1'=>'\\1','2'=>'\\2'))", $text );
  59. }
  60.  
  61. while ( preg_match( "#\[font=([^\]]+)\](.*?)\[/font\]#ies", $text ) )
  62. {
  63. $text = preg_replace( "#\[font=([^\]]+)\](.*?)\[/font\]#ies" , "\\regex_font_attr(array('s'=>'font','1'=>'\\1','2'=>'\\2'))", $text );
  64. }
  65.  
  66. while( preg_match( "#\[color=([^\]]+)\](.+?)\[/color\]#ies", $text ) )
  67. {
  68. $text = preg_replace( "#\[color=([^\]]+)\](.+?)\[/color\]#ies" , "\\regex_font_attr(array('s'=>'col' ,'1'=>'\\1','2'=>'\\2'))", $text );
  69. }
  70.  
  71.  
  72.  
  73.  
  74. $quote_html = wrap_style( array( 'STYLE' => 'QUOTE' ) );
  75.  
  76. //The Dirties
  77. $text = preg_replace( "#\[quote\]#ie" , "\\regex_simple_quote_tag()" , $text );
  78. $text = preg_replace( "#\[quote=([^\]]+?),([^\]]+?)\]#ie" , "\\regex_quote_tag('\\1', '\\2')" , $text );
  79. $text = preg_replace( "#\[quote=([^\]]+?)\]#ie" , "\\regex_quote_tag('\\1', '')" , $text );
  80. $text = preg_replace( "#\[/quote\]#ie" , "\\regex_close_quote()" , $text );
  81. $text = preg_replace( "#\[center\](.+?)\[/center\]#is", "<center>\\1</center>", $text );
  82. $text = preg_replace( "#\[url\](\S+?)\[/url\]#ie" , "\\regex_build_url(array('html' => '\\1', 'show' => '\\1'))", $text );
  83. $text = preg_replace( "#\[url\s*=\s*\&quot\;\s*(\S+?)\s*\&quot\;\s*\](.*?)\[\/url\]#ie" , "\\regex_build_url(array('html' => '\\1', 'show' => '\\2'))", $text );
  84. $text = preg_replace( "#\[url\s*=\s*(\S+?)\s*\](.*?)\[\/url\]#ie" , "\\regex_build_url(array('html' => '\\1', 'show' => '\\2'))", $text );
  85. $text = preg_replace( "#\[img\](.+?)\[/img\]#ie" , "\\regex_check_image('\\1')" , $text );
  86. //end Dirties
  87.  
  88. $smilies=array
  89. (
  90. '#(?<!\w):\)(?!\w)#i' => '<img src=img/smileys/smile.gif alt=":)">',
  91. '#(?<!\w):\((?!\w)#i' => '<img src=img/smileys/sad.gif alt=":(">',
  92. '#(?<!\w);\)(?!\w)#i' => '<img src=img/smileys/wink.gif alt=";)">',
  93. '#(?<!\w):cool2:(?!\w)#i' => '<img src=img/smileys/cool2.gif alt=":cool2:">',
  94. '#(?<!\w):huh:(?!\w)#i' => '<img src=img/smileys/huh.gif alt=":huh:">',
  95. '#(?<!\w)\^_\^(?!\w)#i' => '<img src=img/smileys/happy.gif alt="^_^">',
  96. '#(?<!\w):o(?!\w)#i' => '<img src=img/smileys/ohmy.gif alt=":o">',
  97. '#(?<!\w):P(?!\w)#i' => '<img src=img/smileys/tongue.gif alt=":P">',
  98. '#(?<!\w):D(?!\w)#i' => '<img src=img/smileys/grin.gif alt=":D">',
  99. '#(?<!\w):lol:(?!\w)#i' => '<img src=img/smileys/laugh.gif alt=":lol:">',
  100. '#(?<!\w)B\)(?!\w)#i' => '<img src=img/smileys/cool.gif alt="B)">',
  101. '#(?<!\w):rolleyes:(?!\w)#i' => '<img src=img/smileys/rolleyes.gif alt=":rolleyes:">',
  102. '#(?<!\w)\-_\-(?!\w)#i' => '<img src=img/smileys/sleep.gif alt="-_-">',
  103. '#(?<!\w):wub:(?!\w)#i' => '<img src=img/smileys/wub.gif alt=":wub:">',
  104. '#(?<!\w):rofl:(?!\w)#i' => '<img src=img/smileys/rofl.gif alt=":rofl:">',
  105. '#(?<!\w):hail:(?!\w)#i' => '<img src=img/smileys/hail.gif alt=":hail:">',
  106. '#(?<!\w):blush:(?!\w)#i' => '<img src=img/smileys/blush.gif alt=":blush:">',
  107. '#(?<!\w):popcorn:(?!\w)#i' => '<img src=img/smileys/popcorn.gif alt=":popcorn:">',
  108. '#(?<!\w):yahoo:(?!\w)#i' => '<img src=img/smileys/yahoo.gif alt=":yahoo:">',
  109. '#(?<!\w):love:(?!\w)#i' => '<img src=img/smileys/love2.gif alt=":love:">',
  110. '#(?<!\w):unknow:(?!\w)#i' => '<img src=img/smileys/unknow.gif alt=":unknow:">',
  111. '#(?<!\w):drool:(?!\w)#i' => '<img src=img/smileys/drool.gif alt=":drool:">',
  112. '#(?<!\w):rifle:(?!\w)#i' => '<img src=img/smileys/rifle.gif alt=":rifle:">',
  113. '#(?<!\w):hi:(?!\w)#i' => '<img src=img/smileys/hi.gif alt=":hi:">',
  114. '#(?<!\w):negative:(?!\w)#i' => '<img src=img/smileys/negative.gif alt=":negative:">',
  115. '#(?<!\w):yoyo:(?!\w)#i' => '<img src=img/smileys/yo-yo.gif alt=":yoyo:">',
  116. '#(?<!\w):throat:(?!\w)#i' => '<img src=img/smileys/throat.gif alt=":throat:">',
  117. '#(?<!\w):cooldance:(?!\w)#i' => '<img src=img/smileys/CoolDance.gif alt=":cooldance:">',
  118. '#(?<!\w):wallbash:(?!\w)#i' => '<img src=img/smileys/headbash.gif alt=":wallbash:">',
  119. '#(?<!\w):fume:(?!\w)#i' => '<img src=img/smileys/ranting.gif alt=":fume:">',
  120. '#(?<!\w):pissed:(?!\w)#i' => '<img src=img/smileys/PissedOff.gif alt=":pissed:">',
  121. '#(?<!\w):evil:(?!\w)#i' => '<img src=img/smileys/devil.gif alt=":evil:">',
  122. '#(?<!\w):angel:(?!\w)#i' => '<img src=img/smileys/angel.gif alt=":angel:">',
  123. '#(?<!\w):finger:(?!\w)#i' => '<img src=img/smileys/finger.gif alt=":finger:">',
  124. '#(?<!\w):mgun:(?!\w)#i' => '<img src=img/smileys/machinegun.gif alt=":mgun:">',
  125. '#(?<!\w):banana:(?!\w)#i' => '<img src=img/smileys/banana.gif alt=":banana:">',
  126. '#(?<!\w):santa:(?!\w)#i' => '<img src=img/smileys/santa.gif alt=":santa:">',
  127. '#(?<!\w):heart2:(?!\w)#i' => '<img src=img/smileys/heart2.gif alt=":heart2:">',
  128. '#(?<!\w):cry:(?!\w)#i' => '<img src=img/smileys/cry3.gif alt=":cry:">',
  129. '#(?<!\w):unsure:(?!\w)#i' => '<img src=img/smileys/unsure.gif alt=":unsure:">',
  130. '#(?<!\w):hug:(?!\w)#i' => '<img src=img/smileys/hug.gif alt=":hug:">',
  131. '#(?<!\w):baby:(?!\w)#i' => '<img src=img/smileys/baby.gif alt=":baby:">',
  132. '#(?<!\w):ph34r:(?!\w)#i' => '<img src=img/smileys/ph34r.gif alt=":ph34r:">',
  133. '#(?<!\w):thumbsup:(?!\w)#i' => '<img src=img/smileys/thumbsup.gif alt=":thumbsup:">',
  134. '#(?<!\w):wacko:(?!\w)#i' => '<img src=img/smileys/wacko.gif alt=":wacko:">',
  135. '#&lt;3#i' => '<img src=img/smileys/heart2.gif alt="<3">',
  136. '#&lt;\_&lt;#i' => '<img src=img/smileys/dry.gif alt="<_<">',
  137. );
  138.  
  139. $text=preg_replace(array_keys($smilies), array_values($smilies), $text,7);
  140.  
  141.  
  142.  
  143. $text = preg_replace( "#\[b\](.+?)\[/b\]#is", "<b>\\1</b>", $text );
  144. $text = preg_replace( "#\[i\](.+?)\[/i\]#is", "<i>\\1</i>", $text );
  145. $text = preg_replace( "#\[u\](.+?)\[/u\]#is", "<u>\\1</u>", $text );
  146. $text = preg_replace( "#\[desc\](.+?)\[/desc\]#is", "<div class='desc4'>\\1</div>", $text );
  147.  
  148.  
  149.  
  150. return clean_paragraphs($text);
  151. }
Advertisement
Add Comment
Please, Sign In to add comment