@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * The main entrance point for the 'Posts and topics' screen. |
@@ -98,23 +99,23 @@ discard block |
||
| 98 | 99 | { |
| 99 | 100 | $_POST['censortext'] = explode("\n", strtr($_POST['censortext'], array("\r" => ''))); |
| 100 | 101 | |
| 101 | - foreach ($_POST['censortext'] as $c) |
|
| 102 | - list ($censored_vulgar[], $censored_proper[]) = array_pad(explode('=', trim($c)), 2, ''); |
|
| 103 | - } |
|
| 104 | - elseif (isset($_POST['censor_vulgar'], $_POST['censor_proper'])) |
|
| 102 | + foreach ($_POST['censortext'] as $c) { |
|
| 103 | + list ($censored_vulgar[], $censored_proper[]) = array_pad(explode('=', trim($c)), 2, ''); |
|
| 104 | + } |
|
| 105 | + } elseif (isset($_POST['censor_vulgar'], $_POST['censor_proper'])) |
|
| 105 | 106 | { |
| 106 | 107 | if (is_array($_POST['censor_vulgar'])) |
| 107 | 108 | { |
| 108 | 109 | foreach ($_POST['censor_vulgar'] as $i => $value) |
| 109 | 110 | { |
| 110 | - if (trim(strtr($value, '*', ' ')) == '') |
|
| 111 | - unset($_POST['censor_vulgar'][$i], $_POST['censor_proper'][$i]); |
|
| 111 | + if (trim(strtr($value, '*', ' ')) == '') { |
|
| 112 | + unset($_POST['censor_vulgar'][$i], $_POST['censor_proper'][$i]); |
|
| 113 | + } |
|
| 112 | 114 | } |
| 113 | 115 | |
| 114 | 116 | $censored_vulgar = $_POST['censor_vulgar']; |
| 115 | 117 | $censored_proper = $_POST['censor_proper']; |
| 116 | - } |
|
| 117 | - else |
|
| 118 | + } else |
|
| 118 | 119 | { |
| 119 | 120 | $censored_vulgar = explode("\n", strtr($_POST['censor_vulgar'], array("\r" => ''))); |
| 120 | 121 | $censored_proper = explode("\n", strtr($_POST['censor_proper'], array("\r" => ''))); |
@@ -151,12 +152,14 @@ discard block |
||
| 151 | 152 | $context['censored_words'] = array(); |
| 152 | 153 | for ($i = 0, $n = count($censor_vulgar); $i < $n; $i++) |
| 153 | 154 | { |
| 154 | - if (empty($censor_vulgar[$i])) |
|
| 155 | - continue; |
|
| 155 | + if (empty($censor_vulgar[$i])) { |
|
| 156 | + continue; |
|
| 157 | + } |
|
| 156 | 158 | |
| 157 | 159 | // Skip it, it's either spaces or stars only. |
| 158 | - if (trim(strtr($censor_vulgar[$i], '*', ' ')) == '') |
|
| 159 | - continue; |
|
| 160 | + if (trim(strtr($censor_vulgar[$i], '*', ' ')) == '') { |
|
| 161 | + continue; |
|
| 162 | + } |
|
| 160 | 163 | |
| 161 | 164 | $context['censored_words'][$smcFunc['htmlspecialchars'](trim($censor_vulgar[$i]))] = isset($censor_proper[$i]) ? $smcFunc['htmlspecialchars']($censor_proper[$i]) : ''; |
| 162 | 165 | } |
@@ -187,10 +190,11 @@ discard block |
||
| 187 | 190 | |
| 188 | 191 | // Make an inline conditional a little shorter... |
| 189 | 192 | $can_spell_check = false; |
| 190 | - if (function_exists('pspell_new')) |
|
| 191 | - $can_spell_check = true; |
|
| 192 | - elseif (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv'))) |
|
| 193 | - $can_spell_check = true; |
|
| 193 | + if (function_exists('pspell_new')) { |
|
| 194 | + $can_spell_check = true; |
|
| 195 | + } elseif (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv'))) { |
|
| 196 | + $can_spell_check = true; |
|
| 197 | + } |
|
| 194 | 198 | |
| 195 | 199 | // All the settings... |
| 196 | 200 | $config_vars = array( |
@@ -221,8 +225,9 @@ discard block |
||
| 221 | 225 | |
| 222 | 226 | call_integration_hook('integrate_modify_post_settings', array(&$config_vars)); |
| 223 | 227 | |
| 224 | - if ($return_config) |
|
| 225 | - return $config_vars; |
|
| 228 | + if ($return_config) { |
|
| 229 | + return $config_vars; |
|
| 230 | + } |
|
| 226 | 231 | |
| 227 | 232 | // We'll want this for our easy save. |
| 228 | 233 | require_once($sourcedir . '/ManageServer.php'); |
@@ -242,17 +247,20 @@ discard block |
||
| 242 | 247 | db_extend('packages'); |
| 243 | 248 | |
| 244 | 249 | $colData = $smcFunc['db_list_columns']('{db_prefix}messages', true); |
| 245 | - foreach ($colData as $column) |
|
| 246 | - if ($column['name'] == 'body') |
|
| 250 | + foreach ($colData as $column) { |
|
| 251 | + if ($column['name'] == 'body') |
|
| 247 | 252 | $body_type = $column['type']; |
| 253 | + } |
|
| 248 | 254 | |
| 249 | - if (isset($body_type) && ($_POST['max_messageLength'] > 65535 || $_POST['max_messageLength'] == 0) && $body_type == 'text') |
|
| 250 | - fatal_lang_error('convert_to_mediumtext', false, array($scripturl . '?action=admin;area=maintain;sa=database')); |
|
| 255 | + if (isset($body_type) && ($_POST['max_messageLength'] > 65535 || $_POST['max_messageLength'] == 0) && $body_type == 'text') { |
|
| 256 | + fatal_lang_error('convert_to_mediumtext', false, array($scripturl . '?action=admin;area=maintain;sa=database')); |
|
| 257 | + } |
|
| 251 | 258 | } |
| 252 | 259 | |
| 253 | 260 | // If we're changing the post preview length let's check its valid |
| 254 | - if (!empty($_POST['preview_characters'])) |
|
| 255 | - $_POST['preview_characters'] = (int) min(max(0, $_POST['preview_characters']), 512); |
|
| 261 | + if (!empty($_POST['preview_characters'])) { |
|
| 262 | + $_POST['preview_characters'] = (int) min(max(0, $_POST['preview_characters']), 512); |
|
| 263 | + } |
|
| 256 | 264 | |
| 257 | 265 | call_integration_hook('integrate_save_post_settings'); |
| 258 | 266 | |
@@ -313,8 +321,9 @@ discard block |
||
| 313 | 321 | |
| 314 | 322 | call_integration_hook('integrate_modify_topic_settings', array(&$config_vars)); |
| 315 | 323 | |
| 316 | - if ($return_config) |
|
| 317 | - return $config_vars; |
|
| 324 | + if ($return_config) { |
|
| 325 | + return $config_vars; |
|
| 326 | + } |
|
| 318 | 327 | |
| 319 | 328 | // Get the settings template ready. |
| 320 | 329 | require_once($sourcedir . '/ManageServer.php'); |
@@ -367,8 +376,9 @@ discard block |
||
| 367 | 376 | array('int', 'drafts_autosave_frequency', 'postinput' => $txt['manageposts_seconds'], 'subtext' => $txt['drafts_autosave_frequency_subnote']), |
| 368 | 377 | ); |
| 369 | 378 | |
| 370 | - if ($return_config) |
|
| 371 | - return $config_vars; |
|
| 379 | + if ($return_config) { |
|
| 380 | + return $config_vars; |
|
| 381 | + } |
|
| 372 | 382 | |
| 373 | 383 | // Get the settings template ready. |
| 374 | 384 | require_once($sourcedir . '/ManageServer.php'); |
@@ -15,8 +15,9 @@ discard block |
||
| 15 | 15 | * @version 2.1 Beta 3 |
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | -if (!defined('SMF')) |
|
| 18 | +if (!defined('SMF')) { |
|
| 19 | 19 | die('No direct access...'); |
| 20 | +} |
|
| 20 | 21 | |
| 21 | 22 | /** |
| 22 | 23 | * Log an error, if the error logging is enabled. |
@@ -36,8 +37,9 @@ discard block |
||
| 36 | 37 | static $tried_hook = false; |
| 37 | 38 | |
| 38 | 39 | // Check if error logging is actually on. |
| 39 | - if (empty($modSettings['enableErrorLogging'])) |
|
| 40 | - return $error_message; |
|
| 40 | + if (empty($modSettings['enableErrorLogging'])) { |
|
| 41 | + return $error_message; |
|
| 42 | + } |
|
| 41 | 43 | |
| 42 | 44 | // Basically, htmlspecialchars it minus &. (for entities!) |
| 43 | 45 | $error_message = strtr($error_message, array('<' => '<', '>' => '>', '"' => '"')); |
@@ -45,22 +47,26 @@ discard block |
||
| 45 | 47 | |
| 46 | 48 | // Add a file and line to the error message? |
| 47 | 49 | // Don't use the actual txt entries for file and line but instead use %1$s for file and %2$s for line |
| 48 | - if ($file == null) |
|
| 49 | - $file = ''; |
|
| 50 | - else |
|
| 51 | - // Window style slashes don't play well, lets convert them to the unix style. |
|
| 50 | + if ($file == null) { |
|
| 51 | + $file = ''; |
|
| 52 | + } else { |
|
| 53 | + // Window style slashes don't play well, lets convert them to the unix style. |
|
| 52 | 54 | $file = str_replace('\\', '/', $file); |
| 55 | + } |
|
| 53 | 56 | |
| 54 | - if ($line == null) |
|
| 55 | - $line = 0; |
|
| 56 | - else |
|
| 57 | - $line = (int) $line; |
|
| 57 | + if ($line == null) { |
|
| 58 | + $line = 0; |
|
| 59 | + } else { |
|
| 60 | + $line = (int) $line; |
|
| 61 | + } |
|
| 58 | 62 | |
| 59 | 63 | // Just in case there's no id_member or IP set yet. |
| 60 | - if (empty($user_info['id'])) |
|
| 61 | - $user_info['id'] = 0; |
|
| 62 | - if (empty($user_info['ip'])) |
|
| 63 | - $user_info['ip'] = ''; |
|
| 64 | + if (empty($user_info['id'])) { |
|
| 65 | + $user_info['id'] = 0; |
|
| 66 | + } |
|
| 67 | + if (empty($user_info['ip'])) { |
|
| 68 | + $user_info['ip'] = ''; |
|
| 69 | + } |
|
| 64 | 70 | |
| 65 | 71 | // Find the best query string we can... |
| 66 | 72 | $query_string = empty($_SERVER['QUERY_STRING']) ? (empty($_SERVER['REQUEST_URL']) ? '' : str_replace($scripturl, '', $_SERVER['REQUEST_URL'])) : $_SERVER['QUERY_STRING']; |
@@ -69,8 +75,9 @@ discard block |
||
| 69 | 75 | $query_string = $smcFunc['htmlspecialchars']((SMF == 'SSI' || SMF == 'BACKGROUND' ? '' : '?') . preg_replace(array('~;sesc=[^&;]+~', '~' . session_name() . '=' . session_id() . '[&;]~'), array(';sesc', ''), $query_string)); |
| 70 | 76 | |
| 71 | 77 | // Just so we know what board error messages are from. |
| 72 | - if (isset($_POST['board']) && !isset($_GET['board'])) |
|
| 73 | - $query_string .= ($query_string == '' ? 'board=' : ';board=') . $_POST['board']; |
|
| 78 | + if (isset($_POST['board']) && !isset($_GET['board'])) { |
|
| 79 | + $query_string .= ($query_string == '' ? 'board=' : ';board=') . $_POST['board']; |
|
| 80 | + } |
|
| 74 | 81 | |
| 75 | 82 | // What types of categories do we have? |
| 76 | 83 | $known_error_types = array( |
@@ -132,12 +139,14 @@ discard block |
||
| 132 | 139 | global $txt; |
| 133 | 140 | |
| 134 | 141 | // Send the appropriate HTTP status header - set this to 0 or false if you don't want to send one at all |
| 135 | - if (!empty($status)) |
|
| 136 | - send_http_status($status); |
|
| 142 | + if (!empty($status)) { |
|
| 143 | + send_http_status($status); |
|
| 144 | + } |
|
| 137 | 145 | |
| 138 | 146 | // We don't have $txt yet, but that's okay... |
| 139 | - if (empty($txt)) |
|
| 140 | - die($error); |
|
| 147 | + if (empty($txt)) { |
|
| 148 | + die($error); |
|
| 149 | + } |
|
| 141 | 150 | |
| 142 | 151 | log_error_online($error, false); |
| 143 | 152 | setup_fatal_error_context($log ? log_error($error, $log) : $error); |
@@ -164,8 +173,9 @@ discard block |
||
| 164 | 173 | static $fatal_error_called = false; |
| 165 | 174 | |
| 166 | 175 | // Send the status header - set this to 0 or false if you don't want to send one at all |
| 167 | - if (!empty($status)) |
|
| 168 | - send_http_status($status); |
|
| 176 | + if (!empty($status)) { |
|
| 177 | + send_http_status($status); |
|
| 178 | + } |
|
| 169 | 179 | |
| 170 | 180 | // Try to load a theme if we don't have one. |
| 171 | 181 | if (empty($context['theme_loaded']) && empty($fatal_error_called)) |
@@ -175,8 +185,9 @@ discard block |
||
| 175 | 185 | } |
| 176 | 186 | |
| 177 | 187 | // If we have no theme stuff we can't have the language file... |
| 178 | - if (empty($context['theme_loaded'])) |
|
| 179 | - die($error); |
|
| 188 | + if (empty($context['theme_loaded'])) { |
|
| 189 | + die($error); |
|
| 190 | + } |
|
| 180 | 191 | |
| 181 | 192 | $reload_lang_file = true; |
| 182 | 193 | // Log the error in the forum's language, but don't waste the time if we aren't logging |
@@ -212,8 +223,9 @@ discard block |
||
| 212 | 223 | global $settings, $modSettings, $db_show_debug; |
| 213 | 224 | |
| 214 | 225 | // Ignore errors if we're ignoring them or they are strict notices from PHP 5 (which cannot be solved without breaking PHP 4.) |
| 215 | - if (error_reporting() == 0 || (defined('E_STRICT') && $error_level == E_STRICT && !empty($modSettings['enableErrorLogging']))) |
|
| 216 | - return; |
|
| 226 | + if (error_reporting() == 0 || (defined('E_STRICT') && $error_level == E_STRICT && !empty($modSettings['enableErrorLogging']))) { |
|
| 227 | + return; |
|
| 228 | + } |
|
| 217 | 229 | |
| 218 | 230 | if (strpos($file, 'eval()') !== false && !empty($settings['current_include_filename'])) |
| 219 | 231 | { |
@@ -221,19 +233,22 @@ discard block |
||
| 221 | 233 | $count = count($array); |
| 222 | 234 | for ($i = 0; $i < $count; $i++) |
| 223 | 235 | { |
| 224 | - if ($array[$i]['function'] != 'loadSubTemplate') |
|
| 225 | - continue; |
|
| 236 | + if ($array[$i]['function'] != 'loadSubTemplate') { |
|
| 237 | + continue; |
|
| 238 | + } |
|
| 226 | 239 | |
| 227 | 240 | // This is a bug in PHP, with eval, it seems! |
| 228 | - if (empty($array[$i]['args'])) |
|
| 229 | - $i++; |
|
| 241 | + if (empty($array[$i]['args'])) { |
|
| 242 | + $i++; |
|
| 243 | + } |
|
| 230 | 244 | break; |
| 231 | 245 | } |
| 232 | 246 | |
| 233 | - if (isset($array[$i]) && !empty($array[$i]['args'])) |
|
| 234 | - $file = realpath($settings['current_include_filename']) . ' (' . $array[$i]['args'][0] . ' sub template - eval?)'; |
|
| 235 | - else |
|
| 236 | - $file = realpath($settings['current_include_filename']) . ' (eval?)'; |
|
| 247 | + if (isset($array[$i]) && !empty($array[$i]['args'])) { |
|
| 248 | + $file = realpath($settings['current_include_filename']) . ' (' . $array[$i]['args'][0] . ' sub template - eval?)'; |
|
| 249 | + } else { |
|
| 250 | + $file = realpath($settings['current_include_filename']) . ' (eval?)'; |
|
| 251 | + } |
|
| 237 | 252 | } |
| 238 | 253 | |
| 239 | 254 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -242,8 +257,9 @@ discard block |
||
| 242 | 257 | if ($error_level % 255 != E_ERROR) |
| 243 | 258 | { |
| 244 | 259 | $temporary = ob_get_contents(); |
| 245 | - if (substr($temporary, -2) == '="') |
|
| 246 | - echo '"'; |
|
| 260 | + if (substr($temporary, -2) == '="') { |
|
| 261 | + echo '"'; |
|
| 262 | + } |
|
| 247 | 263 | } |
| 248 | 264 | |
| 249 | 265 | // Debugging! This should look like a PHP error message. |
@@ -259,23 +275,27 @@ discard block |
||
| 259 | 275 | call_integration_hook('integrate_output_error', array($message, $error_type, $error_level, $file, $line)); |
| 260 | 276 | |
| 261 | 277 | // Dying on these errors only causes MORE problems (blank pages!) |
| 262 | - if ($file == 'Unknown') |
|
| 263 | - return; |
|
| 278 | + if ($file == 'Unknown') { |
|
| 279 | + return; |
|
| 280 | + } |
|
| 264 | 281 | |
| 265 | 282 | // If this is an E_ERROR or E_USER_ERROR.... die. Violently so. |
| 266 | - if ($error_level % 255 == E_ERROR) |
|
| 267 | - obExit(false); |
|
| 268 | - else |
|
| 269 | - return; |
|
| 283 | + if ($error_level % 255 == E_ERROR) { |
|
| 284 | + obExit(false); |
|
| 285 | + } else { |
|
| 286 | + return; |
|
| 287 | + } |
|
| 270 | 288 | |
| 271 | 289 | // If this is an E_ERROR, E_USER_ERROR, E_WARNING, or E_USER_WARNING.... die. Violently so. |
| 272 | - if ($error_level % 255 == E_ERROR || $error_level % 255 == E_WARNING) |
|
| 273 | - fatal_error(allowedTo('admin_forum') ? $message : $error_string, false); |
|
| 290 | + if ($error_level % 255 == E_ERROR || $error_level % 255 == E_WARNING) { |
|
| 291 | + fatal_error(allowedTo('admin_forum') ? $message : $error_string, false); |
|
| 292 | + } |
|
| 274 | 293 | |
| 275 | 294 | // We should NEVER get to this point. Any fatal error MUST quit, or very bad things can happen. |
| 276 | - if ($error_level % 255 == E_ERROR) |
|
| 277 | - die('No direct access...'); |
|
| 278 | -} |
|
| 295 | + if ($error_level % 255 == E_ERROR) { |
|
| 296 | + die('No direct access...'); |
|
| 297 | + } |
|
| 298 | + } |
|
| 279 | 299 | |
| 280 | 300 | /** |
| 281 | 301 | * It is called by {@link fatal_error()} and {@link fatal_lang_error()}. |
@@ -291,24 +311,28 @@ discard block |
||
| 291 | 311 | |
| 292 | 312 | // Attempt to prevent a recursive loop. |
| 293 | 313 | ++$level; |
| 294 | - if ($level > 1) |
|
| 295 | - return false; |
|
| 314 | + if ($level > 1) { |
|
| 315 | + return false; |
|
| 316 | + } |
|
| 296 | 317 | |
| 297 | 318 | // Maybe they came from dlattach or similar? |
| 298 | - if (SMF != 'SSI' && SMF != 'BACKGROUND' && empty($context['theme_loaded'])) |
|
| 299 | - loadTheme(); |
|
| 319 | + if (SMF != 'SSI' && SMF != 'BACKGROUND' && empty($context['theme_loaded'])) { |
|
| 320 | + loadTheme(); |
|
| 321 | + } |
|
| 300 | 322 | |
| 301 | 323 | // Don't bother indexing errors mate... |
| 302 | 324 | $context['robot_no_index'] = true; |
| 303 | 325 | |
| 304 | - if (!isset($context['error_title'])) |
|
| 305 | - $context['error_title'] = $txt['error_occured']; |
|
| 326 | + if (!isset($context['error_title'])) { |
|
| 327 | + $context['error_title'] = $txt['error_occured']; |
|
| 328 | + } |
|
| 306 | 329 | $context['error_message'] = isset($context['error_message']) ? $context['error_message'] : $error_message; |
| 307 | 330 | |
| 308 | 331 | $context['error_code'] = isset($error_code) ? 'id="' . $error_code . '" ' : ''; |
| 309 | 332 | |
| 310 | - if (empty($context['page_title'])) |
|
| 311 | - $context['page_title'] = $context['error_title']; |
|
| 333 | + if (empty($context['page_title'])) { |
|
| 334 | + $context['page_title'] = $context['error_title']; |
|
| 335 | + } |
|
| 312 | 336 | |
| 313 | 337 | loadTemplate('Errors'); |
| 314 | 338 | $context['sub_template'] = 'fatal_error'; |
@@ -316,23 +340,26 @@ discard block |
||
| 316 | 340 | // If this is SSI, what do they want us to do? |
| 317 | 341 | if (SMF == 'SSI') |
| 318 | 342 | { |
| 319 | - if (!empty($ssi_on_error_method) && $ssi_on_error_method !== true && is_callable($ssi_on_error_method)) |
|
| 320 | - $ssi_on_error_method(); |
|
| 321 | - elseif (empty($ssi_on_error_method) || $ssi_on_error_method !== true) |
|
| 322 | - loadSubTemplate('fatal_error'); |
|
| 343 | + if (!empty($ssi_on_error_method) && $ssi_on_error_method !== true && is_callable($ssi_on_error_method)) { |
|
| 344 | + $ssi_on_error_method(); |
|
| 345 | + } elseif (empty($ssi_on_error_method) || $ssi_on_error_method !== true) { |
|
| 346 | + loadSubTemplate('fatal_error'); |
|
| 347 | + } |
|
| 323 | 348 | |
| 324 | 349 | // No layers? |
| 325 | - if (empty($ssi_on_error_method) || $ssi_on_error_method !== true) |
|
| 326 | - exit; |
|
| 350 | + if (empty($ssi_on_error_method) || $ssi_on_error_method !== true) { |
|
| 351 | + exit; |
|
| 352 | + } |
|
| 327 | 353 | } |
| 328 | 354 | // Alternatively from the cron call? |
| 329 | 355 | elseif (SMF == 'BACKGROUND') |
| 330 | 356 | { |
| 331 | 357 | // We can't rely on even having language files available. |
| 332 | - if (defined('FROM_CLI') && FROM_CLI) |
|
| 333 | - echo 'cron error: ', $context['error_message']; |
|
| 334 | - else |
|
| 335 | - echo 'An error occurred. More information may be available in your logs.'; |
|
| 358 | + if (defined('FROM_CLI') && FROM_CLI) { |
|
| 359 | + echo 'cron error: ', $context['error_message']; |
|
| 360 | + } else { |
|
| 361 | + echo 'An error occurred. More information may be available in your logs.'; |
|
| 362 | + } |
|
| 336 | 363 | exit; |
| 337 | 364 | } |
| 338 | 365 | |
@@ -360,8 +387,8 @@ discard block |
||
| 360 | 387 | |
| 361 | 388 | set_fatal_error_headers(); |
| 362 | 389 | |
| 363 | - if (!empty($maintenance)) |
|
| 364 | - echo '<!DOCTYPE html> |
|
| 390 | + if (!empty($maintenance)) { |
|
| 391 | + echo '<!DOCTYPE html> |
|
| 365 | 392 | <html> |
| 366 | 393 | <head> |
| 367 | 394 | <meta name="robots" content="noindex"> |
@@ -372,6 +399,7 @@ discard block |
||
| 372 | 399 | ', $mmessage, ' |
| 373 | 400 | </body> |
| 374 | 401 | </html>'; |
| 402 | + } |
|
| 375 | 403 | |
| 376 | 404 | die(); |
| 377 | 405 | } |
@@ -393,15 +421,17 @@ discard block |
||
| 393 | 421 | // For our purposes, we're gonna want this on if at all possible. |
| 394 | 422 | $modSettings['cache_enable'] = '1'; |
| 395 | 423 | |
| 396 | - if (($temp = cache_get_data('db_last_error', 600)) !== null) |
|
| 397 | - $db_last_error = max($db_last_error, $temp); |
|
| 424 | + if (($temp = cache_get_data('db_last_error', 600)) !== null) { |
|
| 425 | + $db_last_error = max($db_last_error, $temp); |
|
| 426 | + } |
|
| 398 | 427 | |
| 399 | 428 | if ($db_last_error < time() - 3600 * 24 * 3 && empty($maintenance) && !empty($db_error_send)) |
| 400 | 429 | { |
| 401 | 430 | // Avoid writing to the Settings.php file if at all possible; use shared memory instead. |
| 402 | 431 | cache_put_data('db_last_error', time(), 600); |
| 403 | - if (($temp = cache_get_data('db_last_error', 600)) === null) |
|
| 404 | - logLastDatabaseError(); |
|
| 432 | + if (($temp = cache_get_data('db_last_error', 600)) === null) { |
|
| 433 | + logLastDatabaseError(); |
|
| 434 | + } |
|
| 405 | 435 | |
| 406 | 436 | // Language files aren't loaded yet :(. |
| 407 | 437 | $db_error = @$smcFunc['db_error']($db_connection); |
@@ -482,12 +512,14 @@ discard block |
||
| 482 | 512 | global $smcFunc, $user_info, $modSettings; |
| 483 | 513 | |
| 484 | 514 | // Don't bother if Who's Online is disabled. |
| 485 | - if (empty($modSettings['who_enabled'])) |
|
| 486 | - return; |
|
| 515 | + if (empty($modSettings['who_enabled'])) { |
|
| 516 | + return; |
|
| 517 | + } |
|
| 487 | 518 | |
| 488 | 519 | // Maybe they came from SSI or similar where sessions are not recorded? |
| 489 | - if (SMF == 'SSI' || SMF == 'BACKGROUND') |
|
| 490 | - return; |
|
| 520 | + if (SMF == 'SSI' || SMF == 'BACKGROUND') { |
|
| 521 | + return; |
|
| 522 | + } |
|
| 491 | 523 | |
| 492 | 524 | $session_id = $user_info['is_guest'] ? 'ip' . $user_info['ip'] : session_id(); |
| 493 | 525 | |
@@ -506,8 +538,9 @@ discard block |
||
| 506 | 538 | $url = smf_json_decode($url, true); |
| 507 | 539 | $url['error'] = $error; |
| 508 | 540 | |
| 509 | - if (!empty($sprintf)) |
|
| 510 | - $url['error_params'] = $sprintf; |
|
| 541 | + if (!empty($sprintf)) { |
|
| 542 | + $url['error_params'] = $sprintf; |
|
| 543 | + } |
|
| 511 | 544 | |
| 512 | 545 | $smcFunc['db_query']('', ' |
| 513 | 546 | UPDATE {db_prefix}log_online |
@@ -538,10 +571,11 @@ discard block |
||
| 538 | 571 | |
| 539 | 572 | $protocol = preg_match('~HTTP/1\.[01]~i', $_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0'; |
| 540 | 573 | |
| 541 | - if (!isset($statuses[$code])) |
|
| 542 | - header($protocol . ' 500 Internal Server Error'); |
|
| 543 | - else |
|
| 544 | - header($protocol . ' ' . $code . ' ' . $statuses[$code]); |
|
| 545 | -} |
|
| 574 | + if (!isset($statuses[$code])) { |
|
| 575 | + header($protocol . ' 500 Internal Server Error'); |
|
| 576 | + } else { |
|
| 577 | + header($protocol . ' ' . $code . ' ' . $statuses[$code]); |
|
| 578 | + } |
|
| 579 | + } |
|
| 546 | 580 | |
| 547 | 581 | ?> |
| 548 | 582 | \ No newline at end of file |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Add the file functions to the $smcFunc array. |
@@ -23,14 +24,15 @@ discard block |
||
| 23 | 24 | { |
| 24 | 25 | global $smcFunc; |
| 25 | 26 | |
| 26 | - if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_query') |
|
| 27 | - $smcFunc += array( |
|
| 27 | + if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_query') { |
|
| 28 | + $smcFunc += array( |
|
| 28 | 29 | 'db_search_query' => 'smf_db_query', |
| 29 | 30 | 'db_search_support' => 'smf_db_search_support', |
| 30 | 31 | 'db_create_word_search' => 'smf_db_create_word_search', |
| 31 | 32 | 'db_support_ignore' => true, |
| 32 | 33 | ); |
| 33 | -} |
|
| 34 | + } |
|
| 35 | + } |
|
| 34 | 36 | |
| 35 | 37 | /** |
| 36 | 38 | * This function will tell you whether this database type supports this search type. |
@@ -54,12 +56,13 @@ discard block |
||
| 54 | 56 | { |
| 55 | 57 | global $smcFunc; |
| 56 | 58 | |
| 57 | - if ($size == 'small') |
|
| 58 | - $size = 'smallint(5)'; |
|
| 59 | - elseif ($size == 'medium') |
|
| 60 | - $size = 'mediumint(8)'; |
|
| 61 | - else |
|
| 62 | - $size = 'int(10)'; |
|
| 59 | + if ($size == 'small') { |
|
| 60 | + $size = 'smallint(5)'; |
|
| 61 | + } elseif ($size == 'medium') { |
|
| 62 | + $size = 'mediumint(8)'; |
|
| 63 | + } else { |
|
| 64 | + $size = 'int(10)'; |
|
| 65 | + } |
|
| 63 | 66 | |
| 64 | 67 | $smcFunc['db_query']('', ' |
| 65 | 68 | CREATE TABLE {db_prefix}log_search_words ( |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 3 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Turn off/on notification for a particular board. |
@@ -34,8 +35,9 @@ discard block |
||
| 34 | 35 | is_not_guest(); |
| 35 | 36 | |
| 36 | 37 | // You have to specify a board to turn notifications on! |
| 37 | - if (empty($board)) |
|
| 38 | - fatal_lang_error('no_board', false); |
|
| 38 | + if (empty($board)) { |
|
| 39 | + fatal_lang_error('no_board', false); |
|
| 40 | + } |
|
| 39 | 41 | |
| 40 | 42 | // No subaction: find out what to do. |
| 41 | 43 | if (isset($_GET['mode'])) |
@@ -48,16 +50,16 @@ discard block |
||
| 48 | 50 | require_once($sourcedir . '/Subs-Notify.php'); |
| 49 | 51 | setNotifyPrefs($user_info['id'], array('board_notify_' . $board => $alertPref)); |
| 50 | 52 | |
| 51 | - if ($mode > 1) |
|
| 52 | - // Turn notification on. (note this just blows smoke if it's already on.) |
|
| 53 | + if ($mode > 1) { |
|
| 54 | + // Turn notification on. (note this just blows smoke if it's already on.) |
|
| 53 | 55 | $smcFunc['db_insert']('ignore', |
| 54 | 56 | '{db_prefix}log_notify', |
| 55 | 57 | array('id_member' => 'int', 'id_board' => 'int'), |
| 56 | 58 | array($user_info['id'], $board), |
| 57 | 59 | array('id_member', 'id_board') |
| 58 | 60 | ); |
| 59 | - else |
|
| 60 | - $smcFunc['db_query']('', ' |
|
| 61 | + } else { |
|
| 62 | + $smcFunc['db_query']('', ' |
|
| 61 | 63 | DELETE FROM {db_prefix}log_notify |
| 62 | 64 | WHERE id_member = {int:current_member} |
| 63 | 65 | AND id_board = {int:current_board}', |
@@ -66,6 +68,7 @@ discard block |
||
| 66 | 68 | 'current_member' => $user_info['id'], |
| 67 | 69 | ) |
| 68 | 70 | ); |
| 71 | + } |
|
| 69 | 72 | |
| 70 | 73 | } |
| 71 | 74 | |
@@ -81,10 +84,10 @@ discard block |
||
| 81 | 84 | ), |
| 82 | 85 | ); |
| 83 | 86 | $context['sub_template'] = 'generic_xml'; |
| 87 | + } else { |
|
| 88 | + redirectexit('board=' . $board . '.' . $_REQUEST['start']); |
|
| 89 | + } |
|
| 84 | 90 | } |
| 85 | - else |
|
| 86 | - redirectexit('board=' . $board . '.' . $_REQUEST['start']); |
|
| 87 | -} |
|
| 88 | 91 | |
| 89 | 92 | /** |
| 90 | 93 | * Turn off/on unread replies subscription for a topic as well as sets individual topic's alert preferences |
@@ -108,8 +111,9 @@ discard block |
||
| 108 | 111 | $mode = (int) $_GET['mode']; |
| 109 | 112 | $alertPref = $mode <= 1 ? 0 : ($mode == 2 ? 1 : 3); |
| 110 | 113 | |
| 111 | - if (empty($mode)) |
|
| 112 | - $mode = 1; |
|
| 114 | + if (empty($mode)) { |
|
| 115 | + $mode = 1; |
|
| 116 | + } |
|
| 113 | 117 | |
| 114 | 118 | $request = $smcFunc['db_query']('', ' |
| 115 | 119 | SELECT id_member, id_topic, id_msg, unwatched |
@@ -132,8 +136,7 @@ discard block |
||
| 132 | 136 | 'id_msg' => 0, |
| 133 | 137 | 'unwatched' => empty($mode) ? 1 : 0, |
| 134 | 138 | ); |
| 135 | - } |
|
| 136 | - else |
|
| 139 | + } else |
|
| 137 | 140 | { |
| 138 | 141 | $insert = false; |
| 139 | 142 | $log['unwatched'] = empty($mode) ? 1 : 0; |
@@ -160,9 +163,8 @@ discard block |
||
| 160 | 163 | array($user_info['id'], $log['id_topic']), |
| 161 | 164 | array('id_member', 'id_board') |
| 162 | 165 | ); |
| 163 | - } |
|
| 164 | - else |
|
| 165 | - $smcFunc['db_query']('', ' |
|
| 166 | + } else { |
|
| 167 | + $smcFunc['db_query']('', ' |
|
| 166 | 168 | DELETE FROM {db_prefix}log_notify |
| 167 | 169 | WHERE id_topic = {int:topic} |
| 168 | 170 | AND id_member = {int:member}', |
@@ -170,6 +172,7 @@ discard block |
||
| 170 | 172 | 'topic' => $log['id_topic'], |
| 171 | 173 | 'member' => $user_info['id'], |
| 172 | 174 | )); |
| 175 | + } |
|
| 173 | 176 | |
| 174 | 177 | } |
| 175 | 178 | } |
@@ -186,9 +189,9 @@ discard block |
||
| 186 | 189 | ), |
| 187 | 190 | ); |
| 188 | 191 | $context['sub_template'] = 'generic_xml'; |
| 192 | + } else { |
|
| 193 | + redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
| 194 | + } |
|
| 189 | 195 | } |
| 190 | - else |
|
| 191 | - redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
| 192 | -} |
|
| 193 | 196 | |
| 194 | 197 | ?> |
| 195 | 198 | \ No newline at end of file |
@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 3 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('Hacking attempt...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Our Cache API class |
@@ -29,8 +30,9 @@ discard block |
||
| 29 | 30 | |
| 30 | 31 | $supported = function_exists('zend_shm_cache_fetch') || function_exists('output_cache_get'); |
| 31 | 32 | |
| 32 | - if ($test) |
|
| 33 | - return $supported; |
|
| 33 | + if ($test) { |
|
| 34 | + return $supported; |
|
| 35 | + } |
|
| 34 | 36 | return parent::isSupported() && $supported; |
| 35 | 37 | } |
| 36 | 38 | |
@@ -42,10 +44,11 @@ discard block |
||
| 42 | 44 | $key = $this->prefix . strtr($key, ':/', '-_'); |
| 43 | 45 | |
| 44 | 46 | // Zend's pricey stuff. |
| 45 | - if (function_exists('zend_shm_cache_fetch')) |
|
| 46 | - return zend_shm_cache_fetch('SMF::' . $key); |
|
| 47 | - elseif (function_exists('output_cache_get')) |
|
| 48 | - return output_cache_get($key, $ttl); |
|
| 47 | + if (function_exists('zend_shm_cache_fetch')) { |
|
| 48 | + return zend_shm_cache_fetch('SMF::' . $key); |
|
| 49 | + } elseif (function_exists('output_cache_get')) { |
|
| 50 | + return output_cache_get($key, $ttl); |
|
| 51 | + } |
|
| 49 | 52 | } |
| 50 | 53 | |
| 51 | 54 | /** |
@@ -55,10 +58,11 @@ discard block |
||
| 55 | 58 | { |
| 56 | 59 | $key = $this->prefix . strtr($key, ':/', '-_'); |
| 57 | 60 | |
| 58 | - if (function_exists('zend_shm_cache_store')) |
|
| 59 | - return zend_shm_cache_store('SMF::' . $key, $value, $ttl); |
|
| 60 | - elseif (function_exists('output_cache_put')) |
|
| 61 | - return output_cache_put($key, $value); |
|
| 61 | + if (function_exists('zend_shm_cache_store')) { |
|
| 62 | + return zend_shm_cache_store('SMF::' . $key, $value, $ttl); |
|
| 63 | + } elseif (function_exists('output_cache_put')) { |
|
| 64 | + return output_cache_put($key, $value); |
|
| 65 | + } |
|
| 62 | 66 | } |
| 63 | 67 | |
| 64 | 68 | /** |
@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 3 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('No direct access...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Used for the "custom search index" option |
@@ -54,8 +55,9 @@ discard block |
||
| 54 | 55 | return; |
| 55 | 56 | } |
| 56 | 57 | |
| 57 | - if (empty($modSettings['search_custom_index_config'])) |
|
| 58 | - return; |
|
| 58 | + if (empty($modSettings['search_custom_index_config'])) { |
|
| 59 | + return; |
|
| 60 | + } |
|
| 59 | 61 | |
| 60 | 62 | $this->indexSettings = smf_json_decode($modSettings['search_custom_index_config'], true); |
| 61 | 63 | |
@@ -118,21 +120,23 @@ discard block |
||
| 118 | 120 | |
| 119 | 121 | $subwords = text2words($word, $this->min_word_length, true); |
| 120 | 122 | |
| 121 | - if (empty($modSettings['search_force_index'])) |
|
| 122 | - $wordsSearch['words'][] = $word; |
|
| 123 | + if (empty($modSettings['search_force_index'])) { |
|
| 124 | + $wordsSearch['words'][] = $word; |
|
| 125 | + } |
|
| 123 | 126 | |
| 124 | 127 | // Excluded phrases don't benefit from being split into subwords. |
| 125 | - if (count($subwords) > 1 && $isExcluded) |
|
| 126 | - return; |
|
| 127 | - else |
|
| 128 | + if (count($subwords) > 1 && $isExcluded) { |
|
| 129 | + return; |
|
| 130 | + } else |
|
| 128 | 131 | { |
| 129 | 132 | foreach ($subwords as $subword) |
| 130 | 133 | { |
| 131 | 134 | if ($smcFunc['strlen']($subword) >= $this->min_word_length && !in_array($subword, $this->bannedWords)) |
| 132 | 135 | { |
| 133 | 136 | $wordsSearch['indexed_words'][] = $subword; |
| 134 | - if ($isExcluded) |
|
| 135 | - $wordsExclude[] = $subword; |
|
| 137 | + if ($isExcluded) { |
|
| 138 | + $wordsExclude[] = $subword; |
|
| 139 | + } |
|
| 136 | 140 | } |
| 137 | 141 | } |
| 138 | 142 | } |
@@ -153,8 +157,9 @@ discard block |
||
| 153 | 157 | $query_where = array(); |
| 154 | 158 | $query_params = $search_data['params']; |
| 155 | 159 | |
| 156 | - if ($query_params['id_search']) |
|
| 157 | - $query_select['id_search'] = '{int:id_search}'; |
|
| 160 | + if ($query_params['id_search']) { |
|
| 161 | + $query_select['id_search'] = '{int:id_search}'; |
|
| 162 | + } |
|
| 158 | 163 | |
| 159 | 164 | $count = 0; |
| 160 | 165 | foreach ($words['words'] as $regularWord) |
@@ -163,30 +168,37 @@ discard block |
||
| 163 | 168 | $query_params['complex_body_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($regularWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $regularWord), '\\\'') . '[[:>:]]'; |
| 164 | 169 | } |
| 165 | 170 | |
| 166 | - if ($query_params['user_query']) |
|
| 167 | - $query_where[] = '{raw:user_query}'; |
|
| 168 | - if ($query_params['board_query']) |
|
| 169 | - $query_where[] = 'm.id_board {raw:board_query}'; |
|
| 171 | + if ($query_params['user_query']) { |
|
| 172 | + $query_where[] = '{raw:user_query}'; |
|
| 173 | + } |
|
| 174 | + if ($query_params['board_query']) { |
|
| 175 | + $query_where[] = 'm.id_board {raw:board_query}'; |
|
| 176 | + } |
|
| 170 | 177 | |
| 171 | - if ($query_params['topic']) |
|
| 172 | - $query_where[] = 'm.id_topic = {int:topic}'; |
|
| 173 | - if ($query_params['min_msg_id']) |
|
| 174 | - $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
| 175 | - if ($query_params['max_msg_id']) |
|
| 176 | - $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
| 178 | + if ($query_params['topic']) { |
|
| 179 | + $query_where[] = 'm.id_topic = {int:topic}'; |
|
| 180 | + } |
|
| 181 | + if ($query_params['min_msg_id']) { |
|
| 182 | + $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
| 183 | + } |
|
| 184 | + if ($query_params['max_msg_id']) { |
|
| 185 | + $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
| 186 | + } |
|
| 177 | 187 | |
| 178 | 188 | $count = 0; |
| 179 | - if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) |
|
| 180 | - foreach ($query_params['excluded_phrases'] as $phrase) |
|
| 189 | + if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) { |
|
| 190 | + foreach ($query_params['excluded_phrases'] as $phrase) |
|
| 181 | 191 | { |
| 182 | 192 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : ' RLIKE ') . '{string:exclude_subject_phrase_' . $count . '}'; |
| 193 | + } |
|
| 183 | 194 | $query_params['exclude_subject_phrase_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($phrase, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $phrase), '\\\'') . '[[:>:]]'; |
| 184 | 195 | } |
| 185 | 196 | $count = 0; |
| 186 | - if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) |
|
| 187 | - foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
| 197 | + if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) { |
|
| 198 | + foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
| 188 | 199 | { |
| 189 | 200 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : ' RLIKE ') . '{string:exclude_subject_words_' . $count . '}'; |
| 201 | + } |
|
| 190 | 202 | $query_params['exclude_subject_words_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($excludedWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $excludedWord), '\\\'') . '[[:>:]]'; |
| 191 | 203 | } |
| 192 | 204 | |
@@ -199,8 +211,7 @@ discard block |
||
| 199 | 211 | { |
| 200 | 212 | $query_left_join[] = '{db_prefix}log_search_words AS lsw' . $numTables . ' ON (lsw' . $numTables . '.id_word = ' . $indexedWord . ' AND lsw' . $numTables . '.id_msg = m.id_msg)'; |
| 201 | 213 | $query_where[] = '(lsw' . $numTables . '.id_word IS NULL)'; |
| 202 | - } |
|
| 203 | - else |
|
| 214 | + } else |
|
| 204 | 215 | { |
| 205 | 216 | $query_inner_join[] = '{db_prefix}log_search_words AS lsw' . $numTables . ' ON (lsw' . $numTables . '.id_msg = ' . ($prev_join === 0 ? 'm' : 'lsw' . $prev_join) . '.id_msg)'; |
| 206 | 217 | $query_where[] = 'lsw' . $numTables . '.id_word = ' . $indexedWord; |
@@ -236,16 +247,18 @@ discard block |
||
| 236 | 247 | $customIndexSettings = smf_json_decode($modSettings['search_custom_index_config'], true); |
| 237 | 248 | |
| 238 | 249 | $inserts = array(); |
| 239 | - foreach (text2words($msgOptions['body'], $customIndexSettings['bytes_per_word'], true) as $word) |
|
| 240 | - $inserts[] = array($word, $msgOptions['id']); |
|
| 250 | + foreach (text2words($msgOptions['body'], $customIndexSettings['bytes_per_word'], true) as $word) { |
|
| 251 | + $inserts[] = array($word, $msgOptions['id']); |
|
| 252 | + } |
|
| 241 | 253 | |
| 242 | - if (!empty($inserts)) |
|
| 243 | - $smcFunc['db_insert']('ignore', |
|
| 254 | + if (!empty($inserts)) { |
|
| 255 | + $smcFunc['db_insert']('ignore', |
|
| 244 | 256 | '{db_prefix}log_search_words', |
| 245 | 257 | array('id_word' => 'int', 'id_msg' => 'int'), |
| 246 | 258 | $inserts, |
| 247 | 259 | array('id_word', 'id_msg') |
| 248 | 260 | ); |
| 261 | + } |
|
| 249 | 262 | } |
| 250 | 263 | |
| 251 | 264 | /** |
@@ -288,8 +301,9 @@ discard block |
||
| 288 | 301 | if (!empty($inserted_words)) |
| 289 | 302 | { |
| 290 | 303 | $inserts = array(); |
| 291 | - foreach ($inserted_words as $word) |
|
| 292 | - $inserts[] = array($word, $msgOptions['id']); |
|
| 304 | + foreach ($inserted_words as $word) { |
|
| 305 | + $inserts[] = array($word, $msgOptions['id']); |
|
| 306 | + } |
|
| 293 | 307 | $smcFunc['db_insert']('insert', |
| 294 | 308 | '{db_prefix}log_search_words', |
| 295 | 309 | array('id_word' => 'string', 'id_msg' => 'int'), |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Show the database queries for debugging |
@@ -30,8 +31,9 @@ discard block |
||
| 30 | 31 | global $scripturl, $settings, $context, $db_connection, $boarddir, $smcFunc, $txt, $db_show_debug; |
| 31 | 32 | |
| 32 | 33 | // We should have debug mode enabled, as well as something to display! |
| 33 | - if (!isset($db_show_debug) || $db_show_debug !== true || !isset($_SESSION['debug'])) |
|
| 34 | - fatal_lang_error('no_access', false); |
|
| 34 | + if (!isset($db_show_debug) || $db_show_debug !== true || !isset($_SESSION['debug'])) { |
|
| 35 | + fatal_lang_error('no_access', false); |
|
| 36 | + } |
|
| 35 | 37 | |
| 36 | 38 | // Don't allow except for administrators. |
| 37 | 39 | isAllowedTo('admin_forum'); |
@@ -41,10 +43,11 @@ discard block |
||
| 41 | 43 | { |
| 42 | 44 | $_SESSION['view_queries'] = $_SESSION['view_queries'] == 1 ? 0 : 1; |
| 43 | 45 | |
| 44 | - if (strpos($_SESSION['old_url'], 'action=viewquery') !== false) |
|
| 45 | - redirectexit(); |
|
| 46 | - else |
|
| 47 | - redirectexit($_SESSION['old_url']); |
|
| 46 | + if (strpos($_SESSION['old_url'], 'action=viewquery') !== false) { |
|
| 47 | + redirectexit(); |
|
| 48 | + } else { |
|
| 49 | + redirectexit($_SESSION['old_url']); |
|
| 50 | + } |
|
| 48 | 51 | } |
| 49 | 52 | |
| 50 | 53 | call_integration_hook('integrate_egg_nog'); |
@@ -83,26 +86,28 @@ discard block |
||
| 83 | 86 | foreach ($query as $line) |
| 84 | 87 | { |
| 85 | 88 | preg_match('/^(\t*)/', $line, $temp); |
| 86 | - if (strlen($temp[0]) < $min_indent || $min_indent == 0) |
|
| 87 | - $min_indent = strlen($temp[0]); |
|
| 89 | + if (strlen($temp[0]) < $min_indent || $min_indent == 0) { |
|
| 90 | + $min_indent = strlen($temp[0]); |
|
| 91 | + } |
|
| 92 | + } |
|
| 93 | + foreach ($query as $l => $dummy) { |
|
| 94 | + $query[$l] = substr($dummy, $min_indent); |
|
| 88 | 95 | } |
| 89 | - foreach ($query as $l => $dummy) |
|
| 90 | - $query[$l] = substr($dummy, $min_indent); |
|
| 91 | 96 | $query_data['q'] = implode("\n", $query); |
| 92 | 97 | |
| 93 | 98 | // Make the filenames look a bit better. |
| 94 | - if (isset($query_data['f'])) |
|
| 95 | - $query_data['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $query_data['f']); |
|
| 99 | + if (isset($query_data['f'])) { |
|
| 100 | + $query_data['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $query_data['f']); |
|
| 101 | + } |
|
| 96 | 102 | |
| 97 | 103 | $is_select_query = substr(trim($query_data['q']), 0, 6) == 'SELECT'; |
| 98 | - if ($is_select_query) |
|
| 99 | - $select = $query_data['q']; |
|
| 100 | - elseif (preg_match('~^INSERT(?: IGNORE)? INTO \w+(?:\s+\([^)]+\))?\s+(SELECT .+)$~s', trim($query_data['q']), $matches) != 0) |
|
| 104 | + if ($is_select_query) { |
|
| 105 | + $select = $query_data['q']; |
|
| 106 | + } elseif (preg_match('~^INSERT(?: IGNORE)? INTO \w+(?:\s+\([^)]+\))?\s+(SELECT .+)$~s', trim($query_data['q']), $matches) != 0) |
|
| 101 | 107 | { |
| 102 | 108 | $is_select_query = true; |
| 103 | 109 | $select = $matches[1]; |
| 104 | - } |
|
| 105 | - elseif (preg_match('~^CREATE TEMPORARY TABLE .+?(SELECT .+)$~s', trim($query_data['q']), $matches) != 0) |
|
| 110 | + } elseif (preg_match('~^CREATE TEMPORARY TABLE .+?(SELECT .+)$~s', trim($query_data['q']), $matches) != 0) |
|
| 106 | 111 | { |
| 107 | 112 | $is_select_query = true; |
| 108 | 113 | $select = $matches[1]; |
@@ -110,10 +115,11 @@ discard block |
||
| 110 | 115 | // Temporary tables created in earlier queries are not explainable. |
| 111 | 116 | if ($is_select_query) |
| 112 | 117 | { |
| 113 | - foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) |
|
| 114 | - if (strpos($select, $tmp) !== false) |
|
| 118 | + foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) { |
|
| 119 | + if (strpos($select, $tmp) !== false) |
|
| 115 | 120 | { |
| 116 | 121 | $is_select_query = false; |
| 122 | + } |
|
| 117 | 123 | break; |
| 118 | 124 | } |
| 119 | 125 | } |
@@ -124,13 +130,15 @@ discard block |
||
| 124 | 130 | ', nl2br(str_replace("\t", ' ', $smcFunc['htmlspecialchars']($query_data['q']))), ' |
| 125 | 131 | </a><br>'; |
| 126 | 132 | |
| 127 | - if (!empty($query_data['f']) && !empty($query_data['l'])) |
|
| 128 | - echo sprintf($txt['debug_query_in_line'], $query_data['f'], $query_data['l']); |
|
| 133 | + if (!empty($query_data['f']) && !empty($query_data['l'])) { |
|
| 134 | + echo sprintf($txt['debug_query_in_line'], $query_data['f'], $query_data['l']); |
|
| 135 | + } |
|
| 129 | 136 | |
| 130 | - if (isset($query_data['s'], $query_data['t']) && isset($txt['debug_query_which_took_at'])) |
|
| 131 | - echo sprintf($txt['debug_query_which_took_at'], round($query_data['t'], 8), round($query_data['s'], 8)); |
|
| 132 | - else |
|
| 133 | - echo sprintf($txt['debug_query_which_took'], round($query_data['t'], 8)); |
|
| 137 | + if (isset($query_data['s'], $query_data['t']) && isset($txt['debug_query_which_took_at'])) { |
|
| 138 | + echo sprintf($txt['debug_query_which_took_at'], round($query_data['t'], 8), round($query_data['s'], 8)); |
|
| 139 | + } else { |
|
| 140 | + echo sprintf($txt['debug_query_which_took'], round($query_data['t'], 8)); |
|
| 141 | + } |
|
| 134 | 142 | |
| 135 | 143 | echo ' |
| 136 | 144 | </div>'; |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 3 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Format a topic to be printer friendly. |
@@ -32,8 +33,9 @@ discard block |
||
| 32 | 33 | global $board_info, $smcFunc, $modSettings; |
| 33 | 34 | |
| 34 | 35 | // Redirect to the boardindex if no valid topic id is provided. |
| 35 | - if (empty($topic)) |
|
| 36 | - redirectexit(); |
|
| 36 | + if (empty($topic)) { |
|
| 37 | + redirectexit(); |
|
| 38 | + } |
|
| 37 | 39 | |
| 38 | 40 | if (!empty($modSettings['disable_print_topic'])) |
| 39 | 41 | { |
@@ -59,8 +61,9 @@ discard block |
||
| 59 | 61 | ) |
| 60 | 62 | ); |
| 61 | 63 | // Redirect to the boardindex if no valid topic id is provided. |
| 62 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 63 | - redirectexit(); |
|
| 64 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 65 | + redirectexit(); |
|
| 66 | + } |
|
| 64 | 67 | $row = $smcFunc['db_fetch_assoc']($request); |
| 65 | 68 | $smcFunc['db_free_result']($request); |
| 66 | 69 | |
@@ -134,20 +137,21 @@ discard block |
||
| 134 | 137 | foreach ($guestinfo as $i => $guestvoted) |
| 135 | 138 | { |
| 136 | 139 | $guestvoted = explode(',', $guestvoted); |
| 137 | - if ($guestvoted[0] == $row['id_poll']) |
|
| 138 | - break; |
|
| 140 | + if ($guestvoted[0] == $row['id_poll']) { |
|
| 141 | + break; |
|
| 142 | + } |
|
| 139 | 143 | } |
| 140 | 144 | // Has the poll been reset since guest voted? |
| 141 | 145 | if ($pollinfo['reset_poll'] > $guestvoted[1]) |
| 142 | 146 | { |
| 143 | 147 | // Remove the poll info from the cookie to allow guest to vote again |
| 144 | 148 | unset($guestinfo[$i]); |
| 145 | - if (!empty($guestinfo)) |
|
| 146 | - $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
| 147 | - else |
|
| 148 | - unset($_COOKIE['guest_poll_vote']); |
|
| 149 | - } |
|
| 150 | - else |
|
| 149 | + if (!empty($guestinfo)) { |
|
| 150 | + $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
| 151 | + } else { |
|
| 152 | + unset($_COOKIE['guest_poll_vote']); |
|
| 153 | + } |
|
| 154 | + } else |
|
| 151 | 155 | { |
| 152 | 156 | // What did they vote for? |
| 153 | 157 | unset($guestvoted[0], $guestvoted[1]); |
@@ -233,8 +237,9 @@ discard block |
||
| 233 | 237 | $context['poster_name'] = $row['poster_name']; |
| 234 | 238 | $context['post_time'] = timeformat($row['poster_time'], false); |
| 235 | 239 | $context['parent_boards'] = array(); |
| 236 | - foreach ($board_info['parent_boards'] as $parent) |
|
| 237 | - $context['parent_boards'][] = $parent['name']; |
|
| 240 | + foreach ($board_info['parent_boards'] as $parent) { |
|
| 241 | + $context['parent_boards'][] = $parent['name']; |
|
| 242 | + } |
|
| 238 | 243 | |
| 239 | 244 | // Split the topics up so we can print them. |
| 240 | 245 | $request = $smcFunc['db_query']('', ' |
@@ -266,8 +271,9 @@ discard block |
||
| 266 | 271 | 'id_msg' => $row['id_msg'], |
| 267 | 272 | ); |
| 268 | 273 | |
| 269 | - if (!isset($context['topic_subject'])) |
|
| 270 | - $context['topic_subject'] = $row['subject']; |
|
| 274 | + if (!isset($context['topic_subject'])) { |
|
| 275 | + $context['topic_subject'] = $row['subject']; |
|
| 276 | + } |
|
| 271 | 277 | } |
| 272 | 278 | $smcFunc['db_free_result']($request); |
| 273 | 279 | |
@@ -275,8 +281,9 @@ discard block |
||
| 275 | 281 | if (isset($_REQUEST['images']) && !empty($modSettings['attachmentEnable']) && allowedTo('view_attachments')) |
| 276 | 282 | { |
| 277 | 283 | $messages = array(); |
| 278 | - foreach ($context['posts'] as $temp) |
|
| 279 | - $messages[] = $temp['id_msg']; |
|
| 284 | + foreach ($context['posts'] as $temp) { |
|
| 285 | + $messages[] = $temp['id_msg']; |
|
| 286 | + } |
|
| 280 | 287 | |
| 281 | 288 | // build the request |
| 282 | 289 | $request = $smcFunc['db_query']('', ' |
@@ -295,8 +302,9 @@ discard block |
||
| 295 | 302 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 296 | 303 | { |
| 297 | 304 | $temp[$row['id_attach']] = $row; |
| 298 | - if (!isset($context['printattach'][$row['id_msg']])) |
|
| 299 | - $context['printattach'][$row['id_msg']] = array(); |
|
| 305 | + if (!isset($context['printattach'][$row['id_msg']])) { |
|
| 306 | + $context['printattach'][$row['id_msg']] = array(); |
|
| 307 | + } |
|
| 300 | 308 | } |
| 301 | 309 | $smcFunc['db_free_result']($request); |
| 302 | 310 | ksort($temp); |
@@ -313,8 +321,7 @@ discard block |
||
| 313 | 321 | $row['height'] = floor($row['height'] * ($modSettings['max_image_width'] / $row['width'])); |
| 314 | 322 | $row['width'] = $modSettings['max_image_width']; |
| 315 | 323 | } |
| 316 | - } |
|
| 317 | - elseif (!empty($modSettings['max_image_width'])) |
|
| 324 | + } elseif (!empty($modSettings['max_image_width'])) |
|
| 318 | 325 | { |
| 319 | 326 | if ($row['height'] > $modSettings['max_image_height']) |
| 320 | 327 | { |
@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 3 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('Hacking attempt...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Our Cache API class |
@@ -34,8 +35,9 @@ discard block |
||
| 34 | 35 | |
| 35 | 36 | $supported = class_exists('memcache'); |
| 36 | 37 | |
| 37 | - if ($test) |
|
| 38 | - return $supported; |
|
| 38 | + if ($test) { |
|
| 39 | + return $supported; |
|
| 40 | + } |
|
| 39 | 41 | return parent::isSupported() && $supported && !empty($cache_memcached); |
| 40 | 42 | } |
| 41 | 43 | |
@@ -61,9 +63,9 @@ discard block |
||
| 61 | 63 | $server = trim($servers[array_rand($servers)]); |
| 62 | 64 | |
| 63 | 65 | // Normal host names do not contain slashes, while e.g. unix sockets do. Assume alternative transport pipe with port 0. |
| 64 | - if (strpos($server,'/') !== false) |
|
| 65 | - $host = $server; |
|
| 66 | - else |
|
| 66 | + if (strpos($server,'/') !== false) { |
|
| 67 | + $host = $server; |
|
| 68 | + } else |
|
| 67 | 69 | { |
| 68 | 70 | $server = explode(':', $server); |
| 69 | 71 | $host = $server[0]; |
@@ -71,10 +73,11 @@ discard block |
||
| 71 | 73 | } |
| 72 | 74 | |
| 73 | 75 | // Don't wait too long: yes, we want the server, but we might be able to run the query faster! |
| 74 | - if (empty($db_persist)) |
|
| 75 | - $connected = $this->memcache->connect($host, $port); |
|
| 76 | - else |
|
| 77 | - $connected = $this->memcache->pconnect($host, $port); |
|
| 76 | + if (empty($db_persist)) { |
|
| 77 | + $connected = $this->memcache->connect($host, $port); |
|
| 78 | + } else { |
|
| 79 | + $connected = $this->memcache->pconnect($host, $port); |
|
| 80 | + } |
|
| 78 | 81 | } |
| 79 | 82 | |
| 80 | 83 | return $connected; |
@@ -90,8 +93,9 @@ discard block |
||
| 90 | 93 | $value = $this->memcache->get($key); |
| 91 | 94 | |
| 92 | 95 | // $value should return either data or false (from failure, key not found or empty array). |
| 93 | - if ($value === false) |
|
| 94 | - return null; |
|
| 96 | + if ($value === false) { |
|
| 97 | + return null; |
|
| 98 | + } |
|
| 95 | 99 | return $value; |
| 96 | 100 | } |
| 97 | 101 | |
@@ -132,8 +136,9 @@ discard block |
||
| 132 | 136 | $config_vars[] = $txt['cache_memcache_settings']; |
| 133 | 137 | $config_vars[] = array('cache_memcached', $txt['cache_memcache_servers'], 'file', 'text', 0, 'cache_memcached', 'postinput' => '<br /><div class="smalltext"><em>' . $txt['cache_memcache_servers_subtext'] . '</em></div>'); |
| 134 | 138 | |
| 135 | - if (!isset($context['settings_post_javascript'])) |
|
| 136 | - $context['settings_post_javascript'] = ''; |
|
| 139 | + if (!isset($context['settings_post_javascript'])) { |
|
| 140 | + $context['settings_post_javascript'] = ''; |
|
| 141 | + } |
|
| 137 | 142 | |
| 138 | 143 | $context['settings_post_javascript'] .= ' |
| 139 | 144 | $("#cache_accelerator").change(function (e) { |