@@ -17,8 +17,9 @@ discard block |
||
| 17 | 17 | * @version 2.1 Beta 3 |
| 18 | 18 | */ |
| 19 | 19 | |
| 20 | -if (!defined('SMF')) |
|
| 20 | +if (!defined('SMF')) { |
|
| 21 | 21 | die('No direct access...'); |
| 22 | +} |
|
| 22 | 23 | |
| 23 | 24 | /** |
| 24 | 25 | * Attempt to start the session, unless it already has been. |
@@ -38,8 +39,9 @@ discard block |
||
| 38 | 39 | { |
| 39 | 40 | $parsed_url = parse_url($boardurl); |
| 40 | 41 | |
| 41 | - if (preg_match('~^\d{1,3}(\.\d{1,3}){3}$~', $parsed_url['host']) == 0 && preg_match('~(?:[^\.]+\.)?([^\.]{2,}\..+)\z~i', $parsed_url['host'], $parts) == 1) |
|
| 42 | - @ini_set('session.cookie_domain', '.' . $parts[1]); |
|
| 42 | + if (preg_match('~^\d{1,3}(\.\d{1,3}){3}$~', $parsed_url['host']) == 0 && preg_match('~(?:[^\.]+\.)?([^\.]{2,}\..+)\z~i', $parsed_url['host'], $parts) == 1) { |
|
| 43 | + @ini_set('session.cookie_domain', '.' . $parts[1]); |
|
| 44 | + } |
|
| 43 | 45 | } |
| 44 | 46 | // @todo Set the session cookie path? |
| 45 | 47 | |
@@ -47,8 +49,9 @@ discard block |
||
| 47 | 49 | if ((ini_get('session.auto_start') == 1 && !empty($modSettings['databaseSession_enable'])) || session_id() == '') |
| 48 | 50 | { |
| 49 | 51 | // Attempt to end the already-started session. |
| 50 | - if (ini_get('session.auto_start') == 1) |
|
| 51 | - session_write_close(); |
|
| 52 | + if (ini_get('session.auto_start') == 1) { |
|
| 53 | + session_write_close(); |
|
| 54 | + } |
|
| 52 | 55 | |
| 53 | 56 | // This is here to stop people from using bad junky PHPSESSIDs. |
| 54 | 57 | if (isset($_REQUEST[session_name()]) && preg_match('~^[A-Za-z0-9,-]{16,64}$~', $_REQUEST[session_name()]) == 0 && !isset($_COOKIE[session_name()])) |
@@ -65,19 +68,21 @@ discard block |
||
| 65 | 68 | @ini_set('session.serialize_handler', 'php'); |
| 66 | 69 | session_set_save_handler('sessionOpen', 'sessionClose', 'sessionRead', 'sessionWrite', 'sessionDestroy', 'sessionGC'); |
| 67 | 70 | @ini_set('session.gc_probability', '1'); |
| 71 | + } elseif (ini_get('session.gc_maxlifetime') <= 1440 && !empty($modSettings['databaseSession_lifetime'])) { |
|
| 72 | + @ini_set('session.gc_maxlifetime', max($modSettings['databaseSession_lifetime'], 60)); |
|
| 68 | 73 | } |
| 69 | - elseif (ini_get('session.gc_maxlifetime') <= 1440 && !empty($modSettings['databaseSession_lifetime'])) |
|
| 70 | - @ini_set('session.gc_maxlifetime', max($modSettings['databaseSession_lifetime'], 60)); |
|
| 71 | 74 | |
| 72 | 75 | // Use cache setting sessions? |
| 73 | - if (empty($modSettings['databaseSession_enable']) && !empty($modSettings['cache_enable']) && php_sapi_name() != 'cli') |
|
| 74 | - call_integration_hook('integrate_session_handlers'); |
|
| 76 | + if (empty($modSettings['databaseSession_enable']) && !empty($modSettings['cache_enable']) && php_sapi_name() != 'cli') { |
|
| 77 | + call_integration_hook('integrate_session_handlers'); |
|
| 78 | + } |
|
| 75 | 79 | |
| 76 | 80 | session_start(); |
| 77 | 81 | |
| 78 | 82 | // Change it so the cache settings are a little looser than default. |
| 79 | - if (!empty($modSettings['databaseSession_loose'])) |
|
| 80 | - header('Cache-Control: private'); |
|
| 83 | + if (!empty($modSettings['databaseSession_loose'])) { |
|
| 84 | + header('Cache-Control: private'); |
|
| 85 | + } |
|
| 81 | 86 | } |
| 82 | 87 | |
| 83 | 88 | // Set the randomly generated code. |
@@ -123,8 +128,9 @@ discard block |
||
| 123 | 128 | { |
| 124 | 129 | global $smcFunc; |
| 125 | 130 | |
| 126 | - if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) |
|
| 127 | - return ''; |
|
| 131 | + if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) { |
|
| 132 | + return ''; |
|
| 133 | + } |
|
| 128 | 134 | |
| 129 | 135 | // Look for it in the database. |
| 130 | 136 | $result = $smcFunc['db_query']('', ' |
@@ -153,8 +159,9 @@ discard block |
||
| 153 | 159 | { |
| 154 | 160 | global $smcFunc; |
| 155 | 161 | |
| 156 | - if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) |
|
| 157 | - return false; |
|
| 162 | + if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) { |
|
| 163 | + return false; |
|
| 164 | + } |
|
| 158 | 165 | |
| 159 | 166 | // First try to update an existing row... |
| 160 | 167 | $result = $smcFunc['db_query']('', ' |
@@ -169,13 +176,14 @@ discard block |
||
| 169 | 176 | ); |
| 170 | 177 | |
| 171 | 178 | // If that didn't work, try inserting a new one. |
| 172 | - if ($smcFunc['db_affected_rows']() == 0) |
|
| 173 | - $result = $smcFunc['db_insert']('ignore', |
|
| 179 | + if ($smcFunc['db_affected_rows']() == 0) { |
|
| 180 | + $result = $smcFunc['db_insert']('ignore', |
|
| 174 | 181 | '{db_prefix}sessions', |
| 175 | 182 | array('session_id' => 'string', 'data' => 'string', 'last_update' => 'int'), |
| 176 | 183 | array($session_id, $data, time()), |
| 177 | 184 | array('session_id') |
| 178 | 185 | ); |
| 186 | + } |
|
| 179 | 187 | |
| 180 | 188 | return ($smcFunc['db_affected_rows']() == 0 ? false : true); |
| 181 | 189 | } |
@@ -190,8 +198,9 @@ discard block |
||
| 190 | 198 | { |
| 191 | 199 | global $smcFunc; |
| 192 | 200 | |
| 193 | - if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) |
|
| 194 | - return false; |
|
| 201 | + if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) { |
|
| 202 | + return false; |
|
| 203 | + } |
|
| 195 | 204 | |
| 196 | 205 | // Just delete the row... |
| 197 | 206 | $smcFunc['db_query']('', ' |
@@ -217,8 +226,9 @@ discard block |
||
| 217 | 226 | global $modSettings, $smcFunc; |
| 218 | 227 | |
| 219 | 228 | // Just set to the default or lower? Ignore it for a higher value. (hopefully) |
| 220 | - if (!empty($modSettings['databaseSession_lifetime']) && ($max_lifetime <= 1440 || $modSettings['databaseSession_lifetime'] > $max_lifetime)) |
|
| 221 | - $max_lifetime = max($modSettings['databaseSession_lifetime'], 60); |
|
| 229 | + if (!empty($modSettings['databaseSession_lifetime']) && ($max_lifetime <= 1440 || $modSettings['databaseSession_lifetime'] > $max_lifetime)) { |
|
| 230 | + $max_lifetime = max($modSettings['databaseSession_lifetime'], 60); |
|
| 231 | + } |
|
| 222 | 232 | |
| 223 | 233 | // Clean up after yerself ;). |
| 224 | 234 | $smcFunc['db_query']('', ' |
@@ -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 |
@@ -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 | * This function allows to move a topic, making sure to ask the moderator |
@@ -32,8 +33,9 @@ discard block |
||
| 32 | 33 | { |
| 33 | 34 | global $txt, $board, $topic, $user_info, $context, $language, $scripturl, $smcFunc, $modSettings, $sourcedir; |
| 34 | 35 | |
| 35 | - if (empty($topic)) |
|
| 36 | - fatal_lang_error('no_access', false); |
|
| 36 | + if (empty($topic)) { |
|
| 37 | + fatal_lang_error('no_access', false); |
|
| 38 | + } |
|
| 37 | 39 | |
| 38 | 40 | $request = $smcFunc['db_query']('', ' |
| 39 | 41 | SELECT t.id_member_started, ms.subject, t.approved |
@@ -49,8 +51,9 @@ discard block |
||
| 49 | 51 | $smcFunc['db_free_result']($request); |
| 50 | 52 | |
| 51 | 53 | // Can they see it - if not approved? |
| 52 | - if ($modSettings['postmod_active'] && !$context['is_approved']) |
|
| 53 | - isAllowedTo('approve_posts'); |
|
| 54 | + if ($modSettings['postmod_active'] && !$context['is_approved']) { |
|
| 55 | + isAllowedTo('approve_posts'); |
|
| 56 | + } |
|
| 54 | 57 | |
| 55 | 58 | // Permission check! |
| 56 | 59 | // @todo |
@@ -59,9 +62,9 @@ discard block |
||
| 59 | 62 | if ($id_member_started == $user_info['id']) |
| 60 | 63 | { |
| 61 | 64 | isAllowedTo('move_own'); |
| 65 | + } else { |
|
| 66 | + isAllowedTo('move_any'); |
|
| 62 | 67 | } |
| 63 | - else |
|
| 64 | - isAllowedTo('move_any'); |
|
| 65 | 68 | } |
| 66 | 69 | |
| 67 | 70 | $context['move_any'] = $user_info['is_admin'] || $modSettings['topic_move_any']; |
@@ -83,11 +86,13 @@ discard block |
||
| 83 | 86 | 'not_redirection' => true, |
| 84 | 87 | ); |
| 85 | 88 | |
| 86 | - if (!empty($_SESSION['move_to_topic']) && $_SESSION['move_to_topic'] != $board) |
|
| 87 | - $options['selected_board'] = $_SESSION['move_to_topic']; |
|
| 89 | + if (!empty($_SESSION['move_to_topic']) && $_SESSION['move_to_topic'] != $board) { |
|
| 90 | + $options['selected_board'] = $_SESSION['move_to_topic']; |
|
| 91 | + } |
|
| 88 | 92 | |
| 89 | - if (!$context['move_any']) |
|
| 90 | - $options['included_boards'] = $boards; |
|
| 93 | + if (!$context['move_any']) { |
|
| 94 | + $options['included_boards'] = $boards; |
|
| 95 | + } |
|
| 91 | 96 | |
| 92 | 97 | require_once($sourcedir . '/Subs-MessageIndex.php'); |
| 93 | 98 | $context['categories'] = getBoardList($options); |
@@ -138,12 +143,14 @@ discard block |
||
| 138 | 143 | global $txt, $board, $topic, $scripturl, $sourcedir, $modSettings, $context; |
| 139 | 144 | global $board, $language, $user_info, $smcFunc; |
| 140 | 145 | |
| 141 | - if (empty($topic)) |
|
| 142 | - fatal_lang_error('no_access', false); |
|
| 146 | + if (empty($topic)) { |
|
| 147 | + fatal_lang_error('no_access', false); |
|
| 148 | + } |
|
| 143 | 149 | |
| 144 | 150 | // You can't choose to have a redirection topic and use an empty reason. |
| 145 | - if (isset($_POST['postRedirect']) && (!isset($_POST['reason']) || trim($_POST['reason']) == '')) |
|
| 146 | - fatal_lang_error('movetopic_no_reason', false); |
|
| 151 | + if (isset($_POST['postRedirect']) && (!isset($_POST['reason']) || trim($_POST['reason']) == '')) { |
|
| 152 | + fatal_lang_error('movetopic_no_reason', false); |
|
| 153 | + } |
|
| 147 | 154 | |
| 148 | 155 | moveTopicConcurrence(); |
| 149 | 156 | |
@@ -163,8 +170,9 @@ discard block |
||
| 163 | 170 | $smcFunc['db_free_result']($request); |
| 164 | 171 | |
| 165 | 172 | // Can they see it? |
| 166 | - if (!$context['is_approved']) |
|
| 167 | - isAllowedTo('approve_posts'); |
|
| 173 | + if (!$context['is_approved']) { |
|
| 174 | + isAllowedTo('approve_posts'); |
|
| 175 | + } |
|
| 168 | 176 | |
| 169 | 177 | // Can they move topics on this board? |
| 170 | 178 | if (!allowedTo('move_any')) |
@@ -173,12 +181,12 @@ discard block |
||
| 173 | 181 | { |
| 174 | 182 | isAllowedTo('move_own'); |
| 175 | 183 | $boards = array_merge(boardsAllowedTo('move_own'), boardsAllowedTo('move_any')); |
| 184 | + } else { |
|
| 185 | + isAllowedTo('move_any'); |
|
| 176 | 186 | } |
| 177 | - else |
|
| 178 | - isAllowedTo('move_any'); |
|
| 187 | + } else { |
|
| 188 | + $boards = boardsAllowedTo('move_any'); |
|
| 179 | 189 | } |
| 180 | - else |
|
| 181 | - $boards = boardsAllowedTo('move_any'); |
|
| 182 | 190 | |
| 183 | 191 | // If this topic isn't approved don't let them move it if they can't approve it! |
| 184 | 192 | if ($modSettings['postmod_active'] && !$context['is_approved'] && !allowedTo('approve_posts')) |
@@ -210,8 +218,9 @@ discard block |
||
| 210 | 218 | 'blank_redirect' => '', |
| 211 | 219 | ) |
| 212 | 220 | ); |
| 213 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 214 | - fatal_lang_error('no_board'); |
|
| 221 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 222 | + fatal_lang_error('no_board'); |
|
| 223 | + } |
|
| 215 | 224 | list ($pcounter, $board_name, $subject) = $smcFunc['db_fetch_row']($request); |
| 216 | 225 | $smcFunc['db_free_result']($request); |
| 217 | 226 | |
@@ -223,8 +232,9 @@ discard block |
||
| 223 | 232 | { |
| 224 | 233 | $_POST['custom_subject'] = strtr($smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['custom_subject'])), array("\r" => '', "\n" => '', "\t" => '')); |
| 225 | 234 | // Keep checking the length. |
| 226 | - if ($smcFunc['strlen']($_POST['custom_subject']) > 100) |
|
| 227 | - $_POST['custom_subject'] = $smcFunc['substr']($_POST['custom_subject'], 0, 100); |
|
| 235 | + if ($smcFunc['strlen']($_POST['custom_subject']) > 100) { |
|
| 236 | + $_POST['custom_subject'] = $smcFunc['substr']($_POST['custom_subject'], 0, 100); |
|
| 237 | + } |
|
| 228 | 238 | |
| 229 | 239 | // If it's still valid move onwards and upwards. |
| 230 | 240 | if ($_POST['custom_subject'] != '') |
@@ -234,9 +244,9 @@ discard block |
||
| 234 | 244 | // Get a response prefix, but in the forum's default language. |
| 235 | 245 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
| 236 | 246 | { |
| 237 | - if ($language === $user_info['language']) |
|
| 238 | - $context['response_prefix'] = $txt['response_prefix']; |
|
| 239 | - else |
|
| 247 | + if ($language === $user_info['language']) { |
|
| 248 | + $context['response_prefix'] = $txt['response_prefix']; |
|
| 249 | + } else |
|
| 240 | 250 | { |
| 241 | 251 | loadLanguage('index', $language, false); |
| 242 | 252 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -276,8 +286,9 @@ discard block |
||
| 276 | 286 | if (isset($_POST['postRedirect'])) |
| 277 | 287 | { |
| 278 | 288 | // Should be in the boardwide language. |
| 279 | - if ($user_info['language'] != $language) |
|
| 280 | - loadLanguage('index', $language); |
|
| 289 | + if ($user_info['language'] != $language) { |
|
| 290 | + loadLanguage('index', $language); |
|
| 291 | + } |
|
| 281 | 292 | |
| 282 | 293 | $_POST['reason'] = $smcFunc['htmlspecialchars']($_POST['reason'], ENT_QUOTES); |
| 283 | 294 | preparsecode($_POST['reason']); |
@@ -341,8 +352,9 @@ discard block |
||
| 341 | 352 | $posters = array(); |
| 342 | 353 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 343 | 354 | { |
| 344 | - if (!isset($posters[$row['id_member']])) |
|
| 345 | - $posters[$row['id_member']] = 0; |
|
| 355 | + if (!isset($posters[$row['id_member']])) { |
|
| 356 | + $posters[$row['id_member']] = 0; |
|
| 357 | + } |
|
| 346 | 358 | |
| 347 | 359 | $posters[$row['id_member']]++; |
| 348 | 360 | } |
@@ -351,11 +363,13 @@ discard block |
||
| 351 | 363 | foreach ($posters as $id_member => $posts) |
| 352 | 364 | { |
| 353 | 365 | // The board we're moving from counted posts, but not to. |
| 354 | - if (empty($pcounter_from)) |
|
| 355 | - updateMemberData($id_member, array('posts' => 'posts - ' . $posts)); |
|
| 366 | + if (empty($pcounter_from)) { |
|
| 367 | + updateMemberData($id_member, array('posts' => 'posts - ' . $posts)); |
|
| 368 | + } |
|
| 356 | 369 | // The reverse: from didn't, to did. |
| 357 | - else |
|
| 358 | - updateMemberData($id_member, array('posts' => 'posts + ' . $posts)); |
|
| 370 | + else { |
|
| 371 | + updateMemberData($id_member, array('posts' => 'posts + ' . $posts)); |
|
| 372 | + } |
|
| 359 | 373 | } |
| 360 | 374 | } |
| 361 | 375 | |
@@ -363,17 +377,19 @@ discard block |
||
| 363 | 377 | moveTopics($topic, $_POST['toboard']); |
| 364 | 378 | |
| 365 | 379 | // Log that they moved this topic. |
| 366 | - if (!allowedTo('move_own') || $id_member_started != $user_info['id']) |
|
| 367 | - logAction('move', array('topic' => $topic, 'board_from' => $board, 'board_to' => $_POST['toboard'])); |
|
| 380 | + if (!allowedTo('move_own') || $id_member_started != $user_info['id']) { |
|
| 381 | + logAction('move', array('topic' => $topic, 'board_from' => $board, 'board_to' => $_POST['toboard'])); |
|
| 382 | + } |
|
| 368 | 383 | // Notify people that this topic has been moved? |
| 369 | 384 | sendNotifications($topic, 'move'); |
| 370 | 385 | |
| 371 | 386 | // Why not go back to the original board in case they want to keep moving? |
| 372 | - if (!isset($_REQUEST['goback'])) |
|
| 373 | - redirectexit('board=' . $board . '.0'); |
|
| 374 | - else |
|
| 375 | - redirectexit('topic=' . $topic . '.0'); |
|
| 376 | -} |
|
| 387 | + if (!isset($_REQUEST['goback'])) { |
|
| 388 | + redirectexit('board=' . $board . '.0'); |
|
| 389 | + } else { |
|
| 390 | + redirectexit('topic=' . $topic . '.0'); |
|
| 391 | + } |
|
| 392 | + } |
|
| 377 | 393 | |
| 378 | 394 | /** |
| 379 | 395 | * Moves one or more topics to a specific board. (doesn't check permissions.) |
@@ -389,18 +405,21 @@ discard block |
||
| 389 | 405 | global $sourcedir, $user_info, $modSettings, $smcFunc; |
| 390 | 406 | |
| 391 | 407 | // Empty array? |
| 392 | - if (empty($topics)) |
|
| 393 | - return; |
|
| 408 | + if (empty($topics)) { |
|
| 409 | + return; |
|
| 410 | + } |
|
| 394 | 411 | |
| 395 | 412 | // Only a single topic. |
| 396 | - if (is_numeric($topics)) |
|
| 397 | - $topics = array($topics); |
|
| 413 | + if (is_numeric($topics)) { |
|
| 414 | + $topics = array($topics); |
|
| 415 | + } |
|
| 398 | 416 | $num_topics = count($topics); |
| 399 | 417 | $fromBoards = array(); |
| 400 | 418 | |
| 401 | 419 | // Destination board empty or equal to 0? |
| 402 | - if (empty($toBoard)) |
|
| 403 | - return; |
|
| 420 | + if (empty($toBoard)) { |
|
| 421 | + return; |
|
| 422 | + } |
|
| 404 | 423 | |
| 405 | 424 | // Are we moving to the recycle board? |
| 406 | 425 | $isRecycleDest = !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] == $toBoard; |
@@ -408,8 +427,9 @@ discard block |
||
| 408 | 427 | // Callback for search APIs to do their thing |
| 409 | 428 | require_once($sourcedir . '/Search.php'); |
| 410 | 429 | $searchAPI = findSearchAPI(); |
| 411 | - if ($searchAPI->supportsMethod('topicsMoved')) |
|
| 412 | - $searchAPI->topicsMoved($topics, $toBoard); |
|
| 430 | + if ($searchAPI->supportsMethod('topicsMoved')) { |
|
| 431 | + $searchAPI->topicsMoved($topics, $toBoard); |
|
| 432 | + } |
|
| 413 | 433 | |
| 414 | 434 | // Determine the source boards... |
| 415 | 435 | $request = $smcFunc['db_query']('', ' |
@@ -423,8 +443,9 @@ discard block |
||
| 423 | 443 | ) |
| 424 | 444 | ); |
| 425 | 445 | // Num of rows = 0 -> no topics found. Num of rows > 1 -> topics are on multiple boards. |
| 426 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 427 | - return; |
|
| 446 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 447 | + return; |
|
| 448 | + } |
|
| 428 | 449 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 429 | 450 | { |
| 430 | 451 | if (!isset($fromBoards[$row['id_board']]['num_posts'])) |
@@ -442,10 +463,11 @@ discard block |
||
| 442 | 463 | $fromBoards[$row['id_board']]['unapproved_posts'] += $row['unapproved_posts']; |
| 443 | 464 | |
| 444 | 465 | // Add the topics to the right type. |
| 445 | - if ($row['approved']) |
|
| 446 | - $fromBoards[$row['id_board']]['num_topics'] += $row['num_topics']; |
|
| 447 | - else |
|
| 448 | - $fromBoards[$row['id_board']]['unapproved_topics'] += $row['num_topics']; |
|
| 466 | + if ($row['approved']) { |
|
| 467 | + $fromBoards[$row['id_board']]['num_topics'] += $row['num_topics']; |
|
| 468 | + } else { |
|
| 469 | + $fromBoards[$row['id_board']]['unapproved_topics'] += $row['num_topics']; |
|
| 470 | + } |
|
| 449 | 471 | } |
| 450 | 472 | $smcFunc['db_free_result']($request); |
| 451 | 473 | |
@@ -571,13 +593,14 @@ discard block |
||
| 571 | 593 | ) |
| 572 | 594 | ); |
| 573 | 595 | $approval_msgs = array(); |
| 574 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 575 | - $approval_msgs[] = $row['id_msg']; |
|
| 596 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 597 | + $approval_msgs[] = $row['id_msg']; |
|
| 598 | + } |
|
| 576 | 599 | $smcFunc['db_free_result']($request); |
| 577 | 600 | |
| 578 | 601 | // Empty the approval queue for these, as we're going to approve them next. |
| 579 | - if (!empty($approval_msgs)) |
|
| 580 | - $smcFunc['db_query']('', ' |
|
| 602 | + if (!empty($approval_msgs)) { |
|
| 603 | + $smcFunc['db_query']('', ' |
|
| 581 | 604 | DELETE FROM {db_prefix}approval_queue |
| 582 | 605 | WHERE id_msg IN ({array_int:message_list}) |
| 583 | 606 | AND id_attach = {int:id_attach}', |
@@ -586,6 +609,7 @@ discard block |
||
| 586 | 609 | 'id_attach' => 0, |
| 587 | 610 | ) |
| 588 | 611 | ); |
| 612 | + } |
|
| 589 | 613 | |
| 590 | 614 | // Get all the current max and mins. |
| 591 | 615 | $request = $smcFunc['db_query']('', ' |
@@ -619,8 +643,8 @@ discard block |
||
| 619 | 643 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 620 | 644 | { |
| 621 | 645 | // If not, update. |
| 622 | - if ($row['first_msg'] != $topicMaxMin[$row['id_topic']]['min'] || $row['last_msg'] != $topicMaxMin[$row['id_topic']]['max']) |
|
| 623 | - $smcFunc['db_query']('', ' |
|
| 646 | + if ($row['first_msg'] != $topicMaxMin[$row['id_topic']]['min'] || $row['last_msg'] != $topicMaxMin[$row['id_topic']]['max']) { |
|
| 647 | + $smcFunc['db_query']('', ' |
|
| 624 | 648 | UPDATE {db_prefix}topics |
| 625 | 649 | SET id_first_msg = {int:first_msg}, id_last_msg = {int:last_msg} |
| 626 | 650 | WHERE id_topic = {int:selected_topic}', |
@@ -630,6 +654,7 @@ discard block |
||
| 630 | 654 | 'selected_topic' => $row['id_topic'], |
| 631 | 655 | ) |
| 632 | 656 | ); |
| 657 | + } |
|
| 633 | 658 | } |
| 634 | 659 | $smcFunc['db_free_result']($request); |
| 635 | 660 | } |
@@ -688,9 +713,10 @@ discard block |
||
| 688 | 713 | } |
| 689 | 714 | |
| 690 | 715 | // Update the cache? |
| 691 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) |
|
| 692 | - foreach ($topics as $topic_id) |
|
| 716 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) { |
|
| 717 | + foreach ($topics as $topic_id) |
|
| 693 | 718 | cache_put_data('topic_board-' . $topic_id, null, 120); |
| 719 | + } |
|
| 694 | 720 | |
| 695 | 721 | require_once($sourcedir . '/Subs-Post.php'); |
| 696 | 722 | |
@@ -714,15 +740,17 @@ discard block |
||
| 714 | 740 | { |
| 715 | 741 | global $board, $topic, $smcFunc, $scripturl; |
| 716 | 742 | |
| 717 | - if (isset($_GET['current_board'])) |
|
| 718 | - $move_from = (int) $_GET['current_board']; |
|
| 743 | + if (isset($_GET['current_board'])) { |
|
| 744 | + $move_from = (int) $_GET['current_board']; |
|
| 745 | + } |
|
| 719 | 746 | |
| 720 | - if (empty($move_from) || empty($board) || empty($topic)) |
|
| 721 | - return true; |
|
| 747 | + if (empty($move_from) || empty($board) || empty($topic)) { |
|
| 748 | + return true; |
|
| 749 | + } |
|
| 722 | 750 | |
| 723 | - if ($move_from == $board) |
|
| 724 | - return true; |
|
| 725 | - else |
|
| 751 | + if ($move_from == $board) { |
|
| 752 | + return true; |
|
| 753 | + } else |
|
| 726 | 754 | { |
| 727 | 755 | $request = $smcFunc['db_query']('', ' |
| 728 | 756 | SELECT m.subject, b.name |
@@ -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 |
@@ -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 | class Attachments |
| 20 | 21 | { |
@@ -70,16 +71,18 @@ discard block |
||
| 70 | 71 | |
| 71 | 72 | $this->_sa = !empty($_REQUEST['sa']) ? $smcFunc['htmlspecialchars']($smcFunc['htmltrim']($_REQUEST['sa'])) : false; |
| 72 | 73 | |
| 73 | - if ($this->_canPostAttachment && $this->_sa && in_array($this->_sa, $this->_subActions)) |
|
| 74 | - $this->{$this->_sa}(); |
|
| 74 | + if ($this->_canPostAttachment && $this->_sa && in_array($this->_sa, $this->_subActions)) { |
|
| 75 | + $this->{$this->_sa}(); |
|
| 76 | + } |
|
| 75 | 77 | |
| 76 | 78 | // Just send a generic message. |
| 77 | - else |
|
| 78 | - $this->setResponse(array( |
|
| 79 | + else { |
|
| 80 | + $this->setResponse(array( |
|
| 79 | 81 | 'text' => $this->_sa == 'add' ? 'attach_error_title' : 'attached_file_deleted_error', |
| 80 | 82 | 'type' => 'error', |
| 81 | 83 | 'data' => false, |
| 82 | 84 | )); |
| 85 | + } |
|
| 83 | 86 | |
| 84 | 87 | // Back to the future, oh, to the browser! |
| 85 | 88 | $this->sendResponse(); |
@@ -95,12 +98,13 @@ discard block |
||
| 95 | 98 | $attachID = !empty($_REQUEST['attach']) && is_numeric($_REQUEST['attach']) ? (int) $_REQUEST['attach'] : 0; |
| 96 | 99 | |
| 97 | 100 | // Need something to work with. |
| 98 | - if (!$attachID || (!empty($_SESSION['already_attached']) && !isset($_SESSION['already_attached'][$attachID]))) |
|
| 99 | - return $this->setResponse(array( |
|
| 101 | + if (!$attachID || (!empty($_SESSION['already_attached']) && !isset($_SESSION['already_attached'][$attachID]))) { |
|
| 102 | + return $this->setResponse(array( |
|
| 100 | 103 | 'text' => 'attached_file_deleted_error', |
| 101 | 104 | 'type' => 'error', |
| 102 | 105 | 'data' => false, |
| 103 | 106 | )); |
| 107 | + } |
|
| 104 | 108 | |
| 105 | 109 | // Lets pass some params and see what happens :P |
| 106 | 110 | $affectedMessage = removeAttachments(array('id_attach' => $attachID), '', true, true); |
@@ -121,19 +125,21 @@ discard block |
||
| 121 | 125 | $result = array(); |
| 122 | 126 | |
| 123 | 127 | // You gotta be able to post attachments. |
| 124 | - if (!$this->_canPostAttachment) |
|
| 125 | - return $this->setResponse(array( |
|
| 128 | + if (!$this->_canPostAttachment) { |
|
| 129 | + return $this->setResponse(array( |
|
| 126 | 130 | 'text' => 'attached_file_cannot', |
| 127 | 131 | 'type' => 'error', |
| 128 | 132 | 'data' => false, |
| 129 | 133 | )); |
| 134 | + } |
|
| 130 | 135 | |
| 131 | 136 | // Process them at once! |
| 132 | 137 | $this->processAttachments(); |
| 133 | 138 | |
| 134 | 139 | // The attachments was created and moved the the right folder, time to update the DB. |
| 135 | - if (!empty($_SESSION['temp_attachments'])) |
|
| 136 | - $this->createAtttach(); |
|
| 140 | + if (!empty($_SESSION['temp_attachments'])) { |
|
| 141 | + $this->createAtttach(); |
|
| 142 | + } |
|
| 137 | 143 | |
| 138 | 144 | // Set the response. |
| 139 | 145 | $this->setResponse(); |
@@ -146,8 +152,9 @@ discard block |
||
| 146 | 152 | { |
| 147 | 153 | global $context, $modSettings, $smcFunc, $user_info, $txt; |
| 148 | 154 | |
| 149 | - if (!isset($_FILES['attachment']['name'])) |
|
| 150 | - $_FILES['attachment']['tmp_name'] = array(); |
|
| 155 | + if (!isset($_FILES['attachment']['name'])) { |
|
| 156 | + $_FILES['attachment']['tmp_name'] = array(); |
|
| 157 | + } |
|
| 151 | 158 | |
| 152 | 159 | // If there are attachments, calculate the total size and how many. |
| 153 | 160 | $context['attachments']['total_size'] = 0; |
@@ -157,25 +164,30 @@ discard block |
||
| 157 | 164 | if (isset($_REQUEST['msg'])) |
| 158 | 165 | { |
| 159 | 166 | $context['attachments']['quantity'] = count($context['current_attachments']); |
| 160 | - foreach ($context['current_attachments'] as $attachment) |
|
| 161 | - $context['attachments']['total_size'] += $attachment['size']; |
|
| 167 | + foreach ($context['current_attachments'] as $attachment) { |
|
| 168 | + $context['attachments']['total_size'] += $attachment['size']; |
|
| 169 | + } |
|
| 162 | 170 | } |
| 163 | 171 | |
| 164 | 172 | // A bit of house keeping first. |
| 165 | - if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) |
|
| 166 | - unset($_SESSION['temp_attachments']); |
|
| 173 | + if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) { |
|
| 174 | + unset($_SESSION['temp_attachments']); |
|
| 175 | + } |
|
| 167 | 176 | |
| 168 | 177 | // Our infamous SESSION var, we are gonna have soo much fun with it! |
| 169 | - if (!isset($_SESSION['temp_attachments'])) |
|
| 170 | - $_SESSION['temp_attachments'] = array(); |
|
| 178 | + if (!isset($_SESSION['temp_attachments'])) { |
|
| 179 | + $_SESSION['temp_attachments'] = array(); |
|
| 180 | + } |
|
| 171 | 181 | |
| 172 | 182 | // Make sure we're uploading to the right place. |
| 173 | - if (!empty($modSettings['automanage_attachments'])) |
|
| 174 | - automanage_attachments_check_directory(); |
|
| 183 | + if (!empty($modSettings['automanage_attachments'])) { |
|
| 184 | + automanage_attachments_check_directory(); |
|
| 185 | + } |
|
| 175 | 186 | |
| 176 | 187 | // Is the attachments folder actually there? |
| 177 | - if (!empty($context['dir_creation_error'])) |
|
| 178 | - $this->_generalErrors[] = $context['dir_creation_error']; |
|
| 188 | + if (!empty($context['dir_creation_error'])) { |
|
| 189 | + $this->_generalErrors[] = $context['dir_creation_error']; |
|
| 190 | + } |
|
| 179 | 191 | |
| 180 | 192 | // The current attach folder ha some issues... |
| 181 | 193 | elseif (!is_dir($this->_attchDir)) |
@@ -200,13 +212,12 @@ discard block |
||
| 200 | 212 | ); |
| 201 | 213 | list ($context['attachments']['quantity'], $context['attachments']['total_size']) = $smcFunc['db_fetch_row']($request); |
| 202 | 214 | $smcFunc['db_free_result']($request); |
| 203 | - } |
|
| 204 | - |
|
| 205 | - else |
|
| 206 | - $context['attachments'] = array( |
|
| 215 | + } else { |
|
| 216 | + $context['attachments'] = array( |
|
| 207 | 217 | 'quantity' => 0, |
| 208 | 218 | 'total_size' => 0, |
| 209 | 219 | ); |
| 220 | + } |
|
| 210 | 221 | |
| 211 | 222 | // Check for other general errors here. |
| 212 | 223 | |
@@ -214,9 +225,10 @@ discard block |
||
| 214 | 225 | if (!empty($this->_generalErrors)) |
| 215 | 226 | { |
| 216 | 227 | // And delete the files 'cos they ain't going nowhere. |
| 217 | - foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) |
|
| 218 | - if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
| 228 | + foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) { |
|
| 229 | + if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
| 219 | 230 | unlink($_FILES['attachment']['tmp_name'][$n]); |
| 231 | + } |
|
| 220 | 232 | |
| 221 | 233 | $_FILES['attachment']['tmp_name'] = array(); |
| 222 | 234 | |
@@ -227,26 +239,29 @@ discard block |
||
| 227 | 239 | // Loop through $_FILES['attachment'] array and move each file to the current attachments folder. |
| 228 | 240 | foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) |
| 229 | 241 | { |
| 230 | - if ($_FILES['attachment']['name'][$n] == '') |
|
| 231 | - continue; |
|
| 242 | + if ($_FILES['attachment']['name'][$n] == '') { |
|
| 243 | + continue; |
|
| 244 | + } |
|
| 232 | 245 | |
| 233 | 246 | // First, let's first check for PHP upload errors. |
| 234 | 247 | $errors = array(); |
| 235 | 248 | if (!empty($_FILES['attachment']['error'][$n])) |
| 236 | 249 | { |
| 237 | - if ($_FILES['attachment']['error'][$n] == 2) |
|
| 238 | - $errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit'])); |
|
| 239 | - |
|
| 240 | - else |
|
| 241 | - log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]); |
|
| 250 | + if ($_FILES['attachment']['error'][$n] == 2) { |
|
| 251 | + $errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit'])); |
|
| 252 | + } else { |
|
| 253 | + log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]); |
|
| 254 | + } |
|
| 242 | 255 | |
| 243 | 256 | // Log this one, because... |
| 244 | - if ($_FILES['attachment']['error'][$n] == 6) |
|
| 245 | - log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical'); |
|
| 257 | + if ($_FILES['attachment']['error'][$n] == 6) { |
|
| 258 | + log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical'); |
|
| 259 | + } |
|
| 246 | 260 | |
| 247 | 261 | // Weird, no errors were cached, still fill out a generic one. |
| 248 | - if (empty($errors)) |
|
| 249 | - $errors[] = 'attach_php_error'; |
|
| 262 | + if (empty($errors)) { |
|
| 263 | + $errors[] = 'attach_php_error'; |
|
| 264 | + } |
|
| 250 | 265 | } |
| 251 | 266 | |
| 252 | 267 | // Try to move and rename the file before doing any more checks on it. |
@@ -266,16 +281,18 @@ discard block |
||
| 266 | 281 | ); |
| 267 | 282 | |
| 268 | 283 | // Move the file to the attachments folder with a temp name for now. |
| 269 | - if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName)) |
|
| 270 | - smf_chmod($destName, 0644); |
|
| 284 | + if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName)) { |
|
| 285 | + smf_chmod($destName, 0644); |
|
| 286 | + } |
|
| 271 | 287 | |
| 272 | 288 | // This is madness!! |
| 273 | 289 | else |
| 274 | 290 | { |
| 275 | 291 | // File couldn't be moved. |
| 276 | 292 | $_SESSION['temp_attachments'][$attachID]['errors'][] = 'attach_timeout'; |
| 277 | - if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
| 278 | - unlink($_FILES['attachment']['tmp_name'][$n]); |
|
| 293 | + if (file_exists($_FILES['attachment']['tmp_name'][$n])) { |
|
| 294 | + unlink($_FILES['attachment']['tmp_name'][$n]); |
|
| 295 | + } |
|
| 279 | 296 | } |
| 280 | 297 | } |
| 281 | 298 | |
@@ -288,13 +305,15 @@ discard block |
||
| 288 | 305 | 'errors' => $errors, |
| 289 | 306 | ); |
| 290 | 307 | |
| 291 | - if (file_exists($_FILES['attachment']['tmp_name'][$n])) |
|
| 292 | - unlink($_FILES['attachment']['tmp_name'][$n]); |
|
| 308 | + if (file_exists($_FILES['attachment']['tmp_name'][$n])) { |
|
| 309 | + unlink($_FILES['attachment']['tmp_name'][$n]); |
|
| 310 | + } |
|
| 293 | 311 | } |
| 294 | 312 | |
| 295 | 313 | // If there's no errors to this point. We still do need to apply some additional checks before we are finished. |
| 296 | - if (empty($_SESSION['temp_attachments'][$attachID]['errors'])) |
|
| 297 | - attachmentChecks($attachID); |
|
| 314 | + if (empty($_SESSION['temp_attachments'][$attachID]['errors'])) { |
|
| 315 | + attachmentChecks($attachID); |
|
| 316 | + } |
|
| 298 | 317 | } |
| 299 | 318 | |
| 300 | 319 | // Mod authors, finally a hook to hang an alternate attachment upload system upon |
@@ -333,23 +352,24 @@ discard block |
||
| 333 | 352 | 'errors' => $attachment['errors'], |
| 334 | 353 | ); |
| 335 | 354 | |
| 336 | - if (empty($attachment['errors'])) |
|
| 337 | - if (createAttachment($attachmentOptions)) |
|
| 355 | + if (empty($attachment['errors'])) { |
|
| 356 | + if (createAttachment($attachmentOptions)) |
|
| 338 | 357 | { |
| 339 | 358 | // Avoid JS getting confused. |
| 340 | 359 | $attachmentOptions['attachID'] = $attachmentOptions['id']; |
| 360 | + } |
|
| 341 | 361 | unset($attachmentOptions['id']); |
| 342 | 362 | |
| 343 | 363 | $_SESSION['already_attached'][$attachmentOptions['attachID']] = $attachmentOptions['attachID']; |
| 344 | 364 | |
| 345 | - if (!empty($attachmentOptions['thumb'])) |
|
| 346 | - $_SESSION['already_attached'][$attachmentOptions['thumb']] = $attachmentOptions['thumb']; |
|
| 347 | - |
|
| 348 | - if ($this->_msg) |
|
| 349 | - assignAttachments($_SESSION['already_attached'], $this->_msg); |
|
| 350 | - } |
|
| 365 | + if (!empty($attachmentOptions['thumb'])) { |
|
| 366 | + $_SESSION['already_attached'][$attachmentOptions['thumb']] = $attachmentOptions['thumb']; |
|
| 367 | + } |
|
| 351 | 368 | |
| 352 | - elseif (!empty($attachmentOptions['errors'])) |
|
| 369 | + if ($this->_msg) { |
|
| 370 | + assignAttachments($_SESSION['already_attached'], $this->_msg); |
|
| 371 | + } |
|
| 372 | + } elseif (!empty($attachmentOptions['errors'])) |
|
| 353 | 373 | { |
| 354 | 374 | // Sort out the errors for display and delete any associated files. |
| 355 | 375 | $log_these = array('attachments_no_create', 'attachments_no_write', 'attach_timeout', 'ran_out_of_space', 'cant_access_upload_path', 'attach_0_byte_file'); |
@@ -361,14 +381,16 @@ discard block |
||
| 361 | 381 | if (!is_array($error)) |
| 362 | 382 | { |
| 363 | 383 | $attachmentOptions['errors'][] = $txt[$error]; |
| 364 | - if (in_array($error, $log_these)) |
|
| 365 | - log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
| 384 | + if (in_array($error, $log_these)) { |
|
| 385 | + log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
| 386 | + } |
|
| 387 | + } else { |
|
| 388 | + $attachmentOptions['errors'][] = vsprintf($txt[$error[0]], $error[1]); |
|
| 366 | 389 | } |
| 367 | - else |
|
| 368 | - $attachmentOptions['errors'][] = vsprintf($txt[$error[0]], $error[1]); |
|
| 369 | 390 | } |
| 370 | - if (file_exists($attachment['tmp_name'])) |
|
| 371 | - unlink($attachment['tmp_name']); |
|
| 391 | + if (file_exists($attachment['tmp_name'])) { |
|
| 392 | + unlink($attachment['tmp_name']); |
|
| 393 | + } |
|
| 372 | 394 | } |
| 373 | 395 | |
| 374 | 396 | // Regardless of errors, pass the results. |
@@ -376,8 +398,9 @@ discard block |
||
| 376 | 398 | } |
| 377 | 399 | |
| 378 | 400 | // Temp save this on the db. |
| 379 | - if (!empty($_SESSION['already_attached'])) |
|
| 380 | - $this->_attachSuccess = $_SESSION['already_attached']; |
|
| 401 | + if (!empty($_SESSION['already_attached'])) { |
|
| 402 | + $this->_attachSuccess = $_SESSION['already_attached']; |
|
| 403 | + } |
|
| 381 | 404 | |
| 382 | 405 | unset($_SESSION['temp_attachments']); |
| 383 | 406 | } |
@@ -397,14 +420,16 @@ discard block |
||
| 397 | 420 | if ($this->_sa == 'add') |
| 398 | 421 | { |
| 399 | 422 | // Is there any generic errors? made some sense out of them! |
| 400 | - if ($this->_generalErrors) |
|
| 401 | - foreach ($this->_generalErrors as $k => $v) |
|
| 423 | + if ($this->_generalErrors) { |
|
| 424 | + foreach ($this->_generalErrors as $k => $v) |
|
| 402 | 425 | $this->_generalErrors[$k] = (is_array($v) ? vsprintf($txt[$v[0]], $v[1]) : $txt[$v]); |
| 426 | + } |
|
| 403 | 427 | |
| 404 | 428 | // Gotta urlencode the filename. |
| 405 | - if ($this->_attachResults) |
|
| 406 | - foreach ($this->_attachResults as $k => $v) |
|
| 429 | + if ($this->_attachResults) { |
|
| 430 | + foreach ($this->_attachResults as $k => $v) |
|
| 407 | 431 | $this->_attachResults[$k]['name'] = urlencode($this->_attachResults[$k]['name']); |
| 432 | + } |
|
| 408 | 433 | |
| 409 | 434 | $this->_response = array( |
| 410 | 435 | 'files' => $this->_attachResults ? $this->_attachResults : false, |
@@ -413,9 +438,10 @@ discard block |
||
| 413 | 438 | } |
| 414 | 439 | |
| 415 | 440 | // Rest of us mere mortals gets no special treatment... |
| 416 | - elseif (!empty($data)) |
|
| 417 | - if (!empty($data['text']) && !empty($txt[$data['text']])) |
|
| 441 | + elseif (!empty($data)) { |
|
| 442 | + if (!empty($data['text']) && !empty($txt[$data['text']])) |
|
| 418 | 443 | $this->_response['text'] = $txt[$data['text']]; |
| 444 | + } |
|
| 419 | 445 | } |
| 420 | 446 | |
| 421 | 447 | protected function sendResponse() |
@@ -424,11 +450,11 @@ discard block |
||
| 424 | 450 | |
| 425 | 451 | ob_end_clean(); |
| 426 | 452 | |
| 427 | - if (!empty($modSettings['CompressedOutput'])) |
|
| 428 | - @ob_start('ob_gzhandler'); |
|
| 429 | - |
|
| 430 | - else |
|
| 431 | - ob_start(); |
|
| 453 | + if (!empty($modSettings['CompressedOutput'])) { |
|
| 454 | + @ob_start('ob_gzhandler'); |
|
| 455 | + } else { |
|
| 456 | + ob_start(); |
|
| 457 | + } |
|
| 432 | 458 | |
| 433 | 459 | // Set the header. |
| 434 | 460 | header('Content-Type: application/json; charset='. $context['character_set'] .''); |
@@ -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 | /** |
@@ -44,8 +45,9 @@ discard block |
||
| 44 | 45 | $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : (allowedTo('manage_membergroups') ? 'index' : 'settings'); |
| 45 | 46 | |
| 46 | 47 | // Is it elsewhere? |
| 47 | - if (isset($subActions[$_REQUEST['sa']][2])) |
|
| 48 | - require_once($sourcedir . '/' . $subActions[$_REQUEST['sa']][2]); |
|
| 48 | + if (isset($subActions[$_REQUEST['sa']][2])) { |
|
| 49 | + require_once($sourcedir . '/' . $subActions[$_REQUEST['sa']][2]); |
|
| 50 | + } |
|
| 49 | 51 | |
| 50 | 52 | // Do the permission check, you might not be allowed her. |
| 51 | 53 | isAllowedTo($subActions[$_REQUEST['sa']][1]); |
@@ -104,19 +106,20 @@ discard block |
||
| 104 | 106 | 'function' => function ($rowData) use ($scripturl) |
| 105 | 107 | { |
| 106 | 108 | // Since the moderator group has no explicit members, no link is needed. |
| 107 | - if ($rowData['id_group'] == 3) |
|
| 108 | - $group_name = $rowData['group_name']; |
|
| 109 | - else |
|
| 109 | + if ($rowData['id_group'] == 3) { |
|
| 110 | + $group_name = $rowData['group_name']; |
|
| 111 | + } else |
|
| 110 | 112 | { |
| 111 | 113 | $color_style = empty($rowData['online_color']) ? '' : sprintf(' style="color: %1$s;"', $rowData['online_color']); |
| 112 | 114 | $group_name = sprintf('<a href="%1$s?action=admin;area=membergroups;sa=members;group=%2$d"%3$s>%4$s</a>', $scripturl, $rowData['id_group'], $color_style, $rowData['group_name']); |
| 113 | 115 | } |
| 114 | 116 | |
| 115 | 117 | // Add a help option for moderator and administrator. |
| 116 | - if ($rowData['id_group'] == 1) |
|
| 117 | - $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_administrator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
| 118 | - elseif ($rowData['id_group'] == 3) |
|
| 119 | - $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_moderator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
| 118 | + if ($rowData['id_group'] == 1) { |
|
| 119 | + $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_administrator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
| 120 | + } elseif ($rowData['id_group'] == 3) { |
|
| 121 | + $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_moderator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
| 122 | + } |
|
| 120 | 123 | |
| 121 | 124 | return $group_name; |
| 122 | 125 | }, |
@@ -330,12 +333,14 @@ discard block |
||
| 330 | 333 | call_integration_hook('integrate_add_membergroup', array($id_group, $postCountBasedGroup)); |
| 331 | 334 | |
| 332 | 335 | // Update the post groups now, if this is a post group! |
| 333 | - if (isset($_POST['min_posts'])) |
|
| 334 | - updateStats('postgroups'); |
|
| 336 | + if (isset($_POST['min_posts'])) { |
|
| 337 | + updateStats('postgroups'); |
|
| 338 | + } |
|
| 335 | 339 | |
| 336 | 340 | // You cannot set permissions for post groups if they are disabled. |
| 337 | - if ($postCountBasedGroup && empty($modSettings['permission_enable_postgroups'])) |
|
| 338 | - $_POST['perm_type'] = ''; |
|
| 341 | + if ($postCountBasedGroup && empty($modSettings['permission_enable_postgroups'])) { |
|
| 342 | + $_POST['perm_type'] = ''; |
|
| 343 | + } |
|
| 339 | 344 | |
| 340 | 345 | if ($_POST['perm_type'] == 'predefined') |
| 341 | 346 | { |
@@ -365,8 +370,9 @@ discard block |
||
| 365 | 370 | $smcFunc['db_free_result']($request); |
| 366 | 371 | |
| 367 | 372 | // Protected groups are... well, protected! |
| 368 | - if ($copy_type == 1) |
|
| 369 | - fatal_lang_error('membergroup_does_not_exist'); |
|
| 373 | + if ($copy_type == 1) { |
|
| 374 | + fatal_lang_error('membergroup_does_not_exist'); |
|
| 375 | + } |
|
| 370 | 376 | } |
| 371 | 377 | |
| 372 | 378 | // Don't allow copying of a real priviledged person! |
@@ -384,18 +390,20 @@ discard block |
||
| 384 | 390 | $inserts = array(); |
| 385 | 391 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 386 | 392 | { |
| 387 | - if (empty($context['illegal_permissions']) || !in_array($row['permission'], $context['illegal_permissions'])) |
|
| 388 | - $inserts[] = array($id_group, $row['permission'], $row['add_deny']); |
|
| 393 | + if (empty($context['illegal_permissions']) || !in_array($row['permission'], $context['illegal_permissions'])) { |
|
| 394 | + $inserts[] = array($id_group, $row['permission'], $row['add_deny']); |
|
| 395 | + } |
|
| 389 | 396 | } |
| 390 | 397 | $smcFunc['db_free_result']($request); |
| 391 | 398 | |
| 392 | - if (!empty($inserts)) |
|
| 393 | - $smcFunc['db_insert']('insert', |
|
| 399 | + if (!empty($inserts)) { |
|
| 400 | + $smcFunc['db_insert']('insert', |
|
| 394 | 401 | '{db_prefix}permissions', |
| 395 | 402 | array('id_group' => 'int', 'permission' => 'string', 'add_deny' => 'int'), |
| 396 | 403 | $inserts, |
| 397 | 404 | array('id_group', 'permission') |
| 398 | 405 | ); |
| 406 | + } |
|
| 399 | 407 | |
| 400 | 408 | $request = $smcFunc['db_query']('', ' |
| 401 | 409 | SELECT id_profile, permission, add_deny |
@@ -406,17 +414,19 @@ discard block |
||
| 406 | 414 | ) |
| 407 | 415 | ); |
| 408 | 416 | $inserts = array(); |
| 409 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 410 | - $inserts[] = array($id_group, $row['id_profile'], $row['permission'], $row['add_deny']); |
|
| 417 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 418 | + $inserts[] = array($id_group, $row['id_profile'], $row['permission'], $row['add_deny']); |
|
| 419 | + } |
|
| 411 | 420 | $smcFunc['db_free_result']($request); |
| 412 | 421 | |
| 413 | - if (!empty($inserts)) |
|
| 414 | - $smcFunc['db_insert']('insert', |
|
| 422 | + if (!empty($inserts)) { |
|
| 423 | + $smcFunc['db_insert']('insert', |
|
| 415 | 424 | '{db_prefix}board_permissions', |
| 416 | 425 | array('id_group' => 'int', 'id_profile' => 'int', 'permission' => 'string', 'add_deny' => 'int'), |
| 417 | 426 | $inserts, |
| 418 | 427 | array('id_group', 'id_profile', 'permission') |
| 419 | 428 | ); |
| 429 | + } |
|
| 420 | 430 | |
| 421 | 431 | // Also get some membergroup information if we're copying and not copying from guests... |
| 422 | 432 | if ($copy_id > 0 && $_POST['perm_type'] == 'copy') |
@@ -469,14 +479,15 @@ discard block |
||
| 469 | 479 | $changed_boards['allow'] = array(); |
| 470 | 480 | $changed_boards['deny'] = array(); |
| 471 | 481 | $changed_boards['ignore'] = array(); |
| 472 | - foreach ($accesses as $group_id => $action) |
|
| 473 | - $changed_boards[$action][] = (int) $group_id; |
|
| 482 | + foreach ($accesses as $group_id => $action) { |
|
| 483 | + $changed_boards[$action][] = (int) $group_id; |
|
| 484 | + } |
|
| 474 | 485 | |
| 475 | 486 | foreach (array('allow', 'deny') as $board_action) |
| 476 | 487 | { |
| 477 | 488 | // Only do this if they have special access requirements. |
| 478 | - if (!empty($changed_boards[$board_action])) |
|
| 479 | - $smcFunc['db_query']('', ' |
|
| 489 | + if (!empty($changed_boards[$board_action])) { |
|
| 490 | + $smcFunc['db_query']('', ' |
|
| 480 | 491 | UPDATE {db_prefix}boards |
| 481 | 492 | SET {raw:column} = CASE WHEN {raw:column} = {string:blank_string} THEN {string:group_id_string} ELSE CONCAT({raw:column}, {string:comma_group}) END |
| 482 | 493 | WHERE id_board IN ({array_int:board_list})', |
@@ -488,11 +499,13 @@ discard block |
||
| 488 | 499 | 'column' => $board_action == 'allow' ? 'member_groups' : 'deny_member_groups', |
| 489 | 500 | ) |
| 490 | 501 | ); |
| 502 | + } |
|
| 491 | 503 | } |
| 492 | 504 | |
| 493 | 505 | // If this is joinable then set it to show group membership in people's profiles. |
| 494 | - if (empty($modSettings['show_group_membership']) && $_POST['group_type'] > 1) |
|
| 495 | - updateSettings(array('show_group_membership' => 1)); |
|
| 506 | + if (empty($modSettings['show_group_membership']) && $_POST['group_type'] > 1) { |
|
| 507 | + updateSettings(array('show_group_membership' => 1)); |
|
| 508 | + } |
|
| 496 | 509 | |
| 497 | 510 | // Rebuild the group cache. |
| 498 | 511 | updateSettings(array( |
@@ -513,8 +526,9 @@ discard block |
||
| 513 | 526 | $context['undefined_group'] = !isset($_REQUEST['postgroup']) && !isset($_REQUEST['generalgroup']); |
| 514 | 527 | $context['allow_protected'] = allowedTo('admin_forum'); |
| 515 | 528 | |
| 516 | - if (!empty($modSettings['deny_boards_access'])) |
|
| 517 | - loadLanguage('ManagePermissions'); |
|
| 529 | + if (!empty($modSettings['deny_boards_access'])) { |
|
| 530 | + loadLanguage('ManagePermissions'); |
|
| 531 | + } |
|
| 518 | 532 | |
| 519 | 533 | $result = $smcFunc['db_query']('', ' |
| 520 | 534 | SELECT id_group, group_name |
@@ -531,11 +545,12 @@ discard block |
||
| 531 | 545 | ) |
| 532 | 546 | ); |
| 533 | 547 | $context['groups'] = array(); |
| 534 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 535 | - $context['groups'][] = array( |
|
| 548 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 549 | + $context['groups'][] = array( |
|
| 536 | 550 | 'id' => $row['id_group'], |
| 537 | 551 | 'name' => $row['group_name'] |
| 538 | 552 | ); |
| 553 | + } |
|
| 539 | 554 | $smcFunc['db_free_result']($result); |
| 540 | 555 | |
| 541 | 556 | $request = $smcFunc['db_query']('', ' |
@@ -552,12 +567,13 @@ discard block |
||
| 552 | 567 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 553 | 568 | { |
| 554 | 569 | // This category hasn't been set up yet.. |
| 555 | - if (!isset($context['categories'][$row['id_cat']])) |
|
| 556 | - $context['categories'][$row['id_cat']] = array( |
|
| 570 | + if (!isset($context['categories'][$row['id_cat']])) { |
|
| 571 | + $context['categories'][$row['id_cat']] = array( |
|
| 557 | 572 | 'id' => $row['id_cat'], |
| 558 | 573 | 'name' => $row['cat_name'], |
| 559 | 574 | 'boards' => array() |
| 560 | 575 | ); |
| 576 | + } |
|
| 561 | 577 | |
| 562 | 578 | // Set this board up, and let the template know when it's a child. (indent them..) |
| 563 | 579 | $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array( |
@@ -605,8 +621,9 @@ discard block |
||
| 605 | 621 | require_once($sourcedir . '/Subs-Membergroups.php'); |
| 606 | 622 | $result = deleteMembergroups((int) $_REQUEST['group']); |
| 607 | 623 | // Need to throw a warning if it went wrong, but this is the only one we have a message for... |
| 608 | - if ($result === 'group_cannot_delete_sub') |
|
| 609 | - fatal_lang_error('membergroups_cannot_delete_paid', false); |
|
| 624 | + if ($result === 'group_cannot_delete_sub') { |
|
| 625 | + fatal_lang_error('membergroups_cannot_delete_paid', false); |
|
| 626 | + } |
|
| 610 | 627 | |
| 611 | 628 | // Go back to the membergroup index. |
| 612 | 629 | redirectexit('action=admin;area=membergroups;'); |
@@ -628,8 +645,9 @@ discard block |
||
| 628 | 645 | |
| 629 | 646 | $_REQUEST['group'] = isset($_REQUEST['group']) && $_REQUEST['group'] > 0 ? (int) $_REQUEST['group'] : 0; |
| 630 | 647 | |
| 631 | - if (!empty($modSettings['deny_boards_access'])) |
|
| 632 | - loadLanguage('ManagePermissions'); |
|
| 648 | + if (!empty($modSettings['deny_boards_access'])) { |
|
| 649 | + loadLanguage('ManagePermissions'); |
|
| 650 | + } |
|
| 633 | 651 | |
| 634 | 652 | // Make sure this group is editable. |
| 635 | 653 | if (!empty($_REQUEST['group'])) |
@@ -651,8 +669,9 @@ discard block |
||
| 651 | 669 | } |
| 652 | 670 | |
| 653 | 671 | // Now, do we have a valid id? |
| 654 | - if (empty($_REQUEST['group'])) |
|
| 655 | - fatal_lang_error('membergroup_does_not_exist', false); |
|
| 672 | + if (empty($_REQUEST['group'])) { |
|
| 673 | + fatal_lang_error('membergroup_does_not_exist', false); |
|
| 674 | + } |
|
| 656 | 675 | |
| 657 | 676 | // People who can manage boards are a bit special. |
| 658 | 677 | require_once($sourcedir . '/Subs-Members.php'); |
@@ -683,8 +702,9 @@ discard block |
||
| 683 | 702 | require_once($sourcedir . '/Subs-Membergroups.php'); |
| 684 | 703 | $result = deleteMembergroups($_REQUEST['group']); |
| 685 | 704 | // Need to throw a warning if it went wrong, but this is the only one we have a message for... |
| 686 | - if ($result === 'group_cannot_delete_sub') |
|
| 687 | - fatal_lang_error('membergroups_cannot_delete_paid', false); |
|
| 705 | + if ($result === 'group_cannot_delete_sub') { |
|
| 706 | + fatal_lang_error('membergroups_cannot_delete_paid', false); |
|
| 707 | + } |
|
| 688 | 708 | |
| 689 | 709 | redirectexit('action=admin;area=membergroups;'); |
| 690 | 710 | } |
@@ -761,16 +781,18 @@ discard block |
||
| 761 | 781 | $request = $smcFunc['db_query']('', ' |
| 762 | 782 | SELECT id_board |
| 763 | 783 | FROM {db_prefix}boards'); |
| 764 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 765 | - $accesses[(int) $row['id_board']] = 'allow'; |
|
| 784 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 785 | + $accesses[(int) $row['id_board']] = 'allow'; |
|
| 786 | + } |
|
| 766 | 787 | $smcFunc['db_free_result']($request); |
| 767 | 788 | } |
| 768 | 789 | |
| 769 | 790 | $changed_boards['allow'] = array(); |
| 770 | 791 | $changed_boards['deny'] = array(); |
| 771 | 792 | $changed_boards['ignore'] = array(); |
| 772 | - foreach ($accesses as $group_id => $action) |
|
| 773 | - $changed_boards[$action][] = (int) $group_id; |
|
| 793 | + foreach ($accesses as $group_id => $action) { |
|
| 794 | + $changed_boards[$action][] = (int) $group_id; |
|
| 795 | + } |
|
| 774 | 796 | |
| 775 | 797 | foreach (array('allow', 'deny') as $board_action) |
| 776 | 798 | { |
@@ -786,8 +808,8 @@ discard block |
||
| 786 | 808 | 'column' => $board_action == 'allow' ? 'member_groups' : 'deny_member_groups', |
| 787 | 809 | ) |
| 788 | 810 | ); |
| 789 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 790 | - $smcFunc['db_query']('', ' |
|
| 811 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 812 | + $smcFunc['db_query']('', ' |
|
| 791 | 813 | UPDATE {db_prefix}boards |
| 792 | 814 | SET {raw:column} = {string:member_group_access} |
| 793 | 815 | WHERE id_board = {int:current_board}', |
@@ -797,11 +819,12 @@ discard block |
||
| 797 | 819 | 'column' => $board_action == 'allow' ? 'member_groups' : 'deny_member_groups', |
| 798 | 820 | ) |
| 799 | 821 | ); |
| 822 | + } |
|
| 800 | 823 | $smcFunc['db_free_result']($request); |
| 801 | 824 | |
| 802 | 825 | // Add the membergroup to all boards that hadn't been set yet. |
| 803 | - if (!empty($changed_boards[$board_action])) |
|
| 804 | - $smcFunc['db_query']('', ' |
|
| 826 | + if (!empty($changed_boards[$board_action])) { |
|
| 827 | + $smcFunc['db_query']('', ' |
|
| 805 | 828 | UPDATE {db_prefix}boards |
| 806 | 829 | SET {raw:column} = CASE WHEN {raw:column} = {string:blank_string} THEN {string:group_id_string} ELSE CONCAT({raw:column}, {string:comma_group}) END |
| 807 | 830 | WHERE id_board IN ({array_int:board_list}) |
@@ -815,6 +838,7 @@ discard block |
||
| 815 | 838 | 'column' => $board_action == 'allow' ? 'member_groups' : 'deny_member_groups', |
| 816 | 839 | ) |
| 817 | 840 | ); |
| 841 | + } |
|
| 818 | 842 | } |
| 819 | 843 | } |
| 820 | 844 | |
@@ -840,12 +864,14 @@ discard block |
||
| 840 | 864 | ) |
| 841 | 865 | ); |
| 842 | 866 | $updates = array(); |
| 843 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 844 | - $updates[$row['additional_groups']][] = $row['id_member']; |
|
| 867 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 868 | + $updates[$row['additional_groups']][] = $row['id_member']; |
|
| 869 | + } |
|
| 845 | 870 | $smcFunc['db_free_result']($request); |
| 846 | 871 | |
| 847 | - foreach ($updates as $additional_groups => $memberArray) |
|
| 848 | - updateMemberData($memberArray, array('additional_groups' => implode(',', array_diff(explode(',', $additional_groups), array((int) $_REQUEST['group']))))); |
|
| 872 | + foreach ($updates as $additional_groups => $memberArray) { |
|
| 873 | + updateMemberData($memberArray, array('additional_groups' => implode(',', array_diff(explode(',', $additional_groups), array((int) $_REQUEST['group']))))); |
|
| 874 | + } |
|
| 849 | 875 | |
| 850 | 876 | // Sorry, but post groups can't moderate boards |
| 851 | 877 | $request = $smcFunc['db_query']('', ' |
@@ -855,8 +881,7 @@ discard block |
||
| 855 | 881 | 'current_group' => (int) $_REQUEST['group'], |
| 856 | 882 | ) |
| 857 | 883 | ); |
| 858 | - } |
|
| 859 | - elseif ($_REQUEST['group'] != 3) |
|
| 884 | + } elseif ($_REQUEST['group'] != 3) |
|
| 860 | 885 | { |
| 861 | 886 | // Making it a hidden group? If so remove everyone with it as primary group (Actually, just make them additional). |
| 862 | 887 | if ($_POST['group_hidden'] == 2) |
@@ -871,8 +896,9 @@ discard block |
||
| 871 | 896 | ) |
| 872 | 897 | ); |
| 873 | 898 | $updates = array(); |
| 874 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 875 | - $updates[$row['additional_groups']][] = $row['id_member']; |
|
| 899 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 900 | + $updates[$row['additional_groups']][] = $row['id_member']; |
|
| 901 | + } |
|
| 876 | 902 | $smcFunc['db_free_result']($request); |
| 877 | 903 | |
| 878 | 904 | foreach ($updates as $additional_groups => $memberArray) |
@@ -914,8 +940,9 @@ discard block |
||
| 914 | 940 | $smcFunc['db_free_result']($request); |
| 915 | 941 | |
| 916 | 942 | // Do we need to update the setting? |
| 917 | - if ((empty($modSettings['show_group_membership']) && $have_joinable) || (!empty($modSettings['show_group_membership']) && !$have_joinable)) |
|
| 918 | - updateSettings(array('show_group_membership' => $have_joinable ? 1 : 0)); |
|
| 943 | + if ((empty($modSettings['show_group_membership']) && $have_joinable) || (!empty($modSettings['show_group_membership']) && !$have_joinable)) { |
|
| 944 | + updateSettings(array('show_group_membership' => $have_joinable ? 1 : 0)); |
|
| 945 | + } |
|
| 919 | 946 | } |
| 920 | 947 | |
| 921 | 948 | // Do we need to set inherited permissions? |
@@ -948,8 +975,9 @@ discard block |
||
| 948 | 975 | { |
| 949 | 976 | $moderators[$k] = trim($moderators[$k]); |
| 950 | 977 | |
| 951 | - if (strlen($moderators[$k]) == 0) |
|
| 952 | - unset($moderators[$k]); |
|
| 978 | + if (strlen($moderators[$k]) == 0) { |
|
| 979 | + unset($moderators[$k]); |
|
| 980 | + } |
|
| 953 | 981 | } |
| 954 | 982 | |
| 955 | 983 | // Find all the id_member's for the member_name's in the list. |
@@ -965,8 +993,9 @@ discard block |
||
| 965 | 993 | 'count' => count($moderators), |
| 966 | 994 | ) |
| 967 | 995 | ); |
| 968 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 969 | - $group_moderators[] = $row['id_member']; |
|
| 996 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 997 | + $group_moderators[] = $row['id_member']; |
|
| 998 | + } |
|
| 970 | 999 | $smcFunc['db_free_result']($request); |
| 971 | 1000 | } |
| 972 | 1001 | } |
@@ -974,8 +1003,9 @@ discard block |
||
| 974 | 1003 | if (!empty($_POST['moderator_list'])) |
| 975 | 1004 | { |
| 976 | 1005 | $moderators = array(); |
| 977 | - foreach ($_POST['moderator_list'] as $moderator) |
|
| 978 | - $moderators[] = (int) $moderator; |
|
| 1006 | + foreach ($_POST['moderator_list'] as $moderator) { |
|
| 1007 | + $moderators[] = (int) $moderator; |
|
| 1008 | + } |
|
| 979 | 1009 | |
| 980 | 1010 | if (!empty($moderators)) |
| 981 | 1011 | { |
@@ -989,8 +1019,9 @@ discard block |
||
| 989 | 1019 | 'num_moderators' => count($moderators), |
| 990 | 1020 | ) |
| 991 | 1021 | ); |
| 992 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 993 | - $group_moderators[] = $row['id_member']; |
|
| 1022 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1023 | + $group_moderators[] = $row['id_member']; |
|
| 1024 | + } |
|
| 994 | 1025 | $smcFunc['db_free_result']($request); |
| 995 | 1026 | } |
| 996 | 1027 | } |
@@ -1002,8 +1033,9 @@ discard block |
||
| 1002 | 1033 | if (!empty($group_moderators)) |
| 1003 | 1034 | { |
| 1004 | 1035 | $mod_insert = array(); |
| 1005 | - foreach ($group_moderators as $moderator) |
|
| 1006 | - $mod_insert[] = array($_REQUEST['group'], $moderator); |
|
| 1036 | + foreach ($group_moderators as $moderator) { |
|
| 1037 | + $mod_insert[] = array($_REQUEST['group'], $moderator); |
|
| 1038 | + } |
|
| 1007 | 1039 | |
| 1008 | 1040 | $smcFunc['db_insert']('insert', |
| 1009 | 1041 | '{db_prefix}group_moderators', |
@@ -1037,8 +1069,9 @@ discard block |
||
| 1037 | 1069 | 'current_group' => (int) $_REQUEST['group'], |
| 1038 | 1070 | ) |
| 1039 | 1071 | ); |
| 1040 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1041 | - fatal_lang_error('membergroup_does_not_exist', false); |
|
| 1072 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1073 | + fatal_lang_error('membergroup_does_not_exist', false); |
|
| 1074 | + } |
|
| 1042 | 1075 | $row = $smcFunc['db_fetch_assoc']($request); |
| 1043 | 1076 | $smcFunc['db_free_result']($request); |
| 1044 | 1077 | |
@@ -1075,14 +1108,16 @@ discard block |
||
| 1075 | 1108 | ) |
| 1076 | 1109 | ); |
| 1077 | 1110 | $context['group']['moderators'] = array(); |
| 1078 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1079 | - $context['group']['moderators'][$row['id_member']] = $row['real_name']; |
|
| 1111 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1112 | + $context['group']['moderators'][$row['id_member']] = $row['real_name']; |
|
| 1113 | + } |
|
| 1080 | 1114 | $smcFunc['db_free_result']($request); |
| 1081 | 1115 | |
| 1082 | 1116 | $context['group']['moderator_list'] = empty($context['group']['moderators']) ? '' : '"' . implode('", "', $context['group']['moderators']) . '"'; |
| 1083 | 1117 | |
| 1084 | - if (!empty($context['group']['moderators'])) |
|
| 1085 | - list ($context['group']['last_moderator_id']) = array_slice(array_keys($context['group']['moderators']), -1); |
|
| 1118 | + if (!empty($context['group']['moderators'])) { |
|
| 1119 | + list ($context['group']['last_moderator_id']) = array_slice(array_keys($context['group']['moderators']), -1); |
|
| 1120 | + } |
|
| 1086 | 1121 | |
| 1087 | 1122 | // Get a list of boards this membergroup is allowed to see. |
| 1088 | 1123 | $context['boards'] = array(); |
@@ -1102,12 +1137,13 @@ discard block |
||
| 1102 | 1137 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1103 | 1138 | { |
| 1104 | 1139 | // This category hasn't been set up yet.. |
| 1105 | - if (!isset($context['categories'][$row['id_cat']])) |
|
| 1106 | - $context['categories'][$row['id_cat']] = array( |
|
| 1140 | + if (!isset($context['categories'][$row['id_cat']])) { |
|
| 1141 | + $context['categories'][$row['id_cat']] = array( |
|
| 1107 | 1142 | 'id' => $row['id_cat'], |
| 1108 | 1143 | 'name' => $row['cat_name'], |
| 1109 | 1144 | 'boards' => array() |
| 1110 | 1145 | ); |
| 1146 | + } |
|
| 1111 | 1147 | |
| 1112 | 1148 | // Set this board up, and let the template know when it's a child. (indent them..) |
| 1113 | 1149 | $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array( |
@@ -1135,8 +1171,9 @@ discard block |
||
| 1135 | 1171 | } |
| 1136 | 1172 | |
| 1137 | 1173 | $max_boards = ceil(count($temp_boards) / 2); |
| 1138 | - if ($max_boards == 1) |
|
| 1139 | - $max_boards = 2; |
|
| 1174 | + if ($max_boards == 1) { |
|
| 1175 | + $max_boards = 2; |
|
| 1176 | + } |
|
| 1140 | 1177 | } |
| 1141 | 1178 | |
| 1142 | 1179 | // Get a list of all the image formats we can select. |
@@ -1159,19 +1196,22 @@ discard block |
||
| 1159 | 1196 | $image_info = getimagesize($settings['default_theme_dir'] . '/images/membericons/' . $value); |
| 1160 | 1197 | |
| 1161 | 1198 | // If this is bigger than 128 in width or 32 in height, skip this one. |
| 1162 | - if ($image_info == false || $image_info[0] > 128 || $image_info[1] > 32) |
|
| 1163 | - continue; |
|
| 1199 | + if ($image_info == false || $image_info[0] > 128 || $image_info[1] > 32) { |
|
| 1200 | + continue; |
|
| 1201 | + } |
|
| 1164 | 1202 | |
| 1165 | 1203 | // Else it's valid. Add it in. |
| 1166 | - else |
|
| 1167 | - $context['possible_icons'][] = $value; |
|
| 1204 | + else { |
|
| 1205 | + $context['possible_icons'][] = $value; |
|
| 1206 | + } |
|
| 1168 | 1207 | } |
| 1169 | 1208 | } |
| 1170 | 1209 | } |
| 1171 | 1210 | |
| 1172 | 1211 | // Insert our JS, if we have possible icons. |
| 1173 | - if (!empty($context['possible_icons'])) |
|
| 1174 | - loadJavaScriptFile('icondropdown.js', array('validate' => true), 'smf_icondropdown'); |
|
| 1212 | + if (!empty($context['possible_icons'])) { |
|
| 1213 | + loadJavaScriptFile('icondropdown.js', array('validate' => true), 'smf_icondropdown'); |
|
| 1214 | + } |
|
| 1175 | 1215 | |
| 1176 | 1216 | loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest'); |
| 1177 | 1217 | |
@@ -1193,8 +1233,9 @@ discard block |
||
| 1193 | 1233 | ) |
| 1194 | 1234 | ); |
| 1195 | 1235 | $context['inheritable_groups'] = array(); |
| 1196 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1197 | - $context['inheritable_groups'][$row['id_group']] = $row['group_name']; |
|
| 1236 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1237 | + $context['inheritable_groups'][$row['id_group']] = $row['group_name']; |
|
| 1238 | + } |
|
| 1198 | 1239 | $smcFunc['db_free_result']($request); |
| 1199 | 1240 | |
| 1200 | 1241 | call_integration_hook('integrate_view_membergroup'); |
@@ -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'), |