Update to SMF 2.0.7 - Installation Instructions for 2.0.6

Update to SMF 2.0.7
This patch file will provide bug fixes to your SMF 2.0.6 forum.

File Edits ALT + Click to collapse all the operations

./index.php

Find: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0.6
Replace With: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0.7
Find: Select

$forum_version = 'SMF 2.0.6';
Replace With: Select

$forum_version = 'SMF 2.0.7';
Find: Select
header('X-XSS-Protection: 1; mode=block');
Replace With: Select
header('X-XSS-Protection: 1');

./Sources/Profile-Modify.php

Find: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0.6
Replace With: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0.7
Find: Select
elseif (substr($row['mask'], 0, 5) == 'regex' && preg_match(substr($row['mask'], 5), $value) === 0)
Replace With: Select
elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0)

./Sources/Register.php

Find: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0.6
Replace With: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0.7
Find: Select
elseif (substr($row['mask'], 0, 5) == 'regex' && preg_match(substr($row['mask'], 5), $value) === 0)
Replace With: Select
elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0)

./Sources/DbSearch-postgresql.php

Find: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0
Replace With: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0.7
Find: Select
'~TYPE=HEAP~i' => '',
Replace With: Select
'~ENGINE=MEMORY~i' => '',

./Sources/DbSearch-sqlite.php

Find: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0
Replace With: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0.7
Find: Select
'~TYPE=HEAP~i' => '',
Replace With: Select
'~ENGINE=MEMORY~i' => '',

./Sources/Search.php

