ソースを参照

! Some more substr() changes
! Fix undefined index: http://www.simplemachines.org/community/index.php?topic=439520
! Undefined index from way back - http://www.simplemachines.org/community/index.php?topic=359749
! Minor code cleaning
! Doc changes
! Move some Javascript to the .js file. There's still so much to go with this.
+ Added session id, session var, and member id to the javascript variables
! A bunch of Javascript changes otherwise.
! Fixed a tiny Javascript issue with moderate login and focusing on it

Spuds 13 年 前
コミット
f265b300f9

+ 1 - 1
Sources/DbExtra-sqlite.php

@@ -339,7 +339,7 @@ function smf_db_get_backup()
 	header('Connection: close');
 
 	// Literally dump the contents.  Try reading the file first.
-	if (@readfile($db_file) == null)
+	if (@readfile($db_file) === null)
 		echo file_get_contents($db_file);
 
 	obExit(false);

+ 1 - 1
Sources/DbPackages-mysql.php

@@ -326,7 +326,7 @@ function smf_db_change_column($table_name, $old_column, $column_info, $parameter
 			$old_info = $column;
 
 	// Nothing?
-	if ($old_info == null)
+	if ($old_info === null)
 		return false;
 
 	// Get the right bits.

+ 1 - 1
Sources/DbPackages-postgresql.php

@@ -364,7 +364,7 @@ function smf_db_change_column($table_name, $old_column, $column_info, $parameter
 			$old_info = $column;
 
 	// Nothing?
-	if ($old_info == null)
+	if ($old_info === null)
 		return false;
 
 	// Now we check each bit individually and ALTER as required.

+ 3 - 3
Sources/Errors.php

@@ -43,13 +43,13 @@ function log_error($error_message, $error_type = 'general', $file = null, $line
 
 	// Add a file and line to the error message?
 	// Don't use the actual txt entries for file and line but instead use %1$s for file and %2$s for line
-	if ($file == null)
+	if ($file === null)
 		$file = '';
 	else
 		// Window style slashes don't play well, lets convert them to the unix style.
 		$file = str_replace('\\', '/', $file);
 
-	if ($line == null)
+	if ($line === null)
 		$line = 0;
 	else
 		$line = (int) $line;
@@ -365,7 +365,7 @@ function display_db_error()
 	{
 		// Avoid writing to the Settings.php file if at all possible; use shared memory instead.
 		cache_put_data('db_last_error', time(), 600);
-		if (($temp = cache_get_data('db_last_error', 600)) == null)
+		if (($temp = cache_get_data('db_last_error', 600)) === null)
 			logLastDatabaseError();
 
 		// Language files aren't loaded yet :(.

+ 1 - 1
Sources/Groups.php

@@ -18,7 +18,7 @@ if (!defined('SMF'))
 
 /**
  * Entry point function, permission checks, admin bars, etc.
- * It allows moderators and users to access the group showing functions.
+ *  It allows moderators and users to access the group showing functions.
  * It handles permission checks, and puts the moderation bar on as required.
  */
 function Groups()

+ 11 - 11
Sources/Load.php

@@ -19,7 +19,7 @@ if (!defined('SMF'))
 /**
  * Load the $modSettings array.
  * @todo okay question of the day: why a function loading settings is called reloadSettings()
- * 
+ *
  * @global array $modSettings is a giant array of all of the forum-wide settings and statistics.
  */
 function reloadSettings()
@@ -35,7 +35,7 @@ function reloadSettings()
 		);
 
 	// Try to load it from the cache first; it'll never get cached if the setting is off.
-	if (($modSettings = cache_get_data('modSettings', 90)) == null)
+	if (($modSettings = cache_get_data('modSettings', 90)) === null)
 	{
 		$request = $smcFunc['db_query']('', '
 			SELECT variable, value
@@ -256,7 +256,7 @@ function loadUserSettings()
 	if ($id_member != 0)
 	{
 		// Is the member data cached?
-		if (empty($modSettings['cache_enable']) || $modSettings['cache_enable'] < 2 || ($user_settings = cache_get_data('user_settings-' . $id_member, 60)) == null)
+		if (empty($modSettings['cache_enable']) || $modSettings['cache_enable'] < 2 || ($user_settings = cache_get_data('user_settings-' . $id_member, 60)) === null)
 		{
 			$request = $smcFunc['db_query']('', '
 				SELECT mem.*, IFNULL(a.id_attach, 0) AS id_attach, a.filename, a.attachment_type
@@ -873,7 +873,7 @@ function loadMemberData($users, $is_name = false, $set = 'normal')
 		for ($i = 0, $n = count($users); $i < $n; $i++)
 		{
 			$data = cache_get_data('member_data-' . $set . '-' . $users[$i], 240);
-			if ($data == null)
+			if ($data === null)
 				continue;
 
 			$loaded_ids[] = $data['id_member'];
@@ -977,7 +977,7 @@ function loadMemberData($users, $is_name = false, $set = 'normal')
 	// Are we loading any moderators?  If so, fix their group data...
 	if (!empty($loaded_ids) && !empty($board_info['moderators']) && $set === 'normal' && count($temp_mods = array_intersect($loaded_ids, array_keys($board_info['moderators']))) !== 0)
 	{
-		if (($row = cache_get_data('moderator_group_info', 480)) == null)
+		if (($row = cache_get_data('moderator_group_info', 480)) === null)
 		{
 			$request = $smcFunc['db_query']('', '
 				SELECT group_name AS member_group, online_color AS member_group_color, stars
@@ -1093,7 +1093,7 @@ function loadMemberContext($user, $display_custom_fields = false)
 			'title' => $profile['website_title'],
 			'url' => $profile['website_url'],
 		),
-		'birth_date' => empty($profile['birthdate']) || $profile['birthdate'] === '0001-01-01' ? '0000-00-00' : (substr($profile['birthdate'], 0, 4) === '0004' ? '0000' . substr($profile['birthdate'], 4) : $profile['birthdate']),
+		'birth_date' => empty($profile['birthdate']) || $profile['birthdate'] === '0001-01-01' ? '0000-00-00' : (strpos($profile['birthdate'], '0004') === 0 ? '0000' . substr($profile['birthdate'], 4) : $profile['birthdate']),
 		'signature' => $profile['signature'],
 		'location' => $profile['location'],
 		'icq' => $profile['icq'] != '' && (empty($modSettings['guest_hideContacts']) || !$user_info['is_guest']) ? array(
@@ -1730,7 +1730,7 @@ function loadTheme($id_theme = 0, $initialize = true)
  *  - uses the template_include() function to include the file.
  *  - detects a wrong default theme directory and tries to work around it.
  *  - if fatal is true, dies with an error message if the template cannot be found.
- * 
+ *
  * @param string $template_name
  * @param array $style_sheets = array()
  * @param bool $fatal = true
@@ -1824,9 +1824,9 @@ function loadTemplate($template_name, $style_sheets = array(), $fatal = true)
  *  template.
  *  - if ?debug is in the query string, shows administrators a marker after every sub template
  *   for debugging purposes.
- * 
+ *
  * @todo get rid of reading $_REQUEST directly
- * 
+ *
  * @param string $sub_template_name
  * @param bool $fatal = false, $fatal = true is for templates that shouldn't get a 'pretty' error screen.
  */
@@ -2036,7 +2036,7 @@ function getLanguages($use_cache = true, $favor_utf8 = true)
 	global $context, $smcFunc, $settings, $modSettings;
 
 	// Either we don't use the cache, or its expired.
-	if (!$use_cache || ($context['languages'] = cache_get_data('known_languages' . ($favor_utf8 ? '' : '_all'), !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600)) == null)
+	if (!$use_cache || ($context['languages'] = cache_get_data('known_languages' . ($favor_utf8 ? '' : '_all'), !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600)) === null)
 	{
 		// If we don't have our theme information yet, lets get it.
 		if (empty($settings['default_theme_dir']))
@@ -2083,7 +2083,7 @@ function getLanguages($use_cache = true, $favor_utf8 = true)
 		if ($favor_utf8)
 		{
 			foreach ($context['languages'] as $lang)
-				if (substr($lang['filename'], strlen($lang['filename']) - 5, 5) != '-utf8' && isset($context['languages'][$lang['filename'] . '-utf8']))
+				if (strpos($lang['filename'], '-utf8') !== strlen($lang['filename']) - 5 && isset($context['languages'][$lang['filename'] . '-utf8']))
 					unset($context['languages'][$lang['filename']]);
 		}
 

+ 2 - 2
Sources/ManageMaintenance.php

@@ -1545,8 +1545,8 @@ function MaintainPurgeInactiveMembers()
 {
 	global $sourcedir, $context, $smcFunc, $txt;
 
-	$_POST['maxdays'] = (int) $_POST['maxdays'];
-	if (!empty($_POST['groups']) && $_POST['maxdays'])
+	$_POST['maxdays'] = empty($_POST['maxdays']) ? 0 : (int) $_POST['maxdays'];
+	if (!empty($_POST['groups']) && $_POST['maxdays'] > 0)
 	{
 		checkSession();
 		validateToken('admin-maint');

+ 14 - 4
Sources/ManageSearchEngines.php

@@ -316,6 +316,9 @@ function ViewSpiders()
 
 /**
  * Callback function for createList()
+ * @param int $start
+ * @param int $items_per_page
+ * @param string sort
  */
 function list_getSpiders($start, $items_per_page, $sort)
 {
@@ -339,6 +342,7 @@ function list_getSpiders($start, $items_per_page, $sort)
 
 /**
  * Callback function for createList()
+ * @return int
  */
 function list_getNumSpiders()
 {
@@ -456,6 +460,7 @@ function EditSpider()
  * Do we think the current user is a spider?
  * 
  * @todo Should this not be... you know... in a different file?
+ * @return int
  */
 function SpiderCheck()
 {
@@ -466,10 +471,7 @@ function SpiderCheck()
 	$_SESSION['robot_check'] = time();
 
 	// We cache the spider data for five minutes if we can.
-	if (!empty($modSettings['cache_enable']))
-		$spider_data = cache_get_data('spider_search', 300);
-
-	if (!isset($spider_data) || $spider_data === NULL)
+	if (($spider_data = cache_get_data('spider_search', 300)) === null)
 	{
 		$request = $smcFunc['db_query']('spider_check', '
 			SELECT id_spider, user_agent, ip_info
@@ -785,6 +787,11 @@ function SpiderLogs()
 
 /**
  * Callback function for createList()
+ * 
+ * @param int $start
+ * @param int $items_per_page
+ * @param string $sort
+ * @return array
  */
 function list_getSpiderLogs($start, $items_per_page, $sort)
 {
@@ -809,6 +816,7 @@ function list_getSpiderLogs($start, $items_per_page, $sort)
 
 /**
  * Callback function for createList()
+ * @return int
  */
 function list_getNumSpiderLogs()
 {
@@ -981,6 +989,7 @@ function SpiderStats()
 
 /**
  * Callback function for createList()
+ * @return array
  */
 function list_getSpiderStats($start, $items_per_page, $sort)
 {
@@ -1005,6 +1014,7 @@ function list_getSpiderStats($start, $items_per_page, $sort)
 
 /**
  * Callback function for createList()
+ * @return int
  */
 function list_getNumSpiderStats()
 {

+ 6 - 5
Sources/PersonalMessage.php

@@ -1246,13 +1246,16 @@ function MessageSearch2()
 
 	// Now we look for -test, etc.... normaller.
 	foreach ($tempSearch as $index => $word)
-		if (strpos(trim($word), '-') === 0)
+	{
+		$word = trim($word);
+		if ($word[0] == '.')
 		{
-			$word = substr($smcFunc['strtolower'](trim($word)), 1);
+			$word = substr($smcFunc['strtolower']($word), 1);
 			if (strlen($word) > 0)
 				$excludedWords[] = $word;
 			unset($tempSearch[$index]);
 		}
+	}
 
 	$searchArray = array_merge($searchArray, $tempSearch);
 
@@ -1349,9 +1352,7 @@ function MessageSearch2()
 	$smcFunc['db_free_result']($request);
 
 	// Get all the matching messages... using standard search only (No caching and the like!)
-	/**
-	 * @todo This doesn't support sent item searching yet.
-	 */
+	// @todo This doesn't support sent item searching yet.
 	$request = $smcFunc['db_query']('', '
 		SELECT pm.id_pm, pm.id_pm_head, pm.id_member_from
 		FROM {db_prefix}pm_recipients AS pmr

+ 1 - 1
Sources/Profile-Modify.php

@@ -351,7 +351,7 @@ function loadProfileFields($force_reload = false)
 
 					// Maybe they are trying to change their password as well?
 					$resetPassword = true;
-					if (isset($_POST[\'passwrd1\']) && $_POST[\'passwrd1\'] != \'\' && isset($_POST[\'passwrd2\']) && $_POST[\'passwrd1\'] == $_POST[\'passwrd2\'] && validatePassword($_POST[\'passwrd1\'], $value, array($cur_profile[\'real_name\'], $user_info[\'username\'], $user_info[\'name\'], $user_info[\'email\'])) == null)
+					if (isset($_POST[\'passwrd1\']) && $_POST[\'passwrd1\'] != \'\' && isset($_POST[\'passwrd2\']) && $_POST[\'passwrd1\'] == $_POST[\'passwrd2\'] && validatePassword($_POST[\'passwrd1\'], $value, array($cur_profile[\'real_name\'], $user_info[\'username\'], $user_info[\'name\'], $user_info[\'email\'])) === null)
 						$resetPassword = false;
 
 					// Do the reset... this will send them an email too.

+ 5 - 5
Sources/QueryString.php

@@ -76,7 +76,7 @@ function cleanRequest()
 
 		// Was this redirected? If so, get the REDIRECT_QUERY_STRING.
 		// Do not urldecode() the querystring, unless you so much wish to break OpenID implementation. :)
-		$_SERVER['QUERY_STRING'] = substr($_SERVER['QUERY_STRING'], 0, 5) === 'url=/' ? $_SERVER['REDIRECT_QUERY_STRING'] : $_SERVER['QUERY_STRING'];
+		$_SERVER['QUERY_STRING'] = strpos($_SERVER['QUERY_STRING'], 'url=/') === 0 ? $_SERVER['REDIRECT_QUERY_STRING'] : $_SERVER['QUERY_STRING'];
 
 		// Replace ';' with '&' and '&something&' with '&something=&'.  (this is done for compatibility...)
 		// @todo smflib
@@ -475,7 +475,7 @@ function JavaScriptEscape($string)
 		'</' => '<\' + \'/',
 		'script' => 'scri\'+\'pt',
 		'<a href' => '<a hr\'+\'ef',
-		$scripturl => $scripturl . '\'+\'',
+		$scripturl => 'smf_scripturl\' + \'',
 	)) . '\'';
 }
 
@@ -483,12 +483,12 @@ function JavaScriptEscape($string)
  * Rewrite URLs to include the session ID.
  * What it does:
  * - rewrites the URLs outputted to have the session ID, if the user
- * is not accepting cookies and is using a standard web browser.
+ *   is not accepting cookies and is using a standard web browser.
  * - handles rewriting URLs for the queryless URLs option.
  * - can be turned off entirely by setting $scripturl to an empty
- * string, ''. (it wouldn't work well like that anyway.)
+ *   string, ''. (it wouldn't work well like that anyway.)
  * - because of bugs in certain builds of PHP, does not function in
- * versions lower than 4.3.0 - please upgrade if this hurts you.
+ *   versions lower than 4.3.0 - please upgrade if this hurts you.
  *
  * @param string $buffer
  * @return string

+ 1 - 1
Sources/Recent.php

@@ -230,7 +230,7 @@ function RecentPosts()
 	);
 
 	$key = 'recent-' . $user_info['id'] . '-' . md5(serialize(array_diff_key($query_parameters, array('max_id_msg' => 0)))) . '-' . (int) $_REQUEST['start'];
-	if (empty($modSettings['cache_enable']) || ($messages = cache_get_data($key, 120)) == null)
+	if (empty($modSettings['cache_enable']) || ($messages = cache_get_data($key, 120)) === null)
 	{
 		$done = false;
 		while (!$done)

+ 1 - 1
Sources/Search.php

@@ -1831,7 +1831,7 @@ function prepareSearchContext($reset = false)
 
 	// Remember which message this is.  (ie. reply #83)
 	static $counter = null;
-	if ($counter == null || $reset)
+	if ($counter === null || $reset)
 		$counter = $_REQUEST['start'] + 1;
 
 	// If the query returned false, bail.

+ 51 - 10
Sources/Security.php

@@ -476,7 +476,9 @@ function is_not_banned($forceCheck = false)
 		banPermissions();
 }
 
-// Fix permissions according to ban status.
+/**
+ * Fix permissions according to ban status.
+ */
 function banPermissions()
 {
 	global $user_info, $sourcedir, $modSettings, $context;
@@ -553,7 +555,11 @@ function banPermissions()
 		$context['open_mod_reports'] = 0;
 }
 
-// Log a ban in the database.
+/**
+ * Log a ban in the database.
+ * @param array $ban_ids = array()
+ * @param string $email = null
+ */
 function log_ban($ban_ids = array(), $email = null)
 {
 	global $user_info, $smcFunc;
@@ -581,7 +587,12 @@ function log_ban($ban_ids = array(), $email = null)
 		);
 }
 
-// Checks if a given email address might be banned.
+/**
+ * Checks if a given email address might be banned.
+ * @param string $email
+ * @param string $restriction
+ * @param string $error
+ */
 function isBannedEmail($email, $restriction, $error)
 {
 	global $txt, $smcFunc;
@@ -640,7 +651,13 @@ function isBannedEmail($email, $restriction, $error)
 	}
 }
 
-// Make sure the user's correct session was passed, and they came from here. (type can be post, get, or request.)
+/**
+ * Make sure the user's correct session was passed, and they came from here. (type can be post, get, or request.)
+ * @param string $type = 'post'
+ * @param string $from_action = ''
+ * @param bool $is_fatal = true
+ * @return string
+ */
 function checkSession($type = 'post', $from_action = '', $is_fatal = true)
 {
 	global $sc, $modSettings, $boardurl;
@@ -747,7 +764,10 @@ function checkSession($type = 'post', $from_action = '', $is_fatal = true)
 	trigger_error('Hacking attempt...', E_USER_ERROR);
 }
 
-// Check if a specific confirm parameter was given.
+/**
+ * Check if a specific confirm parameter was given.
+ * @param string $action
+ */
 function checkConfirm($action)
 {
 	global $modSettings;
@@ -764,7 +784,11 @@ function checkConfirm($action)
 	}
 }
 
-// Lets give you a token of our appreciation.
+/**
+ * Lets give you a token of our appreciation.
+ * @param string $action
+ * @param string $type = 'post'
+ */
 function createToken($action, $type = 'post')
 {
 	global $modSettings, $context;
@@ -780,7 +804,12 @@ function createToken($action, $type = 'post')
 	return array($token_var, $token);
 }
 
-// Only patrons with valid tokens can ride this ride.
+/**
+ * Only patrons with valid tokens can ride this ride.
+ * @param string $action
+ * @param string $type = 'post' (get, request, or post)
+ * @param bool $reset = true
+ */
 function validateToken($action, $type = 'post', $reset = true)
 {
 	global $modSettings;
@@ -825,7 +854,10 @@ function validateToken($action, $type = 'post', $reset = true)
 	return false;
 }
 
-// Clean up a little.
+/**
+ * Clean up a little.
+ * @param bool $complete = false
+ */
 function cleanTokens($complete = false)
 {
 	// We appreciate cleaning up after yourselves.
@@ -838,7 +870,11 @@ function cleanTokens($complete = false)
 			unset($_SESSION['token'][$key]);
 }
 
-// Check whether a form has been submitted twice.
+/**
+ * Check whether a form has been submitted twice.
+ * @param string $action
+ * @param bool $is_fatal = true
+ */
 function checkSubmitOnce($action, $is_fatal = true)
 {
 	global $context;
@@ -875,7 +911,12 @@ function checkSubmitOnce($action, $is_fatal = true)
 		trigger_error('checkSubmitOnce(): Invalid action \'' . $action . '\'', E_USER_WARNING);
 }
 
-// Check the user's permissions.
+/**
+ * Check the user's permissions.
+ * @param string $permission
+ * @param array $boards = null
+ * @return bool
+ */
 function allowedTo($permission, $boards = null)
 {
 	global $user_info, $modSettings, $smcFunc;

+ 2 - 2
Sources/Stats.php

@@ -146,7 +146,7 @@ function DisplayStats()
 	$context['latest_member'] = &$context['common_stats']['latest_member'];
 
 	// Male vs. female ratio - let's calculate this only every four minutes.
-	if (($context['gender'] = cache_get_data('stats_gender', 240)) == null)
+	if (($context['gender'] = cache_get_data('stats_gender', 240)) === null)
 	{
 		$result = $smcFunc['db_query']('', '
 			SELECT COUNT(*) AS total_members, gender
@@ -416,7 +416,7 @@ function DisplayStats()
 	}
 
 	// Try to cache this when possible, because it's a little unavoidably slow.
-	if (($members = cache_get_data('stats_top_starters', 360)) == null)
+	if (($members = cache_get_data('stats_top_starters', 360)) === null)
 	{
 		$request = $smcFunc['db_query']('', '
 			SELECT id_member_started, COUNT(*) AS hits

+ 53 - 27
Sources/Subs-Boards.php

@@ -1,6 +1,9 @@
 <?php
 
 /**
+ * This file is mainly concerned with minor tasks relating to boards, such as
+ * marking them read, collapsing categories, or quick moderation.
+ * 
  * Simple Machines Forum (SMF)
  *
  * @package SMF
@@ -14,16 +17,7 @@
 if (!defined('SMF'))
 	die('Hacking attempt...');
 
-/*	This file is mainly concerned with minor tasks relating to boards, such as
-	marking them read, collapsing categories, or quick moderation.  It defines
-	the following list of functions:
-
-	void MarkRead()
-		// @todo
-
-	int getMsgMemberID(int id_msg)
-		// @todo
-
+/*
 	void modifyBoard(int board_id, array boardOptions)
 		- general function to modify the settings and position of a board.
 		- used by ManageBoards.php to change the settings of a board.
@@ -59,13 +53,6 @@ if (!defined('SMF'))
 		- recurses down the tree until there are no more parents.
 		- returns true if child is a child of parent.
 
-	void getBoardTree()
-		- load information regarding the boards and categories.
-		- the information retrieved is stored in globals:
-			- $boards		properties of each board.
-			- $boardList	a list of boards grouped by category ID.
-			- $cat_tree		properties of each category.
-
 	void recursiveBoards()
 		- function used by getBoardTree to recursively get a list of boards.
 
@@ -190,7 +177,9 @@ function markBoardsRead($boards, $unread = false)
 		);
 }
 
-// Mark one or more boards as read.
+/**
+ * Mark one or more boards as read.
+ */
 function MarkRead()
 {
 	global $board, $topic, $user_info, $board_info, $modSettings, $smcFunc;
@@ -448,7 +437,10 @@ function MarkRead()
 	}
 }
 
-// Get the id_member associated with the specified message.
+/**
+ * Get the id_member associated with the specified message.
+ * @param int $messageID
+ */
 function getMsgMemberID($messageID)
 {
 	global $smcFunc;
@@ -474,7 +466,11 @@ function getMsgMemberID($messageID)
 	return (int) $memberID;
 }
 
-// Modify the settings and position of a board.
+/**
+ * Modify the settings and position of a board.
+ * @param int $board_id
+ * @param array &$boardOptions
+ */
 function modifyBoard($board_id, &$boardOptions)
 {
 	global $sourcedir, $cat_tree, $boards, $boardList, $modSettings, $smcFunc;
@@ -746,7 +742,11 @@ function modifyBoard($board_id, &$boardOptions)
 		logAction('edit_board', array('board' => $board_id), 'admin');
 }
 
-// Create a new board and set its properties and position.
+/**
+ * Create a new board and set its properties and position.
+ * @param array $boardOptions
+ * @return int The new board id
+ */
 function createBoard($boardOptions)
 {
 	global $boards, $modSettings, $smcFunc;
@@ -835,7 +835,11 @@ function createBoard($boardOptions)
 	return $board_id;
 }
 
-// Remove one or more boards.
+/**
+ * Remove one or more boards.
+ * @param array $boards_to_remove
+ * @param array $moveChildrenTo = null
+ */
 function deleteBoards($boards_to_remove, $moveChildrenTo = null)
 {
 	global $sourcedir, $boards, $smcFunc;
@@ -969,7 +973,9 @@ function deleteBoards($boards_to_remove, $moveChildrenTo = null)
 	reorderBoards();
 }
 
-// Put all boards in the right order.
+/**
+ * Put all boards in the right order.
+ */
 function reorderBoards()
 {
 	global $cat_tree, $boardList, $boards, $smcFunc;
@@ -1003,7 +1009,12 @@ function reorderBoards()
 	);
 }
 
-// Fixes the children of a board by setting their child_levels to new values.
+/**
+ * Fixes the children of a board by setting their child_levels to new values.
+ * @param int $parent
+ * @param int $newLevel
+ * @param int $newParent
+ */
 function fixChildren($parent, $newLevel, $newParent)
 {
 	global $smcFunc;
@@ -1039,7 +1050,13 @@ function fixChildren($parent, $newLevel, $newParent)
 		fixChildren($child, $newLevel + 1, $child);
 }
 
-// Load a lot of useful information regarding the boards and categories.
+/**
+ * Load a lot of useful information regarding the boards and categories.
+ * The information retrieved is stored in globals:
+ *  $boards		properties of each board.
+ *  $boardList	a list of boards grouped by category ID.
+ *  $cat_tree	properties of each category.
+ */
 function getBoardTree()
 {
 	global $cat_tree, $boards, $boardList, $txt, $modSettings, $smcFunc;
@@ -1151,7 +1168,11 @@ function getBoardTree()
 	}
 }
 
-// Recursively get a list of boards.
+/**
+ * Recursively get a list of boards.
+ * @param array &$_boardList
+ * @param array &$_tree
+ */
 function recursiveBoards(&$_boardList, &$_tree)
 {
 	if (empty($_tree['children']))
@@ -1164,7 +1185,12 @@ function recursiveBoards(&$_boardList, &$_tree)
 	}
 }
 
-// Returns whether the child board id is actually a child of the parent (recursive).
+/**
+ * Returns whether the child board id is actually a child of the parent (recursive).
+ * @param int $child
+ * @param int $parent
+ * @return bool
+ */
 function isChildOf($child, $parent)
 {
 	global $boards;

+ 1 - 0
Sources/Subs-Compat.php

@@ -309,4 +309,5 @@ if (!function_exists('str_ireplace'))
 		return preg_replace($search, $replace, $subject, $count > 0 ? $count : -1);
 	}
 }
+
 ?>

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

@@ -224,7 +224,7 @@ function smf_db_quote($db_string, $db_values, $connection = null)
 	if (strpos($db_string, '{') !== false)
 	{
 		// This is needed by the callback function.
-		$db_callback = array($db_values, $connection == null ? $db_connection : $connection);
+		$db_callback = array($db_values, $connection === null ? $db_connection : $connection);
 
 		// Do the quoting and escaping
 		$db_string = preg_replace_callback('~{([a-z_]+)(?::([a-zA-Z0-9_-]+))?}~', 'smf_db_replacement__callback', $db_string);
@@ -259,7 +259,7 @@ function smf_db_query($identifier, $db_string, $db_values = array(), $connection
 	);
 
 	// Decide which connection to use.
-	$connection = $connection == null ? $db_connection : $connection;
+	$connection = $connection === null ? $db_connection : $connection;
 
 	// One more query....
 	$db_count = !isset($db_count) ? 1 : $db_count + 1;
@@ -390,7 +390,7 @@ function smf_db_affected_rows($connection = null)
 {
 	global $db_connection;
 
-	return mysql_affected_rows($connection == null ? $db_connection : $connection);
+	return mysql_affected_rows($connection === null ? $db_connection : $connection);
 }
 
 /**
@@ -407,7 +407,7 @@ function smf_db_insert_id($table, $field = null, $connection = null)
 	$table = str_replace('{db_prefix}', $db_prefix, $table);
 
 	// MySQL doesn't need the table or field information.
-	return mysql_insert_id($connection == null ? $db_connection : $connection);
+	return mysql_insert_id($connection === null ? $db_connection : $connection);
 }
 
 /**
@@ -421,7 +421,7 @@ function smf_db_transaction($type = 'commit', $connection = null)
 	global $db_connection;
 
 	// Decide which connection to use
-	$connection = $connection == null ? $db_connection : $connection;
+	$connection = $connection === null ? $db_connection : $connection;
 
 	if ($type == 'begin')
 		return @mysql_query('BEGIN', $connection);
@@ -451,7 +451,7 @@ function smf_db_error($db_string, $connection = null)
 	list ($file, $line) = smf_db_error_backtrace('', '', 'return', __FILE__, __LINE__);
 
 	// Decide which connection to use
-	$connection = $connection == null ? $db_connection : $connection;
+	$connection = $connection === null ? $db_connection : $connection;
 
 	// This is the error message...
 	$query_error = mysql_error($connection);

+ 6 - 6
Sources/Subs-Db-postgresql.php

@@ -216,7 +216,7 @@ function smf_db_quote($db_string, $db_values, $connection = null)
 	if (strpos($db_string, '{') !== false)
 	{
 		// This is needed by the callback function.
-		$db_callback = array($db_values, $connection == null ? $db_connection : $connection);
+		$db_callback = array($db_values, $connection === null ? $db_connection : $connection);
 
 		// Do the quoting and escaping
 		$db_string = preg_replace_callback('~{([a-z_]+)(?::([a-zA-Z0-9_-]+))?}~', 'smf_db_replacement__callback', $db_string);
@@ -239,7 +239,7 @@ function smf_db_query($identifier, $db_string, $db_values = array(), $connection
 	global $db_unbuffered, $db_callback, $db_last_result, $db_replace_result, $modSettings;
 
 	// Decide which connection to use.
-	$connection = $connection == null ? $db_connection : $connection;
+	$connection = $connection === null ? $db_connection : $connection;
 
 	// Special queries that need processing.
 	$replacements = array(
@@ -465,10 +465,10 @@ function smf_db_affected_rows($result = null)
 
 	if ($db_replace_result)
 		return $db_replace_result;
-	elseif ($result == null && !$db_last_result)
+	elseif ($result === null && !$db_last_result)
 		return 0;
 
-	return pg_affected_rows($result == null ? $db_last_result : $result);
+	return pg_affected_rows($result === null ? $db_last_result : $result);
 }
 
 /**
@@ -511,7 +511,7 @@ function smf_db_transaction($type = 'commit', $connection = null)
 	global $db_connection;
 
 	// Decide which connection to use
-	$connection = $connection == null ? $db_connection : $connection;
+	$connection = $connection === null ? $db_connection : $connection;
 
 	if ($type == 'begin')
 		return @pg_query($connection, 'BEGIN');
@@ -541,7 +541,7 @@ function smf_db_error($db_string, $connection = null)
 	list ($file, $line) = smf_db_error_backtrace('', '', 'return', __FILE__, __LINE__);
 
 	// Decide which connection to use
-	$connection = $connection == null ? $db_connection : $connection;
+	$connection = $connection === null ? $db_connection : $connection;
 
 	// This is the error message...
 	$query_error = @pg_last_error($connection);

+ 6 - 6
Sources/Subs-Db-sqlite.php

@@ -232,7 +232,7 @@ function smf_db_quote($db_string, $db_values, $connection = null)
 	if (strpos($db_string, '{') !== false)
 	{
 		// This is needed by the callback function.
-		$db_callback = array($db_values, $connection == null ? $db_connection : $connection);
+		$db_callback = array($db_values, $connection === null ? $db_connection : $connection);
 
 		// Do the quoting and escaping
 		$db_string = preg_replace_callback('~{([a-z_]+)(?::([a-zA-Z0-9_-]+))?}~', 'smf_db_replacement__callback', $db_string);
@@ -253,7 +253,7 @@ function smf_db_query($identifier, $db_string, $db_values = array(), $connection
 	global $db_unbuffered, $db_callback, $modSettings;
 
 	// Decide which connection to use.
-	$connection = $connection == null ? $db_connection : $connection;
+	$connection = $connection === null ? $db_connection : $connection;
 
 	// Special queries that need processing.
 	$replacements = array(
@@ -398,7 +398,7 @@ function smf_db_affected_rows($connection = null)
 {
 	global $db_connection;
 
-	return sqlite_changes($connection == null ? $db_connection : $connection);
+	return sqlite_changes($connection === null ? $db_connection : $connection);
 }
 
 /**
@@ -415,7 +415,7 @@ function smf_db_insert_id($table, $field = null, $connection = null)
 	$table = str_replace('{db_prefix}', $db_prefix, $table);
 
 	// SQLite doesn't need the table or field information.
-	return sqlite_last_insert_rowid($connection == null ? $db_connection : $connection);
+	return sqlite_last_insert_rowid($connection === null ? $db_connection : $connection);
 }
 
 /**
@@ -440,7 +440,7 @@ function smf_db_transaction($type = 'commit', $connection = null)
 	global $db_connection, $db_in_transact;
 
 	// Decide which connection to use
-	$connection = $connection == null ? $db_connection : $connection;
+	$connection = $connection === null ? $db_connection : $connection;
 
 	if ($type == 'begin')
 	{
@@ -479,7 +479,7 @@ function smf_db_error($db_string, $connection = null)
 	list ($file, $line) = smf_db_error_backtrace('', '', 'return', __FILE__, __LINE__);
 
 	// Decide which connection to use
-	$connection = $connection == null ? $db_connection : $connection;
+	$connection = $connection === null ? $db_connection : $connection;
 
 	// This is the error message...
 	$query_errno = sqlite_last_error($connection);

+ 40 - 43
Sources/Subs-Editor.php

@@ -17,34 +17,6 @@
 if (!defined('SMF'))
 	die('Hacking attempt...');
 
-/*
-	void theme_postbox(string message)
-		- for compatibility - passes right through to the template_control_richedit function.
-
-	void create_control_richedit(&array editorOptions)
-		// !!
-
-	void create_control_verification(&array suggestOptions)
-		// !!
-
-	void fetchTagAttributes()
-		// !!
-
-	array getMessageIcons(int board_id)
-	- retrieves a list of message icons.
-	- based on the settings, the array will either contain a list of default
-	  message icons or a list of custom message icons retrieved from the
-	  database.
-	- the board_id is needed for the custom message icons (which can be set for
-	  each board individually).
-
-	void AutoSuggestHandler(string checkRegistered = null)
-		// @todo
-
-	void AutoSuggest_Search_Member()
-		// @todo
-*/
-
 /**
  * At the moment this is only used for returning WYSIWYG data.
  */
@@ -81,6 +53,7 @@ function EditorMain()
 /**
  * Convert only the BBC that can be edited in HTML mode for the editor.
  * @param string $text
+ * @return string
  */
 function bbc_to_html($text)
 {
@@ -904,7 +877,7 @@ function fetchTagAttributes($text)
 	for ($i = 0; $i < strlen($text); $i++)
 	{
 		// We're either moving from the key to the attribute or we're in a string and this is fine.
-		if ($text{$i} == '=')
+		if ($text[$i] == '=')
 		{
 			if ($tag_state == 0)
 				$tag_state = 1;
@@ -912,7 +885,7 @@ function fetchTagAttributes($text)
 				$value .= '=';
 		}
 		// A space is either moving from an attribute back to a potential key or in a string is fine.
-		elseif ($text{$i} == ' ')
+		elseif ($text[$i] == ' ')
 		{
 			if ($tag_state == 2)
 				$value .= ' ';
@@ -924,7 +897,7 @@ function fetchTagAttributes($text)
 			}
 		}
 		// A quote?
-		elseif ($text{$i} == '"')
+		elseif ($text[$i] == '"')
 		{
 			// Must be either going into or out of a string.
 			if ($tag_state == 1)
@@ -936,9 +909,9 @@ function fetchTagAttributes($text)
 		else
 		{
 			if ($tag_state == 0)
-				$key .= $text{$i};
+				$key .= $text[$i];
 			else
-				$value .= $text{$i};
+				$value .= $text[$i];
 		}
 	}
 
@@ -991,7 +964,7 @@ function getMessageIcons($board_id)
 	// Otherwise load the icons, and check we give the right image too...
 	else
 	{
-		if (($temp = cache_get_data('posting_icons-' . $board_id, 480)) == null)
+		if (($temp = cache_get_data('posting_icons-' . $board_id, 480)) === null)
 		{
 			$request = $smcFunc['db_query']('select_message_icons', '
 				SELECT title, filename
@@ -1026,7 +999,11 @@ function getMessageIcons($board_id)
 	return array_values($icons);
 }
 
-// This is an important yet frustrating function - it attempts to clean up illegal BBC caused by browsers like Opera which don't obey the rules!!!
+/**
+ * Attempt to clean up illegal BBC caused by browsers like Opera which don't obey the rules
+ * @param string $text
+ * @return string
+ */
 function legalise_bbc($text)
 {
 	global $modSettings;
@@ -1415,13 +1392,23 @@ function legalise_bbc($text)
 	return $text;
 }
 
-// A help function for legalise_bbc for sorting arrays based on length.
+/**
+ * A help function for legalise_bbc for sorting arrays based on length.
+ * @param string $a
+ * @param string $b
+ * @return int 1 or -1
+ */
 function sort_array_length($a, $b)
 {
 	return strlen($a) < strlen($b) ? 1 : -1;
 }
 
-// Compatibility function - used in 1.1 for showing a post box.
+/**
+ * Compatibility function - used in 1.1 for showing a post box.
+ * 
+ * @param string $msg
+ * @return string
+ */
 function theme_postbox($msg)
 {
 	global $context;
@@ -1429,7 +1416,10 @@ function theme_postbox($msg)
 	return template_control_richedit($context['post_box_name']);
 }
 
-// Creates a box that can be used for richedit stuff like BBC, Smileys etc.
+/**
+ * Creates a box that can be used for richedit stuff like BBC, Smileys etc.
+ * @param array $editorOptions
+ */
 function create_control_richedit($editorOptions)
 {
 	global $txt, $modSettings, $options, $smcFunc;
@@ -1830,7 +1820,7 @@ function create_control_richedit($editorOptions)
 			);
 		elseif ($user_info['smiley_set'] != 'none')
 		{
-			if (($temp = cache_get_data('posting_smileys', 480)) == null)
+			if (($temp = cache_get_data('posting_smileys', 480)) === null)
 			{
 				$request = $smcFunc['db_query']('', '
 					SELECT code, filename, description, smiley_row, hidden
@@ -1892,7 +1882,11 @@ function create_control_richedit($editorOptions)
 	}
 }
 
-// Create a anti-bot verification control?
+/**
+ * Create a anti-bot verification control?
+ * @param array &$verificationOptions
+ * @param bool $do_test = false
+ */
 function create_control_verification(&$verificationOptions, $do_test = false)
 {
 	global $txt, $modSettings, $options, $smcFunc;
@@ -1948,7 +1942,7 @@ function create_control_verification(&$verificationOptions, $do_test = false)
 	// If we want questions do we have a cache of all the IDs?
 	if (!empty($thisVerification['number_questions']) && empty($modSettings['question_id_cache']))
 	{
-		if (($modSettings['question_id_cache'] = cache_get_data('verificationQuestionIds', 300)) == null)
+		if (($modSettings['question_id_cache'] = cache_get_data('verificationQuestionIds', 300)) === null)
 		{
 			$request = $smcFunc['db_query']('', '
 				SELECT id_comment
@@ -2114,7 +2108,10 @@ function create_control_verification(&$verificationOptions, $do_test = false)
 	return true;
 }
 
-// This keeps track of all registered handling functions for auto suggest functionality and passes execution to them.
+/**
+ * This keeps track of all registered handling functions for auto suggest functionality and passes execution to them.
+ * @param bool $checkRegistered = null
+ */
 function AutoSuggestHandler($checkRegistered = null)
 {
 	global $context;
@@ -2125,7 +2122,7 @@ function AutoSuggestHandler($checkRegistered = null)
 	);
 
 	// If we're just checking the callback function is registered return true or false.
-	if ($checkRegistered != null)
+	if ($checkRegistered !== null)
 		return isset($searchTypes[$checkRegistered]) && function_exists('AutoSuggest_Search_' . $checkRegistered);
 
 	checkSession('get');

+ 1 - 1
Sources/Subs-Menu.php

@@ -160,7 +160,7 @@ function createMenu($menuData, $menuOptions = array())
 							{
 								if ((empty($sub[1]) || allowedTo($sub[1])) && (!isset($sub['enabled']) || !empty($sub['enabled'])))
 								{
-									if ($first_sa == null)
+									if ($first_sa === null)
 										$first_sa = $sa;
 
 									$menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa] = array('label' => $sub[0]);

+ 30 - 4
Sources/Subs-OpenID.php

@@ -1,6 +1,7 @@
 <?php
 
 /**
+ * Handle all of the OpenID interfacing and communications.
  * Simple Machines Forum (SMF)
  *
  * @package SMF
@@ -23,6 +24,19 @@ if (!defined('SMF'))
 		- Redirects the user to the IDP for validation
 */
 
+/**
+ * Openid_uri is the URI given by the user
+ * Validates the URI and changes it to a fully canonicalize URL
+ * Determines the IDP server and delegation
+ * Optional array of fields to restore when validation complete.
+ * Redirects the user to the IDP for validation
+ * Enter description here ...
+ * @param string $openid_uri
+ * @param bool $return = false
+ * @param array $save_fields = array()
+ * @param string $return_action = null
+ * @return string
+ */
 function smf_openID_validate($openid_uri, $return = false, $save_fields = array(), $return_action = null)
 {
 	global $sourcedir, $scripturl, $boardurl, $modSettings;
@@ -33,7 +47,7 @@ function smf_openID_validate($openid_uri, $return = false, $save_fields = array(
 	if ($response_data === false)
 		return 'no_data';
 
-	if (($assoc = smf_openID_getAssociation($response_data['server'])) == null)
+	if (($assoc = smf_openID_getAssociation($response_data['server'])) === null)
 		$assoc = smf_openID_makeAssociation($response_data['server']);
 
 	// Before we go wherever it is we are going, store the GET and POST data, because it might be useful when we get back.
@@ -74,7 +88,9 @@ function smf_openID_validate($openid_uri, $return = false, $save_fields = array(
 		redirectexit($redir_url);
 }
 
-// Revalidate a user using OpenID. Note that this function will not return when authentication is required.
+/**
+ * Revalidate a user using OpenID. Note that this function will not return when authentication is required.
+ */
 function smf_openID_revalidate()
 {
 	global $user_settings;
@@ -91,6 +107,13 @@ function smf_openID_revalidate()
 	trigger_error('Hacking attempt...', E_USER_ERROR);
 }
 
+/**
+ * @todo Enter description here ...
+ * @param string $server
+ * @param string $handle = null
+ * @param bool $no_delete = false
+ * @return array
+ */
 function smf_openID_getAssociation($server, $handle = null, $no_delete = false)
 {
 	global $smcFunc;
@@ -369,7 +392,7 @@ function smf_openID_canonize($uri)
 	if (strpos($uri, 'http://') !== 0 && strpos($uri, 'https://') !== 0)
 		$uri = 'http://' . $uri;
 
-	if (strpos(substr($uri, strpos($uri, '://') + 3), '/') === false)
+	if (strpos($uri, '/', strpos($uri, '://') + 3) === false)
 		$uri .= '/';
 
 	return $uri;
@@ -393,7 +416,10 @@ function smf_openid_member_exists($url)
 	return $member;
 }
 
-// Prepare for a Diffie-Hellman key exchange.
+/**
+ * Prepare for a Diffie-Hellman key exchange.
+ * @param bool $regenerate = false
+ */
 function smf_openID_setup_DH($regenerate = false)
 {
 	global $p, $g;

+ 50 - 133
Sources/Subs.php

@@ -18,190 +18,107 @@ if (!defined('SMF'))
 	everything.  It provides all of the following functions:
 
 	void updateStats(string statistic, string condition = '1')
-		- statistic can be 'member', 'message', 'topic', or 'postgroups'.
-		- parameter1 and parameter2 are optional, and are used to update only
-		  those stats that need updating.
-		- the 'member' statistic updates the latest member, the total member
-		  count, and the number of unapproved members.
-		- 'member' also only counts approved members when approval is on, but
-		  is much more efficient with it off.
-		- updating 'message' changes the total number of messages, and the
-		  highest message id by id_msg - which can be parameters 1 and 2,
-		  respectively.
-		- 'topic' updates the total number of topics, or if parameter1 is true
-		  simply increments them.
-		- the 'postgroups' case updates those members who match condition's
-		  post-based membergroups in the database (restricted by parameter1).
+
 
 	void updateMemberData(int id_member, array data)
-		- updates the columns in the members table.
-		- id_member is either an int or an array of ints to be updated.
-		- data is an associative array of the columns to be updated and their
-		  respective values.
-		- any string values updated should be quoted and slashed.
-		- the value of any column can be '+' or '-', which mean 'increment'
-		  and decrement, respectively.
-		- if the member's post number is updated, updates their post groups.
-		- this function should be used whenever member data needs to be
-		  updated in place of an UPDATE query.
 
 	void updateSettings(array changeArray, use_update = false)
-		- updates both the settings table and $modSettings array.
-		- all of changeArray's indexes and values are assumed to have escaped
-		  apostrophes (')!
-		- if a variable is already set to what you want to change it to, that
-		  variable will be skipped over; it would be unnecessary to reset.
-		- if use_update is true, UPDATEs will be used instead of REPLACE.
-		- when use_update is true, the value can be true or false to increment
-		  or decrement it, respectively.
 
 	string constructPageIndex(string base_url, int &start, int max_value,
-			int num_per_page, bool compact_start = false)
-		- builds the page list, e.g. 1 ... 6 7 [8] 9 10 ... 15.
-		- compact_start caused it to use "url.page" instead of
-		  "url;start=page".
-		- handles any wireless settings (adding special things to URLs.)
-		- very importantly, cleans up the start value passed, and forces it to
-		  be a multiple of num_per_page.
-		- also checks that start is not more than max_value.
-		- base_url should be the URL without any start parameter on it.
-		- uses the compactTopicPagesEnable and compactTopicPagesContiguous
-		  settings to decide how to display the menu.
-		- an example is available near the function definition.
 
 	string comma_format(float number)
-		- formats a number to display in the style of the admins' choosing.
-		- uses the format of number_format to decide how to format the number.
-		- for example, it might display "1 234,50".
-		- caches the formatting data from the setting for optimization.
 
 	string timeformat(int time, bool show_today = true, string offset_type = false)
-		- returns a pretty formated version of time based on the user's format
-		  in $user_info['time_format'].
-		- applies all necessary time offsets to the timestamp, unless offset_type
-		  is set.
-		- if todayMod is set and show_today was not not specified or true, an
-		  alternate format string is used to show the date with something to
-		  show it is "today" or "yesterday".
-		- performs localization (more than just strftime would do alone.)
 
 	string un_htmlspecialchars(string text)
-		- removes the base entities (&lt;, &quot;, etc.) from text.
-		- should be used instead of html_entity_decode for PHP version
-		  compatibility reasons.
-		- additionally converts &nbsp; and &#039;.
-		- returns the string without entities.
 
 	string shorten_subject(string regular_subject, int length)
-		- shortens a subject so that it is either shorter than length, or that
-		  length plus an ellipsis.
-		- respects internationalization characters and entities as one character.
-		- avoids trailing entities.
-		- returns the shortened string.
 
 	int forum_time(bool use_user_offset = true)
-		- returns the current time with offsets.
-		- always applies the offset in the time_offset setting.
-		- if use_user_offset is true, applies the user's offset as well.
-		- returns seconds since the unix epoch.
+ * returns the current time with offsets.
+ * always applies the offset in the time_offset setting.
+ * if use_user_offset is true, applies the user's offset as well.
+ * returns seconds since the unix epoch.
 
 	array permute(array input)
-		- calculates all the possible permutations (orders) of array.
-		- should not be called on huge arrays (bigger than like 10 elements.)
-		- returns an array containing each permutation.
+ * calculates all the possible permutations (orders) of array.
+ * should not be called on huge arrays (bigger than like 10 elements.)
+ * returns an array containing each permutation.
 
 	string parse_bbc(string message, bool smileys = true, string cache_id = '', array parse_tags = null)
-		- this very hefty function parses bbc in message.
-		- only parses bbc tags which are not disabled in disabledBBC.
-		- also handles basic HTML, if enablePostHTML is on.
-		- caches the from/to replace regular expressions so as not to reload
-		  them every time a string is parsed.
-		- only parses smileys if smileys is true.
-		- does nothing if the enableBBC setting is off.
-		- applies the fixLongWords magic if the setting is set to on.
-		- uses the cache_id as a unique identifier to facilitate any caching
-		  it may do.
-		- returns the modified message.
+ * this very hefty function parses bbc in message.
+ * only parses bbc tags which are not disabled in disabledBBC.
+ * also handles basic HTML, if enablePostHTML is on.
+ * caches the from/to replace regular expressions so as not to reload
+ *  them every time a string is parsed.
+ * only parses smileys if smileys is true.
+ * does nothing if the enableBBC setting is off.
+ * applies the fixLongWords magic if the setting is set to on.
+ * uses the cache_id as a unique identifier to facilitate any caching
+ *  it may do.
+ * returns the modified message.
 
 	void parsesmileys(string &message)
-		- the smiley parsing function which makes pretty faces appear :).
-		- if custom smiley sets are turned off by smiley_enable, the default
-		  set of smileys will be used.
-		- these are specifically not parsed in code tags [url=mailto:[email protected]]
-		- caches the smileys from the database or array in memory.
-		- doesn't return anything, but rather modifies message directly.
+ * the smiley parsing function which makes pretty faces appear :).
+ * if custom smiley sets are turned off by smiley_enable, the default
+ *  set of smileys will be used.
+ * these are specifically not parsed in code tags [url=mailto:[email protected]]
+ * caches the smileys from the database or array in memory.
+ * doesn't return anything, but rather modifies message directly.
 
 	string highlight_php_code(string code)
-		- Uses PHP's highlight_string() to highlight PHP syntax
-		- does special handling to keep the tabs in the code available.
-		- used to parse PHP code from inside [code] and [php] tags.
-		- returns the code with highlighted HTML.
+ * Uses PHP's highlight_string() to highlight PHP syntax
+ * does special handling to keep the tabs in the code available.
+ * used to parse PHP code from inside [code] and [php] tags.
+ * returns the code with highlighted HTML.
 
 	void redirectexit(string setLocation = '', bool use_refresh = false)
-		// !!!
 
 	void obExit(bool do_header = true, bool do_footer = do_header)
-		// !!!
-
-	array url_image_size(string url)
-		- uses getimagesize() to determine the size of a file.
-		- attempts to connect to the server first so it won't time out.
-		- returns false on failure, otherwise the output of getimagesize().
 
 	void determineTopicClass(array &topic_context)
-		// !!!
 
 	void setupThemeContext(bool force_reload = false)
-		// !!!
 
 	void template_rawdata()
-		// !!!
 
 	void template_header()
-		// !!!
 
 	void theme_copyright(bool get_it = false)
-		// !!!
 
 	void template_footer()
-		// !!!
-
-	void getAttachmentFilename(string filename, int id_attach, bool new = true)
-		// !!!
 
 	array ip2range(string $fullip)
-		- converts a given IP string to an array.
-		- internal function used to convert a user-readable format to
-		  a format suitable for the database.
-		- returns 'unknown' if the ip in the input was '255.255.255.255'.
+ * converts a given IP string to an array.
+ * internal function used to convert a user-readable format to
+ *  a format suitable for the database.
+ * returns 'unknown' if the ip in the input was '255.255.255.255'.
 
 	string host_from_ip(string ip_address)
-		// !!!
 
 	string create_button(string filename, string alt, string label, bool custom = '')
-		// !!!
 
 	void clean_cache(type = '')
-		- clean the cache directory ($cachedir, if any and in use)
-		- it may only remove the files of a certain type
-		(if the $type parameter is given)
+ * clean the cache directory ($cachedir, if any and in use)
+ * it may only remove the files of a certain type
+ *  (if the $type parameter is given)
 
 	array call_integration_hook(string hook, array parameters = array())
-		- calls all functions of the given hook.
-		- supports static class method calls.
-		- returns the results of the functions as an array.
+ * calls all functions of the given hook.
+ * supports static class method calls.
+ * returns the results of the functions as an array.
 
 	void add_integration_function(string hook, string function, bool permanent = true)
-		- adds the given function to the given hook.
-		- does nothing if the functions is already added.
-		- if permanent parameter is true, updates the value in settings table.
+ * adds the given function to the given hook.
+ * does nothing if the functions is already added.
+ * if permanent parameter is true, updates the value in settings table.
 
 	void remove_integration_function(string hook, string function)
-		- removes the given function from the given hook.
-		- does nothing if the functions is not available.
+ * removes the given function from the given hook.
+ * does nothing if the functions is not available.
 */
 
-// Update some basic statistics...
+// 
 /**
  * Update some basic statistics.
  * 
@@ -372,7 +289,7 @@ function updateStats($type, $parameter1 = null, $parameter2 = null)
 		if ($parameter2 !== null && !in_array('posts', $parameter2))
 			return;
 
-		if (($postgroups = cache_get_data('updateStats:postgroups', 360)) == null)
+		if (($postgroups = cache_get_data('updateStats:postgroups', 360)) === null)
 		{
 			// Fetch the postgroups!
 			$request = $smcFunc['db_query']('', '
@@ -2453,7 +2370,7 @@ function parse_bbc($message, $smileys = true, $cache_id = '', $parse_tags = arra
 			// The value may be quoted for some tags - check.
 			if (isset($tag['quoted']))
 			{
-				$quoted = substr($message, '&quot;') === $pos1;
+				$quoted = strpos($message, '&quot;') === $pos1;
 				if ($tag['quoted'] != 'optional' && !$quoted)
 					continue;
 
@@ -2487,7 +2404,7 @@ function parse_bbc($message, $smileys = true, $cache_id = '', $parse_tags = arra
 		}
 
 		// If this is block level, eat any breaks after it.
-		if (!empty($tag['block_level']) && substr($message, '<br />') === $pos + 1)
+		if (!empty($tag['block_level']) && strpos($message, '<br />') === $pos + 1)
 			$message = substr($message, 0, $pos + 1) . substr($message, $pos + 7);
 
 		// Are we trimming outside this tag?
@@ -2561,7 +2478,7 @@ function parsesmileys(&$message)
 		else
 		{
 			// Load the smileys in reverse order by length so they don't get parsed wrong.
-			if (($temp = cache_get_data('parsing_smileys', 480)) == null)
+			if (($temp = cache_get_data('parsing_smileys', 480)) === null)
 			{
 				$result = $smcFunc['db_query']('', '
 					SELECT code, filename, description
@@ -2793,7 +2710,7 @@ function obExit($header = null, $do_footer = null, $from_index = false, $from_fa
 		$_SESSION['old_url'] = $_SERVER['REQUEST_URL'];
 
 	// For session check verification.... don't switch browsers...
-	$_SESSION['USER_AGENT'] = $_SERVER['HTTP_USER_AGENT'];
+	$_SESSION['USER_AGENT'] = empty($_SERVER['HTTP_USER_AGENT']) ? '' : $_SERVER['HTTP_USER_AGENT'];
 
 	if (!empty($settings['strict_doctype']))
 	{

+ 1 - 0
Themes/default/css/index.css

@@ -881,6 +881,7 @@ tr.catbg th.first_th
 tr.catbg th.last_th
 {
 	background: #a7b9cd url(../images/theme/main_block.png) no-repeat 100% -280px;
+	margin-right: 1px;
 }
 tr.titlebg th.first_th
 {

+ 281 - 0
Themes/default/scripts/admin.js

@@ -327,4 +327,285 @@ smf_ViewVersions.prototype.determineVersions = function ()
 	setInnerHTML(document.getElementById('currentLanguages'), oHighCurrent.Languages);
 	if (oLowVersion.Languages)
 		document.getElementById('yourLanguages').style.color = 'red';
+}
+
+function addNewWord()
+{
+	setOuterHTML(document.getElementById('moreCensoredWords'), '<div style="margin-top: 1ex;"><input type="text" name="censor_vulgar[]" size="20" class="input_text" /> => <input type="text" name="censor_proper[]" size="20" class="input_text" /><' + '/div><div id="moreCensoredWords"><' + '/div>');
+}
+
+function toggleBBCDisabled(section, disable)
+{
+	for (var i = 0; i < document.forms.bbcForm.length; i++)
+	{
+		if (typeof(document.forms.bbcForm[i].name) == "undefined" || (document.forms.bbcForm[i].name.substr(0, 11) != "enabledTags") || (document.forms.bbcForm[i].name.indexOf(section) != 11))
+			continue;
+
+		document.forms.bbcForm[i].disabled = disable;
+	}
+	document.getElementById("bbc_" + section + "_select_all").disabled = disable;
+}
+
+function updateInputBoxes()
+{
+	curType = document.getElementById("field_type").value;
+	privStatus = document.getElementById("private").value;
+	document.getElementById("max_length_dt").style.display = curType == "text" || curType == "textarea" ? "" : "none";
+	document.getElementById("max_length_dd").style.display = curType == "text" || curType == "textarea" ? "" : "none";
+	document.getElementById("dimension_dt").style.display = curType == "textarea" ? "" : "none";
+	document.getElementById("dimension_dd").style.display = curType == "textarea" ? "" : "none";
+	document.getElementById("bbc_dt").style.display = curType == "text" || curType == "textarea" ? "" : "none";
+	document.getElementById("bbc_dd").style.display = curType == "text" || curType == "textarea" ? "" : "none";
+	document.getElementById("options_dt").style.display = curType == "select" || curType == "radio" ? "" : "none";
+	document.getElementById("options_dd").style.display = curType == "select" || curType == "radio" ? "" : "none";
+	document.getElementById("default_dt").style.display = curType == "check" ? "" : "none";
+	document.getElementById("default_dd").style.display = curType == "check" ? "" : "none";
+	document.getElementById("mask_dt").style.display = curType == "text" ? "" : "none";
+	document.getElementById("mask").style.display = curType == "text" ? "" : "none";
+	document.getElementById("can_search_dt").style.display = curType == "text" || curType == "textarea" ? "" : "none";
+	document.getElementById("can_search_dd").style.display = curType == "text" || curType == "textarea" ? "" : "none";
+	document.getElementById("regex_div").style.display = curType == "text" && document.getElementById("mask").value == "regex" ? "" : "none";
+	document.getElementById("display").disabled = false;
+	// Cannot show this on the topic
+	if (curType == "textarea" || privStatus >= 2)
+	{
+		document.getElementById("display").checked = false;
+		document.getElementById("display").disabled = true;
+	}
+}
+
+function addOption()
+{
+	setOuterHTML(document.getElementById("addopt"), '<br /><input type="radio" name="default_select" value="' + startOptID + '" id="' + startOptID + '" class="input_radio" /><input type="text" name="select_option[' + startOptID + ']" value="" class="input_text" /><span id="addopt"></span>');
+	startOptID++;
+}
+
+
+//Create a named element dynamically - thanks to: http://www.thunderguy.com/semicolon/2005/05/23/setting-the-name-attribute-in-internet-explorer/
+function createNamedElement(type, name, customFields)
+{
+	var element = null;
+
+	if (!customFields)
+		customFields = "";
+
+	// Try the IE way; this fails on standards-compliant browsers
+	try
+	{
+		element = document.createElement("<" + type + ' name="' + name + '" ' + customFields + ">");
+	}
+	catch (e)
+	{
+	}
+	if (!element || element.nodeName != type.toUpperCase())
+	{
+		// Non-IE browser; use canonical method to create named element
+		element = document.createElement(type);
+		element.name = name;
+	}
+
+	return element;
+}
+
+function addAnotherQuestion()
+{
+	var newDT = document.createElement("dt");
+
+	var newInput = createNamedElement("input", "question[]");
+	newInput.type = "text";
+	newInput.className = "input_text";
+	newInput.size = "50";
+	newInput.setAttribute("class", "verification_question");
+	newDT.appendChild(newInput);
+
+	newDD = document.createElement("dd");
+
+	newInput = createNamedElement("input", "answer[]");
+	newInput.type = "text";
+	newInput.className = "input_text";
+	newInput.size = "50";
+	newInput.setAttribute("class", "verification_answer");
+	newDD.appendChild(newInput);
+
+	placeHolder.parentNode.insertBefore(newDT, placeHolder);
+	placeHolder.parentNode.insertBefore(newDD, placeHolder);
+}
+
+function smfSetLatestThemes()
+{
+	if (typeof(window.smfLatestThemes) != "undefined")
+		setInnerHTML(document.getElementById("themeLatest"), window.smfLatestThemes);
+
+	if (tempOldOnload)
+		tempOldOnload();
+}
+
+function changeVariant(sVariant)
+{
+	document.getElementById('variant_preview').src = oThumbnails[sVariant];
+}
+
+// The idea here is simple: don't refresh the preview on every keypress, but do refresh after they type.
+function setPreviewTimeout()
+{
+	if (previewTimeout)
+	{
+		window.clearTimeout(previewTimeout);
+		previewTimeout = null;
+	}
+
+	previewTimeout = window.setTimeout("refreshPreview(true); previewTimeout = null;", 500);
+}
+
+function toggleDuration(toChange)
+{
+	if (toChange == 'fixed')
+	{
+		document.getElementById("fixed_area").style.display = "inline";
+		document.getElementById("flexible_area").style.display = "none";
+	}
+	else
+	{
+		document.getElementById("fixed_area").style.display = "none";
+		document.getElementById("flexible_area").style.display = "inline";
+	}
+}
+
+function toggleBreakdown(id_group, forcedisplayType)
+{
+	displayType = document.getElementById("group_hr_div_" + id_group).style.display == "none" ? "" : "none";
+	if (typeof(forcedisplayType) != "undefined")
+		displayType = forcedisplayType;
+
+	for (i = 0; i < groupPermissions[id_group].length; i++)
+	{
+		document.getElementById("perm_div_" + id_group + "_" + groupPermissions[id_group][i]).style.display = displayType
+	}
+	document.getElementById("group_hr_div_" + id_group).style.display = displayType
+	document.getElementById("group_toggle_img_" + id_group).src = smf_images_url + "/" + (displayType == "none" ? "selected" : "sort_down") + ".gif";
+
+	return false;
+}
+
+function calculateNewValues()
+{
+	var total = 0;
+	for (var i = 1; i <= 6; i++)
+	{
+		total += parseInt(document.getElementById('weight' + i + '_val').value);
+	}
+	setInnerHTML(document.getElementById('weighttotal'), total);
+	for (var i = 1; i <= 6; i++)
+	{
+		setInnerHTML(document.getElementById('weight' + i), (Math.round(1000 * parseInt(document.getElementById('weight' + i + '_val').value) / total) / 10) + '%');
+	}
+}
+
+function switchType()
+{
+	document.getElementById("ul_settings").style.display = document.getElementById("method-existing").checked ? "none" : "";
+	document.getElementById("ex_settings").style.display = document.getElementById("method-upload").checked ? "none" : "";
+}
+
+function swapUploads()
+{
+	document.getElementById("uploadMore").style.display = document.getElementById("uploadSmiley").disabled ? "none" : "";
+	document.getElementById("uploadSmiley").disabled = !document.getElementById("uploadSmiley").disabled;
+}
+
+function selectMethod(element)
+{
+	document.getElementById("method-existing").checked = element != "upload";
+	document.getElementById("method-upload").checked = element == "upload";
+}
+
+function updatePreview()
+{
+	var currentImage = document.getElementById("preview");
+	currentImage.src = smf_images_url + "/" + document.forms.smileyForm.set.value + "/" + document.forms.smileyForm.smiley_filename.value;
+}
+
+function swap_database_changes()
+{
+	db_vis = !db_vis;
+	database_changes_area.style.display = db_vis ? "" : "none";
+	return false;
+}
+
+function smfSetLatestPackages()
+{
+	if (typeof(window.smfLatestPackages) != "undefined")
+		setInnerHTML(document.getElementById("packagesLatest"), window.smfLatestPackages);
+
+	if (tempOldOnload)
+	tempOldOnload();
+}
+
+function testFTP()
+{
+	ajax_indicator(true);
+
+	// What we need to post.
+	var oPostData = {
+		0: "ftp_server",
+		1: "ftp_port",
+		2: "ftp_username",
+		3: "ftp_password",
+		4: "ftp_path"
+	}
+
+	var sPostData = "";
+	for (i = 0; i < 5; i++)
+		sPostData = sPostData + (sPostData.length == 0 ? "" : "&") + oPostData[i] + "=" + escape(document.getElementById(oPostData[i]).value);
+
+	// Post the data out.
+	sendXMLDocument(smf_prepareScriptUrl(smf_scripturl) + 'action=admin;area=packages;sa=ftptest;xml;' + smf_session_var + '=' + smf_session_id, sPostData, testFTPResults);
+}
+
+function expandFolder(folderIdent, folderReal)
+{
+	// See if it already exists.
+	var possibleTags = document.getElementsByTagName("tr");
+	var foundOne = false;
+
+	for (var i = 0; i < possibleTags.length; i++)
+	{
+		if (possibleTags[i].id.indexOf("content_" + folderIdent + ":-:") == 0)
+		{
+			possibleTags[i].style.display = possibleTags[i].style.display == "none" ? "" : "none";
+			foundOne = true;
+		}
+	}
+
+	// Got something then we're done.
+	if (foundOne)
+	{
+		return false;
+	}
+	// Otherwise we need to get the wicked thing.
+	else if (window.XMLHttpRequest)
+	{
+		ajax_indicator(true);
+		getXMLDocument(smf_prepareScriptUrl(smf_scripturl) + 'action=admin;area=packages;onlyfind=' + escape(folderReal) + ';sa=perms;xml;' + smf_session_var + '=' + smf_session_id, onNewFolderReceived);
+	}
+	// Otherwise reload.
+	else
+		return true;
+
+	return false;
+}
+
+function dynamicExpandFolder()
+{
+	expandFolder(this.ident, this.path);
+
+	return false;
+}
+
+function repeatString(sString, iTime)
+{
+	if (iTime < 1)
+		return '';
+	else
+		return sString + repeatString(sString, iTime - 1);
 }

+ 51 - 0
Themes/default/scripts/register.js

@@ -263,4 +263,55 @@ function smfRegister(formID, passwordDifficultyLevel, regTextStrings)
 
 		return true;
 	}
+}
+
+function updateAuthMethod()
+{
+	// What authentication method is being used?
+	if (!document.getElementById('auth_openid') || !document.getElementById('auth_openid').checked)
+		currentAuthMethod = 'passwd';
+	else
+		currentAuthMethod = 'openid';
+
+	// No openID?
+	if (!document.getElementById('auth_openid'))
+		return true;
+
+	document.forms.registration.openid_url.disabled = currentAuthMethod == 'openid' ? false : true;
+	document.forms.registration.smf_autov_pwmain.disabled = currentAuthMethod == 'passwd' ? false : true;
+	document.forms.registration.smf_autov_pwverify.disabled = currentAuthMethod == 'passwd' ? false : true;
+	document.getElementById('smf_autov_pwmain_div').style.display = currentAuthMethod == 'passwd' ? '' : 'none';
+	document.getElementById('smf_autov_pwverify_div').style.display = currentAuthMethod == 'passwd' ? '' : 'none';
+
+	if (currentAuthMethod == 'passwd')
+	{
+		verificationHandle.refreshMainPassword();
+		verificationHandle.refreshVerifyPassword();
+		document.forms.registration.openid_url.style.backgroundColor = '';
+		document.getElementById('password1_group').style.display = '';
+		document.getElementById('password2_group').style.display = '';
+		document.getElementById('openid_group').style.display = 'none';
+	}
+	else
+	{
+		document.forms.registration.smf_autov_pwmain.style.backgroundColor = '';
+		document.forms.registration.smf_autov_pwverify.style.backgroundColor = '';
+		document.forms.registration.openid_url.style.backgroundColor = '#FFF0F0';
+		document.getElementById('password1_group').style.display = 'none';
+		document.getElementById('password2_group').style.display = 'none';
+		document.getElementById('openid_group').style.display = '';
+	}
+
+	return true;
+}
+
+function onCheckChange()
+{
+	if (document.forms.postForm.emailActivate.checked || document.forms.postForm.password.value == '')
+	{
+		document.forms.postForm.emailPassword.disabled = true;
+		document.forms.postForm.emailPassword.checked = true;
+	}
+	else
+		document.forms.postForm.emailPassword.disabled = false;
 }

+ 132 - 2
Themes/default/scripts/script.js

@@ -887,7 +887,7 @@ smc_Toggle.prototype.changeState = function(bCollapse, bInit)
 		this.oCookie.set(this.opt.oCookieOptions.sCookieName, this.bCollapsed ? '1' : '0');
 
 	if ('oThemeOptions' in this.opt && this.opt.oThemeOptions.bUseThemeSettings)
-		smf_setThemeOption(this.opt.oThemeOptions.sOptionName, this.bCollapsed ? '1' : '0', 'sThemeId' in this.opt.oThemeOptions ? this.opt.oThemeOptions.sThemeId : null, this.opt.oThemeOptions.sSessionId, this.opt.oThemeOptions.sSessionVar, 'sAdditionalVars' in this.opt.oThemeOptions ? this.opt.oThemeOptions.sAdditionalVars : null);
+		smf_setThemeOption(this.opt.oThemeOptions.sOptionName, this.bCollapsed ? '1' : '0', 'sThemeId' in this.opt.oThemeOptions ? this.opt.oThemeOptions.sThemeId : null, smf_session_id, smf_session_var, 'sAdditionalVars' in this.opt.oThemeOptions ? this.opt.oThemeOptions.sAdditionalVars : null);
 }
 
 smc_Toggle.prototype.toggle = function()
@@ -1226,7 +1226,7 @@ IconList.prototype.onItemMouseDown = function (oDiv, sNewIcon)
 	{
 		ajax_indicator(true);
 		this.tmpMethod = getXMLDocument;
-		var oXMLDoc = this.tmpMethod(smf_prepareScriptUrl(this.opt.sScriptUrl) + 'action=jsmodify;topic=' + this.opt.iTopicId + ';msg=' + this.iCurMessageId + ';' + this.opt.sSessionVar + '=' + this.opt.sSessionId + ';icon=' + sNewIcon + ';xml');
+		var oXMLDoc = this.tmpMethod(smf_prepareScriptUrl(this.opt.sScriptUrl) + 'action=jsmodify;topic=' + this.opt.iTopicId + ';msg=' + this.iCurMessageId + ';' + smf_session_var + '=' + smf_session_id + ';icon=' + sNewIcon + ';xml');
 		delete this.tmpMethod;
 		ajax_indicator(false);
 
@@ -1419,3 +1419,133 @@ function cleanFileInput(idElement)
 		document.getElementById(idElement).type = 'file';
 	}
 }
+
+function applyWindowClasses(oList)
+{
+	var bAlternate = false;
+	oListItems = oList.getElementsByTagName("LI");
+	for (i = 0; i < oListItems.length; i++)
+	{
+		// Skip dummies.
+		if (oListItems[i].id == "")
+			continue;
+		oListItems[i].className = "windowbg" + (bAlternate ? "2" : "");
+		bAlternate = !bAlternate;
+	}
+}
+
+function reActivate()
+{
+	document.forms.postmodify.message.readOnly = false;
+}
+
+// The actual message icon selector.
+function showimage()
+{
+	document.images.icons.src = icon_urls[document.forms.postmodify.icon.options[document.forms.postmodify.icon.selectedIndex].value];
+}
+
+function pollOptions()
+{
+	var expire_time = document.getElementById('poll_expire');
+
+	if (isEmptyText(expire_time) || expire_time.value == 0)
+	{
+		document.forms.postmodify.poll_hide[2].disabled = true;
+		if (document.forms.postmodify.poll_hide[2].checked)
+			document.forms.postmodify.poll_hide[1].checked = true;
+	}
+	else
+		document.forms.postmodify.poll_hide[2].disabled = false;
+}
+
+function generateDays(offset = 0)
+{
+	var days = 0, selected = 0;
+	var dayElement = document.getElementById("day" + offset), yearElement = document.getElementById("year" + offset), monthElement = document.getElementById("month" + offset);
+
+	monthLength[1] = 28;
+	if (yearElement.options[yearElement.selectedIndex].value % 4 == 0)
+		monthLength[1] = 29;
+
+	selected = dayElement.selectedIndex;
+	while (dayElement.options.length)
+		dayElement.options[0] = null;
+
+	days = monthLength[monthElement.value - 1];
+
+	for (i = 1; i <= days; i++)
+		dayElement.options[dayElement.length] = new Option(i, i);
+
+	if (selected < days)
+		dayElement.selectedIndex = selected;
+}
+
+function toggleLinked(form)
+{
+	form.board.disabled = !form.link_to_board.checked;
+}
+
+function initSearch()
+{
+	if (document.forms.searchform.search.value.indexOf("%u") != -1)
+		document.forms.searchform.search.value = unescape(document.forms.searchform.search.value);
+}
+
+function selectBoards(ids)
+{
+	var toggle = true;
+
+	for (i = 0; i < ids.length; i++)
+		toggle = toggle & document.forms.searchform["brd" + ids[i]].checked;
+
+	for (i = 0; i < ids.length; i++)
+		document.forms.searchform["brd" + ids[i]].checked = !toggle;
+}
+
+function expandCollapseBoards()
+{
+	var current = document.getElementById("searchBoardsExpand").style.display != "none";
+
+	document.getElementById("searchBoardsExpand").style.display = current ? "none" : "";
+	document.getElementById("expandBoardsIcon").src = smf_images_url + (current ? "/expand.gif" : "/collapse.gif");
+}
+
+function expandCollapseLabels()
+{
+	var current = document.getElementById("searchLabelsExpand").style.display != "none";
+
+	document.getElementById("searchLabelsExpand").style.display = current ? "none" : "";
+	document.getElementById("expandLabelsIcon").src = smf_images_url + (current ? "/expand.gif" : "/collapse.gif");
+}
+
+function updateRuleDef(optNum)
+{
+	if (document.getElementById("ruletype" + optNum).value == "gid")
+	{
+		document.getElementById("defdiv" + optNum).style.display = "none";
+		document.getElementById("defseldiv" + optNum).style.display = "";
+	}
+	else if (document.getElementById("ruletype" + optNum).value == "bud" || document.getElementById("ruletype" + optNum).value == "")
+	{
+		document.getElementById("defdiv" + optNum).style.display = "none";
+		document.getElementById("defseldiv" + optNum).style.display = "none";
+	}
+	else
+	{
+		document.getElementById("defdiv" + optNum).style.display = "";
+		document.getElementById("defseldiv" + optNum).style.display = "none";
+	}
+}
+
+function updateActionDef(optNum)
+{
+	if (document.getElementById("acttype" + optNum).value == "lab")
+	{
+		document.getElementById("labdiv" + optNum).style.display = "";
+	}
+	else
+	{
+		document.getElementById("labdiv" + optNum).style.display = "none";
+	}
+}

+ 33 - 1
Themes/default/scripts/topic.js

@@ -317,7 +317,7 @@ QuickModify.prototype.modifySave = function (sSessionId, sSessionVar)
 
 	// Send in the XMLhttp request and let's hope for the best.
 	ajax_indicator(true);
-	sendXMLDocument.call(this, smf_prepareScriptUrl(this.opt.sScriptUrl) + "action=jsmodify;topic=" + this.opt.iTopicId + ";" + sSessionVar + "=" + sSessionId + ";xml", x.join("&"), this.onModifyDone);
+	sendXMLDocument.call(this, smf_prepareScriptUrl(this.opt.sScriptUrl) + "action=jsmodify;topic=" + this.opt.iTopicId + ";" + smf_session_var + "=" + smf_session_id + ";xml", x.join("&"), this.onModifyDone);
 
 	return false;
 }
@@ -538,4 +538,36 @@ function expandThumb(thumbID)
 	img.style.width = '';
 	img.style.height = '';
 	return false;
+}
+
+// For templating, shown when an inline edit is made.
+function modify_topic_show_edit(subject)
+{
+	// Just template the subject.
+	setInnerHTML(cur_subject_div, '<input type="text" name="subject" value="' + subject + '" size="60" style="width: 95%;" maxlength="80" onkeypress="modify_topic_keypress(event)" class="input_text" /><input type="hidden" name="topic" value="' + cur_topic_id + '" /><input type="hidden" name="msg" value="' + cur_msg_id.substr(4) + '" />');
+}
+
+function modify_topic_click()
+{
+	if (in_edit_mode == 1 && mouse_on_div == 0)
+		modify_topic_save(smf_sesion_id, smf_session_var);
+}
+
+function modify_topic_keypress(oEvent)
+{
+	if (typeof(oEvent.keyCode) != "undefined" && oEvent.keyCode == 13)
+	{
+		modify_topic_save(smf_sesion_id, smf_session_var);
+		if (typeof(oEvent.preventDefault) == "undefined")
+			oEvent.returnValue = false;
+		else
+			oEvent.preventDefault();
+	}
+}
+
+// And the reverse for hiding it.
+function modify_topic_hide_edit(subject)
+{
+	// Re-template the subject!
+	setInnerHTML(cur_subject_div, '<a href="' + smf_scripturl + '?topic=' + cur_topic_id + '.0">' + subject + '<' +'/a>');
 }