[ Index ] |
PHP Cross Reference of phpBB-3.2.11-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * 4 * This file is part of the phpBB Forum Software package. 5 * 6 * @copyright (c) phpBB Limited <https://www.phpbb.com> 7 * @license GNU General Public License, version 2 (GPL-2.0) 8 * 9 * For full copyright and license information, please see 10 * the docs/CREDITS.txt file. 11 * 12 */ 13 14 /** 15 * @ignore 16 */ 17 if (!defined('IN_PHPBB')) 18 { 19 exit; 20 } 21 22 class acp_bbcodes 23 { 24 var $u_action; 25 26 function main($id, $mode) 27 { 28 global $db, $user, $template, $cache, $request, $phpbb_dispatcher, $phpbb_container; 29 global $phpbb_log; 30 31 $user->add_lang('acp/posting'); 32 33 // Set up general vars 34 $action = $request->variable('action', ''); 35 $bbcode_id = $request->variable('bbcode', 0); 36 37 $this->tpl_name = 'acp_bbcodes'; 38 $this->page_title = 'ACP_BBCODES'; 39 $form_key = 'acp_bbcodes'; 40 41 add_form_key($form_key); 42 43 // Set up mode-specific vars 44 switch ($action) 45 { 46 case 'add': 47 $bbcode_match = $bbcode_tpl = $bbcode_helpline = ''; 48 $display_on_posting = 0; 49 break; 50 51 case 'edit': 52 $sql = 'SELECT bbcode_match, bbcode_tpl, display_on_posting, bbcode_helpline 53 FROM ' . BBCODES_TABLE . ' 54 WHERE bbcode_id = ' . $bbcode_id; 55 $result = $db->sql_query($sql); 56 $row = $db->sql_fetchrow($result); 57 $db->sql_freeresult($result); 58 59 if (!$row) 60 { 61 trigger_error($user->lang['BBCODE_NOT_EXIST'] . adm_back_link($this->u_action), E_USER_WARNING); 62 } 63 64 $bbcode_match = $row['bbcode_match']; 65 $bbcode_tpl = htmlspecialchars($row['bbcode_tpl']); 66 $display_on_posting = $row['display_on_posting']; 67 $bbcode_helpline = $row['bbcode_helpline']; 68 break; 69 70 case 'modify': 71 $sql = 'SELECT bbcode_id, bbcode_tag 72 FROM ' . BBCODES_TABLE . ' 73 WHERE bbcode_id = ' . $bbcode_id; 74 $result = $db->sql_query($sql); 75 $row = $db->sql_fetchrow($result); 76 $db->sql_freeresult($result); 77 78 if (!$row) 79 { 80 trigger_error($user->lang['BBCODE_NOT_EXIST'] . adm_back_link($this->u_action), E_USER_WARNING); 81 } 82 83 // No break here 84 85 case 'create': 86 $display_on_posting = $request->variable('display_on_posting', 0); 87 88 $bbcode_match = $request->variable('bbcode_match', ''); 89 $bbcode_tpl = htmlspecialchars_decode($request->variable('bbcode_tpl', '', true)); 90 $bbcode_helpline = $request->variable('bbcode_helpline', '', true); 91 break; 92 } 93 94 // Do major work 95 switch ($action) 96 { 97 case 'edit': 98 case 'add': 99 100 $tpl_ary = array( 101 'S_EDIT_BBCODE' => true, 102 'U_BACK' => $this->u_action, 103 'U_ACTION' => $this->u_action . '&action=' . (($action == 'add') ? 'create' : 'modify') . (($bbcode_id) ? "&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 177 if (!$warn_text && !check_form_key($form_key)) 178 { 179 trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); 180 } 181 182 if (!$warn_text || confirm_box(true)) 183 { 184 $data = $this->build_regexp($bbcode_match, $bbcode_tpl); 185 186 // Make sure the user didn't pick a "bad" name for the BBCode tag. 187 $hard_coded = array('code', 'quote', 'quote=', 'attachment', 'attachment=', 'b', 'i', 'url', 'url=', 'img', 'size', 'size=', 'color', 'color=', 'u', 'list', 'list=', 'email', 'email=', 'flash', 'flash='); 188 189 if (($action == 'modify' && strtolower($data['bbcode_tag']) !== strtolower($row['bbcode_tag'])) || ($action == 'create')) 190 { 191 $sql = 'SELECT 1 as test 192 FROM ' . BBCODES_TABLE . " 193 WHERE LOWER(bbcode_tag) = '" . $db->sql_escape(strtolower($data['bbcode_tag'])) . "'"; 194 $result = $db->sql_query($sql); 195 $info = $db->sql_fetchrow($result); 196 $db->sql_freeresult($result); 197 198 // Grab the end, interrogate the last closing tag 199 if ($info['test'] === '1' || in_array(strtolower($data['bbcode_tag']), $hard_coded) || (preg_match('#\[/([^[]*)]$#', $bbcode_match, $regs) && in_array(strtolower($regs[1]), $hard_coded))) 200 { 201 trigger_error($user->lang['BBCODE_INVALID_TAG_NAME'] . adm_back_link($this->u_action), E_USER_WARNING); 202 } 203 } 204 205 if (substr($data['bbcode_tag'], -1) === '=') 206 { 207 $test = substr($data['bbcode_tag'], 0, -1); 208 } 209 else 210 { 211 $test = $data['bbcode_tag']; 212 } 213 214 if (strlen($data['bbcode_tag']) > 16) 215 { 216 trigger_error($user->lang['BBCODE_TAG_TOO_LONG'] . adm_back_link($this->u_action), E_USER_WARNING); 217 } 218 219 if (strlen($bbcode_match) > 4000) 220 { 221 trigger_error($user->lang['BBCODE_TAG_DEF_TOO_LONG'] . adm_back_link($this->u_action), E_USER_WARNING); 222 } 223 224 if (strlen($bbcode_helpline) > 255) 225 { 226 trigger_error($user->lang['BBCODE_HELPLINE_TOO_LONG'] . adm_back_link($this->u_action), E_USER_WARNING); 227 } 228 229 /** 230 * Replace Emojis and other 4bit UTF-8 chars not allowed by MySQL to UCR/NCR. 231 * Using their Numeric Character Reference's Hexadecimal notation. 232 */ 233 $bbcode_helpline = utf8_encode_ucr($bbcode_helpline); 234 235 $sql_ary = array_merge($sql_ary, array( 236 'bbcode_tag' => $data['bbcode_tag'], 237 'bbcode_match' => $bbcode_match, 238 'bbcode_tpl' => $bbcode_tpl, 239 'display_on_posting' => $display_on_posting, 240 'bbcode_helpline' => $bbcode_helpline, 241 'first_pass_match' => $data['first_pass_match'], 242 'first_pass_replace' => $data['first_pass_replace'], 243 'second_pass_match' => $data['second_pass_match'], 244 'second_pass_replace' => $data['second_pass_replace'] 245 )); 246 247 if ($action == 'create') 248 { 249 $sql = 'SELECT MAX(bbcode_id) as max_bbcode_id 250 FROM ' . BBCODES_TABLE; 251 $result = $db->sql_query($sql); 252 $row = $db->sql_fetchrow($result); 253 $db->sql_freeresult($result); 254 255 if ($row) 256 { 257 $bbcode_id = (int) $row['max_bbcode_id'] + 1; 258 259 // Make sure it is greater than the core bbcode ids... 260 if ($bbcode_id <= NUM_CORE_BBCODES) 261 { 262 $bbcode_id = NUM_CORE_BBCODES + 1; 263 } 264 } 265 else 266 { 267 $bbcode_id = NUM_CORE_BBCODES + 1; 268 } 269 270 if ($bbcode_id > BBCODE_LIMIT) 271 { 272 trigger_error($user->lang['TOO_MANY_BBCODES'] . adm_back_link($this->u_action), E_USER_WARNING); 273 } 274 275 $sql_ary['bbcode_id'] = (int) $bbcode_id; 276 277 $db->sql_query('INSERT INTO ' . BBCODES_TABLE . $db->sql_build_array('INSERT', $sql_ary)); 278 $cache->destroy('sql', BBCODES_TABLE); 279 $phpbb_container->get('text_formatter.cache')->invalidate(); 280 281 $lang = 'BBCODE_ADDED'; 282 $log_action = 'LOG_BBCODE_ADD'; 283 } 284 else 285 { 286 $sql = 'UPDATE ' . BBCODES_TABLE . ' 287 SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' 288 WHERE bbcode_id = ' . $bbcode_id; 289 $db->sql_query($sql); 290 $cache->destroy('sql', BBCODES_TABLE); 291 $phpbb_container->get('text_formatter.cache')->invalidate(); 292 293 $lang = 'BBCODE_EDITED'; 294 $log_action = 'LOG_BBCODE_EDIT'; 295 } 296 297 $phpbb_log->add('admin', $user->data['user_id'], $user->ip, $log_action, false, array($data['bbcode_tag'])); 298 299 /** 300 * Event after a BBCode has been added or updated 301 * 302 * @event core.acp_bbcodes_modify_create_after 303 * @var string action Type of the action: modify|create 304 * @var int bbcode_id The id of the added or updated bbcode 305 * @var array sql_ary Array with bbcode data (read only) 306 * @since 3.2.4-RC1 307 */ 308 $vars = array( 309 'action', 310 'bbcode_id', 311 'sql_ary', 312 ); 313 extract($phpbb_dispatcher->trigger_event('core.acp_bbcodes_modify_create_after', compact($vars))); 314 315 trigger_error($user->lang[$lang] . adm_back_link($this->u_action)); 316 } 317 else 318 { 319 confirm_box(false, $user->lang['BBCODE_DANGER'], build_hidden_fields(array_merge($hidden_fields, array( 320 'action' => $action, 321 'bbcode' => $bbcode_id, 322 'bbcode_match' => $bbcode_match, 323 'bbcode_tpl' => htmlspecialchars($bbcode_tpl), 324 'bbcode_helpline' => $bbcode_helpline, 325 'display_on_posting' => $display_on_posting, 326 ))) 327 , 'confirm_bbcode.html'); 328 } 329 330 break; 331 332 case 'delete': 333 334 $sql = 'SELECT bbcode_tag 335 FROM ' . BBCODES_TABLE . " 336 WHERE bbcode_id = $bbcode_id"; 337 $result = $db->sql_query($sql); 338 $row = $db->sql_fetchrow($result); 339 $db->sql_freeresult($result); 340 341 if ($row) 342 { 343 if (confirm_box(true)) 344 { 345 $bbcode_tag = $row['bbcode_tag']; 346 347 $db->sql_query('DELETE FROM ' . BBCODES_TABLE . " WHERE bbcode_id = $bbcode_id"); 348 $cache->destroy('sql', BBCODES_TABLE); 349 $phpbb_container->get('text_formatter.cache')->invalidate(); 350 $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_BBCODE_DELETE', false, array($bbcode_tag)); 351 352 /** 353 * Event after a BBCode has been deleted 354 * 355 * @event core.acp_bbcodes_delete_after 356 * @var string action Type of the action: delete 357 * @var int bbcode_id The id of the deleted bbcode 358 * @var string bbcode_tag The tag of the deleted bbcode 359 * @since 3.2.4-RC1 360 */ 361 $vars = array( 362 'action', 363 'bbcode_id', 364 'bbcode_tag', 365 ); 366 extract($phpbb_dispatcher->trigger_event('core.acp_bbcodes_delete_after', compact($vars))); 367 368 if ($request->is_ajax()) 369 { 370 $json_response = new \phpbb\json_response; 371 $json_response->send(array( 372 'MESSAGE_TITLE' => $user->lang['INFORMATION'], 373 'MESSAGE_TEXT' => $user->lang['BBCODE_DELETED'], 374 'REFRESH_DATA' => array( 375 'time' => 3 376 ) 377 )); 378 } 379 } 380 else 381 { 382 confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( 383 'bbcode' => $bbcode_id, 384 'i' => $id, 385 'mode' => $mode, 386 'action' => $action)) 387 ); 388 } 389 } 390 391 break; 392 } 393 394 $u_action = $this->u_action; 395 396 $template_data = array( 397 'U_ACTION' => $this->u_action . '&action=add', 398 ); 399 400 $sql_ary = array( 401 'SELECT' => 'b.*', 402 'FROM' => array(BBCODES_TABLE => 'b'), 403 'ORDER_BY' => 'b.bbcode_tag', 404 ); 405 406 /** 407 * Modify custom bbcode template data before we display the form 408 * 409 * @event core.acp_bbcodes_display_form 410 * @var string action Type of the action: modify|create 411 * @var array sql_ary The SQL array to get custom bbcode data 412 * @var array template_data Array with form template data 413 * @var string u_action The u_action link 414 * @since 3.1.0-a3 415 */ 416 $vars = array('action', 'sql_ary', 'template_data', 'u_action'); 417 extract($phpbb_dispatcher->trigger_event('core.acp_bbcodes_display_form', compact($vars))); 418 419 $result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary)); 420 421 $template->assign_vars($template_data); 422 423 while ($row = $db->sql_fetchrow($result)) 424 { 425 $bbcodes_array = array( 426 'BBCODE_TAG' => $row['bbcode_tag'], 427 'U_EDIT' => $u_action . '&action=edit&bbcode=' . $row['bbcode_id'], 428 'U_DELETE' => $u_action . '&action=delete&bbcode=' . $row['bbcode_id'], 429 ); 430 431 /** 432 * Modify display of custom bbcodes in the form 433 * 434 * @event core.acp_bbcodes_display_bbcodes 435 * @var array row Array with current bbcode data 436 * @var array bbcodes_array Array of bbcodes template data 437 * @var string u_action The u_action link 438 * @since 3.1.0-a3 439 */ 440 $vars = array('bbcodes_array', 'row', 'u_action'); 441 extract($phpbb_dispatcher->trigger_event('core.acp_bbcodes_display_bbcodes', compact($vars))); 442 443 $template->assign_block_vars('bbcodes', $bbcodes_array); 444 445 } 446 $db->sql_freeresult($result); 447 } 448 449 /* 450 * Build regular expression for custom bbcode 451 */ 452 function build_regexp(&$bbcode_match, &$bbcode_tpl) 453 { 454 $bbcode_match = trim($bbcode_match); 455 $bbcode_tpl = trim($bbcode_tpl); 456 457 // Allow unicode characters for URL|LOCAL_URL|RELATIVE_URL|INTTEXT tokens 458 $utf8 = preg_match('/(URL|LOCAL_URL|RELATIVE_URL|INTTEXT)/', $bbcode_match); 459 460 $fp_match = preg_quote($bbcode_match, '!'); 461 $fp_replace = preg_replace('#^\[(.*?)\]#', '[$1:$uid]', $bbcode_match); 462 $fp_replace = preg_replace('#\[/(.*?)\]$#', '[/$1:$uid]', $fp_replace); 463 464 $sp_match = preg_quote($bbcode_match, '!'); 465 $sp_match = preg_replace('#^\\\\\[(.*?)\\\\\]#', '\[$1:$uid\]', $sp_match); 466 $sp_match = preg_replace('#\\\\\[/(.*?)\\\\\]$#', '\[/$1:$uid\]', $sp_match); 467 $sp_replace = $bbcode_tpl; 468 469 // @todo Make sure to change this too if something changed in message parsing 470 $tokens = array( 471 'URL' => array( 472 '!(?:(' . 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')" 473 ), 474 'LOCAL_URL' => array( 475 '!(' . str_replace(array('!', '\#'), array('\!', '#'), get_preg_expression('relative_url')) . ')!e' => "\$this->bbcode_specialchars('$1')" 476 ), 477 'RELATIVE_URL' => array( 478 '!(' . str_replace(array('!', '\#'), array('\!', '#'), get_preg_expression('relative_url')) . ')!e' => "\$this->bbcode_specialchars('$1')" 479 ), 480 'EMAIL' => array( 481 '!(' . get_preg_expression('email') . ')!ie' => "\$this->bbcode_specialchars('$1')" 482 ), 483 'TEXT' => array( 484 '!(.*?)!es' => "str_replace(array(\"\\r\\n\", '\\\"', '\\'', '(', ')'), array(\"\\n\", '\"', ''', '(', ')'), trim('\$1'))" 485 ), 486 'SIMPLETEXT' => array( 487 '!([a-zA-Z0-9-+.,_ ]+)!' => "$1" 488 ), 489 'INTTEXT' => array( 490 '!([\p{L}\p{N}\-+,_. ]+)!u' => "$1" 491 ), 492 'IDENTIFIER' => array( 493 '!([a-zA-Z0-9-_]+)!' => "$1" 494 ), 495 'COLOR' => array( 496 '!([a-z]+|#[0-9abcdef]+)!i' => '$1' 497 ), 498 'NUMBER' => array( 499 '!([0-9]+)!' => '$1' 500 ) 501 ); 502 503 $sp_tokens = array( 504 'URL' => '(?i)((?:' . str_replace(array('!', '\#'), array('\!', '#'), get_preg_expression('url')) . ')|(?:' . str_replace(array('!', '\#'), array('\!', '#'), get_preg_expression('www_url')) . '))(?-i)', 505 'LOCAL_URL' => '(?i)(' . str_replace(array('!', '\#'), array('\!', '#'), get_preg_expression('relative_url')) . ')(?-i)', 506 'RELATIVE_URL' => '(?i)(' . str_replace(array('!', '\#'), array('\!', '#'), get_preg_expression('relative_url')) . ')(?-i)', 507 'EMAIL' => '(' . get_preg_expression('email') . ')', 508 'TEXT' => '(.*?)', 509 'SIMPLETEXT' => '([a-zA-Z0-9-+.,_ ]+)', 510 'INTTEXT' => '([\p{L}\p{N}\-+,_. ]+)', 511 'IDENTIFIER' => '([a-zA-Z0-9-_]+)', 512 'COLOR' => '([a-zA-Z]+|#[0-9abcdefABCDEF]+)', 513 'NUMBER' => '([0-9]+)', 514 ); 515 516 $pad = 0; 517 $modifiers = 'i'; 518 $modifiers .= ($utf8) ? 'u' : ''; 519 520 if (preg_match_all('/\{(' . implode('|', array_keys($tokens)) . ')[0-9]*\}/i', $bbcode_match, $m)) 521 { 522 foreach ($m[0] as $n => $token) 523 { 524 $token_type = $m[1][$n]; 525 526 reset($tokens[strtoupper($token_type)]); 527 list($match, $replace) = each($tokens[strtoupper($token_type)]); 528 529 // Pad backreference numbers from tokens 530 if (preg_match_all('/(?<!\\\\)\$([0-9]+)/', $replace, $repad)) 531 { 532 $repad = $pad + count(array_unique($repad[0])); 533 $replace = preg_replace_callback('/(?<!\\\\)\$([0-9]+)/', function ($match) use ($pad) { 534 return '${' . ($match[1] + $pad) . '}'; 535 }, $replace); 536 $pad = $repad; 537 } 538 539 // Obtain pattern modifiers to use and alter the regex accordingly 540 $regex = preg_replace('/!(.*)!([a-z]*)/', '$1', $match); 541 $regex_modifiers = preg_replace('/!(.*)!([a-z]*)/', '$2', $match); 542 543 for ($i = 0, $size = strlen($regex_modifiers); $i < $size; ++$i) 544 { 545 if (strpos($modifiers, $regex_modifiers[$i]) === false) 546 { 547 $modifiers .= $regex_modifiers[$i]; 548 549 if ($regex_modifiers[$i] == 'e') 550 { 551 $fp_replace = "'" . str_replace("'", "\\'", $fp_replace) . "'"; 552 } 553 } 554 555 if ($regex_modifiers[$i] == 'e') 556 { 557 $replace = "'.$replace.'"; 558 } 559 } 560 561 $fp_match = str_replace(preg_quote($token, '!'), $regex, $fp_match); 562 $fp_replace = str_replace($token, $replace, $fp_replace); 563 564 $sp_match = str_replace(preg_quote($token, '!'), $sp_tokens[$token_type], $sp_match); 565 566 // Prepend the board url to local relative links 567 $replace_prepend = ($token_type === 'LOCAL_URL') ? generate_board_url() . '/' : ''; 568 569 $sp_replace = str_replace($token, $replace_prepend . '${' . ($n + 1) . '}', $sp_replace); 570 } 571 572 $fp_match = '!' . $fp_match . '!' . $modifiers; 573 $sp_match = '!' . $sp_match . '!s' . (($utf8) ? 'u' : ''); 574 575 if (strpos($fp_match, 'e') !== false) 576 { 577 $fp_replace = str_replace("'.'", '', $fp_replace); 578 $fp_replace = str_replace(".''.", '.', $fp_replace); 579 } 580 } 581 else 582 { 583 // No replacement is present, no need for a second-pass pattern replacement 584 // A simple str_replace will suffice 585 $fp_match = '!' . $fp_match . '!' . $modifiers; 586 $sp_match = $fp_replace; 587 $sp_replace = ''; 588 } 589 590 // Lowercase tags 591 $bbcode_tag = preg_replace('/.*?\[([a-z0-9_-]+).*/i', '$1', $bbcode_match); 592 $bbcode_search = preg_replace('/.*?\[([a-z0-9_-]+).*/i', '$1', $bbcode_match); 593 594 if (!preg_match('/^[a-zA-Z0-9_-]+$/', $bbcode_tag)) 595 { 596 global $user; 597 trigger_error($user->lang['BBCODE_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); 598 } 599 600 $fp_match = preg_replace_callback('#\[/?' . $bbcode_search . '#i', function ($match) { 601 return strtolower($match[0]); 602 }, $fp_match); 603 $fp_replace = preg_replace_callback('#\[/?' . $bbcode_search . '#i', function ($match) { 604 return strtolower($match[0]); 605 }, $fp_replace); 606 $sp_match = preg_replace_callback('#\[/?' . $bbcode_search . '#i', function ($match) { 607 return strtolower($match[0]); 608 }, $sp_match); 609 $sp_replace = preg_replace_callback('#\[/?' . $bbcode_search . '#i', function ($match) { 610 return strtolower($match[0]); 611 }, $sp_replace); 612 613 return array( 614 'bbcode_tag' => $bbcode_tag, 615 'first_pass_match' => $fp_match, 616 'first_pass_replace' => $fp_replace, 617 'second_pass_match' => $sp_match, 618 'second_pass_replace' => $sp_replace 619 ); 620 } 621 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Nov 11 20:33:01 2020 | Cross-referenced by PHPXref 0.7.1 |