|
@@ -1454,7 +1454,7 @@ function parse_bbc($message, $smileys = true, $cache_id = '', $parse_tags = arra
|
|
'validate' => isset($disabled['php']) ? null : create_function('&$tag, &$data, $disabled', '
|
|
'validate' => isset($disabled['php']) ? null : create_function('&$tag, &$data, $disabled', '
|
|
if (!isset($disabled[\'php\']))
|
|
if (!isset($disabled[\'php\']))
|
|
{
|
|
{
|
|
- $add_begin = substr(trim($data), 0, 5) != \'<?\';
|
|
|
|
|
|
+ $add_begin = strpos(trim($data), \'<?\') === 0;
|
|
$data = highlight_php_code($add_begin ? \'<?php \' . $data . \'?>\' : $data);
|
|
$data = highlight_php_code($add_begin ? \'<?php \' . $data . \'?>\' : $data);
|
|
if ($add_begin)
|
|
if ($add_begin)
|
|
$data = preg_replace(array(\'~^(.+?)<\?.{0,40}?php(?: |\s)~\', \'~\?>((?:</(font|span)>)*)$~\'), \'$1\', $data, 2);
|
|
$data = preg_replace(array(\'~^(.+?)<\?.{0,40}?php(?: |\s)~\', \'~\?>((?:</(font|span)>)*)$~\'), \'$1\', $data, 2);
|
|
@@ -1960,7 +1960,7 @@ function parse_bbc($message, $smileys = true, $cache_id = '', $parse_tags = arra
|
|
if ($pos >= strlen($message) - 1)
|
|
if ($pos >= strlen($message) - 1)
|
|
break;
|
|
break;
|
|
|
|
|
|
- $tags = strtolower(substr($message, $pos + 1, 1));
|
|
|
|
|
|
+ $tags = strtolower($message[$pos + 1]);
|
|
|
|
|
|
if ($tags == '/' && !empty($open_tags))
|
|
if ($tags == '/' && !empty($open_tags))
|
|
{
|
|
{
|
|
@@ -2043,7 +2043,7 @@ function parse_bbc($message, $smileys = true, $cache_id = '', $parse_tags = arra
|
|
$pos2 = $pos - 1;
|
|
$pos2 = $pos - 1;
|
|
|
|
|
|
// See the comment at the end of the big loop - just eating whitespace ;).
|
|
// See the comment at the end of the big loop - just eating whitespace ;).
|
|
- if (!empty($tag['block_level']) && substr($message, $pos, 6) == '<br />')
|
|
|
|
|
|
+ if (!empty($tag['block_level']) && strpos($message, '<br />') === $pos)
|
|
$message = substr($message, 0, $pos) . substr($message, $pos + 6);
|
|
$message = substr($message, 0, $pos) . substr($message, $pos + 6);
|
|
if (!empty($tag['trim']) && $tag['trim'] != 'inside' && preg_match('~(<br />| |\s)*~', substr($message, $pos), $matches) != 0)
|
|
if (!empty($tag['trim']) && $tag['trim'] != 'inside' && preg_match('~(<br />| |\s)*~', substr($message, $pos), $matches) != 0)
|
|
$message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0]));
|
|
$message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0]));
|
|
@@ -2067,10 +2067,10 @@ function parse_bbc($message, $smileys = true, $cache_id = '', $parse_tags = arra
|
|
foreach ($bbc_codes[$tags] as $possible)
|
|
foreach ($bbc_codes[$tags] as $possible)
|
|
{
|
|
{
|
|
// Not a match?
|
|
// Not a match?
|
|
- if (strtolower(substr($message, $pos + 1, strlen($possible['tag']))) != $possible['tag'])
|
|
|
|
|
|
+ if (stripos($message, $possible['tag']) !== $pos + 1)
|
|
continue;
|
|
continue;
|
|
|
|
|
|
- $next_c = substr($message, $pos + 1 + strlen($possible['tag']), 1);
|
|
|
|
|
|
+ $next_c = $message[$pos + 1 + strlen($possible['tag'])];
|
|
|
|
|
|
// A test validation?
|
|
// A test validation?
|
|
if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + strlen($possible['tag']) + 1)) == 0)
|
|
if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + strlen($possible['tag']) + 1)) == 0)
|
|
@@ -2087,7 +2087,7 @@ function parse_bbc($message, $smileys = true, $cache_id = '', $parse_tags = arra
|
|
if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=')
|
|
if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=')
|
|
continue;
|
|
continue;
|
|
// Maybe we just want a /...
|
|
// Maybe we just want a /...
|
|
- if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + strlen($possible['tag']), 2) != '/]' && substr($message, $pos + 1 + strlen($possible['tag']), 3) != ' /]')
|
|
|
|
|
|
+ if ($possible['type'] == 'closed' && $next_c != ']' && strpos($message, '/]') !== $pos + 1 + strlen($possible['tag']) && strpos($message, ' /]') !== $pos + 1 + strlen($possible['tag']))
|
|
continue;
|
|
continue;
|
|
// An immediate ]?
|
|
// An immediate ]?
|
|
if ($possible['type'] == 'unparsed_content' && $next_c != ']')
|
|
if ($possible['type'] == 'unparsed_content' && $next_c != ']')
|
|
@@ -2183,11 +2183,11 @@ function parse_bbc($message, $smileys = true, $cache_id = '', $parse_tags = arra
|
|
}
|
|
}
|
|
|
|
|
|
// Item codes are complicated buggers... they are implicit [li]s and can make [list]s!
|
|
// Item codes are complicated buggers... they are implicit [li]s and can make [list]s!
|
|
- if ($smileys !== false && $tag === null && isset($itemcodes[substr($message, $pos + 1, 1)]) && substr($message, $pos + 2, 1) == ']' && !isset($disabled['list']) && !isset($disabled['li']))
|
|
|
|
|
|
+ if ($smileys !== false && $tag === null && isset($itemcodes[$message[$pos + 1]]) && $message[$pos + 2] == ']' && !isset($disabled['list']) && !isset($disabled['li']))
|
|
{
|
|
{
|
|
- if (substr($message, $pos + 1, 1) == '0' && !in_array(substr($message, $pos - 1, 1), array(';', ' ', "\t", '>')))
|
|
|
|
|
|
+ if ($message[$pos + 1] == '0' && !in_array($message[$pos - 1], array(';', ' ', "\t", '>')))
|
|
continue;
|
|
continue;
|
|
- $tag = $itemcodes[substr($message, $pos + 1, 1)];
|
|
|
|
|
|
+ $tag = $itemcodes[$message[$pos + 1]];
|
|
|
|
|
|
// First let's set up the tree: it needs to be in a list, or after an li.
|
|
// First let's set up the tree: it needs to be in a list, or after an li.
|
|
if ($inside === null || ($inside['tag'] != 'list' && $inside['tag'] != 'li'))
|
|
if ($inside === null || ($inside['tag'] != 'list' && $inside['tag'] != 'li'))
|
|
@@ -2295,7 +2295,7 @@ function parse_bbc($message, $smileys = true, $cache_id = '', $parse_tags = arra
|
|
$pos1 += strlen($open_tags[$i]['after']) + 2;
|
|
$pos1 += strlen($open_tags[$i]['after']) + 2;
|
|
|
|
|
|
// Trim or eat trailing stuff... see comment at the end of the big loop.
|
|
// Trim or eat trailing stuff... see comment at the end of the big loop.
|
|
- if (!empty($open_tags[$i]['block_level']) && substr($message, $pos, 6) == '<br />')
|
|
|
|
|
|
+ if (!empty($open_tags[$i]['block_level']) && strpos($message, '<br />') === $pos)
|
|
$message = substr($message, 0, $pos) . substr($message, $pos + 6);
|
|
$message = substr($message, 0, $pos) . substr($message, $pos + 6);
|
|
if (!empty($open_tags[$i]['trim']) && $tag['trim'] != 'inside' && preg_match('~(<br />| |\s)*~', substr($message, $pos), $matches) != 0)
|
|
if (!empty($open_tags[$i]['trim']) && $tag['trim'] != 'inside' && preg_match('~(<br />| |\s)*~', substr($message, $pos), $matches) != 0)
|
|
$message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0]));
|
|
$message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0]));
|
|
@@ -2321,7 +2321,7 @@ function parse_bbc($message, $smileys = true, $cache_id = '', $parse_tags = arra
|
|
|
|
|
|
$data = substr($message, $pos1, $pos2 - $pos1);
|
|
$data = substr($message, $pos1, $pos2 - $pos1);
|
|
|
|
|
|
- if (!empty($tag['block_level']) && substr($data, 0, 6) == '<br />')
|
|
|
|
|
|
+ if (!empty($tag['block_level']) && strpos($data, '<br />') === 0)
|
|
$data = substr($data, 6);
|
|
$data = substr($data, 6);
|
|
|
|
|
|
if (isset($tag['validate']))
|
|
if (isset($tag['validate']))
|
|
@@ -2340,7 +2340,7 @@ function parse_bbc($message, $smileys = true, $cache_id = '', $parse_tags = arra
|
|
// The value may be quoted for some tags - check.
|
|
// The value may be quoted for some tags - check.
|
|
if (isset($tag['quoted']))
|
|
if (isset($tag['quoted']))
|
|
{
|
|
{
|
|
- $quoted = substr($message, $pos1, 6) == '"';
|
|
|
|
|
|
+ $quoted = strpos($message, '"') == $pos1;
|
|
if ($tag['quoted'] != 'optional' && !$quoted)
|
|
if ($tag['quoted'] != 'optional' && !$quoted)
|
|
continue;
|
|
continue;
|
|
|
|
|
|
@@ -2362,7 +2362,7 @@ function parse_bbc($message, $smileys = true, $cache_id = '', $parse_tags = arra
|
|
substr($message, $pos1, $pos2 - $pos1)
|
|
substr($message, $pos1, $pos2 - $pos1)
|
|
);
|
|
);
|
|
|
|
|
|
- if (!empty($tag['block_level']) && substr($data[0], 0, 6) == '<br />')
|
|
|
|
|
|
+ if (!empty($tag['block_level']) && substr($data[0], '<br />') === 0)
|
|
$data[0] = substr($data[0], 6);
|
|
$data[0] = substr($data[0], 6);
|
|
|
|
|
|
// Validation for my parking, please!
|
|
// Validation for my parking, please!
|
|
@@ -2434,7 +2434,7 @@ function parse_bbc($message, $smileys = true, $cache_id = '', $parse_tags = arra
|
|
// The value may be quoted for some tags - check.
|
|
// The value may be quoted for some tags - check.
|
|
if (isset($tag['quoted']))
|
|
if (isset($tag['quoted']))
|
|
{
|
|
{
|
|
- $quoted = substr($message, $pos1, 6) == '"';
|
|
|
|
|
|
+ $quoted = substr($message, '"') === $pos1;
|
|
if ($tag['quoted'] != 'optional' && !$quoted)
|
|
if ($tag['quoted'] != 'optional' && !$quoted)
|
|
continue;
|
|
continue;
|
|
|
|
|
|
@@ -2468,7 +2468,7 @@ function parse_bbc($message, $smileys = true, $cache_id = '', $parse_tags = arra
|
|
}
|
|
}
|
|
|
|
|
|
// If this is block level, eat any breaks after it.
|
|
// If this is block level, eat any breaks after it.
|
|
- if (!empty($tag['block_level']) && substr($message, $pos + 1, 6) == '<br />')
|
|
|
|
|
|
+ if (!empty($tag['block_level']) && substr($message, '<br />') === $pos + 1)
|
|
$message = substr($message, 0, $pos + 1) . substr($message, $pos + 7);
|
|
$message = substr($message, 0, $pos + 1) . substr($message, $pos + 7);
|
|
|
|
|
|
// Are we trimming outside this tag?
|
|
// Are we trimming outside this tag?
|
|
@@ -2605,7 +2605,7 @@ function highlight_php_code($code)
|
|
$oldlevel = error_reporting(0);
|
|
$oldlevel = error_reporting(0);
|
|
|
|
|
|
// It's easier in 4.2.x+.
|
|
// It's easier in 4.2.x+.
|
|
- if (@version_compare(PHP_VERSION, '4.2.0') == -1)
|
|
|
|
|
|
+ if (version_compare(PHP_VERSION, '4.2.0', '<'))
|
|
{
|
|
{
|
|
ob_start();
|
|
ob_start();
|
|
@highlight_string($code);
|
|
@highlight_string($code);
|
|
@@ -2636,7 +2636,7 @@ function redirectexit($setLocation = '', $refresh = false)
|
|
// @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\
|
|
// @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\
|
|
AddMailQueue(true);
|
|
AddMailQueue(true);
|
|
|
|
|
|
- $add = preg_match('~^(ftp|http)[s]?://~', $setLocation) == 0 && substr($setLocation, 0, 6) != 'about:';
|
|
|
|
|
|
+ $add = preg_match('~^(ftp|http)[s]?://~', $setLocation) == 0 && strpos($setLocation, 'about:') !== 0;
|
|
|
|
|
|
if (WIRELESS)
|
|
if (WIRELESS)
|
|
{
|
|
{
|
|
@@ -2661,7 +2661,7 @@ function redirectexit($setLocation = '', $refresh = false)
|
|
elseif (isset($_GET['debug']))
|
|
elseif (isset($_GET['debug']))
|
|
$setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation);
|
|
$setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation);
|
|
|
|
|
|
- if (!empty($modSettings['queryless_urls']) && (empty($context['server']['is_cgi']) || @ini_get('cgi.fix_pathinfo') == 1 || @get_cfg_var('cgi.fix_pathinfo') == 1) && (!empty($context['server']['is_apache']) || !empty($context['server']['is_lighttpd']) || !empty($context['server']['is_litespeed'])))
|
|
|
|
|
|
+ if (!empty($modSettings['queryless_urls']) && (empty($context['server']['is_cgi']) || ini_get('cgi.fix_pathinfo') == 1 || @get_cfg_var('cgi.fix_pathinfo') == 1) && (!empty($context['server']['is_apache']) || !empty($context['server']['is_lighttpd']) || !empty($context['server']['is_litespeed'])))
|
|
{
|
|
{
|
|
if (defined('SID') && SID != '')
|
|
if (defined('SID') && SID != '')
|
|
$setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$/e', "\$scripturl . '/' . strtr('\$1', '&;=', '//,') . '.html\$2?' . SID", $setLocation);
|
|
$setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$/e', "\$scripturl . '/' . strtr('\$1', '&;=', '//,') . '.html\$2?' . SID", $setLocation);
|
|
@@ -2880,7 +2880,7 @@ function setupThemeContext($forceload = false)
|
|
if ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach']))
|
|
if ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach']))
|
|
$context['user']['avatar']['href'] = $user_info['avatar']['custom_dir'] ? $modSettings['custom_avatar_url'] . '/' . $user_info['avatar']['filename'] : $scripturl . '?action=dlattach;attach=' . $user_info['avatar']['id_attach'] . ';type=avatar';
|
|
$context['user']['avatar']['href'] = $user_info['avatar']['custom_dir'] ? $modSettings['custom_avatar_url'] . '/' . $user_info['avatar']['filename'] : $scripturl . '?action=dlattach;attach=' . $user_info['avatar']['id_attach'] . ';type=avatar';
|
|
// Full URL?
|
|
// Full URL?
|
|
- elseif (substr($user_info['avatar']['url'], 0, 7) == 'http://')
|
|
|
|
|
|
+ elseif (strpos($user_info['avatar']['url'], 'http://') === 0)
|
|
{
|
|
{
|
|
$context['user']['avatar']['href'] = $user_info['avatar']['url'];
|
|
$context['user']['avatar']['href'] = $user_info['avatar']['url'];
|
|
|
|
|
|
@@ -3254,7 +3254,7 @@ function host_from_ip($ip)
|
|
$t = microtime();
|
|
$t = microtime();
|
|
|
|
|
|
// If we can't access nslookup/host, PHP 4.1.x might just crash.
|
|
// If we can't access nslookup/host, PHP 4.1.x might just crash.
|
|
- if (@version_compare(PHP_VERSION, '4.2.0') == -1)
|
|
|
|
|
|
+ if (version_compare(PHP_VERSION, '4.2.0', '<'))
|
|
$host = false;
|
|
$host = false;
|
|
|
|
|
|
// Try the Linux host command, perhaps?
|
|
// Try the Linux host command, perhaps?
|
|
@@ -3392,7 +3392,7 @@ function loadClassFile($filename)
|
|
fatal_lang_error('error_bad_file', 'general', array($sourcedir . '/' . $filename));
|
|
fatal_lang_error('error_bad_file', 'general', array($sourcedir . '/' . $filename));
|
|
|
|
|
|
// Using a version below PHP 5.0? Do a compatibility conversion.
|
|
// Using a version below PHP 5.0? Do a compatibility conversion.
|
|
- if (@version_compare(PHP_VERSION, '5.0.0') != 1)
|
|
|
|
|
|
+ if (version_compare(PHP_VERSION, '5.0.0', '<='))
|
|
{
|
|
{
|
|
// Check if it was included before.
|
|
// Check if it was included before.
|
|
if (in_array($filename, $files_included))
|
|
if (in_array($filename, $files_included))
|
|
@@ -3710,7 +3710,7 @@ function smf_seed_generator()
|
|
updateSettings(array('rand_seed' => $modSettings['rand_seed']));
|
|
updateSettings(array('rand_seed' => $modSettings['rand_seed']));
|
|
}
|
|
}
|
|
|
|
|
|
- if (@version_compare(PHP_VERSION, '4.2.0') == -1)
|
|
|
|
|
|
+ if (version_compare(PHP_VERSION, '4.2.0', '<'))
|
|
{
|
|
{
|
|
$seed = ($modSettings['rand_seed'] + ((double) microtime() * 1000003)) & 0x7fffffff;
|
|
$seed = ($modSettings['rand_seed'] + ((double) microtime() * 1000003)) & 0x7fffffff;
|
|
mt_srand($seed);
|
|
mt_srand($seed);
|