Browse Source

Merge branch 'master' of https://github.com/Spuds/playpen

Conflicts:
	Sources/ManageSettings.php
emanuele 12 years ago
parent
commit
8cc0895176
54 changed files with 420 additions and 197 deletions
  1. 2 1
      README.md
  2. 1 1
      Sources/Admin.php
  3. 8 5
      Sources/Display.php
  4. 34 55
      Sources/Logging.php
  5. 1 1
      Sources/MessageIndex.php
  6. 1 1
      Sources/ModerationCenter.php
  7. 12 3
      Sources/MoveTopic.php
  8. 8 0
      Sources/Profile-Modify.php
  9. 1 0
      Sources/Profile-View.php
  10. 2 2
      Sources/RemoveTopic.php
  11. 38 0
      Sources/ScheduledTasks.php
  12. 2 0
      Sources/Security.php
  13. 2 0
      Sources/Subs-Admin.php
  14. 6 1
      Sources/Subs-Db-mysql.php
  15. 1 1
      Sources/Subs-Editor.php
  16. 4 0
      Sources/Subs-Post.php
  17. 71 5
      Sources/Subs.php
  18. 1 1
      Sources/ViewQuery.php
  19. 4 4
      Themes/default/Admin.template.php
  20. 1 1
      Themes/default/Display.template.php
  21. 1 1
      Themes/default/Errors.template.php
  22. 1 1
      Themes/default/GenericControls.template.php
  23. 2 2
      Themes/default/Help.template.php
  24. 2 2
      Themes/default/ManageBans.template.php
  25. 1 1
      Themes/default/ManageBoards.template.php
  26. 1 1
      Themes/default/ManageMaintenance.template.php
  27. 2 2
      Themes/default/ManageMembergroups.template.php
  28. 1 1
      Themes/default/ManageNews.template.php
  29. 1 1
      Themes/default/ManagePaid.template.php
  30. 1 1
      Themes/default/ManageSmileys.template.php
  31. 2 2
      Themes/default/ModerationCenter.template.php
  32. 21 3
      Themes/default/MoveTopic.template.php
  33. 5 5
      Themes/default/Packages.template.php
  34. 2 2
      Themes/default/PersonalMessage.template.php
  35. 3 3
      Themes/default/Post.template.php
  36. 11 11
      Themes/default/Profile.template.php
  37. 1 1
      Themes/default/Register.template.php
  38. 1 1
      Themes/default/Search.template.php
  39. 1 1
      Themes/default/css/admin.css
  40. 4 4
      Themes/default/css/index.css
  41. 4 4
      Themes/default/index.template.php
  42. 1 1
      Themes/default/languages/Admin.english.php
  43. 2 0
      Themes/default/languages/ManageScheduledTasks.english.php
  44. 1 0
      Themes/default/languages/ManageSmileys.english.php
  45. 1 1
      Themes/default/languages/Themes.english.php
  46. 10 4
      Themes/default/languages/index.english.php
  47. 3 3
      other/install.php
  48. 5 2
      other/install_2-1_mysql.sql
  49. 3 0
      other/install_2-1_postgresql.sql
  50. 3 0
      other/install_2-1_sqlite.sql
  51. 3 5
      other/upgrade.php
  52. 15 2
      other/upgrade_2-1_mysql.sql
  53. 69 45
      other/upgrade_2-1_postgresql.sql
  54. 36 2
      other/upgrade_2-1_sqlite.sql

+ 2 - 1
README.md

@@ -3,7 +3,7 @@
 This is a SMF 2.1 development repository.
 The software is licensed under [BSD 3-clause license](http://www.opensource.org/licenses/BSD-3-Clause).
 
-Contributions to documentation are CC-by-SA 3. Third party libraries or sets of images, are under their own licenses.
+Contributions to documentation are licensed under [CC-by-SA 3](http://creativecommons.org/licenses/by-sa/3.0). Third party libraries or sets of images, are under their own licenses.
 
 ######Notes:
 
@@ -16,6 +16,7 @@ by signing off your contributions, you acknowledge that you can and do license y
 * fork the repository. If you are not used to Github, please check out [fork a repository](http://help.github.com/fork-a-repo).
 * branch your repository, to commit the desired changes.
 * sign-off your commits, to acknowledge your submission under the license of the project.
+ * an easy way to do so, is to define an alias for the git commit command, which includes -s switch (reference: [How to create Git aliases](http://githacks.com/post/1168909216/how-to-create-git-aliases))
 * send a pull request to us.
 
 Finally, feel free to play around. That's what we're doing. ;)

+ 1 - 1
Sources/Admin.php

@@ -30,7 +30,7 @@ function AdminMain()
 	// Load the language and templates....
 	loadLanguage('Admin');
 	loadTemplate('Admin', 'admin');
-	loadJavascriptFile('scripts/admin.js?fin20', array('default_theme' => true));
+	loadJavascriptFile('scripts/admin.js?alp21', array('default_theme' => true));
 
 	// No indexing evil stuff.
 	$context['robot_no_index'] = true;

+ 8 - 5
Sources/Display.php

@@ -149,7 +149,7 @@ function Display()
 	$request = $smcFunc['db_query']('', '
 		SELECT
 			t.num_replies, t.num_views, t.locked, ms.subject, t.is_sticky, t.id_poll,
-			t.id_member_started, t.id_first_msg, t.id_last_msg, t.approved, t.unapproved_posts,
+			t.id_member_started, t.id_first_msg, t.id_last_msg, t.approved, t.unapproved_posts, t.id_redirect_topic,
 			' . ($user_info['is_guest'] ? 't.id_last_msg + 1' : 'IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1') . ' AS new_from
 			' . (!empty($modSettings['recycle_board']) && $modSettings['recycle_board'] == $board ? ', id_previous_board, id_previous_topic' : '') . '
 		FROM {db_prefix}topics AS t
@@ -168,6 +168,10 @@ function Display()
 		fatal_lang_error('not_a_topic', false);
 	$topicinfo = $smcFunc['db_fetch_assoc']($request);
 	$smcFunc['db_free_result']($request);
+	
+	// Is this a moved topic that we are redirecting to?
+	if (!empty($topicinfo['id_redirect_topic']))
+		redirectexit('topic=' . $topicinfo['id_redirect_topic'] . '.0');
 
 	$context['real_num_replies'] = $context['num_replies'] = $topicinfo['num_replies'];
 	$context['topic_first_message'] = $topicinfo['id_first_msg'];
@@ -1190,7 +1194,7 @@ function prepareDisplayContext($reset = false)
 }
 
 /**
- * Downloads an attachment or avatar, and increments the downloads.
+ * Downloads an attachment or avatar, and increments the download count.
  * It requires the view_attachments permission. (not for avatars!)
  * It disables the session parser, and clears any previous output.
  * It depends on the attachmentUploadDir setting being correct.
@@ -1422,8 +1426,7 @@ function Download()
 }
 
 /**
- * This loads an attachment's contextual data including, most importantly, its size
- *  if it is an image.
+ * This loads an attachment's contextual data including, most importantly, its size if it is an image.
  *  Pre-condition: $attachments array to have been filled with the proper attachment data, as Display() does.
  *  (@todo change this pre-condition, too fragile and error-prone.)
  *  It requires the view_attachments permission to calculate image size.
@@ -1445,7 +1448,7 @@ function loadAttachmentContext($id_msg)
 				'id' => $attachment['id_attach'],
 				'name' => preg_replace('~&#(\\d{1,7}|x[0-9a-fA-F]{1,6});~', '&#\\1;', htmlspecialchars($attachment['filename'])),
 				'downloads' => $attachment['downloads'],
-				'size' => round($attachment['filesize'] / 1024, 2) . ' ' . $txt['kilobyte'],
+				'size' => ($attachment['filesize'] < 1024000) ? round($attachment['filesize'] / 1024, 2) . ' ' . $txt['kilobyte'] : round($attachment['filesize'] / 1024 / 1024, 2) . ' ' . $txt['megabyte'],
 				'byte_size' => $attachment['filesize'],
 				'href' => $scripturl . '?action=dlattach;topic=' . $topic . '.0;attach=' . $attachment['id_attach'],
 				'link' => '<a href="' . $scripturl . '?action=dlattach;topic=' . $topic . '.0;attach=' . $attachment['id_attach'] . '">' . htmlspecialchars($attachment['filename']) . '</a>',

+ 34 - 55
Sources/Logging.php

@@ -157,70 +157,38 @@ function writeLog($force = false)
 /**
  * Logs the last database error into a file.
  * Attempts to use the backup file first, to store the last database error
- * and only update Settings.php if the first was successful.
+ * and only update db_last_error.php if the first was successful.
  */
 function logLastDatabaseError()
 {
 	global $boarddir;
-
-	// Find out this way if we can even write things on this filesystem.
-	// In addition, store things first in the backup file
-
-	$last_settings_change = @filemtime($boarddir . '/Settings.php');
-
-	// Make sure the backup file is there...
-	$file = $boarddir . '/Settings_bak.php';
-	if ((!file_exists($file) || filesize($file) == 0) && !copy($boarddir . '/Settings.php', $file))
-			return false;
-
-	// ...and writable!
-	if (!is_writable($file))
-	{
-		chmod($file, 0755);
-		if (!is_writable($file))
-		{
-			chmod($file, 0775);
-			if (!is_writable($file))
-			{
-				chmod($file, 0777);
-				if (!is_writable($file))
-						return false;
-			}
-		}
-	}
-
-	// Put the new timestamp.
-	$data = file_get_contents($file);
-	$data = preg_replace('~\$db_last_error = \d+;~', '$db_last_error = ' . time() . ';', $data);
-
-	// Open the backup file for writing
-	if ($fp = @fopen($file, 'w'))
+	
+	// Make a note of the last modified time in case someone does this before us
+	$last_db_error_change = @filemtime($boarddir . '/db_last_error.php');
+	
+	// save the old file before we do anything
+	$file = $boarddir . '/db_last_error.php';
+	$dberror_backup_fail = !@is_writable($boarddir . '/db_last_error_bak.php') || !@copy($file, $boarddir . '/db_last_error_bak.php');
+	$dberror_backup_fail = !$dberror_backup_fail ? (!file_exists($boarddir . '/db_last_error_bak.php') || filesize($boarddir . '/db_last_error_bak.php') === 0) : $dberror_backup_fail;
+	
+	clearstatcache();
+	if (filemtime($boarddir . '/db_last_error.php') === $last_db_error_change)
 	{
-		// Reset the file buffer.
-		set_file_buffer($fp, 0);
-
-		// Update the file.
-		$t = flock($fp, LOCK_EX);
-		$bytes = fwrite($fp, $data);
-		flock($fp, LOCK_UN);
-		fclose($fp);
-
-		// Was it a success?
-		// ...only relevant if we're still dealing with the same good ole' settings file.
-		clearstatcache();
-		if (($bytes == strlen($data)) && (filemtime($boarddir . '/Settings.php') === $last_settings_change))
+		// Write the change 
+		$write_db_change =  '<' . '?' . "php\n" . '$db_last_error = ' . time() . ';' . "\n" . '?' . '>';
+		$written_bytes = file_put_contents($boarddir . '/db_last_error.php', $write_db_change, LOCK_EX);
+		
+		// survey says ...
+		if ($written_bytes !== strlen($write_db_change) && !$dberror_backup_fail)
 		{
-			// This is our new Settings file...
-			// At least this one is an atomic operation
-			@copy($file, $boarddir . '/Settings.php');
-			return true;
+			// Oops. maybe we have no more disk space left, or some other troubles, troubles...
+			// Copy the file back and run for your life!
+			@copy($boarddir . '/db_last_error_bak.php', $boarddir . '/db_last_error.php');
 		}
 		else
 		{
-			// Oops. Someone might have been faster
-			// or we have no more disk space left, troubles, troubles...
-			// Copy the file back and run for your life!
-			@copy($boarddir . '/Settings.php', $file);
+			@touch($boarddir . '/' . 'Settings.php');
+			return true;
 		}
 	}
 
@@ -274,11 +242,22 @@ function displayDebug()
 
 	echo preg_replace('~</body>\s*</html>~', '', $temp), '
 <div class="smalltext" style="text-align: left; margin: 1ex;">
+	', $txt['debug_browser'], $context['browser_body_id'], ' <em>(', implode('</em>, <em>', array_reverse(array_keys($context['browser'], true))), ')</em><br />
 	', $txt['debug_templates'], count($context['debug']['templates']), ': <em>', implode('</em>, <em>', $context['debug']['templates']), '</em>.<br />
 	', $txt['debug_subtemplates'], count($context['debug']['sub_templates']), ': <em>', implode('</em>, <em>', $context['debug']['sub_templates']), '</em>.<br />
 	', $txt['debug_language_files'], count($context['debug']['language_files']), ': <em>', implode('</em>, <em>', $context['debug']['language_files']), '</em>.<br />
 	', $txt['debug_stylesheets'], count($context['debug']['sheets']), ': <em>', implode('</em>, <em>', $context['debug']['sheets']), '</em>.<br />
 	', $txt['debug_files_included'], count($files), ' - ', round($total_size / 1024), $txt['debug_kb'], ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_include_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_include_info" style="display: none;"><em>', implode('</em>, <em>', $files), '</em></span>)<br />';
+	
+	// What tokens are active?
+	if (isset($_SESSION['token']))
+	{
+		$token_list = array();
+		foreach ($_SESSION['token'] as $key => $data)
+			$token_list[] = $key;
+		
+		echo $txt['debug_tokens'] . '<em>' . implode(',</em> <em>', $token_list), '</em>.<br />';
+	}
 
 	if (!empty($modSettings['cache_enable']) && !empty($cache_hits))
 	{

+ 1 - 1
Sources/MessageIndex.php

@@ -367,7 +367,7 @@ function MessageIndex()
 				mf.poster_name AS first_member_name, mf.id_member AS first_id_member,
 				IFNULL(memf.real_name, mf.poster_name) AS first_display_name, ' . (!empty($modSettings['preview_characters']) ? '
 				SUBSTRING(ml.body, 1, ' . ($modSettings['preview_characters'] + 256) . ') AS last_body,
-				SUBSTRING(mf.body, 1, ' . ($modSettings['preview_characters'] + 256) . ') AS first_body' : '') . 'ml.smileys_enabled AS last_smileys, mf.smileys_enabled AS first_smileys
+				SUBSTRING(mf.body, 1, ' . ($modSettings['preview_characters'] + 256) . ') AS first_body,' : '') . 'ml.smileys_enabled AS last_smileys, mf.smileys_enabled AS first_smileys
 			FROM {db_prefix}topics AS t
 				INNER JOIN {db_prefix}messages AS ml ON (ml.id_msg = t.id_last_msg)
 				INNER JOIN {db_prefix}messages AS mf ON (mf.id_msg = t.id_first_msg)

+ 1 - 1
Sources/ModerationCenter.php

@@ -225,7 +225,7 @@ function ModerationHome()
 	global $txt, $context, $scripturl, $modSettings, $user_info, $user_settings;
 
 	loadTemplate('ModerationCenter');
-	loadJavascriptFile('scripts/admin.js?fin20', array('default_theme' => true));
+	loadJavascriptFile('scripts/admin.js?alp21', array('default_theme' => true));
 
 	$context['page_title'] = $txt['moderation_center'];
 	$context['sub_template'] = 'moderation_center';

+ 12 - 3
Sources/MoveTopic.php

@@ -296,6 +296,12 @@ function MoveTopic2()
 			$txt['movetopic_auto_board'] => '[url=' . $scripturl . '?board=' . $_POST['toboard'] . '.0]' . $board_name . '[/url]',
 			$txt['movetopic_auto_topic'] => '[iurl]' . $scripturl . '?topic=' . $topic . '.0[/iurl]'
 		));
+		
+		// auto remove this MOVED redirection topic in the future?
+		$redirect_expires = !empty($_POST['redirect_expires']) ? ((int) ($_POST['redirect_expires'] * 60) + time()) : 0;
+
+		// redirect to the MOVED topic from topic list?
+		$redirect_topic = isset($_POST['redirect_topic']) ? $topic : 0;
 
 		$msgOptions = array(
 			'subject' => $txt['moved'] . ': ' . $subject,
@@ -307,6 +313,8 @@ function MoveTopic2()
 			'board' => $board,
 			'lock_mode' => 1,
 			'mark_as_read' => true,
+			'redirect_expires' => $redirect_expires,
+			'redirect_topic' => $redirect_topic,
 		);
 		$posterOptions = array(
 			'id' => $user_info['id'],
@@ -384,8 +392,9 @@ function moveTopics($topics, $toBoard)
 	// Empty array?
 	if (empty($topics))
 		return;
+		
 	// Only a single topic.
-	elseif (is_numeric($topics))
+	if (is_numeric($topics))
 		$topics = array($topics);
 	$num_topics = count($topics);
 	$fromBoards = array();
@@ -710,8 +719,8 @@ function moveTopicConcurrence()
 		$request = $smcFunc['db_query']('', '
 			SELECT m.subject, b.name
 			FROM {db_prefix}topics as t
-			LEFT JOIN {db_prefix}boards AS b ON (t.id_board = b.id_board)
-			LEFT JOIN {db_prefix}messages AS m ON (t.id_first_msg = m.id_msg)
+				LEFT JOIN {db_prefix}boards AS b ON (t.id_board = b.id_board)
+				LEFT JOIN {db_prefix}messages AS m ON (t.id_first_msg = m.id_msg)
 			WHERE t.id_topic = {int:topic_id}
 			LIMIT 1',
 			array(

+ 8 - 0
Sources/Profile-Modify.php

@@ -2878,18 +2878,21 @@ function profileValidateSignature(&$value)
 		$disabledTags = !empty($sig_bbc) ? explode(',', $sig_bbc) : array();
 
 		$unparsed_signature = strtr(un_htmlspecialchars($value), array("\r" => '', '&#039' => '\''));
+		
 		// Too many lines?
 		if (!empty($sig_limits[2]) && substr_count($unparsed_signature, "\n") >= $sig_limits[2])
 		{
 			$txt['profile_error_signature_max_lines'] = sprintf($txt['profile_error_signature_max_lines'], $sig_limits[2]);
 			return 'signature_max_lines';
 		}
+		
 		// Too many images?!
 		if (!empty($sig_limits[3]) && (substr_count(strtolower($unparsed_signature), '[img') + substr_count(strtolower($unparsed_signature), '<img')) > $sig_limits[3])
 		{
 			$txt['profile_error_signature_max_image_count'] = sprintf($txt['profile_error_signature_max_image_count'], $sig_limits[3]);
 			return 'signature_max_image_count';
 		}
+		
 		// What about too many smileys!
 		$smiley_parsed = $unparsed_signature;
 		parsesmileys($smiley_parsed);
@@ -2901,6 +2904,7 @@ function profileValidateSignature(&$value)
 			$txt['profile_error_signature_max_smileys'] = sprintf($txt['profile_error_signature_max_smileys'], $sig_limits[4]);
 			return 'signature_max_smileys';
 		}
+		
 		// Maybe we are abusing font sizes?
 		if (!empty($sig_limits[7]) && preg_match_all('~\[size=([\d\.]+)?(px|pt|em|x-large|larger)~i', $unparsed_signature, $matches) !== false && isset($matches[2]))
 		{
@@ -2924,6 +2928,7 @@ function profileValidateSignature(&$value)
 				}
 			}
 		}
+		
 		// The difficult one - image sizes! Don't error on this - just fix it.
 		if ((!empty($sig_limits[5]) || !empty($sig_limits[6])))
 		{
@@ -3008,6 +3013,7 @@ function profileValidateSignature(&$value)
 					$value = str_replace(array_keys($replaces), array_values($replaces), $value);
 			}
 		}
+		
 		// Any disabled BBC?
 		$disabledSigBBC = implode('|', $disabledTags);
 		if (!empty($disabledSigBBC))
@@ -3022,6 +3028,7 @@ function profileValidateSignature(&$value)
 	}
 
 	preparsecode($value);
+	
 	// Too long?
 	if (!allowedTo('admin_forum') && !empty($sig_limits[1]) && $smcFunc['strlen'](str_replace('<br />', "\n", $value)) > $sig_limits[1])
 	{
@@ -3064,6 +3071,7 @@ function profileValidateEmail($email, $memID = 0)
 			'email_address' => $email,
 		)
 	);
+	
 	if ($smcFunc['db_num_rows']($request) > 0)
 		return 'email_taken';
 	$smcFunc['db_free_result']($request);

+ 1 - 0
Sources/Profile-View.php

@@ -536,6 +536,7 @@ function showAttachments($memID)
 
 	// OBEY permissions!
 	$boardsAllowed = boardsAllowedTo('view_attachments');
+	
 	// Make sure we can't actually see anything...
 	if (empty($boardsAllowed))
 		$boardsAllowed = array(-1);

+ 2 - 2
Sources/RemoveTopic.php

@@ -230,9 +230,9 @@ function removeTopics($topics, $decreasePostCount = true, $ignoreRecycling = fal
 	if (empty($topics))
 		return;
 	// Only a single topic.
-	elseif (is_numeric($topics))
+	if (is_numeric($topics))
 		$topics = array($topics);
-
+		
 	// Decrease the post counts.
 	if ($decreasePostCount)
 	{

+ 38 - 0
Sources/ScheduledTasks.php

@@ -1682,4 +1682,42 @@ function scheduled_remove_temp_attachments()
 	}
 }
 
+/**
+ * Check for move topic notices that have past their best by date
+ */
+function scheduled_remove_topic_redirect() 
+{
+	global $smcFunc, $sourcedir;
+	
+	// init
+	$topics = array();
+	
+	// We will need this for lanaguage files
+	loadEssentialThemeData();
+	
+	// Find all of the old MOVE topic notices that were set to expire
+	$request = $smcFunc['db_query']('', '
+		SELECT id_topic
+		FROM {db_prefix}topics
+		WHERE redirect_expires <= {int:redirect_expires}
+			AND redirect_expires <> 0',
+		array(
+			'redirect_expires' => time(),
+		)
+	);
+	
+	while ($row = $smcFunc['db_fetch_row']($request))
+		$topics[] = $row[0];
+	$smcFunc['db_free_result']($request);
+	
+	// Zap, your gone
+	if (count($topics) > 0)
+	{
+		require_once($sourcedir . '/RemoveTopic.php');
+		removeTopics($topics, false, true);
+	}
+
+	return true;
+}
+
 ?>

+ 2 - 0
Sources/Security.php

@@ -786,6 +786,7 @@ function createToken($action, $type = 'post')
 
 /**
  * Only patrons with valid tokens can ride this ride.
+ *
  * @param string $action
  * @param string $type = 'post' (get, request, or post)
  * @param bool $reset = true
@@ -858,6 +859,7 @@ function cleanTokens($complete = false)
  * Depending on the value of is_fatal shows an error or returns true or false.
  * Frees a sequence number from the stack after it's been checked.
  * Frees a sequence number without checking if action == 'free'.
+ *
  * @param string $action
  * @param bool $is_fatal = true
  * @return bool

+ 2 - 0
Sources/Subs-Admin.php

@@ -365,7 +365,9 @@ function updateSettingsFile($config_vars)
 	if (filemtime($boarddir . '/Settings.php') === $last_settings_change)
 	{
 		// save the old before we do anything
+		$file = $boarddir . '/Settings.php';
 		$settings_backup_fail = !@is_writable($boarddir . '/Settings_bak.php') || !@copy($boarddir . '/Settings.php', $boarddir . '/Settings_bak.php');
+		$settings_backup_fail = !$settings_backup_fail ? (!file_exists($boarddir . '/Settings_bak.php') || filesize($boarddir . '/Settings_bak.php') === 0) : $settings_backup_fail;
 
 		// write out the new
 		$write_settings = implode('', $settingsArray);

+ 6 - 1
Sources/Subs-Db-mysql.php

@@ -124,6 +124,10 @@ function smf_db_replacement__callback($matches)
 	global $db_callback, $user_info, $db_prefix;
 
 	list ($values, $connection) = $db_callback;
+	
+	// Connection gone???  This should *never* happen at this point, yet it does :'(
+	if (!is_resource($connection))
+		display_db_error();
 
 	if ($matches[1] === 'db_prefix')
 		return $db_prefix;
@@ -321,8 +325,8 @@ function smf_db_query($identifier, $db_string, $db_values = array(), $connection
 			$_SESSION['debug_redirect'] = array();
 		}
 
-		$st = microtime();
 		// Don't overload it.
+		$st = microtime();
 		$db_cache[$db_count]['q'] = $db_count < 50 ? $db_string : '...';
 		$db_cache[$db_count]['f'] = $file;
 		$db_cache[$db_count]['l'] = $line;
@@ -386,6 +390,7 @@ function smf_db_query($identifier, $db_string, $db_values = array(), $connection
 		$ret = @mysql_query($db_string, $connection);
 	else
 		$ret = @mysql_unbuffered_query($db_string, $connection);
+		
 	if ($ret === false && empty($db_values['db_error_skip']))
 		$ret = smf_db_error($db_string, $connection);
 

+ 1 - 1
Sources/Subs-Editor.php

@@ -1459,7 +1459,7 @@ function create_control_richedit($editorOptions)
 				prompt_text_img: \'' . addcslashes($txt['prompt_text_img'], "'") . '\'
 			}
 		// ]]></script>
-		<script type="text/javascript" src="' . $settings['default_theme_url'] . '/scripts/editor.js?fin20"></script>';
+		<script type="text/javascript" src="' . $settings['default_theme_url'] . '/scripts/editor.js?alp21"></script>';
 
 		$context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && function_exists('pspell_new');
 		if ($context['show_spellchecking'])

+ 4 - 0
Sources/Subs-Post.php

@@ -1762,6 +1762,8 @@ function createPost(&$msgOptions, &$topicOptions, &$posterOptions)
 	$topicOptions['poll'] = isset($topicOptions['poll']) ? (int) $topicOptions['poll'] : null;
 	$topicOptions['lock_mode'] = isset($topicOptions['lock_mode']) ? $topicOptions['lock_mode'] : null;
 	$topicOptions['sticky_mode'] = isset($topicOptions['sticky_mode']) ? $topicOptions['sticky_mode'] : null;
+	$topicOptions['redirect_expires'] = isset($topicOptions['redirect_expires']) ? $topicOptions['redirect_expires'] : null;
+	$topicOptions['redirect_topic'] = isset($topicOptions['redirect_topic']) ? $topicOptions['redirect_topic'] : null;
 	$posterOptions['id'] = empty($posterOptions['id']) ? 0 : (int) $posterOptions['id'];
 	$posterOptions['ip'] = empty($posterOptions['ip']) ? $user_info['ip'] : $posterOptions['ip'];
 
@@ -1869,11 +1871,13 @@ function createPost(&$msgOptions, &$topicOptions, &$posterOptions)
 				'id_board' => 'int', 'id_member_started' => 'int', 'id_member_updated' => 'int', 'id_first_msg' => 'int',
 				'id_last_msg' => 'int', 'locked' => 'int', 'is_sticky' => 'int', 'num_views' => 'int',
 				'id_poll' => 'int', 'unapproved_posts' => 'int', 'approved' => 'int',
+ 				'redirect_expires' => 'int', 'id_redirect_topic' => 'int',
 			),
 			array(
 				$topicOptions['board'], $posterOptions['id'], $posterOptions['id'], $msgOptions['id'],
 				$msgOptions['id'], $topicOptions['lock_mode'] === null ? 0 : $topicOptions['lock_mode'], $topicOptions['sticky_mode'] === null ? 0 : $topicOptions['sticky_mode'], 0,
 				$topicOptions['poll'] === null ? 0 : $topicOptions['poll'], $msgOptions['approved'] ? 0 : 1, $msgOptions['approved'],
+				$topicOptions['redirect_expires'] === null ? 0 : $topicOptions['redirect_expires'], $topicOptions['redirect_topic'] === null ? 0 : $topicOptions['redirect_topic'],
 			),
 			array('id_topic')
 		);

+ 71 - 5
Sources/Subs.php

@@ -848,14 +848,21 @@ function parse_bbc($message, $smileys = true, $cache_id = '', $parse_tags = arra
 	// Don't waste cycles
 	if ($message === '')
 		return '';
+		
+	// Just in case it wasn't determined yet whether UTF-8 is enabled.
+	if (!isset($context['utf8']))
+		$context['utf8'] = (empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']) === 'UTF-8';
+		
+	// Clean up any cut/paste issues we may have
+	$message = sanitizeMSCutPaste($message);
 
 	// If the load average is too high, don't parse the BBC.
-	// I placed this below the empty $message check because it is slower
 	if (!empty($context['load_average']) && !empty($modSettings['bbc']) && $context['load_average'] >= $modSettings['bbc'])
 	{
 		$context['disabled_parse_bbc'] = true;
 		return $message;
 	}
+	
 	// Never show smileys for wireless clients.  More bytes, can't see it anyway :P.
 	if (WIRELESS)
 		$smileys = false;
@@ -870,10 +877,6 @@ function parse_bbc($message, $smileys = true, $cache_id = '', $parse_tags = arra
 		return $message;
 	}
 
-	// Just in case it wasn't determined yet whether UTF-8 is enabled.
-	if (!isset($context['utf8']))
-		$context['utf8'] = (empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']) === 'UTF-8';
-
 	// If we are not doing every tag then we don't cache this run.
 	if (!empty($parse_tags) && !empty($bbc_codes))
 	{
@@ -4060,4 +4063,67 @@ function remove_integration_function($hook, $function)
 	$modSettings[$hook] = implode(',', $functions);
 }
 
+/**
+* Microsoft uses their own character set Code Page 1252 (CP1252), which is a
+* superset of ISO 8859-1, defining several characters between DEC 128 and 159
+* that are not normally displayable.  This converts the popular ones that
+* appear from a cut and paste from windows.
+*
+* @param string $string
+* @return string $string
+*/
+function sanitizeMSCutPaste($string)
+{
+	global $context;
+	
+	if (empty($string))
+		return;
+		
+	// UTF-8 occurences of MS special characters
+	$findchars_utf8 = array(
+		"\xe2\80\x9a",	// single low-9 quotation mark
+		"\xe2\80\x9e",	// double low-9 quotation mark
+		"\xe2\80\xa6",	// horizontal ellipsis
+		"\xe2\x80\x98",	// left single curly quote
+		"\xe2\x80\x99",	// right single curly quote
+		"\xe2\x80\x9c",	// left double curly quote
+		"\xe2\x80\x9d",	// right double curly quote
+		"\xe2\x80\x93",	// en dash
+		"\xe2\x80\x94",	// em dash
+	);
+	
+	// windows 1252 / iso equivalents
+	$findchars_iso = array(
+		chr(130),
+		chr(132),
+		chr(133),
+		chr(145),
+		chr(146),
+		chr(147),
+		chr(148),
+		chr(150),
+		chr(151),
+	);
+
+	// safe replacements
+	$replacechars = array(
+		',',	// &sbquo;
+		',,',	// &bdquo;
+		'...',	// &hellip;
+		"'",	// &lsquo;
+		"'",	// &rsquo;
+		'"',	// &ldquo;
+		'"',	// &rdquo;
+		'-',	// &ndash;
+		'--',	// &mdash;
+	);
+	
+	if ($context['utf8'])
+		$string = str_replace($findchars_utf8, $replacechars, $string);
+	else
+		$string = str_replace($findchars_iso, $replacechars, $string);
+
+	return $string;
+}
+
 ?>

+ 1 - 1
Sources/ViewQuery.php

@@ -55,7 +55,7 @@ function ViewQuery()
 <html xmlns="http://www.w3.org/1999/xhtml"', $context['right_to_left'] ? ' dir="rtl"' : '', '>
 	<head>
 		<title>', $context['forum_name_html_safe'], '</title>
-		<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css?fin20" />
+		<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css?alp21" />
 		<style type="text/css">
 			body
 			{

+ 4 - 4
Themes/default/Admin.template.php

@@ -141,7 +141,7 @@ function template_admin()
 
 	// This sets the announcements and current versions themselves ;).
 	echo '
-		<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/admin.js?fin20"></script>
+		<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/admin.js?alp21"></script>
 		<script type="text/javascript"><!-- // --><![CDATA[
 			var oAdminIndex = new smf_AdminIndex({
 				sSelf: \'oAdminCenter\',
@@ -587,7 +587,7 @@ function template_view_versions()
 	   file categories. (sources, languages, and templates.) */
 	echo '
 		<script type="text/javascript" src="', $scripturl, '?action=viewsmfile;filename=detailed-version.js"></script>
-		<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/admin.js?fin20"></script>
+		<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/admin.js?alp21"></script>
 		<script type="text/javascript"><!-- // --><![CDATA[
 			var oViewVersions = new smf_ViewVersions({
 				aKnownLanguages: [
@@ -639,7 +639,7 @@ function template_edit_censored()
 					<div id="moreCensoredWords"></div><div style="margin-top: 1ex; display: none;" id="moreCensoredWords_link">
 						<a class="button_link" style="float: left" href="#;" onclick="addNewWord(); return false;">', $txt['censor_clickadd'], '</a><br />
 					</div>
-					<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/admin.js?fin20"></script>
+					<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/admin.js?alp21"></script>
 					<script type="text/javascript"><!-- // --><![CDATA[
 						document.getElementById("moreCensoredWords_link").style.display = "";
 					// ]]></script>
@@ -1505,7 +1505,7 @@ function template_callback_question_answer_list()
 		<dt id="add_more_question_placeholder" style="display: none;"></dt><dd></dd>
 		<dt id="add_more_link_div" style="display: none;">
 			<a href="#" onclick="addAnotherQuestion(); return false;">&#171; ', $txt['setup_verification_add_more'], ' &#187;</a>
-			<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/admin.js?fin20"></script>
+			<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/admin.js?alp21"></script>
 
 		</dt><dd></dd>';
 

+ 1 - 1
Themes/default/Display.template.php

@@ -492,7 +492,7 @@ function template_main()
 		// Can the user modify the contents of this post?  Show the modify inline image.
 		if ($message['can_modify'])
 			echo '
-							<img src="', $settings['images_url'], '/icons/modify_inline.png" alt="', $txt['modify_msg'], '" title="', $txt['modify_msg'], '" class="modifybutton" id="modify_button_', $message['id'], '" style="cursor: ', (isBrowser('is_ie5') || isBrowser('is_ie5.5') ? 'hand' : 'pointer'), '; display: none;" onclick="oQuickModify.modifyMsg(\'', $message['id'], '\')" />';
+							<img src="', $settings['images_url'], '/icons/modify_inline.png" alt="', $txt['modify_msg'], '" title="', $txt['modify_msg'], '" class="modifybutton" id="modify_button_', $message['id'], '" style="cursor: pointer; display: none;" onclick="oQuickModify.modifyMsg(\'', $message['id'], '\')" />';
 
 		// Assuming there are attachments...
 		if (!empty($message['attachment']))

+ 1 - 1
Themes/default/Errors.template.php

@@ -193,7 +193,7 @@ function template_show_file()
 	<head>
 		<title>', $context['file_data']['file'], '</title>
 		<meta http-equiv="Content-Type" content="text/html; charset=', $context['character_set'], '" />
-		<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css?fin20" />
+		<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css?alp21" />
 	</head>
 	<body>
 		<table border="0" cellpadding="0" cellspacing="3">';

+ 1 - 1
Themes/default/GenericControls.template.php

@@ -80,7 +80,7 @@ function template_control_richedit($editor_id, $smileyContainer = null, $bbcCont
 						<html>
 							<head>
 								<title>' . $txt['more_smileys_title'] . '</title>
-								<link rel="stylesheet" type="text/css" href="' . $settings['theme_url'] . '/css/index' . $context['theme_variant'] . '.css?fin20" />
+								<link rel="stylesheet" type="text/css" href="' . $settings['theme_url'] . '/css/index' . $context['theme_variant'] . '.css?alp21" />
 							</head>
 							<body id="help_popup">
 								<div class="padding windowbg">

+ 2 - 2
Themes/default/Help.template.php

@@ -21,7 +21,7 @@ function template_popup()
 		<meta http-equiv="Content-Type" content="text/html; charset=', $context['character_set'], '" />
 		<meta name="robots" content="noindex" />
 		<title>', $context['page_title'], '</title>
-		<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css?fin20" />
+		<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css?alp21" />
 		<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/script.js"></script>
 	</head>
 	<body id="help_popup">
@@ -44,7 +44,7 @@ function template_find_members()
 		<title>', $txt['find_members'], '</title>
 		<meta http-equiv="Content-Type" content="text/html; charset=', $context['character_set'], '" />
 		<meta name="robots" content="noindex" />
-		<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css?fin20" />
+		<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css?alp21" />
 		<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/script.js"></script>
 		<script type="text/javascript"><!-- // --><![CDATA[
 			var membersAdded = [];

+ 2 - 2
Themes/default/ManageBans.template.php

@@ -244,7 +244,7 @@ function template_ban_edit()
 	echo '
 	</div>
 	<br class="clear" />
-	<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/suggest.js?fin20"></script>
+	<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/suggest.js?alp21"></script>
 	<script type="text/javascript"><!-- // --><![CDATA[
 		var fUpdateStatus = function ()
 		{
@@ -344,7 +344,7 @@ function template_ban_edit_trigger()
 		</form>
 	</div>
 	<br class="clear" />
-	<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/suggest.js?fin20"></script>
+	<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/suggest.js?alp21"></script>
 	<script type="text/javascript"><!-- // --><![CDATA[
 		var oAddMemberSuggest = new smc_AutoSuggest({
 			sSelf: \'oAddMemberSuggest\',

+ 1 - 1
Themes/default/ManageBoards.template.php

@@ -518,7 +518,7 @@ function template_modify_board()
 		</form>
 	</div>
 	<br class="clear" />
-<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/suggest.js?fin20"></script>
+<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/suggest.js?alp21"></script>
 <script type="text/javascript"><!-- // --><![CDATA[
 	var oModeratorSuggest = new smc_AutoSuggest({
 		sSelf: \'oModeratorSuggest\',

+ 1 - 1
Themes/default/ManageMaintenance.template.php

@@ -406,7 +406,7 @@ function template_maintain_members()
 	</div>
 	<br class="clear" />
 
-	<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/suggest.js?fin20"></script>
+	<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/suggest.js?alp21"></script>
 	<script type="text/javascript"><!-- // --><![CDATA[
 		var oAttributeMemberSuggest = new smc_AutoSuggest({
 			sSelf: \'oAttributeMemberSuggest\',

+ 2 - 2
Themes/default/ManageMembergroups.template.php

@@ -381,7 +381,7 @@ function template_edit_group()
 		</form>
 	</div>
 	<br class="clear" />
-		<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/suggest.js?fin20"></script>
+		<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/suggest.js?alp21"></script>
 		<script type="text/javascript"><!-- // --><![CDATA[
 			var oModeratorSuggest = new smc_AutoSuggest({
 				sSelf: \'oModeratorSuggest\',
@@ -617,7 +617,7 @@ function template_group_members()
 
 	if (!empty($context['group']['assignable']))
 		echo '
-		<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/suggest.js?fin20"></script>
+		<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/suggest.js?alp21"></script>
 		<script type="text/javascript"><!-- // --><![CDATA[
 			var oAddMemberSuggest = new smc_AutoSuggest({
 				sSelf: \'oAddMemberSuggest\',

+ 1 - 1
Themes/default/ManageNews.template.php

@@ -225,7 +225,7 @@ function template_email_members()
 			}
 		});
 	// ]]></script>
-	<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/suggest.js?fin20"></script>
+	<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/suggest.js?alp21"></script>
 	<script type="text/javascript"><!-- // --><![CDATA[
 		var oMemberSuggest = new smc_AutoSuggest({
 			sSelf: \'oMemberSuggest\',

+ 1 - 1
Themes/default/ManagePaid.template.php

@@ -348,7 +348,7 @@ function template_modify_user_subscription()
 			</div>
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
 		</form>
-		<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/suggest.js?fin20"></script>
+		<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/suggest.js?alp21"></script>
 		<script type="text/javascript"><!-- // --><![CDATA[
 		var oAddMemberSuggest = new smc_AutoSuggest({
 			sSelf: \'oAddMemberSuggest\',

+ 1 - 1
Themes/default/ManageSmileys.template.php

@@ -489,7 +489,7 @@ function template_editicon()
 						</dd>';
 	echo '
 						<dt>
-							<strong><label for="icon_filename">', $txt['smileys_filename'], '</label>: </strong><br /><span class="smalltext">', $txt['icons_filename_all_gif'], '</span>
+							<strong><label for="icon_filename">', $txt['smileys_filename'], '</label>: </strong><br /><span class="smalltext">', $txt['icons_filename_all_png'], '</span>
 						</dt>
 						<dd>
 							<input type="text" name="icon_filename" id="icon_filename" value="', !empty($context['icon']['filename']) ? $context['icon']['filename'] . '.gif' : '', '" class="input_text" />

+ 2 - 2
Themes/default/ModerationCenter.template.php

@@ -71,7 +71,7 @@ function template_latest_news()
 	echo '
 		<script type="text/javascript" src="', $scripturl, '?action=viewsmfile;filename=current-version.js"></script>
 		<script type="text/javascript" src="', $scripturl, '?action=viewsmfile;filename=latest-news.js"></script>
-		<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/admin.js?fin20"></script>
+		<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/admin.js?alp21"></script>
 		<script type="text/javascript"><!-- // --><![CDATA[
 			var oAdminIndex = new smf_AdminIndex({
 				sSelf: \'oAdminCenter\',
@@ -790,7 +790,7 @@ function template_show_notice()
 	<head>
 		<meta http-equiv="Content-Type" content="text/html; charset=', $context['character_set'], '" />
 		<title>', $context['page_title'], '</title>
-		<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css?fin20" />
+		<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css?alp21" />
 	</head>
 	<body>
 		<div class="cat_bar">

+ 21 - 3
Themes/default/MoveTopic.template.php

@@ -70,11 +70,29 @@ function template_main()
 								<dd>
 									<textarea name="reason" rows="3" cols="40">', $txt['movetopic_default'], '</textarea>
 								</dd>
+								<dt>
+									<label for="redirect_topic">', $txt['movetopic_redirect'], '</label>
+								</dt>
+								<dd>
+									<input type="checkbox" name="redirect_topic" id="redirect_topic" checked="checked" class="input_check" />
+								</dd>
+								<dt>
+									', $txt['movetopic_expires'], '
+								</dt>
+								<dd>
+									<select name="redirect_expires">
+										<option value="0" selected="selected">', $txt['never'], '</option>
+										<option value="1440">', $txt['one_day'], '</option>
+										<option value="10080">', $txt['one_week'], '</option>
+										<option value="20160">', $txt['two_weeks'], '</option>
+										<option value="43200">', $txt['one_month'], '</option>
+										<option value="86400">', $txt['two_months'], '</option>
+									</select>
+								</dd>
 							</dl>
 						</fieldset>
-						<div class="righttext">
-							<input type="submit" value="', $txt['move_topic'], '" onclick="return submitThisOnce(this);" accesskey="s" class="button_submit" />
-						</div>
+						<input type="submit" value="', $txt['move_topic'], '" onclick="return submitThisOnce(this);" accesskey="s" class="button_submit" />
+						<br class="clear_right" />
 					</div>
 				</div>
 				<span class="botslice"><span></span></span>

+ 5 - 5
Themes/default/Packages.template.php

@@ -678,7 +678,7 @@ function template_browse()
 			}
 		});
 	// ]]></script>
-	<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/suggest.js?fin20"></script>
+	<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/suggest.js?alp21"></script>
 	<script type="text/javascript"><!-- // --><![CDATA[
 			var oAddVersionSuggest = new smc_AutoSuggest({
 			sSelf: \'oAddVersionSuggest\',
@@ -1313,10 +1313,10 @@ function template_view_operations()
 	<head>
 		<title>', $txt['operation_title'], '</title>
 		<meta http-equiv="Content-Type" content="text/html; charset=', $context['character_set'], '" />
-		<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css?fin20" />
-		<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/admin.css" />
-		<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/script.js?fin20"></script>
-		<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/theme.js?fin20"></script>
+		<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css?alp21" />
+		<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/admin.css?alp21" />
+		<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/script.js?alp21"></script>
+		<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/theme.js?alp21"></script>
 	</head>
 	<body>
 		<div class="padding windowbg">

+ 2 - 2
Themes/default/PersonalMessage.template.php

@@ -1223,8 +1223,8 @@ function template_send()
 	</div><br class="clear" />';
 
 	echo '
-		<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/PersonalMessage.js?fin20"></script>
-		<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/suggest.js?fin20"></script>
+		<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/PersonalMessage.js?alp21"></script>
+		<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/suggest.js?alp21"></script>
 		<script type="text/javascript"><!-- // --><![CDATA[
 			var oPersonalMessageSend = new smf_PersonalMessageSend({
 				sSelf: \'oPersonalMessageSend\',

+ 3 - 3
Themes/default/Post.template.php

@@ -184,8 +184,8 @@ function template_main()
 					<div id="post_event">
 						<fieldset id="event_main">
 							<legend><span', isset($context['post_error']['no_event']) ? ' class="error"' : '', ' id="caption_evtitle">', $txt['calendar_event_title'], '</span></legend>
-							<input type="text" name="evtitle" maxlength="255" size="60" value="', $context['event']['title'], '" tabindex="', $context['tabindex']++, '" class="input_text" />
-							<div class="smalltext">
+							<input type="text" name="evtitle" maxlength="255" size="55" value="', $context['event']['title'], '" tabindex="', $context['tabindex']++, '" class="input_text" />
+							<div class="smalltext" style="white-space: nowrap;">
 								<input type="hidden" name="calendar" value="1" />', $txt['calendar_year'], '
 								<select name="year" id="year" tabindex="', $context['tabindex']++, '" onchange="generateDays();">';
 
@@ -874,7 +874,7 @@ function template_spellcheck()
 	<head>
 		<title>', $txt['spell_check'], '</title>
 		<meta http-equiv="Content-Type" content="text/html; charset=', $context['character_set'], '" />
-		<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css?fin20" />
+		<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css?alp21" />
 		<style type="text/css">
 			body, td
 			{

+ 11 - 11
Themes/default/Profile.template.php

@@ -504,8 +504,8 @@ function template_editBuddies()
 	if ($context['can_send_email'])
 		echo '
 				<th scope="col">', $txt['email'], '</th>';
-	
-	// don't show them if they are sdisabled
+
+	// don't show them if they are disabled
 	foreach ($buddy_fields as $key => $column)
 	{
 		if (!isset($disabled_fields[$column]))
@@ -535,7 +535,7 @@ function template_editBuddies()
 		if ($context['can_send_email'])
 			echo '
 				<td align="center">', ($buddy['show_email'] == 'no' ? '' : '<a href="' . $scripturl . '?action=emailuser;sa=email;uid=' . $buddy['id'] . '" rel="nofollow"><img src="' . $settings['images_url'] . '/email_sm.png" alt="' . $txt['email'] . '" title="' . $txt['email'] . ' ' . $buddy['name'] . '" /></a>'), '</td>';
-		
+
 		// If these are off, don't show them
 		foreach ($buddy_fields as $key => $column)
 		{
@@ -543,7 +543,7 @@ function template_editBuddies()
 				echo '
 					<td align="center">', $buddy[$column]['link'], '</td>';
 		}
-		
+
 		echo '
 				<td align="center"><a href="', $scripturl, '?action=profile;area=lists;sa=buddies;u=', $context['id_member'], ';remove=', $buddy['id'], ';', $context['session_var'], '=', $context['session_id'], '"><img src="', $settings['images_url'], '/icons/delete.png" alt="', $txt['buddy_remove'], '" title="', $txt['buddy_remove'], '" /></a></td>
 			</tr>';
@@ -572,7 +572,7 @@ function template_editBuddies()
 						<input type="text" name="new_buddy" id="new_buddy" size="30" class="input_text" />
 					</dd>
 				</dl>';
-					
+
 	if (!empty($context['token_check']))
 		echo '
 				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '" />';
@@ -585,7 +585,7 @@ function template_editBuddies()
 			<span class="lowerframe"><span></span></span>
 		</div>
 	</form>
-	<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/suggest.js?fin20"></script>
+	<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/suggest.js?alp21"></script>
 	<script type="text/javascript"><!-- // --><![CDATA[
 		var oAddBuddySuggest = new smc_AutoSuggest({
 			sSelf: \'oAddBuddySuggest\',
@@ -689,7 +689,7 @@ function template_editIgnoreList()
 			<span class="lowerframe"><span></span></span>
 		</div>
 	</form>
-	<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/suggest.js?fin20"></script>
+	<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/suggest.js?alp21"></script>
 	<script type="text/javascript"><!-- // --><![CDATA[
 		var oAddIgnoreSuggest = new smc_AutoSuggest({
 			sSelf: \'oAddIgnoreSuggest\',
@@ -782,7 +782,7 @@ function template_trackIP()
 					<dt>
 						<label for="searchip"><strong>', $txt['enter_ip'], ':</strong></label>
 					</dt>
-					<dd>					
+					<dd>
 						<input type="text" name="searchip" value="', $context['ip'], '" class="input_text" />
 					</dd>
 				</dl>
@@ -1560,7 +1560,7 @@ function template_profile_theme_settings()
 								<input type="hidden" name="default_options[show_no_signatures]" value="0" />
 								<input type="checkbox" name="default_options[show_no_signatures]" id="show_no_signatures" value="1"', !empty($context['member']['options']['show_no_signatures']) ? ' checked="checked"' : '', ' class="input_check" />
 							</dd>';
-							
+
 	if ($settings['allow_no_censored'])
 		echo '
 							<dt>
@@ -2447,7 +2447,7 @@ function template_deleteAccount()
 					<span class="ie6_header floatleft"><img src="', $settings['images_url'], '/icons/profile_sm.png" alt="" class="icon" />', $txt['deleteAccount'], '</span>
 				</h3>
 			</div>';
-	
+
 	// If deleting another account give them a lovely info box.
 	if (!$context['user']['is_owner'])
 		echo '
@@ -2612,7 +2612,7 @@ function template_profile_group_manage()
 							<dd>
 								<span id="additional_groupsList">
 									<input type="hidden" name="additional_groups[]" value="0" />';
-									
+
 		// For each membergroup show a checkbox so members can be assigned to more than one group.
 		foreach ($context['member_groups'] as $member_group)
 			if ($member_group['can_be_additional'])

+ 1 - 1
Themes/default/Register.template.php

@@ -456,7 +456,7 @@ function template_verification_sound()
 		<meta http-equiv="Content-Type" content="text/html; charset=', $context['character_set'], '" />
 		<title>', $txt['visual_verification_sound'], '</title>
 		<meta name="robots" content="noindex" />
-		<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css?fin20" />
+		<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css?alp21" />
 		<style type="text/css">';
 
 	// Just show the help text and a "close window" link.

+ 1 - 1
Themes/default/Search.template.php

@@ -221,7 +221,7 @@ function template_main()
 		</fieldset>';
 		}
 	echo '
-		<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/suggest.js?fin20"></script>
+		<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/suggest.js?alp21"></script>
 		<script type="text/javascript"><!-- // --><![CDATA[
 			var oAddMemberSuggest = new smc_AutoSuggest({
 				sSelf: \'oAddMemberSuggest\',

+ 1 - 1
Themes/default/css/admin.css

@@ -3,7 +3,7 @@
 
 #quick_search form, h3.catbg #quick_search form
 {
-	padding: 7px;
+	padding: .8em;
 	line-height: 0.9em;
 	font-size: 0.8em !important;
 }

+ 4 - 4
Themes/default/css/index.css

@@ -150,7 +150,7 @@ select option
 }
 
 /* the new "button" */
-a.new_posts
+a span.new_posts
 {
 	padding: 0 4px 1px 4px;
 	background: orange;
@@ -160,9 +160,9 @@ a.new_posts
 	line-height: 1.1em;
 	border-radius: 2px;
 }
-a.new_posts:hover
+a  span.new_posts:hover
 {
-	text-decoration: none;
+	text-decoration: underline;
 }
 
 /* All input elements that are checkboxes or radio buttons shouldn't have a border around them. */
@@ -901,7 +901,7 @@ div.title_barIC h4.titlebg
 	margin: 0;
 	padding: 0.5em;
 }
-img#upshrink_ic, img#newsupshrink, img.panel_toggle
+img#upshrink_ic, img#newsupshrink, img.panel_toggle, img#quickReplyExpand
 {
 	float: right;
 	margin: 12px 5px 0 1em;

+ 4 - 4
Themes/default/index.template.php

@@ -84,9 +84,9 @@ function template_html_above()
 <html xmlns="http://www.w3.org/1999/xhtml"', $context['right_to_left'] ? ' dir="rtl"' : '', '>
 <head>';
 
-	// The ?fin20 part of this link is just here to make sure browsers don't cache it wrongly.
+	// The ?alp21 part of this link is just here to make sure browsers don't cache it wrongly.
 	echo '
-	<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css?fin20" />';
+	<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css?alp21" />';
 
 	// Some browsers need an extra stylesheet due to bugs/compatibility issues.
 	foreach (array('ie7', 'ie6', 'webkit') as $cssfix)
@@ -124,8 +124,8 @@ function template_html_above()
 	
 	// Here comes the JavaScript bits!
 	echo '
-	<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/script.js?fin20"></script>
-	<script type="text/javascript" src="', $settings['theme_url'], '/scripts/theme.js?fin20"></script>
+	<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/script.js?alp21"></script>
+	<script type="text/javascript" src="', $settings['theme_url'], '/scripts/theme.js?alp21"></script>
 	<script type="text/javascript"><!-- // --><![CDATA[
 		var smf_theme_url = "', $settings['theme_url'], '";
 		var smf_default_theme_url = "', $settings['default_theme_url'], '";

+ 1 - 1
Themes/default/languages/Admin.english.php

@@ -650,7 +650,7 @@ $txt['hooks_field_hook_exists'] = 'Status';
 $txt['hooks_active'] = 'Exists';
 $txt['hooks_disabled'] = 'Disabled';
 $txt['hooks_missing'] = 'Not found';
-$txt['hooks_no_hooks'] = 'There are not any hooks setup.';
+$txt['hooks_no_hooks'] = 'There are currenty no hooks in the system.';
 $txt['hooks_button_remove'] = 'Remove';
 $txt['hooks_disable_instructions'] = 'Click on the status icon to enable or disable the hook';
 $txt['hooks_disable_legend'] = 'Legend';

+ 2 - 0
Themes/default/languages/ManageScheduledTasks.english.php

@@ -31,6 +31,8 @@ $txt['scheduled_task_weekly_maintenance'] = 'Weekly Maintenance';
 $txt['scheduled_task_desc_weekly_maintenance'] = 'Runs essential weekly maintenance on the forum - should not be disabled.';
 $txt['scheduled_task_paid_subscriptions'] = 'Paid Subscription Checks';
 $txt['scheduled_task_desc_paid_subscriptions'] = 'Sends out any necessary paid subscription reminders and removes expired member subscriptions.';
+$txt['scheduled_task_remove_topic_redirect'] = 'Remove MOVED: redirection topics';
+$txt['scheduled_task_desc_remove_topic_redirect'] = 'Deletes "MOVED:" topic notifications as specified when the moved notice was created.';
 
 $txt['scheduled_task_reg_starting'] = 'Starting at %1$s';
 $txt['scheduled_task_reg_repeating'] = 'repeating every %1$d %2$s';

+ 1 - 0
Themes/default/languages/ManageSmileys.english.php

@@ -92,5 +92,6 @@ $txt['icons_new_icon'] = 'New Message Icon';
 $txt['icons_location_first_icon'] = 'As First Icon';
 $txt['icons_location_after'] = 'After';
 $txt['icons_filename_all_gif'] = 'All files must be &quot;gif&quot; files';
+$txt['icons_filename_all_png'] = 'All files must be &quot;png&quot; files';
 $txt['icons_no_entries'] = 'There are currently no message icons configured.';
 ?>

+ 1 - 1
Themes/default/languages/Themes.english.php

@@ -64,7 +64,7 @@ $txt['enable_random_news'] = 'Enable random news line in the forum header';
 $txt['show_group_key'] = 'Show group key on board index';
 $txt['additional_options_collapsable'] = 'Enable collapsible additional post options';
 $txt['message_index_preview'] = 'Show post previews on the message index';
-$txt['message_index_preview_first'] = 'When show post previews, Show the text of the first post';
+$txt['message_index_preview_first'] = 'When using post previews, Show the text of the first post';
 $txt['message_index_preview_first_desc'] = 'Leave un-checked to show the text of the last post instead';
 $txt['allow_no_censored'] = 'Allow users to turn off word censoring';
 $txt['who_display_viewing'] = 'Show who is viewing the board index and posts';

+ 10 - 4
Themes/default/languages/index.english.php

@@ -380,7 +380,9 @@ $txt['poll_edit'] = 'Edit Poll';
 $txt['poll'] = 'Poll';
 $txt['one_day'] = '1 Day';
 $txt['one_week'] = '1 Week';
+$txt['two_weeks'] = '2 Weeks';
 $txt['one_month'] = '1 Month';
+$txt['two_months'] = '2 Months';
 $txt['forever'] = 'Forever';
 $txt['quick_login_dec'] = 'Login with username, password and session length';
 $txt['one_hour'] = '1 Hour';
@@ -395,6 +397,7 @@ $txt['delete'] = 'Delete';
 $txt['your_pms'] = 'Your Personal Messages';
 
 $txt['kilobyte'] = 'kB';
+$txt['megabyte'] = 'MB';
 
 $txt['more_stats'] = '[More Stats]';
 
@@ -490,6 +493,11 @@ $txt['moveTopic2'] = 'Change the topic\'s subject';
 $txt['moveTopic3'] = 'New subject';
 $txt['moveTopic4'] = 'Change every message\'s subject';
 $txt['move_topic_unapproved_js'] = 'Warning! This topic has not yet been approved.\\n\\nIt is not recommended that you create a redirection topic unless you intend to approve the post immediately following the move.';
+$txt['movetopic_auto_board'] = '[BOARD]';
+$txt['movetopic_auto_topic'] = '[TOPIC LINK]';
+$txt['movetopic_default'] = 'This topic has been moved to ' . $txt['movetopic_auto_board'] . ".\n\n" . $txt['movetopic_auto_topic'];
+$txt['movetopic_redirect'] = 'Redirect to the moved topic';
+$txt['movetopic_expires'] = 'Automatically remove the redirection topic';
 
 $txt['theme_template_error'] = 'Unable to load the \'%1$s\' template.';
 $txt['theme_language_error'] = 'Unable to load the \'%1$s\' language file.';
@@ -663,10 +671,6 @@ $txt['show_personal_messages'] = 'You have received one or more new personal mes
 $txt['previous_next_back'] = '&laquo; previous';
 $txt['previous_next_forward'] = 'next &raquo;';
 
-$txt['movetopic_auto_board'] = '[BOARD]';
-$txt['movetopic_auto_topic'] = '[TOPIC LINK]';
-$txt['movetopic_default'] = 'This topic has been moved to ' . $txt['movetopic_auto_board'] . ".\n\n" . $txt['movetopic_auto_topic'];
-
 $txt['upshrink_description'] = 'Shrink or expand the header.';
 
 $txt['mark_unread'] = 'Mark unread';
@@ -770,5 +774,7 @@ $txt['debug_query_which_took'] = 'which took %1$s seconds.';
 $txt['debug_query_which_took_at'] = 'which took %1$s seconds at %2$s into request.';
 $txt['debug_show_queries'] = '[Show Queries]';
 $txt['debug_hide_queries'] = '[Hide Queries]';
+$txt['debug_tokens'] = 'Tokens: ';
+$txt['debug_browser'] = 'Browser ID: ';
 
 ?>

+ 3 - 3
other/install.php

@@ -1969,7 +1969,7 @@ function updateSettingsFile($vars)
 function updateDbLastError() 
 {
 	// Write out the db_last_error file with the error timestamp 
-	file_put_contents(dirname(__FILE__) . '/db_last_error.php', "<?php\n$db_last_error = 0;\n?" . ">\n");
+	file_put_contents(dirname(__FILE__) . '/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>');
 	
 	return true;
 }
@@ -2034,8 +2034,8 @@ function template_install_above()
 		<meta http-equiv="Content-Type" content="text/html; charset=', isset($txt['lang_character_set']) ? $txt['lang_character_set'] : 'ISO-8859-1', '" />
 		<meta name="robots" content="noindex" />
 		<title>', $txt['smf_installer'], '</title>
-		<link rel="stylesheet" type="text/css" href="Themes/default/css/index.css?fin20" />
-		<link rel="stylesheet" type="text/css" href="Themes/default/css/install.css?fin20" />
+		<link rel="stylesheet" type="text/css" href="Themes/default/css/index.css?alp21" />
+		<link rel="stylesheet" type="text/css" href="Themes/default/css/install.css?alp21" />
 		<script type="text/javascript" src="Themes/default/scripts/script.js"></script>
 	</head>
 	<body>

+ 5 - 2
other/install_2-1_mysql.sql

@@ -1614,8 +1614,9 @@ VALUES
 	(8, 0, 0, 1, 'd', 1, 'birthdayemails'),
 	(9, 0, 0, 1, 'w', 0, 'weekly_maintenance'),
 	(10, 0, 120, 1, 'd', 1, 'paid_subscriptions'),
-	(11, 0, 120, 1, 'd', 1, 'remove_temp_attachments');
-
+	(11, 0, 120, 1, 'd', 1, 'remove_temp_attachments'),
+	(12, 0, 180, 1, 'd', 1, 'remove_topic_redirect');
+	
 # --------------------------------------------------------
 
 #
@@ -1989,6 +1990,8 @@ CREATE TABLE {$db_prefix}topics (
   num_replies int(10) unsigned NOT NULL default '0',
   num_views int(10) unsigned NOT NULL default '0',
   locked tinyint(4) NOT NULL default '0',
+  redirect_expires int(10) unsigned NOT NULL default '0',
+  id_redirect_topic mediumint(8) unsigned NOT NULL default '0',
   unapproved_posts smallint(5) NOT NULL default '0',
   approved tinyint(3) NOT NULL default '1',
   PRIMARY KEY (id_topic),

+ 3 - 0
other/install_2-1_postgresql.sql

@@ -2106,6 +2106,7 @@ INSERT INTO {$db_prefix}scheduled_tasks	(id_task, next_time, time_offset, time_r
 INSERT INTO {$db_prefix}scheduled_tasks	(id_task, next_time, time_offset, time_regularity, time_unit, disabled, task) VALUES (9, 0, 0, 1, 'w', 0, 'weekly_maintenance');
 INSERT INTO {$db_prefix}scheduled_tasks	(id_task, next_time, time_offset, time_regularity, time_unit, disabled, task) VALUES (10, 0, 120, 1, 'd', 1, 'paid_subscriptions');
 INSERT INTO {$db_prefix}scheduled_tasks	(id_task, next_time, time_offset, time_regularity, time_unit, disabled, task) VALUES (11, 0, 120, 1, 'd', 1, 'remove_temp_attachments');
+INSERT INTO {$db_prefix}scheduled_tasks	(id_task, next_time, time_offset, time_regularity, time_unit, disabled, task) VALUES (12, 0, 180, 1, 'd', 1, 'remove_topic_redirect');
 
 # --------------------------------------------------------
 
@@ -2505,6 +2506,8 @@ CREATE TABLE {$db_prefix}topics (
   num_replies int NOT NULL default '0',
   num_views int NOT NULL default '0',
   locked smallint NOT NULL default '0',
+  redirect_expires int NOT NULL default '0',
+  id_redirect_topic int NOT NULL default '0',
   unapproved_posts smallint NOT NULL default '0',
   approved smallint NOT NULL default '1',
   PRIMARY KEY (id_topic)

+ 3 - 0
other/install_2-1_sqlite.sql

@@ -1757,6 +1757,7 @@ INSERT INTO {$db_prefix}scheduled_tasks	(id_task, next_time, time_offset, time_r
 INSERT INTO {$db_prefix}scheduled_tasks	(id_task, next_time, time_offset, time_regularity, time_unit, disabled, task) VALUES (9, 0, 0, 1, 'w', 0, 'weekly_maintenance');
 INSERT INTO {$db_prefix}scheduled_tasks	(id_task, next_time, time_offset, time_regularity, time_unit, disabled, task) VALUES (10, 0, 120, 1, 'd', 1, 'paid_subscriptions');
 INSERT INTO {$db_prefix}scheduled_tasks	(id_task, next_time, time_offset, time_regularity, time_unit, disabled, task) VALUES (11, 0, 120, 1, 'd', 1, 'remove_temp_attachments');
+INSERT INTO {$db_prefix}scheduled_tasks	(id_task, next_time, time_offset, time_regularity, time_unit, disabled, task) VALUES (12, 0, 180, 1, 'd', 1, 'remove_topic_redirect');
 COMMIT;
 
 # --------------------------------------------------------
@@ -2141,6 +2142,8 @@ CREATE TABLE {$db_prefix}topics (
   num_replies int NOT NULL default '0',
   num_views int NOT NULL default '0',
   locked smallint NOT NULL default '0',
+  redirect_expires int NOT NULL default '0',
+  id_redirect_topic int NOT NULL default '0',
   unapproved_posts smallint NOT NULL default '0',
   approved smallint NOT NULL default '1'
 );

+ 3 - 5
other/upgrade.php

@@ -2170,10 +2170,8 @@ function changeSettings($config_vars)
 }
 function updateLastError() 
 {
-	global $db_last_error;
-
 	// clear out the db_last_error file
-	file_put_contents(dirname(__FILE__) . '/db_last_error.php', "<?php\n$db_last_error = 0;\n?" . ">\n");
+	file_put_contents(dirname(__FILE__) . '/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>');
 }
 
 function php_version_check()
@@ -3436,8 +3434,8 @@ function template_upgrade_above()
 		<meta http-equiv="Content-Type" content="text/html; charset=', isset($txt['lang_character_set']) ? $txt['lang_character_set'] : 'ISO-8859-1', '" />
 		<meta name="robots" content="noindex" />
 		<title>', $txt['upgrade_upgrade_utility'], '</title>
-		<link rel="stylesheet" type="text/css" href="', $settings['default_theme_url'], '/css/index.css?fin20" />
-		<link rel="stylesheet" type="text/css" href="', $settings['default_theme_url'], '/css/install.css?fin20" />
+		<link rel="stylesheet" type="text/css" href="', $settings['default_theme_url'], '/css/index.css?alp21" />
+		<link rel="stylesheet" type="text/css" href="', $settings['default_theme_url'], '/css/install.css?alp21" />
 				<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/script.js"></script>
 		<script type="text/javascript"><!-- // --><![CDATA[
 			var smf_scripturl = \'', $upgradeurl, '\';

+ 15 - 2
other/upgrade_2-1_mysql.sql

@@ -145,11 +145,24 @@ CHANGE `session_id` `session_id` char(64) NOT NULL;
 ---#
 
 /******************************************************************************/
---- Adding new scheduled tasts
+--- Adding support for MOVED topics enhancements
 /******************************************************************************/
----# Adding new Scheduled Task...
+---# Adding new columns to topics ..
+ALTER TABLE {$db_prefix}topics
+ADD COLUMN redirect_expires int(10) unsigned NOT NULL default '0',
+ADD COLUMN id_redirect_topic mediumint(8) unsigned NOT NULL default '0',
+---#
+
+/******************************************************************************/
+--- Adding new scheduled tasks
+/******************************************************************************/
+---# Adding new scheduled tasks
 INSERT INTO {$db_prefix}scheduled_tasks
 	(next_time, time_offset, time_regularity, time_unit, disabled, task)
 VALUES
 	(0, 120, 1, 'd', 0, 'remove_temp_attachments');
+INSERT INTO {$db_prefix}scheduled_tasks
+	(next_time, time_offset, time_regularity, time_unit, disabled, task)
+VALUES
+	(0, 180, 1, 'd', 0, 'remove_topic_redirect');
 ---#

+ 69 - 45
other/upgrade_2-1_postgresql.sql

@@ -115,35 +115,40 @@ ADD COLUMN ip_high8 smallint NOT NULL DEFAULT '0';
 ---# Changing existing columns to ban items...
 ---{
 upgrade_query("
-ALTER TABLE {$db_prefix}ban_items
-ALTER COLUMN ip_low1 type smallint,
-ALTER COLUMN ip_high1 type smallint,
-ALTER COLUMN ip_low2 type smallint,
-ALTER COLUMN ip_high2 type smallint,
-ALTER COLUMN ip_low3 type smallint,
-ALTER COLUMN ip_high3 type smallint,
-ALTER COLUMN ip_low4 type smallint,
-ALTER COLUMN ip_high4 type smallint;");
+	ALTER TABLE {$db_prefix}ban_items
+	ALTER COLUMN ip_low1 type smallint,
+	ALTER COLUMN ip_high1 type smallint,
+	ALTER COLUMN ip_low2 type smallint,
+	ALTER COLUMN ip_high2 type smallint,
+	ALTER COLUMN ip_low3 type smallint,
+	ALTER COLUMN ip_high3 type smallint,
+	ALTER COLUMN ip_low4 type smallint,
+	ALTER COLUMN ip_high4 type smallint;"
+);
+
 upgrade_query("
-ALTER TABLE {$db_prefix}ban_items
-ALTER COLUMN ip_low1 SET DEFAULT '0',
-ALTER COLUMN ip_high1 SET DEFAULT '0',
-ALTER COLUMN ip_low2 SET DEFAULT '0',
-ALTER COLUMN ip_high2 SET DEFAULT '0',
-ALTER COLUMN ip_low3 SET DEFAULT '0',
-ALTER COLUMN ip_high3 SET DEFAULT '0',
-ALTER COLUMN ip_low4 SET DEFAULT '0',
-ALTER COLUMN ip_high4 SET DEFAULT '0';");
+	ALTER TABLE {$db_prefix}ban_items
+	ALTER COLUMN ip_low1 SET DEFAULT '0',
+	ALTER COLUMN ip_high1 SET DEFAULT '0',
+	ALTER COLUMN ip_low2 SET DEFAULT '0',
+	ALTER COLUMN ip_high2 SET DEFAULT '0',
+	ALTER COLUMN ip_low3 SET DEFAULT '0',
+	ALTER COLUMN ip_high3 SET DEFAULT '0',
+	ALTER COLUMN ip_low4 SET DEFAULT '0',
+	ALTER COLUMN ip_high4 SET DEFAULT '0';"
+);
+
 upgrade_query("
-ALTER TABLE {$db_prefix}ban_items
-ALTER COLUMN ip_low1 SET NOT NULL,
-ALTER COLUMN ip_high1 SET NOT NULL,
-ALTER COLUMN ip_low2 SET NOT NULL,
-ALTER COLUMN ip_high2 SET NOT NULL,
-ALTER COLUMN ip_low3 SET NOT NULL,
-ALTER COLUMN ip_high3 SET NOT NULL,
-ALTER COLUMN ip_low4 SET NOT NULL,
-ALTER COLUMN ip_high4 SET NOT NULL;");
+	ALTER TABLE {$db_prefix}ban_items
+	ALTER COLUMN ip_low1 SET NOT NULL,
+	ALTER COLUMN ip_high1 SET NOT NULL,
+	ALTER COLUMN ip_low2 SET NOT NULL,
+	ALTER COLUMN ip_high2 SET NOT NULL,
+	ALTER COLUMN ip_low3 SET NOT NULL,
+	ALTER COLUMN ip_high3 SET NOT NULL,
+	ALTER COLUMN ip_low4 SET NOT NULL,
+	ALTER COLUMN ip_high4 SET NOT NULL;"
+);
 ---}
 ---#
 
@@ -161,38 +166,57 @@ ADD COLUMN credits varchar(255) NOT NULL DEFAULT '';
 ---# Altering the session_id columns...
 ---{
 upgrade_query("
-ALTER TABLE {$db_prefix}log_online
-ALTER COLUMN session type varchar(64);
+	ALTER TABLE {$db_prefix}log_online
+	ALTER COLUMN session type varchar(64);
 
-ALTER TABLE {$db_prefix}log_errors
-ALTER COLUMN session type char(64);
+	ALTER TABLE {$db_prefix}log_errors
+	ALTER COLUMN session type char(64);
 
-ALTER TABLE {$db_prefix}sessions
-ALTER COLUMN session_id type char(64);");
+	ALTER TABLE {$db_prefix}sessions
+	ALTER COLUMN session_id type char(64);");
+	
 upgrade_query("
-ALTER TABLE {$db_prefix}log_online
-ALTER COLUMN session SET DEFAULT '';
+	ALTER TABLE {$db_prefix}log_online
+	ALTER COLUMN session SET DEFAULT '';
 
-ALTER TABLE {$db_prefix}log_errors
-ALTER COLUMN session SET default '                                                                ';");
+	ALTER TABLE {$db_prefix}log_errors
+	ALTER COLUMN session SET default '                                                                ';");
 upgrade_query("
-ALTER TABLE {$db_prefix}log_online
-ALTER COLUMN session SET NOT NULL;
+	ALTER TABLE {$db_prefix}log_online
+	ALTER COLUMN session SET NOT NULL;
 
-ALTER TABLE {$db_prefix}log_errors
-ALTER COLUMN session SET NOT NULL;
+	ALTER TABLE {$db_prefix}log_errors
+	ALTER COLUMN session SET NOT NULL;
 
-ALTER TABLE {$db_prefix}sessions
-ALTER COLUMN session_id SET NOT NULL;");
+	ALTER TABLE {$db_prefix}sessions
+	ALTER COLUMN session_id SET NOT NULL;");
 ---}
 ---#
 
 /******************************************************************************/
---- Adding new scheduled tasts
+--- Adding support for MOVED topics enhancements
 /******************************************************************************/
----# Adding new Scheduled Task...
+---# Adding new columns to topics table
+---{
+upgrade_query("
+	ALTER TABLE {$db_prefix}topics
+	ADD COLUMN redirect_expires int NOT NULL DEFAULT '0'");
+upgrade_query("
+	ALTER TABLE {$db_prefix}topics
+	ADD COLUMN id_redirect_topic int NOT NULL DEFAULT '0'");
+---}
+---#
+
+/******************************************************************************/
+--- Adding new scheduled tasks
+/******************************************************************************/
+---# Adding new scheduled tasks
 INSERT INTO {$db_prefix}scheduled_tasks
 	(next_time, time_offset, time_regularity, time_unit, disabled, task)
 VALUES
 	(0, 120, 1, 'd', 0, 'remove_temp_attachments');
+INSERT INTO {$db_prefix}scheduled_tasks
+	(next_time, time_offset, time_regularity, time_unit, disabled, task)
+VALUES
+	(0, 180, 1, 'd', 0, 'remove_topic_redirect');
 ---#

+ 36 - 2
other/upgrade_2-1_sqlite.sql

@@ -145,11 +145,45 @@ CHANGE `session_id` `session_id` char(64) NOT NULL;
 ---#
 
 /******************************************************************************/
---- Adding new scheduled tasts
+--- Adding new columns for MOVED topic updates
 /******************************************************************************/
----# Adding new Scheduled Task...
+---# Adding new custom fields columns.
+---{
+$smcFunc['db_alter_table']('{db_prefix}topics', array(
+	'add' => array(
+		'redirect_expires' => array(
+			'name' => 'redirect_expires',
+			'null' => false,
+			'default' => '0',
+			'type' => 'int',
+			'auto' => false,
+		),
+	)
+));
+$smcFunc['db_alter_table']('{db_prefix}topics', array(
+	'add' => array(
+		'id_redirect_topic' => array(
+			'name' => 'id_redirect_topic',
+			'null' => false,
+			'default' => '0',
+			'type' => 'int',
+			'auto' => false,
+		),
+	)
+));
+---}
+---#
+
+/******************************************************************************/
+--- Adding new scheduled tasks
+/******************************************************************************/
+---# Adding new scheduled tasks
 INSERT INTO {$db_prefix}scheduled_tasks
 	(next_time, time_offset, time_regularity, time_unit, disabled, task)
 VALUES
 	(0, 120, 1, 'd', 0, 'remove_temp_attachments');
+INSERT INTO {$db_prefix}scheduled_tasks
+	(next_time, time_offset, time_regularity, time_unit, disabled, task)
+VALUES
+	(0, 180, 1, 'd', 0, 'remove_topic_redirect');
 ---#