View Single Post
  #1  
Old 29th June 2009, 11:26
mmisu120000's Avatar
mmisu120000 mmisu120000 is offline
Senior Member
 
Join Date: Jun 2009
P2P
Posts: 202
Default [FIX] TSSE v5.4.1 - BBcodes Fix
Finally, i've managed to fix the bbcodes in comments, forums, etc.....

Here it is:

in globalfunctions.php, find:
PHP Code:
  function format_comment ($s$htmlspecialchars_uni true$noshoutbox true$xss_clean true$show_smilies true$imagerel 'posts')
  {
    global 
$smilies;
    global 
$CURUSER;
    global 
$BASEURL;
    global 
$redirect;
    global 
$rootpath;
    global 
$pic_base_url;
    global 
$lang;
    global 
$cache;
    if (!
defined ('NcodeImageResizer'))
    {
      
define ('NcodeImageResizer'true);
    }

    
$target = ($noshoutbox '_self' '_blank');
    
$s str_replace ('
'
''$s);
    if (
$htmlspecialchars_uni)
    {
      
$s htmlspecialchars_uni ($s);
    }

    
$s ts_remove_badwords ($s);
    if (
$xss_clean)
    {
      
$s xss_clean ($s);
    }

    if (
$noshoutbox)
    {
      
preg_match_all ('#\\[(code|php|sql)\\](.*?)\\[/\\1\\](
?|
?)#si'
$s$code_matchesPREG_SET_ORDER);
      
$s preg_replace ('#\\[(code|php|sql)\\](.*?)\\[/\\1\\](
?|
?)#si'
'{{ts-code}}
'
$s);
    }

    if ((!
preg_match ('/\\[nfo\\](.*?)\\[\\/nfo\\]/is'$s) AND $show_smilies))
    {
      require_once 
$rootpath '/' $cache '/smilies.php';
      @
reset ($smilies);
      while (list (
$code$url) = @each ($smilies))
      {
        
$s str_replace ($code'<img border="0" src="' $BASEURL '/' $pic_base_url 'smilies/' $url '" alt="' htmlspecialchars ($code) . '">'$s);
      }
    }

    if (
$noshoutbox)
    {
      while (
preg_match ('#\\[list\\](.*?)\\[/list\\]#esi'$s))
      {
        
$s preg_replace ('#\\[list\\](.*?)\\[/list\\](
?|
?)#esi'
'' 'parse_list(\'$1\')
'
$s);
      }

      while (
preg_match ('#\\[list=(a|A|i|I|1)\\](.*?)\\[/list\\](
?|
?)#esi'
$s))
      {
        
$s preg_replace ('#\\[list=(a|A|i|I|1)\\](.*?)\\[/list\\]#esi''' 'parse_list(\'$2\', \'$1\')
'
$s);
      }
    }

    
$simple_search = array ('/\\[b\\]((\\s|.)+?)\\[\\/b\\]/is''/\\[i\\]((\\s|.)+?)\\[\\/i\\]/is''/\\[h\\]((\\s|.)+?)\\[\\/h\\]/is''/\\[u\\]((\\s|.)+?)\\[\\/u\\]/is''/\\[img\\]((http|https):\\/\\/[^\\s\'"<>]+(\\.(jpg|gif|png)))\\[\\/img\\]/is''/\\[img=((http|https):\\/\\/[^\\s\'"<>]+(\\.(gif|jpg|png)))\\]/is''/\\[color=([a-zA-Z]+)\\]((\\s|.)+?)\\[\\/color\\]/is''/\\[color=(#[a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9])\\]((\\s|.)+?)\\[\\/color\\]/is''/\\[url=([^()<>\\s]+?)\\]((\\s|.)+?)\\[\\/url\\]/is''/\\[url\\]([^()<>\\s]+?)\\[\\/url\\]/is''/\\[font=([a-zA-Z ,]+)\\]((\\s|.)+?)\\[\\/font\\]/is''/\\[pre\\](.*?)\\[\\/pre\\]/is''/\\[nfo\\](.*?)\\[\\/nfo\\]/is''#\\[size=(xx-small|x-small|small|medium|large|x-large|xx-large)\\](.*?)\\[/size\\]#si''#\\[align=(left|center|right|justify)\\](.*?)\\[/align\\]#si''#\\[email\\](.*?)\\[/email\\]#ei''#\\[email=(.*?)\\](.*?)\\[/email\\]#ei''#\\[youtube\\](.*?)\\[/youtube\\]#i');
    
$imgtag = ($noshoutbox '<a href="\\1" rel="gallery.' . ($imagerel == 'signatures' 'signatures' 'posts') . '"><img border="0" src="\\1" alt="" title="" onload="NcodeImageResizer.' . ($imagerel == 'signatures' 'createOnSigs' 'createOn') . '(this);" /></a>' htmlspecialchars_uni ('\\1'));
    
$youtubetag = ($noshoutbox '<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/' htmlspecialchars_uni ('' '$1') . '"></param><embed src="http://www.youtube.com/v/' htmlspecialchars_uni ('' '$1') . '" type="application/x-shockwave-flash" width="425" height="350"></embed></object>' htmlspecialchars_uni ('' 'http://www.youtube.com/v/$1'));
    
$simple_replace = array ('<b>\\1</b>''<i>\\1</i>''<h3>\\1</h3>''<u>\\1</u>'$imgtag$imgtag'<font color="\\1">\\2</font>''<font color="\\1">\\2</font>''' '<a href="\\1" target="' $target '">\\2</a>''' '<a href="\\1" target="' $target '">\\1</a>''<font face="\\1">\\2</font>''<pre>' htmlspecialchars_uni ('\\1') . '</pre>''<tt><span style="white-space: nowrap;"><font face="MS Linedraw" size="2" style="font-size: 10pt; line-height: 10pt">\\1</font></span></tt>''' '<span style="font-size: $1;">$2</span>''' '<p style="text-align: $1;">$2</p>''' 'parse_email(\'$1\')''' 'parse_email(\'$1\', \'$2\')'$youtubetag);
    
$s preg_replace ($simple_search$simple_replace$s);
    if (!
defined ('TS_CUSTOM_BBCODE'))
    {
      
define ('TS_CUSTOM_BBCODE'true);
    }

    include_once 
INC_PATH '/ts_custom_bbcode.php';
    
$s ts_custom_bbcode ($s);
    if (
$noshoutbox)
    {
      
$s parse_quotes ($s);
    }

    
$s format_urls ($s$target);
    
$s anonymize ($s$target);
    if (((isset (
$code_matches) AND count ($code_matches)) AND $noshoutbox))
    {
      foreach (
$code_matches as $text)
      {
        if (
strtolower ($text[1]) == 'code')
        {
          
$code code_tag ($text[2]);
        }
        else
        {
          if (
strtolower ($text[1]) == 'php')
          {
            
$code php_tag ($text[2]);
          }
          else
          {
            if (
strtolower ($text[1]) == 'sql')
            {
              
$code sql_tag ($text[2]);
            }
          }
        }

        
$s preg_replace ('#\\{\\{ts-code\\}\\}
?#'
$code$s1);
      }
    }

    
$s nl2br ($s);
    
$s preg_replace ('#(</?(?:html|head|body|form|div|p|table|thead|tbody|tfoot|tr|td|th|ul|ol|li|div|p)[^>]*>)\\s*<br>#i''' '$1'$s);
    
$s preg_replace ('#(&nbsp;)+(</?(?:html|head|body|form|div|p|table|thead|tbody|tfoot|tr|td|th|ul|ol|li|div|p)[^>]*>)#i''' '$2'$s);
    
$s ts_wordwrap ($s);
    return 
$s;
  }

  @
error_reporting (E_ALL & ~E_NOTICE);
  @
ini_set ('error_reporting'E_ALL & ~E_NOTICE);
  @
ini_set ('display_errors''0');
  @
ini_set ('log_errors''1');
  if (!
defined ('IN_SCRIPT_TSSEv53'))
  {
    exit (
'<font face=\'verdana\' size=\'2\' color=\'darkred\'><b>Error!</b> Direct initialization of this file is not allowed.</font>');
  }

?> 
and replace it with:

