[ Index ]

PHP Cross Reference of Nuke-Evolution v2.0.5

title

Body

[close]

/includes/ -> bbcode.php (source)

   1  <?php
   2  /*=======================================================================
   3   Nuke-Evolution Basic: Enhanced PHP-Nuke Web Portal System
   4   =======================================================================*/
   5  
   6  /***************************************************************************
   7   *                              bbcode.php
   8   *                            -------------------
   9   *   begin                : Saturday, Feb 13, 2001
  10   *   copyright            : (C) 2001 The phpBB Group
  11   *   email                : support@phpbb.com
  12   *
  13   *   Id: bbcode.php,v 1.36.2.35 2005/07/19 20:01:10 acydburn Exp
  14   *
  15   ***************************************************************************/
  16  
  17  /***************************************************************************
  18   *
  19   *   This program is free software; you can redistribute it and/or modify
  20   *   it under the terms of the GNU General Public License as published by
  21   *   the Free Software Foundation; either version 2 of the License, or
  22   *   (at your option) any later version.
  23   *
  24   ***************************************************************************/
  25  
  26  /*****[CHANGES]**********************************************************
  27  -=[Base]=-
  28        Caching System                           v1.0.0       10/29/2005
  29  -=[Mod]=-
  30        Advanced BBCode Box                      v5.0.0a      11/16/2005
  31        Select Expand BBcodes                    v1.0.2       06/14/2005
  32        Force Word Wrapping                      v1.0.16      06/15/2005
  33        Force Word Wrapping - Configurator       v1.0.16      06/15/2005
  34        Anti Spam                                v1.1.0       06/18/2005
  35        PHP Syntax Highlighter BBCode            v3.0.7       07/10/2005
  36        Select Expand BBcodes (PHP add-on)       v1.0.2       07/18/2005
  37        Allow multiple spaces in posts           v1.0.0       07/30/2005
  38        Advanced Username Color                  v1.0.5       08/03/2005
  39        Extended Quote Tag                       v1.0.0       08/17/2005
  40        Select Expand & Extended Quote Tag       v1.0.0       08/26/2005
  41        Hide Images and Links                    v1.0.0       08/30/2005
  42        BBCode Box                               v1.0.0       10/06/2005
  43   ************************************************************************/
  44  
  45  if (!defined('IN_PHPBB'))
  46  {
  47      die('Hacking attempt');
  48  }
  49  
  50  define("BBCODE_UID_LEN", 10);
  51  
  52  // global that holds loaded-and-prepared bbcode templates, so we only have to do
  53  // that stuff once.
  54  
  55  $bbcode_tpl = null;
  56  /**
  57   * Loads bbcode templates from the bbcode.tpl file of the current template set.
  58   * Creates an array, keys are bbcode names like "b_open" or "url", values
  59   * are the associated template.
  60   * Probably pukes all over the place if there's something really screwed
  61   * with the bbcode.tpl file.
  62   *
  63   * Nathan Codding, Sept 26 2001.
  64   */
  65  
  66  function load_bbcode_template()
  67  {
  68      global $template;
  69      $tpl_filename = $template->make_filename('bbcode.tpl');
  70      $tpl = fread(fopen($tpl_filename, 'r'), filesize($tpl_filename));
  71  
  72      // replace \ with \\ and then ' with \'.
  73      $tpl = str_replace('\\', '\\\\', $tpl);
  74      $tpl  = str_replace('\'', '\\\'', $tpl);
  75  
  76      // strip newlines.
  77      $tpl  = str_replace("\n", '', $tpl);
  78  
  79      // Turn template blocks into PHP assignment statements for the values of $bbcode_tpls..
  80      $tpl = preg_replace('#<!-- BEGIN (.*?) -->(.*?)<!-- END (.*?) -->#', "\n" . '$bbcode_tpls[\'\\1\'] = \'\\2\';', $tpl);
  81  
  82      $bbcode_tpls = array();
  83  
  84      eval($tpl);
  85  
  86      return $bbcode_tpls;
  87  }
  88  /**
  89   * Prepares the loaded bbcode templates for insertion into preg_replace()
  90   * or str_replace() calls in the bbencode_second_pass functions. This
  91   * means replacing template placeholders with the appropriate preg backrefs
  92   * or with language vars. NOTE: If you change how the regexps work in
  93   * bbencode_second_pass(), you MUST change this function.
  94   *
  95   * Nathan Codding, Sept 26 2001
  96   *
  97   */
  98  function prepare_bbcode_template($bbcode_tpl)
  99  {
 100      global $lang, $db;
 101  
 102      $bbcode_tpl['olist_open'] = str_replace('{LIST_TYPE}', '\\1', $bbcode_tpl['olist_open']);
 103  
 104      $bbcode_tpl['color_open'] = str_replace('{COLOR}', '\\1', $bbcode_tpl['color_open']);
 105  
 106      $bbcode_tpl['size_open'] = str_replace('{SIZE}', '\\1', $bbcode_tpl['size_open']);
 107  
 108      $bbcode_tpl['quote_open'] = str_replace('{L_QUOTE}', $lang['Quote'], $bbcode_tpl['quote_open']);
 109  
 110      $bbcode_tpl['quote_username_open'] = str_replace('{L_QUOTE}', $lang['Quote'], $bbcode_tpl['quote_username_open']);
 111      $bbcode_tpl['quote_username_open'] = str_replace('{L_WROTE}', $lang['wrote'], $bbcode_tpl['quote_username_open']);
 112  
 113  /*****[BEGIN]******************************************
 114   [ Mod:     Advanced Username Color            v1.0.5 ]
 115   ******************************************************/
 116      $bbcode_tpl['quote_username_open'] = str_replace('{USERNAME}', UsernameColor('\\1'), $bbcode_tpl['quote_username_open']);
 117  /*****[END]********************************************
 118   [ Mod:     Advanced Username Color            v1.0.5 ]
 119   ******************************************************/
 120  
 121  /*****[BEGIN]******************************************
 122   [ Mod:     Extended Quote Tag                 v1.0.0 ]
 123   ******************************************************/
 124      $bbcode_tpl['quote_post_open'] = str_replace('{L_QUOTE}', $lang['Quote'], $bbcode_tpl['quote_post_open']);
 125      $temp_url = append_sid('show_post.php?p=\\1');
 126      $bbcode_tpl['quote_post_open'] = str_replace('{U_VIEW_POST}', '<a href="#_somewhat" onClick="javascript:open_postreview( \'' . $temp_url . '\' );" class="genmed">' . $lang['View_post'] . '</a>', $bbcode_tpl['quote_post_open']);
 127  
 128      $bbcode_tpl['quote_username_post_open'] = str_replace('{L_QUOTE}', $lang['Quote'], $bbcode_tpl['quote_username_post_open']);
 129      $bbcode_tpl['quote_username_post_open'] = str_replace('{L_WROTE}', $lang['wrote'], $bbcode_tpl['quote_username_post_open']);
 130      $bbcode_tpl['quote_username_post_open'] = str_replace('{USERNAME}', '\\1', $bbcode_tpl['quote_username_post_open']);
 131      $temp_url = append_sid('show_post.php?p=\\2');
 132      $bbcode_tpl['quote_username_post_open'] = str_replace('{U_VIEW_POST}', '<a href="#_somewhat" onClick="javascript:open_postreview( \'' . $temp_url . '\' );" class="genmed">' . $lang['View_post'] . '</a>', $bbcode_tpl['quote_username_post_open']);
 133  /*****[BEGIN]******************************************
 134   [ Mod:     Advanced Username Color            v1.0.5 ]
 135   ******************************************************/
 136      $bbcode_tpl['quote_username_post_open'] = str_replace('{USERNAME}', UsernameColor('\\1'), $bbcode_tpl['quote_username_post_open']);
 137  /*****[END]********************************************
 138   [ Mod:     Advanced Username Color            v1.0.5 ]
 139   ******************************************************/
 140      $temp_url = append_sid('show_post.php?p=\\2');
 141      $bbcode_tpl['quote_username_post_open'] = str_replace('{U_VIEW_POST}', '<a href="#_somewhat" onClick="javascript:open_postreview( \'' . $temp_url . '\' );" class="genmed">' . $lang['View_post'] . '</a>', $bbcode_tpl['quote_username_post_open']);
 142  /*****[END]********************************************
 143   [ Mod:     Extended Quote Tag                 v1.0.0 ]
 144   ******************************************************/
 145  
 146      $bbcode_tpl['code_open'] = str_replace('{L_CODE}', $lang['Code'], $bbcode_tpl['code_open']);
 147  
 148  /*****[BEGIN]******************************************
 149   [ Mod:     PHP Syntax Highlighter BBCode      v3.0.7 ]
 150   ******************************************************/
 151      $bbcode_tpl['php_open'] = str_replace('{L_PHP}', $lang['PHPCode'], $bbcode_tpl['php_open']); // PHP MOD
 152  /*****[END]********************************************
 153   [ Mod:     PHP Syntax Highlighter BBCode      v3.0.7 ]
 154   ******************************************************/
 155  
 156      $bbcode_tpl['img'] = str_replace('{URL}', '\\1', $bbcode_tpl['img']);
 157  
 158      // We do URLs in several different ways..
 159      $bbcode_tpl['url1'] = str_replace('{URL}', '\\1', $bbcode_tpl['url']);
 160      $bbcode_tpl['url1'] = str_replace('{DESCRIPTION}', '\\1', $bbcode_tpl['url1']);
 161  
 162      $bbcode_tpl['url2'] = str_replace('{URL}', 'http://\\1', $bbcode_tpl['url']);
 163      $bbcode_tpl['url2'] = str_replace('{DESCRIPTION}', '\\1', $bbcode_tpl['url2']);
 164  
 165      $bbcode_tpl['url3'] = str_replace('{URL}', '\\1', $bbcode_tpl['url']);
 166      $bbcode_tpl['url3'] = str_replace('{DESCRIPTION}', '\\2', $bbcode_tpl['url3']);
 167  
 168      $bbcode_tpl['url4'] = str_replace('{URL}', 'http://\\1', $bbcode_tpl['url']);
 169      $bbcode_tpl['url4'] = str_replace('{DESCRIPTION}', '\\3', $bbcode_tpl['url4']);
 170  
 171  /*****[BEGIN]******************************************
 172   [ Mod:     Anti-Spam                         v.1.1.0 ]
 173   ******************************************************/
 174      $bbcode_tpl['email'] = str_replace('{EMAIL1}', '\\1', $bbcode_tpl['email']);
 175      $bbcode_tpl['email'] = str_replace('{EMAIL2}', '\\2', $bbcode_tpl['email']);
 176      $bbcode_tpl['email'] = str_replace('{EMAIL3}', '\\3', $bbcode_tpl['email']);
 177  /*****[END]********************************************
 178   [ Mod:     Anti-Spam                         v.1.1.0 ]
 179   ******************************************************/
 180  
 181      $bbcode_tpl['email'] = str_replace('{EMAIL}', '\\1', $bbcode_tpl['email']);
 182  
 183  /*****[BEGIN]******************************************
 184   [ Mod:     Advanced BBCode Box               v5.0.0a ]
 185   ******************************************************/
 186      $bbcode_tpl['spoil_open'] = str_replace('{L_BBCODEBOX_HIDDEN}', $lang['BBCode_box_hidden'], $bbcode_tpl['spoil_open']);
 187      $bbcode_tpl['spoil_open'] = str_replace('{L_BBCODEBOX_VIEW}', $lang['BBcode_box_view'], $bbcode_tpl['spoil_open']);
 188      $bbcode_tpl['spoil_open'] = str_replace('{L_BBCODEBOX_HIDE}', $lang['BBcode_box_hide'], $bbcode_tpl['spoil_open']);
 189      $bbcode_tpl['align_open'] = str_replace('{ALIGN}', '\\1', $bbcode_tpl['align_open']);
 190      $bbcode_tpl['stream'] = str_replace('{URL}', '\\1', $bbcode_tpl['stream']);
 191      $bbcode_tpl['ram'] = str_replace('{URL}', '\\1', $bbcode_tpl['ram']);
 192      $bbcode_tpl['marq_open'] = str_replace('{MARQ}', '\\1', $bbcode_tpl['marq_open']);
 193      $bbcode_tpl['table_open'] = str_replace('{TABLE}', '\\1', $bbcode_tpl['table_open']);
 194      $bbcode_tpl['cell_open'] = str_replace('{CELL}', '\\1', $bbcode_tpl['cell_open']);
 195      $bbcode_tpl['flash'] = str_replace('{WIDTH}', '\\1', $bbcode_tpl['flash']);
 196      $bbcode_tpl['flash'] = str_replace('{HEIGHT}', '\\2', $bbcode_tpl['flash']);
 197      $bbcode_tpl['flash'] = str_replace('{URL}', '\\3', $bbcode_tpl['flash']);
 198      $bbcode_tpl['video'] = str_replace('{URL}', '\\3', $bbcode_tpl['video']);
 199      $bbcode_tpl['video'] = str_replace('{WIDTH}', '\\1', $bbcode_tpl['video']);
 200      $bbcode_tpl['video'] = str_replace('{HEIGHT}', '\\2', $bbcode_tpl['video']);
 201      $bbcode_tpl['font_open'] = str_replace('{FONT}', '\\1', $bbcode_tpl['font_open']);
 202      $bbcode_tpl['GVideo'] = str_replace('{GVIDEOID}', '\\1', $bbcode_tpl['GVideo']);
 203      $bbcode_tpl['GVideo'] = str_replace('{GVIDEOLINK}', $lang['GVideo_link'], $bbcode_tpl['GVideo']);
 204      $bbcode_tpl['youtube'] = str_replace('{YOUTUBEID}', '\\1', $bbcode_tpl['youtube']);
 205      $bbcode_tpl['youtube'] = str_replace('{YOUTUBELINK}', $lang['youtube_link'], $bbcode_tpl['youtube']);
 206  /*****[END]********************************************
 207   [ Mod:     Advanced BBCode Box               v5.0.0a ]
 208   ******************************************************/
 209  
 210  /*****[BEGIN]******************************************
 211   [ Mod:     Select Expand BBcodes              v1.0.2 ]
 212   ******************************************************/
 213      global $phpbb_root_path;
 214      $u_sxbb_jslib = 'includes/select_expand_bbcodes.js';
 215  
 216      // Replacing BBCode variables, but also adding CR to preserve HTML comment delimiters for JS code.
 217      $expand_ary1 = array('<!--', '//-->', '{L_SELECT}', '{L_EXPAND}', '{L_CONTRACT}', '{U_SXBB_JSLIB}');
 218      $expand_ary2 = array("\r<!--\r", "\r//-->\r", $lang['Select'], $lang['Expand'], $lang['Contract'], $u_sxbb_jslib);
 219      $expand_ary3 = array('<!--', '//-->');
 220      $expand_ary4 = array("\r<!--\r", "\r//-->\r");
 221  
 222      $bbcode_tpl['quote_open'] = str_replace($expand_ary1, $expand_ary2, $bbcode_tpl['quote_open']);
 223      $bbcode_tpl['quote_username_open'] = str_replace($expand_ary1, $expand_ary2, $bbcode_tpl['quote_username_open']);
 224      $bbcode_tpl['code_open'] = str_replace($expand_ary1, $expand_ary2, $bbcode_tpl['code_open']);
 225  
 226  /*****[BEGIN]******************************************
 227   [ Mod:     Select Expand & Extended Quote Tag v1.0.0 ]
 228   ******************************************************/
 229      $bbcode_tpl['quote_post_open'] = str_replace($expand_ary1, $expand_ary2, $bbcode_tpl['quote_post_open']);
 230      $bbcode_tpl['quote_username_post_open'] = str_replace($expand_ary1, $expand_ary2, $bbcode_tpl['quote_username_post_open']);
 231  /*****[END]********************************************
 232   [ Mod:     Select Expand & Extended Quote Tag v1.0.0 ]
 233   ******************************************************/
 234  
 235  /*****[BEGIN]******************************************
 236   [ Mod:     Select Expand BBcodes (PHP add-on) v1.0.2 ]
 237   ******************************************************/
 238      $bbcode_tpl['php_open'] = str_replace($expand_ary1, $expand_ary2, $bbcode_tpl['php_open']);
 239  /*****[END]********************************************
 240   [ Mod:     Select Expand BBcodes (PHP add-on) v1.0.2 ]
 241   ******************************************************/
 242  
 243      $bbcode_tpl['quote_close'] = str_replace($expand_ary3, $expand_ary4, $bbcode_tpl['quote_close']);
 244      $bbcode_tpl['code_close'] = str_replace($expand_ary3, $expand_ary4, $bbcode_tpl['code_close']);
 245  
 246  /*****[BEGIN]******************************************
 247   [ Mod:     Select Expand & Extended Quote Tag v1.0.0 ]
 248   ******************************************************/
 249      $bbcode_tpl['quote_post_close'] = str_replace($expand_ary3, $expand_ary4, $bbcode_tpl['quote_post_close']);
 250      $bbcode_tpl['quote_username_post_close'] = str_replace($expand_ary3, $expand_ary4, $bbcode_tpl['quote_username_post_close']);
 251  /*****[END]********************************************
 252   [ Mod:     Select Expand & Extended Quote Tag v1.0.0 ]
 253   ******************************************************/
 254  
 255  /*****[BEGIN]******************************************
 256   [ Mod:     Select Expand BBcodes (PHP add-on) v1.0.2 ]
 257   ******************************************************/
 258      $bbcode_tpl['php_close'] = str_replace($expand_ary3, $expand_ary4, $bbcode_tpl['php_close']);
 259  /*****[END]********************************************
 260   [ Mod:     Select Expand BBcodes (PHP add-on) v1.0.2 ]
 261   [ Mod:     Select Expand BBcodes              v1.0.2 ]
 262   ******************************************************/
 263  
 264      define("BBCODE_TPL_READY", true);
 265  
 266      return $bbcode_tpl;
 267  }
 268  /*****[BEGIN]******************************************
 269   [ Mod:     Hide Images and Links              v1.0.0 ]
 270   ******************************************************/
 271  function replacer($mode, $bb)
 272  {
 273    global $userdata, $lang, $board_config, $phpEx;
 274  
 275          switch($mode) {
 276            case 'img':
 277            $message = $lang['Images_Allowed_For_Registered_Only'];
 278            break;
 279            case 'link':
 280            $message = $lang['Links_Allowed_For_Registered_Only'];
 281            break;
 282            case 'email':
 283            $message = $lang['Emails_Allowed_For_Registered_Only'];
 284            break;
 285          }
 286  
 287      $replacer = '<table width="40%" cellspacing="1" cellpadding="3" border="0"><tr><td class="quote">';
 288      $replacer .= $message . '<br />';
 289      $replacer .= sprintf($lang['Get_Registered'], "<a href=\"" . append_sid('profile.' . $phpEx . '?mode=register') . "\">", "</a>");
 290      $replacer .= "<a href=\"modules.php?name=Forums&amp;file=login\">" . $lang['Login'] . "</a>";
 291      $replacer .= '</td></tr></table>';
 292  
 293      if ($userdata['session_logged_in'])
 294      {
 295          switch($mode) {
 296            case 'img':
 297            $user_option = $userdata['user_hide_images'];
 298            break;
 299            default:
 300            $user_option = 0;
 301            break;
 302          }
 303              $replacer = '<table width="40%" cellspacing="1" cellpadding="3" border="0"><tr><td class="quote">';
 304              $replacer .= sprintf($lang['Image_Blocked'], "<a href=\"" . append_sid('profile.' . $phpEx) . "\">", "</a>");
 305              $replacer .= '</td></tr></table>';
 306          if ($user_option) {
 307              return $replacer;
 308          } else {
 309              return $bb;
 310          }
 311  
 312      } else {
 313           switch($mode) {
 314            case 'img':
 315            $config = $board_config['hide_images'];
 316            break;
 317            case 'link':
 318            $config = $board_config['hide_links'];
 319            break;
 320            case 'email':
 321             $config = $board_config['hide_emails'];
 322            break;
 323          }
 324  
 325          if ($config) {
 326            return $replacer;
 327          } else {
 328            return $bb;
 329          }
 330      }
 331  }
 332  /*****[END]********************************************
 333   [ Mod:     Hide Images and Links              v1.0.0 ]
 334   ******************************************************/
 335  /**
 336   * Does second-pass bbencoding. This should be used before displaying the message in
 337   * a thread. Assumes the message is already first-pass encoded, and we are given the
 338   * correct UID as used in first-pass encoding.
 339   */
 340  function bbencode_second_pass($text, $uid)
 341  {
 342      global $lang, $bbcode_tpl, $userdata, $board_config;
 343  
 344      $text = preg_replace('#(script|about|applet|activex|chrome):#is', "\\1&#058;", $text);
 345  
 346      // pad it with a space so we can distinguish between FALSE and matching the 1st char (index 0).
 347      // This is important; bbencode_quote(), bbencode_list(), and bbencode_code() all depend on it.
 348      $text = " " . $text;
 349  
 350      // First: If there isn't a "[" and a "]" in the message, don't bother.
 351      if (! (strpos($text, "[") && strpos($text, "]")) )
 352      {
 353          // Remove padding, return.
 354          $text = substr($text, 1);
 355          return $text;
 356      }
 357  
 358      // Only load the templates ONCE..
 359      if (!defined("BBCODE_TPL_READY"))
 360      {
 361          // load templates from file into array.
 362          $bbcode_tpl = load_bbcode_template();
 363  
 364          // prepare array for use in regexps.
 365          $bbcode_tpl = prepare_bbcode_template($bbcode_tpl);
 366      }
 367  
 368      // [CODE] and [/CODE] for posting code (HTML, PHP, C etc etc) in your posts.
 369      $text = bbencode_second_pass_code($text, $uid, $bbcode_tpl);
 370  
 371  /*****[BEGIN]******************************************
 372   [ Mod:     PHP Syntax Highlighter BBCode      v3.0.7 ]
 373   ******************************************************/
 374      // [PHP] and [/PHP] for posting PHP code in your posts.
 375      $text = bbencode_second_pass_php($text, $uid, $bbcode_tpl);
 376  /*****[END]********************************************
 377   [ Mod:     PHP Syntax Highlighter BBCode      v3.0.7 ]
 378   ******************************************************/
 379  
 380      // [QUOTE] and [/QUOTE] for posting replies with quote, or just for quoting stuff.
 381      $text = str_replace("[quote:$uid]", $bbcode_tpl['quote_open'], $text);
 382      $text = str_replace("[/quote:$uid]", $bbcode_tpl['quote_close'], $text);
 383  
 384  /*****[BEGIN]******************************************
 385   [ Mod:     Extended Quote Tag                 v1.0.0 ]
 386   ******************************************************/
 387      // opening a quote with a pre-defined post entry
 388      $text = preg_replace("/\[quote:$uid=p=&quot;([0-9]+)&quot;\]/si", $bbcode_tpl['quote_post_open'], $text);
 389      $text = preg_replace("/\[quote:$uid=p=\"([0-9]+)\"\]/si", $bbcode_tpl['quote_post_open'], $text);
 390  
 391      // opening a username quote with a pre-defined post entry
 392      $text = preg_replace("/\[quote:$uid=(?:&quot;?([^\"]*)&quot;?);p=(?:&quot;?([0-9]+)&quot;?)\]/si", $bbcode_tpl['quote_username_post_open'], $text);
 393      $text = preg_replace("/\[quote:$uid=(?:\"?([^\"]*)\"?);p=(?:\"?([0-9]+)\"?)\]/si", $bbcode_tpl['quote_username_post_open'], $text);
 394      $text = preg_replace("/\[quote:$uid=(?:\"?([^\"]*)&quot;?);p=(?:&quot;?([0-9]+)\"?)\]/si", $bbcode_tpl['quote_username_post_open'], $text);
 395  /*****[END]********************************************
 396   [ Mod:     Extended Quote Tag                 v1.0.0 ]
 397   ******************************************************/
 398  
 399      // New one liner to deal with opening quotes with usernames...
 400      // replaces the two line version that I had here before..
 401      $text = preg_replace("/\[quote:$uid=\"(.*?)\"\]/si", $bbcode_tpl['quote_username_open'], $text);
 402      
 403      //Fix for the destroyed quotes Technocrat
 404      $text = preg_replace("/\[quote:$uid=&quot;(.*?)&quot;\]/si", $bbcode_tpl['quote_username_open'], $text);
 405  
 406      // [list] and [list=x] for (un)ordered lists.
 407      // unordered lists
 408      $text = str_replace("[list:$uid]", $bbcode_tpl['ulist_open'], $text);
 409      // li tags
 410      $text = str_replace("[*:$uid]", $bbcode_tpl['listitem'], $text);
 411      // ending tags
 412      $text = str_replace("[/list:u:$uid]", $bbcode_tpl['ulist_close'], $text);
 413      $text = str_replace("[/list:o:$uid]", $bbcode_tpl['olist_close'], $text);
 414      // Ordered lists
 415      $text = preg_replace("/\[list=([a1]):$uid\]/si", $bbcode_tpl['olist_open'], $text);
 416  
 417      // colours
 418      $text = preg_replace("/\[color=(\#[0-9A-F]{6}|[a-z]+):$uid\]/si", $bbcode_tpl['color_open'], $text);
 419      $text = str_replace("[/color:$uid]", $bbcode_tpl['color_close'], $text);
 420  
 421      // size
 422      $text = preg_replace("/\[size=([1-2]?[0-9]):$uid\]/si", $bbcode_tpl['size_open'], $text);
 423      $text = str_replace("[/size:$uid]", $bbcode_tpl['size_close'], $text);
 424  
 425      // [b] and [/b] for bolding text.
 426      $text = str_replace("[b:$uid]", $bbcode_tpl['b_open'], $text);
 427      $text = str_replace("[/b:$uid]", $bbcode_tpl['b_close'], $text);
 428  
 429      // [u] and [/u] for underlining text.
 430      $text = str_replace("[u:$uid]", $bbcode_tpl['u_open'], $text);
 431      $text = str_replace("[/u:$uid]", $bbcode_tpl['u_close'], $text);
 432  
 433      // [i] and [/i] for italicizing text.
 434      $text = str_replace("[i:$uid]", $bbcode_tpl['i_open'], $text);
 435      $text = str_replace("[/i:$uid]", $bbcode_tpl['i_close'], $text);
 436  
 437      // Patterns and replacements for URL and email tags..
 438      $patterns = array();
 439      $replacements = array();
 440  
 441      // [img]image_url_here[/img] code..
 442      // This one gets first-passed..
 443      $patterns[] = "#\[img:$uid\]([^?](?:[^\[]+|\[(?!url))*?)\[/img:$uid\]#i";
 444  
 445      $replacements[] = replacer('img', $bbcode_tpl['img']);
 446  
 447  /*****[BEGIN]******************************************
 448   [ Mod:     Hide Images and Links              v1.0.0 ]
 449   ******************************************************/
 450      // matches a [url]xxxx://www.phpbb.com[/url] code..
 451      $patterns[] = "#\[url\]([\w]+?://([\w\#$%&~/.\-;:=,?@\]+]+|\[(?!url=))*?)\[/url\]#is";
 452  
 453      $replacements[] = replacer('link', $bbcode_tpl['url1']);
 454  
 455      // [url]www.phpbb.com[/url] code.. (no xxxx:// prefix).
 456      $patterns[] = "#\[url\]((www|ftp)\.([\w\#$%&~/.\-;:=,?@\]+]+|\[(?!url=))*?)\[/url\]#is";
 457  
 458      $replacements[] = replacer('link', $bbcode_tpl['url2']);