Browse Source

! Missing requires in censored words ManagePosts.php
! Small fix for early versions of php5 ManageSettings.php
! A little more cleanup in Load.php

Spuds 13 years ago
parent
commit
c0f7e894a4
3 changed files with 23 additions and 21 deletions
  1. 20 19
      Sources/Load.php
  2. 2 1
      Sources/ManagePosts.php
  3. 1 1
      Sources/ManageSettings.php

+ 20 - 19
Sources/Load.php

@@ -18,7 +18,8 @@ if (!defined('SMF'))
 
 
 /**
 /**
  * Load the $modSettings array.
  * Load the $modSettings array.
- * @todo okay question of the day: why a function loading settings is called reloadSettings()
+ *
+ * @todo okay question of the day: why a function for loading settings is called reloadSettings()
  *
  *
  * @global array $modSettings is a giant array of all of the forum-wide settings and statistics.
  * @global array $modSettings is a giant array of all of the forum-wide settings and statistics.
  */
  */
@@ -72,9 +73,7 @@ function reloadSettings()
 	// Preg_replace can handle complex characters only for higher PHP versions.
 	// Preg_replace can handle complex characters only for higher PHP versions.
 	$space_chars = $utf8 ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0';
 	$space_chars = $utf8 ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0';
 
 
-	/**
-	 * @global array An array of anonymous helper functions.
-	 */
+	// global array of anonymous helper functions, used mosly to properly handle multi byte strings
 	$smcFunc += array(
 	$smcFunc += array(
 		'entity_fix' => create_function('$string', '
 		'entity_fix' => create_function('$string', '
 			$num = $string[0] === \'x\' ? hexdec(substr($string, 1)) : (int) $string;
 			$num = $string[0] === \'x\' ? hexdec(substr($string, 1)) : (int) $string;
@@ -165,7 +164,7 @@ function reloadSettings()
 			if (!empty($modSettings['load_average']))
 			if (!empty($modSettings['load_average']))
 				cache_put_data('loadavg', $modSettings['load_average'], 90);
 				cache_put_data('loadavg', $modSettings['load_average'], 90);
 		}
 		}
-		
+
 		if (!empty($modSettings['load_average']))
 		if (!empty($modSettings['load_average']))
 			call_integration_hook('integrate_load_average', array($modSettings['load_average']));
 			call_integration_hook('integrate_load_average', array($modSettings['load_average']));
 
 
@@ -740,6 +739,7 @@ function loadBoard()
 
 
 /**
 /**
  * Load this user's permissions.
  * Load this user's permissions.
+ *
  */
  */
 function loadPermissions()
 function loadPermissions()
 {
 {
@@ -1224,13 +1224,13 @@ function loadMemberContext($user, $display_custom_fields = false)
 }
 }
 
 
 /**
 /**
- * This function is... detecting the browser, right.
- * Loads a bunch of browser information in to $context
+ * Loads information about what browser the user is viewing with and places it in $context
+ *
  */
  */
 function detectBrowser()
 function detectBrowser()
 {
 {
 	global $context, $user_info;
 	global $context, $user_info;
-	
+
 	// The following determines the user agent (browser) as best it can.
 	// The following determines the user agent (browser) as best it can.
 	$context['browser'] = array(
 	$context['browser'] = array(
 		'is_opera' => strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false,
 		'is_opera' => strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false,
@@ -1344,7 +1344,8 @@ function detectBrowser()
 }
 }
 
 
 /**
 /**
- * Are we using this browser? 
+ * Are we using this browser?
+ *
  * Wrapper function for detectBrowser
  * Wrapper function for detectBrowser
  * @param $browser: browser we are checking for.
  * @param $browser: browser we are checking for.
 */
 */
@@ -1688,7 +1689,7 @@ function loadTheme($id_theme = 0, $initialize = true)
 		// If not a user variant, select the default.
 		// If not a user variant, select the default.
 		if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants']))
 		if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants']))
 			$context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0];
 			$context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0];
-	
+
 		// Do this to keep things easier in the templates.
 		// Do this to keep things easier in the templates.
 		$context['theme_variant'] = '_' . $context['theme_variant'];
 		$context['theme_variant'] = '_' . $context['theme_variant'];
 		$context['theme_variant_url'] = $context['theme_variant'] . '/';
 		$context['theme_variant_url'] = $context['theme_variant'] . '/';
@@ -1841,9 +1842,9 @@ function loadTheme($id_theme = 0, $initialize = true)
 /**
 /**
  * Load a template - if the theme doesn't include it, use the default.
  * Load a template - if the theme doesn't include it, use the default.
  * What this function does:
  * What this function does:
- * * loads a template file with the name template_name from the current, default, or base theme.
- * * detects a wrong default theme directory and tries to work around it.
- * 
+ *  - loads a template file with the name template_name from the current, default, or base theme.
+ *  - detects a wrong default theme directory and tries to work around it.
+ *
  * @uses the template_include() function to include the file.
  * @uses the template_include() function to include the file.
  * @param string $template_name
  * @param string $template_name
  * @param array $style_sheets = array()
  * @param array $style_sheets = array()
@@ -1969,6 +1970,7 @@ function loadSubTemplate($sub_template_name, $fatal = false)
 
 
 /**
 /**
  * Add a CSS file for output later
  * Add a CSS file for output later
+ *
  * @param string $filename
  * @param string $filename
  * @param array $options
  * @param array $options
  */
  */
@@ -1984,6 +1986,7 @@ function loadCSSFile($filename, $options = array())
 
 
 /**
 /**
  * Add a Javascript file for output later
  * Add a Javascript file for output later
+ *
  * @param string $filename
  * @param string $filename
  * @param array $options
  * @param array $options
  */
  */
@@ -2243,14 +2246,13 @@ function getLanguages($use_cache = true, $favor_utf8 = true)
  * What this function does:
  * What this function does:
  *  - it censors the passed string.
  *  - it censors the passed string.
  *  - if the theme setting allow_no_censored is on, and the theme option
  *  - if the theme setting allow_no_censored is on, and the theme option
- *  	  show_no_censored is enabled, does not censor - unless force is set.
+ *    show_no_censored is enabled, does not censor, unless force is also set.
  *  - it caches the list of censored words to reduce parsing.
  *  - it caches the list of censored words to reduce parsing.
- * 
+ *
  * @param string &$text
  * @param string &$text
  * @param bool $force = false
  * @param bool $force = false
  * @return string The censored text
  * @return string The censored text
  */
  */
-// Replace all vulgar words with respective proper words. (substring or whole words..)
 function censorText(&$text, $force = false)
 function censorText(&$text, $force = false)
 {
 {
 	global $modSettings, $options, $settings, $txt;
 	global $modSettings, $options, $settings, $txt;
@@ -2525,7 +2527,6 @@ function loadDatabase()
 
 
 /**
 /**
  * Try to retrieve a cache entry. On failure, call the appropriate function.
  * Try to retrieve a cache entry. On failure, call the appropriate function.
- * @todo find a better place for cache implementation
  *
  *
  * @param string $key
  * @param string $key
  * @param string $file
  * @param string $file
@@ -2542,14 +2543,14 @@ function cache_quick_get($key, $file, $function, $params, $level = 1)
 
 
 	if (function_exists('call_integration_hook'))
 	if (function_exists('call_integration_hook'))
 		call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level));
 		call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level));
-		
+
 	/* Refresh the cache if either:
 	/* Refresh the cache if either:
 		1. Caching is disabled.
 		1. Caching is disabled.
 		2. The cache level isn't high enough.
 		2. The cache level isn't high enough.
 		3. The item has not been cached or the cached item expired.
 		3. The item has not been cached or the cached item expired.
 		4. The cached item has a custom expiration condition evaluating to true.
 		4. The cached item has a custom expiration condition evaluating to true.
 		5. The expire time set in the cache item has passed (needed for Zend).
 		5. The expire time set in the cache item has passed (needed for Zend).
-	*/	
+	*/
 	if (empty($modSettings['cache_enable']) || $modSettings['cache_enable'] < $level || !is_array($cache_block = cache_get_data($key, 3600)) || (!empty($cache_block['refresh_eval']) && eval($cache_block['refresh_eval'])) || (!empty($cache_block['expires']) && $cache_block['expires'] < time()))
 	if (empty($modSettings['cache_enable']) || $modSettings['cache_enable'] < $level || !is_array($cache_block = cache_get_data($key, 3600)) || (!empty($cache_block['refresh_eval']) && eval($cache_block['refresh_eval'])) || (!empty($cache_block['expires']) && $cache_block['expires'] < time()))
 	{
 	{
 		require_once($sourcedir . '/' . $file);
 		require_once($sourcedir . '/' . $file);

+ 2 - 1
Sources/ManagePosts.php

@@ -81,7 +81,7 @@ function ManagePostSettings()
  */
  */
 function SetCensor()
 function SetCensor()
 {
 {
-	global $txt, $modSettings, $context, $smcFunc;
+	global $txt, $modSettings, $context, $smcFunc, $sourcedir;
 
 
 	if (!empty($_POST['save_censor']))
 	if (!empty($_POST['save_censor']))
 	{
 	{
@@ -135,6 +135,7 @@ function SetCensor()
 
 
 	if (isset($_POST['censortest']))
 	if (isset($_POST['censortest']))
 	{
 	{
+		require_once($sourcedir . '/Subs-Post.php');
 		$censorText = htmlspecialchars($_POST['censortest'], ENT_QUOTES);
 		$censorText = htmlspecialchars($_POST['censortest'], ENT_QUOTES);
 		preparsecode($censorText);
 		preparsecode($censorText);
 		$context['censor_test'] = strtr(censorText($censorText), array('"' => '&quot;'));
 		$context['censor_test'] = strtr(censorText($censorText), array('"' => '&quot;'));

+ 1 - 1
Sources/ManageSettings.php

@@ -39,7 +39,7 @@ function loadGeneralSettingParameters($subActions = array(), $defaultAction = ''
 	$context['sub_template'] = 'show_settings';
 	$context['sub_template'] = 'show_settings';
 
 
 	// By default do the basic settings.
 	// By default do the basic settings.
-	$_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : (!empty($defaultAction) ? $defaultAction : array_pop(array_keys($subActions)));
+	$_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : (!empty($defaultAction) ? $defaultAction : array_pop($temp = array_keys($subActions)));
 	$context['sub_action'] = $_REQUEST['sa'];
 	$context['sub_action'] = $_REQUEST['sa'];
 }
 }