Browse Source

Merge branch 'master' into l10n

Conflicts:
	Themes/default/Display.template.php
emanuele 11 years ago
parent
commit
0eca34a4b3
100 changed files with 2143 additions and 860 deletions
  1. 3 1
      Packages/index.php
  2. 3 1
      Smileys/index.php
  3. 27 22
      Sources/Attachments.php
  4. 2 2
      Sources/Calendar.php
  5. 21 6
      Sources/Class-BrowserDetect.php
  6. 27 21
      Sources/Class-CurlFetchWeb.php
  7. 145 12
      Sources/Class-Package.php
  8. 6 4
      Sources/DbExtra-mysql.php
  9. 7 5
      Sources/DbExtra-postgresql.php
  10. 7 5
      Sources/DbExtra-sqlite.php
  11. 40 23
      Sources/DbPackages-mysql.php
  12. 34 23
      Sources/DbPackages-postgresql.php
  13. 36 23
      Sources/DbPackages-sqlite.php
  14. 1 1
      Sources/DbSearch-postgresql.php
  15. 1 1
      Sources/DbSearch-sqlite.php
  16. 14 22
      Sources/Display.php
  17. 52 21
      Sources/Drafts.php
  18. 4 2
      Sources/Errors.php
  19. 5 4
      Sources/Groups.php
  20. 4 2
      Sources/Karma.php
  21. 6 6
      Sources/Load.php
  22. 1 1
      Sources/LogInOut.php
  23. 3 2
      Sources/Logging.php
  24. 422 58
      Sources/ManageAttachments.php
  25. 19 15
      Sources/ManageBans.php
  26. 4 3
      Sources/ManageBoards.php
  27. 3 5
      Sources/ManageCalendar.php
  28. 16 7
      Sources/ManageLanguages.php
  29. 1 1
      Sources/ManageMail.php
  30. 4 7
      Sources/ManageMaintenance.php
  31. 10 5
      Sources/ManageMembergroups.php
  32. 6 7
      Sources/ManageMembers.php
  33. 7 1
      Sources/ManageNews.php
  34. 21 19
      Sources/ManagePaid.php
  35. 1 1
      Sources/ManagePermissions.php
  36. 4 5
      Sources/ManageScheduledTasks.php
  37. 4 0
      Sources/ManageSearch.php
  38. 10 4
      Sources/ManageSearchEngines.php
  39. 12 6
      Sources/ManageServer.php
  40. 67 24
      Sources/ManageSettings.php
  41. 23 13
      Sources/ManageSmileys.php
  42. 10 6
      Sources/MessageIndex.php
  43. 3 5
      Sources/ModerationCenter.php
  44. 6 4
      Sources/Modlog.php
  45. 14 1
      Sources/MoveTopic.php
  46. 18 3
      Sources/News.php
  47. 47 2
      Sources/Packages.php
  48. 20 16
      Sources/PersonalMessage.php
  49. 10 3
      Sources/Post.php
  50. 4 6
      Sources/PostModeration.php
  51. 3 3
      Sources/Profile-Actions.php
  52. 8 6
      Sources/Profile-Modify.php
  53. 23 6
      Sources/Profile-View.php
  54. 8 4
      Sources/QueryString.php
  55. 6 2
      Sources/RemoveTopic.php
  56. 3 1
      Sources/RepairBoards.php
  57. 1 1
      Sources/Reports.php
  58. 14 1
      Sources/ScheduledTasks.php
  59. 2 2
      Sources/Search.php
  60. 77 11
      Sources/SearchAPI-Custom.php
  61. 37 9
      Sources/SearchAPI-Fulltext.php
  62. 24 4
      Sources/SearchAPI-Standard.php
  63. 7 7
      Sources/Security.php
  64. 5 5
      Sources/Session.php
  65. 6 0
      Sources/Subs-Admin.php
  66. 9 19
      Sources/Subs-Auth.php
  67. 1 1
      Sources/Subs-Boards.php
  68. 25 25
      Sources/Subs-Calendar.php
  69. 3 4
      Sources/Subs-Categories.php
  70. 17 15
      Sources/Subs-Db-mysql.php
  71. 28 4
      Sources/Subs-Db-postgresql.php
  72. 21 1
      Sources/Subs-Db-sqlite.php
  73. 7 0
      Sources/Subs-Editor.php
  74. 7 6
      Sources/Subs-Graphics.php
  75. 4 2
      Sources/Subs-List.php
  76. 22 5
      Sources/Subs-Membergroups.php
  77. 13 15
      Sources/Subs-Members.php
  78. 2 2
      Sources/Subs-Menu.php
  79. 7 0
      Sources/Subs-MessageIndex.php
  80. 2 2
      Sources/Subs-OpenID.php
  81. 71 15
      Sources/Subs-Package.php
  82. 16 21
      Sources/Subs-Post.php
  83. 1 1
      Sources/Subs-Sound.php
  84. 138 17
      Sources/Subs.php
  85. 12 2
      Sources/Themes.php
  86. 3 5
      Sources/Who.php
  87. 42 35
      Themes/default/Admin.template.php
  88. 11 10
      Themes/default/Display.template.php
  89. 2 2
      Themes/default/Errors.template.php
  90. 5 4
      Themes/default/GenericControls.template.php
  91. 7 7
      Themes/default/GenericList.template.php
  92. 1 1
      Themes/default/GenericMenu.template.php
  93. 1 1
      Themes/default/Help.template.php
  94. 3 3
      Themes/default/Login.template.php
  95. 91 4
      Themes/default/ManageAttachments.template.php
  96. 113 118
      Themes/default/ManageBans.template.php
  97. 8 3
      Themes/default/ManageBoards.template.php
  98. 3 3
      Themes/default/ManageLanguages.template.php
  99. 1 1
      Themes/default/ManageMaintenance.template.php
  100. 7 7
      Themes/default/ManageMembergroups.template.php

+ 3 - 1
Packages/index.php

@@ -1,6 +1,8 @@
 <?php
 
-// This file is here solely to protect your Packages directory.
+/**
+ * This file is here solely to protect your Packages directory.
+ */
 
 // Look for Settings.php....
 if (file_exists(dirname(dirname(__FILE__)) . '/Settings.php'))

+ 3 - 1
Smileys/index.php

@@ -1,6 +1,8 @@
 <?php
 
-// This file is here solely to protect your Smileys directory.
+/**
+ * This file is here solely to protect your Smileys directory.
+ */
 
 // Look for Settings.php....
 if (file_exists(dirname(dirname(__FILE__)) . '/Settings.php'))

+ 27 - 22
Sources/Attachments.php

@@ -23,11 +23,13 @@ function automanage_attachments_check_directory()
 	global $boarddir, $modSettings, $context;
 
 	// Not pretty, but since we don't want folders created for every post. It'll do unless a better solution can be found.
-	if (empty($modSettings['automanage_attachments']))
+	if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'admin')
+		$doit = true;
+	elseif (empty($modSettings['automanage_attachments']))
 		return;
-	elseif (!isset($_FILES) && !isset($doit))
+	elseif (!isset($_FILES))
 		return;
-	elseif (isset($_FILES))
+	elseif (isset($_FILES['attachment']))
 		foreach ($_FILES['attachment']['tmp_name'] as $dummy)
 			if (!empty($dummy))
 			{
@@ -70,7 +72,8 @@ function automanage_attachments_check_directory()
 	$sep = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? '\/' : DIRECTORY_SEPARATOR;
 	$basedirectory = rtrim($basedirectory, $sep);
 
-	switch ($modSettings['automanage_attachments']){
+	switch ($modSettings['automanage_attachments'])
+	{
 		case 1:
 			$updir = $basedirectory . DIRECTORY_SEPARATOR . 'attachments_' . (isset($modSettings['last_attachments_directory'][$base_dir]) ? $modSettings['last_attachments_directory'][$base_dir] : 0);
 			break;
@@ -114,26 +117,26 @@ function automanage_attachments_create_directory($updir)
 {
 	global $modSettings, $initial_error, $context, $boarddir;
 
-	$tree = mama_get_directory_tree_elements($updir);
+	$tree = get_directory_tree_elements($updir);
 	$count = count($tree);
 
-	$directory = mama_init_dir($tree, $count);
+	$directory = attachments_init_dir($tree, $count);
 	if ($directory === false)
 	{
 		// Maybe it's just the folder name
-		$tree = mama_get_directory_tree_elements($boarddir . DIRECTORY_SEPARATOR . $updir);
+		$tree = get_directory_tree_elements($boarddir . DIRECTORY_SEPARATOR . $updir);
 		$count = count($tree);
 	
-		$directory = mama_init_dir($tree, $count);
+		$directory = attachments_init_dir($tree, $count);
 		if ($directory === false)
 			return false;
 	}
 
 	$directory .= DIRECTORY_SEPARATOR . array_shift($tree);
 
-	while (!is_dir($directory) || $count != -1)
+	while (!@is_dir($directory) || $count != -1)
 	{
-		if (!is_dir($directory))
+		if (!@is_dir($directory))
 		{
 			if (!@mkdir($directory,0755))
 			{
@@ -165,7 +168,7 @@ function automanage_attachments_create_directory($updir)
 	}
 
 	// Everything seems fine...let's create the .htaccess
-	if (!file_exists($directory . DIRECTORY_SEPARATOR . '.htacess'))
+	if (!file_exists($directory . DIRECTORY_SEPARATOR . '.htaccess'))
 		secureDirectory($updir, true);
 
 	$sep = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? '\/' : DIRECTORY_SEPARATOR;
@@ -231,7 +234,7 @@ function automanage_attachments_by_space()
 		return false;
 }
 
-function mama_get_directory_tree_elements ($directory)
+function get_directory_tree_elements ($directory)
 {
 	/*
 		In Windows server both \ and / can be used as directory separators in paths
@@ -252,7 +255,7 @@ function mama_get_directory_tree_elements ($directory)
 	return $tree;
 }
 
-function mama_init_dir (&$tree, &$count)
+function attachments_init_dir (&$tree, &$count)
 {
 	$directory = '';
 	// If on Windows servers the first part of the path is the drive (e.g. "C:")
@@ -523,9 +526,11 @@ function attachmentChecks($attachID)
 			$request = $smcFunc['db_query']('', '
 				SELECT COUNT(*), SUM(size)
 				FROM {db_prefix}attachments
-				WHERE id_folder = {int:folder_id}',
+				WHERE id_folder = {int:folder_id}
+					AND attachment_type != {int:type}',
 				array(
-					'folder_id' => (empty($modSettings['currentAttachmentUploadDir']) ? 1 : $modSettings['currentAttachmentUploadDir']),
+					'folder_id' => $modSettings['currentAttachmentUploadDir'],
+					'type' => 1,
 				)
 			);
 			list ($context['dir_files'], $context['dir_size']) = $smcFunc['db_fetch_row']($request);
@@ -535,8 +540,8 @@ function attachmentChecks($attachID)
 		$context['dir_files']++;
 
 		// Are we about to run out of room? Let's notify the admin then.
-		if (empty($modSettings['attachment_full_notified']) && empty($modSettings['attachmentDirSizeLimit']) && $modSettings['attachmentDirSizeLimit'] > 4000 && $context['dir_size'] > ($modSettings['attachmentDirSizeLimit'] - 2000) * 1024
-			|| (empty($modSettings['attachmentDirFileLimit']) && $modSettings['attachmentDirFileLimit'] * .95 < $context['dir_files'] && $modSettings['attachmentDirFileLimit'] > 500))
+		if (empty($modSettings['attachment_full_notified']) && !empty($modSettings['attachmentDirSizeLimit']) && $modSettings['attachmentDirSizeLimit'] > 4000 && $context['dir_size'] > ($modSettings['attachmentDirSizeLimit'] - 2000) * 1024
+			|| (!empty($modSettings['attachmentDirFileLimit']) && $modSettings['attachmentDirFileLimit'] * .95 < $context['dir_files'] && $modSettings['attachmentDirFileLimit'] > 500))
 		{
 			require_once($sourcedir . '/Subs-Admin.php');
 			emailAdmins('admin_attachments_full');
@@ -545,7 +550,7 @@ function attachmentChecks($attachID)
 
 		// // No room left.... What to do now???
 		if (!empty($modSettings['attachmentDirFileLimit']) && $context['dir_files'] + 2 > $modSettings['attachmentDirFileLimit']
-			|| (!empty($modSettings['attachmentDirFileLimit']) && $context['dir_size'] > $modSettings['attachmentDirSizeLimit'] * 1024))
+			|| (!empty($modSettings['attachmentDirSizeLimit']) && $context['dir_size'] > $modSettings['attachmentDirSizeLimit'] * 1024))
 		{
 			if (!empty($modSettings['automanage_attachments']) && $modSettings['automanage_attachments'] == 1)
 			{
@@ -555,8 +560,8 @@ function attachmentChecks($attachID)
 					rename($_SESSION['temp_attachments'][$attachID]['tmp_name'], $context['attach_dir'] . '/' . $attachID);
 					$_SESSION['temp_attachments'][$attachID]['tmp_name'] = $context['attach_dir'] . '/' . $attachID;
 					$_SESSION['temp_attachments'][$attachID]['id_folder'] = $modSettings['currentAttachmentUploadDir'];
-					$context['dir_size'] = $_SESSION['temp_attachments'][$attachID]['size'];
-					$context['dir_files'] = 1;
+					$context['dir_size'] = 0;
+					$context['dir_files'] = 0;
 				}
 				// Or, let the user know that it ain't gonna happen.
 				else
@@ -750,8 +755,8 @@ function createAttachment(&$attachmentOptions)
 					{
 						rename($thumb_path, $context['attach_dir'] . '/' . $thumb_filename);
 						$thumb_path = $context['attach_dir'] . '/' . $thumb_filename;
-						$context['dir_size'] = $thumb_size;
-						$context['dir_files'] = 1;
+						$context['dir_size'] = 0;
+						$context['dir_files'] = 0;
 					}
 				}
 			}

+ 2 - 2
Sources/Calendar.php

@@ -205,7 +205,7 @@ function CalendarPost()
 			$eventOptions = array(
 				'board' => 0,
 				'topic' => 0,
-				'title' => substr($_REQUEST['evtitle'], 0, 60),
+				'title' => $smcFunc['substr']($_REQUEST['evtitle'], 0, 100),
 				'member' => $user_info['id'],
 				'start_date' => sprintf('%04d-%02d-%02d', $_POST['year'], $_POST['month'], $_POST['day']),
 				'span' => isset($_POST['span']) && $_POST['span'] > 0 ? min((int) $modSettings['cal_maxspan'], (int) $_POST['span'] - 1) : 0,
@@ -236,7 +236,7 @@ function CalendarPost()
 			}
 
 			$eventOptions = array(
-				'title' => substr($_REQUEST['evtitle'], 0, 60),
+				'title' => $smcFunc['substr']($_REQUEST['evtitle'], 0, 100),
 				'span' => empty($modSettings['cal_allowspan']) || empty($_POST['span']) || $_POST['span'] == 1 || empty($modSettings['cal_maxspan']) || $_POST['span'] > $modSettings['cal_maxspan'] ? 0 : min((int) $modSettings['cal_maxspan'], (int) $_POST['span'] - 1),
 				'start_date' => strftime('%Y-%m-%d', mktime(0, 0, 0, (int) $_REQUEST['month'], (int) $_REQUEST['day'], (int) $_REQUEST['year'])),
 			);

+ 21 - 6
Sources/Class-BrowserDetect.php

@@ -1,8 +1,21 @@
 <?php
 
 /**
- * This class is an experiment for the job of correctly detecting browsers and settings
- * needed for them.
+ * Simple Machines Forum (SMF)
+ *
+ * @package SMF
+ * @author Simple Machines http://www.simplemachines.org
+ * @copyright 2012 Simple Machines
+ * @license http://www.simplemachines.org/about/smf/license.php BSD
+ *
+ * @version 2.1 Alpha 1
+ */
+
+if (!defined('SMF'))
+	die('Hacking attempt...');
+
+/**
+ *  This class is an experiment for the job of correctly detecting browsers and settings needed for them.
  * - Detects the following browsers
  * - Opera, Webkit, Firefox, Web_tv, Konqueror, IE, Gecko
  * - Webkit variants: Chrome, iphone, blackberry, android, safari, ipad, ipod
@@ -12,10 +25,6 @@
  * - IE Versions: 4, 5, 5.5, 6, 7, 8, 9, 10 ... mobile and Mac
  * - Nokia
  */
-
-if (!defined('SMF'))
-	die('Hacking attempt...');
-
 class browser_detector
 {
 	/**
@@ -24,6 +33,12 @@ class browser_detector
 	 * @var array
 	 */
 	private $_browsers = null;
+
+	/**
+	 * Holds if the detected device may be a mobile one
+	 *
+	 * @var type
+	 */
 	private $_is_mobile = null;
 
 	/**

+ 27 - 21
Sources/Class-CurlFetchWeb.php

@@ -1,7 +1,19 @@
 <?php
 /**
- *
  * Simple Machines Forum (SMF)
+ *
+ * @package SMF
+ * @author Simple Machines http://www.simplemachines.org
+ * @copyright 2012 Simple Machines
+ * @license http://www.simplemachines.org/about/smf/license.php BSD
+ *
+ * @version 2.1 Alpha 1
+ */
+
+if (!defined('SMF'))
+	die('Hacking attempt...');
+
+/**
  * Simple cURL class to fetch a web page
  * Properly redirects even with safe mode and basedir restrictions
  * Can provide simple post options to a page
@@ -23,20 +35,14 @@
  *  - $fetch_data->result(); // an array of results, body, header, http result codes
  *  - $fetch_data->result_raw(); // show all results of all calls (in the event of a redirect)
  *  - $fetch_data->result_raw(0); // show all results of call x
- *
- * @package SMF
- * @author Simple Machines http://www.simplemachines.org
- * @copyright 2012 Simple Machines
- * @license http://www.simplemachines.org/about/smf/license.php BSD
- *
- * @version 2.1 Alpha 1
  */
-
-if (!defined('SMF'))
-	die('Hacking attempt...');
-
 class curl_fetch_web_data
 {
+	/**
+	 * Set the default itmes for this class
+	 *
+	 * @var type
+	 */
 	private $default_options = array(
 		CURLOPT_RETURNTRANSFER	=> 1, // Get returned value as a string (don't output it)
 		CURLOPT_HEADER			=> 1, // We need the headers to do our own redirect
@@ -55,8 +61,8 @@ class curl_fetch_web_data
 	* Start the curl object
 	* - allow for user override values
 	*
-	* @param type $options, cURL options as an array
-	* @param type $max_redirect, use to overide the default of 3
+	* @param type $options cURL options as an array
+	* @param type $max_redirect use to overide the default of 3
 	*/
 	public function __construct($options = array(), $max_redirect = 3)
 	{
@@ -72,8 +78,8 @@ class curl_fetch_web_data
 	*  - passed arrays will be converted to a post string joined with &'s
 	*  - calls set_options to set the curl opts array values based on the defaults and user input
 	*
-	* @param type $url, the site we are going to fetch
-	* @param type $post_data, any post data as form name => value
+	* @param type $url the site we are going to fetch
+	* @param type $post_data any post data as form name => value
 	*/
 	public function get_url_data($url, $post_data = array())
 	{
@@ -95,8 +101,8 @@ class curl_fetch_web_data
 	*  - stores responses (url, code, error, headers, body) in the response array
 	*  - detects 301, 302, 307 codes and will redirect to the given response header location
 	*
-	* @param type $url, site to fetch
-	* @param type $redirect, flag to indicate if this was a redirect request or not
+	* @param type $url site to fetch
+	* @param type $redirect flag to indicate if this was a redirect request or not
 	* @return boolean
 	*/
 	private function curl_request($url, $redirect = false)
@@ -151,8 +157,8 @@ class curl_fetch_web_data
 	/**
 	* Used if being redirected to ensure we have a fully qualified address
 	*
-	* @param type $last_url, where we went to
-	* @param type $new_url, where we were redirected to
+	* @param type $last_url where we went to
+	* @param type $new_url where we were redirected to
 	* @return new url location
 	*/
 	private function get_redirect_url($last_url = '', $new_url = '')
@@ -176,7 +182,7 @@ class curl_fetch_web_data
 	*  - called as ->result() will return the full final array
 	*  - called as ->result('body') to just return the page source of the result
 	*
-	* @param type $area, used to return an area such as body, header, error
+	* @param type $area used to return an area such as body, header, error
 	* @return type
 	*/
 	public function result($area = '')

+ 145 - 12
Sources/Class-Package.php

@@ -21,19 +21,33 @@ if (!defined('SMF'))
  */
 class xmlArray
 {
-	// The array and debugging output level.
-	public $array, $debug_level, $trim;
+	/**
+	 * holds xml parsed results
+	 * @var array
+	 */
+	public $array;
+
+	/**
+	 * holds debugging level
+	 * @var type
+	 */
+	public $debug_level;
+
+	/**
+	 * holds trim level textual data
+	 * @var bool
+	 */
+	public $trim;
 
 	/**
 	 * Constructor for the xml parser.
 	 * Example use:
 	 *  $xml = new xmlArray(file('data.xml'));
+	 *
 	 * @param string $data the xml data or an array of, unless is_clone is true.
-	 * @param bool $auto_trim, default false, used to automatically trim textual data.
-	 * @param int $level, default null, the debug level, specifies whether notices
-	 *  should be generated for missing elements and attributes.
-	 * @param bool $is_clone, default false. If is_clone is true, the
-	 *  xmlArray is cloned from another - used internally only.
+	 * @param bool $auto_trim default false, used to automatically trim textual data.
+	 * @param int $level default null, the debug level, specifies whether notices should be generated for missing elements and attributes.
+	 * @param bool $is_clone default false. If is_clone is true, the  xmlArray is cloned from another - used internally only.
 	 */
 	public function __construct($data, $auto_trim = false, $level = null, $is_clone = false)
 	{
@@ -179,8 +193,9 @@ class xmlArray
 	 * Check if an element exists.
 	 * Example use,
 	 *  echo $xml->exists('html/body') ? 'y' : 'n';
+	 *
 	 * @param string $path - the path to the element to get.
-	 * @return bool
+	 * @return boolean
 	 */
 	public function exists($path)
 	{
@@ -298,7 +313,8 @@ class xmlArray
 	 * Output the xml in an array form.
 	 * Example use:
 	 *  print_r($xml->to_array());
-	 * @param string $path, the path to output.
+	 *
+	 * @param string $path the path to output.
 	 */
 	public function to_array($path = null)
 	{
@@ -322,6 +338,7 @@ class xmlArray
 
 	/**
 	 * Parse data into an array. (privately used...)
+	 *
 	 * @param string $data to parse
 	 */
 	protected function _parse($data)
@@ -469,6 +486,7 @@ class xmlArray
 
 	/**
 	 * Get a specific element's xml. (privately used...)
+	 *
 	 * @param $array
 	 * @param $indent
 	 */
@@ -519,7 +537,12 @@ class xmlArray
 		return $output;
 	}
 
-	// Return an element as an array...
+	/**
+	 * Return an element as an array
+	 *
+	 * @param type $array
+	 * @return type
+	 */
 	protected function _array($array)
 	{
 		$return = array();
@@ -543,6 +566,7 @@ class xmlArray
 
 	/**
 	 * Parse out CDATA tags. (htmlspecialchars them...)
+	 *
 	 * @param $data
 	 */
 	function _to_cdata($data)
@@ -579,6 +603,7 @@ class xmlArray
 
 	/**
 	 * Turn the CDATAs back to normal text.
+	 *
 	 * @param $data
 	 */
 	protected function _from_cdata($data)
@@ -624,6 +649,7 @@ class xmlArray
 
 	/**
 	 * Get a specific array by path, one level down. (privately used...)
+	 *
 	 * @param array $array
 	 * @param string $path
 	 * @param int $level
@@ -686,13 +712,43 @@ class xmlArray
 
 /**
  * Simple FTP protocol implementation.
+ *
  * http://www.faqs.org/rfcs/rfc959.html
  */
 class ftp_connection
 {
-	public $connection, $error, $last_message, $pasv;
+	/**
+	 * holds the connection response
+	 * @var type
+	 */
+	public $connection;
 
-	// Create a new FTP connection...
+	/**
+	 * holds any errors
+	 * @var type
+	 */
+	public $error;
+
+	/**
+	 * holds last message from the server
+	 * @var type
+	 */
+	public $last_message;
+
+	/**
+	 * Passive connection
+	 * @var type
+	 */
+	public $pasv;
+
+	/**
+	 * Create a new FTP connection...
+	 *
+	 * @param type $ftp_server
+	 * @param type $ftp_port
+	 * @param type $ftp_user
+	 * @param type $ftp_pass
+	 */
 	public function __construct($ftp_server, $ftp_port = 21, $ftp_user = 'anonymous', $ftp_pass = '[email protected]')
 	{
 		// Initialize variables.
@@ -704,6 +760,15 @@ class ftp_connection
 			$this->connect($ftp_server, $ftp_port, $ftp_user, $ftp_pass);
 	}
 
+	/**
+	 * Connects to a server
+	 *
+	 * @param type $ftp_server
+	 * @param type $ftp_port
+	 * @param type $ftp_user
+	 * @param type $ftp_pass
+	 * @return type
+	 */
 	public function connect($ftp_server, $ftp_port = 21, $ftp_user = 'anonymous', $ftp_pass = '[email protected]')
 	{
 		if (strpos($ftp_server, 'ftp://') === 0)
@@ -746,6 +811,12 @@ class ftp_connection
 		}
 	}
 
+	/**
+	 * Changes to a directory (chdir) via the ftp connection
+	 *
+	 * @param type $ftp_path
+	 * @return boolean
+	 */
 	public function chdir($ftp_path)
 	{
 		if (!is_resource($this->connection))
@@ -765,6 +836,13 @@ class ftp_connection
 		return true;
 	}
 
+	/**
+	 * Changes a files atrributes (chmod)
+	 *
+	 * @param string $ftp_file
+	 * @param type $chmod
+	 * @return boolean
+	 */
 	public function chmod($ftp_file, $chmod)
 	{
 		if (!is_resource($this->connection))
@@ -784,6 +862,12 @@ class ftp_connection
 		return true;
 	}
 
+	/**
+	 * Deletes a file
+	 *
+	 * @param type $ftp_file
+	 * @return boolean
+	 */
 	public function unlink($ftp_file)
 	{
 		// We are actually connected, right?
@@ -807,6 +891,12 @@ class ftp_connection
 		return true;
 	}
 
+	/**
+	 * Reads the response to the command from the server
+	 *
+	 * @param type $desired
+	 * @return type
+	 */
 	public function check_response($desired)
 	{
 		// Wait for a response that isn't continued with -, but don't wait too long.
@@ -819,6 +909,11 @@ class ftp_connection
 		return is_array($desired) ? in_array(substr($this->last_message, 0, 3), $desired) : substr($this->last_message, 0, 3) == $desired;
 	}
 
+	/**
+	 * Used to create a passive connection
+	 *
+	 * @return boolean
+	 */
 	public function passive()
 	{
 		// We can't create a passive data connection without a primary one first being there.
@@ -852,6 +947,12 @@ class ftp_connection
 		return true;
 	}
 
+	/**
+	 * Creates a new file on the server
+	 *
+	 * @param type $ftp_file
+	 * @return boolean
+	 */
 	public function create_file($ftp_file)
 	{
 		// First, we have to be connected... very important.
@@ -885,6 +986,13 @@ class ftp_connection
 		return true;
 	}
 
+	/**
+	 * Generates a direcotry listing for the current directory
+	 *
+	 * @param type $ftp_path
+	 * @param type $search
+	 * @return boolean
+	 */
 	public function list_dir($ftp_path = '', $search = false)
 	{
 		// Are we even connected...?
@@ -923,6 +1031,13 @@ class ftp_connection
 		return $data;
 	}
 
+	/**
+	 * Determins the current dirctory we are in
+	 *
+	 * @param type $file
+	 * @param type $listing
+	 * @return string|boolean
+	 */
 	public function locate($file, $listing = null)
 	{
 		if ($listing === null)
@@ -963,6 +1078,12 @@ class ftp_connection
 		return false;
 	}
 
+	/**
+	 * Creates a new directory on the server
+	 *
+	 * @param type $ftp_dir
+	 * @return boolean
+	 */
 	public function create_dir($ftp_dir)
 	{
 		// We must be connected to the server to do something.
@@ -980,6 +1101,13 @@ class ftp_connection
 		return true;
 	}
 
+	/**
+	 * Detects the current path
+	 *
+	 * @param type $filesystem_path
+	 * @param type $lookup_file
+	 * @return type
+	 */
 	public function detect_path($filesystem_path, $lookup_file = null)
 	{
 		$username = '';
@@ -1025,6 +1153,11 @@ class ftp_connection
 		return array($username, $path, isset($found_path));
 	}
 
+	/**
+	 * Close the ftp connection
+	 *
+	 * @return boolean
+	 */
 	public function close()
 	{
 		// Goodbye!

+ 6 - 4
Sources/DbExtra-mysql.php

@@ -216,8 +216,9 @@ function smf_db_optimize_table($table)
 /**
  * This function lists all tables in the database.
  * The listing could be filtered according to $filter.
- * @param mixed $db, string holding the table name, or false, default false
- * @param mixed $filter, string to filter by, or false, default false
+ *
+ * @param mixed $db string holding the table name, or false, default false
+ * @param mixed $filter string to filter by, or false, default false
  * @return array, an array of table names. (strings)
  */
 function smf_db_list_tables($db = false, $filter = false)
@@ -248,9 +249,10 @@ function smf_db_list_tables($db = false, $filter = false)
 /**
  * Gets all the necessary INSERTs for the table named table_name.
  * It goes in 250 row segments.
+ *
  * @param string $tableName - the table to create the inserts for.
- * @return string, the query to insert the data back in, or an empty
- *  string if the table was empty.
+ * @param bool $new_table
+ * @return string the query to insert the data back in, or an empty string if the table was empty.
  */
 function smf_db_insert_sql($tableName, $new_table = false)
 {

+ 7 - 5
Sources/DbExtra-postgresql.php

@@ -112,9 +112,10 @@ function smf_db_optimize_table($table)
 /**
  * This function lists all tables in the database.
  * The listing could be filtered according to $filter.
- * @param mixed $db, string holding the table name, or false, default false
- * @param mixed $filter, string to filter by, or false, default false
- * @return array, an array of table names. (strings)
+ *
+ * @param mixed $db string holding the table name, or false, default false
+ * @param mixed $filter string to filter by, or false, default false
+ * @return array an array of table names. (strings)
  */
 function smf_db_list_tables($db = false, $filter = false)
 {
@@ -143,9 +144,10 @@ function smf_db_list_tables($db = false, $filter = false)
 /**
  * Gets all the necessary INSERTs for the table named table_name.
  * It goes in 250 row segments.
+ *
  * @param string $tableName - the table to create the inserts for.
- * @return string, the query to insert the data back in, or an empty
- *  string if the table was empty.
+ * @param bool new_table
+ * @return string the query to insert the data back in, or an empty string if the table was empty.
  */
 function smf_db_insert_sql($tableName, $new_table = false)
 {

+ 7 - 5
Sources/DbExtra-sqlite.php

@@ -158,9 +158,10 @@ function smf_db_optimize_table($table)
 /**
  * This function lists all tables in the database.
  * The listing could be filtered according to $filter.
- * @param mixed $db, string holding the table name, or false, default false
- * @param mixed $filter, string to filter by, or false, default false
- * @return array, an array of table names. (strings)
+ * 
+ * @param mixed $db string holding the table name, or false, default false
+ * @param mixed $filter string to filter by, or false, default false
+ * @return array an array of table names. (strings)
  */
 function smf_db_list_tables($db = false, $filter = false)
 {
@@ -190,9 +191,10 @@ function smf_db_list_tables($db = false, $filter = false)
 /**
  * Gets all the necessary INSERTs for the table named table_name.
  * It goes in 250 row segments.
+ *
  * @param string $tableName - the table to create the inserts for.
- * @return string, the query to insert the data back in, or an empty
- *  string if the table was empty.
+ * @param bool new_table
+ * @return string the query to insert the data back in, or an empty string if the table was empty.
  */
 function smf_db_insert_sql($tableName, $new_table = false)
 {

+ 40 - 23
Sources/DbPackages-mysql.php

@@ -82,12 +82,13 @@ function db_packages_init()
  *  	- 'ignore' will do nothing if the table exists. (And will return true)
  *  	- 'overwrite' will drop any existing table of the same name.
  *  	- 'error' will return false if the table already exists.
+ *
  * @param string $table_name
- * @param array $columns, in the format specified.
- * @param array $indexes, default array(), in the format specified.
- * @param array $parameters, default array()
- * @param string $if_exists, default 'ignore'
- * @param string $error, default 'fatal'
+ * @param array $columns in the format specified.
+ * @param array $indexes default array(), in the format specified.
+ * @param array $parameters default array()
+ * @param string $if_exists default 'ignore'
+ * @param string $error default 'fatal'
  */
 function smf_db_create_table($table_name, $columns, $indexes = array(), $parameters = array(), $if_exists = 'ignore', $error = 'fatal')
 {
@@ -157,9 +158,10 @@ function smf_db_create_table($table_name, $columns, $indexes = array(), $paramet
 
 /**
  * Drop a table.
+ *
  * @param string $table_name
- * @param array $parameters, default array()
- * @param string $error, default 'fatal'
+ * @param array $parameters default array()
+ * @param string $error default 'fatal'
  */
 function smf_db_drop_table($table_name, $parameters = array(), $error = 'fatal')
 {
@@ -196,11 +198,12 @@ function smf_db_drop_table($table_name, $parameters = array(), $error = 'fatal')
 
 /**
  * This function adds a column.
- * @param string $table_name, the name of the table
- * @param array $column_info, with column information
- * @param array $parameters, default array()
- * @param string $if_exists, default 'update'
- * @param string $error, default 'fatal'
+ *
+ * @param string $table_name the name of the table
+ * @param array $column_info with column information
+ * @param array $parameters default array()
+ * @param string $if_exists default 'update'
+ * @param string $error default 'fatal'
  */
 function smf_db_add_column($table_name, $column_info, $parameters = array(), $if_exists = 'update', $error = 'fatal')
 {
@@ -248,10 +251,11 @@ function smf_db_add_column($table_name, $column_info, $parameters = array(), $if
 
 /**
  * Removes a column.
+ *
  * @param string $table_name
  * @param string $column_name
- * @param array $parameters, default array()
- * @param string $error, default 'fatal'
+ * @param array $parameters default array()
+ * @param string $error default 'fatal'
  */
 function smf_db_remove_column($table_name, $column_name, $parameters = array(), $error = 'fatal')
 {
@@ -281,11 +285,12 @@ function smf_db_remove_column($table_name, $column_name, $parameters = array(),
 
 /**
  * Change a column.
+ *
  * @param string $table_name
  * @param $old_column
  * @param $column_info
- * @param array $parameters, default array()
- * @param string $error, default 'fatal'
+ * @param array $parameters default array()
+ * @param string $error default 'fatal'
  */
 function smf_db_change_column($table_name, $old_column, $column_info, $parameters = array(), $error = 'fatal')
 {
@@ -341,11 +346,12 @@ function smf_db_change_column($table_name, $old_column, $column_info, $parameter
 
 /**
  * Add an index.
+ *
  * @param string $table_name
  * @param array $index_info
- * @param array $parameters, default array()
- * @param string $if_exists, default 'update'
- * @param string $error, default 'fatal'
+ * @param array $parameters default array()
+ * @param string $if_exists default 'update'
+ * @param string $error default 'fatal'
  */
 function smf_db_add_index($table_name, $index_info, $parameters = array(), $if_exists = 'update', $error = 'fatal')
 {
@@ -413,10 +419,11 @@ function smf_db_add_index($table_name, $index_info, $parameters = array(), $if_e
 
 /**
  * Remove an index.
+ *
  * @param string $table_name
  * @param string $index_name
- * @param array$parameters, default array()
- * @param string $error, default 'fatal'
+ * @param array$parameters default array()
+ * @param string $error default 'fatal'
  */
 function smf_db_remove_index($table_name, $index_name, $parameters = array(), $error = 'fatal')
 {
@@ -464,6 +471,7 @@ function smf_db_remove_index($table_name, $index_name, $parameters = array(), $e
 
 /**
  * Get the schema formatted name for a type.
+ *
  * @param string $type_name
  * @param $type_size
  * @param $reverse
@@ -476,8 +484,9 @@ function smf_db_calculate_type($type_name, $type_size = null, $reverse = false)
 
 /**
  * Get table structure.
+ *
  * @param string $table_name
- * @param array $parameters, default array()
+ * @param array $parameters default array()
  */
 function smf_db_table_structure($table_name, $parameters = array())
 {
@@ -494,9 +503,10 @@ function smf_db_table_structure($table_name, $parameters = array())
 
 /**
  * Return column information for a table.
+ *
  * @param string $table_name
  * @param bool $detail
- * @param array $parameters, default array()
+ * @param array $parameters default array()
  * @return mixed
  */
 function smf_db_list_columns($table_name, $detail = false, $parameters = array())
@@ -561,6 +571,7 @@ function smf_db_list_columns($table_name, $detail = false, $parameters = array()
 
 /**
  * Get index information.
+ *
  * @param string $table_name
  * @param bool $detail
  * @param array $parameters
@@ -618,6 +629,12 @@ function smf_db_list_indexes($table_name, $detail = false, $parameters = array()
 	return $indexes;
 }
 
+/**
+ * Creates a query for a column
+ *
+ * @param array $column
+ * @return type
+ */
 function smf_db_create_query_column($column)
 {
 	global $smcFunc;

+ 34 - 23
Sources/DbPackages-postgresql.php

@@ -82,12 +82,13 @@ function db_packages_init()
  *  	- 'ignore' will do nothing if the table exists. (And will return true)
  *  	- 'overwrite' will drop any existing table of the same name.
  *  	- 'error' will return false if the table already exists.
+ *
  * @param string $table_name
- * @param array $columns, in the format specified.
- * @param array $indexes, default array(), in the format specified.
- * @param array $parameters, default array()
- * @param string $if_exists, default 'ignore'
- * @param string $error, default 'fatal'
+ * @param array $columns in the format specified.
+ * @param array $indexes default array(), in the format specified.
+ * @param array $parameters default array()
+ * @param string $if_exists default 'ignore'
+ * @param string $error default 'fatal'
  */
 function smf_db_create_table($table_name, $columns, $indexes = array(), $parameters = array(), $if_exists = 'ignore', $error = 'fatal')
 {
@@ -192,9 +193,10 @@ function smf_db_create_table($table_name, $columns, $indexes = array(), $paramet
 
 /**
  * Drop a table.
+ *
  * @param string $table_name
- * @param array $parameters, default array()
- * @param string $error, default 'fatal'
+ * @param array $parameters default array()
+ * @param string $error default 'fatal'
  */
 function smf_db_drop_table($table_name, $parameters = array(), $error = 'fatal')
 {
@@ -248,11 +250,12 @@ function smf_db_drop_table($table_name, $parameters = array(), $error = 'fatal')
 
 /**
  * This function adds a column.
- * @param string $table_name, the name of the table
- * @param array $column_info, with column information
- * @param array $parameters, default array()
- * @param string $if_exists, default 'update'
- * @param string $error, default 'fatal'
+ *
+ * @param string $table_name the name of the table
+ * @param array $column_info with column information
+ * @param array $parameters default array()
+ * @param string $if_exists default 'update'
+ * @param string $error default 'fatal'
  */
 function smf_db_add_column($table_name, $column_info, $parameters = array(), $if_exists = 'update', $error = 'fatal')
 {
@@ -302,10 +305,11 @@ function smf_db_add_column($table_name, $column_info, $parameters = array(), $if
 
 /**
  * Removes a column.
+ *
  * @param string $table_name
  * @param string $column_name
- * @param array $parameters, default array()
- * @param string $error, default 'fatal'
+ * @param array $parameters default array()
+ * @param string $error default 'fatal'
  */
 function smf_db_remove_column($table_name, $column_name, $parameters = array(), $error = 'fatal')
 {
@@ -344,11 +348,12 @@ function smf_db_remove_column($table_name, $column_name, $parameters = array(),
 
 /**
  * Change a column.
+ *
  * @param string $table_name
  * @param $old_column
  * @param $column_info
- * @param array $parameters, default array()
- * @param string $error, default 'fatal'
+ * @param array $parameters default array()
+ * @param string $error default 'fatal'
  */
 function smf_db_change_column($table_name, $old_column, $column_info, $parameters = array(), $error = 'fatal')
 {
@@ -500,11 +505,12 @@ function smf_db_change_column($table_name, $old_column, $column_info, $parameter
 
 /**
  * Add an index.
+ *
  * @param string $table_name
  * @param array $index_info
- * @param array $parameters, default array()
- * @param string $if_exists, default 'update'
- * @param string $error, default 'fatal'
+ * @param array $parameters default array()
+ * @param string $if_exists default 'update'
+ * @param string $error default 'fatal'
  */
 function smf_db_add_index($table_name, $index_info, $parameters = array(), $if_exists = 'update', $error = 'fatal')
 {
@@ -571,10 +577,11 @@ function smf_db_add_index($table_name, $index_info, $parameters = array(), $if_e
 
 /**
  * Remove an index.
+ *
  * @param string $table_name
  * @param string $index_name
- * @param array$parameters, default array()
- * @param string $error, default 'fatal'
+ * @param array$parameters default array()
+ * @param string $error default 'fatal'
  */
 function smf_db_remove_index($table_name, $index_name, $parameters = array(), $error = 'fatal')
 {
@@ -623,6 +630,7 @@ function smf_db_remove_index($table_name, $index_name, $parameters = array(), $e
 
 /**
  * Get the schema formatted name for a type.
+ *
  * @param string $type_name
  * @param $type_size
  * @param $reverse
@@ -669,8 +677,9 @@ function smf_db_calculate_type($type_name, $type_size = null, $reverse = false)
 
 /**
  * Get table structure.
+ *
  * @param string $table_name
- * @param array $parameters, default array()
+ * @param array $parameters default array()
  */
 function smf_db_table_structure($table_name, $parameters = array())
 {
@@ -687,9 +696,10 @@ function smf_db_table_structure($table_name, $parameters = array())
 
 /**
  * Return column information for a table.
+ *
  * @param string $table_name
  * @param bool $detail
- * @param array $parameters, default array()
+ * @param array $parameters default array()
  * @return mixed
  */
 function smf_db_list_columns($table_name, $detail = false, $parameters = array())
@@ -748,6 +758,7 @@ function smf_db_list_columns($table_name, $detail = false, $parameters = array()
 
 /**
  * Get index information.
+ *
  * @param string $table_name
  * @param bool $detail
  * @param array $parameters

+ 36 - 23
Sources/DbPackages-sqlite.php

@@ -83,12 +83,13 @@ function db_packages_init()
  *  	- 'ignore' will do nothing if the table exists. (And will return true)
  *  	- 'overwrite' will drop any existing table of the same name.
  *  	- 'error' will return false if the table already exists.
+ *
  * @param string $table_name
- * @param array $columns, in the format specified.
- * @param array $indexes, default array(), in the format specified.
- * @param array $parameters, default array()
- * @param string $if_exists, default 'ignore'
- * @param string $error, default 'fatal'
+ * @param array $columns in the format specified.
+ * @param array $indexes default array(), in the format specified.
+ * @param array $parameters default array()
+ * @param string $if_exists default 'ignore'
+ * @param string $error default 'fatal'
  */
 function smf_db_create_table($table_name, $columns, $indexes = array(), $parameters = array(), $if_exists = 'ignore', $error = 'fatal')
 {
@@ -196,9 +197,11 @@ function smf_db_create_table($table_name, $columns, $indexes = array(), $paramet
 
 /**
  * Drop a table.
+ *
  * @param string $table_name
- * @param array $parameters, default array()
- * @param string $error, default 'fatal'
+ * @param array $parameters default array()
+ * @param bool $error
+ * @param string $error default 'fatal'
  */
 function smf_db_drop_table($table_name, $parameters = array(), $error = 'fatal')
 {
@@ -232,11 +235,12 @@ function smf_db_drop_table($table_name, $parameters = array(), $error = 'fatal')
 
 /**
  * This function adds a column.
- * @param string $table_name, the name of the table
- * @param array $column_info, with column information
- * @param array $parameters, default array()
- * @param string $if_exists, default 'update'
- * @param string $error, default 'fatal'
+ *
+ * @param string $table_name the name of the table
+ * @param array $column_info with column information
+ * @param array $parameters default array()
+ * @param string $if_exists default 'update'
+ * @param string $error default 'fatal'
  */
 function smf_db_add_column($table_name, $column_info, $parameters = array(), $if_exists = 'update', $error = 'fatal')
 {
@@ -268,11 +272,12 @@ function smf_db_add_column($table_name, $column_info, $parameters = array(), $if
 
 /**
  * Removes a column.
+ *
  * We can't reliably do this on SQLite - damn!
  * @param string $table_name
  * @param string $column_name
- * @param array $parameters, default array()
- * @param string $error, default 'fatal'
+ * @param array $parameters default array()
+ * @param string $error default 'fatal'
  */
 function smf_db_remove_column($table_name, $column_name, $parameters = array(), $error = 'fatal')
 {
@@ -288,11 +293,12 @@ function smf_db_remove_column($table_name, $column_name, $parameters = array(),
 
 /**
  * Change a column.
+ *
  * @param string $table_name
  * @param $old_column
  * @param $column_info
- * @param array $parameters, default array()
- * @param string $error, default 'fatal'
+ * @param array $parameters default array()
+ * @param string $error default 'fatal'
  */
 function smf_db_change_column($table_name, $old_column, $column_info, $parameters = array(), $error = 'fatal')
 {
@@ -308,11 +314,12 @@ function smf_db_change_column($table_name, $old_column, $column_info, $parameter
 
 /**
  * Add an index.
+ *
  * @param string $table_name
  * @param array $index_info
- * @param array $parameters, default array()
- * @param string $if_exists, default 'update'
- * @param string $error, default 'fatal'
+ * @param array $parameters default array()
+ * @param string $if_exists default 'update'
+ * @param string $error default 'fatal'
  */
 function smf_db_add_index($table_name, $index_info, $parameters = array(), $if_exists = 'update', $error = 'fatal')
 {
@@ -373,10 +380,11 @@ function smf_db_add_index($table_name, $index_info, $parameters = array(), $if_e
 
 /**
  * Remove an index.
+ *
  * @param string $table_name
  * @param string $index_name
- * @param array$parameters, default array()
- * @param string $error, default 'fatal'
+ * @param array$parameters default array()
+ * @param string $error default 'fatal'
  */
 function smf_db_remove_index($table_name, $index_name, $parameters = array(), $error = 'fatal')
 {
@@ -410,6 +418,7 @@ function smf_db_remove_index($table_name, $index_name, $parameters = array(), $e
 
 /**
  * Get the schema formatted name for a type.
+ *
  * @param string $type_name
  * @param $type_size
  * @param $reverse
@@ -451,8 +460,9 @@ function smf_db_calculate_type($type_name, $type_size = null, $reverse = false)
 
 /**
  * Get table structure.
+ *
  * @param string $table_name
- * @param array $parameters, default array()
+ * @param array $parameters default array()
  */
 function smf_db_table_structure($table_name, $parameters = array())
 {
@@ -470,9 +480,10 @@ function smf_db_table_structure($table_name, $parameters = array())
 /**
  * Return column information for a table.
  * Harder than it should be, on sqlite!
+ *
  * @param string $table_name
  * @param bool $detail
- * @param array $parameters, default array()
+ * @param array $parameters default array()
  * @return mixed
  */
 function smf_db_list_columns($table_name, $detail = false, $parameters = array())
@@ -535,6 +546,7 @@ function smf_db_list_columns($table_name, $detail = false, $parameters = array()
 
 /**
  * Get index information.
+ *
  * @param string $table_name
  * @param bool $detail
  * @param array $parameters
@@ -596,6 +608,7 @@ function smf_db_list_indexes($table_name, $detail = false, $parameters = array()
 
 /**
  * Alter table on SQLite.
+ *
  * @param string $table_name
  * @param array $columns
  */

+ 1 - 1
Sources/DbSearch-postgresql.php

@@ -49,7 +49,7 @@ function smf_db_search_support($search_type)
  *
  * @param string $identifier
  * @param string $db_string
- * @param array $db_values, default array()
+ * @param array $db_values default array()
  * @param resource $connection
  */
 function smf_db_search_query($identifier, $db_string, $db_values = array(), $connection = null)

+ 1 - 1
Sources/DbSearch-sqlite.php

@@ -49,7 +49,7 @@ function smf_db_search_support($search_type)
  *
  * @param string $identifier
  * @param string $db_string
- * @param array $db_values, default array()
+ * @param array $db_values default array()
  * @param resource $connection
  */
 function smf_db_search_query($identifier, $db_string, $db_values = array(), $connection = null)

+ 14 - 22
Sources/Display.php

@@ -1100,7 +1100,7 @@ function Display()
 		checkSubmitOnce('register');
 		$context['name'] = isset($_SESSION['guest_name']) ? $_SESSION['guest_name'] : '';
 		$context['email'] = isset($_SESSION['guest_email']) ? $_SESSION['guest_email'] : '';
-		if ($options['display_quick_reply'] == 3 && $context['can_reply'])
+		if (!empty($options['use_editor_quick_reply']) && $context['can_reply'])
 		{
 			// Needed for the editor and message icons.
 			require_once($sourcedir . '/Subs-Editor.php');
@@ -1167,7 +1167,8 @@ function Display()
  * It actually gets and prepares the message context.
  * This function will start over from the beginning if reset is set to true, which is
  * useful for showing an index before or after the posts.
- * @param bool $reset, default false.
+ *
+ * @param bool $reset default false.
  */
 function prepareDisplayContext($reset = false)
 {
@@ -1450,29 +1451,17 @@ function Download()
 
 	// Convert the file to UTF-8, cuz most browsers dig that.
 	$utf8name = !$context['utf8'] && function_exists('iconv') ? iconv($context['character_set'], 'UTF-8', $real_filename) : (!$context['utf8'] && function_exists('mb_convert_encoding') ? mb_convert_encoding($real_filename, 'UTF-8', $context['character_set']) : $real_filename);
-	$fixchar = create_function('$n', '
-		if ($n < 32)
-			return \'\';
-		elseif ($n < 128)
-			return chr($n);
-		elseif ($n < 2048)
-			return chr(192 | $n >> 6) . chr(128 | $n & 63);
-		elseif ($n < 65536)
-			return chr(224 | $n >> 12) . chr(128 | $n >> 6 & 63) . chr(128 | $n & 63);
-		else
-			return chr(240 | $n >> 18) . chr(128 | $n >> 12 & 63) . chr(128 | $n >> 6 & 63) . chr(128 | $n & 63);');
-
 	$disposition = !isset($_REQUEST['image']) ? 'attachment' : 'inline';
 
 	// Different browsers like different standards...
 	if (isBrowser('firefox'))
-		header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace('~&#(\d{3,8});~e', '$fixchar(\'$1\')', $utf8name)));
+		header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)));
 
 	elseif (isBrowser('opera'))
-		header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace('~&#(\d{3,8});~e', '$fixchar(\'$1\')', $utf8name) . '"');
+		header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"');
 
 	elseif (isBrowser('ie'))
-		header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace('~&#(\d{3,8});~e', '$fixchar(\'$1\')', $utf8name)) . '"');
+		header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"');
 
 	else
 		header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"');
@@ -1526,11 +1515,14 @@ function Download()
 
 /**
  * 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.
- *  It attempts to keep the "aspect ratio" of the posted image in line, even if it has to be resized by
- *  the max_image_width and max_image_height settings.
+ * 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.
+ * It attempts to keep the "aspect ratio" of the posted image in line, even if it has to be resized by
+ * the max_image_width and max_image_height settings.
+ *
+ * @param type $id_msg message number to load attachments for
+ * @return array of attachemnts
  */
 function loadAttachmentContext($id_msg)
 {

+ 52 - 21
Sources/Drafts.php

@@ -23,7 +23,9 @@ loadLanguage('Drafts');
  * Saves a post draft in the user_drafts table
  * The core draft feature must be enabled, as well as the post draft option
  * Determines if this is a new or an existing draft
+ * Returns errors in $post_errors for display in the template
  *
+ * @param string $post_errors
  * @return boolean
  */
 function SaveDraft(&$post_errors)
@@ -38,6 +40,18 @@ function SaveDraft(&$post_errors)
 	$id_draft = (int) $_POST['id_draft'];
 	$draft_info = ReadDraft($id_draft);
 
+	// A draft has been saved less than 5 seconds ago, let's not do the autosave again
+	if (isset($_REQUEST['xml']) && !empty($draft_info['poster_time']) && time() < $draft_info['poster_time'] + 5)
+	{
+		$context['draft_saved_on'] = $draft_info['poster_time'];
+
+		// since we were called from the autosave function, send something back
+		if (!empty($id_draft))
+			XmlDraft($id_draft);
+
+		return true;
+	}
+
 	// prepare any data from the form
 	$topic_id = empty($_REQUEST['topic']) ? 0 : (int) $_REQUEST['topic'];
 	$draft['icon'] = empty($_POST['icon']) ? 'xx' : preg_replace('~[\./\\\\*:"\'<>]~', '', $_POST['icon']);
@@ -143,15 +157,18 @@ function SaveDraft(&$post_errors)
 
 	// if we were called from the autosave function, send something back
 	if (!empty($id_draft) && isset($_REQUEST['xml']) && (!in_array('session_timeout', $post_errors)))
+	{
+		$context['draft_saved_on'] = time();
 		XmlDraft($id_draft);
+	}
 
 	return true;
 }
 
 /**
  * Saves a PM draft in the user_drafts table
- * The core draft feature must be enable, as well as the pm draft option
- * Determines if this is a new or and update to an existing draft
+ * The core draft feature must be enabled, as well as the pm draft option
+ * Determines if this is a new or and update to an existing pm draft
  *
  * @global type $context
  * @global type $user_info
@@ -173,6 +190,18 @@ function SavePMDraft(&$post_errors, $recipientList)
 	$id_pm_draft = (int) $_POST['id_pm_draft'];
 	$draft_info = ReadDraft($id_pm_draft, 1);
 
+	// 5 seconds is the same limit we have for posting
+	if (isset($_REQUEST['xml']) && !empty($draft_info['poster_time']) && time() < $draft_info['poster_time'] + 5)
+	{
+		$context['draft_saved_on'] = $draft_info['poster_time'];
+
+		// Send something back to the javascript caller
+		if (!empty($id_draft))
+			XmlDraft($id_draft);
+
+		return true;
+	}
+
 	// determine who this is being sent to
 	if (isset($_REQUEST['xml']))
 	{
@@ -188,7 +217,7 @@ function SavePMDraft(&$post_errors, $recipientList)
 	$draft['body'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES);
 	$draft['subject'] = strtr($smcFunc['htmlspecialchars']($_POST['subject']), array("\r" => '', "\n" => '', "\t" => ''));
 
-	// message and subject still need a bit more massaging
+	// message and subject always need a bit more work
 	preparsecode($draft['body']);
 	if ($smcFunc['strlen']($draft['subject']) > 100)
 		$draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100);
@@ -210,8 +239,8 @@ function SavePMDraft(&$post_errors, $recipientList)
 			array(
 				'id_reply' => $reply_id,
 				'type' => 1,
-				'poster_time' =>  time(),
-				'subject' =>  $draft['subject'],
+				'poster_time' => time(),
+				'subject' => $draft['subject'],
 				'body' => $draft['body'],
 				'id_pm_draft' => $id_pm_draft,
 				'to_list' => serialize($recipientList),
@@ -256,7 +285,7 @@ function SavePMDraft(&$post_errors, $recipientList)
 		// get the new id
 		$id_pm_draft = $smcFunc['db_insert_id']('{db_prefix}user_drafts', 'id_draft');
 
-		// everything go as expected, if not toss an error
+		// everything go as expected, if not toss back an error
 		if (!empty($id_pm_draft))
 		{
 			$context['draft_saved'] = true;
@@ -268,7 +297,10 @@ function SavePMDraft(&$post_errors, $recipientList)
 
 	// if we were called from the autosave function, send something back
 	if (!empty($id_pm_draft) && isset($_REQUEST['xml']) && !in_array('session_timeout', $post_errors))
+	{
+		$context['draft_saved_on'] = time();
 		XmlDraft($id_pm_draft);
+	}
 
 	return;
 }
@@ -289,7 +321,7 @@ function ReadDraft($id_draft, $type = 0, $check = true, $load = false)
 {
 	global $context, $user_info, $smcFunc, $modSettings;
 
-	// always clean to be sure
+	// like purell always clean to be sure
 	$id_draft = (int) $id_draft;
 	$type = (int) $type;
 
@@ -471,7 +503,7 @@ function XmlDraft($id_draft)
 
 	echo '<?xml version="1.0" encoding="', $context['character_set'], '"?>
 	<drafts>
-		<draft id="', $id_draft, '"><![CDATA[', $txt['draft_saved_on'], ': ', timeformat(time()), ']]></draft>
+		<draft id="', $id_draft, '"><![CDATA[', $txt['draft_saved_on'], ': ', timeformat($context['draft_saved_on']), ']]></draft>
 	</drafts>';
 
 	obExit(false);
@@ -517,7 +549,7 @@ function showProfileDrafts($memID, $draft_type = 0)
 
 	// Default to 10.
 	if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount']))
-		$_REQUEST['viewscount'] = '10';
+		$_REQUEST['viewscount'] = 10;
 
 	// Get the count of applicable drafts on the boards they can (still) see ...
 	// @todo .. should we just let them see their drafts even if they have lost board access ?
@@ -616,7 +648,7 @@ function showProfileDrafts($memID, $draft_type = 0)
 	}
 	$smcFunc['db_free_result']($request);
 
-	// All drafts were retrieved in reverse order, get them right again.
+	// If the drafts were retrieved in reverse order, get them right again.
 	if ($reverse)
 		$context['drafts'] = array_reverse($context['drafts'], true);
 
@@ -629,7 +661,6 @@ function showProfileDrafts($memID, $draft_type = 0)
  * Allows for the deleting and loading/editing of drafts
  *
  * @param type $memID
- * @param type $draft_type
  */
 function showPMDrafts($memID = -1)
 {
@@ -672,12 +703,12 @@ function showPMDrafts($memID = -1)
 
 	// Default to 10.
 	if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount']))
-		$_REQUEST['viewscount'] = '10';
+		$_REQUEST['viewscount'] = 10;
 
 	// Get the count of applicable drafts
 	$request = $smcFunc['db_query']('', '
 		SELECT COUNT(id_draft)
-		FROM {db_prefix}user_drafts AS ud
+		FROM {db_prefix}user_drafts
 		WHERE id_member = {int:id_member}
 			AND type={int:draft_type}' . (!empty($modSettings['drafts_keep_days']) ? '
 			AND poster_time > {int:time}' : ''),
@@ -817,14 +848,14 @@ function ModifyDraftSettings($return_config = false)
 
 	// Here are all the draft settings, a bit lite for now, but we can add more :P
 	$config_vars = array(
-			// Draft settings ...
-			array('check', 'drafts_post_enabled'),
-			array('check', 'drafts_pm_enabled'),
-			array('check', 'drafts_show_saved_enabled', 'subtext' => $txt['drafts_show_saved_enabled_subnote']),
-			array('int', 'drafts_keep_days', 'postinput' => $txt['days_word'], 'subtext' => $txt['drafts_keep_days_subnote']),
-			'',
-			array('check', 'drafts_autosave_enabled', 'subtext' => $txt['drafts_autosave_enabled_subnote']),
-			array('int', 'drafts_autosave_frequency', 'postinput' => $txt['manageposts_seconds'], 'subtext' => $txt['drafts_autosave_frequency_subnote']),
+		// Draft settings ...
+		array('check', 'drafts_post_enabled'),
+		array('check', 'drafts_pm_enabled'),
+		array('check', 'drafts_show_saved_enabled', 'subtext' => $txt['drafts_show_saved_enabled_subnote']),
+		array('int', 'drafts_keep_days', 'postinput' => $txt['days_word'], 'subtext' => $txt['drafts_keep_days_subnote']),
+		'',
+		array('check', 'drafts_autosave_enabled', 'subtext' => $txt['drafts_autosave_enabled_subnote']),
+		array('int', 'drafts_autosave_frequency', 'postinput' => $txt['manageposts_seconds'], 'subtext' => $txt['drafts_autosave_frequency_subnote']),
 	);
 
 	if ($return_config)

+ 4 - 2
Sources/Errors.php

@@ -23,6 +23,7 @@ if (!defined('SMF'))
  * filename and line should be __FILE__ and __LINE__, respectively.
  * Example use:
  *  die(log_error($msg));
+ *
  * @param string $error_message
  * @param string $error_type = 'general'
  * @param string $file = null
@@ -257,9 +258,10 @@ function error_handler($error_level, $error_string, $file, $line)
 
 /**
  * It is called by fatal_error() and fatal_lang_error().
- * @uses Errors template, fatal_error sub template, or Wireless template,
- * error sub template.
+ * @uses Errors template, fatal_error sub template, or Wireless template, error sub template.
+ * 
  * @param string $error_message
+ * @param type $error_code
  */
 function setup_fatal_error_context($error_message, $error_code)
 {

+ 5 - 4
Sources/Groups.php

@@ -790,7 +790,7 @@ function GroupRequests()
 			'date' => array(
 				'header' => array(
 					'value' => $txt['date'],
-					'style' => 'width: 18%;white-space:nowrap;',
+					'style' => 'width: 18%; white-space:nowrap;',
 				),
 				'data' => array(
 					'db' => 'time_submitted',
@@ -800,6 +800,7 @@ function GroupRequests()
 				'header' => array(
 					'value' => '<input type="checkbox" class="input_check" onclick="invertAll(this, this.form);" />',
 					'style' => 'width: 4%;',
+					'class' => 'centercol',
 				),
 				'data' => array(
 					'sprintf' => array(
@@ -808,7 +809,7 @@ function GroupRequests()
 							'id' => false,
 						),
 					),
-					'style' => 'text-align: center;',
+					'class' => 'centercol',
 				),
 			),
 		),
@@ -832,8 +833,8 @@ function GroupRequests()
 						<option value="reject">' . $txt['mc_groupr_reject'] . '</option>
 						<option value="reason">' . $txt['mc_groupr_reject_w_reason'] . '</option>
 					</select>
-					<input type="submit" name="go" value="' . $txt['go'] . '" onclick="var sel = document.getElementById(\'req_action\'); if (sel.value != 0 &amp;&amp; sel.value != \'reason\' &amp;&amp; !confirm(\'' . $txt['mc_groupr_warning'] . '\')) return false;" class="button_submit" style="float: none"/>',
-				'align' => 'right',
+					<input type="submit" name="go" value="' . $txt['go'] . '" onclick="var sel = document.getElementById(\'req_action\'); if (sel.value != 0 &amp;&amp; sel.value != \'reason\' &amp;&amp; !confirm(\'' . $txt['mc_groupr_warning'] . '\')) return false;" class="button_submit" />',
+				'class' => 'floatright',
 			),
 		),
 	);

+ 4 - 2
Sources/Karma.php

@@ -151,7 +151,9 @@ function ModifyKarma()
 	}
 }
 
-//  What's this?  I dunno, what are you talking about?  Never seen this before, nope.  No sir.
+/**
+ * What's this?  I dunno, what are you talking about?  Never seen this before, nope.  No sir.
+ */
 function BookOfUnknown()
 {
 	global $context;
@@ -159,7 +161,7 @@ function BookOfUnknown()
 	if (strpos($_GET['action'], 'mozilla') !== false && !isBrowser('gecko'))
 		redirectexit('http://www.getfirefox.com/');
 	elseif (strpos($_GET['action'], 'mozilla') !== false)
-		redirectexit('about:mozilla');
+		redirectexit('about:mozilla', true);
 
 	echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml"', $context['right_to_left'] ? ' dir="rtl"' : '', '>

+ 6 - 6
Sources/Load.php

@@ -63,21 +63,21 @@ function reloadSettings()
 			cache_put_data('modSettings', $modSettings, 90);
 	}
 
-	// UTF-8 in regular expressions is unsupported on PHP(win) versions < 4.2.3.
+	// UTF-8 ?
 	$utf8 = (empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']) === 'UTF-8';
 
 	// Set a list of common functions.
 	$ent_list = empty($modSettings['disableEntityCheck']) ? '&(#\d{1,7}|quot|amp|lt|gt|nbsp);' : '&(#021|quot|amp|lt|gt|nbsp);';
-	$ent_check = empty($modSettings['disableEntityCheck']) ? array('preg_replace(\'~(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)~e\', \'$smcFunc[\\\'entity_fix\\\'](\\\'\\2\\\')\', ', ')') : array('', '');
+	$ent_check = empty($modSettings['disableEntityCheck']) ? array('preg_replace_callback(\'~(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)~\', \'entity_fix__callback\', ', ')') : array('', '');
 
-	// Preg_replace can handle complex characters only for higher PHP versions.
+	// Preg_replace space characters depend on the character set in use
 	$space_chars = $utf8 ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0';
 
 	// global array of anonymous helper functions, used mosly to properly handle multi byte strings
 	$smcFunc += array(
 		'entity_fix' => create_function('$string', '
 			$num = $string[0] === \'x\' ? hexdec(substr($string, 1)) : (int) $string;
-			return $num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202E ? \'\' : \'&#\' . $num . \';\';'),
+			return $num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202E || $num === 0x202D ? \'\' : \'&#\' . $num . \';\';'),
 		'htmlspecialchars' => create_function('$string, $quote_style = ENT_COMPAT, $charset = \'ISO-8859-1\'', '
 			global $smcFunc;
 			return ' . strtr($ent_check[0], array('&' => '&amp;')) . 'htmlspecialchars($string, $quote_style, ' . ($utf8 ? '\'UTF-8\'' : '$charset') . ')' . $ent_check[1] . ';'),
@@ -1038,7 +1038,7 @@ function loadMemberData($users, $is_name = false, $set = 'normal')
  *
  * @param int $user
  * @param bool $display_custom_fields = false
- * @return bool
+ * @return boolean
  */
 function loadMemberContext($user, $display_custom_fields = false)
 {
@@ -1786,7 +1786,7 @@ function loadTheme($id_theme = 0, $initialize = true)
  * @param string $template_name
  * @param array $style_sheets = array()
  * @param bool $fatal = true if fatal is true, dies with an error message if the template cannot be found
- * @return bool
+ * @return boolean
  */
 function loadTemplate($template_name, $style_sheets = array(), $fatal = true)
 {

+ 1 - 1
Sources/LogInOut.php

@@ -571,7 +571,7 @@ function DoLogin()
  * It redirects back to $_SESSION['logout_url'], if it exists.
  * It is accessed via ?action=logout;session_var=...
  *
- * @param bool $internal, if true, it doesn't check the session
+ * @param bool $internal if true, it doesn't check the session
  * @param $redirect
  */
 function Logout($internal = false, $redirect = true)

+ 3 - 2
Sources/Logging.php

@@ -329,7 +329,7 @@ function displayDebug()
  * It depends on the trackStats setting.
  *
  * @param array $stats = array()
- * @return bool|array
+ * @return boolean|array
  */
 function trackStats($stats = array())
 {
@@ -389,9 +389,10 @@ function trackStats($stats = array())
  * @example logAction('remove', array('starter' => $id_member_started));
  *
  * @deprecated deprecated since version 2.1
+ *
  * @param string $action
  * @param array $extra = array()
- * @param string $log_type, options 'moderate', 'admin', ...etc.
+ * @param string $log_type options: 'moderate', 'admin', ...etc.
  */
 function logAction($action, $extra = array(), $log_type = 'moderate')
 {

+ 422 - 58
Sources/ManageAttachments.php

@@ -50,7 +50,8 @@ function ManageAttachments()
 		'moveAvatars' => 'MoveAvatars',
 		'repair' => 'RepairAttachments',
 		'remove' => 'RemoveAttachment',
-		'removeall' => 'RemoveAllAttachments'
+		'removeall' => 'RemoveAllAttachments',
+		'transfer' => 'TransferAttachments',
 	);
 
 	call_integration_hook('integrate_manage_attachments', array(&$subActions));
@@ -94,10 +95,14 @@ function ManageAttachmentSettings($return_config = false)
 	$modSettings['attachmentUploadDir'] = unserialize($modSettings['attachmentUploadDir']);
 	$context['attachmentUploadDir'] = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']];
 
+	// First time here?
+	if (empty($modSettings['attachment_basedirectories']) && $modSettings['currentAttachmentUploadDir'] == 1 && count($modSettings['attachmentUploadDir']) == 1)
+		$modSettings['attachmentUploadDir'] = $modSettings['attachmentUploadDir'][1];
+
 	// If not set, show a default path for the base directory
 	if (!isset($_GET['save']) && empty($modSettings['basedirectory_for_attachments']))
-		if (!empty($modSettings['currentAttachmentUploadDir']))
-			$modSettings['basedirectory_for_attachments'] = $modSettings['attachmentUploadDir'][1];
+		if (is_dir($modSettings['attachmentUploadDir'][1]))
+			$modSettings['basedirectory_for_attachments'] = $modSettings['attachmentUploadDir'][1];		
 		else
 			$modSettings['basedirectory_for_attachments'] = $context['attachmentUploadDir'];
 
@@ -138,7 +143,7 @@ function ManageAttachmentSettings($return_config = false)
 			array('select', 'automanage_attachments', array(0 => $txt['attachments_normal'], 1 => $txt['attachments_auto_space'], 2 => $txt['attachments_auto_years'], 3 => $txt['attachments_auto_months'], 4 => $txt['attachments_auto_16'])),
 			array('check', 'use_subdirectories_for_attachments', 'subtext' => $txt['use_subdirectories_for_attachments_note']),
 			(empty($modSettings['attachment_basedirectories']) ? array('text', 'basedirectory_for_attachments', 40,) : array('var_message', 'basedirectory_for_attachments', 'message' => 'basedirectory_for_attachments_path', 'invalid' => empty($context['valid_basedirectory']), 'text_label' => (!empty($context['valid_basedirectory']) ? $txt['basedirectory_for_attachments_current'] : $txt['basedirectory_for_attachments_warning']))),
-			array('var_message', 'attach_current_directory', 'subtext' => $txt['attachmentUploadDir_multiple_configure'], 'message' => 'attachment_path', 'invalid' => empty($context['valid_upload_dir']), 'text_label' => (!empty($context['valid_upload_dir']) ? $txt['attach_current_dir'] : $txt['attach_current_dir_warning'])),
+			empty($modSettings['attachment_basedirectories']) && $modSettings['currentAttachmentUploadDir'] == 1 && count($modSettings['attachmentUploadDir']) == 1	? array('text', 'attachmentUploadDir', 'subtext' => $txt['attachmentUploadDir_multiple_configure'], 40, 'invalid' => !$context['valid_upload_dir']) : array('var_message', 'attach_current_directory', 'subtext' => $txt['attachmentUploadDir_multiple_configure'], 'message' => 'attachment_path', 'invalid' => empty($context['valid_upload_dir']), 'text_label' => (!empty($context['valid_upload_dir']) ? $txt['attach_current_dir'] : $txt['attach_current_dir_warning'])),
 			array('int', 'attachmentDirFileLimit', 'subtext' => $txt['zero_for_no_limit'], 6),
 			array('int', 'attachmentDirSizeLimit', 'subtext' => $txt['zero_for_no_limit'], 6, 'postinput' => $txt['kilobyte']),
 		'',
@@ -198,6 +203,15 @@ function ManageAttachmentSettings($return_config = false)
 	{
 		checkSession();
 
+		if (isset($_POST['attachmentUploadDir']))
+		{
+			if (!empty($_POST['attachmentUploadDir']) && $modSettings['attachmentUploadDir'] != $_POST['attachmentUploadDir'])
+				rename($modSettings['attachmentUploadDir'], $_POST['attachmentUploadDir']);
+
+			$modSettings['attachmentUploadDir'] = array(1 => $_POST['attachmentUploadDir']);
+			$_POST['attachmentUploadDir'] = serialize($modSettings['attachmentUploadDir']);
+		}
+
 		if (!empty($_POST['use_subdirectories_for_attachments']))
 		{
 			if(isset($_POST['use_subdirectories_for_attachments']) && empty($_POST['basedirectory_for_attachments']))
@@ -216,8 +230,10 @@ function ManageAttachmentSettings($return_config = false)
 				$currentAttachmentUploadDir = $modSettings['currentAttachmentUploadDir'];
 
 				if (!in_array($_POST['basedirectory_for_attachments'], $modSettings['attachmentUploadDir']))
+				{
 					if (!automanage_attachments_create_directory($_POST['basedirectory_for_attachments']))
 						$_POST['basedirectory_for_attachments'] = $modSettings['basedirectory_for_attachments'];
+				}
 
 				if (!in_array($_POST['basedirectory_for_attachments'], $modSettings['attachment_basedirectories']))
 				{
@@ -226,6 +242,10 @@ function ManageAttachmentSettings($return_config = false)
 						'attachment_basedirectories' => serialize($modSettings['attachment_basedirectories']),
 						'currentAttachmentUploadDir' => $currentAttachmentUploadDir,
 					));
+
+					$_POST['use_subdirectories_for_attachments'] = 1;
+					$_POST['attachmentUploadDir'] = serialize($modSettings['attachmentUploadDir']);	
+
 				}
 			}
 		}
@@ -496,6 +516,7 @@ function BrowseFiles()
 			'check' => array(
 				'header' => array(
 					'value' => '<input type="checkbox" onclick="invertAll(this, this.form);" class="input_check" />',
+					'class' => 'centercol',
 				),
 				'data' => array(
 					'sprintf' => array(
@@ -504,7 +525,7 @@ function BrowseFiles()
 							'id_attach' => false,
 						),
 					),
-					'style' => 'text-align: center',
+					'class' => 'centercol',
 				),
 			),
 		),
@@ -520,7 +541,6 @@ function BrowseFiles()
 			array(
 				'position' => 'below_table_data',
 				'value' => '<input type="submit" name="remove_submit" class="button_submit" value="' . $txt['quickmod_delete_selected'] . '" onclick="return confirm(\'' . $txt['confirm_delete_attachments'] . '\');" />',
-				'style' => 'text-align: right;',
 			),
 		),
 	);
@@ -537,7 +557,7 @@ function BrowseFiles()
  * @param int $start
  * @param int $items_per_page
  * @param string $sort
- * @param string $browse_type, can be 'avatars' or ... not. :P
+ * @param string $browse_type can be on eof 'avatars' or ... not. :P
  */
 function list_getFiles($start, $items_per_page, $sort, $browse_type)
 {
@@ -596,8 +616,7 @@ function list_getFiles($start, $items_per_page, $sort, $browse_type)
  * Return the number of files of the specified type recorded in the database.
  * (the specified type being attachments or avatars).
  *
- * @param string $browse_type, can be 'avatars' or not. (in which case they're
- * attachments)
+ * @param string $browse_type can be one of 'avatars' or not. (in which case they're attachments)
  */
 function list_getNumFiles($browse_type)
 {
@@ -666,6 +685,7 @@ function MaintainFiles()
 	);
 	list ($context['num_attachments']) = $smcFunc['db_fetch_row']($request);
 	$smcFunc['db_free_result']($request);
+	$context['num_attachments'] = comma_format($context['num_attachments'], 0);
 
 	// Also get the avatar amount....
 	$request = $smcFunc['db_query']('', '
@@ -678,12 +698,15 @@ function MaintainFiles()
 	);
 	list ($context['num_avatars']) = $smcFunc['db_fetch_row']($request);
 	$smcFunc['db_free_result']($request);
+	$context['num_avatars'] = comma_format($context['num_avatars'], 0);
 
 	// Check the size of all the directories.
 	$request = $smcFunc['db_query']('', '
 		SELECT SUM(size)
-		FROM {db_prefix}attachments',
+		FROM {db_prefix}attachments
+		WHERE attachment_type != {int:type}',
 		array(
+			'type' => 1,
 		)
 	);
 	list ($attachmentDirSize) = $smcFunc['db_fetch_row']($request);
@@ -691,13 +714,40 @@ function MaintainFiles()
 
 	// Divide it into kilobytes.
 	$attachmentDirSize /= 1024;
+	$context['attachment_total_size'] = comma_format($attachmentDirSize, 2);
+
+	$request = $smcFunc['db_query']('', '
+		SELECT COUNT(*), SUM(size)
+		FROM {db_prefix}attachments
+		WHERE id_folder = {int:folder_id}
+			AND attachment_type != {int:type}',
+		array(
+			'folder_id' => $modSettings['currentAttachmentUploadDir'],
+			'type' => 1,
+		)
+	);
+	list ($current_dir_files, $current_dir_size) = $smcFunc['db_fetch_row']($request);
+	$smcFunc['db_free_result']($request);
+	$current_dir_size /= 1024;
 
 	// If they specified a limit only....
 	if (!empty($modSettings['attachmentDirSizeLimit']))
-		$context['attachment_space'] = max(round($modSettings['attachmentDirSizeLimit'] - $attachmentDirSize, 2), 0);
-	$context['attachment_total_size'] = round($attachmentDirSize, 2);
-
-	$context['attach_multiple_dirs'] = !empty($modSettings['currentAttachmentUploadDir']);
+		$context['attachment_space'] = comma_format(max($modSettings['attachmentDirSizeLimit'] - $current_dir_size, 0), 2);
+	$context['attachment_current_size'] = comma_format($current_dir_size, 2);
+
+	if (!empty($modSettings['attachmentDirFileLimit']))
+		$context['attachment_files'] = comma_format(max($modSettings['attachmentDirFileLimit'] - $current_dir_files, 0), 0);
+	$context['attachment_current_files'] = comma_format($current_dir_files, 0);
+	
+	$context['attach_multiple_dirs'] = count($attach_dirs) > 1 ? true : false;
+	$context['attach_dirs'] = $attach_dirs;
+	$context['base_dirs'] = !empty($modSettings['attachment_basedirectories']) ? unserialize($modSettings['attachment_basedirectories']) : array();
+	$context['checked'] = isset($_SESSION['checked']) ? $_SESSION['checked'] : true;
+	if (!empty($_SESSION['results']))
+	{
+		$context['results'] = implode('<br />', $_SESSION['results']);
+		unset($_SESSION['results']);
+	}
 }
 
 /**
@@ -1873,6 +1923,7 @@ function ManageAttachmentPaths()
 		$new_dirs = array();
 		foreach ($_POST['dirs'] as $id => $path)
 		{
+			$error = '';
 			$id = (int) $id;
 			if ($id < 1)
 				continue;
@@ -1915,8 +1966,14 @@ function ManageAttachmentPaths()
 				// Update the base directory path
 				if (!empty($modSettings['attachment_basedirectories']) && array_key_exists($id, $modSettings['attachment_basedirectories']))
 				{
+					$base = $modSettings['basedirectory_for_attachments'] == $modSettings['attachmentUploadDir'][$id] ? $path : $modSettings['basedirectory_for_attachments'];
+
 					$modSettings['attachment_basedirectories'][$id] = $path;
-					$update = array('attachment_basedirectories' => serialize($modSettings['attachment_basedirectories']));
+					updateSettings(array(
+						'attachment_basedirectories' => serialize($modSettings['attachment_basedirectories']),
+						'basedirectory_for_attachments' => $base,
+					));
+					$modSettings['attachment_basedirectories'] = unserialize($modSettings['attachment_basedirectories']);
 				}
 			}
 
@@ -1924,7 +1981,7 @@ function ManageAttachmentPaths()
 			{
 				$path = $modSettings['attachmentUploadDir'][$id];
 
-				// It's not a good idea to delete the current directory. 
+				// It's not a good idea to delete the current directory.
 				if ($id == (!empty($_POST['current_dir']) ? $_POST['current_dir'] : $modSettings['currentAttachmentUploadDir']))
 					$errors[] = $path . ': ' . $txt['attach_dir_is_current'];
 				// Or the current base directory
@@ -1970,21 +2027,24 @@ function ManageAttachmentPaths()
 							unlink($path . '/.htaccess');
 							unlink($path . '/index.php');
 							if (!@rmdir($path))
-								$errors[] = $path . ': ' . $txt['attach_dir_no_delete'];
+								$error = $path . ': ' . $txt['attach_dir_no_delete'];
 						}
-					}
-					else
-						$errors[] = $path . ': ' . $txt['attach_dir_no_remove'];
 
-					// Remove it from the base directory list.
-					if (empty($errors) && !empty($modSettings['attachment_basedirectories']))
-					{
-						unset($modSettings['attachment_basedirectories'][$id]);
-						updateSettings(array('attachment_basedirectories' => serialize($modSettings['attachment_basedirectories'])));
+						// Remove it from the base directory list.
+						if (empty($error) && !empty($modSettings['attachment_basedirectories']))
+						{
+							unset($modSettings['attachment_basedirectories'][$id]);
+							updateSettings(array('attachment_basedirectories' => serialize($modSettings['attachment_basedirectories'])));
+							$modSettings['attachment_basedirectories'] = unserialize($modSettings['attachment_basedirectories']);
+						}
 					}
+					else
+						$error = $path . ': ' . $txt['attach_dir_no_remove'];
 
-					if (empty($errors))
+					if (empty($error))
 						continue;
+					else
+						$errors[] = $error;
 				}
 			}
 
@@ -1998,12 +2058,46 @@ function ManageAttachmentPaths()
 		// Find the current directory if there's no value carried,
 		if (empty($_POST['current_dir']) || empty($new_dirs[$_POST['current_dir']]))
 		{
-			if (in_array($modSettings['currentAttachmentUploadDir'], $modSettings['attachmentUploadDir']))
+			if (array_key_exists($modSettings['currentAttachmentUploadDir'], $modSettings['attachmentUploadDir']))
 				$_POST['current_dir'] = $modSettings['currentAttachmentUploadDir'];
 			else
 				$_POST['current_dir'] = max(array_keys($modSettings['attachmentUploadDir']));
 		}
 
+		// If the user wishes to go back, update the last_dir array
+		if ($_POST['current_dir'] !=  $modSettings['currentAttachmentUploadDir']&& !empty($modSettings['last_attachments_directory']) && (isset($modSettings['last_attachments_directory'][$_POST['current_dir']]) || isset($modSettings['last_attachments_directory'][0])))
+		{
+			if (!is_array($modSettings['last_attachments_directory']))
+				$modSettings['last_attachments_directory'] = unserialize($modSettings['last_attachments_directory']);
+			$num = substr(strrchr($modSettings['attachmentUploadDir'][$_POST['current_dir']], '_'), 1);
+			
+			if (is_numeric($num))
+			{
+				// Need to find the base folder.
+				$bid = -1;
+				$use_subdirectories_for_attachments = 0;
+				if (!empty($modSettings['attachment_basedirectories']))
+					foreach($modSettings['attachment_basedirectories'] as $bid => $base)
+						if (strpos($modSettings['attachmentUploadDir'][$_POST['current_dir']], $base . DIRECTORY_SEPARATOR) !==false)
+						{
+							$use_subdirectories_for_attachments = 1;
+							break;
+						}
+
+				if ($use_subdirectories_for_attachments == 0 && strpos($modSettings['attachmentUploadDir'][$_POST['current_dir']], $boarddir . DIRECTORY_SEPARATOR) !== false)
+					$bid = 0;
+
+				$modSettings['last_attachments_directory'][$bid] = (int) $num;
+				$modSettings['basedirectory_for_attachments'] = !empty($modSettings['basedirectory_for_attachments']) ? $modSettings['basedirectory_for_attachments'] : '';
+				$modSettings['use_subdirectories_for_attachments'] = !empty($modSettings['use_subdirectories_for_attachments']) ? $modSettings['use_subdirectories_for_attachments'] : 0;
+				updateSettings(array(
+					'last_attachments_directory' => serialize($modSettings['last_attachments_directory']),
+					'basedirectory_for_attachments' => $bid == 0 ? $modSettings['basedirectory_for_attachments'] : $modSettings['attachment_basedirectories'][$bid],
+					'use_subdirectories_for_attachments' => $use_subdirectories_for_attachments,
+				));
+			}
+		}
+
 		// Going back to just one path?
 		if (count($new_dirs) == 1)
 		{
@@ -2059,7 +2153,42 @@ function ManageAttachmentPaths()
 					'basedirectory_for_attachments' => $modSettings['attachmentUploadDir'][$_POST['current_base_dir']],
 				));
 
-			$modSettings['attachmentUploadDir'] = serialize($modSettings['attachmentUploadDir']);
+			//$modSettings['attachmentUploadDir'] = serialize($modSettings['attachmentUploadDir']);
+		}
+
+		If (isset($_POST['base_dir']))
+		{
+			foreach($_POST['base_dir'] as $id => $dir)
+			{
+				if (!empty($dir) && $dir != $modSettings['attachmentUploadDir'][$id])
+				{
+					if (@rename($modSettings['attachmentUploadDir'][$id], $dir))
+					{
+						$modSettings['attachmentUploadDir'][$id] = $dir;
+						$modSettings['attachment_basedirectories'][$id] = $dir;
+						$update = (array(
+							'attachmentUploadDir' => serialize($modSettings['attachmentUploadDir']),
+							'attachment_basedirectories' => serialize($modSettings['attachment_basedirectories']),
+							'basedirectory_for_attachments' => $modSettings['attachmentUploadDir'][$_POST['current_base_dir']],
+						));
+					}
+				}
+
+				if (empty($dir))
+				{
+					if ($id == $_POST['current_base_dir'])
+					{
+						$errors[] = $modSettings['attachmentUploadDir'][$id] . ': ' . $txt['attach_dir_is_current'];
+						continue;
+					}
+
+					unset($modSettings['attachment_basedirectories'][$id]);
+					$update = (array(
+						'attachment_basedirectories' => serialize($modSettings['attachment_basedirectories']),
+						'basedirectory_for_attachments' => $modSettings['attachmentUploadDir'][$_POST['current_base_dir']],
+					));
+				}
+			}
 		}
 
 		// Or adding a new one?
@@ -2071,11 +2200,10 @@ function ManageAttachmentPaths()
 			$current_dir = $modSettings['currentAttachmentUploadDir'];
 
 			if (!in_array($_POST['new_base_dir'], $modSettings['attachmentUploadDir']))
+			{
 				if (!automanage_attachments_create_directory($_POST['new_base_dir']))
 					$errors[] = $_POST['new_base_dir'] . ': ' . $txt['attach_dir_base_no_create'];
-			else
-				$errors[] = $_POST['new_base_dir'] . ': ' . $txt['attach_dir_base_dupe_msg'];
-
+			}
 
 			$modSettings['currentAttachmentUploadDir'] = array_search($_POST['new_base_dir'], $modSettings['attachmentUploadDir']);
 			if (!in_array($_POST['new_base_dir'], $modSettings['attachment_basedirectories']))
@@ -2090,7 +2218,7 @@ function ManageAttachmentPaths()
 		}
 
 		if (!empty($errors))
-			$_SESSION['base'] = $errors;
+			$_SESSION['errors']['base'] = $errors;
 
 		if (!empty($update))
 			updateSettings($update);
@@ -2100,7 +2228,17 @@ function ManageAttachmentPaths()
 
 	if (isset($_SESSION['errors']))
 	{
-		$errors = $_SESSION['errors'];
+		if (is_array($_SESSION['errors']))
+		{
+			$errors = array();
+			if (!empty($_SESSION['errors']['dir']))
+				foreach($_SESSION['errors']['dir'] as $error)
+					$errors['dir'][] = $smcFunc['htmlspecialchars']($error, ENT_QUOTES);
+			
+			if (!empty($_SESSION['errors']['base']))
+				foreach($_SESSION['errors']['base'] as $error)
+					$errors['base'][] = $smcFunc['htmlspecialchars']($error, ENT_QUOTES);
+		}
 		unset($_SESSION['errors']);
 	}
 
@@ -2115,12 +2253,14 @@ function ManageAttachmentPaths()
 			'current_dir' => array(
 				'header' => array(
 					'value' => $txt['attach_current'],
+					'class' => 'centercol',
 				),
 				'data' => array(
 					'function' => create_function('$rowData', '
 						return \'<input type="radio" name="current_dir" value="\' . $rowData[\'id\'] . \'" \' . ($rowData[\'current\'] ? \' checked="checked"\' : \'\') . (!empty($rowData[\'disable_current\']) ? \' disabled="disabled"\' : \'\') . \' class="input_radio" />\';
 					'),
-					'style' => 'text-align: center; width: 10%;',
+					'style' => 'width: 10%;',
+					'class' => 'centercol',
 				),
 			),
 			'path' => array(
@@ -2131,7 +2271,7 @@ function ManageAttachmentPaths()
 					'function' => create_function('$rowData', '
 						return \'<input type="hidden" name="dirs[\' . $rowData[\'id\'] . \']" value="\' . $rowData[\'path\'] . \'" /><input type="text" size="40" name="dirs[\' . $rowData[\'id\'] . \']" value="\' . $rowData[\'path\'] . \'"\' . (!empty($rowData[\'disable_base_dir\']) ? \' disabled="disabled"\' : \'\') . \' class="input_text" style="width: 100%" />\';
 					'),
-					'style' => 'text-align: center; width: 40%;',
+					'style' => 'width: 40%;',
 				),
 			),
 			'current_size' => array(
@@ -2140,7 +2280,7 @@ function ManageAttachmentPaths()
 				),
 				'data' => array(
 					'db' => 'current_size',
-					'style' => 'text-align: center; width: 15%;',
+					'style' => 'width: 15%;',
 				),
 			),
 			'num_files' => array(
@@ -2149,16 +2289,18 @@ function ManageAttachmentPaths()
 				),
 				'data' => array(
 					'db' => 'num_files',
-					'style' => 'text-align: center; width: 15%;',
+					'style' => 'width: 15%;',
 				),
 			),
 			'status' => array(
 				'header' => array(
 					'value' => $txt['attach_dir_status'],
+					'class' => 'centercol',
 				),
 				'data' => array(
 					'db' => 'status',
-					'style' => 'text-align: center; width: 25%;',
+					'style' => 'width: 25%;',
+					'class' => 'centercol',
 				),
 			),
 		),
@@ -2168,18 +2310,20 @@ function ManageAttachmentPaths()
 		'additional_rows' => array(
 			array(
 				'position' => 'below_table_data',
-				'value' => '<input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '" /><input type="submit" name="new_path" value="' . $txt['attach_add_path'] . '" class="button_submit" />&nbsp;<input type="submit" name="save" value="' . $txt['save'] . '" class="button_submit" />',
-				'style' => 'text-align: right;',
+				'value' => '
+				<input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '" />
+				<input type="submit" name="save" value="' . $txt['save'] . '" class="button_submit" />
+				<input type="submit" name="new_path" value="' . $txt['attach_add_path'] . '" class="button_submit" />',
 			),
 			empty($errors['dir']) ? array(
 				'position' => 'top_of_list',
 				'value' => $txt['attach_dir_desc'],
-				'style' => 'text-align: left; padding: 5px 10px',
+				'style' => 'padding: 5px 10px;',
 				'class' => 'windowbg2 smalltext'
 			) : array(
 				'position' => 'top_of_list',
 				'value' => $txt['attach_dir_save_problem'] . '<br />' . implode('<br />', $errors['dir']),
-				'style' => 'text-align: left;',
+				'style' => 'padding-left: 35px;',
 				'class' => 'noticebox',
 			),
 		),
@@ -2200,12 +2344,14 @@ function ManageAttachmentPaths()
 				'current_dir' => array(
 					'header' => array(
 						'value' => $txt['attach_current'],
+						'class' => 'centercol',
 					),
 					'data' => array(
 						'function' => create_function('$rowData', '
 							return \'<input type="radio" name="current_base_dir" value="\' . $rowData[\'id\'] . \'" \' . ($rowData[\'current\'] ? \' checked="checked"\' : \'\') . \' class="input_radio" />\';
 						'),
-						'style' => 'text-align: center; width: 10%;',
+						'style' => 'width: 10%;',
+						'class' => 'centercol',
 					),
 				),
 				'path' => array(
@@ -2223,7 +2369,7 @@ function ManageAttachmentPaths()
 					),
 					'data' => array(
 						'db' => 'num_dirs',
-						'style' => 'text-align: center; width: 15%;',
+						'style' => 'width: 15%;',
 					),
 				),
 				'status' => array(
@@ -2232,7 +2378,8 @@ function ManageAttachmentPaths()
 					),
 					'data' => array(
 						'db' => 'status',
-						'style' => 'text-align: center; width: 15%;',
+						'style' => 'width: 15%;',
+						'class' => 'centercol',
 					),
 				),
 			),
@@ -2242,18 +2389,18 @@ function ManageAttachmentPaths()
 			'additional_rows' => array(
 				array(
 					'position' => 'below_table_data',
-					'value' => '<input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '" /><input type="submit" name="new_base_path" value="' . $txt['attach_add_path'] . '" class="button_submit" />&nbsp;<input type="submit" name="save2" value="' . $txt['save'] . '" class="button_submit" />',
-					'style' => 'text-align: right;',
+					'value' => '<input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '" /><input type="submit" name="save2" value="' . $txt['save'] . '" class="button_submit" />
+					<input type="submit" name="new_base_path" value="' . $txt['attach_add_path'] . '" class="button_submit" />',
 				),
 				empty($errors['base']) ? array(
 					'position' => 'top_of_list',
 					'value' => $txt['attach_dir_base_desc'],
-					'style' => 'text-align: left; padding: 5px 10px',
+					'style' => 'padding: 5px 10px;',
 					'class' => 'windowbg2 smalltext'
 				) : array(
 					'position' => 'top_of_list',
 					'value' => $txt['attach_dir_save_problem'] . '<br />' . implode('<br />', $errors['base']),
-					'style' => 'text-align: left;',
+					'style' => 'padding-left: 35px',
 					'class' => 'noticebox',
 				),
 			),
@@ -2274,17 +2421,13 @@ function list_getAttachDirs()
 {
 	global $smcFunc, $modSettings, $context, $txt;
 
-	if (isset($_SESSION['dir_errors']))
-	{
-		$context['dir_errors'] = $_SESSION['dir_errors'];
-		unset($_SESSION['dir_errors']);
-	}
-
 	$request = $smcFunc['db_query']('', '
 		SELECT id_folder, COUNT(id_attach) AS num_attach, SUM(size) AS size_attach
 		FROM {db_prefix}attachments
+		WHERE attachment_type != {int:type}
 		GROUP BY id_folder',
 		array(
+			'type' => 1,
 		)
 	);
 
@@ -2326,7 +2469,7 @@ function list_getAttachDirs()
 		$attachdirs[] = array(
 			'id' => $id,
 			'current' => $id == $modSettings['currentAttachmentUploadDir'],
-			'disable_current' => isset($modSettings['automanage_attachments']) && $modSettings['automanage_attachments'] > 0,
+			'disable_current' => isset($modSettings['automanage_attachments']) && $modSettings['automanage_attachments'] > 1,
 			'disable_base_dir' =>  $is_base_dir && $sub_dirs > 0 && !empty($files) && empty($error) && empty($save_errors),
 			'path' => $dir,
 			'current_size' => !empty($expected_size[$id]) ? comma_format($expected_size[$id] / 1024, 0) : 0,
@@ -2379,7 +2522,7 @@ function list_getBaseDirs()
 		$basedirs[] = array(
 			'id' => $id,
 			'current' => $dir == $modSettings['basedirectory_for_attachments'],
-			'path' => $dir,
+			'path' => $expected_dirs > 0 ? $dir : ('<input type="text" name="base_dir[' . $id . ']" value="' . $dir . '" size="40" />'),
 			'num_dirs' => $expected_dirs,
 			'status' => $status == 'ok' ? $txt['attach_dir_ok'] : ('<span class="error">' . $txt['attach_dir_' . $status] . '</span>'),
 		);
@@ -2437,4 +2580,225 @@ function attachDirStatus($dir, $expected_files)
 		return array('ok', false, $num_files);
 }
 
-?>
+/**
+ * Maintance function to move attachments from one directory to another
+ */
+function TransferAttachments()
+{
+	global $modSettings, $context, $smcFunc, $sourcedir, $txt, $boarddir;
+	
+	checkSession();
+	
+	$modSettings['attachmentUploadDir'] = unserialize($modSettings['attachmentUploadDir']);
+	if (!empty($modSettings['attachment_basedirectories']))
+		$modSettings['attachment_basedirectories'] = unserialize($modSettings['attachment_basedirectories']);
+	else
+		$modSettings['basedirectory_for_attachments'] = array();
+
+	$_POST['from'] = (int) $_POST['from'];
+	$_POST['auto'] = !empty($_POST['auto']) ? (int) $_POST['auto'] : 0;
+	$_POST['to'] = (int) $_POST['to'];
+	$start = !empty($_POST['empty_it']) ? 0 : $modSettings['attachmentDirFileLimit'];
+	$_SESSION['checked'] = !empty($_POST['empty_it']) ? true : false;
+	$limit = 501;
+	$results = array();
+	$dir_files = 0;
+	$current_progress = 0;
+	$total_moved = 0;
+	$total_not_moved = 0;
+	
+	if (empty($_POST['from']) || (empty($_POST['auto']) && empty($_POST['to'])))
+		$results[] = $txt['attachment_transfer_no_dir'];
+
+	if ($_POST['from'] == $_POST['to'])
+		$results[] = $txt['attachment_transfer_same_dir'];
+
+	if (empty($results))
+	{
+		// Get the total file count for the progess bar.
+		$request = $smcFunc['db_query']('', '
+			SELECT COUNT(*)
+			FROM {db_prefix}attachments
+			WHERE id_folder = {int:folder_id}
+				AND attachment_type != {int:attachment_type}',
+			array(
+				'folder_id' => $_POST['from'],
+				'attachment_type' => 1,
+			)
+		);
+		list ($total_progress) = $smcFunc['db_fetch_row']($request);
+		$smcFunc['db_free_result']($request);
+		$total_progress -= $start;
+
+		if ($total_progress < 1)
+			$results[] = $txt['attachment_transfer_no_find'];
+	}
+
+	if (empty($results))
+	{
+		// Where are they going?
+		if (!empty($_POST['auto']))
+		{
+			require_once($sourcedir . '/Attachments.php');
+
+			$modSettings['automanage_attachments'] = 1;
+			$modSettings['use_subdirectories_for_attachments'] = $_POST['auto'] == -1 ? 0 : 1;
+			$modSettings['basedirectory_for_attachments'] = $_POST['auto'] > 0 ? $modSettings['attachmentUploadDir'][$_POST['auto']] : $modSettings['basedirectory_for_attachments'];
+
+			automanage_attachments_check_directory();
+			$new_dir = $modSettings['currentAttachmentUploadDir'];
+		}
+		else
+			$new_dir = $_POST['to'];
+
+		$modSettings['currentAttachmentUploadDir'] = $new_dir;
+
+		$break = false;
+		while ($break == false)
+		{
+			@set_time_limit(300);
+			if (function_exists('apache_reset_timeout'))
+				@apache_reset_timeout();
+
+			// If limts are set, get the file count and size for the destination folder
+			if ($dir_files <= 0 && (!empty($modSettings['attachmentDirSizeLimit']) || !empty($modSettings['attachmentDirFileLimit'])))
+			{
+				$request = $smcFunc['db_query']('', '
+					SELECT COUNT(*), SUM(size)
+					FROM {db_prefix}attachments
+					WHERE id_folder = {int:folder_id}
+						AND attachment_type != {int:attachment_type}',
+					array(
+						'folder_id' => $new_dir,
+						'attachment_type' => 1,
+					)
+				);
+				list ($dir_files, $dir_size) = $smcFunc['db_fetch_row']($request);
+				$smcFunc['db_free_result']($request);
+			}
+
+			// Find some attachments to move
+			$request = $smcFunc['db_query']('', '
+				SELECT id_attach, filename, id_folder, file_hash, size
+				FROM {db_prefix}attachments
+				WHERE id_folder = {int:folder}
+					AND attachment_type != {int:attachment_type}
+				LIMIT {int:start}, {int:limit}',
+				array(
+					'folder' => $_POST['from'],
+					'attachment_type' => 1,
+					'start' => $start,
+					'limit' => $limit,
+				)
+			);
+
+			if ($smcFunc['db_num_rows']($request) === 0)
+			{
+				if (empty($current_progress))
+					$results[] = $txt['attachment_transfer_no_find'];
+				break;
+			}
+
+			if ($smcFunc['db_num_rows']($request) < $limit)
+				$break = true;
+
+			// Move them
+			$moved = array();
+			while ($row = $smcFunc['db_fetch_assoc']($request))
+			{
+				// Size and file count check
+				if (!empty($modSettings['attachmentDirSizeLimit']) || !empty($modSettings['attachmentDirFileLimit']))
+				{
+					$dir_files++;
+					$dir_size += !empty($row['size']) ? $row['size'] : filesize($source);
+
+					// If we've reached a limit. Do something.
+					if (!empty($modSettings['attachmentDirSizeLimit']) && $dir_size > $modSettings['attachmentDirSizeLimit'] * 1024 || (!empty($modSettings['attachmentDirFileLimit']) && $dir_files >  $modSettings['attachmentDirFileLimit']))
+					{
+						if (!empty($_POST['auto']))
+						{
+							// Since we're in auto mode. Create a new folder and reset the counters.
+							automanage_attachments_by_space();
+
+							$results[] = sprintf($txt['attachments_transfered'], $total_moved, $modSettings['attachmentUploadDir'][$new_dir]);
+							if (!empty($total_not_moved))
+								$results[] = sprintf($txt['attachments_not_transfered'], $total_not_moved);
+
+							$dir_files = 0;
+							$total_moved = 0;
+							$total_not_moved = 0;
+
+							$break = false;
+							break;
+						}
+						else
+						{
+							// Hmm, not in auto. Time to bail out then...
+							$results[] = $txt['attachment_transfer_no_room'];
+							$break = true;
+							break;
+						}
+					}
+				}
+
+				$source = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']);
+				$dest = $modSettings['attachmentUploadDir'][$new_dir] . '/' . basename($source);
+
+				if (@rename($source, $dest))
+				{
+					$total_moved++;
+					$current_progress++;
+					$moved[] = $row['id_attach'];
+				}
+				else
+					$total_not_moved++;
+			}
+			$smcFunc['db_free_result']($request);
+
+			if (!empty($moved))
+			{
+				// Update the database
+				$smcFunc['db_query']('', '
+					UPDATE {db_prefix}attachments
+					SET id_folder = {int:new}
+					WHERE id_attach IN ({array_int:attachments})',
+					array(
+						'attachments' => $moved,
+						'new' => $new_dir,
+					)
+				);
+			}
+
+			$moved = array();
+			$new_dir = $modSettings['currentAttachmentUploadDir'];
+
+			// Create the progress bar.
+			if (!$break)
+			{
+				$percent_done = min(round($current_progress / $total_progress * 100, 0), 100);
+				$prog_bar = '
+					<div class="progress_bar">
+						<div class="full_bar">' . $percent_done . '%</div>
+						<div class="green_percent" style="width: ' . $percent_done . '%;">&nbsp;</div>
+					</div>';
+				// Write it to a file so it can be displayed
+				$fp = fopen($boarddir . '/progress.php', "w");
+				fwrite($fp, $prog_bar);
+				fclose($fp);
+				usleep(500000);
+			}
+		}
+
+		$results[] = sprintf($txt['attachments_transfered'], $total_moved, $modSettings['attachmentUploadDir'][$new_dir]);
+		if (!empty($total_not_moved))
+			$results[] = sprintf($txt['attachments_not_transfered'], $total_not_moved);
+	}
+
+	$_SESSION['results'] = $results;
+	if (file_exists($boarddir . '/progress.php'))
+		unlink($boarddir . '/progress.php');
+
+	redirectexit('action=admin;area=manageattachments;sa=maintenance#transfer');
+}
+
+?>

+ 19 - 15
Sources/ManageBans.php

@@ -239,7 +239,6 @@ function BanList()
 				),
 				'data' => array(
 					'db' => 'num_triggers',
-					'style' => 'text-align: center;',
 				),
 				'sort' => array(
 					'default' => 'num_triggers DESC',
@@ -249,6 +248,7 @@ function BanList()
 			'actions' => array(
 				'header' => array(
 					'value' => $txt['ban_actions'],
+					'class' => 'centercol',
 				),
 				'data' => array(
 					'sprintf' => array(
@@ -257,12 +257,13 @@ function BanList()
 							'id_ban_group' => false,
 						),
 					),
-					'style' => 'text-align: center;',
+					'class' => 'centercol',
 				),
 			),
 			'check' => array(
 				'header' => array(
 					'value' => '<input type="checkbox" onclick="invertAll(this, this.form);" class="input_check" />',
+					'class' => 'centercol',
 				),
 				'data' => array(
 					'sprintf' => array(
@@ -271,7 +272,7 @@ function BanList()
 							'id_ban_group' => false,
 						),
 					),
-					'style' => 'text-align: center',
+					'class' => 'centercol',
 				),
 			),
 		),
@@ -280,9 +281,8 @@ function BanList()
 		),
 		'additional_rows' => array(
 			array(
-				'position' => 'below_table_data',
+				'position' => 'bottom_of_list',
 				'value' => '<input type="submit" name="removeBans" value="' . $txt['ban_remove_selected'] . '" onclick="return confirm(\'' . $txt['ban_remove_selected_confirm'] . '\');" class="button_submit" />',
-				'style' => 'text-align: right;',
 			),
 		),
 	);
@@ -328,6 +328,11 @@ function list_getBans($start, $items_per_page, $sort)
 	return $bans;
 }
 
+/**
+ * Get the total number of ban from the ban group table
+ *
+ * @return int
+ */
 function list_getNumBans()
 {
 	global $smcFunc;
@@ -1212,7 +1217,6 @@ function BanBrowseTriggers()
 				),
 				'data' => array(
 					'db' => 'hits',
-					'style' => 'text-align: center;',
 				),
 				'sort' => array(
 					'default' => 'bi.hits DESC',
@@ -1222,6 +1226,7 @@ function BanBrowseTriggers()
 			'check' => array(
 				'header' => array(
 					'value' => '<input type="checkbox" onclick="invertAll(this, this.form);" class="input_check" />',
+					'class' => 'centercol',
 				),
 				'data' => array(
 					'sprintf' => array(
@@ -1230,7 +1235,7 @@ function BanBrowseTriggers()
 							'id_ban' => false,
 						),
 					),
-					'style' => 'text-align: center',
+					'class' => 'centercol',
 				),
 			),
 		),
@@ -1245,9 +1250,8 @@ function BanBrowseTriggers()
 				'value' => '<a href="' . $scripturl . '?action=admin;area=ban;sa=browse;entity=ip">' . ($context['selected_entity'] == 'ip' ? '<img src="' . $settings['images_url'] . '/selected.png" alt="&gt;" /> ' : '') . $txt['ip'] . '</a>&nbsp;|&nbsp;<a href="' . $scripturl . '?action=admin;area=ban;sa=browse;entity=hostname">' . ($context['selected_entity'] == 'hostname' ? '<img src="' . $settings['images_url'] . '/selected.png" alt="&gt;" /> ' : '') . $txt['hostname'] . '</a>&nbsp;|&nbsp;<a href="' . $scripturl . '?action=admin;area=ban;sa=browse;entity=email">' . ($context['selected_entity'] == 'email' ? '<img src="' . $settings['images_url'] . '/selected.png" alt="&gt;" /> ' : '') . $txt['email'] . '</a>&nbsp;|&nbsp;<a href="' . $scripturl . '?action=admin;area=ban;sa=browse;entity=member">' . ($context['selected_entity'] == 'member' ? '<img src="' . $settings['images_url'] . '/selected.png" alt="&gt;" /> ' : '') . $txt['username'] . '</a>',
 			),
 			array(
-				'position' => 'below_table_data',
+				'position' => 'bottom_of_list',
 				'value' => '<input type="submit" name="remove_triggers" value="' . $txt['ban_remove_selected_triggers'] . '" onclick="return confirm(\'' . $txt['ban_remove_selected_triggers_confirm'] . '\');" class="button_submit" />',
-				'style' => 'text-align: right;',
 			),
 		),
 	);
@@ -1530,6 +1534,7 @@ function BanLog()
 			'check' => array(
 				'header' => array(
 					'value' => '<input type="checkbox" onclick="invertAll(this, this.form);" class="input_check" />',
+					'class' => 'centercol',
 				),
 				'data' => array(
 					'sprintf' => array(
@@ -1538,7 +1543,7 @@ function BanLog()
 							'id_ban_log' => false,
 						),
 					),
-					'style' => 'text-align: center',
+					'class' => 'centercol',
 				),
 			),
 		),
@@ -1550,11 +1555,10 @@ function BanLog()
 		),
 		'additional_rows' => array(
 			array(
-				'position' => 'below_table_data',
+				'position' => 'bottom_of_list',
 				'value' => '
 					<input type="submit" name="removeSelected" value="' . $txt['ban_log_remove_selected'] . '" onclick="return confirm(\'' . $txt['ban_log_remove_selected_confirm'] . '\');" class="button_submit" />
 					<input type="submit" name="removeAll" value="' . $txt['ban_log_remove_all'] . '" onclick="return confirm(\'' . $txt['ban_log_remove_all_confirm'] . '\');" class="button_submit" />',
-				'style' => 'text-align: right;',
 			),
 		),
 	);
@@ -1626,8 +1630,8 @@ function list_getNumBanLogEntries()
  * @example
  * range2ip(array(10, 10, 10, 0), array(10, 10, 20, 255)) returns '10.10.10-20.*
  *
- * @param array $low, IPv4 format
- * @param array $high, IPv4 format
+ * @param array $low IPv4 format
+ * @param array $high IPv4 format
  * @return string
  */
 function range2ip($low, $high)
@@ -1682,7 +1686,7 @@ function range2ip($low, $high)
  *
  * @param array $ip_array
  * @param string $fullip
- * @return bool
+ * @return boolean
  */
 function checkExistingTriggerIP($ip_array, $fullip = '')
 {

+ 4 - 3
Sources/ManageBoards.php

@@ -20,8 +20,7 @@ if (!defined('SMF'))
  * The main dispatcher; doesn't do anything, just delegates.
  * This is the main entry point for all the manageboards admin screens.
  * Called by ?action=admin;area=manageboards.
- * It checks the permissions, based on the sub-action, and calls a function
- *  based on the sub-action.
+ * It checks the permissions, based on the sub-action, and calls a function based on the sub-action.
  *
  *  @uses ManageBoards language file.
  */
@@ -369,7 +368,6 @@ function EditCategory2()
  * uses the modify_board sub-template of the ManageBoards template.
  * requires manage_boards permission.
  * also used to show the confirm deletion of category screen (sub-template confirm_board_delete).
-		  (sub-template confirm_board_delete).
 
  */
 function EditBoard()
@@ -726,6 +724,9 @@ function EditBoard2()
 		redirectexit('action=admin;area=manageboards');
 }
 
+/**
+ * Used to retrieve data for modifying a board category
+ */
 function ModifyCat()
 {
 	global $cat_tree, $boardList, $boards, $sourcedir, $smcFunc;

+ 3 - 5
Sources/ManageCalendar.php

@@ -142,6 +142,7 @@ function ModifyHolidays()
 			'check' => array(
 				'header' => array(
 					'value' => '<input type="checkbox" onclick="invertAll(this, this.form);" class="input_check" />',
+					'class' => 'centercol',
 				),
 				'data' => array(
 					'sprintf' => array(
@@ -150,7 +151,7 @@ function ModifyHolidays()
 							'id_holiday' => false,
 						),
 					),
-					'style' => 'text-align: center',
+					'class' => 'centercol',
 				),
 			),
 		),
@@ -161,11 +162,8 @@ function ModifyHolidays()
 		'additional_rows' => array(
 			array(
 				'position' => 'below_table_data',
-				'value' => '
-
-					<input type="submit" name="delete" value="' . $txt['quickmod_delete_selected'] . '" class="button_submit" />
+				'value' => '<input type="submit" name="delete" value="' . $txt['quickmod_delete_selected'] . '" class="button_submit" />
 					<a class="button_link" href="' . $scripturl . '?action=admin;area=managecalendar;sa=editholiday" style="margin: 0 1em">' . $txt['holidays_add'] . '</a>',
-				'style' => 'text-align: right;',
 			),
 		),
 	);

+ 16 - 7
Sources/ManageLanguages.php

@@ -113,15 +113,16 @@ function AddLanguage()
 					),
 					'data' => array(
 						'db' => 'utf8',
-						'style' => 'text-align: center',
 					),
 				),
 				'install_link' => array(
 					'header' => array(
 						'value' => $txt['add_language_smf_install'],
+						'class' => 'centercol',
 					),
 					'data' => array(
 						'db' => 'install_link',
+						'class' => 'centercol',
 					),
 				),
 			),
@@ -136,6 +137,12 @@ function AddLanguage()
 	$context['sub_template'] = 'add_language';
 }
 
+/**
+ * Gets a list of available languages from the mother ship
+ * Will return a subset if searching, otherwise all avaialble
+ *
+ * @return string
+ */
 function list_getLanguagesList()
 {
 	global $forum_version, $context, $sourcedir, $smcFunc, $txt, $scripturl;
@@ -213,6 +220,7 @@ function DownloadLanguage()
 
 		$chmod_files = array();
 		$install_files = array();
+
 		// Check writable status.
 		foreach ($_POST['copy_file'] as $file)
 		{
@@ -497,7 +505,6 @@ function DownloadLanguage()
 
 						return \'<span style="color: \' . ($rowData[\'writable\'] ? \'green\' : \'red\') . \';">\' . ($rowData[\'writable\'] ? $txt[\'yes\'] : $txt[\'no\']) . \'</span>\';
 					'),
-					'style' => 'text-align: center',
 				),
 			),
 			'version' => array(
@@ -527,12 +534,14 @@ function DownloadLanguage()
 			'copy' => array(
 				'header' => array(
 					'value' => $txt['languages_download_copy'],
+					'class' => 'centercol',
 				),
 				'data' => array(
 					'function' => create_function('$rowData', '
 						return \'<input type="checkbox" name="copy_file[]" value="\' . $rowData[\'generaldest\'] . \'" \' . ($rowData[\'default_copy\'] ? \'checked="checked"\' : \'\') . \' class="input_check" />\';
 					'),
-					'style' => 'text-align: center; width: 4%;',
+					'style' => 'width: 4%;',
+					'class' => 'centercol',
 				),
 			),
 		),
@@ -592,12 +601,14 @@ function ModifyLanguages()
 			'default' => array(
 				'header' => array(
 					'value' => $txt['languages_default'],
+					'class' => 'centercol',
 				),
 				'data' => array(
 					'function' => create_function('$rowData', '
 						return \'<input type="radio" name="def_language" value="\' . $rowData[\'id\'] . \'" \' . ($rowData[\'default\'] ? \'checked="checked"\' : \'\') . \' onclick="highlightSelected(\\\'list_language_list_\' . $rowData[\'id\'] . \'\\\');" class="input_radio" />\';
 					'),
-					'style' => 'text-align: center; width: 8%;',
+					'style' => 'width: 8%;',
+					'class' => 'centercol',
 				),
 			),
 			'name' => array(
@@ -626,7 +637,6 @@ function ModifyLanguages()
 				),
 				'data' => array(
 					'db_htmlsafe' => 'count',
-					'style' => 'text-align: center',
 				),
 			),
 			'locale' => array(
@@ -644,9 +654,8 @@ function ModifyLanguages()
 		),
 		'additional_rows' => array(
 			array(
-				'position' => 'below_table_data',
+				'position' => 'bottom_of_list',
 				'value' => '<input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '" /><input type="submit" name="set_default" value="' . $txt['save'] . '"' . (is_writable($boarddir . '/Settings.php') ? '' : ' disabled="disabled"') . ' class="button_submit" />',
-				'style' => 'text-align: right;',
 			),
 		),
 		// For highlighting the default.

+ 1 - 1
Sources/ManageMail.php

@@ -198,7 +198,7 @@ function BrowseMailQueue()
 		),
 		'additional_rows' => array(
 			array(
-				'position' => 'below_table_data',
+				'position' => 'bottom_of_list',
 				'value' => '<input type="submit" name="delete_redirects" value="' . $txt['quickmod_delete_selected'] . '" onclick="return confirm(\'' . $txt['quickmod_confirm'] . '\');" class="button_submit" /><a class="button_link" href="' . $scripturl . '?action=admin;area=mailqueue;sa=clear;' . $context['session_var'] . '=' . $context['session_id'] . '" onclick="return confirm(\'' . $txt['mailqueue_clear_list_warning'] . '\');">' . $txt['mailqueue_clear_list'] . '</a> ',
 			),
 		),

+ 4 - 7
Sources/ManageMaintenance.php

@@ -366,7 +366,9 @@ function MaintainEmptyUnimportantLogs()
 	$context['maintenance_finished'] = $txt['maintain_logs'];
 }
 
-// Oh noes!
+/**
+ * Oh noes! I'd document this but that would give it away
+ */
 function Destroy()
 {
 	global $context;
@@ -970,11 +972,6 @@ function ConvertEntities()
 	);
 	$context['num_tables'] = count($tables);
 
-	// This function will do the conversion later on.
-	$entity_replace = create_function('$string', '
-		$num = substr($string, 0, 1) === \'x\' ? hexdec(substr($string, 1)) : (int) $string;
-		return $num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) ? \'\' : ($num < 0x80 ? \'&#\' . $num . \';\' : ($num < 0x800 ? chr(192 | $num >> 6) . chr(128 | $num & 63) : ($num < 0x10000 ? chr(224 | $num >> 12) . chr(128 | $num >> 6 & 63) . chr(128 | $num & 63) : chr(240 | $num >> 18) . chr(128 | $num >> 12 & 63) . chr(128 | $num >> 6 & 63) . chr(128 | $num & 63))));');
-
 	// Loop through all tables that need converting.
 	for (; $context['table'] < $context['num_tables']; $context['table']++)
 	{
@@ -1061,7 +1058,7 @@ function ConvertEntities()
 					if ($column_name !== $primary_key && strpos($column_value, '&#') !== false)
 					{
 						$changes[] = $column_name . ' = {string:changes_' . $column_name . '}';
-						$insertion_variables['changes_' . $column_name] = preg_replace('~(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)~e', '$entity_replace(\'\\2\')', $column_value);
+						$insertion_variables['changes_' . $column_name] = preg_replace_callback('~&#(\d{1,7}|x[0-9a-fA-F]{1,6});~', 'fixchar__callback', $column_value);
 					}
 
 				$where = array();

+ 10 - 5
Sources/ManageMembergroups.php

@@ -158,6 +158,7 @@ function MembergroupIndex()
 			'members' => array(
 				'header' => array(
 					'value' => $txt['membergroups_members_top'],
+					'class' => 'centercol',
 				),
 				'data' => array(
 					'function' => create_function('$rowData', '
@@ -166,7 +167,7 @@ function MembergroupIndex()
 						// No explicit members for the moderator group.
 						return $rowData[\'id_group\'] == 3 ? $txt[\'membergroups_guests_na\'] : $rowData[\'num_members\'];
 					'),
-					'style' => 'text-align: center',
+					'class' => 'centercol',
 				),
 				'sort' => array(
 					'default' => 'CASE WHEN id_group < 4 THEN id_group ELSE 4 END, 1',
@@ -176,6 +177,7 @@ function MembergroupIndex()
 			'modify' => array(
 				'header' => array(
 					'value' => $txt['modify'],
+					'class' => 'centercol',
 				),
 				'data' => array(
 					'sprintf' => array(
@@ -184,7 +186,7 @@ function MembergroupIndex()
 							'id_group' => false,
 						),
 					),
-					'style' => 'text-align: center',
+					'class' => 'centercol',
 				),
 			),
 		),
@@ -261,10 +263,11 @@ function MembergroupIndex()
 			'members' => array(
 				'header' => array(
 					'value' => $txt['membergroups_members_top'],
+					'class' => 'centercol',
 				),
 				'data' => array(
 					'db' => 'num_members',
-					'style' => 'text-align: center',
+					'class' => 'centercol',
 				),
 				'sort' => array(
 					'default' => '1 DESC',
@@ -274,10 +277,11 @@ function MembergroupIndex()
 			'required_posts' => array(
 				'header' => array(
 					'value' => $txt['membergroups_min_posts'],
+					'class' => 'centercol',
 				),
 				'data' => array(
 					'db' => 'min_posts',
-					'style' => 'text-align: center',
+					'class' => 'centercol',
 				),
 				'sort' => array(
 					'default' => 'min_posts',
@@ -287,6 +291,7 @@ function MembergroupIndex()
 			'modify' => array(
 				'header' => array(
 					'value' => $txt['modify'],
+					'class' => 'centercol',
 				),
 				'data' => array(
 					'sprintf' => array(
@@ -295,7 +300,7 @@ function MembergroupIndex()
 							'id_group' => false,
 						),
 					),
-					'style' => 'text-align: center',
+					'class' => 'centercol',
 				),
 			),
 		),

+ 6 - 7
Sources/ManageMembers.php

@@ -448,7 +448,6 @@ function ViewMemberlist()
 				),
 				'data' => array(
 					'db' => 'id_member',
-					'style' => 'text-align: center;',
 				),
 				'sort' => array(
 					'default' => 'id_member',
@@ -580,6 +579,7 @@ function ViewMemberlist()
 			'check' => array(
 				'header' => array(
 					'value' => '<input type="checkbox" onclick="invertAll(this, this.form);" class="input_check" />',
+					'class' => 'centercol',
 				),
 				'data' => array(
 					'function' => create_function('$rowData', '
@@ -587,7 +587,7 @@ function ViewMemberlist()
 
 						return \'<input type="checkbox" name="delete[]" value="\' . $rowData[\'id_member\'] . \'" class="input_check" \' . ($rowData[\'id_member\'] == $user_info[\'id\'] || $rowData[\'id_group\'] == 1 || in_array(1, explode(\',\', $rowData[\'additional_groups\'])) ? \'disabled="disabled"\' : \'\') . \' />\';
 					'),
-					'style' => 'text-align: center',
+					'class' => 'centercol',
 				),
 			),
 		),
@@ -600,7 +600,6 @@ function ViewMemberlist()
 			array(
 				'position' => 'below_table_data',
 				'value' => '<input type="submit" name="delete_members" value="' . $txt['admin_delete_members'] . '" onclick="return confirm(\'' . $txt['confirm_delete_members'] . '\');" class="button_submit" />',
-				'style' => 'text-align: right;',
 			),
 		),
 	);
@@ -826,7 +825,6 @@ function MembersAwaitingActivation()
 				),
 				'data' => array(
 					'db' => 'id_member',
-					'style' => 'text-align: center;',
 				),
 				'sort' => array(
 					'default' => 'id_member',
@@ -916,7 +914,7 @@ function MembersAwaitingActivation()
 				'header' => array(
 					'value' => $txt['duplicates'],
 					// Make sure it doesn't go too wide.
-					'style' => 'width: 20%',
+					'style' => 'width: 20%;',
 				),
 				'data' => array(
 					'function' => create_function('$rowData', '
@@ -938,6 +936,7 @@ function MembersAwaitingActivation()
 			'check' => array(
 				'header' => array(
 					'value' => '<input type="checkbox" onclick="invertAll(this, this.form);" class="input_check" />',
+					'class' => 'centercol',
 				),
 				'data' => array(
 					'sprintf' => array(
@@ -946,7 +945,7 @@ function MembersAwaitingActivation()
 							'id_member' => false,
 						),
 					),
-					'style' => 'text-align: center',
+					'class' => 'centercol',
 				),
 			),
 		),
@@ -968,7 +967,7 @@ function MembersAwaitingActivation()
 					<select name="todo" onchange="onSelectChange();">
 						' . $allowed_actions . '
 					</select>
-					<noscript><input type="submit" value="' . $txt['go'] . '" class="button_submit" /><br class="clear_right"></noscript>
+					<noscript><input type="submit" value="' . $txt['go'] . '" class="button_submit" /><br class="clear_right" /></noscript>
 				',
 				'class' => 'floatright',
 			),

+ 7 - 1
Sources/ManageNews.php

@@ -175,6 +175,7 @@ function EditNews()
 			'check' => array(
 				'header' => array(
 					'value' => '<input type="checkbox" onclick="invertAll(this, this.form);" class="input_check" />',
+					'class' => 'centercol',
 				),
 				'data' => array(
 					'function' => create_function('$news', '
@@ -184,7 +185,7 @@ function EditNews()
 						else
 							return \'\';
 					'),
-					'style' => 'text-align: center',
+					'class' => 'centercol',
 				),
 			),
 		),
@@ -264,6 +265,11 @@ function EditNews()
 	$context['default_list'] = 'news_lists';
 }
 
+/**
+ * Prepares an array of the forum news items for display in the template
+ *
+ * @return array
+ */
 function list_getNews()
 {
 	global $modSettings;

+ 21 - 19
Sources/ManagePaid.php

@@ -222,7 +222,7 @@ function ViewSubscriptions()
 			'name' => array(
 				'header' => array(
 					'value' => $txt['paid_name'],
-					'style' => 'text-align: left; width: 35%;',
+					'style' => 'width: 35%;',
 				),
 				'data' => array(
 					'function' => create_function('$rowData', '
@@ -235,7 +235,6 @@ function ViewSubscriptions()
 			'cost' => array(
 				'header' => array(
 					'value' => $txt['paid_cost'],
-					'style' => 'text-align: left;',
 				),
 				'data' => array(
 					'function' => create_function('$rowData', '
@@ -249,33 +248,37 @@ function ViewSubscriptions()
 				'header' => array(
 					'value' => $txt['paid_pending'],
 					'style' => 'width: 18%;',
+					'class' => 'centercol',
 				),
 				'data' => array(
 					'db_htmlsafe' => 'pending',
-					'style' => 'text-align: center;',
+					'class' => 'centercol',
 				),
 			),
 			'finished' => array(
 				'header' => array(
 					'value' => $txt['paid_finished'],
+					'class' => 'centercol',
 				),
 				'data' => array(
 					'db_htmlsafe' => 'finished',
-					'style' => 'text-align: center;',
+					'class' => 'centercol',
 				),
 			),
 			'total' => array(
 				'header' => array(
 					'value' => $txt['paid_active'],
+					'class' => 'centercol',
 				),
 				'data' => array(
 					'db_htmlsafe' => 'total',
-					'style' => 'text-align: center;',
+					'class' => 'centercol',
 				),
 			),
 			'is_active' => array(
 				'header' => array(
 					'value' => $txt['paid_is_active'],
+					'class' => 'centercol',
 				),
 				'data' => array(
 					'function' => create_function('$rowData', '
@@ -283,7 +286,7 @@ function ViewSubscriptions()
 
 						return \'<span style="color: \' . ($rowData[\'active\'] ? \'green\' : \'red\') . \'">\' . ($rowData[\'active\'] ? $txt[\'yes\'] : $txt[\'no\']) . \'</span>\';
 					'),
-					'style' => 'text-align: center;',
+					'class' => 'centercol',
 				),
 			),
 			'modify' => array(
@@ -293,7 +296,7 @@ function ViewSubscriptions()
 
 						return \'<a href="\' . $scripturl . \'?action=admin;area=paidsubscribe;sa=modify;sid=\' . $rowData[\'id\'] . \'">\' . $txt[\'modify\'] . \'</a>\';
 					'),
-					'style' => 'text-align: center;',
+					'class' => 'centercol',
 				),
 			),
 			'delete' => array(
@@ -303,7 +306,7 @@ function ViewSubscriptions()
 
 						return \'<a href="\' . $scripturl . \'?action=admin;area=paidsubscribe;sa=modify;delete;sid=\' . $rowData[\'id\'] . \'">\' . $txt[\'delete\'] . \'</a>\';
 					'),
-					'style' => 'text-align: center;',
+					'class' => 'centercol',
 				),
 			),
 		),
@@ -313,10 +316,7 @@ function ViewSubscriptions()
 		'additional_rows' => array(
 			array(
 				'position' => 'below_table_data',
-				'value' => '
-					<input type="submit" name="add" value="' . $txt['paid_add_subscription'] . '" class="button_submit" />
-				',
-				'style' => 'text-align: right;',
+				'value' => '<input type="submit" name="add" value="' . $txt['paid_add_subscription'] . '" class="button_submit" />',
 			),
 		),
 	);
@@ -656,7 +656,7 @@ function ViewSubscribedUsers()
 			'name' => array(
 				'header' => array(
 					'value' => $txt['who_member'],
-					'style' => 'text-align: left; width: 20%;',
+					'style' => 'width: 20%;',
 				),
 				'data' => array(
 					'function' => create_function('$rowData', '
@@ -673,7 +673,7 @@ function ViewSubscribedUsers()
 			'status' => array(
 				'header' => array(
 					'value' => $txt['paid_status'],
-					'style' => 'text-align: left; width: 10%;',
+					'style' => 'width: 10%;',
 				),
 				'data' => array(
 					'db_htmlsafe' => 'status_text',
@@ -686,7 +686,7 @@ function ViewSubscribedUsers()
 			'payments_pending' => array(
 				'header' => array(
 					'value' => $txt['paid_payments_pending'],
-					'style' => 'text-align: left; width: 15%;',
+					'style' => 'width: 15%;',
 				),
 				'data' => array(
 					'db_htmlsafe' => 'pending',
@@ -699,7 +699,7 @@ function ViewSubscribedUsers()
 			'start_time' => array(
 				'header' => array(
 					'value' => $txt['start_date'],
-					'style' => 'text-align: left; width: 20%;',
+					'style' => 'width: 20%;',
 				),
 				'data' => array(
 					'db_htmlsafe' => 'start_date',
@@ -713,7 +713,7 @@ function ViewSubscribedUsers()
 			'end_time' => array(
 				'header' => array(
 					'value' => $txt['end_date'],
-					'style' => 'text-align: left; width: 20%;',
+					'style' => 'width: 20%;',
 				),
 				'data' => array(
 					'db_htmlsafe' => 'end_date',
@@ -727,6 +727,7 @@ function ViewSubscribedUsers()
 			'modify' => array(
 				'header' => array(
 					'style' => 'width: 10%;',
+					'class' => 'centercol',
 				),
 				'data' => array(
 					'function' => create_function('$rowData', '
@@ -734,12 +735,13 @@ function ViewSubscribedUsers()
 
 						return \'<a href="\' . $scripturl . \'?action=admin;area=paidsubscribe;sa=modifyuser;lid=\' . $rowData[\'id\'] . \'">\' . $txt[\'modify\'] . \'</a>\';
 					'),
-					'style' => 'text-align: center;',
+					'class' => 'centercol',
 				),
 			),
 			'delete' => array(
 				'header' => array(
 					'style' => 'width: 4%;',
+					'class' => 'centercol',
 				),
 				'data' => array(
 					'function' => create_function('$rowData', '
@@ -747,7 +749,7 @@ function ViewSubscribedUsers()
 
 						return \'<input type="checkbox" name="delsub[\' . $rowData[\'id\'] . \']" class="input_check" />\';
 					'),
-					'style' => 'text-align: center;',
+					'class' => 'centercol',
 				),
 			),
 		),

+ 1 - 1
Sources/ManagePermissions.php

@@ -1393,7 +1393,7 @@ function setPermissionLevel($level, $group, $profile = 'null')
  * Load permissions into $context['permissions'].
  * @internal
  *
- * @param string $loadType, options: 'classic' or 'simple'
+ * @param string $loadType options: 'classic' or 'simple'
  */
 function loadAllPermissions($loadType = 'classic')
 {

+ 4 - 5
Sources/ManageScheduledTasks.php

@@ -207,6 +207,7 @@ function ScheduledTasks()
 				'header' => array(
 					'value' => $txt['scheduled_tasks_enabled'],
 					'style' => 'width: 6%;',
+					'class' => 'centercol',
 				),
 				'data' => array(
 					'sprintf' => array(
@@ -217,13 +218,14 @@ function ScheduledTasks()
 							'checked_state' => false,
 						),
 					),
-					'style' => 'text-align: center;',
+					'class' => 'centercol',
 				),
 			),
 			'run_now' => array(
 				'header' => array(
 					'value' => $txt['scheduled_tasks_run_now'],
 					'style' => 'width: 12%;',
+					'class' => 'centercol',
 				),
 				'data' => array(
 					'sprintf' => array(
@@ -233,7 +235,7 @@ function ScheduledTasks()
 							'id' => false,
 						),
 					),
-					'style' => 'text-align: center;',
+					'class' => 'centercol',
 				),
 			),
 		),
@@ -246,8 +248,6 @@ function ScheduledTasks()
 				'value' => '
 					<input type="submit" name="save" value="' . $txt['scheduled_tasks_save_changes'] . '" class="button_submit" />
 					<input type="submit" name="run" value="' . $txt['scheduled_tasks_run_now'] . '" class="button_submit" />',
-				'class' => 'floatright',
-				'style' => 'text-align: right;',
 			),
 			array(
 				'position' => 'after_title',
@@ -502,7 +502,6 @@ function TaskLog()
 				'position' => 'below_table_data',
 				'value' => '
 					<input type="submit" name="removeAll" value="' . $txt['scheduled_log_empty_log'] . '" onclick="return confirm(\'' . $txt['scheduled_log_empty_log_confirm'] . '\');" class="button_submit" />',
-				'style' => 'text-align: right;',
 			),
 			array(
 				'position' => 'after_title',

+ 4 - 0
Sources/ManageSearch.php

@@ -745,6 +745,10 @@ function loadSearchAPIs()
 	return $apis;
 }
 
+/**
+ * Checks if the message table already has a fulltext index created and returns the key name
+ * Determines if a db is capable of creating a fulltext index
+ */
 function detectFulltextIndex()
 {
 	global $smcFunc, $context, $db_prefix;

+ 10 - 4
Sources/ManageSearchEngines.php

@@ -280,6 +280,7 @@ function ViewSpiders()
 			'check' => array(
 				'header' => array(
 					'value' => '<input type="checkbox" onclick="invertAll(this, this.form);" class="input_check" />',
+					'class' => 'centercol',
 				),
 				'data' => array(
 					'sprintf' => array(
@@ -288,7 +289,7 @@ function ViewSpiders()
 							'id_spider' => false,
 						),
 					),
-					'style' => 'text-align: center',
+					'class' => 'centercol',
 				),
 			),
 		),
@@ -298,12 +299,11 @@ function ViewSpiders()
 		),
 		'additional_rows' => array(
 			array(
-				'position' => 'below_table_data',
+				'position' => 'bottom_of_list',
 				'value' => '
 					<input type="submit" name="removeSpiders" value="' . $txt['spiders_remove_selected'] . '" onclick="return confirm(\'' . $txt['spider_remove_selected_confirm'] . '\');" class="button_submit" />
 					<input type="submit" name="addSpider" value="' . $txt['spiders_add'] . '" class="button_submit" />
 				',
-				'style' => 'text-align: right;',
 			),
 		),
 	);
@@ -758,7 +758,6 @@ function SpiderLogs()
 			array(
 				'position' => 'below_table_data',
 				'value' => '<input type="submit" name="removeAll" value="' . $txt['spider_log_empty_log'] . '" onclick="return confirm(\'' . $txt['spider_log_empty_log_confirm'] . '\');" class="button_submit" />',
-				'style' => 'text-align: right;',
 			),
 		),
 	);
@@ -1021,6 +1020,11 @@ function SpiderStats()
 
 /**
  * Callback function for createList()
+ * Get a list of spider stats from the log_spider table
+ *
+ * @param type $start
+ * @param type $items_per_page
+ * @param type $sort
  * @return array
  */
 function list_getSpiderStats($start, $items_per_page, $sort)
@@ -1046,6 +1050,8 @@ function list_getSpiderStats($start, $items_per_page, $sort)
 
 /**
  * Callback function for createList()
+ * Get the number of spider stat rows from the log spicer stats table
+ *
  * @return int
  */
 function list_getNumSpiderStats()

+ 12 - 6
Sources/ManageServer.php

@@ -338,21 +338,27 @@ function ModifyCacheSettings($return_config = false)
 		$detected['memcached'] = $txt['memcached_cache'];
 	if (function_exists('xcache_set'))
 		$detected['xcache'] = $txt['xcache_cache'];
-
-	// set a message to show what, if anything, we found
+	if (function_exists('file_put_contents'))
+		$detected['smf'] = $txt['default_cache'];
+		
+	// set our values to show what, if anything, we found
 	if (empty($detected))
+	{
 		$txt['cache_settings_message'] = $txt['detected_no_caching'];
+		$cache_level = array($txt['cache_off']);
+		$detected['none'] = $txt['cache_off'];
+	}
 	else
+	{
 		$txt['cache_settings_message'] = sprintf($txt['detected_accelerators'], implode(', ', $detected));
-
-	// This is always an option
-	$detected['smf'] = $txt['default_cache'];
+		$cache_level = array($txt['cache_off'], $txt['cache_level1'], $txt['cache_level2'], $txt['cache_level3']);
+	}
 
 	// Define the variables we want to edit.
 	$config_vars = array(
 		// Only a few settings, but they are important
 		array('', $txt['cache_settings_message'], '', 'desc'),
-		array('cache_enable', $txt['cache_enable'], 'file', 'select', array($txt['cache_off'], $txt['cache_level1'], $txt['cache_level2'], $txt['cache_level3']), 'cache_enable'),
+		array('cache_enable', $txt['cache_enable'], 'file', 'select', $cache_level, 'cache_enable'),
 		array('cache_accelerator', $txt['cache_accelerator'], 'file', 'select', $detected),
 		array('cache_memcached', $txt['cache_memcached'], 'file', 'text', $txt['cache_memcached'], 'cache_memcached'),
 		array('cachedir', $txt['cachedir'], 'file', 'text', 36, 'cache_cachedir'),

+ 67 - 24
Sources/ManageSettings.php

@@ -482,6 +482,8 @@ function ModifyCoreFeatures($return_config = false)
 }
 
 /**
+ * Config array for chaning the basic forum settings
+ * Accessed  from ?action=admin;area=featuresettings;sa=basic;
  *
  * @param $return_config
  */
@@ -624,6 +626,8 @@ function ModifyGeneralSecuritySettings($return_config = false)
 }
 
 /**
+ * Allows modifying the global layout settings in the forum
+ * Accessed through ?action=admin;area=featuresettings;sa=layout;
  *
  * @param $return_config
  */
@@ -676,6 +680,8 @@ function ModifyLayoutSettings($return_config = false)
 }
 
 /**
+ * Config array for chaning the karma settings
+ * Accessed  from ?action=admin;area=featuresettings;sa=karma;
  *
  * @param $return_config
  */
@@ -1424,7 +1430,6 @@ function ShowCustomProfiles()
 			'field' => array(
 				'header' => array(
 					'value' => $txt['standard_profile_field'],
-					'style' => 'text-align: left;',
 				),
 				'data' => array(
 					'db' => 'label',
@@ -1434,6 +1439,7 @@ function ShowCustomProfiles()
 			'active' => array(
 				'header' => array(
 					'value' => $txt['custom_edit_active'],
+					'class' => 'centercol',
 				),
 				'data' => array(
 					'function' => create_function('$rowData', '
@@ -1441,12 +1447,14 @@ function ShowCustomProfiles()
 						$onClickHandler = $rowData[\'can_show_register\'] ? sprintf(\'onclick="document.getElementById(\\\'reg_%1$s\\\').disabled = !this.checked;"\', $rowData[\'id\']) : \'\';
 						return sprintf(\'<input type="checkbox" name="active[]" id="active_%1$s" value="%1$s" class="input_check"%2$s%3$s />\', $rowData[\'id\'], $isChecked, $onClickHandler);
 					'),
-					'style' => 'width: 20%; text-align: center;',
+					'style' => 'width: 20%;',
+					'class' => 'centercol',
 				),
 			),
 			'show_on_registration' => array(
 				'header' => array(
 					'value' => $txt['custom_edit_registration'],
+					'class' => 'centercol',
 				),
 				'data' => array(
 					'function' => create_function('$rowData', '
@@ -1454,7 +1462,8 @@ function ShowCustomProfiles()
 						$isDisabled = $rowData[\'can_show_register\'] ? \'\' : \' disabled="disabled"\';
 						return sprintf(\'<input type="checkbox" name="reg[]" id="reg_%1$s" value="%1$s" class="input_check"%2$s%3$s />\', $rowData[\'id\'], $isChecked, $isDisabled);
 					'),
-					'style' => 'width: 20%; text-align: center;',
+					'style' => 'width: 20%;',
+					'class' => 'centercol',
 				),
 			),
 		),
@@ -1467,7 +1476,6 @@ function ShowCustomProfiles()
 			array(
 				'position' => 'below_table_data',
 				'value' => '<input type="submit" name="save" value="' . $txt['save'] . '" class="button_submit" />',
-				'style' => 'text-align: right;',
 			),
 		),
 	);
@@ -1493,7 +1501,6 @@ function ShowCustomProfiles()
 			'field_name' => array(
 				'header' => array(
 					'value' => $txt['custom_profile_fieldname'],
-					'style' => 'text-align: left;',
 				),
 				'data' => array(
 					'function' => create_function('$rowData', '
@@ -1511,7 +1518,6 @@ function ShowCustomProfiles()
 			'field_type' => array(
 				'header' => array(
 					'value' => $txt['custom_profile_fieldtype'],
-					'style' => 'text-align: left;',
 				),
 				'data' => array(
 					'function' => create_function('$rowData', '
@@ -1537,7 +1543,7 @@ function ShowCustomProfiles()
 
 						return $rowData[\'active\'] ? $txt[\'yes\'] : $txt[\'no\'];
 					'),
-					'style' => 'width: 8%; text-align: center;',
+					'style' => 'width: 8%;',
 				),
 				'sort' => array(
 					'default' => 'active DESC',
@@ -1554,7 +1560,7 @@ function ShowCustomProfiles()
 
 						return $txt[\'custom_profile_placement_\' . (empty($rowData[\'placement\']) ? \'standard\' : ($rowData[\'placement\'] == 1 ? \'withicons\' : \'abovesignature\'))];
 					'),
-					'style' => 'width: 8%; text-align: center;',
+					'style' => 'width: 8%;',
 				),
 				'sort' => array(
 					'default' => 'placement DESC',
@@ -1562,9 +1568,6 @@ function ShowCustomProfiles()
 				),
 			),
 			'show_on_registration' => array(
-				'header' => array(
-					'value' => $txt['modify'],
-				),
 				'data' => array(
 					'sprintf' => array(
 						'format' => '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=%1$s">' . $txt['modify'] . '</a>',
@@ -1572,7 +1575,7 @@ function ShowCustomProfiles()
 							'id_field' => false,
 						),
 					),
-					'style' => 'width: 15%; text-align: center;',
+					'style' => 'width: 15%;',
 				),
 			),
 		),
@@ -1584,7 +1587,6 @@ function ShowCustomProfiles()
 			array(
 				'position' => 'below_table_data',
 				'value' => '<input type="submit" name="new" value="' . $txt['custom_profile_make_new'] . '" class="button_submit" />',
-				'style' => 'text-align: right;',
 			),
 		),
 	);
@@ -2195,14 +2197,23 @@ function ModifyGeneralModSettings($return_config = false)
 	prepareDBSettingContext($config_vars);
 }
 
+/**
+ * Generates a list of integration hooks for display
+ * Accessed through ?action=admin;area=modsettings;sa=hooks;
+ * Allows for removal or disabing of selected hooks
+ */
 function list_integration_hooks()
 {
 	global $sourcedir, $scripturl, $context, $txt, $modSettings, $settings;
 
-	$context['filter'] = '';
+	$context['filter_url'] = '';
+	$context['current_filter'] = '';
 	$currentHooks = get_integration_hooks();
 	if (isset($_GET['filter']) && in_array($_GET['filter'], array_keys($currentHooks)))
-		$context['filter'] = ';filter=' . $_GET['filter'];
+	{
+		$context['filter_url'] = ';filter=' . $_GET['filter'];
+		$context['current_filter'] = $_GET['filter'];
+	}
 
 	if (!empty($modSettings['handlinghooks_enabled']))
 	{
@@ -2231,7 +2242,7 @@ function list_integration_hooks()
 				remove_integration_function($_REQUEST['hook'], $function_remove, $file);
 				add_integration_function($_REQUEST['hook'], $function_add, $file);
 
-				redirectexit('action=admin;area=modsettings;sa=hooks' . $context['filter']);
+				redirectexit('action=admin;area=modsettings;sa=hooks' . $context['filter_url']);
 			}
 		}
 	}
@@ -2240,7 +2251,7 @@ function list_integration_hooks()
 		'id' => 'list_integration_hooks',
 		'title' => $txt['hooks_title_list'],
 		'items_per_page' => 20,
-		'base_href' => $scripturl . '?action=admin;area=modsettings;sa=hooks' . $context['filter'] . ';' . $context['session_var'] . '=' . $context['session_id'],
+		'base_href' => $scripturl . '?action=admin;area=modsettings;sa=hooks' . $context['filter_url'] . ';' . $context['session_var'] . '=' . $context['session_id'],
 		'default_sort_col' => 'hook_name',
 		'get_items' => array(
 			'function' => 'get_integration_hooks_data',
@@ -2296,7 +2307,7 @@ function list_integration_hooks()
 			'status' => array(
 				'header' => array(
 					'value' => $txt['hooks_field_hook_exists'],
-					'style' => 'width:3%',
+					'style' => 'width:3%;',
 				),
 				'data' => array(
 					'function' => create_function('$data', '
@@ -2305,7 +2316,7 @@ function list_integration_hooks()
 						$change_status = array(\'before\' => \'\', \'after\' => \'\');
 						if ($data[\'can_be_disabled\'] && $data[\'status\'] != \'deny\')
 						{
-							$change_status[\'before\'] = \'<a href="\' . $scripturl . \'?action=admin;area=modsettings;sa=hooks;do=\' . ($data[\'enabled\'] ? \'disable\' : \'enable\') . \';hook=\' . $data[\'hook_name\'] . \';function=\' . $data[\'real_function\'] . (!empty($data[\'included_file\']) ? \';includedfile=\' . urlencode($data[\'included_file\']) : \'\') . $context[\'filter\'] . \';\' . $context[\'admin-hook_token_var\'] . \'=\' . $context[\'admin-hook_token\'] . \';\' . $context[\'session_var\'] . \'=\' . $context[\'session_id\'] . \'" onclick="return confirm(\' . javaScriptEscape($txt[\'quickmod_confirm\']) . \');">\';
+							$change_status[\'before\'] = \'<a href="\' . $scripturl . \'?action=admin;area=modsettings;sa=hooks;do=\' . ($data[\'enabled\'] ? \'disable\' : \'enable\') . \';hook=\' . $data[\'hook_name\'] . \';function=\' . $data[\'real_function\'] . (!empty($data[\'included_file\']) ? \';includedfile=\' . urlencode($data[\'included_file\']) : \'\') . $context[\'filter_url\'] . \';\' . $context[\'admin-hook_token_var\'] . \'=\' . $context[\'admin-hook_token\'] . \';\' . $context[\'session_var\'] . \'=\' . $context[\'session_id\'] . \'" onclick="return confirm(\' . javaScriptEscape($txt[\'quickmod_confirm\']) . \');">\';
 							$change_status[\'after\'] = \'</a>\';
 						}
 						return $change_status[\'before\'] . \'<img src="\' . $settings[\'images_url\'] . \'/admin/post_moderation_\' . $data[\'status\'] . \'.png" alt="\' . $data[\'img_text\'] . \'" title="\' . $data[\'img_text\'] . \'" />\' . $change_status[\'after\'];
@@ -2347,7 +2358,7 @@ function list_integration_hooks()
 
 					if (!$data[\'hook_exists\'])
 						return \'
-						<a href="\' . $scripturl . \'?action=admin;area=modsettings;sa=hooks;do=remove;hook=\' . $data[\'hook_name\'] . \';function=\' . urlencode($data[\'function_name\']) . $context[\'filter\'] . \';\' . $context[\'admin-hook_token_var\'] . \'=\' . $context[\'admin-hook_token\'] . \';\' . $context[\'session_var\'] . \'=\' . $context[\'session_id\'] . \'" onclick="return confirm(\' . javaScriptEscape($txt[\'quickmod_confirm\']) . \');">
+						<a href="\' . $scripturl . \'?action=admin;area=modsettings;sa=hooks;do=remove;hook=\' . $data[\'hook_name\'] . \';function=\' . urlencode($data[\'function_name\']) . $context[\'filter_url\'] . \';\' . $context[\'admin-hook_token_var\'] . \'=\' . $context[\'admin-hook_token\'] . \';\' . $context[\'session_var\'] . \'=\' . $context[\'session_id\'] . \'" onclick="return confirm(\' . javaScriptEscape($txt[\'quickmod_confirm\']) . \');">
 							<img src="\' . $settings[\'images_url\'] . \'/icons/quick_remove.png" alt="\' . $txt[\'hooks_button_remove\'] . \'" title="\' . $txt[\'hooks_button_remove\'] . \'" />
 						</a>\';
 				'),
@@ -2355,7 +2366,7 @@ function list_integration_hooks()
 			),
 		);
 		$list_options['form'] = array(
-			'href' => $scripturl . '?action=admin;area=modsettings;sa=hooks' . $context['filter'] . ';' . $context['session_var'] . '=' . $context['session_id'],
+			'href' => $scripturl . '?action=admin;area=modsettings;sa=hooks' . $context['filter_url'] . ';' . $context['session_var'] . '=' . $context['session_id'],
 			'name' => 'list_integration_hooks',
 		);
 	}
@@ -2369,6 +2380,12 @@ function list_integration_hooks()
 	$context['default_list'] = 'list_integration_hooks';
 }
 
+/**
+ * Gets all of the files in a directory and its chidren directories
+ *
+ * @param type $dir_path
+ * @return array
+ */
 function get_files_recursive($dir_path)
 {
 	$files = array();
@@ -2391,6 +2408,16 @@ function get_files_recursive($dir_path)
 	return $files;
 }
 
+/**
+ * Callback function for the integration hooks list (list_integration_hooks)
+ * Gets all of the hooks in the system and their status
+ * Would be better documented if Ema was not lazy
+ *
+ * @param type $start
+ * @param type $per_page
+ * @param type $sort
+ * @return array
+ */
 function get_integration_hooks_data($start, $per_page, $sort)
 {
 	global $boarddir, $sourcedir, $settings, $txt, $context, $scripturl, $modSettings;
@@ -2458,12 +2485,11 @@ function get_integration_hooks_data($start, $per_page, $sort)
 
 	$sort_options = $sort_types[$sort];
 	$sort = array();
-	$context['hooks_filters'] = '';
 	$hooks_filters = array();
 
 	foreach ($hooks as $hook => $functions)
 	{
-		$hooks_filters[] = '<option onclick="window.location = \'' . $scripturl . '?action=admin;area=modsettings;sa=hooks;filter=' . $hook . '\';">' . $hook . '</option>';
+		$hooks_filters[] = '<option ' . ($context['current_filter'] == $hook ? 'selected="selected" ' : '') . 'onclick="window.location = \'' . $scripturl . '?action=admin;area=modsettings;sa=hooks;filter=' . $hook . '\';">' . $hook . '</option>';
 		foreach ($functions as $function)
 		{
 			$enabled = strstr($function, ']') === false;
@@ -2487,7 +2513,11 @@ function get_integration_hooks_data($start, $per_page, $sort)
 	}
 
 	if (!empty($hooks_filters))
-		$context['hooks_filters'] = '<select style="margin-left:15px;">' . '<option>---</option><option onclick="window.location = \'' . $scripturl . '?action=admin;area=modsettings;sa=hooks\';">' . $txt['hooks_reset_filter'] . '</option>' . implode('', $hooks_filters) . '</select>';
+		$context['insert_after_template'] .= '
+		<script type="text/javascript"><!-- // --><![CDATA[
+			var hook_name_header = document.getElementById(\'header_list_integration_hooks_hook_name\');
+			hook_name_header.innerHTML += ' . JavaScriptEscape('<select style="margin-left:15px;"><option>---</option><option onclick="window.location = \'' . $scripturl . '?action=admin;area=modsettings;sa=hooks\';">' . $txt['hooks_reset_filter'] . '</option>' . implode('', $hooks_filters) . '</select>'). ';
+		// ]]></script>';
 
 	$temp_data = array();
 	$id = 0;
@@ -2546,6 +2576,13 @@ function get_integration_hooks_data($start, $per_page, $sort)
 	return $hooks_data;
 }
 
+/**
+ * Simply returns the total count of integraion hooks
+ * Used but the intergation hooks list function (list_integration_hooks)
+ *
+ * @global type $context
+ * @return int
+ */
 function get_integration_hooks_count()
 {
 	global $context;
@@ -2566,6 +2603,12 @@ function get_integration_hooks_count()
 	return $hooks_count;
 }
 
+/**
+ * Parses modSettings to create integration hook array
+ * 
+ * @staticvar type $integration_hooks
+ * @return type
+ */
 function get_integration_hooks()
 {
 	global $modSettings;

+ 23 - 13
Sources/ManageSmileys.php

@@ -384,12 +384,14 @@ function EditSmileySets()
 			'default' => array(
 				'header' => array(
 					'value' => $txt['smiley_sets_default'],
+					'class' => 'centercol',
 				),
 				'data' => array(
 					'function' => create_function('$rowData', '
-						return $rowData[\'selected\'] ? \'<strong>*</strong>\' : \'\';
+						global $settings;
+						return $rowData[\'selected\'] ? \'<img src="\' . $settings[\'images_url\'] . \'/icons/field_valid.png" alt="*" class="icon" />\' : \'\';
 					'),
-					'style' => 'text-align: center;',
+					'class' => 'centercol',
 				),
 				'sort' => array(
 					'default' => 'selected DESC',
@@ -427,6 +429,7 @@ function EditSmileySets()
 			'modify' => array(
 				'header' => array(
 					'value' => $txt['smiley_set_modify'],
+					'class' => 'centercol',
 				),
 				'data' => array(
 					'sprintf' => array(
@@ -435,18 +438,19 @@ function EditSmileySets()
 							'id' => true,
 						),
 					),
-					'style' => 'text-align: center;',
+					'class' => 'centercol',
 				),
 			),
 			'check' => array(
 				'header' => array(
 					'value' => '<input type="checkbox" onclick="invertAll(this, this.form);" class="input_check" />',
+					'class' => 'centercol',
 				),
 				'data' => array(
 					'function' => create_function('$rowData', '
 						return $rowData[\'id\'] == 0 ? \'\' : sprintf(\'<input type="checkbox" name="smiley_set[%1$d]" class="input_check" />\', $rowData[\'id\']);
 					'),
-					'style' => 'text-align: center',
+					'class' => 'centercol',
 				),
 			),
 		),
@@ -951,7 +955,7 @@ function EditSmileys()
 								'description' => true,
 							),
 						),
-						'style' => 'text-align: center;',
+						'class' => 'centercol',
 					),
 				),
 				'code' => array(
@@ -1031,6 +1035,7 @@ function EditSmileys()
 				'modify' => array(
 					'header' => array(
 						'value' => $txt['smileys_modify'],
+						'class' => 'centercol',
 					),
 					'data' => array(
 						'sprintf' => array(
@@ -1039,12 +1044,13 @@ function EditSmileys()
 								'id_smiley' => false,
 							),
 						),
-						'style' => 'text-align: center;',
+						'class' => 'centercol',
 					),
 				),
 				'check' => array(
 					'header' => array(
 						'value' => '<input type="checkbox" onclick="invertAll(this, this.form);" class="input_check" />',
+						'class' => 'centercol',
 					),
 					'data' => array(
 						'sprintf' => array(
@@ -1053,7 +1059,7 @@ function EditSmileys()
 								'id_smiley' => false,
 							),
 						),
-						'style' => 'text-align: center',
+						'class' => 'centercol',
 					),
 				),
 			),
@@ -1065,7 +1071,7 @@ function EditSmileys()
 				array(
 					'position' => 'above_column_headers',
 					'value' => $smileyset_option_list,
-					'style' => 'text-align: right;',
+					'class' => 'righttext',
 				),
 				array(
 					'position' => 'below_table_data',
@@ -1078,8 +1084,10 @@ function EditSmileys()
 							<option value="popup">' . $txt['smileys_show_on_popup'] . '</option>
 							<option value="delete">' . $txt['smileys_remove'] . '</option>
 						</select>
-						<noscript><input type="submit" name="perform_action" value="' . $txt['go'] . '" class="button_submit" /></noscript>',
-					'style' => 'text-align: right;',
+						<noscript>
+							<input type="submit" name="perform_action" value="' . $txt['go'] . '" class="button_submit" />
+						</noscript>',
+					'class' => 'righttext',
 				),
 			),
 			'javascript' => '
@@ -1672,8 +1680,8 @@ function EditMessageIcons()
 						$images_url = $settings[file_exists(sprintf(\'%1$s/images/post/%2$s.png\', $settings[\'theme_dir\'], $rowData[\'filename\'])) ? \'actual_images_url\' : \'default_images_url\'];
 						return sprintf(\'<img src="%1$s/post/%2$s.png" alt="%3$s" />\', $images_url, $rowData[\'filename\'], htmlspecialchars($rowData[\'title\']));
 					'),
+					'class' => 'centercol',
 				),
-				'style' => 'text-align: center;',
 			),
 			'filename' => array(
 				'header' => array(
@@ -1711,6 +1719,7 @@ function EditMessageIcons()
 			'modify' => array(
 				'header' => array(
 					'value' => $txt['smileys_modify'],
+					'class' => 'centercol',
 				),
 				'data' => array(
 					'sprintf' => array(
@@ -1719,12 +1728,13 @@ function EditMessageIcons()
 							'id_icon' => false,
 						),
 					),
-					'style' => 'text-align: center',
+					'class' => 'centercol',
 				),
 			),
 			'check' => array(
 				'header' => array(
 					'value' => '<input type="checkbox" onclick="invertAll(this, this.form);" class="input_check" />',
+					'class' => 'centercol',
 				),
 				'data' => array(
 					'sprintf' => array(
@@ -1733,7 +1743,7 @@ function EditMessageIcons()
 							'id_icon' => false,
 						),
 					),
-					'style' => 'text-align: center',
+					'class' => 'centercol',
 				),
 			),
 		),

+ 10 - 6
Sources/MessageIndex.php

@@ -76,6 +76,10 @@ function MessageIndex()
 		$context['unapproved_posts_message'] = sprintf($txt['there_are_unapproved_topics'], $untopics, $unposts, $scripturl . '?action=moderate;area=postmod;sa=' . ($board_info['unapproved_topics'] ? 'topics' : 'posts') . ';brd=' . $board);
 	}
 
+	// We only know these.
+	if (isset($_REQUEST['sort']) && !in_array($_REQUEST['sort'], array('subject', 'starter', 'last_poster', 'replies', 'views', 'first_post', 'last_post')))
+		$_REQUEST['sort'] = 'last_post';
+		
 	// Make sure the starting place makes sense and construct the page index.
 	if (isset($_REQUEST['sort']))
 		$context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $board_info['total_topics'], $maxindex, true);
@@ -364,7 +368,7 @@ function MessageIndex()
 			SELECT
 				t.id_topic, t.num_replies, t.locked, t.num_views, t.is_sticky, t.id_poll, t.id_previous_board,
 				' . ($user_info['is_guest'] ? '0' : 'IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1') . ' AS new_from,
-				t.id_last_msg, t.approved, t.unapproved_posts, t.id_redirect_topic, ml.poster_time AS last_poster_time,
+				t.id_last_msg, t.approved, t.unapproved_posts, ml.poster_time AS last_poster_time,
 				ml.id_msg_modified, ml.subject AS last_subject, ml.icon AS last_icon,
 				ml.poster_name AS last_member_name, ml.id_member AS last_id_member, ' . (!empty($settings['avatars_on_indexes']) ? 'meml.avatar,' : '') . '
 				IFNULL(meml.real_name, ml.poster_name) AS last_display_name, t.id_first_msg,
@@ -515,8 +519,8 @@ function MessageIndex()
 					'preview' => $row['first_body'],
 					'icon' => $row['first_icon'],
 					'icon_url' => $settings[$context['icon_sources'][$row['first_icon']]] . '/post/' . $row['first_icon'] . '.png',
-					'href' => $scripturl . '?topic=' . (empty($row['id_redirect_topic']) ? $row['id_topic'] : $row['id_redirect_topic']) . '.0',
-					'link' => '<a href="' . $scripturl . '?topic=' . (empty($row['id_redirect_topic']) ? $row['id_topic'] : $row['id_redirect_topic']). '.0">' . $row['first_subject'] . '</a>'
+					'href' => $scripturl . '?topic=' . $row['id_topic'] . '.0',
+					'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['first_subject'] . '</a>'
 				),
 				'last_post' => array(
 					'id' => $row['id_last_msg'],
@@ -533,8 +537,8 @@ function MessageIndex()
 					'preview' => $row['last_body'],
 					'icon' => $row['last_icon'],
 					'icon_url' => $settings[$context['icon_sources'][$row['last_icon']]] . '/post/' . $row['last_icon'] . '.png',
-					'href' => $scripturl . '?topic=' . (empty($row['id_redirect_topic']) ? $row['id_topic'] : $row['id_redirect_topic']) . ($user_info['is_guest'] ? ('.' . (!empty($options['view_newest_first']) ? 0 : ((int) (($row['num_replies']) / $context['pageindex_multiplier'])) * $context['pageindex_multiplier']) . '#msg' . $row['id_last_msg']) : (($row['num_replies'] == 0 ? '.0' : '.msg' . $row['id_last_msg']) . '#new')),
-					'link' => '<a href="' . $scripturl . '?topic=' . (empty($row['id_redirect_topic']) ? $row['id_topic'] : $row['id_redirect_topic']) . ($user_info['is_guest'] ? ('.' . (!empty($options['view_newest_first']) ? 0 : ((int) (($row['num_replies']) / $context['pageindex_multiplier'])) * $context['pageindex_multiplier']) . '#msg' . $row['id_last_msg']) : (($row['num_replies'] == 0 ? '.0' : '.msg' . $row['id_last_msg']) . '#new')) . '" ' . ($row['num_replies'] == 0 ? '' : 'rel="nofollow"') . '>' . $row['last_subject'] . '</a>'
+					'href' => $scripturl . '?topic=' . $row['id_topic'] . ($user_info['is_guest'] ? ('.' . (!empty($options['view_newest_first']) ? 0 : ((int) (($row['num_replies']) / $context['pageindex_multiplier'])) * $context['pageindex_multiplier']) . '#msg' . $row['id_last_msg']) : (($row['num_replies'] == 0 ? '.0' : '.msg' . $row['id_last_msg']) . '#new')),
+					'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . ($user_info['is_guest'] ? ('.' . (!empty($options['view_newest_first']) ? 0 : ((int) (($row['num_replies']) / $context['pageindex_multiplier'])) * $context['pageindex_multiplier']) . '#msg' . $row['id_last_msg']) : (($row['num_replies'] == 0 ? '.0' : '.msg' . $row['id_last_msg']) . '#new')) . '" ' . ($row['num_replies'] == 0 ? '' : 'rel="nofollow"') . '>' . $row['last_subject'] . '</a>'
 				),
 				'is_sticky' => !empty($modSettings['enableStickyTopics']) && !empty($row['is_sticky']),
 				'is_locked' => !empty($row['locked']),
@@ -548,7 +552,7 @@ function MessageIndex()
 				'new' => $row['new_from'] <= $row['id_msg_modified'],
 				'new_from' => $row['new_from'],
 				'newtime' => $row['new_from'],
-				'new_href' => $scripturl . '?topic=' . (empty($row['id_redirect_topic']) ? $row['id_topic'] : $row['id_redirect_topic']) . '.msg' . $row['new_from'] . '#new',
+				'new_href' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['new_from'] . '#new',
 				'pages' => $pages,
 				'replies' => comma_format($row['num_replies']),
 				'views' => comma_format($row['num_views']),

+ 3 - 5
Sources/ModerationCenter.php

@@ -1789,6 +1789,7 @@ function ViewWarningTemplates()
 				'header' => array(
 					'value' => '<input type="checkbox" class="input_check" onclick="invertAll(this, this.form);" />',
 					'style' => 'width: 4%;',
+					'class' => 'centercol',
 				),
 				'data' => array(
 					'function' => create_function('$rowData', '
@@ -1796,7 +1797,7 @@ function ViewWarningTemplates()
 
 						return \'<input type="checkbox" name="deltpl[]" value="\' . $rowData[\'id_comment\'] . \'" class="input_check" />\';
 					'),
-					'style' => 'text-align: center;',
+					'class' => 'centercol',
 				),
 			),
 		),
@@ -1808,13 +1809,10 @@ function ViewWarningTemplates()
 			array(
 				'position' => 'below_table_data',
 				'value' => '&nbsp;<input type="submit" name="delete" value="' . $txt['mc_warning_template_delete'] . '" onclick="return confirm(\'' . $txt['mc_warning_template_delete_confirm'] . '\');" class="button_submit" />',
-				'style' => 'text-align: right;',
 			),
 			array(
 				'position' => 'bottom_of_list',
-				'value' => '
-					<input type="submit" name="add" value="' . $txt['mc_warning_template_add'] . '" class="button_submit" />',
-				'style' => 'text-align: right;',
+				'value' => '<input type="submit" name="add" value="' . $txt['mc_warning_template_add'] . '" class="button_submit" />',
 			),
 		),
 	);

+ 6 - 4
Sources/Modlog.php

@@ -253,12 +253,13 @@ function ViewModlog()
 			'delete' => array(
 				'header' => array(
 					'value' => '<input type="checkbox" name="all" class="input_check" onclick="invertAll(this, this.form);" />',
+					'class' => 'centercol',
 				),
 				'data' => array(
 					'function' => create_function('$entry', '
 						return \'<input type="checkbox" class="input_check" name="delete[]" value="\' . $entry[\'id\'] . \'"\' . ($entry[\'editable\'] ? \'\' : \' disabled="disabled"\') . \' />\';
 					'),
-					'style' => 'text-align: center;',
+					'class' => 'centercol',
 				),
 			),
 		),
@@ -285,9 +286,10 @@ function ViewModlog()
 					' . $txt['modlog_search'] . ' (' . $txt['modlog_by'] . ': ' . $context['search']['label'] . '):
 					<input type="text" name="search" size="18" value="' . $context['search']['string'] . '" class="input_text" />
 					<input type="submit" name="is_search" value="' . $txt['modlog_go'] . '" class="button_submit" style="float:none" />
-					' . ($context['can_delete'] ? ' |
-						<input type="submit" name="remove" value="' . $txt['modlog_remove'] . '" onclick="return confirm(\'' . $txt['modlog_remove_selected_confirm'] . '\');" class="button_submit" />
-						<input type="submit" name="removeall" value="' . $txt['modlog_removeall'] . '" onclick="return confirm(\'' . $txt['modlog_remove_all_confirm'] . '\');" class="button_submit" />' : ''),
+					' . ($context['can_delete'] ? '&nbsp;|
+					<input type="submit" name="remove" value="' . $txt['modlog_remove'] . '" onclick="return confirm(\'' . $txt['modlog_remove_selected_confirm'] . '\');" class="button_submit" />
+					<input type="submit" name="removeall" value="' . $txt['modlog_removeall'] . '" onclick="return confirm(\'' . $txt['modlog_remove_all_confirm'] . '\');" class="button_submit" />' : ''),
+				'class' => 'floatright',
 			),
 		),
 	);

+ 14 - 1
Sources/MoveTopic.php

@@ -384,7 +384,16 @@ function MoveTopic2()
 		redirectexit('topic=' . $topic . '.0');
 }
 
-// Moves one or more topics to a specific board. (doesn't check permissions.)
+/**
+ * Moves one or more topics to a specific board. (doesn't check permissions.)
+ * Determines the source boards for the supplied topics
+ * Handles the moving of mark_read data
+ * Updates the posts count of the affected boards
+ *
+ * @param type $topics
+ * @param type $toBoard
+ * @return type
+ */
 function moveTopics($topics, $toBoard)
 {
 	global $sourcedir, $user_info, $modSettings, $smcFunc;
@@ -702,6 +711,10 @@ function moveTopics($topics, $toBoard)
 	));
 }
 
+/**
+ * Called after a topic is moved to update $board_link and $topic_link to point to new location
+ *
+ */
 function moveTopicConcurrence()
 {
 	global $board, $topic, $smcFunc, $scripturl;

+ 18 - 3
Sources/News.php

@@ -349,6 +349,13 @@ function ShowXmlFeed()
 	obExit(false);
 }
 
+/**
+ * Called from dumpTags to convert data to xml
+ * Finds urls for local sitte and santizes them
+ *
+ * @param type $val
+ * @return type
+ */
 function fix_possible_url($val)
 {
 	global $modSettings, $context, $scripturl;
@@ -365,6 +372,14 @@ function fix_possible_url($val)
 	return $val;
 }
 
+/**
+ * Ensures supplied data is properly encpsulated in cdata xml tags
+ * Called from getXmlProfile in News.php
+ *
+ * @param type $data
+ * @param type $ns
+ * @return type
+ */
 function cdata_parse($data, $ns = '')
 {
 	global $smcFunc, $cdata_override;
@@ -439,9 +454,9 @@ function cdata_parse($data, $ns = '')
  * Additionally formats data based on the specific format passed.
  * This function is recursively called to handle sub arrays of data.
 
- * @param array $data, the array to output as xml data
- * @param int $i, the amount of indentation to use.
- * @param string $tag, if specified, it will be used instead of the keys of data.
+ * @param array $data the array to output as xml data
+ * @param int $i the amount of indentation to use.
+ * @param string $tag if specified, it will be used instead of the keys of data.
  * @param string $xml_format
  */
 function dumpTags($data, $i, $tag = null, $xml_format = '')

+ 47 - 2
Sources/Packages.php

@@ -226,7 +226,9 @@ function PackageInstallTest()
 	$smcFunc['db_free_result']($request);
 
 	$context['database_changes'] = array();
-	if (!empty($db_changes))
+	if (isset($packageInfo['uninstall']['database']))
+		$context['database_changes'][] = $txt['execute_database_changes'] . ' - ' . $packageInfo['uninstall']['database'];
+	elseif (!empty($db_changes))
 	{
 		foreach ($db_changes as $change)
 		{
@@ -1115,6 +1117,13 @@ function PackageInstall()
 			{
 				// We're really just checking for entries which are create table AND add columns (etc).
 				$tables = array();
+				/**
+				 * Table sorting function used in usort
+				 *
+				 * @param type $a
+				 * @param type $b
+				 * @return int
+				 */
 				function sort_table_first($a, $b)
 				{
 					if ($a[0] == $b[0])
@@ -1474,7 +1483,7 @@ function PackageBrowse()
 									<a href="\' . $scripturl . \'?action=admin;area=packages;sa=list;package=\' . $package[\'filename\'] . \'">[ \' . $txt[\'list_files\'] . \' ]</a>
 									<a href="\' . $scripturl . \'?action=admin;area=packages;sa=remove;package=\' . $package[\'filename\'] . \';\' . $context[\'session_var\'] . \'=\' . $context[\'session_id\'] . \'"\' . ($package[\'is_installed\'] && $package[\'is_current\'] ? \' onclick="return confirm(\\\'\' . $txt[\'package_delete_bad\'] . \'\\\');"\' : \'\') . \'>[ \' . $txt[\'package_delete\'] . \' ]</a>\';
 						'),
-						'style' => 'text-align: right;',
+						'class' => 'righttext',
 					),
 				),
 			),
@@ -1501,6 +1510,18 @@ function PackageBrowse()
 	$context['available_all'] = array();
 }
 
+/**
+ * Get a listing of all the packages
+ * Determines if the package is a mod, avatar, language package
+ * Determines if the package has been installed or not
+ *
+ * @param type $start
+ * @param type $items_per_page
+ * @param type $sort
+ * @param type $params
+ * @param type $installed
+ * @return type
+ */
 function list_getPackages($start, $items_per_page, $sort, $params, $installed)
 {
 	global $boarddir, $scripturl, $context, $forum_version;
@@ -1765,6 +1786,9 @@ function list_getPackages($start, $items_per_page, $sort, $params, $installed)
 	return $packages[$params];
 }
 
+/**
+ * Used when a temp FTP access is needed to package functions
+ */
 function PackageOptions()
 {
 	global $txt, $scripturl, $context, $sourcedir, $modSettings, $smcFunc;
@@ -2199,6 +2223,14 @@ function PackagePermissions()
 	}
 }
 
+/**
+ * Checkes the permissions of all the areas that will be affected by the package
+ *
+ * @param type $path
+ * @param type $data
+ * @param type $level
+ * @return type
+ */
 function fetchPerms__recursive($path, &$data, $level)
 {
 	global $context;
@@ -2478,6 +2510,12 @@ function PackagePermissionsAction()
 		// Haven't counted the items yet?
 		if (empty($context['total_items']))
 		{
+			/**
+			 * Counts all the directorys under a given path
+			 *
+			 * @param type $dir
+			 * @return integer
+			 */
 			function count_directories__recursive($dir)
 			{
 				global $context;
@@ -2513,6 +2551,13 @@ function PackagePermissionsAction()
 		if (!isset($_POST['specialFiles']) && $context['predefined_type'] != 'free')
 		{
 			$context['special_files'] = array();
+
+			/**
+			 * Builds a list of special files recusivly for a given path
+			 *
+			 * @param type $path
+			 * @param type $data
+			 */
 			function build_special_files__recursive($path, &$data)
 			{
 				global $context;

+ 20 - 16
Sources/PersonalMessage.php

@@ -174,6 +174,10 @@ function MessageMain()
 	$context['current_label_redirect'] = 'action=pm;f=' . $context['folder'] . (isset($_GET['start']) ? ';start=' . $_GET['start'] : '') . (isset($_REQUEST['l']) ? ';l=' . $_REQUEST['l'] : '');
 	$context['can_issue_warning'] = in_array('w', $context['admin_features']) && allowedTo('issue_warning') && $modSettings['warning_settings'][0] == 1;
 
+	// Are PM drafts enabled?
+	$context['drafts_pm_save'] = !empty($modSettings['drafts_enabled']) && !empty($modSettings['drafts_pm_enabled']) && allowedTo('pm_draft');
+	$context['drafts_autosave'] = !empty($context['drafts_pm_save']) && !empty($modSettings['drafts_autosave_enabled']) && allowedTo('pm_autosave_draft');
+	
 	// Build the linktree for all the actions...
 	$context['linktree'][] = array(
 		'url' => $scripturl . '?action=pm',
@@ -990,6 +994,9 @@ function prepareMessageContext($type = 'subject', $reset = false)
 		'is_replied_to' => &$context['message_replied'][$message['id_pm']],
 		'is_unread' => &$context['message_unread'][$message['id_pm']],
 		'is_selected' => !empty($temp_pm_selected) && in_array($message['id_pm'], $temp_pm_selected),
+		'is_message_author' => $message['id_member_from'] == $user_info['id'],
+		'can_report' => !empty($modSettings['enableReportPM']),
+		'can_see_ip' => allowedTo('moderate_forum') || ($message['id_member'] == $user_info['id'] && !empty($user_info['id'])),
 	);
 
 	$counter++;
@@ -1781,10 +1788,6 @@ function MessagePost()
 
 	$modSettings['disable_wysiwyg'] = !empty($modSettings['disable_wysiwyg']) || empty($modSettings['enableBBC']);
 
-	// Are PM drafts enabled?
-	$context['drafts_pm_save'] = !empty($modSettings['drafts_enabled']) && !empty($modSettings['drafts_pm_enabled']) && allowedTo('pm_draft');
-	$context['drafts_autosave'] = !empty($context['drafts_pm_save']) && !empty($modSettings['drafts_autosave_enabled']) && allowedTo('pm_autosave_draft');
-
 	// Generate a list of drafts that they can load in to the editor
 	if (!empty($context['drafts_pm_save']))
 	{
@@ -1835,10 +1838,6 @@ function MessageDrafts()
 {
 	global $context, $sourcedir, $user_info, $modSettings;
 
-	// Set draft capability
-	$context['drafts_pm_save'] = !empty($modSettings['drafts_pm_enabled']) && allowedTo('pm_draft');
-	$context['drafts_autosave'] = !empty($context['drafts_pm_save']) && !empty($modSettings['drafts_autosave_enabled']) && allowedTo('pm_autosave_draft');
-
 	// validate with loadMemberData()
 	$memberResult = loadMemberData($user_info['id'], false);
 	if (!is_array($memberResult))
@@ -1990,10 +1989,6 @@ function messagePostError($error_types, $named_recipients, $recipient_ids = arra
 			$context['error_type'] = 'serious';
 	}
 
-	// Need to reset draft capability once again
-	$context['drafts_pm_save'] = !empty($modSettings['drafts_pm_enabled']) && allowedTo('pm_draft');
-	$context['drafts_autosave'] = !empty($context['drafts_pm_save']) && !empty($modSettings['drafts_autosave_enabled']) && allowedTo('pm_autosave_draft');
-
 	// We need to load the editor once more.
 	require_once($sourcedir . '/Subs-Editor.php');
 
@@ -2044,6 +2039,10 @@ function MessagePost2()
 
 	isAllowedTo('pm_send');
 	require_once($sourcedir . '/Subs-Auth.php');
+	
+	// PM Drafts enabled and needed? 
+	if ($context['drafts_pm_save'] && (isset($_POST['save_draft']) || isset($_POST['id_pm_draft'])))
+		require_once($sourcedir . '/Drafts.php');
 
 	loadLanguage('PersonalMessage', '', false);
 
@@ -2254,9 +2253,8 @@ function MessagePost2()
 	}
 
 	// Want to save this as a draft and think about it some more?
-	if (!empty($modSettings['drafts_enabled']) && !empty($modSettings['drafts_pm_enabled']) && isset($_POST['save_draft']))
+	if ($context['drafts_pm_save'] && isset($_POST['save_draft']))
 	{
-		require_once($sourcedir . '/Drafts.php');
 		SavePMDraft($post_errors, $recipientList);
 		return messagePostError($post_errors, $namedRecipientList, $recipientList);
 	}
@@ -2310,7 +2308,13 @@ function MessagePost2()
 
 	// Message sent successfully?
 	if (!empty($context['send_log']) && empty($context['send_log']['failed']))
+	{
 		$context['current_label_redirect'] = $context['current_label_redirect'] . ';done=sent';
+		
+		// If we had a PM draft for this one, then its time to remove it since it was just sent
+		if ($context['drafts_pm_save'] && !empty($_POST['id_pm_draft']))
+			DeleteDraft($_POST['id_pm_draft']);
+	}
 
 	// Go back to the where they sent from, if possible...
 	redirectexit($context['current_label_redirect']);
@@ -2624,7 +2628,7 @@ function MessagePrune()
 /**
  * Delete the specified personal messages.
  *
- * @param array $personal_messages, array of pm ids
+ * @param array $personal_messages array of pm ids
  * @param string $folder = null
  * @param int $owner = null
  */
@@ -3656,7 +3660,7 @@ function LoadRules($reload = false)
  *
  * @param int $pmID
  * @param $validFor
- * @return bool
+ * @return boolean
  */
 function isAccessiblePM($pmID, $validFor = 'in_or_outbox')
 {

+ 10 - 3
Sources/Post.php

@@ -26,6 +26,8 @@ if (!defined('SMF'))
  * - requires different permissions depending on the actions, but most notably post_new, post_reply_own, and post_reply_any.
  * - shows options for the editing and posting of calendar events and attachments, as well as the posting of polls.
  * - accessed from ?action=post.
+ *
+ *  @param array $post_errors holds any errors found tyring to post
  */
 function Post($post_errors = array())
 {
@@ -1205,8 +1207,8 @@ function Post2()
 	require_once($sourcedir . '/Subs-Post.php');
 	loadLanguage('Post');
 
-	// Drafts enabled?
-	if (!empty($modSettings['drafts_enabled']) && isset($_POST['save_draft']))
+	// Drafts enabled and needed?
+	if (!empty($modSettings['drafts_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft'])))
 		require_once($sourcedir . '/Drafts.php');
 
 	// First check to see if they are trying to delete any current attachments.
@@ -1244,7 +1246,7 @@ function Post2()
 
 	// Then try to upload any attachments.
 	$context['can_post_attachment'] = !empty($modSettings['attachmentEnable']) && $modSettings['attachmentEnable'] == 1 && (allowedTo('post_attachment') || ($modSettings['postmod_active'] && allowedTo('post_unapproved_attachments')));
-	if ($context['can_post_attachment'] && !empty($_FILES['attachment']) && empty($_POST['from_qr']))
+	if ($context['can_post_attachment'] && empty($_POST['from_qr']))
 	{
 		 require_once($sourcedir . '/Attachments.php');
 		 processAttachments();
@@ -1827,6 +1829,10 @@ function Post2()
 		if (isset($topicOptions['id']))
 			$topic = $topicOptions['id'];
 	}
+	
+	// If we had a draft for this, its time to remove it since it was just posted
+	if (!empty($modSettings['drafts_enabled']) && !empty($_POST['id_draft']))
+		DeleteDraft($_POST['id_draft']);
 
 	// Editing or posting an event?
 	if (isset($_POST['calendar']) && (!isset($_REQUEST['eventid']) || $_REQUEST['eventid'] == -1))
@@ -2025,6 +2031,7 @@ function Post2()
 		$context['linktree'][] = array(
 			'url' => $scripturl . '?topic=' . $topic . '.0',
 			'name' => $_POST['subject'],
+			'extra_before' => $settings['linktree_inline'] ? $txt['topic'] . ': ' : ''
 		);
 
 		if (isset($_REQUEST['msg']))

+ 4 - 6
Sources/PostModeration.php

@@ -475,6 +475,7 @@ function UnapprovedAttachments()
 				'header' => array(
 					'value' => '<input type="checkbox" class="input_check" onclick="invertAll(this, this.form);" checked="checked" />',
 					'style' => 'width: 4%;',
+					'class' => 'centercol',
 				),
 				'data' => array(
 					'sprintf' => array(
@@ -483,7 +484,7 @@ function UnapprovedAttachments()
 							'id' => false,
 						),
 					),
-					'style' => 'text-align: center;',
+					'class' => 'centercol',
 				),
 			),
 		),
@@ -601,13 +602,10 @@ function list_getUnapprovedAttachments($start, $items_per_page, $sort, $approve_
 
 /**
  * Callback function for UnapprovedAttachments
- * count all the attachments waiting for approval the approver can approve
+ * count all the attachments waiting for approval that this approver can approve
  *
- * @param int $start
- * @param int $items_per_page
- * @param string $sort
  * @param string $approve_query additional restrictions based on the boards the approver can see
- * @return int, the number of unapproved attachments
+ * @return int the number of unapproved attachments
  */
 function list_getNumUnapprovedAttachments($approve_query)
 {

+ 3 - 3
Sources/Profile-Actions.php

@@ -473,7 +473,7 @@ function list_getUserWarningCount($memID)
  * @param int $start
  * @param int $items_per_page
  * @param string $sort
- * @param int $memID, the member ID
+ * @param int $memID the member ID
  * @return array the preview warnings
  */
 function list_getUserWarnings($start, $items_per_page, $sort, $memID)
@@ -516,7 +516,7 @@ function list_getUserWarnings($start, $items_per_page, $sort, $memID)
 /**
  * Present a screen to make sure the user wants to be deleted
  *
- * @param int $memID, the member ID
+ * @param int $memID the member ID
  */
 function deleteAccount($memID)
 {
@@ -538,7 +538,7 @@ function deleteAccount($memID)
 /**
  * Actually delete an account.
  *
- * @param int $memID, the member ID
+ * @param int $memID the member ID
  */
 function deleteAccount2($memID)
 {

+ 8 - 6
Sources/Profile-Modify.php

@@ -1329,7 +1329,7 @@ function editBuddyIgnoreLists($memID)
 	$context[$context['profile_menu_name']]['tab_data'] = array(
 		'title' => $txt['editBuddyIgnoreLists'],
 		'description' => $txt['buddy_ignore_desc'],
-		'icon' => 'profile_sm.png',
+		'icon' => 'profile_hd.png',
 		'tabs' => array(
 			'buddies' => array(),
 			'ignore' => array(),
@@ -1896,6 +1896,7 @@ function notification($memID)
 				'header' => array(
 					'value' => '<input type="checkbox" class="input_check" onclick="invertAll(this, this.form);" />',
 					'style' => 'width: 4%;',
+					'class' => 'centercol',
 				),
 				'data' => array(
 					'sprintf' => array(
@@ -1904,7 +1905,7 @@ function notification($memID)
 							'id' => false,
 						),
 					),
-					'style' => 'text-align: center;',
+					'class' => 'centercol',
 				),
 			),
 		),
@@ -2013,6 +2014,7 @@ function notification($memID)
 				'header' => array(
 					'value' => '<input type="checkbox" class="input_check" onclick="invertAll(this, this.form);" />',
 					'style' => 'width: 4%;',
+					'class' => 'centercol',
 				),
 				'data' => array(
 					'sprintf' => array(
@@ -2021,7 +2023,7 @@ function notification($memID)
 							'id' => false,
 						),
 					),
-					'style' => 'text-align: center;',
+					'class' => 'centercol',
 				),
 			),
 		),
@@ -2332,7 +2334,7 @@ function ignoreboards($memID)
 
 /**
  * Load all the languages for the profile.
- * @return bool
+ * @return boolean
  */
 function profileLoadLanguages()
 {
@@ -2890,7 +2892,7 @@ function profileSaveAvatarData(&$value)
  * Validate the signature
  *
  * @param mixed &$value
- * @return bool|string
+ * @return boolean|string
  */
 function profileValidateSignature(&$value)
 {
@@ -3074,7 +3076,7 @@ function profileValidateSignature(&$value)
  *
  * @param string $email
  * @param int $memID = 0
- * @return bool|string
+ * @return boolean|string
  */
 function profileValidateEmail($email, $memID = 0)
 {

+ 23 - 6
Sources/Profile-View.php

@@ -200,7 +200,7 @@ function showPosts($memID)
 	$context[$context['profile_menu_name']]['tab_data'] = array(
 		'title' => $txt['showPosts'],
 		'description' => $txt['showPosts_help'],
-		'icon' => 'profile_sm.png',
+		'icon' => 'profile_hd.png',
 		'tabs' => array(
 			'messages' => array(
 			),
@@ -559,7 +559,7 @@ function showAttachments($memID)
 				'header' => array(
 					'value' => $txt['show_attach_downloads'],
 					'class' => 'lefttext',
-					'style' => 'width: 25%',
+					'style' => 'width: 25%;',
 				),
 				'data' => array(
 					'db' => 'filename',
@@ -572,7 +572,7 @@ function showAttachments($memID)
 			'downloads' => array(
 				'header' => array(
 					'value' => $txt['show_attach_downloads'],
-					'style' => 'width: 12%',
+					'style' => 'width: 12%;',
 				),
 				'data' => array(
 					'db' => 'downloads',
@@ -587,7 +587,7 @@ function showAttachments($memID)
 				'header' => array(
 					'value' => $txt['message'],
 					'class' => 'lefttext',
-					'style' => 'width: 30%',
+					'style' => 'width: 30%;',
 				),
 				'data' => array(
 					'db' => 'subject',
@@ -619,6 +619,16 @@ function showAttachments($memID)
 
 }
 
+/**
+ * Get a list of attachments for this user
+ *
+ * @param type $start
+ * @param type $items_per_page
+ * @param type $sort
+ * @param type $boardsAllowed
+ * @param type $memID
+ * @return type
+ */
 function list_getAttachments($start, $items_per_page, $sort, $boardsAllowed, $memID)
 {
 	global $smcFunc, $board, $modSettings, $context;
@@ -670,6 +680,13 @@ function list_getAttachments($start, $items_per_page, $sort, $boardsAllowed, $me
 	return $attachments;
 }
 
+/**
+ * Gets the total number of attachments for the user
+ *
+ * @param type $boardsAllowed
+ * @param type $memID
+ * @return type
+ */
 function list_getNumAttachments($boardsAllowed, $memID)
 {
 	global $board, $smcFunc, $modSettings, $context;
@@ -919,7 +936,7 @@ function tracking($memID)
 	$context[$context['profile_menu_name']]['tab_data'] = array(
 		'title' => $txt['tracking'],
 		'description' => $txt['tracking_description'],
-		'icon' => 'profile_sm.png',
+		'icon' => 'profile_hd.png',
 		'tabs' => array(
 			'activity' => array(),
 			'ip' => array(),
@@ -2179,7 +2196,7 @@ function viewWarning($memID)
 			'reason' => array(
 				'header' => array(
 					'value' => $txt['profile_warning_previous_reason'],
-					'style' => 'width: 50%',
+					'style' => 'width: 50%;',
 				),
 				'data' => array(
 					'db' => 'reason',

+ 8 - 4
Sources/QueryString.php

@@ -294,8 +294,9 @@ function cleanRequest()
 
 /**
  * Validates a IPv6 address. returns true if it is ipv6.
+ *
  * @param string $ip ip address to be validated
- * @return bool true|false
+ * @return boolean true|false
  */
 function isValidIPv6($ip)
 {
@@ -307,6 +308,7 @@ function isValidIPv6($ip)
 
 /**
  * Converts IPv6s to numbers.  This makes ban checks much easier.
+ *
  * @param string $ip ip address to be converted
  * @return array
  */
@@ -333,8 +335,10 @@ function convertIPv6toInts($ip)
 
 /**
  * Expands a IPv6 address to its full form.
- * @param string $ip ip address to be converted
- * @return bool/string expanded ipv6 address.
+ *
+ * @param type $addr
+ * @param type $strict_check checks lenght to expaned address for compliance
+ * @return boolean/string expanded ipv6 address.
  */
 function expandIPv6($addr, $strict_check = true)
 {
@@ -555,7 +559,7 @@ function cleanXml($string)
 }
 
 /**
- * @todo needs a description
+ * Escapes (replaces) characters in strings to make them safe for use in javascript
  *
  * @param string $string
  * @return string

+ 6 - 2
Sources/RemoveTopic.php

@@ -3,7 +3,7 @@
 /**
  * The contents of this file handle the deletion of topics, posts, and related
  * paraphernalia.
- * 
+ *
  * Simple Machines Forum (SMF)
  *
  * @package SMF
@@ -1231,7 +1231,11 @@ function RestoreTopic()
 }
 
 /**
- * Take a load of messages from one place and stick them in a topic.
+ * Take a load of messages from one place and stick them in a topic
+ *
+ * @param array $msgs
+ * @param integer $from_topic
+ * @param integer $target_topic
  */
 function mergePosts($msgs = array(), $from_topic, $target_topic)
 {

+ 3 - 1
Sources/RepairBoards.php

@@ -157,7 +157,9 @@ function pauseRepairProcess($to_fix, $current_step_description, $max_substep = 0
 	obExit();
 }
 
-// Load up all the tests we might want to do ;)
+/**
+ * Load up all the tests we might want to do ;)
+ */
 function loadForumTests()
 {
 	global $errorTests;

+ 1 - 1
Sources/Reports.php

@@ -906,7 +906,7 @@ function addData($inc_data, $custom_table = null)
  * @param string $title = ''
  * @param string $custom_table = null
  *
- * @return bool returns false if there are no tables
+ * @return boolean returns false if there are no tables
  */
 function addSeparator($title = '', $custom_table = null)
 {

+ 14 - 1
Sources/ScheduledTasks.php

@@ -842,7 +842,12 @@ function scheduled_weekly_digest()
 }
 
 /**
- * Send a bunch of emails from the mail queue.
+ * Send a group of emails from the mail queue.
+ *
+ * @param type $number the number to send each loop through
+ * @param type $override_limit bypassing our limit flaf
+ * @param type $force_send
+ * @return boolean
  */
 function ReduceMailQueue($number = false, $override_limit = false, $force_send = false)
 {
@@ -1043,6 +1048,9 @@ function ReduceMailQueue($number = false, $override_limit = false, $force_send =
 
 /**
  * Calculate the next time the passed tasks should be triggered.
+ *
+ * @param type $tasks
+ * @param type $forceUpdate
  */
 function CalculateNextTrigger($tasks = array(), $forceUpdate = false)
 {
@@ -1109,6 +1117,11 @@ function CalculateNextTrigger($tasks = array(), $forceUpdate = false)
 
 /**
  * Simply returns a time stamp of the next instance of these time parameters.
+ *
+ * @param int $regularity
+ * @param type $unit
+ * @param type $offset
+ * @return int
  */
 function next_time($regularity, $unit, $offset)
 {

+ 2 - 2
Sources/Search.php

@@ -1933,7 +1933,7 @@ function prepareSearchContext($reset = false)
 				foreach ($context['key_words'] as $keyword)
 				{
 					$keyword = un_htmlspecialchars($keyword);
-					$keyword = preg_replace('~&amp;#(\d{1,7}|x[0-9a-fA-F]{1,6});~e', '$GLOBALS[\'smcFunc\'][\'entity_fix\'](\'\\1\')', strtr($keyword, array('\\\'' => '\'', '&' => '&amp;')));
+					$keyword = preg_replace('~(&amp;#(\d{1,7}|x[0-9a-fA-F]{1,6});)~e', 'entity_fix__callback', strtr($keyword, array('\\\'' => '\'', '&' => '&amp;')));
 
 					if (preg_match('~[\'\.,/@%&;:(){}\[\]_\-+\\\\]$~', $keyword) != 0 || preg_match('~^[\'\.,/@%&;:(){}\[\]_\-+\\\\]~', $keyword) != 0)
 						$force_partial_word = true;
@@ -1957,7 +1957,7 @@ function prepareSearchContext($reset = false)
 			}
 
 			// Re-fix the international characters.
-			$message['body'] = preg_replace('~&amp;#(\d{1,7}|x[0-9a-fA-F]{1,6});~e', '$GLOBALS[\'smcFunc\'][\'entity_fix\'](\'\\1\')', $message['body']);
+			$message['body'] = preg_replace('~(&amp;#(\d{1,7}|x[0-9a-fA-F]{1,6});)~e', 'entity_fix__callback', $message['body']);
 		}
 	}
 	else

+ 77 - 11
Sources/SearchAPI-Custom.php

@@ -14,23 +14,58 @@
 if (!defined('SMF'))
 	die('Hacking attempt...');
 
+/**
+ * Custom Search API class .. used when custom SMF index is used
+ */
 class custom_search
 {
-	// This is the last version of SMF that this was tested on, to protect against API changes.
+	/**
+	 *This is the last version of SMF that this was tested on, to protect against API changes.
+	 * @var type
+	 */
 	public $version_compatible = 'SMF 2.1 Alpha 1';
-	// This won't work with versions of SMF less than this.
+
+	/**
+	 *This won't work with versions of SMF less than this.
+	 * @var type
+	 */
 	public $min_smf_version = 'SMF 2.1 Alpha 1';
-	// Is it supported?
+
+	/**
+	 * Is it supported?
+	 * @var type
+	 */
 	public $is_supported = true;
 
+	/**
+	 * Index Settings
+	 * @var type
+	 */
 	protected $indexSettings = array();
-	// What words are banned?
+
+	/**
+	 * What words are banned?
+	 * @var type
+	 */
 	protected $bannedWords = array();
-	// What is the minimum word length?
+
+	/**
+	 * What is the minimum word length?
+	 * @var type
+	 */
 	protected $min_word_length = null;
-	// What databases support the custom index?
+
+	/**
+	 * What databases support the custom index?
+	 * @var type
+	 */
 	protected $supported_databases = array('mysql', 'postgresql', 'sqlite');
 
+	/**
+	 * constructor function
+	 *
+	 * @return type
+	 */
 	public function __construct()
 	{
 		global $modSettings, $db_type;
@@ -51,7 +86,13 @@ class custom_search
 		$this->min_word_length = $this->indexSettings['bytes_per_word'];
 	}
 
-	// Check whether the search can be performed by this API.
+	/**
+	 * Check whether the search can be performed by this API.
+	 *
+	 * @param type $methodName
+	 * @param type $query_params
+	 * @return boolean
+	 */
 	public function supportsMethod($methodName, $query_params = null)
 	{
 		switch ($methodName)
@@ -72,7 +113,11 @@ class custom_search
 		}
 	}
 
-	// If the settings don't exist we can't continue.
+	/**
+	 * If the settings don't exist we can't continue.
+	 *
+	 * @return type
+	 */
 	public function isValid()
 	{
 		global $modSettings;
@@ -98,7 +143,14 @@ class custom_search
 		return $y < $x ? 1 : ($y > $x ? -1 : 0);
 	}
 
-	// Do we have to do some work with the words we are searching for to prepare them?
+	/**
+	 * Do we have to do some work with the words we are searching for to prepare them?
+	 *
+	 * @param type $word
+	 * @param type $wordsSearch
+	 * @param type $wordsExclude
+	 * @param type $isExcluded
+	 */
 	public function prepareIndexes($word, &$wordsSearch, &$wordsExclude, $isExcluded)
 	{
 		global $modSettings, $smcFunc;
@@ -125,7 +177,13 @@ class custom_search
 		}
 	}
 
-	// Search for indexed words.
+	/**
+	 * Search for indexed words.
+	 *
+	 * @param type $words
+	 * @param type $search_data
+	 * @return type
+	 */
 	public function indexedWordQuery($words, $search_data)
 	{
 		global $modSettings, $smcFunc;
@@ -212,7 +270,11 @@ class custom_search
 	}
 
 	/**
-	 * After a post is made, we update the search index database.
+	 *  After a post is made, we update the search index database
+	 *
+	 * @param type $msgOptions
+	 * @param type $topicOptions
+	 * @param type $posterOptions
 	 */
 	public function postCreated($msgOptions, $topicOptions, $posterOptions)
 	{
@@ -235,6 +297,10 @@ class custom_search
 
 	/**
 	 * After a post is modified, we update the search index database.
+	 *
+	 * @param type $msgOptions
+	 * @param type $topicOptions
+	 * @param type $posterOptions
 	 */
 	public function postModified($msgOptions, $topicOptions, $posterOptions)
 	{

+ 37 - 9
Sources/SearchAPI-Fulltext.php

@@ -14,19 +14,46 @@
 if (!defined('SMF'))
 	die('Hacking attempt...');
 
+/**
+ * Fulltext API, used when an SQL fulltext index is used
+ */
 class fulltext_search
 {
-	// This is the last version of SMF that this was tested on, to protect against API changes.
+	/**
+	 * This is the last version of SMF that this was tested on, to protect against API changes.
+	 * @var type
+	 */
 	public $version_compatible = 'SMF 2.1 Alpha 1';
-	// This won't work with versions of SMF less than this.
+
+	/**
+	 * This won't work with versions of SMF less than this.
+	 * @var type
+	 */
 	public $min_smf_version = 'SMF 2.1 Alpha 1';
-	// Is it supported?
+
+	/**
+	 * Is it supported?
+	 *
+	 * @var type
+	 */
 	public $is_supported = true;
-	// What words are banned?
+
+	/**
+	 * What words are banned?
+	 * @var type
+	 */
 	protected $bannedWords = array();
-	// What is the minimum word length?
+
+	/**
+	 * What is the minimum word length?
+	 * @var type
+	 */
 	protected $min_word_length = 4;
-	// What databases support the fulltext index?
+
+	/**
+	 * What databases support the fulltext index?
+	 * @var type
+	 */
 	protected $supported_databases = array('mysql');
 
 	/**
@@ -104,11 +131,12 @@ class fulltext_search
 
 		return $min_word_length;
 	}
-	
+
 	/**
 	 * callback function for usort used to sort the fulltext results.
 	 * the order of sorting is: large words, small words, large words that
 	 * are excluded from the search, small words that are excluded.
+	 *
 	 * @param string $a Word A
 	 * @param string $b Word B
 	 * @return int
@@ -119,10 +147,10 @@ class fulltext_search
 
 		$x = $smcFunc['strlen']($a) - (in_array($a, $excludedWords) ? 1000 : 0);
 		$y = $smcFunc['strlen']($b) - (in_array($b, $excludedWords) ? 1000 : 0);
-		
+
 		return $x < $y ? 1 : ($x > $y ? -1 : 0);
 	}
-	
+
 	/**
 	 * fulltext_search::prepareIndexes()
 	 *

+ 24 - 4
Sources/SearchAPI-Standard.php

@@ -14,18 +14,38 @@
 if (!defined('SMF'))
 	die('Hacking attempt...');
 
+/**
+ * Standard non full index, non custom index search
+ */
 class standard_search
 {
-	// This is the last version of SMF that this was tested on, to protect against API changes.
+	/**
+	 * This is the last version of SMF that this was tested on, to protect against API changes.
+	 *
+	 * @var type
+	 */
 	public $version_compatible = 'SMF 2.1 ALpha';
 
-	// This won't work with versions of SMF less than this.
+	/**
+	 * This won't work with versions of SMF less than this.
+	 *
+	 * @var type
+	 */
 	public $min_smf_version = 'SMF 2.1 Alpha 1';
 
-	// Standard search is supported by default.
+	/**
+	 * Standard search is supported by default.
+	 * @var type
+	 */
 	public $is_supported = true;
 
-	// Method to check whether the method can be performed by the API.
+	/**
+	 * Method to check whether the method can be performed by the API.
+	 *
+	 * @param type $methodName
+	 * @param type $query_params
+	 * @return boolean
+	 */
 	public function supportsMethod($methodName, $query_params = null)
 	{
 		// Always fall back to the standard search method.

+ 7 - 7
Sources/Security.php

@@ -760,7 +760,7 @@ function createToken($action, $type = 'post')
  * @param string $action
  * @param string $type = 'post' (get, request, or post)
  * @param bool $reset = true
- * @return bool
+ * @return boolean
  */
 function validateToken($action, $type = 'post', $reset = true)
 {
@@ -848,7 +848,7 @@ function cleanTokens($complete = false)
  *
  * @param string $action
  * @param bool $is_fatal = true
- * @return bool
+ * @return boolean
  */
 function checkSubmitOnce($action, $is_fatal = true)
 {
@@ -894,7 +894,7 @@ function checkSubmitOnce($action, $is_fatal = true)
  *
  * @param string $permission
  * @param array $boards = null
- * @return bool if the user can do the permission
+ * @return boolean if the user can do the permission
  */
 function allowedTo($permission, $boards = null)
 {
@@ -1151,7 +1151,7 @@ function showEmailAddress($userProfile_hideEmail, $userProfile_id)
  * This function attempts to protect from spammed messages and the like.
  * The time taken depends on error_type - generally uses the modSetting.
  *
- * @param string $error_type, used also as a $txt index. (not an actual string.)
+ * @param string $error_type used also as a $txt index. (not an actual string.)
  * @return boolean
  */
 function spamProtection($error_type)
@@ -1210,9 +1210,9 @@ function spamProtection($error_type)
 /**
  * A generic function to create a pair of index.php and .htaccess files in a directory
  *
- * @param string $path, the (absolute) directory path
- * @param boolean $attachments, if the directory is an attachments directory or not
- * @return true on success, error string if anything fails
+ * @param string $path the (absolute) directory path
+ * @param boolean $attachments if the directory is an attachments directory or not
+ * @return true on success error string if anything fails
  */
 function secureDirectory($path, $attachments = false)
 {

+ 5 - 5
Sources/Session.php

@@ -101,7 +101,7 @@ function loadSession()
  *
  * @param string $save_path
  * @param string $session_name
- * @return bool
+ * @return boolean
  */
 function sessionOpen($save_path, $session_name)
 {
@@ -112,7 +112,7 @@ function sessionOpen($save_path, $session_name)
  * Implementation of sessionClose() replacing the standard close handler.
  * It simply returns true.
  *
- * @return bool
+ * @return boolean
  */
 function sessionClose()
 {
@@ -153,7 +153,7 @@ function sessionRead($session_id)
  *
  * @param string $session_id
  * @param string $data
- * @return bool
+ * @return boolean
  */
 function sessionWrite($session_id, $data)
 {
@@ -190,7 +190,7 @@ function sessionWrite($session_id, $data)
  * Implementation of sessionDestroy() replacing the standard destroy handler.
  *
  * @param string $session_id
- * @return bool
+ * @return boolean
  */
 function sessionDestroy($session_id)
 {
@@ -214,7 +214,7 @@ function sessionDestroy($session_id)
  * Callback for garbage collection.
  *
  * @param int $max_lifetime
- * @return bool
+ * @return boolean
  */
 function sessionGC($max_lifetime)
 {

+ 6 - 0
Sources/Subs-Admin.php

@@ -390,6 +390,8 @@ function updateSettingsFile($config_vars)
  * - Done separately from updateSettingsFile to avoid race conditions
  *   which can occur during a db error
  * - If it fails Settings.php will assume 0
+ *
+ * @param type $time
  */
 function updateDbLastError($time)
 {
@@ -441,6 +443,10 @@ function updateAdminPreferences()
  * - loads all users who are admins or have the admin forum permission.
  * - uses the email template and replacements passed in the parameters.
  * - sends them an email.
+ *
+ * @param string $template
+ * @param array $replacements
+ * @param array $additional_recipients
  */
 function emailAdmins($template, $replacements = array(), $additional_recipients = array())
 {

+ 9 - 19
Sources/Subs-Auth.php

@@ -23,7 +23,7 @@ if (!defined('SMF'))
  * - sets the cookie and session to last the number of seconds specified by cookie_length.
  * - when logging out, if the globalCookies setting is enabled, attempts to clear the subdomain's cookie too.
  *
- * @param int $cookie_length,
+ * @param int $cookie_length
  * @param int $id The id of the member
  * @param string $password = ''
  */
@@ -110,7 +110,7 @@ function setLoginCookie($cookie_length, $id, $password = '')
  * - normally, local and global should be the localCookies and globalCookies settings, respectively.
  * - uses boardurl to determine these two things.
  *
- * @param bool $local,
+ * @param bool $local
  * @param bool $global
  * @return array an array to set the cookie on with domain and path in it, in that order
  */
@@ -250,8 +250,8 @@ function adminLogin($type = 'admin')
  * Used by the adminLogin() function.
  * if 'value' is an array, the function is called recursively.
  *
- * @param string $key
- * @param string $value
+ * @param string $k key
+ * @param string $v value
  * @return string 'hidden' HTML form fields, containing key-value-pairs
  */
 function adminLogin_outputPostVars($k, $v)
@@ -316,7 +316,7 @@ function construct_query_string($get)
  * - searches for members whose username, display name, or e-mail address match the given pattern of array names.
  * - searches only buddies if buddies_only is set.
  *
- * @param array $names,
+ * @param array $names
  * @param bool $use_wildcards = false, accepts wildcards ? and * in the patern if true
  * @param bool $buddies_only = false,
  * @param int $max = 500 retrieves a maximum of max members, if passed
@@ -511,19 +511,7 @@ function RequestMembers()
 		$row['real_name'] = strtr($row['real_name'], array('&amp;' => '&#038;', '&lt;' => '&#060;', '&gt;' => '&#062;', '&quot;' => '&#034;'));
 
 		if (preg_match('~&#\d+;~', $row['real_name']) != 0)
-		{
-			$fixchar = create_function('$n', '
-				if ($n < 128)
-					return chr($n);
-				elseif ($n < 2048)
-					return chr(192 | $n >> 6) . chr(128 | $n & 63);
-				elseif ($n < 65536)
-					return chr(224 | $n >> 12) . chr(128 | $n >> 6 & 63) . chr(128 | $n & 63);
-				else
-					return chr(240 | $n >> 18) . chr(128 | $n >> 12 & 63) . chr(128 | $n >> 6 & 63) . chr(128 | $n & 63);');
-
-			$row['real_name'] = preg_replace('~&#(\d+);~e', '$fixchar(\'$1\')', $row['real_name']);
-		}
+			$row['real_name'] = preg_replace_callback('~&#(\d+);~', 'fixchar__callback', $row['real_name']);
 
 		echo $row['real_name'], "\n";
 	}
@@ -600,8 +588,10 @@ function resetPassword($memID, $username = null)
 /**
  * Checks a username obeys a load of rules
  *
- * @param int $memID,
+ * @param int $memID
  * @param string $username
+ * @param boolean $return_error
+ * @param boolean $check_reserved_name
  * @return string Returns null if fine
  */
 function validateUsername($memID, $username, $return_error = false, $check_reserved_name = true)

+ 1 - 1
Sources/Subs-Boards.php

@@ -1178,7 +1178,7 @@ function recursiveBoards(&$_boardList, &$_tree)
  * Returns whether the child board id is actually a child of the parent (recursive).
  * @param int $child
  * @param int $parent
- * @return bool
+ * @return boolean
  */
 function isChildOf($child, $parent)
 {

+ 25 - 25
Sources/Subs-Calendar.php

@@ -16,30 +16,11 @@
 if (!defined('SMF'))
 	die('Hacking attempt...');
 
-/**
- void insertEvent(
- * inserts the passed event information into the calendar table.
- * allows to either set a time span (in days) or an end_date.
- * does not check any permissions of any sort.
- * @param array $eventOptions
-
- void modifyEvent(
- * modifies an event.
- * allows to either set a time span (in days) or an end_date.
- * does not check any permissions of any sort.
- * @param int $event_id
- * @param array $eventOptions
-
- void removeEvent(
- * removes an event.
- * does no permission checks.
- * @param int $event_id
-*/
-
 /**
  * Get all birthdays within the given time range.
  * finds all the birthdays in the specified range of days.
  * works with birthdays set for no year, or any other year, and respects month and year boundaries.
+ *
  * @param string $low_date inclusive, YYYY-MM-DD
  * @param string $high_date inclusive, YYYY-MM-DD
  * @return array days, each of which an array of birthday information for the context
@@ -109,8 +90,8 @@ function getBirthdayRange($low_date, $high_date)
  * - censors the posted event titles.
  * - uses the current user's permissions if use_permissions is true, otherwise it does nothing "permission specific"
  *
- * @param string $earliest_date
- * @param string $latest_date
+ * @param string $low_date
+ * @param string $high_date
  * @param bool $use_permissions = true
  * @return array contextual information if use_permissions is true, and an array of the data needed to build that otherwise
  */
@@ -214,6 +195,7 @@ function getEventRange($low_date, $high_date, $use_permissions = true)
 
 /**
  * Get all holidays within the given time range.
+ *
  * @param string $low_date YYYY-MM-DD
  * @param string $high_date YYYY-MM-DD
  * @return array an array of days, which are all arrays of holiday names.
@@ -608,6 +590,7 @@ function getCalendarWeek($month, $year, $day, $calendarOptions)
  * cache callback function used to retrieve the birthdays, holidays, and events between now and now + days_to_index.
  * widens the search range by an extra 24 hours to support time offset shifts.
  * used by the cache_getRecentEvents function to get the information needed to calculate the events taking the users time offset into account.
+ *
  * @param int $days_to_index
  * @return array
  */
@@ -803,8 +786,8 @@ function validateEventPost()
 		// No title?
 		if ($smcFunc['htmltrim']($_POST['evtitle']) === '')
 			fatal_lang_error('no_event_title', false);
-		if ($smcFunc['strlen']($_POST['evtitle']) > 30)
-			$_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 30);
+		if ($smcFunc['strlen']($_POST['evtitle']) > 100)
+			$_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100);
 		$_POST['evtitle'] = str_replace(';', '', $_POST['evtitle']);
 	}
 }
@@ -842,6 +825,9 @@ function getEventPoster($event_id)
 
 /**
  * Consolidating the various INSERT statements into this function.
+ * inserts the passed event information into the calendar table.
+ * allows to either set a time span (in days) or an end_date.
+ * does not check any permissions of any sort.
  *
  * @param array $eventOptions
  */
@@ -898,8 +884,12 @@ function insertEvent(&$eventOptions)
 }
 
 /**
+ * modifies an event.
+ * allows to either set a time span (in days) or an end_date.
+ * does not check any permissions of any sort.
+ *
  * @param int $event_id
- * @param array &$eventOptions
+ * @param array $eventOptions
  */
 function modifyEvent($event_id, &$eventOptions)
 {
@@ -958,6 +948,9 @@ function modifyEvent($event_id, &$eventOptions)
 
 /**
  * Remove an event
+ * removes an event.
+ * does no permission checks.
+ *
  * @param int $event_id
  */
 function removeEvent($event_id)
@@ -980,6 +973,8 @@ function removeEvent($event_id)
 }
 
 /**
+ * Gets all the events properties
+ *
  * @param int $event_id
  * @return array
  */
@@ -1037,6 +1032,7 @@ function getEventProperties($event_id)
 }
 
 /**
+ * Gets all of the holidays for the listing
  *
  * @param int $start
  * @param int $items_per_page
@@ -1065,6 +1061,8 @@ function list_getHolidays($start, $items_per_page, $sort)
 }
 
 /**
+ * Helper function to get the total number of holidays
+ *
  * @return int
  */
 function list_getNumHolidays()
@@ -1084,6 +1082,8 @@ function list_getNumHolidays()
 }
 
 /**
+ * Remove a holdiay from the calendar
+ *
  * @param array $holiday_ids An array of
  */
 function removeHolidays($holiday_ids)

+ 3 - 4
Sources/Subs-Categories.php

@@ -122,7 +122,6 @@ function modifyCategory($category_id, $catOptions)
  * allows (almost) the same options as the modifyCat() function.
  * returns the ID of the newly created category.
  *
- * @param int $createCategory
  * @param array $catOptions
  */
 function createCategory($catOptions)
@@ -147,7 +146,7 @@ function createCategory($catOptions)
 	$cat_parameters = array(
 		$catOptions['cat_name'],
 	);
-	
+
 	call_integration_hook('integrate_create_category', array(&$catOptions, &$cat_columns, &$cat_parameters));
 
 	// Add the category to the database.
@@ -178,8 +177,8 @@ function createCategory($catOptions)
  * deletes all information that's associated with the given categories.
  * updates the statistics to reflect the new situation.
  *
- * @param array $categories_to_remove
- * @param int $moveChildrenTo = null
+ * @param string $categories
+ * @param int $moveBoardsTo = null
  */
 function deleteCategories($categories, $moveBoardsTo = null)
 {

+ 17 - 15
Sources/Subs-Db-mysql.php

@@ -19,11 +19,14 @@ if (!defined('SMF'))
 /**
  *  Maps the implementations in this file (smf_db_function_name)
  *  to the $smcFunc['db_function_name'] variable.
- *  @param string $db_server
- *  @param string $db_name
- *  @param string $db_user
- *  @param string $db_passwd
- *  @param array $db_options = array()
+ *
+ * @param string $db_server
+ * @param string $db_name
+ * @param string $db_user
+ * @param string $db_passwd
+ * @param string $db_prefix
+ * @param array $db_options
+ * @return null
  */
 function smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options = array())
 {
@@ -87,8 +90,7 @@ function smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix,
  * Extend the database functionality. It calls the respective file's init
  * to add the implementations in that file to $smcFunc array.
  *
- * @param string $type, indicated which additional file to load.
- * ('extra', 'packages')
+ * @param string $type indicated which additional file to load. ('extra', 'packages')
  */
 function db_extend($type = 'extra')
 {
@@ -101,6 +103,7 @@ function db_extend($type = 'extra')
 
 /**
  * Fix up the prefix so it doesn't require the database to be selected.
+ *
  * @param string &db_prefix
  * @param string $db_name
  */
@@ -110,12 +113,10 @@ function db_fix_prefix(&$db_prefix, $db_name)
 }
 
 /**
- * Callback for preg_replace_calback on the query.
- * It allows to replace on the fly a few pre-defined strings, for
- * convenience ('query_see_board', 'query_wanna_see_board'), with
+ * Callback for preg_replace_callback on the query.
+ * It allows to replace on the fly a few pre-defined strings, for convenience ('query_see_board', 'query_wanna_see_board'), with
  * their current values from $user_info.
- * In addition, it performs checks and sanitization on the values
- * sent to the database.
+ * In addition, it performs checks and sanitization on the values sent to the database.
  *
  * @param $matches
  */
@@ -224,8 +225,8 @@ function smf_db_replacement__callback($matches)
 }
 
 /**
- * Just like the db_query, escape and quote a string,
- * but not executing the query.
+ * Just like the db_query, escape and quote a string, but not executing the query.
+ *
  * @param string $db_string
  * @param array $db_values
  * @param resource $connection = null
@@ -252,6 +253,7 @@ function smf_db_quote($db_string, $db_values, $connection = null)
 
 /**
  * Do a query.  Takes care of errors too.
+ *
  * @param string $identifier
  * @param string $db_string
  * @param array $db_values = array()
@@ -650,7 +652,7 @@ function smf_db_error($db_string, $connection = null)
 /**
  * insert
  *
- * @param string $method, options 'replace', 'ignore', 'insert'
+ * @param string $method - options 'replace', 'ignore', 'insert'
  * @param $table
  * @param $columns
  * @param $data

+ 28 - 4
Sources/Subs-Db-postgresql.php

@@ -17,9 +17,17 @@ if (!defined('SMF'))
 	die('Hacking attempt...');
 
 /**
- *  Maps the implementations in this file (smf_db_function_name)
- *  to the $smcFunc['db_function_name'] variable.
- *  @see Subs-Db-mysql.php#smf_db_initiate
+ * Maps the implementations in this file (smf_db_function_name)
+ * to the $smcFunc['db_function_name'] variable.
+ * @see Subs-Db-mysql.php#smf_db_initiate
+ *
+ * @param type $db_server
+ * @param type $db_name
+ * @param type $db_user
+ * @param type $db_passwd
+ * @param type $db_prefix
+ * @param type $db_options
+ * @return null
  */
 function smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, &$db_prefix, $db_options = array())
 {
@@ -75,6 +83,7 @@ function smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, &$db_prefix
 /**
  * Extend the database functionality. It calls the respective file's init
  * to add the implementations in that file to $smcFunc array.
+ *
  * @param string $type = 'extra'
  */
 function db_extend ($type = 'extra')
@@ -89,6 +98,10 @@ function db_extend ($type = 'extra')
 /**
  * Fix the database prefix if necessary.
  * Do nothing on postgreSQL
+ *
+ * @param type $db_prefix
+ * @param type $db_name
+ * @return type
  */
 function db_fix_prefix (&$db_prefix, $db_name)
 {
@@ -207,6 +220,11 @@ function smf_db_replacement__callback($matches)
 /**
  * Just like the db_query, escape and quote a string,
  * but not executing the query.
+ *
+ * @param string $db_string
+ * @param string $db_values
+ * @param type $connection
+ * @return type
  */
 function smf_db_quote($db_string, $db_values, $connection = null)
 {
@@ -232,6 +250,12 @@ function smf_db_quote($db_string, $db_values, $connection = null)
  * Do a query.  Takes care of errors too.
  * Special queries may need additional replacements to be appropriate
  * for PostgreSQL.
+ *
+ * @param string $identifier
+ * @param string $db_string
+ * @param string $db_values
+ * @param type $connection
+ * @return boolean
  */
 function smf_db_query($identifier, $db_string, $db_values = array(), $connection = null)
 {
@@ -644,7 +668,7 @@ function smf_db_unescape_string($string)
 /**
  * insert
  *
- * @param string $method, options 'replace', 'ignore', 'insert'
+ * @param string $method - options 'replace', 'ignore', 'insert'
  * @param $table
  * @param $columns
  * @param $data

+ 21 - 1
Sources/Subs-Db-sqlite.php

@@ -19,6 +19,13 @@ if (!defined('SMF'))
 /**
  *  Maps the implementations in this file (smf_db_function_name)
  *  to the $smcFunc['db_function_name'] variable.
+ *
+ * @param string $db_server
+ * @param string $db_name
+ * @param string $db_user
+ * @param string $db_passwd
+ * @param string $db_prefix
+ * @param array $db_options
  */
 function smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options = array())
 {
@@ -90,7 +97,7 @@ function smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix,
  * Extend the database functionality. It calls the respective file's init
  * to add the implementations in that file to $smcFunc array.
  *
- * @param string $type, indicated which additional file to load. ('extra', 'packages')
+ * @param string $type indicated which additional file to load. ('extra', 'packages')
  */
 function db_extend($type = 'extra')
 {
@@ -104,6 +111,9 @@ function db_extend($type = 'extra')
 /**
  * Fix db prefix if necessary.
  * SQLite doesn't actually need this!
+ *
+ * @param type $db_prefix
+ * @param type $db_name
  */
 function db_fix_prefix(&$db_prefix, $db_name)
 {
@@ -222,6 +232,10 @@ function smf_db_replacement__callback($matches)
 /**
  * Just like the db_query, escape and quote a string,
  * but not executing the query.
+ *
+ * @param string $db_string
+ * @param string $db_values
+ * @param resource $connection
  */
 function smf_db_quote($db_string, $db_values, $connection = null)
 {
@@ -245,6 +259,11 @@ function smf_db_quote($db_string, $db_values, $connection = null)
 
 /**
  * Do a query.  Takes care of errors too.
+ *
+ * @param string $identifier
+ * @param string $db_string
+ * @param string $db_values
+ * @param resource $connection
  */
 function smf_db_query($identifier, $db_string, $db_values = array(), $connection = null)
 {
@@ -391,6 +410,7 @@ function smf_db_query($identifier, $db_string, $db_values = array(), $connection
 
 /**
  * affected_rows
+ *
  * @param resource $connection
  */
 function smf_db_affected_rows($connection = null)

+ 7 - 0
Sources/Subs-Editor.php

@@ -1467,6 +1467,8 @@ function create_control_richedit($editorOptions)
 	{
 		// Some general stuff.
 		$settings['smileys_url'] = $modSettings['smileys_url'] . '/' . $user_info['smiley_set'];
+		if (!empty($context['drafts_autosave']) && !empty($options['drafts_autosave_enabled']))
+			$context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000;
 
 		// This really has some WYSIWYG stuff.
 		loadTemplate('GenericControls', 'jquery.sceditor');
@@ -2231,6 +2233,11 @@ function AutoSuggest_Search_Member()
 	return $xml_data;
 }
 
+/**
+ * Provides a list of possible SMF versions to use in emulation
+ * 
+ * @return string
+ */
 function AutoSuggest_Search_SMFVersions()
 {
 

+ 7 - 6
Sources/Subs-Graphics.php

@@ -29,11 +29,11 @@ if (!defined('SMF'))
  * - updates the database info for the member's avatar.
  * - returns whether the download and resize was successful.
  *
- * @param string $temporary_path, the full path to the temporary file
- * @param int $memID, member ID
+ * @param string $url the full path to the temporary file
+ * @param int $memID member ID
  * @param int $max_width
  * @param int $max_height
- * @return bool, whether the download and resize was successful.
+ * @return boolean whether the download and resize was successful.
  *
  */
 function downloadAvatar($url, $memID, $max_width, $max_height)
@@ -145,7 +145,7 @@ function downloadAvatar($url, $memID, $max_width, $max_height)
  * @param string $source
  * @param int $max_width
  * @param int $max_height
- * @return bool, whether the thumbnail creation was successful.
+ * @return boolean, whether the thumbnail creation was successful.
  */
 function createThumbnail($source, $max_width, $max_height)
 {
@@ -180,7 +180,7 @@ function createThumbnail($source, $max_width, $max_height)
  *
  * @param string $fileName
  * @param int $preferred_format = 0
- * @return bool, true on success, false on failure.
+ * @return boolean, true on success, false on failure.
  */
 function reencodeImage($fileName, $preferred_format = 0)
 {
@@ -277,6 +277,7 @@ function checkImagick()
 /**
  * See if we have enough memory to thumbnail an image
  *
+ * @param array $sizes image size
  * @return whether we do
  */
 function imageMemoryCheck($sizes)
@@ -733,7 +734,7 @@ if (!function_exists('imagecreatefrombmp'))
  * @param resource $gif
  * @param string $lpszFileName
  * @param int $background_color = -1
- * @return bool, whether it was successful or not.
+ * @return boolean, whether it was successful or not.
  */
 function gif_outputAsPng($gif, $lpszFileName, $background_color = -1)
 {

+ 4 - 2
Sources/Subs-List.php

@@ -82,7 +82,8 @@ function createList($listOptions)
 		$list_context['items_per_page'] = $listOptions['items_per_page'];
 
 		// Then create a page index.
-		$list_context['page_index'] = constructPageIndex($listOptions['base_href'] . (empty($list_context['sort']) ? '' : ';' . $request_var_sort . '=' . $list_context['sort']['id'] . ($list_context['sort']['desc'] ? ';' . $request_var_desc : '')) . ($list_context['start_var_name'] != 'start' ? ';' . $list_context['start_var_name'] . '=%1$d' : ''), $list_context['start'], $list_context['total_num_items'], $list_context['items_per_page'], $list_context['start_var_name'] != 'start');
+		if ($list_context['total_num_items'] > $list_context['items_per_page'])
+			$list_context['page_index'] = constructPageIndex($listOptions['base_href'] . (empty($list_context['sort']) ? '' : ';' . $request_var_sort . '=' . $list_context['sort']['id'] . ($list_context['sort']['desc'] ? ';' . $request_var_desc : '')) . ($list_context['start_var_name'] != 'start' ? ';' . $list_context['start_var_name'] . '=%1$d' : ''), $list_context['start'], $list_context['total_num_items'], $list_context['items_per_page'], $list_context['start_var_name'] != 'start');
 	}
 
 	// Prepare the headers of the table.
@@ -108,7 +109,8 @@ function createList($listOptions)
 
 	// Call the function and include which items we want and in what order.
 	$list_items = call_user_func_array($listOptions['get_items']['function'], array_merge(array($list_context['start'], $list_context['items_per_page'], $sort), empty($listOptions['get_items']['params']) ? array() : $listOptions['get_items']['params']));
-
+	$list_items = empty($list_items) ? array() : $list_items;
+	
 	// Loop through the list items to be shown and construct the data values.
 	$list_context['rows'] = array();
 	foreach ($list_items as $item_id => $list_item)

+ 22 - 5
Sources/Subs-Membergroups.php

@@ -24,7 +24,7 @@ if (!defined('SMF'))
  * Deletes the permissions linked to the membergroup.
  * Takes members out of the deleted membergroups.
  * @param array $groups
- * @return bool
+ * @return boolean
  */
 function deleteMembergroups($groups)
 {
@@ -209,7 +209,7 @@ function deleteMembergroups($groups)
  * @param array $members
  * @param array $groups = null if groups is null, the specified members are stripped from all their membergroups.
  * @param bool $permissionCheckDone = false
- * @return bool
+ * @return boolean
  */
 function removeMembersFromGroups($members, $groups = null, $permissionCheckDone = false)
 {
@@ -434,7 +434,7 @@ function removeMembersFromGroups($members, $groups = null, $permissionCheckDone
  * 	- auto              - Assigns a membergroup to the primary group if it's still
  * 						  available. If not, assign it to the additional group.
  * @param bool $permissionCheckDone
- * @return bool success or failure
+ * @return boolean success or failure
  */
 function addMembersToGroup($members, $group, $type = 'auto', $permissionCheckDone = false)
 {
@@ -575,11 +575,13 @@ function addMembersToGroup($members, $group, $type = 'auto', $permissionCheckDon
 }
 
 /**
+ * Gets the members of a supplied membergroup
+ * Returns them as a link for display
  *
  * @param array &$members
  * @param int $membergroup
  * @param int $limit = null
- * @return bool
+ * @return boolean
  */
 function listMembergroupMembers_Href(&$members, $membergroup, $limit = null)
 {
@@ -609,7 +611,13 @@ function listMembergroupMembers_Href(&$members, $membergroup, $limit = null)
 		return false;
 }
 
-// Retrieve a list of (visible) membergroups used by the cache.
+/**
+ * Retrieve a list of (visible) membergroups used by the cache.
+ *
+ * @global type $scripturl
+ * @global type $smcFunc
+ * @return type
+ */
 function cache_getMembergroupList()
 {
 	global $scripturl, $smcFunc;
@@ -641,6 +649,15 @@ function cache_getMembergroupList()
 	);
 }
 
+/**
+ * Helper function to generate a list of membergroups for display
+ *
+ * @param type $start
+ * @param type $items_per_page
+ * @param type $sort
+ * @param type $membergroup_type
+ * @return type
+ */
 function list_getMembergroups($start, $items_per_page, $sort, $membergroup_type)
 {
 	global $txt, $scripturl, $context, $settings, $smcFunc;

+ 13 - 15
Sources/Subs-Members.php

@@ -22,13 +22,13 @@ if (!defined('SMF'))
  * respectively removing your own account or any account.
  * Non-admins cannot delete admins.
  * The function:
- * - changes author of messages, topics and polls to guest authors.
- * - removes all log entries concerning the deleted members, except the
+ *   - changes author of messages, topics and polls to guest authors.
+ *   - removes all log entries concerning the deleted members, except the
  * error logs, ban logs and moderation logs.
- * - removes these members' personal messages (only the inbox), avatars,
+ *   - removes these members' personal messages (only the inbox), avatars,
  * ban entries, theme settings, moderator positions, poll votes, and
  * karma votes.
- * - updates member statistics afterwards.
+ *   - updates member statistics afterwards.
  *
  * @param array $users
  * @param bool $check_not_admin = false
@@ -866,14 +866,7 @@ function isReservedName($name, $current_ID_MEMBER = 0, $is_name = true, $fatal =
 {
 	global $user_info, $modSettings, $smcFunc, $context;
 
-	// No cheating with entities please.
-	$replaceEntities = create_function('$string', '
-		$num = substr($string, 0, 1) === \'x\' ? hexdec(substr($string, 1)) : (int) $string;' . (empty($context['utf8']) ? '
-		return $num < 0x20 ? \'\' : ($num < 0x80 ? chr($num) : \'&#\' . $string . \';\');' : '
-		return $num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) ? \'\' : ($num < 0x80 ? chr($num) : ($num < 0x800 ? chr(192 | $num >> 6) . chr(128 | $num & 63) : ($num < 0x10000 ? chr(224 | $num >> 12) . chr(128 | $num >> 6 & 63) . chr(128 | $num & 63) : chr(240 | $num >> 18) . chr(128 | $num >> 12 & 63) . chr(128 | $num >> 6 & 63) . chr(128 | $num & 63))));')
-	);
-
-	$name = preg_replace('~(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)~e', '$replaceEntities(\'\\2\')', $name);
+	$name = preg_replace_callback('~(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'replaceEntities__callback', $name);
 	$checkName = $smcFunc['strtolower']($name);
 
 	// Administrators are never restricted ;).
@@ -890,7 +883,7 @@ function isReservedName($name, $current_ID_MEMBER = 0, $is_name = true, $fatal =
 				continue;
 
 			// The admin might've used entities too, level the playing field.
-			$reservedCheck = preg_replace('~(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)~e', '$replaceEntities(\'\\2\')', $reserved);
+			$reservedCheck = preg_replace('~(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'replaceEntities__callback', $reserved);
 
 			// Case sensitive name?
 			if (empty($modSettings['reserveCase']))
@@ -1290,6 +1283,7 @@ function list_getNumMembers($where, $where_params = array())
 }
 
 /**
+ * Find potential duplicate registation members based on the same IP address
  *
  * @param $members
  */
@@ -1407,8 +1401,12 @@ function populateDuplicateMembers(&$members)
 		}
 }
 
-// Generate a random validation code.
-// @todo Err. Whatcha doin' here.
+/**
+ * Generate a random validation code.
+ * @todo Err. Whatcha doin' here.
+ *
+ * @return type
+ */
 function generateValidationCode()
 {
 	global $smcFunc, $modSettings;

+ 2 - 2
Sources/Subs-Menu.php

@@ -20,7 +20,7 @@ if (!defined('SMF'))
  * Create a menu.
  * @param array $menuData
  * @param array $menuOptions = array()
- * @return bool|array
+ * @return boolean|array
  */
 function createMenu($menuData, $menuOptions = array())
 {
@@ -280,7 +280,7 @@ function createMenu($menuData, $menuOptions = array())
 /**
  * Delete a menu.
  * @param string $menu_id = 'last'
- * @return bool
+ * @return boolean
  */
 function destroyMenu($menu_id = 'last')
 {

+ 7 - 0
Sources/Subs-MessageIndex.php

@@ -14,6 +14,13 @@
 if (!defined('SMF'))
 	die('Hacking attempt...');
 
+/**
+ * Generates the query to determine the list of available boards for a user
+ * Executes the query and returns the list
+ *
+ * @param type $boardListOptions
+ * @return type
+ */
 function getBoardList($boardListOptions = array())
 {
 	global $smcFunc, $user_info;

+ 2 - 2
Sources/Subs-OpenID.php

@@ -81,7 +81,7 @@ function smf_openID_validate($openid_uri, $return = false, $save_fields = array(
 
 /**
  * Revalidate a user using OpenID. Note that this function will not return when authentication is required.
- * @return bool
+ * @return boolean
  */
 function smf_openID_revalidate()
 {
@@ -520,7 +520,7 @@ function smf_openid_generate_private_key()
  *
  * Enter description here ...
  * @param string $openid_url
- * @return bool|array
+ * @return boolean|array
  */
 function smf_openID_getServerInfo($openid_url)
 {

+ 71 - 15
Sources/Subs-Package.php

@@ -22,7 +22,8 @@ if (!defined('SMF'))
 /**
  * Reads a .tar.gz file, filename, in and extracts file(s) from it.
  * essentially just a shortcut for read_tgz_data().
- * @param string $filename
+ *
+ * @param string $gzfilename
  * @param string $destination
  * @param bool $single_file = false
  * @param bool $overwrite = false
@@ -225,7 +226,16 @@ function read_tgz_data($data, $destination, $single_file = false, $overwrite = f
 		return $return;
 }
 
-// Extract zip data.  If destination is null, return a listing.
+/**
+ * Extract zip data.  If destination is null, return a listing.
+ *
+ * @param type $data
+ * @param type $destination
+ * @param type $single_file
+ * @param type $overwrite
+ * @param type $files_to_extract
+ * @return boolean
+ */
 function read_zip_data($data, $destination, $single_file = false, $overwrite = false, $files_to_extract = null)
 {
 	umask(0);
@@ -342,7 +352,7 @@ function read_zip_data($data, $destination, $single_file = false, $overwrite = f
  * Checks the existence of a remote file since file_exists() does not do remote.
  * will return false if the file is "moved permanently" or similar.
  * @param string url
- * @return bool true if the remote url exists.
+ * @return boolean true if the remote url exists.
  */
 function url_exists($url)
 {
@@ -432,7 +442,7 @@ function loadInstalledPackages()
  * - otherwise returns a basic array of id, version, filename, and similar information.
  * - an xmlArray is available in 'xml'.
  *
- * @param string $filename
+ * @param string $gzfilename
  * @return array
  */
 function getPackageInfo($gzfilename)
@@ -487,7 +497,14 @@ function getPackageInfo($gzfilename)
 	return $package;
 }
 
-// Create a chmod control for chmoding files.
+/**
+ * Create a chmod control for chmoding files.
+ *
+ * @param type $chmodFiles
+ * @param type $chmodOptions
+ * @param type $restore_write_status
+ * @return boolean
+ */
 function create_chmod_control($chmodFiles = array(), $chmodOptions = array(), $restore_write_status = false)
 {
 	global $context, $modSettings, $package_ftp, $boarddir, $txt, $sourcedir, $scripturl;
@@ -495,6 +512,15 @@ function create_chmod_control($chmodFiles = array(), $chmodOptions = array(), $r
 	// If we're restoring the status of existing files prepare the data.
 	if ($restore_write_status && isset($_SESSION['pack_ftp']) && !empty($_SESSION['pack_ftp']['original_perms']))
 	{
+		/**
+		 * Get a listing of files that will need to be set back to the original state
+		 *
+		 * @param type $dummy1
+		 * @param type $dummy2
+		 * @param type $dummy3
+		 * @param type $do_change
+		 * @return type
+		 */
 		function list_restoreFiles($dummy1, $dummy2, $dummy3, $do_change)
 		{
 			global $txt;
@@ -594,6 +620,7 @@ function create_chmod_control($chmodFiles = array(), $chmodOptions = array(), $r
 				'check' => array(
 					'header' => array(
 						'value' => '<input type="checkbox" onclick="invertAll(this, this.form);" class="input_check" />',
+						'class' => 'centercol',
 					),
 					'data' => array(
 						'sprintf' => array(
@@ -602,7 +629,7 @@ function create_chmod_control($chmodFiles = array(), $chmodOptions = array(), $r
 								'path' => false,
 							),
 						),
-						'style' => 'text-align: center',
+						'class' => 'centercol',
 					),
 				),
 				'result' => array(
@@ -627,7 +654,6 @@ function create_chmod_control($chmodFiles = array(), $chmodOptions = array(), $r
 					'position' => 'below_table_data',
 					'value' => '<input type="submit" name="restore_perms" value="' . $txt['package_restore_permissions_restore'] . '" class="button_submit" />',
 					'class' => 'titlebg',
-					'style' => 'text-align: right;',
 				),
 				array(
 					'position' => 'after_title',
@@ -793,6 +819,8 @@ function create_chmod_control($chmodFiles = array(), $chmodOptions = array(), $r
 }
 
 /**
+ * Use FTP functions to work with a package download/install
+ *
  * @param string $destination_url
  * @param array $files = none
  * @param bool $return = false
@@ -1442,6 +1470,8 @@ function parsePackageInfo(&$packageXML, $testing_only = true, $method = 'install
  * - returns true if the version matched.
  *
  * @param string $versions
+ * @param boolean $reset
+ * @param type $the_version
  * @return highest install value string or false
  */
 function matchHighestPackageVersion($versions, $reset = false, $the_version)
@@ -1481,7 +1511,7 @@ function matchHighestPackageVersion($versions, $reset = false, $the_version)
  *
  * @param string $version
  * @param string $versions
- * @return bool
+ * @return boolean
  */
 function matchPackageVersion($version, $versions)
 {
@@ -1582,6 +1612,7 @@ function compareVersions($version1, $version2)
 
 /**
  * Parses special identifiers out of the specified path.
+ *
  * @param string $path
  * @return string The parsed path
  */
@@ -1617,8 +1648,9 @@ function parse_path($path)
 /**
  * Deletes a directory, and all the files and direcories inside it.
  * requires access to delete these files.
- * @param string $path
- * @param bool $delete_directory = true
+ *
+ * @param string $dir
+ * @param bool $delete_dir = true
  */
 function deltree($dir, $delete_dir = true)
 {
@@ -1692,9 +1724,10 @@ function deltree($dir, $delete_dir = true)
 /**
  * Creates the specified tree structure with the mode specified.
  * creates every directory in path until it finds one that already exists.
- * @param string $path
+ *
+ * @param string $strPath
  * @param int $mode
- * @return bool true if successful, false otherwise
+ * @return boolean true if successful, false otherwise
  */
 function mktree($strPath, $mode)
 {
@@ -1761,6 +1794,7 @@ function mktree($strPath, $mode)
 /**
  * Copies one directory structure over to another.
  * requires the destination to be writable.
+ *
  * @param string $source
  * @param string $destination
  */
@@ -1807,6 +1841,8 @@ function copytree($source, $destination)
 }
 
 /**
+ * Create a tree listing for a given directory path
+ *
  * @param string $path
  * @param string $sub_path = ''
  * @return array
@@ -1839,6 +1875,7 @@ function listtree($path, $sub_path = '')
 
 /**
  * Parses a xml-style modification file (file).
+ *
  * @param string $file
  * @param bool $testing = true tells it the modifications shouldn't actually be saved.
  * @param bool $undo = false specifies that the modifications the file requests should be undone; this doesn't work with everything (regular expressions.)
@@ -2534,6 +2571,12 @@ function parseBoardMod($file, $testing = true, $undo = false, $theme_paths = arr
 	return $actions;
 }
 
+/**
+ * Get the physical contents of a packages file
+ *
+ * @param type $filename
+ * @return boolean
+ */
 function package_get_contents($filename)
 {
 	global $package_cache, $modSettings;
@@ -2561,8 +2604,10 @@ function package_get_contents($filename)
  * uses FTP to create/chmod the file when necessary and available.
  * uses text mode for text mode file extensions.
  * returns the number of bytes written.
+ *
  * @param string $filename
  * @param string $data
+ * @param bool testing
  * @return int
  */
 function package_put_contents($filename, $data, $testing = false)
@@ -2618,6 +2663,12 @@ function package_put_contents($filename, $data, $testing = false)
 	return strlen($data);
 }
 
+/**
+ * Clears (removes the files) the current package cache (temp directory)
+ *
+ * @param type $trash
+ * @return type
+ */
 function package_flush_cache($trash = false)
 {
 	global $package_ftp, $package_cache;
@@ -2676,7 +2727,7 @@ function package_flush_cache($trash = false)
  * @param string $filename
  * @param string $perm_state = 'writable'
  * @param bool $track_change = false
- * @return bool True if it worked, false if it didn't
+ * @return boolean True if it worked, false if it didn't
  */
 function package_chmod($filename, $perm_state = 'writable', $track_change = false)
 {
@@ -3135,10 +3186,15 @@ function fetch_web_data($url, $post_data = '', $keep_alive = false, $redirection
 	return $data;
 }
 
-// crc32 doesn't work as expected on 64-bit functions - make our own.
-// http://www.php.net/crc32#79567
 if (!function_exists('smf_crc32'))
 {
+	/**
+	 * crc32 doesn't work as expected on 64-bit functions - make our own.
+	 * http://www.php.net/crc32#79567
+	 * 
+	 * @param type $number
+	 * @return type
+	 */
 	function smf_crc32($number)
 	{
 		$crc = crc32($number);

+ 16 - 21
Sources/Subs-Post.php

@@ -517,7 +517,7 @@ function fixTag(&$message, $myTag, $protocols, $embeddedUrl = false, $hasEqualSi
  * @param int $priority = 3
  * @param bool $hotmail_fix = null
  * @param $is_private
- * @return bool, whether ot not the email was sent properly.
+ * @return boolean, whether ot not the email was sent properly.
  */
 function sendmail($to, $subject, $message, $from = null, $message_id = null, $send_html = false, $priority = 3, $hotmail_fix = null, $is_private = false)
 {
@@ -696,7 +696,7 @@ function sendmail($to, $subject, $message, $from = null, $message_id = null, $se
  * @param bool $send_html = false
  * @param int $priority = 3
  * @param $is_private
- * @return bool
+ * @return boolean
  */
 function AddMailQueue($flush = false, $to_array = array(), $subject = '', $message = '', $headers = '', $send_html = false, $priority = 3, $is_private = false)
 {
@@ -1211,17 +1211,7 @@ function mimespecialchars($string, $with_charset = true, $hotmail_fix = false, $
 					$string = $newstring;
 			}
 
-			$fixchar = create_function('$n', '
-				if ($n < 128)
-					return chr($n);
-				elseif ($n < 2048)
-					return chr(192 | $n >> 6) . chr(128 | $n & 63);
-				elseif ($n < 65536)
-					return chr(224 | $n >> 12) . chr(128 | $n >> 6 & 63) . chr(128 | $n & 63);
-				else
-					return chr(240 | $n >> 18) . chr(128 | $n >> 12 & 63) . chr(128 | $n >> 6 & 63) . chr(128 | $n & 63);');
-
-			$string = preg_replace('~&#(\d{3,8});~e', '$fixchar(\'$1\')', $string);
+			$string = preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $string);
 
 			// Unicode, baby.
 			$charset = 'UTF-8';
@@ -1275,18 +1265,16 @@ function mimespecialchars($string, $with_charset = true, $hotmail_fix = false, $
 		return array($charset, $string, '7bit');
 }
 
-// Send an email via SMTP.
-
 /**
  * Sends mail, like mail() but over SMTP.
  * It expects no slashes or entities.
  * @internal
  *
  * @param array $mail_to_array - array of strings (email addresses)
- * @param string $subject, email subject
- * @param string $message, email message
- * @param string  $headers
- * @return bool, whether it sent or not.
+ * @param string $subject email subject
+ * @param string $message email message
+ * @param string $headers
+ * @return boolean whether it sent or not.
  */
 function smtp_mail($mail_to_array, $subject, $message, $headers)
 {
@@ -2479,7 +2467,7 @@ function approvePosts($msgs, $approve = true)
  * Approve topics?
  * @todo shouldn't this be in topic
  *
- * @param array $topics, array of topics ids
+ * @param array $topics array of topics ids
  * @param bool $approve = true
  */
 function approveTopics($topics, $approve = true)
@@ -2790,7 +2778,7 @@ function updateLastMessages($setboards, $id_msg = 0)
  * Email is sent to all groups that have the moderate_forum permission.
  * The language set by each member is being used (if available).
  *
- * @param string $type, types supported are 'approval', 'activation', and 'standard'.
+ * @param string $type types supported are 'approval', 'activation', and 'standard'.
  * @param int $memberID
  * @param string $member_name = null
  * @uses the Login language file.
@@ -2940,6 +2928,13 @@ function loadEmailTemplate($template, $replacements = array(), $lang = '', $load
 	return $ret;
 }
 
+/**
+ * Callback function for loademaitemplate on subject and body
+ * Uses capture group 1 in array
+ *
+ * @param type $matches
+ * @return string
+ */
 function user_info_callback($matches)
 {
 	global $user_info;

+ 1 - 1
Sources/Subs-Sound.php

@@ -24,7 +24,7 @@ if (!defined('SMF'))
  * Used by VerificationCode() (Register.php).
  *
  * @param string $word
- * @return bool false on failure
+ * @return boolean false on failure
  */
 
 function createWaveFile($word)

+ 138 - 17
Sources/Subs.php

@@ -1509,8 +1509,8 @@ function parse_bbc($message, $smileys = true, $cache_id = '', $parse_tags = arra
 			),
 			array(
 				'tag' => 'tt',
-				'before' => '<tt class="bbc_tt">',
-				'after' => '</tt>',
+				'before' => '<span class="bbc_tt">',
+				'after' => '</span>',
 			),
 			array(
 				'tag' => 'u',
@@ -2990,7 +2990,7 @@ function setupThemeContext($forceload = false)
  *
  * @param string $needed The amount of memory to request, if needed, like 256M
  * @param bool $in_use Set to true to account for current memory usage of the script
- * @return bool, true if we have at least the needed memory
+ * @return boolean, true if we have at least the needed memory
  */
 function setMemoryLimit($needed, $in_use = false)
 {
@@ -3056,7 +3056,7 @@ function template_rawdata()
 }
 
 /**
- *
+ * The header template
  */
 function template_header()
 {
@@ -3199,7 +3199,7 @@ function theme_copyright()
 }
 
 /**
- *
+ * The template footer
  */
 function template_footer()
 {
@@ -3587,11 +3587,11 @@ function text2words($text, $max_chars = 20, $encrypt = false)
 /**
  * Creates an image/text button
  *
- * @param string $filename
+ * @param string $name
  * @param string $alt
  * @param string $label = ''
- * @param bool $custom = ''
- * @param bool $force_use = false
+ * @param boolean $custom = ''
+ * @param boolean $force_use = false
  * @return string
  */
 function create_button($name, $alt, $label = '', $custom = '', $force_use = false)
@@ -3652,7 +3652,7 @@ function clean_cache($type = '')
 
 				// Remove all unused scripts and data from shared memory and disk cache,
 				// e.g. all data that isn't used in the current requests.
-				eaccelerator_clear();
+				@eaccelerator_clear();
 			}
 		case 'mmcache':
 			if (function_exists('mmcache_gc'))
@@ -3735,6 +3735,9 @@ function loadClassFile($filename)
 }
 
 /**
+ * Sets up all of the top menu buttons
+ * Saves them in the cache if it is available and on
+ * Places the results in $context
  *
  */
 function setupMenuContext()
@@ -4044,7 +4047,7 @@ function smf_seed_generator()
  * supports static class method calls.
  *
  * @param string $hook
- * @param array $paramaters = array()
+ * @param array $parameters = array()
  * @return array the results of the functions
  */
 function call_integration_hook($hook, $parameters = array())
@@ -4203,13 +4206,13 @@ function remove_integration_function($hook, $function, $file = '')
 }
 
 /**
-* 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
+ * 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)
 {
@@ -4265,4 +4268,122 @@ function sanitizeMSCutPaste($string)
 	return $string;
 }
 
+/**
+ * Decode numeric html entities to their ascii or UTF8 equivalent character.
+ *
+ * Callback function for preg_replace_callback in subs-members
+ * Uses capture group 2 in the supplied array
+ * Does basic scan to ensure characters are inside a valid range
+ *
+ * @param array $matches
+ * @return string $string
+*/
+function replaceEntities__callback($matches)
+{
+	global $context;
+	
+	if (!isset($matches[2]))
+		return '';
+
+	$num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2];
+	
+	// remove left to right / right to left overrides
+	if ($num === 0x202D || $num === 0x202E) 
+		return '';
+	
+	// Quote, Ampersand, Apostrophe, Less/Greater Than get html replaced
+	if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E))) 
+		return '&#' . $num . ';';
+
+	if (empty($context['utf8']))
+	{
+		// no control characters
+		if ($num < 0x20)
+			return '';
+		// text is text
+		elseif ($num < 0x80)
+			return chr($num);
+		// all others get html-ised
+		else
+			return '&#' . $matches[2] . ';';
+	}
+	else
+	{
+		// <0x20 are control characters, 0x20 is a space, > 0x10FFFF is past the end of the utf8 character set
+		// 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text)
+		if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF))
+			return '';
+		// <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and puncuation
+		elseif ($num < 0x80)
+			return chr($num);
+		// <0x800 (2048)
+		elseif ($num < 0x800)
+			return chr(($num >> 6) + 192) . chr(($num & 63) + 128);
+		// < 0x10000 (65536)
+		elseif ($num < 0x10000)
+			return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
+		// <= 0x10FFFF (1114111)
+		else
+			return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
+	}
+}
+
+/**
+ * Converts html entities to utf8 equivalents
+ *
+ * Callback function for preg_replace_callback
+ * Uses capture group 1 in the supplied array
+ * Does basic checks to keep characters inside a viewable range.
+ *
+ * @param array $matches
+ * @return string $string
+*/
+function fixchar__callback($matches)
+{
+	if (!isset($matches[1]))
+		return '';
+	
+	$num = $matches[1][0] === 'x' ? hexdec(substr($matches[1], 1)) : (int) $matches[1];
+
+	// <0x20 are control characters, > 0x10FFFF is past the end of the utf8 character set
+	// 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text), 0x202D-E are left to right overrides
+	if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E)
+		return '';
+	// <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and puncuation
+	elseif ($num < 0x80)
+		return chr($num);
+	// <0x800 (2048)
+	elseif ($num < 0x800)
+		return chr(($num >> 6) + 192) . chr(($num & 63) + 128);
+	// < 0x10000 (65536)
+	elseif ($num < 0x10000)
+		return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
+	// <= 0x10FFFF (1114111)
+	else
+		return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
+}
+
+/**
+ * Strips out invalid html entities, replaces others with html style &#123; codes
+ *
+ * Callback function used of preg_replace_callback in smcFunc $ent_checks, for example
+ * strpos, strlen, substr etc
+ *
+ * @param array $matches
+ * @return string $string
+*/
+function entity_fix__callback($matches)
+{
+	if (!isset($matches[2]))
+		return '';
+	
+	$num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2];
+	
+	// we don't allow control characters, characters out of range, byte markers, etc
+	if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E)
+		return '';
+	else
+		return '&#' . $num . ';';
+}
+
 ?>

+ 12 - 2
Sources/Themes.php

@@ -16,8 +16,7 @@
  * - any support website for the theme should be in website.
  * - layers and templates (non-default) should go in those elements ;).
  * - if the images dir isn't images, specify in the images element.
- * - any extra rows for themes should go in extra, serialized.
- * (as in array(variable => value).)
+ * - any extra rows for themes should go in extra, serialized. (as in array(variable => value).)
  * - tar and gzip the directory - and you're done!
  * - please include any special license in a license.txt file.
  *
@@ -1984,6 +1983,13 @@ function EditTheme()
 	createToken('admin-te-' . md5($_GET['th'] . '-' . $_REQUEST['filename']));
 }
 
+/**
+ * Generates a file listing for a given directory
+ *
+ * @param type $path
+ * @param type $relative
+ * @return type
+ */
 function get_file_listing($path, $relative)
 {
 	global $scripturl, $txt, $context;
@@ -2045,6 +2051,10 @@ function get_file_listing($path, $relative)
 	return array_merge($listing1, $listing2);
 }
 
+/**
+ * Makes a copy of a template file in a new location
+ * @uses Themes template, copy_template sub-template.
+ */
 function CopyTemplate()
 {
 	global $context, $settings, $smcFunc;

+ 3 - 5
Sources/Who.php

@@ -250,7 +250,7 @@ function Who()
  * Adding actions to the Who's Online list:
  * Adding actions to this list is actually relatively easy...
  *  - for actions anyone should be able to see, just add a string named whoall_ACTION.
-*     (where ACTION is the action used in index.php.)
+ *    (where ACTION is the action used in index.php.)
  *  - for actions that have a subaction which should be represented differently, use whoall_ACTION_SUBACTION.
  *  - for actions that include a topic, and should be restricted, use whotopic_ACTION.
  *  - for actions that use a message, by msg or quote, use whopost_ACTION.
@@ -259,11 +259,9 @@ function Who()
  *    use whoallow_ACTION and add a list of possible permissions to the
  *    $allowedActions array, using ACTION as the key.
  *
- * @param mixed $urls, a single url (string) or an array of arrays, each
- * inner array being (serialized request data, id_member)
+ * @param mixed $urls  a single url (string) or an array of arrays, each inner array being (serialized request data, id_member)
  * @param string $preferred_prefix = false
- * @return array, an array of descriptions if you passed an array, otherwise
- * the string describing their current location.
+ * @return array, an array of descriptions if you passed an array, otherwise the string describing their current location.
  */
 function determineActions($urls, $preferred_prefix = false)
 {

+ 42 - 35
Themes/default/Admin.template.php

@@ -60,7 +60,7 @@ function template_admin()
 			<div id="live_news" class="floatleft">
 				<div class="cat_bar">
 					<h3 class="catbg">
-						<a href="', $scripturl, '?action=helpadmin;help=live_news" onclick="return reqOverlayDiv(this.href);" class="help"><img src="', $settings['images_url'], '/helptopics.png" class="icon" alt="', $txt['help'], '" /></a> ', $txt['live'], '
+						<a href="', $scripturl, '?action=helpadmin;help=live_news" onclick="return reqOverlayDiv(this.href);" class="help"><img src="', $settings['images_url'], '/helptopics_hd.png" class="icon" alt="', $txt['help'], '" /></a> ', $txt['live'], '
 					</h3>
 				</div>
 				<div class="windowbg nopadding">
@@ -175,7 +175,6 @@ function template_admin()
 								%message%
 							</div>
 						</div>
-						<span class="botslice"><span></span></span>
 					</div>
 				'), ',
 				sUpdateNotificationLink: smf_scripturl + ', JavaScriptEscape('?action=admin;area=packages;pgdownload;auto;package=%package%;' . $context['session_var'] . '=' . $context['session_id']), '
@@ -251,7 +250,7 @@ function template_credits()
 	echo '
 			<div class="cat_bar">
 				<h3 class="catbg">
-					<a href="', $scripturl, '?action=helpadmin;help=latest_support" onclick="return reqOverlayDiv(this.href);" class="help"><img src="', $settings['images_url'], '/helptopics.png" class="icon" alt="', $txt['help'], '" /></a> ', $txt['support_latest'], '
+					<a href="', $scripturl, '?action=helpadmin;help=latest_support" onclick="return reqOverlayDiv(this.href);" class="help"><img src="', $settings['images_url'], '/helptopics_hd.png" class="icon" alt="', $txt['help'], '" /></a> ', $txt['support_latest'], '
 				</h3>
 			</div>
 			<div class="windowbg">
@@ -586,7 +585,7 @@ function template_edit_censored()
 	// First section is for adding/removing words from the censored list.
 	echo '
 	<div id="admincenter">
-		<form action="', $scripturl, '?action=admin;area=postsettings;sa=censor" method="post" accept-charset="', $context['character_set'], '">
+		<form id="admin_form_wrapper" action="', $scripturl, '?action=admin;area=postsettings;sa=censor" method="post" accept-charset="', $context['character_set'], '">
 			<div id="section_header" class="cat_bar">
 				<h3 class="catbg">
 					', $txt['admin_censored_words'], '
@@ -766,7 +765,7 @@ function template_show_settings()
 				echo '
 					<div class="cat_bar">
 						<h3 class="', !empty($config_var['class']) ? $config_var['class'] : 'catbg', '"', !empty($config_var['force_div_id']) ? ' id="' . $config_var['force_div_id'] . '"' : '', '>
-							', ($config_var['help'] ? '<a href="' . $scripturl . '?action=helpadmin;help=' . $config_var['help'] . '" onclick="return reqOverlayDiv(this.href);" class="help"><img src="' . $settings['images_url'] . '/helptopics.png" class="icon" alt="' . $txt['help'] . '" /></a>' : ''), '
+							', ($config_var['help'] ? '<a href="' . $scripturl . '?action=helpadmin;help=' . $config_var['help'] . '" onclick="return reqOverlayDiv(this.href);" class="help"><img src="' . $settings['images_url'] . '/helptopics_hd.png" class="icon" alt="' . $txt['help'] . '" /></a>' : ''), '
 							', $config_var['label'], '
 						</h3>
 					</div>';
@@ -881,7 +880,7 @@ function template_show_settings()
 										</li>';
 					}
 					echo '			</ul>
-								<input type="checkbox" id="bbc_', $config_var['name'], '_select_all" onclick="invertAll(this, this.form, \'', $config_var['name'], '_enabledTags\');"', $context['bbc_sections'][$config_var['name']]['all_selected'] ? ' checked="checked"' : '', ' class="input_check" /> <label for="select_all"><em>', $txt['bbcTagsToUse_select_all'], '</em></label>
+								<input type="checkbox" id="bbc_', $config_var['name'], '_select_all" onclick="invertAll(this, this.form, \'', $config_var['name'], '_enabledTags\');"', $context['bbc_sections'][$config_var['name']]['all_selected'] ? ' checked="checked"' : '', ' class="input_check" /> <label for="bbc_', $config_var['name'], '_select_all"><em>', $txt['bbcTagsToUse_select_all'], '</em></label>
 							</fieldset>';
 				}
 				// A simple message?
@@ -1381,8 +1380,10 @@ function template_core_features()
 				<h3 class="catbg">
 					', $txt['core_settings_title'], '
 				</h3>
+				
 			</div>
-		<form id="core_features" action="', $scripturl, '?action=admin;area=corefeatures" method="post" accept-charset="', $context['character_set'], '">
+			<p class="description">', $txt['core_settings_desc'], '</p>
+			<form id="core_features" action="', $scripturl, '?action=admin;area=corefeatures" method="post" accept-charset="', $context['character_set'], '">
 			<div style="display:none" id="activation_message" class="errorbox"></div>';
 
 	$alternate = true;
@@ -1396,7 +1397,7 @@ function template_core_features()
 				<img class="features_image" src="', $feature['image'], '" alt="', $feature['title'], '" />
 				<div class="features_switch" id="js_feature_', $id, '">
 					<label class="core_features_hide" for="feature_', $id, '">', $txt['core_settings_enabled'], '<input class="core_features_status_box" type="checkbox" name="feature_', $id, '" id="feature_', $id, '"', $feature['enabled'] ? ' checked="checked"' : '', ' /></label>
-					<img class="core_features_img ', $feature['state'], '" src="', $settings['images_url'], '/admin/switch_', $feature['state'], '.png" id="switch_', $id, '" style="margin-top: 1.3em;display:none" />
+					<img class="core_features_img ', $feature['state'], '" src="', $settings['images_url'], '/admin/switch_', $feature['state'], '.png" alt="', $feature['state'], '" id="switch_', $id, '" style="margin-top: 1.3em;display:none" />
 				</div>
 				<h4 id="feature_link_' . $id . '">', ($feature['enabled'] && $feature['url'] ? '<a href="' . $feature['url'] . '">' . $feature['title'] . '</a>' : $feature['title']), '</h4>
 				<p>', $feature['desc'], '</p>
@@ -1567,21 +1568,27 @@ function template_php_info()
 	global $context, $txt;
 
 	echo '
-	<div class="generic_list_wrapper" id="phpinfo">';
-
+	<div id="admin_form_wrapper">
+		<div id="section_header" class="cat_bar">
+			<h3 class="catbg">',
+				$txt['phpinfo_settings'], '
+			</h3>
+		</div>
+		<br />';
+	
 	// for each php info area
 	foreach ($context['pinfo'] as $area => $php_area)
 	{
 		echo '
-	<table id="', str_replace(' ', '_', $area), '" width="100%" class="table_grid">
-		<thead>
-		<tr class="catbg" align="center">
-			<th class="first_th" scope="col" width="33%"></th>
-			<th scope="col" width="33%"><strong>', $area, '</strong></th>
-			<th class="last_th" scope="col" width="33%"></th>
-		</tr>
-		</thead>
-		<tbody>';
+		<table id="', str_replace(' ', '_', $area), '" width="100%" class="table_grid">
+			<thead>
+			<tr class="catbg">
+				<th class="first_th" scope="col" width="33%"></th>
+				<th scope="col" width="33%" class="centercol"><strong>', $area, '</strong></th>
+				<th class="last_th" scope="col" width="33%"></th>
+			</tr>
+			</thead>
+			<tbody>';
 
 		$alternate = true;
 		$localmaster = true;
@@ -1596,42 +1603,42 @@ function template_php_info()
 				{
 					// heading row for the settings section of this categorys settings
 					echo '
-		<tr class="titlebg">
-			<td align="center" width="33%"><strong>', $txt['phpinfo_itemsettings'], '</strong></td>
-			<td align="center" width="33%"><strong>', $txt['phpinfo_localsettings'], '</strong></td>
-			<td align="center" width="33%"><strong>', $txt['phpinfo_defaultsettings'], '</strong></td>
-		</tr>';
+			<tr class="titlebg">
+				<td align="center" width="33%"><strong>', $txt['phpinfo_itemsettings'], '</strong></td>
+				<td align="center" width="33%"><strong>', $txt['phpinfo_localsettings'], '</strong></td>
+				<td align="center" width="33%"><strong>', $txt['phpinfo_defaultsettings'], '</strong></td>
+			</tr>';
 					$localmaster = false;
 				}
 
 				echo '
-		<tr>
-			<td align="left" width="33%" class="windowbg', $alternate ? '2' : '', '">', $key, '</td>';
+			<tr>
+				<td align="left" width="33%" class="windowbg', $alternate ? '2' : '', '">', $key, '</td>';
 
 				foreach ($setting as $key_lm => $value)
 				{
 					echo '
-			<td align="left" width="33%" class="windowbg', $alternate ? '2' : '', '">', $value, '</td>';
+				<td align="left" width="33%" class="windowbg', $alternate ? '2' : '', '">', $value, '</td>';
 				}
 				echo '
-		</tr>';
+			</tr>';
 			}
 			// just a single setting (2 col)
 			else
 			{
 				echo '
-		<tr>
-			<td align="left" width="33%" class="windowbg', $alternate ? '2' : '', '">', $key,  '</td>
-			<td align="left" class="windowbg', $alternate ? '2' : '', '" colspan="2">', $setting, '</td>
-		</tr>';
+			<tr>
+				<td align="left" width="33%" class="windowbg', $alternate ? '2' : '', '">', $key,  '</td>
+				<td align="left" class="windowbg', $alternate ? '2' : '', '" colspan="2">', $setting, '</td>
+			</tr>';
 			}
 
 			$alternate = !$alternate;
 		}
 		echo '
-		</tbody>
-	</table>
-	<br />';
+			</tbody>
+		</table>
+		<br />';
 	}
 
 	echo '

+ 11 - 10
Themes/default/Display.template.php

@@ -338,10 +338,13 @@ function template_main()
 										<li class="email"><a href="', $scripturl, '?action=emailuser;sa=email;msg=', $message['id'], '" rel="nofollow">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/email_sm.png" alt="' . $txt['email'] . '" title="' . $txt['email'] . '" />' : $txt['email']), '</a></li>';
 
 		// Stuff for the staff to wallop them with.
+		echo '
+										<li><hr /></li>';
+
 		// Maybe they want to report this post to the moderator(s)?
 		if ($context['can_report_moderator'])
 			echo '
-										<li class="report_link"><hr /><a href="', $scripturl, '?action=reporttm;topic=', $context['current_topic'], '.', $message['counter'], ';msg=', $message['id'], '">', $txt['report_to_mod'], '</a></li>';
+										<li class="report_link"><a href="', $scripturl, '?action=reporttm;topic=', $context['current_topic'], '.', $message['counter'], ';msg=', $message['id'], '">', $txt['report_to_mod'], '</a></li>';
 
 		// Can we issue a warning because of this post?  Remember, we can't give guests warnings.
 		if ($context['can_issue_warning'] && !$message['is_message_author'] && !$message['member']['is_guest'])
@@ -400,20 +403,18 @@ function template_main()
 			echo '
 								<li class="poster_online"><a href="', $scripturl,'?action=pm">', $txt['pm_short'], ' ', $context['user']['unread_messages'] > 0 ? '[<strong>'. $context['user']['unread_messages'] . '</strong>]' : '' , '</a></li>';
 		}
-
-		if ($context['can_send_pm'] && !$message['is_message_author'] && !$message['member']['is_guest'])
+		elseif ($context['can_send_pm'] && !$message['is_message_author'] && !$message['member']['is_guest'])
 		{
 			if (!empty($modSettings['onlineEnable']))
 				echo '
 								<li class="poster_online"><a href="', $scripturl,'?action=pm;sa=send;u=', $message['member']['id'], '" title="', $message['member']['online']['member_online_text'], '">', $txt['send_message'], ' <img src="'. $message['member']['online']['image_href']. '" alt="" /></a></li>';
 			else
 				echo '
-								<li class="poster_online"><a href="', $scripturl,'?action=pm;sa=send;u=', $message['member']['id'], '">', $txt['send_message'], '</a></li>';
+								<li class="poster_online"><a href="', $scripturl,'?action=pm;sa=send;u=', $message['member']['id'], '">', $txt['send_message'], ' </a></li>';
 		}
-
-		if (!$context['can_send_pm'] && !empty($modSettings['onlineEnable']))
+		elseif (!$context['can_send_pm'] && !empty($modSettings['onlineEnable']))
 			echo '
-								<li class="poster_online">', ($message['member']['online']['is_online']) ? $txt['online'] : $txt['offline'], '<img src="'. $message['member']['online']['image_href']. '" alt="" /></li>';
+								<li class="poster_online">', ($message['member']['online']['is_online']) ? $txt['online'] : $txt['offline'], ' <img src="'. $message['member']['online']['image_href']. '" alt="" /></li>';
 
 		// Are we showing the warning status?
 		// Don't show these things for guests.
@@ -568,7 +569,7 @@ function template_main()
 		// Can the user modify the contents of this post?  Show the modify inline image.
 		if ($message['can_modify'])
 			echo '
-							<li class="quick_edit"><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; margin: 0 0 0 0;" onclick="oQuickModify.modifyMsg(\'', $message['id'], '\')" />', $txt['quick_edit'], '</li>';
+							<li class="quick_edit"><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; margin: 0;" onclick="oQuickModify.modifyMsg(\'', $message['id'], '\')" />', $txt['quick_edit'], '</li>';
 
 		// Can the user modify the contents of this post?
 		if ($message['can_modify'])
@@ -831,7 +832,7 @@ function template_main()
 						sImageCollapsed: "collapse.png",
 						sImageExpanded: "expand.png",
 						sJumpAnchor: "quickreply",
-						bIsFull: ', !empty($options['display_quick_reply']) && $options['display_quick_reply'] > 2 ? 'true' : 'false', '
+						bIsFull: ', !empty($options['use_editor_quick_reply']) ? 'true' : 'false', '
 					});';
 
 	if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $context['can_remove_post'])
@@ -861,11 +862,11 @@ function template_main()
 					});';
 
 	echo '
-					$(".quick_edit").css("display", "inline");
 					if (\'XMLHttpRequest\' in window)
 					{
 						var oQuickModify = new QuickModify({
 							sScriptUrl: smf_scripturl,
+							sClassName: \'quick_edit\',
 							bShowModify: ', $settings['show_modify'] ? 'true' : 'false', ',
 							iTopicId: ', $context['current_topic'], ',
 							sTemplateBodyEdit: ', JavaScriptEscape('

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

@@ -56,7 +56,7 @@ function template_error_log()
 			</div>
 			<div class="pagesection">
 				<div class="floatleft">
-					', $txt['pages'], ': ', $context['page_index'], '
+					', $context['page_index'], '
 				</div>
 			</div>
 			<table border="0" cellspacing="1" class="table_grid" id="error_log">
@@ -158,7 +158,7 @@ function template_error_log()
 				</tr>
 			</table>
 			<div class="pagesection floatleft">
-				&nbsp;&nbsp;', $txt['pages'], ': ', $context['page_index'], '
+				&nbsp;&nbsp;', $context['page_index'], '
 			</div>';
 
 	echo '

+ 5 - 4
Themes/default/GenericControls.template.php

@@ -33,8 +33,7 @@ function template_control_richedit($editor_id, $smileyContainer = null, $bbcCont
 
 				$("#', $editor_id, '").sceditorBBCodePlugin({
 					style: "', $settings['default_theme_url'], '/css/jquery.sceditor.default.css",
-					emoticonsCompat: true,
-					supportedWysiwyg: (is_ie || is_ff || is_opera || is_safari || is_chrome),',
+					emoticonsCompat: true,',
 					!empty($editor_context['locale']) ? '
 					locale: \'' . $editor_context['locale'] . '\',' : '', '
 					colors: "black,red,yellow,pink,green,orange,purple,blue,beige,brown,teal,navy,maroon,limegreen,white"';
@@ -59,6 +58,8 @@ function template_control_richedit($editor_id, $smileyContainer = null, $bbcCont
 						{';
 
 				$numRows = count($smileyRows);
+				// This is needed because otherwise the editor will remove all the duplicate (empty) keys and leave only 1 additional line
+				$emptyPlaceholder = 0;
 				foreach ($smileyRows as $smileyRow)
 				{
 					foreach ($smileyRow['smileys'] as $smiley)
@@ -68,7 +69,7 @@ function template_control_richedit($editor_id, $smileyContainer = null, $bbcCont
 					}
 					if (empty($smileyRow['isLast']) && $numRows != 1)
 						echo ',
-						\'\': \'\',';
+						\'-', $emptyPlaceholder++, '\': \'\',';
 				}
 				echo '
 						}', $countLocations != 0 ? ',' : '';
@@ -169,7 +170,7 @@ function template_control_richedit_buttons($editor_id)
 				sSceditorID: \'', $editor_id, '\',
 				sType: \'post\',
 				iBoard: ', (empty($context['current_board']) ? 0 : $context['current_board']), ',
-				iFreq: ', (empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000), '
+				iFreq: ', $context['drafts_autosave_frequency'], '
 			});
 		// ]]></script>';
 	}

+ 7 - 7
Themes/default/GenericList.template.php

@@ -56,7 +56,7 @@ function template_show_list($list_id = null)
 	if (isset($cur_list['additional_rows']['top_of_list']))
 		template_additional_rows('top_of_list', $cur_list);
 
-	if (!empty($cur_list['items_per_page']) || isset($cur_list['additional_rows']['above_column_headers']))
+	if ((!empty($cur_list['items_per_page']) && !empty($cur_list['page_index'])) || isset($cur_list['additional_rows']['above_column_headers']))
 	{
 		echo '
 			<div class="flow_auto">';
@@ -91,13 +91,13 @@ function template_show_list($list_id = null)
 		foreach ($cur_list['headers'] as $col_header)
 		{
 			$i ++;
-			if (empty($col_header['class']) && $i == 1)
-				$col_header['class'] = 'first_th';
-			elseif (empty($col_header['class']) && $i == $header_count)
-				$col_header['class'] = 'last_th';
+			if ($i === 1)
+				$col_header['class'] = empty($col_header['class']) ? 'first_th' : 'first_th ' . $col_header['class'];
+			elseif ($i === $header_count)
+				$col_header['class'] = empty($col_header['class']) ? 'last_th' : 'last_th ' . $col_header['class'];
 
 			echo '
-					<th scope="col"', empty($col_header['class']) ? '' : ' class="' . $col_header['class'] . '"', empty($col_header['style']) ? '' : ' style="' . $col_header['style'] . '"', empty($col_header['colspan']) ? '' : ' colspan="' . $col_header['colspan'] . '"', '>', empty($col_header['href']) ? '' : '<a href="' . $col_header['href'] . '" rel="nofollow">', empty($col_header['label']) ? '&nbsp;' : $col_header['label'], empty($col_header['href']) ? '' : (empty($col_header['sort_image']) ? '</a>' : ' <img class="sort" src="' . $settings['images_url'] . '/sort_' . $col_header['sort_image'] . '.png" alt="" /></a>'), '</th>';
+					<th scope="col" id="header_', $list_id, '_', $col_header['id'], '"', empty($col_header['class']) ? '' : ' class="' . $col_header['class'] . '"', empty($col_header['style']) ? '' : ' style="' . $col_header['style'] . '"', empty($col_header['colspan']) ? '' : ' colspan="' . $col_header['colspan'] . '"', '>', empty($col_header['href']) ? '' : '<a href="' . $col_header['href'] . '" rel="nofollow">', empty($col_header['label']) ? '&nbsp;' : $col_header['label'], empty($col_header['href']) ? '' : (empty($col_header['sort_image']) ? '</a>' : ' <img class="sort" src="' . $settings['images_url'] . '/sort_' . $col_header['sort_image'] . '.png" alt="" /></a>'), '</th>';
 		}
 
 		echo '
@@ -139,7 +139,7 @@ function template_show_list($list_id = null)
 			</tbody>
 			</table>';
 
-	if (!empty($cur_list['items_per_page']) || isset($cur_list['additional_rows']['below_table_data']))
+	if ((!empty($cur_list['items_per_page']) && !empty($cur_list['page_index'])) || isset($cur_list['additional_rows']['below_table_data']))
 	{
 		echo '
 			<div class="flow_auto">';

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

@@ -251,7 +251,7 @@ function template_generic_menu_tabs(&$menu_context)
 			echo '<img src="', $settings['images_url'], '/icons/', !empty($selected_tab['icon']) ? $selected_tab['icon'] : $tab_context['icon'], '" alt="" class="icon" />';
 
 		if (!empty($selected_tab['help']) || !empty($tab_context['help']))
-			echo '<a href="', $scripturl, '?action=helpadmin;help=', !empty($selected_tab['help']) ? $selected_tab['help'] : $tab_context['help'], '" onclick="return reqOverlayDiv(this.href);" class="help"><img src="', $settings['images_url'], '/helptopics.png" alt="', $txt['help'], '" class="icon" /></a>';
+			echo '<a href="', $scripturl, '?action=helpadmin;help=', !empty($selected_tab['help']) ? $selected_tab['help'] : $tab_context['help'], '" onclick="return reqOverlayDiv(this.href);" class="help"><img src="', $settings['images_url'], '/helptopics_hd.png" alt="', $txt['help'], '" class="icon" /></a>';
 
 		echo $tab_context['title'];
 	}

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

@@ -120,7 +120,7 @@ function template_find_members()
 		echo '
 				</ul>
 				<div class="pagesection">
-					', $txt['pages'], ': ', $context['page_index'], '
+					', $context['page_index'], '
 				</div>';
 	}
 

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

@@ -22,7 +22,7 @@ function template_login()
 		<div class="tborder login">
 			<div class="cat_bar">
 				<h3 class="catbg">
-					<img src="', $settings['images_url'], '/icons/login_sm.png" alt="" class="icon" /> ', $txt['login'], '
+					<img src="', $settings['images_url'], '/icons/login_hd.png" alt="" class="icon" /> ', $txt['login'], '
 				</h3>
 			</div>
 			<div class="roundframe">';
@@ -112,7 +112,7 @@ function template_kick_guest()
 	echo '
 			<div class="cat_bar">
 				<h3 class="catbg">
-					<img src="', $settings['images_url'], '/icons/login_sm.png" alt="" class="icon" /> ', $txt['login'], '
+					<img src="', $settings['images_url'], '/icons/login_hd.png" alt="" class="icon" /> ', $txt['login'], '
 				</h3>
 			</div>
 			<div class="roundframe">
@@ -209,7 +209,7 @@ function template_admin_login()
 	<div class="tborder login" id="admin_login">
 		<div class="cat_bar">
 			<h3 class="catbg">
-				<img src="', $settings['images_url'], '/icons/login_sm.png" alt="" class="icon" /> ', $txt['login'], '
+				<img src="', $settings['images_url'], '/icons/login_hd.png" alt="" class="icon" /> ', $txt['login'], '
 			</h3>
 		</div>
 		<div class="roundframe centertext">';

+ 91 - 4
Themes/default/ManageAttachments.template.php

@@ -57,7 +57,7 @@ function template_browse()
 
 function template_maintenance()
 {
-	global $context, $settings, $options, $scripturl, $txt;
+	global $context, $settings, $options, $scripturl, $txt, $modSettings;
 
 	echo '
 	<div id="manage_attachments">
@@ -69,8 +69,12 @@ function template_maintenance()
 				<dl class="settings">
 					<dt><strong>', $txt['attachment_total'], ':</strong></dt><dd>', $context['num_attachments'], '</dd>
 					<dt><strong>', $txt['attachment_manager_total_avatars'], ':</strong></dt><dd>', $context['num_avatars'], '</dd>
-					<dt><strong>', $txt['attachmentdir_size' . ($context['attach_multiple_dirs'] ? '_current' : '')], ':</strong></dt><dd>', $context['attachment_total_size'], ' ', $txt['kilobyte'], '</dd>
-					<dt><strong>', $txt['attachment_space' . ($context['attach_multiple_dirs'] ? '_current' : '')], ':</strong></dt><dd>', isset($context['attachment_space']) ? $context['attachment_space'] . ' ' . $txt['kilobyte'] : $txt['attachmentdir_size_not_set'], '</dd>
+					<dt><strong>', $txt['attachmentdir_size'], ':</strong></dt><dd>', $context['attachment_total_size'], ' ', $txt['kilobyte'], '</dd>
+					<dt><strong>', $txt['attach_current_dir'], ':</strong></dt><dd>', $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']], '</dd>
+					<dt><strong>', $txt['attachmentdir_size_current'], ':</strong></dt><dd>', $context['attachment_current_size'], ' ', $txt['kilobyte'], '</dd>
+					<dt><strong>', $txt['attachment_space'], ':</strong></dt><dd>', isset($context['attachment_space']) ? $context['attachment_space'] . ' ' . $txt['kilobyte'] : $txt['attachmentdir_size_not_set'], '</dd>
+					<dt><strong>', $txt['attachmentdir_files_current'], ':</strong></dt><dd>', $context['attachment_current_files'], '</dd>
+					<dt><strong>', $txt['attachment_files'], ':</strong></dt><dd>', isset($context['attachment_files']) ? $context['attachment_files'] : $txt['attachmentdir_files_not_set'], '</dd>
 				</dl>
 			</div>
 		</div>
@@ -124,6 +128,89 @@ function template_maintenance()
 			</div>
 		</div>
 	</div>';
+	
+	echo '
+			<div id="transfer" class="cat_bar">
+				<h3 class="catbg">', $txt['attachment_transfer'], '</h3>
+			</div>';
+
+	if (!empty($context['results']))
+		echo '
+			<div class="noticebox">', $context['results'], '</div>';
+
+	echo '
+			<div class="windowbg">
+				<div class="content">
+					<form action="', $scripturl, '?action=admin;area=manageattachments;sa=transfer" method="post" accept-charset="', $context['character_set'], '">
+						<p>', $txt['attachment_transfer_desc'], '</p>
+						<hr class="hrcolor" />
+						<dl class="settings">
+							<dt>', $txt['attachment_transfer_from'], '</dt>
+							<dd><select name="from">
+								<option value="0">', $txt['attachment_transfer_select'], '</option>';
+
+	foreach ($context['attach_dirs'] as $id => $dir)
+		echo '
+								<option value="', $id, '">', $dir, '</option>';
+	echo '
+							</select></dd>
+							<dt>', $txt['attachment_transfer_auto'], '</dt>
+							<dd><select name="auto">
+								<option value="0">', $txt['attachment_transfer_auto_select'], '</option>
+								<option value="-1">', $txt['attachment_transfer_forum_root'], '</option>';
+
+	if (!empty($context['base_dirs']))
+		foreach ($context['base_dirs'] as $id => $dir)
+			echo '
+								<option value="', $id, '">', $dir, '</option>';
+	else
+			echo '
+								<option value="0" disabled="disabled">', $txt['attachment_transfer_no_base'], '</option>';
+
+	echo '
+							</select></dd>
+							<dt>', $txt['attachment_transfer_to'], '</dt>
+							<dd><select name="to">
+								<option value="0">', $txt['attachment_transfer_select'], '</option>';
+
+	foreach($context['attach_dirs'] as $id => $dir)
+		echo '
+								<option value="', $id, '">', $dir, '</option>';
+	echo '
+							</select></dd>';
+
+	if (!empty($modSettings['attachmentDirFileLimit']))
+		echo '
+							<dt>', $txt['attachment_transfer_empty'], '</dt>
+							<dd><input type="checkbox" name="empty_it"', $context['checked'] ? ' checked="checked"' : '', ' /></dd>';
+	echo '
+						</dl>
+						<hr class="hrcolor"/>
+						<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
+						<input type="submit" onclick="start_progress()" name="transfer" value="', $txt['attachment_transfer_now'], '" class="button_submit" />
+						<div id="progress_msg"></div>
+						<div id="show_progress" class="padding"></div>
+						<br class="clear_right" />
+					</form>
+					<script type="text/javascript"><!-- // --><![CDATA[
+						function start_progress() {
+							setTimeout(\'show_msg()\', 1000);
+						}
+
+						function show_msg() {
+							$(\'#progress_msg\').html(\'<div><img src="', $settings['actual_images_url'], '/loading.gif" alt="loading.gif" width="35" height="35" />&nbsp; ', $txt['attachment_transfer_progress'] , '<\/div>\');
+							show_progress();
+						}
+
+						function show_progress() {
+							$(\'#show_progress\').load("progress.php");
+							setTimeout(\'show_progress()\', 1500);
+						}
+
+					// ]]></script>
+				</div>
+			</div>
+			<br class="clear" />';
 }
 
 function template_attachment_repair()
@@ -168,7 +255,7 @@ function template_attachment_repair()
 	{
 		echo '
 	<div id="manage_attachments">
-		<form action="', $scripturl, '?action=admin;area=manageattachments;sa=repair;fixErrors=1;step=0;substep=0;', $context['session_var'], '=', $context['session_id'], '" method="post" accept-charset="', $context['character_set'], '">
+		<form id="admin_form_wrapper" action="', $scripturl, '?action=admin;area=manageattachments;sa=repair;fixErrors=1;step=0;substep=0;', $context['session_var'], '=', $context['session_id'], '" method="post" accept-charset="', $context['character_set'], '">
 			<div class="cat_bar">
 				<h3 class="catbg">', $txt['repair_attachments'], '</h3>
 			</div>

+ 113 - 118
Themes/default/ManageBans.template.php

@@ -16,162 +16,158 @@ function template_ban_edit()
 
 	echo '
 	<div id="manage_bans">
-
-		<div class="cat_bar">
-			<h3 class="catbg">
-				', $context['ban']['is_new'] ? $txt['ban_add_new'] : $txt['ban_edit'] . ' \'' . $context['ban']['name'] . '\'', '
-			</h3>
-		</div>';
-
+		<form id="admin_form_wrapper" action="', $scripturl, '?action=admin;area=ban;sa=edit" method="post" accept-charset="', $context['character_set'], '" onsubmit="if (this.ban_name.value == \'\') {alert(\'', $txt['ban_name_empty'], '\'); return false;} if (this.partial_ban.checked &amp;&amp; !(this.cannot_post.checked || this.cannot_register.checked || this.cannot_login.checked)) {alert(\'', $txt['ban_restriction_empty'], '\'); return false;}">
+			<div class="cat_bar">
+				<h3 class="catbg">
+					', $context['ban']['is_new'] ? $txt['ban_add_new'] : $txt['ban_edit'] . ' \'' . $context['ban']['name'] . '\'', '
+				</h3>
+			</div>';
+			
 	if ($context['ban']['is_new'])
 		echo '
-		<div class="information">', $txt['ban_add_notes'], '</div>';
-
+			<div class="information">', $txt['ban_add_notes'], '</div>';
+		
 	echo '
-		<div class="windowbg">
 			<div class="content">
-				<form action="', $scripturl, '?action=admin;area=ban;sa=edit" method="post" accept-charset="', $context['character_set'], '" onsubmit="if (this.ban_name.value == \'\') {alert(\'', $txt['ban_name_empty'], '\'); return false;} if (this.partial_ban.checked &amp;&amp; !(this.cannot_post.checked || this.cannot_register.checked || this.cannot_login.checked)) {alert(\'', $txt['ban_restriction_empty'], '\'); return false;}">
+				<dl class="settings">
+					<dt>
+						<strong><label for="ban_name">', $txt['ban_name'], ':</label></strong>
+					</dt>
+					<dd>
+						<input type="text" name="ban_name" id="ban_name" value="', $context['ban']['name'], '" size="47" maxlength="60" class="input_text" />
+					</dd>
+					<dt>
+						<strong><label for="reason">', $txt['ban_reason'], ':</label></strong><br />
+						<span class="smalltext">', $txt['ban_reason_desc'], '</span>
+					</dt>
+					<dd>
+						<textarea name="reason" id="reason" cols="40" rows="3" style="min-height: 64px; max-height: 64px; min-width: 50%; max-width: 99%;">', $context['ban']['reason'], '</textarea>
+					</dd>
+					<dt>
+						<strong><label for="ban_notes">', $txt['ban_notes'], ':</label></strong><br />
+						<span class="smalltext">', $txt['ban_notes_desc'], '</span>
+					</dt>
+					<dd>
+						<textarea name="notes" id="ban_notes" cols="40" rows="3" style="min-height: 64px; max-height: 64px; min-width: 50%; max-width: 99%;">', $context['ban']['notes'], '</textarea>
+					</dd>
+				</dl>
+				<fieldset class="ban_settings floatleft">
+					<legend>
+						', $txt['ban_expiration'], '
+					</legend>
+					<input type="radio" name="expiration" value="never" id="never_expires" onclick="fUpdateStatus();"', $context['ban']['expiration']['status'] == 'never' ? ' checked="checked"' : '', ' class="input_radio" /> <label for="never_expires">', $txt['never'], '</label><br />
+					<input type="radio" name="expiration" value="one_day" id="expires_one_day" onclick="fUpdateStatus();"', $context['ban']['expiration']['status'] == 'still_active_but_we_re_counting_the_days' ? ' checked="checked"' : '', ' class="input_radio" /> <label for="expires_one_day">', $txt['ban_will_expire_within'], '</label>: <input type="text" name="expire_date" id="expire_date" size="3" value="', $context['ban']['expiration']['days'], '" class="input_text" /> ', $txt['ban_days'], '<br />
+					<input type="radio" name="expiration" value="expired" id="already_expired" onclick="fUpdateStatus();"', $context['ban']['expiration']['status'] == 'expired' ? ' checked="checked"' : '', ' class="input_radio" /> <label for="already_expired">', $txt['ban_expired'], '</label>
+				</fieldset>
+				<fieldset class="ban_settings floatright">
+					<legend>
+						', $txt['ban_restriction'], '
+					</legend>
+					<input type="radio" name="full_ban" id="full_ban" value="1" onclick="fUpdateStatus();"', $context['ban']['cannot']['access'] ? ' checked="checked"' : '', ' class="input_radio" /> <label for="full_ban">', $txt['ban_full_ban'], '</label><br />
+					<input type="radio" name="full_ban" id="partial_ban" value="0" onclick="fUpdateStatus();"', !$context['ban']['cannot']['access'] ? ' checked="checked"' : '', ' class="input_radio" /> <label for="partial_ban">', $txt['ban_partial_ban'], '</label><br />
+					<input type="checkbox" name="cannot_post" id="cannot_post" value="1"', $context['ban']['cannot']['post'] ? ' checked="checked"' : '', ' class="ban_restriction input_radio" /> <label for="cannot_post">', $txt['ban_cannot_post'], '</label> (<a href="', $scripturl, '?action=helpadmin;help=ban_cannot_post" onclick="return reqOverlayDiv(this.href);">?</a>)<br />
+					<input type="checkbox" name="cannot_register" id="cannot_register" value="1"', $context['ban']['cannot']['register'] ? ' checked="checked"' : '', ' class="ban_restriction input_radio" /> <label for="cannot_register">', $txt['ban_cannot_register'], '</label><br />
+					<input type="checkbox" name="cannot_login" id="cannot_login" value="1"', $context['ban']['cannot']['login'] ? ' checked="checked"' : '', ' class="ban_restriction input_radio" /> <label for="cannot_login">', $txt['ban_cannot_login'], '</label><br />
+				</fieldset>
+				<br class="clear_right" />';
+
+	if (!empty($context['ban_suggestions']))
+	{
+		echo '
+				<fieldset>
+					<legend>
+						', $txt['ban_triggers'], '
+					</legend>
 					<dl class="settings">
 						<dt>
-							<strong><label for="ban_name">', $txt['ban_name'], ':</label></strong>
+							<input type="checkbox" name="ban_suggestion[]" id="main_ip_check" value="main_ip" class="input_check" />
+							<label for="main_ip_check">', $txt['ban_on_ip'], '</label>
 						</dt>
 						<dd>
-							<input type="text" name="ban_name" id="ban_name" value="', $context['ban']['name'], '" size="47" maxlength="60" class="input_text" />
-						</dd>
+							<input type="text" name="main_ip" value="', $context['ban_suggestions']['main_ip'], '" size="44" onfocus="document.getElementById(\'main_ip_check\').checked = true;" class="input_text" />
+						</dd>';
+
+		if (empty($modSettings['disableHostnameLookup']))
+			echo '
 						<dt>
-							<strong><label for="reason">', $txt['ban_reason'], ':</label></strong><br />
-							<span class="smalltext">', $txt['ban_reason_desc'], '</span>
+							<input type="checkbox" name="ban_suggestion[]" id="hostname_check" value="hostname" class="input_check" />
+							<label for="hostname_check">', $txt['ban_on_hostname'], '</label>
 						</dt>
 						<dd>
-							<textarea name="reason" id="reason" cols="40" rows="3" style="min-height: 64px; max-height: 64px; min-width: 50%; max-width: 99%;">', $context['ban']['reason'], '</textarea>
-						</dd>
+							<input type="text" name="hostname" value="', $context['ban_suggestions']['hostname'], '" size="44" onfocus="document.getElementById(\'hostname_check\').checked = true;" class="input_text" />
+						</dd>';
+
+		echo '
 						<dt>
-							<strong><label for="ban_notes">', $txt['ban_notes'], ':</label></strong><br />
-							<span class="smalltext">', $txt['ban_notes_desc'], '</span>
+							<input type="checkbox" name="ban_suggestion[]" id="email_check" value="email" class="input_check" checked="checked" />
+							<label for="email_check">', $txt['ban_on_email'], '</label>
 						</dt>
 						<dd>
-							<textarea name="notes" id="ban_notes" cols="40" rows="3" style="min-height: 64px; max-height: 64px; min-width: 50%; max-width: 99%;">', $context['ban']['notes'], '</textarea>
+							<input type="text" name="email" value="', $context['ban_suggestions']['email'], '" size="44" onfocus="document.getElementById(\'email_check\').checked = true;" class="input_text" />
 						</dd>
-					</dl>
-					<fieldset class="ban_settings floatleft">
-						<legend>
-							', $txt['ban_expiration'], '
-						</legend>
-						<input type="radio" name="expiration" value="never" id="never_expires" onclick="fUpdateStatus();"', $context['ban']['expiration']['status'] == 'never' ? ' checked="checked"' : '', ' class="input_radio" /> <label for="never_expires">', $txt['never'], '</label><br />
-						<input type="radio" name="expiration" value="one_day" id="expires_one_day" onclick="fUpdateStatus();"', $context['ban']['expiration']['status'] == 'still_active_but_we_re_counting_the_days' ? ' checked="checked"' : '', ' class="input_radio" /> <label for="expires_one_day">', $txt['ban_will_expire_within'], '</label>: <input type="text" name="expire_date" id="expire_date" size="3" value="', $context['ban']['expiration']['days'], '" class="input_text" /> ', $txt['ban_days'], '<br />
-						<input type="radio" name="expiration" value="expired" id="already_expired" onclick="fUpdateStatus();"', $context['ban']['expiration']['status'] == 'expired' ? ' checked="checked"' : '', ' class="input_radio" /> <label for="already_expired">', $txt['ban_expired'], '</label>
-					</fieldset>
-					<fieldset class="ban_settings floatright">
-						<legend>
-							', $txt['ban_restriction'], '
-						</legend>
-						<input type="radio" name="full_ban" id="full_ban" value="1" onclick="fUpdateStatus();"', $context['ban']['cannot']['access'] ? ' checked="checked"' : '', ' class="input_radio" /> <label for="full_ban">', $txt['ban_full_ban'], '</label><br />
-						<input type="radio" name="full_ban" id="partial_ban" value="0" onclick="fUpdateStatus();"', !$context['ban']['cannot']['access'] ? ' checked="checked"' : '', ' class="input_radio" /> <label for="partial_ban">', $txt['ban_partial_ban'], '</label><br />
-						<input type="checkbox" name="cannot_post" id="cannot_post" value="1"', $context['ban']['cannot']['post'] ? ' checked="checked"' : '', ' class="ban_restriction input_radio" /> <label for="cannot_post">', $txt['ban_cannot_post'], '</label> (<a href="', $scripturl, '?action=helpadmin;help=ban_cannot_post" onclick="return reqOverlayDiv(this.href);">?</a>)<br />
-						<input type="checkbox" name="cannot_register" id="cannot_register" value="1"', $context['ban']['cannot']['register'] ? ' checked="checked"' : '', ' class="ban_restriction input_radio" /> <label for="cannot_register">', $txt['ban_cannot_register'], '</label><br />
-						<input type="checkbox" name="cannot_login" id="cannot_login" value="1"', $context['ban']['cannot']['login'] ? ' checked="checked"' : '', ' class="ban_restriction input_radio" /> <label for="cannot_login">', $txt['ban_cannot_login'], '</label><br />
-					</fieldset>
-					<br class="clear_right" />';
-
-	if (!empty($context['ban_suggestions']))
-	{
-		echo '
-					<fieldset>
-						<legend>
-							', $txt['ban_triggers'], '
-						</legend>
-						<dl class="settings">
-							<dt>
-								<input type="checkbox" name="ban_suggestion[]" id="main_ip_check" value="main_ip" class="input_check" />
-								<label for="main_ip_check">', $txt['ban_on_ip'], '</label>
-							</dt>
-							<dd>
-								<input type="text" name="main_ip" value="', $context['ban_suggestions']['main_ip'], '" size="44" onfocus="document.getElementById(\'main_ip_check\').checked = true;" class="input_text" />
-							</dd>';
-
-		if (empty($modSettings['disableHostnameLookup']))
-			echo '
-							<dt>
-								<input type="checkbox" name="ban_suggestion[]" id="hostname_check" value="hostname" class="input_check" />
-								<label for="hostname_check">', $txt['ban_on_hostname'], '</label>
-							</dt>
-							<dd>
-								<input type="text" name="hostname" value="', $context['ban_suggestions']['hostname'], '" size="44" onfocus="document.getElementById(\'hostname_check\').checked = true;" class="input_text" />
-							</dd>';
-
-		echo '
-							<dt>
-								<input type="checkbox" name="ban_suggestion[]" id="email_check" value="email" class="input_check" checked="checked" />
-								<label for="email_check">', $txt['ban_on_email'], '</label>
-							</dt>
-							<dd>
-								<input type="text" name="email" value="', $context['ban_suggestions']['email'], '" size="44" onfocus="document.getElementById(\'email_check\').checked = true;" class="input_text" />
-							</dd>
-							<dt>
-								<input type="checkbox" name="ban_suggestion[]" id="user_check" value="user" class="input_check" checked="checked" />
-								<label for="user_check">', $txt['ban_on_username'], '</label>:
-							</dt>
-							<dd>';
+						<dt>
+							<input type="checkbox" name="ban_suggestion[]" id="user_check" value="user" class="input_check" checked="checked" />
+							<label for="user_check">', $txt['ban_on_username'], '</label>:
+						</dt>
+						<dd>';
 
 		if (empty($context['ban_suggestions']['member']['id']))
 			echo '
-								<input type="text" name="user" id="user" value="" size="44" class="input_text" />';
+							<input type="text" name="user" id="user" value="" size="44" class="input_text" />';
 		else
 			echo '
-								', $context['ban_suggestions']['member']['link'], '
-								<input type="hidden" name="bannedUser" value="', $context['ban_suggestions']['member']['id'], '" />';
+							', $context['ban_suggestions']['member']['link'], '
+							<input type="hidden" name="bannedUser" value="', $context['ban_suggestions']['member']['id'], '" />';
 		echo '
-							</dd>';
+						</dd>';
 
 		if (!empty($context['ban_suggestions']['message_ips']))
 		{
 			echo '
-						</dl>
-						<div>', $txt['ips_in_messages'], ':</div>
-						<dl class="settings">';
+					</dl>
+					<div>', $txt['ips_in_messages'], ':</div>
+					<dl class="settings">';
 
 			foreach ($context['ban_suggestions']['message_ips'] as $ip)
 				echo '
-							<dt>
-								<input type="checkbox" name="ban_suggestion[ips][]" value="', $ip, '" class="input_check" />
-							</dt>
-							<dd>
-								', $ip, '
-							</dd>';
+						<dt>
+							<input type="checkbox" name="ban_suggestion[ips][]" value="', $ip, '" class="input_check" />
+						</dt>
+						<dd>
+							', $ip, '
+						</dd>';
 		}
 
 		if (!empty($context['ban_suggestions']['error_ips']))
 		{
 			echo '
-						</dl>
-						<div>', $txt['ips_in_errors'], '</div>
-						<dl class="settings">';
+					</dl>
+					<div>', $txt['ips_in_errors'], '</div>
+					<dl class="settings">';
 
 			foreach ($context['ban_suggestions']['error_ips'] as $ip)
 				echo '
-							<dt>
-								<input type="checkbox" name="ban_suggestion[ips][]" value="', $ip, '" class="input_check" />
-							</dt>
-							<dd>
-								', $ip, '
-							</dd>';
+						<dt>
+							<input type="checkbox" name="ban_suggestion[ips][]" value="', $ip, '" class="input_check" />
+						</dt>
+						<dd>
+							', $ip, '
+						</dd>';
 		}
 
 		echo '
-							</dl>
-						</fieldset>';
+					</dl>
+				</fieldset>';
 	}
 
 	echo '
-						<hr class="hrcolor" />
 						<input type="submit" name="', $context['ban']['is_new'] ? 'add_ban' : 'modify_ban', '" value="', $context['ban']['is_new'] ? $txt['ban_add'] : $txt['ban_modify'], '" class="button_submit" />
 						<input type="hidden" name="old_expire" value="', $context['ban']['expiration']['days'], '" />
 						<input type="hidden" name="bg" value="', $context['ban']['id'], '" />
 						<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
 						<input type="hidden" name="', $context['admin-bet_token_var'], '" value="', $context['admin-bet_token'], '" />
-					</form>
 				</div>
-			</div>';
+			</form>';
 
 	if (!$context['ban']['is_new'] && empty($context['ban_suggestions']))
 	{
@@ -188,6 +184,7 @@ function template_ban_edit()
 						</tr>
 					</thead>
 					<tbody>';
+		
 		if (empty($context['ban_items']))
 			echo '
 						<tr class="windowbg2">
@@ -222,17 +219,15 @@ function template_ban_edit()
 		echo '
 					</tbody>
 				</table>
+				
 				<div class="flow_auto">
-					<div class="floatright">
-						<div class="additional_row">
-							<input type="submit" name="remove_selection" value="', $txt['ban_remove_selected_triggers'], '" class="button_submit" />
-							<a class="button_link" href="', $scripturl, '?action=admin;area=ban;sa=edittrigger;bg=', $context['ban']['id'], '">', $txt['ban_add_trigger'], '</a>
-						</div>
-					</div>
+					<br />
+					<input type="submit" name="remove_selection" value="', $txt['ban_remove_selected_triggers'], '" class="button_submit" />
+					<a class="button_link" href="', $scripturl, '?action=admin;area=ban;sa=edittrigger;bg=', $context['ban']['id'], '">', $txt['ban_add_trigger'], '</a>
+					<input type="hidden" name="bg" value="', $context['ban']['id'], '" />
+					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
+					<input type="hidden" name="', $context['admin-bet_token_var'], '" value="', $context['admin-bet_token'], '" />
 				</div>
-				<input type="hidden" name="bg" value="', $context['ban']['id'], '" />
-				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
-				<input type="hidden" name="', $context['admin-bet_token_var'], '" value="', $context['admin-bet_token'], '" />
 			</form>';
 
 	}
@@ -280,7 +275,7 @@ function template_ban_edit_trigger()
 
 	echo '
 	<div id="manage_bans">
-		<form action="', $scripturl, '?action=admin;area=ban;sa=edit" method="post" accept-charset="', $context['character_set'], '">
+		<form id="admin_form_wrapper" action="', $scripturl, '?action=admin;area=ban;sa=edit" method="post" accept-charset="', $context['character_set'], '">
 			<div class="cat_bar">
 				<h3 class="catbg">
 					', $context['ban_trigger']['is_new'] ? $txt['ban_add_trigger'] : $txt['ban_edit_trigger_title'], '

+ 8 - 3
Themes/default/ManageBoards.template.php

@@ -66,7 +66,8 @@ function template_main()
 		{
 
 			echo '
-						<li', !empty($modSettings['recycle_board']) && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] == $board['id'] ? ' id="recycle_board"' : ' ', ' class="windowbg', $alternate ? '' : '2', '" style="padding-' . ($context['right_to_left'] ? 'right' : 'left') . ': ', 5 + 30 * $board['child_level'], 'px;', $board['move'] ? 'color: red;' : '', '"><span class="floatleft"><a href="', $scripturl, '?board=', $board['id'], '">', $board['name'], '</a>', !empty($modSettings['recycle_board']) && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] == $board['id'] ? '<a href="' . $scripturl . '?action=admin;area=manageboards;sa=settings"> <img src="' . $settings['images_url'] . '/post/recycled.png" alt="' . $txt['recycle_board'] . '" /></a></span>' : '</span>', '
+						<li', !empty($modSettings['recycle_board']) && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] == $board['id'] ? ' id="recycle_board"' : ' ', ' class="windowbg', $alternate ? '' : '2', '" style="padding-' . ($context['right_to_left'] ? 'right' : 'left') . ': ', 5 + 30 * $board['child_level'], 'px;', $board['move'] ? 'color: red;' : '', '">
+							<span class="floatleft"><a href="', $scripturl, '?board=', $board['id'], '">', $board['name'], '</a>', !empty($modSettings['recycle_board']) && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] == $board['id'] ? '<a href="' . $scripturl . '?action=admin;area=manageboards;sa=settings"> <img src="' . $settings['images_url'] . '/post/recycled.png" alt="' . $txt['recycle_board'] . '" /></a></span>' : '</span>', '
 							<span class="floatright">', $context['can_manage_permissions'] ? '<span class="modify_boards"><a href="' . $scripturl . '?action=admin;area=permissions;sa=index;pid=' . $board['permission_profile'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '">' . $txt['mboards_permissions'] . '</a></span>' : '', '
 							<span class="modify_boards"><a href="', $scripturl, '?action=admin;area=manageboards;move=', $board['id'], '">', $txt['mboards_move'], '</a></span>
 							<span class="modify_boards"><a href="', $scripturl, '?action=admin;area=manageboards;sa=board;boardid=', $board['id'], '">', $txt['mboards_modify'], '</a></span></span><br style="clear: right;" />
@@ -98,6 +99,7 @@ function template_main()
 			</div>
 		</form>';
 	}
+	
 	echo '
 	</div>';
 }
@@ -112,14 +114,15 @@ function template_modify_category()
 	<div id="manage_boards">
 		<form action="', $scripturl, '?action=admin;area=manageboards;sa=cat2" method="post" accept-charset="', $context['character_set'], '">
 			<input type="hidden" name="cat" value="', $context['category']['id'], '" />
-				<div class="cat_bar">
-					<h3 class="catbg">
+				<div class="title_bar">
+					<h3 class="titlebg">
 					', isset($context['category']['is_new']) ? $txt['mboards_new_cat_name'] : $txt['catEdit'], '
 					</h3>
 				</div>
 				<div class="windowbg">
 					<div class="content">
 						<dl class="settings">';
+	
 	// If this isn't the only category, let the user choose where this category should be positioned down the board index.
 	if (count($context['category_order']) > 1)
 	{
@@ -127,6 +130,7 @@ function template_modify_category()
 						<dt><strong>', $txt['order'], ':</strong></dt>
 						<dd>
 							<select name="cat_order">';
+	
 		// Print every existing category into a select box.
 		foreach ($context['category_order'] as $order)
 			echo '
@@ -135,6 +139,7 @@ function template_modify_category()
 							</select>
 						</dd>';
 	}
+	
 	// Allow the user to edit the category name and/or choose whether you can collapse the category.
 	echo '
 						<dt>

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

@@ -87,7 +87,7 @@ function template_download_language()
 						<th scope="col" width="100">
 							', $txt['languages_download_exists'], '
 						</th>
-						<th class="last_th" scope="col" width="50">
+						<th class="last_th centercol" scope="col" width="4%">
 							', $txt['languages_download_copy'], '
 						</th>
 					</tr>
@@ -119,7 +119,7 @@ function template_download_language()
 					<td>
 						', $file['exists'] ? ($file['exists'] == 'same' ? $txt['languages_download_exists_same'] : $txt['languages_download_exists_different']) : $txt['no'], '
 					</td>
-					<td>
+					<td class="centercol">
 						<input type="checkbox" name="copy_file[]" value="', $file['generaldest'], '"', ($file['default_copy'] ? ' checked="checked"' : ''), ' class="input_check" />
 					</td>
 				</tr>';
@@ -429,7 +429,7 @@ function template_add_language()
 
 	echo '
 	<div id="admincenter">
-		<form action="', $scripturl, '?action=admin;area=languages;sa=add;', $context['session_var'], '=', $context['session_id'], '" method="post" accept-charset="', $context['character_set'], '">
+		<form id="admin_form_wrapper"action="', $scripturl, '?action=admin;area=languages;sa=add;', $context['session_var'], '=', $context['session_id'], '" method="post" accept-charset="', $context['character_set'], '">
 			<div class="cat_bar">
 				<h3 class="catbg">
 					', $txt['add_language'], '

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

@@ -113,7 +113,7 @@ function template_maintain_database()
 			<div class="content">
 				<form action="', $scripturl, '?action=admin;area=maintain;sa=database;activity=convertutf8" method="post" accept-charset="', $context['character_set'], '">
 					<p>', $txt['utf8_introduction'], '</p>
-					', !empty($modSettings['search_index']) && $modSettings['search_index'] == 'fulltext' ? '<p class="errorbox">' . $txt['utf8_cannot_convert_fulltext'] . '</p>' : '', '
+					', !empty($modSettings['search_index']) && $modSettings['search_index'] == 'fulltext' ? '<div class="errorbox">' . $txt['utf8_cannot_convert_fulltext'] . '</div>' : '', '
 					<input type="submit" value="', $txt['maintain_run_now'], '" class="button_submit" ', !empty($modSettings['search_index']) && $modSettings['search_index'] == 'fulltext' ? 'disabled="disabled"' : '', '/><br class="clear_right" />
 					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
 					<input type="hidden" name="', $context['admin-maint_token_var'], '" value="', $context['admin-maint_token'], '" />

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

@@ -89,8 +89,8 @@ function template_new_group()
 			echo '
 									<option value="', $group['id'], '">', $group['name'], '</option>';
 		echo '
-								</select><br />
-
+								</select>
+								<br />
 								<input type="radio" name="perm_type" id="perm_type_copy" value="copy" class="input_radio" />
 								<label for="perm_type_copy">', $txt['membergroups_new_as_copy'], ':</label>
 								<select name="copyperm" id="copyperm_select" onclick="document.getElementById(\'perm_type_copy\').checked = true;">
@@ -100,8 +100,8 @@ function template_new_group()
 			echo '
 									<option value="', $group['id'], '">', $group['name'], '</option>';
 		echo '
-								</select><br />
-
+								</select>
+								<br />
 								<input type="radio" name="perm_type" id="perm_type_predefined" value="predefined" class="input_radio" />
 								<label for="perm_type_predefined">', $txt['membergroups_new_as_type'], ':</label>
 								<select name="level" id="level_select" onclick="document.getElementById(\'perm_type_predefined\').checked = true;">
@@ -423,7 +423,7 @@ function template_add_edit_group_boards_list($collapse = true)
 							</fieldset>';
 	else
 		echo '
-								<br />
+								<br class="clear" />
 								<span class="select_all_box">
 									<em>', $txt['all'], ': </em>
 									<input type="radio" name="select_all" id="allow_all" class="input_radio" onclick="selectAllRadio(this, this.form, \'boardaccess\', \'allow\');" /> <label for="allow_all">', $txt['board_perms_allow'], '</label>
@@ -511,7 +511,7 @@ function template_group_members()
 				<h4 class="titlebg">', $txt['membergroups_members_group_members'], '</h4>
 			</div>
 			<br />
-			<div class="pagesection">', $txt['pages'], ': ', $context['page_index'], '</div>
+			<div class="pagesection">', $context['page_index'], '</div>
 			<table width="100%" class="table_grid">
 				<thead>
 					<tr class="catbg">
@@ -594,7 +594,7 @@ function template_group_members()
 
 	echo '
 			<div class="pagesection flow_hidden">
-				<div class="floatleft">', $txt['pages'], ': ', $context['page_index'], '</div>
+				<div class="floatleft">', $context['page_index'], '</div>
 			</div>
 			<br />';
 

Some files were not shown because too many files changed in this diff