Update to SMF 1.1.5 - Installation Instructions for 1.1.4

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

File Edits ALT + Click to collapse all the operations

./index.php

Find: Select
* Software Version: SMF 1.1.4 *
Replace With: Select
* Software Version: SMF 1.1.5 *
Find: Select
$forum_version = 'SMF 1.1.4';
Replace With: Select
$forum_version = 'SMF 1.1.5';
Find: Select
// Load the settings...
Replace With: Select
// Make sure some things simply do not exist.
foreach (array('db_character_set') as $variable)
if (isset($GLOBALS[$variable]))
unset($GLOBALS[$variable]);

// Load the settings...
Find: Select
// Determine if this is using WAP, WAP2, or imode. Technically, we should check that wap comes before application/xhtml or text/html, but this doesn't work in practice as much as it should.
Replace With: Select
// Seed the random generator for PHP < 4.2.0.
if (@version_compare(PHP_VERSION, '4.2.0') == -1)
smf_seed_generator();

// Determine if this is using WAP, WAP2, or imode. Technically, we should check that wap comes before application/xhtml or text/html, but this doesn't work in practice as much as it should.

./Sources/Admin.php

Find: Select
* Software Version: SMF 1.1 *
Replace With: Select
* Software Version: SMF 1.1.5 *
Find: Select
if (empty($_SESSION['copy_expire']))
{
list ($key, $expires) = explode(',', $modSettings['copy_settings']);
// Get the expired date.
$fp = @fsockopen("www.simplemachines.org", 80, $errno, $errstr, 1);
if ($fp)
{
$out = "GET /smf/copyright/check_copyright.php?site=" . base64_encode($boardurl) . "&key=" . $key . "&version=" . base64_encode($forum_version) . " HTTP/1.1\r\n";
$out .= "Host: www.simplemachines.org\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($fp, $out);

$return_data = '';
while (!feof($fp))
$return_data .= fgets($fp, 128);
fclose($fp);

// Get the expire date.
$return_data = substr($return_data, strpos($return_data, 'STARTCOPY') + 9);
$return_data = trim(substr($return_data, 0, strpos($return_data, 'ENDCOPY')));

if ($return_data != 'void')
{
list ($_SESSION['copy_expire'], $modSettings['copyright_key']) = explode('|', $return_data);
$_SESSION['copy_key'] = $key;
$modSettings['copy_settings'] = $key . ',' . (int) $return_data;
updateSettings(array('copy_settings' => $modSettings['copy_settings'], 'copyright_key' => $modSettings['copyright_key']));
}
else
{
$_SESSION['copy_expire'] = '';
db_query("
DELETE FROM {$db_prefix}settings
WHERE variable = 'copy_settings'
OR variable = 'copyright_key'", __FILE__, __LINE__);
}
}
}

if ($_SESSION['copy_expire'] && $_SESSION['copy_expire'] > time())
{
$context['copyright_expires'] = (int) (($_SESSION['copy_expire'] - time()) / 3600 / 24);
$context['copyright_key'] = $_SESSION['copy_key'];
}
Replace With: Select
if (empty($_SESSION['copy_expire']))
{
list ($key, $expires) = explode(',', $modSettings['copy_settings']);
// Get the expired date.
require_once($sourcedir . '/Subs-Package.php');
$return_data = fetch_web_data($url = 'http://www.simplemachines.org/smf/copyright/check_copyright.php?site=' . base64_encode($boardurl) . '&key=' . $key . '&version=' . base64_encode($forum_version));

// Get the expire date.
$return_data = substr($return_data, strpos($return_data, 'STARTCOPY') + 9);
$return_data = trim(substr($return_data, 0, strpos($return_data, 'ENDCOPY')));

if ($return_data != 'void')
{
list ($_SESSION['copy_expire'], $copyright_key) = explode('|', $return_data);
$_SESSION['copy_key'] = $key;
$copy_settings = $key . ',' . (int) $_SESSION['copy_expire'];
updateSettings(array('copy_settings' => $copy_settings, 'copyright_key' => $copyright_key));
}
else
{
$_SESSION['copy_expire'] = '';
db_query("
DELETE FROM {$db_prefix}settings
WHERE variable = 'copy_settings'
OR variable = 'copyright_key'", __FILE__, __LINE__);
}
}

if (isset($_SESSION['copy_expire']) && $_SESSION['copy_expire'] > time())
{
$context['copyright_expires'] = (int) (($_SESSION['copy_expire'] - time()) / 3600 / 24);
$context['copyright_key'] = $_SESSION['copy_key'];
}
Find: Select
if (extension_loaded('apc'))
$context['current_versions']['apc'] = array('title' => 'Alternative PHP Cache', 'version' => phpversion('apc'));
Replace With: Select
if (extension_loaded('apc'))
$context['current_versions']['apc'] = array('title' => 'Alternative PHP Cache', 'version' => phpversion('apc'));
if (function_exists('memcache_set'))
$context['current_versions']['memcache'] = array('title' => 'Memcached', 'version' => memcache_get_version());
Find: Select
$fp = @fsockopen("www.simplemachines.org", 80, $errno, $errstr);
if ($fp)
{
$out = "GET /smf/copyright/check_copyright.php?site=" . base64_encode($boardurl) . "&key=" . $_POST['copy_code'] . "&version=" . base64_encode($forum_version) . " HTTP/1.1\r\n";
$out .= "Host: www.simplemachines.org\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($fp, $out);

$return_data = '';
while (!feof($fp))
$return_data .= fgets($fp, 128);
fclose($fp);

// Get the data back
$return_data = substr($return_data, strpos($return_data, 'STARTCOPY') + 9);
$return_data = trim(substr($return_data, 0, strpos($return_data, 'ENDCOPY')));

if ($return_data != 'void')
{
echo $return_data;
list ($_SESSION['copy_expire'], $modSettings['copyright_key']) = explode('|', $return_data);
$_SESSION['copy_key'] = $key;
$modSettings['copy_settings'] = $key . ',' . (int) $return_data;
updateSettings(array('copy_settings' => $modSettings['copy_settings'], 'copyright_key' => $modSettings['copyright_key']));
redirectexit('action=admin');
}
else
{
fatal_lang_error('copyright_failed');
}
}
Replace With: Select
require_once($sourcedir . '/Subs-Package.php');
$return_data = fetch_web_data('http://www.simplemachines.org/smf/copyright/check_copyright.php?site=' . base64_encode($boardurl) . '&key=' . $_POST['copy_code'] . '&version=' . base64_encode($forum_version));

// Get the data back
$return_data = substr($return_data, strpos($return_data, 'STARTCOPY') + 9);
$return_data = trim(substr($return_data, 0, strpos($return_data, 'ENDCOPY')));

if ($return_data != 'void')
{
list ($_SESSION['copy_expire'], $copyright_key) = explode('|', $return_data);
$_SESSION['copy_key'] = $_POST['copy_code'];
$copy_settings = $_POST['copy_code'] . ',' . (int) $_SESSION['copy_expire'];
updateSettings(array('copy_settings' => $copy_settings, 'copyright_key' => $copyright_key));
redirectexit('action=admin');
}
else
{
fatal_lang_error('copyright_failed');
}

./Sources/Calendar.php

Find: Select
* Software Version: SMF 1.1 *
Replace With: Select
* Software Version: SMF 1.1.5 *
Find: Select
// No board? No topic?!?
if (!isset($board))
fatal_lang_error('calendar38', false);
if (!isset($topic))
fatal_lang_error('calendar39', false);
Replace With: Select
// No board? No topic?!?
if (empty($board))
fatal_lang_error('calendar38', false);
if (empty($topic))
fatal_lang_error('calendar39', false);

./Sources/Karma.php

Find: Select
* Software Version: SMF 1.1 *
Replace With: Select
* Software Version: SMF 1.1.5 *
Find: Select
if (isset($topic))
Replace With: Select
if (!empty($topic))

./Sources/Load.php

Find: Select
* Software Version: SMF 1.1.2 *
Replace With: Select
* Software Version: SMF 1.1.5 *
Find: Select
session_set_save_handler('sessionOpen', 'sessionClose', 'sessionRead', 'sessionWrite', 'sessionDestroy', 'sessionGC');
Replace With: Select
{
session_set_save_handler('sessionOpen', 'sessionClose', 'sessionRead', 'sessionWrite', 'sessionDestroy', 'sessionGC');
@ini_set('session.gc_probability', '1');
}
Find: Select
if (isset($modSettings['cache_memcached']) && trim($modSettings['cache_memcached']) != '')
{
// Grab the memcached server.
if (!is_resource($memcached))
get_memcached_server();
if (!$memcached)
return;

// !!! It almost might be best to write null to as many as possible....
if (!fwrite($memcached, 'set ' . $key . ' 0 ' . $ttl . ' ' . strlen($value) . "\r\n" . $value . "\r\n"))
{
$memcached = fclose($memcached);
return;
}

fread($memcached, 128);
}
Replace With: Select
if (function_exists('memcache_set') && isset($modSettings['cache_memcached']) && trim($modSettings['cache_memcached']) != '')
{
// Not connected yet?
if (empty($memcached))
get_memcached_server();
if (!$memcached)
return;

memcache_set($memcached, $key, $value, 0, $ttl);
}
Find: Select
if (isset($modSettings['cache_memcached']) && trim($modSettings['cache_memcached']) != '')
{
// Grab the memcached server.
if (!is_resource($memcached) && $memcached !== '0')
get_memcached_server();
if (!$memcached)
{
// '0' means ignore me for the rest of this page view.
$memcached = '0';
return null;
}

if (!fwrite($memcached, 'get ' . $key . "\r\n"))
{
$memcached = fclose($memcached);
return null;
}

$response = fgets($memcached);
if (substr($response, 0, 3) != 'END' && substr($response, 0, 5) != 'VALUE')
{
// Bad response, junk time.
$memcached = fclose($memcached);
return null;
}

if (substr($response, 0, 5) == 'VALUE' && preg_match('~(\d+)$~', trim($response), $match) != 0)
$value = substr(fread($memcached, $match[1] + 2), 0, -2);

fread($memcached, 5);
}
Replace With: Select
if (function_exists('memcache_get') && isset($modSettings['cache_memcached']) && trim($modSettings['cache_memcached']) != '')
{
// Not connected yet?
if (empty($memcached))
get_memcached_server();
if (!$memcached)
return;

$value = memcache_get($memcached, $key);
}
Find: Select
if (empty($db_persist))
$memcached = @fsockopen($server[0], empty($server[1]) ? 11211 : $server[1], $err, $err, 0.15);
else
$memcached = @pfsockopen($server[0], empty($server[1]) ? 11211 : $server[1], $err, $err, 0.15);

if (!$memcached && $level > 0)
get_memcached_server($level - 1);
elseif ($memcached)
{
@socket_set_timeout($memcached, 1);
@set_file_buffer($memcached, 0);
}
Replace With: Select
if (empty($db_persist))
$memcached = memcache_connect($server[0], empty($server[1]) ? 11211 : $server[1]);
else
$memcached = memcache_pconnect($server[0], empty($server[1]) ? 11211 : $server[1]);

if (!$memcached && $level > 0)
get_memcached_server($level - 1);

./Sources/ManageNews.php

Find: Select
* Software Version: SMF 1.1.4 *
Replace With: Select
* Software Version: SMF 1.1.5 *
Find: Select
WHERE emailAddress IN ('" . implode("', '", addslashes__recursive($send_list)) . "')", __FILE__, __LINE__);
Replace With: Select
WHERE emailAddress IN ('" . implode("', '", addslashes__recursive($send_list)) . "')
AND is_activated = 1", __FILE__, __LINE__);

./Sources/ManagePermissions.php

Find: Select
* Software Version: SMF 1.1.2 *
Replace With: Select
* Software Version: SMF 1.1.5 *
Find: Select
WHERE ID_GROUP IN (" . implode(', ', $_POST['group']) . ")
" . (empty($context['illegal_permissions']) ? '' : ' AND permission NOT IN (' . implode(', ', $context['illegal_permissions']) . ')'), __FILE__, __LINE__);
Replace With: Select
WHERE ID_GROUP IN (" . implode(', ', $_POST['group']) . ")" . (empty($context['illegal_permissions']) ? '' : "
AND permission NOT IN ('" . implode("', '", $context['illegal_permissions']) . "')"), __FILE__, __LINE__);
Find: Select
AND permission = '$permission'
" . (empty($context['illegal_permissions']) ? '' : ' AND permission NOT IN (' . implode(', ', $context['illegal_permissions']) . ')'), __FILE__, __LINE__);
Replace With: Select
AND permission = '$permission'" . (empty($context['illegal_permissions']) ? '' : "
AND permission NOT IN ('" . implode("', '", $context['illegal_permissions']) . "')"), __FILE__, __LINE__);
Find: Select
WHERE ID_GROUP = $_GET[group]
" . (empty($context['illegal_permissions']) ? '' : ' AND permission NOT IN (' . implode(', ', $context['illegal_permissions']) . ')'), __FILE__, __LINE__);
Replace With: Select
WHERE ID_GROUP = $_GET[group]" . (empty($context['illegal_permissions']) ? '' : "
AND permission NOT IN ('" . implode("', '", $context['illegal_permissions']) . "')"), __FILE__, __LINE__);
Find: Select
WHERE ID_GROUP = $group
" . (empty($context['illegal_permissions']) ? '' : ' AND permission NOT IN (' . implode(', ', $context['illegal_permissions']) . ')'), __FILE__, __LINE__);
Replace With: Select
WHERE ID_GROUP = $group" . (empty($context['illegal_permissions']) ? '' : "
AND permission NOT IN ('" . implode("', '", $context['illegal_permissions']) . "')"), __FILE__, __LINE__);
Find: Select
WHERE permission IN ('" . implode("', '", $permissions) . "')
" . (empty($context['illegal_permissions']) ? '' : ' AND permission NOT IN (' . implode(', ', $context['illegal_permissions']) . ')'), __FILE__, __LINE__);
Replace With: Select
WHERE permission IN ('" . implode("', '", $permissions) . "')" . (empty($context['illegal_permissions']) ? '' : "
AND permission NOT IN ('" . implode("', '", $context['illegal_permissions']) . "')"), __FILE__, __LINE__);

./Sources/ManageServer.php

Find: Select
* Software Version: SMF 1.1 *
Replace With: Select
* Software Version: SMF 1.1.5 *
Find: Select
elseif (function_exists('output_cache_put'))
$detected = 'Zend';
else
$detected = 'no_caching';
Replace With: Select
elseif (function_exists('output_cache_put'))
$detected = 'Zend';
elseif (function_exists('memcache_set'))
$detected = 'Memcached';
else
$detected = 'no_caching';

./Sources/PersonalMessage.php

Find: Select
* Software Version: SMF 1.1.4 *
Replace With: Select
* Software Version: SMF 1.1.5 *
Find: Select
$context['can_send_pm'] = allowedTo('send_pm');
Replace With: Select
$context['can_send_pm'] = allowedTo('pm_send');

./Sources/Post.php

Find: Select
* Software Version: SMF 1.1.4 *
Replace With: Select
* Software Version: SMF 1.1.5 *
Find: Select
if (isset($topic))
getTopic();
Replace With: Select
if (!empty($topic))
getTopic();
Find: Select
if (isset($topic) && !isset($_REQUEST['msg']))
fatal_lang_error(1, false);
Replace With: Select
if (!empty($topic) && !isset($_REQUEST['msg']))
fatal_lang_error(1, false);

./Sources/Profile.php

Find: Select
* Software Version: SMF 1.1.4 *
Replace With: Select
* Software Version: SMF 1.1.5 *
Find: Select
if (!empty($_POST['dateRegistered']) && allowedTo('moderate_forum'))
Replace With: Select
if (!empty($_POST['dateRegistered']) && allowedTo('admin_forum'))
Find: Select
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['display_name'] . '</a>'
Replace With: Select
'link' => empty($row['ID_MEMBER']) ? $row['display_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['display_name'] . '</a>'

./Sources/QueryString.php

Find: Select
* Software Version: SMF 1.1.4 *
Replace With: Select
* Software Version: SMF 1.1.5 *
Find: Select
if (get_magic_quotes_gpc() != 0 && empty($modSettings['integrate_magic_quotes']))
$_GET = stripslashes__recursive($_GET);
Replace With: Select
if (@get_magic_quotes_gpc() != 0 && empty($modSettings['integrate_magic_quotes']))
$_GET = stripslashes__recursive($_GET);
Find: Select
// Clean up after annoying ini settings. (magic_quotes_gpc might be off...)
if (get_magic_quotes_gpc() == 0 && empty($modSettings['integrate_magic_quotes']))
Replace With: Select
// Clean up after annoying ini settings. (magic_quotes_gpc might be off...)
if (@get_magic_quotes_gpc() == 0 && empty($modSettings['integrate_magic_quotes']))
Find: Select
// Now make sure the online log gets the right number.
$_GET['topic'] = $topic;
}
Replace With: Select
// Now make sure the online log gets the right number.
$_GET['topic'] = $topic;
}
else
$topic = 0;

./Sources/Recent.php

Find: Select
* Software Version: SMF 1.1 *
Replace With: Select
* Software Version: SMF 1.1.5 *
Find: Select
// They're deleting something... just skip back to it.
if (isset($_GET['delete']))
{
checkSession('get');

// Luckily, removeMessage() checks permissions for us.
require_once($sourcedir . '/RemoveTopic.php');
removeMessage((int) $_GET['delete']);

redirectexit('action=recent');
}

loadTemplate('Recent');
$context['page_title'] = $txt[214];
Replace With: Select
loadTemplate('Recent');
$context['page_title'] = $txt[214];

./Sources/Register.php

Find: Select
* Software Version: SMF 1.1.2 *
Replace With: Select
* Software Version: SMF 1.1.5 *
Find: Select
if (!isset($_POST['new_email']))
Replace With: Select
if (!isset($_POST['new_email']) && $row['is_activated'] != 2)

./Sources/RemoveTopic.php

Find: Select
* Software Version: SMF 1.1 *
Replace With: Select
* Software Version: SMF 1.1.5 *
Find: Select
$request = db_query("
SELECT t.ID_MEMBER_STARTED, m.ID_MEMBER, m.subject, m.posterTime
Replace With: Select
// Is $topic set?
if (empty($topic) && isset($_REQUEST['topic']))
$topic = (int) $_REQUEST['topic'];

$request = db_query("
SELECT t.ID_MEMBER_STARTED, m.ID_MEMBER, m.subject, m.posterTime
Find: Select
if ($full_topic)
Replace With: Select
// We want to redirect back to recent action.
if (isset($_REQUEST['recent']))
redirectexit('action=recent');
elseif ($full_topic)

./Sources/Search.php

Find: Select
* Software Version: SMF 1.1.4 *
Replace With: Select
* Software Version: SMF 1.1.5 *

./Sources/Security.php

Find: Select
* Software Version: SMF 1.1 *
Replace With: Select
* Software Version: SMF 1.1.5 *
Find: Select
// Load the Login template and language file.
loadLanguage('Login');
loadTemplate('Login');
Replace With: Select
// Load the Login template and language file.
loadLanguage('Login');

// Are we in wireless mode?
if (WIRELESS)
$context['sub_template'] = WIRELESS_PROTOCOL . '_login';
else
{
loadTemplate('Login');
$context['sub_template'] = 'kick_guest';
}

./Sources/Subs-Boards.php

Find: Select
* Software Version: SMF 1.1.4 *
Replace With: Select
* Software Version: SMF 1.1.5 *
Find: Select
// Do the insert!
db_query("
INSERT IGNORE INTO {$db_prefix}board_permissions
(ID_BOARD, ID_GROUP, permission, addDeny)
VALUES
(" . implode('), (', $boardPerms) . ")", __FILE__, __LINE__);
Replace With: Select
if (!empty($boardPerms))
// Do the insert!
db_query("
INSERT IGNORE INTO {$db_prefix}board_permissions
(ID_BOARD, ID_GROUP, permission, addDeny)
VALUES
(" . implode('), (', $boardPerms) . ")", __FILE__, __LINE__);

./Sources/Subs-Compat.php

Find: Select
* Software Version: SMF 1.1.2 *
Replace With: Select
* Software Version: SMF 1.1.5 *
Find: Select
if (@version_compare(PHP_VERSION, '4.2.0') == -1)
srand(time());

if (!function_exists('md5_file'))
Replace With: Select
if (!function_exists('md5_file'))
Find: Select
if (!function_exists('sha1'))
{
function sha1($str)
{
return sha1_smf($str);
}
}
}
Replace With: Select
if (!function_exists('sha1'))
{
function sha1($str)
{
return sha1_smf($str);
}
}
}

// Make sure random means random.
if (@version_compare(PHP_VERSION, '4.2.0') == -1)
{
function smf_seed_generator()
{
global $modSettings;

if (empty($modSettings['rand_seed']))
{
$modSettings['rand_seed'] = microtime() * 1000000;
updateSettings(array('rand_seed' => $modSettings['rand_seed']));
}
$seed = ($modSettings['rand_seed'] + ((double) microtime() * 1000003)) & 0x7fffffff;
srand($seed);
// Change the seed?
if (rand(1, 250) == 69)
updateSettings(array('rand_seed' => rand()));
}
}

./Sources/Subs-Graphics.php

Find: Select
* Software Version: SMF 1.1.2 *
Replace With: Select
* Software Version: SMF 1.1.5 *
Find: Select
$tmp = 'IHDR' . pack('N', (int) $this->header->m_nWidth) . pack('N', (int) $this->header->m_nHeight) . "\x08\x03\x00\x00\x00";
$out .= $tmp . pack('N', crc32($tmp));
Replace With: Select
$tmp = 'IHDR' . pack('N', (int) $this->header->m_nWidth) . pack('N', (int) $this->header->m_nHeight) . "\x08\x03\x00\x00\x00";
$out .= $tmp . pack('N', smf_crc32($tmp));
Find: Select
$tmp = 'PLTE' . $pal;
$out .= $tmp . pack('N', crc32($tmp));
Replace With: Select
$tmp = 'PLTE' . $pal;
$out .= $tmp . pack('N', smf_crc32($tmp));
Find: Select
$out .= $tmp . pack('N', crc32($tmp));
}

// Here's the data itself!
$out .= pack('N', strlen($bmp));
$tmp = 'IDAT' . $bmp;
$out .= $tmp . pack('N', crc32($tmp));
Replace With: Select
$out .= $tmp . pack('N', smf_crc32($tmp));
}

// Here's the data itself!
$out .= pack('N', strlen($bmp));
$tmp = 'IDAT' . $bmp;
$out .= $tmp . pack('N', smf_crc32($tmp));
Find: Select
// Nothing more to come.
die();
}
Replace With: Select
// Nothing more to come.
die();
}

