Advertisement:

Navigation

Contents of smf_1-0-10_to_1-0-11_patch.mod:

<edit file>
$boarddir/index.php
</edit file>

<search for>
* Software Version:           SMF 1.0.10                                          *
</search for>

<replace>
* Software Version:           SMF 1.0.11                                          *
</replace>

<search for>
$forum_version = 'SMF 1.0.10';
</search for>

<replace>
$forum_version = 'SMF 1.0.11';
</replace>

<edit file>
$sourcedir/Subs-Auth.php
</edit file>

<search for>
* Software Version:           SMF 1.0.10                                          *
</search for>

<replace>
* Software Version:           SMF 1.0.11                                          *
</replace>

<search for>
	$_SESSION['login_' . $cookiename] = $data;
</search for>

<replace>

	// 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;
	}
</replace>

<search for>
	// Globalize cookies across domains (filter out IP-addresses)?
	if (!empty($modSettings['globalCookies']) && !preg_match('~^\d{1,3}(\.\d{1,3}){3}$~', $parsed_url['host']))
	{
		// 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 (empty($modSettings['localCookies']))
		$parsed_url['host'] = '';
</search for>

<replace>
	// Globalize cookies across domains (filter out IP-addresses)?
	if (!empty($modSettings['globalCookies']) && 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 (empty($modSettings['localCookies']) && empty($modSettings['globalCookies']))
		$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'] = '';
</replace>

<edit file>
$sourcedir/Subs-Package.php
</edit file>

<search for>
* Software Version:           SMF 1.0.10                                          *
</search for>

<replace>
* Software Version:           SMF 1.0.11                                          *
</replace>

<search for>

	if (!mktree(dirname($strPath), $mode))
</search for>

<replace>
	// Is this an invalid path and/or we can't make the directory?
	if ($strPath == dirname($strPath) || !mktree(dirname($strPath), $mode))
</replace>

<search for>
		// Set the debug level.
</search for>

<replace>
		// If we're using this try to get some more memory.
 		@ini_set('memory_limit', '32M');

		// Set the debug level.
</replace>

<search for>
				$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
						);
</search for>

<replace>
				// 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
							);
					}
</replace>

<edit file>
$sourcedir/QueryString.php
</edit file>

<search for>
* Software Version:           SMF 1.0.10                                          *
</search for>

<replace>
* Software Version:           SMF 1.0.11                                          *
</replace>

<search for>
function addslashes__recursive($var)
</search for>

<replace>
function addslashes__recursive($var, $level = 0)
</replace>

<search for>
		$new_var[addslashes($k)] = addslashes__recursive($v);
</search for>

<replace>
		$new_var[addslashes($k)] = $level > 25 ? null : addslashes__recursive($v, $level + 1);
</replace>

<search for>
function htmlspecialchars__recursive($var)
</search for>

<replace>
function htmlspecialchars__recursive($var, $level = 0)
</replace>

<search for>
	foreach ($var as $k => $v)
		$var[$k] = htmlspecialchars__recursive($v);
</search for>

<replace>
	foreach ($var as $k => $v)
		$var[$k] = $level > 25 ? null : htmlspecialchars__recursive($v, $level + 1);
</replace>

<search for>
function urldecode__recursive($var)
</search for>

<replace>
function urldecode__recursive($var, $level = 0)
</replace>

<search for>
		$new_var[urldecode($k)] = urldecode__recursive($v);
</search for>

<replace>
		$new_var[urldecode($k)] = $level > 25 ? null : urldecode__recursive($v, $level + 1);
</replace>

<search for>
function stripslashes__recursive($var)
</search for>

<replace>
function stripslashes__recursive($var, $level = 0)
</replace>

<search for>
		$new_var[stripslashes($k)] = stripslashes__recursive($v);
</search for>

<replace>
		$new_var[stripslashes($k)] = $level > 25 ? null : stripslashes__recursive($v, $level + 1);
</replace>

<search for>
function htmltrim__recursive($var)
</search for>

<replace>
function htmltrim__recursive($var, $level = 0)
</replace>

<search for>
	foreach ($var as $k => $v)
		$var[$k] = htmltrim__recursive($v);
</search for>

<replace>
	foreach ($var as $k => $v)
		$var[$k] = $level > 25 ? null : htmltrim__recursive($v, $level + 1);
</replace>