Browse Source

! replace some strpos(strtolower()) with stripos where mods generally don't play

Spuds 13 years ago
parent
commit
2177f8c106

+ 1 - 2
Sources/Admin.php

@@ -816,8 +816,7 @@ function AdminSearchInternal()
 				$item[0] = array($item[0]);
 			foreach ($item[0] as $term)
 			{
-				$lc_term = strtolower($term);
-				if (strpos($lc_term, $search_term) !== false || (isset($txt[$term]) && strpos(strtolower($txt[$term]), $search_term) !== false) || (isset($txt['setting_' . $term]) && strpos(strtolower($txt['setting_' . $term]), $search_term) !== false))
+				if (stripos($term, $search_term) !== false || (isset($txt[$term]) && stripos($txt[$term], $search_term) !== false) || (isset($txt['setting_' . $term]) && stripos($txt['setting_' . $term], $search_term) !== false))
 				{
 					$found = $term;
 					break;

+ 1 - 1
Sources/Errors.php

@@ -227,7 +227,7 @@ function error_handler($error_level, $error_string, $file, $line)
 <strong>', $error_level % 255 == E_ERROR ? 'Error' : ($error_level % 255 == E_WARNING ? 'Warning' : 'Notice'), '</strong>: ', $error_string, ' in <strong>', $file, '</strong> on line <strong>', $line, '</strong><br />';
 	}
 
-	$error_type = strpos(strtolower($error_string), 'undefined') !== false ? 'undefined_vars' : 'general';
+	$error_type = stripos($error_string, 'undefined') !== false ? 'undefined_vars' : 'general';
 
 	$message = log_error($error_level . ': ' . $error_string, $error_type, $file, $line);
 

+ 1 - 1
Sources/LogInOut.php

@@ -345,7 +345,7 @@ function Login2()
 		}
 
 		// SMF's sha1 function can give a funny result on Linux (Not our fault!). If we've now got the real one let the old one be valid!
-		if (strpos(strtolower(PHP_OS), 'win') !== 0)
+		if (stripos(PHP_OS, 'win') !== 0)
 		{
 			require_once($sourcedir . '/Subs-Compat.php');
 			$other_passwords[] = sha1_smf(strtolower($user_settings['member_name']) . un_htmlspecialchars($_POST['passwrd']));

+ 1 - 1
Sources/ManageServer.php

@@ -388,7 +388,7 @@ function ModifyLoadBalancingSettings($return_config = false)
 	$disabled = true;
 	$context['settings_message'] = $txt['loadavg_disabled_conf'];
 
-	if (strpos(strtolower(PHP_OS), 'win') === 0)
+	if (stripos(PHP_OS, 'win') === 0)
 		$context['settings_message'] = $txt['loadavg_disabled_windows'];
 	else
 	{

+ 1 - 1
Sources/PackageGet.php

@@ -439,7 +439,7 @@ function PackageGBrowse()
 					else
 						$authorhompage = $default_website;
 
-					if (strpos(strtolower($authorhompage), 'a href') === false)
+					if (stripos($authorhompage, 'a href') === false)
 					{
 						$package['author']['website']['href'] = $authorhompage;
 						$package['author']['website']['link'] = '<a href="' . $authorhompage . '">' . $package['author']['website']['name'] . '</a>';

+ 2 - 2
Sources/Subs-Package.php

@@ -2426,7 +2426,7 @@ function package_get_contents($filename)
 	if (!isset($package_cache))
 	{
 		// Windows doesn't seem to care about the memory_limit.
-		if (!empty($modSettings['package_disable_cache']) || ini_set('memory_limit', '128M') !== false || strpos(strtolower(PHP_OS), 'win') !== false)
+		if (!empty($modSettings['package_disable_cache']) || ini_set('memory_limit', '128M') !== false || stripos(PHP_OS, 'win') !== false)
 			$package_cache = array();
 		else
 			$package_cache = false;
@@ -2455,7 +2455,7 @@ function package_put_contents($filename, $data, $testing = false)
 	if (!isset($package_cache))
 	{
 		// Try to increase the memory limit - we don't want to run out of ram!
-		if (!empty($modSettings['package_disable_cache']) || ini_set('memory_limit', '128M') !== false || strpos(strtolower(PHP_OS), 'win') !== false)
+		if (!empty($modSettings['package_disable_cache']) || ini_set('memory_limit', '128M') !== false || stripos(PHP_OS, 'win') !== false)
 			$package_cache = array();
 		else
 			$package_cache = false;

+ 1 - 1
Sources/Subs.php

@@ -3328,7 +3328,7 @@ function host_from_ip($ip)
 	}
 
 	// This is nslookup; usually only Windows, but possibly some Unix?
-	if (!isset($host) && strpos(strtolower(PHP_OS), 'win') !== false && strpos(strtolower(PHP_OS), 'darwin') === false && mt_rand(0, 1) == 1)
+	if (!isset($host) && stripos(PHP_OS, 'win') !== false && strpos(strtolower(PHP_OS), 'darwin') === false && mt_rand(0, 1) == 1)
 	{
 		$test = @shell_exec('nslookup -timeout=1 ' . @escapeshellarg($ip));
 		if (strpos($test, 'Non-existent domain') !== false)