PHP Code:
  function format_comment ($s$htmlspecialchars_uni true$noshoutbox true$xss_clean true$show_smilies true$imagerel 'posts')
  {
    global 
$smilies;
    global 
$CURUSER;
    global 
$BASEURL;
    global 
$redirect;
    global 
$rootpath;
    global 
$pic_base_url;
    global 
$lang;
    global 
$cache;
    if (!
defined ('NcodeImageResizer'))
    {
      
define ('NcodeImageResizer'true);
    }

    
$target = ($noshoutbox '_self' '_blank');
    
$s ts_remove_badwords ($s);
    if (
$htmlspecialchars_uni)
    {
      
$s htmlspecialchars_uni ($s);
    }

    if (
$xss_clean)
    {
      
$s xss_clean ($s);
    }

    if (
$noshoutbox)
    {
      
preg_match_all ('#\\[(code|php|sql)\\](.*?)\\[/\\1\\](
?|
?)#si'
$s$code_matchesPREG_SET_ORDER);
      
$s preg_replace ('#\\[(code|php|sql)\\](.*?)\\[/\\1\\](
?|
?)#si'
'{{ts-code}}
'
$s);
    }

    if ((!
preg_match ('/\\[nfo\\](.*?)\\[\\/nfo\\]/is'$s) AND $show_smilies))
    {
      require_once 
$rootpath '/' $cache '/smilies.php';
      @
reset ($smilies);
      while (list (
$code$url) = @each ($smilies))
      {
        
$s str_replace ($code'<img border="0" src="' $BASEURL '/' $pic_base_url 'smilies/' $url '" alt="' htmlspecialchars ($code) . '" class="inlineimg" />'$s);
      }
    }

    
$simple_search = array ('/\\[b\\]((\\s|.)+?)\\[\\/b\\]/is''/\\[i\\]((\\s|.)+?)\\[\\/i\\]/is''/\\[h\\]((\\s|.)+?)\\[\\/h\\]/is''/\\[u\\]((\\s|.)+?)\\[\\/u\\]/is''/\\[img\\]((http|https):\\/\\/[^\\s\'"<>]+(\\.(jpg|gif|png)))\\[\\/img\\]/is''/\\[img=((http|https):\\/\\/[^\\s\'"<>]+(\\.(gif|jpg|png)))\\]/is''/\\[color=([a-zA-Z]+)\\]((\\s|.)+?)\\[\\/color\\]/is''/\\[color=(#[a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9])\\]((\\s|.)+?)\\[\\/color\\]/is''/\\[url=([^()<>\\s]+?)\\]((\\s|.)+?)\\[\\/url\\]/is''/\\[url\\]([^()<>\\s]+?)\\[\\/url\\]/is''/\\[font=([a-zA-Z ,]+)\\]((\\s|.)+?)\\[\\/font\\]/is''/\\[pre\\](.*?)\\[\\/pre\\]/is''/\\[nfo\\](.*?)\\[\\/nfo\\]/is''#\\[size=(xx-small|x-small|small|medium|large|x-large|xx-large)\\](.*?)\\[/size\\]#si''#\\[align=(left|center|right|justify)\\](.*?)\\[/align\\]#si''#\\[email\\](.*?)\\[/email\\]#ei''#\\[email=(.*?)\\](.*?)\\[/email\\]#ei''#\\[youtube\\](.*?)\\[/youtube\\]#i');
    
$imgtag = ($noshoutbox '<a href="\\1" rel="gallery.' . ($imagerel == 'signatures' 'signatures' 'posts') . '"><img border="0" src="\\1" alt="" title="" onload="NcodeImageResizer.' . ($imagerel == 'signatures' 'createOnSigs' 'createOn') . '(this);" /></a>' '\\1');
    
$youtubetag = ($noshoutbox '<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/' . ('' '$1') . '"></param><embed src="http://www.youtube.com/v/' . ('' '$1') . '" type="application/x-shockwave-flash" width="425" height="350"></embed></object>' '' 'http://www.youtube.com/v/$1');
    
$simple_replace = array ('<b>\\1</b>''<i>\\1</i>''<h3>\\1</h3>''<u>\\1</u>'$imgtag$imgtag'<font color="\\1">\\2</font>''<font color="\\1">\\2</font>''' '<a href="\\1" target="' $target '">\\2</a>''' '<a href="\\1" target="' $target '">\\1</a>''<font face="\\1">\\2</font>''<pre>' '\\1' '</pre>''<tt><span style="white-space: nowrap;"><font face="MS Linedraw" size="2" style="font-size: 10pt; line-height: 10pt">\\1</font></span></tt>''' '<span style="font-size: $1;">$2</span>''' '<p style="text-align: $1;">$2</p>''' 'parse_email(\'$1\')''' 'parse_email(\'$1\', \'$2\')'$youtubetag);
    
$s preg_replace ($simple_search$simple_replace$s);
    if (!
defined ('TS_CUSTOM_BBCODE'))
    {
      
define ('TS_CUSTOM_BBCODE'true);
    }

    include_once 
INC_PATH '/ts_custom_bbcode.php';
    
$s ts_custom_bbcode ($s);
    if (
$noshoutbox)
    {
      
$s parse_quotes ($s);
    }

    
$s format_urls ($s$target);
    
$s anonymize ($s$target);
    
$s nl2br ($s);
    if (((isset (
$code_matches) AND count ($code_matches)) AND $noshoutbox))
    {
      foreach (
$code_matches as $text)
      {
        if (
strtolower ($text[1]) == 'code')
        {
          
$code code_tag ($text[2]);
        }
        else
        {
          if (
strtolower ($text[1]) == 'php')
          {
            
$code php_tag ($text[2]);
          }
          else
          {
            if (
strtolower ($text[1]) == 'sql')
            {
              
$code sql_tag ($text[2]);
            }
          }
        }

        
$s preg_replace ('#\\{\\{ts-code\\}\\}
?#'
$code$s1);
      }
    }

    if (
$noshoutbox)
    {
      while (
preg_match ('#\\[list\\](.*?)\\[/list\\]#esi'$s))
      {
        
$s preg_replace ('#\\[list\\](.*?)\\[/list\\](
?|
?)#esi'
'' 'parse_list(\'$1\')
'
$s);
      }

      while (
preg_match ('#\\[list=(a|A|i|I|1)\\](.*?)\\[/list\\](
?|
?)#esi'
$s))
      {
        
$s preg_replace ('#\\[list=(a|A|i|I|1)\\](.*?)\\[/list\\]#esi''' 'parse_list(\'$2\', \'$1\')
'
$s);
      }
    }

    
$s ts_wordwrap ($s);
    if (
preg_match ('/\\[hide\\](.*?)\\[\\/hide\\]/is'$s))
    {
      while (
preg_match ('#\\[hide\\](.*?)\\[\\/hide\\](
?|
?)#si'
$s))
      {
        if (!
defined ('IS_THIS_USER_POSTED'))
        {
          
$s preg_replace ('#\\[hide\\](.*?)\\[\\/hide\\](
?|
?)#si'
show_notice ($lang->global['h1'], true$lang->global['h2'], ''), $s);
          continue;
        }
        else
        {
          
$s preg_replace ('#\\[hide\\](.*?)\\[\\/hide\\](
?|
?)#si'
show_notice ('$1'false$lang->global['h3'], ''), $s);
          continue;
        }
      }
    }

    return 
$s;
  }

  @
error_reporting (E_ALL & ~E_NOTICE);
  @
ini_set ('error_reporting'E_ALL & ~E_NOTICE);
  @
ini_set ('display_errors''0');
  @
ini_set ('log_errors''1');
  if (!
defined ('IN_SCRIPT_TSSEv53'))
  {
    exit (
'<font face=\'verdana\' size=\'2\' color=\'darkred\'><b>Error!</b> Direct initialization of this file is not allowed.</font>');
  }

?> 
Reply With Quote
The Following 6 Users Say Thank You to mmisu120000 For This Useful Post:
Fynnon (29th June 2009), KingCobra (14th August 2009), konvar (29th June 2009), Marco (5th April 2013), Terminator (29th June 2009), Virusache (29th June 2009)