// crc32 doesn't work as expected on 64-bit functions - make our own.
// http://www.php.net/crc32#79567
if (!function_exists('smf_crc32'))
{
function smf_crc32($number)
{
$crc = crc32($number);

if($crc & 0x80000000){
$crc ^= 0xffffffff;
$crc += 1;
$crc = -$crc;
}

return $crc;
}
}

./Sources/Subs-Members.php

Find: Select
* Software Version: SMF 1.1.2 *
Replace With: Select
* Software Version: SMF 1.1.5 *
Find: Select
SET additionalGroups = IF(additionalGroups = '', '$group', CONCAT(additionalGroups, ',$group')))
Replace With: Select
SET additionalGroups = IF(additionalGroups = '', '$group', CONCAT(additionalGroups, ',$group'))

./Sources/Subs-Package.php

Find: Select
if ($crc['crc32'] != crc32($data))
Replace With: Select
if ($crc['crc32'] != smf_crc32($data))
Find: Select
fclose($this->connection);

return true;
}
}
Replace With: Select
fclose($this->connection);

return true;
}
}

// crc32 doesn't work as expected on 64-bit functions - make our own.
// http://www.php.net/crc32#79567
if (!function_exists('smf_crc32'))
{
function smf_crc32($number)
{
$crc = crc32($number);

if($crc & 0x80000000){
$crc ^= 0xffffffff;
$crc += 1;
$crc = -$crc;
}

return $crc;
}
}
Find: Select
function _to_cdata($data)
{
// Match all of the CDATA tags.
preg_match_all('/<!\[CDATA\[(.*?)\]\]>/s', $data, $match, PREG_SET_ORDER);

// Replace them with htmlentities'd versions.
foreach ($match as $m)
$data = str_replace($m[0], htmlentities($m[1], ENT_QUOTES), $data);

return $data;
}
Replace With: Select
function _to_cdata($data)
{
$inCdata = $inComment = false;
$output = '';

$parts = preg_split('~(<!\[CDATA\[|\]\]>|<!--|-->)~', $data, -1, PREG_SPLIT_DELIM_CAPTURE);
foreach ($parts as $part)
{
// Handle XML comments.
if (!$inCdata && $part === '<!--')
$inComment = true;
if ($inComment && $part === '-->')
$inComment = false;
elseif ($inComment)
continue;

// Handle Cdata blocks.
elseif (!$inComment && $part === '<![CDATA[')
$inCdata = true;
elseif ($inCdata && $part === ']]>')
$inCdata = false;
elseif ($inCdata)
$output .= htmlentities($part, ENT_QUOTES);

// Everything else is kept as is.
else
$output .= $part;
}

return $output;
}

