@@ -2241,9 +2241,9 @@ discard block |
||
| 2241 | 2241 | * |
| 2242 | 2242 | * @uses the template_include() function to include the file. |
| 2243 | 2243 | * @param string $template_name The name of the template to load |
| 2244 | - * @param array|string $style_sheets The name of a single stylesheet or an array of names of stylesheets to load |
|
| 2244 | + * @param string $style_sheets The name of a single stylesheet or an array of names of stylesheets to load |
|
| 2245 | 2245 | * @param bool $fatal If true, dies with an error message if the template cannot be found |
| 2246 | - * @return boolean Whether or not the template was loaded |
|
| 2246 | + * @return boolean|null Whether or not the template was loaded |
|
| 2247 | 2247 | */ |
| 2248 | 2248 | function loadTemplate($template_name, $style_sheets = array(), $fatal = true) |
| 2249 | 2249 | { |
@@ -2426,7 +2426,7 @@ discard block |
||
| 2426 | 2426 | * - all code added with this function is added to the same <style> tag so do make sure your css is valid! |
| 2427 | 2427 | * |
| 2428 | 2428 | * @param string $css Some css code |
| 2429 | - * @return void|bool Adds the CSS to the $context['css_header'] array or returns if no CSS is specified |
|
| 2429 | + * @return false|null Adds the CSS to the $context['css_header'] array or returns if no CSS is specified |
|
| 2430 | 2430 | */ |
| 2431 | 2431 | function addInlineCss($css) |
| 2432 | 2432 | { |
@@ -2442,7 +2442,7 @@ discard block |
||
| 2442 | 2442 | /** |
| 2443 | 2443 | * Add a Javascript file for output later |
| 2444 | 2444 | |
| 2445 | - * @param string $filename The name of the file to load |
|
| 2445 | + * @param string $fileName The name of the file to load |
|
| 2446 | 2446 | * @param array $params An array of parameter info |
| 2447 | 2447 | * Keys are the following: |
| 2448 | 2448 | * - ['external'] (true/false): define if the file is a externally located file. Needs to be set to true if you are loading an external file |
@@ -2540,7 +2540,7 @@ discard block |
||
| 2540 | 2540 | * |
| 2541 | 2541 | * @param string $javascript Some JS code |
| 2542 | 2542 | * @param bool $defer Whether the script should load in <head> or before the closing <html> tag |
| 2543 | - * @return void|bool Adds the code to one of the $context['javascript_inline'] arrays or returns if no JS was specified |
|
| 2543 | + * @return false|null Adds the code to one of the $context['javascript_inline'] arrays or returns if no JS was specified |
|
| 2544 | 2544 | */ |
| 2545 | 2545 | function addInlineJavaScript($javascript, $defer = false) |
| 2546 | 2546 | { |
@@ -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 | * Load the $modSettings array. |
@@ -25,13 +26,14 @@ discard block |
||
| 25 | 26 | global $cache_enable, $sourcedir, $context; |
| 26 | 27 | |
| 27 | 28 | // Most database systems have not set UTF-8 as their default input charset. |
| 28 | - if (!empty($db_character_set)) |
|
| 29 | - $smcFunc['db_query']('', ' |
|
| 29 | + if (!empty($db_character_set)) { |
|
| 30 | + $smcFunc['db_query']('', ' |
|
| 30 | 31 | SET NAMES {string:db_character_set}', |
| 31 | 32 | array( |
| 32 | 33 | 'db_character_set' => $db_character_set, |
| 33 | 34 | ) |
| 34 | 35 | ); |
| 36 | + } |
|
| 35 | 37 | |
| 36 | 38 | // We need some caching support, maybe. |
| 37 | 39 | loadCacheAccelerator(); |
@@ -46,27 +48,35 @@ discard block |
||
| 46 | 48 | ) |
| 47 | 49 | ); |
| 48 | 50 | $modSettings = array(); |
| 49 | - if (!$request) |
|
| 50 | - display_db_error(); |
|
| 51 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 52 | - $modSettings[$row[0]] = $row[1]; |
|
| 51 | + if (!$request) { |
|
| 52 | + display_db_error(); |
|
| 53 | + } |
|
| 54 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 55 | + $modSettings[$row[0]] = $row[1]; |
|
| 56 | + } |
|
| 53 | 57 | $smcFunc['db_free_result']($request); |
| 54 | 58 | |
| 55 | 59 | // Do a few things to protect against missing settings or settings with invalid values... |
| 56 | - if (empty($modSettings['defaultMaxTopics']) || $modSettings['defaultMaxTopics'] <= 0 || $modSettings['defaultMaxTopics'] > 999) |
|
| 57 | - $modSettings['defaultMaxTopics'] = 20; |
|
| 58 | - if (empty($modSettings['defaultMaxMessages']) || $modSettings['defaultMaxMessages'] <= 0 || $modSettings['defaultMaxMessages'] > 999) |
|
| 59 | - $modSettings['defaultMaxMessages'] = 15; |
|
| 60 | - if (empty($modSettings['defaultMaxMembers']) || $modSettings['defaultMaxMembers'] <= 0 || $modSettings['defaultMaxMembers'] > 999) |
|
| 61 | - $modSettings['defaultMaxMembers'] = 30; |
|
| 62 | - if (empty($modSettings['defaultMaxListItems']) || $modSettings['defaultMaxListItems'] <= 0 || $modSettings['defaultMaxListItems'] > 999) |
|
| 63 | - $modSettings['defaultMaxListItems'] = 15; |
|
| 60 | + if (empty($modSettings['defaultMaxTopics']) || $modSettings['defaultMaxTopics'] <= 0 || $modSettings['defaultMaxTopics'] > 999) { |
|
| 61 | + $modSettings['defaultMaxTopics'] = 20; |
|
| 62 | + } |
|
| 63 | + if (empty($modSettings['defaultMaxMessages']) || $modSettings['defaultMaxMessages'] <= 0 || $modSettings['defaultMaxMessages'] > 999) { |
|
| 64 | + $modSettings['defaultMaxMessages'] = 15; |
|
| 65 | + } |
|
| 66 | + if (empty($modSettings['defaultMaxMembers']) || $modSettings['defaultMaxMembers'] <= 0 || $modSettings['defaultMaxMembers'] > 999) { |
|
| 67 | + $modSettings['defaultMaxMembers'] = 30; |
|
| 68 | + } |
|
| 69 | + if (empty($modSettings['defaultMaxListItems']) || $modSettings['defaultMaxListItems'] <= 0 || $modSettings['defaultMaxListItems'] > 999) { |
|
| 70 | + $modSettings['defaultMaxListItems'] = 15; |
|
| 71 | + } |
|
| 64 | 72 | |
| 65 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
| 66 | - $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
| 73 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
| 74 | + $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
| 75 | + } |
|
| 67 | 76 | |
| 68 | - if (!empty($cache_enable)) |
|
| 69 | - cache_put_data('modSettings', $modSettings, 90); |
|
| 77 | + if (!empty($cache_enable)) { |
|
| 78 | + cache_put_data('modSettings', $modSettings, 90); |
|
| 79 | + } |
|
| 70 | 80 | } |
| 71 | 81 | |
| 72 | 82 | $modSettings['cache_enable'] = $cache_enable; |
@@ -86,8 +96,9 @@ discard block |
||
| 86 | 96 | }; |
| 87 | 97 | $fix_utf8mb4 = function($string) use ($utf8) |
| 88 | 98 | { |
| 89 | - if (!$utf8) |
|
| 90 | - return $string; |
|
| 99 | + if (!$utf8) { |
|
| 100 | + return $string; |
|
| 101 | + } |
|
| 91 | 102 | |
| 92 | 103 | $i = 0; |
| 93 | 104 | $len = strlen($string); |
@@ -99,18 +110,15 @@ discard block |
||
| 99 | 110 | { |
| 100 | 111 | $new_string .= $string[$i]; |
| 101 | 112 | $i++; |
| 102 | - } |
|
| 103 | - elseif ($ord < 224) |
|
| 113 | + } elseif ($ord < 224) |
|
| 104 | 114 | { |
| 105 | 115 | $new_string .= $string[$i] . $string[$i + 1]; |
| 106 | 116 | $i += 2; |
| 107 | - } |
|
| 108 | - elseif ($ord < 240) |
|
| 117 | + } elseif ($ord < 240) |
|
| 109 | 118 | { |
| 110 | 119 | $new_string .= $string[$i] . $string[$i + 1] . $string[$i + 2]; |
| 111 | 120 | $i += 3; |
| 112 | - } |
|
| 113 | - elseif ($ord < 248) |
|
| 121 | + } elseif ($ord < 248) |
|
| 114 | 122 | { |
| 115 | 123 | // Magic happens. |
| 116 | 124 | $val = (ord($string[$i]) & 0x07) << 18; |
@@ -154,8 +162,7 @@ discard block |
||
| 154 | 162 | { |
| 155 | 163 | $result = array_search($needle, array_slice($haystack_arr, $offset)); |
| 156 | 164 | return is_int($result) ? $result + $offset : false; |
| 157 | - } |
|
| 158 | - else |
|
| 165 | + } else |
|
| 159 | 166 | { |
| 160 | 167 | $needle_arr = preg_split('~(&#' . (empty($modSettings['disableEntityCheck']) ? '\d{1,7}' : '021') . ';|"|&|<|>| |.)~' . ($utf8 ? 'u' : '') . '', $ent_check($needle), -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); |
| 161 | 168 | $needle_size = count($needle_arr); |
@@ -164,8 +171,9 @@ discard block |
||
| 164 | 171 | while ((int) $result === $result) |
| 165 | 172 | { |
| 166 | 173 | $offset += $result; |
| 167 | - if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr) |
|
| 168 | - return $offset; |
|
| 174 | + if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr) { |
|
| 175 | + return $offset; |
|
| 176 | + } |
|
| 169 | 177 | $result = array_search($needle_arr[0], array_slice($haystack_arr, ++$offset)); |
| 170 | 178 | } |
| 171 | 179 | return false; |
@@ -203,8 +211,9 @@ discard block |
||
| 203 | 211 | $string = $ent_check($string); |
| 204 | 212 | preg_match('~^(' . $ent_list . '|.){' . $smcFunc['strlen'](substr($string, 0, $length)) . '}~' . ($utf8 ? 'u' : ''), $string, $matches); |
| 205 | 213 | $string = $matches[0]; |
| 206 | - while (strlen($string) > $length) |
|
| 207 | - $string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string); |
|
| 214 | + while (strlen($string) > $length) { |
|
| 215 | + $string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string); |
|
| 216 | + } |
|
| 208 | 217 | return $string; |
| 209 | 218 | }, |
| 210 | 219 | 'ucfirst' => $utf8 ? function($string) use (&$smcFunc) |
@@ -214,23 +223,25 @@ discard block |
||
| 214 | 223 | 'ucwords' => $utf8 ? function($string) use (&$smcFunc) |
| 215 | 224 | { |
| 216 | 225 | $words = preg_split('~([\s\r\n\t]+)~', $string, -1, PREG_SPLIT_DELIM_CAPTURE); |
| 217 | - for ($i = 0, $n = count($words); $i < $n; $i += 2) |
|
| 218 | - $words[$i] = $smcFunc['ucfirst']($words[$i]); |
|
| 226 | + for ($i = 0, $n = count($words); $i < $n; $i += 2) { |
|
| 227 | + $words[$i] = $smcFunc['ucfirst']($words[$i]); |
|
| 228 | + } |
|
| 219 | 229 | return implode('', $words); |
| 220 | 230 | } : 'ucwords', |
| 221 | 231 | ); |
| 222 | 232 | |
| 223 | 233 | // Setting the timezone is a requirement for some functions. |
| 224 | - if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list())) |
|
| 225 | - date_default_timezone_set($modSettings['default_timezone']); |
|
| 226 | - else |
|
| 234 | + if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list())) { |
|
| 235 | + date_default_timezone_set($modSettings['default_timezone']); |
|
| 236 | + } else |
|
| 227 | 237 | { |
| 228 | 238 | // Get PHP's default timezone, if set |
| 229 | 239 | $ini_tz = ini_get('date.timezone'); |
| 230 | - if (!empty($ini_tz)) |
|
| 231 | - $modSettings['default_timezone'] = $ini_tz; |
|
| 232 | - else |
|
| 233 | - $modSettings['default_timezone'] = ''; |
|
| 240 | + if (!empty($ini_tz)) { |
|
| 241 | + $modSettings['default_timezone'] = $ini_tz; |
|
| 242 | + } else { |
|
| 243 | + $modSettings['default_timezone'] = ''; |
|
| 244 | + } |
|
| 234 | 245 | |
| 235 | 246 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
| 236 | 247 | if (!in_array($modSettings['default_timezone'], timezone_identifiers_list())) |
@@ -248,22 +259,26 @@ discard block |
||
| 248 | 259 | if (($modSettings['load_average'] = cache_get_data('loadavg', 90)) == null) |
| 249 | 260 | { |
| 250 | 261 | $modSettings['load_average'] = @file_get_contents('/proc/loadavg'); |
| 251 | - if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0) |
|
| 252 | - $modSettings['load_average'] = (float) $matches[1]; |
|
| 253 | - elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0) |
|
| 254 | - $modSettings['load_average'] = (float) $matches[1]; |
|
| 255 | - else |
|
| 256 | - unset($modSettings['load_average']); |
|
| 262 | + if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0) { |
|
| 263 | + $modSettings['load_average'] = (float) $matches[1]; |
|
| 264 | + } elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0) { |
|
| 265 | + $modSettings['load_average'] = (float) $matches[1]; |
|
| 266 | + } else { |
|
| 267 | + unset($modSettings['load_average']); |
|
| 268 | + } |
|
| 257 | 269 | |
| 258 | - if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
|
| 259 | - cache_put_data('loadavg', $modSettings['load_average'], 90); |
|
| 270 | + if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) { |
|
| 271 | + cache_put_data('loadavg', $modSettings['load_average'], 90); |
|
| 272 | + } |
|
| 260 | 273 | } |
| 261 | 274 | |
| 262 | - if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
|
| 263 | - call_integration_hook('integrate_load_average', array($modSettings['load_average'])); |
|
| 275 | + if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) { |
|
| 276 | + call_integration_hook('integrate_load_average', array($modSettings['load_average'])); |
|
| 277 | + } |
|
| 264 | 278 | |
| 265 | - if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum']) |
|
| 266 | - display_loadavg_error(); |
|
| 279 | + if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum']) { |
|
| 280 | + display_loadavg_error(); |
|
| 281 | + } |
|
| 267 | 282 | } |
| 268 | 283 | |
| 269 | 284 | // Is post moderation alive and well? Everywhere else assumes this has been defined, so let's make sure it is. |
@@ -284,8 +299,9 @@ discard block |
||
| 284 | 299 | if (defined('SMF_INTEGRATION_SETTINGS')) |
| 285 | 300 | { |
| 286 | 301 | $integration_settings = smf_json_decode(SMF_INTEGRATION_SETTINGS, true); |
| 287 | - foreach ($integration_settings as $hook => $function) |
|
| 288 | - add_integration_function($hook, $function, '', false); |
|
| 302 | + foreach ($integration_settings as $hook => $function) { |
|
| 303 | + add_integration_function($hook, $function, '', false); |
|
| 304 | + } |
|
| 289 | 305 | } |
| 290 | 306 | |
| 291 | 307 | // Any files to pre include? |
@@ -295,8 +311,9 @@ discard block |
||
| 295 | 311 | foreach ($pre_includes as $include) |
| 296 | 312 | { |
| 297 | 313 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
| 298 | - if (file_exists($include)) |
|
| 299 | - require_once($include); |
|
| 314 | + if (file_exists($include)) { |
|
| 315 | + require_once($include); |
|
| 316 | + } |
|
| 300 | 317 | } |
| 301 | 318 | } |
| 302 | 319 | |
@@ -400,27 +417,28 @@ discard block |
||
| 400 | 417 | break; |
| 401 | 418 | } |
| 402 | 419 | } |
| 420 | + } else { |
|
| 421 | + $id_member = 0; |
|
| 403 | 422 | } |
| 404 | - else |
|
| 405 | - $id_member = 0; |
|
| 406 | 423 | |
| 407 | 424 | if (empty($id_member) && isset($_COOKIE[$cookiename])) |
| 408 | 425 | { |
| 409 | 426 | $cookie_data = smf_json_decode($_COOKIE[$cookiename], true, false); |
| 410 | 427 | |
| 411 | - if (empty($cookie_data)) |
|
| 412 | - $cookie_data = safe_unserialize($_COOKIE[$cookiename]); |
|
| 428 | + if (empty($cookie_data)) { |
|
| 429 | + $cookie_data = safe_unserialize($_COOKIE[$cookiename]); |
|
| 430 | + } |
|
| 413 | 431 | |
| 414 | 432 | list ($id_member, $password) = $cookie_data; |
| 415 | 433 | $id_member = !empty($id_member) && strlen($password) > 0 ? (int) $id_member : 0; |
| 416 | - } |
|
| 417 | - elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA']))) |
|
| 434 | + } elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA']))) |
|
| 418 | 435 | { |
| 419 | 436 | // @todo Perhaps we can do some more checking on this, such as on the first octet of the IP? |
| 420 | 437 | $cookie_data = smf_json_decode($_SESSION['login_' . $cookiename]); |
| 421 | 438 | |
| 422 | - if (empty($cookie_data)) |
|
| 423 | - $cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
| 439 | + if (empty($cookie_data)) { |
|
| 440 | + $cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
| 441 | + } |
|
| 424 | 442 | |
| 425 | 443 | list ($id_member, $password, $login_span) = $cookie_data; |
| 426 | 444 | $id_member = !empty($id_member) && strlen($password) == 128 && $login_span > time() ? (int) $id_member : 0; |
@@ -445,30 +463,34 @@ discard block |
||
| 445 | 463 | $user_settings = $smcFunc['db_fetch_assoc']($request); |
| 446 | 464 | $smcFunc['db_free_result']($request); |
| 447 | 465 | |
| 448 | - if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false) |
|
| 449 | - $user_settings['avatar'] = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($user_settings['avatar']) . '&hash=' . md5($user_settings['avatar'] . $image_proxy_secret); |
|
| 466 | + if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false) { |
|
| 467 | + $user_settings['avatar'] = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($user_settings['avatar']) . '&hash=' . md5($user_settings['avatar'] . $image_proxy_secret); |
|
| 468 | + } |
|
| 450 | 469 | |
| 451 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 452 | - cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
| 470 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 471 | + cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
| 472 | + } |
|
| 453 | 473 | } |
| 454 | 474 | |
| 455 | 475 | // Did we find 'im? If not, junk it. |
| 456 | 476 | if (!empty($user_settings)) |
| 457 | 477 | { |
| 458 | 478 | // As much as the password should be right, we can assume the integration set things up. |
| 459 | - if (!empty($already_verified) && $already_verified === true) |
|
| 460 | - $check = true; |
|
| 479 | + if (!empty($already_verified) && $already_verified === true) { |
|
| 480 | + $check = true; |
|
| 481 | + } |
|
| 461 | 482 | // SHA-512 hash should be 128 characters long. |
| 462 | - elseif (strlen($password) == 128) |
|
| 463 | - $check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password; |
|
| 464 | - else |
|
| 465 | - $check = false; |
|
| 483 | + elseif (strlen($password) == 128) { |
|
| 484 | + $check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password; |
|
| 485 | + } else { |
|
| 486 | + $check = false; |
|
| 487 | + } |
|
| 466 | 488 | |
| 467 | 489 | // Wrong password or not activated - either way, you're going nowhere. |
| 468 | 490 | $id_member = $check && ($user_settings['is_activated'] == 1 || $user_settings['is_activated'] == 11) ? (int) $user_settings['id_member'] : 0; |
| 491 | + } else { |
|
| 492 | + $id_member = 0; |
|
| 469 | 493 | } |
| 470 | - else |
|
| 471 | - $id_member = 0; |
|
| 472 | 494 | |
| 473 | 495 | // If we no longer have the member maybe they're being all hackey, stop brute force! |
| 474 | 496 | if (!$id_member) |
@@ -490,13 +512,15 @@ discard block |
||
| 490 | 512 | { |
| 491 | 513 | $tfa_data = smf_json_decode($_COOKIE[$tfacookie]); |
| 492 | 514 | |
| 493 | - if (is_null($tfa_data)) |
|
| 494 | - $tfa_data = safe_unserialize($_COOKIE[$tfacookie]); |
|
| 515 | + if (is_null($tfa_data)) { |
|
| 516 | + $tfa_data = safe_unserialize($_COOKIE[$tfacookie]); |
|
| 517 | + } |
|
| 495 | 518 | |
| 496 | 519 | list ($tfamember, $tfasecret) = $tfa_data; |
| 497 | 520 | |
| 498 | - if ((int) $tfamember != $id_member) |
|
| 499 | - $tfasecret = null; |
|
| 521 | + if ((int) $tfamember != $id_member) { |
|
| 522 | + $tfasecret = null; |
|
| 523 | + } |
|
| 500 | 524 | } |
| 501 | 525 | |
| 502 | 526 | if (empty($tfasecret) || hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']) != $tfasecret) |
@@ -516,10 +540,12 @@ discard block |
||
| 516 | 540 | // Are we forcing 2FA? Need to check if the user groups actually require 2FA |
| 517 | 541 | elseif (!empty($modSettings['tfa_mode']) && $modSettings['tfa_mode'] >= 2 && $id_member && empty($user_settings['tfa_secret'])) |
| 518 | 542 | { |
| 519 | - if ($modSettings['tfa_mode'] == 2) //only do this if we are just forcing SOME membergroups |
|
| 543 | + if ($modSettings['tfa_mode'] == 2) { |
|
| 544 | + //only do this if we are just forcing SOME membergroups |
|
| 520 | 545 | { |
| 521 | 546 | //Build an array of ALL user membergroups. |
| 522 | 547 | $full_groups = array($user_settings['id_group']); |
| 548 | + } |
|
| 523 | 549 | if (!empty($user_settings['additional_groups'])) |
| 524 | 550 | { |
| 525 | 551 | $full_groups = array_merge($full_groups, explode(',', $user_settings['additional_groups'])); |
@@ -539,15 +565,17 @@ discard block |
||
| 539 | 565 | ); |
| 540 | 566 | $row = $smcFunc['db_fetch_assoc']($request); |
| 541 | 567 | $smcFunc['db_free_result']($request); |
| 568 | + } else { |
|
| 569 | + $row['total'] = 1; |
|
| 542 | 570 | } |
| 543 | - else |
|
| 544 | - $row['total'] = 1; //simplifies logics in the next "if" |
|
| 571 | + //simplifies logics in the next "if" |
|
| 545 | 572 | |
| 546 | 573 | $area = !empty($_REQUEST['area']) ? $_REQUEST['area'] : ''; |
| 547 | 574 | $action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : ''; |
| 548 | 575 | |
| 549 | - if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) |
|
| 550 | - redirectexit('action=profile;area=tfasetup;forced'); |
|
| 576 | + if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) { |
|
| 577 | + redirectexit('action=profile;area=tfasetup;forced'); |
|
| 578 | + } |
|
| 551 | 579 | } |
| 552 | 580 | } |
| 553 | 581 | |
@@ -584,33 +612,37 @@ discard block |
||
| 584 | 612 | updateMemberData($id_member, array('id_msg_last_visit' => (int) $modSettings['maxMsgID'], 'last_login' => time(), 'member_ip' => $_SERVER['REMOTE_ADDR'], 'member_ip2' => $_SERVER['BAN_CHECK_IP'])); |
| 585 | 613 | $user_settings['last_login'] = time(); |
| 586 | 614 | |
| 587 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 588 | - cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
| 615 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 616 | + cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
| 617 | + } |
|
| 589 | 618 | |
| 590 | - if (!empty($modSettings['cache_enable'])) |
|
| 591 | - cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600); |
|
| 619 | + if (!empty($modSettings['cache_enable'])) { |
|
| 620 | + cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600); |
|
| 621 | + } |
|
| 592 | 622 | } |
| 623 | + } elseif (empty($_SESSION['id_msg_last_visit'])) { |
|
| 624 | + $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit']; |
|
| 593 | 625 | } |
| 594 | - elseif (empty($_SESSION['id_msg_last_visit'])) |
|
| 595 | - $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit']; |
|
| 596 | 626 | |
| 597 | 627 | $username = $user_settings['member_name']; |
| 598 | 628 | |
| 599 | - if (empty($user_settings['additional_groups'])) |
|
| 600 | - $user_info = array( |
|
| 629 | + if (empty($user_settings['additional_groups'])) { |
|
| 630 | + $user_info = array( |
|
| 601 | 631 | 'groups' => array($user_settings['id_group'], $user_settings['id_post_group']) |
| 602 | 632 | ); |
| 603 | - else |
|
| 604 | - $user_info = array( |
|
| 633 | + } else { |
|
| 634 | + $user_info = array( |
|
| 605 | 635 | 'groups' => array_merge( |
| 606 | 636 | array($user_settings['id_group'], $user_settings['id_post_group']), |
| 607 | 637 | explode(',', $user_settings['additional_groups']) |
| 608 | 638 | ) |
| 609 | 639 | ); |
| 640 | + } |
|
| 610 | 641 | |
| 611 | 642 | // Because history has proven that it is possible for groups to go bad - clean up in case. |
| 612 | - foreach ($user_info['groups'] as $k => $v) |
|
| 613 | - $user_info['groups'][$k] = (int) $v; |
|
| 643 | + foreach ($user_info['groups'] as $k => $v) { |
|
| 644 | + $user_info['groups'][$k] = (int) $v; |
|
| 645 | + } |
|
| 614 | 646 | |
| 615 | 647 | // This is a logged in user, so definitely not a spider. |
| 616 | 648 | $user_info['possibly_robot'] = false; |
@@ -624,8 +656,7 @@ discard block |
||
| 624 | 656 | $time_system = new DateTime('now', $tz_system); |
| 625 | 657 | $time_user = new DateTime('now', $tz_user); |
| 626 | 658 | $user_info['time_offset'] = ($tz_user->getOffset($time_user) - $tz_system->getOffset($time_system)) / 3600; |
| 627 | - } |
|
| 628 | - else |
|
| 659 | + } else |
|
| 629 | 660 | { |
| 630 | 661 | // !!! Compatibility. |
| 631 | 662 | $user_info['time_offset'] = empty($user_settings['time_offset']) ? 0 : $user_settings['time_offset']; |
@@ -639,16 +670,18 @@ discard block |
||
| 639 | 670 | $user_info = array('groups' => array(-1)); |
| 640 | 671 | $user_settings = array(); |
| 641 | 672 | |
| 642 | - if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) |
|
| 643 | - $_COOKIE[$cookiename] = ''; |
|
| 673 | + if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) { |
|
| 674 | + $_COOKIE[$cookiename] = ''; |
|
| 675 | + } |
|
| 644 | 676 | |
| 645 | 677 | // Expire the 2FA cookie |
| 646 | 678 | if (isset($_COOKIE[$cookiename . '_tfa']) && empty($context['tfa_member'])) |
| 647 | 679 | { |
| 648 | 680 | $tfa_data = smf_json_decode($_COOKIE[$cookiename . '_tfa'], true); |
| 649 | 681 | |
| 650 | - if (is_null($tfa_data)) |
|
| 651 | - $tfa_data = safe_unserialize($_COOKIE[$cookiename . '_tfa']); |
|
| 682 | + if (is_null($tfa_data)) { |
|
| 683 | + $tfa_data = safe_unserialize($_COOKIE[$cookiename . '_tfa']); |
|
| 684 | + } |
|
| 652 | 685 | |
| 653 | 686 | list ($id, $user, $exp, $state, $preserve) = $tfa_data; |
| 654 | 687 | |
@@ -660,19 +693,20 @@ discard block |
||
| 660 | 693 | } |
| 661 | 694 | |
| 662 | 695 | // Create a login token if it doesn't exist yet. |
| 663 | - if (!isset($_SESSION['token']['post-login'])) |
|
| 664 | - createToken('login'); |
|
| 665 | - else |
|
| 666 | - list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login']; |
|
| 696 | + if (!isset($_SESSION['token']['post-login'])) { |
|
| 697 | + createToken('login'); |
|
| 698 | + } else { |
|
| 699 | + list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login']; |
|
| 700 | + } |
|
| 667 | 701 | |
| 668 | 702 | // Do we perhaps think this is a search robot? Check every five minutes just in case... |
| 669 | 703 | if ((!empty($modSettings['spider_mode']) || !empty($modSettings['spider_group'])) && (!isset($_SESSION['robot_check']) || $_SESSION['robot_check'] < time() - 300)) |
| 670 | 704 | { |
| 671 | 705 | require_once($sourcedir . '/ManageSearchEngines.php'); |
| 672 | 706 | $user_info['possibly_robot'] = SpiderCheck(); |
| 707 | + } elseif (!empty($modSettings['spider_mode'])) { |
|
| 708 | + $user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0; |
|
| 673 | 709 | } |
| 674 | - elseif (!empty($modSettings['spider_mode'])) |
|
| 675 | - $user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0; |
|
| 676 | 710 | // If we haven't turned on proper spider hunts then have a guess! |
| 677 | 711 | else |
| 678 | 712 | { |
@@ -720,8 +754,9 @@ discard block |
||
| 720 | 754 | $user_info['groups'] = array_unique($user_info['groups']); |
| 721 | 755 | |
| 722 | 756 | // Make sure that the last item in the ignore boards array is valid. If the list was too long it could have an ending comma that could cause problems. |
| 723 | - if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) |
|
| 724 | - unset($user_info['ignoreboards'][$tmp]); |
|
| 757 | + if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) { |
|
| 758 | + unset($user_info['ignoreboards'][$tmp]); |
|
| 759 | + } |
|
| 725 | 760 | |
| 726 | 761 | // Allow the user to change their language. |
| 727 | 762 | if (!empty($modSettings['userLanguage'])) |
@@ -734,31 +769,36 @@ discard block |
||
| 734 | 769 | $user_info['language'] = strtr($_GET['language'], './\\:', '____'); |
| 735 | 770 | |
| 736 | 771 | // Make it permanent for members. |
| 737 | - if (!empty($user_info['id'])) |
|
| 738 | - updateMemberData($user_info['id'], array('lngfile' => $user_info['language'])); |
|
| 739 | - else |
|
| 740 | - $_SESSION['language'] = $user_info['language']; |
|
| 772 | + if (!empty($user_info['id'])) { |
|
| 773 | + updateMemberData($user_info['id'], array('lngfile' => $user_info['language'])); |
|
| 774 | + } else { |
|
| 775 | + $_SESSION['language'] = $user_info['language']; |
|
| 776 | + } |
|
| 777 | + } elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) { |
|
| 778 | + $user_info['language'] = strtr($_SESSION['language'], './\\:', '____'); |
|
| 741 | 779 | } |
| 742 | - elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) |
|
| 743 | - $user_info['language'] = strtr($_SESSION['language'], './\\:', '____'); |
|
| 744 | 780 | } |
| 745 | 781 | |
| 746 | 782 | // Just build this here, it makes it easier to change/use - administrators can see all boards. |
| 747 | - if ($user_info['is_admin']) |
|
| 748 | - $user_info['query_see_board'] = '1=1'; |
|
| 783 | + if ($user_info['is_admin']) { |
|
| 784 | + $user_info['query_see_board'] = '1=1'; |
|
| 785 | + } |
|
| 749 | 786 | // Otherwise just the groups in $user_info['groups']. |
| 750 | - else |
|
| 751 | - $user_info['query_see_board'] = '((FIND_IN_SET(' . implode(', b.member_groups) != 0 OR FIND_IN_SET(', $user_info['groups']) . ', b.member_groups) != 0)' . (!empty($modSettings['deny_boards_access']) ? ' AND (FIND_IN_SET(' . implode(', b.deny_member_groups) = 0 AND FIND_IN_SET(', $user_info['groups']) . ', b.deny_member_groups) = 0)' : '') . (isset($user_info['mod_cache']) ? ' OR ' . $user_info['mod_cache']['mq'] : '') . ')'; |
|
| 787 | + else { |
|
| 788 | + $user_info['query_see_board'] = '((FIND_IN_SET(' . implode(', b.member_groups) != 0 OR FIND_IN_SET(', $user_info['groups']) . ', b.member_groups) != 0)' . (!empty($modSettings['deny_boards_access']) ? ' AND (FIND_IN_SET(' . implode(', b.deny_member_groups) = 0 AND FIND_IN_SET(', $user_info['groups']) . ', b.deny_member_groups) = 0)' : '') . (isset($user_info['mod_cache']) ? ' OR ' . $user_info['mod_cache']['mq'] : '') . ')'; |
|
| 789 | + } |
|
| 752 | 790 | |
| 753 | 791 | // Build the list of boards they WANT to see. |
| 754 | 792 | // This will take the place of query_see_boards in certain spots, so it better include the boards they can see also |
| 755 | 793 | |
| 756 | 794 | // If they aren't ignoring any boards then they want to see all the boards they can see |
| 757 | - if (empty($user_info['ignoreboards'])) |
|
| 758 | - $user_info['query_wanna_see_board'] = $user_info['query_see_board']; |
|
| 795 | + if (empty($user_info['ignoreboards'])) { |
|
| 796 | + $user_info['query_wanna_see_board'] = $user_info['query_see_board']; |
|
| 797 | + } |
|
| 759 | 798 | // Ok I guess they don't want to see all the boards |
| 760 | - else |
|
| 761 | - $user_info['query_wanna_see_board'] = '(' . $user_info['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $user_info['ignoreboards']) . '))'; |
|
| 799 | + else { |
|
| 800 | + $user_info['query_wanna_see_board'] = '(' . $user_info['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $user_info['ignoreboards']) . '))'; |
|
| 801 | + } |
|
| 762 | 802 | |
| 763 | 803 | call_integration_hook('integrate_user_info'); |
| 764 | 804 | } |
@@ -816,9 +856,9 @@ discard block |
||
| 816 | 856 | } |
| 817 | 857 | |
| 818 | 858 | // Remember redirection is the key to avoiding fallout from your bosses. |
| 819 | - if (!empty($topic)) |
|
| 820 | - redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']); |
|
| 821 | - else |
|
| 859 | + if (!empty($topic)) { |
|
| 860 | + redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']); |
|
| 861 | + } else |
|
| 822 | 862 | { |
| 823 | 863 | loadPermissions(); |
| 824 | 864 | loadTheme(); |
@@ -836,10 +876,11 @@ discard block |
||
| 836 | 876 | if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3)) |
| 837 | 877 | { |
| 838 | 878 | // @todo SLOW? |
| 839 | - if (!empty($topic)) |
|
| 840 | - $temp = cache_get_data('topic_board-' . $topic, 120); |
|
| 841 | - else |
|
| 842 | - $temp = cache_get_data('board-' . $board, 120); |
|
| 879 | + if (!empty($topic)) { |
|
| 880 | + $temp = cache_get_data('topic_board-' . $topic, 120); |
|
| 881 | + } else { |
|
| 882 | + $temp = cache_get_data('board-' . $board, 120); |
|
| 883 | + } |
|
| 843 | 884 | |
| 844 | 885 | if (!empty($temp)) |
| 845 | 886 | { |
@@ -877,8 +918,9 @@ discard block |
||
| 877 | 918 | $row = $smcFunc['db_fetch_assoc']($request); |
| 878 | 919 | |
| 879 | 920 | // Set the current board. |
| 880 | - if (!empty($row['id_board'])) |
|
| 881 | - $board = $row['id_board']; |
|
| 921 | + if (!empty($row['id_board'])) { |
|
| 922 | + $board = $row['id_board']; |
|
| 923 | + } |
|
| 882 | 924 | |
| 883 | 925 | // Basic operating information. (globals... :/) |
| 884 | 926 | $board_info = array( |
@@ -914,21 +956,23 @@ discard block |
||
| 914 | 956 | |
| 915 | 957 | do |
| 916 | 958 | { |
| 917 | - if (!empty($row['id_moderator'])) |
|
| 918 | - $board_info['moderators'][$row['id_moderator']] = array( |
|
| 959 | + if (!empty($row['id_moderator'])) { |
|
| 960 | + $board_info['moderators'][$row['id_moderator']] = array( |
|
| 919 | 961 | 'id' => $row['id_moderator'], |
| 920 | 962 | 'name' => $row['real_name'], |
| 921 | 963 | 'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'], |
| 922 | 964 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>' |
| 923 | 965 | ); |
| 966 | + } |
|
| 924 | 967 | |
| 925 | - if (!empty($row['id_moderator_group'])) |
|
| 926 | - $board_info['moderator_groups'][$row['id_moderator_group']] = array( |
|
| 968 | + if (!empty($row['id_moderator_group'])) { |
|
| 969 | + $board_info['moderator_groups'][$row['id_moderator_group']] = array( |
|
| 927 | 970 | 'id' => $row['id_moderator_group'], |
| 928 | 971 | 'name' => $row['group_name'], |
| 929 | 972 | 'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'], |
| 930 | 973 | 'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>' |
| 931 | 974 | ); |
| 975 | + } |
|
| 932 | 976 | } |
| 933 | 977 | while ($row = $smcFunc['db_fetch_assoc']($request)); |
| 934 | 978 | |
@@ -960,12 +1004,12 @@ discard block |
||
| 960 | 1004 | if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3)) |
| 961 | 1005 | { |
| 962 | 1006 | // @todo SLOW? |
| 963 | - if (!empty($topic)) |
|
| 964 | - cache_put_data('topic_board-' . $topic, $board_info, 120); |
|
| 1007 | + if (!empty($topic)) { |
|
| 1008 | + cache_put_data('topic_board-' . $topic, $board_info, 120); |
|
| 1009 | + } |
|
| 965 | 1010 | cache_put_data('board-' . $board, $board_info, 120); |
| 966 | 1011 | } |
| 967 | - } |
|
| 968 | - else |
|
| 1012 | + } else |
|
| 969 | 1013 | { |
| 970 | 1014 | // Otherwise the topic is invalid, there are no moderators, etc. |
| 971 | 1015 | $board_info = array( |
@@ -979,8 +1023,9 @@ discard block |
||
| 979 | 1023 | $smcFunc['db_free_result']($request); |
| 980 | 1024 | } |
| 981 | 1025 | |
| 982 | - if (!empty($topic)) |
|
| 983 | - $_GET['board'] = (int) $board; |
|
| 1026 | + if (!empty($topic)) { |
|
| 1027 | + $_GET['board'] = (int) $board; |
|
| 1028 | + } |
|
| 984 | 1029 | |
| 985 | 1030 | if (!empty($board)) |
| 986 | 1031 | { |
@@ -990,10 +1035,12 @@ discard block |
||
| 990 | 1035 | // Now check if the user is a moderator. |
| 991 | 1036 | $user_info['is_mod'] = isset($board_info['moderators'][$user_info['id']]) || count(array_intersect($user_info['groups'], $moderator_groups)) != 0; |
| 992 | 1037 | |
| 993 | - if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) |
|
| 994 | - $board_info['error'] = 'access'; |
|
| 995 | - if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) |
|
| 996 | - $board_info['error'] = 'access'; |
|
| 1038 | + if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) { |
|
| 1039 | + $board_info['error'] = 'access'; |
|
| 1040 | + } |
|
| 1041 | + if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) { |
|
| 1042 | + $board_info['error'] = 'access'; |
|
| 1043 | + } |
|
| 997 | 1044 | |
| 998 | 1045 | // Build up the linktree. |
| 999 | 1046 | $context['linktree'] = array_merge( |
@@ -1016,8 +1063,9 @@ discard block |
||
| 1016 | 1063 | $context['current_board'] = $board; |
| 1017 | 1064 | |
| 1018 | 1065 | // No posting in redirection boards! |
| 1019 | - if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) |
|
| 1020 | - $board_info['error'] == 'post_in_redirect'; |
|
| 1066 | + if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) { |
|
| 1067 | + $board_info['error'] == 'post_in_redirect'; |
|
| 1068 | + } |
|
| 1021 | 1069 | |
| 1022 | 1070 | // Hacker... you can't see this topic, I'll tell you that. (but moderators can!) |
| 1023 | 1071 | if (!empty($board_info['error']) && (!empty($modSettings['deny_boards_access']) || $board_info['error'] != 'access' || !$user_info['is_mod'])) |
@@ -1043,24 +1091,23 @@ discard block |
||
| 1043 | 1091 | ob_end_clean(); |
| 1044 | 1092 | header('HTTP/1.1 403 Forbidden'); |
| 1045 | 1093 | die; |
| 1046 | - } |
|
| 1047 | - elseif ($board_info['error'] == 'post_in_redirect') |
|
| 1094 | + } elseif ($board_info['error'] == 'post_in_redirect') |
|
| 1048 | 1095 | { |
| 1049 | 1096 | // Slightly different error message here... |
| 1050 | 1097 | fatal_lang_error('cannot_post_redirect', false); |
| 1051 | - } |
|
| 1052 | - elseif ($user_info['is_guest']) |
|
| 1098 | + } elseif ($user_info['is_guest']) |
|
| 1053 | 1099 | { |
| 1054 | 1100 | loadLanguage('Errors'); |
| 1055 | 1101 | is_not_guest($txt['topic_gone']); |
| 1102 | + } else { |
|
| 1103 | + fatal_lang_error('topic_gone', false); |
|
| 1056 | 1104 | } |
| 1057 | - else |
|
| 1058 | - fatal_lang_error('topic_gone', false); |
|
| 1059 | 1105 | } |
| 1060 | 1106 | |
| 1061 | - if ($user_info['is_mod']) |
|
| 1062 | - $user_info['groups'][] = 3; |
|
| 1063 | -} |
|
| 1107 | + if ($user_info['is_mod']) { |
|
| 1108 | + $user_info['groups'][] = 3; |
|
| 1109 | + } |
|
| 1110 | + } |
|
| 1064 | 1111 | |
| 1065 | 1112 | /** |
| 1066 | 1113 | * Load this user's permissions. |
@@ -1081,8 +1128,9 @@ discard block |
||
| 1081 | 1128 | asort($cache_groups); |
| 1082 | 1129 | $cache_groups = implode(',', $cache_groups); |
| 1083 | 1130 | // If it's a spider then cache it different. |
| 1084 | - if ($user_info['possibly_robot']) |
|
| 1085 | - $cache_groups .= '-spider'; |
|
| 1131 | + if ($user_info['possibly_robot']) { |
|
| 1132 | + $cache_groups .= '-spider'; |
|
| 1133 | + } |
|
| 1086 | 1134 | |
| 1087 | 1135 | if ($modSettings['cache_enable'] >= 2 && !empty($board) && ($temp = cache_get_data('permissions:' . $cache_groups . ':' . $board, 240)) != null && time() - 240 > $modSettings['settings_updated']) |
| 1088 | 1136 | { |
@@ -1090,9 +1138,9 @@ discard block |
||
| 1090 | 1138 | banPermissions(); |
| 1091 | 1139 | |
| 1092 | 1140 | return; |
| 1141 | + } elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) { |
|
| 1142 | + list ($user_info['permissions'], $removals) = $temp; |
|
| 1093 | 1143 | } |
| 1094 | - elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) |
|
| 1095 | - list ($user_info['permissions'], $removals) = $temp; |
|
| 1096 | 1144 | } |
| 1097 | 1145 | |
| 1098 | 1146 | // If it is detected as a robot, and we are restricting permissions as a special group - then implement this. |
@@ -1114,23 +1162,26 @@ discard block |
||
| 1114 | 1162 | $removals = array(); |
| 1115 | 1163 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1116 | 1164 | { |
| 1117 | - if (empty($row['add_deny'])) |
|
| 1118 | - $removals[] = $row['permission']; |
|
| 1119 | - else |
|
| 1120 | - $user_info['permissions'][] = $row['permission']; |
|
| 1165 | + if (empty($row['add_deny'])) { |
|
| 1166 | + $removals[] = $row['permission']; |
|
| 1167 | + } else { |
|
| 1168 | + $user_info['permissions'][] = $row['permission']; |
|
| 1169 | + } |
|
| 1121 | 1170 | } |
| 1122 | 1171 | $smcFunc['db_free_result']($request); |
| 1123 | 1172 | |
| 1124 | - if (isset($cache_groups)) |
|
| 1125 | - cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240); |
|
| 1173 | + if (isset($cache_groups)) { |
|
| 1174 | + cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240); |
|
| 1175 | + } |
|
| 1126 | 1176 | } |
| 1127 | 1177 | |
| 1128 | 1178 | // Get the board permissions. |
| 1129 | 1179 | if (!empty($board)) |
| 1130 | 1180 | { |
| 1131 | 1181 | // Make sure the board (if any) has been loaded by loadBoard(). |
| 1132 | - if (!isset($board_info['profile'])) |
|
| 1133 | - fatal_lang_error('no_board'); |
|
| 1182 | + if (!isset($board_info['profile'])) { |
|
| 1183 | + fatal_lang_error('no_board'); |
|
| 1184 | + } |
|
| 1134 | 1185 | |
| 1135 | 1186 | $request = $smcFunc['db_query']('', ' |
| 1136 | 1187 | SELECT permission, add_deny |
@@ -1146,20 +1197,23 @@ discard block |
||
| 1146 | 1197 | ); |
| 1147 | 1198 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1148 | 1199 | { |
| 1149 | - if (empty($row['add_deny'])) |
|
| 1150 | - $removals[] = $row['permission']; |
|
| 1151 | - else |
|
| 1152 | - $user_info['permissions'][] = $row['permission']; |
|
| 1200 | + if (empty($row['add_deny'])) { |
|
| 1201 | + $removals[] = $row['permission']; |
|
| 1202 | + } else { |
|
| 1203 | + $user_info['permissions'][] = $row['permission']; |
|
| 1204 | + } |
|
| 1153 | 1205 | } |
| 1154 | 1206 | $smcFunc['db_free_result']($request); |
| 1155 | 1207 | } |
| 1156 | 1208 | |
| 1157 | 1209 | // Remove all the permissions they shouldn't have ;). |
| 1158 | - if (!empty($modSettings['permission_enable_deny'])) |
|
| 1159 | - $user_info['permissions'] = array_diff($user_info['permissions'], $removals); |
|
| 1210 | + if (!empty($modSettings['permission_enable_deny'])) { |
|
| 1211 | + $user_info['permissions'] = array_diff($user_info['permissions'], $removals); |
|
| 1212 | + } |
|
| 1160 | 1213 | |
| 1161 | - if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) |
|
| 1162 | - cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240); |
|
| 1214 | + if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) { |
|
| 1215 | + cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240); |
|
| 1216 | + } |
|
| 1163 | 1217 | |
| 1164 | 1218 | // Banned? Watch, don't touch.. |
| 1165 | 1219 | banPermissions(); |
@@ -1171,17 +1225,18 @@ discard block |
||
| 1171 | 1225 | { |
| 1172 | 1226 | require_once($sourcedir . '/Subs-Auth.php'); |
| 1173 | 1227 | rebuildModCache(); |
| 1228 | + } else { |
|
| 1229 | + $user_info['mod_cache'] = $_SESSION['mc']; |
|
| 1174 | 1230 | } |
| 1175 | - else |
|
| 1176 | - $user_info['mod_cache'] = $_SESSION['mc']; |
|
| 1177 | 1231 | |
| 1178 | 1232 | // This is a useful phantom permission added to the current user, and only the current user while they are logged in. |
| 1179 | 1233 | // For example this drastically simplifies certain changes to the profile area. |
| 1180 | 1234 | $user_info['permissions'][] = 'is_not_guest'; |
| 1181 | 1235 | // And now some backwards compatibility stuff for mods and whatnot that aren't expecting the new permissions. |
| 1182 | 1236 | $user_info['permissions'][] = 'profile_view_own'; |
| 1183 | - if (in_array('profile_view', $user_info['permissions'])) |
|
| 1184 | - $user_info['permissions'][] = 'profile_view_any'; |
|
| 1237 | + if (in_array('profile_view', $user_info['permissions'])) { |
|
| 1238 | + $user_info['permissions'][] = 'profile_view_any'; |
|
| 1239 | + } |
|
| 1185 | 1240 | } |
| 1186 | 1241 | } |
| 1187 | 1242 | |
@@ -1199,8 +1254,9 @@ discard block |
||
| 1199 | 1254 | global $image_proxy_enabled, $image_proxy_secret, $boardurl; |
| 1200 | 1255 | |
| 1201 | 1256 | // Can't just look for no users :P. |
| 1202 | - if (empty($users)) |
|
| 1203 | - return array(); |
|
| 1257 | + if (empty($users)) { |
|
| 1258 | + return array(); |
|
| 1259 | + } |
|
| 1204 | 1260 | |
| 1205 | 1261 | // Pass the set value |
| 1206 | 1262 | $context['loadMemberContext_set'] = $set; |
@@ -1215,8 +1271,9 @@ discard block |
||
| 1215 | 1271 | for ($i = 0, $n = count($users); $i < $n; $i++) |
| 1216 | 1272 | { |
| 1217 | 1273 | $data = cache_get_data('member_data-' . $set . '-' . $users[$i], 240); |
| 1218 | - if ($data == null) |
|
| 1219 | - continue; |
|
| 1274 | + if ($data == null) { |
|
| 1275 | + continue; |
|
| 1276 | + } |
|
| 1220 | 1277 | |
| 1221 | 1278 | $loaded_ids[] = $data['id_member']; |
| 1222 | 1279 | $user_profile[$data['id_member']] = $data; |
@@ -1280,13 +1337,16 @@ discard block |
||
| 1280 | 1337 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1281 | 1338 | { |
| 1282 | 1339 | // Take care of proxying avatar if required, do this here for maximum reach |
| 1283 | - if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false) |
|
| 1284 | - $row['avatar'] = $boardurl . '/proxy.php?request=' . urlencode($row['avatar']) . '&hash=' . md5($row['avatar'] . $image_proxy_secret); |
|
| 1340 | + if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false) { |
|
| 1341 | + $row['avatar'] = $boardurl . '/proxy.php?request=' . urlencode($row['avatar']) . '&hash=' . md5($row['avatar'] . $image_proxy_secret); |
|
| 1342 | + } |
|
| 1285 | 1343 | |
| 1286 | - if (isset($row['member_ip'])) |
|
| 1287 | - $row['member_ip'] = inet_dtop($row['member_ip']); |
|
| 1288 | - if (isset($row['member_ip2'])) |
|
| 1289 | - $row['member_ip2'] = inet_dtop($row['member_ip2']); |
|
| 1344 | + if (isset($row['member_ip'])) { |
|
| 1345 | + $row['member_ip'] = inet_dtop($row['member_ip']); |
|
| 1346 | + } |
|
| 1347 | + if (isset($row['member_ip2'])) { |
|
| 1348 | + $row['member_ip2'] = inet_dtop($row['member_ip2']); |
|
| 1349 | + } |
|
| 1290 | 1350 | $new_loaded_ids[] = $row['id_member']; |
| 1291 | 1351 | $loaded_ids[] = $row['id_member']; |
| 1292 | 1352 | $row['options'] = array(); |
@@ -1305,8 +1365,9 @@ discard block |
||
| 1305 | 1365 | 'loaded_ids' => $new_loaded_ids, |
| 1306 | 1366 | ) |
| 1307 | 1367 | ); |
| 1308 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1309 | - $user_profile[$row['id_member']]['options'][$row['variable']] = $row['value']; |
|
| 1368 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1369 | + $user_profile[$row['id_member']]['options'][$row['variable']] = $row['value']; |
|
| 1370 | + } |
|
| 1310 | 1371 | $smcFunc['db_free_result']($request); |
| 1311 | 1372 | } |
| 1312 | 1373 | |
@@ -1317,10 +1378,11 @@ discard block |
||
| 1317 | 1378 | { |
| 1318 | 1379 | foreach ($loaded_ids as $a_member) |
| 1319 | 1380 | { |
| 1320 | - if (!empty($user_profile[$a_member]['additional_groups'])) |
|
| 1321 | - $groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups'])); |
|
| 1322 | - else |
|
| 1323 | - $groups = array($user_profile[$a_member]['id_group']); |
|
| 1381 | + if (!empty($user_profile[$a_member]['additional_groups'])) { |
|
| 1382 | + $groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups'])); |
|
| 1383 | + } else { |
|
| 1384 | + $groups = array($user_profile[$a_member]['id_group']); |
|
| 1385 | + } |
|
| 1324 | 1386 | |
| 1325 | 1387 | $temp = array_intersect($groups, array_keys($board_info['moderator_groups'])); |
| 1326 | 1388 | |
@@ -1333,8 +1395,9 @@ discard block |
||
| 1333 | 1395 | |
| 1334 | 1396 | if (!empty($new_loaded_ids) && !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) |
| 1335 | 1397 | { |
| 1336 | - for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) |
|
| 1337 | - cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240); |
|
| 1398 | + for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) { |
|
| 1399 | + cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240); |
|
| 1400 | + } |
|
| 1338 | 1401 | } |
| 1339 | 1402 | |
| 1340 | 1403 | // Are we loading any moderators? If so, fix their group data... |
@@ -1360,14 +1423,17 @@ discard block |
||
| 1360 | 1423 | foreach ($temp_mods as $id) |
| 1361 | 1424 | { |
| 1362 | 1425 | // By popular demand, don't show admins or global moderators as moderators. |
| 1363 | - if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) |
|
| 1364 | - $user_profile[$id]['member_group'] = $row['member_group']; |
|
| 1426 | + if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) { |
|
| 1427 | + $user_profile[$id]['member_group'] = $row['member_group']; |
|
| 1428 | + } |
|
| 1365 | 1429 | |
| 1366 | 1430 | // If the Moderator group has no color or icons, but their group does... don't overwrite. |
| 1367 | - if (!empty($row['icons'])) |
|
| 1368 | - $user_profile[$id]['icons'] = $row['icons']; |
|
| 1369 | - if (!empty($row['member_group_color'])) |
|
| 1370 | - $user_profile[$id]['member_group_color'] = $row['member_group_color']; |
|
| 1431 | + if (!empty($row['icons'])) { |
|
| 1432 | + $user_profile[$id]['icons'] = $row['icons']; |
|
| 1433 | + } |
|
| 1434 | + if (!empty($row['member_group_color'])) { |
|
| 1435 | + $user_profile[$id]['member_group_color'] = $row['member_group_color']; |
|
| 1436 | + } |
|
| 1371 | 1437 | } |
| 1372 | 1438 | } |
| 1373 | 1439 | |
@@ -1389,12 +1455,14 @@ discard block |
||
| 1389 | 1455 | static $loadedLanguages = array(); |
| 1390 | 1456 | |
| 1391 | 1457 | // If this person's data is already loaded, skip it. |
| 1392 | - if (isset($dataLoaded[$user])) |
|
| 1393 | - return true; |
|
| 1458 | + if (isset($dataLoaded[$user])) { |
|
| 1459 | + return true; |
|
| 1460 | + } |
|
| 1394 | 1461 | |
| 1395 | 1462 | // We can't load guests or members not loaded by loadMemberData()! |
| 1396 | - if ($user == 0) |
|
| 1397 | - return false; |
|
| 1463 | + if ($user == 0) { |
|
| 1464 | + return false; |
|
| 1465 | + } |
|
| 1398 | 1466 | if (!isset($user_profile[$user])) |
| 1399 | 1467 | { |
| 1400 | 1468 | trigger_error('loadMemberContext(): member id ' . $user . ' not previously loaded by loadMemberData()', E_USER_WARNING); |
@@ -1420,12 +1488,16 @@ discard block |
||
| 1420 | 1488 | $buddy_list = !empty($profile['buddy_list']) ? explode(',', $profile['buddy_list']) : array(); |
| 1421 | 1489 | |
| 1422 | 1490 | //We need a little fallback for the membergroup icons. If it doesn't exist in the current theme, fallback to default theme |
| 1423 | - if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) //icon is set and exists |
|
| 1491 | + if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) { |
|
| 1492 | + //icon is set and exists |
|
| 1424 | 1493 | $group_icon_url = $settings['images_url'] . '/membericons/' . $profile['icons'][1]; |
| 1425 | - elseif (isset($profile['icons'][1])) //icon is set and doesn't exist, fallback to default |
|
| 1494 | + } elseif (isset($profile['icons'][1])) { |
|
| 1495 | + //icon is set and doesn't exist, fallback to default |
|
| 1426 | 1496 | $group_icon_url = $settings['default_images_url'] . '/membericons/' . $profile['icons'][1]; |
| 1427 | - else //not set, bye bye |
|
| 1497 | + } else { |
|
| 1498 | + //not set, bye bye |
|
| 1428 | 1499 | $group_icon_url = ''; |
| 1500 | + } |
|
| 1429 | 1501 | |
| 1430 | 1502 | // These minimal values are always loaded |
| 1431 | 1503 | $memberContext[$user] = array( |
@@ -1444,8 +1516,9 @@ discard block |
||
| 1444 | 1516 | if ($context['loadMemberContext_set'] != 'minimal') |
| 1445 | 1517 | { |
| 1446 | 1518 | // Go the extra mile and load the user's native language name. |
| 1447 | - if (empty($loadedLanguages)) |
|
| 1448 | - $loadedLanguages = getLanguages(); |
|
| 1519 | + if (empty($loadedLanguages)) { |
|
| 1520 | + $loadedLanguages = getLanguages(); |
|
| 1521 | + } |
|
| 1449 | 1522 | |
| 1450 | 1523 | $memberContext[$user] += array( |
| 1451 | 1524 | 'username_color' => '<span ' . (!empty($profile['member_group_color']) ? 'style="color:' . $profile['member_group_color'] . ';"' : '') . '>' . $profile['member_name'] . '</span>', |
@@ -1499,31 +1572,33 @@ discard block |
||
| 1499 | 1572 | { |
| 1500 | 1573 | if (!empty($modSettings['gravatarOverride']) || (!empty($modSettings['gravatarEnabled']) && stristr($profile['avatar'], 'gravatar://'))) |
| 1501 | 1574 | { |
| 1502 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) |
|
| 1503 | - $image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11)); |
|
| 1504 | - else |
|
| 1505 | - $image = get_gravatar_url($profile['email_address']); |
|
| 1506 | - } |
|
| 1507 | - else |
|
| 1575 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) { |
|
| 1576 | + $image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11)); |
|
| 1577 | + } else { |
|
| 1578 | + $image = get_gravatar_url($profile['email_address']); |
|
| 1579 | + } |
|
| 1580 | + } else |
|
| 1508 | 1581 | { |
| 1509 | 1582 | // So it's stored in the member table? |
| 1510 | 1583 | if (!empty($profile['avatar'])) |
| 1511 | 1584 | { |
| 1512 | 1585 | $image = (stristr($profile['avatar'], 'http://') || stristr($profile['avatar'], 'https://')) ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar']; |
| 1586 | + } elseif (!empty($profile['filename'])) { |
|
| 1587 | + $image = $modSettings['custom_avatar_url'] . '/' . $profile['filename']; |
|
| 1513 | 1588 | } |
| 1514 | - elseif (!empty($profile['filename'])) |
|
| 1515 | - $image = $modSettings['custom_avatar_url'] . '/' . $profile['filename']; |
|
| 1516 | 1589 | // Right... no avatar...use the default one |
| 1517 | - else |
|
| 1518 | - $image = $modSettings['avatar_url'] . '/default.png'; |
|
| 1590 | + else { |
|
| 1591 | + $image = $modSettings['avatar_url'] . '/default.png'; |
|
| 1592 | + } |
|
| 1519 | 1593 | } |
| 1520 | - if (!empty($image)) |
|
| 1521 | - $memberContext[$user]['avatar'] = array( |
|
| 1594 | + if (!empty($image)) { |
|
| 1595 | + $memberContext[$user]['avatar'] = array( |
|
| 1522 | 1596 | 'name' => $profile['avatar'], |
| 1523 | 1597 | 'image' => '<img class="avatar" src="' . $image . '" alt="avatar_' . $profile['member_name'] . '">', |
| 1524 | 1598 | 'href' => $image, |
| 1525 | 1599 | 'url' => $image, |
| 1526 | 1600 | ); |
| 1601 | + } |
|
| 1527 | 1602 | } |
| 1528 | 1603 | |
| 1529 | 1604 | // Are we also loading the members custom fields into context? |
@@ -1531,35 +1606,41 @@ discard block |
||
| 1531 | 1606 | { |
| 1532 | 1607 | $memberContext[$user]['custom_fields'] = array(); |
| 1533 | 1608 | |
| 1534 | - if (!isset($context['display_fields'])) |
|
| 1535 | - $context['display_fields'] = smf_json_decode($modSettings['displayFields'], true); |
|
| 1609 | + if (!isset($context['display_fields'])) { |
|
| 1610 | + $context['display_fields'] = smf_json_decode($modSettings['displayFields'], true); |
|
| 1611 | + } |
|
| 1536 | 1612 | |
| 1537 | 1613 | foreach ($context['display_fields'] as $custom) |
| 1538 | 1614 | { |
| 1539 | - if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) |
|
| 1540 | - continue; |
|
| 1615 | + if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) { |
|
| 1616 | + continue; |
|
| 1617 | + } |
|
| 1541 | 1618 | |
| 1542 | 1619 | $value = $profile['options'][$custom['col_name']]; |
| 1543 | 1620 | |
| 1544 | 1621 | // Don't show the "disabled" option for the "gender" field. |
| 1545 | - if ($custom['col_name'] == 'cust_gender' && $value == 'Disabled') |
|
| 1546 | - continue; |
|
| 1622 | + if ($custom['col_name'] == 'cust_gender' && $value == 'Disabled') { |
|
| 1623 | + continue; |
|
| 1624 | + } |
|
| 1547 | 1625 | |
| 1548 | 1626 | // BBC? |
| 1549 | - if ($custom['bbc']) |
|
| 1550 | - $value = parse_bbc($value); |
|
| 1627 | + if ($custom['bbc']) { |
|
| 1628 | + $value = parse_bbc($value); |
|
| 1629 | + } |
|
| 1551 | 1630 | // ... or checkbox? |
| 1552 | - elseif (isset($custom['type']) && $custom['type'] == 'check') |
|
| 1553 | - $value = $value ? $txt['yes'] : $txt['no']; |
|
| 1631 | + elseif (isset($custom['type']) && $custom['type'] == 'check') { |
|
| 1632 | + $value = $value ? $txt['yes'] : $txt['no']; |
|
| 1633 | + } |
|
| 1554 | 1634 | |
| 1555 | 1635 | // Enclosing the user input within some other text? |
| 1556 | - if (!empty($custom['enclose'])) |
|
| 1557 | - $value = strtr($custom['enclose'], array( |
|
| 1636 | + if (!empty($custom['enclose'])) { |
|
| 1637 | + $value = strtr($custom['enclose'], array( |
|
| 1558 | 1638 | '{SCRIPTURL}' => $scripturl, |
| 1559 | 1639 | '{IMAGES_URL}' => $settings['images_url'], |
| 1560 | 1640 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
| 1561 | 1641 | '{INPUT}' => $value, |
| 1562 | 1642 | )); |
| 1643 | + } |
|
| 1563 | 1644 | |
| 1564 | 1645 | $memberContext[$user]['custom_fields'][] = array( |
| 1565 | 1646 | 'title' => !empty($custom['title']) ? $custom['title'] : $custom['col_name'], |
@@ -1586,8 +1667,9 @@ discard block |
||
| 1586 | 1667 | global $smcFunc, $txt, $scripturl, $settings; |
| 1587 | 1668 | |
| 1588 | 1669 | // Do not waste my time... |
| 1589 | - if (empty($users) || empty($params)) |
|
| 1590 | - return false; |
|
| 1670 | + if (empty($users) || empty($params)) { |
|
| 1671 | + return false; |
|
| 1672 | + } |
|
| 1591 | 1673 | |
| 1592 | 1674 | // Make sure it's an array. |
| 1593 | 1675 | $users = !is_array($users) ? array($users) : array_unique($users); |
@@ -1611,31 +1693,36 @@ discard block |
||
| 1611 | 1693 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1612 | 1694 | { |
| 1613 | 1695 | // BBC? |
| 1614 | - if (!empty($row['bbc'])) |
|
| 1615 | - $row['value'] = parse_bbc($row['value']); |
|
| 1696 | + if (!empty($row['bbc'])) { |
|
| 1697 | + $row['value'] = parse_bbc($row['value']); |
|
| 1698 | + } |
|
| 1616 | 1699 | |
| 1617 | 1700 | // ... or checkbox? |
| 1618 | - elseif (isset($row['type']) && $row['type'] == 'check') |
|
| 1619 | - $row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no']; |
|
| 1701 | + elseif (isset($row['type']) && $row['type'] == 'check') { |
|
| 1702 | + $row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no']; |
|
| 1703 | + } |
|
| 1620 | 1704 | |
| 1621 | 1705 | // Enclosing the user input within some other text? |
| 1622 | - if (!empty($row['enclose'])) |
|
| 1623 | - $row['value'] = strtr($row['enclose'], array( |
|
| 1706 | + if (!empty($row['enclose'])) { |
|
| 1707 | + $row['value'] = strtr($row['enclose'], array( |
|
| 1624 | 1708 | '{SCRIPTURL}' => $scripturl, |
| 1625 | 1709 | '{IMAGES_URL}' => $settings['images_url'], |
| 1626 | 1710 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
| 1627 | 1711 | '{INPUT}' => un_htmlspecialchars($row['value']), |
| 1628 | 1712 | )); |
| 1713 | + } |
|
| 1629 | 1714 | |
| 1630 | 1715 | // Send a simple array if there is just 1 param |
| 1631 | - if (count($params) == 1) |
|
| 1632 | - $return[$row['id_member']] = $row; |
|
| 1716 | + if (count($params) == 1) { |
|
| 1717 | + $return[$row['id_member']] = $row; |
|
| 1718 | + } |
|
| 1633 | 1719 | |
| 1634 | 1720 | // More than 1? knock yourself out... |
| 1635 | 1721 | else |
| 1636 | 1722 | { |
| 1637 | - if (!isset($return[$row['id_member']])) |
|
| 1638 | - $return[$row['id_member']] = array(); |
|
| 1723 | + if (!isset($return[$row['id_member']])) { |
|
| 1724 | + $return[$row['id_member']] = array(); |
|
| 1725 | + } |
|
| 1639 | 1726 | |
| 1640 | 1727 | $return[$row['id_member']][$row['variable']] = $row; |
| 1641 | 1728 | } |
@@ -1669,8 +1756,9 @@ discard block |
||
| 1669 | 1756 | global $context; |
| 1670 | 1757 | |
| 1671 | 1758 | // Don't know any browser! |
| 1672 | - if (empty($context['browser'])) |
|
| 1673 | - detectBrowser(); |
|
| 1759 | + if (empty($context['browser'])) { |
|
| 1760 | + detectBrowser(); |
|
| 1761 | + } |
|
| 1674 | 1762 | |
| 1675 | 1763 | return !empty($context['browser'][$browser]) || !empty($context['browser']['is_' . $browser]) ? true : false; |
| 1676 | 1764 | } |
@@ -1688,8 +1776,9 @@ discard block |
||
| 1688 | 1776 | global $context, $settings, $options, $sourcedir, $ssi_theme, $smcFunc, $language, $board, $image_proxy_enabled; |
| 1689 | 1777 | |
| 1690 | 1778 | // The theme was specified by parameter. |
| 1691 | - if (!empty($id_theme)) |
|
| 1692 | - $id_theme = (int) $id_theme; |
|
| 1779 | + if (!empty($id_theme)) { |
|
| 1780 | + $id_theme = (int) $id_theme; |
|
| 1781 | + } |
|
| 1693 | 1782 | // The theme was specified by REQUEST. |
| 1694 | 1783 | elseif (!empty($_REQUEST['theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) |
| 1695 | 1784 | { |
@@ -1697,51 +1786,58 @@ discard block |
||
| 1697 | 1786 | $_SESSION['id_theme'] = $id_theme; |
| 1698 | 1787 | } |
| 1699 | 1788 | // The theme was specified by REQUEST... previously. |
| 1700 | - elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) |
|
| 1701 | - $id_theme = (int) $_SESSION['id_theme']; |
|
| 1789 | + elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) { |
|
| 1790 | + $id_theme = (int) $_SESSION['id_theme']; |
|
| 1791 | + } |
|
| 1702 | 1792 | // The theme is just the user's choice. (might use ?board=1;theme=0 to force board theme.) |
| 1703 | - elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) |
|
| 1704 | - $id_theme = $user_info['theme']; |
|
| 1793 | + elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) { |
|
| 1794 | + $id_theme = $user_info['theme']; |
|
| 1795 | + } |
|
| 1705 | 1796 | // The theme was specified by the board. |
| 1706 | - elseif (!empty($board_info['theme'])) |
|
| 1707 | - $id_theme = $board_info['theme']; |
|
| 1797 | + elseif (!empty($board_info['theme'])) { |
|
| 1798 | + $id_theme = $board_info['theme']; |
|
| 1799 | + } |
|
| 1708 | 1800 | // The theme is the forum's default. |
| 1709 | - else |
|
| 1710 | - $id_theme = $modSettings['theme_guests']; |
|
| 1801 | + else { |
|
| 1802 | + $id_theme = $modSettings['theme_guests']; |
|
| 1803 | + } |
|
| 1711 | 1804 | |
| 1712 | 1805 | // Verify the id_theme... no foul play. |
| 1713 | 1806 | // Always allow the board specific theme, if they are overriding. |
| 1714 | - if (!empty($board_info['theme']) && $board_info['override_theme']) |
|
| 1715 | - $id_theme = $board_info['theme']; |
|
| 1807 | + if (!empty($board_info['theme']) && $board_info['override_theme']) { |
|
| 1808 | + $id_theme = $board_info['theme']; |
|
| 1809 | + } |
|
| 1716 | 1810 | // If they have specified a particular theme to use with SSI allow it to be used. |
| 1717 | - elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) |
|
| 1718 | - $id_theme = (int) $id_theme; |
|
| 1719 | - elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum')) |
|
| 1811 | + elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) { |
|
| 1812 | + $id_theme = (int) $id_theme; |
|
| 1813 | + } elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum')) |
|
| 1720 | 1814 | { |
| 1721 | 1815 | $themes = explode(',', $modSettings['enableThemes']); |
| 1722 | - if (!in_array($id_theme, $themes)) |
|
| 1723 | - $id_theme = $modSettings['theme_guests']; |
|
| 1724 | - else |
|
| 1816 | + if (!in_array($id_theme, $themes)) { |
|
| 1817 | + $id_theme = $modSettings['theme_guests']; |
|
| 1818 | + } else { |
|
| 1819 | + $id_theme = (int) $id_theme; |
|
| 1820 | + } |
|
| 1821 | + } else { |
|
| 1725 | 1822 | $id_theme = (int) $id_theme; |
| 1726 | 1823 | } |
| 1727 | - else |
|
| 1728 | - $id_theme = (int) $id_theme; |
|
| 1729 | 1824 | |
| 1730 | 1825 | $member = empty($user_info['id']) ? -1 : $user_info['id']; |
| 1731 | 1826 | |
| 1732 | 1827 | // Disable image proxy if we don't have SSL enabled |
| 1733 | - if (empty($modSettings['force_ssl']) || $modSettings['force_ssl'] < 2) |
|
| 1734 | - $image_proxy_enabled = false; |
|
| 1828 | + if (empty($modSettings['force_ssl']) || $modSettings['force_ssl'] < 2) { |
|
| 1829 | + $image_proxy_enabled = false; |
|
| 1830 | + } |
|
| 1735 | 1831 | |
| 1736 | 1832 | if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2 && ($temp = cache_get_data('theme_settings-' . $id_theme . ':' . $member, 60)) != null && time() - 60 > $modSettings['settings_updated']) |
| 1737 | 1833 | { |
| 1738 | 1834 | $themeData = $temp; |
| 1739 | 1835 | $flag = true; |
| 1836 | + } elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) { |
|
| 1837 | + $themeData = $temp + array($member => array()); |
|
| 1838 | + } else { |
|
| 1839 | + $themeData = array(-1 => array(), 0 => array(), $member => array()); |
|
| 1740 | 1840 | } |
| 1741 | - elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) |
|
| 1742 | - $themeData = $temp + array($member => array()); |
|
| 1743 | - else |
|
| 1744 | - $themeData = array(-1 => array(), 0 => array(), $member => array()); |
|
| 1745 | 1841 | |
| 1746 | 1842 | if (empty($flag)) |
| 1747 | 1843 | { |
@@ -1760,31 +1856,37 @@ discard block |
||
| 1760 | 1856 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 1761 | 1857 | { |
| 1762 | 1858 | // There are just things we shouldn't be able to change as members. |
| 1763 | - if ($row['id_member'] != 0 && in_array($row['variable'], array('actual_theme_url', 'actual_images_url', 'base_theme_dir', 'base_theme_url', 'default_images_url', 'default_theme_dir', 'default_theme_url', 'default_template', 'images_url', 'number_recent_posts', 'smiley_sets_default', 'theme_dir', 'theme_id', 'theme_layers', 'theme_templates', 'theme_url'))) |
|
| 1764 | - continue; |
|
| 1859 | + if ($row['id_member'] != 0 && in_array($row['variable'], array('actual_theme_url', 'actual_images_url', 'base_theme_dir', 'base_theme_url', 'default_images_url', 'default_theme_dir', 'default_theme_url', 'default_template', 'images_url', 'number_recent_posts', 'smiley_sets_default', 'theme_dir', 'theme_id', 'theme_layers', 'theme_templates', 'theme_url'))) { |
|
| 1860 | + continue; |
|
| 1861 | + } |
|
| 1765 | 1862 | |
| 1766 | 1863 | // If this is the theme_dir of the default theme, store it. |
| 1767 | - if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) |
|
| 1768 | - $themeData[0]['default_' . $row['variable']] = $row['value']; |
|
| 1864 | + if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) { |
|
| 1865 | + $themeData[0]['default_' . $row['variable']] = $row['value']; |
|
| 1866 | + } |
|
| 1769 | 1867 | |
| 1770 | 1868 | // If this isn't set yet, is a theme option, or is not the default theme.. |
| 1771 | - if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') |
|
| 1772 | - $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value']; |
|
| 1869 | + if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') { |
|
| 1870 | + $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value']; |
|
| 1871 | + } |
|
| 1773 | 1872 | } |
| 1774 | 1873 | $smcFunc['db_free_result']($result); |
| 1775 | 1874 | |
| 1776 | - if (!empty($themeData[-1])) |
|
| 1777 | - foreach ($themeData[-1] as $k => $v) |
|
| 1875 | + if (!empty($themeData[-1])) { |
|
| 1876 | + foreach ($themeData[-1] as $k => $v) |
|
| 1778 | 1877 | { |
| 1779 | 1878 | if (!isset($themeData[$member][$k])) |
| 1780 | 1879 | $themeData[$member][$k] = $v; |
| 1880 | + } |
|
| 1781 | 1881 | } |
| 1782 | 1882 | |
| 1783 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 1784 | - cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60); |
|
| 1883 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 1884 | + cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60); |
|
| 1885 | + } |
|
| 1785 | 1886 | // Only if we didn't already load that part of the cache... |
| 1786 | - elseif (!isset($temp)) |
|
| 1787 | - cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90); |
|
| 1887 | + elseif (!isset($temp)) { |
|
| 1888 | + cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90); |
|
| 1889 | + } |
|
| 1788 | 1890 | } |
| 1789 | 1891 | |
| 1790 | 1892 | $settings = $themeData[0]; |
@@ -1801,20 +1903,24 @@ discard block |
||
| 1801 | 1903 | $settings['template_dirs'][] = $settings['theme_dir']; |
| 1802 | 1904 | |
| 1803 | 1905 | // Based on theme (if there is one). |
| 1804 | - if (!empty($settings['base_theme_dir'])) |
|
| 1805 | - $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
| 1906 | + if (!empty($settings['base_theme_dir'])) { |
|
| 1907 | + $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
| 1908 | + } |
|
| 1806 | 1909 | |
| 1807 | 1910 | // Lastly the default theme. |
| 1808 | - if ($settings['theme_dir'] != $settings['default_theme_dir']) |
|
| 1809 | - $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
| 1911 | + if ($settings['theme_dir'] != $settings['default_theme_dir']) { |
|
| 1912 | + $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
| 1913 | + } |
|
| 1810 | 1914 | |
| 1811 | - if (!$initialize) |
|
| 1812 | - return; |
|
| 1915 | + if (!$initialize) { |
|
| 1916 | + return; |
|
| 1917 | + } |
|
| 1813 | 1918 | |
| 1814 | 1919 | // Check to see if we're forcing SSL |
| 1815 | 1920 | if (!empty($modSettings['force_ssl']) && $modSettings['force_ssl'] == 2 && empty($maintenance) && |
| 1816 | - (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off') && SMF != 'SSI') |
|
| 1817 | - redirectexit(strtr($_SERVER['REQUEST_URL'], array('http://' => 'https://'))); |
|
| 1921 | + (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off') && SMF != 'SSI') { |
|
| 1922 | + redirectexit(strtr($_SERVER['REQUEST_URL'], array('http://' => 'https://'))); |
|
| 1923 | + } |
|
| 1818 | 1924 | |
| 1819 | 1925 | // Check to see if they're accessing it from the wrong place. |
| 1820 | 1926 | if (isset($_SERVER['HTTP_HOST']) || isset($_SERVER['SERVER_NAME'])) |
@@ -1822,8 +1928,9 @@ discard block |
||
| 1822 | 1928 | $detected_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 'https://' : 'http://'; |
| 1823 | 1929 | $detected_url .= empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] . (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT']) : $_SERVER['HTTP_HOST']; |
| 1824 | 1930 | $temp = preg_replace('~/' . basename($scripturl) . '(/.+)?$~', '', strtr(dirname($_SERVER['PHP_SELF']), '\\', '/')); |
| 1825 | - if ($temp != '/') |
|
| 1826 | - $detected_url .= $temp; |
|
| 1931 | + if ($temp != '/') { |
|
| 1932 | + $detected_url .= $temp; |
|
| 1933 | + } |
|
| 1827 | 1934 | } |
| 1828 | 1935 | if (isset($detected_url) && $detected_url != $boardurl) |
| 1829 | 1936 | { |
@@ -1835,8 +1942,9 @@ discard block |
||
| 1835 | 1942 | foreach ($aliases as $alias) |
| 1836 | 1943 | { |
| 1837 | 1944 | // Rip off all the boring parts, spaces, etc. |
| 1838 | - if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) |
|
| 1839 | - $do_fix = true; |
|
| 1945 | + if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) { |
|
| 1946 | + $do_fix = true; |
|
| 1947 | + } |
|
| 1840 | 1948 | } |
| 1841 | 1949 | } |
| 1842 | 1950 | |
@@ -1844,20 +1952,22 @@ discard block |
||
| 1844 | 1952 | if (empty($do_fix) && strtr($detected_url, array('://' => '://www.')) == $boardurl && (empty($_GET) || count($_GET) == 1) && SMF != 'SSI') |
| 1845 | 1953 | { |
| 1846 | 1954 | // Okay, this seems weird, but we don't want an endless loop - this will make $_GET not empty ;). |
| 1847 | - if (empty($_GET)) |
|
| 1848 | - redirectexit('wwwRedirect'); |
|
| 1849 | - else |
|
| 1955 | + if (empty($_GET)) { |
|
| 1956 | + redirectexit('wwwRedirect'); |
|
| 1957 | + } else |
|
| 1850 | 1958 | { |
| 1851 | 1959 | list ($k, $v) = each($_GET); |
| 1852 | 1960 | |
| 1853 | - if ($k != 'wwwRedirect') |
|
| 1854 | - redirectexit('wwwRedirect;' . $k . '=' . $v); |
|
| 1961 | + if ($k != 'wwwRedirect') { |
|
| 1962 | + redirectexit('wwwRedirect;' . $k . '=' . $v); |
|
| 1963 | + } |
|
| 1855 | 1964 | } |
| 1856 | 1965 | } |
| 1857 | 1966 | |
| 1858 | 1967 | // #3 is just a check for SSL... |
| 1859 | - if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) |
|
| 1860 | - $do_fix = true; |
|
| 1968 | + if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) { |
|
| 1969 | + $do_fix = true; |
|
| 1970 | + } |
|
| 1861 | 1971 | |
| 1862 | 1972 | // Okay, #4 - perhaps it's an IP address? We're gonna want to use that one, then. (assuming it's the IP or something...) |
| 1863 | 1973 | if (!empty($do_fix) || preg_match('~^http[s]?://(?:[\d\.:]+|\[[\d:]+\](?::\d+)?)(?:$|/)~', $detected_url) == 1) |
@@ -1891,8 +2001,9 @@ discard block |
||
| 1891 | 2001 | $board_info['moderators'][$k]['link'] = strtr($dummy['link'], array('"' . $oldurl => '"' . $boardurl)); |
| 1892 | 2002 | } |
| 1893 | 2003 | } |
| 1894 | - foreach ($context['linktree'] as $k => $dummy) |
|
| 1895 | - $context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl)); |
|
| 2004 | + foreach ($context['linktree'] as $k => $dummy) { |
|
| 2005 | + $context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl)); |
|
| 2006 | + } |
|
| 1896 | 2007 | } |
| 1897 | 2008 | } |
| 1898 | 2009 | // Set up the contextual user array. |
@@ -1911,16 +2022,16 @@ discard block |
||
| 1911 | 2022 | 'email' => $user_info['email'], |
| 1912 | 2023 | 'ignoreusers' => $user_info['ignoreusers'], |
| 1913 | 2024 | ); |
| 1914 | - if (!$context['user']['is_guest']) |
|
| 1915 | - $context['user']['name'] = $user_info['name']; |
|
| 1916 | - elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) |
|
| 1917 | - $context['user']['name'] = $txt['guest_title']; |
|
| 2025 | + if (!$context['user']['is_guest']) { |
|
| 2026 | + $context['user']['name'] = $user_info['name']; |
|
| 2027 | + } elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) { |
|
| 2028 | + $context['user']['name'] = $txt['guest_title']; |
|
| 2029 | + } |
|
| 1918 | 2030 | |
| 1919 | 2031 | // Determine the current smiley set. |
| 1920 | 2032 | $user_info['smiley_set'] = (!in_array($user_info['smiley_set'], explode(',', $modSettings['smiley_sets_known'])) && $user_info['smiley_set'] != 'none') || empty($modSettings['smiley_sets_enable']) ? (!empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default']) : $user_info['smiley_set']; |
| 1921 | 2033 | $context['user']['smiley_set'] = $user_info['smiley_set']; |
| 1922 | - } |
|
| 1923 | - else |
|
| 2034 | + } else |
|
| 1924 | 2035 | { |
| 1925 | 2036 | $context['user'] = array( |
| 1926 | 2037 | 'id' => -1, |
@@ -1936,18 +2047,24 @@ discard block |
||
| 1936 | 2047 | } |
| 1937 | 2048 | |
| 1938 | 2049 | // Some basic information... |
| 1939 | - if (!isset($context['html_headers'])) |
|
| 1940 | - $context['html_headers'] = ''; |
|
| 1941 | - if (!isset($context['javascript_files'])) |
|
| 1942 | - $context['javascript_files'] = array(); |
|
| 1943 | - if (!isset($context['css_files'])) |
|
| 1944 | - $context['css_files'] = array(); |
|
| 1945 | - if (!isset($context['css_header'])) |
|
| 1946 | - $context['css_header'] = array(); |
|
| 1947 | - if (!isset($context['javascript_inline'])) |
|
| 1948 | - $context['javascript_inline'] = array('standard' => array(), 'defer' => array()); |
|
| 1949 | - if (!isset($context['javascript_vars'])) |
|
| 1950 | - $context['javascript_vars'] = array(); |
|
| 2050 | + if (!isset($context['html_headers'])) { |
|
| 2051 | + $context['html_headers'] = ''; |
|
| 2052 | + } |
|
| 2053 | + if (!isset($context['javascript_files'])) { |
|
| 2054 | + $context['javascript_files'] = array(); |
|
| 2055 | + } |
|
| 2056 | + if (!isset($context['css_files'])) { |
|
| 2057 | + $context['css_files'] = array(); |
|
| 2058 | + } |
|
| 2059 | + if (!isset($context['css_header'])) { |
|
| 2060 | + $context['css_header'] = array(); |
|
| 2061 | + } |
|
| 2062 | + if (!isset($context['javascript_inline'])) { |
|
| 2063 | + $context['javascript_inline'] = array('standard' => array(), 'defer' => array()); |
|
| 2064 | + } |
|
| 2065 | + if (!isset($context['javascript_vars'])) { |
|
| 2066 | + $context['javascript_vars'] = array(); |
|
| 2067 | + } |
|
| 1951 | 2068 | |
| 1952 | 2069 | $context['login_url'] = (!empty($modSettings['force_ssl']) && $modSettings['force_ssl'] < 2 ? strtr($scripturl, array('http://' => 'https://')) : $scripturl) . '?action=login2'; |
| 1953 | 2070 | $context['menu_separator'] = !empty($settings['use_image_buttons']) ? ' ' : ' | '; |
@@ -1959,8 +2076,9 @@ discard block |
||
| 1959 | 2076 | $context['current_action'] = isset($_REQUEST['action']) ? $smcFunc['htmlspecialchars']($_REQUEST['action']) : null; |
| 1960 | 2077 | $context['current_subaction'] = isset($_REQUEST['sa']) ? $_REQUEST['sa'] : null; |
| 1961 | 2078 | $context['can_register'] = empty($modSettings['registration_method']) || $modSettings['registration_method'] != 3; |
| 1962 | - if (isset($modSettings['load_average'])) |
|
| 1963 | - $context['load_average'] = $modSettings['load_average']; |
|
| 2079 | + if (isset($modSettings['load_average'])) { |
|
| 2080 | + $context['load_average'] = $modSettings['load_average']; |
|
| 2081 | + } |
|
| 1964 | 2082 | |
| 1965 | 2083 | // Detect the browser. This is separated out because it's also used in attachment downloads |
| 1966 | 2084 | detectBrowser(); |
@@ -1974,8 +2092,9 @@ discard block |
||
| 1974 | 2092 | // This allows sticking some HTML on the page output - useful for controls. |
| 1975 | 2093 | $context['insert_after_template'] = ''; |
| 1976 | 2094 | |
| 1977 | - if (!isset($txt)) |
|
| 1978 | - $txt = array(); |
|
| 2095 | + if (!isset($txt)) { |
|
| 2096 | + $txt = array(); |
|
| 2097 | + } |
|
| 1979 | 2098 | |
| 1980 | 2099 | $simpleActions = array( |
| 1981 | 2100 | 'findmember', |
@@ -2021,9 +2140,10 @@ discard block |
||
| 2021 | 2140 | |
| 2022 | 2141 | // See if theres any extra param to check. |
| 2023 | 2142 | $requiresXML = false; |
| 2024 | - foreach ($extraParams as $key => $extra) |
|
| 2025 | - if (isset($_REQUEST[$extra])) |
|
| 2143 | + foreach ($extraParams as $key => $extra) { |
|
| 2144 | + if (isset($_REQUEST[$extra])) |
|
| 2026 | 2145 | $requiresXML = true; |
| 2146 | + } |
|
| 2027 | 2147 | |
| 2028 | 2148 | // Output is fully XML, so no need for the index template. |
| 2029 | 2149 | if (isset($_REQUEST['xml']) && (in_array($context['current_action'], $xmlActions) || $requiresXML)) |
@@ -2038,37 +2158,39 @@ discard block |
||
| 2038 | 2158 | { |
| 2039 | 2159 | loadLanguage('index+Modifications'); |
| 2040 | 2160 | $context['template_layers'] = array(); |
| 2041 | - } |
|
| 2042 | - |
|
| 2043 | - else |
|
| 2161 | + } else |
|
| 2044 | 2162 | { |
| 2045 | 2163 | // Custom templates to load, or just default? |
| 2046 | - if (isset($settings['theme_templates'])) |
|
| 2047 | - $templates = explode(',', $settings['theme_templates']); |
|
| 2048 | - else |
|
| 2049 | - $templates = array('index'); |
|
| 2164 | + if (isset($settings['theme_templates'])) { |
|
| 2165 | + $templates = explode(',', $settings['theme_templates']); |
|
| 2166 | + } else { |
|
| 2167 | + $templates = array('index'); |
|
| 2168 | + } |
|
| 2050 | 2169 | |
| 2051 | 2170 | // Load each template... |
| 2052 | - foreach ($templates as $template) |
|
| 2053 | - loadTemplate($template); |
|
| 2171 | + foreach ($templates as $template) { |
|
| 2172 | + loadTemplate($template); |
|
| 2173 | + } |
|
| 2054 | 2174 | |
| 2055 | 2175 | // ...and attempt to load their associated language files. |
| 2056 | 2176 | $required_files = implode('+', array_merge($templates, array('Modifications'))); |
| 2057 | 2177 | loadLanguage($required_files, '', false); |
| 2058 | 2178 | |
| 2059 | 2179 | // Custom template layers? |
| 2060 | - if (isset($settings['theme_layers'])) |
|
| 2061 | - $context['template_layers'] = explode(',', $settings['theme_layers']); |
|
| 2062 | - else |
|
| 2063 | - $context['template_layers'] = array('html', 'body'); |
|
| 2180 | + if (isset($settings['theme_layers'])) { |
|
| 2181 | + $context['template_layers'] = explode(',', $settings['theme_layers']); |
|
| 2182 | + } else { |
|
| 2183 | + $context['template_layers'] = array('html', 'body'); |
|
| 2184 | + } |
|
| 2064 | 2185 | } |
| 2065 | 2186 | |
| 2066 | 2187 | // Initialize the theme. |
| 2067 | 2188 | loadSubTemplate('init', 'ignore'); |
| 2068 | 2189 | |
| 2069 | 2190 | // Allow overriding the board wide time/number formats. |
| 2070 | - if (empty($user_settings['time_format']) && !empty($txt['time_format'])) |
|
| 2071 | - $user_info['time_format'] = $txt['time_format']; |
|
| 2191 | + if (empty($user_settings['time_format']) && !empty($txt['time_format'])) { |
|
| 2192 | + $user_info['time_format'] = $txt['time_format']; |
|
| 2193 | + } |
|
| 2072 | 2194 | |
| 2073 | 2195 | // Set the character set from the template. |
| 2074 | 2196 | $context['character_set'] = empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']; |
@@ -2076,12 +2198,14 @@ discard block |
||
| 2076 | 2198 | $context['right_to_left'] = !empty($txt['lang_rtl']); |
| 2077 | 2199 | |
| 2078 | 2200 | // Guests may still need a name. |
| 2079 | - if ($context['user']['is_guest'] && empty($context['user']['name'])) |
|
| 2080 | - $context['user']['name'] = $txt['guest_title']; |
|
| 2201 | + if ($context['user']['is_guest'] && empty($context['user']['name'])) { |
|
| 2202 | + $context['user']['name'] = $txt['guest_title']; |
|
| 2203 | + } |
|
| 2081 | 2204 | |
| 2082 | 2205 | // Any theme-related strings that need to be loaded? |
| 2083 | - if (!empty($settings['require_theme_strings'])) |
|
| 2084 | - loadLanguage('ThemeStrings', '', false); |
|
| 2206 | + if (!empty($settings['require_theme_strings'])) { |
|
| 2207 | + loadLanguage('ThemeStrings', '', false); |
|
| 2208 | + } |
|
| 2085 | 2209 | |
| 2086 | 2210 | // Make a special URL for the language. |
| 2087 | 2211 | $settings['lang_images_url'] = $settings['images_url'] . '/' . (!empty($txt['image_lang']) ? $txt['image_lang'] : $user_info['language']); |
@@ -2092,8 +2216,9 @@ discard block |
||
| 2092 | 2216 | // Here is my luvly Responsive CSS |
| 2093 | 2217 | loadCSSFile('responsive.css', array('force_current' => false, 'validate' => true, 'minimize' => true), 'smf_responsive'); |
| 2094 | 2218 | |
| 2095 | - if ($context['right_to_left']) |
|
| 2096 | - loadCSSFile('rtl.css', array(), 'smf_rtl'); |
|
| 2219 | + if ($context['right_to_left']) { |
|
| 2220 | + loadCSSFile('rtl.css', array(), 'smf_rtl'); |
|
| 2221 | + } |
|
| 2097 | 2222 | |
| 2098 | 2223 | // We allow theme variants, because we're cool. |
| 2099 | 2224 | $context['theme_variant'] = ''; |
@@ -2101,14 +2226,17 @@ discard block |
||
| 2101 | 2226 | if (!empty($settings['theme_variants'])) |
| 2102 | 2227 | { |
| 2103 | 2228 | // Overriding - for previews and that ilk. |
| 2104 | - if (!empty($_REQUEST['variant'])) |
|
| 2105 | - $_SESSION['id_variant'] = $_REQUEST['variant']; |
|
| 2229 | + if (!empty($_REQUEST['variant'])) { |
|
| 2230 | + $_SESSION['id_variant'] = $_REQUEST['variant']; |
|
| 2231 | + } |
|
| 2106 | 2232 | // User selection? |
| 2107 | - if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) |
|
| 2108 | - $context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : ''); |
|
| 2233 | + if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) { |
|
| 2234 | + $context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : ''); |
|
| 2235 | + } |
|
| 2109 | 2236 | // If not a user variant, select the default. |
| 2110 | - if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) |
|
| 2111 | - $context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0]; |
|
| 2237 | + if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) { |
|
| 2238 | + $context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0]; |
|
| 2239 | + } |
|
| 2112 | 2240 | |
| 2113 | 2241 | // Do this to keep things easier in the templates. |
| 2114 | 2242 | $context['theme_variant'] = '_' . $context['theme_variant']; |
@@ -2117,20 +2245,23 @@ discard block |
||
| 2117 | 2245 | if (!empty($context['theme_variant'])) |
| 2118 | 2246 | { |
| 2119 | 2247 | loadCSSFile('index' . $context['theme_variant'] . '.css', array(), 'smf_index' . $context['theme_variant']); |
| 2120 | - if ($context['right_to_left']) |
|
| 2121 | - loadCSSFile('rtl' . $context['theme_variant'] . '.css', array(), 'smf_rtl' . $context['theme_variant']); |
|
| 2248 | + if ($context['right_to_left']) { |
|
| 2249 | + loadCSSFile('rtl' . $context['theme_variant'] . '.css', array(), 'smf_rtl' . $context['theme_variant']); |
|
| 2250 | + } |
|
| 2122 | 2251 | } |
| 2123 | 2252 | } |
| 2124 | 2253 | |
| 2125 | 2254 | // Let's be compatible with old themes! |
| 2126 | - if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) |
|
| 2127 | - $context['template_layers'] = array('main'); |
|
| 2255 | + if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) { |
|
| 2256 | + $context['template_layers'] = array('main'); |
|
| 2257 | + } |
|
| 2128 | 2258 | |
| 2129 | 2259 | $context['tabindex'] = 1; |
| 2130 | 2260 | |
| 2131 | 2261 | // Compatibility. |
| 2132 | - if (!isset($settings['theme_version'])) |
|
| 2133 | - $modSettings['memberCount'] = $modSettings['totalMembers']; |
|
| 2262 | + if (!isset($settings['theme_version'])) { |
|
| 2263 | + $modSettings['memberCount'] = $modSettings['totalMembers']; |
|
| 2264 | + } |
|
| 2134 | 2265 | |
| 2135 | 2266 | // Default JS variables for use in every theme |
| 2136 | 2267 | $context['javascript_vars'] = array( |
@@ -2149,18 +2280,18 @@ discard block |
||
| 2149 | 2280 | ); |
| 2150 | 2281 | |
| 2151 | 2282 | // Add the JQuery library to the list of files to load. |
| 2152 | - if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') |
|
| 2153 | - loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
| 2154 | - |
|
| 2155 | - elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') |
|
| 2156 | - loadJavaScriptFile('jquery-2.1.4.min.js', array('seed' => false), 'smf_jquery'); |
|
| 2157 | - |
|
| 2158 | - elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') |
|
| 2159 | - loadJavaScriptFile($modSettings['jquery_custom'], array(), 'smf_jquery'); |
|
| 2283 | + if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') { |
|
| 2284 | + loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
| 2285 | + } elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') { |
|
| 2286 | + loadJavaScriptFile('jquery-2.1.4.min.js', array('seed' => false), 'smf_jquery'); |
|
| 2287 | + } elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') { |
|
| 2288 | + loadJavaScriptFile($modSettings['jquery_custom'], array(), 'smf_jquery'); |
|
| 2289 | + } |
|
| 2160 | 2290 | |
| 2161 | 2291 | // Auto loading? template_javascript() will take care of the local half of this. |
| 2162 | - else |
|
| 2163 | - loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
| 2292 | + else { |
|
| 2293 | + loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
| 2294 | + } |
|
| 2164 | 2295 | |
| 2165 | 2296 | // Queue our JQuery plugins! |
| 2166 | 2297 | loadJavaScriptFile('smf_jquery_plugins.js', array('minimize' => true), 'smf_jquery_plugins'); |
@@ -2183,12 +2314,12 @@ discard block |
||
| 2183 | 2314 | require_once($sourcedir . '/ScheduledTasks.php'); |
| 2184 | 2315 | |
| 2185 | 2316 | // What to do, what to do?! |
| 2186 | - if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) |
|
| 2187 | - AutoTask(); |
|
| 2188 | - else |
|
| 2189 | - ReduceMailQueue(); |
|
| 2190 | - } |
|
| 2191 | - else |
|
| 2317 | + if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) { |
|
| 2318 | + AutoTask(); |
|
| 2319 | + } else { |
|
| 2320 | + ReduceMailQueue(); |
|
| 2321 | + } |
|
| 2322 | + } else |
|
| 2192 | 2323 | { |
| 2193 | 2324 | $type = empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time() ? 'task' : 'mailq'; |
| 2194 | 2325 | $ts = $type == 'mailq' ? $modSettings['mail_next_send'] : $modSettings['next_task_time']; |
@@ -2239,8 +2370,9 @@ discard block |
||
| 2239 | 2370 | foreach ($theme_includes as $include) |
| 2240 | 2371 | { |
| 2241 | 2372 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
| 2242 | - if (file_exists($include)) |
|
| 2243 | - require_once($include); |
|
| 2373 | + if (file_exists($include)) { |
|
| 2374 | + require_once($include); |
|
| 2375 | + } |
|
| 2244 | 2376 | } |
| 2245 | 2377 | } |
| 2246 | 2378 | |
@@ -2270,16 +2402,19 @@ discard block |
||
| 2270 | 2402 | // Do any style sheets first, cause we're easy with those. |
| 2271 | 2403 | if (!empty($style_sheets)) |
| 2272 | 2404 | { |
| 2273 | - if (!is_array($style_sheets)) |
|
| 2274 | - $style_sheets = array($style_sheets); |
|
| 2405 | + if (!is_array($style_sheets)) { |
|
| 2406 | + $style_sheets = array($style_sheets); |
|
| 2407 | + } |
|
| 2275 | 2408 | |
| 2276 | - foreach ($style_sheets as $sheet) |
|
| 2277 | - loadCSSFile($sheet . '.css', array(), $sheet); |
|
| 2409 | + foreach ($style_sheets as $sheet) { |
|
| 2410 | + loadCSSFile($sheet . '.css', array(), $sheet); |
|
| 2411 | + } |
|
| 2278 | 2412 | } |
| 2279 | 2413 | |
| 2280 | 2414 | // No template to load? |
| 2281 | - if ($template_name === false) |
|
| 2282 | - return true; |
|
| 2415 | + if ($template_name === false) { |
|
| 2416 | + return true; |
|
| 2417 | + } |
|
| 2283 | 2418 | |
| 2284 | 2419 | $loaded = false; |
| 2285 | 2420 | foreach ($settings['template_dirs'] as $template_dir) |
@@ -2294,12 +2429,14 @@ discard block |
||
| 2294 | 2429 | |
| 2295 | 2430 | if ($loaded) |
| 2296 | 2431 | { |
| 2297 | - if ($db_show_debug === true) |
|
| 2298 | - $context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')'; |
|
| 2432 | + if ($db_show_debug === true) { |
|
| 2433 | + $context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')'; |
|
| 2434 | + } |
|
| 2299 | 2435 | |
| 2300 | 2436 | // If they have specified an initialization function for this template, go ahead and call it now. |
| 2301 | - if (function_exists('template_' . $template_name . '_init')) |
|
| 2302 | - call_user_func('template_' . $template_name . '_init'); |
|
| 2437 | + if (function_exists('template_' . $template_name . '_init')) { |
|
| 2438 | + call_user_func('template_' . $template_name . '_init'); |
|
| 2439 | + } |
|
| 2303 | 2440 | } |
| 2304 | 2441 | // Hmmm... doesn't exist?! I don't suppose the directory is wrong, is it? |
| 2305 | 2442 | elseif (!file_exists($settings['default_theme_dir']) && file_exists($boarddir . '/Themes/default')) |
@@ -2319,13 +2456,14 @@ discard block |
||
| 2319 | 2456 | loadTemplate($template_name); |
| 2320 | 2457 | } |
| 2321 | 2458 | // Cause an error otherwise. |
| 2322 | - elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) |
|
| 2323 | - fatal_lang_error('theme_template_error', 'template', array((string) $template_name)); |
|
| 2324 | - elseif ($fatal) |
|
| 2325 | - die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load Themes/default/%s.template.php!', (string) $template_name), 'template')); |
|
| 2326 | - else |
|
| 2327 | - return false; |
|
| 2328 | -} |
|
| 2459 | + elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) { |
|
| 2460 | + fatal_lang_error('theme_template_error', 'template', array((string) $template_name)); |
|
| 2461 | + } elseif ($fatal) { |
|
| 2462 | + die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load Themes/default/%s.template.php!', (string) $template_name), 'template')); |
|
| 2463 | + } else { |
|
| 2464 | + return false; |
|
| 2465 | + } |
|
| 2466 | + } |
|
| 2329 | 2467 | |
| 2330 | 2468 | /** |
| 2331 | 2469 | * Load a sub-template. |
@@ -2343,17 +2481,19 @@ discard block |
||
| 2343 | 2481 | { |
| 2344 | 2482 | global $context, $txt, $db_show_debug; |
| 2345 | 2483 | |
| 2346 | - if ($db_show_debug === true) |
|
| 2347 | - $context['debug']['sub_templates'][] = $sub_template_name; |
|
| 2484 | + if ($db_show_debug === true) { |
|
| 2485 | + $context['debug']['sub_templates'][] = $sub_template_name; |
|
| 2486 | + } |
|
| 2348 | 2487 | |
| 2349 | 2488 | // Figure out what the template function is named. |
| 2350 | 2489 | $theme_function = 'template_' . $sub_template_name; |
| 2351 | - if (function_exists($theme_function)) |
|
| 2352 | - $theme_function(); |
|
| 2353 | - elseif ($fatal === false) |
|
| 2354 | - fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name)); |
|
| 2355 | - elseif ($fatal !== 'ignore') |
|
| 2356 | - die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load the %s sub template!', (string) $sub_template_name), 'template')); |
|
| 2490 | + if (function_exists($theme_function)) { |
|
| 2491 | + $theme_function(); |
|
| 2492 | + } elseif ($fatal === false) { |
|
| 2493 | + fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name)); |
|
| 2494 | + } elseif ($fatal !== 'ignore') { |
|
| 2495 | + die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load the %s sub template!', (string) $sub_template_name), 'template')); |
|
| 2496 | + } |
|
| 2357 | 2497 | |
| 2358 | 2498 | // Are we showing debugging for templates? Just make sure not to do it before the doctype... |
| 2359 | 2499 | if (allowedTo('admin_forum') && isset($_REQUEST['debug']) && !in_array($sub_template_name, array('init', 'main_below')) && ob_get_length() > 0 && !isset($_REQUEST['xml'])) |
@@ -2390,8 +2530,9 @@ discard block |
||
| 2390 | 2530 | $params['validate'] = isset($params['validate']) ? $params['validate'] : true; |
| 2391 | 2531 | |
| 2392 | 2532 | // If this is an external file, automatically set this to false. |
| 2393 | - if (!empty($params['external'])) |
|
| 2394 | - $params['minimize'] = false; |
|
| 2533 | + if (!empty($params['external'])) { |
|
| 2534 | + $params['minimize'] = false; |
|
| 2535 | + } |
|
| 2395 | 2536 | |
| 2396 | 2537 | // Account for shorthand like admin.css?alp21 filenames |
| 2397 | 2538 | $has_seed = strpos($fileName, '.css?'); |
@@ -2408,13 +2549,10 @@ discard block |
||
| 2408 | 2549 | { |
| 2409 | 2550 | $fileUrl = $settings['default_theme_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2410 | 2551 | $filePath = $settings['default_theme_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2552 | + } else { |
|
| 2553 | + $fileUrl = false; |
|
| 2411 | 2554 | } |
| 2412 | - |
|
| 2413 | - else |
|
| 2414 | - $fileUrl = false; |
|
| 2415 | - } |
|
| 2416 | - |
|
| 2417 | - else |
|
| 2555 | + } else |
|
| 2418 | 2556 | { |
| 2419 | 2557 | $fileUrl = $settings[$themeRef . '_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2420 | 2558 | $filePath = $settings[$themeRef . '_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
@@ -2429,12 +2567,14 @@ discard block |
||
| 2429 | 2567 | } |
| 2430 | 2568 | |
| 2431 | 2569 | // Add it to the array for use in the template |
| 2432 | - if (!empty($fileName)) |
|
| 2433 | - $context['css_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
| 2570 | + if (!empty($fileName)) { |
|
| 2571 | + $context['css_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
| 2572 | + } |
|
| 2434 | 2573 | |
| 2435 | - if (!empty($context['right_to_left']) && !empty($params['rtl'])) |
|
| 2436 | - loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0))); |
|
| 2437 | -} |
|
| 2574 | + if (!empty($context['right_to_left']) && !empty($params['rtl'])) { |
|
| 2575 | + loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0))); |
|
| 2576 | + } |
|
| 2577 | + } |
|
| 2438 | 2578 | |
| 2439 | 2579 | /** |
| 2440 | 2580 | * Add a block of inline css code to be executed later |
@@ -2451,8 +2591,9 @@ discard block |
||
| 2451 | 2591 | global $context; |
| 2452 | 2592 | |
| 2453 | 2593 | // Gotta add something... |
| 2454 | - if (empty($css)) |
|
| 2455 | - return false; |
|
| 2594 | + if (empty($css)) { |
|
| 2595 | + return false; |
|
| 2596 | + } |
|
| 2456 | 2597 | |
| 2457 | 2598 | $context['css_header'][] = $css; |
| 2458 | 2599 | } |
@@ -2487,8 +2628,9 @@ discard block |
||
| 2487 | 2628 | $params['validate'] = isset($params['validate']) ? $params['validate'] : true; |
| 2488 | 2629 | |
| 2489 | 2630 | // If this is an external file, automatically set this to false. |
| 2490 | - if (!empty($params['external'])) |
|
| 2491 | - $params['minimize'] = false; |
|
| 2631 | + if (!empty($params['external'])) { |
|
| 2632 | + $params['minimize'] = false; |
|
| 2633 | + } |
|
| 2492 | 2634 | |
| 2493 | 2635 | // Account for shorthand like admin.js?alp21 filenames |
| 2494 | 2636 | $has_seed = strpos($fileName, '.js?'); |
@@ -2505,16 +2647,12 @@ discard block |
||
| 2505 | 2647 | { |
| 2506 | 2648 | $fileUrl = $settings['default_theme_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2507 | 2649 | $filePath = $settings['default_theme_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2508 | - } |
|
| 2509 | - |
|
| 2510 | - else |
|
| 2650 | + } else |
|
| 2511 | 2651 | { |
| 2512 | 2652 | $fileUrl = false; |
| 2513 | 2653 | $filePath = false; |
| 2514 | 2654 | } |
| 2515 | - } |
|
| 2516 | - |
|
| 2517 | - else |
|
| 2655 | + } else |
|
| 2518 | 2656 | { |
| 2519 | 2657 | $fileUrl = $settings[$themeRef . '_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2520 | 2658 | $filePath = $settings[$themeRef . '_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
@@ -2529,9 +2667,10 @@ discard block |
||
| 2529 | 2667 | } |
| 2530 | 2668 | |
| 2531 | 2669 | // Add it to the array for use in the template |
| 2532 | - if (!empty($fileName)) |
|
| 2533 | - $context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
| 2534 | -} |
|
| 2670 | + if (!empty($fileName)) { |
|
| 2671 | + $context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
| 2672 | + } |
|
| 2673 | + } |
|
| 2535 | 2674 | |
| 2536 | 2675 | /** |
| 2537 | 2676 | * Add a Javascript variable for output later (for feeding text strings and similar to JS) |
@@ -2545,9 +2684,10 @@ discard block |
||
| 2545 | 2684 | { |
| 2546 | 2685 | global $context; |
| 2547 | 2686 | |
| 2548 | - if (!empty($key) && (!empty($value) || $value === '0')) |
|
| 2549 | - $context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value; |
|
| 2550 | -} |
|
| 2687 | + if (!empty($key) && (!empty($value) || $value === '0')) { |
|
| 2688 | + $context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value; |
|
| 2689 | + } |
|
| 2690 | + } |
|
| 2551 | 2691 | |
| 2552 | 2692 | /** |
| 2553 | 2693 | * Add a block of inline Javascript code to be executed later |
@@ -2564,8 +2704,9 @@ discard block |
||
| 2564 | 2704 | { |
| 2565 | 2705 | global $context; |
| 2566 | 2706 | |
| 2567 | - if (empty($javascript)) |
|
| 2568 | - return false; |
|
| 2707 | + if (empty($javascript)) { |
|
| 2708 | + return false; |
|
| 2709 | + } |
|
| 2569 | 2710 | |
| 2570 | 2711 | $context['javascript_inline'][($defer === true ? 'defer' : 'standard')][] = $javascript; |
| 2571 | 2712 | } |
@@ -2586,15 +2727,18 @@ discard block |
||
| 2586 | 2727 | static $already_loaded = array(); |
| 2587 | 2728 | |
| 2588 | 2729 | // Default to the user's language. |
| 2589 | - if ($lang == '') |
|
| 2590 | - $lang = isset($user_info['language']) ? $user_info['language'] : $language; |
|
| 2730 | + if ($lang == '') { |
|
| 2731 | + $lang = isset($user_info['language']) ? $user_info['language'] : $language; |
|
| 2732 | + } |
|
| 2591 | 2733 | |
| 2592 | 2734 | // Do we want the English version of language file as fallback? |
| 2593 | - if (empty($modSettings['disable_language_fallback']) && $lang != 'english') |
|
| 2594 | - loadLanguage($template_name, 'english', false); |
|
| 2735 | + if (empty($modSettings['disable_language_fallback']) && $lang != 'english') { |
|
| 2736 | + loadLanguage($template_name, 'english', false); |
|
| 2737 | + } |
|
| 2595 | 2738 | |
| 2596 | - if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) |
|
| 2597 | - return $lang; |
|
| 2739 | + if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) { |
|
| 2740 | + return $lang; |
|
| 2741 | + } |
|
| 2598 | 2742 | |
| 2599 | 2743 | // Make sure we have $settings - if not we're in trouble and need to find it! |
| 2600 | 2744 | if (empty($settings['default_theme_dir'])) |
@@ -2605,8 +2749,9 @@ discard block |
||
| 2605 | 2749 | |
| 2606 | 2750 | // What theme are we in? |
| 2607 | 2751 | $theme_name = basename($settings['theme_url']); |
| 2608 | - if (empty($theme_name)) |
|
| 2609 | - $theme_name = 'unknown'; |
|
| 2752 | + if (empty($theme_name)) { |
|
| 2753 | + $theme_name = 'unknown'; |
|
| 2754 | + } |
|
| 2610 | 2755 | |
| 2611 | 2756 | // For each file open it up and write it out! |
| 2612 | 2757 | foreach (explode('+', $template_name) as $template) |
@@ -2685,8 +2830,9 @@ discard block |
||
| 2685 | 2830 | } |
| 2686 | 2831 | |
| 2687 | 2832 | // Keep track of what we're up to soldier. |
| 2688 | - if ($db_show_debug === true) |
|
| 2689 | - $context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')'; |
|
| 2833 | + if ($db_show_debug === true) { |
|
| 2834 | + $context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')'; |
|
| 2835 | + } |
|
| 2690 | 2836 | |
| 2691 | 2837 | // Remember what we have loaded, and in which language. |
| 2692 | 2838 | $already_loaded[$template_name] = $lang; |
@@ -2732,8 +2878,9 @@ discard block |
||
| 2732 | 2878 | ) |
| 2733 | 2879 | ); |
| 2734 | 2880 | // In the EXTREMELY unlikely event this happens, give an error message. |
| 2735 | - if ($smcFunc['db_num_rows']($result) == 0) |
|
| 2736 | - fatal_lang_error('parent_not_found', 'critical'); |
|
| 2881 | + if ($smcFunc['db_num_rows']($result) == 0) { |
|
| 2882 | + fatal_lang_error('parent_not_found', 'critical'); |
|
| 2883 | + } |
|
| 2737 | 2884 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 2738 | 2885 | { |
| 2739 | 2886 | if (!isset($boards[$row['id_board']])) |
@@ -2750,8 +2897,8 @@ discard block |
||
| 2750 | 2897 | ); |
| 2751 | 2898 | } |
| 2752 | 2899 | // If a moderator exists for this board, add that moderator for all children too. |
| 2753 | - if (!empty($row['id_moderator'])) |
|
| 2754 | - foreach ($boards as $id => $dummy) |
|
| 2900 | + if (!empty($row['id_moderator'])) { |
|
| 2901 | + foreach ($boards as $id => $dummy) |
|
| 2755 | 2902 | { |
| 2756 | 2903 | $boards[$id]['moderators'][$row['id_moderator']] = array( |
| 2757 | 2904 | 'id' => $row['id_moderator'], |
@@ -2759,11 +2906,12 @@ discard block |
||
| 2759 | 2906 | 'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'], |
| 2760 | 2907 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>' |
| 2761 | 2908 | ); |
| 2909 | + } |
|
| 2762 | 2910 | } |
| 2763 | 2911 | |
| 2764 | 2912 | // If a moderator group exists for this board, add that moderator group for all children too |
| 2765 | - if (!empty($row['id_moderator_group'])) |
|
| 2766 | - foreach ($boards as $id => $dummy) |
|
| 2913 | + if (!empty($row['id_moderator_group'])) { |
|
| 2914 | + foreach ($boards as $id => $dummy) |
|
| 2767 | 2915 | { |
| 2768 | 2916 | $boards[$id]['moderator_groups'][$row['id_moderator_group']] = array( |
| 2769 | 2917 | 'id' => $row['id_moderator_group'], |
@@ -2771,6 +2919,7 @@ discard block |
||
| 2771 | 2919 | 'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'], |
| 2772 | 2920 | 'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>' |
| 2773 | 2921 | ); |
| 2922 | + } |
|
| 2774 | 2923 | } |
| 2775 | 2924 | } |
| 2776 | 2925 | $smcFunc['db_free_result']($result); |
@@ -2798,23 +2947,27 @@ discard block |
||
| 2798 | 2947 | if (!$use_cache || ($context['languages'] = cache_get_data('known_languages' . ($favor_utf8 ? '' : '_all'), !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600)) == null) |
| 2799 | 2948 | { |
| 2800 | 2949 | // If we don't have our ucwords function defined yet, let's load the settings data. |
| 2801 | - if (empty($smcFunc['ucwords'])) |
|
| 2802 | - reloadSettings(); |
|
| 2950 | + if (empty($smcFunc['ucwords'])) { |
|
| 2951 | + reloadSettings(); |
|
| 2952 | + } |
|
| 2803 | 2953 | |
| 2804 | 2954 | // If we don't have our theme information yet, let's get it. |
| 2805 | - if (empty($settings['default_theme_dir'])) |
|
| 2806 | - loadTheme(0, false); |
|
| 2955 | + if (empty($settings['default_theme_dir'])) { |
|
| 2956 | + loadTheme(0, false); |
|
| 2957 | + } |
|
| 2807 | 2958 | |
| 2808 | 2959 | // Default language directories to try. |
| 2809 | 2960 | $language_directories = array( |
| 2810 | 2961 | $settings['default_theme_dir'] . '/languages', |
| 2811 | 2962 | ); |
| 2812 | - if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) |
|
| 2813 | - $language_directories[] = $settings['actual_theme_dir'] . '/languages'; |
|
| 2963 | + if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) { |
|
| 2964 | + $language_directories[] = $settings['actual_theme_dir'] . '/languages'; |
|
| 2965 | + } |
|
| 2814 | 2966 | |
| 2815 | 2967 | // We possibly have a base theme directory. |
| 2816 | - if (!empty($settings['base_theme_dir'])) |
|
| 2817 | - $language_directories[] = $settings['base_theme_dir'] . '/languages'; |
|
| 2968 | + if (!empty($settings['base_theme_dir'])) { |
|
| 2969 | + $language_directories[] = $settings['base_theme_dir'] . '/languages'; |
|
| 2970 | + } |
|
| 2818 | 2971 | |
| 2819 | 2972 | // Remove any duplicates. |
| 2820 | 2973 | $language_directories = array_unique($language_directories); |
@@ -2828,20 +2981,21 @@ discard block |
||
| 2828 | 2981 | foreach ($language_directories as $language_dir) |
| 2829 | 2982 | { |
| 2830 | 2983 | // Can't look in here... doesn't exist! |
| 2831 | - if (!file_exists($language_dir)) |
|
| 2832 | - continue; |
|
| 2984 | + if (!file_exists($language_dir)) { |
|
| 2985 | + continue; |
|
| 2986 | + } |
|
| 2833 | 2987 | |
| 2834 | 2988 | $dir = dir($language_dir); |
| 2835 | 2989 | while ($entry = $dir->read()) |
| 2836 | 2990 | { |
| 2837 | 2991 | // Look for the index language file.... |
| 2838 | - if (!preg_match('~^index\.(.+)\.php$~', $entry, $matches)) |
|
| 2839 | - continue; |
|
| 2840 | - |
|
| 2841 | - if (!empty($langList) && !empty($langList[$matches[1]])) |
|
| 2842 | - $langName = $langList[$matches[1]]; |
|
| 2992 | + if (!preg_match('~^index\.(.+)\.php$~', $entry, $matches)) { |
|
| 2993 | + continue; |
|
| 2994 | + } |
|
| 2843 | 2995 | |
| 2844 | - else |
|
| 2996 | + if (!empty($langList) && !empty($langList[$matches[1]])) { |
|
| 2997 | + $langName = $langList[$matches[1]]; |
|
| 2998 | + } else |
|
| 2845 | 2999 | { |
| 2846 | 3000 | $langName = $smcFunc['ucwords'](strtr($matches[1], array('_' => ' '))); |
| 2847 | 3001 | |
@@ -2884,20 +3038,23 @@ discard block |
||
| 2884 | 3038 | } |
| 2885 | 3039 | |
| 2886 | 3040 | // Do we need to store the lang list? |
| 2887 | - if (empty($langList)) |
|
| 2888 | - updateSettings(array('langList' => json_encode($catchLang))); |
|
| 3041 | + if (empty($langList)) { |
|
| 3042 | + updateSettings(array('langList' => json_encode($catchLang))); |
|
| 3043 | + } |
|
| 2889 | 3044 | |
| 2890 | 3045 | // Favoring UTF8? Then prevent us from selecting non-UTF8 versions. |
| 2891 | 3046 | if ($favor_utf8) |
| 2892 | 3047 | { |
| 2893 | - foreach ($context['languages'] as $lang) |
|
| 2894 | - if (substr($lang['filename'], strlen($lang['filename']) - 5, 5) != '-utf8' && isset($context['languages'][$lang['filename'] . '-utf8'])) |
|
| 3048 | + foreach ($context['languages'] as $lang) { |
|
| 3049 | + if (substr($lang['filename'], strlen($lang['filename']) - 5, 5) != '-utf8' && isset($context['languages'][$lang['filename'] . '-utf8'])) |
|
| 2895 | 3050 | unset($context['languages'][$lang['filename']]); |
| 3051 | + } |
|
| 2896 | 3052 | } |
| 2897 | 3053 | |
| 2898 | 3054 | // Let's cash in on this deal. |
| 2899 | - if (!empty($modSettings['cache_enable'])) |
|
| 2900 | - cache_put_data('known_languages' . ($favor_utf8 ? '' : '_all'), $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600); |
|
| 3055 | + if (!empty($modSettings['cache_enable'])) { |
|
| 3056 | + cache_put_data('known_languages' . ($favor_utf8 ? '' : '_all'), $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600); |
|
| 3057 | + } |
|
| 2901 | 3058 | } |
| 2902 | 3059 | |
| 2903 | 3060 | return $context['languages']; |
@@ -2920,8 +3077,9 @@ discard block |
||
| 2920 | 3077 | global $modSettings, $options, $txt; |
| 2921 | 3078 | static $censor_vulgar = null, $censor_proper; |
| 2922 | 3079 | |
| 2923 | - if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') |
|
| 2924 | - return $text; |
|
| 3080 | + if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') { |
|
| 3081 | + return $text; |
|
| 3082 | + } |
|
| 2925 | 3083 | |
| 2926 | 3084 | // If they haven't yet been loaded, load them. |
| 2927 | 3085 | if ($censor_vulgar == null) |
@@ -2949,9 +3107,9 @@ discard block |
||
| 2949 | 3107 | { |
| 2950 | 3108 | $func = !empty($modSettings['censorIgnoreCase']) ? 'str_ireplace' : 'str_replace'; |
| 2951 | 3109 | $text = $func($censor_vulgar, $censor_proper, $text); |
| 3110 | + } else { |
|
| 3111 | + $text = preg_replace($censor_vulgar, $censor_proper, $text); |
|
| 2952 | 3112 | } |
| 2953 | - else |
|
| 2954 | - $text = preg_replace($censor_vulgar, $censor_proper, $text); |
|
| 2955 | 3113 | |
| 2956 | 3114 | return $text; |
| 2957 | 3115 | } |
@@ -2977,38 +3135,42 @@ discard block |
||
| 2977 | 3135 | @ini_set('track_errors', '1'); |
| 2978 | 3136 | |
| 2979 | 3137 | // Don't include the file more than once, if $once is true. |
| 2980 | - if ($once && in_array($filename, $templates)) |
|
| 2981 | - return; |
|
| 3138 | + if ($once && in_array($filename, $templates)) { |
|
| 3139 | + return; |
|
| 3140 | + } |
|
| 2982 | 3141 | // Add this file to the include list, whether $once is true or not. |
| 2983 | - else |
|
| 2984 | - $templates[] = $filename; |
|
| 3142 | + else { |
|
| 3143 | + $templates[] = $filename; |
|
| 3144 | + } |
|
| 2985 | 3145 | |
| 2986 | 3146 | // Are we going to use eval? |
| 2987 | 3147 | if (empty($modSettings['disableTemplateEval'])) |
| 2988 | 3148 | { |
| 2989 | 3149 | $file_found = file_exists($filename) && eval('?' . '>' . rtrim(file_get_contents($filename))) !== false; |
| 2990 | 3150 | $settings['current_include_filename'] = $filename; |
| 2991 | - } |
|
| 2992 | - else |
|
| 3151 | + } else |
|
| 2993 | 3152 | { |
| 2994 | 3153 | $file_found = file_exists($filename); |
| 2995 | 3154 | |
| 2996 | - if ($once && $file_found) |
|
| 2997 | - require_once($filename); |
|
| 2998 | - elseif ($file_found) |
|
| 2999 | - require($filename); |
|
| 3155 | + if ($once && $file_found) { |
|
| 3156 | + require_once($filename); |
|
| 3157 | + } elseif ($file_found) { |
|
| 3158 | + require($filename); |
|
| 3159 | + } |
|
| 3000 | 3160 | } |
| 3001 | 3161 | |
| 3002 | 3162 | if ($file_found !== true) |
| 3003 | 3163 | { |
| 3004 | 3164 | ob_end_clean(); |
| 3005 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
| 3006 | - @ob_start('ob_gzhandler'); |
|
| 3007 | - else |
|
| 3008 | - ob_start(); |
|
| 3165 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
| 3166 | + @ob_start('ob_gzhandler'); |
|
| 3167 | + } else { |
|
| 3168 | + ob_start(); |
|
| 3169 | + } |
|
| 3009 | 3170 | |
| 3010 | - if (isset($_GET['debug'])) |
|
| 3011 | - header('Content-Type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
| 3171 | + if (isset($_GET['debug'])) { |
|
| 3172 | + header('Content-Type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
| 3173 | + } |
|
| 3012 | 3174 | |
| 3013 | 3175 | // Don't cache error pages!! |
| 3014 | 3176 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
@@ -3027,12 +3189,13 @@ discard block |
||
| 3027 | 3189 | echo '<!DOCTYPE html> |
| 3028 | 3190 | <html', !empty($context['right_to_left']) ? ' dir="rtl"' : '', '> |
| 3029 | 3191 | <head>'; |
| 3030 | - if (isset($context['character_set'])) |
|
| 3031 | - echo ' |
|
| 3192 | + if (isset($context['character_set'])) { |
|
| 3193 | + echo ' |
|
| 3032 | 3194 | <meta charset="', $context['character_set'], '">'; |
| 3195 | + } |
|
| 3033 | 3196 | |
| 3034 | - if (!empty($maintenance) && !allowedTo('admin_forum')) |
|
| 3035 | - echo ' |
|
| 3197 | + if (!empty($maintenance) && !allowedTo('admin_forum')) { |
|
| 3198 | + echo ' |
|
| 3036 | 3199 | <title>', $mtitle, '</title> |
| 3037 | 3200 | </head> |
| 3038 | 3201 | <body> |
@@ -3040,8 +3203,8 @@ discard block |
||
| 3040 | 3203 | ', $mmessage, ' |
| 3041 | 3204 | </body> |
| 3042 | 3205 | </html>'; |
| 3043 | - elseif (!allowedTo('admin_forum')) |
|
| 3044 | - echo ' |
|
| 3206 | + } elseif (!allowedTo('admin_forum')) { |
|
| 3207 | + echo ' |
|
| 3045 | 3208 | <title>', $txt['template_parse_error'], '</title> |
| 3046 | 3209 | </head> |
| 3047 | 3210 | <body> |
@@ -3049,15 +3212,17 @@ discard block |
||
| 3049 | 3212 | ', $txt['template_parse_error_message'], ' |
| 3050 | 3213 | </body> |
| 3051 | 3214 | </html>'; |
| 3052 | - else |
|
| 3215 | + } else |
|
| 3053 | 3216 | { |
| 3054 | 3217 | require_once($sourcedir . '/Subs-Package.php'); |
| 3055 | 3218 | |
| 3056 | 3219 | $error = fetch_web_data($boardurl . strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => ''))); |
| 3057 | - if (empty($error) && ini_get('track_errors') && !empty($php_errormsg)) |
|
| 3058 | - $error = $php_errormsg; |
|
| 3059 | - if (empty($error)) |
|
| 3060 | - $error = $txt['template_parse_errmsg']; |
|
| 3220 | + if (empty($error) && ini_get('track_errors') && !empty($php_errormsg)) { |
|
| 3221 | + $error = $php_errormsg; |
|
| 3222 | + } |
|
| 3223 | + if (empty($error)) { |
|
| 3224 | + $error = $txt['template_parse_errmsg']; |
|
| 3225 | + } |
|
| 3061 | 3226 | |
| 3062 | 3227 | $error = strtr($error, array('<b>' => '<strong>', '</b>' => '</strong>')); |
| 3063 | 3228 | |
@@ -3068,11 +3233,12 @@ discard block |
||
| 3068 | 3233 | <h3>', $txt['template_parse_error'], '</h3> |
| 3069 | 3234 | ', sprintf($txt['template_parse_error_details'], strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => ''))); |
| 3070 | 3235 | |
| 3071 | - if (!empty($error)) |
|
| 3072 | - echo ' |
|
| 3236 | + if (!empty($error)) { |
|
| 3237 | + echo ' |
|
| 3073 | 3238 | <hr> |
| 3074 | 3239 | |
| 3075 | 3240 | <div style="margin: 0 20px;"><pre>', strtr(strtr($error, array('<strong>' . $boarddir => '<strong>...', '<strong>' . strtr($boarddir, '\\', '/') => '<strong>...')), '\\', '/'), '</pre></div>'; |
| 3241 | + } |
|
| 3076 | 3242 | |
| 3077 | 3243 | // I know, I know... this is VERY COMPLICATED. Still, it's good. |
| 3078 | 3244 | if (preg_match('~ <strong>(\d+)</strong><br( /)?' . '>$~i', $error, $match) != 0) |
@@ -3082,10 +3248,11 @@ discard block |
||
| 3082 | 3248 | $data2 = preg_split('~\<br( /)?\>~', $data2); |
| 3083 | 3249 | |
| 3084 | 3250 | // Fix the PHP code stuff... |
| 3085 | - if (!isBrowser('gecko')) |
|
| 3086 | - $data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2); |
|
| 3087 | - else |
|
| 3088 | - $data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2); |
|
| 3251 | + if (!isBrowser('gecko')) { |
|
| 3252 | + $data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2); |
|
| 3253 | + } else { |
|
| 3254 | + $data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2); |
|
| 3255 | + } |
|
| 3089 | 3256 | |
| 3090 | 3257 | // Now we get to work around a bug in PHP where it doesn't escape <br>s! |
| 3091 | 3258 | $j = -1; |
@@ -3093,8 +3260,9 @@ discard block |
||
| 3093 | 3260 | { |
| 3094 | 3261 | $j++; |
| 3095 | 3262 | |
| 3096 | - if (substr_count($line, '<br>') == 0) |
|
| 3097 | - continue; |
|
| 3263 | + if (substr_count($line, '<br>') == 0) { |
|
| 3264 | + continue; |
|
| 3265 | + } |
|
| 3098 | 3266 | |
| 3099 | 3267 | $n = substr_count($line, '<br>'); |
| 3100 | 3268 | for ($i = 0; $i < $n; $i++) |
@@ -3113,38 +3281,42 @@ discard block |
||
| 3113 | 3281 | // Figure out what the color coding was before... |
| 3114 | 3282 | $line = max($match[1] - 9, 1); |
| 3115 | 3283 | $last_line = ''; |
| 3116 | - for ($line2 = $line - 1; $line2 > 1; $line2--) |
|
| 3117 | - if (strpos($data2[$line2], '<') !== false) |
|
| 3284 | + for ($line2 = $line - 1; $line2 > 1; $line2--) { |
|
| 3285 | + if (strpos($data2[$line2], '<') !== false) |
|
| 3118 | 3286 | { |
| 3119 | 3287 | if (preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line2], $color_match) != 0) |
| 3120 | 3288 | $last_line = $color_match[1]; |
| 3289 | + } |
|
| 3121 | 3290 | break; |
| 3122 | 3291 | } |
| 3123 | 3292 | |
| 3124 | 3293 | // Show the relevant lines... |
| 3125 | 3294 | for ($n = min($match[1] + 4, count($data2) + 1); $line <= $n; $line++) |
| 3126 | 3295 | { |
| 3127 | - if ($line == $match[1]) |
|
| 3128 | - echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">'; |
|
| 3296 | + if ($line == $match[1]) { |
|
| 3297 | + echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">'; |
|
| 3298 | + } |
|
| 3129 | 3299 | |
| 3130 | 3300 | echo '<span style="color: black;">', sprintf('%' . strlen($n) . 's', $line), ':</span> '; |
| 3131 | - if (isset($data2[$line]) && $data2[$line] != '') |
|
| 3132 | - echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line]; |
|
| 3301 | + if (isset($data2[$line]) && $data2[$line] != '') { |
|
| 3302 | + echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line]; |
|
| 3303 | + } |
|
| 3133 | 3304 | |
| 3134 | 3305 | if (isset($data2[$line]) && preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line], $color_match) != 0) |
| 3135 | 3306 | { |
| 3136 | 3307 | $last_line = $color_match[1]; |
| 3137 | 3308 | echo '</', substr($last_line, 1, 4), '>'; |
| 3309 | + } elseif ($last_line != '' && strpos($data2[$line], '<') !== false) { |
|
| 3310 | + $last_line = ''; |
|
| 3311 | + } elseif ($last_line != '' && $data2[$line] != '') { |
|
| 3312 | + echo '</', substr($last_line, 1, 4), '>'; |
|
| 3138 | 3313 | } |
| 3139 | - elseif ($last_line != '' && strpos($data2[$line], '<') !== false) |
|
| 3140 | - $last_line = ''; |
|
| 3141 | - elseif ($last_line != '' && $data2[$line] != '') |
|
| 3142 | - echo '</', substr($last_line, 1, 4), '>'; |
|
| 3143 | 3314 | |
| 3144 | - if ($line == $match[1]) |
|
| 3145 | - echo '</pre></div><pre style="margin: 0;">'; |
|
| 3146 | - else |
|
| 3147 | - echo "\n"; |
|
| 3315 | + if ($line == $match[1]) { |
|
| 3316 | + echo '</pre></div><pre style="margin: 0;">'; |
|
| 3317 | + } else { |
|
| 3318 | + echo "\n"; |
|
| 3319 | + } |
|
| 3148 | 3320 | } |
| 3149 | 3321 | |
| 3150 | 3322 | echo '</pre></div>'; |
@@ -3168,8 +3340,9 @@ discard block |
||
| 3168 | 3340 | global $db_type, $db_name, $ssi_db_user, $ssi_db_passwd, $sourcedir, $db_prefix, $db_port; |
| 3169 | 3341 | |
| 3170 | 3342 | // Figure out what type of database we are using. |
| 3171 | - if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
|
| 3172 | - $db_type = 'mysql'; |
|
| 3343 | + if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) { |
|
| 3344 | + $db_type = 'mysql'; |
|
| 3345 | + } |
|
| 3173 | 3346 | |
| 3174 | 3347 | // Load the file for the database. |
| 3175 | 3348 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
@@ -3177,8 +3350,9 @@ discard block |
||
| 3177 | 3350 | $db_options = array(); |
| 3178 | 3351 | |
| 3179 | 3352 | // Add in the port if needed |
| 3180 | - if (!empty($db_port)) |
|
| 3181 | - $db_options['port'] = $db_port; |
|
| 3353 | + if (!empty($db_port)) { |
|
| 3354 | + $db_options['port'] = $db_port; |
|
| 3355 | + } |
|
| 3182 | 3356 | |
| 3183 | 3357 | // If we are in SSI try them first, but don't worry if it doesn't work, we have the normal username and password we can use. |
| 3184 | 3358 | if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd)) |
@@ -3197,13 +3371,15 @@ discard block |
||
| 3197 | 3371 | } |
| 3198 | 3372 | |
| 3199 | 3373 | // Safe guard here, if there isn't a valid connection lets put a stop to it. |
| 3200 | - if (!$db_connection) |
|
| 3201 | - display_db_error(); |
|
| 3374 | + if (!$db_connection) { |
|
| 3375 | + display_db_error(); |
|
| 3376 | + } |
|
| 3202 | 3377 | |
| 3203 | 3378 | // If in SSI mode fix up the prefix. |
| 3204 | - if (SMF == 'SSI') |
|
| 3205 | - db_fix_prefix($db_prefix, $db_name); |
|
| 3206 | -} |
|
| 3379 | + if (SMF == 'SSI') { |
|
| 3380 | + db_fix_prefix($db_prefix, $db_name); |
|
| 3381 | + } |
|
| 3382 | + } |
|
| 3207 | 3383 | |
| 3208 | 3384 | /** |
| 3209 | 3385 | * Try to load up a supported caching method. This is saved in $cacheAPI if we are not overriding it. |
@@ -3217,10 +3393,11 @@ discard block |
||
| 3217 | 3393 | global $sourcedir, $cacheAPI, $cache_accelerator; |
| 3218 | 3394 | |
| 3219 | 3395 | // Not overriding this and we have a cacheAPI, send it back. |
| 3220 | - if (empty($overrideCache) && is_object($cacheAPI)) |
|
| 3221 | - return $cacheAPI; |
|
| 3222 | - elseif (is_null($cacheAPI)) |
|
| 3223 | - $cacheAPI = false; |
|
| 3396 | + if (empty($overrideCache) && is_object($cacheAPI)) { |
|
| 3397 | + return $cacheAPI; |
|
| 3398 | + } elseif (is_null($cacheAPI)) { |
|
| 3399 | + $cacheAPI = false; |
|
| 3400 | + } |
|
| 3224 | 3401 | |
| 3225 | 3402 | // Make sure our class is in session. |
| 3226 | 3403 | require_once($sourcedir . '/Class-CacheAPI.php'); |
@@ -3241,8 +3418,9 @@ discard block |
||
| 3241 | 3418 | if (!$testAPI->isSupported()) |
| 3242 | 3419 | { |
| 3243 | 3420 | // Can we save ourselves? |
| 3244 | - if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') |
|
| 3245 | - return loadCacheAccelerator(null, false); |
|
| 3421 | + if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') { |
|
| 3422 | + return loadCacheAccelerator(null, false); |
|
| 3423 | + } |
|
| 3246 | 3424 | return false; |
| 3247 | 3425 | } |
| 3248 | 3426 | |
@@ -3254,9 +3432,9 @@ discard block |
||
| 3254 | 3432 | { |
| 3255 | 3433 | $cacheAPI = $testAPI; |
| 3256 | 3434 | return $cacheAPI; |
| 3435 | + } else { |
|
| 3436 | + return $testAPI; |
|
| 3257 | 3437 | } |
| 3258 | - else |
|
| 3259 | - return $testAPI; |
|
| 3260 | 3438 | } |
| 3261 | 3439 | } |
| 3262 | 3440 | |
@@ -3276,8 +3454,9 @@ discard block |
||
| 3276 | 3454 | |
| 3277 | 3455 | // @todo Why are we doing this if caching is disabled? |
| 3278 | 3456 | |
| 3279 | - if (function_exists('call_integration_hook')) |
|
| 3280 | - call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level)); |
|
| 3457 | + if (function_exists('call_integration_hook')) { |
|
| 3458 | + call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level)); |
|
| 3459 | + } |
|
| 3281 | 3460 | |
| 3282 | 3461 | /* Refresh the cache if either: |
| 3283 | 3462 | 1. Caching is disabled. |
@@ -3291,16 +3470,19 @@ discard block |
||
| 3291 | 3470 | require_once($sourcedir . '/' . $file); |
| 3292 | 3471 | $cache_block = call_user_func_array($function, $params); |
| 3293 | 3472 | |
| 3294 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) |
|
| 3295 | - cache_put_data($key, $cache_block, $cache_block['expires'] - time()); |
|
| 3473 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) { |
|
| 3474 | + cache_put_data($key, $cache_block, $cache_block['expires'] - time()); |
|
| 3475 | + } |
|
| 3296 | 3476 | } |
| 3297 | 3477 | |
| 3298 | 3478 | // Some cached data may need a freshening up after retrieval. |
| 3299 | - if (!empty($cache_block['post_retri_eval'])) |
|
| 3300 | - eval($cache_block['post_retri_eval']); |
|
| 3479 | + if (!empty($cache_block['post_retri_eval'])) { |
|
| 3480 | + eval($cache_block['post_retri_eval']); |
|
| 3481 | + } |
|
| 3301 | 3482 | |
| 3302 | - if (function_exists('call_integration_hook')) |
|
| 3303 | - call_integration_hook('post_cache_quick_get', array(&$cache_block)); |
|
| 3483 | + if (function_exists('call_integration_hook')) { |
|
| 3484 | + call_integration_hook('post_cache_quick_get', array(&$cache_block)); |
|
| 3485 | + } |
|
| 3304 | 3486 | |
| 3305 | 3487 | return $cache_block['data']; |
| 3306 | 3488 | } |
@@ -3327,8 +3509,9 @@ discard block |
||
| 3327 | 3509 | global $boardurl, $modSettings, $cache_enable, $cacheAPI; |
| 3328 | 3510 | global $cache_hits, $cache_count, $db_show_debug; |
| 3329 | 3511 | |
| 3330 | - if (empty($cache_enable) || empty($cacheAPI)) |
|
| 3331 | - return; |
|
| 3512 | + if (empty($cache_enable) || empty($cacheAPI)) { |
|
| 3513 | + return; |
|
| 3514 | + } |
|
| 3332 | 3515 | |
| 3333 | 3516 | $cache_count = isset($cache_count) ? $cache_count + 1 : 1; |
| 3334 | 3517 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -3341,12 +3524,14 @@ discard block |
||
| 3341 | 3524 | $value = $value === null ? null : json_encode($value); |
| 3342 | 3525 | $cacheAPI->putData($key, $value, $ttl); |
| 3343 | 3526 | |
| 3344 | - if (function_exists('call_integration_hook')) |
|
| 3345 | - call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl)); |
|
| 3527 | + if (function_exists('call_integration_hook')) { |
|
| 3528 | + call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl)); |
|
| 3529 | + } |
|
| 3346 | 3530 | |
| 3347 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
| 3348 | - $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
| 3349 | -} |
|
| 3531 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
| 3532 | + $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
| 3533 | + } |
|
| 3534 | + } |
|
| 3350 | 3535 | |
| 3351 | 3536 | /** |
| 3352 | 3537 | * Gets the value from the cache specified by key, so long as it is not older than ttl seconds. |
@@ -3362,8 +3547,9 @@ discard block |
||
| 3362 | 3547 | global $boardurl, $modSettings, $cache_enable, $cacheAPI; |
| 3363 | 3548 | global $cache_hits, $cache_count, $cache_misses, $cache_count_misses, $db_show_debug; |
| 3364 | 3549 | |
| 3365 | - if (empty($cache_enable) || empty($cacheAPI)) |
|
| 3366 | - return; |
|
| 3550 | + if (empty($cache_enable) || empty($cacheAPI)) { |
|
| 3551 | + return; |
|
| 3552 | + } |
|
| 3367 | 3553 | |
| 3368 | 3554 | $cache_count = isset($cache_count) ? $cache_count + 1 : 1; |
| 3369 | 3555 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -3383,16 +3569,18 @@ discard block |
||
| 3383 | 3569 | |
| 3384 | 3570 | if (empty($value)) |
| 3385 | 3571 | { |
| 3386 | - if (!is_array($cache_misses)) |
|
| 3387 | - $cache_misses = array(); |
|
| 3572 | + if (!is_array($cache_misses)) { |
|
| 3573 | + $cache_misses = array(); |
|
| 3574 | + } |
|
| 3388 | 3575 | |
| 3389 | 3576 | $cache_count_misses = isset($cache_count_misses) ? $cache_count_misses + 1 : 1; |
| 3390 | 3577 | $cache_misses[$cache_count_misses] = array('k' => $original_key, 'd' => 'get'); |
| 3391 | 3578 | } |
| 3392 | 3579 | } |
| 3393 | 3580 | |
| 3394 | - if (function_exists('call_integration_hook') && isset($value)) |
|
| 3395 | - call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value)); |
|
| 3581 | + if (function_exists('call_integration_hook') && isset($value)) { |
|
| 3582 | + call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value)); |
|
| 3583 | + } |
|
| 3396 | 3584 | |
| 3397 | 3585 | return empty($value) ? null : smf_json_decode($value, true); |
| 3398 | 3586 | } |
@@ -3414,8 +3602,9 @@ discard block |
||
| 3414 | 3602 | global $cachedir, $sourcedir, $modSettings, $cacheAPI; |
| 3415 | 3603 | |
| 3416 | 3604 | // If we can't get to the API, can't do this. |
| 3417 | - if (empty($cacheAPI)) |
|
| 3418 | - return false; |
|
| 3605 | + if (empty($cacheAPI)) { |
|
| 3606 | + return false; |
|
| 3607 | + } |
|
| 3419 | 3608 | |
| 3420 | 3609 | // Ask the API to do the heavy lifting. cleanCache also calls invalidateCache to be sure. |
| 3421 | 3610 | $value = $cacheAPI->cleanCache($type); |
@@ -3440,8 +3629,9 @@ discard block |
||
| 3440 | 3629 | global $modSettings, $boardurl, $smcFunc, $image_proxy_enabled, $image_proxy_secret; |
| 3441 | 3630 | |
| 3442 | 3631 | // Come on! |
| 3443 | - if (empty($data)) |
|
| 3444 | - return array(); |
|
| 3632 | + if (empty($data)) { |
|
| 3633 | + return array(); |
|
| 3634 | + } |
|
| 3445 | 3635 | |
| 3446 | 3636 | // Set a nice default var. |
| 3447 | 3637 | $image = ''; |
@@ -3449,11 +3639,11 @@ discard block |
||
| 3449 | 3639 | // Gravatar has been set as mandatory! |
| 3450 | 3640 | if (!empty($modSettings['gravatarOverride'])) |
| 3451 | 3641 | { |
| 3452 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) |
|
| 3453 | - $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
| 3454 | - |
|
| 3455 | - else if (!empty($data['email'])) |
|
| 3456 | - $image = get_gravatar_url($data['email']); |
|
| 3642 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) { |
|
| 3643 | + $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
| 3644 | + } else if (!empty($data['email'])) { |
|
| 3645 | + $image = get_gravatar_url($data['email']); |
|
| 3646 | + } |
|
| 3457 | 3647 | } |
| 3458 | 3648 | |
| 3459 | 3649 | // Look if the user has a gravatar field or has set an external url as avatar. |
@@ -3465,54 +3655,60 @@ discard block |
||
| 3465 | 3655 | // Gravatar. |
| 3466 | 3656 | if (stristr($data['avatar'], 'gravatar://')) |
| 3467 | 3657 | { |
| 3468 | - if ($data['avatar'] == 'gravatar://') |
|
| 3469 | - $image = get_gravatar_url($data['email']); |
|
| 3470 | - |
|
| 3471 | - elseif (!empty($modSettings['gravatarAllowExtraEmail'])) |
|
| 3472 | - $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
| 3658 | + if ($data['avatar'] == 'gravatar://') { |
|
| 3659 | + $image = get_gravatar_url($data['email']); |
|
| 3660 | + } elseif (!empty($modSettings['gravatarAllowExtraEmail'])) { |
|
| 3661 | + $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
| 3662 | + } |
|
| 3473 | 3663 | } |
| 3474 | 3664 | |
| 3475 | 3665 | // External url. |
| 3476 | 3666 | else |
| 3477 | 3667 | { |
| 3478 | 3668 | // Using ssl? |
| 3479 | - if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false) |
|
| 3480 | - $image = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($data['avatar']) . '&hash=' . md5($data['avatar'] . $image_proxy_secret); |
|
| 3669 | + if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false) { |
|
| 3670 | + $image = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($data['avatar']) . '&hash=' . md5($data['avatar'] . $image_proxy_secret); |
|
| 3671 | + } |
|
| 3481 | 3672 | |
| 3482 | 3673 | // Just a plain external url. |
| 3483 | - else |
|
| 3484 | - $image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar']; |
|
| 3674 | + else { |
|
| 3675 | + $image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar']; |
|
| 3676 | + } |
|
| 3485 | 3677 | } |
| 3486 | 3678 | } |
| 3487 | 3679 | |
| 3488 | 3680 | // Perhaps this user has an attachment as avatar... |
| 3489 | - else if (!empty($data['filename'])) |
|
| 3490 | - $image = $modSettings['custom_avatar_url'] . '/' . $data['filename']; |
|
| 3681 | + else if (!empty($data['filename'])) { |
|
| 3682 | + $image = $modSettings['custom_avatar_url'] . '/' . $data['filename']; |
|
| 3683 | + } |
|
| 3491 | 3684 | |
| 3492 | 3685 | // Right... no avatar... use our default image. |
| 3493 | - else |
|
| 3494 | - $image = $modSettings['avatar_url'] . '/default.png'; |
|
| 3686 | + else { |
|
| 3687 | + $image = $modSettings['avatar_url'] . '/default.png'; |
|
| 3688 | + } |
|
| 3495 | 3689 | } |
| 3496 | 3690 | |
| 3497 | 3691 | call_integration_hook('integrate_set_avatar_data', array(&$image, &$data)); |
| 3498 | 3692 | |
| 3499 | 3693 | // At this point in time $image has to be filled unless you chose to force gravatar and the user doesn't have the needed data to retrieve it... thus a check for !empty() is still needed. |
| 3500 | - if (!empty($image)) |
|
| 3501 | - return array( |
|
| 3694 | + if (!empty($image)) { |
|
| 3695 | + return array( |
|
| 3502 | 3696 | 'name' => !empty($data['avatar']) ? $data['avatar'] : '', |
| 3503 | 3697 | 'image' => '<img class="avatar" src="' . $image . '" />', |
| 3504 | 3698 | 'href' => $image, |
| 3505 | 3699 | 'url' => $image, |
| 3506 | 3700 | ); |
| 3701 | + } |
|
| 3507 | 3702 | |
| 3508 | 3703 | // Fallback to make life easier for everyone... |
| 3509 | - else |
|
| 3510 | - return array( |
|
| 3704 | + else { |
|
| 3705 | + return array( |
|
| 3511 | 3706 | 'name' => '', |
| 3512 | 3707 | 'image' => '', |
| 3513 | 3708 | 'href' => '', |
| 3514 | 3709 | 'url' => '', |
| 3515 | 3710 | ); |
| 3516 | -} |
|
| 3711 | + } |
|
| 3712 | + } |
|
| 3517 | 3713 | |
| 3518 | 3714 | ?> |
| 3519 | 3715 | \ No newline at end of file |
@@ -929,7 +929,7 @@ discard block |
||
| 929 | 929 | * Doesn't clean the inputs |
| 930 | 930 | * |
| 931 | 931 | * @param array $items_ids The items to remove |
| 932 | - * @param bool|int $group_id The ID of the group these triggers are associated with or false if deleting them from all groups |
|
| 932 | + * @param integer $group_id The ID of the group these triggers are associated with or false if deleting them from all groups |
|
| 933 | 933 | * @return bool Always returns true |
| 934 | 934 | */ |
| 935 | 935 | function removeBanTriggers($items_ids = array(), $group_id = false) |
@@ -1123,7 +1123,7 @@ discard block |
||
| 1123 | 1123 | * Errors in $context['ban_errors'] |
| 1124 | 1124 | * |
| 1125 | 1125 | * @param array $triggers The triggers to validate |
| 1126 | - * @return array An array of riggers and log info ready to be used |
|
| 1126 | + * @return integer An array of riggers and log info ready to be used |
|
| 1127 | 1127 | */ |
| 1128 | 1128 | function validateTriggers(&$triggers) |
| 1129 | 1129 | { |
@@ -784,7 +784,7 @@ discard block |
||
| 784 | 784 | ) |
| 785 | 785 | ); |
| 786 | 786 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 787 | - $error_ips[] = inet_dtop($row['ip']); |
|
| 787 | + $error_ips[] = inet_dtop($row['ip']); |
|
| 788 | 788 | $smcFunc['db_free_result']($request); |
| 789 | 789 | |
| 790 | 790 | return $error_ips; |
@@ -2168,9 +2168,9 @@ discard block |
||
| 2168 | 2168 | |
| 2169 | 2169 | if ($low == '255.255.255.255') return 'unknown'; |
| 2170 | 2170 | if ($low == $high) |
| 2171 | - return $low; |
|
| 2171 | + return $low; |
|
| 2172 | 2172 | else |
| 2173 | - return $low . '-' . $high; |
|
| 2173 | + return $low . '-' . $high; |
|
| 2174 | 2174 | } |
| 2175 | 2175 | |
| 2176 | 2176 | /** |
@@ -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 | * Ban center. The main entrance point for all ban center functions. |
@@ -120,10 +121,11 @@ discard block |
||
| 120 | 121 | } |
| 121 | 122 | |
| 122 | 123 | // Create a date string so we don't overload them with date info. |
| 123 | - if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
| 124 | - $context['ban_time_format'] = $user_info['time_format']; |
|
| 125 | - else |
|
| 126 | - $context['ban_time_format'] = $matches[0]; |
|
| 124 | + if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
| 125 | + $context['ban_time_format'] = $user_info['time_format']; |
|
| 126 | + } else { |
|
| 127 | + $context['ban_time_format'] = $matches[0]; |
|
| 128 | + } |
|
| 127 | 129 | |
| 128 | 130 | $listOptions = array( |
| 129 | 131 | 'id' => 'ban_list', |
@@ -201,16 +203,19 @@ discard block |
||
| 201 | 203 | 'function' => function($rowData) use ($txt) |
| 202 | 204 | { |
| 203 | 205 | // This ban never expires...whahaha. |
| 204 | - if ($rowData['expire_time'] === null) |
|
| 205 | - return $txt['never']; |
|
| 206 | + if ($rowData['expire_time'] === null) { |
|
| 207 | + return $txt['never']; |
|
| 208 | + } |
|
| 206 | 209 | |
| 207 | 210 | // This ban has already expired. |
| 208 | - elseif ($rowData['expire_time'] < time()) |
|
| 209 | - return sprintf('<span class="red">%1$s</span>', $txt['ban_expired']); |
|
| 211 | + elseif ($rowData['expire_time'] < time()) { |
|
| 212 | + return sprintf('<span class="red">%1$s</span>', $txt['ban_expired']); |
|
| 213 | + } |
|
| 210 | 214 | |
| 211 | 215 | // Still need to wait a few days for this ban to expire. |
| 212 | - else |
|
| 213 | - return sprintf('%1$d %2$s', ceil(($rowData['expire_time'] - time()) / (60 * 60 * 24)), $txt['ban_days']); |
|
| 216 | + else { |
|
| 217 | + return sprintf('%1$d %2$s', ceil(($rowData['expire_time'] - time()) / (60 * 60 * 24)), $txt['ban_days']); |
|
| 218 | + } |
|
| 214 | 219 | }, |
| 215 | 220 | ), |
| 216 | 221 | 'sort' => array( |
@@ -309,8 +314,9 @@ discard block |
||
| 309 | 314 | ) |
| 310 | 315 | ); |
| 311 | 316 | $bans = array(); |
| 312 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 313 | - $bans[] = $row; |
|
| 317 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 318 | + $bans[] = $row; |
|
| 319 | + } |
|
| 314 | 320 | |
| 315 | 321 | $smcFunc['db_free_result']($request); |
| 316 | 322 | |
@@ -352,8 +358,9 @@ discard block |
||
| 352 | 358 | { |
| 353 | 359 | global $txt, $modSettings, $context, $scripturl, $smcFunc, $sourcedir; |
| 354 | 360 | |
| 355 | - if ((isset($_POST['add_ban']) || isset($_POST['modify_ban']) || isset($_POST['remove_selection'])) && empty($context['ban_errors'])) |
|
| 356 | - BanEdit2(); |
|
| 361 | + if ((isset($_POST['add_ban']) || isset($_POST['modify_ban']) || isset($_POST['remove_selection'])) && empty($context['ban_errors'])) { |
|
| 362 | + BanEdit2(); |
|
| 363 | + } |
|
| 357 | 364 | |
| 358 | 365 | $ban_group_id = isset($context['ban']['id']) ? $context['ban']['id'] : (isset($_REQUEST['bg']) ? (int) $_REQUEST['bg'] : 0); |
| 359 | 366 | |
@@ -364,10 +371,10 @@ discard block |
||
| 364 | 371 | |
| 365 | 372 | if (!empty($context['ban_errors'])) |
| 366 | 373 | { |
| 367 | - foreach ($context['ban_errors'] as $error) |
|
| 368 | - $context['error_messages'][$error] = $txt[$error]; |
|
| 369 | - } |
|
| 370 | - else |
|
| 374 | + foreach ($context['ban_errors'] as $error) { |
|
| 375 | + $context['error_messages'][$error] = $txt[$error]; |
|
| 376 | + } |
|
| 377 | + } else |
|
| 371 | 378 | { |
| 372 | 379 | // If we're editing an existing ban, get it from the database. |
| 373 | 380 | if (!empty($ban_group_id)) |
@@ -403,12 +410,13 @@ discard block |
||
| 403 | 410 | 'data' => array( |
| 404 | 411 | 'function' => function($ban_item) use ($txt) |
| 405 | 412 | { |
| 406 | - if (in_array($ban_item['type'], array('ip', 'hostname', 'email'))) |
|
| 407 | - return '<strong>' . $txt[$ban_item['type']] . ':</strong> ' . $ban_item[$ban_item['type']]; |
|
| 408 | - elseif ($ban_item['type'] == 'user') |
|
| 409 | - return '<strong>' . $txt['username'] . ':</strong> ' . $ban_item['user']['link']; |
|
| 410 | - else |
|
| 411 | - return '<strong>' . $txt['unknown'] . ':</strong> ' . $ban_item['no_bantype_selected']; |
|
| 413 | + if (in_array($ban_item['type'], array('ip', 'hostname', 'email'))) { |
|
| 414 | + return '<strong>' . $txt[$ban_item['type']] . ':</strong> ' . $ban_item[$ban_item['type']]; |
|
| 415 | + } elseif ($ban_item['type'] == 'user') { |
|
| 416 | + return '<strong>' . $txt['username'] . ':</strong> ' . $ban_item['user']['link']; |
|
| 417 | + } else { |
|
| 418 | + return '<strong>' . $txt['unknown'] . ':</strong> ' . $ban_item['no_bantype_selected']; |
|
| 419 | + } |
|
| 412 | 420 | }, |
| 413 | 421 | 'style' => 'text-align: left;', |
| 414 | 422 | ), |
@@ -546,8 +554,9 @@ discard block |
||
| 546 | 554 | $context['ban']['from_user'] = true; |
| 547 | 555 | |
| 548 | 556 | // Would be nice if we could also ban the hostname. |
| 549 | - if ((preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $context['ban_suggestions']['main_ip']) == 1 || isValidIPv6($context['ban_suggestions']['main_ip'])) && empty($modSettings['disableHostnameLookup'])) |
|
| 550 | - $context['ban_suggestions']['hostname'] = host_from_ip($context['ban_suggestions']['main_ip']); |
|
| 557 | + if ((preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $context['ban_suggestions']['main_ip']) == 1 || isValidIPv6($context['ban_suggestions']['main_ip'])) && empty($modSettings['disableHostnameLookup'])) { |
|
| 558 | + $context['ban_suggestions']['hostname'] = host_from_ip($context['ban_suggestions']['main_ip']); |
|
| 559 | + } |
|
| 551 | 560 | |
| 552 | 561 | $context['ban_suggestions']['other_ips'] = banLoadAdditionalIPs($context['ban_suggestions']['member']['id']); |
| 553 | 562 | } |
@@ -615,8 +624,9 @@ discard block |
||
| 615 | 624 | 'items_per_page' => $items_per_page, |
| 616 | 625 | ) |
| 617 | 626 | ); |
| 618 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 619 | - fatal_lang_error('ban_not_found', false); |
|
| 627 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 628 | + fatal_lang_error('ban_not_found', false); |
|
| 629 | + } |
|
| 620 | 630 | |
| 621 | 631 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 622 | 632 | { |
@@ -653,18 +663,15 @@ discard block |
||
| 653 | 663 | { |
| 654 | 664 | $ban_items[$row['id_ban']]['type'] = 'ip'; |
| 655 | 665 | $ban_items[$row['id_ban']]['ip'] = range2ip($row['ip_low'], $row['ip_high']); |
| 656 | - } |
|
| 657 | - elseif (!empty($row['hostname'])) |
|
| 666 | + } elseif (!empty($row['hostname'])) |
|
| 658 | 667 | { |
| 659 | 668 | $ban_items[$row['id_ban']]['type'] = 'hostname'; |
| 660 | 669 | $ban_items[$row['id_ban']]['hostname'] = str_replace('%', '*', $row['hostname']); |
| 661 | - } |
|
| 662 | - elseif (!empty($row['email_address'])) |
|
| 670 | + } elseif (!empty($row['email_address'])) |
|
| 663 | 671 | { |
| 664 | 672 | $ban_items[$row['id_ban']]['type'] = 'email'; |
| 665 | 673 | $ban_items[$row['id_ban']]['email'] = str_replace('%', '*', $row['email_address']); |
| 666 | - } |
|
| 667 | - elseif (!empty($row['id_member'])) |
|
| 674 | + } elseif (!empty($row['id_member'])) |
|
| 668 | 675 | { |
| 669 | 676 | $ban_items[$row['id_ban']]['type'] = 'user'; |
| 670 | 677 | $ban_items[$row['id_ban']]['user'] = array( |
@@ -730,9 +737,10 @@ discard block |
||
| 730 | 737 | $search_list += array('ips_in_messages' => 'banLoadAdditionalIPsMember', 'ips_in_errors' => 'banLoadAdditionalIPsError'); |
| 731 | 738 | |
| 732 | 739 | $return = array(); |
| 733 | - foreach ($search_list as $key => $callable) |
|
| 734 | - if (is_callable($callable)) |
|
| 740 | + foreach ($search_list as $key => $callable) { |
|
| 741 | + if (is_callable($callable)) |
|
| 735 | 742 | $return[$key] = call_user_func($callable, $member_id); |
| 743 | + } |
|
| 736 | 744 | |
| 737 | 745 | return $return; |
| 738 | 746 | } |
@@ -757,8 +765,9 @@ discard block |
||
| 757 | 765 | 'current_user' => $member_id, |
| 758 | 766 | ) |
| 759 | 767 | ); |
| 760 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 761 | - $message_ips[] = inet_dtop($row['poster_ip']); |
|
| 768 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 769 | + $message_ips[] = inet_dtop($row['poster_ip']); |
|
| 770 | + } |
|
| 762 | 771 | $smcFunc['db_free_result']($request); |
| 763 | 772 | |
| 764 | 773 | return $message_ips; |
@@ -783,8 +792,9 @@ discard block |
||
| 783 | 792 | 'current_user' => $member_id, |
| 784 | 793 | ) |
| 785 | 794 | ); |
| 786 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 787 | - $error_ips[] = inet_dtop($row['ip']); |
|
| 795 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 796 | + $error_ips[] = inet_dtop($row['ip']); |
|
| 797 | + } |
|
| 788 | 798 | $smcFunc['db_free_result']($request); |
| 789 | 799 | |
| 790 | 800 | return $error_ips; |
@@ -825,11 +835,13 @@ discard block |
||
| 825 | 835 | $ban_info['cannot']['login'] = !empty($ban_info['full_ban']) || empty($_POST['cannot_login']) ? 0 : 1; |
| 826 | 836 | |
| 827 | 837 | // Adding a new ban group |
| 828 | - if (empty($_REQUEST['bg'])) |
|
| 829 | - $ban_group_id = insertBanGroup($ban_info); |
|
| 838 | + if (empty($_REQUEST['bg'])) { |
|
| 839 | + $ban_group_id = insertBanGroup($ban_info); |
|
| 840 | + } |
|
| 830 | 841 | // Editing an existing ban group |
| 831 | - else |
|
| 832 | - $ban_group_id = updateBanGroup($ban_info); |
|
| 842 | + else { |
|
| 843 | + $ban_group_id = updateBanGroup($ban_info); |
|
| 844 | + } |
|
| 833 | 845 | |
| 834 | 846 | if (is_numeric($ban_group_id)) |
| 835 | 847 | { |
@@ -840,9 +852,10 @@ discard block |
||
| 840 | 852 | $context['ban'] = $ban_info; |
| 841 | 853 | } |
| 842 | 854 | |
| 843 | - if (isset($_POST['ban_suggestions'])) |
|
| 844 | - // @TODO: is $_REQUEST['bi'] ever set? |
|
| 855 | + if (isset($_POST['ban_suggestions'])) { |
|
| 856 | + // @TODO: is $_REQUEST['bi'] ever set? |
|
| 845 | 857 | $saved_triggers = saveTriggers($_POST['ban_suggestions'], $ban_info['id'], isset($_REQUEST['u']) ? (int) $_REQUEST['u'] : 0, isset($_REQUEST['bi']) ? (int) $_REQUEST['bi'] : 0); |
| 858 | + } |
|
| 846 | 859 | |
| 847 | 860 | // Something went wrong somewhere... Oh well, let's go back. |
| 848 | 861 | if (!empty($context['ban_errors'])) |
@@ -852,8 +865,9 @@ discard block |
||
| 852 | 865 | $context['ban_suggestions'] = array_merge($context['ban_suggestions'], getMemberData((int) $_REQUEST['u'])); |
| 853 | 866 | |
| 854 | 867 | // Not strictly necessary, but it's nice |
| 855 | - if (!empty($context['ban_suggestions']['member']['id'])) |
|
| 856 | - $context['ban_suggestions']['other_ips'] = banLoadAdditionalIPs($context['ban_suggestions']['member']['id']); |
|
| 868 | + if (!empty($context['ban_suggestions']['member']['id'])) { |
|
| 869 | + $context['ban_suggestions']['other_ips'] = banLoadAdditionalIPs($context['ban_suggestions']['member']['id']); |
|
| 870 | + } |
|
| 857 | 871 | return BanEdit(); |
| 858 | 872 | } |
| 859 | 873 | $context['ban_suggestions']['saved_triggers'] = !empty($saved_triggers) ? $saved_triggers : array(); |
@@ -902,10 +916,11 @@ discard block |
||
| 902 | 916 | |
| 903 | 917 | foreach ($suggestions as $key => $value) |
| 904 | 918 | { |
| 905 | - if (is_array($value)) |
|
| 906 | - $triggers[$key] = $value; |
|
| 907 | - else |
|
| 908 | - $triggers[$value] = !empty($_POST[$value]) ? $_POST[$value] : ''; |
|
| 919 | + if (is_array($value)) { |
|
| 920 | + $triggers[$key] = $value; |
|
| 921 | + } else { |
|
| 922 | + $triggers[$value] = !empty($_POST[$value]) ? $_POST[$value] : ''; |
|
| 923 | + } |
|
| 909 | 924 | } |
| 910 | 925 | |
| 911 | 926 | $ban_triggers = validateTriggers($triggers); |
@@ -913,16 +928,18 @@ discard block |
||
| 913 | 928 | // Time to save! |
| 914 | 929 | if (!empty($ban_triggers['ban_triggers']) && empty($context['ban_errors'])) |
| 915 | 930 | { |
| 916 | - if (empty($ban_id)) |
|
| 917 | - addTriggers($ban_group, $ban_triggers['ban_triggers'], $ban_triggers['log_info']); |
|
| 918 | - else |
|
| 919 | - updateTriggers($ban_id, $ban_group, array_shift($ban_triggers['ban_triggers']), $ban_triggers['log_info']); |
|
| 931 | + if (empty($ban_id)) { |
|
| 932 | + addTriggers($ban_group, $ban_triggers['ban_triggers'], $ban_triggers['log_info']); |
|
| 933 | + } else { |
|
| 934 | + updateTriggers($ban_id, $ban_group, array_shift($ban_triggers['ban_triggers']), $ban_triggers['log_info']); |
|
| 935 | + } |
|
| 936 | + } |
|
| 937 | + if (!empty($context['ban_errors'])) { |
|
| 938 | + return $triggers; |
|
| 939 | + } else { |
|
| 940 | + return false; |
|
| 941 | + } |
|
| 920 | 942 | } |
| 921 | - if (!empty($context['ban_errors'])) |
|
| 922 | - return $triggers; |
|
| 923 | - else |
|
| 924 | - return false; |
|
| 925 | -} |
|
| 926 | 943 | |
| 927 | 944 | /** |
| 928 | 945 | * This function removes a bunch of triggers based on ids |
@@ -936,14 +953,17 @@ discard block |
||
| 936 | 953 | { |
| 937 | 954 | global $smcFunc, $scripturl; |
| 938 | 955 | |
| 939 | - if ($group_id !== false) |
|
| 940 | - $group_id = (int) $group_id; |
|
| 956 | + if ($group_id !== false) { |
|
| 957 | + $group_id = (int) $group_id; |
|
| 958 | + } |
|
| 941 | 959 | |
| 942 | - if (empty($group_id) && empty($items_ids)) |
|
| 943 | - return false; |
|
| 960 | + if (empty($group_id) && empty($items_ids)) { |
|
| 961 | + return false; |
|
| 962 | + } |
|
| 944 | 963 | |
| 945 | - if (!is_array($items_ids)) |
|
| 946 | - $items_ids = array($items_ids); |
|
| 964 | + if (!is_array($items_ids)) { |
|
| 965 | + $items_ids = array($items_ids); |
|
| 966 | + } |
|
| 947 | 967 | |
| 948 | 968 | $log_info = array(); |
| 949 | 969 | $ban_items = array(); |
@@ -981,8 +1001,7 @@ discard block |
||
| 981 | 1001 | 'bantype' => ($is_range ? 'ip_range' : 'main_ip'), |
| 982 | 1002 | 'value' => $ban_items[$row['id_ban']]['ip'], |
| 983 | 1003 | ); |
| 984 | - } |
|
| 985 | - elseif (!empty($row['hostname'])) |
|
| 1004 | + } elseif (!empty($row['hostname'])) |
|
| 986 | 1005 | { |
| 987 | 1006 | $ban_items[$row['id_ban']]['type'] = 'hostname'; |
| 988 | 1007 | $ban_items[$row['id_ban']]['hostname'] = str_replace('%', '*', $row['hostname']); |
@@ -990,8 +1009,7 @@ discard block |
||
| 990 | 1009 | 'bantype' => 'hostname', |
| 991 | 1010 | 'value' => $row['hostname'], |
| 992 | 1011 | ); |
| 993 | - } |
|
| 994 | - elseif (!empty($row['email_address'])) |
|
| 1012 | + } elseif (!empty($row['email_address'])) |
|
| 995 | 1013 | { |
| 996 | 1014 | $ban_items[$row['id_ban']]['type'] = 'email'; |
| 997 | 1015 | $ban_items[$row['id_ban']]['email'] = str_replace('%', '*', $row['email_address']); |
@@ -999,8 +1017,7 @@ discard block |
||
| 999 | 1017 | 'bantype' => 'email', |
| 1000 | 1018 | 'value' => $ban_items[$row['id_ban']]['email'], |
| 1001 | 1019 | ); |
| 1002 | - } |
|
| 1003 | - elseif (!empty($row['id_member'])) |
|
| 1020 | + } elseif (!empty($row['id_member'])) |
|
| 1004 | 1021 | { |
| 1005 | 1022 | $ban_items[$row['id_ban']]['type'] = 'user'; |
| 1006 | 1023 | $ban_items[$row['id_ban']]['user'] = array( |
@@ -1033,8 +1050,7 @@ discard block |
||
| 1033 | 1050 | 'ban_group' => $group_id, |
| 1034 | 1051 | ) |
| 1035 | 1052 | ); |
| 1036 | - } |
|
| 1037 | - elseif (!empty($items_ids)) |
|
| 1053 | + } elseif (!empty($items_ids)) |
|
| 1038 | 1054 | { |
| 1039 | 1055 | $smcFunc['db_query']('', ' |
| 1040 | 1056 | DELETE FROM {db_prefix}ban_items |
@@ -1059,13 +1075,15 @@ discard block |
||
| 1059 | 1075 | { |
| 1060 | 1076 | global $smcFunc; |
| 1061 | 1077 | |
| 1062 | - if (!is_array($group_ids)) |
|
| 1063 | - $group_ids = array($group_ids); |
|
| 1078 | + if (!is_array($group_ids)) { |
|
| 1079 | + $group_ids = array($group_ids); |
|
| 1080 | + } |
|
| 1064 | 1081 | |
| 1065 | 1082 | $group_ids = array_unique($group_ids); |
| 1066 | 1083 | |
| 1067 | - if (empty($group_ids)) |
|
| 1068 | - return false; |
|
| 1084 | + if (empty($group_ids)) { |
|
| 1085 | + return false; |
|
| 1086 | + } |
|
| 1069 | 1087 | |
| 1070 | 1088 | $smcFunc['db_query']('', ' |
| 1071 | 1089 | DELETE FROM {db_prefix}ban_groups |
@@ -1089,21 +1107,23 @@ discard block |
||
| 1089 | 1107 | { |
| 1090 | 1108 | global $smcFunc; |
| 1091 | 1109 | |
| 1092 | - if (empty($ids)) |
|
| 1093 | - $smcFunc['db_query']('truncate_table', ' |
|
| 1110 | + if (empty($ids)) { |
|
| 1111 | + $smcFunc['db_query']('truncate_table', ' |
|
| 1094 | 1112 | TRUNCATE {db_prefix}log_banned', |
| 1095 | 1113 | array( |
| 1096 | 1114 | ) |
| 1097 | 1115 | ); |
| 1098 | - else |
|
| 1116 | + } else |
|
| 1099 | 1117 | { |
| 1100 | - if (!is_array($ids)) |
|
| 1101 | - $ids = array($ids); |
|
| 1118 | + if (!is_array($ids)) { |
|
| 1119 | + $ids = array($ids); |
|
| 1120 | + } |
|
| 1102 | 1121 | |
| 1103 | 1122 | $ids = array_unique($ids); |
| 1104 | 1123 | |
| 1105 | - if (empty($ids)) |
|
| 1106 | - return false; |
|
| 1124 | + if (empty($ids)) { |
|
| 1125 | + return false; |
|
| 1126 | + } |
|
| 1107 | 1127 | |
| 1108 | 1128 | $smcFunc['db_query']('', ' |
| 1109 | 1129 | DELETE FROM {db_prefix}log_banned |
@@ -1129,8 +1149,9 @@ discard block |
||
| 1129 | 1149 | { |
| 1130 | 1150 | global $context, $smcFunc; |
| 1131 | 1151 | |
| 1132 | - if (empty($triggers)) |
|
| 1133 | - $context['ban_erros'][] = 'ban_empty_triggers'; |
|
| 1152 | + if (empty($triggers)) { |
|
| 1153 | + $context['ban_erros'][] = 'ban_empty_triggers'; |
|
| 1154 | + } |
|
| 1134 | 1155 | |
| 1135 | 1156 | $ban_triggers = array(); |
| 1136 | 1157 | $log_info = array(); |
@@ -1139,39 +1160,39 @@ discard block |
||
| 1139 | 1160 | { |
| 1140 | 1161 | if (!empty($value)) |
| 1141 | 1162 | { |
| 1142 | - if ($key == 'member') |
|
| 1143 | - continue; |
|
| 1163 | + if ($key == 'member') { |
|
| 1164 | + continue; |
|
| 1165 | + } |
|
| 1144 | 1166 | |
| 1145 | 1167 | if ($key == 'main_ip') |
| 1146 | 1168 | { |
| 1147 | 1169 | $value = trim($value); |
| 1148 | 1170 | $ip_parts = ip2range($value); |
| 1149 | - if (!checkExistingTriggerIP($ip_parts, $value)) |
|
| 1150 | - $context['ban_erros'][] = 'invalid_ip'; |
|
| 1151 | - else |
|
| 1171 | + if (!checkExistingTriggerIP($ip_parts, $value)) { |
|
| 1172 | + $context['ban_erros'][] = 'invalid_ip'; |
|
| 1173 | + } else |
|
| 1152 | 1174 | { |
| 1153 | 1175 | $ban_triggers['main_ip'] = array( |
| 1154 | 1176 | 'ip_low' => $ip_parts['low'], |
| 1155 | 1177 | 'ip_high' => $ip_parts['high'] |
| 1156 | 1178 | ); |
| 1157 | 1179 | } |
| 1158 | - } |
|
| 1159 | - elseif ($key == 'hostname') |
|
| 1180 | + } elseif ($key == 'hostname') |
|
| 1160 | 1181 | { |
| 1161 | - if (preg_match('/[^\w.\-*]/', $value) == 1) |
|
| 1162 | - $context['ban_erros'][] = 'invalid_hostname'; |
|
| 1163 | - else |
|
| 1182 | + if (preg_match('/[^\w.\-*]/', $value) == 1) { |
|
| 1183 | + $context['ban_erros'][] = 'invalid_hostname'; |
|
| 1184 | + } else |
|
| 1164 | 1185 | { |
| 1165 | 1186 | // Replace the * wildcard by a MySQL wildcard %. |
| 1166 | 1187 | $value = substr(str_replace('*', '%', $value), 0, 255); |
| 1167 | 1188 | |
| 1168 | 1189 | $ban_triggers['hostname']['hostname'] = $value; |
| 1169 | 1190 | } |
| 1170 | - } |
|
| 1171 | - elseif ($key == 'email') |
|
| 1191 | + } elseif ($key == 'email') |
|
| 1172 | 1192 | { |
| 1173 | - if (preg_match('/[^\w.\-\+*@]/', $value) == 1) |
|
| 1174 | - $context['ban_erros'][] = 'invalid_email'; |
|
| 1193 | + if (preg_match('/[^\w.\-\+*@]/', $value) == 1) { |
|
| 1194 | + $context['ban_erros'][] = 'invalid_email'; |
|
| 1195 | + } |
|
| 1175 | 1196 | |
| 1176 | 1197 | // Check the user is not banning an admin. |
| 1177 | 1198 | $request = $smcFunc['db_query']('', ' |
@@ -1185,15 +1206,15 @@ discard block |
||
| 1185 | 1206 | 'email' => $value, |
| 1186 | 1207 | ) |
| 1187 | 1208 | ); |
| 1188 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 1189 | - $context['ban_erros'][] = 'no_ban_admin'; |
|
| 1209 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 1210 | + $context['ban_erros'][] = 'no_ban_admin'; |
|
| 1211 | + } |
|
| 1190 | 1212 | $smcFunc['db_free_result']($request); |
| 1191 | 1213 | |
| 1192 | 1214 | $value = substr(strtolower(str_replace('*', '%', $value)), 0, 255); |
| 1193 | 1215 | |
| 1194 | 1216 | $ban_triggers['email']['email_address'] = $value; |
| 1195 | - } |
|
| 1196 | - elseif ($key == 'user') |
|
| 1217 | + } elseif ($key == 'user') |
|
| 1197 | 1218 | { |
| 1198 | 1219 | $user = preg_replace('~&#(\d{4,5}|[2-9]\d{2,4}|1[2-9]\d);~', '&#$1;', $smcFunc['htmlspecialchars']($value, ENT_QUOTES)); |
| 1199 | 1220 | |
@@ -1207,8 +1228,9 @@ discard block |
||
| 1207 | 1228 | 'username' => $user, |
| 1208 | 1229 | ) |
| 1209 | 1230 | ); |
| 1210 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1211 | - $context['ban_erros'][] = 'invalid_username'; |
|
| 1231 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1232 | + $context['ban_erros'][] = 'invalid_username'; |
|
| 1233 | + } |
|
| 1212 | 1234 | list ($value, $isAdmin) = $smcFunc['db_fetch_row']($request); |
| 1213 | 1235 | $smcFunc['db_free_result']($request); |
| 1214 | 1236 | |
@@ -1216,25 +1238,25 @@ discard block |
||
| 1216 | 1238 | { |
| 1217 | 1239 | unset($value); |
| 1218 | 1240 | $context['ban_erros'][] = 'no_ban_admin'; |
| 1241 | + } else { |
|
| 1242 | + $ban_triggers['user']['id_member'] = $value; |
|
| 1219 | 1243 | } |
| 1220 | - else |
|
| 1221 | - $ban_triggers['user']['id_member'] = $value; |
|
| 1222 | - } |
|
| 1223 | - elseif (in_array($key, array('ips_in_messages', 'ips_in_errors'))) |
|
| 1244 | + } elseif (in_array($key, array('ips_in_messages', 'ips_in_errors'))) |
|
| 1224 | 1245 | { |
| 1225 | 1246 | // Special case, those two are arrays themselves |
| 1226 | 1247 | $values = array_unique($value); |
| 1227 | 1248 | // Don't add the main IP again. |
| 1228 | - if (isset($triggers['main_ip'])) |
|
| 1229 | - $values = array_diff($values, array($triggers['main_ip'])); |
|
| 1249 | + if (isset($triggers['main_ip'])) { |
|
| 1250 | + $values = array_diff($values, array($triggers['main_ip'])); |
|
| 1251 | + } |
|
| 1230 | 1252 | unset($value); |
| 1231 | 1253 | foreach ($values as $val) |
| 1232 | 1254 | { |
| 1233 | 1255 | $val = trim($val); |
| 1234 | 1256 | $ip_parts = ip2range($val); |
| 1235 | - if (!checkExistingTriggerIP($ip_parts, $val)) |
|
| 1236 | - $context['ban_erros'][] = 'invalid_ip'; |
|
| 1237 | - else |
|
| 1257 | + if (!checkExistingTriggerIP($ip_parts, $val)) { |
|
| 1258 | + $context['ban_erros'][] = 'invalid_ip'; |
|
| 1259 | + } else |
|
| 1238 | 1260 | { |
| 1239 | 1261 | $ban_triggers[$key][] = array( |
| 1240 | 1262 | 'ip_low' => $ip_parts['low'], |
@@ -1247,15 +1269,16 @@ discard block |
||
| 1247 | 1269 | ); |
| 1248 | 1270 | } |
| 1249 | 1271 | } |
| 1272 | + } else { |
|
| 1273 | + $context['ban_erros'][] = 'no_bantype_selected'; |
|
| 1250 | 1274 | } |
| 1251 | - else |
|
| 1252 | - $context['ban_erros'][] = 'no_bantype_selected'; |
|
| 1253 | 1275 | |
| 1254 | - if (isset($value) && !is_array($value)) |
|
| 1255 | - $log_info[] = array( |
|
| 1276 | + if (isset($value) && !is_array($value)) { |
|
| 1277 | + $log_info[] = array( |
|
| 1256 | 1278 | 'value' => $value, |
| 1257 | 1279 | 'bantype' => $key, |
| 1258 | 1280 | ); |
| 1281 | + } |
|
| 1259 | 1282 | } |
| 1260 | 1283 | } |
| 1261 | 1284 | return array('ban_triggers' => $ban_triggers, 'log_info' => $log_info); |
@@ -1275,8 +1298,9 @@ discard block |
||
| 1275 | 1298 | { |
| 1276 | 1299 | global $smcFunc, $context; |
| 1277 | 1300 | |
| 1278 | - if (empty($group_id)) |
|
| 1279 | - $context['ban_errors'][] = 'ban_id_empty'; |
|
| 1301 | + if (empty($group_id)) { |
|
| 1302 | + $context['ban_errors'][] = 'ban_id_empty'; |
|
| 1303 | + } |
|
| 1280 | 1304 | |
| 1281 | 1305 | // Preset all values that are required. |
| 1282 | 1306 | $values = array( |
@@ -1301,18 +1325,21 @@ discard block |
||
| 1301 | 1325 | foreach ($triggers as $key => $trigger) |
| 1302 | 1326 | { |
| 1303 | 1327 | // Exceptions, exceptions, exceptions...always exceptions... :P |
| 1304 | - if (in_array($key, array('ips_in_messages', 'ips_in_errors'))) |
|
| 1305 | - foreach ($trigger as $real_trigger) |
|
| 1328 | + if (in_array($key, array('ips_in_messages', 'ips_in_errors'))) { |
|
| 1329 | + foreach ($trigger as $real_trigger) |
|
| 1306 | 1330 | $insertTriggers[] = array_merge($values, $real_trigger); |
| 1307 | - else |
|
| 1308 | - $insertTriggers[] = array_merge($values, $trigger); |
|
| 1331 | + } else { |
|
| 1332 | + $insertTriggers[] = array_merge($values, $trigger); |
|
| 1333 | + } |
|
| 1309 | 1334 | } |
| 1310 | 1335 | |
| 1311 | - if (empty($insertTriggers)) |
|
| 1312 | - $context['ban_errors'][] = 'ban_no_triggers'; |
|
| 1336 | + if (empty($insertTriggers)) { |
|
| 1337 | + $context['ban_errors'][] = 'ban_no_triggers'; |
|
| 1338 | + } |
|
| 1313 | 1339 | |
| 1314 | - if (!empty($context['ban_errors'])) |
|
| 1315 | - return false; |
|
| 1340 | + if (!empty($context['ban_errors'])) { |
|
| 1341 | + return false; |
|
| 1342 | + } |
|
| 1316 | 1343 | |
| 1317 | 1344 | $smcFunc['db_insert']('', |
| 1318 | 1345 | '{db_prefix}ban_items', |
@@ -1340,15 +1367,19 @@ discard block |
||
| 1340 | 1367 | { |
| 1341 | 1368 | global $smcFunc, $context; |
| 1342 | 1369 | |
| 1343 | - if (empty($ban_item)) |
|
| 1344 | - $context['ban_errors'][] = 'ban_ban_item_empty'; |
|
| 1345 | - if (empty($group_id)) |
|
| 1346 | - $context['ban_errors'][] = 'ban_id_empty'; |
|
| 1347 | - if (empty($trigger)) |
|
| 1348 | - $context['ban_errors'][] = 'ban_no_triggers'; |
|
| 1370 | + if (empty($ban_item)) { |
|
| 1371 | + $context['ban_errors'][] = 'ban_ban_item_empty'; |
|
| 1372 | + } |
|
| 1373 | + if (empty($group_id)) { |
|
| 1374 | + $context['ban_errors'][] = 'ban_id_empty'; |
|
| 1375 | + } |
|
| 1376 | + if (empty($trigger)) { |
|
| 1377 | + $context['ban_errors'][] = 'ban_no_triggers'; |
|
| 1378 | + } |
|
| 1349 | 1379 | |
| 1350 | - if (!empty($context['ban_errors'])) |
|
| 1351 | - return; |
|
| 1380 | + if (!empty($context['ban_errors'])) { |
|
| 1381 | + return; |
|
| 1382 | + } |
|
| 1352 | 1383 | |
| 1353 | 1384 | // Preset all values that are required. |
| 1354 | 1385 | $values = array( |
@@ -1389,8 +1420,9 @@ discard block |
||
| 1389 | 1420 | */ |
| 1390 | 1421 | function logTriggersUpdates($logs, $new = true, $removal = false) |
| 1391 | 1422 | { |
| 1392 | - if (empty($logs)) |
|
| 1393 | - return; |
|
| 1423 | + if (empty($logs)) { |
|
| 1424 | + return; |
|
| 1425 | + } |
|
| 1394 | 1426 | |
| 1395 | 1427 | $log_name_map = array( |
| 1396 | 1428 | 'main_ip' => 'ip_range', |
@@ -1401,14 +1433,15 @@ discard block |
||
| 1401 | 1433 | ); |
| 1402 | 1434 | |
| 1403 | 1435 | // Log the addion of the ban entries into the moderation log. |
| 1404 | - foreach ($logs as $log) |
|
| 1405 | - logAction('ban' . ($removal == true ? 'remove' : ''), array( |
|
| 1436 | + foreach ($logs as $log) { |
|
| 1437 | + logAction('ban' . ($removal == true ? 'remove' : ''), array( |
|
| 1406 | 1438 | $log_name_map[$log['bantype']] => $log['value'], |
| 1407 | 1439 | 'new' => empty($new) ? 0 : 1, |
| 1408 | 1440 | 'remove' => empty($removal) ? 0 : 1, |
| 1409 | 1441 | 'type' => $log['bantype'], |
| 1410 | 1442 | )); |
| 1411 | -} |
|
| 1443 | + } |
|
| 1444 | + } |
|
| 1412 | 1445 | |
| 1413 | 1446 | /** |
| 1414 | 1447 | * Updates an existing ban group |
@@ -1422,12 +1455,15 @@ discard block |
||
| 1422 | 1455 | { |
| 1423 | 1456 | global $smcFunc, $context; |
| 1424 | 1457 | |
| 1425 | - if (empty($ban_info['name'])) |
|
| 1426 | - $context['ban_errors'][] = 'ban_name_empty'; |
|
| 1427 | - if (empty($ban_info['id'])) |
|
| 1428 | - $context['ban_errors'][] = 'ban_id_empty'; |
|
| 1429 | - if (empty($ban_info['cannot']['access']) && empty($ban_info['cannot']['register']) && empty($ban_info['cannot']['post']) && empty($ban_info['cannot']['login'])) |
|
| 1430 | - $context['ban_errors'][] = 'ban_unknown_restriction_type'; |
|
| 1458 | + if (empty($ban_info['name'])) { |
|
| 1459 | + $context['ban_errors'][] = 'ban_name_empty'; |
|
| 1460 | + } |
|
| 1461 | + if (empty($ban_info['id'])) { |
|
| 1462 | + $context['ban_errors'][] = 'ban_id_empty'; |
|
| 1463 | + } |
|
| 1464 | + if (empty($ban_info['cannot']['access']) && empty($ban_info['cannot']['register']) && empty($ban_info['cannot']['post']) && empty($ban_info['cannot']['login'])) { |
|
| 1465 | + $context['ban_errors'][] = 'ban_unknown_restriction_type'; |
|
| 1466 | + } |
|
| 1431 | 1467 | |
| 1432 | 1468 | if (!empty($ban_info['id'])) |
| 1433 | 1469 | { |
@@ -1442,8 +1478,9 @@ discard block |
||
| 1442 | 1478 | ) |
| 1443 | 1479 | ); |
| 1444 | 1480 | |
| 1445 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1446 | - $context['ban_errors'][] = 'ban_not_found'; |
|
| 1481 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1482 | + $context['ban_errors'][] = 'ban_not_found'; |
|
| 1483 | + } |
|
| 1447 | 1484 | $smcFunc['db_free_result']($request); |
| 1448 | 1485 | } |
| 1449 | 1486 | |
@@ -1461,13 +1498,15 @@ discard block |
||
| 1461 | 1498 | 'new_ban_name' => $ban_info['name'], |
| 1462 | 1499 | ) |
| 1463 | 1500 | ); |
| 1464 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 1465 | - $context['ban_errors'][] = 'ban_name_exists'; |
|
| 1501 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 1502 | + $context['ban_errors'][] = 'ban_name_exists'; |
|
| 1503 | + } |
|
| 1466 | 1504 | $smcFunc['db_free_result']($request); |
| 1467 | 1505 | } |
| 1468 | 1506 | |
| 1469 | - if (!empty($context['ban_errors'])) |
|
| 1470 | - return $ban_info['id']; |
|
| 1507 | + if (!empty($context['ban_errors'])) { |
|
| 1508 | + return $ban_info['id']; |
|
| 1509 | + } |
|
| 1471 | 1510 | |
| 1472 | 1511 | $smcFunc['db_query']('', ' |
| 1473 | 1512 | UPDATE {db_prefix}ban_groups |
@@ -1511,10 +1550,12 @@ discard block |
||
| 1511 | 1550 | { |
| 1512 | 1551 | global $smcFunc, $context; |
| 1513 | 1552 | |
| 1514 | - if (empty($ban_info['name'])) |
|
| 1515 | - $context['ban_errors'][] = 'ban_name_empty'; |
|
| 1516 | - if (empty($ban_info['cannot']['access']) && empty($ban_info['cannot']['register']) && empty($ban_info['cannot']['post']) && empty($ban_info['cannot']['login'])) |
|
| 1517 | - $context['ban_errors'][] = 'ban_unknown_restriction_type'; |
|
| 1553 | + if (empty($ban_info['name'])) { |
|
| 1554 | + $context['ban_errors'][] = 'ban_name_empty'; |
|
| 1555 | + } |
|
| 1556 | + if (empty($ban_info['cannot']['access']) && empty($ban_info['cannot']['register']) && empty($ban_info['cannot']['post']) && empty($ban_info['cannot']['login'])) { |
|
| 1557 | + $context['ban_errors'][] = 'ban_unknown_restriction_type'; |
|
| 1558 | + } |
|
| 1518 | 1559 | |
| 1519 | 1560 | if (!empty($ban_info['name'])) |
| 1520 | 1561 | { |
@@ -1529,13 +1570,15 @@ discard block |
||
| 1529 | 1570 | ) |
| 1530 | 1571 | ); |
| 1531 | 1572 | |
| 1532 | - if ($smcFunc['db_num_rows']($request) == 1) |
|
| 1533 | - $context['ban_errors'][] = 'ban_name_exists'; |
|
| 1573 | + if ($smcFunc['db_num_rows']($request) == 1) { |
|
| 1574 | + $context['ban_errors'][] = 'ban_name_exists'; |
|
| 1575 | + } |
|
| 1534 | 1576 | $smcFunc['db_free_result']($request); |
| 1535 | 1577 | } |
| 1536 | 1578 | |
| 1537 | - if (!empty($context['ban_errors'])) |
|
| 1538 | - return; |
|
| 1579 | + if (!empty($context['ban_errors'])) { |
|
| 1580 | + return; |
|
| 1581 | + } |
|
| 1539 | 1582 | |
| 1540 | 1583 | // Yes yes, we're ready to add now. |
| 1541 | 1584 | $smcFunc['db_insert']('', |
@@ -1552,8 +1595,9 @@ discard block |
||
| 1552 | 1595 | ); |
| 1553 | 1596 | $ban_info['id'] = $smcFunc['db_insert_id']('{db_prefix}ban_groups', 'id_ban_group'); |
| 1554 | 1597 | |
| 1555 | - if (empty($ban_info['id'])) |
|
| 1556 | - $context['ban_errors'][] = 'impossible_insert_new_bangroup'; |
|
| 1598 | + if (empty($ban_info['id'])) { |
|
| 1599 | + $context['ban_errors'][] = 'impossible_insert_new_bangroup'; |
|
| 1600 | + } |
|
| 1557 | 1601 | |
| 1558 | 1602 | return $ban_info['id']; |
| 1559 | 1603 | } |
@@ -1578,24 +1622,24 @@ discard block |
||
| 1578 | 1622 | $ban_group = isset($_REQUEST['bg']) ? (int) $_REQUEST['bg'] : 0; |
| 1579 | 1623 | $ban_id = isset($_REQUEST['bi']) ? (int) $_REQUEST['bi'] : 0; |
| 1580 | 1624 | |
| 1581 | - if (empty($ban_group)) |
|
| 1582 | - fatal_lang_error('ban_not_found', false); |
|
| 1625 | + if (empty($ban_group)) { |
|
| 1626 | + fatal_lang_error('ban_not_found', false); |
|
| 1627 | + } |
|
| 1583 | 1628 | |
| 1584 | 1629 | if (isset($_POST['add_new_trigger']) && !empty($_POST['ban_suggestions'])) |
| 1585 | 1630 | { |
| 1586 | 1631 | saveTriggers($_POST['ban_suggestions'], $ban_group, 0, $ban_id); |
| 1587 | 1632 | redirectexit('action=admin;area=ban;sa=edit' . (!empty($ban_group) ? ';bg=' . $ban_group : '')); |
| 1588 | - } |
|
| 1589 | - elseif (isset($_POST['edit_trigger']) && !empty($_POST['ban_suggestions'])) |
|
| 1633 | + } elseif (isset($_POST['edit_trigger']) && !empty($_POST['ban_suggestions'])) |
|
| 1590 | 1634 | { |
| 1591 | 1635 | // The first replaces the old one, the others are added new (simplification, otherwise it would require another query and some work...) |
| 1592 | 1636 | saveTriggers(array_shift($_POST['ban_suggestions']), $ban_group, 0, $ban_id); |
| 1593 | - if (!empty($_POST['ban_suggestions'])) |
|
| 1594 | - saveTriggers($_POST['ban_suggestions'], $ban_group); |
|
| 1637 | + if (!empty($_POST['ban_suggestions'])) { |
|
| 1638 | + saveTriggers($_POST['ban_suggestions'], $ban_group); |
|
| 1639 | + } |
|
| 1595 | 1640 | |
| 1596 | 1641 | redirectexit('action=admin;area=ban;sa=edit' . (!empty($ban_group) ? ';bg=' . $ban_group : '')); |
| 1597 | - } |
|
| 1598 | - elseif (isset($_POST['edit_trigger'])) |
|
| 1642 | + } elseif (isset($_POST['edit_trigger'])) |
|
| 1599 | 1643 | { |
| 1600 | 1644 | removeBanTriggers($ban_id); |
| 1601 | 1645 | redirectexit('action=admin;area=ban;sa=edit' . (!empty($ban_group) ? ';bg=' . $ban_group : '')); |
@@ -1626,8 +1670,7 @@ discard block |
||
| 1626 | 1670 | ), |
| 1627 | 1671 | 'is_new' => true, |
| 1628 | 1672 | ); |
| 1629 | - } |
|
| 1630 | - else |
|
| 1673 | + } else |
|
| 1631 | 1674 | { |
| 1632 | 1675 | $request = $smcFunc['db_query']('', ' |
| 1633 | 1676 | SELECT |
@@ -1644,8 +1687,9 @@ discard block |
||
| 1644 | 1687 | 'ban_group' => $ban_group, |
| 1645 | 1688 | ) |
| 1646 | 1689 | ); |
| 1647 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1648 | - fatal_lang_error('ban_not_found', false); |
|
| 1690 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1691 | + fatal_lang_error('ban_not_found', false); |
|
| 1692 | + } |
|
| 1649 | 1693 | $row = $smcFunc['db_fetch_assoc']($request); |
| 1650 | 1694 | $smcFunc['db_free_result']($request); |
| 1651 | 1695 | |
@@ -1694,8 +1738,9 @@ discard block |
||
| 1694 | 1738 | removeBanTriggers($_POST['remove']); |
| 1695 | 1739 | |
| 1696 | 1740 | // Rehabilitate some members. |
| 1697 | - if ($_REQUEST['entity'] == 'member') |
|
| 1698 | - updateBanMembers(); |
|
| 1741 | + if ($_REQUEST['entity'] == 'member') { |
|
| 1742 | + updateBanMembers(); |
|
| 1743 | + } |
|
| 1699 | 1744 | |
| 1700 | 1745 | // Make sure the ban cache is refreshed. |
| 1701 | 1746 | updateSettings(array('banLastUpdated' => time())); |
@@ -1808,8 +1853,7 @@ discard block |
||
| 1808 | 1853 | 'default' => 'bi.ip_low, bi.ip_high, bi.ip_low', |
| 1809 | 1854 | 'reverse' => 'bi.ip_low DESC, bi.ip_high DESC', |
| 1810 | 1855 | ); |
| 1811 | - } |
|
| 1812 | - elseif ($context['selected_entity'] === 'hostname') |
|
| 1856 | + } elseif ($context['selected_entity'] === 'hostname') |
|
| 1813 | 1857 | { |
| 1814 | 1858 | $listOptions['columns']['banned_entity']['data'] = array( |
| 1815 | 1859 | 'function' => function($rowData) use ($smcFunc) |
@@ -1821,8 +1865,7 @@ discard block |
||
| 1821 | 1865 | 'default' => 'bi.hostname', |
| 1822 | 1866 | 'reverse' => 'bi.hostname DESC', |
| 1823 | 1867 | ); |
| 1824 | - } |
|
| 1825 | - elseif ($context['selected_entity'] === 'email') |
|
| 1868 | + } elseif ($context['selected_entity'] === 'email') |
|
| 1826 | 1869 | { |
| 1827 | 1870 | $listOptions['columns']['banned_entity']['data'] = array( |
| 1828 | 1871 | 'function' => function($rowData) use ($smcFunc) |
@@ -1834,8 +1877,7 @@ discard block |
||
| 1834 | 1877 | 'default' => 'bi.email_address', |
| 1835 | 1878 | 'reverse' => 'bi.email_address DESC', |
| 1836 | 1879 | ); |
| 1837 | - } |
|
| 1838 | - elseif ($context['selected_entity'] === 'member') |
|
| 1880 | + } elseif ($context['selected_entity'] === 'member') |
|
| 1839 | 1881 | { |
| 1840 | 1882 | $listOptions['columns']['banned_entity']['data'] = array( |
| 1841 | 1883 | 'sprintf' => array( |
@@ -1899,8 +1941,9 @@ discard block |
||
| 1899 | 1941 | ) |
| 1900 | 1942 | ); |
| 1901 | 1943 | $ban_triggers = array(); |
| 1902 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1903 | - $ban_triggers[] = $row; |
|
| 1944 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1945 | + $ban_triggers[] = $row; |
|
| 1946 | + } |
|
| 1904 | 1947 | $smcFunc['db_free_result']($request); |
| 1905 | 1948 | |
| 1906 | 1949 | return $ban_triggers; |
@@ -1956,8 +1999,9 @@ discard block |
||
| 1956 | 1999 | validateToken('admin-bl'); |
| 1957 | 2000 | |
| 1958 | 2001 | // 'Delete all entries' button was pressed. |
| 1959 | - if (!empty($_POST['removeAll'])) |
|
| 1960 | - removeBanLogs(); |
|
| 2002 | + if (!empty($_POST['removeAll'])) { |
|
| 2003 | + removeBanLogs(); |
|
| 2004 | + } |
|
| 1961 | 2005 | // 'Delete selection' button was pressed. |
| 1962 | 2006 | else |
| 1963 | 2007 | { |
@@ -2166,12 +2210,15 @@ discard block |
||
| 2166 | 2210 | $low = inet_dtop($low); |
| 2167 | 2211 | $high = inet_dtop($high); |
| 2168 | 2212 | |
| 2169 | - if ($low == '255.255.255.255') return 'unknown'; |
|
| 2170 | - if ($low == $high) |
|
| 2171 | - return $low; |
|
| 2172 | - else |
|
| 2173 | - return $low . '-' . $high; |
|
| 2174 | -} |
|
| 2213 | + if ($low == '255.255.255.255') { |
|
| 2214 | + return 'unknown'; |
|
| 2215 | + } |
|
| 2216 | + if ($low == $high) { |
|
| 2217 | + return $low; |
|
| 2218 | + } else { |
|
| 2219 | + return $low . '-' . $high; |
|
| 2220 | + } |
|
| 2221 | + } |
|
| 2175 | 2222 | |
| 2176 | 2223 | /** |
| 2177 | 2224 | * Checks whether a given IP range already exists in the trigger list. |
@@ -2247,15 +2294,17 @@ discard block |
||
| 2247 | 2294 | $memberEmailWild = array(); |
| 2248 | 2295 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2249 | 2296 | { |
| 2250 | - if ($row['id_member']) |
|
| 2251 | - $memberIDs[$row['id_member']] = $row['id_member']; |
|
| 2297 | + if ($row['id_member']) { |
|
| 2298 | + $memberIDs[$row['id_member']] = $row['id_member']; |
|
| 2299 | + } |
|
| 2252 | 2300 | if ($row['email_address']) |
| 2253 | 2301 | { |
| 2254 | 2302 | // Does it have a wildcard - if so we can't do a IN on it. |
| 2255 | - if (strpos($row['email_address'], '%') !== false) |
|
| 2256 | - $memberEmailWild[$row['email_address']] = $row['email_address']; |
|
| 2257 | - else |
|
| 2258 | - $memberEmails[$row['email_address']] = $row['email_address']; |
|
| 2303 | + if (strpos($row['email_address'], '%') !== false) { |
|
| 2304 | + $memberEmailWild[$row['email_address']] = $row['email_address']; |
|
| 2305 | + } else { |
|
| 2306 | + $memberEmails[$row['email_address']] = $row['email_address']; |
|
| 2307 | + } |
|
| 2259 | 2308 | } |
| 2260 | 2309 | } |
| 2261 | 2310 | $smcFunc['db_free_result']($request); |
@@ -2306,14 +2355,15 @@ discard block |
||
| 2306 | 2355 | } |
| 2307 | 2356 | |
| 2308 | 2357 | // We welcome our new members in the realm of the banned. |
| 2309 | - if (!empty($newMembers)) |
|
| 2310 | - $smcFunc['db_query']('', ' |
|
| 2358 | + if (!empty($newMembers)) { |
|
| 2359 | + $smcFunc['db_query']('', ' |
|
| 2311 | 2360 | DELETE FROM {db_prefix}log_online |
| 2312 | 2361 | WHERE id_member IN ({array_int:new_banned_members})', |
| 2313 | 2362 | array( |
| 2314 | 2363 | 'new_banned_members' => $newMembers, |
| 2315 | 2364 | ) |
| 2316 | 2365 | ); |
| 2366 | + } |
|
| 2317 | 2367 | |
| 2318 | 2368 | // Find members that are wrongfully marked as banned. |
| 2319 | 2369 | $request = $smcFunc['db_query']('', ' |
@@ -2340,9 +2390,10 @@ discard block |
||
| 2340 | 2390 | } |
| 2341 | 2391 | $smcFunc['db_free_result']($request); |
| 2342 | 2392 | |
| 2343 | - if (!empty($updates)) |
|
| 2344 | - foreach ($updates as $newStatus => $members) |
|
| 2393 | + if (!empty($updates)) { |
|
| 2394 | + foreach ($updates as $newStatus => $members) |
|
| 2345 | 2395 | updateMemberData($members, array('is_activated' => $newStatus)); |
| 2396 | + } |
|
| 2346 | 2397 | |
| 2347 | 2398 | // Update the latest member and our total members as banning may change them. |
| 2348 | 2399 | updateStats('member'); |
@@ -1452,7 +1452,7 @@ |
||
| 1452 | 1452 | * |
| 1453 | 1453 | * @param int $id_subscribe The subscription ID |
| 1454 | 1454 | * @param int $id_member The ID of the member |
| 1455 | - * @param int|string $renewal 0 if we're forcing start/end time, otherwise a string indicating how long to renew the subscription for ('D', 'W', 'M' or 'Y') |
|
| 1455 | + * @param integer $renewal 0 if we're forcing start/end time, otherwise a string indicating how long to renew the subscription for ('D', 'W', 'M' or 'Y') |
|
| 1456 | 1456 | * @param int $forceStartTime If set, forces the subscription to start at the specified time |
| 1457 | 1457 | * @param int $forceEndTime If set, forces the subscription to end at the specified time |
| 1458 | 1458 | */ |
@@ -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 | * The main entrance point for the 'Paid Subscription' screen, calling |
@@ -32,18 +33,19 @@ discard block |
||
| 32 | 33 | loadLanguage('ManagePaid'); |
| 33 | 34 | loadTemplate('ManagePaid'); |
| 34 | 35 | |
| 35 | - if (!empty($modSettings['paid_enabled'])) |
|
| 36 | - $subActions = array( |
|
| 36 | + if (!empty($modSettings['paid_enabled'])) { |
|
| 37 | + $subActions = array( |
|
| 37 | 38 | 'modify' => array('ModifySubscription', 'admin_forum'), |
| 38 | 39 | 'modifyuser' => array('ModifyUserSubscription', 'admin_forum'), |
| 39 | 40 | 'settings' => array('ModifySubscriptionSettings', 'admin_forum'), |
| 40 | 41 | 'view' => array('ViewSubscriptions', 'admin_forum'), |
| 41 | 42 | 'viewsub' => array('ViewSubscribedUsers', 'admin_forum'), |
| 42 | 43 | ); |
| 43 | - else |
|
| 44 | - $subActions = array( |
|
| 44 | + } else { |
|
| 45 | + $subActions = array( |
|
| 45 | 46 | 'settings' => array('ModifySubscriptionSettings', 'admin_forum'), |
| 46 | 47 | ); |
| 48 | + } |
|
| 47 | 49 | |
| 48 | 50 | // Default the sub-action to 'view subscriptions', but only if they have already set things up.. |
| 49 | 51 | $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : (!empty($modSettings['paid_currency_symbol']) && !empty($modSettings['paid_enabled']) ? 'view' : 'settings'); |
@@ -59,8 +61,8 @@ discard block |
||
| 59 | 61 | 'help' => '', |
| 60 | 62 | 'description' => $txt['paid_subscriptions_desc'], |
| 61 | 63 | ); |
| 62 | - if (!empty($modSettings['paid_enabled'])) |
|
| 63 | - $context[$context['admin_menu_name']]['tab_data']['tabs'] = array( |
|
| 64 | + if (!empty($modSettings['paid_enabled'])) { |
|
| 65 | + $context[$context['admin_menu_name']]['tab_data']['tabs'] = array( |
|
| 64 | 66 | 'view' => array( |
| 65 | 67 | 'description' => $txt['paid_subs_view_desc'], |
| 66 | 68 | ), |
@@ -68,6 +70,7 @@ discard block |
||
| 68 | 70 | 'description' => $txt['paid_subs_settings_desc'], |
| 69 | 71 | ), |
| 70 | 72 | ); |
| 73 | + } |
|
| 71 | 74 | |
| 72 | 75 | call_integration_hook('integrate_manage_subscriptions', array(&$subActions)); |
| 73 | 76 | |
@@ -92,8 +95,9 @@ discard block |
||
| 92 | 95 | { |
| 93 | 96 | // If the currency is set to something different then we need to set it to other for this to work and set it back shortly. |
| 94 | 97 | $modSettings['paid_currency'] = !empty($modSettings['paid_currency_code']) ? $modSettings['paid_currency_code'] : ''; |
| 95 | - if (!empty($modSettings['paid_currency_code']) && !in_array($modSettings['paid_currency_code'], array('usd', 'eur', 'gbp', 'cad', 'aud'))) |
|
| 96 | - $modSettings['paid_currency'] = 'other'; |
|
| 98 | + if (!empty($modSettings['paid_currency_code']) && !in_array($modSettings['paid_currency_code'], array('usd', 'eur', 'gbp', 'cad', 'aud'))) { |
|
| 99 | + $modSettings['paid_currency'] = 'other'; |
|
| 100 | + } |
|
| 97 | 101 | |
| 98 | 102 | // These are all the default settings. |
| 99 | 103 | $config_vars = array( |
@@ -156,8 +160,7 @@ discard block |
||
| 156 | 160 | } |
| 157 | 161 | } |
| 158 | 162 | toggleOther();', true); |
| 159 | - } |
|
| 160 | - else |
|
| 163 | + } else |
|
| 161 | 164 | { |
| 162 | 165 | $config_vars = array( |
| 163 | 166 | array('check', 'paid_enabled'), |
@@ -166,8 +169,9 @@ discard block |
||
| 166 | 169 | } |
| 167 | 170 | |
| 168 | 171 | // Just searching? |
| 169 | - if ($return_config) |
|
| 170 | - return $config_vars; |
|
| 172 | + if ($return_config) { |
|
| 173 | + return $config_vars; |
|
| 174 | + } |
|
| 171 | 175 | |
| 172 | 176 | // Get the settings template fired up. |
| 173 | 177 | require_once($sourcedir . '/ManageServer.php'); |
@@ -211,8 +215,9 @@ discard block |
||
| 211 | 215 | foreach (explode(',', $_POST['paid_email_to']) as $email) |
| 212 | 216 | { |
| 213 | 217 | $email = trim($email); |
| 214 | - if (!empty($email) && filter_var($email, FILTER_VALIDATE_EMAIL)) |
|
| 215 | - $email_addresses[] = $email; |
|
| 218 | + if (!empty($email) && filter_var($email, FILTER_VALIDATE_EMAIL)) { |
|
| 219 | + $email_addresses[] = $email; |
|
| 220 | + } |
|
| 216 | 221 | $_POST['paid_email_to'] = implode(',', $email_addresses); |
| 217 | 222 | } |
| 218 | 223 | } |
@@ -249,8 +254,9 @@ discard block |
||
| 249 | 254 | global $context, $txt, $modSettings, $sourcedir, $scripturl; |
| 250 | 255 | |
| 251 | 256 | // Not made the settings yet? |
| 252 | - if (empty($modSettings['paid_currency_symbol'])) |
|
| 253 | - fatal_lang_error('paid_not_set_currency', false, $scripturl . '?action=admin;area=paidsubscribe;sa=settings'); |
|
| 257 | + if (empty($modSettings['paid_currency_symbol'])) { |
|
| 258 | + fatal_lang_error('paid_not_set_currency', false, $scripturl . '?action=admin;area=paidsubscribe;sa=settings'); |
|
| 259 | + } |
|
| 254 | 260 | |
| 255 | 261 | // Some basic stuff. |
| 256 | 262 | $context['page_title'] = $txt['paid_subs_view']; |
@@ -270,10 +276,11 @@ discard block |
||
| 270 | 276 | |
| 271 | 277 | foreach ($context['subscriptions'] as $data) |
| 272 | 278 | { |
| 273 | - if (++$counter < $start) |
|
| 274 | - continue; |
|
| 275 | - elseif ($counter == $start + $items_per_page) |
|
| 276 | - break; |
|
| 279 | + if (++$counter < $start) { |
|
| 280 | + continue; |
|
| 281 | + } elseif ($counter == $start + $items_per_page) { |
|
| 282 | + break; |
|
| 283 | + } |
|
| 277 | 284 | |
| 278 | 285 | $subscriptions[] = $data; |
| 279 | 286 | } |
@@ -450,8 +457,9 @@ discard block |
||
| 450 | 457 | ); |
| 451 | 458 | $id_group = 0; |
| 452 | 459 | $add_groups = ''; |
| 453 | - if ($smcFunc['db_num_rows']($request)) |
|
| 454 | - list ($id_group, $add_groups) = $smcFunc['db_fetch_row']($request); |
|
| 460 | + if ($smcFunc['db_num_rows']($request)) { |
|
| 461 | + list ($id_group, $add_groups) = $smcFunc['db_fetch_row']($request); |
|
| 462 | + } |
|
| 455 | 463 | $smcFunc['db_free_result']($request); |
| 456 | 464 | |
| 457 | 465 | $changes = array(); |
@@ -463,8 +471,9 @@ discard block |
||
| 463 | 471 | { |
| 464 | 472 | // If their current primary group isn't what they had before the subscription, and their current group was |
| 465 | 473 | // granted by the sub, remove it. |
| 466 | - if ($member_data['old_id_group'] != $member_data['id_group'] && $member_data['id_group'] == $id_group) |
|
| 467 | - $changes[$id_member]['id_group'] = $member_data['old_id_group']; |
|
| 474 | + if ($member_data['old_id_group'] != $member_data['id_group'] && $member_data['id_group'] == $id_group) { |
|
| 475 | + $changes[$id_member]['id_group'] = $member_data['old_id_group']; |
|
| 476 | + } |
|
| 468 | 477 | } |
| 469 | 478 | } |
| 470 | 479 | |
@@ -477,15 +486,17 @@ discard block |
||
| 477 | 486 | // First let's get their groups sorted. |
| 478 | 487 | $current_groups = explode(',', $member_data['additional_groups']); |
| 479 | 488 | $new_groups = implode(',', array_diff($current_groups, $add_groups)); |
| 480 | - if ($new_groups != $member_data['additional_groups']) |
|
| 481 | - $changes[$id_member]['additional_groups'] = $new_groups; |
|
| 489 | + if ($new_groups != $member_data['additional_groups']) { |
|
| 490 | + $changes[$id_member]['additional_groups'] = $new_groups; |
|
| 491 | + } |
|
| 482 | 492 | } |
| 483 | 493 | } |
| 484 | 494 | |
| 485 | 495 | // We're going through changes... |
| 486 | - if (!empty($changes)) |
|
| 487 | - foreach ($changes as $id_member => $new_values) |
|
| 496 | + if (!empty($changes)) { |
|
| 497 | + foreach ($changes as $id_member => $new_values) |
|
| 488 | 498 | updateMemberData($id_member, $new_values); |
| 499 | + } |
|
| 489 | 500 | } |
| 490 | 501 | |
| 491 | 502 | // Delete the subscription |
@@ -533,11 +544,13 @@ discard block |
||
| 533 | 544 | 'M' => 24, |
| 534 | 545 | 'Y' => 5, |
| 535 | 546 | ); |
| 536 | - if (empty($_POST['span_unit']) || empty($limits[$_POST['span_unit']]) || empty($_POST['span_value']) || $_POST['span_value'] < 1) |
|
| 537 | - fatal_lang_error('paid_invalid_duration', false); |
|
| 547 | + if (empty($_POST['span_unit']) || empty($limits[$_POST['span_unit']]) || empty($_POST['span_value']) || $_POST['span_value'] < 1) { |
|
| 548 | + fatal_lang_error('paid_invalid_duration', false); |
|
| 549 | + } |
|
| 538 | 550 | |
| 539 | - if ($_POST['span_value'] > $limits[$_POST['span_unit']]) |
|
| 540 | - fatal_lang_error('paid_invalid_duration_' . $_POST['span_unit'], false); |
|
| 551 | + if ($_POST['span_value'] > $limits[$_POST['span_unit']]) { |
|
| 552 | + fatal_lang_error('paid_invalid_duration_' . $_POST['span_unit'], false); |
|
| 553 | + } |
|
| 541 | 554 | |
| 542 | 555 | // Clean the span. |
| 543 | 556 | $span = $_POST['span_value'] . $_POST['span_unit']; |
@@ -546,8 +559,9 @@ discard block |
||
| 546 | 559 | $cost = array('fixed' => sprintf('%01.2f', strtr($_POST['cost'], ',', '.'))); |
| 547 | 560 | |
| 548 | 561 | // There needs to be something. |
| 549 | - if (empty($_POST['span_value']) || empty($_POST['cost'])) |
|
| 550 | - fatal_lang_error('paid_no_cost_value'); |
|
| 562 | + if (empty($_POST['span_value']) || empty($_POST['cost'])) { |
|
| 563 | + fatal_lang_error('paid_no_cost_value'); |
|
| 564 | + } |
|
| 551 | 565 | } |
| 552 | 566 | // Flexible is harder but more fun ;) |
| 553 | 567 | else |
@@ -561,8 +575,9 @@ discard block |
||
| 561 | 575 | 'year' => sprintf('%01.2f', strtr($_POST['cost_year'], ',', '.')), |
| 562 | 576 | ); |
| 563 | 577 | |
| 564 | - if (empty($_POST['cost_day']) && empty($_POST['cost_week']) && empty($_POST['cost_month']) && empty($_POST['cost_year'])) |
|
| 565 | - fatal_lang_error('paid_all_freq_blank'); |
|
| 578 | + if (empty($_POST['cost_day']) && empty($_POST['cost_week']) && empty($_POST['cost_month']) && empty($_POST['cost_year'])) { |
|
| 579 | + fatal_lang_error('paid_all_freq_blank'); |
|
| 580 | + } |
|
| 566 | 581 | } |
| 567 | 582 | $cost = json_encode($cost); |
| 568 | 583 | |
@@ -571,9 +586,10 @@ discard block |
||
| 571 | 586 | |
| 572 | 587 | // Yep, time to do additional groups. |
| 573 | 588 | $addgroups = array(); |
| 574 | - if (!empty($_POST['addgroup'])) |
|
| 575 | - foreach ($_POST['addgroup'] as $id => $dummy) |
|
| 589 | + if (!empty($_POST['addgroup'])) { |
|
| 590 | + foreach ($_POST['addgroup'] as $id => $dummy) |
|
| 576 | 591 | $addgroups[] = (int) $id; |
| 592 | + } |
|
| 577 | 593 | $addgroups = implode(',', $addgroups); |
| 578 | 594 | |
| 579 | 595 | // Is it new?! |
@@ -682,18 +698,18 @@ discard block |
||
| 682 | 698 | { |
| 683 | 699 | $span_value = $match[1]; |
| 684 | 700 | $span_unit = $match[2]; |
| 685 | - } |
|
| 686 | - else |
|
| 701 | + } else |
|
| 687 | 702 | { |
| 688 | 703 | $span_value = 0; |
| 689 | 704 | $span_unit = 'D'; |
| 690 | 705 | } |
| 691 | 706 | |
| 692 | 707 | // Is this a flexible one? |
| 693 | - if ($row['length'] == 'F') |
|
| 694 | - $isFlexible = true; |
|
| 695 | - else |
|
| 696 | - $isFlexible = false; |
|
| 708 | + if ($row['length'] == 'F') { |
|
| 709 | + $isFlexible = true; |
|
| 710 | + } else { |
|
| 711 | + $isFlexible = false; |
|
| 712 | + } |
|
| 697 | 713 | |
| 698 | 714 | $context['sub'] = array( |
| 699 | 715 | 'name' => $row['name'], |
@@ -742,8 +758,9 @@ discard block |
||
| 742 | 758 | ) |
| 743 | 759 | ); |
| 744 | 760 | $context['groups'] = array(); |
| 745 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 746 | - $context['groups'][$row['id_group']] = $row['group_name']; |
|
| 761 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 762 | + $context['groups'][$row['id_group']] = $row['group_name']; |
|
| 763 | + } |
|
| 747 | 764 | $smcFunc['db_free_result']($request); |
| 748 | 765 | |
| 749 | 766 | // This always happens. |
@@ -777,8 +794,9 @@ discard block |
||
| 777 | 794 | ) |
| 778 | 795 | ); |
| 779 | 796 | // Something wrong? |
| 780 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 781 | - fatal_lang_error('no_access', false); |
|
| 797 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 798 | + fatal_lang_error('no_access', false); |
|
| 799 | + } |
|
| 782 | 800 | // Do the subscription context. |
| 783 | 801 | $row = $smcFunc['db_fetch_assoc']($request); |
| 784 | 802 | $context['subscription'] = array( |
@@ -1013,8 +1031,8 @@ discard block |
||
| 1013 | 1031 | )) |
| 1014 | 1032 | ); |
| 1015 | 1033 | $subscribers = array(); |
| 1016 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1017 | - $subscribers[] = array( |
|
| 1034 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1035 | + $subscribers[] = array( |
|
| 1018 | 1036 | 'id' => $row['id_sublog'], |
| 1019 | 1037 | 'id_member' => $row['id_member'], |
| 1020 | 1038 | 'name' => $row['name'], |
@@ -1024,6 +1042,7 @@ discard block |
||
| 1024 | 1042 | 'status' => $row['status'], |
| 1025 | 1043 | 'status_text' => $row['status'] == 0 ? ($row['payments_pending'] == 0 ? $txt['paid_finished'] : $txt['paid_pending']) : $txt['paid_active'], |
| 1026 | 1044 | ); |
| 1045 | + } |
|
| 1027 | 1046 | $smcFunc['db_free_result']($request); |
| 1028 | 1047 | |
| 1029 | 1048 | return $subscribers; |
@@ -1058,14 +1077,16 @@ discard block |
||
| 1058 | 1077 | 'current_log_item' => $context['log_id'], |
| 1059 | 1078 | ) |
| 1060 | 1079 | ); |
| 1061 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1062 | - fatal_lang_error('no_access', false); |
|
| 1080 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1081 | + fatal_lang_error('no_access', false); |
|
| 1082 | + } |
|
| 1063 | 1083 | list ($context['sub_id']) = $smcFunc['db_fetch_row']($request); |
| 1064 | 1084 | $smcFunc['db_free_result']($request); |
| 1065 | 1085 | } |
| 1066 | 1086 | |
| 1067 | - if (!isset($context['subscriptions'][$context['sub_id']])) |
|
| 1068 | - fatal_lang_error('no_access', false); |
|
| 1087 | + if (!isset($context['subscriptions'][$context['sub_id']])) { |
|
| 1088 | + fatal_lang_error('no_access', false); |
|
| 1089 | + } |
|
| 1069 | 1090 | $context['current_subscription'] = $context['subscriptions'][$context['sub_id']]; |
| 1070 | 1091 | |
| 1071 | 1092 | // Searching? |
@@ -1098,8 +1119,9 @@ discard block |
||
| 1098 | 1119 | 'name' => $_POST['name'], |
| 1099 | 1120 | ) |
| 1100 | 1121 | ); |
| 1101 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1102 | - fatal_lang_error('error_member_not_found'); |
|
| 1122 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1123 | + fatal_lang_error('error_member_not_found'); |
|
| 1124 | + } |
|
| 1103 | 1125 | |
| 1104 | 1126 | list ($id_member, $id_group) = $smcFunc['db_fetch_row']($request); |
| 1105 | 1127 | $smcFunc['db_free_result']($request); |
@@ -1115,14 +1137,15 @@ discard block |
||
| 1115 | 1137 | 'current_member' => $id_member, |
| 1116 | 1138 | ) |
| 1117 | 1139 | ); |
| 1118 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 1119 | - fatal_lang_error('member_already_subscribed'); |
|
| 1140 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 1141 | + fatal_lang_error('member_already_subscribed'); |
|
| 1142 | + } |
|
| 1120 | 1143 | $smcFunc['db_free_result']($request); |
| 1121 | 1144 | |
| 1122 | 1145 | // Actually put the subscription in place. |
| 1123 | - if ($status == 1) |
|
| 1124 | - addSubscription($context['sub_id'], $id_member, 0, $starttime, $endtime); |
|
| 1125 | - else |
|
| 1146 | + if ($status == 1) { |
|
| 1147 | + addSubscription($context['sub_id'], $id_member, 0, $starttime, $endtime); |
|
| 1148 | + } else |
|
| 1126 | 1149 | { |
| 1127 | 1150 | $smcFunc['db_insert']('', |
| 1128 | 1151 | '{db_prefix}log_subscribed', |
@@ -1149,20 +1172,20 @@ discard block |
||
| 1149 | 1172 | 'current_log_item' => $context['log_id'], |
| 1150 | 1173 | ) |
| 1151 | 1174 | ); |
| 1152 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1153 | - fatal_lang_error('no_access', false); |
|
| 1175 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1176 | + fatal_lang_error('no_access', false); |
|
| 1177 | + } |
|
| 1154 | 1178 | |
| 1155 | 1179 | list ($id_member, $old_status) = $smcFunc['db_fetch_row']($request); |
| 1156 | 1180 | $smcFunc['db_free_result']($request); |
| 1157 | 1181 | |
| 1158 | 1182 | // Pick the right permission stuff depending on what the status is changing from/to. |
| 1159 | - if ($old_status == 1 && $status != 1) |
|
| 1160 | - removeSubscription($context['sub_id'], $id_member); |
|
| 1161 | - elseif ($status == 1 && $old_status != 1) |
|
| 1183 | + if ($old_status == 1 && $status != 1) { |
|
| 1184 | + removeSubscription($context['sub_id'], $id_member); |
|
| 1185 | + } elseif ($status == 1 && $old_status != 1) |
|
| 1162 | 1186 | { |
| 1163 | 1187 | addSubscription($context['sub_id'], $id_member, 0, $starttime, $endtime); |
| 1164 | - } |
|
| 1165 | - else |
|
| 1188 | + } else |
|
| 1166 | 1189 | { |
| 1167 | 1190 | $smcFunc['db_query']('', ' |
| 1168 | 1191 | UPDATE {db_prefix}log_subscribed |
@@ -1190,8 +1213,9 @@ discard block |
||
| 1190 | 1213 | if (!empty($_REQUEST['delsub'])) |
| 1191 | 1214 | { |
| 1192 | 1215 | $toDelete = array(); |
| 1193 | - foreach ($_REQUEST['delsub'] as $id => $dummy) |
|
| 1194 | - $toDelete[] = (int) $id; |
|
| 1216 | + foreach ($_REQUEST['delsub'] as $id => $dummy) { |
|
| 1217 | + $toDelete[] = (int) $id; |
|
| 1218 | + } |
|
| 1195 | 1219 | |
| 1196 | 1220 | $request = $smcFunc['db_query']('', ' |
| 1197 | 1221 | SELECT id_subscribe, id_member |
@@ -1201,8 +1225,9 @@ discard block |
||
| 1201 | 1225 | 'subscription_list' => $toDelete, |
| 1202 | 1226 | ) |
| 1203 | 1227 | ); |
| 1204 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1205 | - removeSubscription($row['id_subscribe'], $row['id_member'], isset($_REQUEST['delete'])); |
|
| 1228 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1229 | + removeSubscription($row['id_subscribe'], $row['id_member'], isset($_REQUEST['delete'])); |
|
| 1230 | + } |
|
| 1206 | 1231 | $smcFunc['db_free_result']($request); |
| 1207 | 1232 | } |
| 1208 | 1233 | redirectexit('action=admin;area=paidsubscribe;sa=viewsub;sid=' . $context['sub_id']); |
@@ -1246,9 +1271,9 @@ discard block |
||
| 1246 | 1271 | ); |
| 1247 | 1272 | list ($context['sub']['username']) = $smcFunc['db_fetch_row']($request); |
| 1248 | 1273 | $smcFunc['db_free_result']($request); |
| 1274 | + } else { |
|
| 1275 | + $context['sub']['username'] = ''; |
|
| 1249 | 1276 | } |
| 1250 | - else |
|
| 1251 | - $context['sub']['username'] = ''; |
|
| 1252 | 1277 | } |
| 1253 | 1278 | // Otherwise load the existing info. |
| 1254 | 1279 | else |
@@ -1265,8 +1290,9 @@ discard block |
||
| 1265 | 1290 | 'blank_string' => '', |
| 1266 | 1291 | ) |
| 1267 | 1292 | ); |
| 1268 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1269 | - fatal_lang_error('no_access', false); |
|
| 1293 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1294 | + fatal_lang_error('no_access', false); |
|
| 1295 | + } |
|
| 1270 | 1296 | $row = $smcFunc['db_fetch_assoc']($request); |
| 1271 | 1297 | $smcFunc['db_free_result']($request); |
| 1272 | 1298 | |
@@ -1287,13 +1313,13 @@ discard block |
||
| 1287 | 1313 | { |
| 1288 | 1314 | foreach ($costs as $duration => $cost) |
| 1289 | 1315 | { |
| 1290 | - if ($cost != 0 && $cost == $pending[1] && $duration == $pending[2]) |
|
| 1291 | - $context['pending_payments'][$id] = array( |
|
| 1316 | + if ($cost != 0 && $cost == $pending[1] && $duration == $pending[2]) { |
|
| 1317 | + $context['pending_payments'][$id] = array( |
|
| 1292 | 1318 | 'desc' => sprintf($modSettings['paid_currency_symbol'], $cost . '/' . $txt[$duration]), |
| 1293 | 1319 | ); |
| 1320 | + } |
|
| 1294 | 1321 | } |
| 1295 | - } |
|
| 1296 | - elseif ($costs['fixed'] == $pending[1]) |
|
| 1322 | + } elseif ($costs['fixed'] == $pending[1]) |
|
| 1297 | 1323 | { |
| 1298 | 1324 | $context['pending_payments'][$id] = array( |
| 1299 | 1325 | 'desc' => sprintf($modSettings['paid_currency_symbol'], $costs['fixed']), |
@@ -1311,8 +1337,9 @@ discard block |
||
| 1311 | 1337 | if ($_GET['pending'] == $id && $pending[3] == 'payback' && isset($context['pending_payments'][$id])) |
| 1312 | 1338 | { |
| 1313 | 1339 | // Flexible? |
| 1314 | - if (isset($_GET['accept'])) |
|
| 1315 | - addSubscription($context['current_subscription']['id'], $row['id_member'], $context['current_subscription']['real_length'] == 'F' ? strtoupper(substr($pending[2], 0, 1)) : 0); |
|
| 1340 | + if (isset($_GET['accept'])) { |
|
| 1341 | + addSubscription($context['current_subscription']['id'], $row['id_member'], $context['current_subscription']['real_length'] == 'F' ? strtoupper(substr($pending[2], 0, 1)) : 0); |
|
| 1342 | + } |
|
| 1316 | 1343 | unset($pending_details[$id]); |
| 1317 | 1344 | |
| 1318 | 1345 | $new_details = json_encode($pending_details); |
@@ -1374,8 +1401,9 @@ discard block |
||
| 1374 | 1401 | global $smcFunc; |
| 1375 | 1402 | |
| 1376 | 1403 | // Make it an array. |
| 1377 | - if (!is_array($users)) |
|
| 1378 | - $users = array($users); |
|
| 1404 | + if (!is_array($users)) { |
|
| 1405 | + $users = array($users); |
|
| 1406 | + } |
|
| 1379 | 1407 | |
| 1380 | 1408 | // Get all the members current groups. |
| 1381 | 1409 | $groups = array(); |
@@ -1413,14 +1441,16 @@ discard block |
||
| 1413 | 1441 | if ($row['id_group'] != 0) |
| 1414 | 1442 | { |
| 1415 | 1443 | // If this is changing - add the old one to the additional groups so it's not lost. |
| 1416 | - if ($row['id_group'] != $groups[$row['id_member']]['primary']) |
|
| 1417 | - $groups[$row['id_member']]['additional'][] = $groups[$row['id_member']]['primary']; |
|
| 1444 | + if ($row['id_group'] != $groups[$row['id_member']]['primary']) { |
|
| 1445 | + $groups[$row['id_member']]['additional'][] = $groups[$row['id_member']]['primary']; |
|
| 1446 | + } |
|
| 1418 | 1447 | $groups[$row['id_member']]['primary'] = $row['id_group']; |
| 1419 | 1448 | } |
| 1420 | 1449 | |
| 1421 | 1450 | // Additional groups. |
| 1422 | - if (!empty($row['add_groups'])) |
|
| 1423 | - $groups[$row['id_member']]['additional'] = array_merge($groups[$row['id_member']]['additional'], explode(',', $row['add_groups'])); |
|
| 1451 | + if (!empty($row['add_groups'])) { |
|
| 1452 | + $groups[$row['id_member']]['additional'] = array_merge($groups[$row['id_member']]['additional'], explode(',', $row['add_groups'])); |
|
| 1453 | + } |
|
| 1424 | 1454 | } |
| 1425 | 1455 | $smcFunc['db_free_result']($request); |
| 1426 | 1456 | |
@@ -1428,9 +1458,10 @@ discard block |
||
| 1428 | 1458 | foreach ($groups as $id => $group) |
| 1429 | 1459 | { |
| 1430 | 1460 | $group['additional'] = array_unique($group['additional']); |
| 1431 | - foreach ($group['additional'] as $key => $value) |
|
| 1432 | - if (empty($value)) |
|
| 1461 | + foreach ($group['additional'] as $key => $value) { |
|
| 1462 | + if (empty($value)) |
|
| 1433 | 1463 | unset($group['additional'][$key]); |
| 1464 | + } |
|
| 1434 | 1465 | $addgroups = implode(',', $group['additional']); |
| 1435 | 1466 | |
| 1436 | 1467 | $smcFunc['db_query']('', ' |
@@ -1464,8 +1495,9 @@ discard block |
||
| 1464 | 1495 | loadSubscriptions(); |
| 1465 | 1496 | |
| 1466 | 1497 | // Exists, yes? |
| 1467 | - if (!isset($context['subscriptions'][$id_subscribe])) |
|
| 1468 | - return; |
|
| 1498 | + if (!isset($context['subscriptions'][$id_subscribe])) { |
|
| 1499 | + return; |
|
| 1500 | + } |
|
| 1469 | 1501 | |
| 1470 | 1502 | $curSub = $context['subscriptions'][$id_subscribe]; |
| 1471 | 1503 | |
@@ -1513,16 +1545,19 @@ discard block |
||
| 1513 | 1545 | list ($id_sublog, $endtime, $starttime) = $smcFunc['db_fetch_row']($request); |
| 1514 | 1546 | |
| 1515 | 1547 | // If this has already expired but is active, extension means the period from now. |
| 1516 | - if ($endtime < time()) |
|
| 1517 | - $endtime = time(); |
|
| 1518 | - if ($starttime == 0) |
|
| 1519 | - $starttime = time(); |
|
| 1548 | + if ($endtime < time()) { |
|
| 1549 | + $endtime = time(); |
|
| 1550 | + } |
|
| 1551 | + if ($starttime == 0) { |
|
| 1552 | + $starttime = time(); |
|
| 1553 | + } |
|
| 1520 | 1554 | |
| 1521 | 1555 | // Work out the new expiry date. |
| 1522 | 1556 | $endtime += $duration; |
| 1523 | 1557 | |
| 1524 | - if ($forceEndTime != 0) |
|
| 1525 | - $endtime = $forceEndTime; |
|
| 1558 | + if ($forceEndTime != 0) { |
|
| 1559 | + $endtime = $forceEndTime; |
|
| 1560 | + } |
|
| 1526 | 1561 | |
| 1527 | 1562 | // As everything else should be good, just update! |
| 1528 | 1563 | $smcFunc['db_query']('', ' |
@@ -1552,8 +1587,9 @@ discard block |
||
| 1552 | 1587 | ); |
| 1553 | 1588 | |
| 1554 | 1589 | // Just in case the member doesn't exist. |
| 1555 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1556 | - return; |
|
| 1590 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1591 | + return; |
|
| 1592 | + } |
|
| 1557 | 1593 | |
| 1558 | 1594 | list ($old_id_group, $additional_groups) = $smcFunc['db_fetch_row']($request); |
| 1559 | 1595 | $smcFunc['db_free_result']($request); |
@@ -1570,16 +1606,18 @@ discard block |
||
| 1570 | 1606 | $id_group = $curSub['prim_group']; |
| 1571 | 1607 | |
| 1572 | 1608 | // Ensure their old privileges are maintained. |
| 1573 | - if ($old_id_group != 0) |
|
| 1574 | - $newAddGroups[] = $old_id_group; |
|
| 1609 | + if ($old_id_group != 0) { |
|
| 1610 | + $newAddGroups[] = $old_id_group; |
|
| 1611 | + } |
|
| 1612 | + } else { |
|
| 1613 | + $id_group = $old_id_group; |
|
| 1575 | 1614 | } |
| 1576 | - else |
|
| 1577 | - $id_group = $old_id_group; |
|
| 1578 | 1615 | |
| 1579 | 1616 | // Yep, make sure it's unique, and no empties. |
| 1580 | - foreach ($newAddGroups as $k => $v) |
|
| 1581 | - if (empty($v)) |
|
| 1617 | + foreach ($newAddGroups as $k => $v) { |
|
| 1618 | + if (empty($v)) |
|
| 1582 | 1619 | unset($newAddGroups[$k]); |
| 1620 | + } |
|
| 1583 | 1621 | $newAddGroups = array_unique($newAddGroups); |
| 1584 | 1622 | $newAddGroups = implode(',', $newAddGroups); |
| 1585 | 1623 | |
@@ -1615,16 +1653,19 @@ discard block |
||
| 1615 | 1653 | list ($id_sublog, $endtime, $starttime) = $smcFunc['db_fetch_row']($request); |
| 1616 | 1654 | |
| 1617 | 1655 | // If this has already expired but is active, extension means the period from now. |
| 1618 | - if ($endtime < time()) |
|
| 1619 | - $endtime = time(); |
|
| 1620 | - if ($starttime == 0) |
|
| 1621 | - $starttime = time(); |
|
| 1656 | + if ($endtime < time()) { |
|
| 1657 | + $endtime = time(); |
|
| 1658 | + } |
|
| 1659 | + if ($starttime == 0) { |
|
| 1660 | + $starttime = time(); |
|
| 1661 | + } |
|
| 1622 | 1662 | |
| 1623 | 1663 | // Work out the new expiry date. |
| 1624 | 1664 | $endtime += $duration; |
| 1625 | 1665 | |
| 1626 | - if ($forceEndTime != 0) |
|
| 1627 | - $endtime = $forceEndTime; |
|
| 1666 | + if ($forceEndTime != 0) { |
|
| 1667 | + $endtime = $forceEndTime; |
|
| 1668 | + } |
|
| 1628 | 1669 | |
| 1629 | 1670 | // As everything else should be good, just update! |
| 1630 | 1671 | $smcFunc['db_query']('', ' |
@@ -1647,13 +1688,15 @@ discard block |
||
| 1647 | 1688 | |
| 1648 | 1689 | // Otherwise a very simple insert. |
| 1649 | 1690 | $endtime = time() + $duration; |
| 1650 | - if ($forceEndTime != 0) |
|
| 1651 | - $endtime = $forceEndTime; |
|
| 1691 | + if ($forceEndTime != 0) { |
|
| 1692 | + $endtime = $forceEndTime; |
|
| 1693 | + } |
|
| 1652 | 1694 | |
| 1653 | - if ($forceStartTime == 0) |
|
| 1654 | - $starttime = time(); |
|
| 1655 | - else |
|
| 1656 | - $starttime = $forceStartTime; |
|
| 1695 | + if ($forceStartTime == 0) { |
|
| 1696 | + $starttime = time(); |
|
| 1697 | + } else { |
|
| 1698 | + $starttime = $forceStartTime; |
|
| 1699 | + } |
|
| 1657 | 1700 | |
| 1658 | 1701 | $smcFunc['db_insert']('', |
| 1659 | 1702 | '{db_prefix}log_subscribed', |
@@ -1726,15 +1769,17 @@ discard block |
||
| 1726 | 1769 | $new_id_group = -1; |
| 1727 | 1770 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1728 | 1771 | { |
| 1729 | - if (!isset($context['subscriptions'][$row['id_subscribe']])) |
|
| 1730 | - continue; |
|
| 1772 | + if (!isset($context['subscriptions'][$row['id_subscribe']])) { |
|
| 1773 | + continue; |
|
| 1774 | + } |
|
| 1731 | 1775 | |
| 1732 | 1776 | // The one we're removing? |
| 1733 | 1777 | if ($row['id_subscribe'] == $id_subscribe) |
| 1734 | 1778 | { |
| 1735 | 1779 | $removals = explode(',', $context['subscriptions'][$row['id_subscribe']]['add_groups']); |
| 1736 | - if ($context['subscriptions'][$row['id_subscribe']]['prim_group'] != 0) |
|
| 1737 | - $removals[] = $context['subscriptions'][$row['id_subscribe']]['prim_group']; |
|
| 1780 | + if ($context['subscriptions'][$row['id_subscribe']]['prim_group'] != 0) { |
|
| 1781 | + $removals[] = $context['subscriptions'][$row['id_subscribe']]['prim_group']; |
|
| 1782 | + } |
|
| 1738 | 1783 | $old_id_group = $row['old_id_group']; |
| 1739 | 1784 | } |
| 1740 | 1785 | // Otherwise things we allow. |
@@ -1752,30 +1797,33 @@ discard block |
||
| 1752 | 1797 | |
| 1753 | 1798 | // Now, for everything we are removing check they definitely are not allowed it. |
| 1754 | 1799 | $existingGroups = explode(',', $additional_groups); |
| 1755 | - foreach ($existingGroups as $key => $group) |
|
| 1756 | - if (empty($group) || (in_array($group, $removals) && !in_array($group, $allowed))) |
|
| 1800 | + foreach ($existingGroups as $key => $group) { |
|
| 1801 | + if (empty($group) || (in_array($group, $removals) && !in_array($group, $allowed))) |
|
| 1757 | 1802 | unset($existingGroups[$key]); |
| 1803 | + } |
|
| 1758 | 1804 | |
| 1759 | 1805 | // Finally, do something with the current primary group. |
| 1760 | 1806 | if (in_array($id_group, $removals)) |
| 1761 | 1807 | { |
| 1762 | 1808 | // If this primary group is actually allowed keep it. |
| 1763 | - if (in_array($id_group, $allowed)) |
|
| 1764 | - $existingGroups[] = $id_group; |
|
| 1809 | + if (in_array($id_group, $allowed)) { |
|
| 1810 | + $existingGroups[] = $id_group; |
|
| 1811 | + } |
|
| 1765 | 1812 | |
| 1766 | 1813 | // Either way, change the id_group back. |
| 1767 | 1814 | if ($new_id_group < 1) |
| 1768 | 1815 | { |
| 1769 | 1816 | // If we revert to the old id-group we need to ensure it wasn't from a subscription. |
| 1770 | - foreach ($context['subscriptions'] as $id => $group) |
|
| 1771 | - // It was? Make them a regular member then! |
|
| 1817 | + foreach ($context['subscriptions'] as $id => $group) { |
|
| 1818 | + // It was? Make them a regular member then! |
|
| 1772 | 1819 | if ($group['prim_group'] == $old_id_group) |
| 1773 | 1820 | $old_id_group = 0; |
| 1821 | + } |
|
| 1774 | 1822 | |
| 1775 | 1823 | $id_group = $old_id_group; |
| 1824 | + } else { |
|
| 1825 | + $id_group = $new_id_group; |
|
| 1776 | 1826 | } |
| 1777 | - else |
|
| 1778 | - $id_group = $new_id_group; |
|
| 1779 | 1827 | } |
| 1780 | 1828 | |
| 1781 | 1829 | // Crazy stuff, we seem to have our groups fixed, just make them unique |
@@ -1795,8 +1843,8 @@ discard block |
||
| 1795 | 1843 | ); |
| 1796 | 1844 | |
| 1797 | 1845 | // Disable the subscription. |
| 1798 | - if (!$delete) |
|
| 1799 | - $smcFunc['db_query']('', ' |
|
| 1846 | + if (!$delete) { |
|
| 1847 | + $smcFunc['db_query']('', ' |
|
| 1800 | 1848 | UPDATE {db_prefix}log_subscribed |
| 1801 | 1849 | SET status = {int:not_active} |
| 1802 | 1850 | WHERE id_member = {int:current_member} |
@@ -1807,9 +1855,10 @@ discard block |
||
| 1807 | 1855 | 'current_subscription' => $id_subscribe, |
| 1808 | 1856 | ) |
| 1809 | 1857 | ); |
| 1858 | + } |
|
| 1810 | 1859 | // Otherwise delete it! |
| 1811 | - else |
|
| 1812 | - $smcFunc['db_query']('', ' |
|
| 1860 | + else { |
|
| 1861 | + $smcFunc['db_query']('', ' |
|
| 1813 | 1862 | DELETE FROM {db_prefix}log_subscribed |
| 1814 | 1863 | WHERE id_member = {int:current_member} |
| 1815 | 1864 | AND id_subscribe = {int:current_subscription}', |
@@ -1818,7 +1867,8 @@ discard block |
||
| 1818 | 1867 | 'current_subscription' => $id_subscribe, |
| 1819 | 1868 | ) |
| 1820 | 1869 | ); |
| 1821 | -} |
|
| 1870 | + } |
|
| 1871 | + } |
|
| 1822 | 1872 | |
| 1823 | 1873 | /** |
| 1824 | 1874 | * This just kind of caches all the subscription data. |
@@ -1827,8 +1877,9 @@ discard block |
||
| 1827 | 1877 | { |
| 1828 | 1878 | global $context, $txt, $modSettings, $smcFunc; |
| 1829 | 1879 | |
| 1830 | - if (!empty($context['subscriptions'])) |
|
| 1831 | - return; |
|
| 1880 | + if (!empty($context['subscriptions'])) { |
|
| 1881 | + return; |
|
| 1882 | + } |
|
| 1832 | 1883 | |
| 1833 | 1884 | // Make sure this is loaded, just in case. |
| 1834 | 1885 | loadLanguage('ManagePaid'); |
@@ -1845,10 +1896,11 @@ discard block |
||
| 1845 | 1896 | // Pick a cost. |
| 1846 | 1897 | $costs = smf_json_decode($row['cost'], true); |
| 1847 | 1898 | |
| 1848 | - if ($row['length'] != 'F' && !empty($modSettings['paid_currency_symbol']) && !empty($costs['fixed'])) |
|
| 1849 | - $cost = sprintf($modSettings['paid_currency_symbol'], $costs['fixed']); |
|
| 1850 | - else |
|
| 1851 | - $cost = '???'; |
|
| 1899 | + if ($row['length'] != 'F' && !empty($modSettings['paid_currency_symbol']) && !empty($costs['fixed'])) { |
|
| 1900 | + $cost = sprintf($modSettings['paid_currency_symbol'], $costs['fixed']); |
|
| 1901 | + } else { |
|
| 1902 | + $cost = '???'; |
|
| 1903 | + } |
|
| 1852 | 1904 | |
| 1853 | 1905 | // Do the span. |
| 1854 | 1906 | preg_match('~(\d*)(\w)~', $row['length'], $match); |
@@ -1875,9 +1927,9 @@ discard block |
||
| 1875 | 1927 | $num_length *= 31556926; |
| 1876 | 1928 | break; |
| 1877 | 1929 | } |
| 1930 | + } else { |
|
| 1931 | + $length = '??'; |
|
| 1878 | 1932 | } |
| 1879 | - else |
|
| 1880 | - $length = '??'; |
|
| 1881 | 1933 | |
| 1882 | 1934 | $context['subscriptions'][$row['id_subscribe']] = array( |
| 1883 | 1935 | 'id' => $row['id_subscribe'], |
@@ -1912,8 +1964,9 @@ discard block |
||
| 1912 | 1964 | { |
| 1913 | 1965 | $ind = $row['status'] == 0 ? 'finished' : 'total'; |
| 1914 | 1966 | |
| 1915 | - if (isset($context['subscriptions'][$row['id_subscribe']])) |
|
| 1916 | - $context['subscriptions'][$row['id_subscribe']][$ind] = $row['member_count']; |
|
| 1967 | + if (isset($context['subscriptions'][$row['id_subscribe']])) { |
|
| 1968 | + $context['subscriptions'][$row['id_subscribe']][$ind] = $row['member_count']; |
|
| 1969 | + } |
|
| 1917 | 1970 | } |
| 1918 | 1971 | $smcFunc['db_free_result']($request); |
| 1919 | 1972 | |
@@ -1927,8 +1980,9 @@ discard block |
||
| 1927 | 1980 | ); |
| 1928 | 1981 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1929 | 1982 | { |
| 1930 | - if (isset($context['subscriptions'][$row['id_subscribe']])) |
|
| 1931 | - $context['subscriptions'][$row['id_subscribe']]['pending'] = $row['total_pending']; |
|
| 1983 | + if (isset($context['subscriptions'][$row['id_subscribe']])) { |
|
| 1984 | + $context['subscriptions'][$row['id_subscribe']]['pending'] = $row['total_pending']; |
|
| 1985 | + } |
|
| 1932 | 1986 | } |
| 1933 | 1987 | $smcFunc['db_free_result']($request); |
| 1934 | 1988 | } |
@@ -4070,7 +4070,7 @@ |
||
| 4070 | 4070 | * |
| 4071 | 4071 | * @param int $pmID The ID of the PM |
| 4072 | 4072 | * @param string $validFor Which folders this is valud for - can be 'inbox', 'outbox' or 'in_or_outbox' |
| 4073 | - * @return boolean Whether the PM is accessible in that folder for the current user |
|
| 4073 | + * @return boolean|null Whether the PM is accessible in that folder for the current user |
|
| 4074 | 4074 | */ |
| 4075 | 4075 | function isAccessiblePM($pmID, $validFor = 'in_or_outbox') |
| 4076 | 4076 | { |
@@ -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 | * This helps organize things... |
@@ -37,13 +38,14 @@ discard block |
||
| 37 | 38 | |
| 38 | 39 | loadLanguage('PersonalMessage+Drafts'); |
| 39 | 40 | |
| 40 | - if (!isset($_REQUEST['xml'])) |
|
| 41 | - loadTemplate('PersonalMessage'); |
|
| 41 | + if (!isset($_REQUEST['xml'])) { |
|
| 42 | + loadTemplate('PersonalMessage'); |
|
| 43 | + } |
|
| 42 | 44 | |
| 43 | 45 | // Load up the members maximum message capacity. |
| 44 | - if ($user_info['is_admin']) |
|
| 45 | - $context['message_limit'] = 0; |
|
| 46 | - elseif (($context['message_limit'] = cache_get_data('msgLimit:' . $user_info['id'], 360)) === null) |
|
| 46 | + if ($user_info['is_admin']) { |
|
| 47 | + $context['message_limit'] = 0; |
|
| 48 | + } elseif (($context['message_limit'] = cache_get_data('msgLimit:' . $user_info['id'], 360)) === null) |
|
| 47 | 49 | { |
| 48 | 50 | // @todo Why do we do this? It seems like if they have any limit we should use it. |
| 49 | 51 | $request = $smcFunc['db_query']('', ' |
@@ -78,8 +80,9 @@ discard block |
||
| 78 | 80 | } |
| 79 | 81 | |
| 80 | 82 | // a previous message was sent successfully? show a small indication. |
| 81 | - if (isset($_GET['done']) && ($_GET['done'] == 'sent')) |
|
| 82 | - $context['pm_sent'] = true; |
|
| 83 | + if (isset($_GET['done']) && ($_GET['done'] == 'sent')) { |
|
| 84 | + $context['pm_sent'] = true; |
|
| 85 | + } |
|
| 83 | 86 | |
| 84 | 87 | $context['labels'] = array(); |
| 85 | 88 | |
@@ -210,11 +213,11 @@ discard block |
||
| 210 | 213 | { |
| 211 | 214 | $_REQUEST['sa'] = ''; |
| 212 | 215 | MessageFolder(); |
| 213 | - } |
|
| 214 | - else |
|
| 216 | + } else |
|
| 215 | 217 | { |
| 216 | - if (!isset($_REQUEST['xml']) && $_REQUEST['sa'] != 'popup') |
|
| 217 | - messageIndexBar($_REQUEST['sa']); |
|
| 218 | + if (!isset($_REQUEST['xml']) && $_REQUEST['sa'] != 'popup') { |
|
| 219 | + messageIndexBar($_REQUEST['sa']); |
|
| 220 | + } |
|
| 218 | 221 | |
| 219 | 222 | call_helper($subActions[$_REQUEST['sa']]); |
| 220 | 223 | } |
@@ -291,16 +294,17 @@ discard block |
||
| 291 | 294 | ); |
| 292 | 295 | |
| 293 | 296 | // Handle labels. |
| 294 | - if (empty($context['currently_using_labels'])) |
|
| 295 | - unset($pm_areas['labels']); |
|
| 296 | - else |
|
| 297 | + if (empty($context['currently_using_labels'])) { |
|
| 298 | + unset($pm_areas['labels']); |
|
| 299 | + } else |
|
| 297 | 300 | { |
| 298 | 301 | // Note we send labels by id as it will have less problems in the querystring. |
| 299 | 302 | $unread_in_labels = 0; |
| 300 | 303 | foreach ($context['labels'] as $label) |
| 301 | 304 | { |
| 302 | - if ($label['id'] == -1) |
|
| 303 | - continue; |
|
| 305 | + if ($label['id'] == -1) { |
|
| 306 | + continue; |
|
| 307 | + } |
|
| 304 | 308 | |
| 305 | 309 | // Count the amount of unread items in labels. |
| 306 | 310 | $unread_in_labels += $label['unread_messages']; |
@@ -314,8 +318,9 @@ discard block |
||
| 314 | 318 | ); |
| 315 | 319 | } |
| 316 | 320 | |
| 317 | - if (!empty($unread_in_labels)) |
|
| 318 | - $pm_areas['labels']['title'] .= ' <span class="amt">' . $unread_in_labels . '</span>'; |
|
| 321 | + if (!empty($unread_in_labels)) { |
|
| 322 | + $pm_areas['labels']['title'] .= ' <span class="amt">' . $unread_in_labels . '</span>'; |
|
| 323 | + } |
|
| 319 | 324 | } |
| 320 | 325 | |
| 321 | 326 | $pm_areas['folders']['areas']['inbox']['unread_messages'] = &$context['labels'][-1]['unread_messages']; |
@@ -356,8 +361,9 @@ discard block |
||
| 356 | 361 | unset($pm_areas); |
| 357 | 362 | |
| 358 | 363 | // No menu means no access. |
| 359 | - if (!$pm_include_data && (!$user_info['is_guest'] || validateSession())) |
|
| 360 | - fatal_lang_error('no_access', false); |
|
| 364 | + if (!$pm_include_data && (!$user_info['is_guest'] || validateSession())) { |
|
| 365 | + fatal_lang_error('no_access', false); |
|
| 366 | + } |
|
| 361 | 367 | |
| 362 | 368 | // Make a note of the Unique ID for this menu. |
| 363 | 369 | $context['pm_menu_id'] = $context['max_menu_id']; |
@@ -368,9 +374,10 @@ discard block |
||
| 368 | 374 | $context['menu_item_selected'] = $current_area; |
| 369 | 375 | |
| 370 | 376 | // Set the template for this area and add the profile layer. |
| 371 | - if (!isset($_REQUEST['xml'])) |
|
| 372 | - $context['template_layers'][] = 'pm'; |
|
| 373 | -} |
|
| 377 | + if (!isset($_REQUEST['xml'])) { |
|
| 378 | + $context['template_layers'][] = 'pm'; |
|
| 379 | + } |
|
| 380 | + } |
|
| 374 | 381 | |
| 375 | 382 | /** |
| 376 | 383 | * The popup for when we ask for the popup from the user. |
@@ -402,8 +409,9 @@ discard block |
||
| 402 | 409 | ) |
| 403 | 410 | ); |
| 404 | 411 | $pms = array(); |
| 405 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 406 | - $pms[] = $row[0]; |
|
| 412 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 413 | + $pms[] = $row[0]; |
|
| 414 | + } |
|
| 407 | 415 | $smcFunc['db_free_result']($request); |
| 408 | 416 | |
| 409 | 417 | if (!empty($pms)) |
@@ -431,8 +439,9 @@ discard block |
||
| 431 | 439 | ); |
| 432 | 440 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 433 | 441 | { |
| 434 | - if (!empty($row['id_member_from'])) |
|
| 435 | - $senders[] = $row['id_member_from']; |
|
| 442 | + if (!empty($row['id_member_from'])) { |
|
| 443 | + $senders[] = $row['id_member_from']; |
|
| 444 | + } |
|
| 436 | 445 | |
| 437 | 446 | $row['replied_to_you'] = $row['id_pm'] != $row['id_pm_head']; |
| 438 | 447 | $row['time'] = timeformat($row['timestamp']); |
@@ -442,13 +451,15 @@ discard block |
||
| 442 | 451 | $smcFunc['db_free_result']($request); |
| 443 | 452 | |
| 444 | 453 | $senders = loadMemberData($senders); |
| 445 | - foreach ($senders as $member) |
|
| 446 | - loadMemberContext($member); |
|
| 454 | + foreach ($senders as $member) { |
|
| 455 | + loadMemberContext($member); |
|
| 456 | + } |
|
| 447 | 457 | |
| 448 | 458 | // Having loaded everyone, attach them to the PMs. |
| 449 | - foreach ($context['unread_pms'] as $id_pm => $details) |
|
| 450 | - if (!empty($memberContext[$details['id_member_from']])) |
|
| 459 | + foreach ($context['unread_pms'] as $id_pm => $details) { |
|
| 460 | + if (!empty($memberContext[$details['id_member_from']])) |
|
| 451 | 461 | $context['unread_pms'][$id_pm]['member'] = &$memberContext[$details['id_member_from']]; |
| 462 | + } |
|
| 452 | 463 | } |
| 453 | 464 | } |
| 454 | 465 | |
@@ -468,12 +479,13 @@ discard block |
||
| 468 | 479 | } |
| 469 | 480 | |
| 470 | 481 | // Make sure the starting location is valid. |
| 471 | - if (isset($_GET['start']) && $_GET['start'] != 'new') |
|
| 472 | - $_GET['start'] = (int) $_GET['start']; |
|
| 473 | - elseif (!isset($_GET['start']) && !empty($options['view_newest_pm_first'])) |
|
| 474 | - $_GET['start'] = 0; |
|
| 475 | - else |
|
| 476 | - $_GET['start'] = 'new'; |
|
| 482 | + if (isset($_GET['start']) && $_GET['start'] != 'new') { |
|
| 483 | + $_GET['start'] = (int) $_GET['start']; |
|
| 484 | + } elseif (!isset($_GET['start']) && !empty($options['view_newest_pm_first'])) { |
|
| 485 | + $_GET['start'] = 0; |
|
| 486 | + } else { |
|
| 487 | + $_GET['start'] = 'new'; |
|
| 488 | + } |
|
| 477 | 489 | |
| 478 | 490 | // Set up some basic theme stuff. |
| 479 | 491 | $context['from_or_to'] = $context['folder'] != 'sent' ? 'from' : 'to'; |
@@ -490,8 +502,7 @@ discard block |
||
| 490 | 502 | { |
| 491 | 503 | $labelQuery = ' |
| 492 | 504 | AND pmr.in_inbox = 1'; |
| 493 | - } |
|
| 494 | - elseif ($context['folder'] != 'sent') |
|
| 505 | + } elseif ($context['folder'] != 'sent') |
|
| 495 | 506 | { |
| 496 | 507 | $labelJoin = ' |
| 497 | 508 | INNER JOIN {db_prefix}pm_labeled_messages AS pl ON (pl.id_pm = pmr.id_pm)'; |
@@ -533,22 +544,24 @@ discard block |
||
| 533 | 544 | $txt['delete_all'] = str_replace('PMBOX', $pmbox, $txt['delete_all']); |
| 534 | 545 | |
| 535 | 546 | // Now, build the link tree! |
| 536 | - if ($context['current_label_id'] == -1) |
|
| 537 | - $context['linktree'][] = array( |
|
| 547 | + if ($context['current_label_id'] == -1) { |
|
| 548 | + $context['linktree'][] = array( |
|
| 538 | 549 | 'url' => $scripturl . '?action=pm;f=' . $context['folder'], |
| 539 | 550 | 'name' => $pmbox |
| 540 | 551 | ); |
| 552 | + } |
|
| 541 | 553 | |
| 542 | 554 | // Build it further for a label. |
| 543 | - if ($context['current_label_id'] != -1) |
|
| 544 | - $context['linktree'][] = array( |
|
| 555 | + if ($context['current_label_id'] != -1) { |
|
| 556 | + $context['linktree'][] = array( |
|
| 545 | 557 | 'url' => $scripturl . '?action=pm;f=' . $context['folder'] . ';l=' . $context['current_label_id'], |
| 546 | 558 | 'name' => $txt['pm_current_label'] . ': ' . $context['current_label'] |
| 547 | 559 | ); |
| 560 | + } |
|
| 548 | 561 | |
| 549 | 562 | // Figure out how many messages there are. |
| 550 | - if ($context['folder'] == 'sent') |
|
| 551 | - $request = $smcFunc['db_query']('', ' |
|
| 563 | + if ($context['folder'] == 'sent') { |
|
| 564 | + $request = $smcFunc['db_query']('', ' |
|
| 552 | 565 | SELECT COUNT(' . ($context['display_mode'] == 2 ? 'DISTINCT pm.id_pm_head' : '*') . ') |
| 553 | 566 | FROM {db_prefix}personal_messages AS pm |
| 554 | 567 | WHERE pm.id_member_from = {int:current_member} |
@@ -558,8 +571,8 @@ discard block |
||
| 558 | 571 | 'not_deleted' => 0, |
| 559 | 572 | ) |
| 560 | 573 | ); |
| 561 | - else |
|
| 562 | - $request = $smcFunc['db_query']('', ' |
|
| 574 | + } else { |
|
| 575 | + $request = $smcFunc['db_query']('', ' |
|
| 563 | 576 | SELECT COUNT(' . ($context['display_mode'] == 2 ? 'DISTINCT pm.id_pm_head' : '*') . ') |
| 564 | 577 | FROM {db_prefix}pm_recipients AS pmr' . ($context['display_mode'] == 2 ? ' |
| 565 | 578 | INNER JOIN {db_prefix}personal_messages AS pm ON (pm.id_pm = pmr.id_pm)' : '') . $labelJoin . ' |
@@ -570,6 +583,7 @@ discard block |
||
| 570 | 583 | 'not_deleted' => 0, |
| 571 | 584 | ) |
| 572 | 585 | ); |
| 586 | + } |
|
| 573 | 587 | list ($max_messages) = $smcFunc['db_fetch_row']($request); |
| 574 | 588 | $smcFunc['db_free_result']($request); |
| 575 | 589 | |
@@ -578,10 +592,11 @@ discard block |
||
| 578 | 592 | $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
| 579 | 593 | |
| 580 | 594 | // Start on the last page. |
| 581 | - if (!is_numeric($_GET['start']) || $_GET['start'] >= $max_messages) |
|
| 582 | - $_GET['start'] = ($max_messages - 1) - (($max_messages - 1) % $maxPerPage); |
|
| 583 | - elseif ($_GET['start'] < 0) |
|
| 584 | - $_GET['start'] = 0; |
|
| 595 | + if (!is_numeric($_GET['start']) || $_GET['start'] >= $max_messages) { |
|
| 596 | + $_GET['start'] = ($max_messages - 1) - (($max_messages - 1) % $maxPerPage); |
|
| 597 | + } elseif ($_GET['start'] < 0) { |
|
| 598 | + $_GET['start'] = 0; |
|
| 599 | + } |
|
| 585 | 600 | |
| 586 | 601 | // ... but wait - what if we want to start from a specific message? |
| 587 | 602 | if (isset($_GET['pmid'])) |
@@ -589,19 +604,21 @@ discard block |
||
| 589 | 604 | $pmID = (int) $_GET['pmid']; |
| 590 | 605 | |
| 591 | 606 | // Make sure you have access to this PM. |
| 592 | - if (!isAccessiblePM($pmID, $context['folder'] == 'sent' ? 'outbox' : 'inbox')) |
|
| 593 | - fatal_lang_error('no_access', false); |
|
| 607 | + if (!isAccessiblePM($pmID, $context['folder'] == 'sent' ? 'outbox' : 'inbox')) { |
|
| 608 | + fatal_lang_error('no_access', false); |
|
| 609 | + } |
|
| 594 | 610 | |
| 595 | 611 | $context['current_pm'] = $pmID; |
| 596 | 612 | |
| 597 | 613 | // With only one page of PM's we're gonna want page 1. |
| 598 | - if ($max_messages <= $maxPerPage) |
|
| 599 | - $_GET['start'] = 0; |
|
| 614 | + if ($max_messages <= $maxPerPage) { |
|
| 615 | + $_GET['start'] = 0; |
|
| 616 | + } |
|
| 600 | 617 | // If we pass kstart we assume we're in the right place. |
| 601 | 618 | elseif (!isset($_GET['kstart'])) |
| 602 | 619 | { |
| 603 | - if ($context['folder'] == 'sent') |
|
| 604 | - $request = $smcFunc['db_query']('', ' |
|
| 620 | + if ($context['folder'] == 'sent') { |
|
| 621 | + $request = $smcFunc['db_query']('', ' |
|
| 605 | 622 | SELECT COUNT(' . ($context['display_mode'] == 2 ? 'DISTINCT pm.id_pm_head' : '*') . ') |
| 606 | 623 | FROM {db_prefix}personal_messages |
| 607 | 624 | WHERE id_member_from = {int:current_member} |
@@ -613,8 +630,8 @@ discard block |
||
| 613 | 630 | 'id_pm' => $pmID, |
| 614 | 631 | ) |
| 615 | 632 | ); |
| 616 | - else |
|
| 617 | - $request = $smcFunc['db_query']('', ' |
|
| 633 | + } else { |
|
| 634 | + $request = $smcFunc['db_query']('', ' |
|
| 618 | 635 | SELECT COUNT(' . ($context['display_mode'] == 2 ? 'DISTINCT pm.id_pm_head' : '*') . ') |
| 619 | 636 | FROM {db_prefix}pm_recipients AS pmr' . ($context['display_mode'] == 2 ? ' |
| 620 | 637 | INNER JOIN {db_prefix}personal_messages AS pm ON (pm.id_pm = pmr.id_pm)' : '') . $labelJoin . ' |
@@ -627,6 +644,7 @@ discard block |
||
| 627 | 644 | 'id_pm' => $pmID, |
| 628 | 645 | ) |
| 629 | 646 | ); |
| 647 | + } |
|
| 630 | 648 | |
| 631 | 649 | list ($_GET['start']) = $smcFunc['db_fetch_row']($request); |
| 632 | 650 | $smcFunc['db_free_result']($request); |
@@ -641,8 +659,9 @@ discard block |
||
| 641 | 659 | { |
| 642 | 660 | $pmsg = (int) $_GET['pmsg']; |
| 643 | 661 | |
| 644 | - if (!isAccessiblePM($pmsg, $context['folder'] == 'sent' ? 'outbox' : 'inbox')) |
|
| 645 | - fatal_lang_error('no_access', false); |
|
| 662 | + if (!isAccessiblePM($pmsg, $context['folder'] == 'sent' ? 'outbox' : 'inbox')) { |
|
| 663 | + fatal_lang_error('no_access', false); |
|
| 664 | + } |
|
| 646 | 665 | } |
| 647 | 666 | |
| 648 | 667 | // Set up the page index. |
@@ -737,8 +756,9 @@ discard block |
||
| 737 | 756 | { |
| 738 | 757 | if (!isset($recipients[$row['id_pm']])) |
| 739 | 758 | { |
| 740 | - if (isset($row['id_member_from'])) |
|
| 741 | - $posters[$row['id_pm']] = $row['id_member_from']; |
|
| 759 | + if (isset($row['id_member_from'])) { |
|
| 760 | + $posters[$row['id_pm']] = $row['id_member_from']; |
|
| 761 | + } |
|
| 742 | 762 | $pms[$row['id_pm']] = $row['id_pm']; |
| 743 | 763 | $recipients[$row['id_pm']] = array( |
| 744 | 764 | 'to' => array(), |
@@ -747,29 +767,33 @@ discard block |
||
| 747 | 767 | } |
| 748 | 768 | |
| 749 | 769 | // Keep track of the last message so we know what the head is without another query! |
| 750 | - if ((empty($pmID) && (empty($options['view_newest_pm_first']) || !isset($lastData))) || empty($lastData) || (!empty($pmID) && $pmID == $row['id_pm'])) |
|
| 751 | - $lastData = array( |
|
| 770 | + if ((empty($pmID) && (empty($options['view_newest_pm_first']) || !isset($lastData))) || empty($lastData) || (!empty($pmID) && $pmID == $row['id_pm'])) { |
|
| 771 | + $lastData = array( |
|
| 752 | 772 | 'id' => $row['id_pm'], |
| 753 | 773 | 'head' => $row['id_pm_head'], |
| 754 | 774 | ); |
| 775 | + } |
|
| 755 | 776 | } |
| 756 | 777 | $smcFunc['db_free_result']($request); |
| 757 | 778 | |
| 758 | 779 | // Make sure that we have been given a correct head pm id! |
| 759 | - if ($context['display_mode'] == 2 && !empty($pmID) && $pmID != $lastData['id']) |
|
| 760 | - fatal_lang_error('no_access', false); |
|
| 780 | + if ($context['display_mode'] == 2 && !empty($pmID) && $pmID != $lastData['id']) { |
|
| 781 | + fatal_lang_error('no_access', false); |
|
| 782 | + } |
|
| 761 | 783 | |
| 762 | 784 | if (!empty($pms)) |
| 763 | 785 | { |
| 764 | 786 | // Select the correct current message. |
| 765 | - if (empty($pmID)) |
|
| 766 | - $context['current_pm'] = $lastData['id']; |
|
| 787 | + if (empty($pmID)) { |
|
| 788 | + $context['current_pm'] = $lastData['id']; |
|
| 789 | + } |
|
| 767 | 790 | |
| 768 | 791 | // This is a list of the pm's that are used for "full" display. |
| 769 | - if ($context['display_mode'] == 0) |
|
| 770 | - $display_pms = $pms; |
|
| 771 | - else |
|
| 772 | - $display_pms = array($context['current_pm']); |
|
| 792 | + if ($context['display_mode'] == 0) { |
|
| 793 | + $display_pms = $pms; |
|
| 794 | + } else { |
|
| 795 | + $display_pms = array($context['current_pm']); |
|
| 796 | + } |
|
| 773 | 797 | |
| 774 | 798 | // At this point we know the main id_pm's. But - if we are looking at conversations we need the others! |
| 775 | 799 | if ($context['display_mode'] == 2) |
@@ -791,16 +815,18 @@ discard block |
||
| 791 | 815 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 792 | 816 | { |
| 793 | 817 | // This is, frankly, a joke. We will put in a workaround for people sending to themselves - yawn! |
| 794 | - if ($context['folder'] == 'sent' && $row['id_member_from'] == $user_info['id'] && $row['deleted_by_sender'] == 1) |
|
| 795 | - continue; |
|
| 796 | - elseif ($row['id_member'] == $user_info['id'] & $row['deleted'] == 1) |
|
| 797 | - continue; |
|
| 818 | + if ($context['folder'] == 'sent' && $row['id_member_from'] == $user_info['id'] && $row['deleted_by_sender'] == 1) { |
|
| 819 | + continue; |
|
| 820 | + } elseif ($row['id_member'] == $user_info['id'] & $row['deleted'] == 1) { |
|
| 821 | + continue; |
|
| 822 | + } |
|
| 798 | 823 | |
| 799 | - if (!isset($recipients[$row['id_pm']])) |
|
| 800 | - $recipients[$row['id_pm']] = array( |
|
| 824 | + if (!isset($recipients[$row['id_pm']])) { |
|
| 825 | + $recipients[$row['id_pm']] = array( |
|
| 801 | 826 | 'to' => array(), |
| 802 | 827 | 'bcc' => array() |
| 803 | 828 | ); |
| 829 | + } |
|
| 804 | 830 | $display_pms[] = $row['id_pm']; |
| 805 | 831 | $posters[$row['id_pm']] = $row['id_member_from']; |
| 806 | 832 | } |
@@ -851,8 +877,9 @@ discard block |
||
| 851 | 877 | while($row2 = $smcFunc['db_fetch_assoc']($request2)) |
| 852 | 878 | { |
| 853 | 879 | $l_id = $row2['id_label']; |
| 854 | - if (isset($context['labels'][$l_id])) |
|
| 855 | - $context['message_labels'][$row['id_pm']][$l_id] = array('id' => $l_id, 'name' => $context['labels'][$l_id]['name']); |
|
| 880 | + if (isset($context['labels'][$l_id])) { |
|
| 881 | + $context['message_labels'][$row['id_pm']][$l_id] = array('id' => $l_id, 'name' => $context['labels'][$l_id]['name']); |
|
| 882 | + } |
|
| 856 | 883 | } |
| 857 | 884 | |
| 858 | 885 | $smcFunc['db_free_result']($request2); |
@@ -869,9 +896,10 @@ discard block |
||
| 869 | 896 | // Make sure we don't load unnecessary data. |
| 870 | 897 | if ($context['display_mode'] == 1) |
| 871 | 898 | { |
| 872 | - foreach ($posters as $k => $v) |
|
| 873 | - if (!in_array($k, $display_pms)) |
|
| 899 | + foreach ($posters as $k => $v) { |
|
| 900 | + if (!in_array($k, $display_pms)) |
|
| 874 | 901 | unset($posters[$k]); |
| 902 | + } |
|
| 875 | 903 | } |
| 876 | 904 | |
| 877 | 905 | // Load any users.... |
@@ -882,8 +910,9 @@ discard block |
||
| 882 | 910 | { |
| 883 | 911 | // Get the order right. |
| 884 | 912 | $orderBy = array(); |
| 885 | - foreach (array_reverse($pms) as $pm) |
|
| 886 | - $orderBy[] = 'pm.id_pm = ' . $pm; |
|
| 913 | + foreach (array_reverse($pms) as $pm) { |
|
| 914 | + $orderBy[] = 'pm.id_pm = ' . $pm; |
|
| 915 | + } |
|
| 887 | 916 | |
| 888 | 917 | // Seperate query for these bits! |
| 889 | 918 | $subjects_request = $smcFunc['db_query']('', ' |
@@ -929,9 +958,9 @@ discard block |
||
| 929 | 958 | // Allow mods to add additional buttons here |
| 930 | 959 | call_integration_hook('integrate_conversation_buttons'); |
| 931 | 960 | } |
| 961 | + } else { |
|
| 962 | + $messages_request = false; |
|
| 932 | 963 | } |
| 933 | - else |
|
| 934 | - $messages_request = false; |
|
| 935 | 964 | |
| 936 | 965 | $context['can_send_pm'] = allowedTo('pm_send'); |
| 937 | 966 | $context['can_send_email'] = allowedTo('moderate_forum'); |
@@ -942,11 +971,13 @@ discard block |
||
| 942 | 971 | if ($context['folder'] != 'sent' && !empty($context['labels'][(int) $context['current_label_id']]['unread_messages'])) |
| 943 | 972 | { |
| 944 | 973 | // If the display mode is "old sk00l" do them all... |
| 945 | - if ($context['display_mode'] == 0) |
|
| 946 | - markMessages(null, $context['current_label_id']); |
|
| 974 | + if ($context['display_mode'] == 0) { |
|
| 975 | + markMessages(null, $context['current_label_id']); |
|
| 976 | + } |
|
| 947 | 977 | // Otherwise do just the current one! |
| 948 | - elseif (!empty($context['current_pm'])) |
|
| 949 | - markMessages($display_pms, $context['current_label_id']); |
|
| 978 | + elseif (!empty($context['current_pm'])) { |
|
| 979 | + markMessages($display_pms, $context['current_label_id']); |
|
| 980 | + } |
|
| 950 | 981 | } |
| 951 | 982 | } |
| 952 | 983 | |
@@ -964,8 +995,9 @@ discard block |
||
| 964 | 995 | |
| 965 | 996 | // Count the current message number.... |
| 966 | 997 | static $counter = null; |
| 967 | - if ($counter === null || $reset) |
|
| 968 | - $counter = $context['start']; |
|
| 998 | + if ($counter === null || $reset) { |
|
| 999 | + $counter = $context['start']; |
|
| 1000 | + } |
|
| 969 | 1001 | |
| 970 | 1002 | static $temp_pm_selected = null; |
| 971 | 1003 | if ($temp_pm_selected === null) |
@@ -1010,19 +1042,22 @@ discard block |
||
| 1010 | 1042 | } |
| 1011 | 1043 | |
| 1012 | 1044 | // Bail if it's false, ie. no messages. |
| 1013 | - if ($messages_request == false) |
|
| 1014 | - return false; |
|
| 1045 | + if ($messages_request == false) { |
|
| 1046 | + return false; |
|
| 1047 | + } |
|
| 1015 | 1048 | |
| 1016 | 1049 | // Reset the data? |
| 1017 | - if ($reset == true) |
|
| 1018 | - return @$smcFunc['db_data_seek']($messages_request, 0); |
|
| 1050 | + if ($reset == true) { |
|
| 1051 | + return @$smcFunc['db_data_seek']($messages_request, 0); |
|
| 1052 | + } |
|
| 1019 | 1053 | |
| 1020 | 1054 | // Get the next one... bail if anything goes wrong. |
| 1021 | 1055 | $message = $smcFunc['db_fetch_assoc']($messages_request); |
| 1022 | 1056 | if (!$message) |
| 1023 | 1057 | { |
| 1024 | - if ($type != 'subject') |
|
| 1025 | - $smcFunc['db_free_result']($messages_request); |
|
| 1058 | + if ($type != 'subject') { |
|
| 1059 | + $smcFunc['db_free_result']($messages_request); |
|
| 1060 | + } |
|
| 1026 | 1061 | |
| 1027 | 1062 | return false; |
| 1028 | 1063 | } |
@@ -1042,8 +1077,7 @@ discard block |
||
| 1042 | 1077 | $memberContext[$message['id_member_from']]['email'] = ''; |
| 1043 | 1078 | $memberContext[$message['id_member_from']]['show_email'] = false; |
| 1044 | 1079 | $memberContext[$message['id_member_from']]['is_guest'] = true; |
| 1045 | - } |
|
| 1046 | - else |
|
| 1080 | + } else |
|
| 1047 | 1081 | { |
| 1048 | 1082 | $memberContext[$message['id_member_from']]['can_view_profile'] = allowedTo('profile_view') || ($message['id_member_from'] == $user_info['id'] && !$user_info['is_guest']); |
| 1049 | 1083 | $memberContext[$message['id_member_from']]['can_see_warning'] = !isset($context['disabled_fields']['warning_status']) && $memberContext[$message['id_member_from']]['warning_status'] && ($context['user']['can_mod'] || (!empty($modSettings['warning_show']) && ($modSettings['warning_show'] > 1 || $message['id_member_from'] == $user_info['id']))); |
@@ -1084,12 +1118,13 @@ discard block |
||
| 1084 | 1118 | $counter++; |
| 1085 | 1119 | |
| 1086 | 1120 | // Any custom profile fields? |
| 1087 | - if (!empty($memberContext[$message['id_member_from']]['custom_fields'])) |
|
| 1088 | - foreach ($memberContext[$message['id_member_from']]['custom_fields'] as $custom) |
|
| 1121 | + if (!empty($memberContext[$message['id_member_from']]['custom_fields'])) { |
|
| 1122 | + foreach ($memberContext[$message['id_member_from']]['custom_fields'] as $custom) |
|
| 1089 | 1123 | switch ($custom['placement']) |
| 1090 | 1124 | { |
| 1091 | 1125 | case 1: |
| 1092 | 1126 | $output['custom_fields']['icons'][] = $custom; |
| 1127 | + } |
|
| 1093 | 1128 | break; |
| 1094 | 1129 | case 2: |
| 1095 | 1130 | $output['custom_fields']['above_signature'][] = $custom; |
@@ -1132,22 +1167,28 @@ discard block |
||
| 1132 | 1167 | $context['search_params'][$k] = $v; |
| 1133 | 1168 | } |
| 1134 | 1169 | } |
| 1135 | - if (isset($_REQUEST['search'])) |
|
| 1136 | - $context['search_params']['search'] = un_htmlspecialchars($_REQUEST['search']); |
|
| 1170 | + if (isset($_REQUEST['search'])) { |
|
| 1171 | + $context['search_params']['search'] = un_htmlspecialchars($_REQUEST['search']); |
|
| 1172 | + } |
|
| 1137 | 1173 | |
| 1138 | - if (isset($context['search_params']['search'])) |
|
| 1139 | - $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
| 1140 | - if (isset($context['search_params']['userspec'])) |
|
| 1141 | - $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
| 1174 | + if (isset($context['search_params']['search'])) { |
|
| 1175 | + $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
| 1176 | + } |
|
| 1177 | + if (isset($context['search_params']['userspec'])) { |
|
| 1178 | + $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
| 1179 | + } |
|
| 1142 | 1180 | |
| 1143 | - if (!empty($context['search_params']['searchtype'])) |
|
| 1144 | - $context['search_params']['searchtype'] = 2; |
|
| 1181 | + if (!empty($context['search_params']['searchtype'])) { |
|
| 1182 | + $context['search_params']['searchtype'] = 2; |
|
| 1183 | + } |
|
| 1145 | 1184 | |
| 1146 | - if (!empty($context['search_params']['minage'])) |
|
| 1147 | - $context['search_params']['minage'] = (int) $context['search_params']['minage']; |
|
| 1185 | + if (!empty($context['search_params']['minage'])) { |
|
| 1186 | + $context['search_params']['minage'] = (int) $context['search_params']['minage']; |
|
| 1187 | + } |
|
| 1148 | 1188 | |
| 1149 | - if (!empty($context['search_params']['maxage'])) |
|
| 1150 | - $context['search_params']['maxage'] = (int) $context['search_params']['maxage']; |
|
| 1189 | + if (!empty($context['search_params']['maxage'])) { |
|
| 1190 | + $context['search_params']['maxage'] = (int) $context['search_params']['maxage']; |
|
| 1191 | + } |
|
| 1151 | 1192 | |
| 1152 | 1193 | $context['search_params']['subject_only'] = !empty($context['search_params']['subject_only']); |
| 1153 | 1194 | $context['search_params']['show_complete'] = !empty($context['search_params']['show_complete']); |
@@ -1174,8 +1215,9 @@ discard block |
||
| 1174 | 1215 | $context['search_errors']['messages'] = array(); |
| 1175 | 1216 | foreach ($context['search_errors'] as $search_error => $dummy) |
| 1176 | 1217 | { |
| 1177 | - if ($search_error == 'messages') |
|
| 1178 | - continue; |
|
| 1218 | + if ($search_error == 'messages') { |
|
| 1219 | + continue; |
|
| 1220 | + } |
|
| 1179 | 1221 | |
| 1180 | 1222 | $context['search_errors']['messages'][] = $txt['error_' . $search_error]; |
| 1181 | 1223 | } |
@@ -1197,8 +1239,9 @@ discard block |
||
| 1197 | 1239 | global $scripturl, $modSettings, $user_info, $context, $txt; |
| 1198 | 1240 | global $memberContext, $smcFunc; |
| 1199 | 1241 | |
| 1200 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) |
|
| 1201 | - fatal_lang_error('loadavg_search_disabled', false); |
|
| 1242 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) { |
|
| 1243 | + fatal_lang_error('loadavg_search_disabled', false); |
|
| 1244 | + } |
|
| 1202 | 1245 | |
| 1203 | 1246 | /** |
| 1204 | 1247 | * @todo For the moment force the folder to the inbox. |
@@ -1227,35 +1270,40 @@ discard block |
||
| 1227 | 1270 | $context['start'] = isset($_GET['start']) ? (int) $_GET['start'] : 0; |
| 1228 | 1271 | |
| 1229 | 1272 | // Store whether simple search was used (needed if the user wants to do another query). |
| 1230 | - if (!isset($search_params['advanced'])) |
|
| 1231 | - $search_params['advanced'] = empty($_REQUEST['advanced']) ? 0 : 1; |
|
| 1273 | + if (!isset($search_params['advanced'])) { |
|
| 1274 | + $search_params['advanced'] = empty($_REQUEST['advanced']) ? 0 : 1; |
|
| 1275 | + } |
|
| 1232 | 1276 | |
| 1233 | 1277 | // 1 => 'allwords' (default, don't set as param) / 2 => 'anywords'. |
| 1234 | - if (!empty($search_params['searchtype']) || (!empty($_REQUEST['searchtype']) && $_REQUEST['searchtype'] == 2)) |
|
| 1235 | - $search_params['searchtype'] = 2; |
|
| 1278 | + if (!empty($search_params['searchtype']) || (!empty($_REQUEST['searchtype']) && $_REQUEST['searchtype'] == 2)) { |
|
| 1279 | + $search_params['searchtype'] = 2; |
|
| 1280 | + } |
|
| 1236 | 1281 | |
| 1237 | 1282 | // Minimum age of messages. Default to zero (don't set param in that case). |
| 1238 | - if (!empty($search_params['minage']) || (!empty($_REQUEST['minage']) && $_REQUEST['minage'] > 0)) |
|
| 1239 | - $search_params['minage'] = !empty($search_params['minage']) ? (int) $search_params['minage'] : (int) $_REQUEST['minage']; |
|
| 1283 | + if (!empty($search_params['minage']) || (!empty($_REQUEST['minage']) && $_REQUEST['minage'] > 0)) { |
|
| 1284 | + $search_params['minage'] = !empty($search_params['minage']) ? (int) $search_params['minage'] : (int) $_REQUEST['minage']; |
|
| 1285 | + } |
|
| 1240 | 1286 | |
| 1241 | 1287 | // Maximum age of messages. Default to infinite (9999 days: param not set). |
| 1242 | - if (!empty($search_params['maxage']) || (!empty($_REQUEST['maxage']) && $_REQUEST['maxage'] != 9999)) |
|
| 1243 | - $search_params['maxage'] = !empty($search_params['maxage']) ? (int) $search_params['maxage'] : (int) $_REQUEST['maxage']; |
|
| 1288 | + if (!empty($search_params['maxage']) || (!empty($_REQUEST['maxage']) && $_REQUEST['maxage'] != 9999)) { |
|
| 1289 | + $search_params['maxage'] = !empty($search_params['maxage']) ? (int) $search_params['maxage'] : (int) $_REQUEST['maxage']; |
|
| 1290 | + } |
|
| 1244 | 1291 | |
| 1245 | 1292 | $search_params['subject_only'] = !empty($search_params['subject_only']) || !empty($_REQUEST['subject_only']); |
| 1246 | 1293 | $search_params['show_complete'] = !empty($search_params['show_complete']) || !empty($_REQUEST['show_complete']); |
| 1247 | 1294 | |
| 1248 | 1295 | // Default the user name to a wildcard matching every user (*). |
| 1249 | - if (!empty($search_params['user_spec']) || (!empty($_REQUEST['userspec']) && $_REQUEST['userspec'] != '*')) |
|
| 1250 | - $search_params['userspec'] = isset($search_params['userspec']) ? $search_params['userspec'] : $_REQUEST['userspec']; |
|
| 1296 | + if (!empty($search_params['user_spec']) || (!empty($_REQUEST['userspec']) && $_REQUEST['userspec'] != '*')) { |
|
| 1297 | + $search_params['userspec'] = isset($search_params['userspec']) ? $search_params['userspec'] : $_REQUEST['userspec']; |
|
| 1298 | + } |
|
| 1251 | 1299 | |
| 1252 | 1300 | // This will be full of all kinds of parameters! |
| 1253 | 1301 | $searchq_parameters = array(); |
| 1254 | 1302 | |
| 1255 | 1303 | // If there's no specific user, then don't mention it in the main query. |
| 1256 | - if (empty($search_params['userspec'])) |
|
| 1257 | - $userQuery = ''; |
|
| 1258 | - else |
|
| 1304 | + if (empty($search_params['userspec'])) { |
|
| 1305 | + $userQuery = ''; |
|
| 1306 | + } else |
|
| 1259 | 1307 | { |
| 1260 | 1308 | $userString = strtr($smcFunc['htmlspecialchars']($search_params['userspec'], ENT_QUOTES), array('"' => '"')); |
| 1261 | 1309 | $userString = strtr($userString, array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_')); |
@@ -1267,8 +1315,9 @@ discard block |
||
| 1267 | 1315 | { |
| 1268 | 1316 | $possible_users[$k] = trim($possible_users[$k]); |
| 1269 | 1317 | |
| 1270 | - if (strlen($possible_users[$k]) == 0) |
|
| 1271 | - unset($possible_users[$k]); |
|
| 1318 | + if (strlen($possible_users[$k]) == 0) { |
|
| 1319 | + unset($possible_users[$k]); |
|
| 1320 | + } |
|
| 1272 | 1321 | } |
| 1273 | 1322 | |
| 1274 | 1323 | if (!empty($possible_users)) |
@@ -1280,8 +1329,9 @@ discard block |
||
| 1280 | 1329 | { |
| 1281 | 1330 | $where_params['name_' . $k] = $v; |
| 1282 | 1331 | $where_clause[] = '{raw:real_name} LIKE {string:name_' . $k . '}'; |
| 1283 | - if (!isset($where_params['real_name'])) |
|
| 1284 | - $where_params['real_name'] = $smcFunc['db_case_sensitive'] ? 'LOWER(real_name)' : 'real_name'; |
|
| 1332 | + if (!isset($where_params['real_name'])) { |
|
| 1333 | + $where_params['real_name'] = $smcFunc['db_case_sensitive'] ? 'LOWER(real_name)' : 'real_name'; |
|
| 1334 | + } |
|
| 1285 | 1335 | } |
| 1286 | 1336 | |
| 1287 | 1337 | // Who matches those criteria? |
@@ -1294,28 +1344,28 @@ discard block |
||
| 1294 | 1344 | ); |
| 1295 | 1345 | |
| 1296 | 1346 | // Simply do nothing if there're too many members matching the criteria. |
| 1297 | - if ($smcFunc['db_num_rows']($request) > $maxMembersToSearch) |
|
| 1298 | - $userQuery = ''; |
|
| 1299 | - elseif ($smcFunc['db_num_rows']($request) == 0) |
|
| 1347 | + if ($smcFunc['db_num_rows']($request) > $maxMembersToSearch) { |
|
| 1348 | + $userQuery = ''; |
|
| 1349 | + } elseif ($smcFunc['db_num_rows']($request) == 0) |
|
| 1300 | 1350 | { |
| 1301 | 1351 | $userQuery = 'AND pm.id_member_from = 0 AND ({raw:pm_from_name} LIKE {raw:guest_user_name_implode})'; |
| 1302 | 1352 | $searchq_parameters['guest_user_name_implode'] = '\'' . implode('\' OR ' . ($smcFunc['db_case_sensitive'] ? 'LOWER(pm.from_name)' : 'pm.from_name') . ' LIKE \'', $possible_users) . '\''; |
| 1303 | 1353 | $searchq_parameters['pm_from_name'] = $smcFunc['db_case_sensitive'] ? 'LOWER(pm.from_name)' : 'pm.from_name'; |
| 1304 | - } |
|
| 1305 | - else |
|
| 1354 | + } else |
|
| 1306 | 1355 | { |
| 1307 | 1356 | $memberlist = array(); |
| 1308 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1309 | - $memberlist[] = $row['id_member']; |
|
| 1357 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1358 | + $memberlist[] = $row['id_member']; |
|
| 1359 | + } |
|
| 1310 | 1360 | $userQuery = 'AND (pm.id_member_from IN ({array_int:member_list}) OR (pm.id_member_from = 0 AND ({raw:pm_from_name} LIKE {raw:guest_user_name_implode})))'; |
| 1311 | 1361 | $searchq_parameters['guest_user_name_implode'] = '\'' . implode('\' OR ' . ($smcFunc['db_case_sensitive'] ? 'LOWER(pm.from_name)' : 'pm.from_name') . ' LIKE \'', $possible_users) . '\''; |
| 1312 | 1362 | $searchq_parameters['member_list'] = $memberlist; |
| 1313 | 1363 | $searchq_parameters['pm_from_name'] = $smcFunc['db_case_sensitive'] ? 'LOWER(pm.from_name)' : 'pm.from_name'; |
| 1314 | 1364 | } |
| 1315 | 1365 | $smcFunc['db_free_result']($request); |
| 1366 | + } else { |
|
| 1367 | + $userQuery = ''; |
|
| 1316 | 1368 | } |
| 1317 | - else |
|
| 1318 | - $userQuery = ''; |
|
| 1319 | 1369 | } |
| 1320 | 1370 | |
| 1321 | 1371 | // Setup the sorting variables... |
@@ -1323,8 +1373,9 @@ discard block |
||
| 1323 | 1373 | $sort_columns = array( |
| 1324 | 1374 | 'pm.id_pm', |
| 1325 | 1375 | ); |
| 1326 | - if (empty($search_params['sort']) && !empty($_REQUEST['sort'])) |
|
| 1327 | - list ($search_params['sort'], $search_params['sort_dir']) = array_pad(explode('|', $_REQUEST['sort']), 2, ''); |
|
| 1376 | + if (empty($search_params['sort']) && !empty($_REQUEST['sort'])) { |
|
| 1377 | + list ($search_params['sort'], $search_params['sort_dir']) = array_pad(explode('|', $_REQUEST['sort']), 2, ''); |
|
| 1378 | + } |
|
| 1328 | 1379 | $search_params['sort'] = !empty($search_params['sort']) && in_array($search_params['sort'], $sort_columns) ? $search_params['sort'] : 'pm.id_pm'; |
| 1329 | 1380 | $search_params['sort_dir'] = !empty($search_params['sort_dir']) && $search_params['sort_dir'] == 'asc' ? 'asc' : 'desc'; |
| 1330 | 1381 | |
@@ -1334,24 +1385,27 @@ discard block |
||
| 1334 | 1385 | if ($context['folder'] == 'inbox' && !empty($search_params['advanced']) && $context['currently_using_labels']) |
| 1335 | 1386 | { |
| 1336 | 1387 | // Came here from pagination? Put them back into $_REQUEST for sanitization. |
| 1337 | - if (isset($search_params['labels'])) |
|
| 1338 | - $_REQUEST['searchlabel'] = explode(',', $search_params['labels']); |
|
| 1388 | + if (isset($search_params['labels'])) { |
|
| 1389 | + $_REQUEST['searchlabel'] = explode(',', $search_params['labels']); |
|
| 1390 | + } |
|
| 1339 | 1391 | |
| 1340 | 1392 | // Assuming we have some labels - make them all integers. |
| 1341 | 1393 | if (!empty($_REQUEST['searchlabel']) && is_array($_REQUEST['searchlabel'])) |
| 1342 | 1394 | { |
| 1343 | - foreach ($_REQUEST['searchlabel'] as $key => $id) |
|
| 1344 | - $_REQUEST['searchlabel'][$key] = (int) $id; |
|
| 1395 | + foreach ($_REQUEST['searchlabel'] as $key => $id) { |
|
| 1396 | + $_REQUEST['searchlabel'][$key] = (int) $id; |
|
| 1397 | + } |
|
| 1398 | + } else { |
|
| 1399 | + $_REQUEST['searchlabel'] = array(); |
|
| 1345 | 1400 | } |
| 1346 | - else |
|
| 1347 | - $_REQUEST['searchlabel'] = array(); |
|
| 1348 | 1401 | |
| 1349 | 1402 | // Now that everything is cleaned up a bit, make the labels a param. |
| 1350 | 1403 | $search_params['labels'] = implode(',', $_REQUEST['searchlabel']); |
| 1351 | 1404 | |
| 1352 | 1405 | // No labels selected? That must be an error! |
| 1353 | - if (empty($_REQUEST['searchlabel'])) |
|
| 1354 | - $context['search_errors']['no_labels_selected'] = true; |
|
| 1406 | + if (empty($_REQUEST['searchlabel'])) { |
|
| 1407 | + $context['search_errors']['no_labels_selected'] = true; |
|
| 1408 | + } |
|
| 1355 | 1409 | // Otherwise prepare the query! |
| 1356 | 1410 | elseif (count($_REQUEST['searchlabel']) != count($context['labels'])) |
| 1357 | 1411 | { |
@@ -1374,8 +1428,7 @@ discard block |
||
| 1374 | 1428 | // Not searching the inbox - PM must be labeled |
| 1375 | 1429 | $labelQuery = ' AND pml.id_label IN ({array_int:labels})'; |
| 1376 | 1430 | $labelJoin = ' INNER JOIN {db_prefix}pm_labeled_messages AS pml ON (pml.id_pm = pmr.id_pm)'; |
| 1377 | - } |
|
| 1378 | - else |
|
| 1431 | + } else |
|
| 1379 | 1432 | { |
| 1380 | 1433 | // Searching the inbox - PM doesn't have to be labeled |
| 1381 | 1434 | $labelQuery = ' AND (' . substr($labelQuery, 5) . ' OR pml.id_label IN ({array_int:labels}))'; |
@@ -1390,8 +1443,9 @@ discard block |
||
| 1390 | 1443 | // What are we actually searching for? |
| 1391 | 1444 | $search_params['search'] = !empty($search_params['search']) ? $search_params['search'] : (isset($_REQUEST['search']) ? $_REQUEST['search'] : ''); |
| 1392 | 1445 | // If we ain't got nothing - we should error! |
| 1393 | - if (!isset($search_params['search']) || $search_params['search'] == '') |
|
| 1394 | - $context['search_errors']['invalid_search_string'] = true; |
|
| 1446 | + if (!isset($search_params['search']) || $search_params['search'] == '') { |
|
| 1447 | + $context['search_errors']['invalid_search_string'] = true; |
|
| 1448 | + } |
|
| 1395 | 1449 | |
| 1396 | 1450 | // Extract phrase parts first (e.g. some words "this is a phrase" some more words.) |
| 1397 | 1451 | preg_match_all('~(?:^|\s)([-]?)"([^"]+)"(?:$|\s)~' . ($context['utf8'] ? 'u' : ''), $search_params['search'], $matches, PREG_PATTERN_ORDER); |
@@ -1404,12 +1458,14 @@ discard block |
||
| 1404 | 1458 | $excludedWords = array(); |
| 1405 | 1459 | |
| 1406 | 1460 | // .. first, we check for things like -"some words", but not "-some words". |
| 1407 | - foreach ($matches[1] as $index => $word) |
|
| 1408 | - if ($word == '-') |
|
| 1461 | + foreach ($matches[1] as $index => $word) { |
|
| 1462 | + if ($word == '-') |
|
| 1409 | 1463 | { |
| 1410 | 1464 | $word = $smcFunc['strtolower'](trim($searchArray[$index])); |
| 1411 | - if (strlen($word) > 0) |
|
| 1412 | - $excludedWords[] = $word; |
|
| 1465 | + } |
|
| 1466 | + if (strlen($word) > 0) { |
|
| 1467 | + $excludedWords[] = $word; |
|
| 1468 | + } |
|
| 1413 | 1469 | unset($searchArray[$index]); |
| 1414 | 1470 | } |
| 1415 | 1471 | |
@@ -1419,8 +1475,9 @@ discard block |
||
| 1419 | 1475 | if (strpos(trim($word), '-') === 0) |
| 1420 | 1476 | { |
| 1421 | 1477 | $word = substr($smcFunc['strtolower']($word), 1); |
| 1422 | - if (strlen($word) > 0) |
|
| 1423 | - $excludedWords[] = $word; |
|
| 1478 | + if (strlen($word) > 0) { |
|
| 1479 | + $excludedWords[] = $word; |
|
| 1480 | + } |
|
| 1424 | 1481 | unset($tempSearch[$index]); |
| 1425 | 1482 | } |
| 1426 | 1483 | } |
@@ -1431,9 +1488,9 @@ discard block |
||
| 1431 | 1488 | foreach ($searchArray as $index => $value) |
| 1432 | 1489 | { |
| 1433 | 1490 | $searchArray[$index] = $smcFunc['strtolower'](trim($value)); |
| 1434 | - if ($searchArray[$index] == '') |
|
| 1435 | - unset($searchArray[$index]); |
|
| 1436 | - else |
|
| 1491 | + if ($searchArray[$index] == '') { |
|
| 1492 | + unset($searchArray[$index]); |
|
| 1493 | + } else |
|
| 1437 | 1494 | { |
| 1438 | 1495 | // Sort out entities first. |
| 1439 | 1496 | $searchArray[$index] = $smcFunc['htmlspecialchars']($searchArray[$index]); |
@@ -1443,27 +1500,32 @@ discard block |
||
| 1443 | 1500 | |
| 1444 | 1501 | // Create an array of replacements for highlighting. |
| 1445 | 1502 | $context['mark'] = array(); |
| 1446 | - foreach ($searchArray as $word) |
|
| 1447 | - $context['mark'][$word] = '<strong class="highlight">' . $word . '</strong>'; |
|
| 1503 | + foreach ($searchArray as $word) { |
|
| 1504 | + $context['mark'][$word] = '<strong class="highlight">' . $word . '</strong>'; |
|
| 1505 | + } |
|
| 1448 | 1506 | |
| 1449 | 1507 | // This contains *everything* |
| 1450 | 1508 | $searchWords = array_merge($searchArray, $excludedWords); |
| 1451 | 1509 | |
| 1452 | 1510 | // Make sure at least one word is being searched for. |
| 1453 | - if (empty($searchArray)) |
|
| 1454 | - $context['search_errors']['invalid_search_string'] = true; |
|
| 1511 | + if (empty($searchArray)) { |
|
| 1512 | + $context['search_errors']['invalid_search_string'] = true; |
|
| 1513 | + } |
|
| 1455 | 1514 | |
| 1456 | 1515 | // Sort out the search query so the user can edit it - if they want. |
| 1457 | 1516 | $context['search_params'] = $search_params; |
| 1458 | - if (isset($context['search_params']['search'])) |
|
| 1459 | - $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
| 1460 | - if (isset($context['search_params']['userspec'])) |
|
| 1461 | - $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
| 1517 | + if (isset($context['search_params']['search'])) { |
|
| 1518 | + $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
| 1519 | + } |
|
| 1520 | + if (isset($context['search_params']['userspec'])) { |
|
| 1521 | + $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
| 1522 | + } |
|
| 1462 | 1523 | |
| 1463 | 1524 | // Now we have all the parameters, combine them together for pagination and the like... |
| 1464 | 1525 | $context['params'] = array(); |
| 1465 | - foreach ($search_params as $k => $v) |
|
| 1466 | - $context['params'][] = $k . '|\'|' . $v; |
|
| 1526 | + foreach ($search_params as $k => $v) { |
|
| 1527 | + $context['params'][] = $k . '|\'|' . $v; |
|
| 1528 | + } |
|
| 1467 | 1529 | $context['params'] = base64_encode(implode('|"|', $context['params'])); |
| 1468 | 1530 | |
| 1469 | 1531 | // Compile the subject query part. |
@@ -1471,26 +1533,31 @@ discard block |
||
| 1471 | 1533 | |
| 1472 | 1534 | foreach ($searchWords as $index => $word) |
| 1473 | 1535 | { |
| 1474 | - if ($word == '') |
|
| 1475 | - continue; |
|
| 1536 | + if ($word == '') { |
|
| 1537 | + continue; |
|
| 1538 | + } |
|
| 1476 | 1539 | |
| 1477 | - if ($search_params['subject_only']) |
|
| 1478 | - $andQueryParts[] = 'pm.subject' . (in_array($word, $excludedWords) ? ' NOT' : '') . ' LIKE {string:search_' . $index . '}'; |
|
| 1479 | - else |
|
| 1480 | - $andQueryParts[] = '(pm.subject' . (in_array($word, $excludedWords) ? ' NOT' : '') . ' LIKE {string:search_' . $index . '} ' . (in_array($word, $excludedWords) ? 'AND pm.body NOT' : 'OR pm.body') . ' LIKE {string:search_' . $index . '})'; |
|
| 1540 | + if ($search_params['subject_only']) { |
|
| 1541 | + $andQueryParts[] = 'pm.subject' . (in_array($word, $excludedWords) ? ' NOT' : '') . ' LIKE {string:search_' . $index . '}'; |
|
| 1542 | + } else { |
|
| 1543 | + $andQueryParts[] = '(pm.subject' . (in_array($word, $excludedWords) ? ' NOT' : '') . ' LIKE {string:search_' . $index . '} ' . (in_array($word, $excludedWords) ? 'AND pm.body NOT' : 'OR pm.body') . ' LIKE {string:search_' . $index . '})'; |
|
| 1544 | + } |
|
| 1481 | 1545 | $searchq_parameters['search_' . $index] = '%' . strtr($word, array('_' => '\\_', '%' => '\\%')) . '%'; |
| 1482 | 1546 | } |
| 1483 | 1547 | |
| 1484 | 1548 | $searchQuery = ' 1=1'; |
| 1485 | - if (!empty($andQueryParts)) |
|
| 1486 | - $searchQuery = implode(!empty($search_params['searchtype']) && $search_params['searchtype'] == 2 ? ' OR ' : ' AND ', $andQueryParts); |
|
| 1549 | + if (!empty($andQueryParts)) { |
|
| 1550 | + $searchQuery = implode(!empty($search_params['searchtype']) && $search_params['searchtype'] == 2 ? ' OR ' : ' AND ', $andQueryParts); |
|
| 1551 | + } |
|
| 1487 | 1552 | |
| 1488 | 1553 | // Age limits? |
| 1489 | 1554 | $timeQuery = ''; |
| 1490 | - if (!empty($search_params['minage'])) |
|
| 1491 | - $timeQuery .= ' AND pm.msgtime < ' . (time() - $search_params['minage'] * 86400); |
|
| 1492 | - if (!empty($search_params['maxage'])) |
|
| 1493 | - $timeQuery .= ' AND pm.msgtime > ' . (time() - $search_params['maxage'] * 86400); |
|
| 1555 | + if (!empty($search_params['minage'])) { |
|
| 1556 | + $timeQuery .= ' AND pm.msgtime < ' . (time() - $search_params['minage'] * 86400); |
|
| 1557 | + } |
|
| 1558 | + if (!empty($search_params['maxage'])) { |
|
| 1559 | + $timeQuery .= ' AND pm.msgtime > ' . (time() - $search_params['maxage'] * 86400); |
|
| 1560 | + } |
|
| 1494 | 1561 | |
| 1495 | 1562 | // If we have errors - return back to the first screen... |
| 1496 | 1563 | if (!empty($context['search_errors'])) |
@@ -1576,8 +1643,9 @@ discard block |
||
| 1576 | 1643 | ) |
| 1577 | 1644 | ); |
| 1578 | 1645 | $real_pm_ids = array(); |
| 1579 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1580 | - $real_pm_ids[$row['id_pm_head']] = $row['id_pm']; |
|
| 1646 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1647 | + $real_pm_ids[$row['id_pm_head']] = $row['id_pm']; |
|
| 1648 | + } |
|
| 1581 | 1649 | $smcFunc['db_free_result']($request); |
| 1582 | 1650 | } |
| 1583 | 1651 | |
@@ -1607,8 +1675,9 @@ discard block |
||
| 1607 | 1675 | ); |
| 1608 | 1676 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1609 | 1677 | { |
| 1610 | - if ($context['folder'] == 'sent' || empty($row['bcc'])) |
|
| 1611 | - $recipients[$row['id_pm']][empty($row['bcc']) ? 'to' : 'bcc'][] = empty($row['id_member_to']) ? $txt['guest_title'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member_to'] . '">' . $row['to_name'] . '</a>'; |
|
| 1678 | + if ($context['folder'] == 'sent' || empty($row['bcc'])) { |
|
| 1679 | + $recipients[$row['id_pm']][empty($row['bcc']) ? 'to' : 'bcc'][] = empty($row['id_member_to']) ? $txt['guest_title'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member_to'] . '">' . $row['to_name'] . '</a>'; |
|
| 1680 | + } |
|
| 1612 | 1681 | |
| 1613 | 1682 | if ($row['id_member_to'] == $user_info['id'] && $context['folder'] != 'sent') |
| 1614 | 1683 | { |
@@ -1629,12 +1698,14 @@ discard block |
||
| 1629 | 1698 | while($row2 = $smcFunc['db_fetch_assoc']($request2)) |
| 1630 | 1699 | { |
| 1631 | 1700 | $l_id = $row2['id_label']; |
| 1632 | - if (isset($context['labels'][$l_id])) |
|
| 1633 | - $context['message_labels'][$row['id_pm']][$l_id] = array('id' => $l_id, 'name' => $context['labels'][$l_id]['name']); |
|
| 1701 | + if (isset($context['labels'][$l_id])) { |
|
| 1702 | + $context['message_labels'][$row['id_pm']][$l_id] = array('id' => $l_id, 'name' => $context['labels'][$l_id]['name']); |
|
| 1703 | + } |
|
| 1634 | 1704 | |
| 1635 | 1705 | // Here we find the first label on a message - for linking to posts in results |
| 1636 | - if (!isset($context['first_label'][$row['id_pm']]) && $row['in_inbox'] != 1) |
|
| 1637 | - $context['first_label'][$row['id_pm']] = $l_id; |
|
| 1706 | + if (!isset($context['first_label'][$row['id_pm']]) && $row['in_inbox'] != 1) { |
|
| 1707 | + $context['first_label'][$row['id_pm']] = $l_id; |
|
| 1708 | + } |
|
| 1638 | 1709 | } |
| 1639 | 1710 | |
| 1640 | 1711 | $smcFunc['db_free_result']($request2); |
@@ -1761,8 +1832,9 @@ discard block |
||
| 1761 | 1832 | list ($postCount) = $smcFunc['db_fetch_row']($request); |
| 1762 | 1833 | $smcFunc['db_free_result']($request); |
| 1763 | 1834 | |
| 1764 | - if (!empty($postCount) && $postCount >= $modSettings['pm_posts_per_hour']) |
|
| 1765 | - fatal_lang_error('pm_too_many_per_hour', true, array($modSettings['pm_posts_per_hour'])); |
|
| 1835 | + if (!empty($postCount) && $postCount >= $modSettings['pm_posts_per_hour']) { |
|
| 1836 | + fatal_lang_error('pm_too_many_per_hour', true, array($modSettings['pm_posts_per_hour'])); |
|
| 1837 | + } |
|
| 1766 | 1838 | } |
| 1767 | 1839 | |
| 1768 | 1840 | // Quoting/Replying to a message? |
@@ -1771,8 +1843,9 @@ discard block |
||
| 1771 | 1843 | $pmsg = (int) $_REQUEST['pmsg']; |
| 1772 | 1844 | |
| 1773 | 1845 | // Make sure this is yours. |
| 1774 | - if (!isAccessiblePM($pmsg)) |
|
| 1775 | - fatal_lang_error('no_access', false); |
|
| 1846 | + if (!isAccessiblePM($pmsg)) { |
|
| 1847 | + fatal_lang_error('no_access', false); |
|
| 1848 | + } |
|
| 1776 | 1849 | |
| 1777 | 1850 | // Work out whether this is one you've received? |
| 1778 | 1851 | $request = $smcFunc['db_query']('', ' |
@@ -1809,8 +1882,9 @@ discard block |
||
| 1809 | 1882 | 'id_pm' => $pmsg, |
| 1810 | 1883 | ) |
| 1811 | 1884 | ); |
| 1812 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1813 | - fatal_lang_error('pm_not_yours', false); |
|
| 1885 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1886 | + fatal_lang_error('pm_not_yours', false); |
|
| 1887 | + } |
|
| 1814 | 1888 | $row_quoted = $smcFunc['db_fetch_assoc']($request); |
| 1815 | 1889 | $smcFunc['db_free_result']($request); |
| 1816 | 1890 | |
@@ -1821,9 +1895,9 @@ discard block |
||
| 1821 | 1895 | // Add 'Re: ' to it.... |
| 1822 | 1896 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
| 1823 | 1897 | { |
| 1824 | - if ($language === $user_info['language']) |
|
| 1825 | - $context['response_prefix'] = $txt['response_prefix']; |
|
| 1826 | - else |
|
| 1898 | + if ($language === $user_info['language']) { |
|
| 1899 | + $context['response_prefix'] = $txt['response_prefix']; |
|
| 1900 | + } else |
|
| 1827 | 1901 | { |
| 1828 | 1902 | loadLanguage('index', $language, false); |
| 1829 | 1903 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -1832,22 +1906,25 @@ discard block |
||
| 1832 | 1906 | cache_put_data('response_prefix', $context['response_prefix'], 600); |
| 1833 | 1907 | } |
| 1834 | 1908 | $form_subject = $row_quoted['subject']; |
| 1835 | - if ($context['reply'] && trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) |
|
| 1836 | - $form_subject = $context['response_prefix'] . $form_subject; |
|
| 1909 | + if ($context['reply'] && trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
| 1910 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
| 1911 | + } |
|
| 1837 | 1912 | |
| 1838 | 1913 | if (isset($_REQUEST['quote'])) |
| 1839 | 1914 | { |
| 1840 | 1915 | // Remove any nested quotes and <br>... |
| 1841 | 1916 | $form_message = preg_replace('~<br ?/?' . '>~i', "\n", $row_quoted['body']); |
| 1842 | - if (!empty($modSettings['removeNestedQuotes'])) |
|
| 1843 | - $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
| 1844 | - if (empty($row_quoted['id_member'])) |
|
| 1845 | - $form_message = '[quote author="' . $row_quoted['real_name'] . '"]' . "\n" . $form_message . "\n" . '[/quote]'; |
|
| 1846 | - else |
|
| 1847 | - $form_message = '[quote author=' . $row_quoted['real_name'] . ' link=action=profile;u=' . $row_quoted['id_member'] . ' date=' . $row_quoted['msgtime'] . ']' . "\n" . $form_message . "\n" . '[/quote]'; |
|
| 1917 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
| 1918 | + $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
| 1919 | + } |
|
| 1920 | + if (empty($row_quoted['id_member'])) { |
|
| 1921 | + $form_message = '[quote author="' . $row_quoted['real_name'] . '"]' . "\n" . $form_message . "\n" . '[/quote]'; |
|
| 1922 | + } else { |
|
| 1923 | + $form_message = '[quote author=' . $row_quoted['real_name'] . ' link=action=profile;u=' . $row_quoted['id_member'] . ' date=' . $row_quoted['msgtime'] . ']' . "\n" . $form_message . "\n" . '[/quote]'; |
|
| 1924 | + } |
|
| 1925 | + } else { |
|
| 1926 | + $form_message = ''; |
|
| 1848 | 1927 | } |
| 1849 | - else |
|
| 1850 | - $form_message = ''; |
|
| 1851 | 1928 | |
| 1852 | 1929 | // Do the BBC thang on the message. |
| 1853 | 1930 | $row_quoted['body'] = parse_bbc($row_quoted['body'], true, 'pm' . $row_quoted['id_pm']); |
@@ -1868,8 +1945,7 @@ discard block |
||
| 1868 | 1945 | 'timestamp' => forum_time(true, $row_quoted['msgtime']), |
| 1869 | 1946 | 'body' => $row_quoted['body'] |
| 1870 | 1947 | ); |
| 1871 | - } |
|
| 1872 | - else |
|
| 1948 | + } else |
|
| 1873 | 1949 | { |
| 1874 | 1950 | $context['quoted_message'] = false; |
| 1875 | 1951 | $form_subject = ''; |
@@ -1888,11 +1964,12 @@ discard block |
||
| 1888 | 1964 | if ($_REQUEST['u'] == 'all' && isset($row_quoted)) |
| 1889 | 1965 | { |
| 1890 | 1966 | // Firstly, to reply to all we clearly already have $row_quoted - so have the original member from. |
| 1891 | - if ($row_quoted['id_member'] != $user_info['id']) |
|
| 1892 | - $context['recipients']['to'][] = array( |
|
| 1967 | + if ($row_quoted['id_member'] != $user_info['id']) { |
|
| 1968 | + $context['recipients']['to'][] = array( |
|
| 1893 | 1969 | 'id' => $row_quoted['id_member'], |
| 1894 | 1970 | 'name' => $smcFunc['htmlspecialchars']($row_quoted['real_name']), |
| 1895 | 1971 | ); |
| 1972 | + } |
|
| 1896 | 1973 | |
| 1897 | 1974 | // Now to get the others. |
| 1898 | 1975 | $request = $smcFunc['db_query']('', ' |
@@ -1908,18 +1985,19 @@ discard block |
||
| 1908 | 1985 | 'not_bcc' => 0, |
| 1909 | 1986 | ) |
| 1910 | 1987 | ); |
| 1911 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1912 | - $context['recipients']['to'][] = array( |
|
| 1988 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1989 | + $context['recipients']['to'][] = array( |
|
| 1913 | 1990 | 'id' => $row['id_member'], |
| 1914 | 1991 | 'name' => $row['real_name'], |
| 1915 | 1992 | ); |
| 1993 | + } |
|
| 1916 | 1994 | $smcFunc['db_free_result']($request); |
| 1917 | - } |
|
| 1918 | - else |
|
| 1995 | + } else |
|
| 1919 | 1996 | { |
| 1920 | 1997 | $_REQUEST['u'] = explode(',', $_REQUEST['u']); |
| 1921 | - foreach ($_REQUEST['u'] as $key => $uID) |
|
| 1922 | - $_REQUEST['u'][$key] = (int) $uID; |
|
| 1998 | + foreach ($_REQUEST['u'] as $key => $uID) { |
|
| 1999 | + $_REQUEST['u'][$key] = (int) $uID; |
|
| 2000 | + } |
|
| 1923 | 2001 | |
| 1924 | 2002 | $_REQUEST['u'] = array_unique($_REQUEST['u']); |
| 1925 | 2003 | |
@@ -1933,22 +2011,24 @@ discard block |
||
| 1933 | 2011 | 'limit' => count($_REQUEST['u']), |
| 1934 | 2012 | ) |
| 1935 | 2013 | ); |
| 1936 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1937 | - $context['recipients']['to'][] = array( |
|
| 2014 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2015 | + $context['recipients']['to'][] = array( |
|
| 1938 | 2016 | 'id' => $row['id_member'], |
| 1939 | 2017 | 'name' => $row['real_name'], |
| 1940 | 2018 | ); |
| 2019 | + } |
|
| 1941 | 2020 | $smcFunc['db_free_result']($request); |
| 1942 | 2021 | } |
| 1943 | 2022 | |
| 1944 | 2023 | // Get a literal name list in case the user has JavaScript disabled. |
| 1945 | 2024 | $names = array(); |
| 1946 | - foreach ($context['recipients']['to'] as $to) |
|
| 1947 | - $names[] = $to['name']; |
|
| 2025 | + foreach ($context['recipients']['to'] as $to) { |
|
| 2026 | + $names[] = $to['name']; |
|
| 2027 | + } |
|
| 1948 | 2028 | $context['to_value'] = empty($names) ? '' : '"' . implode('", "', $names) . '"'; |
| 2029 | + } else { |
|
| 2030 | + $context['to_value'] = ''; |
|
| 1949 | 2031 | } |
| 1950 | - else |
|
| 1951 | - $context['to_value'] = ''; |
|
| 1952 | 2032 | |
| 1953 | 2033 | // Set the defaults... |
| 1954 | 2034 | $context['subject'] = $form_subject; |
@@ -2018,8 +2098,9 @@ discard block |
||
| 2018 | 2098 | |
| 2019 | 2099 | // validate with loadMemberData() |
| 2020 | 2100 | $memberResult = loadMemberData($user_info['id'], false); |
| 2021 | - if (!$memberResult) |
|
| 2022 | - fatal_lang_error('not_a_user', false); |
|
| 2101 | + if (!$memberResult) { |
|
| 2102 | + fatal_lang_error('not_a_user', false); |
|
| 2103 | + } |
|
| 2023 | 2104 | list ($memID) = $memberResult; |
| 2024 | 2105 | |
| 2025 | 2106 | // drafts is where the functions reside |
@@ -2045,9 +2126,9 @@ discard block |
||
| 2045 | 2126 | $context['sub_template'] = 'send'; |
| 2046 | 2127 | loadJavaScriptFile('PersonalMessage.js', array('defer' => false), 'smf_pms'); |
| 2047 | 2128 | loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest'); |
| 2129 | + } else { |
|
| 2130 | + $context['sub_template'] = 'pm'; |
|
| 2048 | 2131 | } |
| 2049 | - else |
|
| 2050 | - $context['sub_template'] = 'pm'; |
|
| 2051 | 2132 | |
| 2052 | 2133 | $context['page_title'] = $txt['send_message']; |
| 2053 | 2134 | |
@@ -2108,10 +2189,11 @@ discard block |
||
| 2108 | 2189 | ); |
| 2109 | 2190 | if ($smcFunc['db_num_rows']($request) == 0) |
| 2110 | 2191 | { |
| 2111 | - if (!isset($_REQUEST['xml'])) |
|
| 2112 | - fatal_lang_error('pm_not_yours', false); |
|
| 2113 | - else |
|
| 2114 | - $error_types[] = 'pm_not_yours'; |
|
| 2192 | + if (!isset($_REQUEST['xml'])) { |
|
| 2193 | + fatal_lang_error('pm_not_yours', false); |
|
| 2194 | + } else { |
|
| 2195 | + $error_types[] = 'pm_not_yours'; |
|
| 2196 | + } |
|
| 2115 | 2197 | } |
| 2116 | 2198 | $row_quoted = $smcFunc['db_fetch_assoc']($request); |
| 2117 | 2199 | $smcFunc['db_free_result']($request); |
@@ -2158,14 +2240,16 @@ discard block |
||
| 2158 | 2240 | $context['post_error'][$error_type] = true; |
| 2159 | 2241 | if (isset($txt['error_' . $error_type])) |
| 2160 | 2242 | { |
| 2161 | - if ($error_type == 'long_message') |
|
| 2162 | - $txt['error_' . $error_type] = sprintf($txt['error_' . $error_type], $modSettings['max_messageLength']); |
|
| 2243 | + if ($error_type == 'long_message') { |
|
| 2244 | + $txt['error_' . $error_type] = sprintf($txt['error_' . $error_type], $modSettings['max_messageLength']); |
|
| 2245 | + } |
|
| 2163 | 2246 | $context['post_error']['messages'][] = $txt['error_' . $error_type]; |
| 2164 | 2247 | } |
| 2165 | 2248 | |
| 2166 | 2249 | // If it's not a minor error flag it as such. |
| 2167 | - if (!in_array($error_type, array('new_reply', 'not_approved', 'new_replies', 'old_topic', 'need_qr_verification', 'no_subject'))) |
|
| 2168 | - $context['error_type'] = 'serious'; |
|
| 2250 | + if (!in_array($error_type, array('new_reply', 'not_approved', 'new_replies', 'old_topic', 'need_qr_verification', 'no_subject'))) { |
|
| 2251 | + $context['error_type'] = 'serious'; |
|
| 2252 | + } |
|
| 2169 | 2253 | } |
| 2170 | 2254 | |
| 2171 | 2255 | // We need to load the editor once more. |
@@ -2223,8 +2307,9 @@ discard block |
||
| 2223 | 2307 | require_once($sourcedir . '/Subs-Auth.php'); |
| 2224 | 2308 | |
| 2225 | 2309 | // PM Drafts enabled and needed? |
| 2226 | - if ($context['drafts_pm_save'] && (isset($_POST['save_draft']) || isset($_POST['id_pm_draft']))) |
|
| 2227 | - require_once($sourcedir . '/Drafts.php'); |
|
| 2310 | + if ($context['drafts_pm_save'] && (isset($_POST['save_draft']) || isset($_POST['id_pm_draft']))) { |
|
| 2311 | + require_once($sourcedir . '/Drafts.php'); |
|
| 2312 | + } |
|
| 2228 | 2313 | |
| 2229 | 2314 | loadLanguage('PersonalMessage', '', false); |
| 2230 | 2315 | |
@@ -2254,24 +2339,27 @@ discard block |
||
| 2254 | 2339 | |
| 2255 | 2340 | if (!empty($postCount) && $postCount >= $modSettings['pm_posts_per_hour']) |
| 2256 | 2341 | { |
| 2257 | - if (!isset($_REQUEST['xml'])) |
|
| 2258 | - fatal_lang_error('pm_too_many_per_hour', true, array($modSettings['pm_posts_per_hour'])); |
|
| 2259 | - else |
|
| 2260 | - $post_errors[] = 'pm_too_many_per_hour'; |
|
| 2342 | + if (!isset($_REQUEST['xml'])) { |
|
| 2343 | + fatal_lang_error('pm_too_many_per_hour', true, array($modSettings['pm_posts_per_hour'])); |
|
| 2344 | + } else { |
|
| 2345 | + $post_errors[] = 'pm_too_many_per_hour'; |
|
| 2346 | + } |
|
| 2261 | 2347 | } |
| 2262 | 2348 | } |
| 2263 | 2349 | |
| 2264 | 2350 | // If your session timed out, show an error, but do allow to re-submit. |
| 2265 | - if (!isset($_REQUEST['xml']) && checkSession('post', '', false) != '') |
|
| 2266 | - $post_errors[] = 'session_timeout'; |
|
| 2351 | + if (!isset($_REQUEST['xml']) && checkSession('post', '', false) != '') { |
|
| 2352 | + $post_errors[] = 'session_timeout'; |
|
| 2353 | + } |
|
| 2267 | 2354 | |
| 2268 | 2355 | $_REQUEST['subject'] = isset($_REQUEST['subject']) ? trim($_REQUEST['subject']) : ''; |
| 2269 | 2356 | $_REQUEST['to'] = empty($_POST['to']) ? (empty($_GET['to']) ? '' : $_GET['to']) : $_POST['to']; |
| 2270 | 2357 | $_REQUEST['bcc'] = empty($_POST['bcc']) ? (empty($_GET['bcc']) ? '' : $_GET['bcc']) : $_POST['bcc']; |
| 2271 | 2358 | |
| 2272 | 2359 | // Route the input from the 'u' parameter to the 'to'-list. |
| 2273 | - if (!empty($_POST['u'])) |
|
| 2274 | - $_POST['recipient_to'] = explode(',', $_POST['u']); |
|
| 2360 | + if (!empty($_POST['u'])) { |
|
| 2361 | + $_POST['recipient_to'] = explode(',', $_POST['u']); |
|
| 2362 | + } |
|
| 2275 | 2363 | |
| 2276 | 2364 | // Construct the list of recipients. |
| 2277 | 2365 | $recipientList = array(); |
@@ -2283,8 +2371,9 @@ discard block |
||
| 2283 | 2371 | $recipientList[$recipientType] = array(); |
| 2284 | 2372 | if (!empty($_POST['recipient_' . $recipientType]) && is_array($_POST['recipient_' . $recipientType])) |
| 2285 | 2373 | { |
| 2286 | - foreach ($_POST['recipient_' . $recipientType] as $recipient) |
|
| 2287 | - $recipientList[$recipientType][] = (int) $recipient; |
|
| 2374 | + foreach ($_POST['recipient_' . $recipientType] as $recipient) { |
|
| 2375 | + $recipientList[$recipientType][] = (int) $recipient; |
|
| 2376 | + } |
|
| 2288 | 2377 | } |
| 2289 | 2378 | |
| 2290 | 2379 | // Are there also literal names set? |
@@ -2298,10 +2387,11 @@ discard block |
||
| 2298 | 2387 | |
| 2299 | 2388 | foreach ($namedRecipientList[$recipientType] as $index => $recipient) |
| 2300 | 2389 | { |
| 2301 | - if (strlen(trim($recipient)) > 0) |
|
| 2302 | - $namedRecipientList[$recipientType][$index] = $smcFunc['htmlspecialchars']($smcFunc['strtolower'](trim($recipient))); |
|
| 2303 | - else |
|
| 2304 | - unset($namedRecipientList[$recipientType][$index]); |
|
| 2390 | + if (strlen(trim($recipient)) > 0) { |
|
| 2391 | + $namedRecipientList[$recipientType][$index] = $smcFunc['htmlspecialchars']($smcFunc['strtolower'](trim($recipient))); |
|
| 2392 | + } else { |
|
| 2393 | + unset($namedRecipientList[$recipientType][$index]); |
|
| 2394 | + } |
|
| 2305 | 2395 | } |
| 2306 | 2396 | |
| 2307 | 2397 | if (!empty($namedRecipientList[$recipientType])) |
@@ -2331,8 +2421,9 @@ discard block |
||
| 2331 | 2421 | } |
| 2332 | 2422 | |
| 2333 | 2423 | // Selected a recipient to be deleted? Remove them now. |
| 2334 | - if (!empty($_POST['delete_recipient'])) |
|
| 2335 | - $recipientList[$recipientType] = array_diff($recipientList[$recipientType], array((int) $_POST['delete_recipient'])); |
|
| 2424 | + if (!empty($_POST['delete_recipient'])) { |
|
| 2425 | + $recipientList[$recipientType] = array_diff($recipientList[$recipientType], array((int) $_POST['delete_recipient'])); |
|
| 2426 | + } |
|
| 2336 | 2427 | |
| 2337 | 2428 | // Make sure we don't include the same name twice |
| 2338 | 2429 | $recipientList[$recipientType] = array_unique($recipientList[$recipientType]); |
@@ -2342,8 +2433,9 @@ discard block |
||
| 2342 | 2433 | $is_recipient_change = !empty($_POST['delete_recipient']) || !empty($_POST['to_submit']) || !empty($_POST['bcc_submit']); |
| 2343 | 2434 | |
| 2344 | 2435 | // Check if there's at least one recipient. |
| 2345 | - if (empty($recipientList['to']) && empty($recipientList['bcc'])) |
|
| 2346 | - $post_errors[] = 'no_to'; |
|
| 2436 | + if (empty($recipientList['to']) && empty($recipientList['bcc'])) { |
|
| 2437 | + $post_errors[] = 'no_to'; |
|
| 2438 | + } |
|
| 2347 | 2439 | |
| 2348 | 2440 | // Make sure that we remove the members who did get it from the screen. |
| 2349 | 2441 | if (!$is_recipient_change) |
@@ -2357,28 +2449,31 @@ discard block |
||
| 2357 | 2449 | // Since we already have a post error, remove the previous one. |
| 2358 | 2450 | $post_errors = array_diff($post_errors, array('no_to')); |
| 2359 | 2451 | |
| 2360 | - foreach ($namesNotFound[$recipientType] as $name) |
|
| 2361 | - $context['send_log']['failed'][] = sprintf($txt['pm_error_user_not_found'], $name); |
|
| 2452 | + foreach ($namesNotFound[$recipientType] as $name) { |
|
| 2453 | + $context['send_log']['failed'][] = sprintf($txt['pm_error_user_not_found'], $name); |
|
| 2454 | + } |
|
| 2362 | 2455 | } |
| 2363 | 2456 | } |
| 2364 | 2457 | } |
| 2365 | 2458 | |
| 2366 | 2459 | // Did they make any mistakes? |
| 2367 | - if ($_REQUEST['subject'] == '') |
|
| 2368 | - $post_errors[] = 'no_subject'; |
|
| 2369 | - if (!isset($_REQUEST['message']) || $_REQUEST['message'] == '') |
|
| 2370 | - $post_errors[] = 'no_message'; |
|
| 2371 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_REQUEST['message']) > $modSettings['max_messageLength']) |
|
| 2372 | - $post_errors[] = 'long_message'; |
|
| 2373 | - else |
|
| 2460 | + if ($_REQUEST['subject'] == '') { |
|
| 2461 | + $post_errors[] = 'no_subject'; |
|
| 2462 | + } |
|
| 2463 | + if (!isset($_REQUEST['message']) || $_REQUEST['message'] == '') { |
|
| 2464 | + $post_errors[] = 'no_message'; |
|
| 2465 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_REQUEST['message']) > $modSettings['max_messageLength']) { |
|
| 2466 | + $post_errors[] = 'long_message'; |
|
| 2467 | + } else |
|
| 2374 | 2468 | { |
| 2375 | 2469 | // Preparse the message. |
| 2376 | 2470 | $message = $_REQUEST['message']; |
| 2377 | 2471 | preparsecode($message); |
| 2378 | 2472 | |
| 2379 | 2473 | // Make sure there's still some content left without the tags. |
| 2380 | - if ($smcFunc['htmltrim'](strip_tags(parse_bbc($smcFunc['htmlspecialchars']($message, ENT_QUOTES), false), '<img>')) === '' && (!allowedTo('admin_forum') || strpos($message, '[html]') === false)) |
|
| 2381 | - $post_errors[] = 'no_message'; |
|
| 2474 | + if ($smcFunc['htmltrim'](strip_tags(parse_bbc($smcFunc['htmlspecialchars']($message, ENT_QUOTES), false), '<img>')) === '' && (!allowedTo('admin_forum') || strpos($message, '[html]') === false)) { |
|
| 2475 | + $post_errors[] = 'no_message'; |
|
| 2476 | + } |
|
| 2382 | 2477 | } |
| 2383 | 2478 | |
| 2384 | 2479 | // Wrong verification code? |
@@ -2390,13 +2485,15 @@ discard block |
||
| 2390 | 2485 | ); |
| 2391 | 2486 | $context['require_verification'] = create_control_verification($verificationOptions, true); |
| 2392 | 2487 | |
| 2393 | - if (is_array($context['require_verification'])) |
|
| 2394 | - $post_errors = array_merge($post_errors, $context['require_verification']); |
|
| 2488 | + if (is_array($context['require_verification'])) { |
|
| 2489 | + $post_errors = array_merge($post_errors, $context['require_verification']); |
|
| 2490 | + } |
|
| 2395 | 2491 | } |
| 2396 | 2492 | |
| 2397 | 2493 | // If they did, give a chance to make ammends. |
| 2398 | - if (!empty($post_errors) && !$is_recipient_change && !isset($_REQUEST['preview']) && !isset($_REQUEST['xml'])) |
|
| 2399 | - return messagePostError($post_errors, $namedRecipientList, $recipientList); |
|
| 2494 | + if (!empty($post_errors) && !$is_recipient_change && !isset($_REQUEST['preview']) && !isset($_REQUEST['xml'])) { |
|
| 2495 | + return messagePostError($post_errors, $namedRecipientList, $recipientList); |
|
| 2496 | + } |
|
| 2400 | 2497 | |
| 2401 | 2498 | // Want to take a second glance before you send? |
| 2402 | 2499 | if (isset($_REQUEST['preview'])) |
@@ -2427,8 +2524,9 @@ discard block |
||
| 2427 | 2524 | foreach ($namesNotFound as $recipientType => $names) |
| 2428 | 2525 | { |
| 2429 | 2526 | $post_errors[] = 'bad_' . $recipientType; |
| 2430 | - foreach ($names as $name) |
|
| 2431 | - $context['send_log']['failed'][] = sprintf($txt['pm_error_user_not_found'], $name); |
|
| 2527 | + foreach ($names as $name) { |
|
| 2528 | + $context['send_log']['failed'][] = sprintf($txt['pm_error_user_not_found'], $name); |
|
| 2529 | + } |
|
| 2432 | 2530 | } |
| 2433 | 2531 | |
| 2434 | 2532 | return messagePostError(array(), $namedRecipientList, $recipientList); |
@@ -2458,13 +2556,14 @@ discard block |
||
| 2458 | 2556 | checkSubmitOnce('check'); |
| 2459 | 2557 | |
| 2460 | 2558 | // Do the actual sending of the PM. |
| 2461 | - if (!empty($recipientList['to']) || !empty($recipientList['bcc'])) |
|
| 2462 | - $context['send_log'] = sendpm($recipientList, $_REQUEST['subject'], $_REQUEST['message'], true, null, !empty($_REQUEST['pm_head']) ? (int) $_REQUEST['pm_head'] : 0); |
|
| 2463 | - else |
|
| 2464 | - $context['send_log'] = array( |
|
| 2559 | + if (!empty($recipientList['to']) || !empty($recipientList['bcc'])) { |
|
| 2560 | + $context['send_log'] = sendpm($recipientList, $_REQUEST['subject'], $_REQUEST['message'], true, null, !empty($_REQUEST['pm_head']) ? (int) $_REQUEST['pm_head'] : 0); |
|
| 2561 | + } else { |
|
| 2562 | + $context['send_log'] = array( |
|
| 2465 | 2563 | 'sent' => array(), |
| 2466 | 2564 | 'failed' => array() |
| 2467 | 2565 | ); |
| 2566 | + } |
|
| 2468 | 2567 | |
| 2469 | 2568 | // Mark the message as "replied to". |
| 2470 | 2569 | if (!empty($context['send_log']['sent']) && !empty($_REQUEST['replied_to']) && isset($_REQUEST['f']) && $_REQUEST['f'] == 'inbox') |
@@ -2482,11 +2581,12 @@ discard block |
||
| 2482 | 2581 | } |
| 2483 | 2582 | |
| 2484 | 2583 | // If one or more of the recipient were invalid, go back to the post screen with the failed usernames. |
| 2485 | - if (!empty($context['send_log']['failed'])) |
|
| 2486 | - return messagePostError($post_errors, $namesNotFound, array( |
|
| 2584 | + if (!empty($context['send_log']['failed'])) { |
|
| 2585 | + return messagePostError($post_errors, $namesNotFound, array( |
|
| 2487 | 2586 | 'to' => array_intersect($recipientList['to'], $context['send_log']['failed']), |
| 2488 | 2587 | 'bcc' => array_intersect($recipientList['bcc'], $context['send_log']['failed']) |
| 2489 | 2588 | )); |
| 2589 | + } |
|
| 2490 | 2590 | |
| 2491 | 2591 | // Message sent successfully? |
| 2492 | 2592 | if (!empty($context['send_log']) && empty($context['send_log']['failed'])) |
@@ -2494,8 +2594,9 @@ discard block |
||
| 2494 | 2594 | $context['current_label_redirect'] = $context['current_label_redirect'] . ';done=sent'; |
| 2495 | 2595 | |
| 2496 | 2596 | // If we had a PM draft for this one, then its time to remove it since it was just sent |
| 2497 | - if ($context['drafts_pm_save'] && !empty($_POST['id_pm_draft'])) |
|
| 2498 | - DeleteDraft($_POST['id_pm_draft']); |
|
| 2597 | + if ($context['drafts_pm_save'] && !empty($_POST['id_pm_draft'])) { |
|
| 2598 | + DeleteDraft($_POST['id_pm_draft']); |
|
| 2599 | + } |
|
| 2499 | 2600 | } |
| 2500 | 2601 | |
| 2501 | 2602 | // Go back to the where they sent from, if possible... |
@@ -2510,24 +2611,28 @@ discard block |
||
| 2510 | 2611 | |
| 2511 | 2612 | checkSession('request'); |
| 2512 | 2613 | |
| 2513 | - if (isset($_REQUEST['del_selected'])) |
|
| 2514 | - $_REQUEST['pm_action'] = 'delete'; |
|
| 2614 | + if (isset($_REQUEST['del_selected'])) { |
|
| 2615 | + $_REQUEST['pm_action'] = 'delete'; |
|
| 2616 | + } |
|
| 2515 | 2617 | |
| 2516 | 2618 | if (isset($_REQUEST['pm_action']) && $_REQUEST['pm_action'] != '' && !empty($_REQUEST['pms']) && is_array($_REQUEST['pms'])) |
| 2517 | 2619 | { |
| 2518 | - foreach ($_REQUEST['pms'] as $pm) |
|
| 2519 | - $_REQUEST['pm_actions'][(int) $pm] = $_REQUEST['pm_action']; |
|
| 2620 | + foreach ($_REQUEST['pms'] as $pm) { |
|
| 2621 | + $_REQUEST['pm_actions'][(int) $pm] = $_REQUEST['pm_action']; |
|
| 2622 | + } |
|
| 2520 | 2623 | } |
| 2521 | 2624 | |
| 2522 | - if (empty($_REQUEST['pm_actions'])) |
|
| 2523 | - redirectexit($context['current_label_redirect']); |
|
| 2625 | + if (empty($_REQUEST['pm_actions'])) { |
|
| 2626 | + redirectexit($context['current_label_redirect']); |
|
| 2627 | + } |
|
| 2524 | 2628 | |
| 2525 | 2629 | // If we are in conversation, we may need to apply this to every message in the conversation. |
| 2526 | 2630 | if ($context['display_mode'] == 2 && isset($_REQUEST['conversation'])) |
| 2527 | 2631 | { |
| 2528 | 2632 | $id_pms = array(); |
| 2529 | - foreach ($_REQUEST['pm_actions'] as $pm => $dummy) |
|
| 2530 | - $id_pms[] = (int) $pm; |
|
| 2633 | + foreach ($_REQUEST['pm_actions'] as $pm => $dummy) { |
|
| 2634 | + $id_pms[] = (int) $pm; |
|
| 2635 | + } |
|
| 2531 | 2636 | |
| 2532 | 2637 | $request = $smcFunc['db_query']('', ' |
| 2533 | 2638 | SELECT id_pm_head, id_pm |
@@ -2538,8 +2643,9 @@ discard block |
||
| 2538 | 2643 | ) |
| 2539 | 2644 | ); |
| 2540 | 2645 | $pm_heads = array(); |
| 2541 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2542 | - $pm_heads[$row['id_pm_head']] = $row['id_pm']; |
|
| 2646 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2647 | + $pm_heads[$row['id_pm_head']] = $row['id_pm']; |
|
| 2648 | + } |
|
| 2543 | 2649 | $smcFunc['db_free_result']($request); |
| 2544 | 2650 | |
| 2545 | 2651 | $request = $smcFunc['db_query']('', ' |
@@ -2553,8 +2659,9 @@ discard block |
||
| 2553 | 2659 | // Copy the action from the single to PM to the others. |
| 2554 | 2660 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2555 | 2661 | { |
| 2556 | - if (isset($pm_heads[$row['id_pm_head']]) && isset($_REQUEST['pm_actions'][$pm_heads[$row['id_pm_head']]])) |
|
| 2557 | - $_REQUEST['pm_actions'][$row['id_pm']] = $_REQUEST['pm_actions'][$pm_heads[$row['id_pm_head']]]; |
|
| 2662 | + if (isset($pm_heads[$row['id_pm_head']]) && isset($_REQUEST['pm_actions'][$pm_heads[$row['id_pm_head']]])) { |
|
| 2663 | + $_REQUEST['pm_actions'][$row['id_pm']] = $_REQUEST['pm_actions'][$pm_heads[$row['id_pm_head']]]; |
|
| 2664 | + } |
|
| 2558 | 2665 | } |
| 2559 | 2666 | $smcFunc['db_free_result']($request); |
| 2560 | 2667 | } |
@@ -2566,22 +2673,21 @@ discard block |
||
| 2566 | 2673 | $labels = array(); |
| 2567 | 2674 | foreach ($_REQUEST['pm_actions'] as $pm => $action) |
| 2568 | 2675 | { |
| 2569 | - if ($action === 'delete') |
|
| 2570 | - $to_delete[] = (int) $pm; |
|
| 2571 | - else |
|
| 2676 | + if ($action === 'delete') { |
|
| 2677 | + $to_delete[] = (int) $pm; |
|
| 2678 | + } else |
|
| 2572 | 2679 | { |
| 2573 | 2680 | if (substr($action, 0, 4) == 'add_') |
| 2574 | 2681 | { |
| 2575 | 2682 | $type = 'add'; |
| 2576 | 2683 | $action = substr($action, 4); |
| 2577 | - } |
|
| 2578 | - elseif (substr($action, 0, 4) == 'rem_') |
|
| 2684 | + } elseif (substr($action, 0, 4) == 'rem_') |
|
| 2579 | 2685 | { |
| 2580 | 2686 | $type = 'rem'; |
| 2581 | 2687 | $action = substr($action, 4); |
| 2688 | + } else { |
|
| 2689 | + $type = 'unk'; |
|
| 2582 | 2690 | } |
| 2583 | - else |
|
| 2584 | - $type = 'unk'; |
|
| 2585 | 2691 | |
| 2586 | 2692 | if ($action == '-1' || (int) $action > 0) |
| 2587 | 2693 | { |
@@ -2592,8 +2698,9 @@ discard block |
||
| 2592 | 2698 | } |
| 2593 | 2699 | |
| 2594 | 2700 | // Deleting, it looks like? |
| 2595 | - if (!empty($to_delete)) |
|
| 2596 | - deleteMessages($to_delete, $context['display_mode'] == 2 ? null : $context['folder']); |
|
| 2701 | + if (!empty($to_delete)) { |
|
| 2702 | + deleteMessages($to_delete, $context['display_mode'] == 2 ? null : $context['folder']); |
|
| 2703 | + } |
|
| 2597 | 2704 | |
| 2598 | 2705 | // Are we labeling anything? |
| 2599 | 2706 | if (!empty($to_label) && $context['folder'] == 'inbox') |
@@ -2661,8 +2768,7 @@ discard block |
||
| 2661 | 2768 | } |
| 2662 | 2769 | |
| 2663 | 2770 | $smcFunc['db_free_result']($request2); |
| 2664 | - } |
|
| 2665 | - elseif ($type == 'rem') |
|
| 2771 | + } elseif ($type == 'rem') |
|
| 2666 | 2772 | { |
| 2667 | 2773 | // If we're removing from the inbox, see if we have at least one other label. |
| 2668 | 2774 | // This query is faster than the one above |
@@ -2694,21 +2800,25 @@ discard block |
||
| 2694 | 2800 | if ($to_label[$row['id_pm']] != '-1') |
| 2695 | 2801 | { |
| 2696 | 2802 | // If this label is in the list and we're not adding it, remove it |
| 2697 | - if (array_key_exists($to_label[$row['id_pm']], $labels) && $type !== 'add') |
|
| 2698 | - unset($labels[$to_label[$row['id_pm']]]); |
|
| 2699 | - else if ($type !== 'rem') |
|
| 2700 | - $labels[$to_label[$row['id_pm']]] = $to_label[$row['id_pm']]; |
|
| 2803 | + if (array_key_exists($to_label[$row['id_pm']], $labels) && $type !== 'add') { |
|
| 2804 | + unset($labels[$to_label[$row['id_pm']]]); |
|
| 2805 | + } else if ($type !== 'rem') { |
|
| 2806 | + $labels[$to_label[$row['id_pm']]] = $to_label[$row['id_pm']]; |
|
| 2807 | + } |
|
| 2701 | 2808 | } |
| 2702 | 2809 | |
| 2703 | 2810 | // Removing all labels or just removing the inbox label |
| 2704 | - if ($type == 'rem' && empty($labels)) |
|
| 2705 | - $in_inbox = (empty($context['can_remove_inbox']) ? 1 : 0); |
|
| 2811 | + if ($type == 'rem' && empty($labels)) { |
|
| 2812 | + $in_inbox = (empty($context['can_remove_inbox']) ? 1 : 0); |
|
| 2813 | + } |
|
| 2706 | 2814 | // Adding new labels, but removing inbox and applying new ones |
| 2707 | - elseif ($type == 'add' && !empty($options['pm_remove_inbox_label']) && !empty($labels)) |
|
| 2708 | - $in_inbox = 0; |
|
| 2815 | + elseif ($type == 'add' && !empty($options['pm_remove_inbox_label']) && !empty($labels)) { |
|
| 2816 | + $in_inbox = 0; |
|
| 2817 | + } |
|
| 2709 | 2818 | // Just adding it to the inbox |
| 2710 | - else |
|
| 2711 | - $in_inbox = 1; |
|
| 2819 | + else { |
|
| 2820 | + $in_inbox = 1; |
|
| 2821 | + } |
|
| 2712 | 2822 | |
| 2713 | 2823 | // Are we adding it to or removing it from the inbox? |
| 2714 | 2824 | if ($in_inbox != $row['in_inbox']) |
@@ -2750,8 +2860,9 @@ discard block |
||
| 2750 | 2860 | if (!empty($labels_to_apply)) |
| 2751 | 2861 | { |
| 2752 | 2862 | $inserts = array(); |
| 2753 | - foreach ($labels_to_apply as $label) |
|
| 2754 | - $inserts[] = array($row['id_pm'], $label); |
|
| 2863 | + foreach ($labels_to_apply as $label) { |
|
| 2864 | + $inserts[] = array($row['id_pm'], $label); |
|
| 2865 | + } |
|
| 2755 | 2866 | |
| 2756 | 2867 | $smcFunc['db_insert']('', |
| 2757 | 2868 | '{db_prefix}pm_labeled_messages', |
@@ -2795,11 +2906,13 @@ discard block |
||
| 2795 | 2906 | checkSession('get'); |
| 2796 | 2907 | |
| 2797 | 2908 | // If all then delete all messages the user has. |
| 2798 | - if ($_REQUEST['f'] == 'all') |
|
| 2799 | - deleteMessages(null, null); |
|
| 2909 | + if ($_REQUEST['f'] == 'all') { |
|
| 2910 | + deleteMessages(null, null); |
|
| 2911 | + } |
|
| 2800 | 2912 | // Otherwise just the selected folder. |
| 2801 | - else |
|
| 2802 | - deleteMessages(null, $_REQUEST['f'] != 'sent' ? 'inbox' : 'sent'); |
|
| 2913 | + else { |
|
| 2914 | + deleteMessages(null, $_REQUEST['f'] != 'sent' ? 'inbox' : 'sent'); |
|
| 2915 | + } |
|
| 2803 | 2916 | |
| 2804 | 2917 | // Done... all gone. |
| 2805 | 2918 | redirectexit($context['current_label_redirect']); |
@@ -2836,8 +2949,9 @@ discard block |
||
| 2836 | 2949 | 'msgtime' => $deleteTime, |
| 2837 | 2950 | ) |
| 2838 | 2951 | ); |
| 2839 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 2840 | - $toDelete[] = $row[0]; |
|
| 2952 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 2953 | + $toDelete[] = $row[0]; |
|
| 2954 | + } |
|
| 2841 | 2955 | $smcFunc['db_free_result']($request); |
| 2842 | 2956 | |
| 2843 | 2957 | // Select all messages in their inbox older than $deleteTime. |
@@ -2854,8 +2968,9 @@ discard block |
||
| 2854 | 2968 | 'msgtime' => $deleteTime, |
| 2855 | 2969 | ) |
| 2856 | 2970 | ); |
| 2857 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2858 | - $toDelete[] = $row['id_pm']; |
|
| 2971 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2972 | + $toDelete[] = $row['id_pm']; |
|
| 2973 | + } |
|
| 2859 | 2974 | $smcFunc['db_free_result']($request); |
| 2860 | 2975 | |
| 2861 | 2976 | // Delete the actual messages. |
@@ -2886,26 +3001,29 @@ discard block |
||
| 2886 | 3001 | { |
| 2887 | 3002 | global $user_info, $smcFunc; |
| 2888 | 3003 | |
| 2889 | - if ($owner === null) |
|
| 2890 | - $owner = array($user_info['id']); |
|
| 2891 | - elseif (empty($owner)) |
|
| 2892 | - return; |
|
| 2893 | - elseif (!is_array($owner)) |
|
| 2894 | - $owner = array($owner); |
|
| 3004 | + if ($owner === null) { |
|
| 3005 | + $owner = array($user_info['id']); |
|
| 3006 | + } elseif (empty($owner)) { |
|
| 3007 | + return; |
|
| 3008 | + } elseif (!is_array($owner)) { |
|
| 3009 | + $owner = array($owner); |
|
| 3010 | + } |
|
| 2895 | 3011 | |
| 2896 | 3012 | if ($personal_messages !== null) |
| 2897 | 3013 | { |
| 2898 | - if (empty($personal_messages) || !is_array($personal_messages)) |
|
| 2899 | - return; |
|
| 3014 | + if (empty($personal_messages) || !is_array($personal_messages)) { |
|
| 3015 | + return; |
|
| 3016 | + } |
|
| 2900 | 3017 | |
| 2901 | - foreach ($personal_messages as $index => $delete_id) |
|
| 2902 | - $personal_messages[$index] = (int) $delete_id; |
|
| 3018 | + foreach ($personal_messages as $index => $delete_id) { |
|
| 3019 | + $personal_messages[$index] = (int) $delete_id; |
|
| 3020 | + } |
|
| 2903 | 3021 | |
| 2904 | 3022 | $where = ' |
| 2905 | 3023 | AND id_pm IN ({array_int:pm_list})'; |
| 3024 | + } else { |
|
| 3025 | + $where = ''; |
|
| 2906 | 3026 | } |
| 2907 | - else |
|
| 2908 | - $where = ''; |
|
| 2909 | 3027 | |
| 2910 | 3028 | if ($folder == 'sent' || $folder === null) |
| 2911 | 3029 | { |
@@ -2940,17 +3058,19 @@ discard block |
||
| 2940 | 3058 | // ...And update the statistics accordingly - now including unread messages!. |
| 2941 | 3059 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2942 | 3060 | { |
| 2943 | - if ($row['is_read']) |
|
| 2944 | - updateMemberData($row['id_member'], array('instant_messages' => $where == '' ? 0 : 'instant_messages - ' . $row['num_deleted_messages'])); |
|
| 2945 | - else |
|
| 2946 | - updateMemberData($row['id_member'], array('instant_messages' => $where == '' ? 0 : 'instant_messages - ' . $row['num_deleted_messages'], 'unread_messages' => $where == '' ? 0 : 'unread_messages - ' . $row['num_deleted_messages'])); |
|
| 3061 | + if ($row['is_read']) { |
|
| 3062 | + updateMemberData($row['id_member'], array('instant_messages' => $where == '' ? 0 : 'instant_messages - ' . $row['num_deleted_messages'])); |
|
| 3063 | + } else { |
|
| 3064 | + updateMemberData($row['id_member'], array('instant_messages' => $where == '' ? 0 : 'instant_messages - ' . $row['num_deleted_messages'], 'unread_messages' => $where == '' ? 0 : 'unread_messages - ' . $row['num_deleted_messages'])); |
|
| 3065 | + } |
|
| 2947 | 3066 | |
| 2948 | 3067 | // If this is the current member we need to make their message count correct. |
| 2949 | 3068 | if ($user_info['id'] == $row['id_member']) |
| 2950 | 3069 | { |
| 2951 | 3070 | $user_info['messages'] -= $row['num_deleted_messages']; |
| 2952 | - if (!($row['is_read'])) |
|
| 2953 | - $user_info['unread_messages'] -= $row['num_deleted_messages']; |
|
| 3071 | + if (!($row['is_read'])) { |
|
| 3072 | + $user_info['unread_messages'] -= $row['num_deleted_messages']; |
|
| 3073 | + } |
|
| 2954 | 3074 | } |
| 2955 | 3075 | } |
| 2956 | 3076 | $smcFunc['db_free_result']($request); |
@@ -3018,8 +3138,9 @@ discard block |
||
| 3018 | 3138 | ) |
| 3019 | 3139 | ); |
| 3020 | 3140 | $remove_pms = array(); |
| 3021 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 3022 | - $remove_pms[] = $row['sender']; |
|
| 3141 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 3142 | + $remove_pms[] = $row['sender']; |
|
| 3143 | + } |
|
| 3023 | 3144 | $smcFunc['db_free_result']($request); |
| 3024 | 3145 | |
| 3025 | 3146 | if (!empty($remove_pms)) |
@@ -3064,8 +3185,9 @@ discard block |
||
| 3064 | 3185 | { |
| 3065 | 3186 | global $user_info, $context, $smcFunc; |
| 3066 | 3187 | |
| 3067 | - if ($owner === null) |
|
| 3068 | - $owner = $user_info['id']; |
|
| 3188 | + if ($owner === null) { |
|
| 3189 | + $owner = $user_info['id']; |
|
| 3190 | + } |
|
| 3069 | 3191 | |
| 3070 | 3192 | $in_inbox = ''; |
| 3071 | 3193 | |
@@ -3089,8 +3211,7 @@ discard block |
||
| 3089 | 3211 | } |
| 3090 | 3212 | |
| 3091 | 3213 | $smcFunc['db_free_result']($get_messages); |
| 3092 | - } |
|
| 3093 | - elseif ($label = '-1') |
|
| 3214 | + } elseif ($label = '-1') |
|
| 3094 | 3215 | { |
| 3095 | 3216 | // Marking all PMs in your inbox read |
| 3096 | 3217 | $in_inbox = ' |
@@ -3115,8 +3236,9 @@ discard block |
||
| 3115 | 3236 | { |
| 3116 | 3237 | if ($owner == $user_info['id']) |
| 3117 | 3238 | { |
| 3118 | - foreach ($context['labels'] as $label) |
|
| 3119 | - $context['labels'][(int) $label['id']]['unread_messages'] = 0; |
|
| 3239 | + foreach ($context['labels'] as $label) { |
|
| 3240 | + $context['labels'][(int) $label['id']]['unread_messages'] = 0; |
|
| 3241 | + } |
|
| 3120 | 3242 | } |
| 3121 | 3243 | |
| 3122 | 3244 | $result = $smcFunc['db_query']('', ' |
@@ -3136,8 +3258,9 @@ discard block |
||
| 3136 | 3258 | { |
| 3137 | 3259 | $total_unread += $row['num']; |
| 3138 | 3260 | |
| 3139 | - if ($owner != $user_info['id'] || empty($row['id_pm'])) |
|
| 3140 | - continue; |
|
| 3261 | + if ($owner != $user_info['id'] || empty($row['id_pm'])) { |
|
| 3262 | + continue; |
|
| 3263 | + } |
|
| 3141 | 3264 | |
| 3142 | 3265 | $this_labels = array(); |
| 3143 | 3266 | |
@@ -3161,11 +3284,13 @@ discard block |
||
| 3161 | 3284 | |
| 3162 | 3285 | $smcFunc['db_free_result']($result2); |
| 3163 | 3286 | |
| 3164 | - foreach ($this_labels as $this_label) |
|
| 3165 | - $context['labels'][$this_label]['unread_messages'] += $row['num']; |
|
| 3287 | + foreach ($this_labels as $this_label) { |
|
| 3288 | + $context['labels'][$this_label]['unread_messages'] += $row['num']; |
|
| 3289 | + } |
|
| 3166 | 3290 | |
| 3167 | - if ($row['in_inbox'] == 1) |
|
| 3168 | - $context['labels'][-1]['unread_messages'] += $row['num']; |
|
| 3291 | + if ($row['in_inbox'] == 1) { |
|
| 3292 | + $context['labels'][-1]['unread_messages'] += $row['num']; |
|
| 3293 | + } |
|
| 3169 | 3294 | } |
| 3170 | 3295 | $smcFunc['db_free_result']($result); |
| 3171 | 3296 | |
@@ -3174,8 +3299,9 @@ discard block |
||
| 3174 | 3299 | updateMemberData($owner, array('unread_messages' => $total_unread)); |
| 3175 | 3300 | |
| 3176 | 3301 | // If it was for the current member, reflect this in the $user_info array too. |
| 3177 | - if ($owner == $user_info['id']) |
|
| 3178 | - $user_info['unread_messages'] = $total_unread; |
|
| 3302 | + if ($owner == $user_info['id']) { |
|
| 3303 | + $user_info['unread_messages'] = $total_unread; |
|
| 3304 | + } |
|
| 3179 | 3305 | } |
| 3180 | 3306 | } |
| 3181 | 3307 | |
@@ -3203,8 +3329,9 @@ discard block |
||
| 3203 | 3329 | // Add all existing labels to the array to save, slashing them as necessary... |
| 3204 | 3330 | foreach ($context['labels'] as $label) |
| 3205 | 3331 | { |
| 3206 | - if ($label['id'] != -1) |
|
| 3207 | - $the_labels[$label['id']] = $label['name']; |
|
| 3332 | + if ($label['id'] != -1) { |
|
| 3333 | + $the_labels[$label['id']] = $label['name']; |
|
| 3334 | + } |
|
| 3208 | 3335 | } |
| 3209 | 3336 | |
| 3210 | 3337 | if (isset($_POST[$context['session_var']])) |
@@ -3223,8 +3350,9 @@ discard block |
||
| 3223 | 3350 | { |
| 3224 | 3351 | $_POST['label'] = strtr($smcFunc['htmlspecialchars'](trim($_POST['label'])), array(',' => ',')); |
| 3225 | 3352 | |
| 3226 | - if ($smcFunc['strlen']($_POST['label']) > 30) |
|
| 3227 | - $_POST['label'] = $smcFunc['substr']($_POST['label'], 0, 30); |
|
| 3353 | + if ($smcFunc['strlen']($_POST['label']) > 30) { |
|
| 3354 | + $_POST['label'] = $smcFunc['substr']($_POST['label'], 0, 30); |
|
| 3355 | + } |
|
| 3228 | 3356 | if ($_POST['label'] != '') |
| 3229 | 3357 | { |
| 3230 | 3358 | $the_labels[] = $_POST['label']; |
@@ -3245,24 +3373,25 @@ discard block |
||
| 3245 | 3373 | { |
| 3246 | 3374 | foreach ($the_labels as $id => $name) |
| 3247 | 3375 | { |
| 3248 | - if ($id == -1) |
|
| 3249 | - continue; |
|
| 3250 | - elseif (isset($_POST['label_name'][$id])) |
|
| 3376 | + if ($id == -1) { |
|
| 3377 | + continue; |
|
| 3378 | + } elseif (isset($_POST['label_name'][$id])) |
|
| 3251 | 3379 | { |
| 3252 | 3380 | $_POST['label_name'][$id] = trim(strtr($smcFunc['htmlspecialchars']($_POST['label_name'][$id]), array(',' => ','))); |
| 3253 | 3381 | |
| 3254 | - if ($smcFunc['strlen']($_POST['label_name'][$id]) > 30) |
|
| 3255 | - $_POST['label_name'][$id] = $smcFunc['substr']($_POST['label_name'][$id], 0, 30); |
|
| 3382 | + if ($smcFunc['strlen']($_POST['label_name'][$id]) > 30) { |
|
| 3383 | + $_POST['label_name'][$id] = $smcFunc['substr']($_POST['label_name'][$id], 0, 30); |
|
| 3384 | + } |
|
| 3256 | 3385 | if ($_POST['label_name'][$id] != '') |
| 3257 | 3386 | { |
| 3258 | 3387 | // Changing the name of this label? |
| 3259 | - if ($the_labels[$id] != $_POST['label_name'][$id]) |
|
| 3260 | - $label_updates[$id] = $_POST['label_name'][$id]; |
|
| 3388 | + if ($the_labels[$id] != $_POST['label_name'][$id]) { |
|
| 3389 | + $label_updates[$id] = $_POST['label_name'][$id]; |
|
| 3390 | + } |
|
| 3261 | 3391 | |
| 3262 | 3392 | $the_labels[(int) $id] = $_POST['label_name'][$id]; |
| 3263 | 3393 | |
| 3264 | - } |
|
| 3265 | - else |
|
| 3394 | + } else |
|
| 3266 | 3395 | { |
| 3267 | 3396 | unset($the_labels[(int) $id]); |
| 3268 | 3397 | $labels_to_remove[] = $id; |
@@ -3276,8 +3405,9 @@ discard block |
||
| 3276 | 3405 | if (!empty($labels_to_add)) |
| 3277 | 3406 | { |
| 3278 | 3407 | $inserts = array(); |
| 3279 | - foreach ($labels_to_add AS $label) |
|
| 3280 | - $inserts[] = array($user_info['id'], $label); |
|
| 3408 | + foreach ($labels_to_add AS $label) { |
|
| 3409 | + $inserts[] = array($user_info['id'], $label); |
|
| 3410 | + } |
|
| 3281 | 3411 | |
| 3282 | 3412 | $smcFunc['db_insert']('', '{db_prefix}pm_labels', array('id_member' => 'int', 'name' => 'string-30'), $inserts, array()); |
| 3283 | 3413 | } |
@@ -3367,8 +3497,9 @@ discard block |
||
| 3367 | 3497 | // Each action... |
| 3368 | 3498 | foreach ($rule['actions'] as $k2 => $action) |
| 3369 | 3499 | { |
| 3370 | - if ($action['t'] != 'lab' || !in_array($action['v'], $labels_to_remove)) |
|
| 3371 | - continue; |
|
| 3500 | + if ($action['t'] != 'lab' || !in_array($action['v'], $labels_to_remove)) { |
|
| 3501 | + continue; |
|
| 3502 | + } |
|
| 3372 | 3503 | |
| 3373 | 3504 | $rule_changes[] = $rule['id']; |
| 3374 | 3505 | |
@@ -3383,8 +3514,8 @@ discard block |
||
| 3383 | 3514 | { |
| 3384 | 3515 | $rule_changes = array_unique($rule_changes); |
| 3385 | 3516 | // Update/delete as appropriate. |
| 3386 | - foreach ($rule_changes as $k => $id) |
|
| 3387 | - if (!empty($context['rules'][$id]['actions'])) |
|
| 3517 | + foreach ($rule_changes as $k => $id) { |
|
| 3518 | + if (!empty($context['rules'][$id]['actions'])) |
|
| 3388 | 3519 | { |
| 3389 | 3520 | $smcFunc['db_query']('', ' |
| 3390 | 3521 | UPDATE {db_prefix}pm_rules |
@@ -3397,12 +3528,13 @@ discard block |
||
| 3397 | 3528 | 'actions' => json_encode($context['rules'][$id]['actions']), |
| 3398 | 3529 | ) |
| 3399 | 3530 | ); |
| 3531 | + } |
|
| 3400 | 3532 | unset($rule_changes[$k]); |
| 3401 | 3533 | } |
| 3402 | 3534 | |
| 3403 | 3535 | // Anything left here means it's lost all actions... |
| 3404 | - if (!empty($rule_changes)) |
|
| 3405 | - $smcFunc['db_query']('', ' |
|
| 3536 | + if (!empty($rule_changes)) { |
|
| 3537 | + $smcFunc['db_query']('', ' |
|
| 3406 | 3538 | DELETE FROM {db_prefix}pm_rules |
| 3407 | 3539 | WHERE id_rule IN ({array_int:rule_list}) |
| 3408 | 3540 | AND id_member = {int:current_member}', |
@@ -3411,6 +3543,7 @@ discard block |
||
| 3411 | 3543 | 'rule_list' => $rule_changes, |
| 3412 | 3544 | ) |
| 3413 | 3545 | ); |
| 3546 | + } |
|
| 3414 | 3547 | } |
| 3415 | 3548 | |
| 3416 | 3549 | // Make sure we're not caching this! |
@@ -3480,8 +3613,9 @@ discard block |
||
| 3480 | 3613 | // Save the fields. |
| 3481 | 3614 | saveProfileFields(); |
| 3482 | 3615 | |
| 3483 | - if (!empty($profile_vars)) |
|
| 3484 | - updateMemberData($user_info['id'], $profile_vars); |
|
| 3616 | + if (!empty($profile_vars)) { |
|
| 3617 | + updateMemberData($user_info['id'], $profile_vars); |
|
| 3618 | + } |
|
| 3485 | 3619 | } |
| 3486 | 3620 | |
| 3487 | 3621 | setupProfileContext( |
@@ -3506,13 +3640,15 @@ discard block |
||
| 3506 | 3640 | global $user_info, $language, $modSettings, $smcFunc; |
| 3507 | 3641 | |
| 3508 | 3642 | // Check that this feature is even enabled! |
| 3509 | - if (empty($modSettings['enableReportPM']) || empty($_REQUEST['pmsg'])) |
|
| 3510 | - fatal_lang_error('no_access', false); |
|
| 3643 | + if (empty($modSettings['enableReportPM']) || empty($_REQUEST['pmsg'])) { |
|
| 3644 | + fatal_lang_error('no_access', false); |
|
| 3645 | + } |
|
| 3511 | 3646 | |
| 3512 | 3647 | $pmsg = (int) $_REQUEST['pmsg']; |
| 3513 | 3648 | |
| 3514 | - if (!isAccessiblePM($pmsg, 'inbox')) |
|
| 3515 | - fatal_lang_error('no_access', false); |
|
| 3649 | + if (!isAccessiblePM($pmsg, 'inbox')) { |
|
| 3650 | + fatal_lang_error('no_access', false); |
|
| 3651 | + } |
|
| 3516 | 3652 | |
| 3517 | 3653 | $context['pm_id'] = $pmsg; |
| 3518 | 3654 | $context['page_title'] = $txt['pm_report_title']; |
@@ -3534,8 +3670,9 @@ discard block |
||
| 3534 | 3670 | ) |
| 3535 | 3671 | ); |
| 3536 | 3672 | $context['admins'] = array(); |
| 3537 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 3538 | - $context['admins'][$row['id_member']] = $row['real_name']; |
|
| 3673 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 3674 | + $context['admins'][$row['id_member']] = $row['real_name']; |
|
| 3675 | + } |
|
| 3539 | 3676 | $smcFunc['db_free_result']($request); |
| 3540 | 3677 | |
| 3541 | 3678 | // How many admins in total? |
@@ -3564,8 +3701,9 @@ discard block |
||
| 3564 | 3701 | ) |
| 3565 | 3702 | ); |
| 3566 | 3703 | // Can only be a hacker here! |
| 3567 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 3568 | - fatal_lang_error('no_access', false); |
|
| 3704 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 3705 | + fatal_lang_error('no_access', false); |
|
| 3706 | + } |
|
| 3569 | 3707 | list ($subject, $body, $time, $memberFromID, $memberFromName) = $smcFunc['db_fetch_row']($request); |
| 3570 | 3708 | $smcFunc['db_free_result']($request); |
| 3571 | 3709 | |
@@ -3589,15 +3727,17 @@ discard block |
||
| 3589 | 3727 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 3590 | 3728 | { |
| 3591 | 3729 | // If it's hidden still don't reveal their names - privacy after all ;) |
| 3592 | - if ($row['bcc']) |
|
| 3593 | - $hidden_recipients++; |
|
| 3594 | - else |
|
| 3595 | - $recipients[] = '[url=' . $scripturl . '?action=profile;u=' . $row['id_member_to'] . ']' . $row['to_name'] . '[/url]'; |
|
| 3730 | + if ($row['bcc']) { |
|
| 3731 | + $hidden_recipients++; |
|
| 3732 | + } else { |
|
| 3733 | + $recipients[] = '[url=' . $scripturl . '?action=profile;u=' . $row['id_member_to'] . ']' . $row['to_name'] . '[/url]'; |
|
| 3734 | + } |
|
| 3596 | 3735 | } |
| 3597 | 3736 | $smcFunc['db_free_result']($request); |
| 3598 | 3737 | |
| 3599 | - if ($hidden_recipients) |
|
| 3600 | - $recipients[] = sprintf($txt['pm_report_pm_hidden'], $hidden_recipients); |
|
| 3738 | + if ($hidden_recipients) { |
|
| 3739 | + $recipients[] = sprintf($txt['pm_report_pm_hidden'], $hidden_recipients); |
|
| 3740 | + } |
|
| 3601 | 3741 | |
| 3602 | 3742 | // Now let's get out and loop through the admins. |
| 3603 | 3743 | $request = $smcFunc['db_query']('', ' |
@@ -3613,8 +3753,9 @@ discard block |
||
| 3613 | 3753 | ); |
| 3614 | 3754 | |
| 3615 | 3755 | // Maybe we shouldn't advertise this? |
| 3616 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 3617 | - fatal_lang_error('no_access', false); |
|
| 3756 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 3757 | + fatal_lang_error('no_access', false); |
|
| 3758 | + } |
|
| 3618 | 3759 | |
| 3619 | 3760 | $memberFromName = un_htmlspecialchars($memberFromName); |
| 3620 | 3761 | |
@@ -3633,8 +3774,9 @@ discard block |
||
| 3633 | 3774 | // Make the body. |
| 3634 | 3775 | $report_body = str_replace(array('{REPORTER}', '{SENDER}'), array(un_htmlspecialchars($user_info['name']), $memberFromName), $txt['pm_report_pm_user_sent']); |
| 3635 | 3776 | $report_body .= "\n" . '[b]' . $_POST['reason'] . '[/b]' . "\n\n"; |
| 3636 | - if (!empty($recipients)) |
|
| 3637 | - $report_body .= $txt['pm_report_pm_other_recipients'] . ' ' . implode(', ', $recipients) . "\n\n"; |
|
| 3777 | + if (!empty($recipients)) { |
|
| 3778 | + $report_body .= $txt['pm_report_pm_other_recipients'] . ' ' . implode(', ', $recipients) . "\n\n"; |
|
| 3779 | + } |
|
| 3638 | 3780 | $report_body .= $txt['pm_report_pm_unedited_below'] . "\n" . '[quote author=' . (empty($memberFromID) ? '"' . $memberFromName . '"' : $memberFromName . ' link=action=profile;u=' . $memberFromID . ' date=' . $time) . ']' . "\n" . un_htmlspecialchars($body) . '[/quote]'; |
| 3639 | 3781 | |
| 3640 | 3782 | // Plonk it in the array ;) |
@@ -3654,12 +3796,14 @@ discard block |
||
| 3654 | 3796 | $smcFunc['db_free_result']($request); |
| 3655 | 3797 | |
| 3656 | 3798 | // Send a different email for each language. |
| 3657 | - foreach ($messagesToSend as $lang => $message) |
|
| 3658 | - sendpm($message['recipients'], $message['subject'], $message['body']); |
|
| 3799 | + foreach ($messagesToSend as $lang => $message) { |
|
| 3800 | + sendpm($message['recipients'], $message['subject'], $message['body']); |
|
| 3801 | + } |
|
| 3659 | 3802 | |
| 3660 | 3803 | // Give the user their own language back! |
| 3661 | - if (!empty($modSettings['userLanguage'])) |
|
| 3662 | - loadLanguage('PersonalMessage', '', false); |
|
| 3804 | + if (!empty($modSettings['userLanguage'])) { |
|
| 3805 | + loadLanguage('PersonalMessage', '', false); |
|
| 3806 | + } |
|
| 3663 | 3807 | |
| 3664 | 3808 | // Leave them with a template. |
| 3665 | 3809 | $context['sub_template'] = 'report_message_complete'; |
@@ -3705,8 +3849,9 @@ discard block |
||
| 3705 | 3849 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 3706 | 3850 | { |
| 3707 | 3851 | // Hide hidden groups! |
| 3708 | - if ($row['hidden'] && !$row['can_moderate'] && !allowedTo('manage_membergroups')) |
|
| 3709 | - continue; |
|
| 3852 | + if ($row['hidden'] && !$row['can_moderate'] && !allowedTo('manage_membergroups')) { |
|
| 3853 | + continue; |
|
| 3854 | + } |
|
| 3710 | 3855 | |
| 3711 | 3856 | $context['groups'][$row['id_group']] = $row['group_name']; |
| 3712 | 3857 | } |
@@ -3732,9 +3877,10 @@ discard block |
||
| 3732 | 3877 | $context['rule'] = $context['rules'][$context['rid']]; |
| 3733 | 3878 | $members = array(); |
| 3734 | 3879 | // Need to get member names! |
| 3735 | - foreach ($context['rule']['criteria'] as $k => $criteria) |
|
| 3736 | - if ($criteria['t'] == 'mid' && !empty($criteria['v'])) |
|
| 3880 | + foreach ($context['rule']['criteria'] as $k => $criteria) { |
|
| 3881 | + if ($criteria['t'] == 'mid' && !empty($criteria['v'])) |
|
| 3737 | 3882 | $members[(int) $criteria['v']] = $k; |
| 3883 | + } |
|
| 3738 | 3884 | |
| 3739 | 3885 | if (!empty($members)) |
| 3740 | 3886 | { |
@@ -3746,19 +3892,20 @@ discard block |
||
| 3746 | 3892 | 'member_list' => array_keys($members), |
| 3747 | 3893 | ) |
| 3748 | 3894 | ); |
| 3749 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 3750 | - $context['rule']['criteria'][$members[$row['id_member']]]['v'] = $row['member_name']; |
|
| 3895 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 3896 | + $context['rule']['criteria'][$members[$row['id_member']]]['v'] = $row['member_name']; |
|
| 3897 | + } |
|
| 3751 | 3898 | $smcFunc['db_free_result']($request); |
| 3752 | 3899 | } |
| 3753 | - } |
|
| 3754 | - else |
|
| 3755 | - $context['rule'] = array( |
|
| 3900 | + } else { |
|
| 3901 | + $context['rule'] = array( |
|
| 3756 | 3902 | 'id' => '', |
| 3757 | 3903 | 'name' => '', |
| 3758 | 3904 | 'criteria' => array(), |
| 3759 | 3905 | 'actions' => array(), |
| 3760 | 3906 | 'logic' => 'and', |
| 3761 | 3907 | ); |
| 3908 | + } |
|
| 3762 | 3909 | } |
| 3763 | 3910 | // Saving? |
| 3764 | 3911 | elseif (isset($_GET['save'])) |
@@ -3768,22 +3915,25 @@ discard block |
||
| 3768 | 3915 | |
| 3769 | 3916 | // Name is easy! |
| 3770 | 3917 | $ruleName = $smcFunc['htmlspecialchars'](trim($_POST['rule_name'])); |
| 3771 | - if (empty($ruleName)) |
|
| 3772 | - fatal_lang_error('pm_rule_no_name', false); |
|
| 3918 | + if (empty($ruleName)) { |
|
| 3919 | + fatal_lang_error('pm_rule_no_name', false); |
|
| 3920 | + } |
|
| 3773 | 3921 | |
| 3774 | 3922 | // Sanity check... |
| 3775 | - if (empty($_POST['ruletype']) || empty($_POST['acttype'])) |
|
| 3776 | - fatal_lang_error('pm_rule_no_criteria', false); |
|
| 3923 | + if (empty($_POST['ruletype']) || empty($_POST['acttype'])) { |
|
| 3924 | + fatal_lang_error('pm_rule_no_criteria', false); |
|
| 3925 | + } |
|
| 3777 | 3926 | |
| 3778 | 3927 | // Let's do the criteria first - it's also hardest! |
| 3779 | 3928 | $criteria = array(); |
| 3780 | 3929 | foreach ($_POST['ruletype'] as $ind => $type) |
| 3781 | 3930 | { |
| 3782 | 3931 | // Check everything is here... |
| 3783 | - if ($type == 'gid' && (!isset($_POST['ruledefgroup'][$ind]) || !isset($context['groups'][$_POST['ruledefgroup'][$ind]]))) |
|
| 3784 | - continue; |
|
| 3785 | - elseif ($type != 'bud' && !isset($_POST['ruledef'][$ind])) |
|
| 3786 | - continue; |
|
| 3932 | + if ($type == 'gid' && (!isset($_POST['ruledefgroup'][$ind]) || !isset($context['groups'][$_POST['ruledefgroup'][$ind]]))) { |
|
| 3933 | + continue; |
|
| 3934 | + } elseif ($type != 'bud' && !isset($_POST['ruledef'][$ind])) { |
|
| 3935 | + continue; |
|
| 3936 | + } |
|
| 3787 | 3937 | |
| 3788 | 3938 | // Members need to be found. |
| 3789 | 3939 | if ($type == 'mid') |
@@ -3807,13 +3957,13 @@ discard block |
||
| 3807 | 3957 | $smcFunc['db_free_result']($request); |
| 3808 | 3958 | |
| 3809 | 3959 | $criteria[] = array('t' => 'mid', 'v' => $memID); |
| 3960 | + } elseif ($type == 'bud') { |
|
| 3961 | + $criteria[] = array('t' => 'bud', 'v' => 1); |
|
| 3962 | + } elseif ($type == 'gid') { |
|
| 3963 | + $criteria[] = array('t' => 'gid', 'v' => (int) $_POST['ruledefgroup'][$ind]); |
|
| 3964 | + } elseif (in_array($type, array('sub', 'msg')) && trim($_POST['ruledef'][$ind]) != '') { |
|
| 3965 | + $criteria[] = array('t' => $type, 'v' => $smcFunc['htmlspecialchars'](trim($_POST['ruledef'][$ind]))); |
|
| 3810 | 3966 | } |
| 3811 | - elseif ($type == 'bud') |
|
| 3812 | - $criteria[] = array('t' => 'bud', 'v' => 1); |
|
| 3813 | - elseif ($type == 'gid') |
|
| 3814 | - $criteria[] = array('t' => 'gid', 'v' => (int) $_POST['ruledefgroup'][$ind]); |
|
| 3815 | - elseif (in_array($type, array('sub', 'msg')) && trim($_POST['ruledef'][$ind]) != '') |
|
| 3816 | - $criteria[] = array('t' => $type, 'v' => $smcFunc['htmlspecialchars'](trim($_POST['ruledef'][$ind]))); |
|
| 3817 | 3967 | } |
| 3818 | 3968 | |
| 3819 | 3969 | // Also do the actions! |
@@ -3823,26 +3973,29 @@ discard block |
||
| 3823 | 3973 | foreach ($_POST['acttype'] as $ind => $type) |
| 3824 | 3974 | { |
| 3825 | 3975 | // Picking a valid label? |
| 3826 | - if ($type == 'lab' && (!isset($_POST['labdef'][$ind]) || !isset($context['labels'][$_POST['labdef'][$ind]]))) |
|
| 3827 | - continue; |
|
| 3976 | + if ($type == 'lab' && (!isset($_POST['labdef'][$ind]) || !isset($context['labels'][$_POST['labdef'][$ind]]))) { |
|
| 3977 | + continue; |
|
| 3978 | + } |
|
| 3828 | 3979 | |
| 3829 | 3980 | // Record what we're doing. |
| 3830 | - if ($type == 'del') |
|
| 3831 | - $doDelete = 1; |
|
| 3832 | - elseif ($type == 'lab') |
|
| 3833 | - $actions[] = array('t' => 'lab', 'v' => (int) $_POST['labdef'][$ind]); |
|
| 3981 | + if ($type == 'del') { |
|
| 3982 | + $doDelete = 1; |
|
| 3983 | + } elseif ($type == 'lab') { |
|
| 3984 | + $actions[] = array('t' => 'lab', 'v' => (int) $_POST['labdef'][$ind]); |
|
| 3985 | + } |
|
| 3834 | 3986 | } |
| 3835 | 3987 | |
| 3836 | - if (empty($criteria) || (empty($actions) && !$doDelete)) |
|
| 3837 | - fatal_lang_error('pm_rule_no_criteria', false); |
|
| 3988 | + if (empty($criteria) || (empty($actions) && !$doDelete)) { |
|
| 3989 | + fatal_lang_error('pm_rule_no_criteria', false); |
|
| 3990 | + } |
|
| 3838 | 3991 | |
| 3839 | 3992 | // What are we storing? |
| 3840 | 3993 | $criteria = json_encode($criteria); |
| 3841 | 3994 | $actions = json_encode($actions); |
| 3842 | 3995 | |
| 3843 | 3996 | // Create the rule? |
| 3844 | - if (empty($context['rid'])) |
|
| 3845 | - $smcFunc['db_insert']('', |
|
| 3997 | + if (empty($context['rid'])) { |
|
| 3998 | + $smcFunc['db_insert']('', |
|
| 3846 | 3999 | '{db_prefix}pm_rules', |
| 3847 | 4000 | array( |
| 3848 | 4001 | 'id_member' => 'int', 'rule_name' => 'string', 'criteria' => 'string', 'actions' => 'string', |
@@ -3853,8 +4006,8 @@ discard block |
||
| 3853 | 4006 | ), |
| 3854 | 4007 | array('id_rule') |
| 3855 | 4008 | ); |
| 3856 | - else |
|
| 3857 | - $smcFunc['db_query']('', ' |
|
| 4009 | + } else { |
|
| 4010 | + $smcFunc['db_query']('', ' |
|
| 3858 | 4011 | UPDATE {db_prefix}pm_rules |
| 3859 | 4012 | SET rule_name = {string:rule_name}, criteria = {string:criteria}, actions = {string:actions}, |
| 3860 | 4013 | delete_pm = {int:delete_pm}, is_or = {int:is_or} |
@@ -3870,6 +4023,7 @@ discard block |
||
| 3870 | 4023 | 'actions' => $actions, |
| 3871 | 4024 | ) |
| 3872 | 4025 | ); |
| 4026 | + } |
|
| 3873 | 4027 | |
| 3874 | 4028 | redirectexit('action=pm;sa=manrules'); |
| 3875 | 4029 | } |
@@ -3878,11 +4032,12 @@ discard block |
||
| 3878 | 4032 | { |
| 3879 | 4033 | checkSession(); |
| 3880 | 4034 | $toDelete = array(); |
| 3881 | - foreach ($_POST['delrule'] as $k => $v) |
|
| 3882 | - $toDelete[] = (int) $k; |
|
| 4035 | + foreach ($_POST['delrule'] as $k => $v) { |
|
| 4036 | + $toDelete[] = (int) $k; |
|
| 4037 | + } |
|
| 3883 | 4038 | |
| 3884 | - if (!empty($toDelete)) |
|
| 3885 | - $smcFunc['db_query']('', ' |
|
| 4039 | + if (!empty($toDelete)) { |
|
| 4040 | + $smcFunc['db_query']('', ' |
|
| 3886 | 4041 | DELETE FROM {db_prefix}pm_rules |
| 3887 | 4042 | WHERE id_rule IN ({array_int:delete_list}) |
| 3888 | 4043 | AND id_member = {int:current_member}', |
@@ -3891,6 +4046,7 @@ discard block |
||
| 3891 | 4046 | 'delete_list' => $toDelete, |
| 3892 | 4047 | ) |
| 3893 | 4048 | ); |
| 4049 | + } |
|
| 3894 | 4050 | |
| 3895 | 4051 | redirectexit('action=pm;sa=manrules'); |
| 3896 | 4052 | } |
@@ -3909,8 +4065,9 @@ discard block |
||
| 3909 | 4065 | loadRules(); |
| 3910 | 4066 | |
| 3911 | 4067 | // No rules? |
| 3912 | - if (empty($context['rules'])) |
|
| 3913 | - return; |
|
| 4068 | + if (empty($context['rules'])) { |
|
| 4069 | + return; |
|
| 4070 | + } |
|
| 3914 | 4071 | |
| 3915 | 4072 | // Just unread ones? |
| 3916 | 4073 | $ruleQuery = $all_messages ? '' : ' AND pmr.is_new = 1'; |
@@ -3940,8 +4097,9 @@ discard block |
||
| 3940 | 4097 | // Loop through all the criteria hoping to make a match. |
| 3941 | 4098 | foreach ($rule['criteria'] as $criterium) |
| 3942 | 4099 | { |
| 3943 | - if (($criterium['t'] == 'mid' && $criterium['v'] == $row['id_member_from']) || ($criterium['t'] == 'gid' && $criterium['v'] == $row['id_group']) || ($criterium['t'] == 'sub' && strpos($row['subject'], $criterium['v']) !== false) || ($criterium['t'] == 'msg' && strpos($row['body'], $criterium['v']) !== false)) |
|
| 3944 | - $match = true; |
|
| 4100 | + if (($criterium['t'] == 'mid' && $criterium['v'] == $row['id_member_from']) || ($criterium['t'] == 'gid' && $criterium['v'] == $row['id_group']) || ($criterium['t'] == 'sub' && strpos($row['subject'], $criterium['v']) !== false) || ($criterium['t'] == 'msg' && strpos($row['body'], $criterium['v']) !== false)) { |
|
| 4101 | + $match = true; |
|
| 4102 | + } |
|
| 3945 | 4103 | // If we're adding and one criteria don't match then we stop! |
| 3946 | 4104 | elseif ($rule['logic'] == 'and') |
| 3947 | 4105 | { |
@@ -3953,17 +4111,18 @@ discard block |
||
| 3953 | 4111 | // If we have a match the rule must be true - act! |
| 3954 | 4112 | if ($match) |
| 3955 | 4113 | { |
| 3956 | - if ($rule['delete']) |
|
| 3957 | - $actions['deletes'][] = $row['id_pm']; |
|
| 3958 | - else |
|
| 4114 | + if ($rule['delete']) { |
|
| 4115 | + $actions['deletes'][] = $row['id_pm']; |
|
| 4116 | + } else |
|
| 3959 | 4117 | { |
| 3960 | 4118 | foreach ($rule['actions'] as $ruleAction) |
| 3961 | 4119 | { |
| 3962 | 4120 | if ($ruleAction['t'] == 'lab') |
| 3963 | 4121 | { |
| 3964 | 4122 | // Get a basic pot started! |
| 3965 | - if (!isset($actions['labels'][$row['id_pm']])) |
|
| 3966 | - $actions['labels'][$row['id_pm']] = array(); |
|
| 4123 | + if (!isset($actions['labels'][$row['id_pm']])) { |
|
| 4124 | + $actions['labels'][$row['id_pm']] = array(); |
|
| 4125 | + } |
|
| 3967 | 4126 | $actions['labels'][$row['id_pm']][] = $ruleAction['v']; |
| 3968 | 4127 | } |
| 3969 | 4128 | } |
@@ -3974,8 +4133,9 @@ discard block |
||
| 3974 | 4133 | $smcFunc['db_free_result']($request); |
| 3975 | 4134 | |
| 3976 | 4135 | // Deletes are easy! |
| 3977 | - if (!empty($actions['deletes'])) |
|
| 3978 | - deleteMessages($actions['deletes']); |
|
| 4136 | + if (!empty($actions['deletes'])) { |
|
| 4137 | + deleteMessages($actions['deletes']); |
|
| 4138 | + } |
|
| 3979 | 4139 | |
| 3980 | 4140 | // Relabel? |
| 3981 | 4141 | if (!empty($actions['labels'])) |
@@ -4002,8 +4162,7 @@ discard block |
||
| 4002 | 4162 | 'current_member' => $user_info['id'], |
| 4003 | 4163 | ) |
| 4004 | 4164 | ); |
| 4005 | - } |
|
| 4006 | - else |
|
| 4165 | + } else |
|
| 4007 | 4166 | { |
| 4008 | 4167 | $realLabels[] = $label['id']; |
| 4009 | 4168 | } |
@@ -4012,8 +4171,9 @@ discard block |
||
| 4012 | 4171 | |
| 4013 | 4172 | $inserts = array(); |
| 4014 | 4173 | // Now we insert the label info |
| 4015 | - foreach ($realLabels as $a_label) |
|
| 4016 | - $inserts[] = array($pm, $a_label); |
|
| 4174 | + foreach ($realLabels as $a_label) { |
|
| 4175 | + $inserts[] = array($pm, $a_label); |
|
| 4176 | + } |
|
| 4017 | 4177 | |
| 4018 | 4178 | $smcFunc['db_insert']('ignore', |
| 4019 | 4179 | '{db_prefix}pm_labeled_messages', |
@@ -4034,8 +4194,9 @@ discard block |
||
| 4034 | 4194 | { |
| 4035 | 4195 | global $user_info, $context, $smcFunc; |
| 4036 | 4196 | |
| 4037 | - if (isset($context['rules']) && !$reload) |
|
| 4038 | - return; |
|
| 4197 | + if (isset($context['rules']) && !$reload) { |
|
| 4198 | + return; |
|
| 4199 | + } |
|
| 4039 | 4200 | |
| 4040 | 4201 | $request = $smcFunc['db_query']('', ' |
| 4041 | 4202 | SELECT |
@@ -4059,8 +4220,9 @@ discard block |
||
| 4059 | 4220 | 'logic' => $row['is_or'] ? 'or' : 'and', |
| 4060 | 4221 | ); |
| 4061 | 4222 | |
| 4062 | - if ($row['delete_pm']) |
|
| 4063 | - $context['rules'][$row['id_rule']]['actions'][] = array('t' => 'del', 'v' => 1); |
|
| 4223 | + if ($row['delete_pm']) { |
|
| 4224 | + $context['rules'][$row['id_rule']]['actions'][] = array('t' => 'del', 'v' => 1); |
|
| 4225 | + } |
|
| 4064 | 4226 | } |
| 4065 | 4227 | $smcFunc['db_free_result']($request); |
| 4066 | 4228 | } |
@@ -2183,7 +2183,7 @@ discard block |
||
| 2183 | 2183 | * Deletes a single or a group of alerts by ID |
| 2184 | 2184 | * |
| 2185 | 2185 | * @param int|array The ID of a single alert to delete or an array containing the IDs of multiple alerts. The function will convert integers into an array for better handling. |
| 2186 | - * @param bool|int $memID The user ID. Used to update the user unread alerts count. |
|
| 2186 | + * @param integer $memID The user ID. Used to update the user unread alerts count. |
|
| 2187 | 2187 | * @return void|int If the $memID param is set, returns the new amount of unread alerts. |
| 2188 | 2188 | */ |
| 2189 | 2189 | function alert_delete($toDelete, $memID = false) |
@@ -2839,7 +2839,7 @@ discard block |
||
| 2839 | 2839 | /** |
| 2840 | 2840 | * Handles the "manage groups" section of the profile |
| 2841 | 2841 | * |
| 2842 | - * @return true Always returns true |
|
| 2842 | + * @return boolean Always returns true |
|
| 2843 | 2843 | */ |
| 2844 | 2844 | function profileLoadGroups() |
| 2845 | 2845 | { |
@@ -2896,7 +2896,7 @@ discard block |
||
| 2896 | 2896 | /** |
| 2897 | 2897 | * Load key signature context data. |
| 2898 | 2898 | * |
| 2899 | - * @return true Always returns true |
|
| 2899 | + * @return boolean Always returns true |
|
| 2900 | 2900 | */ |
| 2901 | 2901 | function profileLoadSignatureData() |
| 2902 | 2902 | { |
@@ -2960,7 +2960,7 @@ discard block |
||
| 2960 | 2960 | /** |
| 2961 | 2961 | * Load avatar context data. |
| 2962 | 2962 | * |
| 2963 | - * @return true Always returns true |
|
| 2963 | + * @return boolean Always returns true |
|
| 2964 | 2964 | */ |
| 2965 | 2965 | function profileLoadAvatarData() |
| 2966 | 2966 | { |
@@ -3033,7 +3033,7 @@ discard block |
||
| 3033 | 3033 | * Save a members group. |
| 3034 | 3034 | * |
| 3035 | 3035 | * @param int &$value The ID of the (new) primary group |
| 3036 | - * @return true Always returns true |
|
| 3036 | + * @return boolean Always returns true |
|
| 3037 | 3037 | */ |
| 3038 | 3038 | function profileSaveGroups(&$value) |
| 3039 | 3039 | { |
@@ -3138,7 +3138,7 @@ discard block |
||
| 3138 | 3138 | * @todo argh, the avatar here. Take this out of here! |
| 3139 | 3139 | * |
| 3140 | 3140 | * @param string &$value What kind of avatar we're expecting. Can be 'none', 'server_stored', 'gravatar', 'external' or 'upload' |
| 3141 | - * @return bool|string False if success (or if memID is empty and password authentication failed), otherwise a string indicating what error occurred |
|
| 3141 | + * @return false|string False if success (or if memID is empty and password authentication failed), otherwise a string indicating what error occurred |
|
| 3142 | 3142 | */ |
| 3143 | 3143 | function profileSaveAvatarData(&$value) |
| 3144 | 3144 | { |
@@ -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 | * This defines every profile field known to man. |
@@ -29,8 +30,9 @@ discard block |
||
| 29 | 30 | global $sourcedir, $profile_vars; |
| 30 | 31 | |
| 31 | 32 | // Don't load this twice! |
| 32 | - if (!empty($profile_fields) && !$force_reload) |
|
| 33 | - return; |
|
| 33 | + if (!empty($profile_fields) && !$force_reload) { |
|
| 34 | + return; |
|
| 35 | + } |
|
| 34 | 36 | |
| 35 | 37 | /* This horrific array defines all the profile fields in the whole world! |
| 36 | 38 | In general each "field" has one array - the key of which is the database column name associated with said field. Each item |
@@ -103,13 +105,14 @@ discard block |
||
| 103 | 105 | if (isset($_POST['bday2'], $_POST['bday3']) && $value > 0 && $_POST['bday2'] > 0) |
| 104 | 106 | { |
| 105 | 107 | // Set to blank? |
| 106 | - if ((int) $_POST['bday3'] == 1 && (int) $_POST['bday2'] == 1 && (int) $value == 1) |
|
| 107 | - $value = '0001-01-01'; |
|
| 108 | - else |
|
| 109 | - $value = checkdate($value, $_POST['bday2'], $_POST['bday3'] < 4 ? 4 : $_POST['bday3']) ? sprintf('%04d-%02d-%02d', $_POST['bday3'] < 4 ? 4 : $_POST['bday3'], $_POST['bday1'], $_POST['bday2']) : '0001-01-01'; |
|
| 108 | + if ((int) $_POST['bday3'] == 1 && (int) $_POST['bday2'] == 1 && (int) $value == 1) { |
|
| 109 | + $value = '0001-01-01'; |
|
| 110 | + } else { |
|
| 111 | + $value = checkdate($value, $_POST['bday2'], $_POST['bday3'] < 4 ? 4 : $_POST['bday3']) ? sprintf('%04d-%02d-%02d', $_POST['bday3'] < 4 ? 4 : $_POST['bday3'], $_POST['bday1'], $_POST['bday2']) : '0001-01-01'; |
|
| 112 | + } |
|
| 113 | + } else { |
|
| 114 | + $value = '0001-01-01'; |
|
| 110 | 115 | } |
| 111 | - else |
|
| 112 | - $value = '0001-01-01'; |
|
| 113 | 116 | |
| 114 | 117 | $profile_vars['birthdate'] = $value; |
| 115 | 118 | $cur_profile['birthdate'] = $value; |
@@ -127,8 +130,7 @@ discard block |
||
| 127 | 130 | { |
| 128 | 131 | $value = checkdate($dates[2], $dates[3], $dates[1] < 4 ? 4 : $dates[1]) ? sprintf('%04d-%02d-%02d', $dates[1] < 4 ? 4 : $dates[1], $dates[2], $dates[3]) : '0001-01-01'; |
| 129 | 132 | return true; |
| 130 | - } |
|
| 131 | - else |
|
| 133 | + } else |
|
| 132 | 134 | { |
| 133 | 135 | $value = empty($cur_profile['birthdate']) ? '0001-01-01' : $cur_profile['birthdate']; |
| 134 | 136 | return false; |
@@ -150,10 +152,11 @@ discard block |
||
| 150 | 152 | return $txt['invalid_registration'] . ' ' . strftime('%d %b %Y ' . (strpos($user_info['time_format'], '%H') !== false ? '%I:%M:%S %p' : '%H:%M:%S'), forum_time(false)); |
| 151 | 153 | } |
| 152 | 154 | // As long as it doesn't equal "N/A"... |
| 153 | - elseif ($value != $txt['not_applicable'] && $value != strtotime(strftime('%Y-%m-%d', $cur_profile['date_registered'] + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600))) |
|
| 154 | - $value = $value - ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
| 155 | - else |
|
| 156 | - $value = $cur_profile['date_registered']; |
|
| 155 | + elseif ($value != $txt['not_applicable'] && $value != strtotime(strftime('%Y-%m-%d', $cur_profile['date_registered'] + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600))) { |
|
| 156 | + $value = $value - ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
| 157 | + } else { |
|
| 158 | + $value = $cur_profile['date_registered']; |
|
| 159 | + } |
|
| 157 | 160 | |
| 158 | 161 | return true; |
| 159 | 162 | }, |
@@ -177,8 +180,9 @@ discard block |
||
| 177 | 180 | { |
| 178 | 181 | global $context, $old_profile, $profile_vars, $sourcedir, $modSettings; |
| 179 | 182 | |
| 180 | - if (strtolower($value) == strtolower($old_profile['email_address'])) |
|
| 181 | - return false; |
|
| 183 | + if (strtolower($value) == strtolower($old_profile['email_address'])) { |
|
| 184 | + return false; |
|
| 185 | + } |
|
| 182 | 186 | |
| 183 | 187 | $isValid = profileValidateEmail($value, $context['id_member']); |
| 184 | 188 | |
@@ -254,11 +258,11 @@ discard block |
||
| 254 | 258 | |
| 255 | 259 | if (isset($context['profile_languages'][$value])) |
| 256 | 260 | { |
| 257 | - if ($context['user']['is_owner'] && empty($context['password_auth_failed'])) |
|
| 258 | - $_SESSION['language'] = $value; |
|
| 261 | + if ($context['user']['is_owner'] && empty($context['password_auth_failed'])) { |
|
| 262 | + $_SESSION['language'] = $value; |
|
| 263 | + } |
|
| 259 | 264 | return true; |
| 260 | - } |
|
| 261 | - else |
|
| 265 | + } else |
|
| 262 | 266 | { |
| 263 | 267 | $value = $cur_profile['lngfile']; |
| 264 | 268 | return false; |
@@ -282,13 +286,14 @@ discard block |
||
| 282 | 286 | |
| 283 | 287 | // Maybe they are trying to change their password as well? |
| 284 | 288 | $resetPassword = true; |
| 285 | - if (isset($_POST['passwrd1']) && $_POST['passwrd1'] != '' && isset($_POST['passwrd2']) && $_POST['passwrd1'] == $_POST['passwrd2'] && validatePassword($_POST['passwrd1'], $value, array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])) == null) |
|
| 286 | - $resetPassword = false; |
|
| 289 | + if (isset($_POST['passwrd1']) && $_POST['passwrd1'] != '' && isset($_POST['passwrd2']) && $_POST['passwrd1'] == $_POST['passwrd2'] && validatePassword($_POST['passwrd1'], $value, array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])) == null) { |
|
| 290 | + $resetPassword = false; |
|
| 291 | + } |
|
| 287 | 292 | |
| 288 | 293 | // Do the reset... this will send them an email too. |
| 289 | - if ($resetPassword) |
|
| 290 | - resetPassword($context['id_member'], $value); |
|
| 291 | - elseif ($value !== null) |
|
| 294 | + if ($resetPassword) { |
|
| 295 | + resetPassword($context['id_member'], $value); |
|
| 296 | + } elseif ($value !== null) |
|
| 292 | 297 | { |
| 293 | 298 | validateUsername($context['id_member'], trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $value))); |
| 294 | 299 | updateMemberData($context['id_member'], array('member_name' => $value)); |
@@ -312,20 +317,23 @@ discard block |
||
| 312 | 317 | 'input_validate' => function(&$value) use ($sourcedir, $user_info, $smcFunc, $cur_profile) |
| 313 | 318 | { |
| 314 | 319 | // If we didn't try it then ignore it! |
| 315 | - if ($value == '') |
|
| 316 | - return false; |
|
| 320 | + if ($value == '') { |
|
| 321 | + return false; |
|
| 322 | + } |
|
| 317 | 323 | |
| 318 | 324 | // Do the two entries for the password even match? |
| 319 | - if (!isset($_POST['passwrd2']) || $value != $_POST['passwrd2']) |
|
| 320 | - return 'bad_new_password'; |
|
| 325 | + if (!isset($_POST['passwrd2']) || $value != $_POST['passwrd2']) { |
|
| 326 | + return 'bad_new_password'; |
|
| 327 | + } |
|
| 321 | 328 | |
| 322 | 329 | // Let's get the validation function into play... |
| 323 | 330 | require_once($sourcedir . '/Subs-Auth.php'); |
| 324 | 331 | $passwordErrors = validatePassword($value, $cur_profile['member_name'], array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])); |
| 325 | 332 | |
| 326 | 333 | // Were there errors? |
| 327 | - if ($passwordErrors != null) |
|
| 328 | - return 'password_' . $passwordErrors; |
|
| 334 | + if ($passwordErrors != null) { |
|
| 335 | + return 'password_' . $passwordErrors; |
|
| 336 | + } |
|
| 329 | 337 | |
| 330 | 338 | // Set up the new password variable... ready for storage. |
| 331 | 339 | $value = hash_password($cur_profile['member_name'], un_htmlspecialchars($value)); |
@@ -350,8 +358,9 @@ discard block |
||
| 350 | 358 | 'permission' => 'profile_blurb', |
| 351 | 359 | 'input_validate' => function(&$value) use ($smcFunc) |
| 352 | 360 | { |
| 353 | - if ($smcFunc['strlen']($value) > 50) |
|
| 354 | - return 'personal_text_too_long'; |
|
| 361 | + if ($smcFunc['strlen']($value) > 50) { |
|
| 362 | + return 'personal_text_too_long'; |
|
| 363 | + } |
|
| 355 | 364 | |
| 356 | 365 | return true; |
| 357 | 366 | }, |
@@ -386,10 +395,11 @@ discard block |
||
| 386 | 395 | 'permission' => 'moderate_forum', |
| 387 | 396 | 'input_validate' => function(&$value) |
| 388 | 397 | { |
| 389 | - if (!is_numeric($value)) |
|
| 390 | - return 'digits_only'; |
|
| 391 | - else |
|
| 392 | - $value = $value != '' ? strtr($value, array(',' => '', '.' => '', ' ' => '')) : 0; |
|
| 398 | + if (!is_numeric($value)) { |
|
| 399 | + return 'digits_only'; |
|
| 400 | + } else { |
|
| 401 | + $value = $value != '' ? strtr($value, array(',' => '', '.' => '', ' ' => '')) : 0; |
|
| 402 | + } |
|
| 393 | 403 | return true; |
| 394 | 404 | }, |
| 395 | 405 | ), |
@@ -405,15 +415,16 @@ discard block |
||
| 405 | 415 | { |
| 406 | 416 | $value = trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $value)); |
| 407 | 417 | |
| 408 | - if (trim($value) == '') |
|
| 409 | - return 'no_name'; |
|
| 410 | - elseif ($smcFunc['strlen']($value) > 60) |
|
| 411 | - return 'name_too_long'; |
|
| 412 | - elseif ($cur_profile['real_name'] != $value) |
|
| 418 | + if (trim($value) == '') { |
|
| 419 | + return 'no_name'; |
|
| 420 | + } elseif ($smcFunc['strlen']($value) > 60) { |
|
| 421 | + return 'name_too_long'; |
|
| 422 | + } elseif ($cur_profile['real_name'] != $value) |
|
| 413 | 423 | { |
| 414 | 424 | require_once($sourcedir . '/Subs-Members.php'); |
| 415 | - if (isReservedName($value, $context['id_member'])) |
|
| 416 | - return 'name_taken'; |
|
| 425 | + if (isReservedName($value, $context['id_member'])) { |
|
| 426 | + return 'name_taken'; |
|
| 427 | + } |
|
| 417 | 428 | } |
| 418 | 429 | return true; |
| 419 | 430 | }, |
@@ -471,8 +482,9 @@ discard block |
||
| 471 | 482 | 'selected' => $set == $context['member']['smiley_set']['id'] |
| 472 | 483 | ); |
| 473 | 484 | |
| 474 | - if ($context['smiley_sets'][$i]['selected']) |
|
| 475 | - $context['member']['smiley_set']['name'] = $set_names[$i]; |
|
| 485 | + if ($context['smiley_sets'][$i]['selected']) { |
|
| 486 | + $context['member']['smiley_set']['name'] = $set_names[$i]; |
|
| 487 | + } |
|
| 476 | 488 | } |
| 477 | 489 | return true; |
| 478 | 490 | }, |
@@ -481,8 +493,9 @@ discard block |
||
| 481 | 493 | global $modSettings; |
| 482 | 494 | |
| 483 | 495 | $smiley_sets = explode(',', $modSettings['smiley_sets_known']); |
| 484 | - if (!in_array($value, $smiley_sets) && $value != 'none') |
|
| 485 | - $value = ''; |
|
| 496 | + if (!in_array($value, $smiley_sets) && $value != 'none') { |
|
| 497 | + $value = ''; |
|
| 498 | + } |
|
| 486 | 499 | return true; |
| 487 | 500 | }, |
| 488 | 501 | ), |
@@ -497,8 +510,9 @@ discard block |
||
| 497 | 510 | loadLanguage('Settings'); |
| 498 | 511 | |
| 499 | 512 | $context['allow_no_censored'] = false; |
| 500 | - if ($user_info['is_admin'] || $context['user']['is_owner']) |
|
| 501 | - $context['allow_no_censored'] = !empty($modSettings['allow_no_censored']); |
|
| 513 | + if ($user_info['is_admin'] || $context['user']['is_owner']) { |
|
| 514 | + $context['allow_no_censored'] = !empty($modSettings['allow_no_censored']); |
|
| 515 | + } |
|
| 502 | 516 | |
| 503 | 517 | return true; |
| 504 | 518 | }, |
@@ -545,8 +559,9 @@ discard block |
||
| 545 | 559 | 'input_validate' => function($value) |
| 546 | 560 | { |
| 547 | 561 | $tz = smf_list_timezones(); |
| 548 | - if (!isset($tz[$value])) |
|
| 549 | - return 'bad_timezone'; |
|
| 562 | + if (!isset($tz[$value])) { |
|
| 563 | + return 'bad_timezone'; |
|
| 564 | + } |
|
| 550 | 565 | |
| 551 | 566 | return true; |
| 552 | 567 | }, |
@@ -561,8 +576,9 @@ discard block |
||
| 561 | 576 | 'enabled' => !empty($modSettings['titlesEnable']), |
| 562 | 577 | 'input_validate' => function(&$value) use ($smcFunc) |
| 563 | 578 | { |
| 564 | - if ($smcFunc['strlen']($value) > 50) |
|
| 565 | - return 'user_title_too_long'; |
|
| 579 | + if ($smcFunc['strlen']($value) > 50) { |
|
| 580 | + return 'user_title_too_long'; |
|
| 581 | + } |
|
| 566 | 582 | |
| 567 | 583 | return true; |
| 568 | 584 | }, |
@@ -584,10 +600,12 @@ discard block |
||
| 584 | 600 | // Fix the URL... |
| 585 | 601 | 'input_validate' => function(&$value) |
| 586 | 602 | { |
| 587 | - if (strlen(trim($value)) > 0 && strpos($value, '://') === false) |
|
| 588 | - $value = 'http://' . $value; |
|
| 589 | - if (strlen($value) < 8 || (substr($value, 0, 7) !== 'http://' && substr($value, 0, 8) !== 'https://')) |
|
| 590 | - $value = ''; |
|
| 603 | + if (strlen(trim($value)) > 0 && strpos($value, '://') === false) { |
|
| 604 | + $value = 'http://' . $value; |
|
| 605 | + } |
|
| 606 | + if (strlen($value) < 8 || (substr($value, 0, 7) !== 'http://' && substr($value, 0, 8) !== 'https://')) { |
|
| 607 | + $value = ''; |
|
| 608 | + } |
|
| 591 | 609 | return true; |
| 592 | 610 | }, |
| 593 | 611 | 'link_with' => 'website', |
@@ -601,16 +619,19 @@ discard block |
||
| 601 | 619 | foreach ($profile_fields as $key => $field) |
| 602 | 620 | { |
| 603 | 621 | // Do we have permission to do this? |
| 604 | - if (isset($field['permission']) && !allowedTo(($context['user']['is_owner'] ? array($field['permission'] . '_own', $field['permission'] . '_any') : $field['permission'] . '_any')) && !allowedTo($field['permission'])) |
|
| 605 | - unset($profile_fields[$key]); |
|
| 622 | + if (isset($field['permission']) && !allowedTo(($context['user']['is_owner'] ? array($field['permission'] . '_own', $field['permission'] . '_any') : $field['permission'] . '_any')) && !allowedTo($field['permission'])) { |
|
| 623 | + unset($profile_fields[$key]); |
|
| 624 | + } |
|
| 606 | 625 | |
| 607 | 626 | // Is it enabled? |
| 608 | - if (isset($field['enabled']) && !$field['enabled']) |
|
| 609 | - unset($profile_fields[$key]); |
|
| 627 | + if (isset($field['enabled']) && !$field['enabled']) { |
|
| 628 | + unset($profile_fields[$key]); |
|
| 629 | + } |
|
| 610 | 630 | |
| 611 | 631 | // Is it specifically disabled? |
| 612 | - if (in_array($key, $disabled_fields) || (isset($field['link_with']) && in_array($field['link_with'], $disabled_fields))) |
|
| 613 | - unset($profile_fields[$key]); |
|
| 632 | + if (in_array($key, $disabled_fields) || (isset($field['link_with']) && in_array($field['link_with'], $disabled_fields))) { |
|
| 633 | + unset($profile_fields[$key]); |
|
| 634 | + } |
|
| 614 | 635 | } |
| 615 | 636 | } |
| 616 | 637 | |
@@ -635,9 +656,10 @@ discard block |
||
| 635 | 656 | loadProfileFields(true); |
| 636 | 657 | |
| 637 | 658 | // First check for any linked sets. |
| 638 | - foreach ($profile_fields as $key => $field) |
|
| 639 | - if (isset($field['link_with']) && in_array($field['link_with'], $fields)) |
|
| 659 | + foreach ($profile_fields as $key => $field) { |
|
| 660 | + if (isset($field['link_with']) && in_array($field['link_with'], $fields)) |
|
| 640 | 661 | $fields[] = $key; |
| 662 | + } |
|
| 641 | 663 | |
| 642 | 664 | $i = 0; |
| 643 | 665 | $last_type = ''; |
@@ -649,38 +671,46 @@ discard block |
||
| 649 | 671 | $cur_field = &$profile_fields[$field]; |
| 650 | 672 | |
| 651 | 673 | // Does it have a preload and does that preload succeed? |
| 652 | - if (isset($cur_field['preload']) && !$cur_field['preload']()) |
|
| 653 | - continue; |
|
| 674 | + if (isset($cur_field['preload']) && !$cur_field['preload']()) { |
|
| 675 | + continue; |
|
| 676 | + } |
|
| 654 | 677 | |
| 655 | 678 | // If this is anything but complex we need to do more cleaning! |
| 656 | 679 | if ($cur_field['type'] != 'callback' && $cur_field['type'] != 'hidden') |
| 657 | 680 | { |
| 658 | - if (!isset($cur_field['label'])) |
|
| 659 | - $cur_field['label'] = isset($txt[$field]) ? $txt[$field] : $field; |
|
| 681 | + if (!isset($cur_field['label'])) { |
|
| 682 | + $cur_field['label'] = isset($txt[$field]) ? $txt[$field] : $field; |
|
| 683 | + } |
|
| 660 | 684 | |
| 661 | 685 | // Everything has a value! |
| 662 | - if (!isset($cur_field['value'])) |
|
| 663 | - $cur_field['value'] = isset($cur_profile[$field]) ? $cur_profile[$field] : ''; |
|
| 686 | + if (!isset($cur_field['value'])) { |
|
| 687 | + $cur_field['value'] = isset($cur_profile[$field]) ? $cur_profile[$field] : ''; |
|
| 688 | + } |
|
| 664 | 689 | |
| 665 | 690 | // Any input attributes? |
| 666 | 691 | $cur_field['input_attr'] = !empty($cur_field['input_attr']) ? implode(',', $cur_field['input_attr']) : ''; |
| 667 | 692 | } |
| 668 | 693 | |
| 669 | 694 | // Was there an error with this field on posting? |
| 670 | - if (isset($context['profile_errors'][$field])) |
|
| 671 | - $cur_field['is_error'] = true; |
|
| 695 | + if (isset($context['profile_errors'][$field])) { |
|
| 696 | + $cur_field['is_error'] = true; |
|
| 697 | + } |
|
| 672 | 698 | |
| 673 | 699 | // Any javascript stuff? |
| 674 | - if (!empty($cur_field['js_submit'])) |
|
| 675 | - $context['profile_onsubmit_javascript'] .= $cur_field['js_submit']; |
|
| 676 | - if (!empty($cur_field['js'])) |
|
| 677 | - $context['profile_javascript'] .= $cur_field['js']; |
|
| 700 | + if (!empty($cur_field['js_submit'])) { |
|
| 701 | + $context['profile_onsubmit_javascript'] .= $cur_field['js_submit']; |
|
| 702 | + } |
|
| 703 | + if (!empty($cur_field['js'])) { |
|
| 704 | + $context['profile_javascript'] .= $cur_field['js']; |
|
| 705 | + } |
|
| 678 | 706 | |
| 679 | 707 | // Any template stuff? |
| 680 | - if (!empty($cur_field['prehtml'])) |
|
| 681 | - $context['profile_prehtml'] .= $cur_field['prehtml']; |
|
| 682 | - if (!empty($cur_field['posthtml'])) |
|
| 683 | - $context['profile_posthtml'] .= $cur_field['posthtml']; |
|
| 708 | + if (!empty($cur_field['prehtml'])) { |
|
| 709 | + $context['profile_prehtml'] .= $cur_field['prehtml']; |
|
| 710 | + } |
|
| 711 | + if (!empty($cur_field['posthtml'])) { |
|
| 712 | + $context['profile_posthtml'] .= $cur_field['posthtml']; |
|
| 713 | + } |
|
| 684 | 714 | |
| 685 | 715 | // Finally put it into context? |
| 686 | 716 | if ($cur_field['type'] != 'hidden') |
@@ -713,12 +743,14 @@ discard block |
||
| 713 | 743 | }, false);' : ''), true); |
| 714 | 744 | |
| 715 | 745 | // Any onsubmit javascript? |
| 716 | - if (!empty($context['profile_onsubmit_javascript'])) |
|
| 717 | - addInlineJavaScript($context['profile_onsubmit_javascript'], true); |
|
| 746 | + if (!empty($context['profile_onsubmit_javascript'])) { |
|
| 747 | + addInlineJavaScript($context['profile_onsubmit_javascript'], true); |
|
| 748 | + } |
|
| 718 | 749 | |
| 719 | 750 | // Any totally custom stuff? |
| 720 | - if (!empty($context['profile_javascript'])) |
|
| 721 | - addInlineJavaScript($context['profile_javascript'], true); |
|
| 751 | + if (!empty($context['profile_javascript'])) { |
|
| 752 | + addInlineJavaScript($context['profile_javascript'], true); |
|
| 753 | + } |
|
| 722 | 754 | |
| 723 | 755 | // Free up some memory. |
| 724 | 756 | unset($profile_fields); |
@@ -739,8 +771,9 @@ discard block |
||
| 739 | 771 | |
| 740 | 772 | // This allows variables to call activities when they save - by default just to reload their settings |
| 741 | 773 | $context['profile_execute_on_save'] = array(); |
| 742 | - if ($context['user']['is_owner']) |
|
| 743 | - $context['profile_execute_on_save']['reload_user'] = 'profileReloadUser'; |
|
| 774 | + if ($context['user']['is_owner']) { |
|
| 775 | + $context['profile_execute_on_save']['reload_user'] = 'profileReloadUser'; |
|
| 776 | + } |
|
| 744 | 777 | |
| 745 | 778 | // Assume we log nothing. |
| 746 | 779 | $context['log_changes'] = array(); |
@@ -748,8 +781,9 @@ discard block |
||
| 748 | 781 | // Cycle through the profile fields working out what to do! |
| 749 | 782 | foreach ($profile_fields as $key => $field) |
| 750 | 783 | { |
| 751 | - if (!isset($_POST[$key]) || !empty($field['is_dummy']) || (isset($_POST['preview_signature']) && $key == 'signature')) |
|
| 752 | - continue; |
|
| 784 | + if (!isset($_POST[$key]) || !empty($field['is_dummy']) || (isset($_POST['preview_signature']) && $key == 'signature')) { |
|
| 785 | + continue; |
|
| 786 | + } |
|
| 753 | 787 | |
| 754 | 788 | // What gets updated? |
| 755 | 789 | $db_key = isset($field['save_key']) ? $field['save_key'] : $key; |
@@ -777,12 +811,13 @@ discard block |
||
| 777 | 811 | $field['cast_type'] = empty($field['cast_type']) ? $field['type'] : $field['cast_type']; |
| 778 | 812 | |
| 779 | 813 | // Finally, clean up certain types. |
| 780 | - if ($field['cast_type'] == 'int') |
|
| 781 | - $_POST[$key] = (int) $_POST[$key]; |
|
| 782 | - elseif ($field['cast_type'] == 'float') |
|
| 783 | - $_POST[$key] = (float) $_POST[$key]; |
|
| 784 | - elseif ($field['cast_type'] == 'check') |
|
| 785 | - $_POST[$key] = !empty($_POST[$key]) ? 1 : 0; |
|
| 814 | + if ($field['cast_type'] == 'int') { |
|
| 815 | + $_POST[$key] = (int) $_POST[$key]; |
|
| 816 | + } elseif ($field['cast_type'] == 'float') { |
|
| 817 | + $_POST[$key] = (float) $_POST[$key]; |
|
| 818 | + } elseif ($field['cast_type'] == 'check') { |
|
| 819 | + $_POST[$key] = !empty($_POST[$key]) ? 1 : 0; |
|
| 820 | + } |
|
| 786 | 821 | |
| 787 | 822 | // If we got here we're doing OK. |
| 788 | 823 | if ($field['type'] != 'hidden' && (!isset($old_profile[$key]) || $_POST[$key] != $old_profile[$key])) |
@@ -793,11 +828,12 @@ discard block |
||
| 793 | 828 | $cur_profile[$key] = $_POST[$key]; |
| 794 | 829 | |
| 795 | 830 | // Are we logging it? |
| 796 | - if (!empty($field['log_change']) && isset($old_profile[$key])) |
|
| 797 | - $context['log_changes'][$key] = array( |
|
| 831 | + if (!empty($field['log_change']) && isset($old_profile[$key])) { |
|
| 832 | + $context['log_changes'][$key] = array( |
|
| 798 | 833 | 'previous' => $old_profile[$key], |
| 799 | 834 | 'new' => $_POST[$key], |
| 800 | 835 | ); |
| 836 | + } |
|
| 801 | 837 | } |
| 802 | 838 | |
| 803 | 839 | // Logging group changes are a bit different... |
@@ -830,10 +866,11 @@ discard block |
||
| 830 | 866 | { |
| 831 | 867 | foreach ($groups as $id => $group) |
| 832 | 868 | { |
| 833 | - if (isset($context['member_groups'][$group])) |
|
| 834 | - $additional_groups[$type][$id] = $context['member_groups'][$group]['name']; |
|
| 835 | - else |
|
| 836 | - unset($additional_groups[$type][$id]); |
|
| 869 | + if (isset($context['member_groups'][$group])) { |
|
| 870 | + $additional_groups[$type][$id] = $context['member_groups'][$group]['name']; |
|
| 871 | + } else { |
|
| 872 | + unset($additional_groups[$type][$id]); |
|
| 873 | + } |
|
| 837 | 874 | } |
| 838 | 875 | $additional_groups[$type] = implode(', ', $additional_groups[$type]); |
| 839 | 876 | } |
@@ -844,10 +881,11 @@ discard block |
||
| 844 | 881 | } |
| 845 | 882 | |
| 846 | 883 | // @todo Temporary |
| 847 | - if ($context['user']['is_owner']) |
|
| 848 | - $changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own')); |
|
| 849 | - else |
|
| 850 | - $changeOther = allowedTo('profile_extra_any'); |
|
| 884 | + if ($context['user']['is_owner']) { |
|
| 885 | + $changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own')); |
|
| 886 | + } else { |
|
| 887 | + $changeOther = allowedTo('profile_extra_any'); |
|
| 888 | + } |
|
| 851 | 889 | if ($changeOther && empty($post_errors)) |
| 852 | 890 | { |
| 853 | 891 | makeThemeChanges($context['id_member'], isset($_POST['id_theme']) ? (int) $_POST['id_theme'] : $old_profile['id_theme']); |
@@ -855,8 +893,9 @@ discard block |
||
| 855 | 893 | { |
| 856 | 894 | $custom_fields_errors = makeCustomFieldChanges($context['id_member'], $_REQUEST['sa'], false, true); |
| 857 | 895 | |
| 858 | - if (!empty($custom_fields_errors)) |
|
| 859 | - $post_errors = array_merge($post_errors, $custom_fields_errors); |
|
| 896 | + if (!empty($custom_fields_errors)) { |
|
| 897 | + $post_errors = array_merge($post_errors, $custom_fields_errors); |
|
| 898 | + } |
|
| 860 | 899 | } |
| 861 | 900 | } |
| 862 | 901 | |
@@ -883,8 +922,7 @@ discard block |
||
| 883 | 922 | { |
| 884 | 923 | $changeIdentity = allowedTo(array('profile_identity_any', 'profile_identity_own', 'profile_password_any', 'profile_password_own')); |
| 885 | 924 | $changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own', 'profile_website_any', 'profile_website_own', 'profile_signature_any', 'profile_signature_own')); |
| 886 | - } |
|
| 887 | - else |
|
| 925 | + } else |
|
| 888 | 926 | { |
| 889 | 927 | $changeIdentity = allowedTo('profile_identity_any', 'profile_signature_any'); |
| 890 | 928 | $changeOther = allowedTo('profile_extra_any', 'profile_website_any', 'profile_signature_any'); |
@@ -899,22 +937,25 @@ discard block |
||
| 899 | 937 | 'ignore_boards', |
| 900 | 938 | ); |
| 901 | 939 | |
| 902 | - if (isset($_POST['sa']) && $_POST['sa'] == 'ignoreboards' && empty($_POST['ignore_brd'])) |
|
| 903 | - $_POST['ignore_brd'] = array(); |
|
| 940 | + if (isset($_POST['sa']) && $_POST['sa'] == 'ignoreboards' && empty($_POST['ignore_brd'])) { |
|
| 941 | + $_POST['ignore_brd'] = array(); |
|
| 942 | + } |
|
| 904 | 943 | |
| 905 | 944 | unset($_POST['ignore_boards']); // Whatever it is set to is a dirty filthy thing. Kinda like our minds. |
| 906 | 945 | if (isset($_POST['ignore_brd'])) |
| 907 | 946 | { |
| 908 | - if (!is_array($_POST['ignore_brd'])) |
|
| 909 | - $_POST['ignore_brd'] = array($_POST['ignore_brd']); |
|
| 947 | + if (!is_array($_POST['ignore_brd'])) { |
|
| 948 | + $_POST['ignore_brd'] = array($_POST['ignore_brd']); |
|
| 949 | + } |
|
| 910 | 950 | |
| 911 | 951 | foreach ($_POST['ignore_brd'] as $k => $d) |
| 912 | 952 | { |
| 913 | 953 | $d = (int) $d; |
| 914 | - if ($d != 0) |
|
| 915 | - $_POST['ignore_brd'][$k] = $d; |
|
| 916 | - else |
|
| 917 | - unset($_POST['ignore_brd'][$k]); |
|
| 954 | + if ($d != 0) { |
|
| 955 | + $_POST['ignore_brd'][$k] = $d; |
|
| 956 | + } else { |
|
| 957 | + unset($_POST['ignore_brd'][$k]); |
|
| 958 | + } |
|
| 918 | 959 | } |
| 919 | 960 | $_POST['ignore_boards'] = implode(',', $_POST['ignore_brd']); |
| 920 | 961 | unset($_POST['ignore_brd']); |
@@ -927,21 +968,26 @@ discard block |
||
| 927 | 968 | makeThemeChanges($memID, isset($_POST['id_theme']) ? (int) $_POST['id_theme'] : $old_profile['id_theme']); |
| 928 | 969 | //makeAvatarChanges($memID, $post_errors); |
| 929 | 970 | |
| 930 | - if (!empty($_REQUEST['sa'])) |
|
| 931 | - makeCustomFieldChanges($memID, $_REQUEST['sa'], false); |
|
| 971 | + if (!empty($_REQUEST['sa'])) { |
|
| 972 | + makeCustomFieldChanges($memID, $_REQUEST['sa'], false); |
|
| 973 | + } |
|
| 932 | 974 | |
| 933 | - foreach ($profile_bools as $var) |
|
| 934 | - if (isset($_POST[$var])) |
|
| 975 | + foreach ($profile_bools as $var) { |
|
| 976 | + if (isset($_POST[$var])) |
|
| 935 | 977 | $profile_vars[$var] = empty($_POST[$var]) ? '0' : '1'; |
| 936 | - foreach ($profile_ints as $var) |
|
| 937 | - if (isset($_POST[$var])) |
|
| 978 | + } |
|
| 979 | + foreach ($profile_ints as $var) { |
|
| 980 | + if (isset($_POST[$var])) |
|
| 938 | 981 | $profile_vars[$var] = $_POST[$var] != '' ? (int) $_POST[$var] : ''; |
| 939 | - foreach ($profile_floats as $var) |
|
| 940 | - if (isset($_POST[$var])) |
|
| 982 | + } |
|
| 983 | + foreach ($profile_floats as $var) { |
|
| 984 | + if (isset($_POST[$var])) |
|
| 941 | 985 | $profile_vars[$var] = (float) $_POST[$var]; |
| 942 | - foreach ($profile_strings as $var) |
|
| 943 | - if (isset($_POST[$var])) |
|
| 986 | + } |
|
| 987 | + foreach ($profile_strings as $var) { |
|
| 988 | + if (isset($_POST[$var])) |
|
| 944 | 989 | $profile_vars[$var] = $_POST[$var]; |
| 990 | + } |
|
| 945 | 991 | } |
| 946 | 992 | } |
| 947 | 993 | |
@@ -975,8 +1021,9 @@ discard block |
||
| 975 | 1021 | ); |
| 976 | 1022 | |
| 977 | 1023 | // Can't change reserved vars. |
| 978 | - if ((isset($_POST['options']) && count(array_intersect(array_keys($_POST['options']), $reservedVars)) != 0) || (isset($_POST['default_options']) && count(array_intersect(array_keys($_POST['default_options']), $reservedVars)) != 0)) |
|
| 979 | - fatal_lang_error('no_access', false); |
|
| 1024 | + if ((isset($_POST['options']) && count(array_intersect(array_keys($_POST['options']), $reservedVars)) != 0) || (isset($_POST['default_options']) && count(array_intersect(array_keys($_POST['default_options']), $reservedVars)) != 0)) { |
|
| 1025 | + fatal_lang_error('no_access', false); |
|
| 1026 | + } |
|
| 980 | 1027 | |
| 981 | 1028 | // Don't allow any overriding of custom fields with default or non-default options. |
| 982 | 1029 | $request = $smcFunc['db_query']('', ' |
@@ -988,8 +1035,9 @@ discard block |
||
| 988 | 1035 | ) |
| 989 | 1036 | ); |
| 990 | 1037 | $custom_fields = array(); |
| 991 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 992 | - $custom_fields[] = $row['col_name']; |
|
| 1038 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1039 | + $custom_fields[] = $row['col_name']; |
|
| 1040 | + } |
|
| 993 | 1041 | $smcFunc['db_free_result']($request); |
| 994 | 1042 | |
| 995 | 1043 | // These are the theme changes... |
@@ -998,33 +1046,39 @@ discard block |
||
| 998 | 1046 | { |
| 999 | 1047 | foreach ($_POST['options'] as $opt => $val) |
| 1000 | 1048 | { |
| 1001 | - if (in_array($opt, $custom_fields)) |
|
| 1002 | - continue; |
|
| 1049 | + if (in_array($opt, $custom_fields)) { |
|
| 1050 | + continue; |
|
| 1051 | + } |
|
| 1003 | 1052 | |
| 1004 | 1053 | // These need to be controlled. |
| 1005 | - if ($opt == 'topics_per_page' || $opt == 'messages_per_page') |
|
| 1006 | - $val = max(0, min($val, 50)); |
|
| 1054 | + if ($opt == 'topics_per_page' || $opt == 'messages_per_page') { |
|
| 1055 | + $val = max(0, min($val, 50)); |
|
| 1056 | + } |
|
| 1007 | 1057 | // We don't set this per theme anymore. |
| 1008 | - elseif ($opt == 'allow_no_censored') |
|
| 1009 | - continue; |
|
| 1058 | + elseif ($opt == 'allow_no_censored') { |
|
| 1059 | + continue; |
|
| 1060 | + } |
|
| 1010 | 1061 | |
| 1011 | 1062 | $themeSetArray[] = array($memID, $id_theme, $opt, is_array($val) ? implode(',', $val) : $val); |
| 1012 | 1063 | } |
| 1013 | 1064 | } |
| 1014 | 1065 | |
| 1015 | 1066 | $erase_options = array(); |
| 1016 | - if (isset($_POST['default_options']) && is_array($_POST['default_options'])) |
|
| 1017 | - foreach ($_POST['default_options'] as $opt => $val) |
|
| 1067 | + if (isset($_POST['default_options']) && is_array($_POST['default_options'])) { |
|
| 1068 | + foreach ($_POST['default_options'] as $opt => $val) |
|
| 1018 | 1069 | { |
| 1019 | 1070 | if (in_array($opt, $custom_fields)) |
| 1020 | 1071 | continue; |
| 1072 | + } |
|
| 1021 | 1073 | |
| 1022 | 1074 | // These need to be controlled. |
| 1023 | - if ($opt == 'topics_per_page' || $opt == 'messages_per_page') |
|
| 1024 | - $val = max(0, min($val, 50)); |
|
| 1075 | + if ($opt == 'topics_per_page' || $opt == 'messages_per_page') { |
|
| 1076 | + $val = max(0, min($val, 50)); |
|
| 1077 | + } |
|
| 1025 | 1078 | // Only let admins and owners change the censor. |
| 1026 | - elseif ($opt == 'allow_no_censored' && !$user_info['is_admin'] && !$context['user']['is_owner']) |
|
| 1027 | - continue; |
|
| 1079 | + elseif ($opt == 'allow_no_censored' && !$user_info['is_admin'] && !$context['user']['is_owner']) { |
|
| 1080 | + continue; |
|
| 1081 | + } |
|
| 1028 | 1082 | |
| 1029 | 1083 | $themeSetArray[] = array($memID, 1, $opt, is_array($val) ? implode(',', $val) : $val); |
| 1030 | 1084 | $erase_options[] = $opt; |
@@ -1060,8 +1114,9 @@ discard block |
||
| 1060 | 1114 | |
| 1061 | 1115 | // Admins can choose any theme, even if it's not enabled... |
| 1062 | 1116 | $themes = allowedTo('admin_forum') ? explode(',', $modSettings['knownThemes']) : explode(',', $modSettings['enableThemes']); |
| 1063 | - foreach ($themes as $t) |
|
| 1064 | - cache_put_data('theme_settings-' . $t . ':' . $memID, null, 60); |
|
| 1117 | + foreach ($themes as $t) { |
|
| 1118 | + cache_put_data('theme_settings-' . $t . ':' . $memID, null, 60); |
|
| 1119 | + } |
|
| 1065 | 1120 | } |
| 1066 | 1121 | } |
| 1067 | 1122 | |
@@ -1080,8 +1135,9 @@ discard block |
||
| 1080 | 1135 | if (isset($_POST['edit_notify_boards']) && !empty($_POST['notify_boards'])) |
| 1081 | 1136 | { |
| 1082 | 1137 | // Make sure only integers are deleted. |
| 1083 | - foreach ($_POST['notify_boards'] as $index => $id) |
|
| 1084 | - $_POST['notify_boards'][$index] = (int) $id; |
|
| 1138 | + foreach ($_POST['notify_boards'] as $index => $id) { |
|
| 1139 | + $_POST['notify_boards'][$index] = (int) $id; |
|
| 1140 | + } |
|
| 1085 | 1141 | |
| 1086 | 1142 | // id_board = 0 is reserved for topic notifications. |
| 1087 | 1143 | $_POST['notify_boards'] = array_diff($_POST['notify_boards'], array(0)); |
@@ -1100,8 +1156,9 @@ discard block |
||
| 1100 | 1156 | // We are editing topic notifications...... |
| 1101 | 1157 | elseif (isset($_POST['edit_notify_topics']) && !empty($_POST['notify_topics'])) |
| 1102 | 1158 | { |
| 1103 | - foreach ($_POST['notify_topics'] as $index => $id) |
|
| 1104 | - $_POST['notify_topics'][$index] = (int) $id; |
|
| 1159 | + foreach ($_POST['notify_topics'] as $index => $id) { |
|
| 1160 | + $_POST['notify_topics'][$index] = (int) $id; |
|
| 1161 | + } |
|
| 1105 | 1162 | |
| 1106 | 1163 | // Make sure there are no zeros left. |
| 1107 | 1164 | $_POST['notify_topics'] = array_diff($_POST['notify_topics'], array(0)); |
@@ -1115,16 +1172,18 @@ discard block |
||
| 1115 | 1172 | 'selected_member' => $memID, |
| 1116 | 1173 | ) |
| 1117 | 1174 | ); |
| 1118 | - foreach ($_POST['notify_topics'] as $topic) |
|
| 1119 | - setNotifyPrefs($memID, array('topic_notify_' . $topic => 0)); |
|
| 1175 | + foreach ($_POST['notify_topics'] as $topic) { |
|
| 1176 | + setNotifyPrefs($memID, array('topic_notify_' . $topic => 0)); |
|
| 1177 | + } |
|
| 1120 | 1178 | } |
| 1121 | 1179 | |
| 1122 | 1180 | // We are removing topic preferences |
| 1123 | 1181 | elseif (isset($_POST['remove_notify_topics']) && !empty($_POST['notify_topics'])) |
| 1124 | 1182 | { |
| 1125 | 1183 | $prefs = array(); |
| 1126 | - foreach ($_POST['notify_topics'] as $topic) |
|
| 1127 | - $prefs[] = 'topic_notify_' . $topic; |
|
| 1184 | + foreach ($_POST['notify_topics'] as $topic) { |
|
| 1185 | + $prefs[] = 'topic_notify_' . $topic; |
|
| 1186 | + } |
|
| 1128 | 1187 | deleteNotifyPrefs($memID, $prefs); |
| 1129 | 1188 | } |
| 1130 | 1189 | |
@@ -1132,8 +1191,9 @@ discard block |
||
| 1132 | 1191 | elseif (isset($_POST['remove_notify_board']) && !empty($_POST['notify_boards'])) |
| 1133 | 1192 | { |
| 1134 | 1193 | $prefs = array(); |
| 1135 | - foreach ($_POST['notify_boards'] as $board) |
|
| 1136 | - $prefs[] = 'board_notify_' . $board; |
|
| 1194 | + foreach ($_POST['notify_boards'] as $board) { |
|
| 1195 | + $prefs[] = 'board_notify_' . $board; |
|
| 1196 | + } |
|
| 1137 | 1197 | deleteNotifyPrefs($memID, $prefs); |
| 1138 | 1198 | } |
| 1139 | 1199 | } |
@@ -1154,8 +1214,9 @@ discard block |
||
| 1154 | 1214 | |
| 1155 | 1215 | $errors = array(); |
| 1156 | 1216 | |
| 1157 | - if ($sanitize && isset($_POST['customfield'])) |
|
| 1158 | - $_POST['customfield'] = htmlspecialchars__recursive($_POST['customfield']); |
|
| 1217 | + if ($sanitize && isset($_POST['customfield'])) { |
|
| 1218 | + $_POST['customfield'] = htmlspecialchars__recursive($_POST['customfield']); |
|
| 1219 | + } |
|
| 1159 | 1220 | |
| 1160 | 1221 | $where = $area == 'register' ? 'show_reg != 0' : 'show_profile = {string:area}'; |
| 1161 | 1222 | |
@@ -1180,48 +1241,49 @@ discard block |
||
| 1180 | 1241 | - The data is not invisible to users but editable by the owner (or if it is the user is not the owner) |
| 1181 | 1242 | - The area isn't registration, and if it is that the field is not supposed to be shown there. |
| 1182 | 1243 | */ |
| 1183 | - if ($row['private'] != 0 && !allowedTo('admin_forum') && ($memID != $user_info['id'] || $row['private'] != 2) && ($area != 'register' || $row['show_reg'] == 0)) |
|
| 1184 | - continue; |
|
| 1244 | + if ($row['private'] != 0 && !allowedTo('admin_forum') && ($memID != $user_info['id'] || $row['private'] != 2) && ($area != 'register' || $row['show_reg'] == 0)) { |
|
| 1245 | + continue; |
|
| 1246 | + } |
|
| 1185 | 1247 | |
| 1186 | 1248 | // Validate the user data. |
| 1187 | - if ($row['field_type'] == 'check') |
|
| 1188 | - $value = isset($_POST['customfield'][$row['col_name']]) ? 1 : 0; |
|
| 1189 | - elseif ($row['field_type'] == 'select' || $row['field_type'] == 'radio') |
|
| 1249 | + if ($row['field_type'] == 'check') { |
|
| 1250 | + $value = isset($_POST['customfield'][$row['col_name']]) ? 1 : 0; |
|
| 1251 | + } elseif ($row['field_type'] == 'select' || $row['field_type'] == 'radio') |
|
| 1190 | 1252 | { |
| 1191 | 1253 | $value = $row['default_value']; |
| 1192 | - foreach (explode(',', $row['field_options']) as $k => $v) |
|
| 1193 | - if (isset($_POST['customfield'][$row['col_name']]) && $_POST['customfield'][$row['col_name']] == $k) |
|
| 1254 | + foreach (explode(',', $row['field_options']) as $k => $v) { |
|
| 1255 | + if (isset($_POST['customfield'][$row['col_name']]) && $_POST['customfield'][$row['col_name']] == $k) |
|
| 1194 | 1256 | $value = $v; |
| 1257 | + } |
|
| 1195 | 1258 | } |
| 1196 | 1259 | // Otherwise some form of text! |
| 1197 | 1260 | else |
| 1198 | 1261 | { |
| 1199 | 1262 | $value = isset($_POST['customfield'][$row['col_name']]) ? $_POST['customfield'][$row['col_name']] : ''; |
| 1200 | - if ($row['field_length']) |
|
| 1201 | - $value = $smcFunc['substr']($value, 0, $row['field_length']); |
|
| 1263 | + if ($row['field_length']) { |
|
| 1264 | + $value = $smcFunc['substr']($value, 0, $row['field_length']); |
|
| 1265 | + } |
|
| 1202 | 1266 | |
| 1203 | 1267 | // Any masks? |
| 1204 | 1268 | if ($row['field_type'] == 'text' && !empty($row['mask']) && $row['mask'] != 'none') |
| 1205 | 1269 | { |
| 1206 | 1270 | if ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255)) |
| 1207 | 1271 | { |
| 1208 | - if ($returnErrors) |
|
| 1209 | - $errors[] = 'custom_field_mail_fail'; |
|
| 1210 | - |
|
| 1211 | - else |
|
| 1212 | - $value = ''; |
|
| 1213 | - } |
|
| 1214 | - elseif ($row['mask'] == 'number') |
|
| 1272 | + if ($returnErrors) { |
|
| 1273 | + $errors[] = 'custom_field_mail_fail'; |
|
| 1274 | + } else { |
|
| 1275 | + $value = ''; |
|
| 1276 | + } |
|
| 1277 | + } elseif ($row['mask'] == 'number') |
|
| 1215 | 1278 | { |
| 1216 | 1279 | $value = (int) $value; |
| 1217 | - } |
|
| 1218 | - elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) |
|
| 1280 | + } elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) |
|
| 1219 | 1281 | { |
| 1220 | - if ($returnErrors) |
|
| 1221 | - $errors[] = 'custom_field_regex_fail'; |
|
| 1222 | - |
|
| 1223 | - else |
|
| 1224 | - $value = ''; |
|
| 1282 | + if ($returnErrors) { |
|
| 1283 | + $errors[] = 'custom_field_regex_fail'; |
|
| 1284 | + } else { |
|
| 1285 | + $value = ''; |
|
| 1286 | + } |
|
| 1225 | 1287 | } |
| 1226 | 1288 | } |
| 1227 | 1289 | } |
@@ -1248,8 +1310,9 @@ discard block |
||
| 1248 | 1310 | $hook_errors = array(); |
| 1249 | 1311 | $hook_errors = call_integration_hook('integrate_save_custom_profile_fields', array(&$changes, &$log_changes, &$errors, $returnErrors, $memID, $area, $sanitize)); |
| 1250 | 1312 | |
| 1251 | - if (!empty($hook_errors) && is_array($hook_errors)) |
|
| 1252 | - $errors = array_merge($errors, $hook_errors); |
|
| 1313 | + if (!empty($hook_errors) && is_array($hook_errors)) { |
|
| 1314 | + $errors = array_merge($errors, $hook_errors); |
|
| 1315 | + } |
|
| 1253 | 1316 | |
| 1254 | 1317 | // Make those changes! |
| 1255 | 1318 | if (!empty($changes) && empty($context['password_auth_failed']) && empty($errors)) |
@@ -1267,9 +1330,10 @@ discard block |
||
| 1267 | 1330 | } |
| 1268 | 1331 | } |
| 1269 | 1332 | |
| 1270 | - if ($returnErrors) |
|
| 1271 | - return $errors; |
|
| 1272 | -} |
|
| 1333 | + if ($returnErrors) { |
|
| 1334 | + return $errors; |
|
| 1335 | + } |
|
| 1336 | + } |
|
| 1273 | 1337 | |
| 1274 | 1338 | /** |
| 1275 | 1339 | * Show all the users buddies, as well as a add/delete interface. |
@@ -1281,8 +1345,9 @@ discard block |
||
| 1281 | 1345 | global $context, $txt, $modSettings; |
| 1282 | 1346 | |
| 1283 | 1347 | // Do a quick check to ensure people aren't getting here illegally! |
| 1284 | - if (!$context['user']['is_owner'] || empty($modSettings['enable_buddylist'])) |
|
| 1285 | - fatal_lang_error('no_access', false); |
|
| 1348 | + if (!$context['user']['is_owner'] || empty($modSettings['enable_buddylist'])) { |
|
| 1349 | + fatal_lang_error('no_access', false); |
|
| 1350 | + } |
|
| 1286 | 1351 | |
| 1287 | 1352 | // Can we email the user direct? |
| 1288 | 1353 | $context['can_moderate_forum'] = allowedTo('moderate_forum'); |
@@ -1312,9 +1377,10 @@ discard block |
||
| 1312 | 1377 | $context['sub_template'] = $subActions[$context['list_area']][0]; |
| 1313 | 1378 | $call = call_helper($subActions[$context['list_area']][0], true); |
| 1314 | 1379 | |
| 1315 | - if (!empty($call)) |
|
| 1316 | - call_user_func($call, $memID); |
|
| 1317 | -} |
|
| 1380 | + if (!empty($call)) { |
|
| 1381 | + call_user_func($call, $memID); |
|
| 1382 | + } |
|
| 1383 | + } |
|
| 1318 | 1384 | |
| 1319 | 1385 | /** |
| 1320 | 1386 | * Show all the users buddies, as well as a add/delete interface. |
@@ -1328,9 +1394,10 @@ discard block |
||
| 1328 | 1394 | |
| 1329 | 1395 | // For making changes! |
| 1330 | 1396 | $buddiesArray = explode(',', $user_profile[$memID]['buddy_list']); |
| 1331 | - foreach ($buddiesArray as $k => $dummy) |
|
| 1332 | - if ($dummy == '') |
|
| 1397 | + foreach ($buddiesArray as $k => $dummy) { |
|
| 1398 | + if ($dummy == '') |
|
| 1333 | 1399 | unset($buddiesArray[$k]); |
| 1400 | + } |
|
| 1334 | 1401 | |
| 1335 | 1402 | // Removing a buddy? |
| 1336 | 1403 | if (isset($_GET['remove'])) |
@@ -1342,10 +1409,11 @@ discard block |
||
| 1342 | 1409 | $_SESSION['prf-save'] = $txt['could_not_remove_person']; |
| 1343 | 1410 | |
| 1344 | 1411 | // Heh, I'm lazy, do it the easy way... |
| 1345 | - foreach ($buddiesArray as $key => $buddy) |
|
| 1346 | - if ($buddy == (int) $_GET['remove']) |
|
| 1412 | + foreach ($buddiesArray as $key => $buddy) { |
|
| 1413 | + if ($buddy == (int) $_GET['remove']) |
|
| 1347 | 1414 | { |
| 1348 | 1415 | unset($buddiesArray[$key]); |
| 1416 | + } |
|
| 1349 | 1417 | $_SESSION['prf-save'] = true; |
| 1350 | 1418 | } |
| 1351 | 1419 | |
@@ -1355,8 +1423,7 @@ discard block |
||
| 1355 | 1423 | |
| 1356 | 1424 | // Redirect off the page because we don't like all this ugly query stuff to stick in the history. |
| 1357 | 1425 | redirectexit('action=profile;area=lists;sa=buddies;u=' . $memID); |
| 1358 | - } |
|
| 1359 | - elseif (isset($_POST['new_buddy'])) |
|
| 1426 | + } elseif (isset($_POST['new_buddy'])) |
|
| 1360 | 1427 | { |
| 1361 | 1428 | checkSession(); |
| 1362 | 1429 | |
@@ -1369,8 +1436,9 @@ discard block |
||
| 1369 | 1436 | { |
| 1370 | 1437 | $new_buddies[$k] = strtr(trim($new_buddies[$k]), array('\'' => ''')); |
| 1371 | 1438 | |
| 1372 | - if (strlen($new_buddies[$k]) == 0 || in_array($new_buddies[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) |
|
| 1373 | - unset($new_buddies[$k]); |
|
| 1439 | + if (strlen($new_buddies[$k]) == 0 || in_array($new_buddies[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) { |
|
| 1440 | + unset($new_buddies[$k]); |
|
| 1441 | + } |
|
| 1374 | 1442 | } |
| 1375 | 1443 | |
| 1376 | 1444 | call_integration_hook('integrate_add_buddies', array($memID, &$new_buddies)); |
@@ -1390,16 +1458,18 @@ discard block |
||
| 1390 | 1458 | ) |
| 1391 | 1459 | ); |
| 1392 | 1460 | |
| 1393 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 1394 | - $_SESSION['prf-save'] = true; |
|
| 1461 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 1462 | + $_SESSION['prf-save'] = true; |
|
| 1463 | + } |
|
| 1395 | 1464 | |
| 1396 | 1465 | // Add the new member to the buddies array. |
| 1397 | 1466 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1398 | 1467 | { |
| 1399 | - if (in_array($row['id_member'], $buddiesArray)) |
|
| 1400 | - continue; |
|
| 1401 | - else |
|
| 1402 | - $buddiesArray[] = (int) $row['id_member']; |
|
| 1468 | + if (in_array($row['id_member'], $buddiesArray)) { |
|
| 1469 | + continue; |
|
| 1470 | + } else { |
|
| 1471 | + $buddiesArray[] = (int) $row['id_member']; |
|
| 1472 | + } |
|
| 1403 | 1473 | } |
| 1404 | 1474 | $smcFunc['db_free_result']($request); |
| 1405 | 1475 | |
@@ -1429,18 +1499,20 @@ discard block |
||
| 1429 | 1499 | |
| 1430 | 1500 | $context['custom_pf'] = array(); |
| 1431 | 1501 | $disabled_fields = isset($modSettings['disabled_profile_fields']) ? array_flip(explode(',', $modSettings['disabled_profile_fields'])) : array(); |
| 1432 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1433 | - if (!isset($disabled_fields[$row['col_name']])) |
|
| 1502 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1503 | + if (!isset($disabled_fields[$row['col_name']])) |
|
| 1434 | 1504 | $context['custom_pf'][$row['col_name']] = array( |
| 1435 | 1505 | 'label' => $row['field_name'], |
| 1436 | 1506 | 'type' => $row['field_type'], |
| 1437 | 1507 | 'bbc' => !empty($row['bbc']), |
| 1438 | 1508 | 'enclose' => $row['enclose'], |
| 1439 | 1509 | ); |
| 1510 | + } |
|
| 1440 | 1511 | |
| 1441 | 1512 | // Gotta disable the gender option. |
| 1442 | - if (isset($context['custom_pf']['cust_gender']) && $context['custom_pf']['cust_gender'] == 'Disabled') |
|
| 1443 | - unset($context['custom_pf']['cust_gender']); |
|
| 1513 | + if (isset($context['custom_pf']['cust_gender']) && $context['custom_pf']['cust_gender'] == 'Disabled') { |
|
| 1514 | + unset($context['custom_pf']['cust_gender']); |
|
| 1515 | + } |
|
| 1444 | 1516 | |
| 1445 | 1517 | $smcFunc['db_free_result']($request); |
| 1446 | 1518 | |
@@ -1457,8 +1529,9 @@ discard block |
||
| 1457 | 1529 | 'buddy_list_count' => substr_count($user_profile[$memID]['buddy_list'], ',') + 1, |
| 1458 | 1530 | ) |
| 1459 | 1531 | ); |
| 1460 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 1461 | - $buddies[] = $row['id_member']; |
|
| 1532 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 1533 | + $buddies[] = $row['id_member']; |
|
| 1534 | + } |
|
| 1462 | 1535 | $smcFunc['db_free_result']($result); |
| 1463 | 1536 | } |
| 1464 | 1537 | |
@@ -1486,30 +1559,32 @@ discard block |
||
| 1486 | 1559 | continue; |
| 1487 | 1560 | } |
| 1488 | 1561 | |
| 1489 | - if ($column['bbc'] && !empty($context['buddies'][$buddy]['options'][$key])) |
|
| 1490 | - $context['buddies'][$buddy]['options'][$key] = strip_tags(parse_bbc($context['buddies'][$buddy]['options'][$key])); |
|
| 1491 | - |
|
| 1492 | - elseif ($column['type'] == 'check') |
|
| 1493 | - $context['buddies'][$buddy]['options'][$key] = $context['buddies'][$buddy]['options'][$key] == 0 ? $txt['no'] : $txt['yes']; |
|
| 1562 | + if ($column['bbc'] && !empty($context['buddies'][$buddy]['options'][$key])) { |
|
| 1563 | + $context['buddies'][$buddy]['options'][$key] = strip_tags(parse_bbc($context['buddies'][$buddy]['options'][$key])); |
|
| 1564 | + } elseif ($column['type'] == 'check') { |
|
| 1565 | + $context['buddies'][$buddy]['options'][$key] = $context['buddies'][$buddy]['options'][$key] == 0 ? $txt['no'] : $txt['yes']; |
|
| 1566 | + } |
|
| 1494 | 1567 | |
| 1495 | 1568 | // Enclosing the user input within some other text? |
| 1496 | - if (!empty($column['enclose']) && !empty($context['buddies'][$buddy]['options'][$key])) |
|
| 1497 | - $context['buddies'][$buddy]['options'][$key] = strtr($column['enclose'], array( |
|
| 1569 | + if (!empty($column['enclose']) && !empty($context['buddies'][$buddy]['options'][$key])) { |
|
| 1570 | + $context['buddies'][$buddy]['options'][$key] = strtr($column['enclose'], array( |
|
| 1498 | 1571 | '{SCRIPTURL}' => $scripturl, |
| 1499 | 1572 | '{IMAGES_URL}' => $settings['images_url'], |
| 1500 | 1573 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
| 1501 | 1574 | '{INPUT}' => $context['buddies'][$buddy]['options'][$key], |
| 1502 | 1575 | )); |
| 1576 | + } |
|
| 1503 | 1577 | } |
| 1504 | 1578 | } |
| 1505 | 1579 | } |
| 1506 | 1580 | |
| 1507 | 1581 | if (isset($_SESSION['prf-save'])) |
| 1508 | 1582 | { |
| 1509 | - if ($_SESSION['prf-save'] === true) |
|
| 1510 | - $context['saved_successful'] = true; |
|
| 1511 | - else |
|
| 1512 | - $context['saved_failed'] = $_SESSION['prf-save']; |
|
| 1583 | + if ($_SESSION['prf-save'] === true) { |
|
| 1584 | + $context['saved_successful'] = true; |
|
| 1585 | + } else { |
|
| 1586 | + $context['saved_failed'] = $_SESSION['prf-save']; |
|
| 1587 | + } |
|
| 1513 | 1588 | |
| 1514 | 1589 | unset($_SESSION['prf-save']); |
| 1515 | 1590 | } |
@@ -1529,9 +1604,10 @@ discard block |
||
| 1529 | 1604 | |
| 1530 | 1605 | // For making changes! |
| 1531 | 1606 | $ignoreArray = explode(',', $user_profile[$memID]['pm_ignore_list']); |
| 1532 | - foreach ($ignoreArray as $k => $dummy) |
|
| 1533 | - if ($dummy == '') |
|
| 1607 | + foreach ($ignoreArray as $k => $dummy) { |
|
| 1608 | + if ($dummy == '') |
|
| 1534 | 1609 | unset($ignoreArray[$k]); |
| 1610 | + } |
|
| 1535 | 1611 | |
| 1536 | 1612 | // Removing a member from the ignore list? |
| 1537 | 1613 | if (isset($_GET['remove'])) |
@@ -1541,10 +1617,11 @@ discard block |
||
| 1541 | 1617 | $_SESSION['prf-save'] = $txt['could_not_remove_person']; |
| 1542 | 1618 | |
| 1543 | 1619 | // Heh, I'm lazy, do it the easy way... |
| 1544 | - foreach ($ignoreArray as $key => $id_remove) |
|
| 1545 | - if ($id_remove == (int) $_GET['remove']) |
|
| 1620 | + foreach ($ignoreArray as $key => $id_remove) { |
|
| 1621 | + if ($id_remove == (int) $_GET['remove']) |
|
| 1546 | 1622 | { |
| 1547 | 1623 | unset($ignoreArray[$key]); |
| 1624 | + } |
|
| 1548 | 1625 | $_SESSION['prf-save'] = true; |
| 1549 | 1626 | } |
| 1550 | 1627 | |
@@ -1554,8 +1631,7 @@ discard block |
||
| 1554 | 1631 | |
| 1555 | 1632 | // Redirect off the page because we don't like all this ugly query stuff to stick in the history. |
| 1556 | 1633 | redirectexit('action=profile;area=lists;sa=ignore;u=' . $memID); |
| 1557 | - } |
|
| 1558 | - elseif (isset($_POST['new_ignore'])) |
|
| 1634 | + } elseif (isset($_POST['new_ignore'])) |
|
| 1559 | 1635 | { |
| 1560 | 1636 | checkSession(); |
| 1561 | 1637 | // Prepare the string for extraction... |
@@ -1567,8 +1643,9 @@ discard block |
||
| 1567 | 1643 | { |
| 1568 | 1644 | $new_entries[$k] = strtr(trim($new_entries[$k]), array('\'' => ''')); |
| 1569 | 1645 | |
| 1570 | - if (strlen($new_entries[$k]) == 0 || in_array($new_entries[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) |
|
| 1571 | - unset($new_entries[$k]); |
|
| 1646 | + if (strlen($new_entries[$k]) == 0 || in_array($new_entries[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) { |
|
| 1647 | + unset($new_entries[$k]); |
|
| 1648 | + } |
|
| 1572 | 1649 | } |
| 1573 | 1650 | |
| 1574 | 1651 | $_SESSION['prf-save'] = $txt['could_not_add_person']; |
@@ -1586,16 +1663,18 @@ discard block |
||
| 1586 | 1663 | ) |
| 1587 | 1664 | ); |
| 1588 | 1665 | |
| 1589 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 1590 | - $_SESSION['prf-save'] = true; |
|
| 1666 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 1667 | + $_SESSION['prf-save'] = true; |
|
| 1668 | + } |
|
| 1591 | 1669 | |
| 1592 | 1670 | // Add the new member to the buddies array. |
| 1593 | 1671 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1594 | 1672 | { |
| 1595 | - if (in_array($row['id_member'], $ignoreArray)) |
|
| 1596 | - continue; |
|
| 1597 | - else |
|
| 1598 | - $ignoreArray[] = (int) $row['id_member']; |
|
| 1673 | + if (in_array($row['id_member'], $ignoreArray)) { |
|
| 1674 | + continue; |
|
| 1675 | + } else { |
|
| 1676 | + $ignoreArray[] = (int) $row['id_member']; |
|
| 1677 | + } |
|
| 1599 | 1678 | } |
| 1600 | 1679 | $smcFunc['db_free_result']($request); |
| 1601 | 1680 | |
@@ -1624,8 +1703,9 @@ discard block |
||
| 1624 | 1703 | 'ignore_list_count' => substr_count($user_profile[$memID]['pm_ignore_list'], ',') + 1, |
| 1625 | 1704 | ) |
| 1626 | 1705 | ); |
| 1627 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 1628 | - $ignored[] = $row['id_member']; |
|
| 1706 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 1707 | + $ignored[] = $row['id_member']; |
|
| 1708 | + } |
|
| 1629 | 1709 | $smcFunc['db_free_result']($result); |
| 1630 | 1710 | } |
| 1631 | 1711 | |
@@ -1644,10 +1724,11 @@ discard block |
||
| 1644 | 1724 | |
| 1645 | 1725 | if (isset($_SESSION['prf-save'])) |
| 1646 | 1726 | { |
| 1647 | - if ($_SESSION['prf-save'] === true) |
|
| 1648 | - $context['saved_successful'] = true; |
|
| 1649 | - else |
|
| 1650 | - $context['saved_failed'] = $_SESSION['prf-save']; |
|
| 1727 | + if ($_SESSION['prf-save'] === true) { |
|
| 1728 | + $context['saved_successful'] = true; |
|
| 1729 | + } else { |
|
| 1730 | + $context['saved_failed'] = $_SESSION['prf-save']; |
|
| 1731 | + } |
|
| 1651 | 1732 | |
| 1652 | 1733 | unset($_SESSION['prf-save']); |
| 1653 | 1734 | } |
@@ -1663,8 +1744,9 @@ discard block |
||
| 1663 | 1744 | global $context, $txt; |
| 1664 | 1745 | |
| 1665 | 1746 | loadThemeOptions($memID); |
| 1666 | - if (allowedTo(array('profile_identity_own', 'profile_identity_any', 'profile_password_own', 'profile_password_any'))) |
|
| 1667 | - loadCustomFields($memID, 'account'); |
|
| 1747 | + if (allowedTo(array('profile_identity_own', 'profile_identity_any', 'profile_password_own', 'profile_password_any'))) { |
|
| 1748 | + loadCustomFields($memID, 'account'); |
|
| 1749 | + } |
|
| 1668 | 1750 | |
| 1669 | 1751 | $context['sub_template'] = 'edit_options'; |
| 1670 | 1752 | $context['page_desc'] = $txt['account_info']; |
@@ -1691,8 +1773,9 @@ discard block |
||
| 1691 | 1773 | global $context, $txt; |
| 1692 | 1774 | |
| 1693 | 1775 | loadThemeOptions($memID); |
| 1694 | - if (allowedTo(array('profile_forum_own', 'profile_forum_any'))) |
|
| 1695 | - loadCustomFields($memID, 'forumprofile'); |
|
| 1776 | + if (allowedTo(array('profile_forum_own', 'profile_forum_any'))) { |
|
| 1777 | + loadCustomFields($memID, 'forumprofile'); |
|
| 1778 | + } |
|
| 1696 | 1779 | |
| 1697 | 1780 | $context['sub_template'] = 'edit_options'; |
| 1698 | 1781 | $context['page_desc'] = $txt['forumProfile_info']; |
@@ -1725,18 +1808,21 @@ discard block |
||
| 1725 | 1808 | $dirs = array(); |
| 1726 | 1809 | $files = array(); |
| 1727 | 1810 | |
| 1728 | - if (!$dir) |
|
| 1729 | - return array(); |
|
| 1811 | + if (!$dir) { |
|
| 1812 | + return array(); |
|
| 1813 | + } |
|
| 1730 | 1814 | |
| 1731 | 1815 | while ($line = $dir->read()) |
| 1732 | 1816 | { |
| 1733 | - if (in_array($line, array('.', '..', 'blank.png', 'index.php'))) |
|
| 1734 | - continue; |
|
| 1817 | + if (in_array($line, array('.', '..', 'blank.png', 'index.php'))) { |
|
| 1818 | + continue; |
|
| 1819 | + } |
|
| 1735 | 1820 | |
| 1736 | - if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line)) |
|
| 1737 | - $dirs[] = $line; |
|
| 1738 | - else |
|
| 1739 | - $files[] = $line; |
|
| 1821 | + if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line)) { |
|
| 1822 | + $dirs[] = $line; |
|
| 1823 | + } else { |
|
| 1824 | + $files[] = $line; |
|
| 1825 | + } |
|
| 1740 | 1826 | } |
| 1741 | 1827 | $dir->close(); |
| 1742 | 1828 | |
@@ -1757,14 +1843,15 @@ discard block |
||
| 1757 | 1843 | foreach ($dirs as $line) |
| 1758 | 1844 | { |
| 1759 | 1845 | $tmp = getAvatars($directory . (!empty($directory) ? '/' : '') . $line, $level + 1); |
| 1760 | - if (!empty($tmp)) |
|
| 1761 | - $result[] = array( |
|
| 1846 | + if (!empty($tmp)) { |
|
| 1847 | + $result[] = array( |
|
| 1762 | 1848 | 'filename' => $smcFunc['htmlspecialchars']($line), |
| 1763 | 1849 | 'checked' => strpos($context['member']['avatar']['server_pic'], $line . '/') !== false, |
| 1764 | 1850 | 'name' => '[' . $smcFunc['htmlspecialchars'](str_replace('_', ' ', $line)) . ']', |
| 1765 | 1851 | 'is_dir' => true, |
| 1766 | 1852 | 'files' => $tmp |
| 1767 | 1853 | ); |
| 1854 | + } |
|
| 1768 | 1855 | unset($tmp); |
| 1769 | 1856 | } |
| 1770 | 1857 | |
@@ -1774,8 +1861,9 @@ discard block |
||
| 1774 | 1861 | $extension = substr(strrchr($line, '.'), 1); |
| 1775 | 1862 | |
| 1776 | 1863 | // Make sure it is an image. |
| 1777 | - if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0) |
|
| 1778 | - continue; |
|
| 1864 | + if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0) { |
|
| 1865 | + continue; |
|
| 1866 | + } |
|
| 1779 | 1867 | |
| 1780 | 1868 | $result[] = array( |
| 1781 | 1869 | 'filename' => $smcFunc['htmlspecialchars']($line), |
@@ -1783,8 +1871,9 @@ discard block |
||
| 1783 | 1871 | 'name' => $smcFunc['htmlspecialchars'](str_replace('_', ' ', $filename)), |
| 1784 | 1872 | 'is_dir' => false |
| 1785 | 1873 | ); |
| 1786 | - if ($level == 1) |
|
| 1787 | - $context['avatar_list'][] = $directory . '/' . $line; |
|
| 1874 | + if ($level == 1) { |
|
| 1875 | + $context['avatar_list'][] = $directory . '/' . $line; |
|
| 1876 | + } |
|
| 1788 | 1877 | } |
| 1789 | 1878 | |
| 1790 | 1879 | return $result; |
@@ -1800,8 +1889,9 @@ discard block |
||
| 1800 | 1889 | global $txt, $context; |
| 1801 | 1890 | |
| 1802 | 1891 | loadThemeOptions($memID); |
| 1803 | - if (allowedTo(array('profile_extra_own', 'profile_extra_any'))) |
|
| 1804 | - loadCustomFields($memID, 'theme'); |
|
| 1892 | + if (allowedTo(array('profile_extra_own', 'profile_extra_any'))) { |
|
| 1893 | + loadCustomFields($memID, 'theme'); |
|
| 1894 | + } |
|
| 1805 | 1895 | |
| 1806 | 1896 | $context['sub_template'] = 'edit_options'; |
| 1807 | 1897 | $context['page_desc'] = $txt['theme_info']; |
@@ -1855,16 +1945,19 @@ discard block |
||
| 1855 | 1945 | { |
| 1856 | 1946 | global $txt, $user_profile, $context, $modSettings, $smcFunc, $sourcedir; |
| 1857 | 1947 | |
| 1858 | - if (!isset($context['token_check'])) |
|
| 1859 | - $context['token_check'] = 'profile-nt' . $memID; |
|
| 1948 | + if (!isset($context['token_check'])) { |
|
| 1949 | + $context['token_check'] = 'profile-nt' . $memID; |
|
| 1950 | + } |
|
| 1860 | 1951 | |
| 1861 | 1952 | is_not_guest(); |
| 1862 | - if (!$context['user']['is_owner']) |
|
| 1863 | - isAllowedTo('profile_extra_any'); |
|
| 1953 | + if (!$context['user']['is_owner']) { |
|
| 1954 | + isAllowedTo('profile_extra_any'); |
|
| 1955 | + } |
|
| 1864 | 1956 | |
| 1865 | 1957 | // Set the post action if we're coming from the profile... |
| 1866 | - if (!isset($context['action'])) |
|
| 1867 | - $context['action'] = 'action=profile;area=notification;sa=alerts;u=' . $memID; |
|
| 1958 | + if (!isset($context['action'])) { |
|
| 1959 | + $context['action'] = 'action=profile;area=notification;sa=alerts;u=' . $memID; |
|
| 1960 | + } |
|
| 1868 | 1961 | |
| 1869 | 1962 | // What options are set |
| 1870 | 1963 | loadThemeOptions($memID); |
@@ -1951,28 +2044,34 @@ discard block |
||
| 1951 | 2044 | ); |
| 1952 | 2045 | |
| 1953 | 2046 | // There are certain things that are disabled at the group level. |
| 1954 | - if (empty($modSettings['cal_enabled'])) |
|
| 1955 | - unset($alert_types['calendar']); |
|
| 2047 | + if (empty($modSettings['cal_enabled'])) { |
|
| 2048 | + unset($alert_types['calendar']); |
|
| 2049 | + } |
|
| 1956 | 2050 | |
| 1957 | 2051 | // Disable paid subscriptions at group level if they're disabled |
| 1958 | - if (empty($modSettings['paid_enabled'])) |
|
| 1959 | - unset($alert_types['paidsubs']); |
|
| 2052 | + if (empty($modSettings['paid_enabled'])) { |
|
| 2053 | + unset($alert_types['paidsubs']); |
|
| 2054 | + } |
|
| 1960 | 2055 | |
| 1961 | 2056 | // Disable membergroup requests at group level if they're disabled |
| 1962 | - if (empty($modSettings['show_group_membership'])) |
|
| 1963 | - unset($alert_types['groupr'], $alert_types['members']['request_group']); |
|
| 2057 | + if (empty($modSettings['show_group_membership'])) { |
|
| 2058 | + unset($alert_types['groupr'], $alert_types['members']['request_group']); |
|
| 2059 | + } |
|
| 1964 | 2060 | |
| 1965 | 2061 | // Disable mentions if they're disabled |
| 1966 | - if (empty($modSettings['enable_mentions'])) |
|
| 1967 | - unset($alert_types['msg']['msg_mention']); |
|
| 2062 | + if (empty($modSettings['enable_mentions'])) { |
|
| 2063 | + unset($alert_types['msg']['msg_mention']); |
|
| 2064 | + } |
|
| 1968 | 2065 | |
| 1969 | 2066 | // Disable likes if they're disabled |
| 1970 | - if (empty($modSettings['enable_likes'])) |
|
| 1971 | - unset($alert_types['msg']['msg_like']); |
|
| 2067 | + if (empty($modSettings['enable_likes'])) { |
|
| 2068 | + unset($alert_types['msg']['msg_like']); |
|
| 2069 | + } |
|
| 1972 | 2070 | |
| 1973 | 2071 | // Disable buddy requests if they're disabled |
| 1974 | - if (empty($modSettings['enable_buddylist'])) |
|
| 1975 | - unset($alert_types['members']['buddy_request']); |
|
| 2072 | + if (empty($modSettings['enable_buddylist'])) { |
|
| 2073 | + unset($alert_types['members']['buddy_request']); |
|
| 2074 | + } |
|
| 1976 | 2075 | |
| 1977 | 2076 | // Now, now, we could pass this through global but we should really get into the habit of |
| 1978 | 2077 | // passing content to hooks, not expecting hooks to splatter everything everywhere. |
@@ -2000,15 +2099,17 @@ discard block |
||
| 2000 | 2099 | $perms_cache['manage_membergroups'] = in_array($memID, $members); |
| 2001 | 2100 | } |
| 2002 | 2101 | |
| 2003 | - if (!($perms_cache['manage_membergroups'] || $can_mod != 0)) |
|
| 2004 | - unset($alert_types['members']['request_group']); |
|
| 2102 | + if (!($perms_cache['manage_membergroups'] || $can_mod != 0)) { |
|
| 2103 | + unset($alert_types['members']['request_group']); |
|
| 2104 | + } |
|
| 2005 | 2105 | |
| 2006 | 2106 | foreach ($alert_types as $group => $items) |
| 2007 | 2107 | { |
| 2008 | 2108 | foreach ($items as $alert_key => $alert_value) |
| 2009 | 2109 | { |
| 2010 | - if (!isset($alert_value['permission'])) |
|
| 2011 | - continue; |
|
| 2110 | + if (!isset($alert_value['permission'])) { |
|
| 2111 | + continue; |
|
| 2112 | + } |
|
| 2012 | 2113 | if (!isset($perms_cache[$alert_value['permission']['name']])) |
| 2013 | 2114 | { |
| 2014 | 2115 | $in_board = !empty($alert_value['permission']['is_board']) ? 0 : null; |
@@ -2016,12 +2117,14 @@ discard block |
||
| 2016 | 2117 | $perms_cache[$alert_value['permission']['name']] = in_array($memID, $members); |
| 2017 | 2118 | } |
| 2018 | 2119 | |
| 2019 | - if (!$perms_cache[$alert_value['permission']['name']]) |
|
| 2020 | - unset ($alert_types[$group][$alert_key]); |
|
| 2120 | + if (!$perms_cache[$alert_value['permission']['name']]) { |
|
| 2121 | + unset ($alert_types[$group][$alert_key]); |
|
| 2122 | + } |
|
| 2021 | 2123 | } |
| 2022 | 2124 | |
| 2023 | - if (empty($alert_types[$group])) |
|
| 2024 | - unset ($alert_types[$group]); |
|
| 2125 | + if (empty($alert_types[$group])) { |
|
| 2126 | + unset ($alert_types[$group]); |
|
| 2127 | + } |
|
| 2025 | 2128 | } |
| 2026 | 2129 | } |
| 2027 | 2130 | |
@@ -2053,9 +2156,9 @@ discard block |
||
| 2053 | 2156 | $update_prefs[$this_option[1]] = !empty($_POST['opt_' . $this_option[1]]) ? 1 : 0; |
| 2054 | 2157 | break; |
| 2055 | 2158 | case 'select': |
| 2056 | - if (isset($_POST['opt_' . $this_option[1]], $this_option['opts'][$_POST['opt_' . $this_option[1]]])) |
|
| 2057 | - $update_prefs[$this_option[1]] = $_POST['opt_' . $this_option[1]]; |
|
| 2058 | - else |
|
| 2159 | + if (isset($_POST['opt_' . $this_option[1]], $this_option['opts'][$_POST['opt_' . $this_option[1]]])) { |
|
| 2160 | + $update_prefs[$this_option[1]] = $_POST['opt_' . $this_option[1]]; |
|
| 2161 | + } else |
|
| 2059 | 2162 | { |
| 2060 | 2163 | // We didn't have a sane value. Let's grab the first item from the possibles. |
| 2061 | 2164 | $keys = array_keys($this_option['opts']); |
@@ -2075,23 +2178,28 @@ discard block |
||
| 2075 | 2178 | $this_value = 0; |
| 2076 | 2179 | foreach ($context['alert_bits'] as $type => $bitvalue) |
| 2077 | 2180 | { |
| 2078 | - if ($this_options[$type] == 'yes' && !empty($_POST[$type . '_' . $item_key]) || $this_options[$type] == 'always') |
|
| 2079 | - $this_value |= $bitvalue; |
|
| 2181 | + if ($this_options[$type] == 'yes' && !empty($_POST[$type . '_' . $item_key]) || $this_options[$type] == 'always') { |
|
| 2182 | + $this_value |= $bitvalue; |
|
| 2183 | + } |
|
| 2184 | + } |
|
| 2185 | + if (!isset($context['alert_prefs'][$item_key]) || $context['alert_prefs'][$item_key] != $this_value) { |
|
| 2186 | + $update_prefs[$item_key] = $this_value; |
|
| 2080 | 2187 | } |
| 2081 | - if (!isset($context['alert_prefs'][$item_key]) || $context['alert_prefs'][$item_key] != $this_value) |
|
| 2082 | - $update_prefs[$item_key] = $this_value; |
|
| 2083 | 2188 | } |
| 2084 | 2189 | } |
| 2085 | 2190 | |
| 2086 | - if (!empty($_POST['opt_alert_timeout'])) |
|
| 2087 | - $update_prefs['alert_timeout'] = $context['member']['alert_timeout'] = (int) $_POST['opt_alert_timeout']; |
|
| 2191 | + if (!empty($_POST['opt_alert_timeout'])) { |
|
| 2192 | + $update_prefs['alert_timeout'] = $context['member']['alert_timeout'] = (int) $_POST['opt_alert_timeout']; |
|
| 2193 | + } |
|
| 2088 | 2194 | |
| 2089 | - if (!empty($_POST['notify_announcements'])) |
|
| 2090 | - $update_prefs['announcements'] = $context['member']['notify_announcements'] = (int) $_POST['notify_announcements']; |
|
| 2195 | + if (!empty($_POST['notify_announcements'])) { |
|
| 2196 | + $update_prefs['announcements'] = $context['member']['notify_announcements'] = (int) $_POST['notify_announcements']; |
|
| 2197 | + } |
|
| 2091 | 2198 | |
| 2092 | 2199 | setNotifyPrefs((int) $memID, $update_prefs); |
| 2093 | - foreach ($update_prefs as $pref => $value) |
|
| 2094 | - $context['alert_prefs'][$pref] = $value; |
|
| 2200 | + foreach ($update_prefs as $pref => $value) { |
|
| 2201 | + $context['alert_prefs'][$pref] = $value; |
|
| 2202 | + } |
|
| 2095 | 2203 | |
| 2096 | 2204 | makeNotificationChanges($memID); |
| 2097 | 2205 | |
@@ -2121,8 +2229,9 @@ discard block |
||
| 2121 | 2229 | |
| 2122 | 2230 | // Now we're all set up. |
| 2123 | 2231 | is_not_guest(); |
| 2124 | - if (!$context['user']['is_owner']) |
|
| 2125 | - fatal_error('no_access'); |
|
| 2232 | + if (!$context['user']['is_owner']) { |
|
| 2233 | + fatal_error('no_access'); |
|
| 2234 | + } |
|
| 2126 | 2235 | |
| 2127 | 2236 | checkSession('get'); |
| 2128 | 2237 | |
@@ -2154,8 +2263,9 @@ discard block |
||
| 2154 | 2263 | { |
| 2155 | 2264 | global $smcFunc; |
| 2156 | 2265 | |
| 2157 | - if (empty($toMark) || empty($memID)) |
|
| 2158 | - return false; |
|
| 2266 | + if (empty($toMark) || empty($memID)) { |
|
| 2267 | + return false; |
|
| 2268 | + } |
|
| 2159 | 2269 | |
| 2160 | 2270 | $toMark = (array) $toMark; |
| 2161 | 2271 | $count = 0; |
@@ -2190,8 +2300,9 @@ discard block |
||
| 2190 | 2300 | { |
| 2191 | 2301 | global $smcFunc; |
| 2192 | 2302 | |
| 2193 | - if (empty($toDelete)) |
|
| 2194 | - return false; |
|
| 2303 | + if (empty($toDelete)) { |
|
| 2304 | + return false; |
|
| 2305 | + } |
|
| 2195 | 2306 | |
| 2196 | 2307 | $toDelete = (array) $toDelete; |
| 2197 | 2308 | |
@@ -2226,8 +2337,9 @@ discard block |
||
| 2226 | 2337 | { |
| 2227 | 2338 | global $smcFunc; |
| 2228 | 2339 | |
| 2229 | - if (empty($memID)) |
|
| 2230 | - return false; |
|
| 2340 | + if (empty($memID)) { |
|
| 2341 | + return false; |
|
| 2342 | + } |
|
| 2231 | 2343 | |
| 2232 | 2344 | $count = 0; |
| 2233 | 2345 | |
@@ -2306,8 +2418,9 @@ discard block |
||
| 2306 | 2418 | { |
| 2307 | 2419 | $link = $topic['link']; |
| 2308 | 2420 | |
| 2309 | - if ($topic['new']) |
|
| 2310 | - $link .= ' <a href="' . $topic['new_href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
| 2421 | + if ($topic['new']) { |
|
| 2422 | + $link .= ' <a href="' . $topic['new_href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
| 2423 | + } |
|
| 2311 | 2424 | |
| 2312 | 2425 | $link .= '<br><span class="smalltext"><em>' . $txt['in'] . ' ' . $topic['board_link'] . '</em></span>'; |
| 2313 | 2426 | |
@@ -2458,8 +2571,9 @@ discard block |
||
| 2458 | 2571 | { |
| 2459 | 2572 | $link = $board['link']; |
| 2460 | 2573 | |
| 2461 | - if ($board['new']) |
|
| 2462 | - $link .= ' <a href="' . $board['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
| 2574 | + if ($board['new']) { |
|
| 2575 | + $link .= ' <a href="' . $board['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
| 2576 | + } |
|
| 2463 | 2577 | |
| 2464 | 2578 | return $link; |
| 2465 | 2579 | }, |
@@ -2659,8 +2773,8 @@ discard block |
||
| 2659 | 2773 | ) |
| 2660 | 2774 | ); |
| 2661 | 2775 | $notification_boards = array(); |
| 2662 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2663 | - $notification_boards[] = array( |
|
| 2776 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2777 | + $notification_boards[] = array( |
|
| 2664 | 2778 | 'id' => $row['id_board'], |
| 2665 | 2779 | 'name' => $row['name'], |
| 2666 | 2780 | 'href' => $scripturl . '?board=' . $row['id_board'] . '.0', |
@@ -2668,6 +2782,7 @@ discard block |
||
| 2668 | 2782 | 'new' => $row['board_read'] < $row['id_msg_updated'], |
| 2669 | 2783 | 'notify_pref' => isset($prefs['board_notify_' . $row['id_board']]) ? $prefs['board_notify_' . $row['id_board']] : (!empty($prefs['board_notify']) ? $prefs['board_notify'] : 0), |
| 2670 | 2784 | ); |
| 2785 | + } |
|
| 2671 | 2786 | $smcFunc['db_free_result']($request); |
| 2672 | 2787 | |
| 2673 | 2788 | return $notification_boards; |
@@ -2682,17 +2797,18 @@ discard block |
||
| 2682 | 2797 | { |
| 2683 | 2798 | global $context, $options, $cur_profile, $smcFunc; |
| 2684 | 2799 | |
| 2685 | - if (isset($_POST['default_options'])) |
|
| 2686 | - $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; |
|
| 2800 | + if (isset($_POST['default_options'])) { |
|
| 2801 | + $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; |
|
| 2802 | + } |
|
| 2687 | 2803 | |
| 2688 | 2804 | if ($context['user']['is_owner']) |
| 2689 | 2805 | { |
| 2690 | 2806 | $context['member']['options'] = $options; |
| 2691 | - if (isset($_POST['options']) && is_array($_POST['options'])) |
|
| 2692 | - foreach ($_POST['options'] as $k => $v) |
|
| 2807 | + if (isset($_POST['options']) && is_array($_POST['options'])) { |
|
| 2808 | + foreach ($_POST['options'] as $k => $v) |
|
| 2693 | 2809 | $context['member']['options'][$k] = $v; |
| 2694 | - } |
|
| 2695 | - else |
|
| 2810 | + } |
|
| 2811 | + } else |
|
| 2696 | 2812 | { |
| 2697 | 2813 | $request = $smcFunc['db_query']('', ' |
| 2698 | 2814 | SELECT id_member, variable, value |
@@ -2713,8 +2829,9 @@ discard block |
||
| 2713 | 2829 | continue; |
| 2714 | 2830 | } |
| 2715 | 2831 | |
| 2716 | - if (isset($_POST['options'][$row['variable']])) |
|
| 2717 | - $row['value'] = $_POST['options'][$row['variable']]; |
|
| 2832 | + if (isset($_POST['options'][$row['variable']])) { |
|
| 2833 | + $row['value'] = $_POST['options'][$row['variable']]; |
|
| 2834 | + } |
|
| 2718 | 2835 | $context['member']['options'][$row['variable']] = $row['value']; |
| 2719 | 2836 | } |
| 2720 | 2837 | $smcFunc['db_free_result']($request); |
@@ -2722,8 +2839,9 @@ discard block |
||
| 2722 | 2839 | // Load up the default theme options for any missing. |
| 2723 | 2840 | foreach ($temp as $k => $v) |
| 2724 | 2841 | { |
| 2725 | - if (!isset($context['member']['options'][$k])) |
|
| 2726 | - $context['member']['options'][$k] = $v; |
|
| 2842 | + if (!isset($context['member']['options'][$k])) { |
|
| 2843 | + $context['member']['options'][$k] = $v; |
|
| 2844 | + } |
|
| 2727 | 2845 | } |
| 2728 | 2846 | } |
| 2729 | 2847 | } |
@@ -2738,8 +2856,9 @@ discard block |
||
| 2738 | 2856 | global $context, $modSettings, $smcFunc, $cur_profile, $sourcedir; |
| 2739 | 2857 | |
| 2740 | 2858 | // Have the admins enabled this option? |
| 2741 | - if (empty($modSettings['allow_ignore_boards'])) |
|
| 2742 | - fatal_lang_error('ignoreboards_disallowed', 'user'); |
|
| 2859 | + if (empty($modSettings['allow_ignore_boards'])) { |
|
| 2860 | + fatal_lang_error('ignoreboards_disallowed', 'user'); |
|
| 2861 | + } |
|
| 2743 | 2862 | |
| 2744 | 2863 | // Find all the boards this user is allowed to see. |
| 2745 | 2864 | $request = $smcFunc['db_query']('order_by_board_order', ' |
@@ -2759,12 +2878,13 @@ discard block |
||
| 2759 | 2878 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2760 | 2879 | { |
| 2761 | 2880 | // This category hasn't been set up yet.. |
| 2762 | - if (!isset($context['categories'][$row['id_cat']])) |
|
| 2763 | - $context['categories'][$row['id_cat']] = array( |
|
| 2881 | + if (!isset($context['categories'][$row['id_cat']])) { |
|
| 2882 | + $context['categories'][$row['id_cat']] = array( |
|
| 2764 | 2883 | 'id' => $row['id_cat'], |
| 2765 | 2884 | 'name' => $row['cat_name'], |
| 2766 | 2885 | 'boards' => array() |
| 2767 | 2886 | ); |
| 2887 | + } |
|
| 2768 | 2888 | |
| 2769 | 2889 | // Set this board up, and let the template know when it's a child. (indent them..) |
| 2770 | 2890 | $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array( |
@@ -2794,18 +2914,20 @@ discard block |
||
| 2794 | 2914 | } |
| 2795 | 2915 | |
| 2796 | 2916 | $max_boards = ceil(count($temp_boards) / 2); |
| 2797 | - if ($max_boards == 1) |
|
| 2798 | - $max_boards = 2; |
|
| 2917 | + if ($max_boards == 1) { |
|
| 2918 | + $max_boards = 2; |
|
| 2919 | + } |
|
| 2799 | 2920 | |
| 2800 | 2921 | // Now, alternate them so they can be shown left and right ;). |
| 2801 | 2922 | $context['board_columns'] = array(); |
| 2802 | 2923 | for ($i = 0; $i < $max_boards; $i++) |
| 2803 | 2924 | { |
| 2804 | 2925 | $context['board_columns'][] = $temp_boards[$i]; |
| 2805 | - if (isset($temp_boards[$i + $max_boards])) |
|
| 2806 | - $context['board_columns'][] = $temp_boards[$i + $max_boards]; |
|
| 2807 | - else |
|
| 2808 | - $context['board_columns'][] = array(); |
|
| 2926 | + if (isset($temp_boards[$i + $max_boards])) { |
|
| 2927 | + $context['board_columns'][] = $temp_boards[$i + $max_boards]; |
|
| 2928 | + } else { |
|
| 2929 | + $context['board_columns'][] = array(); |
|
| 2930 | + } |
|
| 2809 | 2931 | } |
| 2810 | 2932 | |
| 2811 | 2933 | loadThemeOptions($memID); |
@@ -2874,8 +2996,9 @@ discard block |
||
| 2874 | 2996 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2875 | 2997 | { |
| 2876 | 2998 | // We should skip the administrator group if they don't have the admin_forum permission! |
| 2877 | - if ($row['id_group'] == 1 && !allowedTo('admin_forum')) |
|
| 2878 | - continue; |
|
| 2999 | + if ($row['id_group'] == 1 && !allowedTo('admin_forum')) { |
|
| 3000 | + continue; |
|
| 3001 | + } |
|
| 2879 | 3002 | |
| 2880 | 3003 | $context['member_groups'][$row['id_group']] = array( |
| 2881 | 3004 | 'id' => $row['id_group'], |
@@ -2921,16 +3044,17 @@ discard block |
||
| 2921 | 3044 | $context['max_signature_length'] = $context['signature_limits']['max_length']; |
| 2922 | 3045 | // Warning message for signature image limits? |
| 2923 | 3046 | $context['signature_warning'] = ''; |
| 2924 | - if ($context['signature_limits']['max_image_width'] && $context['signature_limits']['max_image_height']) |
|
| 2925 | - $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_size'], $context['signature_limits']['max_image_width'], $context['signature_limits']['max_image_height']); |
|
| 2926 | - elseif ($context['signature_limits']['max_image_width'] || $context['signature_limits']['max_image_height']) |
|
| 2927 | - $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_' . ($context['signature_limits']['max_image_width'] ? 'width' : 'height')], $context['signature_limits'][$context['signature_limits']['max_image_width'] ? 'max_image_width' : 'max_image_height']); |
|
| 3047 | + if ($context['signature_limits']['max_image_width'] && $context['signature_limits']['max_image_height']) { |
|
| 3048 | + $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_size'], $context['signature_limits']['max_image_width'], $context['signature_limits']['max_image_height']); |
|
| 3049 | + } elseif ($context['signature_limits']['max_image_width'] || $context['signature_limits']['max_image_height']) { |
|
| 3050 | + $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_' . ($context['signature_limits']['max_image_width'] ? 'width' : 'height')], $context['signature_limits'][$context['signature_limits']['max_image_width'] ? 'max_image_width' : 'max_image_height']); |
|
| 3051 | + } |
|
| 2928 | 3052 | |
| 2929 | 3053 | $context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && (function_exists('pspell_new') || (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv')))); |
| 2930 | 3054 | |
| 2931 | - if (empty($context['do_preview'])) |
|
| 2932 | - $context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<', '>', '"', '\''), array("\n", '<', '>', '"', '''), $cur_profile['signature']); |
|
| 2933 | - else |
|
| 3055 | + if (empty($context['do_preview'])) { |
|
| 3056 | + $context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<', '>', '"', '\''), array("\n", '<', '>', '"', '''), $cur_profile['signature']); |
|
| 3057 | + } else |
|
| 2934 | 3058 | { |
| 2935 | 3059 | $signature = !empty($_POST['signature']) ? $_POST['signature'] : ''; |
| 2936 | 3060 | $validation = profileValidateSignature($signature); |
@@ -2940,8 +3064,9 @@ discard block |
||
| 2940 | 3064 | $context['post_errors'] = array(); |
| 2941 | 3065 | } |
| 2942 | 3066 | $context['post_errors'][] = 'signature_not_yet_saved'; |
| 2943 | - if ($validation !== true && $validation !== false) |
|
| 2944 | - $context['post_errors'][] = $validation; |
|
| 3067 | + if ($validation !== true && $validation !== false) { |
|
| 3068 | + $context['post_errors'][] = $validation; |
|
| 3069 | + } |
|
| 2945 | 3070 | |
| 2946 | 3071 | censorText($context['member']['signature']); |
| 2947 | 3072 | $context['member']['current_signature'] = $context['member']['signature']; |
@@ -2951,8 +3076,9 @@ discard block |
||
| 2951 | 3076 | } |
| 2952 | 3077 | |
| 2953 | 3078 | // Load the spell checker? |
| 2954 | - if ($context['show_spellchecking']) |
|
| 2955 | - loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
| 3079 | + if ($context['show_spellchecking']) { |
|
| 3080 | + loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
| 3081 | + } |
|
| 2956 | 3082 | |
| 2957 | 3083 | return true; |
| 2958 | 3084 | } |
@@ -2986,8 +3112,7 @@ discard block |
||
| 2986 | 3112 | 'external' => $cur_profile['avatar'] == 'gravatar://' || empty($modSettings['gravatarAllowExtraEmail']) || !empty($modSettings['gravatarOverride']) ? $cur_profile['email_address'] : substr($cur_profile['avatar'], 11) |
| 2987 | 3113 | ); |
| 2988 | 3114 | $context['member']['avatar']['href'] = get_gravatar_url($context['member']['avatar']['external']); |
| 2989 | - } |
|
| 2990 | - elseif ($cur_profile['avatar'] == '' && $cur_profile['id_attach'] > 0 && $context['member']['avatar']['allow_upload']) |
|
| 3115 | + } elseif ($cur_profile['avatar'] == '' && $cur_profile['id_attach'] > 0 && $context['member']['avatar']['allow_upload']) |
|
| 2991 | 3116 | { |
| 2992 | 3117 | $context['member']['avatar'] += array( |
| 2993 | 3118 | 'choice' => 'upload', |
@@ -2995,34 +3120,34 @@ discard block |
||
| 2995 | 3120 | 'external' => 'http://' |
| 2996 | 3121 | ); |
| 2997 | 3122 | $context['member']['avatar']['href'] = empty($cur_profile['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $cur_profile['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $cur_profile['filename']; |
| 2998 | - } |
|
| 2999 | - elseif ((stristr($cur_profile['avatar'], 'http://') || stristr($cur_profile['avatar'], 'https://')) && $context['member']['avatar']['allow_external']) |
|
| 3000 | - $context['member']['avatar'] += array( |
|
| 3123 | + } elseif ((stristr($cur_profile['avatar'], 'http://') || stristr($cur_profile['avatar'], 'https://')) && $context['member']['avatar']['allow_external']) { |
|
| 3124 | + $context['member']['avatar'] += array( |
|
| 3001 | 3125 | 'choice' => 'external', |
| 3002 | 3126 | 'server_pic' => 'blank.png', |
| 3003 | 3127 | 'external' => $cur_profile['avatar'] |
| 3004 | 3128 | ); |
| 3005 | - elseif ($cur_profile['avatar'] != '' && file_exists($modSettings['avatar_directory'] . '/' . $cur_profile['avatar']) && $context['member']['avatar']['allow_server_stored']) |
|
| 3006 | - $context['member']['avatar'] += array( |
|
| 3129 | + } elseif ($cur_profile['avatar'] != '' && file_exists($modSettings['avatar_directory'] . '/' . $cur_profile['avatar']) && $context['member']['avatar']['allow_server_stored']) { |
|
| 3130 | + $context['member']['avatar'] += array( |
|
| 3007 | 3131 | 'choice' => 'server_stored', |
| 3008 | 3132 | 'server_pic' => $cur_profile['avatar'] == '' ? 'blank.png' : $cur_profile['avatar'], |
| 3009 | 3133 | 'external' => 'http://' |
| 3010 | 3134 | ); |
| 3011 | - else |
|
| 3012 | - $context['member']['avatar'] += array( |
|
| 3135 | + } else { |
|
| 3136 | + $context['member']['avatar'] += array( |
|
| 3013 | 3137 | 'choice' => 'none', |
| 3014 | 3138 | 'server_pic' => 'blank.png', |
| 3015 | 3139 | 'external' => 'http://' |
| 3016 | 3140 | ); |
| 3141 | + } |
|
| 3017 | 3142 | |
| 3018 | 3143 | // Get a list of all the avatars. |
| 3019 | 3144 | if ($context['member']['avatar']['allow_server_stored']) |
| 3020 | 3145 | { |
| 3021 | 3146 | $context['avatar_list'] = array(); |
| 3022 | 3147 | $context['avatars'] = is_dir($modSettings['avatar_directory']) ? getAvatars('', 0) : array(); |
| 3148 | + } else { |
|
| 3149 | + $context['avatars'] = array(); |
|
| 3023 | 3150 | } |
| 3024 | - else |
|
| 3025 | - $context['avatars'] = array(); |
|
| 3026 | 3151 | |
| 3027 | 3152 | // Second level selected avatar... |
| 3028 | 3153 | $context['avatar_selected'] = substr(strrchr($context['member']['avatar']['server_pic'], '/'), 1); |
@@ -3051,19 +3176,22 @@ discard block |
||
| 3051 | 3176 | ) |
| 3052 | 3177 | ); |
| 3053 | 3178 | $protected_groups = array(1); |
| 3054 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 3055 | - $protected_groups[] = $row['id_group']; |
|
| 3179 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 3180 | + $protected_groups[] = $row['id_group']; |
|
| 3181 | + } |
|
| 3056 | 3182 | $smcFunc['db_free_result']($request); |
| 3057 | 3183 | |
| 3058 | 3184 | $protected_groups = array_unique($protected_groups); |
| 3059 | 3185 | } |
| 3060 | 3186 | |
| 3061 | 3187 | // The account page allows the change of your id_group - but not to a protected group! |
| 3062 | - if (empty($protected_groups) || count(array_intersect(array((int) $value, $old_profile['id_group']), $protected_groups)) == 0) |
|
| 3063 | - $value = (int) $value; |
|
| 3188 | + if (empty($protected_groups) || count(array_intersect(array((int) $value, $old_profile['id_group']), $protected_groups)) == 0) { |
|
| 3189 | + $value = (int) $value; |
|
| 3190 | + } |
|
| 3064 | 3191 | // ... otherwise it's the old group sir. |
| 3065 | - else |
|
| 3066 | - $value = $old_profile['id_group']; |
|
| 3192 | + else { |
|
| 3193 | + $value = $old_profile['id_group']; |
|
| 3194 | + } |
|
| 3067 | 3195 | |
| 3068 | 3196 | // Find the additional membergroups (if any) |
| 3069 | 3197 | if (isset($_POST['additional_groups']) && is_array($_POST['additional_groups'])) |
@@ -3072,16 +3200,18 @@ discard block |
||
| 3072 | 3200 | foreach ($_POST['additional_groups'] as $group_id) |
| 3073 | 3201 | { |
| 3074 | 3202 | $group_id = (int) $group_id; |
| 3075 | - if (!empty($group_id) && (empty($protected_groups) || !in_array($group_id, $protected_groups))) |
|
| 3076 | - $additional_groups[] = $group_id; |
|
| 3203 | + if (!empty($group_id) && (empty($protected_groups) || !in_array($group_id, $protected_groups))) { |
|
| 3204 | + $additional_groups[] = $group_id; |
|
| 3205 | + } |
|
| 3077 | 3206 | } |
| 3078 | 3207 | |
| 3079 | 3208 | // Put the protected groups back in there if you don't have permission to take them away. |
| 3080 | 3209 | $old_additional_groups = explode(',', $old_profile['additional_groups']); |
| 3081 | 3210 | foreach ($old_additional_groups as $group_id) |
| 3082 | 3211 | { |
| 3083 | - if (!empty($protected_groups) && in_array($group_id, $protected_groups)) |
|
| 3084 | - $additional_groups[] = $group_id; |
|
| 3212 | + if (!empty($protected_groups) && in_array($group_id, $protected_groups)) { |
|
| 3213 | + $additional_groups[] = $group_id; |
|
| 3214 | + } |
|
| 3085 | 3215 | } |
| 3086 | 3216 | |
| 3087 | 3217 | if (implode(',', $additional_groups) !== $old_profile['additional_groups']) |
@@ -3113,18 +3243,20 @@ discard block |
||
| 3113 | 3243 | list ($another) = $smcFunc['db_fetch_row']($request); |
| 3114 | 3244 | $smcFunc['db_free_result']($request); |
| 3115 | 3245 | |
| 3116 | - if (empty($another)) |
|
| 3117 | - fatal_lang_error('at_least_one_admin', 'critical'); |
|
| 3246 | + if (empty($another)) { |
|
| 3247 | + fatal_lang_error('at_least_one_admin', 'critical'); |
|
| 3248 | + } |
|
| 3118 | 3249 | } |
| 3119 | 3250 | } |
| 3120 | 3251 | |
| 3121 | 3252 | // If we are changing group status, update permission cache as necessary. |
| 3122 | 3253 | if ($value != $old_profile['id_group'] || isset($profile_vars['additional_groups'])) |
| 3123 | 3254 | { |
| 3124 | - if ($context['user']['is_owner']) |
|
| 3125 | - $_SESSION['mc']['time'] = 0; |
|
| 3126 | - else |
|
| 3127 | - updateSettings(array('settings_updated' => time())); |
|
| 3255 | + if ($context['user']['is_owner']) { |
|
| 3256 | + $_SESSION['mc']['time'] = 0; |
|
| 3257 | + } else { |
|
| 3258 | + updateSettings(array('settings_updated' => time())); |
|
| 3259 | + } |
|
| 3128 | 3260 | } |
| 3129 | 3261 | |
| 3130 | 3262 | // Announce to any hooks that we have changed groups, but don't allow them to change it. |
@@ -3145,8 +3277,9 @@ discard block |
||
| 3145 | 3277 | global $modSettings, $sourcedir, $smcFunc, $profile_vars, $cur_profile, $context; |
| 3146 | 3278 | |
| 3147 | 3279 | $memID = $context['id_member']; |
| 3148 | - if (empty($memID) && !empty($context['password_auth_failed'])) |
|
| 3149 | - return false; |
|
| 3280 | + if (empty($memID) && !empty($context['password_auth_failed'])) { |
|
| 3281 | + return false; |
|
| 3282 | + } |
|
| 3150 | 3283 | |
| 3151 | 3284 | require_once($sourcedir . '/ManageAttachments.php'); |
| 3152 | 3285 | |
@@ -3157,8 +3290,9 @@ discard block |
||
| 3157 | 3290 | $downloadedExternalAvatar = false; |
| 3158 | 3291 | if ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && strlen($_POST['userpicpersonal']) > 7 && !empty($modSettings['avatar_download_external'])) |
| 3159 | 3292 | { |
| 3160 | - if (!is_writable($uploadDir)) |
|
| 3161 | - fatal_lang_error('attachments_no_write', 'critical'); |
|
| 3293 | + if (!is_writable($uploadDir)) { |
|
| 3294 | + fatal_lang_error('attachments_no_write', 'critical'); |
|
| 3295 | + } |
|
| 3162 | 3296 | |
| 3163 | 3297 | require_once($sourcedir . '/Subs-Package.php'); |
| 3164 | 3298 | |
@@ -3202,19 +3336,18 @@ discard block |
||
| 3202 | 3336 | |
| 3203 | 3337 | // Get rid of their old avatar. (if uploaded.) |
| 3204 | 3338 | removeAttachments(array('id_member' => $memID)); |
| 3205 | - } |
|
| 3206 | - elseif ($value == 'gravatar' && !empty($modSettings['gravatarEnabled'])) |
|
| 3339 | + } elseif ($value == 'gravatar' && !empty($modSettings['gravatarEnabled'])) |
|
| 3207 | 3340 | { |
| 3208 | 3341 | // One wasn't specified, or it's not allowed to use extra email addresses, or it's not a valid one, reset to default Gravatar. |
| 3209 | - if (empty($_POST['gravatarEmail']) || empty($modSettings['gravatarAllowExtraEmail']) || !filter_var($_POST['gravatarEmail'], FILTER_VALIDATE_EMAIL)) |
|
| 3210 | - $profile_vars['avatar'] = 'gravatar://'; |
|
| 3211 | - else |
|
| 3212 | - $profile_vars['avatar'] = 'gravatar://' . ($_POST['gravatarEmail'] != $cur_profile['email_address'] ? $_POST['gravatarEmail'] : ''); |
|
| 3342 | + if (empty($_POST['gravatarEmail']) || empty($modSettings['gravatarAllowExtraEmail']) || !filter_var($_POST['gravatarEmail'], FILTER_VALIDATE_EMAIL)) { |
|
| 3343 | + $profile_vars['avatar'] = 'gravatar://'; |
|
| 3344 | + } else { |
|
| 3345 | + $profile_vars['avatar'] = 'gravatar://' . ($_POST['gravatarEmail'] != $cur_profile['email_address'] ? $_POST['gravatarEmail'] : ''); |
|
| 3346 | + } |
|
| 3213 | 3347 | |
| 3214 | 3348 | // Get rid of their old avatar. (if uploaded.) |
| 3215 | 3349 | removeAttachments(array('id_member' => $memID)); |
| 3216 | - } |
|
| 3217 | - elseif ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && empty($modSettings['avatar_download_external'])) |
|
| 3350 | + } elseif ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && empty($modSettings['avatar_download_external'])) |
|
| 3218 | 3351 | { |
| 3219 | 3352 | // We need these clean... |
| 3220 | 3353 | $cur_profile['id_attach'] = 0; |
@@ -3226,11 +3359,13 @@ discard block |
||
| 3226 | 3359 | |
| 3227 | 3360 | $profile_vars['avatar'] = str_replace(' ', '%20', preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $_POST['userpicpersonal'])); |
| 3228 | 3361 | |
| 3229 | - if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///') |
|
| 3230 | - $profile_vars['avatar'] = ''; |
|
| 3362 | + if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///') { |
|
| 3363 | + $profile_vars['avatar'] = ''; |
|
| 3364 | + } |
|
| 3231 | 3365 | // Trying to make us do something we'll regret? |
| 3232 | - elseif (substr($profile_vars['avatar'], 0, 7) != 'http://' && substr($profile_vars['avatar'], 0, 8) != 'https://') |
|
| 3233 | - return 'bad_avatar_invalid_url'; |
|
| 3366 | + elseif (substr($profile_vars['avatar'], 0, 7) != 'http://' && substr($profile_vars['avatar'], 0, 8) != 'https://') { |
|
| 3367 | + return 'bad_avatar_invalid_url'; |
|
| 3368 | + } |
|
| 3234 | 3369 | // Should we check dimensions? |
| 3235 | 3370 | elseif (!empty($modSettings['avatar_max_height_external']) || !empty($modSettings['avatar_max_width_external'])) |
| 3236 | 3371 | { |
@@ -3240,9 +3375,9 @@ discard block |
||
| 3240 | 3375 | if (is_array($sizes) && (($sizes[0] > $modSettings['avatar_max_width_external'] && !empty($modSettings['avatar_max_width_external'])) || ($sizes[1] > $modSettings['avatar_max_height_external'] && !empty($modSettings['avatar_max_height_external'])))) |
| 3241 | 3376 | { |
| 3242 | 3377 | // Houston, we have a problem. The avatar is too large!! |
| 3243 | - if ($modSettings['avatar_action_too_large'] == 'option_refuse') |
|
| 3244 | - return 'bad_avatar_too_large'; |
|
| 3245 | - elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize') |
|
| 3378 | + if ($modSettings['avatar_action_too_large'] == 'option_refuse') { |
|
| 3379 | + return 'bad_avatar_too_large'; |
|
| 3380 | + } elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize') |
|
| 3246 | 3381 | { |
| 3247 | 3382 | // @todo remove this if appropriate |
| 3248 | 3383 | require_once($sourcedir . '/Subs-Graphics.php'); |
@@ -3252,26 +3387,27 @@ discard block |
||
| 3252 | 3387 | $cur_profile['id_attach'] = $modSettings['new_avatar_data']['id']; |
| 3253 | 3388 | $cur_profile['filename'] = $modSettings['new_avatar_data']['filename']; |
| 3254 | 3389 | $cur_profile['attachment_type'] = $modSettings['new_avatar_data']['type']; |
| 3390 | + } else { |
|
| 3391 | + return 'bad_avatar'; |
|
| 3255 | 3392 | } |
| 3256 | - else |
|
| 3257 | - return 'bad_avatar'; |
|
| 3258 | 3393 | } |
| 3259 | 3394 | } |
| 3260 | 3395 | } |
| 3261 | - } |
|
| 3262 | - elseif (($value == 'upload' && allowedTo('profile_upload_avatar')) || $downloadedExternalAvatar) |
|
| 3396 | + } elseif (($value == 'upload' && allowedTo('profile_upload_avatar')) || $downloadedExternalAvatar) |
|
| 3263 | 3397 | { |
| 3264 | 3398 | if ((isset($_FILES['attachment']['name']) && $_FILES['attachment']['name'] != '') || $downloadedExternalAvatar) |
| 3265 | 3399 | { |
| 3266 | 3400 | // Get the dimensions of the image. |
| 3267 | 3401 | if (!$downloadedExternalAvatar) |
| 3268 | 3402 | { |
| 3269 | - if (!is_writable($uploadDir)) |
|
| 3270 | - fatal_lang_error('attachments_no_write', 'critical'); |
|
| 3403 | + if (!is_writable($uploadDir)) { |
|
| 3404 | + fatal_lang_error('attachments_no_write', 'critical'); |
|
| 3405 | + } |
|
| 3271 | 3406 | |
| 3272 | 3407 | $new_filename = $uploadDir . '/' . getAttachmentFilename('avatar_tmp_' . $memID, false, null, true); |
| 3273 | - if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $new_filename)) |
|
| 3274 | - fatal_lang_error('attach_timeout', 'critical'); |
|
| 3408 | + if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $new_filename)) { |
|
| 3409 | + fatal_lang_error('attach_timeout', 'critical'); |
|
| 3410 | + } |
|
| 3275 | 3411 | |
| 3276 | 3412 | $_FILES['attachment']['tmp_name'] = $new_filename; |
| 3277 | 3413 | } |
@@ -3384,17 +3520,19 @@ discard block |
||
| 3384 | 3520 | $profile_vars['avatar'] = ''; |
| 3385 | 3521 | |
| 3386 | 3522 | // Delete any temporary file. |
| 3387 | - if (file_exists($_FILES['attachment']['tmp_name'])) |
|
| 3388 | - @unlink($_FILES['attachment']['tmp_name']); |
|
| 3523 | + if (file_exists($_FILES['attachment']['tmp_name'])) { |
|
| 3524 | + @unlink($_FILES['attachment']['tmp_name']); |
|
| 3525 | + } |
|
| 3389 | 3526 | } |
| 3390 | 3527 | // Selected the upload avatar option and had one already uploaded before or didn't upload one. |
| 3391 | - else |
|
| 3528 | + else { |
|
| 3529 | + $profile_vars['avatar'] = ''; |
|
| 3530 | + } |
|
| 3531 | + } elseif ($value == 'gravatar' && allowedTo('profile_gravatar_avatar')) { |
|
| 3532 | + $profile_vars['avatar'] = 'gravatar://www.gravatar.com/avatar/' . md5(strtolower(trim($cur_profile['email_address']))); |
|
| 3533 | + } else { |
|
| 3392 | 3534 | $profile_vars['avatar'] = ''; |
| 3393 | 3535 | } |
| 3394 | - elseif ($value == 'gravatar' && allowedTo('profile_gravatar_avatar')) |
|
| 3395 | - $profile_vars['avatar'] = 'gravatar://www.gravatar.com/avatar/' . md5(strtolower(trim($cur_profile['email_address']))); |
|
| 3396 | - else |
|
| 3397 | - $profile_vars['avatar'] = ''; |
|
| 3398 | 3536 | |
| 3399 | 3537 | // Setup the profile variables so it shows things right on display! |
| 3400 | 3538 | $cur_profile['avatar'] = $profile_vars['avatar']; |
@@ -3442,9 +3580,9 @@ discard block |
||
| 3442 | 3580 | $smiley_parsed = $unparsed_signature; |
| 3443 | 3581 | parsesmileys($smiley_parsed); |
| 3444 | 3582 | $smiley_count = substr_count(strtolower($smiley_parsed), '<img') - substr_count(strtolower($unparsed_signature), '<img'); |
| 3445 | - if (!empty($sig_limits[4]) && $sig_limits[4] == -1 && $smiley_count > 0) |
|
| 3446 | - return 'signature_allow_smileys'; |
|
| 3447 | - elseif (!empty($sig_limits[4]) && $sig_limits[4] > 0 && $smiley_count > $sig_limits[4]) |
|
| 3583 | + if (!empty($sig_limits[4]) && $sig_limits[4] == -1 && $smiley_count > 0) { |
|
| 3584 | + return 'signature_allow_smileys'; |
|
| 3585 | + } elseif (!empty($sig_limits[4]) && $sig_limits[4] > 0 && $smiley_count > $sig_limits[4]) |
|
| 3448 | 3586 | { |
| 3449 | 3587 | $txt['profile_error_signature_max_smileys'] = sprintf($txt['profile_error_signature_max_smileys'], $sig_limits[4]); |
| 3450 | 3588 | return 'signature_max_smileys'; |
@@ -3457,14 +3595,15 @@ discard block |
||
| 3457 | 3595 | { |
| 3458 | 3596 | $limit_broke = 0; |
| 3459 | 3597 | // Attempt to allow all sizes of abuse, so to speak. |
| 3460 | - if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) |
|
| 3461 | - $limit_broke = $sig_limits[7] . 'px'; |
|
| 3462 | - elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) |
|
| 3463 | - $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
| 3464 | - elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) |
|
| 3465 | - $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
| 3466 | - elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) |
|
| 3467 | - $limit_broke = 'large'; |
|
| 3598 | + if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) { |
|
| 3599 | + $limit_broke = $sig_limits[7] . 'px'; |
|
| 3600 | + } elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) { |
|
| 3601 | + $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
| 3602 | + } elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) { |
|
| 3603 | + $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
| 3604 | + } elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) { |
|
| 3605 | + $limit_broke = 'large'; |
|
| 3606 | + } |
|
| 3468 | 3607 | |
| 3469 | 3608 | if ($limit_broke) |
| 3470 | 3609 | { |
@@ -3506,24 +3645,26 @@ discard block |
||
| 3506 | 3645 | $width = -1; $height = -1; |
| 3507 | 3646 | |
| 3508 | 3647 | // Does it have predefined restraints? Width first. |
| 3509 | - if ($matches[6][$key]) |
|
| 3510 | - $matches[2][$key] = $matches[6][$key]; |
|
| 3648 | + if ($matches[6][$key]) { |
|
| 3649 | + $matches[2][$key] = $matches[6][$key]; |
|
| 3650 | + } |
|
| 3511 | 3651 | if ($matches[2][$key] && $sig_limits[5] && $matches[2][$key] > $sig_limits[5]) |
| 3512 | 3652 | { |
| 3513 | 3653 | $width = $sig_limits[5]; |
| 3514 | 3654 | $matches[4][$key] = $matches[4][$key] * ($width / $matches[2][$key]); |
| 3655 | + } elseif ($matches[2][$key]) { |
|
| 3656 | + $width = $matches[2][$key]; |
|
| 3515 | 3657 | } |
| 3516 | - elseif ($matches[2][$key]) |
|
| 3517 | - $width = $matches[2][$key]; |
|
| 3518 | 3658 | // ... and height. |
| 3519 | 3659 | if ($matches[4][$key] && $sig_limits[6] && $matches[4][$key] > $sig_limits[6]) |
| 3520 | 3660 | { |
| 3521 | 3661 | $height = $sig_limits[6]; |
| 3522 | - if ($width != -1) |
|
| 3523 | - $width = $width * ($height / $matches[4][$key]); |
|
| 3662 | + if ($width != -1) { |
|
| 3663 | + $width = $width * ($height / $matches[4][$key]); |
|
| 3664 | + } |
|
| 3665 | + } elseif ($matches[4][$key]) { |
|
| 3666 | + $height = $matches[4][$key]; |
|
| 3524 | 3667 | } |
| 3525 | - elseif ($matches[4][$key]) |
|
| 3526 | - $height = $matches[4][$key]; |
|
| 3527 | 3668 | |
| 3528 | 3669 | // If the dimensions are still not fixed - we need to check the actual image. |
| 3529 | 3670 | if (($width == -1 && $sig_limits[5]) || ($height == -1 && $sig_limits[6])) |
@@ -3541,21 +3682,24 @@ discard block |
||
| 3541 | 3682 | if ($sizes[1] > $sig_limits[6] && $sig_limits[6]) |
| 3542 | 3683 | { |
| 3543 | 3684 | $height = $sig_limits[6]; |
| 3544 | - if ($width == -1) |
|
| 3545 | - $width = $sizes[0]; |
|
| 3685 | + if ($width == -1) { |
|
| 3686 | + $width = $sizes[0]; |
|
| 3687 | + } |
|
| 3546 | 3688 | $width = $width * ($height / $sizes[1]); |
| 3689 | + } elseif ($width != -1) { |
|
| 3690 | + $height = $sizes[1]; |
|
| 3547 | 3691 | } |
| 3548 | - elseif ($width != -1) |
|
| 3549 | - $height = $sizes[1]; |
|
| 3550 | 3692 | } |
| 3551 | 3693 | } |
| 3552 | 3694 | |
| 3553 | 3695 | // Did we come up with some changes? If so remake the string. |
| 3554 | - if ($width != -1 || $height != -1) |
|
| 3555 | - $replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]'; |
|
| 3696 | + if ($width != -1 || $height != -1) { |
|
| 3697 | + $replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]'; |
|
| 3698 | + } |
|
| 3699 | + } |
|
| 3700 | + if (!empty($replaces)) { |
|
| 3701 | + $value = str_replace(array_keys($replaces), array_values($replaces), $value); |
|
| 3556 | 3702 | } |
| 3557 | - if (!empty($replaces)) |
|
| 3558 | - $value = str_replace(array_keys($replaces), array_values($replaces), $value); |
|
| 3559 | 3703 | } |
| 3560 | 3704 | } |
| 3561 | 3705 | |
@@ -3599,10 +3743,12 @@ discard block |
||
| 3599 | 3743 | $email = strtr($email, array(''' => '\'')); |
| 3600 | 3744 | |
| 3601 | 3745 | // Check the name and email for validity. |
| 3602 | - if (trim($email) == '') |
|
| 3603 | - return 'no_email'; |
|
| 3604 | - if (!filter_var($email, FILTER_VALIDATE_EMAIL)) |
|
| 3605 | - return 'bad_email'; |
|
| 3746 | + if (trim($email) == '') { |
|
| 3747 | + return 'no_email'; |
|
| 3748 | + } |
|
| 3749 | + if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { |
|
| 3750 | + return 'bad_email'; |
|
| 3751 | + } |
|
| 3606 | 3752 | |
| 3607 | 3753 | // Email addresses should be and stay unique. |
| 3608 | 3754 | $request = $smcFunc['db_query']('', ' |
@@ -3617,8 +3763,9 @@ discard block |
||
| 3617 | 3763 | ) |
| 3618 | 3764 | ); |
| 3619 | 3765 | |
| 3620 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
| 3621 | - return 'email_taken'; |
|
| 3766 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
| 3767 | + return 'email_taken'; |
|
| 3768 | + } |
|
| 3622 | 3769 | $smcFunc['db_free_result']($request); |
| 3623 | 3770 | |
| 3624 | 3771 | return true; |
@@ -3631,8 +3778,9 @@ discard block |
||
| 3631 | 3778 | { |
| 3632 | 3779 | global $modSettings, $context, $cur_profile; |
| 3633 | 3780 | |
| 3634 | - if (isset($_POST['passwrd2']) && $_POST['passwrd2'] != '') |
|
| 3635 | - setLoginCookie(60 * $modSettings['cookieTime'], $context['id_member'], hash_salt($_POST['passwrd1'], $cur_profile['password_salt'])); |
|
| 3781 | + if (isset($_POST['passwrd2']) && $_POST['passwrd2'] != '') { |
|
| 3782 | + setLoginCookie(60 * $modSettings['cookieTime'], $context['id_member'], hash_salt($_POST['passwrd1'], $cur_profile['password_salt'])); |
|
| 3783 | + } |
|
| 3636 | 3784 | |
| 3637 | 3785 | loadUserSettings(); |
| 3638 | 3786 | writeLog(); |
@@ -3648,8 +3796,9 @@ discard block |
||
| 3648 | 3796 | require_once($sourcedir . '/Subs-Post.php'); |
| 3649 | 3797 | |
| 3650 | 3798 | // Shouldn't happen but just in case. |
| 3651 | - if (empty($profile_vars['email_address'])) |
|
| 3652 | - return; |
|
| 3799 | + if (empty($profile_vars['email_address'])) { |
|
| 3800 | + return; |
|
| 3801 | + } |
|
| 3653 | 3802 | |
| 3654 | 3803 | $replacements = array( |
| 3655 | 3804 | 'ACTIVATIONLINK' => $scripturl . '?action=activate;u=' . $context['id_member'] . ';code=' . $profile_vars['validation_code'], |
@@ -3672,8 +3821,9 @@ discard block |
||
| 3672 | 3821 | $_SESSION['log_time'] = 0; |
| 3673 | 3822 | $_SESSION['login_' . $cookiename] = json_encode(array(0, '', 0)); |
| 3674 | 3823 | |
| 3675 | - if (isset($_COOKIE[$cookiename])) |
|
| 3676 | - $_COOKIE[$cookiename] = ''; |
|
| 3824 | + if (isset($_COOKIE[$cookiename])) { |
|
| 3825 | + $_COOKIE[$cookiename] = ''; |
|
| 3826 | + } |
|
| 3677 | 3827 | |
| 3678 | 3828 | loadUserSettings(); |
| 3679 | 3829 | |
@@ -3706,11 +3856,13 @@ discard block |
||
| 3706 | 3856 | $groups[] = $curMember['id_group']; |
| 3707 | 3857 | |
| 3708 | 3858 | // Ensure the query doesn't croak! |
| 3709 | - if (empty($groups)) |
|
| 3710 | - $groups = array(0); |
|
| 3859 | + if (empty($groups)) { |
|
| 3860 | + $groups = array(0); |
|
| 3861 | + } |
|
| 3711 | 3862 | // Just to be sure... |
| 3712 | - foreach ($groups as $k => $v) |
|
| 3713 | - $groups[$k] = (int) $v; |
|
| 3863 | + foreach ($groups as $k => $v) { |
|
| 3864 | + $groups[$k] = (int) $v; |
|
| 3865 | + } |
|
| 3714 | 3866 | |
| 3715 | 3867 | // Get all the membergroups they can join. |
| 3716 | 3868 | $request = $smcFunc['db_query']('', ' |
@@ -3740,12 +3892,14 @@ discard block |
||
| 3740 | 3892 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 3741 | 3893 | { |
| 3742 | 3894 | // Can they edit their primary group? |
| 3743 | - if (($row['id_group'] == $context['primary_group'] && $row['group_type'] > 1) || ($row['hidden'] != 2 && $context['primary_group'] == 0 && in_array($row['id_group'], $groups))) |
|
| 3744 | - $context['can_edit_primary'] = true; |
|
| 3895 | + if (($row['id_group'] == $context['primary_group'] && $row['group_type'] > 1) || ($row['hidden'] != 2 && $context['primary_group'] == 0 && in_array($row['id_group'], $groups))) { |
|
| 3896 | + $context['can_edit_primary'] = true; |
|
| 3897 | + } |
|
| 3745 | 3898 | |
| 3746 | 3899 | // If they can't manage (protected) groups, and it's not publically joinable or already assigned, they can't see it. |
| 3747 | - if (((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) && $row['id_group'] != $context['primary_group']) |
|
| 3748 | - continue; |
|
| 3900 | + if (((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) && $row['id_group'] != $context['primary_group']) { |
|
| 3901 | + continue; |
|
| 3902 | + } |
|
| 3749 | 3903 | |
| 3750 | 3904 | $context['groups'][in_array($row['id_group'], $groups) ? 'member' : 'available'][$row['id_group']] = array( |
| 3751 | 3905 | 'id' => $row['id_group'], |
@@ -3774,13 +3928,15 @@ discard block |
||
| 3774 | 3928 | ); |
| 3775 | 3929 | |
| 3776 | 3930 | // No changing primary one unless you have enough groups! |
| 3777 | - if (count($context['groups']['member']) < 2) |
|
| 3778 | - $context['can_edit_primary'] = false; |
|
| 3931 | + if (count($context['groups']['member']) < 2) { |
|
| 3932 | + $context['can_edit_primary'] = false; |
|
| 3933 | + } |
|
| 3779 | 3934 | |
| 3780 | 3935 | // In the special case that someone is requesting membership of a group, setup some special context vars. |
| 3781 | - if (isset($_REQUEST['request']) && isset($context['groups']['available'][(int) $_REQUEST['request']]) && $context['groups']['available'][(int) $_REQUEST['request']]['type'] == 2) |
|
| 3782 | - $context['group_request'] = $context['groups']['available'][(int) $_REQUEST['request']]; |
|
| 3783 | -} |
|
| 3936 | + if (isset($_REQUEST['request']) && isset($context['groups']['available'][(int) $_REQUEST['request']]) && $context['groups']['available'][(int) $_REQUEST['request']]['type'] == 2) { |
|
| 3937 | + $context['group_request'] = $context['groups']['available'][(int) $_REQUEST['request']]; |
|
| 3938 | + } |
|
| 3939 | + } |
|
| 3784 | 3940 | |
| 3785 | 3941 | /** |
| 3786 | 3942 | * This function actually makes all the group changes |
@@ -3795,10 +3951,12 @@ discard block |
||
| 3795 | 3951 | global $user_info, $context, $user_profile, $modSettings, $smcFunc; |
| 3796 | 3952 | |
| 3797 | 3953 | // Let's be extra cautious... |
| 3798 | - if (!$context['user']['is_owner'] || empty($modSettings['show_group_membership'])) |
|
| 3799 | - isAllowedTo('manage_membergroups'); |
|
| 3800 | - if (!isset($_REQUEST['gid']) && !isset($_POST['primary'])) |
|
| 3801 | - fatal_lang_error('no_access', false); |
|
| 3954 | + if (!$context['user']['is_owner'] || empty($modSettings['show_group_membership'])) { |
|
| 3955 | + isAllowedTo('manage_membergroups'); |
|
| 3956 | + } |
|
| 3957 | + if (!isset($_REQUEST['gid']) && !isset($_POST['primary'])) { |
|
| 3958 | + fatal_lang_error('no_access', false); |
|
| 3959 | + } |
|
| 3802 | 3960 | |
| 3803 | 3961 | checkSession(isset($_GET['gid']) ? 'get' : 'post'); |
| 3804 | 3962 | |
@@ -3817,8 +3975,9 @@ discard block |
||
| 3817 | 3975 | $foundTarget = $changeType == 'primary' && $group_id == 0 ? true : false; |
| 3818 | 3976 | |
| 3819 | 3977 | // Sanity check!! |
| 3820 | - if ($group_id == 1) |
|
| 3821 | - isAllowedTo('admin_forum'); |
|
| 3978 | + if ($group_id == 1) { |
|
| 3979 | + isAllowedTo('admin_forum'); |
|
| 3980 | + } |
|
| 3822 | 3981 | // Protected groups too! |
| 3823 | 3982 | else |
| 3824 | 3983 | { |
@@ -3835,8 +3994,9 @@ discard block |
||
| 3835 | 3994 | list ($is_protected) = $smcFunc['db_fetch_row']($request); |
| 3836 | 3995 | $smcFunc['db_free_result']($request); |
| 3837 | 3996 | |
| 3838 | - if ($is_protected == 1) |
|
| 3839 | - isAllowedTo('admin_forum'); |
|
| 3997 | + if ($is_protected == 1) { |
|
| 3998 | + isAllowedTo('admin_forum'); |
|
| 3999 | + } |
|
| 3840 | 4000 | } |
| 3841 | 4001 | |
| 3842 | 4002 | // What ever we are doing, we need to determine if changing primary is possible! |
@@ -3858,36 +4018,43 @@ discard block |
||
| 3858 | 4018 | $group_name = $row['group_name']; |
| 3859 | 4019 | |
| 3860 | 4020 | // Does the group type match what we're doing - are we trying to request a non-requestable group? |
| 3861 | - if ($changeType == 'request' && $row['group_type'] != 2) |
|
| 3862 | - fatal_lang_error('no_access', false); |
|
| 4021 | + if ($changeType == 'request' && $row['group_type'] != 2) { |
|
| 4022 | + fatal_lang_error('no_access', false); |
|
| 4023 | + } |
|
| 3863 | 4024 | // What about leaving a requestable group we are not a member of? |
| 3864 | - elseif ($changeType == 'free' && $row['group_type'] == 2 && $old_profile['id_group'] != $row['id_group'] && !isset($addGroups[$row['id_group']])) |
|
| 3865 | - fatal_lang_error('no_access', false); |
|
| 3866 | - elseif ($changeType == 'free' && $row['group_type'] != 3 && $row['group_type'] != 2) |
|
| 3867 | - fatal_lang_error('no_access', false); |
|
| 4025 | + elseif ($changeType == 'free' && $row['group_type'] == 2 && $old_profile['id_group'] != $row['id_group'] && !isset($addGroups[$row['id_group']])) { |
|
| 4026 | + fatal_lang_error('no_access', false); |
|
| 4027 | + } elseif ($changeType == 'free' && $row['group_type'] != 3 && $row['group_type'] != 2) { |
|
| 4028 | + fatal_lang_error('no_access', false); |
|
| 4029 | + } |
|
| 3868 | 4030 | |
| 3869 | 4031 | // We can't change the primary group if this is hidden! |
| 3870 | - if ($row['hidden'] == 2) |
|
| 3871 | - $canChangePrimary = false; |
|
| 4032 | + if ($row['hidden'] == 2) { |
|
| 4033 | + $canChangePrimary = false; |
|
| 4034 | + } |
|
| 3872 | 4035 | } |
| 3873 | 4036 | |
| 3874 | 4037 | // If this is their old primary, can we change it? |
| 3875 | - if ($row['id_group'] == $old_profile['id_group'] && ($row['group_type'] > 1 || $context['can_manage_membergroups']) && $canChangePrimary !== false) |
|
| 3876 | - $canChangePrimary = 1; |
|
| 4038 | + if ($row['id_group'] == $old_profile['id_group'] && ($row['group_type'] > 1 || $context['can_manage_membergroups']) && $canChangePrimary !== false) { |
|
| 4039 | + $canChangePrimary = 1; |
|
| 4040 | + } |
|
| 3877 | 4041 | |
| 3878 | 4042 | // If we are not doing a force primary move, don't do it automatically if current primary is not 0. |
| 3879 | - if ($changeType != 'primary' && $old_profile['id_group'] != 0) |
|
| 3880 | - $canChangePrimary = false; |
|
| 4043 | + if ($changeType != 'primary' && $old_profile['id_group'] != 0) { |
|
| 4044 | + $canChangePrimary = false; |
|
| 4045 | + } |
|
| 3881 | 4046 | |
| 3882 | 4047 | // If this is the one we are acting on, can we even act? |
| 3883 | - if ((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) |
|
| 3884 | - $canChangePrimary = false; |
|
| 4048 | + if ((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) { |
|
| 4049 | + $canChangePrimary = false; |
|
| 4050 | + } |
|
| 3885 | 4051 | } |
| 3886 | 4052 | $smcFunc['db_free_result']($request); |
| 3887 | 4053 | |
| 3888 | 4054 | // Didn't find the target? |
| 3889 | - if (!$foundTarget) |
|
| 3890 | - fatal_lang_error('no_access', false); |
|
| 4055 | + if (!$foundTarget) { |
|
| 4056 | + fatal_lang_error('no_access', false); |
|
| 4057 | + } |
|
| 3891 | 4058 | |
| 3892 | 4059 | // Final security check, don't allow users to promote themselves to admin. |
| 3893 | 4060 | if ($context['can_manage_membergroups'] && !allowedTo('admin_forum')) |
@@ -3907,8 +4074,9 @@ discard block |
||
| 3907 | 4074 | list ($disallow) = $smcFunc['db_fetch_row']($request); |
| 3908 | 4075 | $smcFunc['db_free_result']($request); |
| 3909 | 4076 | |
| 3910 | - if ($disallow) |
|
| 3911 | - isAllowedTo('admin_forum'); |
|
| 4077 | + if ($disallow) { |
|
| 4078 | + isAllowedTo('admin_forum'); |
|
| 4079 | + } |
|
| 3912 | 4080 | } |
| 3913 | 4081 | |
| 3914 | 4082 | // If we're requesting, add the note then return. |
@@ -3926,8 +4094,9 @@ discard block |
||
| 3926 | 4094 | 'status_open' => 0, |
| 3927 | 4095 | ) |
| 3928 | 4096 | ); |
| 3929 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 3930 | - fatal_lang_error('profile_error_already_requested_group'); |
|
| 4097 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 4098 | + fatal_lang_error('profile_error_already_requested_group'); |
|
| 4099 | + } |
|
| 3931 | 4100 | $smcFunc['db_free_result']($request); |
| 3932 | 4101 | |
| 3933 | 4102 | // Log the request. |
@@ -3961,10 +4130,11 @@ discard block |
||
| 3961 | 4130 | // Are we leaving? |
| 3962 | 4131 | if ($old_profile['id_group'] == $group_id || isset($addGroups[$group_id])) |
| 3963 | 4132 | { |
| 3964 | - if ($old_profile['id_group'] == $group_id) |
|
| 3965 | - $newPrimary = 0; |
|
| 3966 | - else |
|
| 3967 | - unset($addGroups[$group_id]); |
|
| 4133 | + if ($old_profile['id_group'] == $group_id) { |
|
| 4134 | + $newPrimary = 0; |
|
| 4135 | + } else { |
|
| 4136 | + unset($addGroups[$group_id]); |
|
| 4137 | + } |
|
| 3968 | 4138 | } |
| 3969 | 4139 | // ... if not, must be joining. |
| 3970 | 4140 | else |
@@ -3972,36 +4142,42 @@ discard block |
||
| 3972 | 4142 | // Can we change the primary, and do we want to? |
| 3973 | 4143 | if ($canChangePrimary) |
| 3974 | 4144 | { |
| 3975 | - if ($old_profile['id_group'] != 0) |
|
| 3976 | - $addGroups[$old_profile['id_group']] = -1; |
|
| 4145 | + if ($old_profile['id_group'] != 0) { |
|
| 4146 | + $addGroups[$old_profile['id_group']] = -1; |
|
| 4147 | + } |
|
| 3977 | 4148 | $newPrimary = $group_id; |
| 3978 | 4149 | } |
| 3979 | 4150 | // Otherwise it's an additional group... |
| 3980 | - else |
|
| 3981 | - $addGroups[$group_id] = -1; |
|
| 4151 | + else { |
|
| 4152 | + $addGroups[$group_id] = -1; |
|
| 4153 | + } |
|
| 3982 | 4154 | } |
| 3983 | 4155 | } |
| 3984 | 4156 | // Finally, we must be setting the primary. |
| 3985 | 4157 | elseif ($canChangePrimary) |
| 3986 | 4158 | { |
| 3987 | - if ($old_profile['id_group'] != 0) |
|
| 3988 | - $addGroups[$old_profile['id_group']] = -1; |
|
| 3989 | - if (isset($addGroups[$group_id])) |
|
| 3990 | - unset($addGroups[$group_id]); |
|
| 4159 | + if ($old_profile['id_group'] != 0) { |
|
| 4160 | + $addGroups[$old_profile['id_group']] = -1; |
|
| 4161 | + } |
|
| 4162 | + if (isset($addGroups[$group_id])) { |
|
| 4163 | + unset($addGroups[$group_id]); |
|
| 4164 | + } |
|
| 3991 | 4165 | $newPrimary = $group_id; |
| 3992 | 4166 | } |
| 3993 | 4167 | |
| 3994 | 4168 | // Finally, we can make the changes! |
| 3995 | - foreach ($addGroups as $id => $dummy) |
|
| 3996 | - if (empty($id)) |
|
| 4169 | + foreach ($addGroups as $id => $dummy) { |
|
| 4170 | + if (empty($id)) |
|
| 3997 | 4171 | unset($addGroups[$id]); |
| 4172 | + } |
|
| 3998 | 4173 | $addGroups = implode(',', array_flip($addGroups)); |
| 3999 | 4174 | |
| 4000 | 4175 | // Ensure that we don't cache permissions if the group is changing. |
| 4001 | - if ($context['user']['is_owner']) |
|
| 4002 | - $_SESSION['mc']['time'] = 0; |
|
| 4003 | - else |
|
| 4004 | - updateSettings(array('settings_updated' => time())); |
|
| 4176 | + if ($context['user']['is_owner']) { |
|
| 4177 | + $_SESSION['mc']['time'] = 0; |
|
| 4178 | + } else { |
|
| 4179 | + updateSettings(array('settings_updated' => time())); |
|
| 4180 | + } |
|
| 4005 | 4181 | |
| 4006 | 4182 | updateMemberData($memID, array('id_group' => $newPrimary, 'additional_groups' => $addGroups)); |
| 4007 | 4183 | |
@@ -4024,8 +4200,9 @@ discard block |
||
| 4024 | 4200 | if (empty($user_settings['tfa_secret']) && $context['user']['is_owner']) |
| 4025 | 4201 | { |
| 4026 | 4202 | // Check to ensure we're forcing SSL for authentication |
| 4027 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
| 4028 | - fatal_lang_error('login_ssl_required'); |
|
| 4203 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
| 4204 | + fatal_lang_error('login_ssl_required'); |
|
| 4205 | + } |
|
| 4029 | 4206 | |
| 4030 | 4207 | // In some cases (forced 2FA or backup code) they would be forced to be redirected here, |
| 4031 | 4208 | // we do not want too much AJAX to confuse them. |
@@ -4062,8 +4239,7 @@ discard block |
||
| 4062 | 4239 | $context['sub_template'] = 'tfasetup_backup'; |
| 4063 | 4240 | |
| 4064 | 4241 | return; |
| 4065 | - } |
|
| 4066 | - else |
|
| 4242 | + } else |
|
| 4067 | 4243 | { |
| 4068 | 4244 | $context['tfa_secret'] = $_SESSION['tfa_secret']; |
| 4069 | 4245 | $context['tfa_error'] = !$valid_code; |
@@ -4071,8 +4247,7 @@ discard block |
||
| 4071 | 4247 | $context['tfa_pass_value'] = $_POST['passwd']; |
| 4072 | 4248 | $context['tfa_value'] = $_POST['tfa_code']; |
| 4073 | 4249 | } |
| 4074 | - } |
|
| 4075 | - else |
|
| 4250 | + } else |
|
| 4076 | 4251 | { |
| 4077 | 4252 | $totp = new \TOTP\Auth(); |
| 4078 | 4253 | $secret = $totp->generateCode(); |
@@ -4082,17 +4257,16 @@ discard block |
||
| 4082 | 4257 | } |
| 4083 | 4258 | |
| 4084 | 4259 | $context['tfa_qr_url'] = $totp->getQrCodeUrl($context['forum_name'] . ':' . $user_info['name'], $context['tfa_secret']); |
| 4085 | - } |
|
| 4086 | - elseif (isset($_REQUEST['disable'])) |
|
| 4260 | + } elseif (isset($_REQUEST['disable'])) |
|
| 4087 | 4261 | { |
| 4088 | 4262 | updateMemberData($memID, array( |
| 4089 | 4263 | 'tfa_secret' => '', |
| 4090 | 4264 | 'tfa_backup' => '', |
| 4091 | 4265 | )); |
| 4092 | 4266 | redirectexit('action=profile;area=account;u=' . $memID); |
| 4267 | + } else { |
|
| 4268 | + redirectexit('action=profile;area=account;u=' . $memID); |
|
| 4269 | + } |
|
| 4093 | 4270 | } |
| 4094 | - else |
|
| 4095 | - redirectexit('action=profile;area=account;u=' . $memID); |
|
| 4096 | -} |
|
| 4097 | 4271 | |
| 4098 | 4272 | ?> |
| 4099 | 4273 | \ No newline at end of file |
@@ -2605,7 +2605,7 @@ |
||
| 2605 | 2605 | * @param int $start Which item to start with (for pagination purposes) |
| 2606 | 2606 | * @param int $items_per_page How many items to show on each page |
| 2607 | 2607 | * @param string $sort A string indicating how to sort the results |
| 2608 | - * @param int $memID The ID of the member |
|
| 2608 | + * @param string $memID The ID of the member |
|
| 2609 | 2609 | * @return array An array of information about the user's group requests |
| 2610 | 2610 | */ |
| 2611 | 2611 | function list_getGroupRequests($start, $items_per_page, $sort, $memID) |
@@ -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 | * View a summary. |
@@ -23,8 +24,9 @@ discard block |
||
| 23 | 24 | global $context, $memberContext, $txt, $modSettings, $user_profile, $sourcedir, $scripturl, $smcFunc; |
| 24 | 25 | |
| 25 | 26 | // Attempt to load the member's profile data. |
| 26 | - if (!loadMemberContext($memID) || !isset($memberContext[$memID])) |
|
| 27 | - fatal_lang_error('not_a_user', false, 404); |
|
| 27 | + if (!loadMemberContext($memID) || !isset($memberContext[$memID])) { |
|
| 28 | + fatal_lang_error('not_a_user', false, 404); |
|
| 29 | + } |
|
| 28 | 30 | |
| 29 | 31 | // Set up the stuff and load the user. |
| 30 | 32 | $context += array( |
@@ -49,19 +51,21 @@ discard block |
||
| 49 | 51 | |
| 50 | 52 | // See if they have broken any warning levels... |
| 51 | 53 | list ($modSettings['warning_enable'], $modSettings['user_limit']) = explode(',', $modSettings['warning_settings']); |
| 52 | - if (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $context['member']['warning']) |
|
| 53 | - $context['warning_status'] = $txt['profile_warning_is_muted']; |
|
| 54 | - elseif (!empty($modSettings['warning_moderate']) && $modSettings['warning_moderate'] <= $context['member']['warning']) |
|
| 55 | - $context['warning_status'] = $txt['profile_warning_is_moderation']; |
|
| 56 | - elseif (!empty($modSettings['warning_watch']) && $modSettings['warning_watch'] <= $context['member']['warning']) |
|
| 57 | - $context['warning_status'] = $txt['profile_warning_is_watch']; |
|
| 54 | + if (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $context['member']['warning']) { |
|
| 55 | + $context['warning_status'] = $txt['profile_warning_is_muted']; |
|
| 56 | + } elseif (!empty($modSettings['warning_moderate']) && $modSettings['warning_moderate'] <= $context['member']['warning']) { |
|
| 57 | + $context['warning_status'] = $txt['profile_warning_is_moderation']; |
|
| 58 | + } elseif (!empty($modSettings['warning_watch']) && $modSettings['warning_watch'] <= $context['member']['warning']) { |
|
| 59 | + $context['warning_status'] = $txt['profile_warning_is_watch']; |
|
| 60 | + } |
|
| 58 | 61 | |
| 59 | 62 | // They haven't even been registered for a full day!? |
| 60 | 63 | $days_registered = (int) ((time() - $user_profile[$memID]['date_registered']) / (3600 * 24)); |
| 61 | - if (empty($user_profile[$memID]['date_registered']) || $days_registered < 1) |
|
| 62 | - $context['member']['posts_per_day'] = $txt['not_applicable']; |
|
| 63 | - else |
|
| 64 | - $context['member']['posts_per_day'] = comma_format($context['member']['real_posts'] / $days_registered, 3); |
|
| 64 | + if (empty($user_profile[$memID]['date_registered']) || $days_registered < 1) { |
|
| 65 | + $context['member']['posts_per_day'] = $txt['not_applicable']; |
|
| 66 | + } else { |
|
| 67 | + $context['member']['posts_per_day'] = comma_format($context['member']['real_posts'] / $days_registered, 3); |
|
| 68 | + } |
|
| 65 | 69 | |
| 66 | 70 | // Set the age... |
| 67 | 71 | if (empty($context['member']['birth_date'])) |
@@ -70,8 +74,7 @@ discard block |
||
| 70 | 74 | 'age' => $txt['not_applicable'], |
| 71 | 75 | 'today_is_birthday' => false |
| 72 | 76 | ); |
| 73 | - } |
|
| 74 | - else |
|
| 77 | + } else |
|
| 75 | 78 | { |
| 76 | 79 | list ($birth_year, $birth_month, $birth_day) = sscanf($context['member']['birth_date'], '%d-%d-%d'); |
| 77 | 80 | $datearray = getdate(forum_time()); |
@@ -84,15 +87,16 @@ discard block |
||
| 84 | 87 | if (allowedTo('moderate_forum')) |
| 85 | 88 | { |
| 86 | 89 | // Make sure it's a valid ip address; otherwise, don't bother... |
| 87 | - if (preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $memberContext[$memID]['ip']) == 1 && empty($modSettings['disableHostnameLookup'])) |
|
| 88 | - $context['member']['hostname'] = host_from_ip($memberContext[$memID]['ip']); |
|
| 89 | - else |
|
| 90 | - $context['member']['hostname'] = ''; |
|
| 90 | + if (preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $memberContext[$memID]['ip']) == 1 && empty($modSettings['disableHostnameLookup'])) { |
|
| 91 | + $context['member']['hostname'] = host_from_ip($memberContext[$memID]['ip']); |
|
| 92 | + } else { |
|
| 93 | + $context['member']['hostname'] = ''; |
|
| 94 | + } |
|
| 91 | 95 | |
| 92 | 96 | $context['can_see_ip'] = true; |
| 97 | + } else { |
|
| 98 | + $context['can_see_ip'] = false; |
|
| 93 | 99 | } |
| 94 | - else |
|
| 95 | - $context['can_see_ip'] = false; |
|
| 96 | 100 | |
| 97 | 101 | // Are they hidden? |
| 98 | 102 | $context['member']['is_hidden'] = empty($user_profile[$memID]['show_online']); |
@@ -103,8 +107,9 @@ discard block |
||
| 103 | 107 | include_once($sourcedir . '/Who.php'); |
| 104 | 108 | $action = determineActions($user_profile[$memID]['url']); |
| 105 | 109 | |
| 106 | - if ($action !== false) |
|
| 107 | - $context['member']['action'] = $action; |
|
| 110 | + if ($action !== false) { |
|
| 111 | + $context['member']['action'] = $action; |
|
| 112 | + } |
|
| 108 | 113 | } |
| 109 | 114 | |
| 110 | 115 | // If the user is awaiting activation, and the viewer has permission - setup some activation context messages. |
@@ -167,13 +172,15 @@ discard block |
||
| 167 | 172 | { |
| 168 | 173 | // Work out what restrictions we actually have. |
| 169 | 174 | $ban_restrictions = array(); |
| 170 | - foreach (array('access', 'register', 'login', 'post') as $type) |
|
| 171 | - if ($row['cannot_' . $type]) |
|
| 175 | + foreach (array('access', 'register', 'login', 'post') as $type) { |
|
| 176 | + if ($row['cannot_' . $type]) |
|
| 172 | 177 | $ban_restrictions[] = $txt['ban_type_' . $type]; |
| 178 | + } |
|
| 173 | 179 | |
| 174 | 180 | // No actual ban in place? |
| 175 | - if (empty($ban_restrictions)) |
|
| 176 | - continue; |
|
| 181 | + if (empty($ban_restrictions)) { |
|
| 182 | + continue; |
|
| 183 | + } |
|
| 177 | 184 | |
| 178 | 185 | // Prepare the link for context. |
| 179 | 186 | $ban_explanation = sprintf($txt['user_cannot_due_to'], implode(', ', $ban_restrictions), '<a href="' . $scripturl . '?action=admin;area=ban;sa=edit;bg=' . $row['id_ban_group'] . '">' . $row['name'] . '</a>'); |
@@ -196,9 +203,10 @@ discard block |
||
| 196 | 203 | $context['print_custom_fields'] = array(); |
| 197 | 204 | |
| 198 | 205 | // Any custom profile fields? |
| 199 | - if (!empty($context['custom_fields'])) |
|
| 200 | - foreach ($context['custom_fields'] as $custom) |
|
| 206 | + if (!empty($context['custom_fields'])) { |
|
| 207 | + foreach ($context['custom_fields'] as $custom) |
|
| 201 | 208 | $context['print_custom_fields'][$context['cust_profile_fields_placement'][$custom['placement']]][] = $custom; |
| 209 | + } |
|
| 202 | 210 | |
| 203 | 211 | } |
| 204 | 212 | |
@@ -242,14 +250,16 @@ discard block |
||
| 242 | 250 | $row['extra'] = !empty($row['extra']) ? smf_json_decode($row['extra'], true) : array(); |
| 243 | 251 | $alerts[$id_alert] = $row; |
| 244 | 252 | |
| 245 | - if (!empty($row['sender_id'])) |
|
| 246 | - $senders[] = $row['sender_id']; |
|
| 253 | + if (!empty($row['sender_id'])) { |
|
| 254 | + $senders[] = $row['sender_id']; |
|
| 255 | + } |
|
| 247 | 256 | } |
| 248 | 257 | $smcFunc['db_free_result']($request); |
| 249 | 258 | |
| 250 | 259 | $senders = loadMemberData($senders); |
| 251 | - foreach ($senders as $member) |
|
| 252 | - loadMemberContext($member); |
|
| 260 | + foreach ($senders as $member) { |
|
| 261 | + loadMemberContext($member); |
|
| 262 | + } |
|
| 253 | 263 | |
| 254 | 264 | // Now go through and actually make with the text. |
| 255 | 265 | loadLanguage('Alerts'); |
@@ -263,12 +273,15 @@ discard block |
||
| 263 | 273 | $msgs = array(); |
| 264 | 274 | foreach ($alerts as $id_alert => $alert) |
| 265 | 275 | { |
| 266 | - if (isset($alert['extra']['board'])) |
|
| 267 | - $boards[$alert['extra']['board']] = $txt['board_na']; |
|
| 268 | - if (isset($alert['extra']['topic'])) |
|
| 269 | - $topics[$alert['extra']['topic']] = $txt['topic_na']; |
|
| 270 | - if ($alert['content_type'] == 'msg') |
|
| 271 | - $msgs[$alert['content_id']] = $txt['topic_na']; |
|
| 276 | + if (isset($alert['extra']['board'])) { |
|
| 277 | + $boards[$alert['extra']['board']] = $txt['board_na']; |
|
| 278 | + } |
|
| 279 | + if (isset($alert['extra']['topic'])) { |
|
| 280 | + $topics[$alert['extra']['topic']] = $txt['topic_na']; |
|
| 281 | + } |
|
| 282 | + if ($alert['content_type'] == 'msg') { |
|
| 283 | + $msgs[$alert['content_id']] = $txt['topic_na']; |
|
| 284 | + } |
|
| 272 | 285 | } |
| 273 | 286 | |
| 274 | 287 | // Having figured out what boards etc. there are, let's now get the names of them if we can see them. If not, there's already a fallback set up. |
@@ -283,8 +296,9 @@ discard block |
||
| 283 | 296 | 'boards' => array_keys($boards), |
| 284 | 297 | ) |
| 285 | 298 | ); |
| 286 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 287 | - $boards[$row['id_board']] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 299 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 300 | + $boards[$row['id_board']] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 301 | + } |
|
| 288 | 302 | } |
| 289 | 303 | if (!empty($topics)) |
| 290 | 304 | { |
@@ -299,8 +313,9 @@ discard block |
||
| 299 | 313 | 'topics' => array_keys($topics), |
| 300 | 314 | ) |
| 301 | 315 | ); |
| 302 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 303 | - $topics[$row['id_topic']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>'; |
|
| 316 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 317 | + $topics[$row['id_topic']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>'; |
|
| 318 | + } |
|
| 304 | 319 | } |
| 305 | 320 | if (!empty($msgs)) |
| 306 | 321 | { |
@@ -315,26 +330,33 @@ discard block |
||
| 315 | 330 | 'msgs' => array_keys($msgs), |
| 316 | 331 | ) |
| 317 | 332 | ); |
| 318 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 319 | - $msgs[$row['id_msg']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
| 333 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 334 | + $msgs[$row['id_msg']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
| 335 | + } |
|
| 320 | 336 | } |
| 321 | 337 | |
| 322 | 338 | // Now to go back through the alerts, reattach this extra information and then try to build the string out of it (if a hook didn't already) |
| 323 | 339 | foreach ($alerts as $id_alert => $alert) |
| 324 | 340 | { |
| 325 | - if (!empty($alert['text'])) |
|
| 326 | - continue; |
|
| 327 | - if (isset($alert['extra']['board'])) |
|
| 328 | - $alerts[$id_alert]['extra']['board_msg'] = $boards[$alert['extra']['board']]; |
|
| 329 | - if (isset($alert['extra']['topic'])) |
|
| 330 | - $alerts[$id_alert]['extra']['topic_msg'] = $topics[$alert['extra']['topic']]; |
|
| 331 | - if ($alert['content_type'] == 'msg') |
|
| 332 | - $alerts[$id_alert]['extra']['msg_msg'] = $msgs[$alert['content_id']]; |
|
| 333 | - if ($alert['content_type'] == 'profile') |
|
| 334 | - $alerts[$id_alert]['extra']['profile_msg'] = '<a href="' . $scripturl . '?action=profile;u=' . $alerts[$id_alert]['content_id'] . '">' . $alerts[$id_alert]['extra']['user_name'] . '</a>'; |
|
| 335 | - |
|
| 336 | - if (!empty($memberContext[$alert['sender_id']])) |
|
| 337 | - $alerts[$id_alert]['sender'] = &$memberContext[$alert['sender_id']]; |
|
| 341 | + if (!empty($alert['text'])) { |
|
| 342 | + continue; |
|
| 343 | + } |
|
| 344 | + if (isset($alert['extra']['board'])) { |
|
| 345 | + $alerts[$id_alert]['extra']['board_msg'] = $boards[$alert['extra']['board']]; |
|
| 346 | + } |
|
| 347 | + if (isset($alert['extra']['topic'])) { |
|
| 348 | + $alerts[$id_alert]['extra']['topic_msg'] = $topics[$alert['extra']['topic']]; |
|
| 349 | + } |
|
| 350 | + if ($alert['content_type'] == 'msg') { |
|
| 351 | + $alerts[$id_alert]['extra']['msg_msg'] = $msgs[$alert['content_id']]; |
|
| 352 | + } |
|
| 353 | + if ($alert['content_type'] == 'profile') { |
|
| 354 | + $alerts[$id_alert]['extra']['profile_msg'] = '<a href="' . $scripturl . '?action=profile;u=' . $alerts[$id_alert]['content_id'] . '">' . $alerts[$id_alert]['extra']['user_name'] . '</a>'; |
|
| 355 | + } |
|
| 356 | + |
|
| 357 | + if (!empty($memberContext[$alert['sender_id']])) { |
|
| 358 | + $alerts[$id_alert]['sender'] = &$memberContext[$alert['sender_id']]; |
|
| 359 | + } |
|
| 338 | 360 | |
| 339 | 361 | $string = 'alert_' . $alert['content_type'] . '_' . $alert['content_action']; |
| 340 | 362 | if (isset($txt[$string])) |
@@ -422,11 +444,11 @@ discard block |
||
| 422 | 444 | checkSession('request'); |
| 423 | 445 | |
| 424 | 446 | // Call it! |
| 425 | - if ($action == 'remove') |
|
| 426 | - alert_delete($toMark, $memID); |
|
| 427 | - |
|
| 428 | - else |
|
| 429 | - alert_mark($memID, $toMark, $action == 'read' ? 1 : 0); |
|
| 447 | + if ($action == 'remove') { |
|
| 448 | + alert_delete($toMark, $memID); |
|
| 449 | + } else { |
|
| 450 | + alert_mark($memID, $toMark, $action == 'read' ? 1 : 0); |
|
| 451 | + } |
|
| 430 | 452 | |
| 431 | 453 | // Set a nice update message. |
| 432 | 454 | $_SESSION['update_message'] = true; |
@@ -476,23 +498,27 @@ discard block |
||
| 476 | 498 | ); |
| 477 | 499 | |
| 478 | 500 | // Set the page title |
| 479 | - if (isset($_GET['sa']) && array_key_exists($_GET['sa'], $title)) |
|
| 480 | - $context['page_title'] = $txt['show' . $title[$_GET['sa']]]; |
|
| 481 | - else |
|
| 482 | - $context['page_title'] = $txt['showPosts']; |
|
| 501 | + if (isset($_GET['sa']) && array_key_exists($_GET['sa'], $title)) { |
|
| 502 | + $context['page_title'] = $txt['show' . $title[$_GET['sa']]]; |
|
| 503 | + } else { |
|
| 504 | + $context['page_title'] = $txt['showPosts']; |
|
| 505 | + } |
|
| 483 | 506 | |
| 484 | 507 | $context['page_title'] .= ' - ' . $user_profile[$memID]['real_name']; |
| 485 | 508 | |
| 486 | 509 | // Is the load average too high to allow searching just now? |
| 487 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_show_posts']) && $context['load_average'] >= $modSettings['loadavg_show_posts']) |
|
| 488 | - fatal_lang_error('loadavg_show_posts_disabled', false); |
|
| 510 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_show_posts']) && $context['load_average'] >= $modSettings['loadavg_show_posts']) { |
|
| 511 | + fatal_lang_error('loadavg_show_posts_disabled', false); |
|
| 512 | + } |
|
| 489 | 513 | |
| 490 | 514 | // If we're specifically dealing with attachments use that function! |
| 491 | - if (isset($_GET['sa']) && $_GET['sa'] == 'attach') |
|
| 492 | - return showAttachments($memID); |
|
| 515 | + if (isset($_GET['sa']) && $_GET['sa'] == 'attach') { |
|
| 516 | + return showAttachments($memID); |
|
| 517 | + } |
|
| 493 | 518 | // Instead, if we're dealing with unwatched topics (and the feature is enabled) use that other function. |
| 494 | - elseif (isset($_GET['sa']) && $_GET['sa'] == 'unwatchedtopics') |
|
| 495 | - return showUnwatched($memID); |
|
| 519 | + elseif (isset($_GET['sa']) && $_GET['sa'] == 'unwatchedtopics') { |
|
| 520 | + return showUnwatched($memID); |
|
| 521 | + } |
|
| 496 | 522 | |
| 497 | 523 | // Are we just viewing topics? |
| 498 | 524 | $context['is_topics'] = isset($_GET['sa']) && $_GET['sa'] == 'topics' ? true : false; |
@@ -515,27 +541,30 @@ discard block |
||
| 515 | 541 | $smcFunc['db_free_result']($request); |
| 516 | 542 | |
| 517 | 543 | // Trying to remove a message that doesn't exist. |
| 518 | - if (empty($info)) |
|
| 519 | - redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
|
| 544 | + if (empty($info)) { |
|
| 545 | + redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
|
| 546 | + } |
|
| 520 | 547 | |
| 521 | 548 | // We can be lazy, since removeMessage() will check the permissions for us. |
| 522 | 549 | require_once($sourcedir . '/RemoveTopic.php'); |
| 523 | 550 | removeMessage((int) $_GET['delete']); |
| 524 | 551 | |
| 525 | 552 | // Add it to the mod log. |
| 526 | - if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) |
|
| 527 | - logAction('delete', array('topic' => $info[2], 'subject' => $info[0], 'member' => $info[1], 'board' => $info[3])); |
|
| 553 | + if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) { |
|
| 554 | + logAction('delete', array('topic' => $info[2], 'subject' => $info[0], 'member' => $info[1], 'board' => $info[3])); |
|
| 555 | + } |
|
| 528 | 556 | |
| 529 | 557 | // Back to... where we are now ;). |
| 530 | 558 | redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
| 531 | 559 | } |
| 532 | 560 | |
| 533 | 561 | // Default to 10. |
| 534 | - if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) |
|
| 535 | - $_REQUEST['viewscount'] = '10'; |
|
| 562 | + if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) { |
|
| 563 | + $_REQUEST['viewscount'] = '10'; |
|
| 564 | + } |
|
| 536 | 565 | |
| 537 | - if ($context['is_topics']) |
|
| 538 | - $request = $smcFunc['db_query']('', ' |
|
| 566 | + if ($context['is_topics']) { |
|
| 567 | + $request = $smcFunc['db_query']('', ' |
|
| 539 | 568 | SELECT COUNT(*) |
| 540 | 569 | FROM {db_prefix}topics AS t' . ($user_info['query_see_board'] == '1=1' ? '' : ' |
| 541 | 570 | INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board AND {query_see_board})') . ' |
@@ -548,8 +577,8 @@ discard block |
||
| 548 | 577 | 'board' => $board, |
| 549 | 578 | ) |
| 550 | 579 | ); |
| 551 | - else |
|
| 552 | - $request = $smcFunc['db_query']('', ' |
|
| 580 | + } else { |
|
| 581 | + $request = $smcFunc['db_query']('', ' |
|
| 553 | 582 | SELECT COUNT(*) |
| 554 | 583 | FROM {db_prefix}messages AS m' . ($user_info['query_see_board'] == '1=1' ? '' : ' |
| 555 | 584 | INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board AND {query_see_board})') . ' |
@@ -562,6 +591,7 @@ discard block |
||
| 562 | 591 | 'board' => $board, |
| 563 | 592 | ) |
| 564 | 593 | ); |
| 594 | + } |
|
| 565 | 595 | list ($msgCount) = $smcFunc['db_fetch_row']($request); |
| 566 | 596 | $smcFunc['db_free_result']($request); |
| 567 | 597 | |
@@ -583,10 +613,11 @@ discard block |
||
| 583 | 613 | $reverse = false; |
| 584 | 614 | $range_limit = ''; |
| 585 | 615 | |
| 586 | - if ($context['is_topics']) |
|
| 587 | - $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics']; |
|
| 588 | - else |
|
| 589 | - $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
|
| 616 | + if ($context['is_topics']) { |
|
| 617 | + $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics']; |
|
| 618 | + } else { |
|
| 619 | + $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
|
| 620 | + } |
|
| 590 | 621 | |
| 591 | 622 | $maxIndex = $maxPerPage; |
| 592 | 623 | |
@@ -612,9 +643,9 @@ discard block |
||
| 612 | 643 | { |
| 613 | 644 | $margin *= 5; |
| 614 | 645 | $range_limit = $reverse ? 't.id_first_msg < ' . ($min_msg_member + $margin) : 't.id_first_msg > ' . ($max_msg_member - $margin); |
| 646 | + } else { |
|
| 647 | + $range_limit = $reverse ? 'm.id_msg < ' . ($min_msg_member + $margin) : 'm.id_msg > ' . ($max_msg_member - $margin); |
|
| 615 | 648 | } |
| 616 | - else |
|
| 617 | - $range_limit = $reverse ? 'm.id_msg < ' . ($min_msg_member + $margin) : 'm.id_msg > ' . ($max_msg_member - $margin); |
|
| 618 | 649 | } |
| 619 | 650 | |
| 620 | 651 | // Find this user's posts. The left join on categories somehow makes this faster, weird as it looks. |
@@ -646,8 +677,7 @@ discard block |
||
| 646 | 677 | 'max' => $maxIndex, |
| 647 | 678 | ) |
| 648 | 679 | ); |
| 649 | - } |
|
| 650 | - else |
|
| 680 | + } else |
|
| 651 | 681 | { |
| 652 | 682 | $request = $smcFunc['db_query']('', ' |
| 653 | 683 | SELECT |
@@ -676,8 +706,9 @@ discard block |
||
| 676 | 706 | } |
| 677 | 707 | |
| 678 | 708 | // Make sure we quit this loop. |
| 679 | - if ($smcFunc['db_num_rows']($request) === $maxIndex || $looped) |
|
| 680 | - break; |
|
| 709 | + if ($smcFunc['db_num_rows']($request) === $maxIndex || $looped) { |
|
| 710 | + break; |
|
| 711 | + } |
|
| 681 | 712 | $looped = true; |
| 682 | 713 | $range_limit = ''; |
| 683 | 714 | } |
@@ -721,19 +752,21 @@ discard block |
||
| 721 | 752 | 'css_class' => $row['approved'] ? 'windowbg' : 'approvebg', |
| 722 | 753 | ); |
| 723 | 754 | |
| 724 | - if ($user_info['id'] == $row['id_member_started']) |
|
| 725 | - $board_ids['own'][$row['id_board']][] = $counter; |
|
| 755 | + if ($user_info['id'] == $row['id_member_started']) { |
|
| 756 | + $board_ids['own'][$row['id_board']][] = $counter; |
|
| 757 | + } |
|
| 726 | 758 | $board_ids['any'][$row['id_board']][] = $counter; |
| 727 | 759 | } |
| 728 | 760 | $smcFunc['db_free_result']($request); |
| 729 | 761 | |
| 730 | 762 | // All posts were retrieved in reverse order, get them right again. |
| 731 | - if ($reverse) |
|
| 732 | - $context['posts'] = array_reverse($context['posts'], true); |
|
| 763 | + if ($reverse) { |
|
| 764 | + $context['posts'] = array_reverse($context['posts'], true); |
|
| 765 | + } |
|
| 733 | 766 | |
| 734 | 767 | // These are all the permissions that are different from board to board.. |
| 735 | - if ($context['is_topics']) |
|
| 736 | - $permissions = array( |
|
| 768 | + if ($context['is_topics']) { |
|
| 769 | + $permissions = array( |
|
| 737 | 770 | 'own' => array( |
| 738 | 771 | 'post_reply_own' => 'can_reply', |
| 739 | 772 | ), |
@@ -741,8 +774,8 @@ discard block |
||
| 741 | 774 | 'post_reply_any' => 'can_reply', |
| 742 | 775 | ) |
| 743 | 776 | ); |
| 744 | - else |
|
| 745 | - $permissions = array( |
|
| 777 | + } else { |
|
| 778 | + $permissions = array( |
|
| 746 | 779 | 'own' => array( |
| 747 | 780 | 'post_reply_own' => 'can_reply', |
| 748 | 781 | 'delete_own' => 'can_delete', |
@@ -752,6 +785,7 @@ discard block |
||
| 752 | 785 | 'delete_any' => 'can_delete', |
| 753 | 786 | ) |
| 754 | 787 | ); |
| 788 | + } |
|
| 755 | 789 | |
| 756 | 790 | // For every permission in the own/any lists... |
| 757 | 791 | foreach ($permissions as $type => $list) |
@@ -762,19 +796,22 @@ discard block |
||
| 762 | 796 | $boards = boardsAllowedTo($permission); |
| 763 | 797 | |
| 764 | 798 | // Hmm, they can do it on all boards, can they? |
| 765 | - if (!empty($boards) && $boards[0] == 0) |
|
| 766 | - $boards = array_keys($board_ids[$type]); |
|
| 799 | + if (!empty($boards) && $boards[0] == 0) { |
|
| 800 | + $boards = array_keys($board_ids[$type]); |
|
| 801 | + } |
|
| 767 | 802 | |
| 768 | 803 | // Now go through each board they can do the permission on. |
| 769 | 804 | foreach ($boards as $board_id) |
| 770 | 805 | { |
| 771 | 806 | // There aren't any posts displayed from this board. |
| 772 | - if (!isset($board_ids[$type][$board_id])) |
|
| 773 | - continue; |
|
| 807 | + if (!isset($board_ids[$type][$board_id])) { |
|
| 808 | + continue; |
|
| 809 | + } |
|
| 774 | 810 | |
| 775 | 811 | // Set the permission to true ;). |
| 776 | - foreach ($board_ids[$type][$board_id] as $counter) |
|
| 777 | - $context['posts'][$counter][$allowed] = true; |
|
| 812 | + foreach ($board_ids[$type][$board_id] as $counter) { |
|
| 813 | + $context['posts'][$counter][$allowed] = true; |
|
| 814 | + } |
|
| 778 | 815 | } |
| 779 | 816 | } |
| 780 | 817 | } |
@@ -805,8 +842,9 @@ discard block |
||
| 805 | 842 | $boardsAllowed = boardsAllowedTo('view_attachments'); |
| 806 | 843 | |
| 807 | 844 | // Make sure we can't actually see anything... |
| 808 | - if (empty($boardsAllowed)) |
|
| 809 | - $boardsAllowed = array(-1); |
|
| 845 | + if (empty($boardsAllowed)) { |
|
| 846 | + $boardsAllowed = array(-1); |
|
| 847 | + } |
|
| 810 | 848 | |
| 811 | 849 | require_once($sourcedir . '/Subs-List.php'); |
| 812 | 850 | |
@@ -957,8 +995,8 @@ discard block |
||
| 957 | 995 | ) |
| 958 | 996 | ); |
| 959 | 997 | $attachments = array(); |
| 960 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 961 | - $attachments[] = array( |
|
| 998 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 999 | + $attachments[] = array( |
|
| 962 | 1000 | 'id' => $row['id_attach'], |
| 963 | 1001 | 'filename' => $row['filename'], |
| 964 | 1002 | 'downloads' => $row['downloads'], |
@@ -970,6 +1008,7 @@ discard block |
||
| 970 | 1008 | 'board_name' => $row['name'], |
| 971 | 1009 | 'approved' => $row['approved'], |
| 972 | 1010 | ); |
| 1011 | + } |
|
| 973 | 1012 | |
| 974 | 1013 | $smcFunc['db_free_result']($request); |
| 975 | 1014 | |
@@ -1024,8 +1063,9 @@ discard block |
||
| 1024 | 1063 | global $txt, $user_info, $scripturl, $modSettings, $context, $sourcedir; |
| 1025 | 1064 | |
| 1026 | 1065 | // Only the owner can see the list (if the function is enabled of course) |
| 1027 | - if ($user_info['id'] != $memID) |
|
| 1028 | - return; |
|
| 1066 | + if ($user_info['id'] != $memID) { |
|
| 1067 | + return; |
|
| 1068 | + } |
|
| 1029 | 1069 | |
| 1030 | 1070 | require_once($sourcedir . '/Subs-List.php'); |
| 1031 | 1071 | |
@@ -1171,8 +1211,9 @@ discard block |
||
| 1171 | 1211 | ); |
| 1172 | 1212 | |
| 1173 | 1213 | $topics = array(); |
| 1174 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1175 | - $topics[] = $row['id_topic']; |
|
| 1214 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1215 | + $topics[] = $row['id_topic']; |
|
| 1216 | + } |
|
| 1176 | 1217 | |
| 1177 | 1218 | $smcFunc['db_free_result']($request); |
| 1178 | 1219 | |
@@ -1192,8 +1233,9 @@ discard block |
||
| 1192 | 1233 | 'topics' => $topics, |
| 1193 | 1234 | ) |
| 1194 | 1235 | ); |
| 1195 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1196 | - $topicsInfo[] = $row; |
|
| 1236 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1237 | + $topicsInfo[] = $row; |
|
| 1238 | + } |
|
| 1197 | 1239 | $smcFunc['db_free_result']($request); |
| 1198 | 1240 | } |
| 1199 | 1241 | |
@@ -1241,8 +1283,9 @@ discard block |
||
| 1241 | 1283 | $context['page_title'] = $txt['statPanel_showStats'] . ' ' . $user_profile[$memID]['real_name']; |
| 1242 | 1284 | |
| 1243 | 1285 | // Is the load average too high to allow searching just now? |
| 1244 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_userstats']) && $context['load_average'] >= $modSettings['loadavg_userstats']) |
|
| 1245 | - fatal_lang_error('loadavg_userstats_disabled', false); |
|
| 1286 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_userstats']) && $context['load_average'] >= $modSettings['loadavg_userstats']) { |
|
| 1287 | + fatal_lang_error('loadavg_userstats_disabled', false); |
|
| 1288 | + } |
|
| 1246 | 1289 | |
| 1247 | 1290 | // General user statistics. |
| 1248 | 1291 | $timeDays = floor($user_profile[$memID]['total_time_logged_in'] / 86400); |
@@ -1400,11 +1443,13 @@ discard block |
||
| 1400 | 1443 | } |
| 1401 | 1444 | $smcFunc['db_free_result']($result); |
| 1402 | 1445 | |
| 1403 | - if ($maxPosts > 0) |
|
| 1404 | - for ($hour = 0; $hour < 24; $hour++) |
|
| 1446 | + if ($maxPosts > 0) { |
|
| 1447 | + for ($hour = 0; |
|
| 1448 | + } |
|
| 1449 | + $hour < 24; $hour++) |
|
| 1405 | 1450 | { |
| 1406 | - if (!isset($context['posts_by_time'][$hour])) |
|
| 1407 | - $context['posts_by_time'][$hour] = array( |
|
| 1451 | + if (!isset($context['posts_by_time'][$hour])) { |
|
| 1452 | + $context['posts_by_time'][$hour] = array( |
|
| 1408 | 1453 | 'hour' => $hour, |
| 1409 | 1454 | 'hour_format' => stripos($user_info['time_format'], '%p') === false ? $hour : date('g a', mktime($hour)), |
| 1410 | 1455 | 'posts' => 0, |
@@ -1412,7 +1457,7 @@ discard block |
||
| 1412 | 1457 | 'relative_percent' => 0, |
| 1413 | 1458 | 'is_last' => $hour == 23, |
| 1414 | 1459 | ); |
| 1415 | - else |
|
| 1460 | + } else |
|
| 1416 | 1461 | { |
| 1417 | 1462 | $context['posts_by_time'][$hour]['posts_percent'] = round(($context['posts_by_time'][$hour]['posts'] * 100) / $realPosts); |
| 1418 | 1463 | $context['posts_by_time'][$hour]['relative_percent'] = round(($context['posts_by_time'][$hour]['posts'] * 100) / $maxPosts); |
@@ -1445,8 +1490,9 @@ discard block |
||
| 1445 | 1490 | |
| 1446 | 1491 | foreach ($subActions as $sa => $action) |
| 1447 | 1492 | { |
| 1448 | - if (!allowedTo($action[2])) |
|
| 1449 | - unset($subActions[$sa]); |
|
| 1493 | + if (!allowedTo($action[2])) { |
|
| 1494 | + unset($subActions[$sa]); |
|
| 1495 | + } |
|
| 1450 | 1496 | } |
| 1451 | 1497 | |
| 1452 | 1498 | // Create the tabs for the template. |
@@ -1464,15 +1510,18 @@ discard block |
||
| 1464 | 1510 | ); |
| 1465 | 1511 | |
| 1466 | 1512 | // Moderation must be on to track edits. |
| 1467 | - if (empty($modSettings['userlog_enabled'])) |
|
| 1468 | - unset($context[$context['profile_menu_name']]['tab_data']['edits'], $subActions['edits']); |
|
| 1513 | + if (empty($modSettings['userlog_enabled'])) { |
|
| 1514 | + unset($context[$context['profile_menu_name']]['tab_data']['edits'], $subActions['edits']); |
|
| 1515 | + } |
|
| 1469 | 1516 | |
| 1470 | 1517 | // Group requests must be active to show it... |
| 1471 | - if (empty($modSettings['show_group_membership'])) |
|
| 1472 | - unset($context[$context['profile_menu_name']]['tab_data']['groupreq'], $subActions['groupreq']); |
|
| 1518 | + if (empty($modSettings['show_group_membership'])) { |
|
| 1519 | + unset($context[$context['profile_menu_name']]['tab_data']['groupreq'], $subActions['groupreq']); |
|
| 1520 | + } |
|
| 1473 | 1521 | |
| 1474 | - if (empty($subActions)) |
|
| 1475 | - fatal_lang_error('no_access', false); |
|
| 1522 | + if (empty($subActions)) { |
|
| 1523 | + fatal_lang_error('no_access', false); |
|
| 1524 | + } |
|
| 1476 | 1525 | |
| 1477 | 1526 | $keys = array_keys($subActions); |
| 1478 | 1527 | $default = array_shift($keys); |
@@ -1485,9 +1534,10 @@ discard block |
||
| 1485 | 1534 | $context['sub_template'] = $subActions[$context['tracking_area']][0]; |
| 1486 | 1535 | $call = call_helper($subActions[$context['tracking_area']][0], true); |
| 1487 | 1536 | |
| 1488 | - if (!empty($call)) |
|
| 1489 | - call_user_func($call, $memID); |
|
| 1490 | -} |
|
| 1537 | + if (!empty($call)) { |
|
| 1538 | + call_user_func($call, $memID); |
|
| 1539 | + } |
|
| 1540 | + } |
|
| 1491 | 1541 | |
| 1492 | 1542 | /** |
| 1493 | 1543 | * Handles tracking a user's activity |
@@ -1503,8 +1553,9 @@ discard block |
||
| 1503 | 1553 | isAllowedTo('moderate_forum'); |
| 1504 | 1554 | |
| 1505 | 1555 | $context['last_ip'] = $user_profile[$memID]['member_ip']; |
| 1506 | - if ($context['last_ip'] != $user_profile[$memID]['member_ip2']) |
|
| 1507 | - $context['last_ip2'] = $user_profile[$memID]['member_ip2']; |
|
| 1556 | + if ($context['last_ip'] != $user_profile[$memID]['member_ip2']) { |
|
| 1557 | + $context['last_ip2'] = $user_profile[$memID]['member_ip2']; |
|
| 1558 | + } |
|
| 1508 | 1559 | $context['member']['name'] = $user_profile[$memID]['real_name']; |
| 1509 | 1560 | |
| 1510 | 1561 | // Set the options for the list component. |
@@ -1670,8 +1721,9 @@ discard block |
||
| 1670 | 1721 | ) |
| 1671 | 1722 | ); |
| 1672 | 1723 | $message_members = array(); |
| 1673 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1674 | - $message_members[] = $row['id_member']; |
|
| 1724 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1725 | + $message_members[] = $row['id_member']; |
|
| 1726 | + } |
|
| 1675 | 1727 | $smcFunc['db_free_result']($request); |
| 1676 | 1728 | |
| 1677 | 1729 | // Fetch their names, cause of the GROUP BY doesn't like giving us that normally. |
@@ -1686,8 +1738,9 @@ discard block |
||
| 1686 | 1738 | 'ip_list' => $ips, |
| 1687 | 1739 | ) |
| 1688 | 1740 | ); |
| 1689 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1690 | - $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 1741 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1742 | + $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 1743 | + } |
|
| 1691 | 1744 | $smcFunc['db_free_result']($request); |
| 1692 | 1745 | } |
| 1693 | 1746 | |
@@ -1701,8 +1754,9 @@ discard block |
||
| 1701 | 1754 | 'ip_list' => $ips, |
| 1702 | 1755 | ) |
| 1703 | 1756 | ); |
| 1704 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1705 | - $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 1757 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1758 | + $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 1759 | + } |
|
| 1706 | 1760 | $smcFunc['db_free_result']($request); |
| 1707 | 1761 | } |
| 1708 | 1762 | } |
@@ -1762,8 +1816,8 @@ discard block |
||
| 1762 | 1816 | )) |
| 1763 | 1817 | ); |
| 1764 | 1818 | $error_messages = array(); |
| 1765 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1766 | - $error_messages[] = array( |
|
| 1819 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1820 | + $error_messages[] = array( |
|
| 1767 | 1821 | 'ip' => inet_dtop($row['ip']), |
| 1768 | 1822 | 'member_link' => $row['id_member'] > 0 ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>' : $row['display_name'], |
| 1769 | 1823 | 'message' => strtr($row['message'], array('<span class="remove">' => '', '</span>' => '')), |
@@ -1771,6 +1825,7 @@ discard block |
||
| 1771 | 1825 | 'time' => timeformat($row['log_time']), |
| 1772 | 1826 | 'timestamp' => forum_time(true, $row['log_time']), |
| 1773 | 1827 | ); |
| 1828 | + } |
|
| 1774 | 1829 | $smcFunc['db_free_result']($request); |
| 1775 | 1830 | |
| 1776 | 1831 | return $error_messages; |
@@ -1833,8 +1888,8 @@ discard block |
||
| 1833 | 1888 | )) |
| 1834 | 1889 | ); |
| 1835 | 1890 | $messages = array(); |
| 1836 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1837 | - $messages[] = array( |
|
| 1891 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1892 | + $messages[] = array( |
|
| 1838 | 1893 | 'ip' => inet_dtop($row['poster_ip']), |
| 1839 | 1894 | 'member_link' => empty($row['id_member']) ? $row['display_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>', |
| 1840 | 1895 | 'board' => array( |
@@ -1847,6 +1902,7 @@ discard block |
||
| 1847 | 1902 | 'time' => timeformat($row['poster_time']), |
| 1848 | 1903 | 'timestamp' => forum_time(true, $row['poster_time']) |
| 1849 | 1904 | ); |
| 1905 | + } |
|
| 1850 | 1906 | $smcFunc['db_free_result']($request); |
| 1851 | 1907 | |
| 1852 | 1908 | return $messages; |
@@ -1873,19 +1929,20 @@ discard block |
||
| 1873 | 1929 | $context['sub_template'] = 'trackIP'; |
| 1874 | 1930 | $context['page_title'] = $txt['profile']; |
| 1875 | 1931 | $context['base_url'] = $scripturl . '?action=trackip'; |
| 1876 | - } |
|
| 1877 | - else |
|
| 1932 | + } else |
|
| 1878 | 1933 | { |
| 1879 | 1934 | $context['ip'] = $user_profile[$memID]['member_ip']; |
| 1880 | 1935 | $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
| 1881 | 1936 | } |
| 1882 | 1937 | |
| 1883 | 1938 | // Searching? |
| 1884 | - if (isset($_REQUEST['searchip'])) |
|
| 1885 | - $context['ip'] = trim($_REQUEST['searchip']); |
|
| 1939 | + if (isset($_REQUEST['searchip'])) { |
|
| 1940 | + $context['ip'] = trim($_REQUEST['searchip']); |
|
| 1941 | + } |
|
| 1886 | 1942 | |
| 1887 | - if (isValidIP($context['ip']) === false) |
|
| 1888 | - fatal_lang_error('invalid_tracking_ip', false); |
|
| 1943 | + if (isValidIP($context['ip']) === false) { |
|
| 1944 | + fatal_lang_error('invalid_tracking_ip', false); |
|
| 1945 | + } |
|
| 1889 | 1946 | |
| 1890 | 1947 | //mysql didn't support like search with varbinary |
| 1891 | 1948 | //$ip_var = str_replace('*', '%', $context['ip']); |
@@ -1893,8 +1950,9 @@ discard block |
||
| 1893 | 1950 | $ip_var = $context['ip']; |
| 1894 | 1951 | $ip_string = '= {inet:ip_address}'; |
| 1895 | 1952 | |
| 1896 | - if (empty($context['tracking_area'])) |
|
| 1897 | - $context['page_title'] = $txt['trackIP'] . ' - ' . $context['ip']; |
|
| 1953 | + if (empty($context['tracking_area'])) { |
|
| 1954 | + $context['page_title'] = $txt['trackIP'] . ' - ' . $context['ip']; |
|
| 1955 | + } |
|
| 1898 | 1956 | |
| 1899 | 1957 | $request = $smcFunc['db_query']('', ' |
| 1900 | 1958 | SELECT id_member, real_name AS display_name, member_ip |
@@ -1905,8 +1963,9 @@ discard block |
||
| 1905 | 1963 | ) |
| 1906 | 1964 | ); |
| 1907 | 1965 | $context['ips'] = array(); |
| 1908 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1909 | - $context['ips'][inet_dtop($row['member_ip'])][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>'; |
|
| 1966 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1967 | + $context['ips'][inet_dtop($row['member_ip'])][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>'; |
|
| 1968 | + } |
|
| 1910 | 1969 | $smcFunc['db_free_result']($request); |
| 1911 | 1970 | |
| 1912 | 1971 | ksort($context['ips']); |
@@ -2135,8 +2194,9 @@ discard block |
||
| 2135 | 2194 | foreach ($context['whois_servers'] as $whois) |
| 2136 | 2195 | { |
| 2137 | 2196 | // Strip off the "decimal point" and anything following... |
| 2138 | - if (in_array((int) $context['ip'], $whois['range'])) |
|
| 2139 | - $context['auto_whois_server'] = $whois; |
|
| 2197 | + if (in_array((int) $context['ip'], $whois['range'])) { |
|
| 2198 | + $context['auto_whois_server'] = $whois; |
|
| 2199 | + } |
|
| 2140 | 2200 | } |
| 2141 | 2201 | } |
| 2142 | 2202 | } |
@@ -2153,10 +2213,11 @@ discard block |
||
| 2153 | 2213 | // Gonna want this for the list. |
| 2154 | 2214 | require_once($sourcedir . '/Subs-List.php'); |
| 2155 | 2215 | |
| 2156 | - if ($memID == 0) |
|
| 2157 | - $context['base_url'] = $scripturl . '?action=trackip'; |
|
| 2158 | - else |
|
| 2159 | - $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
|
| 2216 | + if ($memID == 0) { |
|
| 2217 | + $context['base_url'] = $scripturl . '?action=trackip'; |
|
| 2218 | + } else { |
|
| 2219 | + $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
|
| 2220 | + } |
|
| 2160 | 2221 | |
| 2161 | 2222 | // Start with the user messages. |
| 2162 | 2223 | $listOptions = array( |
@@ -2266,12 +2327,13 @@ discard block |
||
| 2266 | 2327 | ) |
| 2267 | 2328 | ); |
| 2268 | 2329 | $logins = array(); |
| 2269 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2270 | - $logins[] = array( |
|
| 2330 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2331 | + $logins[] = array( |
|
| 2271 | 2332 | 'time' => timeformat($row['time']), |
| 2272 | 2333 | 'ip' => inet_dtop($row['ip']), |
| 2273 | 2334 | 'ip2' => inet_dtop($row['ip2']), |
| 2274 | 2335 | ); |
| 2336 | + } |
|
| 2275 | 2337 | $smcFunc['db_free_result']($request); |
| 2276 | 2338 | |
| 2277 | 2339 | return $logins; |
@@ -2296,11 +2358,12 @@ discard block |
||
| 2296 | 2358 | ) |
| 2297 | 2359 | ); |
| 2298 | 2360 | $context['custom_field_titles'] = array(); |
| 2299 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2300 | - $context['custom_field_titles']['customfield_' . $row['col_name']] = array( |
|
| 2361 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2362 | + $context['custom_field_titles']['customfield_' . $row['col_name']] = array( |
|
| 2301 | 2363 | 'title' => $row['field_name'], |
| 2302 | 2364 | 'parse_bbc' => $row['bbc'], |
| 2303 | 2365 | ); |
| 2366 | + } |
|
| 2304 | 2367 | $smcFunc['db_free_result']($request); |
| 2305 | 2368 | |
| 2306 | 2369 | // Set the options for the error lists. |
@@ -2439,19 +2502,22 @@ discard block |
||
| 2439 | 2502 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2440 | 2503 | { |
| 2441 | 2504 | $extra = smf_json_decode($row['extra'], true); |
| 2442 | - if (!empty($extra['applicator'])) |
|
| 2443 | - $members[] = $extra['applicator']; |
|
| 2505 | + if (!empty($extra['applicator'])) { |
|
| 2506 | + $members[] = $extra['applicator']; |
|
| 2507 | + } |
|
| 2444 | 2508 | |
| 2445 | 2509 | // Work out what the name of the action is. |
| 2446 | - if (isset($txt['trackEdit_action_' . $row['action']])) |
|
| 2447 | - $action_text = $txt['trackEdit_action_' . $row['action']]; |
|
| 2448 | - elseif (isset($txt[$row['action']])) |
|
| 2449 | - $action_text = $txt[$row['action']]; |
|
| 2510 | + if (isset($txt['trackEdit_action_' . $row['action']])) { |
|
| 2511 | + $action_text = $txt['trackEdit_action_' . $row['action']]; |
|
| 2512 | + } elseif (isset($txt[$row['action']])) { |
|
| 2513 | + $action_text = $txt[$row['action']]; |
|
| 2514 | + } |
|
| 2450 | 2515 | // Custom field? |
| 2451 | - elseif (isset($context['custom_field_titles'][$row['action']])) |
|
| 2452 | - $action_text = $context['custom_field_titles'][$row['action']]['title']; |
|
| 2453 | - else |
|
| 2454 | - $action_text = $row['action']; |
|
| 2516 | + elseif (isset($context['custom_field_titles'][$row['action']])) { |
|
| 2517 | + $action_text = $context['custom_field_titles'][$row['action']]['title']; |
|
| 2518 | + } else { |
|
| 2519 | + $action_text = $row['action']; |
|
| 2520 | + } |
|
| 2455 | 2521 | |
| 2456 | 2522 | // Parse BBC? |
| 2457 | 2523 | $parse_bbc = isset($context['custom_field_titles'][$row['action']]) && $context['custom_field_titles'][$row['action']]['parse_bbc'] ? true : false; |
@@ -2483,13 +2549,15 @@ discard block |
||
| 2483 | 2549 | ) |
| 2484 | 2550 | ); |
| 2485 | 2551 | $members = array(); |
| 2486 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2487 | - $members[$row['id_member']] = $row['real_name']; |
|
| 2552 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2553 | + $members[$row['id_member']] = $row['real_name']; |
|
| 2554 | + } |
|
| 2488 | 2555 | $smcFunc['db_free_result']($request); |
| 2489 | 2556 | |
| 2490 | - foreach ($edits as $key => $value) |
|
| 2491 | - if (isset($members[$value['id_member']])) |
|
| 2557 | + foreach ($edits as $key => $value) { |
|
| 2558 | + if (isset($members[$value['id_member']])) |
|
| 2492 | 2559 | $edits[$key]['member_link'] = '<a href="' . $scripturl . '?action=profile;u=' . $value['id_member'] . '">' . $members[$value['id_member']] . '</a>'; |
| 2560 | + } |
|
| 2493 | 2561 | } |
| 2494 | 2562 | |
| 2495 | 2563 | return $edits; |
@@ -2690,10 +2758,11 @@ discard block |
||
| 2690 | 2758 | $context['board'] = $board; |
| 2691 | 2759 | |
| 2692 | 2760 | // Determine which groups this user is in. |
| 2693 | - if (empty($user_profile[$memID]['additional_groups'])) |
|
| 2694 | - $curGroups = array(); |
|
| 2695 | - else |
|
| 2696 | - $curGroups = explode(',', $user_profile[$memID]['additional_groups']); |
|
| 2761 | + if (empty($user_profile[$memID]['additional_groups'])) { |
|
| 2762 | + $curGroups = array(); |
|
| 2763 | + } else { |
|
| 2764 | + $curGroups = explode(',', $user_profile[$memID]['additional_groups']); |
|
| 2765 | + } |
|
| 2697 | 2766 | $curGroups[] = $user_profile[$memID]['id_group']; |
| 2698 | 2767 | $curGroups[] = $user_profile[$memID]['id_post_group']; |
| 2699 | 2768 | |
@@ -2713,28 +2782,30 @@ discard block |
||
| 2713 | 2782 | $context['no_access_boards'] = array(); |
| 2714 | 2783 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2715 | 2784 | { |
| 2716 | - if (count(array_intersect($curGroups, explode(',', $row['member_groups']))) === 0 && !$row['is_mod']) |
|
| 2717 | - $context['no_access_boards'][] = array( |
|
| 2785 | + if (count(array_intersect($curGroups, explode(',', $row['member_groups']))) === 0 && !$row['is_mod']) { |
|
| 2786 | + $context['no_access_boards'][] = array( |
|
| 2718 | 2787 | 'id' => $row['id_board'], |
| 2719 | 2788 | 'name' => $row['name'], |
| 2720 | 2789 | 'is_last' => false, |
| 2721 | 2790 | ); |
| 2722 | - elseif ($row['id_profile'] != 1 || $row['is_mod']) |
|
| 2723 | - $context['boards'][$row['id_board']] = array( |
|
| 2791 | + } elseif ($row['id_profile'] != 1 || $row['is_mod']) { |
|
| 2792 | + $context['boards'][$row['id_board']] = array( |
|
| 2724 | 2793 | 'id' => $row['id_board'], |
| 2725 | 2794 | 'name' => $row['name'], |
| 2726 | 2795 | 'selected' => $board == $row['id_board'], |
| 2727 | 2796 | 'profile' => $row['id_profile'], |
| 2728 | 2797 | 'profile_name' => $context['profiles'][$row['id_profile']]['name'], |
| 2729 | 2798 | ); |
| 2799 | + } |
|
| 2730 | 2800 | } |
| 2731 | 2801 | $smcFunc['db_free_result']($request); |
| 2732 | 2802 | |
| 2733 | 2803 | require_once($sourcedir . '/Subs-Boards.php'); |
| 2734 | 2804 | sortBoards($context['boards']); |
| 2735 | 2805 | |
| 2736 | - if (!empty($context['no_access_boards'])) |
|
| 2737 | - $context['no_access_boards'][count($context['no_access_boards']) - 1]['is_last'] = true; |
|
| 2806 | + if (!empty($context['no_access_boards'])) { |
|
| 2807 | + $context['no_access_boards'][count($context['no_access_boards']) - 1]['is_last'] = true; |
|
| 2808 | + } |
|
| 2738 | 2809 | |
| 2739 | 2810 | $context['member']['permissions'] = array( |
| 2740 | 2811 | 'general' => array(), |
@@ -2743,8 +2814,9 @@ discard block |
||
| 2743 | 2814 | |
| 2744 | 2815 | // If you're an admin we know you can do everything, we might as well leave. |
| 2745 | 2816 | $context['member']['has_all_permissions'] = in_array(1, $curGroups); |
| 2746 | - if ($context['member']['has_all_permissions']) |
|
| 2747 | - return; |
|
| 2817 | + if ($context['member']['has_all_permissions']) { |
|
| 2818 | + return; |
|
| 2819 | + } |
|
| 2748 | 2820 | |
| 2749 | 2821 | $denied = array(); |
| 2750 | 2822 | |
@@ -2763,21 +2835,24 @@ discard block |
||
| 2763 | 2835 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 2764 | 2836 | { |
| 2765 | 2837 | // We don't know about this permission, it doesn't exist :P. |
| 2766 | - if (!isset($txt['permissionname_' . $row['permission']])) |
|
| 2767 | - continue; |
|
| 2838 | + if (!isset($txt['permissionname_' . $row['permission']])) { |
|
| 2839 | + continue; |
|
| 2840 | + } |
|
| 2768 | 2841 | |
| 2769 | - if (empty($row['add_deny'])) |
|
| 2770 | - $denied[] = $row['permission']; |
|
| 2842 | + if (empty($row['add_deny'])) { |
|
| 2843 | + $denied[] = $row['permission']; |
|
| 2844 | + } |
|
| 2771 | 2845 | |
| 2772 | 2846 | // Permissions that end with _own or _any consist of two parts. |
| 2773 | - if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) |
|
| 2774 | - $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
| 2775 | - else |
|
| 2776 | - $name = $txt['permissionname_' . $row['permission']]; |
|
| 2847 | + if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) { |
|
| 2848 | + $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
| 2849 | + } else { |
|
| 2850 | + $name = $txt['permissionname_' . $row['permission']]; |
|
| 2851 | + } |
|
| 2777 | 2852 | |
| 2778 | 2853 | // Add this permission if it doesn't exist yet. |
| 2779 | - if (!isset($context['member']['permissions']['general'][$row['permission']])) |
|
| 2780 | - $context['member']['permissions']['general'][$row['permission']] = array( |
|
| 2854 | + if (!isset($context['member']['permissions']['general'][$row['permission']])) { |
|
| 2855 | + $context['member']['permissions']['general'][$row['permission']] = array( |
|
| 2781 | 2856 | 'id' => $row['permission'], |
| 2782 | 2857 | 'groups' => array( |
| 2783 | 2858 | 'allowed' => array(), |
@@ -2787,6 +2862,7 @@ discard block |
||
| 2787 | 2862 | 'is_denied' => false, |
| 2788 | 2863 | 'is_global' => true, |
| 2789 | 2864 | ); |
| 2865 | + } |
|
| 2790 | 2866 | |
| 2791 | 2867 | // Add the membergroup to either the denied or the allowed groups. |
| 2792 | 2868 | $context['member']['permissions']['general'][$row['permission']]['groups'][empty($row['add_deny']) ? 'denied' : 'allowed'][] = $row['id_group'] == 0 ? $txt['membergroups_members'] : $row['group_name']; |
@@ -2820,18 +2896,20 @@ discard block |
||
| 2820 | 2896 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2821 | 2897 | { |
| 2822 | 2898 | // We don't know about this permission, it doesn't exist :P. |
| 2823 | - if (!isset($txt['permissionname_' . $row['permission']])) |
|
| 2824 | - continue; |
|
| 2899 | + if (!isset($txt['permissionname_' . $row['permission']])) { |
|
| 2900 | + continue; |
|
| 2901 | + } |
|
| 2825 | 2902 | |
| 2826 | 2903 | // The name of the permission using the format 'permission name' - 'own/any topic/event/etc.'. |
| 2827 | - if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) |
|
| 2828 | - $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
| 2829 | - else |
|
| 2830 | - $name = $txt['permissionname_' . $row['permission']]; |
|
| 2904 | + if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) { |
|
| 2905 | + $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
| 2906 | + } else { |
|
| 2907 | + $name = $txt['permissionname_' . $row['permission']]; |
|
| 2908 | + } |
|
| 2831 | 2909 | |
| 2832 | 2910 | // Create the structure for this permission. |
| 2833 | - if (!isset($context['member']['permissions']['board'][$row['permission']])) |
|
| 2834 | - $context['member']['permissions']['board'][$row['permission']] = array( |
|
| 2911 | + if (!isset($context['member']['permissions']['board'][$row['permission']])) { |
|
| 2912 | + $context['member']['permissions']['board'][$row['permission']] = array( |
|
| 2835 | 2913 | 'id' => $row['permission'], |
| 2836 | 2914 | 'groups' => array( |
| 2837 | 2915 | 'allowed' => array(), |
@@ -2841,6 +2919,7 @@ discard block |
||
| 2841 | 2919 | 'is_denied' => false, |
| 2842 | 2920 | 'is_global' => empty($board), |
| 2843 | 2921 | ); |
| 2922 | + } |
|
| 2844 | 2923 | |
| 2845 | 2924 | $context['member']['permissions']['board'][$row['permission']]['groups'][empty($row['add_deny']) ? 'denied' : 'allowed'][$row['id_group']] = $row['id_group'] == 0 ? $txt['membergroups_members'] : $row['group_name']; |
| 2846 | 2925 | |
@@ -2859,8 +2938,9 @@ discard block |
||
| 2859 | 2938 | global $modSettings, $context, $sourcedir, $txt, $scripturl; |
| 2860 | 2939 | |
| 2861 | 2940 | // Firstly, can we actually even be here? |
| 2862 | - if (!($context['user']['is_owner'] && allowedTo('view_warning_own')) && !allowedTo('view_warning_any') && !allowedTo('issue_warning') && !allowedTo('moderate_forum')) |
|
| 2863 | - fatal_lang_error('no_access', false); |
|
| 2941 | + if (!($context['user']['is_owner'] && allowedTo('view_warning_own')) && !allowedTo('view_warning_any') && !allowedTo('issue_warning') && !allowedTo('moderate_forum')) { |
|
| 2942 | + fatal_lang_error('no_access', false); |
|
| 2943 | + } |
|
| 2864 | 2944 | |
| 2865 | 2945 | // Make sure things which are disabled stay disabled. |
| 2866 | 2946 | $modSettings['warning_watch'] = !empty($modSettings['warning_watch']) ? $modSettings['warning_watch'] : 110; |
@@ -2947,9 +3027,10 @@ discard block |
||
| 2947 | 3027 | $modSettings['warning_mute'] => $txt['profile_warning_effect_own_muted'], |
| 2948 | 3028 | ); |
| 2949 | 3029 | $context['current_level'] = 0; |
| 2950 | - foreach ($context['level_effects'] as $limit => $dummy) |
|
| 2951 | - if ($context['member']['warning'] >= $limit) |
|
| 3030 | + foreach ($context['level_effects'] as $limit => $dummy) { |
|
| 3031 | + if ($context['member']['warning'] >= $limit) |
|
| 2952 | 3032 | $context['current_level'] = $limit; |
| 2953 | -} |
|
| 3033 | + } |
|
| 3034 | + } |
|
| 2954 | 3035 | |
| 2955 | 3036 | ?> |
| 2956 | 3037 | \ No newline at end of file |
@@ -325,7 +325,7 @@ |
||
| 325 | 325 | * Validates a IPv6 address. returns true if it is ipv6. |
| 326 | 326 | * |
| 327 | 327 | * @param string $ip The ip address to be validated |
| 328 | - * @return boolean Whether the specified IP is a valid IPv6 address |
|
| 328 | + * @return false|string Whether the specified IP is a valid IPv6 address |
|
| 329 | 329 | */ |
| 330 | 330 | function isValidIPv6($ip) |
| 331 | 331 | { |
@@ -426,8 +426,8 @@ |
||
| 426 | 426 | */ |
| 427 | 427 | function matchIPtoCIDR($ip_address, $cidr_address) |
| 428 | 428 | { |
| 429 | - list ($cidr_network, $cidr_subnetmask) = preg_split('/', $cidr_address); |
|
| 430 | - return (ip2long($ip_address) & (~((1 << (32 - $cidr_subnetmask)) - 1))) == ip2long($cidr_network); |
|
| 429 | + list ($cidr_network, $cidr_subnetmask) = preg_split('/', $cidr_address); |
|
| 430 | + return (ip2long($ip_address) & (~((1 << (32 - $cidr_subnetmask)) - 1))) == ip2long($cidr_network); |
|
| 431 | 431 | } |
| 432 | 432 | |
| 433 | 433 | /** |
@@ -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 | * Clean the request variables - add html entities to GET and slashes if magic_quotes_gpc is Off. |
@@ -44,22 +45,26 @@ discard block |
||
| 44 | 45 | unset($GLOBALS['HTTP_POST_FILES'], $GLOBALS['HTTP_POST_FILES']); |
| 45 | 46 | |
| 46 | 47 | // These keys shouldn't be set...ever. |
| 47 | - if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) |
|
| 48 | - die('Invalid request variable.'); |
|
| 48 | + if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) { |
|
| 49 | + die('Invalid request variable.'); |
|
| 50 | + } |
|
| 49 | 51 | |
| 50 | 52 | // Same goes for numeric keys. |
| 51 | - foreach (array_merge(array_keys($_POST), array_keys($_GET), array_keys($_FILES)) as $key) |
|
| 52 | - if (is_numeric($key)) |
|
| 53 | + foreach (array_merge(array_keys($_POST), array_keys($_GET), array_keys($_FILES)) as $key) { |
|
| 54 | + if (is_numeric($key)) |
|
| 53 | 55 | die('Numeric request keys are invalid.'); |
| 56 | + } |
|
| 54 | 57 | |
| 55 | 58 | // Numeric keys in cookies are less of a problem. Just unset those. |
| 56 | - foreach ($_COOKIE as $key => $value) |
|
| 57 | - if (is_numeric($key)) |
|
| 59 | + foreach ($_COOKIE as $key => $value) { |
|
| 60 | + if (is_numeric($key)) |
|
| 58 | 61 | unset($_COOKIE[$key]); |
| 62 | + } |
|
| 59 | 63 | |
| 60 | 64 | // Get the correct query string. It may be in an environment variable... |
| 61 | - if (!isset($_SERVER['QUERY_STRING'])) |
|
| 62 | - $_SERVER['QUERY_STRING'] = getenv('QUERY_STRING'); |
|
| 65 | + if (!isset($_SERVER['QUERY_STRING'])) { |
|
| 66 | + $_SERVER['QUERY_STRING'] = getenv('QUERY_STRING'); |
|
| 67 | + } |
|
| 63 | 68 | |
| 64 | 69 | // It seems that sticking a URL after the query string is mighty common, well, it's evil - don't. |
| 65 | 70 | if (strpos($_SERVER['QUERY_STRING'], 'http') === 0) |
@@ -83,13 +88,14 @@ discard block |
||
| 83 | 88 | parse_str(preg_replace('/&(\w+)(?=&|$)/', '&$1=', strtr($_SERVER['QUERY_STRING'], array(';?' => '&', ';' => '&', '%00' => '', "\0" => ''))), $_GET); |
| 84 | 89 | |
| 85 | 90 | // Magic quotes still applies with parse_str - so clean it up. |
| 86 | - if (function_exists('get_magic_quotes_gpc') && @get_magic_quotes_gpc() != 0 && empty($modSettings['integrate_magic_quotes'])) |
|
| 87 | - $_GET = $removeMagicQuoteFunction($_GET); |
|
| 88 | - } |
|
| 89 | - elseif (strpos(ini_get('arg_separator.input'), ';') !== false) |
|
| 91 | + if (function_exists('get_magic_quotes_gpc') && @get_magic_quotes_gpc() != 0 && empty($modSettings['integrate_magic_quotes'])) { |
|
| 92 | + $_GET = $removeMagicQuoteFunction($_GET); |
|
| 93 | + } |
|
| 94 | + } elseif (strpos(ini_get('arg_separator.input'), ';') !== false) |
|
| 90 | 95 | { |
| 91 | - if (function_exists('get_magic_quotes_gpc') && @get_magic_quotes_gpc() != 0 && empty($modSettings['integrate_magic_quotes'])) |
|
| 92 | - $_GET = $removeMagicQuoteFunction($_GET); |
|
| 96 | + if (function_exists('get_magic_quotes_gpc') && @get_magic_quotes_gpc() != 0 && empty($modSettings['integrate_magic_quotes'])) { |
|
| 97 | + $_GET = $removeMagicQuoteFunction($_GET); |
|
| 98 | + } |
|
| 93 | 99 | |
| 94 | 100 | // Search engines will send action=profile%3Bu=1, which confuses PHP. |
| 95 | 101 | foreach ($_GET as $k => $v) |
@@ -102,8 +108,9 @@ discard block |
||
| 102 | 108 | for ($i = 1, $n = count($temp); $i < $n; $i++) |
| 103 | 109 | { |
| 104 | 110 | @list ($key, $val) = @explode('=', $temp[$i], 2); |
| 105 | - if (!isset($_GET[$key])) |
|
| 106 | - $_GET[$key] = $val; |
|
| 111 | + if (!isset($_GET[$key])) { |
|
| 112 | + $_GET[$key] = $val; |
|
| 113 | + } |
|
| 107 | 114 | } |
| 108 | 115 | } |
| 109 | 116 | |
@@ -120,18 +127,20 @@ discard block |
||
| 120 | 127 | if (!empty($_SERVER['REQUEST_URI'])) |
| 121 | 128 | { |
| 122 | 129 | // Remove the .html, assuming there is one. |
| 123 | - if (substr($_SERVER['REQUEST_URI'], strrpos($_SERVER['REQUEST_URI'], '.'), 4) == '.htm') |
|
| 124 | - $request = substr($_SERVER['REQUEST_URI'], 0, strrpos($_SERVER['REQUEST_URI'], '.')); |
|
| 125 | - else |
|
| 126 | - $request = $_SERVER['REQUEST_URI']; |
|
| 130 | + if (substr($_SERVER['REQUEST_URI'], strrpos($_SERVER['REQUEST_URI'], '.'), 4) == '.htm') { |
|
| 131 | + $request = substr($_SERVER['REQUEST_URI'], 0, strrpos($_SERVER['REQUEST_URI'], '.')); |
|
| 132 | + } else { |
|
| 133 | + $request = $_SERVER['REQUEST_URI']; |
|
| 134 | + } |
|
| 127 | 135 | |
| 128 | 136 | // @todo smflib. |
| 129 | 137 | // Replace 'index.php/a,b,c/d/e,f' with 'a=b,c&d=&e=f' and parse it into $_GET. |
| 130 | 138 | if (strpos($request, basename($scripturl) . '/') !== false) |
| 131 | 139 | { |
| 132 | 140 | parse_str(substr(preg_replace('/&(\w+)(?=&|$)/', '&$1=', strtr(preg_replace('~/([^,/]+),~', '/$1=', substr($request, strpos($request, basename($scripturl)) + strlen(basename($scripturl)))), '/', '&')), 1), $temp); |
| 133 | - if (function_exists('get_magic_quotes_gpc') && @get_magic_quotes_gpc() != 0 && empty($modSettings['integrate_magic_quotes'])) |
|
| 134 | - $temp = $removeMagicQuoteFunction($temp); |
|
| 141 | + if (function_exists('get_magic_quotes_gpc') && @get_magic_quotes_gpc() != 0 && empty($modSettings['integrate_magic_quotes'])) { |
|
| 142 | + $temp = $removeMagicQuoteFunction($temp); |
|
| 143 | + } |
|
| 135 | 144 | $_GET += $temp; |
| 136 | 145 | } |
| 137 | 146 | } |
@@ -142,9 +151,10 @@ discard block |
||
| 142 | 151 | $_ENV = $removeMagicQuoteFunction($_ENV); |
| 143 | 152 | $_POST = $removeMagicQuoteFunction($_POST); |
| 144 | 153 | $_COOKIE = $removeMagicQuoteFunction($_COOKIE); |
| 145 | - foreach ($_FILES as $k => $dummy) |
|
| 146 | - if (isset($_FILES[$k]['name'])) |
|
| 154 | + foreach ($_FILES as $k => $dummy) { |
|
| 155 | + if (isset($_FILES[$k]['name'])) |
|
| 147 | 156 | $_FILES[$k]['name'] = $removeMagicQuoteFunction($_FILES[$k]['name']); |
| 157 | + } |
|
| 148 | 158 | } |
| 149 | 159 | |
| 150 | 160 | // Add entities to GET. This is kinda like the slashes on everything else. |
@@ -160,11 +170,13 @@ discard block |
||
| 160 | 170 | $_REQUEST['board'] = (string) $_REQUEST['board']; |
| 161 | 171 | |
| 162 | 172 | // If there's a slash in it, we've got a start value! (old, compatible links.) |
| 163 | - if (strpos($_REQUEST['board'], '/') !== false) |
|
| 164 | - list ($_REQUEST['board'], $_REQUEST['start']) = explode('/', $_REQUEST['board']); |
|
| 173 | + if (strpos($_REQUEST['board'], '/') !== false) { |
|
| 174 | + list ($_REQUEST['board'], $_REQUEST['start']) = explode('/', $_REQUEST['board']); |
|
| 175 | + } |
|
| 165 | 176 | // Same idea, but dots. This is the currently used format - ?board=1.0... |
| 166 | - elseif (strpos($_REQUEST['board'], '.') !== false) |
|
| 167 | - list ($_REQUEST['board'], $_REQUEST['start']) = explode('.', $_REQUEST['board']); |
|
| 177 | + elseif (strpos($_REQUEST['board'], '.') !== false) { |
|
| 178 | + list ($_REQUEST['board'], $_REQUEST['start']) = explode('.', $_REQUEST['board']); |
|
| 179 | + } |
|
| 168 | 180 | // Now make absolutely sure it's a number. |
| 169 | 181 | $board = (int) $_REQUEST['board']; |
| 170 | 182 | $_REQUEST['start'] = isset($_REQUEST['start']) ? (int) $_REQUEST['start'] : 0; |
@@ -173,12 +185,14 @@ discard block |
||
| 173 | 185 | $_GET['board'] = $board; |
| 174 | 186 | } |
| 175 | 187 | // Well, $board is going to be a number no matter what. |
| 176 | - else |
|
| 177 | - $board = 0; |
|
| 188 | + else { |
|
| 189 | + $board = 0; |
|
| 190 | + } |
|
| 178 | 191 | |
| 179 | 192 | // If there's a threadid, it's probably an old YaBB SE link. Flow with it. |
| 180 | - if (isset($_REQUEST['threadid']) && !isset($_REQUEST['topic'])) |
|
| 181 | - $_REQUEST['topic'] = $_REQUEST['threadid']; |
|
| 193 | + if (isset($_REQUEST['threadid']) && !isset($_REQUEST['topic'])) { |
|
| 194 | + $_REQUEST['topic'] = $_REQUEST['threadid']; |
|
| 195 | + } |
|
| 182 | 196 | |
| 183 | 197 | // We've got topic! |
| 184 | 198 | if (isset($_REQUEST['topic'])) |
@@ -187,29 +201,34 @@ discard block |
||
| 187 | 201 | $_REQUEST['topic'] = (string) $_REQUEST['topic']; |
| 188 | 202 | |
| 189 | 203 | // Slash means old, beta style, formatting. That's okay though, the link should still work. |
| 190 | - if (strpos($_REQUEST['topic'], '/') !== false) |
|
| 191 | - list ($_REQUEST['topic'], $_REQUEST['start']) = explode('/', $_REQUEST['topic']); |
|
| 204 | + if (strpos($_REQUEST['topic'], '/') !== false) { |
|
| 205 | + list ($_REQUEST['topic'], $_REQUEST['start']) = explode('/', $_REQUEST['topic']); |
|
| 206 | + } |
|
| 192 | 207 | // Dots are useful and fun ;). This is ?topic=1.15. |
| 193 | - elseif (strpos($_REQUEST['topic'], '.') !== false) |
|
| 194 | - list ($_REQUEST['topic'], $_REQUEST['start']) = explode('.', $_REQUEST['topic']); |
|
| 208 | + elseif (strpos($_REQUEST['topic'], '.') !== false) { |
|
| 209 | + list ($_REQUEST['topic'], $_REQUEST['start']) = explode('.', $_REQUEST['topic']); |
|
| 210 | + } |
|
| 195 | 211 | |
| 196 | 212 | $topic = (int) $_REQUEST['topic']; |
| 197 | 213 | |
| 198 | 214 | // Now make sure the online log gets the right number. |
| 199 | 215 | $_GET['topic'] = $topic; |
| 216 | + } else { |
|
| 217 | + $topic = 0; |
|
| 200 | 218 | } |
| 201 | - else |
|
| 202 | - $topic = 0; |
|
| 203 | 219 | |
| 204 | 220 | // There should be a $_REQUEST['start'], some at least. If you need to default to other than 0, use $_GET['start']. |
| 205 | - if (empty($_REQUEST['start']) || $_REQUEST['start'] < 0 || (int) $_REQUEST['start'] > 2147473647) |
|
| 206 | - $_REQUEST['start'] = 0; |
|
| 221 | + if (empty($_REQUEST['start']) || $_REQUEST['start'] < 0 || (int) $_REQUEST['start'] > 2147473647) { |
|
| 222 | + $_REQUEST['start'] = 0; |
|
| 223 | + } |
|
| 207 | 224 | |
| 208 | 225 | // The action needs to be a string and not an array or anything else |
| 209 | - if (isset($_REQUEST['action'])) |
|
| 210 | - $_REQUEST['action'] = (string) $_REQUEST['action']; |
|
| 211 | - if (isset($_GET['action'])) |
|
| 212 | - $_GET['action'] = (string) $_GET['action']; |
|
| 226 | + if (isset($_REQUEST['action'])) { |
|
| 227 | + $_REQUEST['action'] = (string) $_REQUEST['action']; |
|
| 228 | + } |
|
| 229 | + if (isset($_GET['action'])) { |
|
| 230 | + $_GET['action'] = (string) $_GET['action']; |
|
| 231 | + } |
|
| 213 | 232 | |
| 214 | 233 | // Some mail providers like to encode semicolons in activation URLs... |
| 215 | 234 | if (!empty($_REQUEST['action']) && substr($_SERVER['QUERY_STRING'], 0, 18) == 'action=activate%3b') |
@@ -235,29 +254,33 @@ discard block |
||
| 235 | 254 | $_SERVER['BAN_CHECK_IP'] = $_SERVER['REMOTE_ADDR']; |
| 236 | 255 | |
| 237 | 256 | // If we haven't specified how to handle Reverse Proxy IP headers, lets do what we always used to do. |
| 238 | - if (!isset($modSettings['proxy_ip_header'])) |
|
| 239 | - $modSettings['proxy_ip_header'] = 'autodetect'; |
|
| 257 | + if (!isset($modSettings['proxy_ip_header'])) { |
|
| 258 | + $modSettings['proxy_ip_header'] = 'autodetect'; |
|
| 259 | + } |
|
| 240 | 260 | |
| 241 | 261 | // Which headers are we going to check for Reverse Proxy IP headers? |
| 242 | - if ($modSettings['proxy_ip_header'] == 'disabled') |
|
| 243 | - $reverseIPheaders = array(); |
|
| 244 | - elseif ($modSettings['proxy_ip_header'] == 'autodetect') |
|
| 245 | - $reverseIPheaders = array('HTTP_X_FORWARDED_FOR', 'HTTP_CLIENT_IP'); |
|
| 246 | - else |
|
| 247 | - $reverseIPheaders = array($modSettings['proxy_ip_header']); |
|
| 262 | + if ($modSettings['proxy_ip_header'] == 'disabled') { |
|
| 263 | + $reverseIPheaders = array(); |
|
| 264 | + } elseif ($modSettings['proxy_ip_header'] == 'autodetect') { |
|
| 265 | + $reverseIPheaders = array('HTTP_X_FORWARDED_FOR', 'HTTP_CLIENT_IP'); |
|
| 266 | + } else { |
|
| 267 | + $reverseIPheaders = array($modSettings['proxy_ip_header']); |
|
| 268 | + } |
|
| 248 | 269 | |
| 249 | 270 | // Find the user's IP address. (but don't let it give you 'unknown'!) |
| 250 | 271 | foreach ($reverseIPheaders as $proxyIPheader) |
| 251 | 272 | { |
| 252 | 273 | // Ignore if this is not set. |
| 253 | - if (!isset($_SERVER[$proxyIPheader])) |
|
| 254 | - continue; |
|
| 274 | + if (!isset($_SERVER[$proxyIPheader])) { |
|
| 275 | + continue; |
|
| 276 | + } |
|
| 255 | 277 | |
| 256 | 278 | if (!empty($modSettings['proxy_ip_servers'])) |
| 257 | 279 | { |
| 258 | - foreach (explode(',', $modSettings['proxy_ip_servers']) as $proxy) |
|
| 259 | - if ($proxy == $_SERVER['REMOTE_ADDR'] || matchIPtoCIDR($_SERVER['REMOTE_ADDR'], $proxy)) |
|
| 280 | + foreach (explode(',', $modSettings['proxy_ip_servers']) as $proxy) { |
|
| 281 | + if ($proxy == $_SERVER['REMOTE_ADDR'] || matchIPtoCIDR($_SERVER['REMOTE_ADDR'], $proxy)) |
|
| 260 | 282 | continue; |
| 283 | + } |
|
| 261 | 284 | } |
| 262 | 285 | |
| 263 | 286 | // If there are commas, get the last one.. probably. |
@@ -277,8 +300,9 @@ discard block |
||
| 277 | 300 | |
| 278 | 301 | // Just incase we have a legacy IPv4 address. |
| 279 | 302 | // @ TODO: Convert to IPv6. |
| 280 | - if (preg_match('~^((([1]?\d)?\d|2[0-4]\d|25[0-5])\.){3}(([1]?\d)?\d|2[0-4]\d|25[0-5])$~', $_SERVER[$proxyIPheader]) === 0) |
|
| 281 | - continue; |
|
| 303 | + if (preg_match('~^((([1]?\d)?\d|2[0-4]\d|25[0-5])\.){3}(([1]?\d)?\d|2[0-4]\d|25[0-5])$~', $_SERVER[$proxyIPheader]) === 0) { |
|
| 304 | + continue; |
|
| 305 | + } |
|
| 282 | 306 | } |
| 283 | 307 | |
| 284 | 308 | continue; |
@@ -290,36 +314,40 @@ discard block |
||
| 290 | 314 | } |
| 291 | 315 | } |
| 292 | 316 | // Otherwise just use the only one. |
| 293 | - elseif (preg_match('~^((0|10|172\.(1[6-9]|2[0-9]|3[01])|192\.168|255|127)\.|unknown|::1|fe80::|fc00::)~', $_SERVER[$proxyIPheader]) == 0 || preg_match('~^((0|10|172\.(1[6-9]|2[0-9]|3[01])|192\.168|255|127)\.|unknown|::1|fe80::|fc00::)~', $_SERVER['REMOTE_ADDR']) != 0) |
|
| 294 | - $_SERVER['BAN_CHECK_IP'] = $_SERVER[$proxyIPheader]; |
|
| 295 | - elseif (!isValidIPv6($_SERVER[$proxyIPheader]) || preg_match('~::ffff:\d+\.\d+\.\d+\.\d+~', $_SERVER[$proxyIPheader]) !== 0) |
|
| 317 | + elseif (preg_match('~^((0|10|172\.(1[6-9]|2[0-9]|3[01])|192\.168|255|127)\.|unknown|::1|fe80::|fc00::)~', $_SERVER[$proxyIPheader]) == 0 || preg_match('~^((0|10|172\.(1[6-9]|2[0-9]|3[01])|192\.168|255|127)\.|unknown|::1|fe80::|fc00::)~', $_SERVER['REMOTE_ADDR']) != 0) { |
|
| 318 | + $_SERVER['BAN_CHECK_IP'] = $_SERVER[$proxyIPheader]; |
|
| 319 | + } elseif (!isValidIPv6($_SERVER[$proxyIPheader]) || preg_match('~::ffff:\d+\.\d+\.\d+\.\d+~', $_SERVER[$proxyIPheader]) !== 0) |
|
| 296 | 320 | { |
| 297 | 321 | $_SERVER[$proxyIPheader] = preg_replace('~^::ffff:(\d+\.\d+\.\d+\.\d+)~', '\1', $_SERVER[$proxyIPheader]); |
| 298 | 322 | |
| 299 | 323 | // Just incase we have a legacy IPv4 address. |
| 300 | 324 | // @ TODO: Convert to IPv6. |
| 301 | - if (preg_match('~^((([1]?\d)?\d|2[0-4]\d|25[0-5])\.){3}(([1]?\d)?\d|2[0-4]\d|25[0-5])$~', $_SERVER[$proxyIPheader]) === 0) |
|
| 302 | - continue; |
|
| 325 | + if (preg_match('~^((([1]?\d)?\d|2[0-4]\d|25[0-5])\.){3}(([1]?\d)?\d|2[0-4]\d|25[0-5])$~', $_SERVER[$proxyIPheader]) === 0) { |
|
| 326 | + continue; |
|
| 327 | + } |
|
| 303 | 328 | } |
| 304 | 329 | } |
| 305 | 330 | |
| 306 | 331 | // Make sure we know the URL of the current request. |
| 307 | - if (empty($_SERVER['REQUEST_URI'])) |
|
| 308 | - $_SERVER['REQUEST_URL'] = $scripturl . (!empty($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : ''); |
|
| 309 | - elseif (preg_match('~^([^/]+//[^/]+)~', $scripturl, $match) == 1) |
|
| 310 | - $_SERVER['REQUEST_URL'] = $match[1] . $_SERVER['REQUEST_URI']; |
|
| 311 | - else |
|
| 312 | - $_SERVER['REQUEST_URL'] = $_SERVER['REQUEST_URI']; |
|
| 332 | + if (empty($_SERVER['REQUEST_URI'])) { |
|
| 333 | + $_SERVER['REQUEST_URL'] = $scripturl . (!empty($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : ''); |
|
| 334 | + } elseif (preg_match('~^([^/]+//[^/]+)~', $scripturl, $match) == 1) { |
|
| 335 | + $_SERVER['REQUEST_URL'] = $match[1] . $_SERVER['REQUEST_URI']; |
|
| 336 | + } else { |
|
| 337 | + $_SERVER['REQUEST_URL'] = $_SERVER['REQUEST_URI']; |
|
| 338 | + } |
|
| 313 | 339 | |
| 314 | 340 | // And make sure HTTP_USER_AGENT is set. |
| 315 | 341 | $_SERVER['HTTP_USER_AGENT'] = isset($_SERVER['HTTP_USER_AGENT']) ? (isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($smcFunc['db_unescape_string']($_SERVER['HTTP_USER_AGENT']), ENT_QUOTES) : htmlspecialchars($smcFunc['db_unescape_string']($_SERVER['HTTP_USER_AGENT']), ENT_QUOTES)) : ''; |
| 316 | 342 | |
| 317 | 343 | // Some final checking. |
| 318 | - if (!isValidIP($_SERVER['BAN_CHECK_IP'])) |
|
| 319 | - $_SERVER['BAN_CHECK_IP'] = ''; |
|
| 320 | - if ($_SERVER['REMOTE_ADDR'] == 'unknown') |
|
| 321 | - $_SERVER['REMOTE_ADDR'] = ''; |
|
| 322 | -} |
|
| 344 | + if (!isValidIP($_SERVER['BAN_CHECK_IP'])) { |
|
| 345 | + $_SERVER['BAN_CHECK_IP'] = ''; |
|
| 346 | + } |
|
| 347 | + if ($_SERVER['REMOTE_ADDR'] == 'unknown') { |
|
| 348 | + $_SERVER['REMOTE_ADDR'] = ''; |
|
| 349 | + } |
|
| 350 | + } |
|
| 323 | 351 | |
| 324 | 352 | /** |
| 325 | 353 | * Validates a IPv6 address. returns true if it is ipv6. |
@@ -330,8 +358,9 @@ discard block |
||
| 330 | 358 | function isValidIPv6($ip) |
| 331 | 359 | { |
| 332 | 360 | //looking for : |
| 333 | - if (strpos($ip, ':') === false) |
|
| 334 | - return false; |
|
| 361 | + if (strpos($ip, ':') === false) { |
|
| 362 | + return false; |
|
| 363 | + } |
|
| 335 | 364 | |
| 336 | 365 | //check valid address |
| 337 | 366 | return inet_pton($ip); |
@@ -348,15 +377,17 @@ discard block |
||
| 348 | 377 | static $expanded = array(); |
| 349 | 378 | |
| 350 | 379 | // Check if we have done this already. |
| 351 | - if (isset($expanded[$ip])) |
|
| 352 | - return $expanded[$ip]; |
|
| 380 | + if (isset($expanded[$ip])) { |
|
| 381 | + return $expanded[$ip]; |
|
| 382 | + } |
|
| 353 | 383 | |
| 354 | 384 | // Expand the IP out. |
| 355 | 385 | $expanded_ip = explode(':', expandIPv6($ip)); |
| 356 | 386 | |
| 357 | 387 | $new_ip = array(); |
| 358 | - foreach ($expanded_ip as $int) |
|
| 359 | - $new_ip[] = hexdec($int); |
|
| 388 | + foreach ($expanded_ip as $int) { |
|
| 389 | + $new_ip[] = hexdec($int); |
|
| 390 | + } |
|
| 360 | 391 | |
| 361 | 392 | // Save this incase of repeated use. |
| 362 | 393 | $expanded[$ip] = $new_ip; |
@@ -376,8 +407,9 @@ discard block |
||
| 376 | 407 | static $converted = array(); |
| 377 | 408 | |
| 378 | 409 | // Check if we have done this already. |
| 379 | - if (isset($converted[$addr])) |
|
| 380 | - return $converted[$addr]; |
|
| 410 | + if (isset($converted[$addr])) { |
|
| 411 | + return $converted[$addr]; |
|
| 412 | + } |
|
| 381 | 413 | |
| 382 | 414 | // Check if there are segments missing, insert if necessary. |
| 383 | 415 | if (strpos($addr, '::') !== false) |
@@ -387,18 +419,20 @@ discard block |
||
| 387 | 419 | $part[1] = explode(':', $part[1]); |
| 388 | 420 | $missing = array(); |
| 389 | 421 | |
| 390 | - for ($i = 0; $i < (8 - (count($part[0]) + count($part[1]))); $i++) |
|
| 391 | - array_push($missing, '0000'); |
|
| 422 | + for ($i = 0; $i < (8 - (count($part[0]) + count($part[1]))); $i++) { |
|
| 423 | + array_push($missing, '0000'); |
|
| 424 | + } |
|
| 392 | 425 | |
| 393 | 426 | $part = array_merge($part[0], $missing, $part[1]); |
| 427 | + } else { |
|
| 428 | + $part = explode(':', $addr); |
|
| 394 | 429 | } |
| 395 | - else |
|
| 396 | - $part = explode(':', $addr); |
|
| 397 | 430 | |
| 398 | 431 | // Pad each segment until it has 4 digits. |
| 399 | - foreach ($part as &$p) |
|
| 400 | - while (strlen($p) < 4) |
|
| 432 | + foreach ($part as &$p) { |
|
| 433 | + while (strlen($p) < 4) |
|
| 401 | 434 | $p = '0' . $p; |
| 435 | + } |
|
| 402 | 436 | |
| 403 | 437 | unset($p); |
| 404 | 438 | |
@@ -409,11 +443,12 @@ discard block |
||
| 409 | 443 | $converted[$addr] = $result; |
| 410 | 444 | |
| 411 | 445 | // Quick check to make sure the length is as expected. |
| 412 | - if (!$strict_check || strlen($result) == 39) |
|
| 413 | - return $result; |
|
| 414 | - else |
|
| 415 | - return false; |
|
| 416 | -} |
|
| 446 | + if (!$strict_check || strlen($result) == 39) { |
|
| 447 | + return $result; |
|
| 448 | + } else { |
|
| 449 | + return false; |
|
| 450 | + } |
|
| 451 | + } |
|
| 417 | 452 | |
| 418 | 453 | |
| 419 | 454 | /** |
@@ -444,15 +479,17 @@ discard block |
||
| 444 | 479 | { |
| 445 | 480 | global $smcFunc; |
| 446 | 481 | |
| 447 | - if (!is_array($var)) |
|
| 448 | - return $smcFunc['db_escape_string']($var); |
|
| 482 | + if (!is_array($var)) { |
|
| 483 | + return $smcFunc['db_escape_string']($var); |
|
| 484 | + } |
|
| 449 | 485 | |
| 450 | 486 | // Reindex the array with slashes. |
| 451 | 487 | $new_var = array(); |
| 452 | 488 | |
| 453 | 489 | // Add slashes to every element, even the indexes! |
| 454 | - foreach ($var as $k => $v) |
|
| 455 | - $new_var[$smcFunc['db_escape_string']($k)] = escapestring__recursive($v); |
|
| 490 | + foreach ($var as $k => $v) { |
|
| 491 | + $new_var[$smcFunc['db_escape_string']($k)] = escapestring__recursive($v); |
|
| 492 | + } |
|
| 456 | 493 | |
| 457 | 494 | return $new_var; |
| 458 | 495 | } |
@@ -472,12 +509,14 @@ discard block |
||
| 472 | 509 | { |
| 473 | 510 | global $smcFunc; |
| 474 | 511 | |
| 475 | - if (!is_array($var)) |
|
| 476 | - return isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($var, ENT_QUOTES) : htmlspecialchars($var, ENT_QUOTES); |
|
| 512 | + if (!is_array($var)) { |
|
| 513 | + return isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($var, ENT_QUOTES) : htmlspecialchars($var, ENT_QUOTES); |
|
| 514 | + } |
|
| 477 | 515 | |
| 478 | 516 | // Add the htmlspecialchars to every element. |
| 479 | - foreach ($var as $k => $v) |
|
| 480 | - $var[$k] = $level > 25 ? null : htmlspecialchars__recursive($v, $level + 1); |
|
| 517 | + foreach ($var as $k => $v) { |
|
| 518 | + $var[$k] = $level > 25 ? null : htmlspecialchars__recursive($v, $level + 1); |
|
| 519 | + } |
|
| 481 | 520 | |
| 482 | 521 | return $var; |
| 483 | 522 | } |
@@ -495,15 +534,17 @@ discard block |
||
| 495 | 534 | */ |
| 496 | 535 | function urldecode__recursive($var, $level = 0) |
| 497 | 536 | { |
| 498 | - if (!is_array($var)) |
|
| 499 | - return urldecode($var); |
|
| 537 | + if (!is_array($var)) { |
|
| 538 | + return urldecode($var); |
|
| 539 | + } |
|
| 500 | 540 | |
| 501 | 541 | // Reindex the array... |
| 502 | 542 | $new_var = array(); |
| 503 | 543 | |
| 504 | 544 | // Add the htmlspecialchars to every element. |
| 505 | - foreach ($var as $k => $v) |
|
| 506 | - $new_var[urldecode($k)] = $level > 25 ? null : urldecode__recursive($v, $level + 1); |
|
| 545 | + foreach ($var as $k => $v) { |
|
| 546 | + $new_var[urldecode($k)] = $level > 25 ? null : urldecode__recursive($v, $level + 1); |
|
| 547 | + } |
|
| 507 | 548 | |
| 508 | 549 | return $new_var; |
| 509 | 550 | } |
@@ -521,15 +562,17 @@ discard block |
||
| 521 | 562 | { |
| 522 | 563 | global $smcFunc; |
| 523 | 564 | |
| 524 | - if (!is_array($var)) |
|
| 525 | - return $smcFunc['db_unescape_string']($var); |
|
| 565 | + if (!is_array($var)) { |
|
| 566 | + return $smcFunc['db_unescape_string']($var); |
|
| 567 | + } |
|
| 526 | 568 | |
| 527 | 569 | // Reindex the array without slashes, this time. |
| 528 | 570 | $new_var = array(); |
| 529 | 571 | |
| 530 | 572 | // Strip the slashes from every element. |
| 531 | - foreach ($var as $k => $v) |
|
| 532 | - $new_var[$smcFunc['db_unescape_string']($k)] = unescapestring__recursive($v); |
|
| 573 | + foreach ($var as $k => $v) { |
|
| 574 | + $new_var[$smcFunc['db_unescape_string']($k)] = unescapestring__recursive($v); |
|
| 575 | + } |
|
| 533 | 576 | |
| 534 | 577 | return $new_var; |
| 535 | 578 | } |
@@ -547,15 +590,17 @@ discard block |
||
| 547 | 590 | */ |
| 548 | 591 | function stripslashes__recursive($var, $level = 0) |
| 549 | 592 | { |
| 550 | - if (!is_array($var)) |
|
| 551 | - return stripslashes($var); |
|
| 593 | + if (!is_array($var)) { |
|
| 594 | + return stripslashes($var); |
|
| 595 | + } |
|
| 552 | 596 | |
| 553 | 597 | // Reindex the array without slashes, this time. |
| 554 | 598 | $new_var = array(); |
| 555 | 599 | |
| 556 | 600 | // Strip the slashes from every element. |
| 557 | - foreach ($var as $k => $v) |
|
| 558 | - $new_var[stripslashes($k)] = $level > 25 ? null : stripslashes__recursive($v, $level + 1); |
|
| 601 | + foreach ($var as $k => $v) { |
|
| 602 | + $new_var[stripslashes($k)] = $level > 25 ? null : stripslashes__recursive($v, $level + 1); |
|
| 603 | + } |
|
| 559 | 604 | |
| 560 | 605 | return $new_var; |
| 561 | 606 | } |
@@ -576,12 +621,14 @@ discard block |
||
| 576 | 621 | global $smcFunc; |
| 577 | 622 | |
| 578 | 623 | // Remove spaces (32), tabs (9), returns (13, 10, and 11), nulls (0), and hard spaces. (160) |
| 579 | - if (!is_array($var)) |
|
| 580 | - return isset($smcFunc) ? $smcFunc['htmltrim']($var) : trim($var, ' ' . "\t\n\r\x0B" . '\0' . "\xA0"); |
|
| 624 | + if (!is_array($var)) { |
|
| 625 | + return isset($smcFunc) ? $smcFunc['htmltrim']($var) : trim($var, ' ' . "\t\n\r\x0B" . '\0' . "\xA0"); |
|
| 626 | + } |
|
| 581 | 627 | |
| 582 | 628 | // Go through all the elements and remove the whitespace. |
| 583 | - foreach ($var as $k => $v) |
|
| 584 | - $var[$k] = $level > 25 ? null : htmltrim__recursive($v, $level + 1); |
|
| 629 | + foreach ($var as $k => $v) { |
|
| 630 | + $var[$k] = $level > 25 ? null : htmltrim__recursive($v, $level + 1); |
|
| 631 | + } |
|
| 585 | 632 | |
| 586 | 633 | return $var; |
| 587 | 634 | } |
@@ -646,30 +693,37 @@ discard block |
||
| 646 | 693 | global $scripturl, $modSettings, $context; |
| 647 | 694 | |
| 648 | 695 | // If $scripturl is set to nothing, or the SID is not defined (SSI?) just quit. |
| 649 | - if ($scripturl == '' || !defined('SID')) |
|
| 650 | - return $buffer; |
|
| 696 | + if ($scripturl == '' || !defined('SID')) { |
|
| 697 | + return $buffer; |
|
| 698 | + } |
|
| 651 | 699 | |
| 652 | 700 | // Do nothing if the session is cookied, or they are a crawler - guests are caught by redirectexit(). This doesn't work below PHP 4.3.0, because it makes the output buffer bigger. |
| 653 | 701 | // @todo smflib |
| 654 | - if (empty($_COOKIE) && SID != '' && !isBrowser('possibly_robot')) |
|
| 655 | - $buffer = preg_replace('/(?<!<link rel="canonical" href=)"' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', '"' . $scripturl . '?' . SID . '&', $buffer); |
|
| 702 | + if (empty($_COOKIE) && SID != '' && !isBrowser('possibly_robot')) { |
|
| 703 | + $buffer = preg_replace('/(?<!<link rel="canonical" href=)"' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', '"' . $scripturl . '?' . SID . '&', $buffer); |
|
| 704 | + } |
|
| 656 | 705 | // Debugging templates, are we? |
| 657 | - elseif (isset($_GET['debug'])) |
|
| 658 | - $buffer = preg_replace('/(?<!<link rel="canonical" href=)"' . preg_quote($scripturl, '/') . '\\??/', '"' . $scripturl . '?debug;', $buffer); |
|
| 706 | + elseif (isset($_GET['debug'])) { |
|
| 707 | + $buffer = preg_replace('/(?<!<link rel="canonical" href=)"' . preg_quote($scripturl, '/') . '\\??/', '"' . $scripturl . '?debug;', $buffer); |
|
| 708 | + } |
|
| 659 | 709 | |
| 660 | 710 | // This should work even in 4.2.x, just not CGI without cgi.fix_pathinfo. |
| 661 | 711 | if (!empty($modSettings['queryless_urls']) && (!$context['server']['is_cgi'] || ini_get('cgi.fix_pathinfo') == 1 || @get_cfg_var('cgi.fix_pathinfo') == 1) && ($context['server']['is_apache'] || $context['server']['is_lighttpd'] || $context['server']['is_litespeed'])) |
| 662 | 712 | { |
| 663 | 713 | // Let's do something special for session ids! |
| 664 | - if (defined('SID') && SID != '') |
|
| 665 | - $buffer = preg_replace_callback('~"' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#"]+?)(#[^"]*?)?"~', function($m) |
|
| 714 | + if (defined('SID') && SID != '') { |
|
| 715 | + $buffer = preg_replace_callback('~"' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#"]+?)(#[^"]*?)?"~', function($m) |
|
| 666 | 716 | { |
| 667 | - global $scripturl; return '"' . $scripturl . "/" . strtr("$m[1]", '&;=', '//,') . ".html?" . SID . (isset($m[2]) ? $m[2] : "") . '"'; |
|
| 717 | + global $scripturl; |
|
| 718 | + } |
|
| 719 | + return '"' . $scripturl . "/" . strtr("$m[1]", '&;=', '//,') . ".html?" . SID . (isset($m[2]) ? $m[2] : "") . '"'; |
|
| 668 | 720 | }, $buffer); |
| 669 | - else |
|
| 670 | - $buffer = preg_replace_callback('~"' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?"~', function($m) |
|
| 721 | + else { |
|
| 722 | + $buffer = preg_replace_callback('~"' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?"~', function($m) |
|
| 671 | 723 | { |
| 672 | - global $scripturl; return '"' . $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? $m[2] : "") . '"'; |
|
| 724 | + global $scripturl; |
|
| 725 | + } |
|
| 726 | + return '"' . $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? $m[2] : "") . '"'; |
|
| 673 | 727 | }, $buffer); |
| 674 | 728 | } |
| 675 | 729 | |
@@ -1491,7 +1491,7 @@ |
||
| 1491 | 1491 | |
| 1492 | 1492 | /** |
| 1493 | 1493 | * Try to determine if the topic has already been deleted by another user. |
| 1494 | - * @return bool False if it can't be deleted (recycling not enabled or no recycling board set), true if we've confirmed it can be deleted. Dies with an error if it's already been deleted. |
|
| 1494 | + * @return boolean|null False if it can't be deleted (recycling not enabled or no recycling board set), true if we've confirmed it can be deleted. Dies with an error if it's already been deleted. |
|
| 1495 | 1495 | */ |
| 1496 | 1496 | function removeDeleteConcurrence() |
| 1497 | 1497 | { |
@@ -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 | /* The contents of this file handle the deletion of topics, posts, and related |
| 21 | 22 | paraphernalia. It has the following functions: |
@@ -37,8 +38,9 @@ discard block |
||
| 37 | 38 | require_once($sourcedir . '/Subs-Post.php'); |
| 38 | 39 | |
| 39 | 40 | // Trying to fool us around, are we? |
| 40 | - if (empty($topic)) |
|
| 41 | - redirectexit(); |
|
| 41 | + if (empty($topic)) { |
|
| 42 | + redirectexit(); |
|
| 43 | + } |
|
| 42 | 44 | |
| 43 | 45 | removeDeleteConcurrence(); |
| 44 | 46 | |
@@ -55,20 +57,23 @@ discard block |
||
| 55 | 57 | list ($starter, $subject, $approved, $locked) = $smcFunc['db_fetch_row']($request); |
| 56 | 58 | $smcFunc['db_free_result']($request); |
| 57 | 59 | |
| 58 | - if ($starter == $user_info['id'] && !allowedTo('remove_any')) |
|
| 59 | - isAllowedTo('remove_own'); |
|
| 60 | - else |
|
| 61 | - isAllowedTo('remove_any'); |
|
| 60 | + if ($starter == $user_info['id'] && !allowedTo('remove_any')) { |
|
| 61 | + isAllowedTo('remove_own'); |
|
| 62 | + } else { |
|
| 63 | + isAllowedTo('remove_any'); |
|
| 64 | + } |
|
| 62 | 65 | |
| 63 | 66 | // Can they see the topic? |
| 64 | - if ($modSettings['postmod_active'] && !$approved && $starter != $user_info['id']) |
|
| 65 | - isAllowedTo('approve_posts'); |
|
| 67 | + if ($modSettings['postmod_active'] && !$approved && $starter != $user_info['id']) { |
|
| 68 | + isAllowedTo('approve_posts'); |
|
| 69 | + } |
|
| 66 | 70 | |
| 67 | 71 | // Ok, we got that far, but is it locked? |
| 68 | 72 | if ($locked) |
| 69 | 73 | { |
| 70 | - if (!($locked == 1 && $starter == $user_info['id'] || allowedTo('lock_any'))) |
|
| 71 | - fatal_lang_error('cannot_remove_locked', 'user'); |
|
| 74 | + if (!($locked == 1 && $starter == $user_info['id'] || allowedTo('lock_any'))) { |
|
| 75 | + fatal_lang_error('cannot_remove_locked', 'user'); |
|
| 76 | + } |
|
| 72 | 77 | } |
| 73 | 78 | |
| 74 | 79 | // Notify people that this topic has been removed. |
@@ -77,8 +82,9 @@ discard block |
||
| 77 | 82 | removeTopics($topic); |
| 78 | 83 | |
| 79 | 84 | // Note, only log topic ID in native form if it's not gone forever. |
| 80 | - if (allowedTo('remove_any') || (allowedTo('remove_own') && $starter == $user_info['id'])) |
|
| 81 | - logAction('remove', array((empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $board ? 'topic' : 'old_topic_id') => $topic, 'subject' => $subject, 'member' => $starter, 'board' => $board)); |
|
| 85 | + if (allowedTo('remove_any') || (allowedTo('remove_own') && $starter == $user_info['id'])) { |
|
| 86 | + logAction('remove', array((empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $board ? 'topic' : 'old_topic_id') => $topic, 'subject' => $subject, 'member' => $starter, 'board' => $board)); |
|
| 87 | + } |
|
| 82 | 88 | |
| 83 | 89 | redirectexit('board=' . $board . '.0'); |
| 84 | 90 | } |
@@ -96,8 +102,9 @@ discard block |
||
| 96 | 102 | $_REQUEST['msg'] = (int) $_REQUEST['msg']; |
| 97 | 103 | |
| 98 | 104 | // Is $topic set? |
| 99 | - if (empty($topic) && isset($_REQUEST['topic'])) |
|
| 100 | - $topic = (int) $_REQUEST['topic']; |
|
| 105 | + if (empty($topic) && isset($_REQUEST['topic'])) { |
|
| 106 | + $topic = (int) $_REQUEST['topic']; |
|
| 107 | + } |
|
| 101 | 108 | |
| 102 | 109 | removeDeleteConcurrence(); |
| 103 | 110 | |
@@ -116,44 +123,48 @@ discard block |
||
| 116 | 123 | $smcFunc['db_free_result']($request); |
| 117 | 124 | |
| 118 | 125 | // Verify they can see this! |
| 119 | - if ($modSettings['postmod_active'] && !$approved && !empty($poster) && $poster != $user_info['id']) |
|
| 120 | - isAllowedTo('approve_posts'); |
|
| 126 | + if ($modSettings['postmod_active'] && !$approved && !empty($poster) && $poster != $user_info['id']) { |
|
| 127 | + isAllowedTo('approve_posts'); |
|
| 128 | + } |
|
| 121 | 129 | |
| 122 | 130 | if ($poster == $user_info['id']) |
| 123 | 131 | { |
| 124 | 132 | if (!allowedTo('delete_own')) |
| 125 | 133 | { |
| 126 | - if ($starter == $user_info['id'] && !allowedTo('delete_any')) |
|
| 127 | - isAllowedTo('delete_replies'); |
|
| 128 | - elseif (!allowedTo('delete_any')) |
|
| 129 | - isAllowedTo('delete_own'); |
|
| 134 | + if ($starter == $user_info['id'] && !allowedTo('delete_any')) { |
|
| 135 | + isAllowedTo('delete_replies'); |
|
| 136 | + } elseif (!allowedTo('delete_any')) { |
|
| 137 | + isAllowedTo('delete_own'); |
|
| 138 | + } |
|
| 139 | + } elseif (!allowedTo('delete_any') && ($starter != $user_info['id'] || !allowedTo('delete_replies')) && !empty($modSettings['edit_disable_time']) && $post_time + $modSettings['edit_disable_time'] * 60 < time()) { |
|
| 140 | + fatal_lang_error('modify_post_time_passed', false); |
|
| 130 | 141 | } |
| 131 | - elseif (!allowedTo('delete_any') && ($starter != $user_info['id'] || !allowedTo('delete_replies')) && !empty($modSettings['edit_disable_time']) && $post_time + $modSettings['edit_disable_time'] * 60 < time()) |
|
| 132 | - fatal_lang_error('modify_post_time_passed', false); |
|
| 142 | + } elseif ($starter == $user_info['id'] && !allowedTo('delete_any')) { |
|
| 143 | + isAllowedTo('delete_replies'); |
|
| 144 | + } else { |
|
| 145 | + isAllowedTo('delete_any'); |
|
| 133 | 146 | } |
| 134 | - elseif ($starter == $user_info['id'] && !allowedTo('delete_any')) |
|
| 135 | - isAllowedTo('delete_replies'); |
|
| 136 | - else |
|
| 137 | - isAllowedTo('delete_any'); |
|
| 138 | 147 | |
| 139 | 148 | // If the full topic was removed go back to the board. |
| 140 | 149 | $full_topic = removeMessage($_REQUEST['msg']); |
| 141 | 150 | |
| 142 | - if (allowedTo('delete_any') && (!allowedTo('delete_own') || $poster != $user_info['id'])) |
|
| 143 | - logAction('delete', array('topic' => $topic, 'subject' => $subject, 'member' => $poster, 'board' => $board)); |
|
| 151 | + if (allowedTo('delete_any') && (!allowedTo('delete_own') || $poster != $user_info['id'])) { |
|
| 152 | + logAction('delete', array('topic' => $topic, 'subject' => $subject, 'member' => $poster, 'board' => $board)); |
|
| 153 | + } |
|
| 144 | 154 | |
| 145 | 155 | // We want to redirect back to recent action. |
| 146 | - if (isset($_REQUEST['modcenter'])) |
|
| 147 | - redirectexit('action=moderate;area=reportedposts;done'); |
|
| 148 | - elseif (isset($_REQUEST['recent'])) |
|
| 149 | - redirectexit('action=recent'); |
|
| 150 | - elseif (isset($_REQUEST['profile'], $_REQUEST['start'], $_REQUEST['u'])) |
|
| 151 | - redirectexit('action=profile;u=' . $_REQUEST['u'] . ';area=showposts;start=' . $_REQUEST['start']); |
|
| 152 | - elseif ($full_topic) |
|
| 153 | - redirectexit('board=' . $board . '.0'); |
|
| 154 | - else |
|
| 155 | - redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
| 156 | -} |
|
| 156 | + if (isset($_REQUEST['modcenter'])) { |
|
| 157 | + redirectexit('action=moderate;area=reportedposts;done'); |
|
| 158 | + } elseif (isset($_REQUEST['recent'])) { |
|
| 159 | + redirectexit('action=recent'); |
|
| 160 | + } elseif (isset($_REQUEST['profile'], $_REQUEST['start'], $_REQUEST['u'])) { |
|
| 161 | + redirectexit('action=profile;u=' . $_REQUEST['u'] . ';area=showposts;start=' . $_REQUEST['start']); |
|
| 162 | + } elseif ($full_topic) { |
|
| 163 | + redirectexit('board=' . $board . '.0'); |
|
| 164 | + } else { |
|
| 165 | + redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
| 166 | + } |
|
| 167 | + } |
|
| 157 | 168 | |
| 158 | 169 | /** |
| 159 | 170 | * So long as you are sure... all old posts will be gone. |
@@ -167,8 +178,9 @@ discard block |
||
| 167 | 178 | checkSession('post', 'admin'); |
| 168 | 179 | |
| 169 | 180 | // No boards at all? Forget it then :/. |
| 170 | - if (empty($_POST['boards'])) |
|
| 171 | - redirectexit('action=admin;area=maintain;sa=topics'); |
|
| 181 | + if (empty($_POST['boards'])) { |
|
| 182 | + redirectexit('action=admin;area=maintain;sa=topics'); |
|
| 183 | + } |
|
| 172 | 184 | |
| 173 | 185 | // This should exist, but we can make sure. |
| 174 | 186 | $_POST['delete_type'] = isset($_POST['delete_type']) ? $_POST['delete_type'] : 'nothing'; |
@@ -222,8 +234,9 @@ discard block |
||
| 222 | 234 | $condition_params |
| 223 | 235 | ); |
| 224 | 236 | $topics = array(); |
| 225 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 226 | - $topics[] = $row['id_topic']; |
|
| 237 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 238 | + $topics[] = $row['id_topic']; |
|
| 239 | + } |
|
| 227 | 240 | $smcFunc['db_free_result']($request); |
| 228 | 241 | |
| 229 | 242 | removeTopics($topics, false, true); |
@@ -247,11 +260,13 @@ discard block |
||
| 247 | 260 | global $sourcedir, $modSettings, $smcFunc; |
| 248 | 261 | |
| 249 | 262 | // Nothing to do? |
| 250 | - if (empty($topics)) |
|
| 251 | - return; |
|
| 263 | + if (empty($topics)) { |
|
| 264 | + return; |
|
| 265 | + } |
|
| 252 | 266 | // Only a single topic. |
| 253 | - if (is_numeric($topics)) |
|
| 254 | - $topics = array($topics); |
|
| 267 | + if (is_numeric($topics)) { |
|
| 268 | + $topics = array($topics); |
|
| 269 | + } |
|
| 255 | 270 | |
| 256 | 271 | $recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0; |
| 257 | 272 | |
@@ -276,8 +291,9 @@ discard block |
||
| 276 | 291 | ); |
| 277 | 292 | if ($smcFunc['db_num_rows']($requestMembers) > 0) |
| 278 | 293 | { |
| 279 | - while ($rowMembers = $smcFunc['db_fetch_assoc']($requestMembers)) |
|
| 280 | - updateMemberData($rowMembers['id_member'], array('posts' => 'posts - ' . $rowMembers['posts'])); |
|
| 294 | + while ($rowMembers = $smcFunc['db_fetch_assoc']($requestMembers)) { |
|
| 295 | + updateMemberData($rowMembers['id_member'], array('posts' => 'posts - ' . $rowMembers['posts'])); |
|
| 296 | + } |
|
| 281 | 297 | } |
| 282 | 298 | $smcFunc['db_free_result']($requestMembers); |
| 283 | 299 | } |
@@ -303,8 +319,9 @@ discard block |
||
| 303 | 319 | $recycleTopics = array(); |
| 304 | 320 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 305 | 321 | { |
| 306 | - if (function_exists('apache_reset_timeout')) |
|
| 307 | - @apache_reset_timeout(); |
|
| 322 | + if (function_exists('apache_reset_timeout')) { |
|
| 323 | + @apache_reset_timeout(); |
|
| 324 | + } |
|
| 308 | 325 | |
| 309 | 326 | $recycleTopics[] = $row['id_topic']; |
| 310 | 327 | |
@@ -346,20 +363,22 @@ discard block |
||
| 346 | 363 | |
| 347 | 364 | // Topics that were recycled don't need to be deleted, so subtract them. |
| 348 | 365 | $topics = array_diff($topics, $recycleTopics); |
| 366 | + } else { |
|
| 367 | + $smcFunc['db_free_result']($request); |
|
| 349 | 368 | } |
| 350 | - else |
|
| 351 | - $smcFunc['db_free_result']($request); |
|
| 352 | 369 | } |
| 353 | 370 | |
| 354 | 371 | // Still topics left to delete? |
| 355 | - if (empty($topics)) |
|
| 356 | - return; |
|
| 372 | + if (empty($topics)) { |
|
| 373 | + return; |
|
| 374 | + } |
|
| 357 | 375 | |
| 358 | 376 | // Callback for search APIs to do their thing |
| 359 | 377 | require_once($sourcedir . '/Search.php'); |
| 360 | 378 | $searchAPI = findSearchAPI(); |
| 361 | - if ($searchAPI->supportsMethod('topicsRemoved')) |
|
| 362 | - $searchAPI->topicsRemoved($topics); |
|
| 379 | + if ($searchAPI->supportsMethod('topicsRemoved')) { |
|
| 380 | + $searchAPI->topicsRemoved($topics); |
|
| 381 | + } |
|
| 363 | 382 | |
| 364 | 383 | $adjustBoards = array(); |
| 365 | 384 | |
@@ -391,10 +410,11 @@ discard block |
||
| 391 | 410 | $adjustBoards[$row['id_board']]['unapproved_posts'] += $row['unapproved_posts']; |
| 392 | 411 | |
| 393 | 412 | // Add the topics to the right type. |
| 394 | - if ($row['approved']) |
|
| 395 | - $adjustBoards[$row['id_board']]['num_topics'] += $row['num_topics']; |
|
| 396 | - else |
|
| 397 | - $adjustBoards[$row['id_board']]['unapproved_topics'] += $row['num_topics']; |
|
| 413 | + if ($row['approved']) { |
|
| 414 | + $adjustBoards[$row['id_board']]['num_topics'] += $row['num_topics']; |
|
| 415 | + } else { |
|
| 416 | + $adjustBoards[$row['id_board']]['unapproved_topics'] += $row['num_topics']; |
|
| 417 | + } |
|
| 398 | 418 | } |
| 399 | 419 | $smcFunc['db_free_result']($request); |
| 400 | 420 | |
@@ -403,8 +423,9 @@ discard block |
||
| 403 | 423 | // Decrease the posts/topics... |
| 404 | 424 | foreach ($adjustBoards as $stats) |
| 405 | 425 | { |
| 406 | - if (function_exists('apache_reset_timeout')) |
|
| 407 | - @apache_reset_timeout(); |
|
| 426 | + if (function_exists('apache_reset_timeout')) { |
|
| 427 | + @apache_reset_timeout(); |
|
| 428 | + } |
|
| 408 | 429 | |
| 409 | 430 | $smcFunc['db_query']('', ' |
| 410 | 431 | UPDATE {db_prefix}boards |
@@ -438,8 +459,9 @@ discard block |
||
| 438 | 459 | ) |
| 439 | 460 | ); |
| 440 | 461 | $polls = array(); |
| 441 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 442 | - $polls[] = $row['id_poll']; |
|
| 462 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 463 | + $polls[] = $row['id_poll']; |
|
| 464 | + } |
|
| 443 | 465 | $smcFunc['db_free_result']($request); |
| 444 | 466 | |
| 445 | 467 | if (!empty($polls)) |
@@ -492,8 +514,9 @@ discard block |
||
| 492 | 514 | ); |
| 493 | 515 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 494 | 516 | { |
| 495 | - if (function_exists('apache_reset_timeout')) |
|
| 496 | - @apache_reset_timeout(); |
|
| 517 | + if (function_exists('apache_reset_timeout')) { |
|
| 518 | + @apache_reset_timeout(); |
|
| 519 | + } |
|
| 497 | 520 | |
| 498 | 521 | $words = array_merge($words, text2words($row['body'], $customIndexSettings['bytes_per_word'], true)); |
| 499 | 522 | $messages[] = $row['id_msg']; |
@@ -501,8 +524,8 @@ discard block |
||
| 501 | 524 | $smcFunc['db_free_result']($request); |
| 502 | 525 | $words = array_unique($words); |
| 503 | 526 | |
| 504 | - if (!empty($words) && !empty($messages)) |
|
| 505 | - $smcFunc['db_query']('', ' |
|
| 527 | + if (!empty($words) && !empty($messages)) { |
|
| 528 | + $smcFunc['db_query']('', ' |
|
| 506 | 529 | DELETE FROM {db_prefix}log_search_words |
| 507 | 530 | WHERE id_word IN ({array_int:word_list}) |
| 508 | 531 | AND id_msg IN ({array_int:message_list})', |
@@ -511,6 +534,7 @@ discard block |
||
| 511 | 534 | 'message_list' => $messages, |
| 512 | 535 | ) |
| 513 | 536 | ); |
| 537 | + } |
|
| 514 | 538 | } |
| 515 | 539 | |
| 516 | 540 | // Delete anything related to the topic. |
@@ -569,8 +593,9 @@ discard block |
||
| 569 | 593 | |
| 570 | 594 | require_once($sourcedir . '/Subs-Post.php'); |
| 571 | 595 | $updates = array(); |
| 572 | - foreach ($adjustBoards as $stats) |
|
| 573 | - $updates[] = $stats['id_board']; |
|
| 596 | + foreach ($adjustBoards as $stats) { |
|
| 597 | + $updates[] = $stats['id_board']; |
|
| 598 | + } |
|
| 574 | 599 | updateLastMessages($updates); |
| 575 | 600 | } |
| 576 | 601 | |
@@ -587,8 +612,9 @@ discard block |
||
| 587 | 612 | { |
| 588 | 613 | global $board, $sourcedir, $modSettings, $user_info, $smcFunc; |
| 589 | 614 | |
| 590 | - if (empty($message) || !is_numeric($message)) |
|
| 591 | - return false; |
|
| 615 | + if (empty($message) || !is_numeric($message)) { |
|
| 616 | + return false; |
|
| 617 | + } |
|
| 592 | 618 | |
| 593 | 619 | $recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0; |
| 594 | 620 | |
@@ -607,8 +633,9 @@ discard block |
||
| 607 | 633 | 'id_msg' => $message, |
| 608 | 634 | ) |
| 609 | 635 | ); |
| 610 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 611 | - return false; |
|
| 636 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 637 | + return false; |
|
| 638 | + } |
|
| 612 | 639 | $row = $smcFunc['db_fetch_assoc']($request); |
| 613 | 640 | $smcFunc['db_free_result']($request); |
| 614 | 641 | |
@@ -629,54 +656,57 @@ discard block |
||
| 629 | 656 | { |
| 630 | 657 | if ($row['id_member_poster'] == $user_info['id']) |
| 631 | 658 | { |
| 632 | - if (!$delete_replies) |
|
| 633 | - fatal_lang_error('cannot_delete_replies', 'permission'); |
|
| 659 | + if (!$delete_replies) { |
|
| 660 | + fatal_lang_error('cannot_delete_replies', 'permission'); |
|
| 661 | + } |
|
| 662 | + } else { |
|
| 663 | + fatal_lang_error('cannot_delete_own', 'permission'); |
|
| 634 | 664 | } |
| 635 | - else |
|
| 636 | - fatal_lang_error('cannot_delete_own', 'permission'); |
|
| 665 | + } elseif (($row['id_member_poster'] != $user_info['id'] || !$delete_replies) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time()) { |
|
| 666 | + fatal_lang_error('modify_post_time_passed', false); |
|
| 637 | 667 | } |
| 638 | - elseif (($row['id_member_poster'] != $user_info['id'] || !$delete_replies) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time()) |
|
| 639 | - fatal_lang_error('modify_post_time_passed', false); |
|
| 640 | - } |
|
| 641 | - elseif ($row['id_member_poster'] == $user_info['id']) |
|
| 668 | + } elseif ($row['id_member_poster'] == $user_info['id']) |
|
| 642 | 669 | { |
| 643 | - if (!$delete_replies) |
|
| 644 | - fatal_lang_error('cannot_delete_replies', 'permission'); |
|
| 670 | + if (!$delete_replies) { |
|
| 671 | + fatal_lang_error('cannot_delete_replies', 'permission'); |
|
| 672 | + } |
|
| 673 | + } else { |
|
| 674 | + fatal_lang_error('cannot_delete_any', 'permission'); |
|
| 645 | 675 | } |
| 646 | - else |
|
| 647 | - fatal_lang_error('cannot_delete_any', 'permission'); |
|
| 648 | 676 | } |
| 649 | 677 | |
| 650 | 678 | // Can't delete an unapproved message, if you can't see it! |
| 651 | 679 | if ($modSettings['postmod_active'] && !$row['approved'] && $row['id_member'] != $user_info['id'] && !(in_array(0, $delete_any) || in_array($row['id_board'], $delete_any))) |
| 652 | 680 | { |
| 653 | 681 | $approve_posts = boardsAllowedTo('approve_posts'); |
| 654 | - if (!in_array(0, $approve_posts) && !in_array($row['id_board'], $approve_posts)) |
|
| 655 | - return false; |
|
| 682 | + if (!in_array(0, $approve_posts) && !in_array($row['id_board'], $approve_posts)) { |
|
| 683 | + return false; |
|
| 684 | + } |
|
| 656 | 685 | } |
| 657 | - } |
|
| 658 | - else |
|
| 686 | + } else |
|
| 659 | 687 | { |
| 660 | 688 | // Check permissions to delete this message. |
| 661 | 689 | if ($row['id_member'] == $user_info['id']) |
| 662 | 690 | { |
| 663 | 691 | if (!allowedTo('delete_own')) |
| 664 | 692 | { |
| 665 | - if ($row['id_member_poster'] == $user_info['id'] && !allowedTo('delete_any')) |
|
| 666 | - isAllowedTo('delete_replies'); |
|
| 667 | - elseif (!allowedTo('delete_any')) |
|
| 668 | - isAllowedTo('delete_own'); |
|
| 693 | + if ($row['id_member_poster'] == $user_info['id'] && !allowedTo('delete_any')) { |
|
| 694 | + isAllowedTo('delete_replies'); |
|
| 695 | + } elseif (!allowedTo('delete_any')) { |
|
| 696 | + isAllowedTo('delete_own'); |
|
| 697 | + } |
|
| 698 | + } elseif (!allowedTo('delete_any') && ($row['id_member_poster'] != $user_info['id'] || !allowedTo('delete_replies')) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time()) { |
|
| 699 | + fatal_lang_error('modify_post_time_passed', false); |
|
| 669 | 700 | } |
| 670 | - elseif (!allowedTo('delete_any') && ($row['id_member_poster'] != $user_info['id'] || !allowedTo('delete_replies')) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time()) |
|
| 671 | - fatal_lang_error('modify_post_time_passed', false); |
|
| 701 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('delete_any')) { |
|
| 702 | + isAllowedTo('delete_replies'); |
|
| 703 | + } else { |
|
| 704 | + isAllowedTo('delete_any'); |
|
| 672 | 705 | } |
| 673 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('delete_any')) |
|
| 674 | - isAllowedTo('delete_replies'); |
|
| 675 | - else |
|
| 676 | - isAllowedTo('delete_any'); |
|
| 677 | 706 | |
| 678 | - if ($modSettings['postmod_active'] && !$row['approved'] && $row['id_member'] != $user_info['id'] && !allowedTo('delete_own')) |
|
| 679 | - isAllowedTo('approve_posts'); |
|
| 707 | + if ($modSettings['postmod_active'] && !$row['approved'] && $row['id_member'] != $user_info['id'] && !allowedTo('delete_own')) { |
|
| 708 | + isAllowedTo('approve_posts'); |
|
| 709 | + } |
|
| 680 | 710 | } |
| 681 | 711 | |
| 682 | 712 | // Delete the *whole* topic, but only if the topic consists of one message. |
@@ -692,31 +722,34 @@ discard block |
||
| 692 | 722 | $remove_own = in_array(0, $remove_own) || in_array($row['id_board'], $remove_own); |
| 693 | 723 | } |
| 694 | 724 | |
| 695 | - if ($row['id_member'] != $user_info['id'] && !$remove_any) |
|
| 696 | - fatal_lang_error('cannot_remove_any', 'permission'); |
|
| 697 | - elseif (!$remove_any && !$remove_own) |
|
| 698 | - fatal_lang_error('cannot_remove_own', 'permission'); |
|
| 699 | - } |
|
| 700 | - else |
|
| 725 | + if ($row['id_member'] != $user_info['id'] && !$remove_any) { |
|
| 726 | + fatal_lang_error('cannot_remove_any', 'permission'); |
|
| 727 | + } elseif (!$remove_any && !$remove_own) { |
|
| 728 | + fatal_lang_error('cannot_remove_own', 'permission'); |
|
| 729 | + } |
|
| 730 | + } else |
|
| 701 | 731 | { |
| 702 | 732 | // Check permissions to delete a whole topic. |
| 703 | - if ($row['id_member'] != $user_info['id']) |
|
| 704 | - isAllowedTo('remove_any'); |
|
| 705 | - elseif (!allowedTo('remove_any')) |
|
| 706 | - isAllowedTo('remove_own'); |
|
| 733 | + if ($row['id_member'] != $user_info['id']) { |
|
| 734 | + isAllowedTo('remove_any'); |
|
| 735 | + } elseif (!allowedTo('remove_any')) { |
|
| 736 | + isAllowedTo('remove_own'); |
|
| 737 | + } |
|
| 707 | 738 | } |
| 708 | 739 | |
| 709 | 740 | // ...if there is only one post. |
| 710 | - if (!empty($row['num_replies'])) |
|
| 711 | - fatal_lang_error('delFirstPost', false); |
|
| 741 | + if (!empty($row['num_replies'])) { |
|
| 742 | + fatal_lang_error('delFirstPost', false); |
|
| 743 | + } |
|
| 712 | 744 | |
| 713 | 745 | removeTopics($row['id_topic']); |
| 714 | 746 | return true; |
| 715 | 747 | } |
| 716 | 748 | |
| 717 | 749 | // Deleting a recycled message can not lower anyone's post count. |
| 718 | - if (!empty($recycle_board) && $row['id_board'] == $recycle_board) |
|
| 719 | - $decreasePostCount = false; |
|
| 750 | + if (!empty($recycle_board) && $row['id_board'] == $recycle_board) { |
|
| 751 | + $decreasePostCount = false; |
|
| 752 | + } |
|
| 720 | 753 | |
| 721 | 754 | // This is the last post, update the last post on the board. |
| 722 | 755 | if ($row['id_last_msg'] == $message) |
@@ -755,8 +788,8 @@ discard block |
||
| 755 | 788 | ); |
| 756 | 789 | } |
| 757 | 790 | // Only decrease post counts. |
| 758 | - else |
|
| 759 | - $smcFunc['db_query']('', ' |
|
| 791 | + else { |
|
| 792 | + $smcFunc['db_query']('', ' |
|
| 760 | 793 | UPDATE {db_prefix}topics |
| 761 | 794 | SET ' . ($row['approved'] ? ' |
| 762 | 795 | num_replies = CASE WHEN num_replies = {int:no_replies} THEN 0 ELSE num_replies - 1 END' : ' |
@@ -768,6 +801,7 @@ discard block |
||
| 768 | 801 | 'id_topic' => $row['id_topic'], |
| 769 | 802 | ) |
| 770 | 803 | ); |
| 804 | + } |
|
| 771 | 805 | |
| 772 | 806 | // Default recycle to false. |
| 773 | 807 | $recycle = false; |
@@ -787,8 +821,9 @@ discard block |
||
| 787 | 821 | 'recycle_board' => $modSettings['recycle_board'], |
| 788 | 822 | ) |
| 789 | 823 | ); |
| 790 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 791 | - fatal_lang_error('recycle_no_valid_board'); |
|
| 824 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 825 | + fatal_lang_error('recycle_no_valid_board'); |
|
| 826 | + } |
|
| 792 | 827 | list ($isRead, $last_board_msg) = $smcFunc['db_fetch_row']($request); |
| 793 | 828 | $smcFunc['db_free_result']($request); |
| 794 | 829 | |
@@ -807,8 +842,8 @@ discard block |
||
| 807 | 842 | $smcFunc['db_free_result']($request); |
| 808 | 843 | |
| 809 | 844 | // Insert a new topic in the recycle board if $id_recycle_topic is empty. |
| 810 | - if (empty($id_recycle_topic)) |
|
| 811 | - $smcFunc['db_insert']('', |
|
| 845 | + if (empty($id_recycle_topic)) { |
|
| 846 | + $smcFunc['db_insert']('', |
|
| 812 | 847 | '{db_prefix}topics', |
| 813 | 848 | array( |
| 814 | 849 | 'id_board' => 'int', 'id_member_started' => 'int', 'id_member_updated' => 'int', 'id_first_msg' => 'int', |
@@ -820,6 +855,7 @@ discard block |
||
| 820 | 855 | ), |
| 821 | 856 | array('id_topic') |
| 822 | 857 | ); |
| 858 | + } |
|
| 823 | 859 | |
| 824 | 860 | // Capture the ID of the new topic... |
| 825 | 861 | $topicID = empty($id_recycle_topic) ? $smcFunc['db_insert_id']('{db_prefix}topics', 'id_topic') : $id_recycle_topic; |
@@ -857,22 +893,24 @@ discard block |
||
| 857 | 893 | ); |
| 858 | 894 | |
| 859 | 895 | // Mark recycled topic as read. |
| 860 | - if (!$user_info['is_guest']) |
|
| 861 | - $smcFunc['db_insert']('replace', |
|
| 896 | + if (!$user_info['is_guest']) { |
|
| 897 | + $smcFunc['db_insert']('replace', |
|
| 862 | 898 | '{db_prefix}log_topics', |
| 863 | 899 | array('id_topic' => 'int', 'id_member' => 'int', 'id_msg' => 'int', 'unwatched' => 'int'), |
| 864 | 900 | array($topicID, $user_info['id'], $modSettings['maxMsgID'], 0), |
| 865 | 901 | array('id_topic', 'id_member') |
| 866 | 902 | ); |
| 903 | + } |
|
| 867 | 904 | |
| 868 | 905 | // Mark recycle board as seen, if it was marked as seen before. |
| 869 | - if (!empty($isRead) && !$user_info['is_guest']) |
|
| 870 | - $smcFunc['db_insert']('replace', |
|
| 906 | + if (!empty($isRead) && !$user_info['is_guest']) { |
|
| 907 | + $smcFunc['db_insert']('replace', |
|
| 871 | 908 | '{db_prefix}log_boards', |
| 872 | 909 | array('id_board' => 'int', 'id_member' => 'int', 'id_msg' => 'int'), |
| 873 | 910 | array($modSettings['recycle_board'], $user_info['id'], $modSettings['maxMsgID']), |
| 874 | 911 | array('id_board', 'id_member') |
| 875 | 912 | ); |
| 913 | + } |
|
| 876 | 914 | |
| 877 | 915 | // Add one topic and post to the recycle bin board. |
| 878 | 916 | $smcFunc['db_query']('', ' |
@@ -890,8 +928,8 @@ discard block |
||
| 890 | 928 | ); |
| 891 | 929 | |
| 892 | 930 | // Lets increase the num_replies, and the first/last message ID as appropriate. |
| 893 | - if (!empty($id_recycle_topic)) |
|
| 894 | - $smcFunc['db_query']('', ' |
|
| 931 | + if (!empty($id_recycle_topic)) { |
|
| 932 | + $smcFunc['db_query']('', ' |
|
| 895 | 933 | UPDATE {db_prefix}topics |
| 896 | 934 | SET num_replies = num_replies + 1' . |
| 897 | 935 | ($message > $last_topic_msg ? ', id_last_msg = {int:id_merged_msg}' : '') . |
@@ -902,6 +940,7 @@ discard block |
||
| 902 | 940 | 'id_merged_msg' => $message, |
| 903 | 941 | ) |
| 904 | 942 | ); |
| 943 | + } |
|
| 905 | 944 | |
| 906 | 945 | // Make sure this message isn't getting deleted later on. |
| 907 | 946 | $recycle = true; |
@@ -911,8 +950,8 @@ discard block |
||
| 911 | 950 | } |
| 912 | 951 | |
| 913 | 952 | // If it wasn't approved don't keep it in the queue. |
| 914 | - if (!$row['approved']) |
|
| 915 | - $smcFunc['db_query']('', ' |
|
| 953 | + if (!$row['approved']) { |
|
| 954 | + $smcFunc['db_query']('', ' |
|
| 916 | 955 | DELETE FROM {db_prefix}approval_queue |
| 917 | 956 | WHERE id_msg = {int:id_msg} |
| 918 | 957 | AND id_attach = {int:id_attach}', |
@@ -921,6 +960,7 @@ discard block |
||
| 921 | 960 | 'id_attach' => 0, |
| 922 | 961 | ) |
| 923 | 962 | ); |
| 963 | + } |
|
| 924 | 964 | } |
| 925 | 965 | |
| 926 | 966 | $smcFunc['db_query']('', ' |
@@ -938,8 +978,9 @@ discard block |
||
| 938 | 978 | |
| 939 | 979 | // If the poster was registered and the board this message was on incremented |
| 940 | 980 | // the member's posts when it was posted, decrease his or her post count. |
| 941 | - if (!empty($row['id_member']) && $decreasePostCount && empty($row['count_posts']) && $row['approved']) |
|
| 942 | - updateMemberData($row['id_member'], array('posts' => '-')); |
|
| 981 | + if (!empty($row['id_member']) && $decreasePostCount && empty($row['count_posts']) && $row['approved']) { |
|
| 982 | + updateMemberData($row['id_member'], array('posts' => '-')); |
|
| 983 | + } |
|
| 943 | 984 | |
| 944 | 985 | // Only remove posts if they're not recycled. |
| 945 | 986 | if (!$recycle) |
@@ -947,8 +988,9 @@ discard block |
||
| 947 | 988 | // Callback for search APIs to do their thing |
| 948 | 989 | require_once($sourcedir . '/Search.php'); |
| 949 | 990 | $searchAPI = findSearchAPI(); |
| 950 | - if ($searchAPI->supportsMethod('postRemoved')) |
|
| 951 | - $searchAPI->postRemoved($message); |
|
| 991 | + if ($searchAPI->supportsMethod('postRemoved')) { |
|
| 992 | + $searchAPI->postRemoved($message); |
|
| 993 | + } |
|
| 952 | 994 | |
| 953 | 995 | // Remove the message! |
| 954 | 996 | $smcFunc['db_query']('', ' |
@@ -963,8 +1005,8 @@ discard block |
||
| 963 | 1005 | { |
| 964 | 1006 | $customIndexSettings = smf_json_decode($modSettings['search_custom_index_config'], true); |
| 965 | 1007 | $words = text2words($row['body'], $customIndexSettings['bytes_per_word'], true); |
| 966 | - if (!empty($words)) |
|
| 967 | - $smcFunc['db_query']('', ' |
|
| 1008 | + if (!empty($words)) { |
|
| 1009 | + $smcFunc['db_query']('', ' |
|
| 968 | 1010 | DELETE FROM {db_prefix}log_search_words |
| 969 | 1011 | WHERE id_word IN ({array_int:word_list}) |
| 970 | 1012 | AND id_msg = {int:id_msg}', |
@@ -973,6 +1015,7 @@ discard block |
||
| 973 | 1015 | 'id_msg' => $message, |
| 974 | 1016 | ) |
| 975 | 1017 | ); |
| 1018 | + } |
|
| 976 | 1019 | } |
| 977 | 1020 | |
| 978 | 1021 | // Delete attachment(s) if they exist. |
@@ -996,10 +1039,11 @@ discard block |
||
| 996 | 1039 | |
| 997 | 1040 | // And now to update the last message of each board we messed with. |
| 998 | 1041 | require_once($sourcedir . '/Subs-Post.php'); |
| 999 | - if ($recycle) |
|
| 1000 | - updateLastMessages(array($row['id_board'], $modSettings['recycle_board'])); |
|
| 1001 | - else |
|
| 1002 | - updateLastMessages($row['id_board']); |
|
| 1042 | + if ($recycle) { |
|
| 1043 | + updateLastMessages(array($row['id_board'], $modSettings['recycle_board'])); |
|
| 1044 | + } else { |
|
| 1045 | + updateLastMessages($row['id_board']); |
|
| 1046 | + } |
|
| 1003 | 1047 | |
| 1004 | 1048 | // Close any moderation reports for this message. |
| 1005 | 1049 | $smcFunc['db_query']('', ' |
@@ -1032,8 +1076,9 @@ discard block |
||
| 1032 | 1076 | checkSession('get'); |
| 1033 | 1077 | |
| 1034 | 1078 | // Is recycled board enabled? |
| 1035 | - if (empty($modSettings['recycle_enable'])) |
|
| 1036 | - fatal_lang_error('restored_disabled', 'critical'); |
|
| 1079 | + if (empty($modSettings['recycle_enable'])) { |
|
| 1080 | + fatal_lang_error('restored_disabled', 'critical'); |
|
| 1081 | + } |
|
| 1037 | 1082 | |
| 1038 | 1083 | // Can we be in here? |
| 1039 | 1084 | isAllowedTo('move_any', $modSettings['recycle_board']); |
@@ -1048,8 +1093,9 @@ discard block |
||
| 1048 | 1093 | if (!empty($_REQUEST['msgs'])) |
| 1049 | 1094 | { |
| 1050 | 1095 | $msgs = explode(',', $_REQUEST['msgs']); |
| 1051 | - foreach ($msgs as $k => $msg) |
|
| 1052 | - $msgs[$k] = (int) $msg; |
|
| 1096 | + foreach ($msgs as $k => $msg) { |
|
| 1097 | + $msgs[$k] = (int) $msg; |
|
| 1098 | + } |
|
| 1053 | 1099 | |
| 1054 | 1100 | // Get the id_previous_board and id_previous_topic. |
| 1055 | 1101 | $request = $smcFunc['db_query']('', ' |
@@ -1083,8 +1129,8 @@ discard block |
||
| 1083 | 1129 | } |
| 1084 | 1130 | |
| 1085 | 1131 | $previous_topics[] = $row['id_previous_topic']; |
| 1086 | - if (empty($actioned_messages[$row['id_previous_topic']])) |
|
| 1087 | - $actioned_messages[$row['id_previous_topic']] = array( |
|
| 1132 | + if (empty($actioned_messages[$row['id_previous_topic']])) { |
|
| 1133 | + $actioned_messages[$row['id_previous_topic']] = array( |
|
| 1088 | 1134 | 'msgs' => array(), |
| 1089 | 1135 | 'count_posts' => $row['count_posts'], |
| 1090 | 1136 | 'subject' => $row['subject'], |
@@ -1094,17 +1140,20 @@ discard block |
||
| 1094 | 1140 | 'current_board' => $row['id_board'], |
| 1095 | 1141 | 'members' => array(), |
| 1096 | 1142 | ); |
| 1143 | + } |
|
| 1097 | 1144 | |
| 1098 | 1145 | $actioned_messages[$row['id_previous_topic']]['msgs'][$row['id_msg']] = $row['subject']; |
| 1099 | - if ($row['id_member']) |
|
| 1100 | - $actioned_messages[$row['id_previous_topic']]['members'][] = $row['id_member']; |
|
| 1146 | + if ($row['id_member']) { |
|
| 1147 | + $actioned_messages[$row['id_previous_topic']]['members'][] = $row['id_member']; |
|
| 1148 | + } |
|
| 1101 | 1149 | } |
| 1102 | 1150 | $smcFunc['db_free_result']($request); |
| 1103 | 1151 | |
| 1104 | 1152 | // Check for topics we are going to fully restore. |
| 1105 | - foreach ($actioned_messages as $topic => $data) |
|
| 1106 | - if (in_array($topic, $topics_to_restore)) |
|
| 1153 | + foreach ($actioned_messages as $topic => $data) { |
|
| 1154 | + if (in_array($topic, $topics_to_restore)) |
|
| 1107 | 1155 | unset($actioned_messages[$topic]); |
| 1156 | + } |
|
| 1108 | 1157 | |
| 1109 | 1158 | // Load any previous topics to check they exist. |
| 1110 | 1159 | if (!empty($previous_topics)) |
@@ -1119,11 +1168,12 @@ discard block |
||
| 1119 | 1168 | ) |
| 1120 | 1169 | ); |
| 1121 | 1170 | $previous_topics = array(); |
| 1122 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1123 | - $previous_topics[$row['id_topic']] = array( |
|
| 1171 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1172 | + $previous_topics[$row['id_topic']] = array( |
|
| 1124 | 1173 | 'board' => $row['id_board'], |
| 1125 | 1174 | 'subject' => $row['subject'], |
| 1126 | 1175 | ); |
| 1176 | + } |
|
| 1127 | 1177 | $smcFunc['db_free_result']($request); |
| 1128 | 1178 | } |
| 1129 | 1179 | |
@@ -1145,11 +1195,11 @@ discard block |
||
| 1145 | 1195 | // Log em. |
| 1146 | 1196 | logAction('restore_posts', array('topic' => $topic, 'subject' => $previous_topics[$topic]['subject'], 'board' => empty($data['previous_board']) ? $data['possible_prev_board'] : $data['previous_board'])); |
| 1147 | 1197 | $messages = array_merge(array_keys($data['msgs']), $messages); |
| 1148 | - } |
|
| 1149 | - else |
|
| 1198 | + } else |
|
| 1150 | 1199 | { |
| 1151 | - foreach ($data['msgs'] as $msg) |
|
| 1152 | - $unfound_messages[$msg['id']] = $msg['subject']; |
|
| 1200 | + foreach ($data['msgs'] as $msg) { |
|
| 1201 | + $unfound_messages[$msg['id']] = $msg['subject']; |
|
| 1202 | + } |
|
| 1153 | 1203 | } |
| 1154 | 1204 | } |
| 1155 | 1205 | } |
@@ -1158,8 +1208,9 @@ discard block |
||
| 1158 | 1208 | if (!empty($_REQUEST['topics'])) |
| 1159 | 1209 | { |
| 1160 | 1210 | $topics = explode(',', $_REQUEST['topics']); |
| 1161 | - foreach ($topics as $id) |
|
| 1162 | - $topics_to_restore[] = (int) $id; |
|
| 1211 | + foreach ($topics as $id) { |
|
| 1212 | + $topics_to_restore[] = (int) $id; |
|
| 1213 | + } |
|
| 1163 | 1214 | } |
| 1164 | 1215 | |
| 1165 | 1216 | if (!empty($topics_to_restore)) |
@@ -1213,8 +1264,9 @@ discard block |
||
| 1213 | 1264 | ) |
| 1214 | 1265 | ); |
| 1215 | 1266 | |
| 1216 | - while ($member = $smcFunc['db_fetch_assoc']($request2)) |
|
| 1217 | - updateMemberData($member['id_member'], array('posts' => 'posts + ' . $member['post_count'])); |
|
| 1267 | + while ($member = $smcFunc['db_fetch_assoc']($request2)) { |
|
| 1268 | + updateMemberData($member['id_member'], array('posts' => 'posts + ' . $member['post_count'])); |
|
| 1269 | + } |
|
| 1218 | 1270 | $smcFunc['db_free_result']($request2); |
| 1219 | 1271 | } |
| 1220 | 1272 | |
@@ -1225,8 +1277,9 @@ discard block |
||
| 1225 | 1277 | } |
| 1226 | 1278 | |
| 1227 | 1279 | // Didn't find some things? |
| 1228 | - if (!empty($unfound_messages)) |
|
| 1229 | - fatal_lang_error('restore_not_found', false, array(implode('<br>', $unfound_messages))); |
|
| 1280 | + if (!empty($unfound_messages)) { |
|
| 1281 | + fatal_lang_error('restore_not_found', false, array(implode('<br>', $unfound_messages))); |
|
| 1282 | + } |
|
| 1230 | 1283 | |
| 1231 | 1284 | // Just send them to the index if they get here. |
| 1232 | 1285 | redirectexit(); |
@@ -1246,12 +1299,14 @@ discard block |
||
| 1246 | 1299 | //!!! This really needs to be rewritten to take a load of messages from ANY topic, it's also inefficient. |
| 1247 | 1300 | |
| 1248 | 1301 | // Is it an array? |
| 1249 | - if (!is_array($msgs)) |
|
| 1250 | - $msgs = array($msgs); |
|
| 1302 | + if (!is_array($msgs)) { |
|
| 1303 | + $msgs = array($msgs); |
|
| 1304 | + } |
|
| 1251 | 1305 | |
| 1252 | 1306 | // Lets make sure they are int. |
| 1253 | - foreach ($msgs as $key => $msg) |
|
| 1254 | - $msgs[$key] = (int) $msg; |
|
| 1307 | + foreach ($msgs as $key => $msg) { |
|
| 1308 | + $msgs[$key] = (int) $msg; |
|
| 1309 | + } |
|
| 1255 | 1310 | |
| 1256 | 1311 | // Get the source information. |
| 1257 | 1312 | $request = $smcFunc['db_query']('', ' |
@@ -1294,8 +1349,9 @@ discard block |
||
| 1294 | 1349 | ) |
| 1295 | 1350 | ); |
| 1296 | 1351 | |
| 1297 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1298 | - updateMemberData($row['id_member'], array('posts' => '+')); |
|
| 1352 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1353 | + updateMemberData($row['id_member'], array('posts' => '+')); |
|
| 1354 | + } |
|
| 1299 | 1355 | } |
| 1300 | 1356 | |
| 1301 | 1357 | // Time to move the messages. |
@@ -1331,13 +1387,15 @@ discard block |
||
| 1331 | 1387 | ); |
| 1332 | 1388 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1333 | 1389 | { |
| 1334 | - if ($row['id_first_msg'] < $target_topic_data['id_first_msg']) |
|
| 1335 | - $target_topic_data['id_first_msg'] = $row['id_first_msg']; |
|
| 1390 | + if ($row['id_first_msg'] < $target_topic_data['id_first_msg']) { |
|
| 1391 | + $target_topic_data['id_first_msg'] = $row['id_first_msg']; |
|
| 1392 | + } |
|
| 1336 | 1393 | $target_topic_data['id_last_msg'] = $row['id_last_msg']; |
| 1337 | - if (!$row['approved']) |
|
| 1338 | - $target_topic_data['unapproved_posts'] = $row['message_count']; |
|
| 1339 | - else |
|
| 1340 | - $target_topic_data['num_replies'] = max(0, $row['message_count'] - 1); |
|
| 1394 | + if (!$row['approved']) { |
|
| 1395 | + $target_topic_data['unapproved_posts'] = $row['message_count']; |
|
| 1396 | + } else { |
|
| 1397 | + $target_topic_data['num_replies'] = max(0, $row['message_count'] - 1); |
|
| 1398 | + } |
|
| 1341 | 1399 | } |
| 1342 | 1400 | $smcFunc['db_free_result']($request); |
| 1343 | 1401 | |
@@ -1396,13 +1454,15 @@ discard block |
||
| 1396 | 1454 | ); |
| 1397 | 1455 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1398 | 1456 | { |
| 1399 | - if ($row['id_first_msg'] < $source_topic_data['id_first_msg']) |
|
| 1400 | - $source_topic_data['id_first_msg'] = $row['id_first_msg']; |
|
| 1457 | + if ($row['id_first_msg'] < $source_topic_data['id_first_msg']) { |
|
| 1458 | + $source_topic_data['id_first_msg'] = $row['id_first_msg']; |
|
| 1459 | + } |
|
| 1401 | 1460 | $source_topic_data['id_last_msg'] = $row['id_last_msg']; |
| 1402 | - if (!$row['approved']) |
|
| 1403 | - $source_topic_data['unapproved_posts'] = $row['message_count']; |
|
| 1404 | - else |
|
| 1405 | - $source_topic_data['num_replies'] = max(0, $row['message_count'] - 1); |
|
| 1461 | + if (!$row['approved']) { |
|
| 1462 | + $source_topic_data['unapproved_posts'] = $row['message_count']; |
|
| 1463 | + } else { |
|
| 1464 | + $source_topic_data['num_replies'] = max(0, $row['message_count'] - 1); |
|
| 1465 | + } |
|
| 1406 | 1466 | } |
| 1407 | 1467 | $smcFunc['db_free_result']($request); |
| 1408 | 1468 | |
@@ -1466,10 +1526,12 @@ discard block |
||
| 1466 | 1526 | |
| 1467 | 1527 | // Subject cache? |
| 1468 | 1528 | $cache_updates = array(); |
| 1469 | - if ($target_first_msg != $target_topic_data['id_first_msg']) |
|
| 1470 | - $cache_updates[] = $target_topic_data['id_first_msg']; |
|
| 1471 | - if (!empty($source_topic_data['id_first_msg']) && $from_first_msg != $source_topic_data['id_first_msg']) |
|
| 1472 | - $cache_updates[] = $source_topic_data['id_first_msg']; |
|
| 1529 | + if ($target_first_msg != $target_topic_data['id_first_msg']) { |
|
| 1530 | + $cache_updates[] = $target_topic_data['id_first_msg']; |
|
| 1531 | + } |
|
| 1532 | + if (!empty($source_topic_data['id_first_msg']) && $from_first_msg != $source_topic_data['id_first_msg']) { |
|
| 1533 | + $cache_updates[] = $source_topic_data['id_first_msg']; |
|
| 1534 | + } |
|
| 1473 | 1535 | |
| 1474 | 1536 | if (!empty($cache_updates)) |
| 1475 | 1537 | { |
@@ -1481,8 +1543,9 @@ discard block |
||
| 1481 | 1543 | 'first_messages' => $cache_updates, |
| 1482 | 1544 | ) |
| 1483 | 1545 | ); |
| 1484 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1485 | - updateStats('subject', $row['id_topic'], $row['subject']); |
|
| 1546 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1547 | + updateStats('subject', $row['id_topic'], $row['subject']); |
|
| 1548 | + } |
|
| 1486 | 1549 | $smcFunc['db_free_result']($request); |
| 1487 | 1550 | } |
| 1488 | 1551 | |
@@ -1498,22 +1561,26 @@ discard block |
||
| 1498 | 1561 | global $modSettings, $board, $scripturl, $context; |
| 1499 | 1562 | |
| 1500 | 1563 | // No recycle no need to go further |
| 1501 | - if (empty($modSettings['recycle_enable']) || empty($modSettings['recycle_board'])) |
|
| 1502 | - return false; |
|
| 1564 | + if (empty($modSettings['recycle_enable']) || empty($modSettings['recycle_board'])) { |
|
| 1565 | + return false; |
|
| 1566 | + } |
|
| 1503 | 1567 | |
| 1504 | 1568 | // If it's confirmed go on and delete (from recycle) |
| 1505 | - if (isset($_GET['confirm_delete'])) |
|
| 1506 | - return true; |
|
| 1569 | + if (isset($_GET['confirm_delete'])) { |
|
| 1570 | + return true; |
|
| 1571 | + } |
|
| 1507 | 1572 | |
| 1508 | - if (empty($board)) |
|
| 1509 | - return false; |
|
| 1573 | + if (empty($board)) { |
|
| 1574 | + return false; |
|
| 1575 | + } |
|
| 1510 | 1576 | |
| 1511 | - if ($modSettings['recycle_board'] != $board) |
|
| 1512 | - return true; |
|
| 1513 | - elseif (isset($_REQUEST['msg'])) |
|
| 1514 | - $confirm_url = $scripturl . '?action=deletemsg;confirm_delete;topic=' . $context['current_topic'] . '.0;msg=' . $_REQUEST['msg'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
|
| 1515 | - else |
|
| 1516 | - $confirm_url = $scripturl . '?action=removetopic2;confirm_delete;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id']; |
|
| 1577 | + if ($modSettings['recycle_board'] != $board) { |
|
| 1578 | + return true; |
|
| 1579 | + } elseif (isset($_REQUEST['msg'])) { |
|
| 1580 | + $confirm_url = $scripturl . '?action=deletemsg;confirm_delete;topic=' . $context['current_topic'] . '.0;msg=' . $_REQUEST['msg'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
|
| 1581 | + } else { |
|
| 1582 | + $confirm_url = $scripturl . '?action=removetopic2;confirm_delete;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id']; |
|
| 1583 | + } |
|
| 1517 | 1584 | |
| 1518 | 1585 | fatal_lang_error('post_already_deleted', false, array($confirm_url)); |
| 1519 | 1586 | } |
@@ -1013,7 +1013,7 @@ |
||
| 1013 | 1013 | * @param string $title The title of the separator |
| 1014 | 1014 | * @param null|string $custom_table The ID of the custom table |
| 1015 | 1015 | * |
| 1016 | - * @return void|bool Returns false if there are no tables |
|
| 1016 | + * @return null|false Returns false if there are no tables |
|
| 1017 | 1017 | */ |
| 1018 | 1018 | function addSeparator($title = '', $custom_table = null) |
| 1019 | 1019 | { |
@@ -21,8 +21,9 @@ discard block |
||
| 21 | 21 | * @version 2.1 Beta 3 |
| 22 | 22 | */ |
| 23 | 23 | |
| 24 | -if (!defined('SMF')) |
|
| 24 | +if (!defined('SMF')) { |
|
| 25 | 25 | die('No direct access...'); |
| 26 | +} |
|
| 26 | 27 | |
| 27 | 28 | /** |
| 28 | 29 | * Handling function for generating reports. |
@@ -69,14 +70,15 @@ discard block |
||
| 69 | 70 | ); |
| 70 | 71 | |
| 71 | 72 | $is_first = 0; |
| 72 | - foreach ($context['report_types'] as $k => $temp) |
|
| 73 | - $context['report_types'][$k] = array( |
|
| 73 | + foreach ($context['report_types'] as $k => $temp) { |
|
| 74 | + $context['report_types'][$k] = array( |
|
| 74 | 75 | 'id' => $k, |
| 75 | 76 | 'title' => isset($txt['gr_type_' . $k]) ? $txt['gr_type_' . $k] : $k, |
| 76 | 77 | 'description' => isset($txt['gr_type_desc_' . $k]) ? $txt['gr_type_desc_' . $k] : null, |
| 77 | 78 | 'function' => $temp, |
| 78 | 79 | 'is_first' => $is_first++ == 0, |
| 79 | 80 | ); |
| 81 | + } |
|
| 80 | 82 | |
| 81 | 83 | // If they haven't chosen a report type which is valid, send them off to the report type chooser! |
| 82 | 84 | if (empty($_REQUEST['rt']) || !isset($context['report_types'][$_REQUEST['rt']])) |
@@ -102,8 +104,9 @@ discard block |
||
| 102 | 104 | $context['sub_template'] = $_REQUEST['st']; |
| 103 | 105 | |
| 104 | 106 | // Are we disabling the other layers - print friendly for example? |
| 105 | - if ($reportTemplates[$_REQUEST['st']]['layers'] !== null) |
|
| 106 | - $context['template_layers'] = $reportTemplates[$_REQUEST['st']]['layers']; |
|
| 107 | + if ($reportTemplates[$_REQUEST['st']]['layers'] !== null) { |
|
| 108 | + $context['template_layers'] = $reportTemplates[$_REQUEST['st']]['layers']; |
|
| 109 | + } |
|
| 107 | 110 | } |
| 108 | 111 | |
| 109 | 112 | // Make the page title more descriptive. |
@@ -151,8 +154,9 @@ discard block |
||
| 151 | 154 | ) |
| 152 | 155 | ); |
| 153 | 156 | $moderators = array(); |
| 154 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 155 | - $moderators[$row['id_board']][] = $row['real_name']; |
|
| 157 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 158 | + $moderators[$row['id_board']][] = $row['real_name']; |
|
| 159 | + } |
|
| 156 | 160 | $smcFunc['db_free_result']($request); |
| 157 | 161 | |
| 158 | 162 | // Get every moderator gruop. |
@@ -164,8 +168,9 @@ discard block |
||
| 164 | 168 | ) |
| 165 | 169 | ); |
| 166 | 170 | $moderator_groups = array(); |
| 167 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 168 | - $moderator_groups[$row['id_board']][] = $row['group_name']; |
|
| 171 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 172 | + $moderator_groups[$row['id_board']][] = $row['group_name']; |
|
| 173 | + } |
|
| 169 | 174 | $smcFunc['db_free_result']($request); |
| 170 | 175 | |
| 171 | 176 | // Get all the possible membergroups! |
@@ -176,8 +181,9 @@ discard block |
||
| 176 | 181 | ) |
| 177 | 182 | ); |
| 178 | 183 | $groups = array(-1 => $txt['guest_title'], 0 => $txt['full_member']); |
| 179 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 180 | - $groups[$row['id_group']] = empty($row['online_color']) ? $row['group_name'] : '<span style="color: ' . $row['online_color'] . '">' . $row['group_name'] . '</span>'; |
|
| 184 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 185 | + $groups[$row['id_group']] = empty($row['online_color']) ? $row['group_name'] : '<span style="color: ' . $row['online_color'] . '">' . $row['group_name'] . '</span>'; |
|
| 186 | + } |
|
| 181 | 187 | $smcFunc['db_free_result']($request); |
| 182 | 188 | |
| 183 | 189 | // All the fields we'll show. |
@@ -195,8 +201,9 @@ discard block |
||
| 195 | 201 | 'moderator_groups' => $txt['board_moderator_groups'], |
| 196 | 202 | 'groups' => $txt['board_groups'], |
| 197 | 203 | ); |
| 198 | - if (!empty($modSettings['deny_boards_access'])) |
|
| 199 | - $boardSettings['disallowed_groups'] = $txt['board_disallowed_groups']; |
|
| 204 | + if (!empty($modSettings['deny_boards_access'])) { |
|
| 205 | + $boardSettings['disallowed_groups'] = $txt['board_disallowed_groups']; |
|
| 206 | + } |
|
| 200 | 207 | |
| 201 | 208 | // Do it in columns, it's just easier. |
| 202 | 209 | setKeys('cols'); |
@@ -222,8 +229,9 @@ discard block |
||
| 222 | 229 | newTable($row['name'], '', 'left', 'auto', 'left', 200, 'left'); |
| 223 | 230 | |
| 224 | 231 | $this_boardSettings = $boardSettings; |
| 225 | - if (empty($row['redirect'])) |
|
| 226 | - unset($this_boardSettings['redirect']); |
|
| 232 | + if (empty($row['redirect'])) { |
|
| 233 | + unset($this_boardSettings['redirect']); |
|
| 234 | + } |
|
| 227 | 235 | |
| 228 | 236 | // First off, add in the side key. |
| 229 | 237 | addData($this_boardSettings); |
@@ -250,10 +258,11 @@ discard block |
||
| 250 | 258 | $allowedGroups = explode(',', $row['member_groups']); |
| 251 | 259 | foreach ($allowedGroups as $key => $group) |
| 252 | 260 | { |
| 253 | - if (isset($groups[$group])) |
|
| 254 | - $allowedGroups[$key] = $groups[$group]; |
|
| 255 | - else |
|
| 256 | - unset($allowedGroups[$key]); |
|
| 261 | + if (isset($groups[$group])) { |
|
| 262 | + $allowedGroups[$key] = $groups[$group]; |
|
| 263 | + } else { |
|
| 264 | + unset($allowedGroups[$key]); |
|
| 265 | + } |
|
| 257 | 266 | } |
| 258 | 267 | $boardData['groups'] = implode(', ', $allowedGroups); |
| 259 | 268 | if (!empty($modSettings['deny_boards_access'])) |
@@ -261,16 +270,18 @@ discard block |
||
| 261 | 270 | $disallowedGroups = explode(',', $row['deny_member_groups']); |
| 262 | 271 | foreach ($disallowedGroups as $key => $group) |
| 263 | 272 | { |
| 264 | - if (isset($groups[$group])) |
|
| 265 | - $disallowedGroups[$key] = $groups[$group]; |
|
| 266 | - else |
|
| 267 | - unset($disallowedGroups[$key]); |
|
| 273 | + if (isset($groups[$group])) { |
|
| 274 | + $disallowedGroups[$key] = $groups[$group]; |
|
| 275 | + } else { |
|
| 276 | + unset($disallowedGroups[$key]); |
|
| 277 | + } |
|
| 268 | 278 | } |
| 269 | 279 | $boardData['disallowed_groups'] = implode(', ', $disallowedGroups); |
| 270 | 280 | } |
| 271 | 281 | |
| 272 | - if (empty($row['redirect'])) |
|
| 273 | - unset ($boardData['redirect']); |
|
| 282 | + if (empty($row['redirect'])) { |
|
| 283 | + unset ($boardData['redirect']); |
|
| 284 | + } |
|
| 274 | 285 | |
| 275 | 286 | // Next add the main data. |
| 276 | 287 | addData($boardData); |
@@ -295,27 +306,31 @@ discard block |
||
| 295 | 306 | |
| 296 | 307 | if (isset($_REQUEST['boards'])) |
| 297 | 308 | { |
| 298 | - if (!is_array($_REQUEST['boards'])) |
|
| 299 | - $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
|
| 300 | - foreach ($_REQUEST['boards'] as $k => $dummy) |
|
| 301 | - $_REQUEST['boards'][$k] = (int) $dummy; |
|
| 309 | + if (!is_array($_REQUEST['boards'])) { |
|
| 310 | + $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
|
| 311 | + } |
|
| 312 | + foreach ($_REQUEST['boards'] as $k => $dummy) { |
|
| 313 | + $_REQUEST['boards'][$k] = (int) $dummy; |
|
| 314 | + } |
|
| 302 | 315 | |
| 303 | 316 | $board_clause = 'id_board IN ({array_int:boards})'; |
| 317 | + } else { |
|
| 318 | + $board_clause = '1=1'; |
|
| 304 | 319 | } |
| 305 | - else |
|
| 306 | - $board_clause = '1=1'; |
|
| 307 | 320 | |
| 308 | 321 | if (isset($_REQUEST['groups'])) |
| 309 | 322 | { |
| 310 | - if (!is_array($_REQUEST['groups'])) |
|
| 311 | - $_REQUEST['groups'] = explode(',', $_REQUEST['groups']); |
|
| 312 | - foreach ($_REQUEST['groups'] as $k => $dummy) |
|
| 313 | - $_REQUEST['groups'][$k] = (int) $dummy; |
|
| 323 | + if (!is_array($_REQUEST['groups'])) { |
|
| 324 | + $_REQUEST['groups'] = explode(',', $_REQUEST['groups']); |
|
| 325 | + } |
|
| 326 | + foreach ($_REQUEST['groups'] as $k => $dummy) { |
|
| 327 | + $_REQUEST['groups'][$k] = (int) $dummy; |
|
| 328 | + } |
|
| 314 | 329 | |
| 315 | 330 | $group_clause = 'id_group IN ({array_int:groups})'; |
| 331 | + } else { |
|
| 332 | + $group_clause = '1=1'; |
|
| 316 | 333 | } |
| 317 | - else |
|
| 318 | - $group_clause = '1=1'; |
|
| 319 | 334 | |
| 320 | 335 | // Fetch all the board names. |
| 321 | 336 | $request = $smcFunc['db_query']('', ' |
@@ -369,12 +384,14 @@ discard block |
||
| 369 | 384 | 'groups' => isset($_REQUEST['groups']) ? $_REQUEST['groups'] : array(), |
| 370 | 385 | ) |
| 371 | 386 | ); |
| 372 | - if (!isset($_REQUEST['groups']) || in_array(-1, $_REQUEST['groups']) || in_array(0, $_REQUEST['groups'])) |
|
| 373 | - $member_groups = array('col' => '', -1 => $txt['membergroups_guests'], 0 => $txt['membergroups_members']); |
|
| 374 | - else |
|
| 375 | - $member_groups = array('col' => ''); |
|
| 376 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 377 | - $member_groups[$row['id_group']] = $row['group_name']; |
|
| 387 | + if (!isset($_REQUEST['groups']) || in_array(-1, $_REQUEST['groups']) || in_array(0, $_REQUEST['groups'])) { |
|
| 388 | + $member_groups = array('col' => '', -1 => $txt['membergroups_guests'], 0 => $txt['membergroups_members']); |
|
| 389 | + } else { |
|
| 390 | + $member_groups = array('col' => ''); |
|
| 391 | + } |
|
| 392 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 393 | + $member_groups[$row['id_group']] = $row['group_name']; |
|
| 394 | + } |
|
| 378 | 395 | $smcFunc['db_free_result']($request); |
| 379 | 396 | |
| 380 | 397 | // Make sure that every group is represented - plus in rows! |
@@ -411,12 +428,14 @@ discard block |
||
| 411 | 428 | ); |
| 412 | 429 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 413 | 430 | { |
| 414 | - if (in_array($row['permission'], $disabled_permissions)) |
|
| 415 | - continue; |
|
| 431 | + if (in_array($row['permission'], $disabled_permissions)) { |
|
| 432 | + continue; |
|
| 433 | + } |
|
| 416 | 434 | |
| 417 | - foreach ($boards as $id => $board) |
|
| 418 | - if ($board['profile'] == $row['id_profile']) |
|
| 435 | + foreach ($boards as $id => $board) { |
|
| 436 | + if ($board['profile'] == $row['id_profile']) |
|
| 419 | 437 | $board_permissions[$id][$row['id_group']][$row['permission']] = $row['add_deny']; |
| 438 | + } |
|
| 420 | 439 | |
| 421 | 440 | // Make sure we get every permission. |
| 422 | 441 | if (!isset($permissions[$row['permission']])) |
@@ -454,8 +473,9 @@ discard block |
||
| 454 | 473 | foreach ($member_groups as $id_group => $name) |
| 455 | 474 | { |
| 456 | 475 | // Don't overwrite the key column! |
| 457 | - if ($id_group === 'col') |
|
| 458 | - continue; |
|
| 476 | + if ($id_group === 'col') { |
|
| 477 | + continue; |
|
| 478 | + } |
|
| 459 | 479 | |
| 460 | 480 | $group_permissions = isset($groups[$id_group]) ? $groups[$id_group] : array(); |
| 461 | 481 | |
@@ -477,16 +497,18 @@ discard block |
||
| 477 | 497 | } |
| 478 | 498 | |
| 479 | 499 | // Now actually make the data for the group look right. |
| 480 | - if (empty($curData[$id_group])) |
|
| 481 | - $curData[$id_group] = '<span class="red">' . $txt['board_perms_deny'] . '</span>'; |
|
| 482 | - elseif ($curData[$id_group] == 1) |
|
| 483 | - $curData[$id_group] = '<span style="color: darkgreen;">' . $txt['board_perms_allow'] . '</span>'; |
|
| 484 | - else |
|
| 485 | - $curData[$id_group] = 'x'; |
|
| 500 | + if (empty($curData[$id_group])) { |
|
| 501 | + $curData[$id_group] = '<span class="red">' . $txt['board_perms_deny'] . '</span>'; |
|
| 502 | + } elseif ($curData[$id_group] == 1) { |
|
| 503 | + $curData[$id_group] = '<span style="color: darkgreen;">' . $txt['board_perms_allow'] . '</span>'; |
|
| 504 | + } else { |
|
| 505 | + $curData[$id_group] = 'x'; |
|
| 506 | + } |
|
| 486 | 507 | |
| 487 | 508 | // Embolden those permissions different from global (makes it a lot easier!) |
| 488 | - if (@$board_permissions[0][$id_group][$ID_PERM] != @$group_permissions[$ID_PERM]) |
|
| 489 | - $curData[$id_group] = '<strong>' . $curData[$id_group] . '</strong>'; |
|
| 509 | + if (@$board_permissions[0][$id_group][$ID_PERM] != @$group_permissions[$ID_PERM]) { |
|
| 510 | + $curData[$id_group] = '<strong>' . $curData[$id_group] . '</strong>'; |
|
| 511 | + } |
|
| 490 | 512 | } |
| 491 | 513 | |
| 492 | 514 | // Now add the data for this permission. |
@@ -516,15 +538,17 @@ discard block |
||
| 516 | 538 | ); |
| 517 | 539 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 518 | 540 | { |
| 519 | - if (trim($row['member_groups']) == '') |
|
| 520 | - $groups = array(1); |
|
| 521 | - else |
|
| 522 | - $groups = array_merge(array(1), explode(',', $row['member_groups'])); |
|
| 541 | + if (trim($row['member_groups']) == '') { |
|
| 542 | + $groups = array(1); |
|
| 543 | + } else { |
|
| 544 | + $groups = array_merge(array(1), explode(',', $row['member_groups'])); |
|
| 545 | + } |
|
| 523 | 546 | |
| 524 | - if (trim($row['deny_member_groups']) == '') |
|
| 525 | - $denyGroups = array(); |
|
| 526 | - else |
|
| 527 | - $denyGroups = explode(',', $row['deny_member_groups']); |
|
| 547 | + if (trim($row['deny_member_groups']) == '') { |
|
| 548 | + $denyGroups = array(); |
|
| 549 | + } else { |
|
| 550 | + $denyGroups = explode(',', $row['deny_member_groups']); |
|
| 551 | + } |
|
| 528 | 552 | |
| 529 | 553 | $boards[$row['id_board']] = array( |
| 530 | 554 | 'id' => $row['id_board'], |
@@ -548,8 +572,9 @@ discard block |
||
| 548 | 572 | ); |
| 549 | 573 | |
| 550 | 574 | // Add on the boards! |
| 551 | - foreach ($boards as $board) |
|
| 552 | - $mgSettings['board_' . $board['id']] = $board['name']; |
|
| 575 | + foreach ($boards as $board) { |
|
| 576 | + $mgSettings['board_' . $board['id']] = $board['name']; |
|
| 577 | + } |
|
| 553 | 578 | |
| 554 | 579 | // Add all the membergroup settings, plus we'll be adding in columns! |
| 555 | 580 | setKeys('cols', $mgSettings); |
@@ -594,8 +619,9 @@ discard block |
||
| 594 | 619 | 'icons' => '' |
| 595 | 620 | ), |
| 596 | 621 | ); |
| 597 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 598 | - $rows[] = $row; |
|
| 622 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 623 | + $rows[] = $row; |
|
| 624 | + } |
|
| 599 | 625 | $smcFunc['db_free_result']($request); |
| 600 | 626 | |
| 601 | 627 | foreach ($rows as $row) |
@@ -611,8 +637,9 @@ discard block |
||
| 611 | 637 | ); |
| 612 | 638 | |
| 613 | 639 | // Board permissions. |
| 614 | - foreach ($boards as $board) |
|
| 615 | - $group['board_' . $board['id']] = in_array($row['id_group'], $board['groups']) ? '<span class="success">' . $txt['board_perms_allow'] . '</span>' : (!empty($modSettings['deny_boards_access']) && in_array($row['id_group'], $board['deny_groups']) ? '<span class="alert">' . $txt['board_perms_deny'] . '</span>' : 'x'); |
|
| 640 | + foreach ($boards as $board) { |
|
| 641 | + $group['board_' . $board['id']] = in_array($row['id_group'], $board['groups']) ? '<span class="success">' . $txt['board_perms_allow'] . '</span>' : (!empty($modSettings['deny_boards_access']) && in_array($row['id_group'], $board['deny_groups']) ? '<span class="alert">' . $txt['board_perms_deny'] . '</span>' : 'x'); |
|
| 642 | + } |
|
| 616 | 643 | |
| 617 | 644 | addData($group); |
| 618 | 645 | } |
@@ -632,16 +659,18 @@ discard block |
||
| 632 | 659 | |
| 633 | 660 | if (isset($_REQUEST['groups'])) |
| 634 | 661 | { |
| 635 | - if (!is_array($_REQUEST['groups'])) |
|
| 636 | - $_REQUEST['groups'] = explode(',', $_REQUEST['groups']); |
|
| 637 | - foreach ($_REQUEST['groups'] as $k => $dummy) |
|
| 638 | - $_REQUEST['groups'][$k] = (int) $dummy; |
|
| 662 | + if (!is_array($_REQUEST['groups'])) { |
|
| 663 | + $_REQUEST['groups'] = explode(',', $_REQUEST['groups']); |
|
| 664 | + } |
|
| 665 | + foreach ($_REQUEST['groups'] as $k => $dummy) { |
|
| 666 | + $_REQUEST['groups'][$k] = (int) $dummy; |
|
| 667 | + } |
|
| 639 | 668 | $_REQUEST['groups'] = array_diff($_REQUEST['groups'], array(3)); |
| 640 | 669 | |
| 641 | 670 | $clause = 'id_group IN ({array_int:groups})'; |
| 671 | + } else { |
|
| 672 | + $clause = 'id_group != {int:moderator_group}'; |
|
| 642 | 673 | } |
| 643 | - else |
|
| 644 | - $clause = 'id_group != {int:moderator_group}'; |
|
| 645 | 674 | |
| 646 | 675 | // Get all the possible membergroups, except admin! |
| 647 | 676 | $request = $smcFunc['db_query']('', ' |
@@ -659,12 +688,14 @@ discard block |
||
| 659 | 688 | 'groups' => isset($_REQUEST['groups']) ? $_REQUEST['groups'] : array(), |
| 660 | 689 | ) |
| 661 | 690 | ); |
| 662 | - if (!isset($_REQUEST['groups']) || in_array(-1, $_REQUEST['groups']) || in_array(0, $_REQUEST['groups'])) |
|
| 663 | - $groups = array('col' => '', -1 => $txt['membergroups_guests'], 0 => $txt['membergroups_members']); |
|
| 664 | - else |
|
| 665 | - $groups = array('col' => ''); |
|
| 666 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 667 | - $groups[$row['id_group']] = $row['group_name']; |
|
| 691 | + if (!isset($_REQUEST['groups']) || in_array(-1, $_REQUEST['groups']) || in_array(0, $_REQUEST['groups'])) { |
|
| 692 | + $groups = array('col' => '', -1 => $txt['membergroups_guests'], 0 => $txt['membergroups_members']); |
|
| 693 | + } else { |
|
| 694 | + $groups = array('col' => ''); |
|
| 695 | + } |
|
| 696 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 697 | + $groups[$row['id_group']] = $row['group_name']; |
|
| 698 | + } |
|
| 668 | 699 | $smcFunc['db_free_result']($request); |
| 669 | 700 | |
| 670 | 701 | // Make sure that every group is represented! |
@@ -688,8 +719,9 @@ discard block |
||
| 688 | 719 | $disabled_permissions[] = 'calendar_edit_own'; |
| 689 | 720 | $disabled_permissions[] = 'calendar_edit_any'; |
| 690 | 721 | } |
| 691 | - if (empty($modSettings['warning_settings']) || $modSettings['warning_settings'][0] == 0) |
|
| 692 | - $disabled_permissions[] = 'issue_warning'; |
|
| 722 | + if (empty($modSettings['warning_settings']) || $modSettings['warning_settings'][0] == 0) { |
|
| 723 | + $disabled_permissions[] = 'issue_warning'; |
|
| 724 | + } |
|
| 693 | 725 | |
| 694 | 726 | call_integration_hook('integrate_reports_groupperm', array(&$disabled_permissions)); |
| 695 | 727 | |
@@ -710,15 +742,17 @@ discard block |
||
| 710 | 742 | $curData = array(); |
| 711 | 743 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 712 | 744 | { |
| 713 | - if (in_array($row['permission'], $disabled_permissions)) |
|
| 714 | - continue; |
|
| 745 | + if (in_array($row['permission'], $disabled_permissions)) { |
|
| 746 | + continue; |
|
| 747 | + } |
|
| 715 | 748 | |
| 716 | 749 | // If this is a new permission flush the last row. |
| 717 | 750 | if ($row['permission'] != $lastPermission) |
| 718 | 751 | { |
| 719 | 752 | // Send the data! |
| 720 | - if ($lastPermission !== null) |
|
| 721 | - addData($curData); |
|
| 753 | + if ($lastPermission !== null) { |
|
| 754 | + addData($curData); |
|
| 755 | + } |
|
| 722 | 756 | |
| 723 | 757 | // Add the permission name in the left column. |
| 724 | 758 | $curData = array('col' => isset($txt['group_perms_name_' . $row['permission']]) ? $txt['group_perms_name_' . $row['permission']] : $row['permission']); |
@@ -727,10 +761,11 @@ discard block |
||
| 727 | 761 | } |
| 728 | 762 | |
| 729 | 763 | // Good stuff - add the permission to the list! |
| 730 | - if ($row['add_deny']) |
|
| 731 | - $curData[$row['id_group']] = '<span style="color: darkgreen;">' . $txt['board_perms_allow'] . '</span>'; |
|
| 732 | - else |
|
| 733 | - $curData[$row['id_group']] = '<span class="red">' . $txt['board_perms_deny'] . '</span>'; |
|
| 764 | + if ($row['add_deny']) { |
|
| 765 | + $curData[$row['id_group']] = '<span style="color: darkgreen;">' . $txt['board_perms_allow'] . '</span>'; |
|
| 766 | + } else { |
|
| 767 | + $curData[$row['id_group']] = '<span class="red">' . $txt['board_perms_deny'] . '</span>'; |
|
| 768 | + } |
|
| 734 | 769 | } |
| 735 | 770 | $smcFunc['db_free_result']($request); |
| 736 | 771 | |
@@ -760,8 +795,9 @@ discard block |
||
| 760 | 795 | ) |
| 761 | 796 | ); |
| 762 | 797 | $boards = array(); |
| 763 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 764 | - $boards[$row['id_board']] = $row['name']; |
|
| 798 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 799 | + $boards[$row['id_board']] = $row['name']; |
|
| 800 | + } |
|
| 765 | 801 | $smcFunc['db_free_result']($request); |
| 766 | 802 | |
| 767 | 803 | // Get every moderator. |
@@ -793,12 +829,14 @@ discard block |
||
| 793 | 829 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 794 | 830 | { |
| 795 | 831 | // Either we don't have them as a moderator at all or at least not as a moderator of this board |
| 796 | - if (!array_key_exists($row['id_member'], $moderators) || !in_array($row['id_board'], $moderators[$row['id_member']])) |
|
| 797 | - $moderators[$row['id_member']][] = $row['id_board']; |
|
| 832 | + if (!array_key_exists($row['id_member'], $moderators) || !in_array($row['id_board'], $moderators[$row['id_member']])) { |
|
| 833 | + $moderators[$row['id_member']][] = $row['id_board']; |
|
| 834 | + } |
|
| 798 | 835 | |
| 799 | 836 | // We don't have them listed as a moderator yet |
| 800 | - if (!array_key_exists($row['id_member'], $local_mods)) |
|
| 801 | - $local_mods[$row['id_member']] = $row['id_member']; |
|
| 837 | + if (!array_key_exists($row['id_member'], $local_mods)) { |
|
| 838 | + $local_mods[$row['id_member']] = $row['id_member']; |
|
| 839 | + } |
|
| 802 | 840 | } |
| 803 | 841 | |
| 804 | 842 | // Get a list of global moderators (i.e. members with moderation powers). |
@@ -811,8 +849,9 @@ discard block |
||
| 811 | 849 | $allStaff = array_unique($allStaff); |
| 812 | 850 | |
| 813 | 851 | // This is a bit of a cop out - but we're protecting their forum, really! |
| 814 | - if (count($allStaff) > 300) |
|
| 815 | - fatal_lang_error('report_error_too_many_staff'); |
|
| 852 | + if (count($allStaff) > 300) { |
|
| 853 | + fatal_lang_error('report_error_too_many_staff'); |
|
| 854 | + } |
|
| 816 | 855 | |
| 817 | 856 | // Get all the possible membergroups! |
| 818 | 857 | $request = $smcFunc['db_query']('', ' |
@@ -822,8 +861,9 @@ discard block |
||
| 822 | 861 | ) |
| 823 | 862 | ); |
| 824 | 863 | $groups = array(0 => $txt['full_member']); |
| 825 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 826 | - $groups[$row['id_group']] = empty($row['online_color']) ? $row['group_name'] : '<span style="color: ' . $row['online_color'] . '">' . $row['group_name'] . '</span>'; |
|
| 864 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 865 | + $groups[$row['id_group']] = empty($row['online_color']) ? $row['group_name'] : '<span style="color: ' . $row['online_color'] . '">' . $row['group_name'] . '</span>'; |
|
| 866 | + } |
|
| 827 | 867 | $smcFunc['db_free_result']($request); |
| 828 | 868 | |
| 829 | 869 | // All the fields we'll show. |
@@ -864,19 +904,20 @@ discard block |
||
| 864 | 904 | ); |
| 865 | 905 | |
| 866 | 906 | // What do they moderate? |
| 867 | - if (in_array($row['id_member'], $global_mods)) |
|
| 868 | - $staffData['moderates'] = '<em>' . $txt['report_staff_all_boards'] . '</em>'; |
|
| 869 | - elseif (isset($moderators[$row['id_member']])) |
|
| 907 | + if (in_array($row['id_member'], $global_mods)) { |
|
| 908 | + $staffData['moderates'] = '<em>' . $txt['report_staff_all_boards'] . '</em>'; |
|
| 909 | + } elseif (isset($moderators[$row['id_member']])) |
|
| 870 | 910 | { |
| 871 | 911 | // Get the names |
| 872 | - foreach ($moderators[$row['id_member']] as $board) |
|
| 873 | - if (isset($boards[$board])) |
|
| 912 | + foreach ($moderators[$row['id_member']] as $board) { |
|
| 913 | + if (isset($boards[$board])) |
|
| 874 | 914 | $staffData['moderates'][] = $boards[$board]; |
| 915 | + } |
|
| 875 | 916 | |
| 876 | 917 | $staffData['moderates'] = implode(', ', $staffData['moderates']); |
| 918 | + } else { |
|
| 919 | + $staffData['moderates'] = '<em>' . $txt['report_staff_no_boards'] . '</em>'; |
|
| 877 | 920 | } |
| 878 | - else |
|
| 879 | - $staffData['moderates'] = '<em>' . $txt['report_staff_no_boards'] . '</em>'; |
|
| 880 | 921 | |
| 881 | 922 | // Next add the main data. |
| 882 | 923 | addData($staffData); |
@@ -904,8 +945,9 @@ discard block |
||
| 904 | 945 | global $context; |
| 905 | 946 | |
| 906 | 947 | // Set the table count if needed. |
| 907 | - if (empty($context['table_count'])) |
|
| 908 | - $context['table_count'] = 0; |
|
| 948 | + if (empty($context['table_count'])) { |
|
| 949 | + $context['table_count'] = 0; |
|
| 950 | + } |
|
| 909 | 951 | |
| 910 | 952 | // Create the table! |
| 911 | 953 | $context['tables'][$context['table_count']] = array( |
@@ -955,16 +997,18 @@ discard block |
||
| 955 | 997 | global $context; |
| 956 | 998 | |
| 957 | 999 | // No tables? Create one even though we are probably already in a bad state! |
| 958 | - if (empty($context['table_count'])) |
|
| 959 | - newTable(); |
|
| 1000 | + if (empty($context['table_count'])) { |
|
| 1001 | + newTable(); |
|
| 1002 | + } |
|
| 960 | 1003 | |
| 961 | 1004 | // Specific table? |
| 962 | - if ($custom_table !== null && !isset($context['tables'][$custom_table])) |
|
| 963 | - return false; |
|
| 964 | - elseif ($custom_table !== null) |
|
| 965 | - $table = $custom_table; |
|
| 966 | - else |
|
| 967 | - $table = $context['current_table']; |
|
| 1005 | + if ($custom_table !== null && !isset($context['tables'][$custom_table])) { |
|
| 1006 | + return false; |
|
| 1007 | + } elseif ($custom_table !== null) { |
|
| 1008 | + $table = $custom_table; |
|
| 1009 | + } else { |
|
| 1010 | + $table = $context['current_table']; |
|
| 1011 | + } |
|
| 968 | 1012 | |
| 969 | 1013 | // If we have keys, sanitise the data... |
| 970 | 1014 | if (!empty($context['keys'])) |
@@ -976,11 +1020,11 @@ discard block |
||
| 976 | 1020 | 'v' => empty($inc_data[$key]) ? $context['tables'][$table]['default_value'] : $inc_data[$key], |
| 977 | 1021 | ); |
| 978 | 1022 | // Special "hack" the adding separators when doing data by column. |
| 979 | - if (substr($key, 0, 5) == '#sep#') |
|
| 980 | - $data[$key]['separator'] = true; |
|
| 1023 | + if (substr($key, 0, 5) == '#sep#') { |
|
| 1024 | + $data[$key]['separator'] = true; |
|
| 1025 | + } |
|
| 981 | 1026 | } |
| 982 | - } |
|
| 983 | - else |
|
| 1027 | + } else |
|
| 984 | 1028 | { |
| 985 | 1029 | $data = $inc_data; |
| 986 | 1030 | foreach ($data as $key => $value) |
@@ -988,8 +1032,9 @@ discard block |
||
| 988 | 1032 | $data[$key] = array( |
| 989 | 1033 | 'v' => $value, |
| 990 | 1034 | ); |
| 991 | - if (substr($key, 0, 5) == '#sep#') |
|
| 992 | - $data[$key]['separator'] = true; |
|
| 1035 | + if (substr($key, 0, 5) == '#sep#') { |
|
| 1036 | + $data[$key]['separator'] = true; |
|
| 1037 | + } |
|
| 993 | 1038 | } |
| 994 | 1039 | } |
| 995 | 1040 | |
@@ -1002,8 +1047,9 @@ discard block |
||
| 1002 | 1047 | // Otherwise, tricky! |
| 1003 | 1048 | else |
| 1004 | 1049 | { |
| 1005 | - foreach ($data as $key => $item) |
|
| 1006 | - $context['tables'][$table]['data'][$key][] = $item; |
|
| 1050 | + foreach ($data as $key => $item) { |
|
| 1051 | + $context['tables'][$table]['data'][$key][] = $item; |
|
| 1052 | + } |
|
| 1007 | 1053 | } |
| 1008 | 1054 | } |
| 1009 | 1055 | |
@@ -1020,16 +1066,18 @@ discard block |
||
| 1020 | 1066 | global $context; |
| 1021 | 1067 | |
| 1022 | 1068 | // No tables - return? |
| 1023 | - if (empty($context['table_count'])) |
|
| 1024 | - return; |
|
| 1069 | + if (empty($context['table_count'])) { |
|
| 1070 | + return; |
|
| 1071 | + } |
|
| 1025 | 1072 | |
| 1026 | 1073 | // Specific table? |
| 1027 | - if ($custom_table !== null && !isset($context['tables'][$table])) |
|
| 1028 | - return false; |
|
| 1029 | - elseif ($custom_table !== null) |
|
| 1030 | - $table = $custom_table; |
|
| 1031 | - else |
|
| 1032 | - $table = $context['current_table']; |
|
| 1074 | + if ($custom_table !== null && !isset($context['tables'][$table])) { |
|
| 1075 | + return false; |
|
| 1076 | + } elseif ($custom_table !== null) { |
|
| 1077 | + $table = $custom_table; |
|
| 1078 | + } else { |
|
| 1079 | + $table = $context['current_table']; |
|
| 1080 | + } |
|
| 1033 | 1081 | |
| 1034 | 1082 | // Plumb in the separator |
| 1035 | 1083 | $context['tables'][$table]['data'][] = array(0 => array( |
@@ -1050,8 +1098,9 @@ discard block |
||
| 1050 | 1098 | { |
| 1051 | 1099 | global $context; |
| 1052 | 1100 | |
| 1053 | - if (empty($context['tables'])) |
|
| 1054 | - return; |
|
| 1101 | + if (empty($context['tables'])) { |
|
| 1102 | + return; |
|
| 1103 | + } |
|
| 1055 | 1104 | |
| 1056 | 1105 | // Loop through each table counting up some basic values, to help with the templating. |
| 1057 | 1106 | foreach ($context['tables'] as $id => $table) |
@@ -1062,12 +1111,13 @@ discard block |
||
| 1062 | 1111 | $context['tables'][$id]['column_count'] = count($curElement); |
| 1063 | 1112 | |
| 1064 | 1113 | // Work out the rough width - for templates like the print template. Without this we might get funny tables. |
| 1065 | - if ($table['shading']['left'] && $table['width']['shaded'] != 'auto' && $table['width']['normal'] != 'auto') |
|
| 1066 | - $context['tables'][$id]['max_width'] = $table['width']['shaded'] + ($context['tables'][$id]['column_count'] - 1) * $table['width']['normal']; |
|
| 1067 | - elseif ($table['width']['normal'] != 'auto') |
|
| 1068 | - $context['tables'][$id]['max_width'] = $context['tables'][$id]['column_count'] * $table['width']['normal']; |
|
| 1069 | - else |
|
| 1070 | - $context['tables'][$id]['max_width'] = 'auto'; |
|
| 1114 | + if ($table['shading']['left'] && $table['width']['shaded'] != 'auto' && $table['width']['normal'] != 'auto') { |
|
| 1115 | + $context['tables'][$id]['max_width'] = $table['width']['shaded'] + ($context['tables'][$id]['column_count'] - 1) * $table['width']['normal']; |
|
| 1116 | + } elseif ($table['width']['normal'] != 'auto') { |
|
| 1117 | + $context['tables'][$id]['max_width'] = $context['tables'][$id]['column_count'] * $table['width']['normal']; |
|
| 1118 | + } else { |
|
| 1119 | + $context['tables'][$id]['max_width'] = 'auto'; |
|
| 1120 | + } |
|
| 1071 | 1121 | } |
| 1072 | 1122 | } |
| 1073 | 1123 | |
@@ -1092,10 +1142,11 @@ discard block |
||
| 1092 | 1142 | global $context; |
| 1093 | 1143 | |
| 1094 | 1144 | // Do we want to use the keys of the keys as the keys? :P |
| 1095 | - if ($reverse) |
|
| 1096 | - $context['keys'] = array_flip($keys); |
|
| 1097 | - else |
|
| 1098 | - $context['keys'] = $keys; |
|
| 1145 | + if ($reverse) { |
|
| 1146 | + $context['keys'] = array_flip($keys); |
|
| 1147 | + } else { |
|
| 1148 | + $context['keys'] = $keys; |
|
| 1149 | + } |
|
| 1099 | 1150 | |
| 1100 | 1151 | // Rows or columns? |
| 1101 | 1152 | $context['key_method'] = $method == 'rows' ? 'rows' : 'cols'; |