Browse Source

! some more minor doc changes
! removed some micro-optimizations which showed questionable results across various versions of php5 32 & 64bit (many files)
! removed malformed multi-table deletes (ManageBans.php, ManageMaintenance.php, ManagePermissions.php
! removed some minor changes which would needlessly break mod installations (===)

Spuds 12 years ago
parent
commit
7ce72a18f5
58 changed files with 197 additions and 237 deletions
  1. 1 1
      SSI.php
  2. 1 1
      Sources/Admin.php
  3. 3 3
      Sources/Class-Package.php
  4. 1 1
      Sources/DbExtra-sqlite.php
  5. 3 3
      Sources/DbPackages-mysql.php
  6. 1 1
      Sources/DbPackages-postgresql.php
  7. 2 6
      Sources/DbPackages-sqlite.php
  8. 2 2
      Sources/Display.php
  9. 2 2
      Sources/Errors.php
  10. 1 3
      Sources/Groups.php
  11. 1 1
      Sources/Help.php
  12. 22 22
      Sources/Load.php
  13. 1 1
      Sources/ManageAttachments.php
  14. 8 1
      Sources/ManageBans.php
  15. 2 2
      Sources/ManageErrors.php
  16. 11 6
      Sources/ManageMaintenance.php
  17. 1 3
      Sources/ManageMembergroups.php
  18. 1 2
      Sources/ManageNews.php
  19. 3 3
      Sources/ManagePaid.php
  20. 16 3
      Sources/ManagePermissions.php
  21. 1 3
      Sources/ManagePosts.php
  22. 4 7
      Sources/ManageServer.php
  23. 3 7
      Sources/ManageSettings.php
  24. 2 6
      Sources/ManageSmileys.php
  25. 1 1
      Sources/Memberlist.php
  26. 1 3
      Sources/ModerationCenter.php
  27. 1 1
      Sources/Modlog.php
  28. 1 3
      Sources/MoveTopic.php
  29. 3 7
      Sources/News.php
  30. 1 1
      Sources/PackageGet.php
  31. 8 24
      Sources/Packages.php
  32. 4 8
      Sources/PersonalMessage.php
  33. 4 12
      Sources/Post.php
  34. 1 3
      Sources/Profile-Actions.php
  35. 6 6
      Sources/Profile-Modify.php
  36. 2 2
      Sources/QueryString.php
  37. 1 1
      Sources/Recent.php
  38. 2 2
      Sources/Register.php
  39. 2 2
      Sources/Reports.php
  40. 1 1
      Sources/ScheduledTasks.php
  41. 1 1
      Sources/Search.php
  42. 2 2
      Sources/Stats.php
  43. 3 3
      Sources/Subs-Admin.php
  44. 1 6
      Sources/Subs-Auth.php
  45. 1 1
      Sources/Subs-Categories.php
  46. 5 5
      Sources/Subs-Editor.php
  47. 1 1
      Sources/Subs-Graphics.php
  48. 1 1
      Sources/Subs-Membergroups.php
  49. 1 1
      Sources/Subs-Menu.php
  50. 2 2
      Sources/Subs-OpenID.php
  51. 6 6
      Sources/Subs-Package.php
  52. 7 7
      Sources/Subs-Post.php
  53. 15 15
      Sources/Subs.php
  54. 1 1
      Sources/Subscriptions-PayPal.php
  55. 4 4
      Sources/Themes.php
  56. 6 6
      Sources/ViewQuery.php
  57. 1 1
      Themes/default/languages/Help.english.php
  58. 7 7
      index.php

+ 1 - 1
SSI.php

@@ -55,7 +55,7 @@ if ($maintenance == 2 && (!isset($ssi_maintenance_off) || $ssi_maintenance_off !
 	die($mmessage);
 
 // Fix for using the current directory as a path.
-if (strpos($sourcedir, '.') === 0 && strpos($sourcedir, '.') !== 1)
+if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.')
 	$sourcedir = dirname(__FILE__) . substr($sourcedir, 1);
 
 // Load the important includes.

+ 1 - 1
Sources/Admin.php

@@ -830,7 +830,7 @@ function AdminSearchInternal()
 				$name = preg_replace('~<(?:div|span)\sclass="smalltext">.+?</(?:div|span)>~', '', $name);
 
 				$context['search_results'][] = array(
-					'url' => (strpos($item[1], 'area') === 0 ? $scripturl . '?action=admin;' . $item[1] : $item[1]) . ';' . $context['session_var'] . '=' . $context['session_id'] . ((strpos($item[1], 'area') === 0 && $section == 'settings' ? '#' . $item[0][0] : '')),
+					'url' => (substr($item[1], 0, 4) == 'area' ? $scripturl . '?action=admin;' . $item[1] : $item[1]) . ';' . $context['session_var'] . '=' . $context['session_id'] . ((substr($item[1], 0, 4) == 'area' && $section == 'settings' ? '#' . $item[0][0] : '')),
 					'name' => $name,
 					'type' => $section,
 					'help' => shorten_subject(isset($item[2]) ? strip_tags($helptxt[$item[2]]) : (isset($helptxt[$found]) ? strip_tags($helptxt[$found]) : ''), 255),

+ 3 - 3
Sources/Class-Package.php

@@ -138,7 +138,7 @@ class xmlArray
 				$el = substr($el, 0, strpos($el, '['));
 			}
 			// Find an attribute.
-			elseif (strpos($el, '@') === 0)
+			elseif (substr($el, 0, 1) == '@')
 			{
 				// It simplifies things if the attribute is already there ;).
 				if (isset($array[$el]))
@@ -200,7 +200,7 @@ class xmlArray
 				$el = substr($el, 0, strpos($el, '['));
 			}
 			// Find an attribute.
-			elseif (strpos($el, '@') === 0)
+			elseif (substr($el, 0, 1) == '@')
 				return isset($array[$el]);
 			else
 				$lvl = null;
@@ -501,7 +501,7 @@ class xmlArray
 		// Run through and recurively output all the elements or attrbutes inside this.
 		foreach ($array as $k => $v)
 		{
-			if (strpos($k, '@') === 0)
+			if (substr($k, 0, 1) == '@')
 				$output .= ' ' . substr($k, 1) . '="' . $v . '"';
 			elseif (is_array($v))
 			{

+ 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);

+ 3 - 3
Sources/DbPackages-mysql.php

@@ -303,7 +303,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.
@@ -511,7 +511,7 @@ function smf_db_list_columns($table_name, $detail = false, $parameters = array()
 		SHOW FIELDS
 		FROM {raw:table_name}',
 		array(
-			'table_name' => strpos($table_name, '`') === 0 ? $table_name : '`' . $table_name . '`',
+			'table_name' => substr($table_name, 0, 1) == '`' ? $table_name : '`' . $table_name . '`',
 		)
 	);
 	$columns = array();
@@ -578,7 +578,7 @@ function smf_db_list_indexes($table_name, $detail = false, $parameters = array()
 		SHOW KEYS
 		FROM {raw:table_name}',
 		array(
-			'table_name' => strpos($table_name, '`') === 0 ? $table_name : '`' . $table_name . '`',
+			'table_name' => substr($table_name, 0, 1) == '`' ? $table_name : '`' . $table_name . '`',
 		)
 	);
 	$indexes = array();

+ 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.

+ 2 - 6
Sources/DbPackages-sqlite.php

@@ -358,9 +358,7 @@ function smf_db_add_index($table_name, $index_info, $parameters = array(), $if_e
 	// If we're here we know we don't have the index - so just add it.
 	if (!empty($index_info['type']) && $index_info['type'] == 'primary')
 	{
-		/**
-		 * @todo Doesn't work with PRIMARY KEY yet.
-		 */
+		// @todo Doesn't work with PRIMARY KEY yet.
 	}
 	else
 	{
@@ -391,9 +389,7 @@ function smf_db_remove_index($table_name, $index_name, $parameters = array(), $e
 
 	foreach ($indexes as $index)
 	{
-		/**
-		 * @todo Doesn't do primary key at the moment!
-		 */
+		// @todo Doesn't do primary key at the moment!
 		if ($index['type'] != 'primary' && $index['name'] == $index_name)
 		{
 			// Drop the bugger...

+ 2 - 2
Sources/Display.php

@@ -252,7 +252,7 @@ function Display()
 		}
 
 		// Start from a certain time index, not a message.
-		if (strpos($_REQUEST['start'], 'from') === 0)
+		if (substr($_REQUEST['start'], 0, 4) == 'from')
 		{
 			$timestamp = (int) substr($_REQUEST['start'], 4);
 			if ($timestamp === 0)
@@ -282,7 +282,7 @@ function Display()
 		}
 
 		// Link to a message...
-		elseif (strpos($_REQUEST['start'], 'msg') === 0)
+		elseif (substr($_REQUEST['start'], 0, 3) == 'msg')
 		{
 			$virtual_msg = (int) substr($_REQUEST['start'], 3);
 			if (!$topicinfo['unapproved_posts'] && $virtual_msg >= $topicinfo['id_last_msg'])

+ 2 - 2
Sources/Errors.php

@@ -44,13 +44,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;

+ 1 - 3
Sources/Groups.php

@@ -519,9 +519,7 @@ function MembergroupMembers()
 			$smcFunc['db_free_result']($request);
 		}
 
-		/**
-		 * @todo Add $_POST['additional'] to templates!
-		 */
+		// @todo Add $_POST['additional'] to templates!
 
 		// Do the updates...
 		if (!empty($members))

+ 1 - 1
Sources/Help.php

@@ -80,7 +80,7 @@ function ShowAdminHelp()
 	loadLanguage('Help');
 
 	// Permission specific help?
-	if (isset($_GET['help']) && strpos($_GET['help'], 'permissionhelp') === 0)
+	if (isset($_GET['help']) && substr($_GET['help'], 0, 14) == 'permissionhelp')
 		loadLanguage('ManagePermissions');
 
 	loadTemplate('Help');

+ 22 - 22
Sources/Load.php

@@ -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
@@ -103,7 +103,7 @@ function reloadSettings()
 				$needle_size = count($needle_arr);
 
 				$result = array_search($needle_arr[0], array_slice($haystack_arr, $offset));
-				while (is_int($result))
+				while ((int) $result === $result)
 				{
 					$offset += $result;
 					if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr)
@@ -152,7 +152,7 @@ function reloadSettings()
 	// Check the load averages?
 	if (!empty($modSettings['loadavg_enable']))
 	{
-		if (($modSettings['load_average'] = cache_get_data('loadavg', 90)) === null)
+		if (($modSettings['load_average'] = cache_get_data('loadavg', 90)) == null)
 		{
 			$modSettings['load_average'] = @file_get_contents('/proc/loadavg');
 			if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0)
@@ -246,7 +246,7 @@ function loadUserSettings()
 	}
 	elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA'])))
 	{
-		 // @todo Perhaps we can do some more checking on this, such as on the first octet of the IP?
+		// @todo Perhaps we can do some more checking on this, such as on the first octet of the IP?
 		list ($id_member, $password, $login_span) = @unserialize($_SESSION['login_' . $cookiename]);
 		$id_member = !empty($id_member) && strlen($password) == 40 && $login_span > time() ? (int) $id_member : 0;
 	}
@@ -255,7 +255,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
@@ -766,7 +766,7 @@ function loadPermissions()
 
 			return;
 		}
-		elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) !== null && time() - 240 > $modSettings['settings_updated'])
+		elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated'])
 			list ($user_info['permissions'], $removals) = $temp;
 	}
 
@@ -878,7 +878,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'];
@@ -982,7 +982,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
@@ -1099,7 +1099,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' : (strpos($profile['birthdate'], '0004') === 0 ? '0000' . substr($profile['birthdate'], 4) : $profile['birthdate']),
+		'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']),
 		'signature' => $profile['signature'],
 		'location' => $profile['location'],
 		'icq' => $profile['icq'] != '' && (empty($modSettings['guest_hideContacts']) || !$user_info['is_guest']) ? array(
@@ -1439,7 +1439,7 @@ function loadTheme($id_theme = 0, $initialize = true)
 		$themeData = $temp;
 		$flag = true;
 	}
-	elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) !== null && time() - 60 > $modSettings['settings_updated'])
+	elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated'])
 		$themeData = $temp + array($member => array());
 	else
 		$themeData = array(-1 => array(), 0 => array(), $member => array());