./Sources/Subs-Post.php

Find: Select
* Software Version: SMF 1.1.4 *
Replace With: Select
* Software Version: SMF 1.1.5 *
Find: Select
if (!$previewing)
{
if (allowedTo('admin_forum'))
$parts[$i] = preg_replace('~\[html\](.+?)\[/html\]~ise', '\'[html]\' . strtr(un_htmlspecialchars(\'$1\'), array("\n" => \'&#13;\', \' \' => \' &#32;\')) . \'[/html]\'', $parts[$i]);
// We should edit them out, or else if an admin edits the message they will get shown...
else
$parts[$i] = preg_replace('~\[[/]?html\]~i', '', $parts[$i]);
Replace With: Select
if (!$previewing && strpos($parts[$i], '[html]') !== false)
{
if (allowedTo('admin_forum'))
$parts[$i] = preg_replace('~\[html\](.+?)\[/html\]~ise', '\'[html]\' . strtr(un_htmlspecialchars(\'$1\'), array("\n" => \'&#13;\', \' \' => \' &#32;\')) . \'[/html]\'', $parts[$i]);
// We should edit them out, or else if an admin edits the message they will get shown...
else
{
while (strpos($parts[$i], '[html]') !== false)
$parts[$i] = preg_replace('~\[[/]?html\]~i', '', $parts[$i]);
}

./Sources/Subs-Sound.php

Find: Select
* Software Version: SMF 1.1 *
Replace With: Select
* Software Version: SMF 1.1.5 *
Find: Select
global $settings, $user_info;
Replace With: Select
global $settings, $user_info, $context;

// Allow max 2 requests per 20 seconds.
if (($ip = cache_get_data('wave_file/' . $user_info['ip'], 20)) > 2 || ($ip2 = cache_get_data('wave_file/' . $user_info['ip2'], 20)) > 2)
die(header('HTTP/1.1 400 Bad Request'));
cache_put_data('wave_file/' . $user_info['ip'], $ip ? $ip + 1 : 1, 20);
if (!empty($user_info['ip2']) && $user_info['ip2'] != $user_info['ip'])
cache_put_data('wave_file/' . $user_info['ip2'], $ip2 ? $ip2 + 1 : 1, 20);

// Fixate randomization for this word.
srand(end(unpack('n', md5($word . session_id()))));
Find: Select
$sound_word .= substr($sound_letter, strpos($sound_letter, 'data') + 8) . str_repeat(chr(0x80), rand(700, 710) * 8);
}

// The .wav header.
$sound_header = array(
0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00,
0x40, 0x1F, 0x00, 0x00, 0x40, 0x1F, 0x00, 0x00,
0x01, 0x00, 0x08, 0x00, 0x64, 0x61, 0x74, 0x61,
);


$data_size = strlen($sound_word);
$file_size = $data_size + 0x24;

// Add a little randomness.
for ($i = 0; $i < $data_size; $i += rand(1, 10))
$sound_word{$i} = chr(ord($sound_word{$i}) + rand(-1, 1));

// Output the wav.
header('Content-type: audio/x-wav');
header('Content-Length: ' . $file_size);
echo 'RIFF', chr($file_size & 0xFF), chr(($file_size & 0xFF00) >> 8), chr(($file_size & 0xFF0000) >> 16), chr(($file_size & 0xFF000000) >> 24), 'WAVEfmt ';
foreach ($sound_header as $char)
echo chr($char);
echo chr($data_size & 0xFF), chr(($data_size & 0xFF00) >> 8), chr(($data_size & 0xFF0000) >> 16), chr(($data_size & 0xFF000000) >> 24), $sound_word;
Replace With: Select

$sound_letter = substr($sound_letter, strpos($sound_letter, 'data') + 8);
switch ($word{$i} === 's' ? 0 : rand(0, 2))
{
case 0:
for ($j = 0, $n = strlen($sound_letter); $j < $n; $j++)
for ($k = 0, $m = round(rand(15, 25) / 10); $k < $m; $k++)
$sound_word .= $word{$i} === 's' ? $sound_letter{$j} : chr(rand(max(ord($sound_letter{$j}) - 1, 0x00), min(ord($sound_letter{$j}) + 1, 0xFF)));
break;

case 1:
for ($j = 0, $n = strlen($sound_letter) - 1; $j < $n; $j += 2)
$sound_word .= (rand(0, 3) == 0 ? '' : $sound_letter{$j}) . (rand(0, 3) === 0 ? $sound_letter{$j + 1} : $sound_letter{$j}) . (rand(0, 3) === 0 ? $sound_letter{$j} : $sound_letter{$j + 1}) . $sound_letter{$j + 1} . (rand(0, 3) == 0 ? $sound_letter{$j + 1} : '');
$sound_word .= str_repeat($sound_letter{$n}, 2);
break;

case 2:
$shift = 0;
for ($j = 0, $n = strlen($sound_letter); $j < $n; $j++)
{
if (rand(0, 10) === 0)
$shift += rand(-3, 3);
for ($k = 0, $m = round(rand(15, 25) / 10); $k < $m; $k++)
$sound_word .= chr(min(max(ord($sound_letter{$j}) + $shift, 0x00), 0xFF));
}
break;

}

$sound_word .= str_repeat(chr(0x80), rand(10000, 10500));
}