Find: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0
Replace With: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0.7
Find: Select
CREATE TEMPORARY TABLE {db_prefix}tmp_log_search_topics (
id_topic mediumint(8) unsigned NOT NULL default {string:string_zero},
PRIMARY KEY (id_topic)
) TYPE=HEAP
Replace With: Select
CREATE TEMPORARY TABLE {db_prefix}tmp_log_search_topics (
id_topic mediumint(8) unsigned NOT NULL default {string:string_zero},
PRIMARY KEY (id_topic)
) ENGINE=MEMORY
Find: Select
CREATE TEMPORARY TABLE {db_prefix}tmp_log_search_messages (
id_msg int(10) unsigned NOT NULL default {string:string_zero},
PRIMARY KEY (id_msg)
) TYPE=HEAP
Replace With: Select
CREATE TEMPORARY TABLE {db_prefix}tmp_log_search_messages (
id_msg int(10) unsigned NOT NULL default {string:string_zero},
PRIMARY KEY (id_msg)
) ENGINE=MEMORY
Find: Select
$keyword = preg_replace('~&#(\d{1,7}|x[0-9a-fA-F]{1,6});~e', '$GLOBALS[\'smcFunc\'][\'entity_fix\'](\'\\1\')', strtr($keyword, array('\\\'' => '\'', '&' => '&')));
Replace With: Select
$keyword = preg_replace_callback('~(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'entity_fix__callback', strtr($keyword, array('\\\'' => '\'', '&' => '&')));
Find: Select
$message['body'] = preg_replace('~&#(\d{1,7}|x[0-9a-fA-F]{1,6});~e', '$GLOBALS[\'smcFunc\'][\'entity_fix\'](\'\\1\')', $message['body']);
Replace With: Select
$message['body'] = preg_replace_callback('~(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'entity_fix__callback', $message['body']);
Find: Select
// Fix the international characters in the keyword too.
$query = strtr($smcFunc['htmlspecialchars']($query), array('\\\'' => '\''));

$body_highlighted = preg_replace('/((<[^>]*)|' . preg_quote(strtr($query, array('\'' => '&#039;')), '/') . ')/ie' . ($context['utf8'] ? 'u' : ''), "'\$2' == '\$1' ? stripslashes('\$1') : '<strong class=\"highlight\">\$1</strong>'", $body_highlighted);
Replace With: Select
// Fix the international characters in the keyword too.
$query = strtr($smcFunc['htmlspecialchars']($query), array('\\\'' => '\''));

$body_highlighted = preg_replace_callback('/((<[^>]*)|' . preg_quote(strtr($query, array('\'' => '&#039;')), '/') . ')/i' . ($context['utf8'] ? 'u' : ''), create_function('$m', 'return isset($m[2]) && "$m[2]" == "$m[1]" ? stripslashes("$m[1]") : "<strong class=\"highlight\">$m[1]</strong>";'), $body_highlighted);

./Themes/default/Themes.template.php

Find: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0
Replace With: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0.7
Find: Select
var sBaseUseUrl = smf_prepareScriptUrl(smf_scripturl) + \'action=theme;sa=pick;u=', $context['current_member'], ';th=', $theme['id'], ';', $context['session_var'], '=', $context['session_id'], '\';
var sBasePreviewUrl = smf_prepareScriptUrl(smf_scripturl) + \'action=theme;sa=pick;u=', $context['current_member'], ';theme=', $theme['id'], ';', $context['session_var'], '=', $context['session_id'], '\';
Replace With: Select
var sBaseUseUrl', $theme['id'], ' = smf_prepareScriptUrl(smf_scripturl) + \'action=theme;sa=pick;u=', $context['current_member'], ';th=', $theme['id'], ';', $context['session_var'], '=', $context['session_id'], '\';
var sBasePreviewUrl', $theme['id'], ' = smf_prepareScriptUrl(smf_scripturl) + \'action=theme;sa=pick;u=', $context['current_member'], ';theme=', $theme['id'], ';', $context['session_var'], '=', $context['session_id'], '\';
Find: Select
document.getElementById(\'theme_use_', $theme['id'], '\').href = sBaseUseUrl + \';vrt=\' + sVariant;
document.getElementById(\'theme_thumb_preview_', $theme['id'], '\').href = sBasePreviewUrl + \';vrt=\' + sVariant + \';variant=\' + sVariant;
document.getElementById(\'theme_preview_', $theme['id'], '\').href = sBasePreviewUrl + \';vrt=\' + sVariant + \';variant=\' + sVariant;
Replace With: Select
document.getElementById(\'theme_use_', $theme['id'], '\').href = sBaseUseUrl', $theme['id'], ' + \';vrt=\' + sVariant;
document.getElementById(\'theme_thumb_preview_', $theme['id'], '\').href = sBasePreviewUrl', $theme['id'], ' + \';vrt=\' + sVariant + \';variant=\' + sVariant;
document.getElementById(\'theme_preview_', $theme['id'], '\').href = sBasePreviewUrl', $theme['id'], ' + \';vrt=\' + sVariant + \';variant=\' + sVariant;

./SSI.php

Find: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0.4
Replace With: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0.7
Find: Select
WHERE ' . ($board === null ? '' : 'id_board = {int:current_board}
AND ') . 'FIND_IN_SET(-1, member_groups)
LIMIT 1
Replace With: Select
WHERE ' . ($board === null ? '' : 'id_board = {int:current_board}
AND ') . 'FIND_IN_SET(-1, member_groups) != 0
LIMIT 1
Find: Select
OR id_post_group = {int:id_group}
OR FIND_IN_SET({int:id_group}, additional_groups)';
Replace With: Select
OR id_post_group = {int:id_group}
OR FIND_IN_SET({int:id_group}, additional_groups) != 0';
Find: Select
return ssi_queryPosts($query_where, $query_where_params, '', 'm.id_msg DESC', $output_method);
Replace With: Select
return ssi_queryPosts($query_where, $query_where_params, '', 'm.id_msg DESC', $output_method, false, $override_permissions);

./Themes/default/scripts/editor.js

Find: Select
function smc_BBCButtonBox(oOptions)
{
this.opt = oOptions;
this.init();
}
Replace With: Select
function smc_BBCButtonBox(oOptions)
{
this.opt = oOptions;
this.init();

var items = ['sActiveButtonBackgroundImageHover', 'sActiveButtonBackgroundImage', 'sButtonBackgroundImageHover', 'sButtonBackgroundImage'];
for (var i = 0; i < items.length; i++)
{
if (items[i] in this.opt)
this.opt[items[i]] = this.opt[items[i]].replace(' ', '%20');
}
}

./Sources/ScheduledTasks.php

Find: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0
Replace With: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0.7
Find: Select
SELECT /*!40001 SQL_NO_CACHE */ id_mail, recipient, body, subject, headers, send_html
Replace With: Select
SELECT /*!40001 SQL_NO_CACHE */ id_mail, recipient, body, subject, headers, send_html, time_sent, private
Find: Select
'headers' => $row['headers'],
'send_html' => $row['send_html'],
Replace With: Select
'headers' => $row['headers'],
'send_html' => $row['send_html'],
'time_sent' => $row['time_sent'],
'private' => $row['private'],
Find: Select
$failed_emails[] = array($email['to'], $email['body'], $email['subject'], $email['headers'], $email['send_html']);
Replace With: Select
$failed_emails[] = array($email['to'], $email['body'], $email['subject'], $email['headers'], $email['send_html'], $email['time_sent'], $email['private']);
Find: Select
array('recipient' => 'string', 'body' => 'string', 'subject' => 'string', 'headers' => 'string', 'send_html' => 'string'),
Replace With: Select
array('recipient' => 'string', 'body' => 'string', 'subject' => 'string', 'headers' => 'string', 'send_html' => 'string', 'time_sent' => 'string', 'private' => 'int'),
Find: Select
SET value = {string:mail_next_send}
WHERE variable = {string:next_mail_send}
Replace With: Select
SET value = {string:next_mail_send}
WHERE variable = {string:mail_next_send}
Find: Select
$result = $smcFunc['db_query']('', '
SELECT id_report
FROM {db_prefix}log_reported
WHERE time_started < {int:time_started}',
array(
'time_started' => $t,
)
);
Replace With: Select
$result = $smcFunc['db_query']('', '
SELECT id_report
FROM {db_prefix}log_reported
WHERE time_started < {int:time_started}
AND closed = {int:not_closed}
AND ignore_all = {int:not_ignored}',
array(
'time_started' => $t,
'not_closed' => 0,
'not_ignored' => 0,
)
);

./Sources/Load.php

Find: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0.3
Replace With: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0.7
Find: Select
require($cachedir . '/data_' . $key . '.php');
Replace With: Select
@include($cachedir . '/data_' . $key . '.php');
Find: Select
$fh = @fopen($cachedir . '/data_' . $key . '.php', 'w');
if ($fh)
{
// Write the file.
set_file_buffer($fh, 0);
flock($fh, LOCK_EX);
$cache_bytes = fwrite($fh, $cache_data);
flock($fh, LOCK_UN);
fclose($fh);

// Check that the cache write was successful; all the data should be written
// If it fails due to low diskspace, remove the cache file
if ($cache_bytes != strlen($cache_data))
@unlink($cachedir . '/data_' . $key . '.php');
}
Replace With: Select
// Write the file.
if (function_exists('file_put_contents'))
{
$cache_bytes = @file_put_contents($cachedir . '/data_' . $key . '.php', $cache_data, LOCK_EX);
if ($cache_bytes != strlen($cache_data))
@unlink($cachedir . '/data_' . $key . '.php');
}
else
{
$fh = @fopen($cachedir . '/data_' . $key . '.php', 'w');
if ($fh)
{
// Write the file.
set_file_buffer($fh, 0);
flock($fh, LOCK_EX);
$cache_bytes = fwrite($fh, $cache_data);
flock($fh, LOCK_UN);
fclose($fh);

// Check that the cache write was successful; all the data should be written
// If it fails due to low diskspace, remove the cache file
if ($cache_bytes != strlen($cache_data))
@unlink($cachedir . '/data_' . $key . '.php');
}
}
Find: Select
// Set a list of common functions.
$ent_list = empty($modSettings['disableEntityCheck']) ? '&(#\d{1,7}|quot|amp|lt|gt|nbsp);' : '&(#021|quot|amp|lt|gt|nbsp);';
$ent_check = empty($modSettings['disableEntityCheck']) ? array('preg_replace(\'~(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)~e\', \'$smcFunc[\\\'entity_fix\\\'](\\\'\\2\\\')\', ', ')') : array('', '');
Replace With: Select
// Set a list of common functions.
$ent_list = empty($modSettings['disableEntityCheck']) ? '&(#\d{1,7}|quot|amp|lt|gt|nbsp);' : '&(#021|quot|amp|lt|gt|nbsp);';
$ent_check = empty($modSettings['disableEntityCheck']) ? array('preg_replace_callback(\'~(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)~\', \'entity_fix__callback\', ', ')') : array('', '');

./Sources/Subs-Post.php

Find: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0
Replace With: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0.7
Find: Select
// Have a go at getting the right mime type.
if (empty($attachmentOptions['mime_type']) && $attachmentOptions['width'])
{
if (!empty($size['mime']))
$attachmentOptions['mime_type'] = $size['mime'];
elseif (isset($validImageTypes[$size[2]]))
$attachmentOptions['mime_type'] = 'image/' . $validImageTypes[$size[2]];
}

if (!empty($attachmentOptions['width']) && !empty($attachmentOptions['height']))
Replace With: Select
// Have a go at getting the right mime type.
if (empty($attachmentOptions['mime_type']) && $attachmentOptions['width'])
{
if (!empty($size['mime']))
$attachmentOptions['mime_type'] = $size['mime'];
elseif (isset($validImageTypes[$size[2]]))
$attachmentOptions['mime_type'] = 'image/' . $validImageTypes[$size[2]];
}

// It is possible we might have a MIME type that isn't actually an image but still have a size.
// For example, Shockwave files will be able to return size but be 'application/shockwave' or similar.
if (!empty($attachmentOptions['mime_type']) && strpos($attachmentOptions['mime_type'], 'image/') !== 0)
{
$attachmentOptions['width'] = 0;
$attachmentOptions['height'] = 0;
}

if (!empty($attachmentOptions['width']) && !empty($attachmentOptions['height']))
Find: Select
// Get the hash if no hash has been given yet.
Replace With: Select
// It is possible we might have a MIME type that isn't actually an image but still have a size.
// For example, Shockwave files will be able to return size but be 'application/shockwave' or similar.
if (!empty($attachmentOptions['mime_type']) && strpos($attachmentOptions['mime_type'], 'image/') !== 0)
{
$attachmentOptions['width'] = 0;
$attachmentOptions['height'] = 0;
}

// Get the hash if no hash has been given yet.
Find: Select
// Now fix possible security problems with images loading links automatically...
$message = preg_replace('~(\[img.*?\])(.+?)\[/img\]~eis', '\'$1\' . preg_replace(\'~action(=|%3d)(?!dlattach)~i\', \'action-\', \'$2\') . \'[/img]\'', $message);
Replace With: Select
// Now fix possible security problems with images loading links automatically...
$message = preg_replace_callback('~(\[img.*?\])(.+?)\[/img\]~is', create_function('$m', 'return "$m[1]" . preg_replace("~action(=|%3d)(?!dlattach)~i", "action-", "$m[2]") . "[/img]";'), $message);
Find: Select
if ($simple)
$string = preg_replace('~&#(\d{3,8});~e', 'chr(\'$1\')', $string);
else
Replace With: Select
if ($simple)
$string = preg_replace_callback('~&#(\d{3,8});~', create_function('$m', ' return chr("$m[1]");'), $string);
else
Find: Select
$string = preg_replace('~&#(\d{3,8});~e', '$fixchar(\'$1\')', $string);

// Unicode, baby.
Replace With: Select
$string = preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $string);

// Unicode, baby.
Find: Select
// Convert all 'special' characters to HTML entities.
return array($charset, preg_replace('~([\x80-' . ($context['server']['complex_preg_chars'] ? '\x{10FFFF}' : "\xF7\xBF\xBF\xBF") . '])~eu', '$entityConvert(\'\1\')', $string), '7bit');
Replace With: Select
$entityConvert = create_function('$m', '
$c = $m[1];
if (strlen($c) === 1 && ord($c[0]) <= 0x7F)
return $c;
elseif (strlen($c) === 2 && ord($c[0]) >= 0xC0 && ord($c[0]) <= 0xDF)
return "&#" . (((ord($c[0]) ^ 0xC0) << 6) + (ord($c[1]) ^ 0x80)) . ";";
elseif (strlen($c) === 3 && ord($c[0]) >= 0xE0 && ord($c[0]) <= 0xEF)
return "&#" . (((ord($c[0]) ^ 0xE0) << 12) + ((ord($c[1]) ^ 0x80) << 6) + (ord($c[2]) ^ 0x80)) . ";";
elseif (strlen($c) === 4 && ord($c[0]) >= 0xF0 && ord($c[0]) <= 0xF7)
return "&#" . (((ord($c[0]) ^ 0xF0) << 18) + ((ord($c[1]) ^ 0x80) << 12) + ((ord($c[2]) ^ 0x80) << 6) + (ord($c[3]) ^ 0x80)) . ";";
else
return "";');

// Convert all 'special' characters to HTML entities.
return array($charset, preg_replace_callback('~([\x80-\x{10FFFF}])~u', $entityConvert, $string), '7bit');
Find: Select
// Clean up after nobbc ;).
$message = preg_replace('~\[nobbc\](.+?)\[/nobbc\]~ie', '\'[nobbc]\' . strtr(\'$1\', array(\'[\' => \'&#91;\', \']\' => \'&#93;\', \':\' => \'&#58;\', \'@\' => \'&#64;\')) . \'[/nobbc]\'', $message);
Replace With: Select
// Clean up after nobbc ;).
$message = preg_replace_callback('~\[nobbc\](.+?)\[/nobbc\]~i', create_function('$m', ' return "[nobbc]" . strtr("$m[1]", array("[" => "&#91;", "]" => "&#93;", ":" => "&#58;", "@" => "&#64;")) . "[/nobbc]";'), $message);
Find: Select
// Let's look at the time tags...
$parts[$i] = preg_replace('~\[time(?:=(absolute))*\](.+?)\[/time\]~ie', '\'[time]\' . (is_numeric(\'$2\') || @strtotime(\'$2\') == 0 ? \'$2\' : strtotime(\'$2\') - (\'$1\' == \'absolute\' ? 0 : (($modSettings[\'time_offset\'] + $user_info[\'time_offset\']) * 3600))) . \'[/time]\'', $parts[$i]);
Replace With: Select
// Let's look at the time tags...
$parts[$i] = preg_replace_callback('~\[time(?:=(absolute))*\](.+?)\[/time\]~i', create_function('$m', 'global $modSettings, $user_info; return "[time]" . (is_numeric("$m[2]") || @strtotime("$m[2]") == 0 ? "$m[2]" : strtotime("$m[2]") - ("$m[1]" == "absolute" ? 0 : (($modSettings["time_offset"] + $user_info["time_offset"]) * 3600))) . "[/time]";'), $parts[$i]);
Find: Select
// Make sure all tags are lowercase.
$parts[$i] = preg_replace('~\[([/]?)(list|li|table|tr|td)((\s[^\]]+)*)\]~ie', '\'[$1\' . strtolower(\'$2\') . \'$3]\'', $parts[$i]);
Replace With: Select
// Make sure all tags are lowercase.
$parts[$i] = preg_replace_callback('~\[([/]?)(list|li|table|tr|td)((\s[^\]]+)*)\]~i', create_function('$m', ' return "[$m[1]" . strtolower("$m[2]") . "$m[3]]";'), $parts[$i]);
Find: Select
// If $i is a multiple of four (0, 4, 8, ...) then it's not a code section...
if ($i % 4 == 0)
{
$parts[$i] = preg_replace('~\[html\](.+?)\[/html\]~ie', '\'[html]\' . strtr(htmlspecialchars(\'$1\', ENT_QUOTES), array(\'\\&quot;\' => \'&quot;\', \'&amp;#13;\' => \'<br />\', \'&amp;#32;\' => \' \', \'&amp;#91;\' => \'[\', \'&amp;#93;\' => \']\')) . \'[/html]\'', $parts[$i]);
Replace With: Select
// If $i is a multiple of four (0, 4, 8, ...) then it's not a code section...
if ($i % 4 == 0)
{
$parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~i', create_function('$m', 'return "[html]" . strtr(htmlspecialchars("$m[1]", ENT_QUOTES), array("\\&quot;" => "&quot;", "&amp;#13;" => "<br />", "&amp;#32;" => " ", "&amp;#91;" => "[", "&amp;#93;" => "]")) . "[/html]";'), $parts[$i]);
Find: Select
// Attempt to un-parse the time to something less awful.
$parts[$i] = preg_replace('~\[time\](\d{0,10})\[/time\]~ie', '\'[time]\' . timeformat(\'$1\', false) . \'[/time]\'', $parts[$i]);
Replace With: Select
// Attempt to un-parse the time to something less awful.
$parts[$i] = preg_replace_callback('~\[time\](\d{0,10})\[/time\]~i', create_function('$m', ' return "[time]" . timeformat("$m[1]", false) . "[/time]";'), $parts[$i]);
Find: Select
if (allowedTo('admin_forum'))
$parts[$i] = preg_replace('~\[html\](.+?)\[/html\]~ise', '\'[html]\' . strtr(un_htmlspecialchars(\'$1\'), array("\n" => \'&#13;\', \' \' => \' &#32;\', \'[\' => \'&#91;\', \']\' => \'&#93;\')) . \'[/html]\'', $parts[$i]);
Replace With: Select
if (allowedTo('admin_forum'))
{
static $htmlfunc = null;
if ($htmlfunc === null)
$htmlfunc = create_function('$m', 'return \'[html]\' . strtr(un_htmlspecialchars("$m[1]"), array("\n" => \'&#13;\', \' \' => \' &#32;\', \'[\' => \'&#91;\', \']\' => \'&#93;\')) . \'[/html]\';');
$parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', $htmlfunc, $parts[$i]);
}

./Sources/LogInOut.php

Find: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0.6
Replace With: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0.7
Find: Select
// Are we using any sort of integration to validate the login?
Replace With: Select
// And if it's too long, trim it back.
if ($smcFunc['strlen']($_POST['user']) > 80)
{
$_POST['user'] = $smcFunc['substr']($_POST['user'], 0, 79);
$context['default_username'] = preg_replace('~&amp;#(\\d{1,7}|x[0-9a-fA-F]{1,6});~', '&#\\1;', $smcFunc['htmlspecialchars']($_POST['user']));
}

// Are we using any sort of integration to validate the login?

./Sources/ManageMembergroups.php

Find: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0
Replace With: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0.7
Find: Select
if ($_POST['group_inherit'] != -2 && !allowedTo('admin_forum'))
Replace With: Select
if ($_REQUEST['group'] > 1 && $_REQUEST['group'] != 3 && isset($_POST['group_inherit']) && $_POST['group_inherit'] != -2 && !allowedTo('admin_forum'))

./Sources/Subs.php

Find: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0.6
Replace With: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0.7
Find: Select
$modSettings[$hook] = implode(',', $functions);
}
Replace With: Select
$modSettings[$hook] = implode(',', $functions);
}

// Decode numeric html entities to their ascii or UTF8 equivalent character.
function replaceEntities__callback($matches)
{
global $context;

if (!isset($matches[2]))
return '';

$num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2];

// remove left to right / right to left overrides
if ($num === 0x202D || $num === 0x202E)
return '';

// Quote, Ampersand, Apostrophe, Less/Greater Than get html replaced
if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E)))
return '&#' . $num . ';';

if (empty($context['utf8']))
{
// no control characters
if ($num < 0x20)
return '';
// text is text
elseif ($num < 0x80)
return chr($num);
// all others get html-ised
else
return '&#' . $matches[2] . ';';
}
else
{
// <0x20 are control characters, 0x20 is a space, > 0x10FFFF is past the end of the utf8 character set
// 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text)
if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF))
return '';
// <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and puncuation
elseif ($num < 0x80)
return chr($num);
// <0x800 (2048)
elseif ($num < 0x800)
return chr(($num >> 6) + 192) . chr(($num & 63) + 128);
// < 0x10000 (65536)
elseif ($num < 0x10000)
return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
// <= 0x10FFFF (1114111)
else
return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
}
}

// Converts html entities to utf8 equivalents.
function fixchar__callback($matches)
{
if (!isset($matches[1]))
return '';

$num = $matches[1][0] === 'x' ? hexdec(substr($matches[1], 1)) : (int) $matches[1];

// <0x20 are control characters, > 0x10FFFF is past the end of the utf8 character set
// 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text), 0x202D-E are left to right overrides
if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E)
return '';
// <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and puncuation
elseif ($num < 0x80)
return chr($num);
// <0x800 (2048)
elseif ($num < 0x800)
return chr(($num >> 6) + 192) . chr(($num & 63) + 128);
// < 0x10000 (65536)
elseif ($num < 0x10000)
return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
// <= 0x10FFFF (1114111)
else
return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
}