@@ -1470,7 +1470,7 @@ function loadTheme($id_theme = 0, $initialize = true)
 
 			// If this isn't set yet, is a theme option, or is not the default theme..
 			if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1')
-				$themeData[$row['id_member']][$row['variable']] = strpos($row['variable'], 'show_') === 0 ? $row['value'] == '1' : $row['value'];
+				$themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value'];
 		}
 		$smcFunc['db_free_result']($result);
 
@@ -1515,7 +1515,7 @@ function loadTheme($id_theme = 0, $initialize = true)
 	// Check to see if they're accessing it from the wrong place.
 	if (isset($_SERVER['HTTP_HOST']) || isset($_SERVER['SERVER_NAME']))
 	{
-		$detected_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) === 'on' ? 'https://' : 'http://';
+		$detected_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 'https://' : 'http://';
 		$detected_url .= empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] . (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT']) : $_SERVER['HTTP_HOST'];
 		$temp = preg_replace('~/' . basename($scripturl) . '(/.+)?$~', '', strtr(dirname($_SERVER['PHP_SELF']), '\\', '/'));
 		if ($temp != '/')
@@ -1647,7 +1647,7 @@ function loadTheme($id_theme = 0, $initialize = true)
 	// A bug in some versions of IIS under CGI (older ones) makes cookie setting not work with Location: headers.
 	$context['server']['needs_login_fix'] = $context['server']['is_cgi'] && $context['server']['is_iis'];
 
-	// Detect the browser. This is separated out because it's also used in attachment downloads.
+	// Detect the browser. This is separated out because it's also used in attachment downloads
 	detectBrowser();
 
 	// Set the top level linktree up.
@@ -1777,7 +1777,7 @@ function loadTheme($id_theme = 0, $initialize = true)
 
 	// Fix font size with HTML 4.01, etc.
 	if (isset($settings['doctype']))
-		$context['browser']['needs_size_fix'] |= $settings['doctype'] === 'html' && isBrowser('ie6');
+		$context['browser']['needs_size_fix'] |= $settings['doctype'] == 'html' && isBrowser('ie6');
 
 	// Compatibility.
 	if (!isset($settings['theme_version']))
@@ -1892,7 +1892,7 @@ function loadTemplate($template_name, $style_sheets = array(), $fatal = true)
 	if ($loaded)
 	{
 		// For compatibility reasons, if this is the index template without new functions, include compatible stuff.
-		if (strpos($template_name, 'index') === 0 && !function_exists('template_button_strip'))
+		if (substr($template_name, 0, 5) == 'index' && !function_exists('template_button_strip'))
 			loadTemplate('Compat');
 
 		if ($db_show_debug === true)
@@ -1920,7 +1920,7 @@ function loadTemplate($template_name, $style_sheets = array(), $fatal = true)
 		loadTemplate($template_name);
 	}
 	// Cause an error otherwise.
-	elseif ($template_name !== 'Errors' && $template_name !== 'index' && $fatal)
+	elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal)
 		fatal_lang_error('theme_template_error', 'template', array((string) $template_name));
 	elseif ($fatal)
 		die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load Themes/default/%s.template.php!', (string) $template_name), 'template'));
@@ -2129,7 +2129,7 @@ function getBoardParents($id_parent)
 				)
 			);
 			// In the EXTREMELY unlikely event this happens, give an error message.
-			if ($smcFunc['db_num_rows']($result) === 0)
+			if ($smcFunc['db_num_rows']($result) == 0)
 				fatal_lang_error('parent_not_found', 'critical');
 			while ($row = $smcFunc['db_fetch_assoc']($result))
 			{
@@ -2177,7 +2177,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']))
@@ -2224,7 +2224,7 @@ function getLanguages($use_cache = true, $favor_utf8 = true)
 		if ($favor_utf8)
 		{
 			foreach ($context['languages'] as $lang)
-				if (strpos($lang['filename'], '-utf8') !== strlen($lang['filename']) - 5 && isset($context['languages'][$lang['filename'] . '-utf8']))
+				if (substr($lang['filename'], strlen($lang['filename']) - 5, 5) != '-utf8' && isset($context['languages'][$lang['filename'] . '-utf8']))
 					unset($context['languages'][$lang['filename']]);
 		}
 
@@ -2258,7 +2258,7 @@ function censorText(&$text, $force = false)
 		return $text;
 
 	// If they haven't yet been loaded, load them.
-	if ($censor_vulgar === null)
+	if ($censor_vulgar == null)
 	{
 		$censor_vulgar = explode("\n", $modSettings['censor_vulgar']);
 		$censor_proper = explode("\n", $modSettings['censor_proper']);
@@ -2459,7 +2459,7 @@ function template_include($filename, $once = false)
 
 					echo '<span style="color: black;">', sprintf('%' . strlen($n) . 's', $line), ':</span> ';
 					if (isset($data2[$line]) && $data2[$line] != '')
-						echo strpos($data2[$line], '</') === 0 ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line];
+						echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line];
 
 					if (isset($data2[$line]) && preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line], $color_match) != 0)
 					{
@@ -2517,7 +2517,7 @@ function loadDatabase()
 		display_db_error();
 
 	// If in SSI mode fix up the prefix.
-	if (SMF === 'SSI')
+	if (SMF == 'SSI')
 		db_fix_prefix($db_prefix, $db_name);
 }
 

+ 1 - 1
Sources/ManageAttachments.php

