Update to SMF 2.0.9 - Installation Instructions for 2.0.8

Update to SMF 2.0.9
This patch file will provide important stability fixes to your SMF 2.0.8 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.8
Replace With: Select

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

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

$forum_version = 'SMF 2.0.9';

./Sources/PackageGet.php

Find: Select

* @version 2.0
Replace With: Select

* @version 2.0.9
Find: Select

$package['href'] = $url . '/' . $package['filename'];
$package['name'] = $smcFunc['htmlspecialchars']($package['name']);
Replace With: Select

$package['href'] = $url . '/' . $package['filename'];

./Sources/Subs-Package.php

Find: Select

* @version 2.0.1
Replace With: Select

* @version 2.0.9
Find: Select

$installed[] = array(
Replace With: Select

// Clean things up first...
$row = htmlspecialchars__recursive($row);

$installed[] = array(
Find: Select

$package = $packageInfo->to_array();
$package['xml'] = $packageInfo;
$package['filename'] = $gzfilename;
Replace With: Select

$package = $packageInfo->to_array();
$package = htmlspecialchars__recursive($package);
$package['xml'] = $packageInfo;
$package['filename'] = $gzfilename;

// Don't want to mess with code...
$types = array('install', 'uninstall', 'upgrade');
foreach($types as $type)
{
if (isset($package[$type]['code']))
{
$package[$type]['code'] = un_htmlspecialchars($package[$type]['code']);
}
}

./Sources/Packages.php

Find: Select

* @version 2.0.2
Replace With: Select

* @version 2.0.9
Find: Select

preparsecode($context['package_readme']);
$context['package_readme'] = parse_bbc($context['package_readme']);
Replace With: Select

$context['package_readme'] = preg_replace('~\[[/]?html\]~i', '', $context['package_readme']);
preparsecode($context['package_readme']);
$context['package_readme'] = parse_bbc($context['package_readme']);
Find: Select

$failed_step_insert = serialize($failed_steps);
Replace With: Select

$failed_step_insert = serialize($failed_steps);

// Un-sanitize things before we insert them...
$keys = array('filename', 'name', 'id', 'version');
foreach ($keys as $key)
{
// Yay for variable variables...
${"package_$key"} = un_htmlspecialchars($packageInfo[$key]);
}
Find: Select

$packageInfo['filename'], $packageInfo['name'], $packageInfo['id'], $packageInfo['version'],
Replace With: Select

$package_filename, $package_name, $package_id, $package_version,
Find: Select

logAction($context['uninstalling'] ? 'uninstall_package' : (!empty($is_upgrade) ? 'upgrade_package' : 'install_package'), array('package' => $smcFunc['htmlspecialchars']($packageInfo['name']), 'version' => $smcFunc['htmlspecialchars']($packageInfo['version'])), 'admin');
Replace With: Select

logAction($context['uninstalling'] ? 'uninstall_package' : (!empty($is_upgrade) ? 'upgrade_package' : 'install_package'), array('package' => $packageInfo['name'], 'version' => $packageInfo['version']), 'admin');

./Sources/Load.php

Find: Select

* @version 2.0.7
Replace With: Select

* @version 2.0.9
Find: Select

$cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st));
}
Replace With: Select

$cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st));

// Invalidate the opcode cache
if (function_exists('opcache_invalidate'))
opcache_invalidate($cachedir . '/data_' . $key . '.php', true);

if (function_exists('apc_delete_file'))
@apc_delete_file($cachedir . '/data_' . $key . '.php');
}

./Sources/ManageServer.php

Find: Select

* @version 2.0.5
Replace With: Select

* @version 2.0.9
Find: Select

$context['config_vars'][$config_var[1]]['value'] = unserialize($context['config_vars'][$config_var[1]]['value']);
Add After: Select

$context['config_vars'][$config_var[1]]['value'] = !empty($context['config_vars'][$config_var[1]]['value']) ? unserialize($context['config_vars'][$config_var[1]]['value']) : array();

./Sources/Subs-Auth.php

Find: Select

* @version 2.0.7
Replace With: Select

* @version 2.0.9
Find: Select

global $txt, $mtitle, $mmessage, $context;
Replace With: Select

global $txt, $mtitle, $mmessage, $context, $smcFunc;
Find: Select

$context['title'] = &$mtitle;
Replace With: Select

$context['title'] = $smcFunc['htmlspecialchars']($mtitle);

./Sources/Subs-Db-mysql.php

Find: Select

* @version 2.0.8
Replace With: Select

* @version 2.0.9
Find: Select

if (strpos($db_string, 'GROUP BY') !== false && strpos($db_string, 'ORDER BY') === false && strpos($db_string, 'INSERT INTO') === false)
Replace With: Select

if (strpos($db_string, 'GROUP BY') !== false && strpos($db_string, 'ORDER BY') === false && preg_match('~^\s+SELECT~i', $db_string))

./Sources/Display.php

Find: Select

* @version 2.0.7
Replace With: Select

* @version 2.0.9
Find: Select

$context['show_view_results_button'] = $context['allow_vote'] && (!$context['allow_poll_view'] || !$context['poll']['show_results'] || !$context['poll']['has_voted']);
Replace With: Select

$context['show_view_results_button'] = $context['allow_vote'] && $context['allow_poll_view'] && !$context['poll']['show_results'];

./Sources/QueryString.php

Find: Select

* @version 2.0.8
Replace With: Select

* @version 2.0.9
Find: Select

// Make sure we have a valid REMOTE_ADDR.
Replace With: Select

// Some mail providers like to encode semicolons in activation URLs...
if (!empty($_REQUEST['action']) && substr($_SERVER['QUERY_STRING'], 0, 18) == 'action=activate%3b')
{
header('Location: ' . $scripturl . '?' . str_replace('%3b', ';', $_SERVER['QUERY_STRING']));
exit;
}

// Make sure we have a valid REMOTE_ADDR.

./Sources/Search.php

Find: Select

* @version 2.0.8
Replace With: Select

* @version 2.0.9
Find: Select

$match = strtr(htmlspecialchars($match, ENT_QUOTES), array("\n" => ' '));
Replace With: Select

$match = strtr($smcFunc['htmlspecialchars']($match, ENT_QUOTES), array("\n" => ' '));

./Sources/ScheduledTasks.php

Find: Select

* @version 2.0.7
Replace With: Select

* @version 2.0.9
Find: Select

AND closed = {int:not_closed}
Replace With: Select

AND closed = {int:closed}
Find: Select

'not_closed' => 0,
Replace With: Select

'closed' => 1,

./Sources/Post.php

Find: Select

* @version 2.0.8
Replace With: Select

* @version 2.0.9
Find: Select

if (isset($_REQUEST['preview']))
return Post();
Replace With: Select

if (isset($_REQUEST['preview']))
{
checkSession();
return Post();
}

./Sources/Subs-Graphics.php

Find: Select

* @version 2.0
Replace With: Select

* @version 2.0.9
Find: Select

// Check for potential infection
if (preg_match('~(iframe|html|eval|body|script\W|[CF]WS[\x01-\x0C])~i', $prev_chunk . $cur_chunk) === 1)
Replace With: Select

// Check for potential infection
if (preg_match('~(iframe|(?<!cellTextIs)html|eval|body|script\W|[CF]WS[\x01-\x0C])~i', $prev_chunk . $cur_chunk) === 1)

./Themes/default/ManagePermissions.template.php

Find: Select

* @version 2.0
Replace With: Select

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

// If this is general permissions also show the default profile.
if ($context['permission_type'] == 'membergroup')
{
echo '
</div>
Replace With: Select

echo '
</div>';

// If this is general permissions also show the default profile.
if ($context['permission_type'] == 'membergroup')
{
echo '

./Sources/Memberlist.php

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

$serach_fields[] = 'email';
Replace With: Select

$search_fields[] = 'email';

./Sources/Subs-Post.php

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

$htmlfunc = create_function('$m', 'return \'[html]\' . strtr(un_htmlspecialchars("$m[1]"), array("\n" => \'&#13;\', \' \' => \' &#32;\', \'[\' => \'&#91;\', \']\' => \'&#93;\')) . \'[/html]\';');
Replace With: Select

$htmlfunc = create_function('$m', 'return \'[html]\' . strtr(un_htmlspecialchars("$m[1]"), array("\n" => \'&#13;\', \' \' => \' &#32;\', \'[\' => \'&#91;\', \']\' => \'&#93;\')) . \'[/html]\';');
Find: Select

$message = trim(un_htmlspecialchars(strip_tags(strtr(parse_bbc(htmlspecialchars($message), false), array('<br />' => "\n", '</div>' => "\n", '</li>' => "\n", '&#91;' => '[', '&#93;' => ']')))));
Replace With: Select

$message = trim(un_htmlspecialchars(strip_tags(strtr(parse_bbc($smcFunc['htmlspecialchars']($message), false), array('<br />' => "\n", '</div>' => "\n", '</li>' => "\n", '&#91;' => '[', '&#93;' => ']')))));

./SSI.php

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

* @version 2.0.4
Replace With: Select

* @version 2.0.7
Advertisement: