Update to SMF 1.1.3 - Installation Instructions for 1.1.2

Update to SMF 1.1.3
This patch file will update your forum to SMF 1.1.3.

File Edits ALT + Click to collapse all the operations

./index.php

Find: Select
* Software Version: SMF 1.1.2 *
Replace With: Select
* Software Version: SMF 1.1.3 *
Find: Select
$forum_version = 'SMF 1.1.2';
Replace With: Select
$forum_version = 'SMF 1.1.3';

./Sources/ManageNews.php

Find: Select
* Software Version: SMF 1.1.2 *
Replace With: Select
* Software Version: SMF 1.1.3 *
Find: Select
SELECT mem.ID_MEMBER
FROM {$db_prefix}ban_groups AS bg
LEFT JOIN {$db_prefix}ban_items AS bi ON (bg.ID_BAN_GROUP = bi.ID_BAN_GROUP)
LEFT JOIN {$db_prefix}members AS mem ON (bi.ID_MEMBER = mem.ID_MEMBER OR mem.emailAddress LIKE bi.email_address)
WHERE (bg.cannot_access = 1 OR bg.cannot_login = 1) AND (ISNULL(bg.expire_time) OR bg.expire_time > " . time() . ")
AND NOT ISNULL(mem.ID_MEMBER)
GROUP BY mem.ID_MEMBER", __FILE__, __LINE__);

$banMembers = array();
while ($row = mysql_fetch_row($request))
list ($banMembers[]) = $row;
mysql_free_result($request);

$condition .= empty($banMembers) ? '' : '
AND mem.ID_MEMBER NOT IN (' . implode(', ', $banMembers) . ')';
Replace With: Select
SELECT DISTINCT mem.ID_MEMBER
FROM {$db_prefix}ban_groups AS bg
INNER JOIN {$db_prefix}ban_items AS bi ON (bg.ID_BAN_GROUP = bi.ID_BAN_GROUP)
INNER JOIN {$db_prefix}members AS mem ON (bi.ID_MEMBER = mem.ID_MEMBER)
WHERE (bg.cannot_access = 1 OR bg.cannot_login = 1)
AND (ISNULL(bg.expire_time) OR bg.expire_time > " . time() . ")", __FILE__, __LINE__);
$condition_array = array();
$members = array();
while ($row = mysql_fetch_assoc($request))
$members[] = $row['ID_MEMBER'];
if (!empty($members))
$condition_array[] = 'mem.ID_MEMBER NOT IN (' . implode(', ', $members) . ')';

$request = db_query("
SELECT DISTINCT bi.email_address
FROM {$db_prefix}ban_items AS bi
INNER JOIN {$db_prefix}ban_groups AS bg ON (bg.ID_BAN_GROUP = bi.ID_BAN_GROUP)
WHERE (bg.cannot_access = 1 OR bg.cannot_login = 1)
AND (ISNULL(bg.expire_time) OR bg.expire_time > " . time() . ")
AND bi.email_address != ''", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
$condition_array[] = "mem.emailAddress NOT LIKE '" . $row['email_address'] . "'";

if (!empty($condition_array))
$condition = '
AND ' . implode('
AND ', $condition_array);

./Sources/PersonalMessage.php

Find: Select
* Software Version: SMF 1.1.2 *
Replace With: Select
* Software Version: SMF 1.1.3 *
Find: Select
$report_body .= "\n[b]$_REQUEST[reason][/b]\n\n";
Replace With: Select
$report_body .= stripslashes("\n[b]$_REQUEST[reason][/b]\n\n");
Find: Select
'subject' => ($func['strpos']($subject, $txt['pm_report_pm_subject']) === false ? $txt['pm_report_pm_subject'] : '') . $subject,
'body' => $report_body,
Replace With: Select
'subject' => addslashes(($func['strpos']($subject, $txt['pm_report_pm_subject']) === false ? $txt['pm_report_pm_subject'] : '') . $subject),
'body' => addslashes($report_body),

./Sources/Subs-Auth.php

Find: Select
* Software Version: SMF 1.1 *
Replace With: Select
* Software Version: SMF 1.1.3 *
Find: Select
if (isset($_COOKIE[$cookiename]))
Replace With: Select
if (isset($_COOKIE[$cookiename]) && preg_match('~^a:[34]:\{i:0;(i:\d{1,6}|s:[1-8]:"\d{1,8}");i:1;s:(0|40):"([a-fA-F0-9]{40})?";i:2;[id]:\d{1,14};(i:3;i:\d;)?\}$~', $_COOKIE[$cookiename]) === 1)
Find: Select
$_SESSION['login_' . $cookiename] = $data;
Replace With: Select

// Make sure the user logs in with a new session ID.
if (!isset($_SESSION['login_' . $cookiename]) || $_SESSION['login_' . $cookiename] !== $data)
{
// Backup and remove the old session.
$oldSessionData = $_SESSION;
$_SESSION = array();
session_destroy();

// Recreate and restore the new session.
loadSession();
session_regenerate_id();
$_SESSION = $oldSessionData;

// Version 4.3.2 didn't store the cookie of the new session.
if (version_compare(PHP_VERSION, '4.3.2') === 0)
setcookie(session_name(), session_id(), time() + $cookie_length, $cookie_url[1], '', 0);

$_SESSION['login_' . $cookiename] = $data;
}
}

// PHP < 4.3.2 doesn't have this function
if (!function_exists('session_regenerate_id'))
{
function session_regenerate_id()
{
// Too late to change the session now.
if (headers_sent())
return false;

session_id(strtolower(md5(uniqid(rand(), true))));
return true;
}
Find: Select
// Globalize cookies across domains (filter out IP-addresses)?
if ($global && preg_match('~^\d{1,3}(\.\d{1,3}){3}$~', $parsed_url['host']) == 0)
{
// If we can't figure it out, just skip it.
if (preg_match('~(?:[^\.]+\.)?([^\.]{2,}\..+)\z~i', $parsed_url['host'], $parts) == 1)
$parsed_url['host'] = '.' . $parts[1];
}
// We shouldn't use a host at all if both options are off.
elseif (!$local)
$parsed_url['host'] = '';
Replace With: Select
// Globalize cookies across domains (filter out IP-addresses)?
if ($global && preg_match('~^\d{1,3}(\.\d{1,3}){3}$~', $parsed_url['host']) == 0 && preg_match('~(?:[^\.]+\.)?([^\.]{2,}\..+)\z~i', $parsed_url['host'], $parts) == 1)
$parsed_url['host'] = '.' . $parts[1];

// We shouldn't use a host at all if both options are off.
elseif (!$local && !$global)
$parsed_url['host'] = '';

// The host also shouldn't be set if there aren't any dots in it.
elseif (!isset($parsed_url['host']) || strpos($parsed_url['host'], '.') === false)
$parsed_url['host'] = '';

./Sources/Subs-Package.php

Find: Select

if (!mktree(dirname($strPath), $mode))
Replace With: Select
// Is this an invalid path and/or we can't make the directory?
if ($strPath == dirname($strPath) || !mktree(dirname($strPath), $mode))
Find: Select
// Set the debug level.
Replace With: Select
// If we're using this try to get some more memory.
@ini_set('memory_limit', '32M');

// Set the debug level.
Find: Select
$tag = preg_quote($match[1], '/');
$reg = '/\A(.*?(<' . $tag . ' .*?' . '>.*?<\/' . $tag . '>.*?)*?)<\/' . $tag . '>/s';

// Remove the element and fetch the inner data.
preg_match($reg, $data, $inner_match);
$data = preg_replace($reg, '', $data, 1);

if (!isset($inner_match[1]))
continue;

// Parse the inner data.
if (strpos($inner_match[1], '<') !== false)
$el += $this->_parse($inner_match[1]);
elseif (trim($inner_match[1]) != '')
{
$text_value = $this->_from_cdata($inner_match[1]);
if ($text_value != '')
$el[] = array(
'name' => '!',
'value' => $text_value
);
Replace With: Select
// Because PHP 5.2.0+ seems to croak using regex, we'll have to do this the less fun way.
$last_tag_end = strpos($data, '</' . $match[1]. '>');
if ($last_tag_end === false)
continue;

$offset = 0;
while (1 == 1)
{
// Where is the next start tag?
$next_tag_start = strpos($data, '<' . $match[1], $offset);
// If the next start tag is after the last end tag then we've found the right close.
if ($next_tag_start === false || $next_tag_start > $last_tag_end)
break;

// If not then find the next ending tag.
$next_tag_end = strpos($data, '</' . $match[1]. '>', $offset);

// Didn't find one? Then just use the last and sod it.
if ($next_tag_end === false)
break;
else
{
$last_tag_end = $next_tag_end;
$offset = $next_tag_start + 1;
}
}
// Parse the insides.
$inner_match = substr($data, 0, $last_tag_end);
// Data now starts from where this section ends.
$data = substr($data, $last_tag_end + strlen('</' . $match[1]. '>'));

if (!empty($inner_match))
{
// Parse the inner data.
if (strpos($inner_match, '<') !== false)
$el += $this->_parse($inner_match);
elseif (trim($inner_match) != '')
{
$text_value = $this->_from_cdata($inner_match);
if ($text_value != '')
$el[] = array(
'name' => '!',
'value' => $text_value
);
}

./Sources/Subs.php

Find: Select
* Software Version: SMF 1.1.2 *
Replace With: Select
* Software Version: SMF 1.1.3 *
Find: Select
INSERT INTO {$db_prefix}log_search_subjects
Replace With: Select
INSERT IGNORE INTO {$db_prefix}log_search_subjects
Find: Select
if (!$no_autolink_area)
Replace With: Select
// Don't go backwards.
$lastAutoPos = isset($lastAutoPos) ? $lastAutoPos : 0;
if ($pos < $lastAutoPos)
$no_autolink_area = true;
$lastAutoPos = $pos;

if (!$no_autolink_area)

./Sources/QueryString.php

Find: Select
* Software Version: SMF 1.1 *
Replace With: Select
* Software Version: SMF 1.1.3 *
Find: Select
function addslashes__recursive($var)
Replace With: Select
function addslashes__recursive($var, $level = 0)
Find: Select
$new_var[addslashes($k)] = addslashes__recursive($v);
Replace With: Select
$new_var[addslashes($k)] = $level > 25 ? null : addslashes__recursive($v, $level + 1);
Find: Select
function htmlspecialchars__recursive($var)
Replace With: Select
function htmlspecialchars__recursive($var, $level = 0)
Find: Select
return array_map('htmlspecialchars__recursive', $var);
Replace With: Select
foreach ($var as $k => $v)
$var[$k] = $level > 25 ? null : htmlspecialchars__recursive($v, $level + 1);

return $var;
Find: Select
function urldecode__recursive($var)
Replace With: Select
function urldecode__recursive($var, $level = 0)
Find: Select
$new_var[urldecode($k)] = urldecode__recursive($v);
Replace With: Select
$new_var[urldecode($k)] = $level > 25 ? null : urldecode__recursive($v, $level + 1);
Find: Select
function stripslashes__recursive($var)
Replace With: Select
function stripslashes__recursive($var, $level = 0)
Find: Select
$new_var[stripslashes($k)] = stripslashes__recursive($v);
Replace With: Select
$new_var[stripslashes($k)] = $level > 25 ? null : stripslashes__recursive($v, $level + 1);
Find: Select
function htmltrim__recursive($var)
Replace With: Select
function htmltrim__recursive($var, $level = 0)
Find: Select
return array_map('htmltrim__recursive', $var);
Replace With: Select
foreach ($var as $k => $v)
$var[$k] = $level > 25 ? null : htmltrim__recursive($v, $level + 1);

return $var;

./Themes/default/xml_topic.js

Find: Select
subject_text = subject_text.replace(/\{&dollarfix;\$\}/g,"$");
setInnerHTML(document.getElementById("top_subject"), subject_text);
Replace With: Select
subject_top = subject_top.replace(/\{&dollarfix;\$\}/g,"$");
setInnerHTML(document.getElementById("top_subject"), subject_top);

./Sources/Post.php

Find: Select
* Software Version: SMF 1.1.2 *
Replace With: Select
* Software Version: SMF 1.1.3 *
Find: Select
SELECT IFNULL(mem.realName, m.posterName) AS posterName, m.posterTime, m.body, m.ID_TOPIC, m.subject
FROM ({$db_prefix}messages AS m, {$db_prefix}boards AS b)
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)
WHERE m.ID_MSG = " . (int) $_REQUEST['quote'] . "
AND b.ID_BOARD = m.ID_BOARD
AND $user_info[query_see_board]
LIMIT 1", __FILE__, __LINE__);
$context['close_window'] = mysql_num_rows($request) == 0;
Replace With: Select
SELECT IFNULL(mem.realName, m.posterName) AS posterName, m.posterTime, m.body, m.ID_TOPIC, m.subject, t.locked
FROM ({$db_prefix}messages AS m, {$db_prefix}boards AS b, {$db_prefix}topics AS t)
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)
WHERE m.ID_MSG = " . (int) $_REQUEST['quote'] . "
AND b.ID_BOARD = m.ID_BOARD
AND t.ID_TOPIC = m.ID_TOPIC
AND $user_info[query_see_board]" . (!isset($_REQUEST['modify']) || (!empty($moderate_boards) && $moderate_boards[0] == 0) ? '' : '
AND (t.locked = 0' . (empty($moderate_boards) ? '' : ' OR b.ID_BOARD IN (' . implode(', ', $moderate_boards)) . ')') . "
LIMIT 1", __FILE__, __LINE__);
$context['close_window'] = mysql_num_rows($request) == 0;

$context['sub_template'] = 'quotefast';
Find: Select
$context['quote'] = array(
'xml' => '',
'mozilla' => '',
'text' => '',
);

$context['sub_template'] = 'quotefast';
Replace With: Select
$context['quote'] = array(
'xml' => '',
'mozilla' => '',
'text' => '',
);
Find: Select
if (isset($_POST['message']) || isset($_POST['subject']) || isset($_POST['icon']))
{
if ($row['ID_MEMBER'] == $ID_MEMBER && !allowedTo('modify_any'))
Replace With: Select
if (isset($_POST['message']) || isset($_POST['subject']) || isset($_POST['icon']))
{
if (!empty($row['locked']))
isAllowedTo('moderate_board');

if ($row['ID_MEMBER'] == $ID_MEMBER && !allowedTo('modify_any'))

./Sources/Display.php

Find: Select
* Software Version: SMF 1.1.2 *
Replace With: Select
* Software Version: SMF 1.1.3 *
Find: Select
'can_modify' => allowedTo('modify_any') || (allowedTo('modify_replies') && $context['user']['started']) || (allowedTo('modify_own') && $message['ID_MEMBER'] == $ID_MEMBER && (empty($modSettings['edit_disable_time']) || $message['posterTime'] + $modSettings['edit_disable_time'] * 60 > time())),
Replace With: Select
'can_modify' => (!$context['is_locked'] || allowedTo('moderate_board')) && (allowedTo('modify_any') || (allowedTo('modify_replies') && $context['user']['started']) || (allowedTo('modify_own') && $message['ID_MEMBER'] == $ID_MEMBER && (empty($modSettings['edit_disable_time']) || $message['posterTime'] + $modSettings['edit_disable_time'] * 60 > time()))),

./Sources/Profile.php

Find: Select
* Software Version: SMF 1.1.2 *
Replace With: Select
* Software Version: SMF 1.1.3 *
Find: Select
elseif (isset($_POST['bday1'], $_POST['bday2']) && $_POST['bday1'] > 0 && $_POST['bday2'] > 0)
Replace With: Select
elseif (isset($_POST['bday1'], $_POST['bday2'], $_POST['bday3']) && $_POST['bday1'] > 0 && $_POST['bday2'] > 0)
Find: Select
preparsecode($_POST['signature']);
Replace With: Select
$_POST['signature'] = strtr($_POST['signature'], array('&quot;' => '\\&quot;', '&#039;' => '\\&#39;', '&#39;' => '\\&#39;'));
preparsecode($_POST['signature']);

./Sources/LogInOut.php

Find: Select
* Software Version: SMF 1.1.2 *
Replace With: Select
* Software Version: SMF 1.1.3 *
Find: Select
if (isset($_COOKIE[$cookiename]))
Replace With: Select
if (isset($_COOKIE[$cookiename]) && preg_match('~^a:[34]:\{i:0;(i:\d{1,6}|s:[1-8]:"\d{1,8}");i:1;s:(0|40):"([a-fA-F0-9]{40})?";i:2;[id]:\d{1,14};(i:3;i:\d;)?\}$~', $_COOKIE[$cookiename]) === 1)
Advertisement: