Line 113 | Line 113 |
---|
{ $template->assign_block_vars('token', array( 'TOKEN' => '{' . $token . '}',
|
{ $template->assign_block_vars('token', array( 'TOKEN' => '{' . $token . '}',
|
'EXPLAIN' => $token_explain) );
| 'EXPLAIN' => ($token === 'LOCAL_URL') ? sprintf($token_explain, generate_board_url() . '/') : $token_explain, ));
|
}
return;
| }
return;
|
Line 124 | Line 124 |
---|
case 'modify': case 'create':
|
case 'modify': case 'create':
|
| $warn_text = preg_match('%<[^>]*\{text[\d]*\}[^>]*>%i', $bbcode_tpl); if (!$warn_text || confirm_box(true)) {
|
$data = $this->build_regexp($bbcode_match, $bbcode_tpl);
// Make sure the user didn't pick a "bad" name for the BBCode tag.
| $data = $this->build_regexp($bbcode_match, $bbcode_tpl);
// Make sure the user didn't pick a "bad" name for the BBCode tag.
|
Line 210 | Line 213 |
---|
$bbcode_id = NUM_CORE_BBCODES + 1; }
|
$bbcode_id = NUM_CORE_BBCODES + 1; }
|
if ($bbcode_id > 1511)
| if ($bbcode_id > BBCODE_LIMIT)
|
{ trigger_error($user->lang['TOO_MANY_BBCODES'] . adm_back_link($this->u_action), E_USER_WARNING); }
| { trigger_error($user->lang['TOO_MANY_BBCODES'] . adm_back_link($this->u_action), E_USER_WARNING); }
|
Line 238 | Line 241 |
---|
add_log('admin', $log_action, $data['bbcode_tag']);
trigger_error($user->lang[$lang] . adm_back_link($this->u_action));
|
add_log('admin', $log_action, $data['bbcode_tag']);
trigger_error($user->lang[$lang] . adm_back_link($this->u_action));
|
| } else { confirm_box(false, $user->lang['BBCODE_DANGER'], build_hidden_fields(array( 'action' => $action, 'bbcode' => $bbcode_id, 'bbcode_match' => $bbcode_match, 'bbcode_tpl' => htmlspecialchars($bbcode_tpl), 'bbcode_helpline' => $bbcode_helpline, 'display_on_posting' => $display_on_posting, )) , 'confirm_bbcode.html'); }
|
break;
| break;
|
Line 299 | Line 315 |
---|
{ $bbcode_match = trim($bbcode_match); $bbcode_tpl = trim($bbcode_tpl);
|
{ $bbcode_match = trim($bbcode_match); $bbcode_tpl = trim($bbcode_tpl);
|
| $utf8 = strpos($bbcode_match, 'INTTEXT') !== false;
// make sure we have utf8 support $utf8_pcre_properties = false; if (version_compare(PHP_VERSION, '5.1.0', '>=') || (version_compare(PHP_VERSION, '5.0.0-dev', '<=') && version_compare(PHP_VERSION, '4.4.0', '>='))) { // While this is the proper range of PHP versions, PHP may not be linked with the bundled PCRE lib and instead with an older version if (@preg_match('/\p{L}/u', 'a') !== false) { $utf8_pcre_properties = true; } }
|
$fp_match = preg_quote($bbcode_match, '!'); $fp_replace = preg_replace('#^\[(.*?)\]#', '[$1:$uid]', $bbcode_match);
| $fp_match = preg_quote($bbcode_match, '!'); $fp_replace = preg_replace('#^\[(.*?)\]#', '[$1:$uid]', $bbcode_match);
|
Line 315 | Line 343 |
---|
'!(?:(' . 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')" ), 'LOCAL_URL' => array(
|
'!(?:(' . 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')" ), 'LOCAL_URL' => array(
|
| '!(' . str_replace(array('!', '\#'), array('\!', '#'), get_preg_expression('relative_url')) . ')!e' => "\$this->bbcode_specialchars('$1')" ), 'RELATIVE_URL' => array(
|
'!(' . str_replace(array('!', '\#'), array('\!', '#'), get_preg_expression('relative_url')) . ')!e' => "\$this->bbcode_specialchars('$1')" ), 'EMAIL' => array(
| '!(' . str_replace(array('!', '\#'), array('\!', '#'), get_preg_expression('relative_url')) . ')!e' => "\$this->bbcode_specialchars('$1')" ), 'EMAIL' => array(
|
Line 325 | Line 356 |
---|
), 'SIMPLETEXT' => array( '!([a-zA-Z0-9-+.,_ ]+)!' => "$1"
|
), 'SIMPLETEXT' => array( '!([a-zA-Z0-9-+.,_ ]+)!' => "$1"
|
| ), 'INTTEXT' => array( ($utf8_pcre_properties) ? '!([\p{L}\p{N}\-+,_. ]+)!u' : '!([a-zA-Z0-9\-+,_. ]+)!u' => "$1"
|
), 'IDENTIFIER' => array( '!([a-zA-Z0-9-_]+)!' => "$1"
| ), 'IDENTIFIER' => array( '!([a-zA-Z0-9-_]+)!' => "$1"
|
Line 340 | Line 374 |
---|
$sp_tokens = array( 'URL' => '(?i)((?:' . str_replace(array('!', '\#'), array('\!', '#'), get_preg_expression('url')) . ')|(?:' . str_replace(array('!', '\#'), array('\!', '#'), get_preg_expression('www_url')) . '))(?-i)', 'LOCAL_URL' => '(?i)(' . str_replace(array('!', '\#'), array('\!', '#'), get_preg_expression('relative_url')) . ')(?-i)',
|
$sp_tokens = array( 'URL' => '(?i)((?:' . str_replace(array('!', '\#'), array('\!', '#'), get_preg_expression('url')) . ')|(?:' . str_replace(array('!', '\#'), array('\!', '#'), get_preg_expression('www_url')) . '))(?-i)', 'LOCAL_URL' => '(?i)(' . str_replace(array('!', '\#'), array('\!', '#'), get_preg_expression('relative_url')) . ')(?-i)',
|
| 'RELATIVE_URL' => '(?i)(' . str_replace(array('!', '\#'), array('\!', '#'), get_preg_expression('relative_url')) . ')(?-i)',
|
'EMAIL' => '(' . get_preg_expression('email') . ')', 'TEXT' => '(.*?)', 'SIMPLETEXT' => '([a-zA-Z0-9-+.,_ ]+)',
|
'EMAIL' => '(' . get_preg_expression('email') . ')', 'TEXT' => '(.*?)', 'SIMPLETEXT' => '([a-zA-Z0-9-+.,_ ]+)',
|
| 'INTTEXT' => ($utf8_pcre_properties) ? '([\p{L}\p{N}\-+,_. ]+)' : '([a-zA-Z0-9\-+,_. ]+)',
|
'IDENTIFIER' => '([a-zA-Z0-9-_]+)', 'COLOR' => '([a-zA-Z]+|#[0-9abcdefABCDEF]+)', 'NUMBER' => '([0-9]+)',
| 'IDENTIFIER' => '([a-zA-Z0-9-_]+)', 'COLOR' => '([a-zA-Z]+|#[0-9abcdefABCDEF]+)', 'NUMBER' => '([0-9]+)',
|
Line 350 | Line 386 |
---|
$pad = 0; $modifiers = 'i';
|
$pad = 0; $modifiers = 'i';
|
| $modifiers .= ($utf8 && $utf8_pcre_properties) ? 'u' : '';
|
if (preg_match_all('/\{(' . implode('|', array_keys($tokens)) . ')[0-9]*\}/i', $bbcode_match, $m)) {
| if (preg_match_all('/\{(' . implode('|', array_keys($tokens)) . ')[0-9]*\}/i', $bbcode_match, $m)) {
|
Line 394 | Line 431 |
---|
$fp_replace = str_replace($token, $replace, $fp_replace);
$sp_match = str_replace(preg_quote($token, '!'), $sp_tokens[$token_type], $sp_match);
|
$fp_replace = str_replace($token, $replace, $fp_replace);
$sp_match = str_replace(preg_quote($token, '!'), $sp_tokens[$token_type], $sp_match);
|
$sp_replace = str_replace($token, '${' . ($n + 1) . '}', $sp_replace);
| // Prepend the board url to local relative links $replace_prepend = ($token_type === 'LOCAL_URL') ? generate_board_url() . '/' : '';
$sp_replace = str_replace($token, $replace_prepend . '${' . ($n + 1) . '}', $sp_replace);
|
}
$fp_match = '!' . $fp_match . '!' . $modifiers;
|
}
$fp_match = '!' . $fp_match . '!' . $modifiers;
|
$sp_match = '!' . $sp_match . '!s';
| $sp_match = '!' . $sp_match . '!s' . (($utf8) ? 'u' : '');
|
if (strpos($fp_match, 'e') !== false) {
| if (strpos($fp_match, 'e') !== false) {
|