$data_size = strlen($sound_word);
$file_size = $data_size + 0x24;
$sample_rate = 16000;

// Disable compression.
ob_end_clean();
header('Content-Encoding: none');

// Output the wav.
header('Content-type: audio/x-wav');
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT');
header('Content-Length: ' . ($file_size + 0x08));

echo pack('nnVnnnnnnnnVVnnnnV', 0x5249, 0x4646, $file_size, 0x5741, 0x5645, 0x666D, 0x7420, 0x1000, 0x0000, 0x0100, 0x0100, $sample_rate, $sample_rate, 0x0100, 0x0800, 0x6461, 0x7461, $data_size), $sound_word;

./Sources/Subs.php

Find: Select
* Software Version: SMF 1.1.4 *
Replace With: Select
* Software Version: SMF 1.1.5 *
Find: Select
if (isset($data['posts']))
$data['posts'] = 'IF(' . $data['posts'] . ' < 0, 0, ' . $data['posts'] . ')';
if (isset($data['instantMessages']))
$data['instantMessages'] = 'IF(' . $data['instantMessages'] . ' < 0, 0, ' . $data['instantMessages'] . ')';
if (isset($data['unreadMessages']))
$data['unreadMessages'] = 'IF(' . $data['unreadMessages'] . ' < 0, 0, ' . $data['unreadMessages'] . ')';
Replace With: Select
foreach(array('posts', 'instantMessages', 'unreadMessages') as $type)
if (isset($data[$type]) && preg_match('~^' . $type . ' - ([\d]+)~', $data[$type], $match) === 1)
$data[$type] = 'CASE WHEN ' . $type . ' <= ' . $match[1] . ' THEN 0 ELSE ' . $data[$type] . ' END';