@@ -856,7 +856,7 @@ function removeAttachments($condition, $query_type = '', $return_affected_messag
 		foreach ($condition as $real_type => $restriction)
 		{
 			// Doing a NOT?
-			$is_not = strpos($real_type, 'not_') === 0;
+			$is_not = substr($real_type, 0, 4) == 'not_';
 			$type = $is_not ? substr($real_type, 4) : $real_type;
 
 			if (in_array($type, array('id_member', 'id_attach', 'id_msg')))

+ 8 - 1
Sources/ManageBans.php

@@ -111,7 +111,14 @@ function BanList()
 
 		// Unban them all!
 		$smcFunc['db_query']('', '
-			DELETE FROM {db_prefix}ban_groups, {db_prefix}ban_items
+			DELETE FROM {db_prefix}ban_groups
+			WHERE id_ban_group IN ({array_int:ban_list})',
+			array(
+				'ban_list' => $_POST['remove'],
+			)
+		);
+		$smcFunc['db_query']('', '
+			DELETE FROM {db_prefix}ban_items
 			WHERE id_ban_group IN ({array_int:ban_list})',
 			array(
 				'ban_list' => $_POST['remove'],

+ 2 - 2
Sources/ManageErrors.php

@@ -125,7 +125,7 @@ function ViewErrorLog()
 			'time' => timeformat($row['log_time']),
 			'timestamp' => $row['log_time'],
 			'url' => array(
-				'html' => htmlspecialchars((strpos($row['url'], '?') === 0 ? $scripturl : '') . $row['url']),
+				'html' => htmlspecialchars((substr($row['url'], 0, 1) == '?' ? $scripturl : '') . $row['url']),
 				'href' => base64_encode($smcFunc['db_escape_wildcard_string']($row['url']))
 			),
 			'message' => array(
@@ -206,7 +206,7 @@ function ViewErrorLog()
 			$context['filter']['value']['html'] = '<a href="' . $scripturl . '?action=profile;u=' . $id . '">' . $user_profile[$id]['real_name'] . '</a>';
 		}
 		elseif ($filter['variable'] == 'url')
-			$context['filter']['value']['html'] = '\'' . strtr(htmlspecialchars((strpos($filter['value']['sql'], '?') === 0 ? $scripturl : '') . $filter['value']['sql']), array('\_' => '_')) . '\'';
+			$context['filter']['value']['html'] = '\'' . strtr(htmlspecialchars((substr($filter['value']['sql'], 0, 1) == '?' ? $scripturl : '') . $filter['value']['sql']), array('\_' => '_')) . '\'';
 		elseif ($filter['variable'] == 'message')
 		{
 			$context['filter']['value']['html'] = '\'' . strtr(htmlspecialchars($filter['value']['sql']), array("\n" => '<br />', '&lt;br /&gt;' => '<br />', "\t" => '&nbsp;&nbsp;&nbsp;', '\_' => '_', '\\%' => '%', '\\\\' => '\\')) . '\'';

+ 11 - 6
Sources/ManageMaintenance.php

@@ -262,19 +262,24 @@ function MaintainEmptyUnimportantLogs()
 
 	// No one's online now.... MUHAHAHAHA :P.
 	$smcFunc['db_query']('', '
-		DELETE FROM ');
+		DELETE FROM {db_prefix}log_online');
 
-	// @todo why are we truncating some but not all?
-
-	// Clear out the ban, SPAM, and karma logs.
+	// Dump the banning logs.
 	$smcFunc['db_query']('', '
-		DELETE FROM {db_prefix}log_banned, {db_prefix}log_online,
-			{db_prefix}log_floodcontrol, {db_prefix}log_karma');
+		DELETE FROM {db_prefix}log_banned');
 
 	// Start id_error back at 0 and dump the error log.
 	$smcFunc['db_query']('truncate_table', '
 		TRUNCATE {db_prefix}log_errors');
 
+	// Clear out the spam log.
+	$smcFunc['db_query']('', '
+		DELETE FROM {db_prefix}log_floodcontrol');
+
+	// Clear out the karma actions.
+	$smcFunc['db_query']('', '
+		DELETE FROM {db_prefix}log_karma');
+
 	// Last but not least, the search logs!
 	$smcFunc['db_query']('truncate_table', '
 		TRUNCATE {db_prefix}log_search_topics');

+ 1 - 3
Sources/ManageMembergroups.php

@@ -715,9 +715,7 @@ function EditMembergroup()
 		$_POST['group_hidden'] = empty($_POST['group_hidden']) || $_POST['min_posts'] != -1 || $_REQUEST['group'] == 3 ? 0 : (int) $_POST['group_hidden'];
 		$_POST['group_inherit'] = $_REQUEST['group'] > 1 && $_REQUEST['group'] != 3 && (empty($inherit_type) || $inherit_type != 1) ? (int) $_POST['group_inherit'] : -2;
 
-		/**
-		 * @todo Don't set online_color for the Moderators group?
-		 */
+		//@todo Don't set online_color for the Moderators group?
 
 		// Do the update of the membergroup settings.
 		$smcFunc['db_query']('', '

+ 1 - 2
Sources/ManageNews.php

@@ -67,13 +67,12 @@ function ManageNews()
 	);
 
 	// Force the right area...
-	if (strpos($_REQUEST['sa'], 'mailing') === 0)
+	if (substr($_REQUEST['sa'], 0, 7) == 'mailing')
 		$context[$context['admin_menu_name']]['current_subsection'] = 'mailingmembers';
 
 	$subActions[$_REQUEST['sa']][0]();
 }
 
-//
 /**
  * Let the administrator(s) edit the news items for the forum.
  * It writes an entry into the moderation log.

+ 3 - 3
Sources/ManagePaid.php

@@ -26,7 +26,7 @@ if (!defined('SMF'))
  */
 function ManagePaidSubscriptions()
 {
-	global $context, $txt, $scripturl, $smcFunc, $modSettings;
+	global $context, $txt, $scripturl, $sourcedir, $smcFunc, $modSettings;
 
 	// Load the required language and template.
 	loadLanguage('ManagePaid');
@@ -79,7 +79,7 @@ function ManagePaidSubscriptions()
  */
 function ModifySubscriptionSettings($return_config = false)
 {
-	global $context, $txt, $modSettings, $smcFunc, $scripturl;
+	global $context, $txt, $modSettings, $sourcedir, $smcFunc, $scripturl;
 
 	// If the currency is set to something different then we need to set it to other for this to work and set it back shortly.
 	$modSettings['paid_currency'] = !empty($modSettings['paid_currency_code']) ? $modSettings['paid_currency_code'] : '';
@@ -187,7 +187,7 @@ function ModifySubscriptionSettings($return_config = false)
  */
 function ViewSubscriptions()
 {
-	global $context, $txt, $modSettings, $smcFunc, $scripturl, $sourcedir;
+	global $context, $txt, $modSettings, $smcFunc, $sourcedir, $scripturl;
 
 	// Not made the settings yet?
 	if (empty($modSettings['paid_currency_symbol']))

+ 16 - 3
Sources/ManagePermissions.php

@@ -1001,7 +1001,14 @@ function GeneralPermissionSettings($return_config = false)
 		if (empty($modSettings['permission_enable_deny']))
 		{
 			$smcFunc['db_query']('', '
-				DELETE FROM {db_prefix}permissions, {db_prefix}board_permissions
+				DELETE FROM {db_prefix}permissions
+				WHERE add_deny = {int:denied}',
+				array(
+					'denied' => 0,
+				)
+			);
+			$smcFunc['db_query']('', '
+				DELETE FROM {db_prefix}board_permissions
 				WHERE add_deny = {int:denied}',
 				array(
 					'denied' => 0,
@@ -1028,7 +1035,14 @@ function GeneralPermissionSettings($return_config = false)
 
 			// Remove'em.
 			$smcFunc['db_query']('', '
-				DELETE FROM {db_prefix}permissions, {db_prefix}board_permissions
+				DELETE FROM {db_prefix}permissions
+				WHERE id_group IN ({array_int:post_group_list})',
+				array(
+					'post_group_list' => $post_groups,
+				)
+			);
+			$smcFunc['db_query']('', '
+				DELETE FROM {db_prefix}board_permissions
 				WHERE id_group IN ({array_int:post_group_list})',
 				array(
 					'post_group_list' => $post_groups,
@@ -1672,7 +1686,6 @@ function loadAllPermissions($loadType = 'classic')
 		}
 }
 
-//
 /**
  * Initialize a form with inline permissions settings.
  * It loads a context variables for each permission.

+ 1 - 3
Sources/ManagePosts.php

@@ -232,9 +232,7 @@ function ModifyPostSettings($return_config = false)
 
 			if (isset($body_type) && $_POST['max_messageLength'] > 65535 && $body_type == 'text')
 			{
-				/**
-				 * @todo Show an error message?!
-				 */
+				// @todo Show an error message?!
 				// MySQL only likes fulltext indexes on text columns... for now?
 				if (!empty($fulltext))
 					$_POST['max_messageLength'] = 65535;

+ 4 - 7
Sources/ManageServer.php

@@ -262,6 +262,7 @@ function ModifyCookieSettings($return_config = false)
 	// Define the variables we want to edit.
 	$config_vars = array(
 		// Cookies...
+		array('cookiename', $txt['cookie_name'], 'file', 'text', 20),
 		array('cookieTime', $txt['cookieTime'], 'db', 'int'),
 		array('localCookies', $txt['localCookies'], 'db', 'check', false, 'localCookies'),
 		array('globalCookies', $txt['globalCookies'], 'db', 'check', false, 'globalCookies'),
@@ -417,7 +418,7 @@ function ModifyLoadBalancingSettings($return_config = false)
 		'loadavg_allunread' => '2.0',
 		'loadavg_unreadreplies' => '3.5',
 		'loadavg_show_posts' => '2.0',
-		'loadavg_bbc' => '25.0',
+		'loadavg_bbc' => '30.0',
 		'loadavg_forum' => '40.0',
 	);
 
@@ -594,9 +595,7 @@ function prepareDBSettingContext(&$config_vars)
 			}
 
 			// Set the subtext in case it's part of the label.
-			/**
-			 * @todo Temporary. Preventing divs inside label tags.
-			 */
+			// @todo Temporary. Preventing divs inside label tags.
 			$divPos = strpos($context['config_vars'][$config_var[1]]['label'], '<div');
 			if ($divPos !== false)
 			{
@@ -640,9 +639,7 @@ function prepareDBSettingContext(&$config_vars)
 
 			$context['bbc_columns'][$col][] = array(
 				'tag' => $tag,
-				/**
-				 * @todo  'tag_' . ?
-				 */
+				// @todo  'tag_' . ?
 				'show_help' => isset($helptxt[$tag]),
 			);
 

+ 3 - 7
Sources/ManageSettings.php

@@ -1657,7 +1657,7 @@ function EditCustomProfiles()
 				'private' => $row['private'],
 				'can_search' => $row['can_search'],
 				'mask' => $row['mask'],
-				'regex' => strpos($row['mask'], 'regex') === 0 ? substr($row['mask'], 5) : '',
+				'regex' => substr($row['mask'], 0, 5) == 'regex' ? substr($row['mask'], 5) : '',
 				'enclose' => $row['enclose'],
 				'placement' => $row['placement'],
 			);
@@ -1766,9 +1766,7 @@ function EditCustomProfiles()
 				$colname = $initial_colname = 'cust_' . mt_rand(1, 999);
 
 			// Make sure this is unique.
-			/**
-			 * @todo This may not be the most efficient way to do this.
-			 */
+			// @todo This may not be the most efficient way to do this.
 			$unique = false;
 			for ($i = 0; !$unique && $i < 9; $i ++)
 			{
@@ -1848,9 +1846,7 @@ function EditCustomProfiles()
 						);
 				}
 			}
-			/**
-			 * @todo Maybe we should adjust based on new text length limits?
-			 */
+			// @todo Maybe we should adjust based on new text length limits?
 		}
 
 		// Do the insertion/updates.

+ 2 - 6
Sources/ManageSmileys.php

@@ -1390,9 +1390,7 @@ function InstallSmileySet()
 	$name = strtok(basename(isset($_FILES['set_gz']) ? $_FILES['set_gz']['name'] : $_REQUEST['set_gz']), '.');
 	$name = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $name);
 
-	/**
-	 * @todo Decide: overwrite or not?
-	 */
+	//@todo Decide: overwrite or not?
 	if (isset($_FILES['set_gz']) && is_uploaded_file($_FILES['set_gz']['tmp_name']) && (ini_get('open_basedir') != '' || file_exists($_FILES['set_gz']['tmp_name'])))
 		$extracted = read_tgz_file($_FILES['set_gz']['tmp_name'], $boarddir . '/Smileys/' . $name);
 	elseif (isset($_REQUEST['set_gz']))
@@ -1414,9 +1412,7 @@ function InstallSmileySet()
 	cache_put_data('parsing_smileys', null, 480);
 	cache_put_data('posting_smileys', null, 480);
 
-	/**
-	 * @todo Add some confirmation?
-	 */
+	// @todo Add some confirmation?
 	redirectexit('action=admin;area=smileys');
 }
 

+ 1 - 1
Sources/Memberlist.php

@@ -475,7 +475,7 @@ function MLSearch()
 		foreach ($_POST['fields'] as $field)
 		{
 			$curField = substr($field, 5);
-			if (strpos($field, 'cust_') === 0 && isset($context['custom_search_fields'][$curField]))
+			if (substr($field, 0, 5) == 'cust_' && isset($context['custom_search_fields'][$curField]))
 			{
 				$customJoin[] = 'LEFT JOIN {db_prefix}themes AS t' . $curField . ' ON (t' . $curField . '.variable = {string:t' . $curField . '} AND t' . $curField . '.id_theme = 1 AND t' . $curField . '.id_member = mem.id_member)';
 				$query_parameters['t' . $curField] = $curField;

+ 1 - 3
Sources/ModerationCenter.php

@@ -1059,9 +1059,7 @@ function ShowNotice()
 
 	loadTemplate('ModerationCenter');
 
-	/**
-	 * @todo Assumes nothing needs permission more than accessing moderation center!
-	 */
+	// @todo Assumes nothing needs permission more than accessing moderation center!
 	$id_notice = (int) $_GET['nid'];
 	$request = $smcFunc['db_query']('', '
 		SELECT body, subject

+ 1 - 1
Sources/Modlog.php

@@ -143,7 +143,7 @@ function ViewModlog()
 		// For the moment they can only search for ONE action!
 		foreach ($txt as $key => $text)
 		{
-			if (strpos($key, 'modlog_ac_') === 0 && strpos($text, $search_params['string']) !== false)
+			if (substr($key, 0, 10) == 'modlog_ac_' && strpos($text, $search_params['string']) !== false)
 			{
 				$search_params['string'] = substr($key, 10);
 				break;

+ 1 - 3
Sources/MoveTopic.php

@@ -278,9 +278,7 @@ function MoveTopic2()
 	}
 
 	// Create a link to this in the old board.
-	/**
-	 * @todo Does this make sense if the topic was unapproved before? I'd just about say so.
-	 */
+	// @todo Does this make sense if the topic was unapproved before? I'd just about say so.
 	if (isset($_POST['postRedirect']))
 	{
 		// Should be in the boardwide language.

+ 3 - 7
Sources/News.php

@@ -170,9 +170,7 @@ function ShowXmlFeed()
 	// Show in rss or proprietary format?
 	$xml_format = isset($_GET['type']) && in_array($_GET['type'], array('smf', 'rss', 'rss2', 'atom', 'rdf', 'webslice')) ? $_GET['type'] : 'smf';
 
-	/**
-	 * @todo Birthdays? 
-	 */
+	// @todo Birthdays? 
 
 	// List all the different types of data they can pull.
 	$subActions = array(
@@ -184,9 +182,7 @@ function ShowXmlFeed()
 	if (empty($_GET['sa']) || !isset($subActions[$_GET['sa']]))
 		$_GET['sa'] = 'recent';
 
-	/**
-	 * @todo Temp - webslices doesn't do everything yet.
-	 */
+	// @todo Temp - webslices doesn't do everything yet.
 	if ($xml_format == 'webslice' && $_GET['sa'] != 'recent')
 		$xml_format = 'rss2';
 	// If this is webslices we kinda cheat - we allow a template that we call direct for the HTML, and we override the CDATA.
@@ -973,7 +969,7 @@ function getXmlProfile($xml_format)
 		if (in_array($profile['show_email'], array('yes', 'yes_permission_override')))
 			$data['email'] = $profile['email'];
 
-		if (!empty($profile['birth_date']) && strpos($profile['birth_date'], '0000') !== 0)
+		if (!empty($profile['birth_date']) && substr($profile['birth_date'], 0, 4) != '0000')
 		{
 			list ($birth_year, $birth_month, $birth_day) = sscanf($profile['birth_date'], '%d-%d-%d');
 			$datearray = getdate(forum_time());

+ 1 - 1
Sources/PackageGet.php

@@ -333,7 +333,7 @@ function PackageGBrowse()
 			{
 				$remote_type = $thisPackage->exists('@type') ? $thisPackage->fetch('@type') : 'relative';
 
-				if ($remote_type == 'relative' && strpos($thisPackage->fetch('@href'), 'http://') !== 0)
+				if ($remote_type == 'relative' && substr($thisPackage->fetch('@href'), 0, 7) != 'http://')
 				{
 					if (isset($_GET['absolute']))
 						$current_url = $_GET['absolute'] . '/';

+ 8 - 24
Sources/Packages.php

@@ -66,9 +66,7 @@ function Packages()
 	// Set up some tabs...
 	$context[$context['admin_menu_name']]['tab_data'] = array(
 		'title' => $txt['package_manager'],
-		/**
-		 * @todo 'help' => 'registrations',
-		 */
+		// @todo 'help' => 'registrations',
 		'description' => $txt['package_manager_desc'],
 		'tabs' => array(
 			'browse' => array(
@@ -585,9 +583,7 @@ function PackageInstallTest()
 		if (empty($thisAction))
 			continue;
 
-		/**
-		 * @todo None given?
-		 */
+		// @todo None given?
 		$thisAction['description'] = isset($action['description']) ? $action['description'] : '';
 		$context['actions'][] = $thisAction;
 	}
@@ -698,9 +694,7 @@ function PackageInstall()
 
 	require_once($sourcedir . '/Subs-Package.php');
 
-	/**
-	 * @todo Perhaps do it in steps, if necessary?
-	 */
+	// @todo Perhaps do it in steps, if necessary?
 
 	$context['uninstalling'] = $_REQUEST['sa'] == 'uninstall2';
 
@@ -812,9 +806,7 @@ function PackageInstall()
 	if (!empty($modSettings['package_make_full_backups']) && (!isset($_SESSION['last_backup_for']) || $_SESSION['last_backup_for'] != $context['filename'] . ($context['uninstalling'] ? '$$' : '$')))
 	{
 		$_SESSION['last_backup_for'] = $context['filename'] . ($context['uninstalling'] ? '$$' : '$');
-		/**
-		 * @todo Internationalize this?
-		 */
+		// @todo Internationalize this?
 		package_create_backup(($context['uninstalling'] ? 'backup_' : 'before_') . strtok($context['filename'], '.'));
 	}
 
@@ -843,9 +835,7 @@ function PackageInstall()
 	$smcFunc['db_free_result']($request);
 
 	// Wait, it's not installed yet!
-	/**
-	 * @todo Replace with a better error message!
-	 */
+	// @todo Replace with a better error message!
 	if (!isset($old_version) && $context['uninstalling'])
 	{
 		deltree($boarddir . '/Packages/temp');
@@ -889,9 +879,7 @@ function PackageInstall()
 
 	$context['install_finished'] = false;
 
-	/**
-	 * @todo Make a log of any errors that occurred and output them?
-	 */
+	// @todo Make a log of any errors that occurred and output them?
 
 	if (!empty($install_log))
 	{
@@ -1706,9 +1694,7 @@ function PackagePermissions()
 		if (!is_array($modSettings['attachmentUploadDir']))
 			$modSettings['attachmentUploadDir'] = unserialize($modSettings['attachmentUploadDir']);
 
-		/**
-		 * @todo Should we suggest non-current directories be read only?
-		 */
+		// @todo Should we suggest non-current directories be read only?
 		foreach ($modSettings['attachmentUploadDir'] as $dir)
 			$context['file_tree'][strtr($dir, array('\\' => '/'))] = array(
 			'type' => 'dir',
@@ -1886,9 +1872,7 @@ function fetchPerms__recursive($path, &$data, $level)
 	// Are we actually interested in saving this data?
 	$save_data = empty($context['only_find']) || $context['only_find'] == $path;
 
-	/**
-	 * @todo Shouldn't happen - but better error message?
-	 */
+	// @todo Shouldn't happen - but better error message?
 	if (!is_dir($path))
 		fatal_lang_error('no_access', false);
 

+ 4 - 8
Sources/PersonalMessage.php

@@ -49,9 +49,7 @@ function MessageMain()
 		$context['message_limit'] = 0;
 	elseif (($context['message_limit'] = cache_get_data('msgLimit:' . $user_info['id'], 360)) === null)
 	{
-		/**
-		 * @todo Why do we do this?  It seems like if they have any limit we should use it.
-		 */
+		// @todo Why do we do this?  It seems like if they have any limit we should use it.
 		$request = $smcFunc['db_query']('', '
 			SELECT MAX(max_messages) AS top_limit, MIN(max_messages) AS bottom_limit
 			FROM {db_prefix}membergroups
@@ -1134,9 +1132,7 @@ function MessageSearch2()
 		}
 
 		// Who matches those criteria?
-		/**
-		 * @todo This doesn't support sent item searching.
-		 */
+		// @todo This doesn't support sent item searching.
 		$request = $smcFunc['db_query']('', '
 			SELECT id_member
 			FROM {db_prefix}members
@@ -2349,12 +2345,12 @@ function MessageActionsApply()
 			$to_delete[] = (int) $pm;
 		else
 		{
-			if (strpos($action, 'add_') === 0)
+			if (substr($action, 0, 4) == 'add_')
 			{
 				$type = 'add';
 				$action = substr($action, 4);
 			}
-			elseif (strpos($action, 'rem_') === 0)
+			elseif (substr($action, 0, 4) == 'rem_')
 			{
 				$type = 'rem';
 				$action = substr($action, 4);

+ 4 - 12
Sources/Post.php

@@ -578,9 +578,7 @@ function Post()
 				)
 			);
 			// The message they were trying to edit was most likely deleted.
-			/**
-			 * @todo Change this error message?
-			 */
+			// @todo Change this error message?
 			if ($smcFunc['db_num_rows']($request) == 0)
 				fatal_lang_error('no_board', false);
 			$row = $smcFunc['db_fetch_assoc']($request);
@@ -683,9 +681,7 @@ function Post()
 			)
 		);
 		// The message they were trying to edit was most likely deleted.
-		/**
-		 * @todo Change this error message?
-		 */
+		//@todo Change this error message?
 		if ($smcFunc['db_num_rows']($request) == 0)
 			fatal_lang_error('no_board', false);
 		$row = $smcFunc['db_fetch_assoc']($request);
@@ -1052,9 +1048,7 @@ function Post()
 		$context['linktree'][count($context['linktree']) - 1]['url'] = $scripturl . '?action=post;' . (!empty($topic) ? 'topic=' . $topic : 'board=' . $board) . '.' . $_REQUEST['start'] . (isset($_REQUEST['msg']) ? ';msg=' . (int) $_REQUEST['msg'] . ';' . $context['session_var'] . '=' . $context['session_id'] : '');
 
 	// If they've unchecked an attachment, they may still want to attach that many more files, but don't allow more than num_allowed_attachments.
-	/**
-	 * @todo This won't work if you're posting an event.
-	 */
+	// @todo This won't work if you're posting an event.
 	$context['num_allowed_attachments'] = empty($modSettings['attachmentNumPerPostLimit']) ? 50 : min($modSettings['attachmentNumPerPostLimit'] - count($context['current_attachments']) + (isset($deleted_attachments) ? $deleted_attachments : 0), $modSettings['attachmentNumPerPostLimit']);
 	$context['can_post_attachment'] = !empty($modSettings['attachmentEnable']) && $modSettings['attachmentEnable'] == 1 && (allowedTo('post_attachment') || ($modSettings['postmod_active'] && allowedTo('post_unapproved_attachments'))) && $context['num_allowed_attachments'] > 0;
 	$context['can_post_attachment_unapproved'] = allowedTo('post_attachment');
@@ -2620,9 +2614,7 @@ function QuoteFast()
 
 		$context['quote']['mozilla'] = strtr($smcFunc['htmlspecialchars']($context['quote']['text']), array('&quot;' => '"'));
 	}
-	/**
-	 * @todo Needs a nicer interface.
-	 */
+	//@todo Needs a nicer interface.
 	// In case our message has been removed in the meantime.
 	elseif (isset($_REQUEST['modify']))
 	{

+ 1 - 3
Sources/Profile-Actions.php

@@ -432,9 +432,7 @@ function deleteAccount2($profile_vars, $post_errors, $memID)
 	// Try get more time...
 	@set_time_limit(600);
 
-	/**
-	 * @todo Add a way to delete pms as well?
-	 */
+	// @todo Add a way to delete pms as well?
 
 	if (!$context['user']['is_owner'])
 		isAllowedTo('profile_remove_any');

+ 6 - 6
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.
@@ -1224,16 +1224,16 @@ function makeCustomFieldChanges($memID, $area, $sanitize = true)
 				$value = $smcFunc['substr']($value, 0, $row['field_length']);
 
 			// Any masks?
-			if ($row['field_type'] === 'text' && !empty($row['mask']) && $row['mask'] != 'none')
+			if ($row['field_type'] == 'text' && !empty($row['mask']) && $row['mask'] != 'none')
 			{
 				// @todo We never error on this - just ignore it at the moment...
-				if ($row['mask'] === 'email' && (preg_match('~^[0-9A-Za-z=_+\-/][0-9A-Za-z=_\'+\-/\.]*@[\w\-]+(\.[\w\-]+)*(\.[\w]{2,6})$~', $value) === 0 || strlen($value) > 255))
+				if ($row['mask'] == 'email' && (preg_match('~^[0-9A-Za-z=_+\-/][0-9A-Za-z=_\'+\-/\.]*@[\w\-]+(\.[\w\-]+)*(\.[\w]{2,6})$~', $value) === 0 || strlen($value) > 255))
 					$value = '';
-				elseif ($row['mask'] === 'number')
+				elseif ($row['mask'] == 'number')
 				{
 					$value = (int) $value;
 				}
-				elseif (strpos($row['mask'], 'regex') === 0 && preg_match(substr($row['mask'], 5), $value) === 0)
+				elseif (substr($row['mask'], 0, 5) == 'regex' && preg_match(substr($row['mask'], 5), $value) === 0)
 					$value = '';
 			}
 		}
@@ -2680,7 +2680,7 @@ function profileSaveAvatarData(&$value)
 		if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///')
 			$profile_vars['avatar'] = '';
 		// Trying to make us do something we'll regret?
-		elseif (strpos($profile_vars['avatar'], 'http://') !== 0)
+		elseif (substr($profile_vars['avatar'], 0, 7) != 'http://')
 			return 'bad_avatar';
 		// Should we check dimensions?
 		elseif (!empty($modSettings['avatar_max_height_external']) || !empty($modSettings['avatar_max_width_external']))

+ 2 - 2
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'] = strpos($_SERVER['QUERY_STRING'], 'url=/') === 0 ? $_SERVER['REDIRECT_QUERY_STRING'] : $_SERVER['QUERY_STRING'];
+		$_SERVER['QUERY_STRING'] = substr($_SERVER['QUERY_STRING'], 0, 5) === 'url=/' ? $_SERVER['REDIRECT_QUERY_STRING'] : $_SERVER['QUERY_STRING'];
 
 		// Replace ';' with '&' and '&something&' with '&something=&'.  (this is done for compatibility...)
 		// @todo smflib
@@ -94,7 +94,7 @@ function cleanRequest()
 		// Search engines will send action=profile%3Bu=1, which confuses PHP.
 		foreach ($_GET as $k => $v)
 		{
-			if (is_string($v) && strpos($k, ';') !== false)
+			if ((string) $v === $v && strpos($k, ';') !== false)
 			{
 				$temp = explode(';', $v);
 				$_GET[$k] = $temp[0];

+ 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)

+ 2 - 2
Sources/Register.php

@@ -29,7 +29,7 @@ function Register($reg_errors = array())
 	global $language, $scripturl, $smcFunc, $sourcedir, $smcFunc, $cur_profile;
 
 	// Is this an incoming AJAX check?
-	if (isset($_GET['sa']) && $_GET['sa'] === 'usernamecheck')
+	if (isset($_GET['sa']) && $_GET['sa'] == 'usernamecheck')
 		return RegisterCheckUsername();
 
 	// Check if the administrator has it disabled.
@@ -421,7 +421,7 @@ function Register2($verifiedOpenID = false)
 					$custom_field_errors[] = array('custom_field_invalid_email', array($row['field_name']));
 				elseif ($row['mask'] == 'number' && preg_match('~[^\d]~', $value))
 					$custom_field_errors[] = array('custom_field_not_number', array($row['field_name']));
-				elseif (strpos($row['mask'], 'regex') === 0 && preg_match(substr($row['mask'], 5), $value) === 0)
+				elseif (substr($row['mask'], 0, 5) == 'regex' && preg_match(substr($row['mask'], 5), $value) === 0)
 					$custom_field_errors[] = array('custom_field_inproper_format', array($row['field_name']));
 			}
 		}

+ 2 - 2
Sources/Reports.php

@@ -839,7 +839,7 @@ function addData($inc_data, $custom_table = null)
 				'v' => empty($inc_data[$key]) ? $context['tables'][$table]['default_value'] : $inc_data[$key],
 			);
 			// Special "hack" the adding separators when doing data by column.
-			if (strpos($key, '#sep#') === 0)
+			if (substr($key, 0, 5) == '#sep#')
 				$data[$key]['separator'] = true;
 		}
 	}
@@ -851,7 +851,7 @@ function addData($inc_data, $custom_table = null)
 			$data[$key] = array(
 				'v' => $value,
 			);
-			if (strpos($key, '#sep#') === 0)
+			if (substr($key, 0, 5) == '#sep#')
 				$data[$key]['separator'] = true;
 		}
 	}

+ 1 - 1
Sources/ScheduledTasks.php

@@ -1242,7 +1242,7 @@ function scheduled_fetchSMfiles()
 	foreach ($js_files as $ID_FILE => $file)
 	{
 		// Create the url
-		$server = empty($file['path']) || strpos($file['path'], 'http://') !== 0 ? 'http://www.simplemachines.org' : '';
+		$server = empty($file['path']) || substr($file['path'], 0, 7) != 'http://' ? 'http://www.simplemachines.org' : '';
 		$url = $server . (!empty($file['path']) ? $file['path'] : $file['path']) . $file['filename'] . (!empty($file['parameters']) ? '?' . $file['parameters'] : '');
 
 		// Get the file

+ 1 - 1
Sources/Search.php

@@ -1839,7 +1839,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.

+ 2 - 2
Sources/Stats.php

@@ -149,7 +149,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
@@ -419,7 +419,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

+ 3 - 3
Sources/Subs-Admin.php

@@ -252,7 +252,7 @@ function updateSettingsFile($config_vars)
 	if (count($config_vars) == 1 && isset($config_vars['db_last_error']))
 	{
 		$temp = trim(implode("\n", $settingsArray));
-		if (strpos($temp, '<' . '?php') !== 0 || substr($temp, -2) != '?' . '>')
+		if (substr($temp, 0, 5) != '<?php' || substr($temp, -2) != '?' . '>')
 			return;
 		if (strpos($temp, 'sourcedir') === false || strpos($temp, 'boarddir') === false)
 			return;
@@ -268,7 +268,7 @@ function updateSettingsFile($config_vars)
 	for ($i = 0, $n = count($settingsArray); $i < $n; $i++)
 	{
 		// Don't trim or bother with it if it's not a variable.
-		if (strpos($settingsArray[$i], '$') !== 0)
+		if (substr($settingsArray[$i], 0, 1) != '$')
 			continue;
 
 		$settingsArray[$i] = trim($settingsArray[$i]) . "\n";
@@ -286,7 +286,7 @@ function updateSettingsFile($config_vars)
 			}
 		}
 
-		if (strpos(trim($settingsArray[$i]), '?' . '>'))
+		if (substr(trim($settingsArray[$i]), 0, 2) == '?' . '>')
 			$end = $i;
 	}
 

+ 1 - 6
Sources/Subs-Auth.php

@@ -103,12 +103,7 @@ function setLoginCookie($cookie_length, $id, $password = '')
 	}
 }
 
-// @todo remove this? wouldn't it get caught earlier?
-// PHP < 4.3.2 doesn't have this function
-if (!function_exists('session_regenerate_id'))
-{
-	require_once $sourcedir . 'Subs-Compat.php';
-}
+
 
 /**
  * Get the domain and path for the cookie

+ 1 - 1
Sources/Subs-Categories.php

@@ -128,7 +128,7 @@ function createCategory($catOptions)
 	call_integration_hook('integrate_create_category', array(&$catOptions));
 
 	// Check required values.
-	if (!isset($catOptions['cat_name']) || trim($catOptions['cat_name']) === '')
+	if (!isset($catOptions['cat_name']) || trim($catOptions['cat_name']) == '')
 		trigger_error('createCategory(): A category name is required', E_USER_ERROR);
 
 	// Set default values.

+ 5 - 5
Sources/Subs-Editor.php

@@ -814,7 +814,7 @@ function html_to_bbc($text)
 					$tag_type = 'ftp';
 
 				// Or is this a link to an email address?
-				elseif (strpos($href, 'mailto:') === 0)
+				elseif (substr($href, 0, 7) == 'mailto:')
 				{
 					$tag_type = 'email';
 					$href = substr($href, 7);
@@ -968,7 +968,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
@@ -1824,7 +1824,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
@@ -1946,7 +1946,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
@@ -2126,7 +2126,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-Graphics.php

@@ -305,7 +305,7 @@ function resizeImageFile($source, $destination, $max_width, $max_height, $prefer
 
 	// Get the image file, we have to work with something after all
 	$fp_destination = fopen($destination, 'wb');
-	if ($fp_destination && strpos($source, 'http://') === 0)
+	if ($fp_destination && substr($source, 0, 7) == 'http://')
 	{
 		$fileContents = fetch_web_data($source);
 

+ 1 - 1
Sources/Subs-Membergroups.php

@@ -747,7 +747,7 @@ function list_getMembergroups($start, $items_per_page, $sort, $membergroup_type)
 	}
 
 	// Apply manual sorting if the 'number of members' column is selected.
-	if (strpos($sort, '1') === 0 || strpos($sort, ', 1') !== false)
+	if (substr($sort, 0, 1) == '1' || strpos($sort, ', 1') !== false)
 	{
 		$sort_ascending = strpos($sort, 'DESC') === false;
 

+ 1 - 1
Sources/Subs-Menu.php

@@ -164,7 +164,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]);

+ 2 - 2
Sources/Subs-OpenID.php

@@ -38,7 +38,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.
@@ -393,7 +393,7 @@ function smf_openID_canonize($uri)
 	if (strpos($uri, 'http://') !== 0 && strpos($uri, 'https://') !== 0)
 		$uri = 'http://' . $uri;
 
-	if (strpos($uri, '/', strpos($uri, '://') + 3) === false)
+	if (strpos(substr($uri, strpos($uri, '://') + 3), '/') === false)
 		$uri .= '/';
 
 	return $uri;

+ 6 - 6
Sources/Subs-Package.php

@@ -30,7 +30,7 @@ if (!defined('SMF'))
  */
 function read_tgz_file($gzfilename, $destination, $single_file = false, $overwrite = false, $files_to_extract = null)
 {
-	if (strpos($gzfilename, 'http://') === 0)
+	if (substr($gzfilename, 0, 7) == 'http://')
 	{
 		$data = fetch_web_data($gzfilename);
 
@@ -88,7 +88,7 @@ function read_tgz_data($data, $destination, $single_file = false, $overwrite = f
 	if (strtolower($id['a'] . $id['b']) != '1f8b')
 	{
 		// Okay, this ain't no tar.gz, but maybe it's a zip file.
-		if (strpos($data, 'PK') === 0)
+		if (substr($data, 0, 2) == 'PK')
 			return read_zip_data($data, $destination, $single_file, $overwrite, $files_to_extract);
 		else
 			return false;
@@ -681,7 +681,7 @@ function create_chmod_control($chmodFiles = array(), $chmodOptions = array(), $r
 			if (!in_array($_POST['ftp_path'], array('', '/')))
 			{
 				$ftp_root = strtr($boarddir, array($_POST['ftp_path'] => ''));
-				if (substr($ftp_root, -1) == '/' && ($_POST['ftp_path'] == '' || strpos($_POST['ftp_path'], '/') === 0))
+				if (substr($ftp_root, -1) == '/' && ($_POST['ftp_path'] == '' || substr($_POST['ftp_path'], 0, 1) == '/'))
 					$ftp_root = substr($ftp_root, 0, -1);
 			}
 			else
@@ -944,7 +944,7 @@ function packageRequireFTP($destination_url, $files = null, $return = false)
 		if (!in_array($_POST['ftp_path'], array('', '/')))
 		{
 			$ftp_root = strtr($boarddir, array($_POST['ftp_path'] => ''));
-			if (substr($ftp_root, -1) == '/' && ($_POST['ftp_path'] == '' || strpos($_POST['ftp_path'], '/') === 0))
+			if (substr($ftp_root, -1) == '/' && ($_POST['ftp_path'] == '' || $_POST['ftp_path'][0] == '/'))
 				$ftp_root = substr($ftp_root, 0, -1);
 		}
 		else
@@ -1127,7 +1127,7 @@ function parsePackageInfo(&$packageXML, $testing_only = true, $method = 'install
 		);
 
 		// If there is a destination, make sure it makes sense.
-		if (strpos($actionType, 'remove') !== 0)
+		if (substr($actionType, 0, 6) != 'remove')
 		{
 			$this_action['unparsed_destination'] = $action->fetch('@destination');
 			$this_action['destination'] = parse_path($action->fetch('@destination')) . '/' . basename($this_action['filename']);
@@ -1139,7 +1139,7 @@ function parsePackageInfo(&$packageXML, $testing_only = true, $method = 'install
 		}
 
 		// If we're moving or requiring (copying) a file.
-		if (strpos($actionType, 'move') === 0 || strpos($actionType, 'require') === 0)
+		if (substr($actionType, 0, 4) == 'move' || substr($actionType, 0, 7) == 'require')
 		{
 			if ($action->exists('@from'))
 				$this_action['source'] = parse_path($action->fetch('@from'));

+ 7 - 7
Sources/Subs-Post.php

@@ -45,7 +45,7 @@ function preparsecode(&$message, $previewing = false)
 	// Trim off trailing quotes - these often happen by accident.
 	while (substr($message, -7) == '[quote]')
 		$message = substr($message, 0, -7);
-	while (strpos($message, '[/quote]') === 0)
+	while (substr($message, 0, 8) == '[/quote]')
 		$message = substr($message, 8);
 
 	// Find all code blocks, work out whether we'd be parsing them, then ensure they are all closed.
@@ -465,11 +465,11 @@ function fixTag(&$message, $myTag, $protocols, $embeddedUrl = false, $hasEqualSi
 
 		if (!$found && $protocols[0] == 'http')
 		{
-			if (strpos($replace, '/') === 0)
+			if (substr($replace, 0, 1) == '/')
 				$replace = $domain_url . $replace;
-			elseif (strpos($replace, '?') === 0)
+			elseif (substr($replace, 0, 1) == '?')
 				$replace = $scripturl . $replace;
-			elseif (strpos($replace, '#') === 0 && $embeddedUrl)
+			elseif (substr($replace, 0, 1) == '#' && $embeddedUrl)
 			{
 				$replace = '#' . preg_replace('~[^A-Za-z0-9_\-#]~', '', substr($replace, 1));
 				$this_tag = 'iurl';
@@ -1269,7 +1269,7 @@ function smtp_mail($mail_to_array, $subject, $message, $headers)
 	if ($modSettings['mail_type'] == 2 && $modSettings['smtp_username'] != '' && $modSettings['smtp_password'] != '')
 	{
 		$socket = fsockopen($modSettings['smtp_host'], 110, $errno, $errstr, 2);
-		if (!$socket && (strpos($modSettings['smtp_host'], 'smtp.') === 0 || strpos($modSettings['smtp_host'], 'ssl://smtp.') === 0))
+		if (!$socket && (substr($modSettings['smtp_host'], 0, 5) == 'smtp.' || substr($modSettings['smtp_host'], 0, 11) == 'ssl://smtp.'))
 			$socket = fsockopen(strtr($modSettings['smtp_host'], array('smtp.' => 'pop.')), 110, $errno, $errstr, 2);
 
 		if ($socket)
@@ -1289,7 +1289,7 @@ function smtp_mail($mail_to_array, $subject, $message, $headers)
 	if (!$socket = fsockopen($modSettings['smtp_host'], empty($modSettings['smtp_port']) ? 25 : $modSettings['smtp_port'], $errno, $errstr, 3))
 	{
 		// Maybe we can still save this?  The port might be wrong.
-		if (strpos($modSettings['smtp_host'], 'ssl:') === 0 && (empty($modSettings['smtp_port']) || $modSettings['smtp_port'] == 25))
+		if (substr($modSettings['smtp_host'], 0, 4) == 'ssl:' && (empty($modSettings['smtp_port']) || $modSettings['smtp_port'] == 25))
 		{
 			if ($socket = fsockopen($modSettings['smtp_host'], 465, $errno, $errstr, 3))
 				log_error($txt['smtp_port_ssl']);
@@ -1396,7 +1396,7 @@ function server_parse($message, $socket, $response)
 	// No response yet.
 	$server_response = '';
 
-	while (strpos($server_response, ' ', 3) !== 3)
+	while (substr($server_response, 3, 1) != ' ')
 		if (!($server_response = fgets($socket, 256)))
 		{
 			// @todo Change this message to reflect that it may mean bad user/password/server issues/etc.

+ 15 - 15
Sources/Subs.php

@@ -186,7 +186,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']('', '
@@ -612,7 +612,7 @@ function comma_format($number, $override_decimal_count = false)
 	}
 
 	// Format the string with our friend, number_format.
-	return number_format($number, is_float($number) ? ($override_decimal_count === false ? $decimal_count : $override_decimal_count) : 0, $decimal_separator, $thousands_separator);
+	return number_format($number, (float) $number === $number ? ($override_decimal_count === false ? $decimal_count : $override_decimal_count) : 0, $decimal_separator, $thousands_separator);
 }
 
 /**
@@ -634,7 +634,7 @@ function comma_format($number, $override_decimal_count = false)
 function timeformat($log_time, $show_today = true, $offset_type = false)
 {
 	global $context, $user_info, $txt, $modSettings, $smcFunc;
-	static $non_twelve_hour = null;
+	static $non_twelve_hour;
 
 	// Offset the time.
 	if (!$offset_type)
@@ -1323,7 +1323,7 @@ function parse_bbc($message, $smileys = true, $cache_id = '', $parse_tags = arra
 				'validate' => isset($disabled['php']) ? null : create_function('&$tag, &$data, $disabled', '
 					if (!isset($disabled[\'php\']))
 					{
-						$add_begin = strpos(trim($data), \'&lt;?\') === 0;
+						$add_begin = substr(trim($data), 0, 5) != \'&lt;?\';
 						$data = highlight_php_code($add_begin ? \'&lt;?php \' . $data . \'?&gt;\' : $data);
 						if ($add_begin)
 							$data = preg_replace(array(\'~^(.+?)&lt;\?.{0,40}?php(?:&nbsp;|\s)~\', \'~\?&gt;((?:</(font|span)>)*)$~\'), \'$1\', $data, 2);
@@ -1912,7 +1912,7 @@ function parse_bbc($message, $smileys = true, $cache_id = '', $parse_tags = arra
 				$pos2 = $pos - 1;
 
 				// See the comment at the end of the big loop - just eating whitespace ;).
-				if (!empty($tag['block_level']) && strpos($message, '<br />', $pos) === $pos)
+				if (!empty($tag['block_level']) && substr($message, $pos, 6) == '<br />')
 					$message = substr($message, 0, $pos) . substr($message, $pos + 6);
 				if (!empty($tag['trim']) && $tag['trim'] != 'inside' && preg_match('~(<br />|&nbsp;|\s)*~', substr($message, $pos), $matches) != 0)
 					$message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0]));
@@ -1956,7 +1956,7 @@ function parse_bbc($message, $smileys = true, $cache_id = '', $parse_tags = arra
 				if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=')
 					continue;
 				// Maybe we just want a /...
-				if ($possible['type'] == 'closed' && $next_c != ']' && (strpos($message, '/]', $pos + 1 + strlen($possible['tag'])) !== $pos + 1 + strlen($possible['tag'])) && (strpos($message, ' /]', $pos + 1 + strlen($possible['tag'])) !== $pos + 1 + strlen($possible['tag'])))
+				if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + strlen($possible['tag']), 2) != '/]' && substr($message, $pos + 1 + strlen($possible['tag']), 3) != ' /]')
 					continue;
 				// An immediate ]?
 				if ($possible['type'] == 'unparsed_content' && $next_c != ']')
@@ -2164,7 +2164,7 @@ function parse_bbc($message, $smileys = true, $cache_id = '', $parse_tags = arra
 				$pos1 += strlen($open_tags[$i]['after']) + 2;
 
 				// Trim or eat trailing stuff... see comment at the end of the big loop.
-				if (!empty($open_tags[$i]['block_level']) && strpos($message, '<br />', $pos) === $pos)
+				if (!empty($open_tags[$i]['block_level']) && substr($message, $pos, 6) == '<br />')
 					$message = substr($message, 0, $pos) . substr($message, $pos + 6);
 				if (!empty($open_tags[$i]['trim']) && $tag['trim'] != 'inside' && preg_match('~(<br />|&nbsp;|\s)*~', substr($message, $pos), $matches) != 0)
 					$message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0]));
@@ -2190,7 +2190,7 @@ function parse_bbc($message, $smileys = true, $cache_id = '', $parse_tags = arra
 
 			$data = substr($message, $pos1, $pos2 - $pos1);
 
-			if (!empty($tag['block_level']) && strpos($data, '<br />') === 0)
+			if (!empty($tag['block_level']) && substr($data, 0, 6) == '<br />')
 				$data = substr($data, 6);
 
 			if (isset($tag['validate']))
@@ -2209,7 +2209,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 = strpos($message, '&quot;', $pos1) === $pos1;
+				$quoted = substr($message, $pos1, 6) == '&quot;';
 				if ($tag['quoted'] != 'optional' && !$quoted)
 					continue;
 
@@ -2231,7 +2231,7 @@ function parse_bbc($message, $smileys = true, $cache_id = '', $parse_tags = arra
 				substr($message, $pos1, $pos2 - $pos1)
 			);
 
-			if (!empty($tag['block_level']) && strpos($data[0], '<br />') === 0)
+			if (!empty($tag['block_level']) && substr($data[0], 0, 6) == '<br />')
 				$data[0] = substr($data[0], 6);
 
 			// Validation for my parking, please!
@@ -2303,7 +2303,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 = strpos($message, '&quot;', $pos1) === $pos1;
+				$quoted = substr($message, $pos1, 6) == '&quot;';
 				if ($tag['quoted'] != 'optional' && !$quoted)
 					continue;
 
@@ -2337,7 +2337,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']) && strpos($message, '<br />', $pos + 1) === $pos + 1)
+		if (!empty($tag['block_level']) && substr($message, $pos + 1, 6) == '<br />')
 			$message = substr($message, 0, $pos + 1) . substr($message, $pos + 7);
 
 		// Are we trimming outside this tag?
@@ -2421,7 +2421,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
@@ -2515,7 +2515,7 @@ function redirectexit($setLocation = '', $refresh = false)
 		// @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\
 		AddMailQueue(true);
 
-	$add = preg_match('~^(ftp|http)[s]?://~', $setLocation) == 0 && strpos($setLocation, 'about:') !== 0;
+	$add = preg_match('~^(ftp|http)[s]?://~', $setLocation) == 0 && substr($setLocation, 0, 6) != 'about:';
 
 	if (WIRELESS)
 	{
@@ -2855,7 +2855,7 @@ function setupThemeContext($forceload = false)
 		if ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach']))
 			$context['user']['avatar']['href'] = $user_info['avatar']['custom_dir'] ? $modSettings['custom_avatar_url'] . '/' . $user_info['avatar']['filename'] : $scripturl . '?action=dlattach;attach=' . $user_info['avatar']['id_attach'] . ';type=avatar';
 		// Full URL?
-		elseif (strpos($user_info['avatar']['url'], 'http://') === 0)
+		elseif (substr($user_info['avatar']['url'], 0, 7) == 'http://')
 		{
 			$context['user']['avatar']['href'] = $user_info['avatar']['url'];
 

+ 1 - 1
Sources/Subscriptions-PayPal.php

@@ -223,7 +223,7 @@ class paypal_payment
 	// Is this a subscription?
 	public function isSubscription()
 	{
-		if (strpos($_POST['txn_type'], 'subscr_payment') === 0)
+		if (substr($_POST['txn_type'], 0, 14) == 'subscr_payment')
 			return true;
 		else
 			return false;

+ 4 - 4
Sources/Themes.php

@@ -1791,7 +1791,7 @@ function EditTheme()
 	{
 		if (isset($_GET['directory']))
 		{
-			if (strpos($_GET['directory'], '.') === 0)
+			if (substr($_GET['directory'], 0, 1) == '.')
 				$_GET['directory'] = '';
 			else
 			{
@@ -1828,7 +1828,7 @@ function EditTheme()
 	}
 	else
 	{
-		if (strpos($_REQUEST['filename'], '.') === 0)
+		if (substr($_REQUEST['filename'], 0, 1) == '.')
 			$_REQUEST['filename'] = '';
 		else
 		{
@@ -1940,7 +1940,7 @@ function EditTheme()
 		$context['file_parts'] = array(array('lines' => 0, 'line' => 1, 'data' => ''));
 		for ($i = 0, $n = count($file_data); $i < $n; $i++)
 		{
-			if (isset($file_data[$i + 1]) && strpos($file_data[$i + 1], 'function ') === 0)
+			if (isset($file_data[$i + 1]) && substr($file_data[$i + 1], 0, 9) == 'function ')
 			{
 				// Try to format the functions a little nicer...
 				$context['file_parts'][$j]['data'] = trim($context['file_parts'][$j]['data']) . "\n";
@@ -1989,7 +1989,7 @@ function get_file_listing($path, $relative)
 	foreach ($entries as $entry)
 	{
 		// Skip all dot files, including .htaccess.
-		if (strpos($entry, '.') === 0 || $entry == 'CVS')
+		if (substr($entry, 0, 1) == '.' || $entry == 'CVS')
 			continue;
 
 		if (is_dir($path . '/' . $entry))

+ 6 - 6
Sources/ViewQuery.php

@@ -19,11 +19,11 @@ if (!defined('SMF'))
 /**
  * Show the database queries for debugging
  * What this does:
- * * Toggles the session variable 'view_queries'.
- * * Views a list of queries and analyzes them.
- * * Requires the admin_forum permission.
- * * Is accessed via ?action=viewquery.
- * * Strings in this function have not been internationalized.
+ * - Toggles the session variable 'view_queries'.
+ * - Views a list of queries and analyzes them.
+ * - Requires the admin_forum permission.
+ * - Is accessed via ?action=viewquery.
+ * - Strings in this function have not been internationalized.
  */
 function ViewQuery()
 {
@@ -94,7 +94,7 @@ function ViewQuery()
 		if (isset($query_data['f']))
 			$query_data['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $query_data['f']);
 
-		$is_select_query = strpos(trim($query_data['q']), 'SELECT') === 0;
+		$is_select_query = substr(trim($query_data['q']), 0, 6) == 'SELECT';
 		if ($is_select_query)
 			$select = $query_data['q'];
 		elseif (preg_match('~^INSERT(?: IGNORE)? INTO \w+(?:\s+\([^)]+\))?\s+(SELECT .+)$~s', trim($query_data['q']), $matches) != 0)

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

@@ -406,7 +406,7 @@ $helptxt['ssi_db_user'] = 'Optional setting to use a different database user and
 
 $helptxt['queryless_urls'] = 'This changes the format of URLs a little so search engines will like them better.  They will look like index.php/topic,1.0.html.<br /><br />This feature will ' . (isset($_SERVER['SERVER_SOFTWARE']) && (strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== false || strpos($_SERVER['SERVER_SOFTWARE'], 'lighttpd') !== false) ? '' : 'not') . ' work on your server.';
 $helptxt['countChildPosts'] = 'Checking this option will mean that posts and topics in a board\'s child board will count toward its totals on the index page.<br /><br />This will make things notably slower, but means that a parent with no posts in it won\'t show \'0\'.';
-$helptxt['fixLongWords'] = 'This option breaks words longer than a certain length into pieces so they don\'t disturb the forum\'s layout. (as much...)  This option should not be set to a value under 40. This option will not work with forums using UTF-8 and PHP less than 4.4.0. This ' . (empty($GLOBALS['context']['utf8']) || version_compare(PHP_VERSION, '4.4.0', '>=') ? 'WILL' : 'WILL NOT') . ' work on your server';
+$helptxt['fixLongWords'] = 'This option breaks words longer than a certain length into pieces so they don\'t disturb the forum\'s layout. (as much...)  This option should not be set to a value under 40. This option will not work with forums using UTF-8. This ' . (empty($GLOBALS['context']['utf8'])) ? 'WILL' : 'WILL NOT') . ' work on your server';
 $helptxt['allow_ignore_boards'] = 'Checking this option will allow users to select boards they wish to ignore.';
 
 $helptxt['who_enabled'] = 'This option allows you to turn on or off the ability for users to see who is browsing the forum and what they are doing.';

+ 7 - 7
index.php

@@ -35,7 +35,7 @@ ob_start();
 // Do some cleaning, just in case.
 foreach (array('db_character_set', 'cachedir') as $variable)
 	if (isset($GLOBALS[$variable]))
-		unset($GLOBALS[$variable]);
+		unset($GLOBALS[$variable], $GLOBALS[$variable]);
 
 // Load the settings...
 require_once(dirname(__FILE__) . '/Settings.php');
@@ -88,7 +88,7 @@ if (isset($_GET['scheduled']))
 if (!empty($modSettings['enableCompressedOutput']) && !headers_sent())
 {
 	// If zlib is being used, turn off output compression.
-	if (ini_get('zlib.output_compression') == '1' || ini_get('output_handler') === 'ob_gzhandler' || version_compare(PHP_VERSION, '4.2.0', '<'))
+	if (ini_get('zlib.output_compression') == '1' || ini_get('output_handler') == 'ob_gzhandler')
 		$modSettings['enableCompressedOutput'] = '0';
 	else
 	{
@@ -137,7 +137,7 @@ if (WIRELESS)
 	$modSettings['defaultMaxTopics'] = 9;
 
 	// Wireless protocol header.
-	if (WIRELESS_PROTOCOL === 'wap')
+	if (WIRELESS_PROTOCOL == 'wap')
 		header('Content-Type: text/vnd.wap.wml');
 }
 
@@ -163,7 +163,7 @@ function smf_main()
 	global $modSettings, $settings, $user_info, $board, $topic, $board_info, $maintenance, $sourcedir;
 
 	// Special case: session keep-alive, output a transparent pixel.
-	if (isset($_GET['action']) && $_GET['action'] === 'keepalive')
+	if (isset($_GET['action']) && $_GET['action'] == 'keepalive')
 	{
 		header('Content-Type: image/gif');
 		die("\x47\x49\x46\x38\x39\x61\x01\x00\x01\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x21\xF9\x04\x01\x00\x00\x00\x00\x2C\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02\x44\x01\x00\x3B");
@@ -179,7 +179,7 @@ function smf_main()
 	loadPermissions();
 
 	// Attachments don't require the entire theme to be loaded.
-	if (isset($_REQUEST['action']) && $_REQUEST['action'] === 'dlattach' && (!empty($modSettings['allow_guestAccess']) && $user_info['is_guest']))
+	if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach' && (!empty($modSettings['allow_guestAccess']) && $user_info['is_guest']))
 		detectBrowser();
 	// Load the current theme.  (note that ?theme=1 will also work, may be used for guest theming.)
 	else
@@ -210,10 +210,10 @@ function smf_main()
 	if (!empty($maintenance) && !allowedTo('admin_forum'))
 	{
 		// You can only login.... otherwise, you're getting the "maintenance mode" display.
-		if (isset($_REQUEST['action']) && ($_REQUEST['action'] === 'login2' || $_REQUEST['action'] === 'logout'))
+		if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'login2' || $_REQUEST['action'] == 'logout'))
 		{
 			require_once($sourcedir . '/LogInOut.php');
-			return $_REQUEST['action'] === 'login2' ? 'Login2' : 'Logout';
+			return $_REQUEST['action'] == 'login2' ? 'Login2' : 'Logout';
 		}
 		// Don't even try it, sonny.
 		else