// Strips out invalid html entities, replaces others with html style &#123; codes.
function entity_fix__callback($matches)
{
if (!isset($matches[2]))
return '';

$num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2];

// we don't allow control characters, characters out of range, byte markers, etc
if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E)
return '';
else
return '&#' . $num . ';';
}
Find: Select
$smileyPregSearch = '~(?<=[>:\?\.\s' . $non_breaking_space . '[\]()*\\\;]|^)(' . implode('|', $searchParts) . ')(?=[^[:alpha:]0-9]|$)~e' . ($context['utf8'] ? 'u' : '');
}

// Replace away!
$message = preg_replace($smileyPregSearch, 'isset($smileyPregReplacements[\'$1\']) ? $smileyPregReplacements[\'$1\'] : \'\'', $message);
}
Replace With: Select
$smileyPregSearch = '~(?<=[>:\?\.\s' . $non_breaking_space . '[\]()*\\\;]|^)(' . implode('|', $searchParts) . ')(?=[^[:alpha:]0-9]|$)~' . ($context['utf8'] ? 'u' : '');
}

// Replace away!

// TODO: When SMF supports only PHP 5.3+, we can change this to "uses" keyword and simplify this.
$callback = pregReplaceCurry('smielyPregReplaceCallback', 2);
$message = preg_replace_callback($smileyPregSearch, $callback($smileyPregReplacements), $message);
}

// This allows use to do delayed argument binding and bring in the replacement variables for some preg replacements.
function pregReplaceCurry($func, $arity)
{
return create_function('', "
\$args = func_get_args();
if(count(\$args) >= $arity)
return call_user_func_array('$func', \$args);
\$args = var_export(\$args, 1);
return create_function('','
\$a = func_get_args();
\$z = ' . \$args . ';
\$a = array_merge(\$z,\$a);
return call_user_func_array(\'$func\', \$a);
');
");
}

// Our callback that does the actual smiley replacements.
function smielyPregReplaceCallback($replacements, $matches)
{
return $replacements[$matches[1]];
}
Find: Select
// This is done in a roundabout way because $breaker has "long words" :P.
$data = strtr($data, array($breaker => '< >', '&nbsp;' => $context['utf8'] ? "\xC2\xA0" : "\xA0"));
$data = preg_replace(
'~(?<=[>;:!? ' . $non_breaking_space . '\]()]|^)([\w' . ($context['utf8'] ? '\pL' : '') . '\.]{' . $modSettings['fixLongWords'] . ',})~e' . ($context['utf8'] ? 'u' : ''),
'preg_replace(\'/(.{' . ($modSettings['fixLongWords'] - 1) . '})/' . ($context['utf8'] ? 'u' : '') . '\', \'\\$1< >\', \'$1\')',
$data);
Replace With: Select
// This is done in a roundabout way because $breaker has "long words" :P.
$data = strtr($data, array($breaker => '< >', '&nbsp;' => $context['utf8'] ? "\xC2\xA0" : "\xA0"));
$data = preg_replace_callback(
'~(?<=[>;:!? ' . $non_breaking_space . '\]()]|^)([\w' . ($context['utf8'] ? '\pL' : '') . '\.]{' . $modSettings['fixLongWords'] . ',})~' . ($context['utf8'] ? 'u' : ''),
create_function('$m', 'return preg_replace(\'~(.{' . ($modSettings['fixLongWords'] - 1) . '})~' . ($context['utf8'] ? 'u' : '') . '\', \'$1< >\', "$m[1]");'),
$data);
Find: Select
$setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\?(?:'
Replace With: Select
$setLocation = preg_replace_callback('~"' . preg_quote($scripturl, '/') . '\?(?:'
Find: Select
$/e', "\$scripturl . '/' . strtr('\$1', '&;=', '//,') . '.html\$2?' . SID", $setLocation);
Replace With: Select
$~', create_function('$m', 'global $scripturl; return $scripturl . \'/\' . strtr("$m[1]", \'&;=\', \'//,\') . \'.html?\' . SID . (isset($m[2]) ? "$m[2]" : "");'), $setLocation);
Find: Select
$setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\?((
Replace With: Select
$setLocation = preg_replace_callback('~"' . preg_quote($scripturl, '/') . '\?((
Find: Select
$/e', "\$scripturl . '/' . strtr('\$1', '&;=', '//,') . '.html\$2'", $setLocation);
Replace With: Select
$~', create_function('$m', 'global $scripturl; return $scripturl . \'/\' . strtr("$m[1]", \'&;=\', \'//,\') . \'.html\' . (isset($m[2]) ? "$m[2]" : "");'), $setLocation);

./Sources/ManageMaintenance.php

Find: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0.1
Replace With: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0.7
Find: Select
$insertion_variables['changes_' . $column_name] = preg_replace('~(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)~e', '$entity_replace(\'\\2\')', $column_value);
Replace With: Select
$insertion_variables['changes_' . $column_name] = preg_replace_callback('~&#(\d{1,7}|x[0-9a-fA-F]{1,6});~', 'fixchar__callback', $column_value);

./Sources/Subs-Auth.php

Find: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0
Replace With: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0.7
Find: Select
$row['real_name'] = preg_replace('~&#(\d+);~e', '$fixchar(\'$1\')', $row['real_name']);
Replace With: Select
$row['real_name'] = preg_replace_callback('~&#(\d+);~', 'fixchar__callback', $row['real_name']);

./Sources/Display.php

Find: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0
Replace With: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0.7
Find: Select
// Different browsers like different standards...
if ($context['browser']['is_firefox'])
header('Content-Disposition: ' . $disposition . '; filename*="UTF-8\'\'' . preg_replace('~&#(\d{3,8});~e', '$fixchar(\'$1\')', $utf8name) . '"');
Replace With: Select
// Different browsers like different standards...
if ($context['browser']['is_firefox'])
header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)));
Find: Select
elseif ($context['browser']['is_opera'])
header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace('~&#(\d{3,8});~e', '$fixchar(\'$1\')', $utf8name) . '"');
Replace With: Select
elseif ($context['browser']['is_opera'])
header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"');
Find: Select
elseif ($context['browser']['is_ie'])
header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace('~&#(\d{3,8});~e', '$fixchar(\'$1\')', $utf8name)) . '"');
Replace With: Select
elseif ($context['browser']['is_ie'])
header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"');