./Themes/default/index.template.php

Find: Select
// Version: 1.1; index
Replace With: Select
// Version: 1.1.5; index
Find: Select
if ($context['user']['is_guest'])
$options['collapse_header'] = !empty($_COOKIE['upshrink']);
Replace With: Select
if ($context['user']['is_guest'])
{
$options['collapse_header'] = !empty($_COOKIE['upshrink']);
$options['collapse_header_ic'] = !empty($_COOKIE['upshrinkIC']);
}

./Themes/default/Post.template.php

Find: Select
// Version: 1.1; Post
Replace With: Select
// Version: 1.1.5; Post
Find: Select
<td class="windowbg" width="100%">
<div id="preview_body" class="post">', empty($context['preview_message']) ? '' : $context['preview_message'], '</div>
Replace With: Select
<td class="post" width="100%" id="preview_body">
', empty($context['preview_message']) ? str_repeat('<br />', 5) : $context['preview_message'], '

./Themes/default/Recent.template.php

Find: Select
// Version: 1.1; Recent
Replace With: Select
// Version: 1.1.5; Recent
Find: Select
$button_set['delete'] = array('text' => 31, 'image' => 'delete.gif', 'lang' => true, 'custom' => 'onclick="return confirm(\'' . $txt[154] . '?\');"', 'url' => $scripturl . '?action=recent;delete=' . $post['id'] . ';sesc=' . $context['session_id']);
Replace With: Select
$button_set['delete'] = array('text' => 31, 'image' => 'delete.gif', 'lang' => true, 'custom' => 'onclick="return confirm(\'' . $txt[154] . '?\');"', 'url' => $scripturl . '?action=deletemsg2;msg=' . $post['id'] . ';topic=' . $post['topic'] . ';recent;sesc=' . $context['session_id']);

./Themes/default/Register.template.php

Find: Select
// Version: 1.1.2; Register
Replace With: Select
// Version: 1.1.5; Register
Find: Select
<td width="40%" align="top">
Replace With: Select
<td width="40%" valign="top">

./Themes/default/style.css

Find: Select
.windowbg
{
Replace With: Select
.windowbg, #preview_body
{

./SSI.php

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

* Software Version: SMF 1.1 *
Replace With: Select

* Software Version: SMF 1.1.5 *
This operation isn't vital to the installation of this mod.
Find: Select

$ssi_magic_quotes_runtime = get_magic_quotes_runtime();
Replace With: Select

$ssi_magic_quotes_runtime = @get_magic_quotes_runtime();
This operation isn't vital to the installation of this mod.
Find: Select

// Get the forum's settings for database and file paths.
Replace With: Select

// Make sure some things simply do not exist.
foreach (array('db_character_set') as $variable)
if (isset($GLOBALS[$variable]))
unset($GLOBALS[$variable]);

// Get the forum's settings for database and file paths.
This operation isn't vital to the installation of this mod.
Find: Select

if ((get_magic_quotes_gpc() ? addslashes($_REQUEST['ssi_layers']) : $_REQUEST['ssi_layers']) == htmlspecialchars($ssi_layers))
Replace With: Select

if ((@get_magic_quotes_gpc() ? addslashes($_REQUEST['ssi_layers']) : $_REQUEST['ssi_layers']) == htmlspecialchars($ssi_layers))
This operation isn't vital to the installation of this mod.
Find: Select

p.ID_POLL, p.question, p.votingLocked, p.hideResults, p.expireTime, p.maxVotes
FROM ({$db_prefix}topics AS t, {$db_prefix}polls AS p, {$db_prefix}boards AS b)
Replace With: Select

p.ID_POLL, p.question, p.votingLocked, p.hideResults, p.expireTime, p.maxVotes, b.ID_BOARD
FROM ({$db_prefix}topics AS t, {$db_prefix}polls AS p, {$db_prefix}boards AS b)
This operation isn't vital to the installation of this mod.
Find: Select

p.ID_POLL, p.question, p.votingLocked, p.hideResults, p.expireTime, p.maxVotes, p.ID_BOARD
FROM ({$db_prefix}topics AS t, {$db_prefix}polls AS p, {$db_prefix}boards AS b)
Replace With: Select

p.ID_POLL, p.question, p.votingLocked, p.hideResults, p.expireTime, p.maxVotes, b.ID_BOARD
FROM ({$db_prefix}topics AS t, {$db_prefix}polls AS p, {$db_prefix}boards AS b)
This operation isn't vital to the installation of this mod.
Find: Select

elseif ($user_info['is_guest'] || !empty($row['votingLocked']) || !allowedTo('poll_vote'))
Replace With: Select

elseif ($user_info['is_guest'] || !empty($row['votingLocked']) || !allowedTo('poll_vote', array($row['ID_BOARD'])))

./Themes/default/languages/index.english.php

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

// Version: 1.1.2; index
Replace With: Select

// Version: 1.1.5; index
This operation isn't vital to the installation of this mod.
Find: Select

$forum_copyright = '<a href="http://www.simplemachines.org/" title="Simple Machines Forum" target="_blank">Powered by ' . $forum_version . '</a> |
<a href="http://www.simplemachines.org/about/copyright.php" title="Free Forum Software" target="_blank">SMF &copy; 2006-2007, Simple Machines LLC</a>';
Replace With: Select

$forum_copyright = '<a href="http://www.simplemachines.org/" title="Simple Machines Forum" target="_blank">Powered by ' . $forum_version . '</a> |
<a href="http://www.simplemachines.org/about/copyright.php" title="Free Forum Software" target="_blank">SMF &copy; 2006-2008, Simple Machines LLC</a>';

./Themes/default/languages/ModSettings.english.php

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

// Version: 1.1; ModSettings
Replace With: Select

// Version: 1.1.5; ModSettings
This operation isn't vital to the installation of this mod.
Find: Select

$txt['detected_Zend'] = '<b style="color: green">SMF has detected that your server has Zend installed.';

$txt['cache_enable'] = 'Caching Level';
Replace With: Select

$txt['detected_Zend'] = '<b style="color: green">SMF has detected that your server has Zend installed.';
$txt['detected_Memcached'] = '<b style="color: green">SMF has detected that your server has Memcached installed.';

$txt['cache_enable'] = 'Caching Level';
Advertisement: