Verzeichnisstruktur phpBB-3.1.0


Veröffentlicht
27.10.2014

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

acp_bbcodes.php

Zuletzt modifiziert: 09.10.2024, 12:52 - Dateigröße: 18.18 KiB


001  <?php
002  /**
003  *
004  * This file is part of the phpBB Forum Software package.
005  *
006  * @copyright (c) phpBB Limited <https://www.phpbb.com>
007  * @license GNU General Public License, version 2 (GPL-2.0)
008  *
009  * For full copyright and license information, please see
010  * the docs/CREDITS.txt file.
011  *
012  */
013   
014  /**
015  * @ignore
016  */
017  if (!defined('IN_PHPBB'))
018  {
019      exit;
020  }
021   
022  class acp_bbcodes
023  {
024      var $u_action;
025   
026      function main($id, $mode)
027      {
028          global $db, $user, $auth, $template, $cache, $request, $phpbb_dispatcher;
029          global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
030   
031          $user->add_lang('acp/posting');
032   
033          // Set up general vars
034          $action    = request_var('action', '');
035          $bbcode_id = request_var('bbcode', 0);
036   
037          $this->tpl_name = 'acp_bbcodes';
038          $this->page_title = 'ACP_BBCODES';
039          $form_key = 'acp_bbcodes';
040   
041          add_form_key($form_key);
042   
043          // Set up mode-specific vars
044          switch ($action)
045          {
046              case 'add':
047                  $bbcode_match = $bbcode_tpl = $bbcode_helpline = '';
048                  $display_on_posting = 0;
049              break;
050   
051              case 'edit':
052                  $sql = 'SELECT bbcode_match, bbcode_tpl, display_on_posting, bbcode_helpline
053                      FROM ' . BBCODES_TABLE . '
054                      WHERE bbcode_id = ' . $bbcode_id;
055                  $result = $db->sql_query($sql);
056                  $row = $db->sql_fetchrow($result);
057                  $db->sql_freeresult($result);
058   
059                  if (!$row)
060                  {
061                      trigger_error($user->lang['BBCODE_NOT_EXIST'] . adm_back_link($this->u_action), E_USER_WARNING);
062                  }
063   
064                  $bbcode_match = $row['bbcode_match'];
065                  $bbcode_tpl = htmlspecialchars($row['bbcode_tpl']);
066                  $display_on_posting = $row['display_on_posting'];
067                  $bbcode_helpline = $row['bbcode_helpline'];
068              break;
069   
070              case 'modify':
071                  $sql = 'SELECT bbcode_id, bbcode_tag
072                      FROM ' . BBCODES_TABLE . '
073                      WHERE bbcode_id = ' . $bbcode_id;
074                  $result = $db->sql_query($sql);
075                  $row = $db->sql_fetchrow($result);
076                  $db->sql_freeresult($result);
077   
078                  if (!$row)
079                  {
080                      trigger_error($user->lang['BBCODE_NOT_EXIST'] . adm_back_link($this->u_action), E_USER_WARNING);
081                  }
082   
083              // No break here
084   
085              case 'create':
086                  $display_on_posting = request_var('display_on_posting', 0);
087   
088                  $bbcode_match = request_var('bbcode_match', '');
089                  $bbcode_tpl = htmlspecialchars_decode(utf8_normalize_nfc(request_var('bbcode_tpl', '', true)));
090                  $bbcode_helpline = utf8_normalize_nfc(request_var('bbcode_helpline', '', true));
091              break;
092          }
093   
094          // Do major work
095          switch ($action)
096          {
097              case 'edit':
098              case 'add':
099   
100                  $tpl_ary = array(
101                      'S_EDIT_BBCODE'        => true,
102                      'U_BACK'            => $this->u_action,
103                      'U_ACTION'            => $this->u_action . '&amp;action=' . (($action == 'add') ? 'create' : 'modify') . (($bbcode_id) ? "&amp;bbcode=$bbcode_id" : ''),
104   
105                      'L_BBCODE_USAGE_EXPLAIN'=> sprintf($user->lang['BBCODE_USAGE_EXPLAIN'], '<a href="#down">', '</a>'),
106                      'BBCODE_MATCH'            => $bbcode_match,
107                      'BBCODE_TPL'            => $bbcode_tpl,
108                      'BBCODE_HELPLINE'        => $bbcode_helpline,
109                      'DISPLAY_ON_POSTING'    => $display_on_posting,
110                  );
111   
112                  $bbcode_tokens = array('TEXT', 'SIMPLETEXT', 'INTTEXT', 'IDENTIFIER', 'NUMBER', 'EMAIL', 'URL', 'LOCAL_URL', 'RELATIVE_URL', 'COLOR');
113   
114                  /**
115                  * Modify custom bbcode template data before we display the add/edit form
116                  *
117                  * @event core.acp_bbcodes_edit_add
118                  * @var    string    action            Type of the action: add|edit
119                  * @var    array    tpl_ary            Array with custom bbcode add/edit data
120                  * @var    int        bbcode_id        When editing: the bbcode id,
121                  *                                when creating: 0
122                  * @var    array    bbcode_tokens    Array of bbcode tokens
123                  * @since 3.1.0-a3
124                  */
125                  $vars = array('action', 'tpl_ary', 'bbcode_id', 'bbcode_tokens');
126                  extract($phpbb_dispatcher->trigger_event('core.acp_bbcodes_edit_add', compact($vars)));
127   
128                  $template->assign_vars($tpl_ary);
129   
130                  foreach ($bbcode_tokens as $token)
131                  {
132                      $template->assign_block_vars('token', array(
133                          'TOKEN'        => '{' . $token . '}',
134                          'EXPLAIN'    => ($token === 'LOCAL_URL') ? $user->lang(array('tokens', $token), generate_board_url() . '/') : $user->lang(array('tokens', $token)),
135                      ));
136                  }
137   
138                  return;
139   
140              break;
141   
142              case 'modify':
143              case 'create':
144   
145                  $sql_ary = $hidden_fields = array();
146   
147                  /**
148                  * Modify custom bbcode data before the modify/create action
149                  *
150                  * @event core.acp_bbcodes_modify_create
151                  * @var    string    action                Type of the action: modify|create
152                  * @var    array    sql_ary                Array with new bbcode data
153                  * @var    int        bbcode_id            When editing: the bbcode id,
154                  *                                    when creating: 0
155                  * @var    bool    display_on_posting    Display bbcode on posting form
156                  * @var    string    bbcode_match        The bbcode usage string to match
157                  * @var    string    bbcode_tpl            The bbcode HTML replacement string
158                  * @var    string    bbcode_helpline        The bbcode help line string
159                  * @var    array    hidden_fields        Array of hidden fields for use when
160                  *                                    submitting form when $warn_text is true
161                  * @since 3.1.0-a3
162                  */
163                  $vars = array(
164                      'action',
165                      'sql_ary',
166                      'bbcode_id',
167                      'display_on_posting',
168                      'bbcode_match',
169                      'bbcode_tpl',
170                      'bbcode_helpline',
171                      'hidden_fields',
172                  );
173                  extract($phpbb_dispatcher->trigger_event('core.acp_bbcodes_modify_create', compact($vars)));
174   
175                  $warn_text = preg_match('%<[^>]*\{text[\d]*\}[^>]*>%i', $bbcode_tpl);
176                  if (!$warn_text || confirm_box(true))
177                  {
178                      $data = $this->build_regexp($bbcode_match, $bbcode_tpl);
179   
180                      // Make sure the user didn't pick a "bad" name for the BBCode tag.
181                      $hard_coded = array('code', 'quote', 'quote=', 'attachment', 'attachment=', 'b', 'i', 'url', 'url=', 'img', 'size', 'size=', 'color', 'color=', 'u', 'list', 'list=', 'email', 'email=', 'flash', 'flash=');
182   
183                      if (($action == 'modify' && strtolower($data['bbcode_tag']) !== strtolower($row['bbcode_tag'])) || ($action == 'create'))
184                      {
185                          $sql = 'SELECT 1 as test
186                              FROM ' . BBCODES_TABLE . "
187                              WHERE LOWER(bbcode_tag) = '" . $db->sql_escape(strtolower($data['bbcode_tag'])) . "'";
188                          $result = $db->sql_query($sql);
189                          $info = $db->sql_fetchrow($result);
190                          $db->sql_freeresult($result);
191   
192                          // Grab the end, interrogate the last closing tag
193                          if ($info['test'] === '1' || in_array(strtolower($data['bbcode_tag']), $hard_coded) || (preg_match('#\[/([^[]*)]$#', $bbcode_match, $regs) && in_array(strtolower($regs[1]), $hard_coded)))
194                          {
195                              trigger_error($user->lang['BBCODE_INVALID_TAG_NAME'] . adm_back_link($this->u_action), E_USER_WARNING);
196                          }
197                      }
198   
199                      if (substr($data['bbcode_tag'], -1) === '=')
200                      {
201                          $test = substr($data['bbcode_tag'], 0, -1);
202                      }
203                      else
204                      {
205                          $test = $data['bbcode_tag'];
206                      }
207   
208                      if (!preg_match('%\\[' . $test . '[^]]*].*?\\[/' . $test . ']%s', $bbcode_match))
209                      {
210                          trigger_error($user->lang['BBCODE_OPEN_ENDED_TAG'] . adm_back_link($this->u_action), E_USER_WARNING);
211                      }
212   
213                      if (strlen($data['bbcode_tag']) > 16)
214                      {
215                          trigger_error($user->lang['BBCODE_TAG_TOO_LONG'] . adm_back_link($this->u_action), E_USER_WARNING);
216                      }
217   
218                      if (strlen($bbcode_match) > 4000)
219                      {
220                          trigger_error($user->lang['BBCODE_TAG_DEF_TOO_LONG'] . adm_back_link($this->u_action), E_USER_WARNING);
221                      }
222   
223                      if (strlen($bbcode_helpline) > 255)
224                      {
225                          trigger_error($user->lang['BBCODE_HELPLINE_TOO_LONG'] . adm_back_link($this->u_action), E_USER_WARNING);
226                      }
227   
228                      $sql_ary = array_merge($sql_ary, array(
229                          'bbcode_tag'                => $data['bbcode_tag'],
230                          'bbcode_match'                => $bbcode_match,
231                          'bbcode_tpl'                => $bbcode_tpl,
232                          'display_on_posting'        => $display_on_posting,
233                          'bbcode_helpline'            => $bbcode_helpline,
234                          'first_pass_match'            => $data['first_pass_match'],
235                          'first_pass_replace'        => $data['first_pass_replace'],
236                          'second_pass_match'            => $data['second_pass_match'],
237                          'second_pass_replace'        => $data['second_pass_replace']
238                      ));
239   
240                      if ($action == 'create')
241                      {
242                          $sql = 'SELECT MAX(bbcode_id) as max_bbcode_id
243                              FROM ' . BBCODES_TABLE;
244                          $result = $db->sql_query($sql);
245                          $row = $db->sql_fetchrow($result);
246                          $db->sql_freeresult($result);
247   
248                          if ($row)
249                          {
250                              $bbcode_id = $row['max_bbcode_id'] + 1;
251   
252                              // Make sure it is greater than the core bbcode ids...
253                              if ($bbcode_id <= NUM_CORE_BBCODES)
254                              {
255                                  $bbcode_id = NUM_CORE_BBCODES + 1;
256                              }
257                          }
258                          else
259                          {
260                              $bbcode_id = NUM_CORE_BBCODES + 1;
261                          }
262   
263                          if ($bbcode_id > BBCODE_LIMIT)
264                          {
265                              trigger_error($user->lang['TOO_MANY_BBCODES'] . adm_back_link($this->u_action), E_USER_WARNING);
266                          }
267   
268                          $sql_ary['bbcode_id'] = (int) $bbcode_id;
269   
270                          $db->sql_query('INSERT INTO ' . BBCODES_TABLE . $db->sql_build_array('INSERT', $sql_ary));
271                          $cache->destroy('sql', BBCODES_TABLE);
272   
273                          $lang = 'BBCODE_ADDED';
274                          $log_action = 'LOG_BBCODE_ADD';
275                      }
276                      else
277                      {
278                          $sql = 'UPDATE ' . BBCODES_TABLE . '
279                              SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
280                              WHERE bbcode_id = ' . $bbcode_id;
281                          $db->sql_query($sql);
282                          $cache->destroy('sql', BBCODES_TABLE);
283   
284                          $lang = 'BBCODE_EDITED';
285                          $log_action = 'LOG_BBCODE_EDIT';
286                      }
287   
288                      add_log('admin', $log_action, $data['bbcode_tag']);
289   
290                      trigger_error($user->lang[$lang] . adm_back_link($this->u_action));
291                  }
292                  else
293                  {
294                      confirm_box(false, $user->lang['BBCODE_DANGER'], build_hidden_fields(array_merge($hidden_fields, array(
295                          'action'                => $action,
296                          'bbcode'                => $bbcode_id,
297                          'bbcode_match'            => $bbcode_match,
298                          'bbcode_tpl'            => htmlspecialchars($bbcode_tpl),
299                          'bbcode_helpline'        => $bbcode_helpline,
300                          'display_on_posting'    => $display_on_posting,
301                          )))
302                      , 'confirm_bbcode.html');
303                  }
304   
305              break;
306   
307              case 'delete':
308   
309                  $sql = 'SELECT bbcode_tag
310                      FROM ' . BBCODES_TABLE . "
311                      WHERE bbcode_id = $bbcode_id";
312                  $result = $db->sql_query($sql);
313                  $row = $db->sql_fetchrow($result);
314                  $db->sql_freeresult($result);
315   
316                  if ($row)
317                  {
318                      if (confirm_box(true))
319                      {
320                          $db->sql_query('DELETE FROM ' . BBCODES_TABLE . " WHERE bbcode_id = $bbcode_id");
321                          $cache->destroy('sql', BBCODES_TABLE);
322                          add_log('admin', 'LOG_BBCODE_DELETE', $row['bbcode_tag']);
323   
324                          if ($request->is_ajax())
325                          {
326                              $json_response = new \phpbb\json_response;
327                              $json_response->send(array(
328                                  'MESSAGE_TITLE'    => $user->lang['INFORMATION'],
329                                  'MESSAGE_TEXT'    => $user->lang['BBCODE_DELETED'],
330                                  'REFRESH_DATA'    => array(
331                                      'time'    => 3
332                                  )
333                              ));
334                          }
335                      }
336                      else
337                      {
338                          confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
339                              'bbcode'    => $bbcode_id,
340                              'i'            => $id,
341                              'mode'        => $mode,
342                              'action'    => $action))
343                          );
344                      }
345                  }
346   
347              break;
348          }
349   
350          $u_action = $this->u_action;
351   
352          $template_data = array(
353              'U_ACTION'        => $this->u_action . '&amp;action=add',
354          );
355   
356          $sql_ary = array(
357              'SELECT'    => 'b.*',
358              'FROM'        => array(BBCODES_TABLE => 'b'),
359              'ORDER_BY'    => 'b.bbcode_tag',
360          );
361   
362          /**
363          *  Modify custom bbcode template data before we display the form
364          *
365          * @event core.acp_bbcodes_display_form
366          * @var    string    action            Type of the action: modify|create
367          * @var    string    sql_ary            The SQL array to get custom bbcode data
368          * @var    array    template_data    Array with form template data
369          * @var    string    u_action        The u_action link
370          * @since 3.1.0-a3
371          */
372          $vars = array('action', 'sql_ary', 'template_data', 'u_action');
373          extract($phpbb_dispatcher->trigger_event('core.acp_bbcodes_display_form', compact($vars)));
374   
375          $result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary));
376   
377          $template->assign_vars($template_data);
378   
379          while ($row = $db->sql_fetchrow($result))
380          {
381              $bbcodes_array = array(
382                  'BBCODE_TAG'        => $row['bbcode_tag'],
383                  'U_EDIT'            => $u_action . '&amp;action=edit&amp;bbcode=' . $row['bbcode_id'],
384                  'U_DELETE'            => $u_action . '&amp;action=delete&amp;bbcode=' . $row['bbcode_id'],
385              );
386   
387              /**
388              *  Modify display of custom bbcodes in the form
389              *
390              * @event core.acp_bbcodes_display_bbcodes
391              * @var    array    row                Array with current bbcode data
392              * @var    array    bbcodes_array    Array of bbcodes template data
393              * @var    string    u_action        The u_action link
394              * @since 3.1.0-a3
395              */
396              $vars = array('bbcodes_array', 'row', 'u_action');
397              extract($phpbb_dispatcher->trigger_event('core.acp_bbcodes_display_bbcodes', compact($vars)));
398   
399              $template->assign_block_vars('bbcodes', $bbcodes_array);
400   
401          }
402          $db->sql_freeresult($result);
403      }
404   
405      /*
406      * Build regular expression for custom bbcode
407      */
408      function build_regexp(&$bbcode_match, &$bbcode_tpl)
409      {
410          $bbcode_match = trim($bbcode_match);
411          $bbcode_tpl = trim($bbcode_tpl);
412          $utf8 = strpos($bbcode_match, 'INTTEXT') !== false;
413   
414          $utf8_pcre_properties = phpbb_pcre_utf8_support();
415   
416          $fp_match = preg_quote($bbcode_match, '!');
417          $fp_replace = preg_replace('#^\[(.*?)\]#', '[$1:$uid]', $bbcode_match);
418          $fp_replace = preg_replace('#\[/(.*?)\]$#', '[/$1:$uid]', $fp_replace);
419   
420          $sp_match = preg_quote($bbcode_match, '!');
421          $sp_match = preg_replace('#^\\\\\[(.*?)\\\\\]#', '\[$1:$uid\]', $sp_match);
422          $sp_match = preg_replace('#\\\\\[/(.*?)\\\\\]$#', '\[/$1:$uid\]', $sp_match);
423          $sp_replace = $bbcode_tpl;
424   
425          // @todo Make sure to change this too if something changed in message parsing
426          $tokens = array(
427              'URL'     => array(
428                  '!(?:(' . str_replace(array('!', '\#'), array('\!', '#'), get_preg_expression('url')) . ')|(' . str_replace(array('!', '\#'), array('\!', '#'), get_preg_expression('www_url')) . '))!ie'    =>    "\$this->bbcode_specialchars(('\$1') ? '\$1' : 'http://\$2')"
429              ),
430              'LOCAL_URL'     => array(
431                  '!(' . str_replace(array('!', '\#'), array('\!', '#'), get_preg_expression('relative_url')) . ')!e'    =>    "\$this->bbcode_specialchars('$1')"
432              ),
433              'RELATIVE_URL'    => array(
434                  '!(' . str_replace(array('!', '\#'), array('\!', '#'), get_preg_expression('relative_url')) . ')!e'    =>    "\$this->bbcode_specialchars('$1')"
435              ),
436              'EMAIL' => array(
437                  '!(' . get_preg_expression('email') . ')!ie'    =>    "\$this->bbcode_specialchars('$1')"
438              ),
439              'TEXT' => array(
440                  '!(.*?)!es'     =>    "str_replace(array(\"\\r\\n\", '\\\"', '\\'', '(', ')'), array(\"\\n\", '\"', '&#39;', '&#40;', '&#41;'), trim('\$1'))"
441              ),
442              'SIMPLETEXT' => array(
443                  '!([a-zA-Z0-9-+.,_ ]+)!'     =>    "$1"
444              ),
445              'INTTEXT' => array(
446                  ($utf8_pcre_properties) ? '!([\p{L}\p{N}\-+,_. ]+)!u' : '!([a-zA-Z0-9\-+,_. ]+)!u'     =>    "$1"
447              ),
448              'IDENTIFIER' => array(
449                  '!([a-zA-Z0-9-_]+)!'     =>    "$1"
450              ),
451              'COLOR' => array(
452                  '!([a-z]+|#[0-9abcdef]+)!i'    =>    '$1'
453              ),
454              'NUMBER' => array(
455                  '!([0-9]+)!'    =>    '$1'
456              )
457          );
458   
459          $sp_tokens = array(
460              'URL'     => '(?i)((?:' . str_replace(array('!', '\#'), array('\!', '#'), get_preg_expression('url')) . ')|(?:' . str_replace(array('!', '\#'), array('\!', '#'), get_preg_expression('www_url')) . '))(?-i)',
461              'LOCAL_URL'     => '(?i)(' . str_replace(array('!', '\#'), array('\!', '#'), get_preg_expression('relative_url')) . ')(?-i)',
462              'RELATIVE_URL'     => '(?i)(' . str_replace(array('!', '\#'), array('\!', '#'), get_preg_expression('relative_url')) . ')(?-i)',
463              'EMAIL' => '(' . get_preg_expression('email') . ')',
464              'TEXT' => '(.*?)',
465              'SIMPLETEXT' => '([a-zA-Z0-9-+.,_ ]+)',
466              'INTTEXT' => ($utf8_pcre_properties) ? '([\p{L}\p{N}\-+,_. ]+)' : '([a-zA-Z0-9\-+,_. ]+)',
467              'IDENTIFIER' => '([a-zA-Z0-9-_]+)',
468              'COLOR' => '([a-zA-Z]+|#[0-9abcdefABCDEF]+)',
469              'NUMBER' => '([0-9]+)',
470          );
471   
472          $pad = 0;
473          $modifiers = 'i';
474          $modifiers .= ($utf8 && $utf8_pcre_properties) ? 'u' : '';
475   
476          if (preg_match_all('/\{(' . implode('|', array_keys($tokens)) . ')[0-9]*\}/i', $bbcode_match, $m))
477          {
478              foreach ($m[0] as $n => $token)
479              {
480                  $token_type = $m[1][$n];
481   
482                  reset($tokens[strtoupper($token_type)]);
483                  list($match, $replace) = each($tokens[strtoupper($token_type)]);
484   
485                  // Pad backreference numbers from tokens
486                  if (preg_match_all('/(?<!\\\\)\$([0-9]+)/', $replace, $repad))
487                  {
488                      $repad = $pad + sizeof(array_unique($repad[0]));
489                      $replace = preg_replace('/(?<!\\\\)\$([0-9]+)/e', "'\${' . (\$1 + \$pad) . '}'", $replace);
490                      $pad = $repad;
491                  }
492   
493                  // Obtain pattern modifiers to use and alter the regex accordingly
494                  $regex = preg_replace('/!(.*)!([a-z]*)/', '$1', $match);
495                  $regex_modifiers = preg_replace('/!(.*)!([a-z]*)/', '$2', $match);
496   
497                  for ($i = 0, $size = strlen($regex_modifiers); $i < $size; ++$i)
498                  {
499                      if (strpos($modifiers, $regex_modifiers[$i]) === false)
500                      {
501                          $modifiers .= $regex_modifiers[$i];
502   
503                          if ($regex_modifiers[$i] == 'e')
504                          {
505                              $fp_replace = "'" . str_replace("'", "\\'", $fp_replace) . "'";
506                          }
507                      }
508   
509                      if ($regex_modifiers[$i] == 'e')
510                      {
511                          $replace = "'.$replace.'";
512                      }
513                  }
514   
515                  $fp_match = str_replace(preg_quote($token, '!'), $regex, $fp_match);
516                  $fp_replace = str_replace($token, $replace, $fp_replace);
517   
518                  $sp_match = str_replace(preg_quote($token, '!'), $sp_tokens[$token_type], $sp_match);
519   
520                  // Prepend the board url to local relative links
521                  $replace_prepend = ($token_type === 'LOCAL_URL') ? generate_board_url() . '/' : '';
522   
523                  $sp_replace = str_replace($token, $replace_prepend . '${' . ($n + 1) . '}', $sp_replace);
524              }
525   
526              $fp_match = '!' . $fp_match . '!' . $modifiers;
527              $sp_match = '!' . $sp_match . '!s' . (($utf8) ? 'u' : '');
528   
529              if (strpos($fp_match, 'e') !== false)
530              {
531                  $fp_replace = str_replace("'.'", '', $fp_replace);
532                  $fp_replace = str_replace(".''.", '.', $fp_replace);
533              }
534          }
535          else
536          {
537              // No replacement is present, no need for a second-pass pattern replacement
538              // A simple str_replace will suffice
539              $fp_match = '!' . $fp_match . '!' . $modifiers;
540              $sp_match = $fp_replace;
541              $sp_replace = '';
542          }
543   
544          // Lowercase tags
545          $bbcode_tag = preg_replace('/.*?\[([a-z0-9_-]+=?).*/i', '$1', $bbcode_match);
546          $bbcode_search = preg_replace('/.*?\[([a-z0-9_-]+)=?.*/i', '$1', $bbcode_match);
547   
548          if (!preg_match('/^[a-zA-Z0-9_-]+=?$/', $bbcode_tag))
549          {
550              global $user;
551              trigger_error($user->lang['BBCODE_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
552          }
553   
554          $fp_match = preg_replace('#\[/?' . $bbcode_search . '#ie', "strtolower('\$0')", $fp_match);
555          $fp_replace = preg_replace('#\[/?' . $bbcode_search . '#ie', "strtolower('\$0')", $fp_replace);
556          $sp_match = preg_replace('#\[/?' . $bbcode_search . '#ie', "strtolower('\$0')", $sp_match);
557          $sp_replace = preg_replace('#\[/?' . $bbcode_search . '#ie', "strtolower('\$0')", $sp_replace);
558   
559          return array(
560              'bbcode_tag'                => $bbcode_tag,
561              'first_pass_match'            => $fp_match,
562              'first_pass_replace'        => $fp_replace,
563              'second_pass_match'            => $sp_match,
564              'second_pass_replace'        => $sp_replace
565          );
566      }
567  }
568