./Sources/Subs-Members.php

This operation isn't vital to the installation of this mod.
Find: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0.1
Replace With: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0.7
This operation isn't vital to the installation of this mod.
Find: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0.6
Replace With: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0.7
Find: Select
$name = preg_replace('~(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)~e', '$replaceEntities(\'\\2\')', $name);
$checkName = $smcFunc['strtolower']($name);
Replace With: Select
$name = preg_replace_callback('~(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'replaceEntities__callback', $name);
$checkName = $smcFunc['strtolower']($name);
Find: Select
// The admin might've used entities too, level the playing field.
$reservedCheck = preg_replace('~(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)~e', '$replaceEntities(\'\\2\')', $reserved);
Replace With: Select
// The admin might've used entities too, level the playing field.
$reservedCheck = preg_replace('~(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'replaceEntities__callback', $reserved);

./Sources/Modlog.php

Find: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0.3
Replace With: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0.7
Find: Select
// Do some formatting of the action string.
foreach ($entries as $k => $entry)
Replace With: Select
// Do some formatting of the action string.
$callback = pregReplaceCurry('list_getModLogEntriesCallback', 3);
foreach ($entries as $k => $entry)
Find: Select
$entries[$k]['action_text'] = preg_replace('~\{([A-Za-z\d_]+)\}~ie', 'isset($entries[$k][\'extra\'][\'$1\']) ? $entries[$k][\'extra\'][\'$1\'] : \'\'', $entries[$k]['action_text']);
}

// Back we go!
return $entries;
}
Replace With: Select
$entries[$k]['action_text'] = preg_replace_callback('~\{([A-Za-z\d_]+)\}~i', $callback($entries, $k), $entries[$k]['action_text']);

}

// Back we go!
return $entries;
}

// Mog Log Replacment Callback.
function list_getModLogEntriesCallback($entries, $key, $matches)
{
return isset($entries[$key]['extra'][$matches[1]]) ? $entries[$key]['extra'][$matches[1]] : '';
}

./Sources/Subs-Editor.php

Find: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0
Replace With: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0.7
Find: Select
// Parse unique ID's and disable javascript into the smileys - using the double space.
$i = 1;
$text = preg_replace('~(?:\s|&nbsp;)?<(img\ssrc="' . preg_quote($modSettings['smileys_url'], '~') . '/[^<>]+?/([^<>]+?)"\s*)[^<>]*?class="smiley" />~e', '\'<\' . ' . 'stripslashes(\'$1\') . \'alt="" title="" onresizestart="return false;" id="smiley_\' . ' . "\$" . 'i++ . \'_$2" style="padding: 0 3px 0 3px;" />\'', $text);
Replace With: Select
// Parse unique ID's and disable javascript into the smileys - using the double space.
$text = preg_replace_callback('~(?:\s|&nbsp;)?<(img\ssrc="' . preg_quote($modSettings['smileys_url'], '~') . '/[^<>]+?/([^<>]+?)"\s*)[^<>]*?class="smiley" />~', create_function('$m', 'static $i = 1; return \'<\' . ' . 'stripslashes($m[1]) . \'alt="" title="" onresizestart="return false;" id="smiley_\' . ' . "\$" . 'i++ . \'_\' . $m[2] . \'" style="padding: 0 3px 0 3px;" />\';'), $text);
Find: Select
'~</tr>~i' => '[/tr]',
'~<(td|th)\s[^<>]*?colspan="?(\d{1,2})"?.*?' . '>~ie' => 'str_repeat(\'[td][/td]\', $2 - 1) . \'[td]\'',
'~<(td|th)(\s(.)*?)*?' . '>~i' => '[td]',
Replace With: Select
'~</tr>~i' => '[/tr]',
'~<(td|th)(\s(.)*?)*?' . '>~i' => '[td]',
Find: Select
$text = preg_replace(array_keys($tags), array_values($tags), $text);

// Please give us just a little more time.
Replace With: Select
$text = preg_replace_callback('~<(td|th)\s[^<>]*?colspan="?(\d{1,2})"?.*?' . '>~i', create_function('$m', 'return str_repeat(\'[td][/td]\', $m[2] - 1) . \'[td]\';'), $text);
$text = preg_replace(array_keys($tags), array_values($tags), $text);

// Please give us just a little more time.

./Sources/Class-Package.php

Find: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0
Replace With: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0.7
Find: Select
// Translate all the entities out.
$data = strtr(preg_replace('~&#(\d{1,4});~e', "chr('\$1')", $data), $trans_tbl);
Replace With: Select
// Translate all the entities out.
$data = strtr(preg_replace_callback('~&#(\d{1,4});~', create_function('$m', 'return chr("$m[1]");'), $data), $trans_tbl);

./Sources/Post.php

Find: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0
Replace With: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0.7
Find: Select
// It goes 0 = outside, 1 = begin tag, 2 = inside, 3 = close tag, repeat.
if ($i % 4 == 0)
$parts[$i] = preg_replace('~\[html\](.+?)\[/html\]~ise', '\'[html]\' . preg_replace(\'~<br\s?/?' . '>~i\', \'&lt;br /&gt;<br />\', \'$1\') . \'[/html]\'', $parts[$i]);
Replace With: Select
// It goes 0 = outside, 1 = begin tag, 2 = inside, 3 = close tag, repeat.
if ($i % 4 == 0)
$parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', create_function('$m', ' return \'[html]\' . preg_replace(\'~<br\s?/?' . '>~i\', \'&lt;br /&gt;<br />\', "$m[1]") . \'[/html]\';'), $parts[$i]);

./Sources/News.php

Find: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0
Replace With: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0.7
Find: Select
$val = preg_replace('/^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+)(#[^"]*)?$/e', '\'\' . $scripturl . \'/\' . strtr(\'$1\', \'&;=\', \'//,\') . \'.html$2\'', $val);
return $val;
Replace With: Select
$val = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+)(#[^"]*)?$~', create_function('$m', 'global $scripturl; return $scripturl . \'/\' . strtr("$m[1]", \'&;=\', \'//,\') . \'.html\' . (isset($m[2]) ? $m[2] : "");'), $val);
return $val;

./Sources/QueryString.php

Find: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0.6
Replace With: Select

* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0.7
Find: Select
$buffer = preg_replace('/"' . preg_quote($scripturl, '/') . '\?(?:'
Replace With: Select
$buffer = preg_replace_callback('~"' . preg_quote($scripturl, '/') . '\?(?:'
Find: Select
"/e', "'\"' . \$scripturl . '/' . strtr('\$1', '&;=', '//,') . '.html?' . SID . '\$2\"'", $buffer);
Replace With: Select
"~', create_function('$m', 'global $scripturl; return \'"\' . $scripturl . "/" . strtr("$m[1]", \'&;=\', \'//,\') . ".html?" . SID . (isset($m[2]) ? $m[2] : "") . \'"\';'), $buffer);
Find: Select
$buffer = preg_replace('/"' . preg_quote($scripturl, '/') . '\?((
Replace With: Select
$buffer = preg_replace_callback('~"' . preg_quote($scripturl, '/') . '\?((
Find: Select
"/e', "'\"' . \$scripturl . '/' . strtr('\$1', '&;=', '//,') . '.html\$2\"'", $buffer);
Replace With: Select
"~', create_function('$m', 'global $scripturl; return \'"\' . $scripturl . "/" . strtr("$m[1]", \'&;=\', \'//,\') . ".html" . (isset($m[2]) ? $m[2] : "") . \'"\';'), $buffer);

Code

fix_calendar.php
This file should be able to execute standalone.
Advertisement: