@@ -20,8 +20,9 @@ discard block |
||
| 20 | 20 | // ><html dir="ltr"><head><title>Error!</title></head><body>Sorry, this installer requires PHP!<div style="display: none;"> |
| 21 | 21 | |
| 22 | 22 | // Let's pull in useful classes |
| 23 | -if (!defined('SMF')) |
|
| 23 | +if (!defined('SMF')) { |
|
| 24 | 24 | define('SMF', 1); |
| 25 | +} |
|
| 25 | 26 | |
| 26 | 27 | require_once('Sources/Class-Package.php'); |
| 27 | 28 | |
@@ -63,10 +64,11 @@ discard block |
||
| 63 | 64 | |
| 64 | 65 | list ($charcode) = pg_fetch_row($request); |
| 65 | 66 | |
| 66 | - if ($charcode == 'UTF8') |
|
| 67 | - return true; |
|
| 68 | - else |
|
| 69 | - return false; |
|
| 67 | + if ($charcode == 'UTF8') { |
|
| 68 | + return true; |
|
| 69 | + } else { |
|
| 70 | + return false; |
|
| 71 | + } |
|
| 70 | 72 | }, |
| 71 | 73 | 'utf8_version' => '8.0', |
| 72 | 74 | 'utf8_version_check' => '$request = pg_query(\'SELECT version()\'); list ($version) = pg_fetch_row($request); list($pgl, $version) = explode(" ", $version); return $version;', |
@@ -76,12 +78,14 @@ discard block |
||
| 76 | 78 | $value = preg_replace('~[^A-Za-z0-9_\$]~', '', $value); |
| 77 | 79 | |
| 78 | 80 | // Is it reserved? |
| 79 | - if ($value == 'pg_') |
|
| 80 | - return $txt['error_db_prefix_reserved']; |
|
| 81 | + if ($value == 'pg_') { |
|
| 82 | + return $txt['error_db_prefix_reserved']; |
|
| 83 | + } |
|
| 81 | 84 | |
| 82 | 85 | // Is the prefix numeric? |
| 83 | - if (preg_match('~^\d~', $value)) |
|
| 84 | - return $txt['error_db_prefix_numeric']; |
|
| 86 | + if (preg_match('~^\d~', $value)) { |
|
| 87 | + return $txt['error_db_prefix_numeric']; |
|
| 88 | + } |
|
| 85 | 89 | |
| 86 | 90 | return true; |
| 87 | 91 | }, |
@@ -128,10 +132,11 @@ discard block |
||
| 128 | 132 | $incontext['skip'] = false; |
| 129 | 133 | |
| 130 | 134 | // Call the step and if it returns false that means pause! |
| 131 | - if (function_exists($step[2]) && $step[2]() === false) |
|
| 132 | - break; |
|
| 133 | - elseif (function_exists($step[2])) |
|
| 134 | - $incontext['current_step']++; |
|
| 135 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
| 136 | + break; |
|
| 137 | + } elseif (function_exists($step[2])) { |
|
| 138 | + $incontext['current_step']++; |
|
| 139 | + } |
|
| 135 | 140 | |
| 136 | 141 | // No warnings pass on. |
| 137 | 142 | $incontext['warning'] = ''; |
@@ -147,8 +152,9 @@ discard block |
||
| 147 | 152 | global $databases; |
| 148 | 153 | |
| 149 | 154 | // Just so people using older versions of PHP aren't left in the cold. |
| 150 | - if (!isset($_SERVER['PHP_SELF'])) |
|
| 151 | - $_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php'; |
|
| 155 | + if (!isset($_SERVER['PHP_SELF'])) { |
|
| 156 | + $_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php'; |
|
| 157 | + } |
|
| 152 | 158 | |
| 153 | 159 | // Enable error reporting for fatal errors. |
| 154 | 160 | error_reporting(E_ERROR | E_PARSE); |
@@ -164,21 +170,23 @@ discard block |
||
| 164 | 170 | { |
| 165 | 171 | ob_start(); |
| 166 | 172 | |
| 167 | - if (ini_get('session.save_handler') == 'user') |
|
| 168 | - @ini_set('session.save_handler', 'files'); |
|
| 169 | - if (function_exists('session_start')) |
|
| 170 | - @session_start(); |
|
| 171 | - } |
|
| 172 | - else |
|
| 173 | + if (ini_get('session.save_handler') == 'user') { |
|
| 174 | + @ini_set('session.save_handler', 'files'); |
|
| 175 | + } |
|
| 176 | + if (function_exists('session_start')) { |
|
| 177 | + @session_start(); |
|
| 178 | + } |
|
| 179 | + } else |
|
| 173 | 180 | { |
| 174 | 181 | ob_start('ob_gzhandler'); |
| 175 | 182 | |
| 176 | - if (ini_get('session.save_handler') == 'user') |
|
| 177 | - @ini_set('session.save_handler', 'files'); |
|
| 183 | + if (ini_get('session.save_handler') == 'user') { |
|
| 184 | + @ini_set('session.save_handler', 'files'); |
|
| 185 | + } |
|
| 178 | 186 | session_start(); |
| 179 | 187 | |
| 180 | - if (!headers_sent()) |
|
| 181 | - echo '<!DOCTYPE html> |
|
| 188 | + if (!headers_sent()) { |
|
| 189 | + echo '<!DOCTYPE html> |
|
| 182 | 190 | <html> |
| 183 | 191 | <head> |
| 184 | 192 | <title>', htmlspecialchars($_GET['pass_string']), '</title> |
@@ -187,14 +195,16 @@ discard block |
||
| 187 | 195 | <strong>', htmlspecialchars($_GET['pass_string']), '</strong> |
| 188 | 196 | </body> |
| 189 | 197 | </html>'; |
| 198 | + } |
|
| 190 | 199 | exit; |
| 191 | 200 | } |
| 192 | 201 | |
| 193 | 202 | // Add slashes, as long as they aren't already being added. |
| 194 | - if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) |
|
| 195 | - foreach ($_POST as $k => $v) |
|
| 203 | + if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) { |
|
| 204 | + foreach ($_POST as $k => $v) |
|
| 196 | 205 | if (strpos($k, 'password') === false && strpos($k, 'db_passwd') === false) |
| 197 | 206 | $_POST[$k] = addslashes($v); |
| 207 | + } |
|
| 198 | 208 | |
| 199 | 209 | // This is really quite simple; if ?delete is on the URL, delete the installer... |
| 200 | 210 | if (isset($_GET['delete'])) |
@@ -215,8 +225,7 @@ discard block |
||
| 215 | 225 | $ftp->close(); |
| 216 | 226 | |
| 217 | 227 | unset($_SESSION['installer_temp_ftp']); |
| 218 | - } |
|
| 219 | - else |
|
| 228 | + } else |
|
| 220 | 229 | { |
| 221 | 230 | @unlink(__FILE__); |
| 222 | 231 | |
@@ -230,10 +239,11 @@ discard block |
||
| 230 | 239 | // Now just redirect to a blank.png... |
| 231 | 240 | $secure = false; |
| 232 | 241 | |
| 233 | - if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') |
|
| 234 | - $secure = true; |
|
| 235 | - elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') |
|
| 236 | - $secure = true; |
|
| 242 | + if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { |
|
| 243 | + $secure = true; |
|
| 244 | + } elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') { |
|
| 245 | + $secure = true; |
|
| 246 | + } |
|
| 237 | 247 | |
| 238 | 248 | header('location: http' . ($secure ? 's' : '') . '://' . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT']) . dirname($_SERVER['PHP_SELF']) . '/Themes/default/images/blank.png'); |
| 239 | 249 | exit; |
@@ -244,10 +254,11 @@ discard block |
||
| 244 | 254 | { |
| 245 | 255 | // Get PHP's default timezone, if set |
| 246 | 256 | $ini_tz = ini_get('date.timezone'); |
| 247 | - if (!empty($ini_tz)) |
|
| 248 | - $timezone_id = $ini_tz; |
|
| 249 | - else |
|
| 250 | - $timezone_id = ''; |
|
| 257 | + if (!empty($ini_tz)) { |
|
| 258 | + $timezone_id = $ini_tz; |
|
| 259 | + } else { |
|
| 260 | + $timezone_id = ''; |
|
| 261 | + } |
|
| 251 | 262 | |
| 252 | 263 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
| 253 | 264 | if (!in_array($timezone_id, timezone_identifiers_list())) |
@@ -277,8 +288,9 @@ discard block |
||
| 277 | 288 | $dir = dir(dirname(__FILE__) . '/Themes/default/languages'); |
| 278 | 289 | while ($entry = $dir->read()) |
| 279 | 290 | { |
| 280 | - if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') |
|
| 281 | - $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
| 291 | + if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') { |
|
| 292 | + $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
| 293 | + } |
|
| 282 | 294 | } |
| 283 | 295 | $dir->close(); |
| 284 | 296 | } |
@@ -325,10 +337,11 @@ discard block |
||
| 325 | 337 | } |
| 326 | 338 | |
| 327 | 339 | // Override the language file? |
| 328 | - if (isset($_GET['lang_file'])) |
|
| 329 | - $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
| 330 | - elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) |
|
| 331 | - $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
| 340 | + if (isset($_GET['lang_file'])) { |
|
| 341 | + $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
| 342 | + } elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) { |
|
| 343 | + $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
| 344 | + } |
|
| 332 | 345 | |
| 333 | 346 | // Make sure it exists, if it doesn't reset it. |
| 334 | 347 | if (!isset($_SESSION['installer_temp_lang']) || preg_match('~[^\\w_\\-.]~', $_SESSION['installer_temp_lang']) === 1 || !file_exists(dirname(__FILE__) . '/Themes/default/languages/' . $_SESSION['installer_temp_lang'])) |
@@ -337,8 +350,9 @@ discard block |
||
| 337 | 350 | list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
| 338 | 351 | |
| 339 | 352 | // If we have english and some other language, use the other language. We Americans hate english :P. |
| 340 | - if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) |
|
| 341 | - list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
| 353 | + if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) { |
|
| 354 | + list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
| 355 | + } |
|
| 342 | 356 | } |
| 343 | 357 | |
| 344 | 358 | // And now include the actual language file itself. |
@@ -355,15 +369,18 @@ discard block |
||
| 355 | 369 | global $db_prefix, $db_connection, $sourcedir, $smcFunc, $modSettings; |
| 356 | 370 | global $db_server, $db_passwd, $db_type, $db_name, $db_user, $db_persist; |
| 357 | 371 | |
| 358 | - if (empty($sourcedir)) |
|
| 359 | - $sourcedir = dirname(__FILE__) . '/Sources'; |
|
| 372 | + if (empty($sourcedir)) { |
|
| 373 | + $sourcedir = dirname(__FILE__) . '/Sources'; |
|
| 374 | + } |
|
| 360 | 375 | |
| 361 | 376 | // Need this to check whether we need the database password. |
| 362 | 377 | require(dirname(__FILE__) . '/Settings.php'); |
| 363 | - if (!defined('SMF')) |
|
| 364 | - define('SMF', 1); |
|
| 365 | - if (empty($smcFunc)) |
|
| 366 | - $smcFunc = array(); |
|
| 378 | + if (!defined('SMF')) { |
|
| 379 | + define('SMF', 1); |
|
| 380 | + } |
|
| 381 | + if (empty($smcFunc)) { |
|
| 382 | + $smcFunc = array(); |
|
| 383 | + } |
|
| 367 | 384 | |
| 368 | 385 | $modSettings['disableQueryCheck'] = true; |
| 369 | 386 | |
@@ -371,8 +388,9 @@ discard block |
||
| 371 | 388 | if (!$db_connection) |
| 372 | 389 | { |
| 373 | 390 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
| 374 | - if (version_compare(PHP_VERSION, '5', '<')) |
|
| 375 | - require_once($sourcedir . '/Subs-Compat.php'); |
|
| 391 | + if (version_compare(PHP_VERSION, '5', '<')) { |
|
| 392 | + require_once($sourcedir . '/Subs-Compat.php'); |
|
| 393 | + } |
|
| 376 | 394 | |
| 377 | 395 | $db_options = array('persist' => $db_persist); |
| 378 | 396 | $port = ''; |
@@ -383,19 +401,20 @@ discard block |
||
| 383 | 401 | if ($db_type == 'mysql') |
| 384 | 402 | { |
| 385 | 403 | $port = ((int) $_POST['db_port'] == ini_get($db_type . 'default_port')) ? '' : (int) $_POST['db_port']; |
| 386 | - } |
|
| 387 | - elseif ($db_type == 'postgresql') |
|
| 404 | + } elseif ($db_type == 'postgresql') |
|
| 388 | 405 | { |
| 389 | 406 | // PostgreSQL doesn't have a default port setting in php.ini, so just check against the default |
| 390 | 407 | $port = ((int) $_POST['db_port'] == 5432) ? '' : (int) $_POST['db_port']; |
| 391 | 408 | } |
| 392 | 409 | } |
| 393 | 410 | |
| 394 | - if (!empty($port)) |
|
| 395 | - $db_options['port'] = $port; |
|
| 411 | + if (!empty($port)) { |
|
| 412 | + $db_options['port'] = $port; |
|
| 413 | + } |
|
| 396 | 414 | |
| 397 | - if (!$db_connection) |
|
| 398 | - $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options); |
|
| 415 | + if (!$db_connection) { |
|
| 416 | + $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options); |
|
| 417 | + } |
|
| 399 | 418 | } |
| 400 | 419 | } |
| 401 | 420 | |
@@ -423,8 +442,9 @@ discard block |
||
| 423 | 442 | // @todo REMOVE THIS!! |
| 424 | 443 | else |
| 425 | 444 | { |
| 426 | - if (function_exists('doStep' . $_GET['step'])) |
|
| 427 | - call_user_func('doStep' . $_GET['step']); |
|
| 445 | + if (function_exists('doStep' . $_GET['step'])) { |
|
| 446 | + call_user_func('doStep' . $_GET['step']); |
|
| 447 | + } |
|
| 428 | 448 | } |
| 429 | 449 | // Show the footer. |
| 430 | 450 | template_install_below(); |
@@ -442,8 +462,9 @@ discard block |
||
| 442 | 462 | $incontext['sub_template'] = 'welcome_message'; |
| 443 | 463 | |
| 444 | 464 | // Done the submission? |
| 445 | - if (isset($_POST['contbutt'])) |
|
| 446 | - return true; |
|
| 465 | + if (isset($_POST['contbutt'])) { |
|
| 466 | + return true; |
|
| 467 | + } |
|
| 447 | 468 | |
| 448 | 469 | // See if we think they have already installed it? |
| 449 | 470 | if (is_readable(dirname(__FILE__) . '/Settings.php')) |
@@ -451,14 +472,17 @@ discard block |
||
| 451 | 472 | $probably_installed = 0; |
| 452 | 473 | foreach (file(dirname(__FILE__) . '/Settings.php') as $line) |
| 453 | 474 | { |
| 454 | - if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) |
|
| 455 | - $probably_installed++; |
|
| 456 | - if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) |
|
| 457 | - $probably_installed++; |
|
| 475 | + if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) { |
|
| 476 | + $probably_installed++; |
|
| 477 | + } |
|
| 478 | + if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) { |
|
| 479 | + $probably_installed++; |
|
| 480 | + } |
|
| 458 | 481 | } |
| 459 | 482 | |
| 460 | - if ($probably_installed == 2) |
|
| 461 | - $incontext['warning'] = $txt['error_already_installed']; |
|
| 483 | + if ($probably_installed == 2) { |
|
| 484 | + $incontext['warning'] = $txt['error_already_installed']; |
|
| 485 | + } |
|
| 462 | 486 | } |
| 463 | 487 | |
| 464 | 488 | // Is some database support even compiled in? |
@@ -473,45 +497,54 @@ discard block |
||
| 473 | 497 | $databases[$key]['supported'] = false; |
| 474 | 498 | $notFoundSQLFile = true; |
| 475 | 499 | $txt['error_db_script_missing'] = sprintf($txt['error_db_script_missing'], 'install_' . $GLOBALS['db_script_version'] . '_' . $type . '.sql'); |
| 500 | + } else { |
|
| 501 | + $incontext['supported_databases'][] = $db; |
|
| 476 | 502 | } |
| 477 | - else |
|
| 478 | - $incontext['supported_databases'][] = $db; |
|
| 479 | 503 | } |
| 480 | 504 | } |
| 481 | 505 | |
| 482 | 506 | // Check the PHP version. |
| 483 | - if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>='))) |
|
| 484 | - $error = 'error_php_too_low'; |
|
| 507 | + if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>='))) { |
|
| 508 | + $error = 'error_php_too_low'; |
|
| 509 | + } |
|
| 485 | 510 | // Make sure we have a supported database |
| 486 | - elseif (empty($incontext['supported_databases'])) |
|
| 487 | - $error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing'; |
|
| 511 | + elseif (empty($incontext['supported_databases'])) { |
|
| 512 | + $error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing'; |
|
| 513 | + } |
|
| 488 | 514 | // How about session support? Some crazy sysadmin remove it? |
| 489 | - elseif (!function_exists('session_start')) |
|
| 490 | - $error = 'error_session_missing'; |
|
| 515 | + elseif (!function_exists('session_start')) { |
|
| 516 | + $error = 'error_session_missing'; |
|
| 517 | + } |
|
| 491 | 518 | // Make sure they uploaded all the files. |
| 492 | - elseif (!file_exists(dirname(__FILE__) . '/index.php')) |
|
| 493 | - $error = 'error_missing_files'; |
|
| 519 | + elseif (!file_exists(dirname(__FILE__) . '/index.php')) { |
|
| 520 | + $error = 'error_missing_files'; |
|
| 521 | + } |
|
| 494 | 522 | // Very simple check on the session.save_path for Windows. |
| 495 | 523 | // @todo Move this down later if they don't use database-driven sessions? |
| 496 | - elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') |
|
| 497 | - $error = 'error_session_save_path'; |
|
| 524 | + elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') { |
|
| 525 | + $error = 'error_session_save_path'; |
|
| 526 | + } |
|
| 498 | 527 | |
| 499 | 528 | // Since each of the three messages would look the same, anyway... |
| 500 | - if (isset($error)) |
|
| 501 | - $incontext['error'] = $txt[$error]; |
|
| 529 | + if (isset($error)) { |
|
| 530 | + $incontext['error'] = $txt[$error]; |
|
| 531 | + } |
|
| 502 | 532 | |
| 503 | 533 | // Mod_security blocks everything that smells funny. Let SMF handle security. |
| 504 | - if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) |
|
| 505 | - $incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again']; |
|
| 534 | + if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) { |
|
| 535 | + $incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again']; |
|
| 536 | + } |
|
| 506 | 537 | |
| 507 | 538 | // Confirm mbstring is loaded... |
| 508 | - if (!extension_loaded('mbstring')) |
|
| 509 | - $incontext['error'] = $txt['install_no_mbstring']; |
|
| 539 | + if (!extension_loaded('mbstring')) { |
|
| 540 | + $incontext['error'] = $txt['install_no_mbstring']; |
|
| 541 | + } |
|
| 510 | 542 | |
| 511 | 543 | // Check for https stream support. |
| 512 | 544 | $supported_streams = stream_get_wrappers(); |
| 513 | - if (!in_array('https', $supported_streams)) |
|
| 514 | - $incontext['warning'] = $txt['install_no_https']; |
|
| 545 | + if (!in_array('https', $supported_streams)) { |
|
| 546 | + $incontext['warning'] = $txt['install_no_https']; |
|
| 547 | + } |
|
| 515 | 548 | |
| 516 | 549 | return false; |
| 517 | 550 | } |
@@ -536,12 +569,14 @@ discard block |
||
| 536 | 569 | 'Settings_bak.php', |
| 537 | 570 | ); |
| 538 | 571 | |
| 539 | - foreach ($incontext['detected_languages'] as $lang => $temp) |
|
| 540 | - $extra_files[] = 'Themes/default/languages/' . $lang; |
|
| 572 | + foreach ($incontext['detected_languages'] as $lang => $temp) { |
|
| 573 | + $extra_files[] = 'Themes/default/languages/' . $lang; |
|
| 574 | + } |
|
| 541 | 575 | |
| 542 | 576 | // With mod_security installed, we could attempt to fix it with .htaccess. |
| 543 | - if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) |
|
| 544 | - $writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.'; |
|
| 577 | + if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) { |
|
| 578 | + $writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.'; |
|
| 579 | + } |
|
| 545 | 580 | |
| 546 | 581 | $failed_files = array(); |
| 547 | 582 | |
@@ -553,20 +588,23 @@ discard block |
||
| 553 | 588 | foreach ($writable_files as $file) |
| 554 | 589 | { |
| 555 | 590 | // Some files won't exist, try to address up front |
| 556 | - if (!file_exists(dirname(__FILE__) . '/' . $file)) |
|
| 557 | - @touch(dirname(__FILE__) . '/' . $file); |
|
| 591 | + if (!file_exists(dirname(__FILE__) . '/' . $file)) { |
|
| 592 | + @touch(dirname(__FILE__) . '/' . $file); |
|
| 593 | + } |
|
| 558 | 594 | // NOW do the writable check... |
| 559 | 595 | if (!is_writable(dirname(__FILE__) . '/' . $file)) |
| 560 | 596 | { |
| 561 | 597 | @chmod(dirname(__FILE__) . '/' . $file, 0755); |
| 562 | 598 | |
| 563 | 599 | // Well, 755 hopefully worked... if not, try 777. |
| 564 | - if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) |
|
| 565 | - $failed_files[] = $file; |
|
| 600 | + if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) { |
|
| 601 | + $failed_files[] = $file; |
|
| 602 | + } |
|
| 566 | 603 | } |
| 567 | 604 | } |
| 568 | - foreach ($extra_files as $file) |
|
| 569 | - @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
| 605 | + foreach ($extra_files as $file) { |
|
| 606 | + @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
| 607 | + } |
|
| 570 | 608 | } |
| 571 | 609 | // Windows is trickier. Let's try opening for r+... |
| 572 | 610 | else |
@@ -576,30 +614,35 @@ discard block |
||
| 576 | 614 | foreach ($writable_files as $file) |
| 577 | 615 | { |
| 578 | 616 | // Folders can't be opened for write... but the index.php in them can ;) |
| 579 | - if (is_dir(dirname(__FILE__) . '/' . $file)) |
|
| 580 | - $file .= '/index.php'; |
|
| 617 | + if (is_dir(dirname(__FILE__) . '/' . $file)) { |
|
| 618 | + $file .= '/index.php'; |
|
| 619 | + } |
|
| 581 | 620 | |
| 582 | 621 | // Funny enough, chmod actually does do something on windows - it removes the read only attribute. |
| 583 | 622 | @chmod(dirname(__FILE__) . '/' . $file, 0777); |
| 584 | 623 | $fp = @fopen(dirname(__FILE__) . '/' . $file, 'r+'); |
| 585 | 624 | |
| 586 | 625 | // Hmm, okay, try just for write in that case... |
| 587 | - if (!is_resource($fp)) |
|
| 588 | - $fp = @fopen(dirname(__FILE__) . '/' . $file, 'w'); |
|
| 626 | + if (!is_resource($fp)) { |
|
| 627 | + $fp = @fopen(dirname(__FILE__) . '/' . $file, 'w'); |
|
| 628 | + } |
|
| 589 | 629 | |
| 590 | - if (!is_resource($fp)) |
|
| 591 | - $failed_files[] = $file; |
|
| 630 | + if (!is_resource($fp)) { |
|
| 631 | + $failed_files[] = $file; |
|
| 632 | + } |
|
| 592 | 633 | |
| 593 | 634 | @fclose($fp); |
| 594 | 635 | } |
| 595 | - foreach ($extra_files as $file) |
|
| 596 | - @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
| 636 | + foreach ($extra_files as $file) { |
|
| 637 | + @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
| 638 | + } |
|
| 597 | 639 | } |
| 598 | 640 | |
| 599 | 641 | $failure = count($failed_files) >= 1; |
| 600 | 642 | |
| 601 | - if (!isset($_SERVER)) |
|
| 602 | - return !$failure; |
|
| 643 | + if (!isset($_SERVER)) { |
|
| 644 | + return !$failure; |
|
| 645 | + } |
|
| 603 | 646 | |
| 604 | 647 | // Put the list into context. |
| 605 | 648 | $incontext['failed_files'] = $failed_files; |
@@ -647,19 +690,23 @@ discard block |
||
| 647 | 690 | |
| 648 | 691 | if (!isset($ftp) || $ftp->error !== false) |
| 649 | 692 | { |
| 650 | - if (!isset($ftp)) |
|
| 651 | - $ftp = new ftp_connection(null); |
|
| 693 | + if (!isset($ftp)) { |
|
| 694 | + $ftp = new ftp_connection(null); |
|
| 695 | + } |
|
| 652 | 696 | // Save the error so we can mess with listing... |
| 653 | - elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) |
|
| 654 | - $incontext['ftp_errors'][] = $ftp->last_message; |
|
| 697 | + elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) { |
|
| 698 | + $incontext['ftp_errors'][] = $ftp->last_message; |
|
| 699 | + } |
|
| 655 | 700 | |
| 656 | 701 | list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__)); |
| 657 | 702 | |
| 658 | - if (empty($_POST['ftp_path']) && $found_path) |
|
| 659 | - $_POST['ftp_path'] = $detect_path; |
|
| 703 | + if (empty($_POST['ftp_path']) && $found_path) { |
|
| 704 | + $_POST['ftp_path'] = $detect_path; |
|
| 705 | + } |
|
| 660 | 706 | |
| 661 | - if (!isset($_POST['ftp_username'])) |
|
| 662 | - $_POST['ftp_username'] = $username; |
|
| 707 | + if (!isset($_POST['ftp_username'])) { |
|
| 708 | + $_POST['ftp_username'] = $username; |
|
| 709 | + } |
|
| 663 | 710 | |
| 664 | 711 | // Set the username etc, into context. |
| 665 | 712 | $incontext['ftp'] = array( |
@@ -671,8 +718,7 @@ discard block |
||
| 671 | 718 | ); |
| 672 | 719 | |
| 673 | 720 | return false; |
| 674 | - } |
|
| 675 | - else |
|
| 721 | + } else |
|
| 676 | 722 | { |
| 677 | 723 | $_SESSION['installer_temp_ftp'] = array( |
| 678 | 724 | 'server' => $_POST['ftp_server'], |
@@ -686,10 +732,12 @@ discard block |
||
| 686 | 732 | |
| 687 | 733 | foreach ($failed_files as $file) |
| 688 | 734 | { |
| 689 | - if (!is_writable(dirname(__FILE__) . '/' . $file)) |
|
| 690 | - $ftp->chmod($file, 0755); |
|
| 691 | - if (!is_writable(dirname(__FILE__) . '/' . $file)) |
|
| 692 | - $ftp->chmod($file, 0777); |
|
| 735 | + if (!is_writable(dirname(__FILE__) . '/' . $file)) { |
|
| 736 | + $ftp->chmod($file, 0755); |
|
| 737 | + } |
|
| 738 | + if (!is_writable(dirname(__FILE__) . '/' . $file)) { |
|
| 739 | + $ftp->chmod($file, 0777); |
|
| 740 | + } |
|
| 693 | 741 | if (!is_writable(dirname(__FILE__) . '/' . $file)) |
| 694 | 742 | { |
| 695 | 743 | $failed_files_updated[] = $file; |
@@ -745,15 +793,17 @@ discard block |
||
| 745 | 793 | |
| 746 | 794 | if (!$foundOne) |
| 747 | 795 | { |
| 748 | - if (isset($db['default_host'])) |
|
| 749 | - $incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost'; |
|
| 796 | + if (isset($db['default_host'])) { |
|
| 797 | + $incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost'; |
|
| 798 | + } |
|
| 750 | 799 | if (isset($db['default_user'])) |
| 751 | 800 | { |
| 752 | 801 | $incontext['db']['user'] = ini_get($db['default_user']); |
| 753 | 802 | $incontext['db']['name'] = ini_get($db['default_user']); |
| 754 | 803 | } |
| 755 | - if (isset($db['default_password'])) |
|
| 756 | - $incontext['db']['pass'] = ini_get($db['default_password']); |
|
| 804 | + if (isset($db['default_password'])) { |
|
| 805 | + $incontext['db']['pass'] = ini_get($db['default_password']); |
|
| 806 | + } |
|
| 757 | 807 | |
| 758 | 808 | // For simplicity and less confusion, leave the port blank by default |
| 759 | 809 | $incontext['db']['port'] = ''; |
@@ -772,10 +822,10 @@ discard block |
||
| 772 | 822 | $incontext['db']['server'] = $_POST['db_server']; |
| 773 | 823 | $incontext['db']['prefix'] = $_POST['db_prefix']; |
| 774 | 824 | |
| 775 | - if (!empty($_POST['db_port'])) |
|
| 776 | - $incontext['db']['port'] = $_POST['db_port']; |
|
| 777 | - } |
|
| 778 | - else |
|
| 825 | + if (!empty($_POST['db_port'])) { |
|
| 826 | + $incontext['db']['port'] = $_POST['db_port']; |
|
| 827 | + } |
|
| 828 | + } else |
|
| 779 | 829 | { |
| 780 | 830 | $incontext['db']['prefix'] = 'smf_'; |
| 781 | 831 | } |
@@ -811,10 +861,11 @@ discard block |
||
| 811 | 861 | if (!empty($_POST['db_port'])) |
| 812 | 862 | { |
| 813 | 863 | // For MySQL, we can get the "default port" from PHP. PostgreSQL has no such option though. |
| 814 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) |
|
| 815 | - $vars['db_port'] = (int) $_POST['db_port']; |
|
| 816 | - elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) |
|
| 817 | - $vars['db_port'] = (int) $_POST['db_port']; |
|
| 864 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) { |
|
| 865 | + $vars['db_port'] = (int) $_POST['db_port']; |
|
| 866 | + } elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) { |
|
| 867 | + $vars['db_port'] = (int) $_POST['db_port']; |
|
| 868 | + } |
|
| 818 | 869 | } |
| 819 | 870 | |
| 820 | 871 | // God I hope it saved! |
@@ -827,8 +878,9 @@ discard block |
||
| 827 | 878 | // Make sure it works. |
| 828 | 879 | require(dirname(__FILE__) . '/Settings.php'); |
| 829 | 880 | |
| 830 | - if (empty($sourcedir)) |
|
| 831 | - $sourcedir = dirname(__FILE__) . '/Sources'; |
|
| 881 | + if (empty($sourcedir)) { |
|
| 882 | + $sourcedir = dirname(__FILE__) . '/Sources'; |
|
| 883 | + } |
|
| 832 | 884 | |
| 833 | 885 | // Better find the database file! |
| 834 | 886 | if (!file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
@@ -838,18 +890,21 @@ discard block |
||
| 838 | 890 | } |
| 839 | 891 | |
| 840 | 892 | // Now include it for database functions! |
| 841 | - if (!defined('SMF')) |
|
| 842 | - define('SMF', 1); |
|
| 893 | + if (!defined('SMF')) { |
|
| 894 | + define('SMF', 1); |
|
| 895 | + } |
|
| 843 | 896 | |
| 844 | 897 | $modSettings['disableQueryCheck'] = true; |
| 845 | - if (empty($smcFunc)) |
|
| 846 | - $smcFunc = array(); |
|
| 898 | + if (empty($smcFunc)) { |
|
| 899 | + $smcFunc = array(); |
|
| 900 | + } |
|
| 847 | 901 | |
| 848 | 902 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
| 849 | 903 | |
| 850 | 904 | // What - running PHP4? The shame! |
| 851 | - if (version_compare(PHP_VERSION, '5', '<')) |
|
| 852 | - require_once($sourcedir . '/Subs-Compat.php'); |
|
| 905 | + if (version_compare(PHP_VERSION, '5', '<')) { |
|
| 906 | + require_once($sourcedir . '/Subs-Compat.php'); |
|
| 907 | + } |
|
| 853 | 908 | |
| 854 | 909 | // Attempt a connection. |
| 855 | 910 | $needsDB = !empty($databases[$db_type]['always_has_db']); |
@@ -937,12 +992,14 @@ discard block |
||
| 937 | 992 | $incontext['page_title'] = $txt['install_settings']; |
| 938 | 993 | |
| 939 | 994 | // Let's see if we got the database type correct. |
| 940 | - if (isset($_POST['db_type'], $databases[$_POST['db_type']])) |
|
| 941 | - $db_type = $_POST['db_type']; |
|
| 995 | + if (isset($_POST['db_type'], $databases[$_POST['db_type']])) { |
|
| 996 | + $db_type = $_POST['db_type']; |
|
| 997 | + } |
|
| 942 | 998 | |
| 943 | 999 | // Else we'd better be able to get the connection. |
| 944 | - else |
|
| 945 | - load_database(); |
|
| 1000 | + else { |
|
| 1001 | + load_database(); |
|
| 1002 | + } |
|
| 946 | 1003 | |
| 947 | 1004 | $db_type = isset($_POST['db_type']) ? $_POST['db_type'] : $db_type; |
| 948 | 1005 | |
@@ -951,10 +1008,11 @@ discard block |
||
| 951 | 1008 | |
| 952 | 1009 | $secure = false; |
| 953 | 1010 | |
| 954 | - if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') |
|
| 955 | - $secure = true; |
|
| 956 | - elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') |
|
| 957 | - $secure = true; |
|
| 1011 | + if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { |
|
| 1012 | + $secure = true; |
|
| 1013 | + } elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') { |
|
| 1014 | + $secure = true; |
|
| 1015 | + } |
|
| 958 | 1016 | |
| 959 | 1017 | // Now, to put what we've learned together... and add a path. |
| 960 | 1018 | $incontext['detected_url'] = 'http' . ($secure ? 's' : '') . '://' . $host . substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], '/')); |
@@ -986,18 +1044,21 @@ discard block |
||
| 986 | 1044 | // Submitting? |
| 987 | 1045 | if (isset($_POST['boardurl'])) |
| 988 | 1046 | { |
| 989 | - if (substr($_POST['boardurl'], -10) == '/index.php') |
|
| 990 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
| 991 | - elseif (substr($_POST['boardurl'], -1) == '/') |
|
| 992 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
| 993 | - if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') |
|
| 994 | - $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
| 1047 | + if (substr($_POST['boardurl'], -10) == '/index.php') { |
|
| 1048 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
| 1049 | + } elseif (substr($_POST['boardurl'], -1) == '/') { |
|
| 1050 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
| 1051 | + } |
|
| 1052 | + if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') { |
|
| 1053 | + $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
| 1054 | + } |
|
| 995 | 1055 | |
| 996 | 1056 | //Make sure boardurl is aligned with ssl setting |
| 997 | - if (empty($_POST['force_ssl'])) |
|
| 998 | - $_POST['boardurl'] = strtr($_POST['boardurl'], array('https://' => 'http://')); |
|
| 999 | - else |
|
| 1000 | - $_POST['boardurl'] = strtr($_POST['boardurl'], array('http://' => 'https://')); |
|
| 1057 | + if (empty($_POST['force_ssl'])) { |
|
| 1058 | + $_POST['boardurl'] = strtr($_POST['boardurl'], array('https://' => 'http://')); |
|
| 1059 | + } else { |
|
| 1060 | + $_POST['boardurl'] = strtr($_POST['boardurl'], array('http://' => 'https://')); |
|
| 1061 | + } |
|
| 1001 | 1062 | |
| 1002 | 1063 | // Save these variables. |
| 1003 | 1064 | $vars = array( |
@@ -1036,10 +1097,10 @@ discard block |
||
| 1036 | 1097 | { |
| 1037 | 1098 | $incontext['error'] = sprintf($txt['error_utf8_version'], $databases[$db_type]['utf8_version']); |
| 1038 | 1099 | return false; |
| 1039 | - } |
|
| 1040 | - else |
|
| 1041 | - // Set the character set here. |
|
| 1100 | + } else { |
|
| 1101 | + // Set the character set here. |
|
| 1042 | 1102 | updateSettingsFile(array('db_character_set' => 'utf8')); |
| 1103 | + } |
|
| 1043 | 1104 | } |
| 1044 | 1105 | |
| 1045 | 1106 | // Good, skip on. |
@@ -1059,8 +1120,9 @@ discard block |
||
| 1059 | 1120 | $incontext['continue'] = 1; |
| 1060 | 1121 | |
| 1061 | 1122 | // Already done? |
| 1062 | - if (isset($_POST['pop_done'])) |
|
| 1063 | - return true; |
|
| 1123 | + if (isset($_POST['pop_done'])) { |
|
| 1124 | + return true; |
|
| 1125 | + } |
|
| 1064 | 1126 | |
| 1065 | 1127 | // Reload settings. |
| 1066 | 1128 | require(dirname(__FILE__) . '/Settings.php'); |
@@ -1078,8 +1140,9 @@ discard block |
||
| 1078 | 1140 | $modSettings = array(); |
| 1079 | 1141 | if ($result !== false) |
| 1080 | 1142 | { |
| 1081 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 1082 | - $modSettings[$row['variable']] = $row['value']; |
|
| 1143 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 1144 | + $modSettings[$row['variable']] = $row['value']; |
|
| 1145 | + } |
|
| 1083 | 1146 | $smcFunc['db_free_result']($result); |
| 1084 | 1147 | |
| 1085 | 1148 | // Do they match? If so, this is just a refresh so charge on! |
@@ -1092,20 +1155,22 @@ discard block |
||
| 1092 | 1155 | $modSettings['disableQueryCheck'] = true; |
| 1093 | 1156 | |
| 1094 | 1157 | // If doing UTF8, select it. PostgreSQL requires passing it as a string... |
| 1095 | - if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) |
|
| 1096 | - $smcFunc['db_query']('', ' |
|
| 1158 | + if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) { |
|
| 1159 | + $smcFunc['db_query']('', ' |
|
| 1097 | 1160 | SET NAMES {string:utf8}', |
| 1098 | 1161 | array( |
| 1099 | 1162 | 'db_error_skip' => true, |
| 1100 | 1163 | 'utf8' => 'utf8', |
| 1101 | 1164 | ) |
| 1102 | 1165 | ); |
| 1166 | + } |
|
| 1103 | 1167 | |
| 1104 | 1168 | // Windows likes to leave the trailing slash, which yields to C:\path\to\SMF\/attachments... |
| 1105 | - if (substr(__DIR__, -1) == '\\') |
|
| 1106 | - $attachdir = __DIR__ . 'attachments'; |
|
| 1107 | - else |
|
| 1108 | - $attachdir = __DIR__ . '/attachments'; |
|
| 1169 | + if (substr(__DIR__, -1) == '\\') { |
|
| 1170 | + $attachdir = __DIR__ . 'attachments'; |
|
| 1171 | + } else { |
|
| 1172 | + $attachdir = __DIR__ . '/attachments'; |
|
| 1173 | + } |
|
| 1109 | 1174 | |
| 1110 | 1175 | $replaces = array( |
| 1111 | 1176 | '{$db_prefix}' => $db_prefix, |
@@ -1122,8 +1187,9 @@ discard block |
||
| 1122 | 1187 | |
| 1123 | 1188 | foreach ($txt as $key => $value) |
| 1124 | 1189 | { |
| 1125 | - if (substr($key, 0, 8) == 'default_') |
|
| 1126 | - $replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value); |
|
| 1190 | + if (substr($key, 0, 8) == 'default_') { |
|
| 1191 | + $replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value); |
|
| 1192 | + } |
|
| 1127 | 1193 | } |
| 1128 | 1194 | $replaces['{$default_reserved_names}'] = strtr($replaces['{$default_reserved_names}'], array('\\\\n' => '\\n')); |
| 1129 | 1195 | |
@@ -1138,8 +1204,9 @@ discard block |
||
| 1138 | 1204 | |
| 1139 | 1205 | while ($row = $smcFunc['db_fetch_assoc']($get_engines)) |
| 1140 | 1206 | { |
| 1141 | - if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') |
|
| 1142 | - $engines[] = $row['Engine']; |
|
| 1207 | + if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') { |
|
| 1208 | + $engines[] = $row['Engine']; |
|
| 1209 | + } |
|
| 1143 | 1210 | } |
| 1144 | 1211 | |
| 1145 | 1212 | // Done with this now |
@@ -1163,8 +1230,7 @@ discard block |
||
| 1163 | 1230 | $replaces['START TRANSACTION;'] = ''; |
| 1164 | 1231 | $replaces['COMMIT;'] = ''; |
| 1165 | 1232 | } |
| 1166 | - } |
|
| 1167 | - else |
|
| 1233 | + } else |
|
| 1168 | 1234 | { |
| 1169 | 1235 | $has_innodb = false; |
| 1170 | 1236 | } |
@@ -1186,21 +1252,24 @@ discard block |
||
| 1186 | 1252 | foreach ($sql_lines as $count => $line) |
| 1187 | 1253 | { |
| 1188 | 1254 | // No comments allowed! |
| 1189 | - if (substr(trim($line), 0, 1) != '#') |
|
| 1190 | - $current_statement .= "\n" . rtrim($line); |
|
| 1255 | + if (substr(trim($line), 0, 1) != '#') { |
|
| 1256 | + $current_statement .= "\n" . rtrim($line); |
|
| 1257 | + } |
|
| 1191 | 1258 | |
| 1192 | 1259 | // Is this the end of the query string? |
| 1193 | - if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) |
|
| 1194 | - continue; |
|
| 1260 | + if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) { |
|
| 1261 | + continue; |
|
| 1262 | + } |
|
| 1195 | 1263 | |
| 1196 | 1264 | // Does this table already exist? If so, don't insert more data into it! |
| 1197 | 1265 | if (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) != 0 && in_array($match[1], $exists)) |
| 1198 | 1266 | { |
| 1199 | 1267 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
| 1200 | - if (!empty($matches[0])) |
|
| 1201 | - $incontext['sql_results']['insert_dups'] += count($matches[0]); |
|
| 1202 | - else |
|
| 1203 | - $incontext['sql_results']['insert_dups']++; |
|
| 1268 | + if (!empty($matches[0])) { |
|
| 1269 | + $incontext['sql_results']['insert_dups'] += count($matches[0]); |
|
| 1270 | + } else { |
|
| 1271 | + $incontext['sql_results']['insert_dups']++; |
|
| 1272 | + } |
|
| 1204 | 1273 | |
| 1205 | 1274 | $current_statement = ''; |
| 1206 | 1275 | continue; |
@@ -1209,8 +1278,9 @@ discard block |
||
| 1209 | 1278 | if ($smcFunc['db_query']('', $current_statement, array('security_override' => true, 'db_error_skip' => true), $db_connection) === false) |
| 1210 | 1279 | { |
| 1211 | 1280 | // Use the appropriate function based on the DB type |
| 1212 | - if ($db_type == 'mysql' || $db_type == 'mysqli') |
|
| 1213 | - $db_errorno = $db_type . '_errno'; |
|
| 1281 | + if ($db_type == 'mysql' || $db_type == 'mysqli') { |
|
| 1282 | + $db_errorno = $db_type . '_errno'; |
|
| 1283 | + } |
|
| 1214 | 1284 | |
| 1215 | 1285 | // Error 1050: Table already exists! |
| 1216 | 1286 | // @todo Needs to be made better! |
@@ -1225,18 +1295,18 @@ discard block |
||
| 1225 | 1295 | // MySQLi requires a connection object. It's optional with MySQL and Postgres |
| 1226 | 1296 | $incontext['failures'][$count] = $smcFunc['db_error']($db_connection); |
| 1227 | 1297 | } |
| 1228 | - } |
|
| 1229 | - else |
|
| 1298 | + } else |
|
| 1230 | 1299 | { |
| 1231 | - if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
| 1232 | - $incontext['sql_results']['tables']++; |
|
| 1233 | - elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
| 1300 | + if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) { |
|
| 1301 | + $incontext['sql_results']['tables']++; |
|
| 1302 | + } elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
| 1234 | 1303 | { |
| 1235 | 1304 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
| 1236 | - if (!empty($matches[0])) |
|
| 1237 | - $incontext['sql_results']['inserts'] += count($matches[0]); |
|
| 1238 | - else |
|
| 1239 | - $incontext['sql_results']['inserts']++; |
|
| 1305 | + if (!empty($matches[0])) { |
|
| 1306 | + $incontext['sql_results']['inserts'] += count($matches[0]); |
|
| 1307 | + } else { |
|
| 1308 | + $incontext['sql_results']['inserts']++; |
|
| 1309 | + } |
|
| 1240 | 1310 | } |
| 1241 | 1311 | } |
| 1242 | 1312 | |
@@ -1249,15 +1319,17 @@ discard block |
||
| 1249 | 1319 | // Sort out the context for the SQL. |
| 1250 | 1320 | foreach ($incontext['sql_results'] as $key => $number) |
| 1251 | 1321 | { |
| 1252 | - if ($number == 0) |
|
| 1253 | - unset($incontext['sql_results'][$key]); |
|
| 1254 | - else |
|
| 1255 | - $incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number); |
|
| 1322 | + if ($number == 0) { |
|
| 1323 | + unset($incontext['sql_results'][$key]); |
|
| 1324 | + } else { |
|
| 1325 | + $incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number); |
|
| 1326 | + } |
|
| 1256 | 1327 | } |
| 1257 | 1328 | |
| 1258 | 1329 | // Make sure UTF will be used globally. |
| 1259 | - if ((!empty($databases[$db_type]['utf8_support']) && !empty($databases[$db_type]['utf8_required'])) || (empty($databases[$db_type]['utf8_required']) && !empty($databases[$db_type]['utf8_support']) && isset($_POST['utf8']))) |
|
| 1260 | - $newSettings[] = array('global_character_set', 'UTF-8'); |
|
| 1330 | + if ((!empty($databases[$db_type]['utf8_support']) && !empty($databases[$db_type]['utf8_required'])) || (empty($databases[$db_type]['utf8_required']) && !empty($databases[$db_type]['utf8_support']) && isset($_POST['utf8']))) { |
|
| 1331 | + $newSettings[] = array('global_character_set', 'UTF-8'); |
|
| 1332 | + } |
|
| 1261 | 1333 | |
| 1262 | 1334 | // Auto-detect local & global cookie settings |
| 1263 | 1335 | $url_parts = parse_url($boardurl); |
@@ -1286,15 +1358,19 @@ discard block |
||
| 1286 | 1358 | |
| 1287 | 1359 | // Look for subfolder, if found, set localCookie |
| 1288 | 1360 | // Checking for len > 1 ensures you don't have just a slash... |
| 1289 | - if (!empty($url_parts['path']) && strlen($url_parts['path']) > 1) |
|
| 1290 | - $localCookies = '1'; |
|
| 1361 | + if (!empty($url_parts['path']) && strlen($url_parts['path']) > 1) { |
|
| 1362 | + $localCookies = '1'; |
|
| 1363 | + } |
|
| 1291 | 1364 | |
| 1292 | - if (isset($globalCookies)) |
|
| 1293 | - $newSettings[] = array('globalCookies', $globalCookies); |
|
| 1294 | - if (isset($globalCookiesDomain)) |
|
| 1295 | - $newSettings[] = array('globalCookiesDomain', $globalCookiesDomain); |
|
| 1296 | - if (isset($localCookies)) |
|
| 1297 | - $newSettings[] = array('localCookies', $localCookies); |
|
| 1365 | + if (isset($globalCookies)) { |
|
| 1366 | + $newSettings[] = array('globalCookies', $globalCookies); |
|
| 1367 | + } |
|
| 1368 | + if (isset($globalCookiesDomain)) { |
|
| 1369 | + $newSettings[] = array('globalCookiesDomain', $globalCookiesDomain); |
|
| 1370 | + } |
|
| 1371 | + if (isset($localCookies)) { |
|
| 1372 | + $newSettings[] = array('localCookies', $localCookies); |
|
| 1373 | + } |
|
| 1298 | 1374 | } |
| 1299 | 1375 | |
| 1300 | 1376 | // Are we allowing stat collection? |
@@ -1312,16 +1388,17 @@ discard block |
||
| 1312 | 1388 | fwrite($fp, $out); |
| 1313 | 1389 | |
| 1314 | 1390 | $return_data = ''; |
| 1315 | - while (!feof($fp)) |
|
| 1316 | - $return_data .= fgets($fp, 128); |
|
| 1391 | + while (!feof($fp)) { |
|
| 1392 | + $return_data .= fgets($fp, 128); |
|
| 1393 | + } |
|
| 1317 | 1394 | |
| 1318 | 1395 | fclose($fp); |
| 1319 | 1396 | |
| 1320 | 1397 | // Get the unique site ID. |
| 1321 | 1398 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
| 1322 | 1399 | |
| 1323 | - if (!empty($ID[1])) |
|
| 1324 | - $smcFunc['db_insert']('replace', |
|
| 1400 | + if (!empty($ID[1])) { |
|
| 1401 | + $smcFunc['db_insert']('replace', |
|
| 1325 | 1402 | $db_prefix . 'settings', |
| 1326 | 1403 | array('variable' => 'string', 'value' => 'string'), |
| 1327 | 1404 | array( |
@@ -1330,11 +1407,12 @@ discard block |
||
| 1330 | 1407 | ), |
| 1331 | 1408 | array('variable') |
| 1332 | 1409 | ); |
| 1410 | + } |
|
| 1333 | 1411 | } |
| 1334 | 1412 | } |
| 1335 | 1413 | // Don't remove stat collection unless we unchecked the box for real, not from the loop. |
| 1336 | - elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) |
|
| 1337 | - $smcFunc['db_query']('', ' |
|
| 1414 | + elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) { |
|
| 1415 | + $smcFunc['db_query']('', ' |
|
| 1338 | 1416 | DELETE FROM {db_prefix}settings |
| 1339 | 1417 | WHERE variable = {string:enable_sm_stats}', |
| 1340 | 1418 | array( |
@@ -1342,20 +1420,23 @@ discard block |
||
| 1342 | 1420 | 'db_error_skip' => true, |
| 1343 | 1421 | ) |
| 1344 | 1422 | ); |
| 1423 | + } |
|
| 1345 | 1424 | |
| 1346 | 1425 | // Are we enabling SSL? |
| 1347 | - if (!empty($_POST['force_ssl'])) |
|
| 1348 | - $newSettings[] = array('force_ssl', 1); |
|
| 1426 | + if (!empty($_POST['force_ssl'])) { |
|
| 1427 | + $newSettings[] = array('force_ssl', 1); |
|
| 1428 | + } |
|
| 1349 | 1429 | |
| 1350 | 1430 | // Setting a timezone is required. |
| 1351 | 1431 | if (!isset($modSettings['default_timezone']) && function_exists('date_default_timezone_set')) |
| 1352 | 1432 | { |
| 1353 | 1433 | // Get PHP's default timezone, if set |
| 1354 | 1434 | $ini_tz = ini_get('date.timezone'); |
| 1355 | - if (!empty($ini_tz)) |
|
| 1356 | - $timezone_id = $ini_tz; |
|
| 1357 | - else |
|
| 1358 | - $timezone_id = ''; |
|
| 1435 | + if (!empty($ini_tz)) { |
|
| 1436 | + $timezone_id = $ini_tz; |
|
| 1437 | + } else { |
|
| 1438 | + $timezone_id = ''; |
|
| 1439 | + } |
|
| 1359 | 1440 | |
| 1360 | 1441 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
| 1361 | 1442 | if (!in_array($timezone_id, timezone_identifiers_list())) |
@@ -1364,8 +1445,9 @@ discard block |
||
| 1364 | 1445 | $timezone_id = timezone_name_from_abbr('', $server_offset, 0); |
| 1365 | 1446 | } |
| 1366 | 1447 | |
| 1367 | - if (date_default_timezone_set($timezone_id)) |
|
| 1368 | - $newSettings[] = array('default_timezone', $timezone_id); |
|
| 1448 | + if (date_default_timezone_set($timezone_id)) { |
|
| 1449 | + $newSettings[] = array('default_timezone', $timezone_id); |
|
| 1450 | + } |
|
| 1369 | 1451 | } |
| 1370 | 1452 | |
| 1371 | 1453 | if (!empty($newSettings)) |
@@ -1396,16 +1478,18 @@ discard block |
||
| 1396 | 1478 | } |
| 1397 | 1479 | |
| 1398 | 1480 | // MySQL specific stuff |
| 1399 | - if (substr($db_type, 0, 5) != 'mysql') |
|
| 1400 | - return false; |
|
| 1481 | + if (substr($db_type, 0, 5) != 'mysql') { |
|
| 1482 | + return false; |
|
| 1483 | + } |
|
| 1401 | 1484 | |
| 1402 | 1485 | // Find database user privileges. |
| 1403 | 1486 | $privs = array(); |
| 1404 | 1487 | $get_privs = $smcFunc['db_query']('', 'SHOW PRIVILEGES', array()); |
| 1405 | 1488 | while ($row = $smcFunc['db_fetch_assoc']($get_privs)) |
| 1406 | 1489 | { |
| 1407 | - if ($row['Privilege'] == 'Alter') |
|
| 1408 | - $privs[] = $row['Privilege']; |
|
| 1490 | + if ($row['Privilege'] == 'Alter') { |
|
| 1491 | + $privs[] = $row['Privilege']; |
|
| 1492 | + } |
|
| 1409 | 1493 | } |
| 1410 | 1494 | $smcFunc['db_free_result']($get_privs); |
| 1411 | 1495 | |
@@ -1435,8 +1519,9 @@ discard block |
||
| 1435 | 1519 | $incontext['continue'] = 1; |
| 1436 | 1520 | |
| 1437 | 1521 | // Skipping? |
| 1438 | - if (!empty($_POST['skip'])) |
|
| 1439 | - return true; |
|
| 1522 | + if (!empty($_POST['skip'])) { |
|
| 1523 | + return true; |
|
| 1524 | + } |
|
| 1440 | 1525 | |
| 1441 | 1526 | // Need this to check whether we need the database password. |
| 1442 | 1527 | require(dirname(__FILE__) . '/Settings.php'); |
@@ -1453,18 +1538,22 @@ discard block |
||
| 1453 | 1538 | // We need this to properly hash the password for Admin |
| 1454 | 1539 | $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) { |
| 1455 | 1540 | global $sourcedir; |
| 1456 | - if (function_exists('mb_strtolower')) |
|
| 1457 | - return mb_strtolower($string, 'UTF-8'); |
|
| 1541 | + if (function_exists('mb_strtolower')) { |
|
| 1542 | + return mb_strtolower($string, 'UTF-8'); |
|
| 1543 | + } |
|
| 1458 | 1544 | require_once($sourcedir . '/Subs-Charset.php'); |
| 1459 | 1545 | return utf8_strtolower($string); |
| 1460 | 1546 | }; |
| 1461 | 1547 | |
| 1462 | - if (!isset($_POST['username'])) |
|
| 1463 | - $_POST['username'] = ''; |
|
| 1464 | - if (!isset($_POST['email'])) |
|
| 1465 | - $_POST['email'] = ''; |
|
| 1466 | - if (!isset($_POST['server_email'])) |
|
| 1467 | - $_POST['server_email'] = ''; |
|
| 1548 | + if (!isset($_POST['username'])) { |
|
| 1549 | + $_POST['username'] = ''; |
|
| 1550 | + } |
|
| 1551 | + if (!isset($_POST['email'])) { |
|
| 1552 | + $_POST['email'] = ''; |
|
| 1553 | + } |
|
| 1554 | + if (!isset($_POST['server_email'])) { |
|
| 1555 | + $_POST['server_email'] = ''; |
|
| 1556 | + } |
|
| 1468 | 1557 | |
| 1469 | 1558 | $incontext['username'] = htmlspecialchars(stripslashes($_POST['username'])); |
| 1470 | 1559 | $incontext['email'] = htmlspecialchars(stripslashes($_POST['email'])); |
@@ -1483,8 +1572,9 @@ discard block |
||
| 1483 | 1572 | 'admin_group' => 1, |
| 1484 | 1573 | ) |
| 1485 | 1574 | ); |
| 1486 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 1487 | - $incontext['skip'] = 1; |
|
| 1575 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 1576 | + $incontext['skip'] = 1; |
|
| 1577 | + } |
|
| 1488 | 1578 | $smcFunc['db_free_result']($request); |
| 1489 | 1579 | |
| 1490 | 1580 | // Trying to create an account? |
@@ -1515,8 +1605,9 @@ discard block |
||
| 1515 | 1605 | } |
| 1516 | 1606 | |
| 1517 | 1607 | // Update the webmaster's email? |
| 1518 | - if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) |
|
| 1519 | - updateSettingsFile(array('webmaster_email' => $_POST['server_email'])); |
|
| 1608 | + if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) { |
|
| 1609 | + updateSettingsFile(array('webmaster_email' => $_POST['server_email'])); |
|
| 1610 | + } |
|
| 1520 | 1611 | |
| 1521 | 1612 | // Work out whether we're going to have dodgy characters and remove them. |
| 1522 | 1613 | $invalid_characters = preg_match('~[<>&"\'=\\\]~', $_POST['username']) != 0; |
@@ -1539,32 +1630,27 @@ discard block |
||
| 1539 | 1630 | $smcFunc['db_free_result']($result); |
| 1540 | 1631 | |
| 1541 | 1632 | $incontext['account_existed'] = $txt['error_user_settings_taken']; |
| 1542 | - } |
|
| 1543 | - elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) |
|
| 1633 | + } elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) |
|
| 1544 | 1634 | { |
| 1545 | 1635 | // Try the previous step again. |
| 1546 | 1636 | $incontext['error'] = $_POST['username'] == '' ? $txt['error_username_left_empty'] : $txt['error_username_too_long']; |
| 1547 | 1637 | return false; |
| 1548 | - } |
|
| 1549 | - elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) |
|
| 1638 | + } elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) |
|
| 1550 | 1639 | { |
| 1551 | 1640 | // Try the previous step again. |
| 1552 | 1641 | $incontext['error'] = $txt['error_invalid_characters_username']; |
| 1553 | 1642 | return false; |
| 1554 | - } |
|
| 1555 | - elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255) |
|
| 1643 | + } elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255) |
|
| 1556 | 1644 | { |
| 1557 | 1645 | // One step back, this time fill out a proper admin email address. |
| 1558 | 1646 | $incontext['error'] = sprintf($txt['error_valid_admin_email_needed'], $_POST['username']); |
| 1559 | 1647 | return false; |
| 1560 | - } |
|
| 1561 | - elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255) |
|
| 1648 | + } elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255) |
|
| 1562 | 1649 | { |
| 1563 | 1650 | // One step back, this time fill out a proper admin email address. |
| 1564 | 1651 | $incontext['error'] = $txt['error_valid_server_email_needed']; |
| 1565 | 1652 | return false; |
| 1566 | - } |
|
| 1567 | - elseif ($_POST['username'] != '') |
|
| 1653 | + } elseif ($_POST['username'] != '') |
|
| 1568 | 1654 | { |
| 1569 | 1655 | $incontext['member_salt'] = substr(md5(mt_rand()), 0, 4); |
| 1570 | 1656 | |
@@ -1632,17 +1718,19 @@ discard block |
||
| 1632 | 1718 | reloadSettings(); |
| 1633 | 1719 | |
| 1634 | 1720 | // Bring a warning over. |
| 1635 | - if (!empty($incontext['account_existed'])) |
|
| 1636 | - $incontext['warning'] = $incontext['account_existed']; |
|
| 1721 | + if (!empty($incontext['account_existed'])) { |
|
| 1722 | + $incontext['warning'] = $incontext['account_existed']; |
|
| 1723 | + } |
|
| 1637 | 1724 | |
| 1638 | - if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) |
|
| 1639 | - $smcFunc['db_query']('', ' |
|
| 1725 | + if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) { |
|
| 1726 | + $smcFunc['db_query']('', ' |
|
| 1640 | 1727 | SET NAMES {string:db_character_set}', |
| 1641 | 1728 | array( |
| 1642 | 1729 | 'db_character_set' => $db_character_set, |
| 1643 | 1730 | 'db_error_skip' => true, |
| 1644 | 1731 | ) |
| 1645 | 1732 | ); |
| 1733 | + } |
|
| 1646 | 1734 | |
| 1647 | 1735 | // As track stats is by default enabled let's add some activity. |
| 1648 | 1736 | $smcFunc['db_insert']('ignore', |
@@ -1663,14 +1751,16 @@ discard block |
||
| 1663 | 1751 | // Only proceed if we can load the data. |
| 1664 | 1752 | if ($request) |
| 1665 | 1753 | { |
| 1666 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 1667 | - $modSettings[$row[0]] = $row[1]; |
|
| 1754 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 1755 | + $modSettings[$row[0]] = $row[1]; |
|
| 1756 | + } |
|
| 1668 | 1757 | $smcFunc['db_free_result']($request); |
| 1669 | 1758 | } |
| 1670 | 1759 | |
| 1671 | 1760 | // Automatically log them in ;) |
| 1672 | - if (isset($incontext['member_id']) && isset($incontext['member_salt'])) |
|
| 1673 | - setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt'])); |
|
| 1761 | + if (isset($incontext['member_id']) && isset($incontext['member_salt'])) { |
|
| 1762 | + setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt'])); |
|
| 1763 | + } |
|
| 1674 | 1764 | |
| 1675 | 1765 | $result = $smcFunc['db_query']('', ' |
| 1676 | 1766 | SELECT value |
@@ -1681,13 +1771,14 @@ discard block |
||
| 1681 | 1771 | 'db_error_skip' => true, |
| 1682 | 1772 | ) |
| 1683 | 1773 | ); |
| 1684 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
| 1685 | - list ($db_sessions) = $smcFunc['db_fetch_row']($result); |
|
| 1774 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
| 1775 | + list ($db_sessions) = $smcFunc['db_fetch_row']($result); |
|
| 1776 | + } |
|
| 1686 | 1777 | $smcFunc['db_free_result']($result); |
| 1687 | 1778 | |
| 1688 | - if (empty($db_sessions)) |
|
| 1689 | - $_SESSION['admin_time'] = time(); |
|
| 1690 | - else |
|
| 1779 | + if (empty($db_sessions)) { |
|
| 1780 | + $_SESSION['admin_time'] = time(); |
|
| 1781 | + } else |
|
| 1691 | 1782 | { |
| 1692 | 1783 | $_SERVER['HTTP_USER_AGENT'] = substr($_SERVER['HTTP_USER_AGENT'], 0, 211); |
| 1693 | 1784 | |
@@ -1711,8 +1802,9 @@ discard block |
||
| 1711 | 1802 | $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : |
| 1712 | 1803 | function($string){ |
| 1713 | 1804 | global $sourcedir; |
| 1714 | - if (function_exists('mb_strtolower')) |
|
| 1715 | - return mb_strtolower($string, 'UTF-8'); |
|
| 1805 | + if (function_exists('mb_strtolower')) { |
|
| 1806 | + return mb_strtolower($string, 'UTF-8'); |
|
| 1807 | + } |
|
| 1716 | 1808 | require_once($sourcedir . '/Subs-Charset.php'); |
| 1717 | 1809 | return utf8_strtolower($string); |
| 1718 | 1810 | }; |
@@ -1728,8 +1820,9 @@ discard block |
||
| 1728 | 1820 | ) |
| 1729 | 1821 | ); |
| 1730 | 1822 | $context['utf8'] = $db_character_set === 'utf8' || $txt['lang_character_set'] === 'UTF-8'; |
| 1731 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
| 1732 | - updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject'])); |
|
| 1823 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
| 1824 | + updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject'])); |
|
| 1825 | + } |
|
| 1733 | 1826 | $smcFunc['db_free_result']($request); |
| 1734 | 1827 | |
| 1735 | 1828 | // Now is the perfect time to fetch the SM files. |
@@ -1748,8 +1841,9 @@ discard block |
||
| 1748 | 1841 | |
| 1749 | 1842 | // Check if we need some stupid MySQL fix. |
| 1750 | 1843 | $server_version = $smcFunc['db_server_info'](); |
| 1751 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
| 1752 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1844 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
| 1845 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1846 | + } |
|
| 1753 | 1847 | |
| 1754 | 1848 | // Some final context for the template. |
| 1755 | 1849 | $incontext['dir_still_writable'] = is_writable(dirname(__FILE__)) && substr(__FILE__, 1, 2) != ':\\'; |
@@ -1769,8 +1863,9 @@ discard block |
||
| 1769 | 1863 | $settingsArray = file(dirname(__FILE__) . '/Settings.php'); |
| 1770 | 1864 | |
| 1771 | 1865 | // @todo Do we just want to read the file in clean, and split it this way always? |
| 1772 | - if (count($settingsArray) == 1) |
|
| 1773 | - $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
| 1866 | + if (count($settingsArray) == 1) { |
|
| 1867 | + $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
| 1868 | + } |
|
| 1774 | 1869 | |
| 1775 | 1870 | for ($i = 0, $n = count($settingsArray); $i < $n; $i++) |
| 1776 | 1871 | { |
@@ -1778,25 +1873,29 @@ discard block |
||
| 1778 | 1873 | if (trim($settingsArray[$i]) == 'if (file_exists(dirname(__FILE__) . \'/install.php\'))' && trim($settingsArray[$i + 1]) == '{' && trim($settingsArray[$i + 9]) == '}') |
| 1779 | 1874 | { |
| 1780 | 1875 | // Set the ten lines to nothing. |
| 1781 | - for ($j=0; $j < 10; $j++) |
|
| 1782 | - $settingsArray[$i++] = ''; |
|
| 1876 | + for ($j=0; $j < 10; $j++) { |
|
| 1877 | + $settingsArray[$i++] = ''; |
|
| 1878 | + } |
|
| 1783 | 1879 | |
| 1784 | 1880 | continue; |
| 1785 | 1881 | } |
| 1786 | 1882 | |
| 1787 | - if (trim($settingsArray[$i]) == '?' . '>') |
|
| 1788 | - $settingsArray[$i] = ''; |
|
| 1883 | + if (trim($settingsArray[$i]) == '?' . '>') { |
|
| 1884 | + $settingsArray[$i] = ''; |
|
| 1885 | + } |
|
| 1789 | 1886 | |
| 1790 | 1887 | // Don't trim or bother with it if it's not a variable. |
| 1791 | - if (substr($settingsArray[$i], 0, 1) != '$') |
|
| 1792 | - continue; |
|
| 1888 | + if (substr($settingsArray[$i], 0, 1) != '$') { |
|
| 1889 | + continue; |
|
| 1890 | + } |
|
| 1793 | 1891 | |
| 1794 | 1892 | $settingsArray[$i] = rtrim($settingsArray[$i]) . "\n"; |
| 1795 | 1893 | |
| 1796 | - foreach ($vars as $var => $val) |
|
| 1797 | - if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
| 1894 | + foreach ($vars as $var => $val) { |
|
| 1895 | + if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
| 1798 | 1896 | { |
| 1799 | 1897 | $comment = strstr($settingsArray[$i], '#'); |
| 1898 | + } |
|
| 1800 | 1899 | $settingsArray[$i] = '$' . $var . ' = \'' . $val . '\';' . ($comment != '' ? "\t\t" . $comment : "\n"); |
| 1801 | 1900 | unset($vars[$var]); |
| 1802 | 1901 | } |
@@ -1806,36 +1905,41 @@ discard block |
||
| 1806 | 1905 | if (!empty($vars)) |
| 1807 | 1906 | { |
| 1808 | 1907 | $settingsArray[$i++] = ''; |
| 1809 | - foreach ($vars as $var => $val) |
|
| 1810 | - $settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n"; |
|
| 1908 | + foreach ($vars as $var => $val) { |
|
| 1909 | + $settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n"; |
|
| 1910 | + } |
|
| 1811 | 1911 | } |
| 1812 | 1912 | |
| 1813 | 1913 | // Blank out the file - done to fix a oddity with some servers. |
| 1814 | 1914 | $fp = @fopen(dirname(__FILE__) . '/Settings.php', 'w'); |
| 1815 | - if (!$fp) |
|
| 1816 | - return false; |
|
| 1915 | + if (!$fp) { |
|
| 1916 | + return false; |
|
| 1917 | + } |
|
| 1817 | 1918 | fclose($fp); |
| 1818 | 1919 | |
| 1819 | 1920 | $fp = fopen(dirname(__FILE__) . '/Settings.php', 'r+'); |
| 1820 | 1921 | |
| 1821 | 1922 | // Gotta have one of these ;) |
| 1822 | - if (trim($settingsArray[0]) != '<?php') |
|
| 1823 | - fwrite($fp, "<?php\n"); |
|
| 1923 | + if (trim($settingsArray[0]) != '<?php') { |
|
| 1924 | + fwrite($fp, "<?php\n"); |
|
| 1925 | + } |
|
| 1824 | 1926 | |
| 1825 | 1927 | $lines = count($settingsArray); |
| 1826 | 1928 | for ($i = 0; $i < $lines - 1; $i++) |
| 1827 | 1929 | { |
| 1828 | 1930 | // Don't just write a bunch of blank lines. |
| 1829 | - if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') |
|
| 1830 | - fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
| 1931 | + if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') { |
|
| 1932 | + fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
| 1933 | + } |
|
| 1831 | 1934 | } |
| 1832 | 1935 | fwrite($fp, $settingsArray[$i] . '?' . '>'); |
| 1833 | 1936 | fclose($fp); |
| 1834 | 1937 | |
| 1835 | 1938 | // Even though on normal installations the filemtime should prevent this being used by the installer incorrectly |
| 1836 | 1939 | // it seems that there are times it might not. So let's MAKE it dump the cache. |
| 1837 | - if (function_exists('opcache_invalidate')) |
|
| 1838 | - opcache_invalidate(dirname(__FILE__) . '/Settings.php', true); |
|
| 1940 | + if (function_exists('opcache_invalidate')) { |
|
| 1941 | + opcache_invalidate(dirname(__FILE__) . '/Settings.php', true); |
|
| 1942 | + } |
|
| 1839 | 1943 | |
| 1840 | 1944 | return true; |
| 1841 | 1945 | } |
@@ -1845,10 +1949,11 @@ discard block |
||
| 1845 | 1949 | global $cachedir; |
| 1846 | 1950 | |
| 1847 | 1951 | // Write out the db_last_error file with the error timestamp |
| 1848 | - if (!empty($cachedir) && is_writable($cachedir)) |
|
| 1849 | - file_put_contents($cachedir . '/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>'); |
|
| 1850 | - else |
|
| 1851 | - file_put_contents(dirname(__FILE__) . '/cache/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>'); |
|
| 1952 | + if (!empty($cachedir) && is_writable($cachedir)) { |
|
| 1953 | + file_put_contents($cachedir . '/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>'); |
|
| 1954 | + } else { |
|
| 1955 | + file_put_contents(dirname(__FILE__) . '/cache/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>'); |
|
| 1956 | + } |
|
| 1852 | 1957 | |
| 1853 | 1958 | return true; |
| 1854 | 1959 | } |
@@ -1865,9 +1970,9 @@ discard block |
||
| 1865 | 1970 | SecFilterScanPOST Off |
| 1866 | 1971 | </IfModule>'; |
| 1867 | 1972 | |
| 1868 | - if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) |
|
| 1869 | - return true; |
|
| 1870 | - elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess')) |
|
| 1973 | + if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) { |
|
| 1974 | + return true; |
|
| 1975 | + } elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess')) |
|
| 1871 | 1976 | { |
| 1872 | 1977 | $current_htaccess = implode('', file(dirname(__FILE__) . '/.htaccess')); |
| 1873 | 1978 | |
@@ -1879,29 +1984,28 @@ discard block |
||
| 1879 | 1984 | fwrite($ht_handle, $htaccess_addition); |
| 1880 | 1985 | fclose($ht_handle); |
| 1881 | 1986 | return true; |
| 1987 | + } else { |
|
| 1988 | + return false; |
|
| 1882 | 1989 | } |
| 1883 | - else |
|
| 1884 | - return false; |
|
| 1990 | + } else { |
|
| 1991 | + return true; |
|
| 1885 | 1992 | } |
| 1886 | - else |
|
| 1887 | - return true; |
|
| 1888 | - } |
|
| 1889 | - elseif (file_exists(dirname(__FILE__) . '/.htaccess')) |
|
| 1890 | - return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false; |
|
| 1891 | - elseif (is_writable(dirname(__FILE__))) |
|
| 1993 | + } elseif (file_exists(dirname(__FILE__) . '/.htaccess')) { |
|
| 1994 | + return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false; |
|
| 1995 | + } elseif (is_writable(dirname(__FILE__))) |
|
| 1892 | 1996 | { |
| 1893 | 1997 | if ($ht_handle = fopen(dirname(__FILE__) . '/.htaccess', 'w')) |
| 1894 | 1998 | { |
| 1895 | 1999 | fwrite($ht_handle, $htaccess_addition); |
| 1896 | 2000 | fclose($ht_handle); |
| 1897 | 2001 | return true; |
| 2002 | + } else { |
|
| 2003 | + return false; |
|
| 1898 | 2004 | } |
| 1899 | - else |
|
| 2005 | + } else { |
|
| 1900 | 2006 | return false; |
| 1901 | 2007 | } |
| 1902 | - else |
|
| 1903 | - return false; |
|
| 1904 | -} |
|
| 2008 | + } |
|
| 1905 | 2009 | |
| 1906 | 2010 | function template_install_above() |
| 1907 | 2011 | { |
@@ -1940,9 +2044,10 @@ discard block |
||
| 1940 | 2044 | <label for="installer_language">', $txt['installer_language'], ':</label> |
| 1941 | 2045 | <select id="installer_language" name="lang_file" onchange="location.href = \'', $installurl, '?lang_file=\' + this.options[this.selectedIndex].value;">'; |
| 1942 | 2046 | |
| 1943 | - foreach ($incontext['detected_languages'] as $lang => $name) |
|
| 1944 | - echo ' |
|
| 2047 | + foreach ($incontext['detected_languages'] as $lang => $name) { |
|
| 2048 | + echo ' |
|
| 1945 | 2049 | <option', isset($_SESSION['installer_temp_lang']) && $_SESSION['installer_temp_lang'] == $lang ? ' selected' : '', ' value="', $lang, '">', $name, '</option>'; |
| 2050 | + } |
|
| 1946 | 2051 | |
| 1947 | 2052 | echo ' |
| 1948 | 2053 | </select> |
@@ -1962,9 +2067,10 @@ discard block |
||
| 1962 | 2067 | <h2>', $txt['upgrade_progress'], '</h2> |
| 1963 | 2068 | <ul>'; |
| 1964 | 2069 | |
| 1965 | - foreach ($incontext['steps'] as $num => $step) |
|
| 1966 | - echo ' |
|
| 2070 | + foreach ($incontext['steps'] as $num => $step) { |
|
| 2071 | + echo ' |
|
| 1967 | 2072 | <li class="', $num < $incontext['current_step'] ? 'stepdone' : ($num == $incontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
| 2073 | + } |
|
| 1968 | 2074 | |
| 1969 | 2075 | echo ' |
| 1970 | 2076 | </ul> |
@@ -1990,20 +2096,23 @@ discard block |
||
| 1990 | 2096 | echo ' |
| 1991 | 2097 | <div class="floatright">'; |
| 1992 | 2098 | |
| 1993 | - if (!empty($incontext['continue'])) |
|
| 1994 | - echo ' |
|
| 2099 | + if (!empty($incontext['continue'])) { |
|
| 2100 | + echo ' |
|
| 1995 | 2101 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '" onclick="return submitThisOnce(this);" class="button">'; |
| 1996 | - if (!empty($incontext['skip'])) |
|
| 1997 | - echo ' |
|
| 2102 | + } |
|
| 2103 | + if (!empty($incontext['skip'])) { |
|
| 2104 | + echo ' |
|
| 1998 | 2105 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="return submitThisOnce(this);" class="button">'; |
| 2106 | + } |
|
| 1999 | 2107 | echo ' |
| 2000 | 2108 | </div>'; |
| 2001 | 2109 | } |
| 2002 | 2110 | |
| 2003 | 2111 | // Show the closing form tag and other data only if not in the last step |
| 2004 | - if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) |
|
| 2005 | - echo ' |
|
| 2112 | + if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) { |
|
| 2113 | + echo ' |
|
| 2006 | 2114 | </form>'; |
| 2115 | + } |
|
| 2007 | 2116 | |
| 2008 | 2117 | echo ' |
| 2009 | 2118 | </div><!-- .panel --> |
@@ -2036,13 +2145,15 @@ discard block |
||
| 2036 | 2145 | </div>'; |
| 2037 | 2146 | |
| 2038 | 2147 | // Show the warnings, or not. |
| 2039 | - if (template_warning_divs()) |
|
| 2040 | - echo ' |
|
| 2148 | + if (template_warning_divs()) { |
|
| 2149 | + echo ' |
|
| 2041 | 2150 | <h3>', $txt['install_all_lovely'], '</h3>'; |
| 2151 | + } |
|
| 2042 | 2152 | |
| 2043 | 2153 | // Say we want the continue button! |
| 2044 | - if (empty($incontext['error'])) |
|
| 2045 | - $incontext['continue'] = 1; |
|
| 2154 | + if (empty($incontext['error'])) { |
|
| 2155 | + $incontext['continue'] = 1; |
|
| 2156 | + } |
|
| 2046 | 2157 | |
| 2047 | 2158 | // For the latest version stuff. |
| 2048 | 2159 | echo ' |
@@ -2076,19 +2187,21 @@ discard block |
||
| 2076 | 2187 | global $txt, $incontext; |
| 2077 | 2188 | |
| 2078 | 2189 | // Errors are very serious.. |
| 2079 | - if (!empty($incontext['error'])) |
|
| 2080 | - echo ' |
|
| 2190 | + if (!empty($incontext['error'])) { |
|
| 2191 | + echo ' |
|
| 2081 | 2192 | <div class="errorbox"> |
| 2082 | 2193 | <h3>', $txt['upgrade_critical_error'], '</h3> |
| 2083 | 2194 | ', $incontext['error'], ' |
| 2084 | 2195 | </div>'; |
| 2196 | + } |
|
| 2085 | 2197 | // A warning message? |
| 2086 | - elseif (!empty($incontext['warning'])) |
|
| 2087 | - echo ' |
|
| 2198 | + elseif (!empty($incontext['warning'])) { |
|
| 2199 | + echo ' |
|
| 2088 | 2200 | <div class="errorbox"> |
| 2089 | 2201 | <h3>', $txt['upgrade_warning'], '</h3> |
| 2090 | 2202 | ', $incontext['warning'], ' |
| 2091 | 2203 | </div>'; |
| 2204 | + } |
|
| 2092 | 2205 | |
| 2093 | 2206 | return empty($incontext['error']) && empty($incontext['warning']); |
| 2094 | 2207 | } |
@@ -2104,26 +2217,29 @@ discard block |
||
| 2104 | 2217 | <li>', $incontext['failed_files']), '</li> |
| 2105 | 2218 | </ul>'; |
| 2106 | 2219 | |
| 2107 | - if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') |
|
| 2108 | - echo ' |
|
| 2220 | + if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') { |
|
| 2221 | + echo ' |
|
| 2109 | 2222 | <hr> |
| 2110 | 2223 | <p>', $txt['chmod_linux_info'], '</p> |
| 2111 | 2224 | <samp># chmod a+w ', implode(' ' . $incontext['detected_path'] . '/', $incontext['failed_files']), '</samp>'; |
| 2225 | + } |
|
| 2112 | 2226 | |
| 2113 | 2227 | // This is serious! |
| 2114 | - if (!template_warning_divs()) |
|
| 2115 | - return; |
|
| 2228 | + if (!template_warning_divs()) { |
|
| 2229 | + return; |
|
| 2230 | + } |
|
| 2116 | 2231 | |
| 2117 | 2232 | echo ' |
| 2118 | 2233 | <hr> |
| 2119 | 2234 | <p>', $txt['ftp_setup_info'], '</p>'; |
| 2120 | 2235 | |
| 2121 | - if (!empty($incontext['ftp_errors'])) |
|
| 2122 | - echo ' |
|
| 2236 | + if (!empty($incontext['ftp_errors'])) { |
|
| 2237 | + echo ' |
|
| 2123 | 2238 | <div class="error_message"> |
| 2124 | 2239 | ', $txt['error_ftp_no_connect'], '<br><br> |
| 2125 | 2240 | <code>', implode('<br>', $incontext['ftp_errors']), '</code> |
| 2126 | 2241 | </div>'; |
| 2242 | + } |
|
| 2127 | 2243 | |
| 2128 | 2244 | echo ' |
| 2129 | 2245 | <form action="', $incontext['form_url'], '" method="post"> |
@@ -2192,16 +2308,16 @@ discard block |
||
| 2192 | 2308 | <dd> |
| 2193 | 2309 | <select name="db_type" id="db_type_input" onchange="toggleDBInput();">'; |
| 2194 | 2310 | |
| 2195 | - foreach ($incontext['supported_databases'] as $key => $db) |
|
| 2196 | - echo ' |
|
| 2311 | + foreach ($incontext['supported_databases'] as $key => $db) { |
|
| 2312 | + echo ' |
|
| 2197 | 2313 | <option value="', $key, '"', isset($_POST['db_type']) && $_POST['db_type'] == $key ? ' selected' : '', '>', $db['name'], '</option>'; |
| 2314 | + } |
|
| 2198 | 2315 | |
| 2199 | 2316 | echo ' |
| 2200 | 2317 | </select> |
| 2201 | 2318 | <div class="smalltext">', $txt['db_settings_type_info'], '</div> |
| 2202 | 2319 | </dd>'; |
| 2203 | - } |
|
| 2204 | - else |
|
| 2320 | + } else |
|
| 2205 | 2321 | { |
| 2206 | 2322 | echo ' |
| 2207 | 2323 | <dd> |
@@ -2376,9 +2492,10 @@ discard block |
||
| 2376 | 2492 | <div class="red">', $txt['error_db_queries'], '</div> |
| 2377 | 2493 | <ul>'; |
| 2378 | 2494 | |
| 2379 | - foreach ($incontext['failures'] as $line => $fail) |
|
| 2380 | - echo ' |
|
| 2495 | + foreach ($incontext['failures'] as $line => $fail) { |
|
| 2496 | + echo ' |
|
| 2381 | 2497 | <li><strong>', $txt['error_db_queries_line'], $line + 1, ':</strong> ', nl2br(htmlspecialchars($fail)), '</li>'; |
| 2498 | + } |
|
| 2382 | 2499 | |
| 2383 | 2500 | echo ' |
| 2384 | 2501 | </ul>'; |
@@ -2443,15 +2560,16 @@ discard block |
||
| 2443 | 2560 | </dd> |
| 2444 | 2561 | </dl>'; |
| 2445 | 2562 | |
| 2446 | - if ($incontext['require_db_confirm']) |
|
| 2447 | - echo ' |
|
| 2563 | + if ($incontext['require_db_confirm']) { |
|
| 2564 | + echo ' |
|
| 2448 | 2565 | <h2>', $txt['user_settings_database'], '</h2> |
| 2449 | 2566 | <p>', $txt['user_settings_database_info'], '</p> |
| 2450 | 2567 | |
| 2451 | 2568 | <div class="lefttext"> |
| 2452 | 2569 | <input type="password" name="password3" size="30"> |
| 2453 | 2570 | </div>'; |
| 2454 | -} |
|
| 2571 | + } |
|
| 2572 | + } |
|
| 2455 | 2573 | |
| 2456 | 2574 | // Tell them it's done, and to delete. |
| 2457 | 2575 | function template_delete_install() |
@@ -2464,13 +2582,14 @@ discard block |
||
| 2464 | 2582 | template_warning_divs(); |
| 2465 | 2583 | |
| 2466 | 2584 | // Install directory still writable? |
| 2467 | - if ($incontext['dir_still_writable']) |
|
| 2468 | - echo ' |
|
| 2585 | + if ($incontext['dir_still_writable']) { |
|
| 2586 | + echo ' |
|
| 2469 | 2587 | <p><em>', $txt['still_writable'], '</em></p>'; |
| 2588 | + } |
|
| 2470 | 2589 | |
| 2471 | 2590 | // Don't show the box if it's like 99% sure it won't work :P. |
| 2472 | - if ($incontext['probably_delete_install']) |
|
| 2473 | - echo ' |
|
| 2591 | + if ($incontext['probably_delete_install']) { |
|
| 2592 | + echo ' |
|
| 2474 | 2593 | <label> |
| 2475 | 2594 | <input type="checkbox" id="delete_self" onclick="doTheDelete();"> |
| 2476 | 2595 | <strong>', $txt['delete_installer'], !isset($_SESSION['installer_temp_ftp']) ? ' ' . $txt['delete_installer_maybe'] : '', '</strong> |
@@ -2486,6 +2605,7 @@ discard block |
||
| 2486 | 2605 | theCheck.disabled = true; |
| 2487 | 2606 | } |
| 2488 | 2607 | </script>'; |
| 2608 | + } |
|
| 2489 | 2609 | |
| 2490 | 2610 | echo ' |
| 2491 | 2611 | <p>', sprintf($txt['go_to_your_forum'], $boardurl . '/index.php'), '</p> |
@@ -31,25 +31,27 @@ discard block |
||
| 31 | 31 | </div> |
| 32 | 32 | <div class="information">'; |
| 33 | 33 | |
| 34 | - if ($context['is_installed']) |
|
| 35 | - echo ' |
|
| 34 | + if ($context['is_installed']) { |
|
| 35 | + echo ' |
|
| 36 | 36 | <strong>', $txt['package_installed_warning1'], '</strong><br> |
| 37 | 37 | <br> |
| 38 | 38 | ', $txt['package_installed_warning2'], '<br> |
| 39 | 39 | <br>'; |
| 40 | + } |
|
| 40 | 41 | |
| 41 | 42 | echo $txt['package_installed_warning3'], ' |
| 42 | 43 | </div> |
| 43 | 44 | <br>'; |
| 44 | 45 | |
| 45 | 46 | // Do errors exist in the install? If so light them up like a christmas tree. |
| 46 | - if ($context['has_failure']) |
|
| 47 | - echo ' |
|
| 47 | + if ($context['has_failure']) { |
|
| 48 | + echo ' |
|
| 48 | 49 | <div class="errorbox"> |
| 49 | 50 | ', sprintf($txt['package_will_fail_title'], $txt['package_' . ($context['uninstalling'] ? 'uninstall' : 'install')]), '<br> |
| 50 | 51 | ', sprintf($txt['package_will_fail_warning'], $txt['package_' . ($context['uninstalling'] ? 'uninstall' : 'install')]), |
| 51 | 52 | !empty($context['failure_details']) ? '<br><br><strong>' . $context['failure_details'] . '</strong>' : '', ' |
| 52 | 53 | </div>'; |
| 54 | + } |
|
| 53 | 55 | |
| 54 | 56 | // Display the package readme if one exists |
| 55 | 57 | if (isset($context['package_readme'])) |
@@ -63,9 +65,10 @@ discard block |
||
| 63 | 65 | <span class="floatright">', $txt['package_available_readme_language'], ' |
| 64 | 66 | <select name="readme_language" id="readme_language" onchange="if (this.options[this.selectedIndex].value) window.location.href = smf_prepareScriptUrl(smf_scripturl + \'', '?action=admin;area=packages;sa=', $context['uninstalling'] ? 'uninstall' : 'install', ';package=', $context['filename'], ';readme=\' + this.options[this.selectedIndex].value + \';license=\' + get_selected(\'license_language\'));">'; |
| 65 | 67 | |
| 66 | - foreach ($context['readmes'] as $a => $b) |
|
| 67 | - echo ' |
|
| 68 | + foreach ($context['readmes'] as $a => $b) { |
|
| 69 | + echo ' |
|
| 68 | 70 | <option value="', $b, '"', $a === 'selected' ? ' selected' : '', '>', $b == 'default' ? $txt['package_readme_default'] : ucfirst($b), '</option>'; |
| 71 | + } |
|
| 69 | 72 | |
| 70 | 73 | echo ' |
| 71 | 74 | </select> |
@@ -86,9 +89,10 @@ discard block |
||
| 86 | 89 | <span class="floatright">', $txt['package_available_license_language'], ' |
| 87 | 90 | <select name="license_language" id="license_language" onchange="if (this.options[this.selectedIndex].value) window.location.href = smf_prepareScriptUrl(smf_scripturl + \'', '?action=admin;area=packages;sa=install', ';package=', $context['filename'], ';license=\' + this.options[this.selectedIndex].value + \';readme=\' + get_selected(\'readme_language\'));">'; |
| 88 | 91 | |
| 89 | - foreach ($context['licenses'] as $a => $b) |
|
| 90 | - echo ' |
|
| 92 | + foreach ($context['licenses'] as $a => $b) { |
|
| 93 | + echo ' |
|
| 91 | 94 | <option value="', $b, '"', $a === 'selected' ? ' selected' : '', '>', $b == 'default' ? $txt['package_license_default'] : ucfirst($b), '</option>'; |
| 95 | + } |
|
| 92 | 96 | echo ' |
| 93 | 97 | </select> |
| 94 | 98 | </span> |
@@ -115,9 +119,10 @@ discard block |
||
| 115 | 119 | ', $txt['package_db_uninstall_actions'], ': |
| 116 | 120 | <ul>'; |
| 117 | 121 | |
| 118 | - foreach ($context['database_changes'] as $change) |
|
| 119 | - echo ' |
|
| 122 | + foreach ($context['database_changes'] as $change) { |
|
| 123 | + echo ' |
|
| 120 | 124 | <li>', $change, '</li>'; |
| 125 | + } |
|
| 121 | 126 | |
| 122 | 127 | echo ' |
| 123 | 128 | </ul> |
@@ -128,14 +133,14 @@ discard block |
||
| 128 | 133 | echo ' |
| 129 | 134 | <div class="information">'; |
| 130 | 135 | |
| 131 | - if (empty($context['actions']) && empty($context['database_changes'])) |
|
| 132 | - echo ' |
|
| 136 | + if (empty($context['actions']) && empty($context['database_changes'])) { |
|
| 137 | + echo ' |
|
| 133 | 138 | <br> |
| 134 | 139 | <div class="errorbox"> |
| 135 | 140 | ', $txt['corrupt_compatible'], ' |
| 136 | 141 | </div> |
| 137 | 142 | </div><!-- .information -->'; |
| 138 | - else |
|
| 143 | + } else |
|
| 139 | 144 | { |
| 140 | 145 | echo ' |
| 141 | 146 | ', $txt['perform_actions'], ' |
@@ -239,9 +244,10 @@ discard block |
||
| 239 | 244 | <td></td> |
| 240 | 245 | <td>'; |
| 241 | 246 | |
| 242 | - if (!empty($context['themes_locked'])) |
|
| 243 | - echo ' |
|
| 247 | + if (!empty($context['themes_locked'])) { |
|
| 248 | + echo ' |
|
| 244 | 249 | <input type="hidden" name="custom_theme[]" value="', $id, '">'; |
| 250 | + } |
|
| 245 | 251 | echo ' |
| 246 | 252 | <input type="checkbox" name="custom_theme[]" id="custom_theme_', $id, '" value="', $id, '" onclick="', (!empty($theme['has_failure']) ? 'if (this.form.custom_theme_' . $id . '.checked && !confirm(\'' . $txt['package_theme_failure_warning'] . '\')) return false;' : ''), 'invertAll(this, this.form, \'dummy_theme_', $id, '\', true);"', !empty($context['themes_locked']) ? ' disabled checked' : '', '> |
| 247 | 253 | </td> |
@@ -307,21 +313,23 @@ discard block |
||
| 307 | 313 | } |
| 308 | 314 | |
| 309 | 315 | // Are we effectively ready to install? |
| 310 | - if (!$context['ftp_needed'] && (!empty($context['actions']) || !empty($context['database_changes']))) |
|
| 311 | - echo ' |
|
| 316 | + if (!$context['ftp_needed'] && (!empty($context['actions']) || !empty($context['database_changes']))) { |
|
| 317 | + echo ' |
|
| 312 | 318 | <div class="righttext padding"> |
| 313 | 319 | <input type="submit" value="', $context['uninstalling'] ? $txt['package_uninstall_now'] : $txt['package_install_now'], '" onclick="return ', !empty($context['has_failure']) ? '(submitThisOnce(this) && confirm(\'' . ($context['uninstalling'] ? $txt['package_will_fail_popup_uninstall'] : $txt['package_will_fail_popup']) . '\'))' : 'submitThisOnce(this)', ';" class="button"> |
| 314 | 320 | </div>'; |
| 321 | + } |
|
| 315 | 322 | |
| 316 | 323 | // If we need ftp information then demand it! |
| 317 | - elseif ($context['ftp_needed']) |
|
| 318 | - echo ' |
|
| 324 | + elseif ($context['ftp_needed']) { |
|
| 325 | + echo ' |
|
| 319 | 326 | <div class="cat_bar"> |
| 320 | 327 | <h3 class="catbg">', $txt['package_ftp_necessary'], '</h3> |
| 321 | 328 | </div> |
| 322 | 329 | <div> |
| 323 | 330 | ', template_control_chmod(), ' |
| 324 | 331 | </div>'; |
| 332 | + } |
|
| 325 | 333 | |
| 326 | 334 | echo ' |
| 327 | 335 | |
@@ -338,8 +346,8 @@ discard block |
||
| 338 | 346 | // Operations. |
| 339 | 347 | if (!empty($js_operations)) |
| 340 | 348 | { |
| 341 | - foreach ($js_operations as $key => $operation) |
|
| 342 | - echo ' |
|
| 349 | + foreach ($js_operations as $key => $operation) { |
|
| 350 | + echo ' |
|
| 343 | 351 | aOperationElements[', $key, '] = new smc_Toggle({ |
| 344 | 352 | bToggleEnabled: true, |
| 345 | 353 | bNoAnimate: true, |
@@ -357,6 +365,7 @@ discard block |
||
| 357 | 365 | } |
| 358 | 366 | ] |
| 359 | 367 | });'; |
| 368 | + } |
|
| 360 | 369 | } |
| 361 | 370 | |
| 362 | 371 | echo ' |
@@ -378,14 +387,15 @@ discard block |
||
| 378 | 387 | </script>'; |
| 379 | 388 | |
| 380 | 389 | // And a bit more for database changes. |
| 381 | - if (!empty($context['database_changes'])) |
|
| 382 | - echo ' |
|
| 390 | + if (!empty($context['database_changes'])) { |
|
| 391 | + echo ' |
|
| 383 | 392 | <script> |
| 384 | 393 | var database_changes_area = document.getElementById(\'db_changes_div\'); |
| 385 | 394 | var db_vis = false; |
| 386 | 395 | database_changes_area.style.display = "none"; |
| 387 | 396 | </script>'; |
| 388 | -} |
|
| 397 | + } |
|
| 398 | + } |
|
| 389 | 399 | |
| 390 | 400 | /** |
| 391 | 401 | * Extract package contents |
@@ -394,8 +404,8 @@ discard block |
||
| 394 | 404 | { |
| 395 | 405 | global $context, $txt, $scripturl; |
| 396 | 406 | |
| 397 | - if (!empty($context['redirect_url'])) |
|
| 398 | - echo ' |
|
| 407 | + if (!empty($context['redirect_url'])) { |
|
| 408 | + echo ' |
|
| 399 | 409 | <script> |
| 400 | 410 | setTimeout("doRedirect();", ', empty($context['redirect_timeout']) ? '5000' : $context['redirect_timeout'], '); |
| 401 | 411 | |
@@ -404,52 +414,51 @@ discard block |
||
| 404 | 414 | window.location = "', $context['redirect_url'], '"; |
| 405 | 415 | } |
| 406 | 416 | </script>'; |
| 417 | + } |
|
| 407 | 418 | |
| 408 | 419 | echo ' |
| 409 | 420 | <div id="admincenter">'; |
| 410 | 421 | |
| 411 | - if (empty($context['redirect_url'])) |
|
| 412 | - echo ' |
|
| 422 | + if (empty($context['redirect_url'])) { |
|
| 423 | + echo ' |
|
| 413 | 424 | <div class="cat_bar"> |
| 414 | 425 | <h3 class="catbg">', $context['uninstalling'] ? $txt['uninstall'] : $txt['extracting'], '</h3> |
| 415 | 426 | </div> |
| 416 | 427 | <div class="information">', $txt['package_installed_extract'], '</div>'; |
| 417 | - else |
|
| 418 | - echo ' |
|
| 428 | + } else { |
|
| 429 | + echo ' |
|
| 419 | 430 | <div class="cat_bar"> |
| 420 | 431 | <h3 class="catbg">', $txt['package_installed_redirecting'], '</h3> |
| 421 | 432 | </div>'; |
| 433 | + } |
|
| 422 | 434 | |
| 423 | 435 | echo ' |
| 424 | 436 | <div class="windowbg">'; |
| 425 | 437 | |
| 426 | 438 | // If we are going to redirect we have a slightly different agenda. |
| 427 | - if (!empty($context['redirect_url'])) |
|
| 428 | - echo ' |
|
| 439 | + if (!empty($context['redirect_url'])) { |
|
| 440 | + echo ' |
|
| 429 | 441 | ', $context['redirect_text'], '<br><br> |
| 430 | 442 | <a href="', $context['redirect_url'], '">', $txt['package_installed_redirect_go_now'], '</a> | <a href="', $scripturl, '?action=admin;area=packages;sa=browse">', $txt['package_installed_redirect_cancel'], '</a>'; |
| 431 | - |
|
| 432 | - elseif ($context['uninstalling']) |
|
| 433 | - echo ' |
|
| 443 | + } elseif ($context['uninstalling']) { |
|
| 444 | + echo ' |
|
| 434 | 445 | ', $txt['package_uninstall_done']; |
| 435 | - |
|
| 436 | - elseif ($context['install_finished']) |
|
| 446 | + } elseif ($context['install_finished']) |
|
| 437 | 447 | { |
| 438 | - if ($context['extract_type'] == 'avatar') |
|
| 439 | - echo ' |
|
| 448 | + if ($context['extract_type'] == 'avatar') { |
|
| 449 | + echo ' |
|
| 440 | 450 | ', $txt['avatars_extracted']; |
| 441 | - |
|
| 442 | - elseif ($context['extract_type'] == 'language') |
|
| 443 | - echo ' |
|
| 451 | + } elseif ($context['extract_type'] == 'language') { |
|
| 452 | + echo ' |
|
| 444 | 453 | ', $txt['language_extracted']; |
| 445 | - |
|
| 446 | - else |
|
| 447 | - echo ' |
|
| 454 | + } else { |
|
| 455 | + echo ' |
|
| 448 | 456 | ', $txt['package_installed_done']; |
| 449 | - } |
|
| 450 | - else |
|
| 451 | - echo ' |
|
| 457 | + } |
|
| 458 | + } else { |
|
| 459 | + echo ' |
|
| 452 | 460 | ', $txt['corrupt_compatible']; |
| 461 | + } |
|
| 453 | 462 | |
| 454 | 463 | echo ' |
| 455 | 464 | </div><!-- .windowbg -->'; |
@@ -483,9 +492,10 @@ discard block |
||
| 483 | 492 | <div class="windowbg"> |
| 484 | 493 | <ol>'; |
| 485 | 494 | |
| 486 | - foreach ($context['files'] as $fileinfo) |
|
| 487 | - echo ' |
|
| 495 | + foreach ($context['files'] as $fileinfo) { |
|
| 496 | + echo ' |
|
| 488 | 497 | <li><a href="', $scripturl, '?action=admin;area=packages;sa=examine;package=', $context['filename'], ';file=', $fileinfo['filename'], '" title="', $txt['view'], '">', $fileinfo['filename'], '</a> (', $fileinfo['size'], ' ', $txt['package_bytes'], ')</li>'; |
| 498 | + } |
|
| 489 | 499 | |
| 490 | 500 | echo ' |
| 491 | 501 | </ol> |
@@ -549,9 +559,10 @@ discard block |
||
| 549 | 559 | </script> |
| 550 | 560 | <div id="yourVersion" style="display:none">', $context['forum_version'], '</div>'; |
| 551 | 561 | |
| 552 | - if (empty($modSettings['disable_smf_js'])) |
|
| 553 | - echo ' |
|
| 562 | + if (empty($modSettings['disable_smf_js'])) { |
|
| 563 | + echo ' |
|
| 554 | 564 | <script src="', $scripturl, '?action=viewsmfile;filename=latest-news.js"></script>'; |
| 565 | + } |
|
| 555 | 566 | |
| 556 | 567 | // This sets the announcements and current versions themselves ;). |
| 557 | 568 | echo ' |
@@ -589,12 +600,13 @@ discard block |
||
| 589 | 600 | } |
| 590 | 601 | } |
| 591 | 602 | |
| 592 | - if (!$mods_available) |
|
| 593 | - echo ' |
|
| 603 | + if (!$mods_available) { |
|
| 604 | + echo ' |
|
| 594 | 605 | <div class="noticebox">', $txt['no_packages'], '</div>'; |
| 595 | - else |
|
| 596 | - echo ' |
|
| 606 | + } else { |
|
| 607 | + echo ' |
|
| 597 | 608 | <br>'; |
| 609 | + } |
|
| 598 | 610 | |
| 599 | 611 | // The advanced (emulation) box, collapsed by default |
| 600 | 612 | echo ' |
@@ -621,9 +633,10 @@ discard block |
||
| 621 | 633 | <a id="revert" name="revert"></a> |
| 622 | 634 | <select name="version_emulate" id="ve">'; |
| 623 | 635 | |
| 624 | - foreach ($context['emulation_versions'] as $version) |
|
| 625 | - echo ' |
|
| 636 | + foreach ($context['emulation_versions'] as $version) { |
|
| 637 | + echo ' |
|
| 626 | 638 | <option value="', $version, '"', ($version == $context['selected_version'] ? ' selected="selected"' : ''), '>', $version, '</option>'; |
| 639 | + } |
|
| 627 | 640 | |
| 628 | 641 | echo ' |
| 629 | 642 | </select> |
@@ -679,11 +692,12 @@ discard block |
||
| 679 | 692 | { |
| 680 | 693 | global $context, $txt, $scripturl; |
| 681 | 694 | |
| 682 | - if (!empty($context['package_ftp']['error'])) |
|
| 683 | - echo ' |
|
| 695 | + if (!empty($context['package_ftp']['error'])) { |
|
| 696 | + echo ' |
|
| 684 | 697 | <div class="errorbox"> |
| 685 | 698 | <pre>', $context['package_ftp']['error'], '</pre> |
| 686 | 699 | </div>'; |
| 700 | + } |
|
| 687 | 701 | |
| 688 | 702 | echo ' |
| 689 | 703 | <div id="admin_form_wrapper"> |
@@ -766,13 +780,14 @@ discard block |
||
| 766 | 780 | <legend>' . $txt['package_servers'] . '</legend> |
| 767 | 781 | <ul class="package_servers">'; |
| 768 | 782 | |
| 769 | - foreach ($context['servers'] as $server) |
|
| 770 | - echo ' |
|
| 783 | + foreach ($context['servers'] as $server) { |
|
| 784 | + echo ' |
|
| 771 | 785 | <li class="flow_auto"> |
| 772 | 786 | <span class="floatleft">' . $server['name'] . '</span> |
| 773 | 787 | <span class="package_server floatright"><a href="' . $scripturl . '?action=admin;area=packages;get;sa=remove;server=' . $server['id'] . ';', $context['session_var'], '=', $context['session_id'], '">[ ' . $txt['delete'] . ' ]</a></span> |
| 774 | 788 | <span class="package_server floatright"><a href="' . $scripturl . '?action=admin;area=packages;get;sa=browse;server=' . $server['id'] . '">[ ' . $txt['package_browse'] . ' ]</a></span> |
| 775 | 789 | </li>'; |
| 790 | + } |
|
| 776 | 791 | echo ' |
| 777 | 792 | </ul> |
| 778 | 793 | </fieldset> |
@@ -859,11 +874,12 @@ discard block |
||
| 859 | 874 | <div class="windowbg">'; |
| 860 | 875 | |
| 861 | 876 | // No packages, as yet. |
| 862 | - if (empty($context['package_list'])) |
|
| 863 | - echo ' |
|
| 877 | + if (empty($context['package_list'])) { |
|
| 878 | + echo ' |
|
| 864 | 879 | <ul> |
| 865 | 880 | <li>', $txt['no_packages'], '</li> |
| 866 | 881 | </ul>'; |
| 882 | + } |
|
| 867 | 883 | |
| 868 | 884 | // List out the packages... |
| 869 | 885 | else |
@@ -877,11 +893,12 @@ discard block |
||
| 877 | 893 | <li> |
| 878 | 894 | <strong><span id="ps_img_', $i, '" class="toggle_up" alt="*" style="display: none;"></span> ', $packageSection['title'], '</strong>'; |
| 879 | 895 | |
| 880 | - if (!empty($packageSection['text'])) |
|
| 881 | - echo ' |
|
| 896 | + if (!empty($packageSection['text'])) { |
|
| 897 | + echo ' |
|
| 882 | 898 | <div class="sub_bar"> |
| 883 | 899 | <h3 class="subbg">', $packageSection['text'], '</h3> |
| 884 | 900 | </div>'; |
| 901 | + } |
|
| 885 | 902 | |
| 886 | 903 | echo ' |
| 887 | 904 | <', $context['list_type'], ' id="package_section_', $i, '" class="packages">'; |
@@ -892,24 +909,28 @@ discard block |
||
| 892 | 909 | <li>'; |
| 893 | 910 | |
| 894 | 911 | // Textual message. Could be empty just for a blank line... |
| 895 | - if ($package['is_text']) |
|
| 896 | - echo ' |
|
| 912 | + if ($package['is_text']) { |
|
| 913 | + echo ' |
|
| 897 | 914 | ', empty($package['name']) ? ' ' : $package['name']; |
| 915 | + } |
|
| 898 | 916 | |
| 899 | 917 | // This is supposed to be a rule.. |
| 900 | - elseif ($package['is_line']) |
|
| 901 | - echo ' |
|
| 918 | + elseif ($package['is_line']) { |
|
| 919 | + echo ' |
|
| 902 | 920 | <hr>'; |
| 921 | + } |
|
| 903 | 922 | |
| 904 | 923 | // A remote link. |
| 905 | - elseif ($package['is_remote']) |
|
| 906 | - echo ' |
|
| 924 | + elseif ($package['is_remote']) { |
|
| 925 | + echo ' |
|
| 907 | 926 | <strong>', $package['link'], '</strong>'; |
| 927 | + } |
|
| 908 | 928 | |
| 909 | 929 | // A title? |
| 910 | - elseif ($package['is_heading'] || $package['is_title']) |
|
| 911 | - echo ' |
|
| 930 | + elseif ($package['is_heading'] || $package['is_title']) { |
|
| 931 | + echo ' |
|
| 912 | 932 | <strong>', $package['name'], '</strong>'; |
| 933 | + } |
|
| 913 | 934 | |
| 914 | 935 | // Otherwise, it's a package. |
| 915 | 936 | else |
@@ -920,32 +941,36 @@ discard block |
||
| 920 | 941 | <ul id="package_section_', $i, '_pkg_', $id, '" class="package_section">'; |
| 921 | 942 | |
| 922 | 943 | // Show the mod type? |
| 923 | - if ($package['type'] != '') |
|
| 924 | - echo ' |
|
| 944 | + if ($package['type'] != '') { |
|
| 945 | + echo ' |
|
| 925 | 946 | <li class="package_section"> |
| 926 | 947 | ', $txt['package_type'], ': ', $smcFunc['ucwords']($smcFunc['strtolower']($package['type'])), ' |
| 927 | 948 | </li>'; |
| 949 | + } |
|
| 928 | 950 | |
| 929 | 951 | // Show the version number? |
| 930 | - if ($package['version'] != '') |
|
| 931 | - echo ' |
|
| 952 | + if ($package['version'] != '') { |
|
| 953 | + echo ' |
|
| 932 | 954 | <li class="package_section"> |
| 933 | 955 | ', $txt['mod_version'], ': ', $package['version'], ' |
| 934 | 956 | </li>'; |
| 957 | + } |
|
| 935 | 958 | |
| 936 | 959 | // How 'bout the author? |
| 937 | - if (!empty($package['author']) && $package['author']['name'] != '' && isset($package['author']['link'])) |
|
| 938 | - echo ' |
|
| 960 | + if (!empty($package['author']) && $package['author']['name'] != '' && isset($package['author']['link'])) { |
|
| 961 | + echo ' |
|
| 939 | 962 | <li class="package_section"> |
| 940 | 963 | ', $txt['mod_author'], ': ', $package['author']['link'], ' |
| 941 | 964 | </li>'; |
| 965 | + } |
|
| 942 | 966 | |
| 943 | 967 | // The homepage... |
| 944 | - if ($package['author']['website']['link'] != '') |
|
| 945 | - echo ' |
|
| 968 | + if ($package['author']['website']['link'] != '') { |
|
| 969 | + echo ' |
|
| 946 | 970 | <li class="package_section"> |
| 947 | 971 | ', $txt['author_website'], ': ', $package['author']['website']['link'], ' |
| 948 | 972 | </li>'; |
| 973 | + } |
|
| 949 | 974 | |
| 950 | 975 | // Description: bleh bleh! |
| 951 | 976 | // Location of file: http://someplace/. |
@@ -1004,8 +1029,8 @@ discard block |
||
| 1004 | 1029 | |
| 1005 | 1030 | foreach ($ps['items'] as $id => $package) |
| 1006 | 1031 | { |
| 1007 | - if (!$package['is_text'] && !$package['is_line'] && !$package['is_remote']) |
|
| 1008 | - echo ' |
|
| 1032 | + if (!$package['is_text'] && !$package['is_line'] && !$package['is_remote']) { |
|
| 1033 | + echo ' |
|
| 1009 | 1034 | var oPackageToggle_', $section, '_pkg_', $id, ' = new smc_Toggle({ |
| 1010 | 1035 | bToggleEnabled: true, |
| 1011 | 1036 | bCurrentlyCollapsed: true, |
@@ -1020,6 +1045,7 @@ discard block |
||
| 1020 | 1045 | } |
| 1021 | 1046 | ] |
| 1022 | 1047 | });'; |
| 1048 | + } |
|
| 1023 | 1049 | } |
| 1024 | 1050 | } |
| 1025 | 1051 | |
@@ -1064,9 +1090,10 @@ discard block |
||
| 1064 | 1090 | { |
| 1065 | 1091 | global $context, $txt, $scripturl; |
| 1066 | 1092 | |
| 1067 | - if (!empty($context['saved_successful'])) |
|
| 1068 | - echo ' |
|
| 1093 | + if (!empty($context['saved_successful'])) { |
|
| 1094 | + echo ' |
|
| 1069 | 1095 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
| 1096 | + } |
|
| 1070 | 1097 | |
| 1071 | 1098 | echo ' |
| 1072 | 1099 | <div id="admincenter"> |
@@ -1128,8 +1155,9 @@ discard block |
||
| 1128 | 1155 | global $context, $txt; |
| 1129 | 1156 | |
| 1130 | 1157 | // Nothing to do? Brilliant! |
| 1131 | - if (empty($context['package_ftp'])) |
|
| 1132 | - return false; |
|
| 1158 | + if (empty($context['package_ftp'])) { |
|
| 1159 | + return false; |
|
| 1160 | + } |
|
| 1133 | 1161 | |
| 1134 | 1162 | if (empty($context['package_ftp']['form_elements_only'])) |
| 1135 | 1163 | { |
@@ -1139,19 +1167,21 @@ discard block |
||
| 1139 | 1167 | ', $txt['package_ftp_why_file_list'], ' |
| 1140 | 1168 | <ul style="display: inline;">'; |
| 1141 | 1169 | |
| 1142 | - if (!empty($context['notwritable_files'])) |
|
| 1143 | - foreach ($context['notwritable_files'] as $file) |
|
| 1170 | + if (!empty($context['notwritable_files'])) { |
|
| 1171 | + foreach ($context['notwritable_files'] as $file) |
|
| 1144 | 1172 | echo ' |
| 1145 | 1173 | <li>', $file, '</li>'; |
| 1174 | + } |
|
| 1146 | 1175 | |
| 1147 | 1176 | echo ' |
| 1148 | 1177 | </ul>'; |
| 1149 | 1178 | |
| 1150 | - if (!$context['server']['is_windows']) |
|
| 1151 | - echo ' |
|
| 1179 | + if (!$context['server']['is_windows']) { |
|
| 1180 | + echo ' |
|
| 1152 | 1181 | <hr> |
| 1153 | 1182 | ', $txt['package_chmod_linux'], '<br> |
| 1154 | 1183 | <samp># chmod a+w ', implode(' ', $context['notwritable_files']), '</samp>'; |
| 1184 | + } |
|
| 1155 | 1185 | |
| 1156 | 1186 | echo ' |
| 1157 | 1187 | </div><!-- #need_writable_list -->'; |
@@ -1164,9 +1194,10 @@ discard block |
||
| 1164 | 1194 | </div> |
| 1165 | 1195 | </div>'; |
| 1166 | 1196 | |
| 1167 | - if (!empty($context['package_ftp']['destination'])) |
|
| 1168 | - echo ' |
|
| 1197 | + if (!empty($context['package_ftp']['destination'])) { |
|
| 1198 | + echo ' |
|
| 1169 | 1199 | <form action="', $context['package_ftp']['destination'], '" method="post" accept-charset="', $context['character_set'], '">'; |
| 1200 | + } |
|
| 1170 | 1201 | |
| 1171 | 1202 | echo ' |
| 1172 | 1203 | <fieldset> |
@@ -1200,24 +1231,27 @@ discard block |
||
| 1200 | 1231 | </dl> |
| 1201 | 1232 | </fieldset>'; |
| 1202 | 1233 | |
| 1203 | - if (empty($context['package_ftp']['form_elements_only'])) |
|
| 1204 | - echo ' |
|
| 1234 | + if (empty($context['package_ftp']['form_elements_only'])) { |
|
| 1235 | + echo ' |
|
| 1205 | 1236 | <div class="righttext" style="margin: 1ex;"> |
| 1206 | 1237 | <span id="test_ftp_placeholder_full"></span> |
| 1207 | 1238 | <input type="submit" value="', $txt['package_proceed'], '" class="button"> |
| 1208 | 1239 | </div>'; |
| 1240 | + } |
|
| 1209 | 1241 | |
| 1210 | - if (!empty($context['package_ftp']['destination'])) |
|
| 1211 | - echo ' |
|
| 1242 | + if (!empty($context['package_ftp']['destination'])) { |
|
| 1243 | + echo ' |
|
| 1212 | 1244 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
| 1213 | 1245 | </form>'; |
| 1246 | + } |
|
| 1214 | 1247 | |
| 1215 | 1248 | // Hide the details of the list. |
| 1216 | - if (empty($context['package_ftp']['form_elements_only'])) |
|
| 1217 | - echo ' |
|
| 1249 | + if (empty($context['package_ftp']['form_elements_only'])) { |
|
| 1250 | + echo ' |
|
| 1218 | 1251 | <script> |
| 1219 | 1252 | document.getElementById(\'need_writable_list\').style.display = \'none\'; |
| 1220 | 1253 | </script>'; |
| 1254 | + } |
|
| 1221 | 1255 | |
| 1222 | 1256 | // Quick generate the test button. |
| 1223 | 1257 | echo ' |
@@ -1574,9 +1608,10 @@ discard block |
||
| 1574 | 1608 | <td width="30%"> |
| 1575 | 1609 | <strong>'; |
| 1576 | 1610 | |
| 1577 | - if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive')) |
|
| 1578 | - echo ' |
|
| 1611 | + if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive')) { |
|
| 1612 | + echo ' |
|
| 1579 | 1613 | <span class="generic_icons folder"></span>'; |
| 1614 | + } |
|
| 1580 | 1615 | |
| 1581 | 1616 | echo ' |
| 1582 | 1617 | ', $name, ' |
@@ -1603,8 +1638,9 @@ discard block |
||
| 1603 | 1638 | </td> |
| 1604 | 1639 | </tr>'; |
| 1605 | 1640 | |
| 1606 | - if (!empty($dir['contents'])) |
|
| 1607 | - template_permission_show_contents($name, $dir['contents'], 1); |
|
| 1641 | + if (!empty($dir['contents'])) { |
|
| 1642 | + template_permission_show_contents($name, $dir['contents'], 1); |
|
| 1643 | + } |
|
| 1608 | 1644 | } |
| 1609 | 1645 | |
| 1610 | 1646 | echo ' |
@@ -1640,13 +1676,14 @@ discard block |
||
| 1640 | 1676 | </fieldset>'; |
| 1641 | 1677 | |
| 1642 | 1678 | // Likely to need FTP? |
| 1643 | - if (empty($context['ftp_connected'])) |
|
| 1644 | - echo ' |
|
| 1679 | + if (empty($context['ftp_connected'])) { |
|
| 1680 | + echo ' |
|
| 1645 | 1681 | <p> |
| 1646 | 1682 | ', $txt['package_file_perms_ftp_details'], ': |
| 1647 | 1683 | </p> |
| 1648 | 1684 | ', template_control_chmod(), ' |
| 1649 | 1685 | <div class="noticebox">', $txt['package_file_perms_ftp_retain'], '</div>'; |
| 1686 | + } |
|
| 1650 | 1687 | |
| 1651 | 1688 | echo ' |
| 1652 | 1689 | <span id="test_ftp_placeholder_full"></span> |
@@ -1655,9 +1692,10 @@ discard block |
||
| 1655 | 1692 | </div><!-- .windowbg -->'; |
| 1656 | 1693 | |
| 1657 | 1694 | // Any looks fors we've already done? |
| 1658 | - foreach ($context['look_for'] as $path) |
|
| 1659 | - echo ' |
|
| 1695 | + foreach ($context['look_for'] as $path) { |
|
| 1696 | + echo ' |
|
| 1660 | 1697 | <input type="hidden" name="back_look[]" value="', $path, '">'; |
| 1698 | + } |
|
| 1661 | 1699 | |
| 1662 | 1700 | echo ' |
| 1663 | 1701 | </form> |
@@ -1699,9 +1737,10 @@ discard block |
||
| 1699 | 1737 | <td class="smalltext" width="30%">' . str_repeat(' ', $level * 5), ' |
| 1700 | 1738 | ', (!empty($dir['type']) && $dir['type'] == 'dir_recursive') || !empty($dir['list_contents']) ? '<a id="link_' . $cur_ident . '" href="' . $scripturl . '?action=admin;area=packages;sa=perms;find=' . base64_encode($ident . '/' . $name) . ';back_look=' . $context['back_look_data'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '#fol_' . $cur_ident . '" onclick="return expandFolder(\'' . $cur_ident . '\', \'' . addcslashes($ident . '/' . $name, "'\\") . '\');">' : ''; |
| 1701 | 1739 | |
| 1702 | - if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive')) |
|
| 1703 | - echo ' |
|
| 1740 | + if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive')) { |
|
| 1741 | + echo ' |
|
| 1704 | 1742 | <span class="generic_icons folder"></span>'; |
| 1743 | + } |
|
| 1705 | 1744 | |
| 1706 | 1745 | echo ' |
| 1707 | 1746 | ', $name, ' |
@@ -1719,34 +1758,38 @@ discard block |
||
| 1719 | 1758 | </tr> |
| 1720 | 1759 | <tr id="insert_div_loc_' . $cur_ident . '" style="display: none;"><td></td></tr>'; |
| 1721 | 1760 | |
| 1722 | - if (!empty($dir['contents'])) |
|
| 1723 | - template_permission_show_contents($ident . '/' . $name, $dir['contents'], $level + 1, !empty($dir['more_files'])); |
|
| 1761 | + if (!empty($dir['contents'])) { |
|
| 1762 | + template_permission_show_contents($ident . '/' . $name, $dir['contents'], $level + 1, !empty($dir['more_files'])); |
|
| 1763 | + } |
|
| 1724 | 1764 | } |
| 1725 | 1765 | } |
| 1726 | 1766 | |
| 1727 | 1767 | // We have more files to show? |
| 1728 | - if ($has_more) |
|
| 1729 | - echo ' |
|
| 1768 | + if ($has_more) { |
|
| 1769 | + echo ' |
|
| 1730 | 1770 | <tr class="windowbg" id="content_', $js_ident, '_more"> |
| 1731 | 1771 | <td class="smalltext" width="40%">' . str_repeat(' ', $level * 5), ' |
| 1732 | 1772 | « <a href="' . $scripturl . '?action=admin;area=packages;sa=perms;find=' . base64_encode($ident) . ';fileoffset=', ($context['file_offset'] + $context['file_limit']), ';' . $context['session_var'] . '=' . $context['session_id'] . '#fol_' . preg_replace('~[^A-Za-z0-9_\-=:]~', ':-:', $ident) . '">', $txt['package_file_perms_more_files'], '</a> » |
| 1733 | 1773 | </td> |
| 1734 | 1774 | <td colspan="6"></td> |
| 1735 | 1775 | </tr>'; |
| 1776 | + } |
|
| 1736 | 1777 | |
| 1737 | 1778 | if ($drawn_div) |
| 1738 | 1779 | { |
| 1739 | 1780 | // Hide anything too far down the tree. |
| 1740 | 1781 | $isFound = false; |
| 1741 | - foreach ($context['look_for'] as $tree) |
|
| 1742 | - if (substr($tree, 0, strlen($ident)) == $ident) |
|
| 1782 | + foreach ($context['look_for'] as $tree) { |
|
| 1783 | + if (substr($tree, 0, strlen($ident)) == $ident) |
|
| 1743 | 1784 | $isFound = true; |
| 1785 | + } |
|
| 1744 | 1786 | |
| 1745 | - if ($level > 1 && !$isFound) |
|
| 1746 | - echo ' |
|
| 1787 | + if ($level > 1 && !$isFound) { |
|
| 1788 | + echo ' |
|
| 1747 | 1789 | <script> |
| 1748 | 1790 | expandFolder(\'', $js_ident, '\', \'\'); |
| 1749 | 1791 | </script>'; |
| 1792 | + } |
|
| 1750 | 1793 | } |
| 1751 | 1794 | } |
| 1752 | 1795 | |
@@ -1766,11 +1809,12 @@ discard block |
||
| 1766 | 1809 | <h3 class="catbg">', $txt['package_file_perms_applying'], '</h3> |
| 1767 | 1810 | </div>'; |
| 1768 | 1811 | |
| 1769 | - if (!empty($context['skip_ftp'])) |
|
| 1770 | - echo ' |
|
| 1812 | + if (!empty($context['skip_ftp'])) { |
|
| 1813 | + echo ' |
|
| 1771 | 1814 | <div class="errorbox"> |
| 1772 | 1815 | ', $txt['package_file_perms_skipping_ftp'], ' |
| 1773 | 1816 | </div>'; |
| 1817 | + } |
|
| 1774 | 1818 | |
| 1775 | 1819 | // How many have we done? |
| 1776 | 1820 | $remaining_items = count($context['method'] == 'individual' ? $context['to_process'] : $context['directory_list']); |
@@ -1808,28 +1852,31 @@ discard block |
||
| 1808 | 1852 | <br>'; |
| 1809 | 1853 | |
| 1810 | 1854 | // Put out the right hidden data. |
| 1811 | - if ($context['method'] == 'individual') |
|
| 1812 | - echo ' |
|
| 1855 | + if ($context['method'] == 'individual') { |
|
| 1856 | + echo ' |
|
| 1813 | 1857 | <input type="hidden" name="custom_value" value="', $context['custom_value'], '"> |
| 1814 | 1858 | <input type="hidden" name="totalItems" value="', $context['total_items'], '"> |
| 1815 | 1859 | <input type="hidden" name="toProcess" value="', $context['to_process_encode'], '">'; |
| 1816 | - else |
|
| 1817 | - echo ' |
|
| 1860 | + } else { |
|
| 1861 | + echo ' |
|
| 1818 | 1862 | <input type="hidden" name="predefined" value="', $context['predefined_type'], '"> |
| 1819 | 1863 | <input type="hidden" name="fileOffset" value="', $context['file_offset'], '"> |
| 1820 | 1864 | <input type="hidden" name="totalItems" value="', $context['total_items'], '"> |
| 1821 | 1865 | <input type="hidden" name="dirList" value="', $context['directory_list_encode'], '"> |
| 1822 | 1866 | <input type="hidden" name="specialFiles" value="', $context['special_files_encode'], '">'; |
| 1867 | + } |
|
| 1823 | 1868 | |
| 1824 | 1869 | // Are we not using FTP for whatever reason. |
| 1825 | - if (!empty($context['skip_ftp'])) |
|
| 1826 | - echo ' |
|
| 1870 | + if (!empty($context['skip_ftp'])) { |
|
| 1871 | + echo ' |
|
| 1827 | 1872 | <input type="hidden" name="skip_ftp" value="1">'; |
| 1873 | + } |
|
| 1828 | 1874 | |
| 1829 | 1875 | // Retain state. |
| 1830 | - foreach ($context['back_look_data'] as $path) |
|
| 1831 | - echo ' |
|
| 1876 | + foreach ($context['back_look_data'] as $path) { |
|
| 1877 | + echo ' |
|
| 1832 | 1878 | <input type="hidden" name="back_look[]" value="', $path, '">'; |
| 1879 | + } |
|
| 1833 | 1880 | |
| 1834 | 1881 | echo ' |
| 1835 | 1882 | <input type="hidden" name="method" value="', $context['method'], '"> |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 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,28 +48,36 @@ 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 | 73 | // We excpiclity do not use $smcFunc['json_decode'] here yet, as $smcFunc is not fully loaded. |
| 66 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
| 67 | - $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
| 74 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
| 75 | + $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
| 76 | + } |
|
| 68 | 77 | |
| 69 | - if (!empty($cache_enable)) |
|
| 70 | - cache_put_data('modSettings', $modSettings, 90); |
|
| 78 | + if (!empty($cache_enable)) { |
|
| 79 | + cache_put_data('modSettings', $modSettings, 90); |
|
| 80 | + } |
|
| 71 | 81 | } |
| 72 | 82 | |
| 73 | 83 | $modSettings['cache_enable'] = $cache_enable; |
@@ -87,8 +97,9 @@ discard block |
||
| 87 | 97 | }; |
| 88 | 98 | $fix_utf8mb4 = function($string) use ($utf8, $smcFunc) |
| 89 | 99 | { |
| 90 | - if (!$utf8 || $smcFunc['db_mb4']) |
|
| 91 | - return $string; |
|
| 100 | + if (!$utf8 || $smcFunc['db_mb4']) { |
|
| 101 | + return $string; |
|
| 102 | + } |
|
| 92 | 103 | |
| 93 | 104 | $i = 0; |
| 94 | 105 | $len = strlen($string); |
@@ -100,18 +111,15 @@ discard block |
||
| 100 | 111 | { |
| 101 | 112 | $new_string .= $string[$i]; |
| 102 | 113 | $i++; |
| 103 | - } |
|
| 104 | - elseif ($ord < 224) |
|
| 114 | + } elseif ($ord < 224) |
|
| 105 | 115 | { |
| 106 | 116 | $new_string .= $string[$i] . $string[$i + 1]; |
| 107 | 117 | $i += 2; |
| 108 | - } |
|
| 109 | - elseif ($ord < 240) |
|
| 118 | + } elseif ($ord < 240) |
|
| 110 | 119 | { |
| 111 | 120 | $new_string .= $string[$i] . $string[$i + 1] . $string[$i + 2]; |
| 112 | 121 | $i += 3; |
| 113 | - } |
|
| 114 | - elseif ($ord < 248) |
|
| 122 | + } elseif ($ord < 248) |
|
| 115 | 123 | { |
| 116 | 124 | // Magic happens. |
| 117 | 125 | $val = (ord($string[$i]) & 0x07) << 18; |
@@ -155,8 +163,7 @@ discard block |
||
| 155 | 163 | { |
| 156 | 164 | $result = array_search($needle, array_slice($haystack_arr, $offset)); |
| 157 | 165 | return is_int($result) ? $result + $offset : false; |
| 158 | - } |
|
| 159 | - else |
|
| 166 | + } else |
|
| 160 | 167 | { |
| 161 | 168 | $needle_arr = preg_split('~(' . $ent_list . '|.)~' . ($utf8 ? 'u' : '') . '', $ent_check($needle), -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); |
| 162 | 169 | $needle_size = count($needle_arr); |
@@ -165,8 +172,9 @@ discard block |
||
| 165 | 172 | while ((int) $result === $result) |
| 166 | 173 | { |
| 167 | 174 | $offset += $result; |
| 168 | - if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr) |
|
| 169 | - return $offset; |
|
| 175 | + if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr) { |
|
| 176 | + return $offset; |
|
| 177 | + } |
|
| 170 | 178 | $result = array_search($needle_arr[0], array_slice($haystack_arr, ++$offset)); |
| 171 | 179 | } |
| 172 | 180 | return false; |
@@ -204,8 +212,9 @@ discard block |
||
| 204 | 212 | $string = $ent_check($string); |
| 205 | 213 | preg_match('~^(' . $ent_list . '|.){' . $smcFunc['strlen'](substr($string, 0, $length)) . '}~' . ($utf8 ? 'u' : ''), $string, $matches); |
| 206 | 214 | $string = $matches[0]; |
| 207 | - while (strlen($string) > $length) |
|
| 208 | - $string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string); |
|
| 215 | + while (strlen($string) > $length) { |
|
| 216 | + $string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string); |
|
| 217 | + } |
|
| 209 | 218 | return $string; |
| 210 | 219 | }, |
| 211 | 220 | 'ucfirst' => $utf8 ? function($string) use (&$smcFunc) |
@@ -215,8 +224,9 @@ discard block |
||
| 215 | 224 | 'ucwords' => $utf8 ? function($string) use (&$smcFunc) |
| 216 | 225 | { |
| 217 | 226 | $words = preg_split('~([\s\r\n\t]+)~', $string, -1, PREG_SPLIT_DELIM_CAPTURE); |
| 218 | - for ($i = 0, $n = count($words); $i < $n; $i += 2) |
|
| 219 | - $words[$i] = $smcFunc['ucfirst']($words[$i]); |
|
| 227 | + for ($i = 0, $n = count($words); $i < $n; $i += 2) { |
|
| 228 | + $words[$i] = $smcFunc['ucfirst']($words[$i]); |
|
| 229 | + } |
|
| 220 | 230 | return implode('', $words); |
| 221 | 231 | } : 'ucwords', |
| 222 | 232 | 'json_decode' => 'smf_json_decode', |
@@ -224,16 +234,17 @@ discard block |
||
| 224 | 234 | ); |
| 225 | 235 | |
| 226 | 236 | // Setting the timezone is a requirement for some functions. |
| 227 | - if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list())) |
|
| 228 | - date_default_timezone_set($modSettings['default_timezone']); |
|
| 229 | - else |
|
| 237 | + if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list())) { |
|
| 238 | + date_default_timezone_set($modSettings['default_timezone']); |
|
| 239 | + } else |
|
| 230 | 240 | { |
| 231 | 241 | // Get PHP's default timezone, if set |
| 232 | 242 | $ini_tz = ini_get('date.timezone'); |
| 233 | - if (!empty($ini_tz)) |
|
| 234 | - $modSettings['default_timezone'] = $ini_tz; |
|
| 235 | - else |
|
| 236 | - $modSettings['default_timezone'] = ''; |
|
| 243 | + if (!empty($ini_tz)) { |
|
| 244 | + $modSettings['default_timezone'] = $ini_tz; |
|
| 245 | + } else { |
|
| 246 | + $modSettings['default_timezone'] = ''; |
|
| 247 | + } |
|
| 237 | 248 | |
| 238 | 249 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
| 239 | 250 | if (!in_array($modSettings['default_timezone'], timezone_identifiers_list())) |
@@ -251,22 +262,26 @@ discard block |
||
| 251 | 262 | if (($modSettings['load_average'] = cache_get_data('loadavg', 90)) == null) |
| 252 | 263 | { |
| 253 | 264 | $modSettings['load_average'] = @file_get_contents('/proc/loadavg'); |
| 254 | - if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0) |
|
| 255 | - $modSettings['load_average'] = (float) $matches[1]; |
|
| 256 | - elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0) |
|
| 257 | - $modSettings['load_average'] = (float) $matches[1]; |
|
| 258 | - else |
|
| 259 | - unset($modSettings['load_average']); |
|
| 265 | + if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0) { |
|
| 266 | + $modSettings['load_average'] = (float) $matches[1]; |
|
| 267 | + } elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0) { |
|
| 268 | + $modSettings['load_average'] = (float) $matches[1]; |
|
| 269 | + } else { |
|
| 270 | + unset($modSettings['load_average']); |
|
| 271 | + } |
|
| 260 | 272 | |
| 261 | - if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
|
| 262 | - cache_put_data('loadavg', $modSettings['load_average'], 90); |
|
| 273 | + if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) { |
|
| 274 | + cache_put_data('loadavg', $modSettings['load_average'], 90); |
|
| 275 | + } |
|
| 263 | 276 | } |
| 264 | 277 | |
| 265 | - if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
|
| 266 | - call_integration_hook('integrate_load_average', array($modSettings['load_average'])); |
|
| 278 | + if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) { |
|
| 279 | + call_integration_hook('integrate_load_average', array($modSettings['load_average'])); |
|
| 280 | + } |
|
| 267 | 281 | |
| 268 | - if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum']) |
|
| 269 | - display_loadavg_error(); |
|
| 282 | + if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum']) { |
|
| 283 | + display_loadavg_error(); |
|
| 284 | + } |
|
| 270 | 285 | } |
| 271 | 286 | |
| 272 | 287 | // Is post moderation alive and well? Everywhere else assumes this has been defined, so let's make sure it is. |
@@ -287,8 +302,9 @@ discard block |
||
| 287 | 302 | if (defined('SMF_INTEGRATION_SETTINGS')) |
| 288 | 303 | { |
| 289 | 304 | $integration_settings = $smcFunc['json_decode'](SMF_INTEGRATION_SETTINGS, true); |
| 290 | - foreach ($integration_settings as $hook => $function) |
|
| 291 | - add_integration_function($hook, $function, '', false); |
|
| 305 | + foreach ($integration_settings as $hook => $function) { |
|
| 306 | + add_integration_function($hook, $function, '', false); |
|
| 307 | + } |
|
| 292 | 308 | } |
| 293 | 309 | |
| 294 | 310 | // Any files to pre include? |
@@ -298,8 +314,9 @@ discard block |
||
| 298 | 314 | foreach ($pre_includes as $include) |
| 299 | 315 | { |
| 300 | 316 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
| 301 | - if (file_exists($include)) |
|
| 302 | - require_once($include); |
|
| 317 | + if (file_exists($include)) { |
|
| 318 | + require_once($include); |
|
| 319 | + } |
|
| 303 | 320 | } |
| 304 | 321 | } |
| 305 | 322 | |
@@ -392,9 +409,9 @@ discard block |
||
| 392 | 409 | break; |
| 393 | 410 | } |
| 394 | 411 | } |
| 412 | + } else { |
|
| 413 | + $id_member = 0; |
|
| 395 | 414 | } |
| 396 | - else |
|
| 397 | - $id_member = 0; |
|
| 398 | 415 | |
| 399 | 416 | if (empty($id_member) && isset($_COOKIE[$cookiename])) |
| 400 | 417 | { |
@@ -402,8 +419,9 @@ discard block |
||
| 402 | 419 | $cookie_data = $smcFunc['json_decode']($_COOKIE[$cookiename], true, false); |
| 403 | 420 | |
| 404 | 421 | // Legacy format (for recent 2.0 --> 2.1 upgrades) |
| 405 | - if (empty($cookie_data)) |
|
| 406 | - $cookie_data = safe_unserialize($_COOKIE[$cookiename]); |
|
| 422 | + if (empty($cookie_data)) { |
|
| 423 | + $cookie_data = safe_unserialize($_COOKIE[$cookiename]); |
|
| 424 | + } |
|
| 407 | 425 | |
| 408 | 426 | list($id_member, $password, $login_span, $cookie_domain, $cookie_path) = array_pad((array) $cookie_data, 5, ''); |
| 409 | 427 | |
@@ -411,16 +429,17 @@ discard block |
||
| 411 | 429 | |
| 412 | 430 | // Make sure the cookie is set to the correct domain and path |
| 413 | 431 | require_once($sourcedir . '/Subs-Auth.php'); |
| 414 | - if (array($cookie_domain, $cookie_path) !== url_parts(!empty($modSettings['localCookies']), !empty($modSettings['globalCookies']))) |
|
| 415 | - setLoginCookie((int) $login_span - time(), $id_member); |
|
| 416 | - } |
|
| 417 | - elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA']))) |
|
| 432 | + if (array($cookie_domain, $cookie_path) !== url_parts(!empty($modSettings['localCookies']), !empty($modSettings['globalCookies']))) { |
|
| 433 | + setLoginCookie((int) $login_span - time(), $id_member); |
|
| 434 | + } |
|
| 435 | + } elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA']))) |
|
| 418 | 436 | { |
| 419 | 437 | // @todo Perhaps we can do some more checking on this, such as on the first octet of the IP? |
| 420 | 438 | $cookie_data = $smcFunc['json_decode']($_SESSION['login_' . $cookiename], true); |
| 421 | 439 | |
| 422 | - if (empty($cookie_data)) |
|
| 423 | - $cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
| 440 | + if (empty($cookie_data)) { |
|
| 441 | + $cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
| 442 | + } |
|
| 424 | 443 | |
| 425 | 444 | list($id_member, $password, $login_span) = array_pad((array) $cookie_data, 3, ''); |
| 426 | 445 | $id_member = !empty($id_member) && strlen($password) == 128 && (int) $login_span > time() ? (int) $id_member : 0; |
@@ -445,30 +464,34 @@ discard block |
||
| 445 | 464 | $user_settings = $smcFunc['db_fetch_assoc']($request); |
| 446 | 465 | $smcFunc['db_free_result']($request); |
| 447 | 466 | |
| 448 | - if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) |
|
| 449 | - $user_settings['avatar'] = get_proxied_url($user_settings['avatar']); |
|
| 467 | + if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) { |
|
| 468 | + $user_settings['avatar'] = get_proxied_url($user_settings['avatar']); |
|
| 469 | + } |
|
| 450 | 470 | |
| 451 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 452 | - cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
| 471 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 472 | + cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
| 473 | + } |
|
| 453 | 474 | } |
| 454 | 475 | |
| 455 | 476 | // Did we find 'im? If not, junk it. |
| 456 | 477 | if (!empty($user_settings)) |
| 457 | 478 | { |
| 458 | 479 | // 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; |
|
| 480 | + if (!empty($already_verified) && $already_verified === true) { |
|
| 481 | + $check = true; |
|
| 482 | + } |
|
| 461 | 483 | // 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; |
|
| 484 | + elseif (strlen($password) == 128) { |
|
| 485 | + $check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password; |
|
| 486 | + } else { |
|
| 487 | + $check = false; |
|
| 488 | + } |
|
| 466 | 489 | |
| 467 | 490 | // Wrong password or not activated - either way, you're going nowhere. |
| 468 | 491 | $id_member = $check && ($user_settings['is_activated'] == 1 || $user_settings['is_activated'] == 11) ? (int) $user_settings['id_member'] : 0; |
| 492 | + } else { |
|
| 493 | + $id_member = 0; |
|
| 469 | 494 | } |
| 470 | - else |
|
| 471 | - $id_member = 0; |
|
| 472 | 495 | |
| 473 | 496 | // If we no longer have the member maybe they're being all hackey, stop brute force! |
| 474 | 497 | if (!$id_member) |
@@ -497,8 +520,9 @@ discard block |
||
| 497 | 520 | |
| 498 | 521 | list ($tfamember, $tfasecret) = array_pad((array) $tfa_data, 2, ''); |
| 499 | 522 | |
| 500 | - if (!isset($tfamember, $tfasecret) || (int) $tfamember != $id_member) |
|
| 501 | - $tfasecret = null; |
|
| 523 | + if (!isset($tfamember, $tfasecret) || (int) $tfamember != $id_member) { |
|
| 524 | + $tfasecret = null; |
|
| 525 | + } |
|
| 502 | 526 | } |
| 503 | 527 | |
| 504 | 528 | // They didn't finish logging in before coming here? Then they're no one to us. |
@@ -520,10 +544,12 @@ discard block |
||
| 520 | 544 | // Are we forcing 2FA? Need to check if the user groups actually require 2FA |
| 521 | 545 | elseif (!empty($modSettings['tfa_mode']) && $modSettings['tfa_mode'] >= 2 && $id_member && empty($user_settings['tfa_secret'])) |
| 522 | 546 | { |
| 523 | - if ($modSettings['tfa_mode'] == 2) //only do this if we are just forcing SOME membergroups |
|
| 547 | + if ($modSettings['tfa_mode'] == 2) { |
|
| 548 | + //only do this if we are just forcing SOME membergroups |
|
| 524 | 549 | { |
| 525 | 550 | //Build an array of ALL user membergroups. |
| 526 | 551 | $full_groups = array($user_settings['id_group']); |
| 552 | + } |
|
| 527 | 553 | if (!empty($user_settings['additional_groups'])) |
| 528 | 554 | { |
| 529 | 555 | $full_groups = array_merge($full_groups, explode(',', $user_settings['additional_groups'])); |
@@ -543,15 +569,17 @@ discard block |
||
| 543 | 569 | ); |
| 544 | 570 | $row = $smcFunc['db_fetch_assoc']($request); |
| 545 | 571 | $smcFunc['db_free_result']($request); |
| 572 | + } else { |
|
| 573 | + $row['total'] = 1; |
|
| 546 | 574 | } |
| 547 | - else |
|
| 548 | - $row['total'] = 1; //simplifies logics in the next "if" |
|
| 575 | + //simplifies logics in the next "if" |
|
| 549 | 576 | |
| 550 | 577 | $area = !empty($_REQUEST['area']) ? $_REQUEST['area'] : ''; |
| 551 | 578 | $action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : ''; |
| 552 | 579 | |
| 553 | - if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) |
|
| 554 | - redirectexit('action=profile;area=tfasetup;forced'); |
|
| 580 | + if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) { |
|
| 581 | + redirectexit('action=profile;area=tfasetup;forced'); |
|
| 582 | + } |
|
| 555 | 583 | } |
| 556 | 584 | } |
| 557 | 585 | |
@@ -588,29 +616,32 @@ discard block |
||
| 588 | 616 | 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'])); |
| 589 | 617 | $user_settings['last_login'] = time(); |
| 590 | 618 | |
| 591 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 592 | - cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
| 619 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 620 | + cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
| 621 | + } |
|
| 593 | 622 | |
| 594 | - if (!empty($modSettings['cache_enable'])) |
|
| 595 | - cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600); |
|
| 623 | + if (!empty($modSettings['cache_enable'])) { |
|
| 624 | + cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600); |
|
| 625 | + } |
|
| 596 | 626 | } |
| 627 | + } elseif (empty($_SESSION['id_msg_last_visit'])) { |
|
| 628 | + $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit']; |
|
| 597 | 629 | } |
| 598 | - elseif (empty($_SESSION['id_msg_last_visit'])) |
|
| 599 | - $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit']; |
|
| 600 | 630 | |
| 601 | 631 | $username = $user_settings['member_name']; |
| 602 | 632 | |
| 603 | - if (empty($user_settings['additional_groups'])) |
|
| 604 | - $user_info = array( |
|
| 633 | + if (empty($user_settings['additional_groups'])) { |
|
| 634 | + $user_info = array( |
|
| 605 | 635 | 'groups' => array($user_settings['id_group'], $user_settings['id_post_group']) |
| 606 | 636 | ); |
| 607 | - else |
|
| 608 | - $user_info = array( |
|
| 637 | + } else { |
|
| 638 | + $user_info = array( |
|
| 609 | 639 | 'groups' => array_merge( |
| 610 | 640 | array($user_settings['id_group'], $user_settings['id_post_group']), |
| 611 | 641 | explode(',', $user_settings['additional_groups']) |
| 612 | 642 | ) |
| 613 | 643 | ); |
| 644 | + } |
|
| 614 | 645 | |
| 615 | 646 | // Because history has proven that it is possible for groups to go bad - clean up in case. |
| 616 | 647 | $user_info['groups'] = array_map('intval', $user_info['groups']); |
@@ -627,8 +658,7 @@ discard block |
||
| 627 | 658 | $time_system = new DateTime('now', $tz_system); |
| 628 | 659 | $time_user = new DateTime('now', $tz_user); |
| 629 | 660 | $user_info['time_offset'] = ($tz_user->getOffset($time_user) - $tz_system->getOffset($time_system)) / 3600; |
| 630 | - } |
|
| 631 | - else |
|
| 661 | + } else |
|
| 632 | 662 | { |
| 633 | 663 | // !!! Compatibility. |
| 634 | 664 | $user_info['time_offset'] = empty($user_settings['time_offset']) ? 0 : $user_settings['time_offset']; |
@@ -642,8 +672,9 @@ discard block |
||
| 642 | 672 | $user_info = array('groups' => array(-1)); |
| 643 | 673 | $user_settings = array(); |
| 644 | 674 | |
| 645 | - if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) |
|
| 646 | - $_COOKIE[$cookiename] = ''; |
|
| 675 | + if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) { |
|
| 676 | + $_COOKIE[$cookiename] = ''; |
|
| 677 | + } |
|
| 647 | 678 | |
| 648 | 679 | // Expire the 2FA cookie |
| 649 | 680 | if (isset($_COOKIE[$cookiename . '_tfa']) && empty($context['tfa_member'])) |
@@ -660,19 +691,20 @@ discard block |
||
| 660 | 691 | } |
| 661 | 692 | |
| 662 | 693 | // 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']; |
|
| 694 | + if (!isset($_SESSION['token']['post-login'])) { |
|
| 695 | + createToken('login'); |
|
| 696 | + } else { |
|
| 697 | + list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login']; |
|
| 698 | + } |
|
| 667 | 699 | |
| 668 | 700 | // Do we perhaps think this is a search robot? Check every five minutes just in case... |
| 669 | 701 | if ((!empty($modSettings['spider_mode']) || !empty($modSettings['spider_group'])) && (!isset($_SESSION['robot_check']) || $_SESSION['robot_check'] < time() - 300)) |
| 670 | 702 | { |
| 671 | 703 | require_once($sourcedir . '/ManageSearchEngines.php'); |
| 672 | 704 | $user_info['possibly_robot'] = SpiderCheck(); |
| 705 | + } elseif (!empty($modSettings['spider_mode'])) { |
|
| 706 | + $user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0; |
|
| 673 | 707 | } |
| 674 | - elseif (!empty($modSettings['spider_mode'])) |
|
| 675 | - $user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0; |
|
| 676 | 708 | // If we haven't turned on proper spider hunts then have a guess! |
| 677 | 709 | else |
| 678 | 710 | { |
@@ -720,8 +752,9 @@ discard block |
||
| 720 | 752 | $user_info['groups'] = array_unique($user_info['groups']); |
| 721 | 753 | |
| 722 | 754 | // 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]); |
|
| 755 | + if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) { |
|
| 756 | + unset($user_info['ignoreboards'][$tmp]); |
|
| 757 | + } |
|
| 725 | 758 | |
| 726 | 759 | // Allow the user to change their language. |
| 727 | 760 | if (!empty($modSettings['userLanguage'])) |
@@ -734,13 +767,14 @@ discard block |
||
| 734 | 767 | $user_info['language'] = strtr($_GET['language'], './\\:', '____'); |
| 735 | 768 | |
| 736 | 769 | // 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']; |
|
| 770 | + if (!empty($user_info['id'])) { |
|
| 771 | + updateMemberData($user_info['id'], array('lngfile' => $user_info['language'])); |
|
| 772 | + } else { |
|
| 773 | + $_SESSION['language'] = $user_info['language']; |
|
| 774 | + } |
|
| 775 | + } elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) { |
|
| 776 | + $user_info['language'] = strtr($_SESSION['language'], './\\:', '____'); |
|
| 741 | 777 | } |
| 742 | - elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) |
|
| 743 | - $user_info['language'] = strtr($_SESSION['language'], './\\:', '____'); |
|
| 744 | 778 | } |
| 745 | 779 | |
| 746 | 780 | $temp = build_query_board($user_info['id']); |
@@ -803,9 +837,9 @@ discard block |
||
| 803 | 837 | } |
| 804 | 838 | |
| 805 | 839 | // Remember redirection is the key to avoiding fallout from your bosses. |
| 806 | - if (!empty($topic)) |
|
| 807 | - redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']); |
|
| 808 | - else |
|
| 840 | + if (!empty($topic)) { |
|
| 841 | + redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']); |
|
| 842 | + } else |
|
| 809 | 843 | { |
| 810 | 844 | loadPermissions(); |
| 811 | 845 | loadTheme(); |
@@ -823,10 +857,11 @@ discard block |
||
| 823 | 857 | if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3)) |
| 824 | 858 | { |
| 825 | 859 | // @todo SLOW? |
| 826 | - if (!empty($topic)) |
|
| 827 | - $temp = cache_get_data('topic_board-' . $topic, 120); |
|
| 828 | - else |
|
| 829 | - $temp = cache_get_data('board-' . $board, 120); |
|
| 860 | + if (!empty($topic)) { |
|
| 861 | + $temp = cache_get_data('topic_board-' . $topic, 120); |
|
| 862 | + } else { |
|
| 863 | + $temp = cache_get_data('board-' . $board, 120); |
|
| 864 | + } |
|
| 830 | 865 | |
| 831 | 866 | if (!empty($temp)) |
| 832 | 867 | { |
@@ -864,8 +899,9 @@ discard block |
||
| 864 | 899 | $row = $smcFunc['db_fetch_assoc']($request); |
| 865 | 900 | |
| 866 | 901 | // Set the current board. |
| 867 | - if (!empty($row['id_board'])) |
|
| 868 | - $board = $row['id_board']; |
|
| 902 | + if (!empty($row['id_board'])) { |
|
| 903 | + $board = $row['id_board']; |
|
| 904 | + } |
|
| 869 | 905 | |
| 870 | 906 | // Basic operating information. (globals... :/) |
| 871 | 907 | $board_info = array( |
@@ -901,21 +937,23 @@ discard block |
||
| 901 | 937 | |
| 902 | 938 | do |
| 903 | 939 | { |
| 904 | - if (!empty($row['id_moderator'])) |
|
| 905 | - $board_info['moderators'][$row['id_moderator']] = array( |
|
| 940 | + if (!empty($row['id_moderator'])) { |
|
| 941 | + $board_info['moderators'][$row['id_moderator']] = array( |
|
| 906 | 942 | 'id' => $row['id_moderator'], |
| 907 | 943 | 'name' => $row['real_name'], |
| 908 | 944 | 'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'], |
| 909 | 945 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>' |
| 910 | 946 | ); |
| 947 | + } |
|
| 911 | 948 | |
| 912 | - if (!empty($row['id_moderator_group'])) |
|
| 913 | - $board_info['moderator_groups'][$row['id_moderator_group']] = array( |
|
| 949 | + if (!empty($row['id_moderator_group'])) { |
|
| 950 | + $board_info['moderator_groups'][$row['id_moderator_group']] = array( |
|
| 914 | 951 | 'id' => $row['id_moderator_group'], |
| 915 | 952 | 'name' => $row['group_name'], |
| 916 | 953 | 'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'], |
| 917 | 954 | 'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>' |
| 918 | 955 | ); |
| 956 | + } |
|
| 919 | 957 | } |
| 920 | 958 | while ($row = $smcFunc['db_fetch_assoc']($request)); |
| 921 | 959 | |
@@ -947,12 +985,12 @@ discard block |
||
| 947 | 985 | if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3)) |
| 948 | 986 | { |
| 949 | 987 | // @todo SLOW? |
| 950 | - if (!empty($topic)) |
|
| 951 | - cache_put_data('topic_board-' . $topic, $board_info, 120); |
|
| 988 | + if (!empty($topic)) { |
|
| 989 | + cache_put_data('topic_board-' . $topic, $board_info, 120); |
|
| 990 | + } |
|
| 952 | 991 | cache_put_data('board-' . $board, $board_info, 120); |
| 953 | 992 | } |
| 954 | - } |
|
| 955 | - else |
|
| 993 | + } else |
|
| 956 | 994 | { |
| 957 | 995 | // Otherwise the topic is invalid, there are no moderators, etc. |
| 958 | 996 | $board_info = array( |
@@ -966,8 +1004,9 @@ discard block |
||
| 966 | 1004 | $smcFunc['db_free_result']($request); |
| 967 | 1005 | } |
| 968 | 1006 | |
| 969 | - if (!empty($topic)) |
|
| 970 | - $_GET['board'] = (int) $board; |
|
| 1007 | + if (!empty($topic)) { |
|
| 1008 | + $_GET['board'] = (int) $board; |
|
| 1009 | + } |
|
| 971 | 1010 | |
| 972 | 1011 | if (!empty($board)) |
| 973 | 1012 | { |
@@ -977,10 +1016,12 @@ discard block |
||
| 977 | 1016 | // Now check if the user is a moderator. |
| 978 | 1017 | $user_info['is_mod'] = isset($board_info['moderators'][$user_info['id']]) || count(array_intersect($user_info['groups'], $moderator_groups)) != 0; |
| 979 | 1018 | |
| 980 | - if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) |
|
| 981 | - $board_info['error'] = 'access'; |
|
| 982 | - if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) |
|
| 983 | - $board_info['error'] = 'access'; |
|
| 1019 | + if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) { |
|
| 1020 | + $board_info['error'] = 'access'; |
|
| 1021 | + } |
|
| 1022 | + if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) { |
|
| 1023 | + $board_info['error'] = 'access'; |
|
| 1024 | + } |
|
| 984 | 1025 | |
| 985 | 1026 | // Build up the linktree. |
| 986 | 1027 | $context['linktree'] = array_merge( |
@@ -1003,8 +1044,9 @@ discard block |
||
| 1003 | 1044 | $context['current_board'] = $board; |
| 1004 | 1045 | |
| 1005 | 1046 | // No posting in redirection boards! |
| 1006 | - if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) |
|
| 1007 | - $board_info['error'] == 'post_in_redirect'; |
|
| 1047 | + if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) { |
|
| 1048 | + $board_info['error'] == 'post_in_redirect'; |
|
| 1049 | + } |
|
| 1008 | 1050 | |
| 1009 | 1051 | // Hacker... you can't see this topic, I'll tell you that. (but moderators can!) |
| 1010 | 1052 | if (!empty($board_info['error']) && (!empty($modSettings['deny_boards_access']) || $board_info['error'] != 'access' || !$user_info['is_mod'])) |
@@ -1030,24 +1072,23 @@ discard block |
||
| 1030 | 1072 | ob_end_clean(); |
| 1031 | 1073 | header('HTTP/1.1 403 Forbidden'); |
| 1032 | 1074 | die; |
| 1033 | - } |
|
| 1034 | - elseif ($board_info['error'] == 'post_in_redirect') |
|
| 1075 | + } elseif ($board_info['error'] == 'post_in_redirect') |
|
| 1035 | 1076 | { |
| 1036 | 1077 | // Slightly different error message here... |
| 1037 | 1078 | fatal_lang_error('cannot_post_redirect', false); |
| 1038 | - } |
|
| 1039 | - elseif ($user_info['is_guest']) |
|
| 1079 | + } elseif ($user_info['is_guest']) |
|
| 1040 | 1080 | { |
| 1041 | 1081 | loadLanguage('Errors'); |
| 1042 | 1082 | is_not_guest($txt['topic_gone']); |
| 1083 | + } else { |
|
| 1084 | + fatal_lang_error('topic_gone', false); |
|
| 1043 | 1085 | } |
| 1044 | - else |
|
| 1045 | - fatal_lang_error('topic_gone', false); |
|
| 1046 | 1086 | } |
| 1047 | 1087 | |
| 1048 | - if ($user_info['is_mod']) |
|
| 1049 | - $user_info['groups'][] = 3; |
|
| 1050 | -} |
|
| 1088 | + if ($user_info['is_mod']) { |
|
| 1089 | + $user_info['groups'][] = 3; |
|
| 1090 | + } |
|
| 1091 | + } |
|
| 1051 | 1092 | |
| 1052 | 1093 | /** |
| 1053 | 1094 | * Load this user's permissions. |
@@ -1068,8 +1109,9 @@ discard block |
||
| 1068 | 1109 | asort($cache_groups); |
| 1069 | 1110 | $cache_groups = implode(',', $cache_groups); |
| 1070 | 1111 | // If it's a spider then cache it different. |
| 1071 | - if ($user_info['possibly_robot']) |
|
| 1072 | - $cache_groups .= '-spider'; |
|
| 1112 | + if ($user_info['possibly_robot']) { |
|
| 1113 | + $cache_groups .= '-spider'; |
|
| 1114 | + } |
|
| 1073 | 1115 | |
| 1074 | 1116 | if ($modSettings['cache_enable'] >= 2 && !empty($board) && ($temp = cache_get_data('permissions:' . $cache_groups . ':' . $board, 240)) != null && time() - 240 > $modSettings['settings_updated']) |
| 1075 | 1117 | { |
@@ -1077,9 +1119,9 @@ discard block |
||
| 1077 | 1119 | banPermissions(); |
| 1078 | 1120 | |
| 1079 | 1121 | return; |
| 1122 | + } elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) { |
|
| 1123 | + list ($user_info['permissions'], $removals) = $temp; |
|
| 1080 | 1124 | } |
| 1081 | - elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) |
|
| 1082 | - list ($user_info['permissions'], $removals) = $temp; |
|
| 1083 | 1125 | } |
| 1084 | 1126 | |
| 1085 | 1127 | // If it is detected as a robot, and we are restricting permissions as a special group - then implement this. |
@@ -1101,23 +1143,26 @@ discard block |
||
| 1101 | 1143 | $removals = array(); |
| 1102 | 1144 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1103 | 1145 | { |
| 1104 | - if (empty($row['add_deny'])) |
|
| 1105 | - $removals[] = $row['permission']; |
|
| 1106 | - else |
|
| 1107 | - $user_info['permissions'][] = $row['permission']; |
|
| 1146 | + if (empty($row['add_deny'])) { |
|
| 1147 | + $removals[] = $row['permission']; |
|
| 1148 | + } else { |
|
| 1149 | + $user_info['permissions'][] = $row['permission']; |
|
| 1150 | + } |
|
| 1108 | 1151 | } |
| 1109 | 1152 | $smcFunc['db_free_result']($request); |
| 1110 | 1153 | |
| 1111 | - if (isset($cache_groups)) |
|
| 1112 | - cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240); |
|
| 1154 | + if (isset($cache_groups)) { |
|
| 1155 | + cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240); |
|
| 1156 | + } |
|
| 1113 | 1157 | } |
| 1114 | 1158 | |
| 1115 | 1159 | // Get the board permissions. |
| 1116 | 1160 | if (!empty($board)) |
| 1117 | 1161 | { |
| 1118 | 1162 | // Make sure the board (if any) has been loaded by loadBoard(). |
| 1119 | - if (!isset($board_info['profile'])) |
|
| 1120 | - fatal_lang_error('no_board'); |
|
| 1163 | + if (!isset($board_info['profile'])) { |
|
| 1164 | + fatal_lang_error('no_board'); |
|
| 1165 | + } |
|
| 1121 | 1166 | |
| 1122 | 1167 | $request = $smcFunc['db_query']('', ' |
| 1123 | 1168 | SELECT permission, add_deny |
@@ -1133,20 +1178,23 @@ discard block |
||
| 1133 | 1178 | ); |
| 1134 | 1179 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1135 | 1180 | { |
| 1136 | - if (empty($row['add_deny'])) |
|
| 1137 | - $removals[] = $row['permission']; |
|
| 1138 | - else |
|
| 1139 | - $user_info['permissions'][] = $row['permission']; |
|
| 1181 | + if (empty($row['add_deny'])) { |
|
| 1182 | + $removals[] = $row['permission']; |
|
| 1183 | + } else { |
|
| 1184 | + $user_info['permissions'][] = $row['permission']; |
|
| 1185 | + } |
|
| 1140 | 1186 | } |
| 1141 | 1187 | $smcFunc['db_free_result']($request); |
| 1142 | 1188 | } |
| 1143 | 1189 | |
| 1144 | 1190 | // Remove all the permissions they shouldn't have ;). |
| 1145 | - if (!empty($modSettings['permission_enable_deny'])) |
|
| 1146 | - $user_info['permissions'] = array_diff($user_info['permissions'], $removals); |
|
| 1191 | + if (!empty($modSettings['permission_enable_deny'])) { |
|
| 1192 | + $user_info['permissions'] = array_diff($user_info['permissions'], $removals); |
|
| 1193 | + } |
|
| 1147 | 1194 | |
| 1148 | - if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) |
|
| 1149 | - cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240); |
|
| 1195 | + if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) { |
|
| 1196 | + cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240); |
|
| 1197 | + } |
|
| 1150 | 1198 | |
| 1151 | 1199 | // Banned? Watch, don't touch.. |
| 1152 | 1200 | banPermissions(); |
@@ -1158,17 +1206,18 @@ discard block |
||
| 1158 | 1206 | { |
| 1159 | 1207 | require_once($sourcedir . '/Subs-Auth.php'); |
| 1160 | 1208 | rebuildModCache(); |
| 1209 | + } else { |
|
| 1210 | + $user_info['mod_cache'] = $_SESSION['mc']; |
|
| 1161 | 1211 | } |
| 1162 | - else |
|
| 1163 | - $user_info['mod_cache'] = $_SESSION['mc']; |
|
| 1164 | 1212 | |
| 1165 | 1213 | // This is a useful phantom permission added to the current user, and only the current user while they are logged in. |
| 1166 | 1214 | // For example this drastically simplifies certain changes to the profile area. |
| 1167 | 1215 | $user_info['permissions'][] = 'is_not_guest'; |
| 1168 | 1216 | // And now some backwards compatibility stuff for mods and whatnot that aren't expecting the new permissions. |
| 1169 | 1217 | $user_info['permissions'][] = 'profile_view_own'; |
| 1170 | - if (in_array('profile_view', $user_info['permissions'])) |
|
| 1171 | - $user_info['permissions'][] = 'profile_view_any'; |
|
| 1218 | + if (in_array('profile_view', $user_info['permissions'])) { |
|
| 1219 | + $user_info['permissions'][] = 'profile_view_any'; |
|
| 1220 | + } |
|
| 1172 | 1221 | } |
| 1173 | 1222 | } |
| 1174 | 1223 | |
@@ -1186,8 +1235,9 @@ discard block |
||
| 1186 | 1235 | global $image_proxy_enabled, $user_info; |
| 1187 | 1236 | |
| 1188 | 1237 | // Can't just look for no users :P. |
| 1189 | - if (empty($users)) |
|
| 1190 | - return array(); |
|
| 1238 | + if (empty($users)) { |
|
| 1239 | + return array(); |
|
| 1240 | + } |
|
| 1191 | 1241 | |
| 1192 | 1242 | // Pass the set value |
| 1193 | 1243 | $context['loadMemberContext_set'] = $set; |
@@ -1202,8 +1252,9 @@ discard block |
||
| 1202 | 1252 | for ($i = 0, $n = count($users); $i < $n; $i++) |
| 1203 | 1253 | { |
| 1204 | 1254 | $data = cache_get_data('member_data-' . $set . '-' . $users[$i], 240); |
| 1205 | - if ($data == null) |
|
| 1206 | - continue; |
|
| 1255 | + if ($data == null) { |
|
| 1256 | + continue; |
|
| 1257 | + } |
|
| 1207 | 1258 | |
| 1208 | 1259 | $loaded_ids[] = $data['id_member']; |
| 1209 | 1260 | $user_profile[$data['id_member']] = $data; |
@@ -1270,16 +1321,19 @@ discard block |
||
| 1270 | 1321 | $row['avatar_original'] = !empty($row['avatar']) ? $row['avatar'] : ''; |
| 1271 | 1322 | |
| 1272 | 1323 | // Take care of proxying avatar if required, do this here for maximum reach |
| 1273 | - if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) |
|
| 1274 | - $row['avatar'] = get_proxied_url($row['avatar']); |
|
| 1324 | + if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) { |
|
| 1325 | + $row['avatar'] = get_proxied_url($row['avatar']); |
|
| 1326 | + } |
|
| 1275 | 1327 | |
| 1276 | 1328 | // Keep track of the member's normal member group |
| 1277 | 1329 | $row['primary_group'] = !empty($row['member_group']) ? $row['member_group'] : ''; |
| 1278 | 1330 | |
| 1279 | - if (isset($row['member_ip'])) |
|
| 1280 | - $row['member_ip'] = inet_dtop($row['member_ip']); |
|
| 1281 | - if (isset($row['member_ip2'])) |
|
| 1282 | - $row['member_ip2'] = inet_dtop($row['member_ip2']); |
|
| 1331 | + if (isset($row['member_ip'])) { |
|
| 1332 | + $row['member_ip'] = inet_dtop($row['member_ip']); |
|
| 1333 | + } |
|
| 1334 | + if (isset($row['member_ip2'])) { |
|
| 1335 | + $row['member_ip2'] = inet_dtop($row['member_ip2']); |
|
| 1336 | + } |
|
| 1283 | 1337 | $new_loaded_ids[] = $row['id_member']; |
| 1284 | 1338 | $loaded_ids[] = $row['id_member']; |
| 1285 | 1339 | $row['options'] = array(); |
@@ -1298,8 +1352,9 @@ discard block |
||
| 1298 | 1352 | 'loaded_ids' => $new_loaded_ids, |
| 1299 | 1353 | ) |
| 1300 | 1354 | ); |
| 1301 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1302 | - $user_profile[$row['id_member']]['options'][$row['variable']] = $row['value']; |
|
| 1355 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1356 | + $user_profile[$row['id_member']]['options'][$row['variable']] = $row['value']; |
|
| 1357 | + } |
|
| 1303 | 1358 | $smcFunc['db_free_result']($request); |
| 1304 | 1359 | } |
| 1305 | 1360 | |
@@ -1310,10 +1365,11 @@ discard block |
||
| 1310 | 1365 | { |
| 1311 | 1366 | foreach ($loaded_ids as $a_member) |
| 1312 | 1367 | { |
| 1313 | - if (!empty($user_profile[$a_member]['additional_groups'])) |
|
| 1314 | - $groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups'])); |
|
| 1315 | - else |
|
| 1316 | - $groups = array($user_profile[$a_member]['id_group']); |
|
| 1368 | + if (!empty($user_profile[$a_member]['additional_groups'])) { |
|
| 1369 | + $groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups'])); |
|
| 1370 | + } else { |
|
| 1371 | + $groups = array($user_profile[$a_member]['id_group']); |
|
| 1372 | + } |
|
| 1317 | 1373 | |
| 1318 | 1374 | $temp = array_intersect($groups, array_keys($board_info['moderator_groups'])); |
| 1319 | 1375 | |
@@ -1326,8 +1382,9 @@ discard block |
||
| 1326 | 1382 | |
| 1327 | 1383 | if (!empty($new_loaded_ids) && !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) |
| 1328 | 1384 | { |
| 1329 | - for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) |
|
| 1330 | - cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240); |
|
| 1385 | + for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) { |
|
| 1386 | + cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240); |
|
| 1387 | + } |
|
| 1331 | 1388 | } |
| 1332 | 1389 | |
| 1333 | 1390 | // Are we loading any moderators? If so, fix their group data... |
@@ -1353,14 +1410,17 @@ discard block |
||
| 1353 | 1410 | foreach ($temp_mods as $id) |
| 1354 | 1411 | { |
| 1355 | 1412 | // By popular demand, don't show admins or global moderators as moderators. |
| 1356 | - if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) |
|
| 1357 | - $user_profile[$id]['member_group'] = $row['member_group']; |
|
| 1413 | + if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) { |
|
| 1414 | + $user_profile[$id]['member_group'] = $row['member_group']; |
|
| 1415 | + } |
|
| 1358 | 1416 | |
| 1359 | 1417 | // If the Moderator group has no color or icons, but their group does... don't overwrite. |
| 1360 | - if (!empty($row['icons'])) |
|
| 1361 | - $user_profile[$id]['icons'] = $row['icons']; |
|
| 1362 | - if (!empty($row['member_group_color'])) |
|
| 1363 | - $user_profile[$id]['member_group_color'] = $row['member_group_color']; |
|
| 1418 | + if (!empty($row['icons'])) { |
|
| 1419 | + $user_profile[$id]['icons'] = $row['icons']; |
|
| 1420 | + } |
|
| 1421 | + if (!empty($row['member_group_color'])) { |
|
| 1422 | + $user_profile[$id]['member_group_color'] = $row['member_group_color']; |
|
| 1423 | + } |
|
| 1364 | 1424 | } |
| 1365 | 1425 | } |
| 1366 | 1426 | |
@@ -1382,12 +1442,14 @@ discard block |
||
| 1382 | 1442 | static $loadedLanguages = array(); |
| 1383 | 1443 | |
| 1384 | 1444 | // If this person's data is already loaded, skip it. |
| 1385 | - if (isset($dataLoaded[$user])) |
|
| 1386 | - return true; |
|
| 1445 | + if (isset($dataLoaded[$user])) { |
|
| 1446 | + return true; |
|
| 1447 | + } |
|
| 1387 | 1448 | |
| 1388 | 1449 | // We can't load guests or members not loaded by loadMemberData()! |
| 1389 | - if ($user == 0) |
|
| 1390 | - return false; |
|
| 1450 | + if ($user == 0) { |
|
| 1451 | + return false; |
|
| 1452 | + } |
|
| 1391 | 1453 | if (!isset($user_profile[$user])) |
| 1392 | 1454 | { |
| 1393 | 1455 | trigger_error('loadMemberContext(): member id ' . $user . ' not previously loaded by loadMemberData()', E_USER_WARNING); |
@@ -1413,12 +1475,16 @@ discard block |
||
| 1413 | 1475 | $buddy_list = !empty($profile['buddy_list']) ? explode(',', $profile['buddy_list']) : array(); |
| 1414 | 1476 | |
| 1415 | 1477 | //We need a little fallback for the membergroup icons. If it doesn't exist in the current theme, fallback to default theme |
| 1416 | - if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) //icon is set and exists |
|
| 1478 | + if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) { |
|
| 1479 | + //icon is set and exists |
|
| 1417 | 1480 | $group_icon_url = $settings['images_url'] . '/membericons/' . $profile['icons'][1]; |
| 1418 | - elseif (isset($profile['icons'][1])) //icon is set and doesn't exist, fallback to default |
|
| 1481 | + } elseif (isset($profile['icons'][1])) { |
|
| 1482 | + //icon is set and doesn't exist, fallback to default |
|
| 1419 | 1483 | $group_icon_url = $settings['default_images_url'] . '/membericons/' . $profile['icons'][1]; |
| 1420 | - else //not set, bye bye |
|
| 1484 | + } else { |
|
| 1485 | + //not set, bye bye |
|
| 1421 | 1486 | $group_icon_url = ''; |
| 1487 | + } |
|
| 1422 | 1488 | |
| 1423 | 1489 | // These minimal values are always loaded |
| 1424 | 1490 | $memberContext[$user] = array( |
@@ -1437,8 +1503,9 @@ discard block |
||
| 1437 | 1503 | if ($context['loadMemberContext_set'] != 'minimal') |
| 1438 | 1504 | { |
| 1439 | 1505 | // Go the extra mile and load the user's native language name. |
| 1440 | - if (empty($loadedLanguages)) |
|
| 1441 | - $loadedLanguages = getLanguages(); |
|
| 1506 | + if (empty($loadedLanguages)) { |
|
| 1507 | + $loadedLanguages = getLanguages(); |
|
| 1508 | + } |
|
| 1442 | 1509 | |
| 1443 | 1510 | $memberContext[$user] += array( |
| 1444 | 1511 | 'username_color' => '<span ' . (!empty($profile['member_group_color']) ? 'style="color:' . $profile['member_group_color'] . ';"' : '') . '>' . $profile['member_name'] . '</span>', |
@@ -1493,31 +1560,33 @@ discard block |
||
| 1493 | 1560 | { |
| 1494 | 1561 | if (!empty($modSettings['gravatarOverride']) || (!empty($modSettings['gravatarEnabled']) && stristr($profile['avatar'], 'gravatar://'))) |
| 1495 | 1562 | { |
| 1496 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) |
|
| 1497 | - $image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11)); |
|
| 1498 | - else |
|
| 1499 | - $image = get_gravatar_url($profile['email_address']); |
|
| 1500 | - } |
|
| 1501 | - else |
|
| 1563 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) { |
|
| 1564 | + $image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11)); |
|
| 1565 | + } else { |
|
| 1566 | + $image = get_gravatar_url($profile['email_address']); |
|
| 1567 | + } |
|
| 1568 | + } else |
|
| 1502 | 1569 | { |
| 1503 | 1570 | // So it's stored in the member table? |
| 1504 | 1571 | if (!empty($profile['avatar'])) |
| 1505 | 1572 | { |
| 1506 | 1573 | $image = (stristr($profile['avatar'], 'http://') || stristr($profile['avatar'], 'https://')) ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar']; |
| 1574 | + } elseif (!empty($profile['filename'])) { |
|
| 1575 | + $image = $modSettings['custom_avatar_url'] . '/' . $profile['filename']; |
|
| 1507 | 1576 | } |
| 1508 | - elseif (!empty($profile['filename'])) |
|
| 1509 | - $image = $modSettings['custom_avatar_url'] . '/' . $profile['filename']; |
|
| 1510 | 1577 | // Right... no avatar...use the default one |
| 1511 | - else |
|
| 1512 | - $image = $modSettings['avatar_url'] . '/default.png'; |
|
| 1578 | + else { |
|
| 1579 | + $image = $modSettings['avatar_url'] . '/default.png'; |
|
| 1580 | + } |
|
| 1513 | 1581 | } |
| 1514 | - if (!empty($image)) |
|
| 1515 | - $memberContext[$user]['avatar'] = array( |
|
| 1582 | + if (!empty($image)) { |
|
| 1583 | + $memberContext[$user]['avatar'] = array( |
|
| 1516 | 1584 | 'name' => $profile['avatar'], |
| 1517 | 1585 | 'image' => '<img class="avatar" src="' . $image . '" alt="avatar_' . $profile['member_name'] . '">', |
| 1518 | 1586 | 'href' => $image, |
| 1519 | 1587 | 'url' => $image, |
| 1520 | 1588 | ); |
| 1589 | + } |
|
| 1521 | 1590 | } |
| 1522 | 1591 | |
| 1523 | 1592 | // Are we also loading the members custom fields into context? |
@@ -1525,13 +1594,15 @@ discard block |
||
| 1525 | 1594 | { |
| 1526 | 1595 | $memberContext[$user]['custom_fields'] = array(); |
| 1527 | 1596 | |
| 1528 | - if (!isset($context['display_fields'])) |
|
| 1529 | - $context['display_fields'] = $smcFunc['json_decode']($modSettings['displayFields'], true); |
|
| 1597 | + if (!isset($context['display_fields'])) { |
|
| 1598 | + $context['display_fields'] = $smcFunc['json_decode']($modSettings['displayFields'], true); |
|
| 1599 | + } |
|
| 1530 | 1600 | |
| 1531 | 1601 | foreach ($context['display_fields'] as $custom) |
| 1532 | 1602 | { |
| 1533 | - if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) |
|
| 1534 | - continue; |
|
| 1603 | + if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) { |
|
| 1604 | + continue; |
|
| 1605 | + } |
|
| 1535 | 1606 | |
| 1536 | 1607 | $value = $profile['options'][$custom['col_name']]; |
| 1537 | 1608 | |
@@ -1539,31 +1610,36 @@ discard block |
||
| 1539 | 1610 | $currentKey = 0; |
| 1540 | 1611 | |
| 1541 | 1612 | // Create a key => value array for multiple options fields |
| 1542 | - if (!empty($custom['options'])) |
|
| 1543 | - foreach ($custom['options'] as $k => $v) |
|
| 1613 | + if (!empty($custom['options'])) { |
|
| 1614 | + foreach ($custom['options'] as $k => $v) |
|
| 1544 | 1615 | { |
| 1545 | 1616 | $fieldOptions[] = $v; |
| 1546 | - if (empty($currentKey)) |
|
| 1547 | - $currentKey = $v == $value ? $k : 0; |
|
| 1617 | + } |
|
| 1618 | + if (empty($currentKey)) { |
|
| 1619 | + $currentKey = $v == $value ? $k : 0; |
|
| 1620 | + } |
|
| 1548 | 1621 | } |
| 1549 | 1622 | |
| 1550 | 1623 | // BBC? |
| 1551 | - if ($custom['bbc']) |
|
| 1552 | - $value = parse_bbc($value); |
|
| 1624 | + if ($custom['bbc']) { |
|
| 1625 | + $value = parse_bbc($value); |
|
| 1626 | + } |
|
| 1553 | 1627 | |
| 1554 | 1628 | // ... or checkbox? |
| 1555 | - elseif (isset($custom['type']) && $custom['type'] == 'check') |
|
| 1556 | - $value = $value ? $txt['yes'] : $txt['no']; |
|
| 1629 | + elseif (isset($custom['type']) && $custom['type'] == 'check') { |
|
| 1630 | + $value = $value ? $txt['yes'] : $txt['no']; |
|
| 1631 | + } |
|
| 1557 | 1632 | |
| 1558 | 1633 | // Enclosing the user input within some other text? |
| 1559 | - if (!empty($custom['enclose'])) |
|
| 1560 | - $value = strtr($custom['enclose'], array( |
|
| 1634 | + if (!empty($custom['enclose'])) { |
|
| 1635 | + $value = strtr($custom['enclose'], array( |
|
| 1561 | 1636 | '{SCRIPTURL}' => $scripturl, |
| 1562 | 1637 | '{IMAGES_URL}' => $settings['images_url'], |
| 1563 | 1638 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
| 1564 | 1639 | '{INPUT}' => $value, |
| 1565 | 1640 | '{KEY}' => $currentKey, |
| 1566 | 1641 | )); |
| 1642 | + } |
|
| 1567 | 1643 | |
| 1568 | 1644 | $memberContext[$user]['custom_fields'][] = array( |
| 1569 | 1645 | 'title' => !empty($custom['title']) ? $custom['title'] : $custom['col_name'], |
@@ -1590,8 +1666,9 @@ discard block |
||
| 1590 | 1666 | global $smcFunc, $txt, $scripturl, $settings; |
| 1591 | 1667 | |
| 1592 | 1668 | // Do not waste my time... |
| 1593 | - if (empty($users) || empty($params)) |
|
| 1594 | - return false; |
|
| 1669 | + if (empty($users) || empty($params)) { |
|
| 1670 | + return false; |
|
| 1671 | + } |
|
| 1595 | 1672 | |
| 1596 | 1673 | // Make sure it's an array. |
| 1597 | 1674 | $users = !is_array($users) ? array($users) : array_unique($users); |
@@ -1618,41 +1695,48 @@ discard block |
||
| 1618 | 1695 | $currentKey = 0; |
| 1619 | 1696 | |
| 1620 | 1697 | // Create a key => value array for multiple options fields |
| 1621 | - if (!empty($row['field_options'])) |
|
| 1622 | - foreach (explode(',', $row['field_options']) as $k => $v) |
|
| 1698 | + if (!empty($row['field_options'])) { |
|
| 1699 | + foreach (explode(',', $row['field_options']) as $k => $v) |
|
| 1623 | 1700 | { |
| 1624 | 1701 | $fieldOptions[] = $v; |
| 1625 | - if (empty($currentKey)) |
|
| 1626 | - $currentKey = $v == $row['value'] ? $k : 0; |
|
| 1702 | + } |
|
| 1703 | + if (empty($currentKey)) { |
|
| 1704 | + $currentKey = $v == $row['value'] ? $k : 0; |
|
| 1705 | + } |
|
| 1627 | 1706 | } |
| 1628 | 1707 | |
| 1629 | 1708 | // BBC? |
| 1630 | - if (!empty($row['bbc'])) |
|
| 1631 | - $row['value'] = parse_bbc($row['value']); |
|
| 1709 | + if (!empty($row['bbc'])) { |
|
| 1710 | + $row['value'] = parse_bbc($row['value']); |
|
| 1711 | + } |
|
| 1632 | 1712 | |
| 1633 | 1713 | // ... or checkbox? |
| 1634 | - elseif (isset($row['type']) && $row['type'] == 'check') |
|
| 1635 | - $row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no']; |
|
| 1714 | + elseif (isset($row['type']) && $row['type'] == 'check') { |
|
| 1715 | + $row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no']; |
|
| 1716 | + } |
|
| 1636 | 1717 | |
| 1637 | 1718 | // Enclosing the user input within some other text? |
| 1638 | - if (!empty($row['enclose'])) |
|
| 1639 | - $row['value'] = strtr($row['enclose'], array( |
|
| 1719 | + if (!empty($row['enclose'])) { |
|
| 1720 | + $row['value'] = strtr($row['enclose'], array( |
|
| 1640 | 1721 | '{SCRIPTURL}' => $scripturl, |
| 1641 | 1722 | '{IMAGES_URL}' => $settings['images_url'], |
| 1642 | 1723 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
| 1643 | 1724 | '{INPUT}' => un_htmlspecialchars($row['value']), |
| 1644 | 1725 | '{KEY}' => $currentKey, |
| 1645 | 1726 | )); |
| 1727 | + } |
|
| 1646 | 1728 | |
| 1647 | 1729 | // Send a simple array if there is just 1 param |
| 1648 | - if (count($params) == 1) |
|
| 1649 | - $return[$row['id_member']] = $row; |
|
| 1730 | + if (count($params) == 1) { |
|
| 1731 | + $return[$row['id_member']] = $row; |
|
| 1732 | + } |
|
| 1650 | 1733 | |
| 1651 | 1734 | // More than 1? knock yourself out... |
| 1652 | 1735 | else |
| 1653 | 1736 | { |
| 1654 | - if (!isset($return[$row['id_member']])) |
|
| 1655 | - $return[$row['id_member']] = array(); |
|
| 1737 | + if (!isset($return[$row['id_member']])) { |
|
| 1738 | + $return[$row['id_member']] = array(); |
|
| 1739 | + } |
|
| 1656 | 1740 | |
| 1657 | 1741 | $return[$row['id_member']][$row['variable']] = $row; |
| 1658 | 1742 | } |
@@ -1686,8 +1770,9 @@ discard block |
||
| 1686 | 1770 | global $context; |
| 1687 | 1771 | |
| 1688 | 1772 | // Don't know any browser! |
| 1689 | - if (empty($context['browser'])) |
|
| 1690 | - detectBrowser(); |
|
| 1773 | + if (empty($context['browser'])) { |
|
| 1774 | + detectBrowser(); |
|
| 1775 | + } |
|
| 1691 | 1776 | |
| 1692 | 1777 | return !empty($context['browser'][$browser]) || !empty($context['browser']['is_' . $browser]) ? true : false; |
| 1693 | 1778 | } |
@@ -1705,8 +1790,9 @@ discard block |
||
| 1705 | 1790 | global $context, $settings, $options, $sourcedir, $ssi_theme, $smcFunc, $language, $board, $image_proxy_enabled; |
| 1706 | 1791 | |
| 1707 | 1792 | // The theme was specified by parameter. |
| 1708 | - if (!empty($id_theme)) |
|
| 1709 | - $id_theme = (int) $id_theme; |
|
| 1793 | + if (!empty($id_theme)) { |
|
| 1794 | + $id_theme = (int) $id_theme; |
|
| 1795 | + } |
|
| 1710 | 1796 | // The theme was specified by REQUEST. |
| 1711 | 1797 | elseif (!empty($_REQUEST['theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) |
| 1712 | 1798 | { |
@@ -1714,32 +1800,38 @@ discard block |
||
| 1714 | 1800 | $_SESSION['id_theme'] = $id_theme; |
| 1715 | 1801 | } |
| 1716 | 1802 | // The theme was specified by REQUEST... previously. |
| 1717 | - elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) |
|
| 1718 | - $id_theme = (int) $_SESSION['id_theme']; |
|
| 1803 | + elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) { |
|
| 1804 | + $id_theme = (int) $_SESSION['id_theme']; |
|
| 1805 | + } |
|
| 1719 | 1806 | // The theme is just the user's choice. (might use ?board=1;theme=0 to force board theme.) |
| 1720 | - elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) |
|
| 1721 | - $id_theme = $user_info['theme']; |
|
| 1807 | + elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) { |
|
| 1808 | + $id_theme = $user_info['theme']; |
|
| 1809 | + } |
|
| 1722 | 1810 | // The theme was specified by the board. |
| 1723 | - elseif (!empty($board_info['theme'])) |
|
| 1724 | - $id_theme = $board_info['theme']; |
|
| 1811 | + elseif (!empty($board_info['theme'])) { |
|
| 1812 | + $id_theme = $board_info['theme']; |
|
| 1813 | + } |
|
| 1725 | 1814 | // The theme is the forum's default. |
| 1726 | - else |
|
| 1727 | - $id_theme = $modSettings['theme_guests']; |
|
| 1815 | + else { |
|
| 1816 | + $id_theme = $modSettings['theme_guests']; |
|
| 1817 | + } |
|
| 1728 | 1818 | |
| 1729 | 1819 | // Verify the id_theme... no foul play. |
| 1730 | 1820 | // Always allow the board specific theme, if they are overriding. |
| 1731 | - if (!empty($board_info['theme']) && $board_info['override_theme']) |
|
| 1732 | - $id_theme = $board_info['theme']; |
|
| 1821 | + if (!empty($board_info['theme']) && $board_info['override_theme']) { |
|
| 1822 | + $id_theme = $board_info['theme']; |
|
| 1823 | + } |
|
| 1733 | 1824 | // If they have specified a particular theme to use with SSI allow it to be used. |
| 1734 | - elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) |
|
| 1735 | - $id_theme = (int) $id_theme; |
|
| 1736 | - elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum')) |
|
| 1825 | + elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) { |
|
| 1826 | + $id_theme = (int) $id_theme; |
|
| 1827 | + } elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum')) |
|
| 1737 | 1828 | { |
| 1738 | 1829 | $themes = explode(',', $modSettings['enableThemes']); |
| 1739 | - if (!in_array($id_theme, $themes)) |
|
| 1740 | - $id_theme = $modSettings['theme_guests']; |
|
| 1741 | - else |
|
| 1742 | - $id_theme = (int) $id_theme; |
|
| 1830 | + if (!in_array($id_theme, $themes)) { |
|
| 1831 | + $id_theme = $modSettings['theme_guests']; |
|
| 1832 | + } else { |
|
| 1833 | + $id_theme = (int) $id_theme; |
|
| 1834 | + } |
|
| 1743 | 1835 | } |
| 1744 | 1836 | |
| 1745 | 1837 | // We already load the basic stuff? |
@@ -1748,18 +1840,19 @@ discard block |
||
| 1748 | 1840 | $member = empty($user_info['id']) ? -1 : $user_info['id']; |
| 1749 | 1841 | |
| 1750 | 1842 | // Disable image proxy if we don't have SSL enabled |
| 1751 | - if (empty($modSettings['force_ssl'])) |
|
| 1752 | - $image_proxy_enabled = false; |
|
| 1843 | + if (empty($modSettings['force_ssl'])) { |
|
| 1844 | + $image_proxy_enabled = false; |
|
| 1845 | + } |
|
| 1753 | 1846 | |
| 1754 | 1847 | 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']) |
| 1755 | 1848 | { |
| 1756 | 1849 | $themeData = $temp; |
| 1757 | 1850 | $flag = true; |
| 1851 | + } elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) { |
|
| 1852 | + $themeData = $temp + array($member => array()); |
|
| 1853 | + } else { |
|
| 1854 | + $themeData = array(-1 => array(), 0 => array(), $member => array()); |
|
| 1758 | 1855 | } |
| 1759 | - elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) |
|
| 1760 | - $themeData = $temp + array($member => array()); |
|
| 1761 | - else |
|
| 1762 | - $themeData = array(-1 => array(), 0 => array(), $member => array()); |
|
| 1763 | 1856 | |
| 1764 | 1857 | if (empty($flag)) |
| 1765 | 1858 | { |
@@ -1779,31 +1872,37 @@ discard block |
||
| 1779 | 1872 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 1780 | 1873 | { |
| 1781 | 1874 | // There are just things we shouldn't be able to change as members. |
| 1782 | - 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'))) |
|
| 1783 | - continue; |
|
| 1875 | + 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'))) { |
|
| 1876 | + continue; |
|
| 1877 | + } |
|
| 1784 | 1878 | |
| 1785 | 1879 | // If this is the theme_dir of the default theme, store it. |
| 1786 | - if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) |
|
| 1787 | - $themeData[0]['default_' . $row['variable']] = $row['value']; |
|
| 1880 | + if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) { |
|
| 1881 | + $themeData[0]['default_' . $row['variable']] = $row['value']; |
|
| 1882 | + } |
|
| 1788 | 1883 | |
| 1789 | 1884 | // If this isn't set yet, is a theme option, or is not the default theme.. |
| 1790 | - if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') |
|
| 1791 | - $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value']; |
|
| 1885 | + if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') { |
|
| 1886 | + $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value']; |
|
| 1887 | + } |
|
| 1792 | 1888 | } |
| 1793 | 1889 | $smcFunc['db_free_result']($result); |
| 1794 | 1890 | |
| 1795 | - if (!empty($themeData[-1])) |
|
| 1796 | - foreach ($themeData[-1] as $k => $v) |
|
| 1891 | + if (!empty($themeData[-1])) { |
|
| 1892 | + foreach ($themeData[-1] as $k => $v) |
|
| 1797 | 1893 | { |
| 1798 | 1894 | if (!isset($themeData[$member][$k])) |
| 1799 | 1895 | $themeData[$member][$k] = $v; |
| 1896 | + } |
|
| 1800 | 1897 | } |
| 1801 | 1898 | |
| 1802 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 1803 | - cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60); |
|
| 1899 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 1900 | + cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60); |
|
| 1901 | + } |
|
| 1804 | 1902 | // Only if we didn't already load that part of the cache... |
| 1805 | - elseif (!isset($temp)) |
|
| 1806 | - cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90); |
|
| 1903 | + elseif (!isset($temp)) { |
|
| 1904 | + cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90); |
|
| 1905 | + } |
|
| 1807 | 1906 | } |
| 1808 | 1907 | |
| 1809 | 1908 | $settings = $themeData[0]; |
@@ -1820,17 +1919,20 @@ discard block |
||
| 1820 | 1919 | $settings['template_dirs'][] = $settings['theme_dir']; |
| 1821 | 1920 | |
| 1822 | 1921 | // Based on theme (if there is one). |
| 1823 | - if (!empty($settings['base_theme_dir'])) |
|
| 1824 | - $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
| 1922 | + if (!empty($settings['base_theme_dir'])) { |
|
| 1923 | + $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
| 1924 | + } |
|
| 1825 | 1925 | |
| 1826 | 1926 | // Lastly the default theme. |
| 1827 | - if ($settings['theme_dir'] != $settings['default_theme_dir']) |
|
| 1828 | - $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
| 1927 | + if ($settings['theme_dir'] != $settings['default_theme_dir']) { |
|
| 1928 | + $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
| 1929 | + } |
|
| 1829 | 1930 | } |
| 1830 | 1931 | |
| 1831 | 1932 | |
| 1832 | - if (!$initialize) |
|
| 1833 | - return; |
|
| 1933 | + if (!$initialize) { |
|
| 1934 | + return; |
|
| 1935 | + } |
|
| 1834 | 1936 | |
| 1835 | 1937 | // Check to see if we're forcing SSL |
| 1836 | 1938 | if (!empty($modSettings['force_ssl']) && empty($maintenance) && |
@@ -1851,8 +1953,9 @@ discard block |
||
| 1851 | 1953 | $detected_url = httpsOn() ? 'https://' : 'http://'; |
| 1852 | 1954 | $detected_url .= empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] . (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT']) : $_SERVER['HTTP_HOST']; |
| 1853 | 1955 | $temp = preg_replace('~/' . basename($scripturl) . '(/.+)?$~', '', strtr(dirname($_SERVER['PHP_SELF']), '\\', '/')); |
| 1854 | - if ($temp != '/') |
|
| 1855 | - $detected_url .= $temp; |
|
| 1956 | + if ($temp != '/') { |
|
| 1957 | + $detected_url .= $temp; |
|
| 1958 | + } |
|
| 1856 | 1959 | } |
| 1857 | 1960 | if (isset($detected_url) && $detected_url != $boardurl) |
| 1858 | 1961 | { |
@@ -1864,8 +1967,9 @@ discard block |
||
| 1864 | 1967 | foreach ($aliases as $alias) |
| 1865 | 1968 | { |
| 1866 | 1969 | // Rip off all the boring parts, spaces, etc. |
| 1867 | - if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) |
|
| 1868 | - $do_fix = true; |
|
| 1970 | + if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) { |
|
| 1971 | + $do_fix = true; |
|
| 1972 | + } |
|
| 1869 | 1973 | } |
| 1870 | 1974 | } |
| 1871 | 1975 | |
@@ -1873,21 +1977,23 @@ discard block |
||
| 1873 | 1977 | if (empty($do_fix) && strtr($detected_url, array('://' => '://www.')) == $boardurl && (empty($_GET) || count($_GET) == 1) && SMF != 'SSI') |
| 1874 | 1978 | { |
| 1875 | 1979 | // Okay, this seems weird, but we don't want an endless loop - this will make $_GET not empty ;). |
| 1876 | - if (empty($_GET)) |
|
| 1877 | - redirectexit('wwwRedirect'); |
|
| 1878 | - else |
|
| 1980 | + if (empty($_GET)) { |
|
| 1981 | + redirectexit('wwwRedirect'); |
|
| 1982 | + } else |
|
| 1879 | 1983 | { |
| 1880 | 1984 | $k = key($_GET); |
| 1881 | 1985 | $v = current($_GET); |
| 1882 | 1986 | |
| 1883 | - if ($k != 'wwwRedirect') |
|
| 1884 | - redirectexit('wwwRedirect;' . $k . '=' . $v); |
|
| 1987 | + if ($k != 'wwwRedirect') { |
|
| 1988 | + redirectexit('wwwRedirect;' . $k . '=' . $v); |
|
| 1989 | + } |
|
| 1885 | 1990 | } |
| 1886 | 1991 | } |
| 1887 | 1992 | |
| 1888 | 1993 | // #3 is just a check for SSL... |
| 1889 | - if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) |
|
| 1890 | - $do_fix = true; |
|
| 1994 | + if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) { |
|
| 1995 | + $do_fix = true; |
|
| 1996 | + } |
|
| 1891 | 1997 | |
| 1892 | 1998 | // Okay, #4 - perhaps it's an IP address? We're gonna want to use that one, then. (assuming it's the IP or something...) |
| 1893 | 1999 | if (!empty($do_fix) || preg_match('~^http[s]?://(?:[\d\.:]+|\[[\d:]+\](?::\d+)?)(?:$|/)~', $detected_url) == 1) |
@@ -1922,8 +2028,9 @@ discard block |
||
| 1922 | 2028 | $board_info['moderators'][$k]['link'] = strtr($dummy['link'], array('"' . $oldurl => '"' . $boardurl)); |
| 1923 | 2029 | } |
| 1924 | 2030 | } |
| 1925 | - foreach ($context['linktree'] as $k => $dummy) |
|
| 1926 | - $context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl)); |
|
| 2031 | + foreach ($context['linktree'] as $k => $dummy) { |
|
| 2032 | + $context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl)); |
|
| 2033 | + } |
|
| 1927 | 2034 | } |
| 1928 | 2035 | } |
| 1929 | 2036 | // Set up the contextual user array. |
@@ -1942,16 +2049,16 @@ discard block |
||
| 1942 | 2049 | 'email' => $user_info['email'], |
| 1943 | 2050 | 'ignoreusers' => $user_info['ignoreusers'], |
| 1944 | 2051 | ); |
| 1945 | - if (!$context['user']['is_guest']) |
|
| 1946 | - $context['user']['name'] = $user_info['name']; |
|
| 1947 | - elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) |
|
| 1948 | - $context['user']['name'] = $txt['guest_title']; |
|
| 2052 | + if (!$context['user']['is_guest']) { |
|
| 2053 | + $context['user']['name'] = $user_info['name']; |
|
| 2054 | + } elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) { |
|
| 2055 | + $context['user']['name'] = $txt['guest_title']; |
|
| 2056 | + } |
|
| 1949 | 2057 | |
| 1950 | 2058 | // Determine the current smiley set. |
| 1951 | 2059 | $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']; |
| 1952 | 2060 | $context['user']['smiley_set'] = $user_info['smiley_set']; |
| 1953 | - } |
|
| 1954 | - else |
|
| 2061 | + } else |
|
| 1955 | 2062 | { |
| 1956 | 2063 | // What to do when there is no $user_info (e.g., an error very early in the login process) |
| 1957 | 2064 | $context['user'] = array( |
@@ -1985,18 +2092,24 @@ discard block |
||
| 1985 | 2092 | } |
| 1986 | 2093 | |
| 1987 | 2094 | // Some basic information... |
| 1988 | - if (!isset($context['html_headers'])) |
|
| 1989 | - $context['html_headers'] = ''; |
|
| 1990 | - if (!isset($context['javascript_files'])) |
|
| 1991 | - $context['javascript_files'] = array(); |
|
| 1992 | - if (!isset($context['css_files'])) |
|
| 1993 | - $context['css_files'] = array(); |
|
| 1994 | - if (!isset($context['css_header'])) |
|
| 1995 | - $context['css_header'] = array(); |
|
| 1996 | - if (!isset($context['javascript_inline'])) |
|
| 1997 | - $context['javascript_inline'] = array('standard' => array(), 'defer' => array()); |
|
| 1998 | - if (!isset($context['javascript_vars'])) |
|
| 1999 | - $context['javascript_vars'] = array(); |
|
| 2095 | + if (!isset($context['html_headers'])) { |
|
| 2096 | + $context['html_headers'] = ''; |
|
| 2097 | + } |
|
| 2098 | + if (!isset($context['javascript_files'])) { |
|
| 2099 | + $context['javascript_files'] = array(); |
|
| 2100 | + } |
|
| 2101 | + if (!isset($context['css_files'])) { |
|
| 2102 | + $context['css_files'] = array(); |
|
| 2103 | + } |
|
| 2104 | + if (!isset($context['css_header'])) { |
|
| 2105 | + $context['css_header'] = array(); |
|
| 2106 | + } |
|
| 2107 | + if (!isset($context['javascript_inline'])) { |
|
| 2108 | + $context['javascript_inline'] = array('standard' => array(), 'defer' => array()); |
|
| 2109 | + } |
|
| 2110 | + if (!isset($context['javascript_vars'])) { |
|
| 2111 | + $context['javascript_vars'] = array(); |
|
| 2112 | + } |
|
| 2000 | 2113 | |
| 2001 | 2114 | $context['login_url'] = $scripturl . '?action=login2'; |
| 2002 | 2115 | $context['menu_separator'] = !empty($settings['use_image_buttons']) ? ' ' : ' | '; |
@@ -2008,16 +2121,18 @@ discard block |
||
| 2008 | 2121 | $context['current_action'] = isset($_REQUEST['action']) ? $smcFunc['htmlspecialchars']($_REQUEST['action']) : null; |
| 2009 | 2122 | $context['current_subaction'] = isset($_REQUEST['sa']) ? $_REQUEST['sa'] : null; |
| 2010 | 2123 | $context['can_register'] = empty($modSettings['registration_method']) || $modSettings['registration_method'] != 3; |
| 2011 | - if (isset($modSettings['load_average'])) |
|
| 2012 | - $context['load_average'] = $modSettings['load_average']; |
|
| 2124 | + if (isset($modSettings['load_average'])) { |
|
| 2125 | + $context['load_average'] = $modSettings['load_average']; |
|
| 2126 | + } |
|
| 2013 | 2127 | |
| 2014 | 2128 | // Detect the browser. This is separated out because it's also used in attachment downloads |
| 2015 | 2129 | detectBrowser(); |
| 2016 | 2130 | |
| 2017 | 2131 | // Set the top level linktree up. |
| 2018 | 2132 | // Note that if we're dealing with certain very early errors (e.g., login) the linktree might not be set yet... |
| 2019 | - if (empty($context['linktree'])) |
|
| 2020 | - $context['linktree'] = array(); |
|
| 2133 | + if (empty($context['linktree'])) { |
|
| 2134 | + $context['linktree'] = array(); |
|
| 2135 | + } |
|
| 2021 | 2136 | array_unshift($context['linktree'], array( |
| 2022 | 2137 | 'url' => $scripturl, |
| 2023 | 2138 | 'name' => $context['forum_name_html_safe'] |
@@ -2026,8 +2141,9 @@ discard block |
||
| 2026 | 2141 | // This allows sticking some HTML on the page output - useful for controls. |
| 2027 | 2142 | $context['insert_after_template'] = ''; |
| 2028 | 2143 | |
| 2029 | - if (!isset($txt)) |
|
| 2030 | - $txt = array(); |
|
| 2144 | + if (!isset($txt)) { |
|
| 2145 | + $txt = array(); |
|
| 2146 | + } |
|
| 2031 | 2147 | |
| 2032 | 2148 | $simpleActions = array( |
| 2033 | 2149 | 'findmember', |
@@ -2073,9 +2189,10 @@ discard block |
||
| 2073 | 2189 | |
| 2074 | 2190 | // See if theres any extra param to check. |
| 2075 | 2191 | $requiresXML = false; |
| 2076 | - foreach ($extraParams as $key => $extra) |
|
| 2077 | - if (isset($_REQUEST[$extra])) |
|
| 2192 | + foreach ($extraParams as $key => $extra) { |
|
| 2193 | + if (isset($_REQUEST[$extra])) |
|
| 2078 | 2194 | $requiresXML = true; |
| 2195 | + } |
|
| 2079 | 2196 | |
| 2080 | 2197 | // Output is fully XML, so no need for the index template. |
| 2081 | 2198 | if (isset($_REQUEST['xml']) && (in_array($context['current_action'], $xmlActions) || $requiresXML)) |
@@ -2090,37 +2207,39 @@ discard block |
||
| 2090 | 2207 | { |
| 2091 | 2208 | loadLanguage('index+Modifications'); |
| 2092 | 2209 | $context['template_layers'] = array(); |
| 2093 | - } |
|
| 2094 | - |
|
| 2095 | - else |
|
| 2210 | + } else |
|
| 2096 | 2211 | { |
| 2097 | 2212 | // Custom templates to load, or just default? |
| 2098 | - if (isset($settings['theme_templates'])) |
|
| 2099 | - $templates = explode(',', $settings['theme_templates']); |
|
| 2100 | - else |
|
| 2101 | - $templates = array('index'); |
|
| 2213 | + if (isset($settings['theme_templates'])) { |
|
| 2214 | + $templates = explode(',', $settings['theme_templates']); |
|
| 2215 | + } else { |
|
| 2216 | + $templates = array('index'); |
|
| 2217 | + } |
|
| 2102 | 2218 | |
| 2103 | 2219 | // Load each template... |
| 2104 | - foreach ($templates as $template) |
|
| 2105 | - loadTemplate($template); |
|
| 2220 | + foreach ($templates as $template) { |
|
| 2221 | + loadTemplate($template); |
|
| 2222 | + } |
|
| 2106 | 2223 | |
| 2107 | 2224 | // ...and attempt to load their associated language files. |
| 2108 | 2225 | $required_files = implode('+', array_merge($templates, array('Modifications'))); |
| 2109 | 2226 | loadLanguage($required_files, '', false); |
| 2110 | 2227 | |
| 2111 | 2228 | // Custom template layers? |
| 2112 | - if (isset($settings['theme_layers'])) |
|
| 2113 | - $context['template_layers'] = explode(',', $settings['theme_layers']); |
|
| 2114 | - else |
|
| 2115 | - $context['template_layers'] = array('html', 'body'); |
|
| 2229 | + if (isset($settings['theme_layers'])) { |
|
| 2230 | + $context['template_layers'] = explode(',', $settings['theme_layers']); |
|
| 2231 | + } else { |
|
| 2232 | + $context['template_layers'] = array('html', 'body'); |
|
| 2233 | + } |
|
| 2116 | 2234 | } |
| 2117 | 2235 | |
| 2118 | 2236 | // Initialize the theme. |
| 2119 | 2237 | loadSubTemplate('init', 'ignore'); |
| 2120 | 2238 | |
| 2121 | 2239 | // Allow overriding the board wide time/number formats. |
| 2122 | - if (empty($user_settings['time_format']) && !empty($txt['time_format'])) |
|
| 2123 | - $user_info['time_format'] = $txt['time_format']; |
|
| 2240 | + if (empty($user_settings['time_format']) && !empty($txt['time_format'])) { |
|
| 2241 | + $user_info['time_format'] = $txt['time_format']; |
|
| 2242 | + } |
|
| 2124 | 2243 | |
| 2125 | 2244 | // Set the character set from the template. |
| 2126 | 2245 | $context['character_set'] = empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']; |
@@ -2128,12 +2247,14 @@ discard block |
||
| 2128 | 2247 | $context['right_to_left'] = !empty($txt['lang_rtl']); |
| 2129 | 2248 | |
| 2130 | 2249 | // Guests may still need a name. |
| 2131 | - if ($context['user']['is_guest'] && empty($context['user']['name'])) |
|
| 2132 | - $context['user']['name'] = $txt['guest_title']; |
|
| 2250 | + if ($context['user']['is_guest'] && empty($context['user']['name'])) { |
|
| 2251 | + $context['user']['name'] = $txt['guest_title']; |
|
| 2252 | + } |
|
| 2133 | 2253 | |
| 2134 | 2254 | // Any theme-related strings that need to be loaded? |
| 2135 | - if (!empty($settings['require_theme_strings'])) |
|
| 2136 | - loadLanguage('ThemeStrings', '', false); |
|
| 2255 | + if (!empty($settings['require_theme_strings'])) { |
|
| 2256 | + loadLanguage('ThemeStrings', '', false); |
|
| 2257 | + } |
|
| 2137 | 2258 | |
| 2138 | 2259 | // Make a special URL for the language. |
| 2139 | 2260 | $settings['lang_images_url'] = $settings['images_url'] . '/' . (!empty($txt['image_lang']) ? $txt['image_lang'] : $user_info['language']); |
@@ -2144,8 +2265,9 @@ discard block |
||
| 2144 | 2265 | // Here is my luvly Responsive CSS |
| 2145 | 2266 | loadCSSFile('responsive.css', array('force_current' => false, 'validate' => true, 'minimize' => true, 'order_pos' => 9000), 'smf_responsive'); |
| 2146 | 2267 | |
| 2147 | - if ($context['right_to_left']) |
|
| 2148 | - loadCSSFile('rtl.css', array('order_pos' => 200), 'smf_rtl'); |
|
| 2268 | + if ($context['right_to_left']) { |
|
| 2269 | + loadCSSFile('rtl.css', array('order_pos' => 200), 'smf_rtl'); |
|
| 2270 | + } |
|
| 2149 | 2271 | |
| 2150 | 2272 | // We allow theme variants, because we're cool. |
| 2151 | 2273 | $context['theme_variant'] = ''; |
@@ -2153,14 +2275,17 @@ discard block |
||
| 2153 | 2275 | if (!empty($settings['theme_variants'])) |
| 2154 | 2276 | { |
| 2155 | 2277 | // Overriding - for previews and that ilk. |
| 2156 | - if (!empty($_REQUEST['variant'])) |
|
| 2157 | - $_SESSION['id_variant'] = $_REQUEST['variant']; |
|
| 2278 | + if (!empty($_REQUEST['variant'])) { |
|
| 2279 | + $_SESSION['id_variant'] = $_REQUEST['variant']; |
|
| 2280 | + } |
|
| 2158 | 2281 | // User selection? |
| 2159 | - if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) |
|
| 2160 | - $context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : ''); |
|
| 2282 | + if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) { |
|
| 2283 | + $context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : ''); |
|
| 2284 | + } |
|
| 2161 | 2285 | // If not a user variant, select the default. |
| 2162 | - if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) |
|
| 2163 | - $context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0]; |
|
| 2286 | + if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) { |
|
| 2287 | + $context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0]; |
|
| 2288 | + } |
|
| 2164 | 2289 | |
| 2165 | 2290 | // Do this to keep things easier in the templates. |
| 2166 | 2291 | $context['theme_variant'] = '_' . $context['theme_variant']; |
@@ -2169,20 +2294,23 @@ discard block |
||
| 2169 | 2294 | if (!empty($context['theme_variant'])) |
| 2170 | 2295 | { |
| 2171 | 2296 | loadCSSFile('index' . $context['theme_variant'] . '.css', array('order_pos' => 300), 'smf_index' . $context['theme_variant']); |
| 2172 | - if ($context['right_to_left']) |
|
| 2173 | - loadCSSFile('rtl' . $context['theme_variant'] . '.css', array('order_pos' => 400), 'smf_rtl' . $context['theme_variant']); |
|
| 2297 | + if ($context['right_to_left']) { |
|
| 2298 | + loadCSSFile('rtl' . $context['theme_variant'] . '.css', array('order_pos' => 400), 'smf_rtl' . $context['theme_variant']); |
|
| 2299 | + } |
|
| 2174 | 2300 | } |
| 2175 | 2301 | } |
| 2176 | 2302 | |
| 2177 | 2303 | // Let's be compatible with old themes! |
| 2178 | - if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) |
|
| 2179 | - $context['template_layers'] = array('main'); |
|
| 2304 | + if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) { |
|
| 2305 | + $context['template_layers'] = array('main'); |
|
| 2306 | + } |
|
| 2180 | 2307 | |
| 2181 | 2308 | $context['tabindex'] = 1; |
| 2182 | 2309 | |
| 2183 | 2310 | // Compatibility. |
| 2184 | - if (!isset($settings['theme_version'])) |
|
| 2185 | - $modSettings['memberCount'] = $modSettings['totalMembers']; |
|
| 2311 | + if (!isset($settings['theme_version'])) { |
|
| 2312 | + $modSettings['memberCount'] = $modSettings['totalMembers']; |
|
| 2313 | + } |
|
| 2186 | 2314 | |
| 2187 | 2315 | // Default JS variables for use in every theme |
| 2188 | 2316 | $context['javascript_vars'] = array( |
@@ -2202,18 +2330,18 @@ discard block |
||
| 2202 | 2330 | ); |
| 2203 | 2331 | |
| 2204 | 2332 | // Add the JQuery library to the list of files to load. |
| 2205 | - if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') |
|
| 2206 | - loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
| 2207 | - |
|
| 2208 | - elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') |
|
| 2209 | - loadJavaScriptFile('jquery-3.2.1.min.js', array('seed' => false), 'smf_jquery'); |
|
| 2210 | - |
|
| 2211 | - elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') |
|
| 2212 | - loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery'); |
|
| 2333 | + if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') { |
|
| 2334 | + loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
| 2335 | + } elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') { |
|
| 2336 | + loadJavaScriptFile('jquery-3.2.1.min.js', array('seed' => false), 'smf_jquery'); |
|
| 2337 | + } elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') { |
|
| 2338 | + loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery'); |
|
| 2339 | + } |
|
| 2213 | 2340 | |
| 2214 | 2341 | // Auto loading? template_javascript() will take care of the local half of this. |
| 2215 | - else |
|
| 2216 | - loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
| 2342 | + else { |
|
| 2343 | + loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
| 2344 | + } |
|
| 2217 | 2345 | |
| 2218 | 2346 | // Queue our JQuery plugins! |
| 2219 | 2347 | loadJavaScriptFile('smf_jquery_plugins.js', array('minimize' => true), 'smf_jquery_plugins'); |
@@ -2236,12 +2364,12 @@ discard block |
||
| 2236 | 2364 | require_once($sourcedir . '/ScheduledTasks.php'); |
| 2237 | 2365 | |
| 2238 | 2366 | // What to do, what to do?! |
| 2239 | - if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) |
|
| 2240 | - AutoTask(); |
|
| 2241 | - else |
|
| 2242 | - ReduceMailQueue(); |
|
| 2243 | - } |
|
| 2244 | - else |
|
| 2367 | + if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) { |
|
| 2368 | + AutoTask(); |
|
| 2369 | + } else { |
|
| 2370 | + ReduceMailQueue(); |
|
| 2371 | + } |
|
| 2372 | + } else |
|
| 2245 | 2373 | { |
| 2246 | 2374 | $type = empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time() ? 'task' : 'mailq'; |
| 2247 | 2375 | $ts = $type == 'mailq' ? $modSettings['mail_next_send'] : $modSettings['next_task_time']; |
@@ -2292,8 +2420,9 @@ discard block |
||
| 2292 | 2420 | foreach ($theme_includes as $include) |
| 2293 | 2421 | { |
| 2294 | 2422 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
| 2295 | - if (file_exists($include)) |
|
| 2296 | - require_once($include); |
|
| 2423 | + if (file_exists($include)) { |
|
| 2424 | + require_once($include); |
|
| 2425 | + } |
|
| 2297 | 2426 | } |
| 2298 | 2427 | } |
| 2299 | 2428 | |
@@ -2323,16 +2452,19 @@ discard block |
||
| 2323 | 2452 | // Do any style sheets first, cause we're easy with those. |
| 2324 | 2453 | if (!empty($style_sheets)) |
| 2325 | 2454 | { |
| 2326 | - if (!is_array($style_sheets)) |
|
| 2327 | - $style_sheets = array($style_sheets); |
|
| 2455 | + if (!is_array($style_sheets)) { |
|
| 2456 | + $style_sheets = array($style_sheets); |
|
| 2457 | + } |
|
| 2328 | 2458 | |
| 2329 | - foreach ($style_sheets as $sheet) |
|
| 2330 | - loadCSSFile($sheet . '.css', array(), $sheet); |
|
| 2459 | + foreach ($style_sheets as $sheet) { |
|
| 2460 | + loadCSSFile($sheet . '.css', array(), $sheet); |
|
| 2461 | + } |
|
| 2331 | 2462 | } |
| 2332 | 2463 | |
| 2333 | 2464 | // No template to load? |
| 2334 | - if ($template_name === false) |
|
| 2335 | - return true; |
|
| 2465 | + if ($template_name === false) { |
|
| 2466 | + return true; |
|
| 2467 | + } |
|
| 2336 | 2468 | |
| 2337 | 2469 | $loaded = false; |
| 2338 | 2470 | foreach ($settings['template_dirs'] as $template_dir) |
@@ -2347,12 +2479,14 @@ discard block |
||
| 2347 | 2479 | |
| 2348 | 2480 | if ($loaded) |
| 2349 | 2481 | { |
| 2350 | - if ($db_show_debug === true) |
|
| 2351 | - $context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')'; |
|
| 2482 | + if ($db_show_debug === true) { |
|
| 2483 | + $context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')'; |
|
| 2484 | + } |
|
| 2352 | 2485 | |
| 2353 | 2486 | // If they have specified an initialization function for this template, go ahead and call it now. |
| 2354 | - if (function_exists('template_' . $template_name . '_init')) |
|
| 2355 | - call_user_func('template_' . $template_name . '_init'); |
|
| 2487 | + if (function_exists('template_' . $template_name . '_init')) { |
|
| 2488 | + call_user_func('template_' . $template_name . '_init'); |
|
| 2489 | + } |
|
| 2356 | 2490 | } |
| 2357 | 2491 | // Hmmm... doesn't exist?! I don't suppose the directory is wrong, is it? |
| 2358 | 2492 | elseif (!file_exists($settings['default_theme_dir']) && file_exists($boarddir . '/Themes/default')) |
@@ -2372,13 +2506,14 @@ discard block |
||
| 2372 | 2506 | loadTemplate($template_name); |
| 2373 | 2507 | } |
| 2374 | 2508 | // Cause an error otherwise. |
| 2375 | - elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) |
|
| 2376 | - fatal_lang_error('theme_template_error', 'template', array((string) $template_name)); |
|
| 2377 | - elseif ($fatal) |
|
| 2378 | - 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')); |
|
| 2379 | - else |
|
| 2380 | - return false; |
|
| 2381 | -} |
|
| 2509 | + elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) { |
|
| 2510 | + fatal_lang_error('theme_template_error', 'template', array((string) $template_name)); |
|
| 2511 | + } elseif ($fatal) { |
|
| 2512 | + 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')); |
|
| 2513 | + } else { |
|
| 2514 | + return false; |
|
| 2515 | + } |
|
| 2516 | + } |
|
| 2382 | 2517 | |
| 2383 | 2518 | /** |
| 2384 | 2519 | * Load a sub-template. |
@@ -2396,17 +2531,19 @@ discard block |
||
| 2396 | 2531 | { |
| 2397 | 2532 | global $context, $txt, $db_show_debug; |
| 2398 | 2533 | |
| 2399 | - if ($db_show_debug === true) |
|
| 2400 | - $context['debug']['sub_templates'][] = $sub_template_name; |
|
| 2534 | + if ($db_show_debug === true) { |
|
| 2535 | + $context['debug']['sub_templates'][] = $sub_template_name; |
|
| 2536 | + } |
|
| 2401 | 2537 | |
| 2402 | 2538 | // Figure out what the template function is named. |
| 2403 | 2539 | $theme_function = 'template_' . $sub_template_name; |
| 2404 | - if (function_exists($theme_function)) |
|
| 2405 | - $theme_function(); |
|
| 2406 | - elseif ($fatal === false) |
|
| 2407 | - fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name)); |
|
| 2408 | - elseif ($fatal !== 'ignore') |
|
| 2409 | - 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')); |
|
| 2540 | + if (function_exists($theme_function)) { |
|
| 2541 | + $theme_function(); |
|
| 2542 | + } elseif ($fatal === false) { |
|
| 2543 | + fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name)); |
|
| 2544 | + } elseif ($fatal !== 'ignore') { |
|
| 2545 | + 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')); |
|
| 2546 | + } |
|
| 2410 | 2547 | |
| 2411 | 2548 | // Are we showing debugging for templates? Just make sure not to do it before the doctype... |
| 2412 | 2549 | if (allowedTo('admin_forum') && isset($_REQUEST['debug']) && !in_array($sub_template_name, array('init', 'main_below')) && ob_get_length() > 0 && !isset($_REQUEST['xml'])) |
@@ -2436,8 +2573,9 @@ discard block |
||
| 2436 | 2573 | { |
| 2437 | 2574 | global $settings, $context, $modSettings; |
| 2438 | 2575 | |
| 2439 | - if (empty($context['css_files_order'])) |
|
| 2440 | - $context['css_files_order'] = array(); |
|
| 2576 | + if (empty($context['css_files_order'])) { |
|
| 2577 | + $context['css_files_order'] = array(); |
|
| 2578 | + } |
|
| 2441 | 2579 | |
| 2442 | 2580 | $params['seed'] = (!array_key_exists('seed', $params) || (array_key_exists('seed', $params) && $params['seed'] === true)) ? (array_key_exists('browser_cache', $modSettings) ? $modSettings['browser_cache'] : '') : (is_string($params['seed']) ? ($params['seed'] = $params['seed'][0] === '?' ? $params['seed'] : '?' . $params['seed']) : ''); |
| 2443 | 2581 | $params['force_current'] = isset($params['force_current']) ? $params['force_current'] : false; |
@@ -2448,8 +2586,9 @@ discard block |
||
| 2448 | 2586 | $params['order_pos'] = isset($params['order_pos']) ? (int) $params['order_pos'] : 3000; |
| 2449 | 2587 | |
| 2450 | 2588 | // If this is an external file, automatically set this to false. |
| 2451 | - if (!empty($params['external'])) |
|
| 2452 | - $params['minimize'] = false; |
|
| 2589 | + if (!empty($params['external'])) { |
|
| 2590 | + $params['minimize'] = false; |
|
| 2591 | + } |
|
| 2453 | 2592 | |
| 2454 | 2593 | // Account for shorthand like admin.css?alp21 filenames |
| 2455 | 2594 | $has_seed = strpos($fileName, '.css?'); |
@@ -2466,16 +2605,12 @@ discard block |
||
| 2466 | 2605 | { |
| 2467 | 2606 | $fileUrl = $settings['default_theme_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2468 | 2607 | $filePath = $settings['default_theme_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2469 | - } |
|
| 2470 | - |
|
| 2471 | - else |
|
| 2608 | + } else |
|
| 2472 | 2609 | { |
| 2473 | 2610 | $fileUrl = false; |
| 2474 | 2611 | $filePath = false; |
| 2475 | 2612 | } |
| 2476 | - } |
|
| 2477 | - |
|
| 2478 | - else |
|
| 2613 | + } else |
|
| 2479 | 2614 | { |
| 2480 | 2615 | $fileUrl = $settings[$themeRef . '_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2481 | 2616 | $filePath = $settings[$themeRef . '_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
@@ -2493,16 +2628,18 @@ discard block |
||
| 2493 | 2628 | if (!empty($fileName)) |
| 2494 | 2629 | { |
| 2495 | 2630 | // find a free number/position |
| 2496 | - while (isset($context['css_files_order'][$params['order_pos']])) |
|
| 2497 | - $params['order_pos']++; |
|
| 2631 | + while (isset($context['css_files_order'][$params['order_pos']])) { |
|
| 2632 | + $params['order_pos']++; |
|
| 2633 | + } |
|
| 2498 | 2634 | $context['css_files_order'][$params['order_pos']] = $id; |
| 2499 | 2635 | |
| 2500 | 2636 | $context['css_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
| 2501 | 2637 | } |
| 2502 | 2638 | |
| 2503 | - if (!empty($context['right_to_left']) && !empty($params['rtl'])) |
|
| 2504 | - loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0))); |
|
| 2505 | -} |
|
| 2639 | + if (!empty($context['right_to_left']) && !empty($params['rtl'])) { |
|
| 2640 | + loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0))); |
|
| 2641 | + } |
|
| 2642 | + } |
|
| 2506 | 2643 | |
| 2507 | 2644 | /** |
| 2508 | 2645 | * Add a block of inline css code to be executed later |
@@ -2519,8 +2656,9 @@ discard block |
||
| 2519 | 2656 | global $context; |
| 2520 | 2657 | |
| 2521 | 2658 | // Gotta add something... |
| 2522 | - if (empty($css)) |
|
| 2523 | - return false; |
|
| 2659 | + if (empty($css)) { |
|
| 2660 | + return false; |
|
| 2661 | + } |
|
| 2524 | 2662 | |
| 2525 | 2663 | $context['css_header'][] = $css; |
| 2526 | 2664 | } |
@@ -2556,8 +2694,9 @@ discard block |
||
| 2556 | 2694 | $params['validate'] = isset($params['validate']) ? $params['validate'] : true; |
| 2557 | 2695 | |
| 2558 | 2696 | // If this is an external file, automatically set this to false. |
| 2559 | - if (!empty($params['external'])) |
|
| 2560 | - $params['minimize'] = false; |
|
| 2697 | + if (!empty($params['external'])) { |
|
| 2698 | + $params['minimize'] = false; |
|
| 2699 | + } |
|
| 2561 | 2700 | |
| 2562 | 2701 | // Account for shorthand like admin.js?alp21 filenames |
| 2563 | 2702 | $has_seed = strpos($fileName, '.js?'); |
@@ -2574,16 +2713,12 @@ discard block |
||
| 2574 | 2713 | { |
| 2575 | 2714 | $fileUrl = $settings['default_theme_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2576 | 2715 | $filePath = $settings['default_theme_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2577 | - } |
|
| 2578 | - |
|
| 2579 | - else |
|
| 2716 | + } else |
|
| 2580 | 2717 | { |
| 2581 | 2718 | $fileUrl = false; |
| 2582 | 2719 | $filePath = false; |
| 2583 | 2720 | } |
| 2584 | - } |
|
| 2585 | - |
|
| 2586 | - else |
|
| 2721 | + } else |
|
| 2587 | 2722 | { |
| 2588 | 2723 | $fileUrl = $settings[$themeRef . '_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2589 | 2724 | $filePath = $settings[$themeRef . '_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
@@ -2598,9 +2733,10 @@ discard block |
||
| 2598 | 2733 | } |
| 2599 | 2734 | |
| 2600 | 2735 | // Add it to the array for use in the template |
| 2601 | - if (!empty($fileName)) |
|
| 2602 | - $context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
| 2603 | -} |
|
| 2736 | + if (!empty($fileName)) { |
|
| 2737 | + $context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
| 2738 | + } |
|
| 2739 | + } |
|
| 2604 | 2740 | |
| 2605 | 2741 | /** |
| 2606 | 2742 | * Add a Javascript variable for output later (for feeding text strings and similar to JS) |
@@ -2614,9 +2750,10 @@ discard block |
||
| 2614 | 2750 | { |
| 2615 | 2751 | global $context; |
| 2616 | 2752 | |
| 2617 | - if (!empty($key) && (!empty($value) || $value === '0')) |
|
| 2618 | - $context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value; |
|
| 2619 | -} |
|
| 2753 | + if (!empty($key) && (!empty($value) || $value === '0')) { |
|
| 2754 | + $context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value; |
|
| 2755 | + } |
|
| 2756 | + } |
|
| 2620 | 2757 | |
| 2621 | 2758 | /** |
| 2622 | 2759 | * Add a block of inline Javascript code to be executed later |
@@ -2633,8 +2770,9 @@ discard block |
||
| 2633 | 2770 | { |
| 2634 | 2771 | global $context; |
| 2635 | 2772 | |
| 2636 | - if (empty($javascript)) |
|
| 2637 | - return false; |
|
| 2773 | + if (empty($javascript)) { |
|
| 2774 | + return false; |
|
| 2775 | + } |
|
| 2638 | 2776 | |
| 2639 | 2777 | $context['javascript_inline'][($defer === true ? 'defer' : 'standard')][] = $javascript; |
| 2640 | 2778 | } |
@@ -2655,15 +2793,18 @@ discard block |
||
| 2655 | 2793 | static $already_loaded = array(); |
| 2656 | 2794 | |
| 2657 | 2795 | // Default to the user's language. |
| 2658 | - if ($lang == '') |
|
| 2659 | - $lang = isset($user_info['language']) ? $user_info['language'] : $language; |
|
| 2796 | + if ($lang == '') { |
|
| 2797 | + $lang = isset($user_info['language']) ? $user_info['language'] : $language; |
|
| 2798 | + } |
|
| 2660 | 2799 | |
| 2661 | 2800 | // Do we want the English version of language file as fallback? |
| 2662 | - if (empty($modSettings['disable_language_fallback']) && $lang != 'english') |
|
| 2663 | - loadLanguage($template_name, 'english', false); |
|
| 2801 | + if (empty($modSettings['disable_language_fallback']) && $lang != 'english') { |
|
| 2802 | + loadLanguage($template_name, 'english', false); |
|
| 2803 | + } |
|
| 2664 | 2804 | |
| 2665 | - if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) |
|
| 2666 | - return $lang; |
|
| 2805 | + if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) { |
|
| 2806 | + return $lang; |
|
| 2807 | + } |
|
| 2667 | 2808 | |
| 2668 | 2809 | // Make sure we have $settings - if not we're in trouble and need to find it! |
| 2669 | 2810 | if (empty($settings['default_theme_dir'])) |
@@ -2674,8 +2815,9 @@ discard block |
||
| 2674 | 2815 | |
| 2675 | 2816 | // What theme are we in? |
| 2676 | 2817 | $theme_name = basename($settings['theme_url']); |
| 2677 | - if (empty($theme_name)) |
|
| 2678 | - $theme_name = 'unknown'; |
|
| 2818 | + if (empty($theme_name)) { |
|
| 2819 | + $theme_name = 'unknown'; |
|
| 2820 | + } |
|
| 2679 | 2821 | |
| 2680 | 2822 | // For each file open it up and write it out! |
| 2681 | 2823 | foreach (explode('+', $template_name) as $template) |
@@ -2717,8 +2859,9 @@ discard block |
||
| 2717 | 2859 | $found = true; |
| 2718 | 2860 | |
| 2719 | 2861 | // setlocale is required for basename() & pathinfo() to work properly on the selected language |
| 2720 | - if (!empty($txt['lang_locale']) && !empty($modSettings['global_character_set'])) |
|
| 2721 | - setlocale(LC_CTYPE, $txt['lang_locale'] . '.' . $modSettings['global_character_set']); |
|
| 2862 | + if (!empty($txt['lang_locale']) && !empty($modSettings['global_character_set'])) { |
|
| 2863 | + setlocale(LC_CTYPE, $txt['lang_locale'] . '.' . $modSettings['global_character_set']); |
|
| 2864 | + } |
|
| 2722 | 2865 | |
| 2723 | 2866 | break; |
| 2724 | 2867 | } |
@@ -2758,8 +2901,9 @@ discard block |
||
| 2758 | 2901 | } |
| 2759 | 2902 | |
| 2760 | 2903 | // Keep track of what we're up to soldier. |
| 2761 | - if ($db_show_debug === true) |
|
| 2762 | - $context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')'; |
|
| 2904 | + if ($db_show_debug === true) { |
|
| 2905 | + $context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')'; |
|
| 2906 | + } |
|
| 2763 | 2907 | |
| 2764 | 2908 | // Remember what we have loaded, and in which language. |
| 2765 | 2909 | $already_loaded[$template_name] = $lang; |
@@ -2805,8 +2949,9 @@ discard block |
||
| 2805 | 2949 | ) |
| 2806 | 2950 | ); |
| 2807 | 2951 | // In the EXTREMELY unlikely event this happens, give an error message. |
| 2808 | - if ($smcFunc['db_num_rows']($result) == 0) |
|
| 2809 | - fatal_lang_error('parent_not_found', 'critical'); |
|
| 2952 | + if ($smcFunc['db_num_rows']($result) == 0) { |
|
| 2953 | + fatal_lang_error('parent_not_found', 'critical'); |
|
| 2954 | + } |
|
| 2810 | 2955 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 2811 | 2956 | { |
| 2812 | 2957 | if (!isset($boards[$row['id_board']])) |
@@ -2823,8 +2968,8 @@ discard block |
||
| 2823 | 2968 | ); |
| 2824 | 2969 | } |
| 2825 | 2970 | // If a moderator exists for this board, add that moderator for all children too. |
| 2826 | - if (!empty($row['id_moderator'])) |
|
| 2827 | - foreach ($boards as $id => $dummy) |
|
| 2971 | + if (!empty($row['id_moderator'])) { |
|
| 2972 | + foreach ($boards as $id => $dummy) |
|
| 2828 | 2973 | { |
| 2829 | 2974 | $boards[$id]['moderators'][$row['id_moderator']] = array( |
| 2830 | 2975 | 'id' => $row['id_moderator'], |
@@ -2832,11 +2977,12 @@ discard block |
||
| 2832 | 2977 | 'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'], |
| 2833 | 2978 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>' |
| 2834 | 2979 | ); |
| 2980 | + } |
|
| 2835 | 2981 | } |
| 2836 | 2982 | |
| 2837 | 2983 | // If a moderator group exists for this board, add that moderator group for all children too |
| 2838 | - if (!empty($row['id_moderator_group'])) |
|
| 2839 | - foreach ($boards as $id => $dummy) |
|
| 2984 | + if (!empty($row['id_moderator_group'])) { |
|
| 2985 | + foreach ($boards as $id => $dummy) |
|
| 2840 | 2986 | { |
| 2841 | 2987 | $boards[$id]['moderator_groups'][$row['id_moderator_group']] = array( |
| 2842 | 2988 | 'id' => $row['id_moderator_group'], |
@@ -2844,6 +2990,7 @@ discard block |
||
| 2844 | 2990 | 'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'], |
| 2845 | 2991 | 'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>' |
| 2846 | 2992 | ); |
| 2993 | + } |
|
| 2847 | 2994 | } |
| 2848 | 2995 | } |
| 2849 | 2996 | $smcFunc['db_free_result']($result); |
@@ -2870,23 +3017,27 @@ discard block |
||
| 2870 | 3017 | if (!$use_cache || ($context['languages'] = cache_get_data('known_languages', !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600)) == null) |
| 2871 | 3018 | { |
| 2872 | 3019 | // If we don't have our ucwords function defined yet, let's load the settings data. |
| 2873 | - if (empty($smcFunc['ucwords'])) |
|
| 2874 | - reloadSettings(); |
|
| 3020 | + if (empty($smcFunc['ucwords'])) { |
|
| 3021 | + reloadSettings(); |
|
| 3022 | + } |
|
| 2875 | 3023 | |
| 2876 | 3024 | // If we don't have our theme information yet, let's get it. |
| 2877 | - if (empty($settings['default_theme_dir'])) |
|
| 2878 | - loadTheme(0, false); |
|
| 3025 | + if (empty($settings['default_theme_dir'])) { |
|
| 3026 | + loadTheme(0, false); |
|
| 3027 | + } |
|
| 2879 | 3028 | |
| 2880 | 3029 | // Default language directories to try. |
| 2881 | 3030 | $language_directories = array( |
| 2882 | 3031 | $settings['default_theme_dir'] . '/languages', |
| 2883 | 3032 | ); |
| 2884 | - if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) |
|
| 2885 | - $language_directories[] = $settings['actual_theme_dir'] . '/languages'; |
|
| 3033 | + if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) { |
|
| 3034 | + $language_directories[] = $settings['actual_theme_dir'] . '/languages'; |
|
| 3035 | + } |
|
| 2886 | 3036 | |
| 2887 | 3037 | // We possibly have a base theme directory. |
| 2888 | - if (!empty($settings['base_theme_dir'])) |
|
| 2889 | - $language_directories[] = $settings['base_theme_dir'] . '/languages'; |
|
| 3038 | + if (!empty($settings['base_theme_dir'])) { |
|
| 3039 | + $language_directories[] = $settings['base_theme_dir'] . '/languages'; |
|
| 3040 | + } |
|
| 2890 | 3041 | |
| 2891 | 3042 | // Remove any duplicates. |
| 2892 | 3043 | $language_directories = array_unique($language_directories); |
@@ -2900,20 +3051,21 @@ discard block |
||
| 2900 | 3051 | foreach ($language_directories as $language_dir) |
| 2901 | 3052 | { |
| 2902 | 3053 | // Can't look in here... doesn't exist! |
| 2903 | - if (!file_exists($language_dir)) |
|
| 2904 | - continue; |
|
| 3054 | + if (!file_exists($language_dir)) { |
|
| 3055 | + continue; |
|
| 3056 | + } |
|
| 2905 | 3057 | |
| 2906 | 3058 | $dir = dir($language_dir); |
| 2907 | 3059 | while ($entry = $dir->read()) |
| 2908 | 3060 | { |
| 2909 | 3061 | // Look for the index language file... For good measure skip any "index.language-utf8.php" files |
| 2910 | - if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches)) |
|
| 2911 | - continue; |
|
| 2912 | - |
|
| 2913 | - if (!empty($langList) && !empty($langList[$matches[1]])) |
|
| 2914 | - $langName = $langList[$matches[1]]; |
|
| 3062 | + if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches)) { |
|
| 3063 | + continue; |
|
| 3064 | + } |
|
| 2915 | 3065 | |
| 2916 | - else |
|
| 3066 | + if (!empty($langList) && !empty($langList[$matches[1]])) { |
|
| 3067 | + $langName = $langList[$matches[1]]; |
|
| 3068 | + } else |
|
| 2917 | 3069 | { |
| 2918 | 3070 | $langName = $smcFunc['ucwords'](strtr($matches[1], array('_' => ' '))); |
| 2919 | 3071 | |
@@ -2954,12 +3106,14 @@ discard block |
||
| 2954 | 3106 | } |
| 2955 | 3107 | |
| 2956 | 3108 | // Do we need to store the lang list? |
| 2957 | - if (empty($langList)) |
|
| 2958 | - updateSettings(array('langList' => $smcFunc['json_encode']($catchLang))); |
|
| 3109 | + if (empty($langList)) { |
|
| 3110 | + updateSettings(array('langList' => $smcFunc['json_encode']($catchLang))); |
|
| 3111 | + } |
|
| 2959 | 3112 | |
| 2960 | 3113 | // Let's cash in on this deal. |
| 2961 | - if (!empty($modSettings['cache_enable'])) |
|
| 2962 | - cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600); |
|
| 3114 | + if (!empty($modSettings['cache_enable'])) { |
|
| 3115 | + cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600); |
|
| 3116 | + } |
|
| 2963 | 3117 | } |
| 2964 | 3118 | |
| 2965 | 3119 | return $context['languages']; |
@@ -2982,8 +3136,9 @@ discard block |
||
| 2982 | 3136 | global $modSettings, $options, $txt; |
| 2983 | 3137 | static $censor_vulgar = null, $censor_proper; |
| 2984 | 3138 | |
| 2985 | - if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') |
|
| 2986 | - return $text; |
|
| 3139 | + if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') { |
|
| 3140 | + return $text; |
|
| 3141 | + } |
|
| 2987 | 3142 | |
| 2988 | 3143 | // If they haven't yet been loaded, load them. |
| 2989 | 3144 | if ($censor_vulgar == null) |
@@ -3014,9 +3169,9 @@ discard block |
||
| 3014 | 3169 | { |
| 3015 | 3170 | $func = !empty($modSettings['censorIgnoreCase']) ? 'str_ireplace' : 'str_replace'; |
| 3016 | 3171 | $text = $func($censor_vulgar, $censor_proper, $text); |
| 3172 | + } else { |
|
| 3173 | + $text = preg_replace($censor_vulgar, $censor_proper, $text); |
|
| 3017 | 3174 | } |
| 3018 | - else |
|
| 3019 | - $text = preg_replace($censor_vulgar, $censor_proper, $text); |
|
| 3020 | 3175 | |
| 3021 | 3176 | return $text; |
| 3022 | 3177 | } |
@@ -3042,30 +3197,35 @@ discard block |
||
| 3042 | 3197 | @ini_set('track_errors', '1'); |
| 3043 | 3198 | |
| 3044 | 3199 | // Don't include the file more than once, if $once is true. |
| 3045 | - if ($once && in_array($filename, $templates)) |
|
| 3046 | - return; |
|
| 3200 | + if ($once && in_array($filename, $templates)) { |
|
| 3201 | + return; |
|
| 3202 | + } |
|
| 3047 | 3203 | // Add this file to the include list, whether $once is true or not. |
| 3048 | - else |
|
| 3049 | - $templates[] = $filename; |
|
| 3204 | + else { |
|
| 3205 | + $templates[] = $filename; |
|
| 3206 | + } |
|
| 3050 | 3207 | |
| 3051 | 3208 | |
| 3052 | 3209 | $file_found = file_exists($filename); |
| 3053 | 3210 | |
| 3054 | - if ($once && $file_found) |
|
| 3055 | - require_once($filename); |
|
| 3056 | - elseif ($file_found) |
|
| 3057 | - require($filename); |
|
| 3211 | + if ($once && $file_found) { |
|
| 3212 | + require_once($filename); |
|
| 3213 | + } elseif ($file_found) { |
|
| 3214 | + require($filename); |
|
| 3215 | + } |
|
| 3058 | 3216 | |
| 3059 | 3217 | if ($file_found !== true) |
| 3060 | 3218 | { |
| 3061 | 3219 | ob_end_clean(); |
| 3062 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
| 3063 | - @ob_start('ob_gzhandler'); |
|
| 3064 | - else |
|
| 3065 | - ob_start(); |
|
| 3220 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
| 3221 | + @ob_start('ob_gzhandler'); |
|
| 3222 | + } else { |
|
| 3223 | + ob_start(); |
|
| 3224 | + } |
|
| 3066 | 3225 | |
| 3067 | - if (isset($_GET['debug'])) |
|
| 3068 | - header('content-type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
| 3226 | + if (isset($_GET['debug'])) { |
|
| 3227 | + header('content-type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
| 3228 | + } |
|
| 3069 | 3229 | |
| 3070 | 3230 | // Don't cache error pages!! |
| 3071 | 3231 | header('expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
@@ -3084,12 +3244,13 @@ discard block |
||
| 3084 | 3244 | echo '<!DOCTYPE html> |
| 3085 | 3245 | <html', !empty($context['right_to_left']) ? ' dir="rtl"' : '', '> |
| 3086 | 3246 | <head>'; |
| 3087 | - if (isset($context['character_set'])) |
|
| 3088 | - echo ' |
|
| 3247 | + if (isset($context['character_set'])) { |
|
| 3248 | + echo ' |
|
| 3089 | 3249 | <meta charset="', $context['character_set'], '">'; |
| 3250 | + } |
|
| 3090 | 3251 | |
| 3091 | - if (!empty($maintenance) && !allowedTo('admin_forum')) |
|
| 3092 | - echo ' |
|
| 3252 | + if (!empty($maintenance) && !allowedTo('admin_forum')) { |
|
| 3253 | + echo ' |
|
| 3093 | 3254 | <title>', $mtitle, '</title> |
| 3094 | 3255 | </head> |
| 3095 | 3256 | <body> |
@@ -3097,8 +3258,8 @@ discard block |
||
| 3097 | 3258 | ', $mmessage, ' |
| 3098 | 3259 | </body> |
| 3099 | 3260 | </html>'; |
| 3100 | - elseif (!allowedTo('admin_forum')) |
|
| 3101 | - echo ' |
|
| 3261 | + } elseif (!allowedTo('admin_forum')) { |
|
| 3262 | + echo ' |
|
| 3102 | 3263 | <title>', $txt['template_parse_error'], '</title> |
| 3103 | 3264 | </head> |
| 3104 | 3265 | <body> |
@@ -3106,14 +3267,16 @@ discard block |
||
| 3106 | 3267 | ', $txt['template_parse_error_message'], ' |
| 3107 | 3268 | </body> |
| 3108 | 3269 | </html>'; |
| 3109 | - else |
|
| 3270 | + } else |
|
| 3110 | 3271 | { |
| 3111 | 3272 | $error = fetch_web_data($boardurl . strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => ''))); |
| 3112 | 3273 | $error_array = error_get_last(); |
| 3113 | - if (empty($error) && ini_get('track_errors') && !empty($error_array)) |
|
| 3114 | - $error = $error_array['message']; |
|
| 3115 | - if (empty($error)) |
|
| 3116 | - $error = $txt['template_parse_errmsg']; |
|
| 3274 | + if (empty($error) && ini_get('track_errors') && !empty($error_array)) { |
|
| 3275 | + $error = $error_array['message']; |
|
| 3276 | + } |
|
| 3277 | + if (empty($error)) { |
|
| 3278 | + $error = $txt['template_parse_errmsg']; |
|
| 3279 | + } |
|
| 3117 | 3280 | |
| 3118 | 3281 | $error = strtr($error, array('<b>' => '<strong>', '</b>' => '</strong>')); |
| 3119 | 3282 | |
@@ -3124,11 +3287,12 @@ discard block |
||
| 3124 | 3287 | <h3>', $txt['template_parse_error'], '</h3> |
| 3125 | 3288 | ', sprintf($txt['template_parse_error_details'], strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => ''))); |
| 3126 | 3289 | |
| 3127 | - if (!empty($error)) |
|
| 3128 | - echo ' |
|
| 3290 | + if (!empty($error)) { |
|
| 3291 | + echo ' |
|
| 3129 | 3292 | <hr> |
| 3130 | 3293 | |
| 3131 | 3294 | <div style="margin: 0 20px;"><pre>', strtr(strtr($error, array('<strong>' . $boarddir => '<strong>...', '<strong>' . strtr($boarddir, '\\', '/') => '<strong>...')), '\\', '/'), '</pre></div>'; |
| 3295 | + } |
|
| 3132 | 3296 | |
| 3133 | 3297 | // I know, I know... this is VERY COMPLICATED. Still, it's good. |
| 3134 | 3298 | if (preg_match('~ <strong>(\d+)</strong><br( /)?' . '>$~i', $error, $match) != 0) |
@@ -3138,10 +3302,11 @@ discard block |
||
| 3138 | 3302 | $data2 = preg_split('~\<br( /)?\>~', $data2); |
| 3139 | 3303 | |
| 3140 | 3304 | // Fix the PHP code stuff... |
| 3141 | - if (!isBrowser('gecko')) |
|
| 3142 | - $data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2); |
|
| 3143 | - else |
|
| 3144 | - $data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2); |
|
| 3305 | + if (!isBrowser('gecko')) { |
|
| 3306 | + $data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2); |
|
| 3307 | + } else { |
|
| 3308 | + $data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2); |
|
| 3309 | + } |
|
| 3145 | 3310 | |
| 3146 | 3311 | // Now we get to work around a bug in PHP where it doesn't escape <br>s! |
| 3147 | 3312 | $j = -1; |
@@ -3149,8 +3314,9 @@ discard block |
||
| 3149 | 3314 | { |
| 3150 | 3315 | $j++; |
| 3151 | 3316 | |
| 3152 | - if (substr_count($line, '<br>') == 0) |
|
| 3153 | - continue; |
|
| 3317 | + if (substr_count($line, '<br>') == 0) { |
|
| 3318 | + continue; |
|
| 3319 | + } |
|
| 3154 | 3320 | |
| 3155 | 3321 | $n = substr_count($line, '<br>'); |
| 3156 | 3322 | for ($i = 0; $i < $n; $i++) |
@@ -3169,38 +3335,42 @@ discard block |
||
| 3169 | 3335 | // Figure out what the color coding was before... |
| 3170 | 3336 | $line = max($match[1] - 9, 1); |
| 3171 | 3337 | $last_line = ''; |
| 3172 | - for ($line2 = $line - 1; $line2 > 1; $line2--) |
|
| 3173 | - if (strpos($data2[$line2], '<') !== false) |
|
| 3338 | + for ($line2 = $line - 1; $line2 > 1; $line2--) { |
|
| 3339 | + if (strpos($data2[$line2], '<') !== false) |
|
| 3174 | 3340 | { |
| 3175 | 3341 | if (preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line2], $color_match) != 0) |
| 3176 | 3342 | $last_line = $color_match[1]; |
| 3343 | + } |
|
| 3177 | 3344 | break; |
| 3178 | 3345 | } |
| 3179 | 3346 | |
| 3180 | 3347 | // Show the relevant lines... |
| 3181 | 3348 | for ($n = min($match[1] + 4, count($data2) + 1); $line <= $n; $line++) |
| 3182 | 3349 | { |
| 3183 | - if ($line == $match[1]) |
|
| 3184 | - echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">'; |
|
| 3350 | + if ($line == $match[1]) { |
|
| 3351 | + echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">'; |
|
| 3352 | + } |
|
| 3185 | 3353 | |
| 3186 | 3354 | echo '<span style="color: black;">', sprintf('%' . strlen($n) . 's', $line), ':</span> '; |
| 3187 | - if (isset($data2[$line]) && $data2[$line] != '') |
|
| 3188 | - echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line]; |
|
| 3355 | + if (isset($data2[$line]) && $data2[$line] != '') { |
|
| 3356 | + echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line]; |
|
| 3357 | + } |
|
| 3189 | 3358 | |
| 3190 | 3359 | if (isset($data2[$line]) && preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line], $color_match) != 0) |
| 3191 | 3360 | { |
| 3192 | 3361 | $last_line = $color_match[1]; |
| 3193 | 3362 | echo '</', substr($last_line, 1, 4), '>'; |
| 3363 | + } elseif ($last_line != '' && strpos($data2[$line], '<') !== false) { |
|
| 3364 | + $last_line = ''; |
|
| 3365 | + } elseif ($last_line != '' && $data2[$line] != '') { |
|
| 3366 | + echo '</', substr($last_line, 1, 4), '>'; |
|
| 3194 | 3367 | } |
| 3195 | - elseif ($last_line != '' && strpos($data2[$line], '<') !== false) |
|
| 3196 | - $last_line = ''; |
|
| 3197 | - elseif ($last_line != '' && $data2[$line] != '') |
|
| 3198 | - echo '</', substr($last_line, 1, 4), '>'; |
|
| 3199 | 3368 | |
| 3200 | - if ($line == $match[1]) |
|
| 3201 | - echo '</pre></div><pre style="margin: 0;">'; |
|
| 3202 | - else |
|
| 3203 | - echo "\n"; |
|
| 3369 | + if ($line == $match[1]) { |
|
| 3370 | + echo '</pre></div><pre style="margin: 0;">'; |
|
| 3371 | + } else { |
|
| 3372 | + echo "\n"; |
|
| 3373 | + } |
|
| 3204 | 3374 | } |
| 3205 | 3375 | |
| 3206 | 3376 | echo '</pre></div>'; |
@@ -3224,8 +3394,9 @@ discard block |
||
| 3224 | 3394 | global $db_type, $db_name, $ssi_db_user, $ssi_db_passwd, $sourcedir, $db_prefix, $db_port, $db_mb4; |
| 3225 | 3395 | |
| 3226 | 3396 | // Figure out what type of database we are using. |
| 3227 | - if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
|
| 3228 | - $db_type = 'mysql'; |
|
| 3397 | + if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) { |
|
| 3398 | + $db_type = 'mysql'; |
|
| 3399 | + } |
|
| 3229 | 3400 | |
| 3230 | 3401 | // Load the file for the database. |
| 3231 | 3402 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
@@ -3233,11 +3404,13 @@ discard block |
||
| 3233 | 3404 | $db_options = array(); |
| 3234 | 3405 | |
| 3235 | 3406 | // Add in the port if needed |
| 3236 | - if (!empty($db_port)) |
|
| 3237 | - $db_options['port'] = $db_port; |
|
| 3407 | + if (!empty($db_port)) { |
|
| 3408 | + $db_options['port'] = $db_port; |
|
| 3409 | + } |
|
| 3238 | 3410 | |
| 3239 | - if (!empty($db_mb4)) |
|
| 3240 | - $db_options['db_mb4'] = $db_mb4; |
|
| 3411 | + if (!empty($db_mb4)) { |
|
| 3412 | + $db_options['db_mb4'] = $db_mb4; |
|
| 3413 | + } |
|
| 3241 | 3414 | |
| 3242 | 3415 | // 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. |
| 3243 | 3416 | if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd)) |
@@ -3256,13 +3429,15 @@ discard block |
||
| 3256 | 3429 | } |
| 3257 | 3430 | |
| 3258 | 3431 | // Safe guard here, if there isn't a valid connection lets put a stop to it. |
| 3259 | - if (!$db_connection) |
|
| 3260 | - display_db_error(); |
|
| 3432 | + if (!$db_connection) { |
|
| 3433 | + display_db_error(); |
|
| 3434 | + } |
|
| 3261 | 3435 | |
| 3262 | 3436 | // If in SSI mode fix up the prefix. |
| 3263 | - if (SMF == 'SSI') |
|
| 3264 | - db_fix_prefix($db_prefix, $db_name); |
|
| 3265 | -} |
|
| 3437 | + if (SMF == 'SSI') { |
|
| 3438 | + db_fix_prefix($db_prefix, $db_name); |
|
| 3439 | + } |
|
| 3440 | + } |
|
| 3266 | 3441 | |
| 3267 | 3442 | /** |
| 3268 | 3443 | * Try to load up a supported caching method. This is saved in $cacheAPI if we are not overriding it. |
@@ -3276,10 +3451,11 @@ discard block |
||
| 3276 | 3451 | global $sourcedir, $cacheAPI, $cache_accelerator; |
| 3277 | 3452 | |
| 3278 | 3453 | // Not overriding this and we have a cacheAPI, send it back. |
| 3279 | - if (empty($overrideCache) && is_object($cacheAPI)) |
|
| 3280 | - return $cacheAPI; |
|
| 3281 | - elseif (is_null($cacheAPI)) |
|
| 3282 | - $cacheAPI = false; |
|
| 3454 | + if (empty($overrideCache) && is_object($cacheAPI)) { |
|
| 3455 | + return $cacheAPI; |
|
| 3456 | + } elseif (is_null($cacheAPI)) { |
|
| 3457 | + $cacheAPI = false; |
|
| 3458 | + } |
|
| 3283 | 3459 | |
| 3284 | 3460 | // Make sure our class is in session. |
| 3285 | 3461 | require_once($sourcedir . '/Class-CacheAPI.php'); |
@@ -3300,8 +3476,9 @@ discard block |
||
| 3300 | 3476 | if (!$testAPI->isSupported()) |
| 3301 | 3477 | { |
| 3302 | 3478 | // Can we save ourselves? |
| 3303 | - if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') |
|
| 3304 | - return loadCacheAccelerator(null, false); |
|
| 3479 | + if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') { |
|
| 3480 | + return loadCacheAccelerator(null, false); |
|
| 3481 | + } |
|
| 3305 | 3482 | return false; |
| 3306 | 3483 | } |
| 3307 | 3484 | |
@@ -3313,9 +3490,9 @@ discard block |
||
| 3313 | 3490 | { |
| 3314 | 3491 | $cacheAPI = $testAPI; |
| 3315 | 3492 | return $cacheAPI; |
| 3493 | + } else { |
|
| 3494 | + return $testAPI; |
|
| 3316 | 3495 | } |
| 3317 | - else |
|
| 3318 | - return $testAPI; |
|
| 3319 | 3496 | } |
| 3320 | 3497 | } |
| 3321 | 3498 | |
@@ -3335,8 +3512,9 @@ discard block |
||
| 3335 | 3512 | |
| 3336 | 3513 | // @todo Why are we doing this if caching is disabled? |
| 3337 | 3514 | |
| 3338 | - if (function_exists('call_integration_hook')) |
|
| 3339 | - call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level)); |
|
| 3515 | + if (function_exists('call_integration_hook')) { |
|
| 3516 | + call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level)); |
|
| 3517 | + } |
|
| 3340 | 3518 | |
| 3341 | 3519 | /* Refresh the cache if either: |
| 3342 | 3520 | 1. Caching is disabled. |
@@ -3350,16 +3528,19 @@ discard block |
||
| 3350 | 3528 | require_once($sourcedir . '/' . $file); |
| 3351 | 3529 | $cache_block = call_user_func_array($function, $params); |
| 3352 | 3530 | |
| 3353 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) |
|
| 3354 | - cache_put_data($key, $cache_block, $cache_block['expires'] - time()); |
|
| 3531 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) { |
|
| 3532 | + cache_put_data($key, $cache_block, $cache_block['expires'] - time()); |
|
| 3533 | + } |
|
| 3355 | 3534 | } |
| 3356 | 3535 | |
| 3357 | 3536 | // Some cached data may need a freshening up after retrieval. |
| 3358 | - if (!empty($cache_block['post_retri_eval'])) |
|
| 3359 | - eval($cache_block['post_retri_eval']); |
|
| 3537 | + if (!empty($cache_block['post_retri_eval'])) { |
|
| 3538 | + eval($cache_block['post_retri_eval']); |
|
| 3539 | + } |
|
| 3360 | 3540 | |
| 3361 | - if (function_exists('call_integration_hook')) |
|
| 3362 | - call_integration_hook('post_cache_quick_get', array(&$cache_block)); |
|
| 3541 | + if (function_exists('call_integration_hook')) { |
|
| 3542 | + call_integration_hook('post_cache_quick_get', array(&$cache_block)); |
|
| 3543 | + } |
|
| 3363 | 3544 | |
| 3364 | 3545 | return $cache_block['data']; |
| 3365 | 3546 | } |
@@ -3386,8 +3567,9 @@ discard block |
||
| 3386 | 3567 | global $smcFunc, $cache_enable, $cacheAPI; |
| 3387 | 3568 | global $cache_hits, $cache_count, $db_show_debug; |
| 3388 | 3569 | |
| 3389 | - if (empty($cache_enable) || empty($cacheAPI)) |
|
| 3390 | - return; |
|
| 3570 | + if (empty($cache_enable) || empty($cacheAPI)) { |
|
| 3571 | + return; |
|
| 3572 | + } |
|
| 3391 | 3573 | |
| 3392 | 3574 | $cache_count = isset($cache_count) ? $cache_count + 1 : 1; |
| 3393 | 3575 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -3400,12 +3582,14 @@ discard block |
||
| 3400 | 3582 | $value = $value === null ? null : (isset($smcFunc['json_encode']) ? $smcFunc['json_encode']($value) : json_encode($value)); |
| 3401 | 3583 | $cacheAPI->putData($key, $value, $ttl); |
| 3402 | 3584 | |
| 3403 | - if (function_exists('call_integration_hook')) |
|
| 3404 | - call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl)); |
|
| 3585 | + if (function_exists('call_integration_hook')) { |
|
| 3586 | + call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl)); |
|
| 3587 | + } |
|
| 3405 | 3588 | |
| 3406 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
| 3407 | - $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
| 3408 | -} |
|
| 3589 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
| 3590 | + $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
| 3591 | + } |
|
| 3592 | + } |
|
| 3409 | 3593 | |
| 3410 | 3594 | /** |
| 3411 | 3595 | * Gets the value from the cache specified by key, so long as it is not older than ttl seconds. |
@@ -3421,8 +3605,9 @@ discard block |
||
| 3421 | 3605 | global $smcFunc, $cache_enable, $cacheAPI; |
| 3422 | 3606 | global $cache_hits, $cache_count, $cache_misses, $cache_count_misses, $db_show_debug; |
| 3423 | 3607 | |
| 3424 | - if (empty($cache_enable) || empty($cacheAPI)) |
|
| 3425 | - return; |
|
| 3608 | + if (empty($cache_enable) || empty($cacheAPI)) { |
|
| 3609 | + return; |
|
| 3610 | + } |
|
| 3426 | 3611 | |
| 3427 | 3612 | $cache_count = isset($cache_count) ? $cache_count + 1 : 1; |
| 3428 | 3613 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -3442,16 +3627,18 @@ discard block |
||
| 3442 | 3627 | |
| 3443 | 3628 | if (empty($value)) |
| 3444 | 3629 | { |
| 3445 | - if (!is_array($cache_misses)) |
|
| 3446 | - $cache_misses = array(); |
|
| 3630 | + if (!is_array($cache_misses)) { |
|
| 3631 | + $cache_misses = array(); |
|
| 3632 | + } |
|
| 3447 | 3633 | |
| 3448 | 3634 | $cache_count_misses = isset($cache_count_misses) ? $cache_count_misses + 1 : 1; |
| 3449 | 3635 | $cache_misses[$cache_count_misses] = array('k' => $original_key, 'd' => 'get'); |
| 3450 | 3636 | } |
| 3451 | 3637 | } |
| 3452 | 3638 | |
| 3453 | - if (function_exists('call_integration_hook') && isset($value)) |
|
| 3454 | - call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value)); |
|
| 3639 | + if (function_exists('call_integration_hook') && isset($value)) { |
|
| 3640 | + call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value)); |
|
| 3641 | + } |
|
| 3455 | 3642 | |
| 3456 | 3643 | return empty($value) ? null : (isset($smcFunc['json_decode']) ? $smcFunc['json_decode']($value, true) : smf_json_decode($value, true)); |
| 3457 | 3644 | } |
@@ -3473,8 +3660,9 @@ discard block |
||
| 3473 | 3660 | global $cacheAPI; |
| 3474 | 3661 | |
| 3475 | 3662 | // If we can't get to the API, can't do this. |
| 3476 | - if (empty($cacheAPI)) |
|
| 3477 | - return; |
|
| 3663 | + if (empty($cacheAPI)) { |
|
| 3664 | + return; |
|
| 3665 | + } |
|
| 3478 | 3666 | |
| 3479 | 3667 | // Ask the API to do the heavy lifting. cleanCache also calls invalidateCache to be sure. |
| 3480 | 3668 | $cacheAPI->cleanCache($type); |
@@ -3499,8 +3687,9 @@ discard block |
||
| 3499 | 3687 | global $modSettings, $smcFunc, $image_proxy_enabled, $user_info; |
| 3500 | 3688 | |
| 3501 | 3689 | // Come on! |
| 3502 | - if (empty($data)) |
|
| 3503 | - return array(); |
|
| 3690 | + if (empty($data)) { |
|
| 3691 | + return array(); |
|
| 3692 | + } |
|
| 3504 | 3693 | |
| 3505 | 3694 | // Set a nice default var. |
| 3506 | 3695 | $image = ''; |
@@ -3508,11 +3697,11 @@ discard block |
||
| 3508 | 3697 | // Gravatar has been set as mandatory! |
| 3509 | 3698 | if (!empty($modSettings['gravatarOverride'])) |
| 3510 | 3699 | { |
| 3511 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) |
|
| 3512 | - $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
| 3513 | - |
|
| 3514 | - else if (!empty($data['email'])) |
|
| 3515 | - $image = get_gravatar_url($data['email']); |
|
| 3700 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) { |
|
| 3701 | + $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
| 3702 | + } else if (!empty($data['email'])) { |
|
| 3703 | + $image = get_gravatar_url($data['email']); |
|
| 3704 | + } |
|
| 3516 | 3705 | } |
| 3517 | 3706 | |
| 3518 | 3707 | // Look if the user has a gravatar field or has set an external url as avatar. |
@@ -3524,54 +3713,60 @@ discard block |
||
| 3524 | 3713 | // Gravatar. |
| 3525 | 3714 | if (stristr($data['avatar'], 'gravatar://')) |
| 3526 | 3715 | { |
| 3527 | - if ($data['avatar'] == 'gravatar://') |
|
| 3528 | - $image = get_gravatar_url($data['email']); |
|
| 3529 | - |
|
| 3530 | - elseif (!empty($modSettings['gravatarAllowExtraEmail'])) |
|
| 3531 | - $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
| 3716 | + if ($data['avatar'] == 'gravatar://') { |
|
| 3717 | + $image = get_gravatar_url($data['email']); |
|
| 3718 | + } elseif (!empty($modSettings['gravatarAllowExtraEmail'])) { |
|
| 3719 | + $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
| 3720 | + } |
|
| 3532 | 3721 | } |
| 3533 | 3722 | |
| 3534 | 3723 | // External url. |
| 3535 | 3724 | else |
| 3536 | 3725 | { |
| 3537 | 3726 | // Using ssl? |
| 3538 | - if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) |
|
| 3539 | - $image = get_proxied_url($data['avatar']); |
|
| 3727 | + if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) { |
|
| 3728 | + $image = get_proxied_url($data['avatar']); |
|
| 3729 | + } |
|
| 3540 | 3730 | |
| 3541 | 3731 | // Just a plain external url. |
| 3542 | - else |
|
| 3543 | - $image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar']; |
|
| 3732 | + else { |
|
| 3733 | + $image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar']; |
|
| 3734 | + } |
|
| 3544 | 3735 | } |
| 3545 | 3736 | } |
| 3546 | 3737 | |
| 3547 | 3738 | // Perhaps this user has an attachment as avatar... |
| 3548 | - else if (!empty($data['filename'])) |
|
| 3549 | - $image = $modSettings['custom_avatar_url'] . '/' . $data['filename']; |
|
| 3739 | + else if (!empty($data['filename'])) { |
|
| 3740 | + $image = $modSettings['custom_avatar_url'] . '/' . $data['filename']; |
|
| 3741 | + } |
|
| 3550 | 3742 | |
| 3551 | 3743 | // Right... no avatar... use our default image. |
| 3552 | - else |
|
| 3553 | - $image = $modSettings['avatar_url'] . '/default.png'; |
|
| 3744 | + else { |
|
| 3745 | + $image = $modSettings['avatar_url'] . '/default.png'; |
|
| 3746 | + } |
|
| 3554 | 3747 | } |
| 3555 | 3748 | |
| 3556 | 3749 | call_integration_hook('integrate_set_avatar_data', array(&$image, &$data)); |
| 3557 | 3750 | |
| 3558 | 3751 | // 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. |
| 3559 | - if (!empty($image)) |
|
| 3560 | - return array( |
|
| 3752 | + if (!empty($image)) { |
|
| 3753 | + return array( |
|
| 3561 | 3754 | 'name' => !empty($data['avatar']) ? $data['avatar'] : '', |
| 3562 | 3755 | 'image' => '<img class="avatar" src="' . $image . '" />', |
| 3563 | 3756 | 'href' => $image, |
| 3564 | 3757 | 'url' => $image, |
| 3565 | 3758 | ); |
| 3759 | + } |
|
| 3566 | 3760 | |
| 3567 | 3761 | // Fallback to make life easier for everyone... |
| 3568 | - else |
|
| 3569 | - return array( |
|
| 3762 | + else { |
|
| 3763 | + return array( |
|
| 3570 | 3764 | 'name' => '', |
| 3571 | 3765 | 'image' => '', |
| 3572 | 3766 | 'href' => '', |
| 3573 | 3767 | 'url' => '', |
| 3574 | 3768 | ); |
| 3575 | -} |
|
| 3769 | + } |
|
| 3770 | + } |
|
| 3576 | 3771 | |
| 3577 | 3772 | ?> |
| 3578 | 3773 | \ No newline at end of file |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 4 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * This function shows the board index. |
@@ -34,8 +35,9 @@ discard block |
||
| 34 | 35 | $context['canonical_url'] = $scripturl; |
| 35 | 36 | |
| 36 | 37 | // Do not let search engines index anything if there is a random thing in $_GET. |
| 37 | - if (!empty($_GET)) |
|
| 38 | - $context['robot_no_index'] = true; |
|
| 38 | + if (!empty($_GET)) { |
|
| 39 | + $context['robot_no_index'] = true; |
|
| 40 | + } |
|
| 39 | 41 | |
| 40 | 42 | // Retrieve the categories and boards. |
| 41 | 43 | require_once($sourcedir . '/Subs-BoardIndex.php'); |
@@ -62,11 +64,12 @@ discard block |
||
| 62 | 64 | $context['latest_posts'] = cache_quick_get('boardindex-latest_posts:' . md5($user_info['query_wanna_see_board'] . $user_info['language']), 'Subs-Recent.php', 'cache_getLastPosts', array($latestPostOptions)); |
| 63 | 65 | } |
| 64 | 66 | |
| 65 | - if (!empty($context['latest_posts']) || !empty($context['latest_post'])) |
|
| 66 | - $context['info_center'][] = array( |
|
| 67 | + if (!empty($context['latest_posts']) || !empty($context['latest_post'])) { |
|
| 68 | + $context['info_center'][] = array( |
|
| 67 | 69 | 'tpl' => 'recent', |
| 68 | 70 | 'txt' => 'recent_posts', |
| 69 | 71 | ); |
| 72 | + } |
|
| 70 | 73 | } |
| 71 | 74 | |
| 72 | 75 | // Load the calendar? |
@@ -87,20 +90,22 @@ discard block |
||
| 87 | 90 | // This is used to show the "how-do-I-edit" help. |
| 88 | 91 | $context['calendar_can_edit'] = allowedTo('calendar_edit_any'); |
| 89 | 92 | |
| 90 | - if (!empty($context['show_calendar'])) |
|
| 91 | - $context['info_center'][] = array( |
|
| 93 | + if (!empty($context['show_calendar'])) { |
|
| 94 | + $context['info_center'][] = array( |
|
| 92 | 95 | 'tpl' => 'calendar', |
| 93 | 96 | 'txt' => $context['calendar_only_today'] ? 'calendar_today' : 'calendar_upcoming', |
| 94 | 97 | ); |
| 98 | + } |
|
| 95 | 99 | } |
| 96 | 100 | |
| 97 | 101 | // And stats. |
| 98 | 102 | $context['show_stats'] = allowedTo('view_stats') && !empty($modSettings['trackStats']); |
| 99 | - if ($settings['show_stats_index']) |
|
| 100 | - $context['info_center'][] = array( |
|
| 103 | + if ($settings['show_stats_index']) { |
|
| 104 | + $context['info_center'][] = array( |
|
| 101 | 105 | 'tpl' => 'stats', |
| 102 | 106 | 'txt' => 'forum_stats', |
| 103 | 107 | ); |
| 108 | + } |
|
| 104 | 109 | |
| 105 | 110 | // Now the online stuff |
| 106 | 111 | require_once($sourcedir . '/Subs-MembersOnline.php'); |
@@ -118,12 +123,14 @@ discard block |
||
| 118 | 123 | ); |
| 119 | 124 | |
| 120 | 125 | // Track most online statistics? (Subs-MembersOnline.php) |
| 121 | - if (!empty($modSettings['trackStats'])) |
|
| 122 | - trackStatsUsersOnline($context['num_guests'] + $context['num_spiders'] + $context['num_users_online']); |
|
| 126 | + if (!empty($modSettings['trackStats'])) { |
|
| 127 | + trackStatsUsersOnline($context['num_guests'] + $context['num_spiders'] + $context['num_users_online']); |
|
| 128 | + } |
|
| 123 | 129 | |
| 124 | 130 | // Are we showing all membergroups on the board index? |
| 125 | - if (!empty($settings['show_group_key'])) |
|
| 126 | - $context['membergroups'] = cache_quick_get('membergroup_list', 'Subs-Membergroups.php', 'cache_getMembergroupList', array()); |
|
| 131 | + if (!empty($settings['show_group_key'])) { |
|
| 132 | + $context['membergroups'] = cache_quick_get('membergroup_list', 'Subs-Membergroups.php', 'cache_getMembergroupList', array()); |
|
| 133 | + } |
|
| 127 | 134 | |
| 128 | 135 | // And back to normality. |
| 129 | 136 | $context['page_title'] = sprintf($txt['forum_index'], $context['forum_name']); |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 4 |
| 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 | * Check if the user is who he/she says he is |
@@ -42,12 +43,14 @@ discard block |
||
| 42 | 43 | $refreshTime = isset($_GET['xml']) ? 4200 : 3600; |
| 43 | 44 | |
| 44 | 45 | // Is the security option off? |
| 45 | - if (!empty($modSettings['securityDisable' . ($type != 'admin' ? '_' . $type : '')])) |
|
| 46 | - return; |
|
| 46 | + if (!empty($modSettings['securityDisable' . ($type != 'admin' ? '_' . $type : '')])) { |
|
| 47 | + return; |
|
| 48 | + } |
|
| 47 | 49 | |
| 48 | 50 | // Or are they already logged in?, Moderator or admin session is need for this area |
| 49 | - if ((!empty($_SESSION[$type . '_time']) && $_SESSION[$type . '_time'] + $refreshTime >= time()) || (!empty($_SESSION['admin_time']) && $_SESSION['admin_time'] + $refreshTime >= time())) |
|
| 50 | - return; |
|
| 51 | + if ((!empty($_SESSION[$type . '_time']) && $_SESSION[$type . '_time'] + $refreshTime >= time()) || (!empty($_SESSION['admin_time']) && $_SESSION['admin_time'] + $refreshTime >= time())) { |
|
| 52 | + return; |
|
| 53 | + } |
|
| 51 | 54 | |
| 52 | 55 | require_once($sourcedir . '/Subs-Auth.php'); |
| 53 | 56 | |
@@ -55,8 +58,9 @@ discard block |
||
| 55 | 58 | if (isset($_POST[$type . '_pass'])) |
| 56 | 59 | { |
| 57 | 60 | // Check to ensure we're forcing SSL for authentication |
| 58 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) |
|
| 59 | - fatal_lang_error('login_ssl_required'); |
|
| 61 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) { |
|
| 62 | + fatal_lang_error('login_ssl_required'); |
|
| 63 | + } |
|
| 60 | 64 | |
| 61 | 65 | checkSession(); |
| 62 | 66 | |
@@ -72,17 +76,19 @@ discard block |
||
| 72 | 76 | } |
| 73 | 77 | |
| 74 | 78 | // Better be sure to remember the real referer |
| 75 | - if (empty($_SESSION['request_referer'])) |
|
| 76 | - $_SESSION['request_referer'] = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array(); |
|
| 77 | - elseif (empty($_POST)) |
|
| 78 | - unset($_SESSION['request_referer']); |
|
| 79 | + if (empty($_SESSION['request_referer'])) { |
|
| 80 | + $_SESSION['request_referer'] = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array(); |
|
| 81 | + } elseif (empty($_POST)) { |
|
| 82 | + unset($_SESSION['request_referer']); |
|
| 83 | + } |
|
| 79 | 84 | |
| 80 | 85 | // Need to type in a password for that, man. |
| 81 | - if (!isset($_GET['xml'])) |
|
| 82 | - adminLogin($type); |
|
| 83 | - else |
|
| 84 | - return 'session_verify_fail'; |
|
| 85 | -} |
|
| 86 | + if (!isset($_GET['xml'])) { |
|
| 87 | + adminLogin($type); |
|
| 88 | + } else { |
|
| 89 | + return 'session_verify_fail'; |
|
| 90 | + } |
|
| 91 | + } |
|
| 86 | 92 | |
| 87 | 93 | /** |
| 88 | 94 | * Require a user who is logged in. (not a guest.) |
@@ -96,25 +102,30 @@ discard block |
||
| 96 | 102 | global $user_info, $txt, $context, $scripturl, $modSettings; |
| 97 | 103 | |
| 98 | 104 | // Luckily, this person isn't a guest. |
| 99 | - if (!$user_info['is_guest']) |
|
| 100 | - return; |
|
| 105 | + if (!$user_info['is_guest']) { |
|
| 106 | + return; |
|
| 107 | + } |
|
| 101 | 108 | |
| 102 | 109 | // Log what they were trying to do didn't work) |
| 103 | - if (!empty($modSettings['who_enabled'])) |
|
| 104 | - $_GET['error'] = 'guest_login'; |
|
| 110 | + if (!empty($modSettings['who_enabled'])) { |
|
| 111 | + $_GET['error'] = 'guest_login'; |
|
| 112 | + } |
|
| 105 | 113 | writeLog(true); |
| 106 | 114 | |
| 107 | 115 | // Just die. |
| 108 | - if (isset($_REQUEST['xml'])) |
|
| 109 | - obExit(false); |
|
| 116 | + if (isset($_REQUEST['xml'])) { |
|
| 117 | + obExit(false); |
|
| 118 | + } |
|
| 110 | 119 | |
| 111 | 120 | // Attempt to detect if they came from dlattach. |
| 112 | - if (SMF != 'SSI' && empty($context['theme_loaded'])) |
|
| 113 | - loadTheme(); |
|
| 121 | + if (SMF != 'SSI' && empty($context['theme_loaded'])) { |
|
| 122 | + loadTheme(); |
|
| 123 | + } |
|
| 114 | 124 | |
| 115 | 125 | // Never redirect to an attachment |
| 116 | - if (strpos($_SERVER['REQUEST_URL'], 'dlattach') === false) |
|
| 117 | - $_SESSION['login_url'] = $_SERVER['REQUEST_URL']; |
|
| 126 | + if (strpos($_SERVER['REQUEST_URL'], 'dlattach') === false) { |
|
| 127 | + $_SESSION['login_url'] = $_SERVER['REQUEST_URL']; |
|
| 128 | + } |
|
| 118 | 129 | |
| 119 | 130 | // Load the Login template and language file. |
| 120 | 131 | loadLanguage('Login'); |
@@ -124,8 +135,7 @@ discard block |
||
| 124 | 135 | { |
| 125 | 136 | $_SESSION['login_url'] = $scripturl . '?' . $_SERVER['QUERY_STRING']; |
| 126 | 137 | redirectexit('action=login'); |
| 127 | - } |
|
| 128 | - else |
|
| 138 | + } else |
|
| 129 | 139 | { |
| 130 | 140 | loadTemplate('Login'); |
| 131 | 141 | $context['sub_template'] = 'kick_guest'; |
@@ -155,8 +165,9 @@ discard block |
||
| 155 | 165 | global $sourcedir, $cookiename, $user_settings, $smcFunc; |
| 156 | 166 | |
| 157 | 167 | // You cannot be banned if you are an admin - doesn't help if you log out. |
| 158 | - if ($user_info['is_admin']) |
|
| 159 | - return; |
|
| 168 | + if ($user_info['is_admin']) { |
|
| 169 | + return; |
|
| 170 | + } |
|
| 160 | 171 | |
| 161 | 172 | // Only check the ban every so often. (to reduce load.) |
| 162 | 173 | if ($forceCheck || !isset($_SESSION['ban']) || empty($modSettings['banLastUpdated']) || ($_SESSION['ban']['last_checked'] < $modSettings['banLastUpdated']) || $_SESSION['ban']['id_member'] != $user_info['id'] || $_SESSION['ban']['ip'] != $user_info['ip'] || $_SESSION['ban']['ip2'] != $user_info['ip2'] || (isset($user_info['email'], $_SESSION['ban']['email']) && $_SESSION['ban']['email'] != $user_info['email'])) |
@@ -177,8 +188,9 @@ discard block |
||
| 177 | 188 | // Check both IP addresses. |
| 178 | 189 | foreach (array('ip', 'ip2') as $ip_number) |
| 179 | 190 | { |
| 180 | - if ($ip_number == 'ip2' && $user_info['ip2'] == $user_info['ip']) |
|
| 181 | - continue; |
|
| 191 | + if ($ip_number == 'ip2' && $user_info['ip2'] == $user_info['ip']) { |
|
| 192 | + continue; |
|
| 193 | + } |
|
| 182 | 194 | $ban_query[] = ' {inet:' . $ip_number . '} BETWEEN bi.ip_low and bi.ip_high'; |
| 183 | 195 | $ban_query_vars[$ip_number] = $user_info[$ip_number]; |
| 184 | 196 | // IP was valid, maybe there's also a hostname... |
@@ -228,24 +240,28 @@ discard block |
||
| 228 | 240 | // Store every type of ban that applies to you in your session. |
| 229 | 241 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 230 | 242 | { |
| 231 | - foreach ($restrictions as $restriction) |
|
| 232 | - if (!empty($row[$restriction])) |
|
| 243 | + foreach ($restrictions as $restriction) { |
|
| 244 | + if (!empty($row[$restriction])) |
|
| 233 | 245 | { |
| 234 | 246 | $_SESSION['ban'][$restriction]['reason'] = $row['reason']; |
| 247 | + } |
|
| 235 | 248 | $_SESSION['ban'][$restriction]['ids'][] = $row['id_ban']; |
| 236 | - if (!isset($_SESSION['ban']['expire_time']) || ($_SESSION['ban']['expire_time'] != 0 && ($row['expire_time'] == 0 || $row['expire_time'] > $_SESSION['ban']['expire_time']))) |
|
| 237 | - $_SESSION['ban']['expire_time'] = $row['expire_time']; |
|
| 249 | + if (!isset($_SESSION['ban']['expire_time']) || ($_SESSION['ban']['expire_time'] != 0 && ($row['expire_time'] == 0 || $row['expire_time'] > $_SESSION['ban']['expire_time']))) { |
|
| 250 | + $_SESSION['ban']['expire_time'] = $row['expire_time']; |
|
| 251 | + } |
|
| 238 | 252 | |
| 239 | - if (!$user_info['is_guest'] && $restriction == 'cannot_access' && ($row['id_member'] == $user_info['id'] || $row['email_address'] == $user_info['email'])) |
|
| 240 | - $flag_is_activated = true; |
|
| 253 | + if (!$user_info['is_guest'] && $restriction == 'cannot_access' && ($row['id_member'] == $user_info['id'] || $row['email_address'] == $user_info['email'])) { |
|
| 254 | + $flag_is_activated = true; |
|
| 255 | + } |
|
| 241 | 256 | } |
| 242 | 257 | } |
| 243 | 258 | $smcFunc['db_free_result']($request); |
| 244 | 259 | } |
| 245 | 260 | |
| 246 | 261 | // Mark the cannot_access and cannot_post bans as being 'hit'. |
| 247 | - if (isset($_SESSION['ban']['cannot_access']) || isset($_SESSION['ban']['cannot_post']) || isset($_SESSION['ban']['cannot_login'])) |
|
| 248 | - log_ban(array_merge(isset($_SESSION['ban']['cannot_access']) ? $_SESSION['ban']['cannot_access']['ids'] : array(), isset($_SESSION['ban']['cannot_post']) ? $_SESSION['ban']['cannot_post']['ids'] : array(), isset($_SESSION['ban']['cannot_login']) ? $_SESSION['ban']['cannot_login']['ids'] : array())); |
|
| 262 | + if (isset($_SESSION['ban']['cannot_access']) || isset($_SESSION['ban']['cannot_post']) || isset($_SESSION['ban']['cannot_login'])) { |
|
| 263 | + log_ban(array_merge(isset($_SESSION['ban']['cannot_access']) ? $_SESSION['ban']['cannot_access']['ids'] : array(), isset($_SESSION['ban']['cannot_post']) ? $_SESSION['ban']['cannot_post']['ids'] : array(), isset($_SESSION['ban']['cannot_login']) ? $_SESSION['ban']['cannot_login']['ids'] : array())); |
|
| 264 | + } |
|
| 249 | 265 | |
| 250 | 266 | // If for whatever reason the is_activated flag seems wrong, do a little work to clear it up. |
| 251 | 267 | if ($user_info['id'] && (($user_settings['is_activated'] >= 10 && !$flag_is_activated) |
@@ -260,8 +276,9 @@ discard block |
||
| 260 | 276 | if (!isset($_SESSION['ban']['cannot_access']) && !empty($_COOKIE[$cookiename . '_'])) |
| 261 | 277 | { |
| 262 | 278 | $bans = explode(',', $_COOKIE[$cookiename . '_']); |
| 263 | - foreach ($bans as $key => $value) |
|
| 264 | - $bans[$key] = (int) $value; |
|
| 279 | + foreach ($bans as $key => $value) { |
|
| 280 | + $bans[$key] = (int) $value; |
|
| 281 | + } |
|
| 265 | 282 | $request = $smcFunc['db_query']('', ' |
| 266 | 283 | SELECT bi.id_ban, bg.reason, COALESCE(bg.expire_time, 0) AS expire_time |
| 267 | 284 | FROM {db_prefix}ban_items AS bi |
@@ -298,14 +315,15 @@ discard block |
||
| 298 | 315 | if (isset($_SESSION['ban']['cannot_access'])) |
| 299 | 316 | { |
| 300 | 317 | // We don't wanna see you! |
| 301 | - if (!$user_info['is_guest']) |
|
| 302 | - $smcFunc['db_query']('', ' |
|
| 318 | + if (!$user_info['is_guest']) { |
|
| 319 | + $smcFunc['db_query']('', ' |
|
| 303 | 320 | DELETE FROM {db_prefix}log_online |
| 304 | 321 | WHERE id_member = {int:current_member}', |
| 305 | 322 | array( |
| 306 | 323 | 'current_member' => $user_info['id'], |
| 307 | 324 | ) |
| 308 | 325 | ); |
| 326 | + } |
|
| 309 | 327 | |
| 310 | 328 | // 'Log' the user out. Can't have any funny business... (save the name!) |
| 311 | 329 | $old_name = isset($user_info['name']) && $user_info['name'] != '' ? $user_info['name'] : $txt['guest_title']; |
@@ -391,9 +409,10 @@ discard block |
||
| 391 | 409 | } |
| 392 | 410 | |
| 393 | 411 | // Fix up the banning permissions. |
| 394 | - if (isset($user_info['permissions'])) |
|
| 395 | - banPermissions(); |
|
| 396 | -} |
|
| 412 | + if (isset($user_info['permissions'])) { |
|
| 413 | + banPermissions(); |
|
| 414 | + } |
|
| 415 | + } |
|
| 397 | 416 | |
| 398 | 417 | /** |
| 399 | 418 | * Fix permissions according to ban status. |
@@ -404,8 +423,9 @@ discard block |
||
| 404 | 423 | global $user_info, $sourcedir, $modSettings, $context; |
| 405 | 424 | |
| 406 | 425 | // Somehow they got here, at least take away all permissions... |
| 407 | - if (isset($_SESSION['ban']['cannot_access'])) |
|
| 408 | - $user_info['permissions'] = array(); |
|
| 426 | + if (isset($_SESSION['ban']['cannot_access'])) { |
|
| 427 | + $user_info['permissions'] = array(); |
|
| 428 | + } |
|
| 409 | 429 | // Okay, well, you can watch, but don't touch a thing. |
| 410 | 430 | elseif (isset($_SESSION['ban']['cannot_post']) || (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $user_info['warning'])) |
| 411 | 431 | { |
@@ -447,19 +467,20 @@ discard block |
||
| 447 | 467 | call_integration_hook('integrate_warn_permissions', array(&$permission_change)); |
| 448 | 468 | foreach ($permission_change as $old => $new) |
| 449 | 469 | { |
| 450 | - if (!in_array($old, $user_info['permissions'])) |
|
| 451 | - unset($permission_change[$old]); |
|
| 452 | - else |
|
| 453 | - $user_info['permissions'][] = $new; |
|
| 470 | + if (!in_array($old, $user_info['permissions'])) { |
|
| 471 | + unset($permission_change[$old]); |
|
| 472 | + } else { |
|
| 473 | + $user_info['permissions'][] = $new; |
|
| 474 | + } |
|
| 454 | 475 | } |
| 455 | 476 | $user_info['permissions'] = array_diff($user_info['permissions'], array_keys($permission_change)); |
| 456 | 477 | } |
| 457 | 478 | |
| 458 | 479 | // @todo Find a better place to call this? Needs to be after permissions loaded! |
| 459 | 480 | // Finally, some bits we cache in the session because it saves queries. |
| 460 | - if (isset($_SESSION['mc']) && $_SESSION['mc']['time'] > $modSettings['settings_updated'] && $_SESSION['mc']['id'] == $user_info['id']) |
|
| 461 | - $user_info['mod_cache'] = $_SESSION['mc']; |
|
| 462 | - else |
|
| 481 | + if (isset($_SESSION['mc']) && $_SESSION['mc']['time'] > $modSettings['settings_updated'] && $_SESSION['mc']['id'] == $user_info['id']) { |
|
| 482 | + $user_info['mod_cache'] = $_SESSION['mc']; |
|
| 483 | + } else |
|
| 463 | 484 | { |
| 464 | 485 | require_once($sourcedir . '/Subs-Auth.php'); |
| 465 | 486 | rebuildModCache(); |
@@ -470,14 +491,12 @@ discard block |
||
| 470 | 491 | { |
| 471 | 492 | $context['open_mod_reports'] = $_SESSION['rc']['reports']; |
| 472 | 493 | $context['open_member_reports'] = $_SESSION['rc']['member_reports']; |
| 473 | - } |
|
| 474 | - elseif ($_SESSION['mc']['bq'] != '0=1') |
|
| 494 | + } elseif ($_SESSION['mc']['bq'] != '0=1') |
|
| 475 | 495 | { |
| 476 | 496 | require_once($sourcedir . '/Subs-ReportedContent.php'); |
| 477 | 497 | $context['open_mod_reports'] = recountOpenReports('posts'); |
| 478 | 498 | $context['open_member_reports'] = recountOpenReports('members'); |
| 479 | - } |
|
| 480 | - else |
|
| 499 | + } else |
|
| 481 | 500 | { |
| 482 | 501 | $context['open_mod_reports'] = 0; |
| 483 | 502 | $context['open_member_reports'] = 0; |
@@ -497,8 +516,9 @@ discard block |
||
| 497 | 516 | global $user_info, $smcFunc; |
| 498 | 517 | |
| 499 | 518 | // Don't log web accelerators, it's very confusing... |
| 500 | - if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') |
|
| 501 | - return; |
|
| 519 | + if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') { |
|
| 520 | + return; |
|
| 521 | + } |
|
| 502 | 522 | |
| 503 | 523 | $smcFunc['db_insert']('', |
| 504 | 524 | '{db_prefix}log_banned', |
@@ -508,8 +528,8 @@ discard block |
||
| 508 | 528 | ); |
| 509 | 529 | |
| 510 | 530 | // One extra point for these bans. |
| 511 | - if (!empty($ban_ids)) |
|
| 512 | - $smcFunc['db_query']('', ' |
|
| 531 | + if (!empty($ban_ids)) { |
|
| 532 | + $smcFunc['db_query']('', ' |
|
| 513 | 533 | UPDATE {db_prefix}ban_items |
| 514 | 534 | SET hits = hits + 1 |
| 515 | 535 | WHERE id_ban IN ({array_int:ban_ids})', |
@@ -517,7 +537,8 @@ discard block |
||
| 517 | 537 | 'ban_ids' => $ban_ids, |
| 518 | 538 | ) |
| 519 | 539 | ); |
| 520 | -} |
|
| 540 | + } |
|
| 541 | + } |
|
| 521 | 542 | |
| 522 | 543 | /** |
| 523 | 544 | * Checks if a given email address might be banned. |
@@ -533,8 +554,9 @@ discard block |
||
| 533 | 554 | global $txt, $smcFunc; |
| 534 | 555 | |
| 535 | 556 | // Can't ban an empty email |
| 536 | - if (empty($email) || trim($email) == '') |
|
| 537 | - return; |
|
| 557 | + if (empty($email) || trim($email) == '') { |
|
| 558 | + return; |
|
| 559 | + } |
|
| 538 | 560 | |
| 539 | 561 | // Let's start with the bans based on your IP/hostname/memberID... |
| 540 | 562 | $ban_ids = isset($_SESSION['ban'][$restriction]) ? $_SESSION['ban'][$restriction]['ids'] : array(); |
@@ -607,16 +629,18 @@ discard block |
||
| 607 | 629 | if ($type == 'post') |
| 608 | 630 | { |
| 609 | 631 | $check = isset($_POST[$_SESSION['session_var']]) ? $_POST[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_POST['sc']) ? $_POST['sc'] : null); |
| 610 | - if ($check !== $sc) |
|
| 611 | - $error = 'session_timeout'; |
|
| 632 | + if ($check !== $sc) { |
|
| 633 | + $error = 'session_timeout'; |
|
| 634 | + } |
|
| 612 | 635 | } |
| 613 | 636 | |
| 614 | 637 | // How about $_GET['sesc']? |
| 615 | 638 | elseif ($type == 'get') |
| 616 | 639 | { |
| 617 | 640 | $check = isset($_GET[$_SESSION['session_var']]) ? $_GET[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_GET['sesc']) ? $_GET['sesc'] : null); |
| 618 | - if ($check !== $sc) |
|
| 619 | - $error = 'session_verify_fail'; |
|
| 641 | + if ($check !== $sc) { |
|
| 642 | + $error = 'session_verify_fail'; |
|
| 643 | + } |
|
| 620 | 644 | } |
| 621 | 645 | |
| 622 | 646 | // Or can it be in either? |
@@ -624,13 +648,15 @@ discard block |
||
| 624 | 648 | { |
| 625 | 649 | $check = isset($_GET[$_SESSION['session_var']]) ? $_GET[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_GET['sesc']) ? $_GET['sesc'] : (isset($_POST[$_SESSION['session_var']]) ? $_POST[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_POST['sc']) ? $_POST['sc'] : null))); |
| 626 | 650 | |
| 627 | - if ($check !== $sc) |
|
| 628 | - $error = 'session_verify_fail'; |
|
| 651 | + if ($check !== $sc) { |
|
| 652 | + $error = 'session_verify_fail'; |
|
| 653 | + } |
|
| 629 | 654 | } |
| 630 | 655 | |
| 631 | 656 | // Verify that they aren't changing user agents on us - that could be bad. |
| 632 | - if ((!isset($_SESSION['USER_AGENT']) || $_SESSION['USER_AGENT'] != $_SERVER['HTTP_USER_AGENT']) && empty($modSettings['disableCheckUA'])) |
|
| 633 | - $error = 'session_verify_fail'; |
|
| 657 | + if ((!isset($_SESSION['USER_AGENT']) || $_SESSION['USER_AGENT'] != $_SERVER['HTTP_USER_AGENT']) && empty($modSettings['disableCheckUA'])) { |
|
| 658 | + $error = 'session_verify_fail'; |
|
| 659 | + } |
|
| 634 | 660 | |
| 635 | 661 | // Make sure a page with session check requirement is not being prefetched. |
| 636 | 662 | if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') |
@@ -641,30 +667,35 @@ discard block |
||
| 641 | 667 | } |
| 642 | 668 | |
| 643 | 669 | // Check the referring site - it should be the same server at least! |
| 644 | - if (isset($_SESSION['request_referer'])) |
|
| 645 | - $referrer = $_SESSION['request_referer']; |
|
| 646 | - else |
|
| 647 | - $referrer = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array(); |
|
| 670 | + if (isset($_SESSION['request_referer'])) { |
|
| 671 | + $referrer = $_SESSION['request_referer']; |
|
| 672 | + } else { |
|
| 673 | + $referrer = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array(); |
|
| 674 | + } |
|
| 648 | 675 | if (!empty($referrer['host'])) |
| 649 | 676 | { |
| 650 | - if (strpos($_SERVER['HTTP_HOST'], ':') !== false) |
|
| 651 | - $real_host = substr($_SERVER['HTTP_HOST'], 0, strpos($_SERVER['HTTP_HOST'], ':')); |
|
| 652 | - else |
|
| 653 | - $real_host = $_SERVER['HTTP_HOST']; |
|
| 677 | + if (strpos($_SERVER['HTTP_HOST'], ':') !== false) { |
|
| 678 | + $real_host = substr($_SERVER['HTTP_HOST'], 0, strpos($_SERVER['HTTP_HOST'], ':')); |
|
| 679 | + } else { |
|
| 680 | + $real_host = $_SERVER['HTTP_HOST']; |
|
| 681 | + } |
|
| 654 | 682 | |
| 655 | 683 | $parsed_url = parse_url($boardurl); |
| 656 | 684 | |
| 657 | 685 | // Are global cookies on? If so, let's check them ;). |
| 658 | 686 | if (!empty($modSettings['globalCookies'])) |
| 659 | 687 | { |
| 660 | - if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $parsed_url['host'], $parts) == 1) |
|
| 661 | - $parsed_url['host'] = $parts[1]; |
|
| 688 | + if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $parsed_url['host'], $parts) == 1) { |
|
| 689 | + $parsed_url['host'] = $parts[1]; |
|
| 690 | + } |
|
| 662 | 691 | |
| 663 | - if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $referrer['host'], $parts) == 1) |
|
| 664 | - $referrer['host'] = $parts[1]; |
|
| 692 | + if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $referrer['host'], $parts) == 1) { |
|
| 693 | + $referrer['host'] = $parts[1]; |
|
| 694 | + } |
|
| 665 | 695 | |
| 666 | - if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $real_host, $parts) == 1) |
|
| 667 | - $real_host = $parts[1]; |
|
| 696 | + if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $real_host, $parts) == 1) { |
|
| 697 | + $real_host = $parts[1]; |
|
| 698 | + } |
|
| 668 | 699 | } |
| 669 | 700 | |
| 670 | 701 | // Okay: referrer must either match parsed_url or real_host. |
@@ -682,12 +713,14 @@ discard block |
||
| 682 | 713 | $log_error = true; |
| 683 | 714 | } |
| 684 | 715 | |
| 685 | - if (strtolower($_SERVER['HTTP_USER_AGENT']) == 'hacker') |
|
| 686 | - fatal_error('Sound the alarm! It\'s a hacker! Close the castle gates!!', false); |
|
| 716 | + if (strtolower($_SERVER['HTTP_USER_AGENT']) == 'hacker') { |
|
| 717 | + fatal_error('Sound the alarm! It\'s a hacker! Close the castle gates!!', false); |
|
| 718 | + } |
|
| 687 | 719 | |
| 688 | 720 | // Everything is ok, return an empty string. |
| 689 | - if (!isset($error)) |
|
| 690 | - return ''; |
|
| 721 | + if (!isset($error)) { |
|
| 722 | + return ''; |
|
| 723 | + } |
|
| 691 | 724 | // A session error occurred, show the error. |
| 692 | 725 | elseif ($is_fatal) |
| 693 | 726 | { |
@@ -696,13 +729,14 @@ discard block |
||
| 696 | 729 | ob_end_clean(); |
| 697 | 730 | header('HTTP/1.1 403 Forbidden - Session timeout'); |
| 698 | 731 | die; |
| 732 | + } else { |
|
| 733 | + fatal_lang_error($error, isset($log_error) ? 'user' : false); |
|
| 699 | 734 | } |
| 700 | - else |
|
| 701 | - fatal_lang_error($error, isset($log_error) ? 'user' : false); |
|
| 702 | 735 | } |
| 703 | 736 | // A session error occurred, return the error to the calling function. |
| 704 | - else |
|
| 705 | - return $error; |
|
| 737 | + else { |
|
| 738 | + return $error; |
|
| 739 | + } |
|
| 706 | 740 | |
| 707 | 741 | // We really should never fall through here, for very important reasons. Let's make sure. |
| 708 | 742 | trigger_error('Hacking attempt...', E_USER_ERROR); |
@@ -718,10 +752,9 @@ discard block |
||
| 718 | 752 | { |
| 719 | 753 | global $modSettings; |
| 720 | 754 | |
| 721 | - if (isset($_GET['confirm']) && isset($_SESSION['confirm_' . $action]) && md5($_GET['confirm'] . $_SERVER['HTTP_USER_AGENT']) == $_SESSION['confirm_' . $action]) |
|
| 722 | - return true; |
|
| 723 | - |
|
| 724 | - else |
|
| 755 | + if (isset($_GET['confirm']) && isset($_SESSION['confirm_' . $action]) && md5($_GET['confirm'] . $_SERVER['HTTP_USER_AGENT']) == $_SESSION['confirm_' . $action]) { |
|
| 756 | + return true; |
|
| 757 | + } else |
|
| 725 | 758 | { |
| 726 | 759 | $token = md5(mt_rand() . session_id() . (string) microtime() . $modSettings['rand_seed']); |
| 727 | 760 | $_SESSION['confirm_' . $action] = md5($token . $_SERVER['HTTP_USER_AGENT']); |
@@ -772,9 +805,9 @@ discard block |
||
| 772 | 805 | $return = $_SESSION['token'][$type . '-' . $action][3]; |
| 773 | 806 | unset($_SESSION['token'][$type . '-' . $action]); |
| 774 | 807 | return $return; |
| 808 | + } else { |
|
| 809 | + return ''; |
|
| 775 | 810 | } |
| 776 | - else |
|
| 777 | - return ''; |
|
| 778 | 811 | } |
| 779 | 812 | |
| 780 | 813 | // This nasty piece of code validates a token. |
@@ -805,12 +838,14 @@ discard block |
||
| 805 | 838 | fatal_lang_error('token_verify_fail', false); |
| 806 | 839 | } |
| 807 | 840 | // Remove this token as its useless |
| 808 | - else |
|
| 809 | - unset($_SESSION['token'][$type . '-' . $action]); |
|
| 841 | + else { |
|
| 842 | + unset($_SESSION['token'][$type . '-' . $action]); |
|
| 843 | + } |
|
| 810 | 844 | |
| 811 | 845 | // Randomly check if we should remove some older tokens. |
| 812 | - if (mt_rand(0, 138) == 23) |
|
| 813 | - cleanTokens(); |
|
| 846 | + if (mt_rand(0, 138) == 23) { |
|
| 847 | + cleanTokens(); |
|
| 848 | + } |
|
| 814 | 849 | |
| 815 | 850 | return false; |
| 816 | 851 | } |
@@ -825,14 +860,16 @@ discard block |
||
| 825 | 860 | function cleanTokens($complete = false) |
| 826 | 861 | { |
| 827 | 862 | // We appreciate cleaning up after yourselves. |
| 828 | - if (!isset($_SESSION['token'])) |
|
| 829 | - return; |
|
| 863 | + if (!isset($_SESSION['token'])) { |
|
| 864 | + return; |
|
| 865 | + } |
|
| 830 | 866 | |
| 831 | 867 | // Clean up tokens, trying to give enough time still. |
| 832 | - foreach ($_SESSION['token'] as $key => $data) |
|
| 833 | - if ($data[2] + 10800 < time() || $complete) |
|
| 868 | + foreach ($_SESSION['token'] as $key => $data) { |
|
| 869 | + if ($data[2] + 10800 < time() || $complete) |
|
| 834 | 870 | unset($_SESSION['token'][$key]); |
| 835 | -} |
|
| 871 | + } |
|
| 872 | + } |
|
| 836 | 873 | |
| 837 | 874 | /** |
| 838 | 875 | * Check whether a form has been submitted twice. |
@@ -850,37 +887,40 @@ discard block |
||
| 850 | 887 | { |
| 851 | 888 | global $context; |
| 852 | 889 | |
| 853 | - if (!isset($_SESSION['forms'])) |
|
| 854 | - $_SESSION['forms'] = array(); |
|
| 890 | + if (!isset($_SESSION['forms'])) { |
|
| 891 | + $_SESSION['forms'] = array(); |
|
| 892 | + } |
|
| 855 | 893 | |
| 856 | 894 | // Register a form number and store it in the session stack. (use this on the page that has the form.) |
| 857 | 895 | if ($action == 'register') |
| 858 | 896 | { |
| 859 | 897 | $context['form_sequence_number'] = 0; |
| 860 | - while (empty($context['form_sequence_number']) || in_array($context['form_sequence_number'], $_SESSION['forms'])) |
|
| 861 | - $context['form_sequence_number'] = mt_rand(1, 16000000); |
|
| 898 | + while (empty($context['form_sequence_number']) || in_array($context['form_sequence_number'], $_SESSION['forms'])) { |
|
| 899 | + $context['form_sequence_number'] = mt_rand(1, 16000000); |
|
| 900 | + } |
|
| 862 | 901 | } |
| 863 | 902 | // Check whether the submitted number can be found in the session. |
| 864 | 903 | elseif ($action == 'check') |
| 865 | 904 | { |
| 866 | - if (!isset($_REQUEST['seqnum'])) |
|
| 867 | - return true; |
|
| 868 | - elseif (!in_array($_REQUEST['seqnum'], $_SESSION['forms'])) |
|
| 905 | + if (!isset($_REQUEST['seqnum'])) { |
|
| 906 | + return true; |
|
| 907 | + } elseif (!in_array($_REQUEST['seqnum'], $_SESSION['forms'])) |
|
| 869 | 908 | { |
| 870 | 909 | $_SESSION['forms'][] = (int) $_REQUEST['seqnum']; |
| 871 | 910 | return true; |
| 911 | + } elseif ($is_fatal) { |
|
| 912 | + fatal_lang_error('error_form_already_submitted', false); |
|
| 913 | + } else { |
|
| 914 | + return false; |
|
| 872 | 915 | } |
| 873 | - elseif ($is_fatal) |
|
| 874 | - fatal_lang_error('error_form_already_submitted', false); |
|
| 875 | - else |
|
| 876 | - return false; |
|
| 877 | 916 | } |
| 878 | 917 | // Don't check, just free the stack number. |
| 879 | - elseif ($action == 'free' && isset($_REQUEST['seqnum']) && in_array($_REQUEST['seqnum'], $_SESSION['forms'])) |
|
| 880 | - $_SESSION['forms'] = array_diff($_SESSION['forms'], array($_REQUEST['seqnum'])); |
|
| 881 | - elseif ($action != 'free') |
|
| 882 | - trigger_error('checkSubmitOnce(): Invalid action \'' . $action . '\'', E_USER_WARNING); |
|
| 883 | -} |
|
| 918 | + elseif ($action == 'free' && isset($_REQUEST['seqnum']) && in_array($_REQUEST['seqnum'], $_SESSION['forms'])) { |
|
| 919 | + $_SESSION['forms'] = array_diff($_SESSION['forms'], array($_REQUEST['seqnum'])); |
|
| 920 | + } elseif ($action != 'free') { |
|
| 921 | + trigger_error('checkSubmitOnce(): Invalid action \'' . $action . '\'', E_USER_WARNING); |
|
| 922 | + } |
|
| 923 | + } |
|
| 884 | 924 | |
| 885 | 925 | /** |
| 886 | 926 | * Check the user's permissions. |
@@ -899,16 +939,19 @@ discard block |
||
| 899 | 939 | global $user_info, $smcFunc; |
| 900 | 940 | |
| 901 | 941 | // You're always allowed to do nothing. (unless you're a working man, MR. LAZY :P!) |
| 902 | - if (empty($permission)) |
|
| 903 | - return true; |
|
| 942 | + if (empty($permission)) { |
|
| 943 | + return true; |
|
| 944 | + } |
|
| 904 | 945 | |
| 905 | 946 | // You're never allowed to do something if your data hasn't been loaded yet! |
| 906 | - if (empty($user_info)) |
|
| 907 | - return false; |
|
| 947 | + if (empty($user_info)) { |
|
| 948 | + return false; |
|
| 949 | + } |
|
| 908 | 950 | |
| 909 | 951 | // Administrators are supermen :P. |
| 910 | - if ($user_info['is_admin']) |
|
| 911 | - return true; |
|
| 952 | + if ($user_info['is_admin']) { |
|
| 953 | + return true; |
|
| 954 | + } |
|
| 912 | 955 | |
| 913 | 956 | // Let's ensure this is an array. |
| 914 | 957 | $permission = (array) $permission; |
@@ -916,14 +959,16 @@ discard block |
||
| 916 | 959 | // Are we checking the _current_ board, or some other boards? |
| 917 | 960 | if ($boards === null) |
| 918 | 961 | { |
| 919 | - if (count(array_intersect($permission, $user_info['permissions'])) != 0) |
|
| 920 | - return true; |
|
| 962 | + if (count(array_intersect($permission, $user_info['permissions'])) != 0) { |
|
| 963 | + return true; |
|
| 964 | + } |
|
| 921 | 965 | // You aren't allowed, by default. |
| 922 | - else |
|
| 923 | - return false; |
|
| 966 | + else { |
|
| 967 | + return false; |
|
| 968 | + } |
|
| 969 | + } elseif (!is_array($boards)) { |
|
| 970 | + $boards = array($boards); |
|
| 924 | 971 | } |
| 925 | - elseif (!is_array($boards)) |
|
| 926 | - $boards = array($boards); |
|
| 927 | 972 | |
| 928 | 973 | $request = $smcFunc['db_query']('', ' |
| 929 | 974 | SELECT MIN(bp.add_deny) AS add_deny |
@@ -951,20 +996,23 @@ discard block |
||
| 951 | 996 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 952 | 997 | { |
| 953 | 998 | $result = !empty($row['add_deny']); |
| 954 | - if ($result == true) |
|
| 955 | - break; |
|
| 999 | + if ($result == true) { |
|
| 1000 | + break; |
|
| 1001 | + } |
|
| 956 | 1002 | } |
| 957 | 1003 | $smcFunc['db_free_result']($request); |
| 958 | 1004 | return $result; |
| 959 | 1005 | } |
| 960 | 1006 | |
| 961 | 1007 | // Make sure they can do it on all of the boards. |
| 962 | - if ($smcFunc['db_num_rows']($request) != count($boards)) |
|
| 963 | - return false; |
|
| 1008 | + if ($smcFunc['db_num_rows']($request) != count($boards)) { |
|
| 1009 | + return false; |
|
| 1010 | + } |
|
| 964 | 1011 | |
| 965 | 1012 | $result = true; |
| 966 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 967 | - $result &= !empty($row['add_deny']); |
|
| 1013 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1014 | + $result &= !empty($row['add_deny']); |
|
| 1015 | + } |
|
| 968 | 1016 | $smcFunc['db_free_result']($request); |
| 969 | 1017 | |
| 970 | 1018 | // If the query returned 1, they can do it... otherwise, they can't. |
@@ -1031,9 +1079,10 @@ discard block |
||
| 1031 | 1079 | |
| 1032 | 1080 | // If you're doing something on behalf of some "heavy" permissions, validate your session. |
| 1033 | 1081 | // (take out the heavy permissions, and if you can't do anything but those, you need a validated session.) |
| 1034 | - if (!allowedTo(array_diff($permission, $heavy_permissions), $boards)) |
|
| 1035 | - validateSession(); |
|
| 1036 | -} |
|
| 1082 | + if (!allowedTo(array_diff($permission, $heavy_permissions), $boards)) { |
|
| 1083 | + validateSession(); |
|
| 1084 | + } |
|
| 1085 | + } |
|
| 1037 | 1086 | |
| 1038 | 1087 | /** |
| 1039 | 1088 | * Return the boards a user has a certain (board) permission on. (array(0) if all.) |
@@ -1064,13 +1113,14 @@ discard block |
||
| 1064 | 1113 | // Administrators are all powerful, sorry. |
| 1065 | 1114 | if ($user_info['is_admin']) |
| 1066 | 1115 | { |
| 1067 | - if ($simple) |
|
| 1068 | - return array(0); |
|
| 1069 | - else |
|
| 1116 | + if ($simple) { |
|
| 1117 | + return array(0); |
|
| 1118 | + } else |
|
| 1070 | 1119 | { |
| 1071 | 1120 | $boards = array(); |
| 1072 | - foreach ($permissions as $permission) |
|
| 1073 | - $boards[$permission] = array(0); |
|
| 1121 | + foreach ($permissions as $permission) { |
|
| 1122 | + $boards[$permission] = array(0); |
|
| 1123 | + } |
|
| 1074 | 1124 | |
| 1075 | 1125 | return $boards; |
| 1076 | 1126 | } |
@@ -1102,31 +1152,32 @@ discard block |
||
| 1102 | 1152 | { |
| 1103 | 1153 | if ($simple) |
| 1104 | 1154 | { |
| 1105 | - if (empty($row['add_deny'])) |
|
| 1106 | - $deny_boards[] = $row['id_board']; |
|
| 1107 | - else |
|
| 1108 | - $boards[] = $row['id_board']; |
|
| 1109 | - } |
|
| 1110 | - else |
|
| 1155 | + if (empty($row['add_deny'])) { |
|
| 1156 | + $deny_boards[] = $row['id_board']; |
|
| 1157 | + } else { |
|
| 1158 | + $boards[] = $row['id_board']; |
|
| 1159 | + } |
|
| 1160 | + } else |
|
| 1111 | 1161 | { |
| 1112 | - if (empty($row['add_deny'])) |
|
| 1113 | - $deny_boards[$row['permission']][] = $row['id_board']; |
|
| 1114 | - else |
|
| 1115 | - $boards[$row['permission']][] = $row['id_board']; |
|
| 1162 | + if (empty($row['add_deny'])) { |
|
| 1163 | + $deny_boards[$row['permission']][] = $row['id_board']; |
|
| 1164 | + } else { |
|
| 1165 | + $boards[$row['permission']][] = $row['id_board']; |
|
| 1166 | + } |
|
| 1116 | 1167 | } |
| 1117 | 1168 | } |
| 1118 | 1169 | $smcFunc['db_free_result']($request); |
| 1119 | 1170 | |
| 1120 | - if ($simple) |
|
| 1121 | - $boards = array_unique(array_values(array_diff($boards, $deny_boards))); |
|
| 1122 | - else |
|
| 1171 | + if ($simple) { |
|
| 1172 | + $boards = array_unique(array_values(array_diff($boards, $deny_boards))); |
|
| 1173 | + } else |
|
| 1123 | 1174 | { |
| 1124 | 1175 | foreach ($permissions as $permission) |
| 1125 | 1176 | { |
| 1126 | 1177 | // never had it to start with |
| 1127 | - if (empty($boards[$permission])) |
|
| 1128 | - $boards[$permission] = array(); |
|
| 1129 | - else |
|
| 1178 | + if (empty($boards[$permission])) { |
|
| 1179 | + $boards[$permission] = array(); |
|
| 1180 | + } else |
|
| 1130 | 1181 | { |
| 1131 | 1182 | // Or it may have been removed |
| 1132 | 1183 | $deny_boards[$permission] = isset($deny_boards[$permission]) ? $deny_boards[$permission] : array(); |
@@ -1162,10 +1213,11 @@ discard block |
||
| 1162 | 1213 | |
| 1163 | 1214 | |
| 1164 | 1215 | // Moderators are free... |
| 1165 | - if (!allowedTo('moderate_board')) |
|
| 1166 | - $timeLimit = isset($timeOverrides[$error_type]) ? $timeOverrides[$error_type] : $modSettings['spamWaitTime']; |
|
| 1167 | - else |
|
| 1168 | - $timeLimit = 2; |
|
| 1216 | + if (!allowedTo('moderate_board')) { |
|
| 1217 | + $timeLimit = isset($timeOverrides[$error_type]) ? $timeOverrides[$error_type] : $modSettings['spamWaitTime']; |
|
| 1218 | + } else { |
|
| 1219 | + $timeLimit = 2; |
|
| 1220 | + } |
|
| 1169 | 1221 | |
| 1170 | 1222 | call_integration_hook('integrate_spam_protection', array(&$timeOverrides, &$timeLimit)); |
| 1171 | 1223 | |
@@ -1192,8 +1244,9 @@ discard block |
||
| 1192 | 1244 | if ($smcFunc['db_affected_rows']() != 1) |
| 1193 | 1245 | { |
| 1194 | 1246 | // Spammer! You only have to wait a *few* seconds! |
| 1195 | - if (!$only_return_result) |
|
| 1196 | - fatal_lang_error($error_type . '_WaitTime_broken', false, array($timeLimit)); |
|
| 1247 | + if (!$only_return_result) { |
|
| 1248 | + fatal_lang_error($error_type . '_WaitTime_broken', false, array($timeLimit)); |
|
| 1249 | + } |
|
| 1197 | 1250 | |
| 1198 | 1251 | return true; |
| 1199 | 1252 | } |
@@ -1211,11 +1264,13 @@ discard block |
||
| 1211 | 1264 | */ |
| 1212 | 1265 | function secureDirectory($path, $attachments = false) |
| 1213 | 1266 | { |
| 1214 | - if (empty($path)) |
|
| 1215 | - return 'empty_path'; |
|
| 1267 | + if (empty($path)) { |
|
| 1268 | + return 'empty_path'; |
|
| 1269 | + } |
|
| 1216 | 1270 | |
| 1217 | - if (!is_writable($path)) |
|
| 1218 | - return 'path_not_writable'; |
|
| 1271 | + if (!is_writable($path)) { |
|
| 1272 | + return 'path_not_writable'; |
|
| 1273 | + } |
|
| 1219 | 1274 | |
| 1220 | 1275 | $directoryname = basename($path); |
| 1221 | 1276 | |
@@ -1227,9 +1282,9 @@ discard block |
||
| 1227 | 1282 | |
| 1228 | 1283 | RemoveHandler .php .php3 .phtml .cgi .fcgi .pl .fpl .shtml'; |
| 1229 | 1284 | |
| 1230 | - if (file_exists($path . '/.htaccess')) |
|
| 1231 | - $errors[] = 'htaccess_exists'; |
|
| 1232 | - else |
|
| 1285 | + if (file_exists($path . '/.htaccess')) { |
|
| 1286 | + $errors[] = 'htaccess_exists'; |
|
| 1287 | + } else |
|
| 1233 | 1288 | { |
| 1234 | 1289 | $fh = @fopen($path . '/.htaccess', 'w'); |
| 1235 | 1290 | if ($fh) |
@@ -1242,9 +1297,9 @@ discard block |
||
| 1242 | 1297 | $errors[] = 'htaccess_cannot_create_file'; |
| 1243 | 1298 | } |
| 1244 | 1299 | |
| 1245 | - if (file_exists($path . '/index.php')) |
|
| 1246 | - $errors[] = 'index-php_exists'; |
|
| 1247 | - else |
|
| 1300 | + if (file_exists($path . '/index.php')) { |
|
| 1301 | + $errors[] = 'index-php_exists'; |
|
| 1302 | + } else |
|
| 1248 | 1303 | { |
| 1249 | 1304 | $fh = @fopen($path . '/index.php', 'w'); |
| 1250 | 1305 | if ($fh) |
@@ -1272,11 +1327,12 @@ discard block |
||
| 1272 | 1327 | $errors[] = 'index-php_cannot_create_file'; |
| 1273 | 1328 | } |
| 1274 | 1329 | |
| 1275 | - if (!empty($errors)) |
|
| 1276 | - return $errors; |
|
| 1277 | - else |
|
| 1278 | - return true; |
|
| 1279 | -} |
|
| 1330 | + if (!empty($errors)) { |
|
| 1331 | + return $errors; |
|
| 1332 | + } else { |
|
| 1333 | + return true; |
|
| 1334 | + } |
|
| 1335 | + } |
|
| 1280 | 1336 | |
| 1281 | 1337 | /** |
| 1282 | 1338 | * This sets the X-Frame-Options header. |
@@ -1289,14 +1345,16 @@ discard block |
||
| 1289 | 1345 | global $modSettings; |
| 1290 | 1346 | |
| 1291 | 1347 | $option = 'SAMEORIGIN'; |
| 1292 | - if (is_null($override) && !empty($modSettings['frame_security'])) |
|
| 1293 | - $option = $modSettings['frame_security']; |
|
| 1294 | - elseif (in_array($override, array('SAMEORIGIN', 'DENY'))) |
|
| 1295 | - $option = $override; |
|
| 1348 | + if (is_null($override) && !empty($modSettings['frame_security'])) { |
|
| 1349 | + $option = $modSettings['frame_security']; |
|
| 1350 | + } elseif (in_array($override, array('SAMEORIGIN', 'DENY'))) { |
|
| 1351 | + $option = $override; |
|
| 1352 | + } |
|
| 1296 | 1353 | |
| 1297 | 1354 | // Don't bother setting the header if we have disabled it. |
| 1298 | - if ($option == 'DISABLE') |
|
| 1299 | - return; |
|
| 1355 | + if ($option == 'DISABLE') { |
|
| 1356 | + return; |
|
| 1357 | + } |
|
| 1300 | 1358 | |
| 1301 | 1359 | // Finally set it. |
| 1302 | 1360 | header('x-frame-options: ' . $option); |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 4 |
| 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 | * Handles showing the post screen, loading the post to be modified, and loading any post quoted. |
@@ -35,12 +36,14 @@ discard block |
||
| 35 | 36 | global $sourcedir, $smcFunc, $language; |
| 36 | 37 | |
| 37 | 38 | loadLanguage('Post'); |
| 38 | - if (!empty($modSettings['drafts_post_enabled'])) |
|
| 39 | - loadLanguage('Drafts'); |
|
| 39 | + if (!empty($modSettings['drafts_post_enabled'])) { |
|
| 40 | + loadLanguage('Drafts'); |
|
| 41 | + } |
|
| 40 | 42 | |
| 41 | 43 | // You can't reply with a poll... hacker. |
| 42 | - if (isset($_REQUEST['poll']) && !empty($topic) && !isset($_REQUEST['msg'])) |
|
| 43 | - unset($_REQUEST['poll']); |
|
| 44 | + if (isset($_REQUEST['poll']) && !empty($topic) && !isset($_REQUEST['msg'])) { |
|
| 45 | + unset($_REQUEST['poll']); |
|
| 46 | + } |
|
| 44 | 47 | |
| 45 | 48 | // Posting an event? |
| 46 | 49 | $context['make_event'] = isset($_REQUEST['calendar']); |
@@ -60,12 +63,14 @@ discard block |
||
| 60 | 63 | { |
| 61 | 64 | // Get ids of all the boards they can post in. |
| 62 | 65 | $post_permissions = array('post_new'); |
| 63 | - if ($modSettings['postmod_active']) |
|
| 64 | - $post_permissions[] = 'post_unapproved_topics'; |
|
| 66 | + if ($modSettings['postmod_active']) { |
|
| 67 | + $post_permissions[] = 'post_unapproved_topics'; |
|
| 68 | + } |
|
| 65 | 69 | |
| 66 | 70 | $boards = boardsAllowedTo($post_permissions); |
| 67 | - if (empty($boards)) |
|
| 68 | - fatal_lang_error('cannot_post_new', false); |
|
| 71 | + if (empty($boards)) { |
|
| 72 | + fatal_lang_error('cannot_post_new', false); |
|
| 73 | + } |
|
| 69 | 74 | |
| 70 | 75 | // Get a list of boards for the select menu |
| 71 | 76 | require_once($sourcedir . '/Subs-MessageIndex.php'); |
@@ -78,8 +83,9 @@ discard block |
||
| 78 | 83 | $board_list = getBoardList($boardListOptions); |
| 79 | 84 | } |
| 80 | 85 | // Let's keep things simple for ourselves below |
| 81 | - else |
|
| 82 | - $boards = array($board); |
|
| 86 | + else { |
|
| 87 | + $boards = array($board); |
|
| 88 | + } |
|
| 83 | 89 | |
| 84 | 90 | require_once($sourcedir . '/Subs-Post.php'); |
| 85 | 91 | |
@@ -102,10 +108,11 @@ discard block |
||
| 102 | 108 | array( |
| 103 | 109 | 'msg' => (int) $_REQUEST['msg'], |
| 104 | 110 | )); |
| 105 | - if ($smcFunc['db_num_rows']($request) != 1) |
|
| 106 | - unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']); |
|
| 107 | - else |
|
| 108 | - list ($topic) = $smcFunc['db_fetch_row']($request); |
|
| 111 | + if ($smcFunc['db_num_rows']($request) != 1) { |
|
| 112 | + unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']); |
|
| 113 | + } else { |
|
| 114 | + list ($topic) = $smcFunc['db_fetch_row']($request); |
|
| 115 | + } |
|
| 109 | 116 | $smcFunc['db_free_result']($request); |
| 110 | 117 | } |
| 111 | 118 | |
@@ -132,33 +139,36 @@ discard block |
||
| 132 | 139 | $smcFunc['db_free_result']($request); |
| 133 | 140 | |
| 134 | 141 | // If this topic already has a poll, they sure can't add another. |
| 135 | - if (isset($_REQUEST['poll']) && $pollID > 0) |
|
| 136 | - unset($_REQUEST['poll']); |
|
| 142 | + if (isset($_REQUEST['poll']) && $pollID > 0) { |
|
| 143 | + unset($_REQUEST['poll']); |
|
| 144 | + } |
|
| 137 | 145 | |
| 138 | 146 | if (empty($_REQUEST['msg'])) |
| 139 | 147 | { |
| 140 | - if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any'))) |
|
| 141 | - is_not_guest(); |
|
| 148 | + if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any'))) { |
|
| 149 | + is_not_guest(); |
|
| 150 | + } |
|
| 142 | 151 | |
| 143 | 152 | // By default the reply will be approved... |
| 144 | 153 | $context['becomes_approved'] = true; |
| 145 | 154 | if ($id_member_poster != $user_info['id'] || $user_info['is_guest']) |
| 146 | 155 | { |
| 147 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) |
|
| 148 | - $context['becomes_approved'] = false; |
|
| 149 | - else |
|
| 150 | - isAllowedTo('post_reply_any'); |
|
| 151 | - } |
|
| 152 | - elseif (!allowedTo('post_reply_any')) |
|
| 156 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) { |
|
| 157 | + $context['becomes_approved'] = false; |
|
| 158 | + } else { |
|
| 159 | + isAllowedTo('post_reply_any'); |
|
| 160 | + } |
|
| 161 | + } elseif (!allowedTo('post_reply_any')) |
|
| 153 | 162 | { |
| 154 | - if ($modSettings['postmod_active'] && ((allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) || allowedTo('post_unapproved_replies_any'))) |
|
| 155 | - $context['becomes_approved'] = false; |
|
| 156 | - else |
|
| 157 | - isAllowedTo('post_reply_own'); |
|
| 163 | + if ($modSettings['postmod_active'] && ((allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) || allowedTo('post_unapproved_replies_any'))) { |
|
| 164 | + $context['becomes_approved'] = false; |
|
| 165 | + } else { |
|
| 166 | + isAllowedTo('post_reply_own'); |
|
| 167 | + } |
|
| 158 | 168 | } |
| 169 | + } else { |
|
| 170 | + $context['becomes_approved'] = true; |
|
| 159 | 171 | } |
| 160 | - else |
|
| 161 | - $context['becomes_approved'] = true; |
|
| 162 | 172 | |
| 163 | 173 | $context['can_lock'] = allowedTo('lock_any') || ($user_info['id'] == $id_member_poster && allowedTo('lock_own')); |
| 164 | 174 | $context['can_sticky'] = allowedTo('make_sticky'); |
@@ -173,17 +183,18 @@ discard block |
||
| 173 | 183 | $context['sticky'] = isset($_REQUEST['sticky']) ? !empty($_REQUEST['sticky']) : $sticky; |
| 174 | 184 | |
| 175 | 185 | // Check whether this is a really old post being bumped... |
| 176 | - if (!empty($modSettings['oldTopicDays']) && $lastPostTime + $modSettings['oldTopicDays'] * 86400 < time() && empty($sticky) && !isset($_REQUEST['subject'])) |
|
| 177 | - $post_errors[] = array('old_topic', array($modSettings['oldTopicDays'])); |
|
| 178 | - } |
|
| 179 | - else |
|
| 186 | + if (!empty($modSettings['oldTopicDays']) && $lastPostTime + $modSettings['oldTopicDays'] * 86400 < time() && empty($sticky) && !isset($_REQUEST['subject'])) { |
|
| 187 | + $post_errors[] = array('old_topic', array($modSettings['oldTopicDays'])); |
|
| 188 | + } |
|
| 189 | + } else |
|
| 180 | 190 | { |
| 181 | 191 | // @todo Should use JavaScript to hide and show the warning based on the selection in the board select menu |
| 182 | 192 | $context['becomes_approved'] = true; |
| 183 | - if ($modSettings['postmod_active'] && !allowedTo('post_new', $boards, true) && allowedTo('post_unapproved_topics', $boards, true)) |
|
| 184 | - $context['becomes_approved'] = false; |
|
| 185 | - else |
|
| 186 | - isAllowedTo('post_new', $boards, true); |
|
| 193 | + if ($modSettings['postmod_active'] && !allowedTo('post_new', $boards, true) && allowedTo('post_unapproved_topics', $boards, true)) { |
|
| 194 | + $context['becomes_approved'] = false; |
|
| 195 | + } else { |
|
| 196 | + isAllowedTo('post_new', $boards, true); |
|
| 197 | + } |
|
| 187 | 198 | |
| 188 | 199 | $locked = 0; |
| 189 | 200 | $context['already_locked'] = 0; |
@@ -213,27 +224,32 @@ discard block |
||
| 213 | 224 | if (empty($_REQUEST['message']) && empty($_REQUEST['preview']) && !empty($_SESSION['already_attached'])) |
| 214 | 225 | { |
| 215 | 226 | require_once($sourcedir . '/ManageAttachments.php'); |
| 216 | - foreach ($_SESSION['already_attached'] as $attachID => $attachment) |
|
| 217 | - removeAttachments(array('id_attach' => $attachID)); |
|
| 227 | + foreach ($_SESSION['already_attached'] as $attachID => $attachment) { |
|
| 228 | + removeAttachments(array('id_attach' => $attachID)); |
|
| 229 | + } |
|
| 218 | 230 | |
| 219 | 231 | unset($_SESSION['already_attached']); |
| 220 | 232 | } |
| 221 | 233 | |
| 222 | 234 | // Don't allow a post if it's locked and you aren't all powerful. |
| 223 | - if ($locked && !allowedTo('moderate_board')) |
|
| 224 | - fatal_lang_error('topic_locked', false); |
|
| 235 | + if ($locked && !allowedTo('moderate_board')) { |
|
| 236 | + fatal_lang_error('topic_locked', false); |
|
| 237 | + } |
|
| 225 | 238 | // Check the users permissions - is the user allowed to add or post a poll? |
| 226 | 239 | if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1') |
| 227 | 240 | { |
| 228 | 241 | // New topic, new poll. |
| 229 | - if (empty($topic)) |
|
| 230 | - isAllowedTo('poll_post'); |
|
| 242 | + if (empty($topic)) { |
|
| 243 | + isAllowedTo('poll_post'); |
|
| 244 | + } |
|
| 231 | 245 | // This is an old topic - but it is yours! Can you add to it? |
| 232 | - elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any')) |
|
| 233 | - isAllowedTo('poll_add_own'); |
|
| 246 | + elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any')) { |
|
| 247 | + isAllowedTo('poll_add_own'); |
|
| 248 | + } |
|
| 234 | 249 | // If you're not the owner, can you add to any poll? |
| 235 | - else |
|
| 236 | - isAllowedTo('poll_add_any'); |
|
| 250 | + else { |
|
| 251 | + isAllowedTo('poll_add_any'); |
|
| 252 | + } |
|
| 237 | 253 | |
| 238 | 254 | if (!empty($board)) |
| 239 | 255 | { |
@@ -242,8 +258,9 @@ discard block |
||
| 242 | 258 | $guest_vote_enabled = in_array(-1, $allowedVoteGroups['allowed']); |
| 243 | 259 | } |
| 244 | 260 | // No board, so we'll have to check this again in Post2 |
| 245 | - else |
|
| 246 | - $guest_vote_enabled = true; |
|
| 261 | + else { |
|
| 262 | + $guest_vote_enabled = true; |
|
| 263 | + } |
|
| 247 | 264 | |
| 248 | 265 | // Set up the poll options. |
| 249 | 266 | $context['poll_options'] = array( |
@@ -269,8 +286,9 @@ discard block |
||
| 269 | 286 | if ($context['make_event']) |
| 270 | 287 | { |
| 271 | 288 | // They might want to pick a board. |
| 272 | - if (!isset($context['current_board'])) |
|
| 273 | - $context['current_board'] = 0; |
|
| 289 | + if (!isset($context['current_board'])) { |
|
| 290 | + $context['current_board'] = 0; |
|
| 291 | + } |
|
| 274 | 292 | |
| 275 | 293 | // Start loading up the event info. |
| 276 | 294 | $context['event'] = array(); |
@@ -284,10 +302,11 @@ discard block |
||
| 284 | 302 | isAllowedTo('calendar_post'); |
| 285 | 303 | |
| 286 | 304 | // We want a fairly compact version of the time, but as close as possible to the user's settings. |
| 287 | - if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
| 288 | - $time_string = '%k:%M'; |
|
| 289 | - else |
|
| 290 | - $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
| 305 | + if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
| 306 | + $time_string = '%k:%M'; |
|
| 307 | + } else { |
|
| 308 | + $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
| 309 | + } |
|
| 291 | 310 | |
| 292 | 311 | $js_time_string = str_replace( |
| 293 | 312 | array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
@@ -309,8 +328,7 @@ discard block |
||
| 309 | 328 | require_once($sourcedir . '/Subs-Calendar.php'); |
| 310 | 329 | $eventProperties = getEventProperties($context['event']['id']); |
| 311 | 330 | $context['event'] = array_merge($context['event'], $eventProperties); |
| 312 | - } |
|
| 313 | - else |
|
| 331 | + } else |
|
| 314 | 332 | { |
| 315 | 333 | // Get the current event information. |
| 316 | 334 | require_once($sourcedir . '/Subs-Calendar.php'); |
@@ -318,10 +336,12 @@ discard block |
||
| 318 | 336 | $context['event'] = array_merge($context['event'], $eventProperties); |
| 319 | 337 | |
| 320 | 338 | // Make sure the year and month are in the valid range. |
| 321 | - if ($context['event']['month'] < 1 || $context['event']['month'] > 12) |
|
| 322 | - fatal_lang_error('invalid_month', false); |
|
| 323 | - if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > $modSettings['cal_maxyear']) |
|
| 324 | - fatal_lang_error('invalid_year', false); |
|
| 339 | + if ($context['event']['month'] < 1 || $context['event']['month'] > 12) { |
|
| 340 | + fatal_lang_error('invalid_month', false); |
|
| 341 | + } |
|
| 342 | + if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > $modSettings['cal_maxyear']) { |
|
| 343 | + fatal_lang_error('invalid_year', false); |
|
| 344 | + } |
|
| 325 | 345 | |
| 326 | 346 | $context['event']['categories'] = $board_list; |
| 327 | 347 | } |
@@ -432,10 +452,11 @@ discard block |
||
| 432 | 452 | |
| 433 | 453 | if (!empty($context['new_replies'])) |
| 434 | 454 | { |
| 435 | - if ($context['new_replies'] == 1) |
|
| 436 | - $txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply']; |
|
| 437 | - else |
|
| 438 | - $txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']); |
|
| 455 | + if ($context['new_replies'] == 1) { |
|
| 456 | + $txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply']; |
|
| 457 | + } else { |
|
| 458 | + $txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']); |
|
| 459 | + } |
|
| 439 | 460 | |
| 440 | 461 | $post_errors[] = 'new_replies'; |
| 441 | 462 | |
@@ -447,9 +468,9 @@ discard block |
||
| 447 | 468 | // Get a response prefix (like 'Re:') in the default forum language. |
| 448 | 469 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
| 449 | 470 | { |
| 450 | - if ($language === $user_info['language']) |
|
| 451 | - $context['response_prefix'] = $txt['response_prefix']; |
|
| 452 | - else |
|
| 471 | + if ($language === $user_info['language']) { |
|
| 472 | + $context['response_prefix'] = $txt['response_prefix']; |
|
| 473 | + } else |
|
| 453 | 474 | { |
| 454 | 475 | loadLanguage('index', $language, false); |
| 455 | 476 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -462,23 +483,26 @@ discard block |
||
| 462 | 483 | // Do we have a body, but an error happened. |
| 463 | 484 | if (isset($_REQUEST['message']) || isset($_REQUEST['quickReply']) || !empty($context['post_error'])) |
| 464 | 485 | { |
| 465 | - if (isset($_REQUEST['quickReply'])) |
|
| 466 | - $_REQUEST['message'] = $_REQUEST['quickReply']; |
|
| 486 | + if (isset($_REQUEST['quickReply'])) { |
|
| 487 | + $_REQUEST['message'] = $_REQUEST['quickReply']; |
|
| 488 | + } |
|
| 467 | 489 | |
| 468 | 490 | // Validate inputs. |
| 469 | 491 | if (empty($context['post_error'])) |
| 470 | 492 | { |
| 471 | 493 | // This means they didn't click Post and get an error. |
| 472 | 494 | $really_previewing = true; |
| 473 | - } |
|
| 474 | - else |
|
| 495 | + } else |
|
| 475 | 496 | { |
| 476 | - if (!isset($_REQUEST['subject'])) |
|
| 477 | - $_REQUEST['subject'] = ''; |
|
| 478 | - if (!isset($_REQUEST['message'])) |
|
| 479 | - $_REQUEST['message'] = ''; |
|
| 480 | - if (!isset($_REQUEST['icon'])) |
|
| 481 | - $_REQUEST['icon'] = 'xx'; |
|
| 497 | + if (!isset($_REQUEST['subject'])) { |
|
| 498 | + $_REQUEST['subject'] = ''; |
|
| 499 | + } |
|
| 500 | + if (!isset($_REQUEST['message'])) { |
|
| 501 | + $_REQUEST['message'] = ''; |
|
| 502 | + } |
|
| 503 | + if (!isset($_REQUEST['icon'])) { |
|
| 504 | + $_REQUEST['icon'] = 'xx'; |
|
| 505 | + } |
|
| 482 | 506 | |
| 483 | 507 | // They are previewing if they asked to preview (i.e. came from quick reply). |
| 484 | 508 | $really_previewing = !empty($_POST['preview']); |
@@ -494,8 +518,9 @@ discard block |
||
| 494 | 518 | $form_message = $smcFunc['htmlspecialchars']($_REQUEST['message'], ENT_QUOTES); |
| 495 | 519 | |
| 496 | 520 | // Make sure the subject isn't too long - taking into account special characters. |
| 497 | - if ($smcFunc['strlen']($form_subject) > 100) |
|
| 498 | - $form_subject = $smcFunc['substr']($form_subject, 0, 100); |
|
| 521 | + if ($smcFunc['strlen']($form_subject) > 100) { |
|
| 522 | + $form_subject = $smcFunc['substr']($form_subject, 0, 100); |
|
| 523 | + } |
|
| 499 | 524 | |
| 500 | 525 | if (isset($_REQUEST['poll'])) |
| 501 | 526 | { |
@@ -507,8 +532,9 @@ discard block |
||
| 507 | 532 | $_POST['options'] = empty($_POST['options']) ? array() : htmlspecialchars__recursive($_POST['options']); |
| 508 | 533 | foreach ($_POST['options'] as $option) |
| 509 | 534 | { |
| 510 | - if (trim($option) == '') |
|
| 511 | - continue; |
|
| 535 | + if (trim($option) == '') { |
|
| 536 | + continue; |
|
| 537 | + } |
|
| 512 | 538 | |
| 513 | 539 | $context['choices'][] = array( |
| 514 | 540 | 'id' => $choice_id++, |
@@ -570,13 +596,14 @@ discard block |
||
| 570 | 596 | $context['preview_subject'] = $form_subject; |
| 571 | 597 | |
| 572 | 598 | censorText($context['preview_subject']); |
| 599 | + } else { |
|
| 600 | + $context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>'; |
|
| 573 | 601 | } |
| 574 | - else |
|
| 575 | - $context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>'; |
|
| 576 | 602 | |
| 577 | 603 | // Protect any CDATA blocks. |
| 578 | - if (isset($_REQUEST['xml'])) |
|
| 579 | - $context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]><![CDATA[>')); |
|
| 604 | + if (isset($_REQUEST['xml'])) { |
|
| 605 | + $context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]>< == 0) |
|
| 619 | - fatal_lang_error('no_board', false); |
|
| 645 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 646 | + fatal_lang_error('no_board', false); |
|
| 647 | + } |
|
| 620 | 648 | $row = $smcFunc['db_fetch_assoc']($request); |
| 621 | 649 | |
| 622 | 650 | $attachment_stuff = array($row); |
| 623 | - while ($row2 = $smcFunc['db_fetch_assoc']($request)) |
|
| 624 | - $attachment_stuff[] = $row2; |
|
| 651 | + while ($row2 = $smcFunc['db_fetch_assoc']($request)) { |
|
| 652 | + $attachment_stuff[] = $row2; |
|
| 653 | + } |
|
| 625 | 654 | $smcFunc['db_free_result']($request); |
| 626 | 655 | |
| 627 | 656 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
| 628 | 657 | { |
| 629 | 658 | // Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public. |
| 630 | - if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
| 631 | - fatal_lang_error('modify_post_time_passed', false); |
|
| 632 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) |
|
| 633 | - isAllowedTo('modify_replies'); |
|
| 634 | - else |
|
| 635 | - isAllowedTo('modify_own'); |
|
| 659 | + if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
| 660 | + fatal_lang_error('modify_post_time_passed', false); |
|
| 661 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
| 662 | + isAllowedTo('modify_replies'); |
|
| 663 | + } else { |
|
| 664 | + isAllowedTo('modify_own'); |
|
| 665 | + } |
|
| 666 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
| 667 | + isAllowedTo('modify_replies'); |
|
| 668 | + } else { |
|
| 669 | + isAllowedTo('modify_any'); |
|
| 636 | 670 | } |
| 637 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 638 | - isAllowedTo('modify_replies'); |
|
| 639 | - else |
|
| 640 | - isAllowedTo('modify_any'); |
|
| 641 | 671 | |
| 642 | 672 | if ($context['can_announce'] && !empty($row['id_action'])) |
| 643 | 673 | { |
@@ -661,8 +691,9 @@ discard block |
||
| 661 | 691 | |
| 662 | 692 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 663 | 693 | { |
| 664 | - if ($row['filesize'] <= 0) |
|
| 665 | - continue; |
|
| 694 | + if ($row['filesize'] <= 0) { |
|
| 695 | + continue; |
|
| 696 | + } |
|
| 666 | 697 | $context['current_attachments'][$row['id_attach']] = array( |
| 667 | 698 | 'name' => $smcFunc['htmlspecialchars']($row['filename']), |
| 668 | 699 | 'size' => $row['filesize'], |
@@ -732,29 +763,32 @@ discard block |
||
| 732 | 763 | ) |
| 733 | 764 | ); |
| 734 | 765 | // The message they were trying to edit was most likely deleted. |
| 735 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 736 | - fatal_lang_error('no_message', false); |
|
| 766 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 767 | + fatal_lang_error('no_message', false); |
|
| 768 | + } |
|
| 737 | 769 | $row = $smcFunc['db_fetch_assoc']($request); |
| 738 | 770 | |
| 739 | 771 | $attachment_stuff = array($row); |
| 740 | - while ($row2 = $smcFunc['db_fetch_assoc']($request)) |
|
| 741 | - $attachment_stuff[] = $row2; |
|
| 772 | + while ($row2 = $smcFunc['db_fetch_assoc']($request)) { |
|
| 773 | + $attachment_stuff[] = $row2; |
|
| 774 | + } |
|
| 742 | 775 | $smcFunc['db_free_result']($request); |
| 743 | 776 | |
| 744 | 777 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
| 745 | 778 | { |
| 746 | 779 | // Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public. |
| 747 | - if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
| 748 | - fatal_lang_error('modify_post_time_passed', false); |
|
| 749 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) |
|
| 750 | - isAllowedTo('modify_replies'); |
|
| 751 | - else |
|
| 752 | - isAllowedTo('modify_own'); |
|
| 780 | + if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
| 781 | + fatal_lang_error('modify_post_time_passed', false); |
|
| 782 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
| 783 | + isAllowedTo('modify_replies'); |
|
| 784 | + } else { |
|
| 785 | + isAllowedTo('modify_own'); |
|
| 786 | + } |
|
| 787 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
| 788 | + isAllowedTo('modify_replies'); |
|
| 789 | + } else { |
|
| 790 | + isAllowedTo('modify_any'); |
|
| 753 | 791 | } |
| 754 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 755 | - isAllowedTo('modify_replies'); |
|
| 756 | - else |
|
| 757 | - isAllowedTo('modify_any'); |
|
| 758 | 792 | |
| 759 | 793 | if ($context['can_announce'] && !empty($row['id_action'])) |
| 760 | 794 | { |
@@ -781,15 +815,17 @@ discard block |
||
| 781 | 815 | $context['icon'] = $row['icon']; |
| 782 | 816 | |
| 783 | 817 | // Show an "approve" box if the user can approve it, and the message isn't approved. |
| 784 | - if (!$row['approved'] && !$context['show_approval']) |
|
| 785 | - $context['show_approval'] = allowedTo('approve_posts'); |
|
| 818 | + if (!$row['approved'] && !$context['show_approval']) { |
|
| 819 | + $context['show_approval'] = allowedTo('approve_posts'); |
|
| 820 | + } |
|
| 786 | 821 | |
| 787 | 822 | // Sort the attachments so they are in the order saved |
| 788 | 823 | $temp = array(); |
| 789 | 824 | foreach ($attachment_stuff as $attachment) |
| 790 | 825 | { |
| 791 | - if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable'])) |
|
| 792 | - $temp[$attachment['id_attach']] = $attachment; |
|
| 826 | + if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable'])) { |
|
| 827 | + $temp[$attachment['id_attach']] = $attachment; |
|
| 828 | + } |
|
| 793 | 829 | } |
| 794 | 830 | ksort($temp); |
| 795 | 831 | |
@@ -850,14 +886,16 @@ discard block |
||
| 850 | 886 | 'is_approved' => 1, |
| 851 | 887 | ) |
| 852 | 888 | ); |
| 853 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 854 | - fatal_lang_error('quoted_post_deleted', false); |
|
| 889 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 890 | + fatal_lang_error('quoted_post_deleted', false); |
|
| 891 | + } |
|
| 855 | 892 | list ($form_subject, $mname, $mdate, $form_message) = $smcFunc['db_fetch_row']($request); |
| 856 | 893 | $smcFunc['db_free_result']($request); |
| 857 | 894 | |
| 858 | 895 | // Add 'Re: ' to the front of the quoted subject. |
| 859 | - if (trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) |
|
| 860 | - $form_subject = $context['response_prefix'] . $form_subject; |
|
| 896 | + if (trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
| 897 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
| 898 | + } |
|
| 861 | 899 | |
| 862 | 900 | // Censor the message and subject. |
| 863 | 901 | censorText($form_message); |
@@ -870,10 +908,11 @@ discard block |
||
| 870 | 908 | for ($i = 0, $n = count($parts); $i < $n; $i++) |
| 871 | 909 | { |
| 872 | 910 | // It goes 0 = outside, 1 = begin tag, 2 = inside, 3 = close tag, repeat. |
| 873 | - if ($i % 4 == 0) |
|
| 874 | - $parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) |
|
| 911 | + if ($i % 4 == 0) { |
|
| 912 | + $parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) |
|
| 875 | 913 | { |
| 876 | 914 | return '[html]' . preg_replace('~<br\s?/?' . '>~i', '<br /><br>', "$m[1]") . '[/html]'; |
| 915 | + } |
|
| 877 | 916 | }, $parts[$i]); |
| 878 | 917 | } |
| 879 | 918 | $form_message = implode('', $parts); |
@@ -882,8 +921,9 @@ discard block |
||
| 882 | 921 | $form_message = preg_replace('~<br ?/?' . '>~i', "\n", $form_message); |
| 883 | 922 | |
| 884 | 923 | // Remove any nested quotes, if necessary. |
| 885 | - if (!empty($modSettings['removeNestedQuotes'])) |
|
| 886 | - $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
| 924 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
| 925 | + $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
| 926 | + } |
|
| 887 | 927 | |
| 888 | 928 | // Add a quote string on the front and end. |
| 889 | 929 | $form_message = '[quote author=' . $mname . ' link=msg=' . (int) $_REQUEST['quote'] . ' date=' . $mdate . ']' . "\n" . rtrim($form_message) . "\n" . '[/quote]'; |
@@ -895,15 +935,15 @@ discard block |
||
| 895 | 935 | $form_subject = $first_subject; |
| 896 | 936 | |
| 897 | 937 | // Add 'Re: ' to the front of the subject. |
| 898 | - if (trim($context['response_prefix']) != '' && $form_subject != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) |
|
| 899 | - $form_subject = $context['response_prefix'] . $form_subject; |
|
| 938 | + if (trim($context['response_prefix']) != '' && $form_subject != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
| 939 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
| 940 | + } |
|
| 900 | 941 | |
| 901 | 942 | // Censor the subject. |
| 902 | 943 | censorText($form_subject); |
| 903 | 944 | |
| 904 | 945 | $form_message = ''; |
| 905 | - } |
|
| 906 | - else |
|
| 946 | + } else |
|
| 907 | 947 | { |
| 908 | 948 | $form_subject = isset($_GET['subject']) ? $_GET['subject'] : ''; |
| 909 | 949 | $form_message = ''; |
@@ -922,13 +962,15 @@ discard block |
||
| 922 | 962 | if (isset($_REQUEST['msg'])) |
| 923 | 963 | { |
| 924 | 964 | $context['attachments']['quantity'] = count($context['current_attachments']); |
| 925 | - foreach ($context['current_attachments'] as $attachment) |
|
| 926 | - $context['attachments']['total_size'] += $attachment['size']; |
|
| 965 | + foreach ($context['current_attachments'] as $attachment) { |
|
| 966 | + $context['attachments']['total_size'] += $attachment['size']; |
|
| 967 | + } |
|
| 927 | 968 | } |
| 928 | 969 | |
| 929 | 970 | // A bit of house keeping first. |
| 930 | - if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) |
|
| 931 | - unset($_SESSION['temp_attachments']); |
|
| 971 | + if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) { |
|
| 972 | + unset($_SESSION['temp_attachments']); |
|
| 973 | + } |
|
| 932 | 974 | |
| 933 | 975 | if (!empty($_SESSION['temp_attachments'])) |
| 934 | 976 | { |
@@ -937,9 +979,10 @@ discard block |
||
| 937 | 979 | { |
| 938 | 980 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
| 939 | 981 | { |
| 940 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
| 941 | - if (file_exists($attachment['tmp_name'])) |
|
| 982 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) { |
|
| 983 | + if (file_exists($attachment['tmp_name'])) |
|
| 942 | 984 | unlink($attachment['tmp_name']); |
| 985 | + } |
|
| 943 | 986 | } |
| 944 | 987 | $post_errors[] = 'temp_attachments_gone'; |
| 945 | 988 | $_SESSION['temp_attachments'] = array(); |
@@ -953,8 +996,9 @@ discard block |
||
| 953 | 996 | // See if any files still exist before showing the warning message and the files attached. |
| 954 | 997 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
| 955 | 998 | { |
| 956 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
| 957 | - continue; |
|
| 999 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
| 1000 | + continue; |
|
| 1001 | + } |
|
| 958 | 1002 | |
| 959 | 1003 | if (file_exists($attachment['tmp_name'])) |
| 960 | 1004 | { |
@@ -964,20 +1008,21 @@ discard block |
||
| 964 | 1008 | break; |
| 965 | 1009 | } |
| 966 | 1010 | } |
| 967 | - } |
|
| 968 | - else |
|
| 1011 | + } else |
|
| 969 | 1012 | { |
| 970 | 1013 | // Since, they don't belong here. Let's inform the user that they exist.. |
| 971 | - if (!empty($topic)) |
|
| 972 | - $delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp'; |
|
| 973 | - else |
|
| 974 | - $delete_url = $scripturl . '?action=post' . (!empty($board) ? ';board=' . $board : '') . ';delete_temp'; |
|
| 1014 | + if (!empty($topic)) { |
|
| 1015 | + $delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp'; |
|
| 1016 | + } else { |
|
| 1017 | + $delete_url = $scripturl . '?action=post' . (!empty($board) ? ';board=' . $board : '') . ';delete_temp'; |
|
| 1018 | + } |
|
| 975 | 1019 | |
| 976 | 1020 | // Compile a list of the files to show the user. |
| 977 | 1021 | $file_list = array(); |
| 978 | - foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
| 979 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
| 1022 | + foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) { |
|
| 1023 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
| 980 | 1024 | $file_list[] = $attachment['name']; |
| 1025 | + } |
|
| 981 | 1026 | |
| 982 | 1027 | $_SESSION['temp_attachments']['post']['files'] = $file_list; |
| 983 | 1028 | $file_list = '<div class="attachments">' . implode('<br>', $file_list) . '</div>'; |
@@ -989,8 +1034,7 @@ discard block |
||
| 989 | 1034 | |
| 990 | 1035 | $post_errors[] = array('temp_attachments_found', array($delete_url, $goback_url, $file_list)); |
| 991 | 1036 | $context['ignore_temp_attachments'] = true; |
| 992 | - } |
|
| 993 | - else |
|
| 1037 | + } else |
|
| 994 | 1038 | { |
| 995 | 1039 | $post_errors[] = array('temp_attachments_lost', array($delete_url, $file_list)); |
| 996 | 1040 | $context['ignore_temp_attachments'] = true; |
@@ -998,16 +1042,19 @@ discard block |
||
| 998 | 1042 | } |
| 999 | 1043 | } |
| 1000 | 1044 | |
| 1001 | - if (!empty($context['we_are_history'])) |
|
| 1002 | - $post_errors[] = $context['we_are_history']; |
|
| 1045 | + if (!empty($context['we_are_history'])) { |
|
| 1046 | + $post_errors[] = $context['we_are_history']; |
|
| 1047 | + } |
|
| 1003 | 1048 | |
| 1004 | 1049 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
| 1005 | 1050 | { |
| 1006 | - if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files'])) |
|
| 1007 | - break; |
|
| 1051 | + if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files'])) { |
|
| 1052 | + break; |
|
| 1053 | + } |
|
| 1008 | 1054 | |
| 1009 | - if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
| 1010 | - continue; |
|
| 1055 | + if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
| 1056 | + continue; |
|
| 1057 | + } |
|
| 1011 | 1058 | |
| 1012 | 1059 | if ($attachID == 'initial_error') |
| 1013 | 1060 | { |
@@ -1022,15 +1069,17 @@ discard block |
||
| 1022 | 1069 | { |
| 1023 | 1070 | $txt['error_attach_errors'] = empty($txt['error_attach_errors']) ? '<br>' : ''; |
| 1024 | 1071 | $txt['error_attach_errors'] .= vsprintf($txt['attach_warning'], $attachment['name']) . '<div style="padding: 0 1em;">'; |
| 1025 | - foreach ($attachment['errors'] as $error) |
|
| 1026 | - $txt['error_attach_errors'] .= (is_array($error) ? vsprintf($txt[$error[0]], $error[1]) : $txt[$error]) . '<br >'; |
|
| 1072 | + foreach ($attachment['errors'] as $error) { |
|
| 1073 | + $txt['error_attach_errors'] .= (is_array($error) ? vsprintf($txt[$error[0]], $error[1]) : $txt[$error]) . '<br >'; |
|
| 1074 | + } |
|
| 1027 | 1075 | $txt['error_attach_errors'] .= '</div>'; |
| 1028 | 1076 | $post_errors[] = 'attach_errors'; |
| 1029 | 1077 | |
| 1030 | 1078 | // Take out the trash. |
| 1031 | 1079 | unset($_SESSION['temp_attachments'][$attachID]); |
| 1032 | - if (file_exists($attachment['tmp_name'])) |
|
| 1033 | - unlink($attachment['tmp_name']); |
|
| 1080 | + if (file_exists($attachment['tmp_name'])) { |
|
| 1081 | + unlink($attachment['tmp_name']); |
|
| 1082 | + } |
|
| 1034 | 1083 | continue; |
| 1035 | 1084 | } |
| 1036 | 1085 | |
@@ -1043,8 +1092,9 @@ discard block |
||
| 1043 | 1092 | |
| 1044 | 1093 | $context['attachments']['quantity']++; |
| 1045 | 1094 | $context['attachments']['total_size'] += $attachment['size']; |
| 1046 | - if (!isset($context['files_in_session_warning'])) |
|
| 1047 | - $context['files_in_session_warning'] = $txt['attached_files_in_session']; |
|
| 1095 | + if (!isset($context['files_in_session_warning'])) { |
|
| 1096 | + $context['files_in_session_warning'] = $txt['attached_files_in_session']; |
|
| 1097 | + } |
|
| 1048 | 1098 | |
| 1049 | 1099 | $context['current_attachments'][$attachID] = array( |
| 1050 | 1100 | 'name' => '<u>' . $smcFunc['htmlspecialchars']($attachment['name']) . '</u>', |
@@ -1072,8 +1122,9 @@ discard block |
||
| 1072 | 1122 | } |
| 1073 | 1123 | |
| 1074 | 1124 | // If they came from quick reply, and have to enter verification details, give them some notice. |
| 1075 | - if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification'])) |
|
| 1076 | - $post_errors[] = 'need_qr_verification'; |
|
| 1125 | + if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification'])) { |
|
| 1126 | + $post_errors[] = 'need_qr_verification'; |
|
| 1127 | + } |
|
| 1077 | 1128 | |
| 1078 | 1129 | /* |
| 1079 | 1130 | * There are two error types: serious and minor. Serious errors |
@@ -1090,52 +1141,56 @@ discard block |
||
| 1090 | 1141 | { |
| 1091 | 1142 | loadLanguage('Errors'); |
| 1092 | 1143 | $context['error_type'] = 'minor'; |
| 1093 | - foreach ($post_errors as $post_error) |
|
| 1094 | - if (is_array($post_error)) |
|
| 1144 | + foreach ($post_errors as $post_error) { |
|
| 1145 | + if (is_array($post_error)) |
|
| 1095 | 1146 | { |
| 1096 | 1147 | $post_error_id = $post_error[0]; |
| 1148 | + } |
|
| 1097 | 1149 | $context['post_error'][$post_error_id] = vsprintf($txt['error_' . $post_error_id], $post_error[1]); |
| 1098 | 1150 | |
| 1099 | 1151 | // If it's not a minor error flag it as such. |
| 1100 | - if (!in_array($post_error_id, $minor_errors)) |
|
| 1101 | - $context['error_type'] = 'serious'; |
|
| 1102 | - } |
|
| 1103 | - else |
|
| 1152 | + if (!in_array($post_error_id, $minor_errors)) { |
|
| 1153 | + $context['error_type'] = 'serious'; |
|
| 1154 | + } |
|
| 1155 | + } else |
|
| 1104 | 1156 | { |
| 1105 | 1157 | $context['post_error'][$post_error] = $txt['error_' . $post_error]; |
| 1106 | 1158 | |
| 1107 | 1159 | // If it's not a minor error flag it as such. |
| 1108 | - if (!in_array($post_error, $minor_errors)) |
|
| 1109 | - $context['error_type'] = 'serious'; |
|
| 1160 | + if (!in_array($post_error, $minor_errors)) { |
|
| 1161 | + $context['error_type'] = 'serious'; |
|
| 1162 | + } |
|
| 1110 | 1163 | } |
| 1111 | 1164 | } |
| 1112 | 1165 | |
| 1113 | 1166 | // What are you doing? Posting a poll, modifying, previewing, new post, or reply... |
| 1114 | - if (isset($_REQUEST['poll'])) |
|
| 1115 | - $context['page_title'] = $txt['new_poll']; |
|
| 1116 | - elseif ($context['make_event']) |
|
| 1117 | - $context['page_title'] = $context['event']['id'] == -1 ? $txt['calendar_post_event'] : $txt['calendar_edit']; |
|
| 1118 | - elseif (isset($_REQUEST['msg'])) |
|
| 1119 | - $context['page_title'] = $txt['modify_msg']; |
|
| 1120 | - elseif (isset($_REQUEST['subject'], $context['preview_subject'])) |
|
| 1121 | - $context['page_title'] = $txt['preview'] . ' - ' . strip_tags($context['preview_subject']); |
|
| 1122 | - elseif (empty($topic)) |
|
| 1123 | - $context['page_title'] = $txt['start_new_topic']; |
|
| 1124 | - else |
|
| 1125 | - $context['page_title'] = $txt['post_reply']; |
|
| 1167 | + if (isset($_REQUEST['poll'])) { |
|
| 1168 | + $context['page_title'] = $txt['new_poll']; |
|
| 1169 | + } elseif ($context['make_event']) { |
|
| 1170 | + $context['page_title'] = $context['event']['id'] == -1 ? $txt['calendar_post_event'] : $txt['calendar_edit']; |
|
| 1171 | + } elseif (isset($_REQUEST['msg'])) { |
|
| 1172 | + $context['page_title'] = $txt['modify_msg']; |
|
| 1173 | + } elseif (isset($_REQUEST['subject'], $context['preview_subject'])) { |
|
| 1174 | + $context['page_title'] = $txt['preview'] . ' - ' . strip_tags($context['preview_subject']); |
|
| 1175 | + } elseif (empty($topic)) { |
|
| 1176 | + $context['page_title'] = $txt['start_new_topic']; |
|
| 1177 | + } else { |
|
| 1178 | + $context['page_title'] = $txt['post_reply']; |
|
| 1179 | + } |
|
| 1126 | 1180 | |
| 1127 | 1181 | // Build the link tree. |
| 1128 | - if (empty($topic)) |
|
| 1129 | - $context['linktree'][] = array( |
|
| 1182 | + if (empty($topic)) { |
|
| 1183 | + $context['linktree'][] = array( |
|
| 1130 | 1184 | 'name' => '<em>' . $txt['start_new_topic'] . '</em>' |
| 1131 | 1185 | ); |
| 1132 | - else |
|
| 1133 | - $context['linktree'][] = array( |
|
| 1186 | + } else { |
|
| 1187 | + $context['linktree'][] = array( |
|
| 1134 | 1188 | 'url' => $scripturl . '?topic=' . $topic . '.' . $_REQUEST['start'], |
| 1135 | 1189 | 'name' => $form_subject, |
| 1136 | 1190 | 'extra_before' => '<span><strong class="nav">' . $context['page_title'] . ' (</strong></span>', |
| 1137 | 1191 | 'extra_after' => '<span><strong class="nav">)</strong></span>' |
| 1138 | 1192 | ); |
| 1193 | + } |
|
| 1139 | 1194 | |
| 1140 | 1195 | $context['subject'] = addcslashes($form_subject, '"'); |
| 1141 | 1196 | $context['message'] = str_replace(array('"', '<', '>', ' '), array('"', '<', '>', ' '), $form_message); |
@@ -1179,8 +1234,9 @@ discard block |
||
| 1179 | 1234 | // Message icons - customized icons are off? |
| 1180 | 1235 | $context['icons'] = getMessageIcons(!empty($board) ? $board : 0); |
| 1181 | 1236 | |
| 1182 | - if (!empty($context['icons'])) |
|
| 1183 | - $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
| 1237 | + if (!empty($context['icons'])) { |
|
| 1238 | + $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
| 1239 | + } |
|
| 1184 | 1240 | |
| 1185 | 1241 | // Are we starting a poll? if set the poll icon as selected if its available |
| 1186 | 1242 | if (isset($_REQUEST['poll'])) |
@@ -1200,8 +1256,9 @@ discard block |
||
| 1200 | 1256 | for ($i = 0, $n = count($context['icons']); $i < $n; $i++) |
| 1201 | 1257 | { |
| 1202 | 1258 | $context['icons'][$i]['selected'] = $context['icon'] == $context['icons'][$i]['value']; |
| 1203 | - if ($context['icons'][$i]['selected']) |
|
| 1204 | - $context['icon_url'] = $context['icons'][$i]['url']; |
|
| 1259 | + if ($context['icons'][$i]['selected']) { |
|
| 1260 | + $context['icon_url'] = $context['icons'][$i]['url']; |
|
| 1261 | + } |
|
| 1205 | 1262 | } |
| 1206 | 1263 | if (empty($context['icon_url'])) |
| 1207 | 1264 | { |
@@ -1215,8 +1272,9 @@ discard block |
||
| 1215 | 1272 | )); |
| 1216 | 1273 | } |
| 1217 | 1274 | |
| 1218 | - if (!empty($topic) && !empty($modSettings['topicSummaryPosts'])) |
|
| 1219 | - getTopic(); |
|
| 1275 | + if (!empty($topic) && !empty($modSettings['topicSummaryPosts'])) { |
|
| 1276 | + getTopic(); |
|
| 1277 | + } |
|
| 1220 | 1278 | |
| 1221 | 1279 | // If the user can post attachments prepare the warning labels. |
| 1222 | 1280 | if ($context['can_post_attachment']) |
@@ -1227,12 +1285,13 @@ discard block |
||
| 1227 | 1285 | $context['attachment_restrictions'] = array(); |
| 1228 | 1286 | $context['allowed_extensions'] = strtr(strtolower($modSettings['attachmentExtensions']), array(',' => ', ')); |
| 1229 | 1287 | $attachmentRestrictionTypes = array('attachmentNumPerPostLimit', 'attachmentPostLimit', 'attachmentSizeLimit'); |
| 1230 | - foreach ($attachmentRestrictionTypes as $type) |
|
| 1231 | - if (!empty($modSettings[$type])) |
|
| 1288 | + foreach ($attachmentRestrictionTypes as $type) { |
|
| 1289 | + if (!empty($modSettings[$type])) |
|
| 1232 | 1290 | { |
| 1233 | 1291 | // Show the max number of attachments if not 0. |
| 1234 | 1292 | if ($type == 'attachmentNumPerPostLimit') |
| 1235 | 1293 | $context['attachment_restrictions'][] = sprintf($txt['attach_remaining'], $modSettings['attachmentNumPerPostLimit'] - $context['attachments']['quantity']); |
| 1294 | + } |
|
| 1236 | 1295 | } |
| 1237 | 1296 | } |
| 1238 | 1297 | |
@@ -1266,8 +1325,8 @@ discard block |
||
| 1266 | 1325 | |
| 1267 | 1326 | if (!empty($context['current_attachments'])) |
| 1268 | 1327 | { |
| 1269 | - foreach ($context['current_attachments'] as $key => $mock) |
|
| 1270 | - addInlineJavaScript(' |
|
| 1328 | + foreach ($context['current_attachments'] as $key => $mock) { |
|
| 1329 | + addInlineJavaScript(' |
|
| 1271 | 1330 | current_attachments.push({ |
| 1272 | 1331 | name: '. JavaScriptEscape($mock['name']) . ', |
| 1273 | 1332 | size: '. $mock['size'] . ', |
@@ -1276,6 +1335,7 @@ discard block |
||
| 1276 | 1335 | type: '. JavaScriptEscape(!empty($mock['mime_type']) ? $mock['mime_type'] : '') . ', |
| 1277 | 1336 | thumbID: '. (!empty($mock['thumb']) ? $mock['thumb'] : 0) . ' |
| 1278 | 1337 | });'); |
| 1338 | + } |
|
| 1279 | 1339 | } |
| 1280 | 1340 | |
| 1281 | 1341 | // File Upload. |
@@ -1350,9 +1410,10 @@ discard block |
||
| 1350 | 1410 | $context['posting_fields']['board']['dd'] .= ' |
| 1351 | 1411 | <optgroup label="' . $category['name'] . '">'; |
| 1352 | 1412 | |
| 1353 | - foreach ($category['boards'] as $brd) |
|
| 1354 | - $context['posting_fields']['board']['dd'] .= ' |
|
| 1413 | + foreach ($category['boards'] as $brd) { |
|
| 1414 | + $context['posting_fields']['board']['dd'] .= ' |
|
| 1355 | 1415 | <option value="' . $brd['id'] . '"' . ($brd['selected'] ? ' selected' : '') . '>' . ($brd['child_level'] > 0 ? str_repeat('==', $brd['child_level'] - 1) . '=>' : '') . ' ' . $brd['name'] . '</option>'; |
| 1416 | + } |
|
| 1356 | 1417 | |
| 1357 | 1418 | $context['posting_fields']['board']['dd'] .= ' |
| 1358 | 1419 | </optgroup>'; |
@@ -1383,8 +1444,9 @@ discard block |
||
| 1383 | 1444 | |
| 1384 | 1445 | |
| 1385 | 1446 | // Finally, load the template. |
| 1386 | - if (!isset($_REQUEST['xml'])) |
|
| 1387 | - loadTemplate('Post'); |
|
| 1447 | + if (!isset($_REQUEST['xml'])) { |
|
| 1448 | + loadTemplate('Post'); |
|
| 1449 | + } |
|
| 1388 | 1450 | |
| 1389 | 1451 | call_integration_hook('integrate_post_end'); |
| 1390 | 1452 | } |
@@ -1405,13 +1467,14 @@ discard block |
||
| 1405 | 1467 | // Sneaking off, are we? |
| 1406 | 1468 | if (empty($_POST) && empty($topic)) |
| 1407 | 1469 | { |
| 1408 | - if (empty($_SERVER['CONTENT_LENGTH'])) |
|
| 1409 | - redirectexit('action=post;board=' . $board . '.0'); |
|
| 1410 | - else |
|
| 1411 | - fatal_lang_error('post_upload_error', false); |
|
| 1470 | + if (empty($_SERVER['CONTENT_LENGTH'])) { |
|
| 1471 | + redirectexit('action=post;board=' . $board . '.0'); |
|
| 1472 | + } else { |
|
| 1473 | + fatal_lang_error('post_upload_error', false); |
|
| 1474 | + } |
|
| 1475 | + } elseif (empty($_POST) && !empty($topic)) { |
|
| 1476 | + redirectexit('action=post;topic=' . $topic . '.0'); |
|
| 1412 | 1477 | } |
| 1413 | - elseif (empty($_POST) && !empty($topic)) |
|
| 1414 | - redirectexit('action=post;topic=' . $topic . '.0'); |
|
| 1415 | 1478 | |
| 1416 | 1479 | // No need! |
| 1417 | 1480 | $context['robot_no_index'] = true; |
@@ -1423,8 +1486,9 @@ discard block |
||
| 1423 | 1486 | $post_errors = array(); |
| 1424 | 1487 | |
| 1425 | 1488 | // If the session has timed out, let the user re-submit their form. |
| 1426 | - if (checkSession('post', '', false) != '') |
|
| 1427 | - $post_errors[] = 'session_timeout'; |
|
| 1489 | + if (checkSession('post', '', false) != '') { |
|
| 1490 | + $post_errors[] = 'session_timeout'; |
|
| 1491 | + } |
|
| 1428 | 1492 | |
| 1429 | 1493 | // Wrong verification code? |
| 1430 | 1494 | if (!$user_info['is_admin'] && !$user_info['is_mod'] && !empty($modSettings['posts_require_captcha']) && ($user_info['posts'] < $modSettings['posts_require_captcha'] || ($user_info['is_guest'] && $modSettings['posts_require_captcha'] == -1))) |
@@ -1434,8 +1498,9 @@ discard block |
||
| 1434 | 1498 | 'id' => 'post', |
| 1435 | 1499 | ); |
| 1436 | 1500 | $context['require_verification'] = create_control_verification($verificationOptions, true); |
| 1437 | - if (is_array($context['require_verification'])) |
|
| 1438 | - $post_errors = array_merge($post_errors, $context['require_verification']); |
|
| 1501 | + if (is_array($context['require_verification'])) { |
|
| 1502 | + $post_errors = array_merge($post_errors, $context['require_verification']); |
|
| 1503 | + } |
|
| 1439 | 1504 | } |
| 1440 | 1505 | |
| 1441 | 1506 | require_once($sourcedir . '/Subs-Post.php'); |
@@ -1444,25 +1509,29 @@ discard block |
||
| 1444 | 1509 | call_integration_hook('integrate_post2_start'); |
| 1445 | 1510 | |
| 1446 | 1511 | // Drafts enabled and needed? |
| 1447 | - if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft']))) |
|
| 1448 | - require_once($sourcedir . '/Drafts.php'); |
|
| 1512 | + if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft']))) { |
|
| 1513 | + require_once($sourcedir . '/Drafts.php'); |
|
| 1514 | + } |
|
| 1449 | 1515 | |
| 1450 | 1516 | // First check to see if they are trying to delete any current attachments. |
| 1451 | 1517 | if (isset($_POST['attach_del'])) |
| 1452 | 1518 | { |
| 1453 | 1519 | $keep_temp = array(); |
| 1454 | 1520 | $keep_ids = array(); |
| 1455 | - foreach ($_POST['attach_del'] as $dummy) |
|
| 1456 | - if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false) |
|
| 1521 | + foreach ($_POST['attach_del'] as $dummy) { |
|
| 1522 | + if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false) |
|
| 1457 | 1523 | $keep_temp[] = $dummy; |
| 1458 | - else |
|
| 1459 | - $keep_ids[] = (int) $dummy; |
|
| 1524 | + } |
|
| 1525 | + else { |
|
| 1526 | + $keep_ids[] = (int) $dummy; |
|
| 1527 | + } |
|
| 1460 | 1528 | |
| 1461 | - if (isset($_SESSION['temp_attachments'])) |
|
| 1462 | - foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
| 1529 | + if (isset($_SESSION['temp_attachments'])) { |
|
| 1530 | + foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
| 1463 | 1531 | { |
| 1464 | 1532 | if ((isset($_SESSION['temp_attachments']['post']['files'], $attachment['name']) && in_array($attachment['name'], $_SESSION['temp_attachments']['post']['files'])) || in_array($attachID, $keep_temp) || strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
| 1465 | 1533 | continue; |
| 1534 | + } |
|
| 1466 | 1535 | |
| 1467 | 1536 | unset($_SESSION['temp_attachments'][$attachID]); |
| 1468 | 1537 | unlink($attachment['tmp_name']); |
@@ -1494,8 +1563,9 @@ discard block |
||
| 1494 | 1563 | { |
| 1495 | 1564 | require_once($sourcedir . '/ManageAttachments.php'); |
| 1496 | 1565 | |
| 1497 | - foreach ($_SESSION['already_attached'] as $attachID => $attachment) |
|
| 1498 | - removeAttachments(array('id_attach' => $attachID)); |
|
| 1566 | + foreach ($_SESSION['already_attached'] as $attachID => $attachment) { |
|
| 1567 | + removeAttachments(array('id_attach' => $attachID)); |
|
| 1568 | + } |
|
| 1499 | 1569 | |
| 1500 | 1570 | unset($_SESSION['already_attached']); |
| 1501 | 1571 | |
@@ -1518,12 +1588,14 @@ discard block |
||
| 1518 | 1588 | $smcFunc['db_free_result']($request); |
| 1519 | 1589 | |
| 1520 | 1590 | // Though the topic should be there, it might have vanished. |
| 1521 | - if (!is_array($topic_info)) |
|
| 1522 | - fatal_lang_error('topic_doesnt_exist', 404); |
|
| 1591 | + if (!is_array($topic_info)) { |
|
| 1592 | + fatal_lang_error('topic_doesnt_exist', 404); |
|
| 1593 | + } |
|
| 1523 | 1594 | |
| 1524 | 1595 | // Did this topic suddenly move? Just checking... |
| 1525 | - if ($topic_info['id_board'] != $board) |
|
| 1526 | - fatal_lang_error('not_a_topic'); |
|
| 1596 | + if ($topic_info['id_board'] != $board) { |
|
| 1597 | + fatal_lang_error('not_a_topic'); |
|
| 1598 | + } |
|
| 1527 | 1599 | |
| 1528 | 1600 | // Do the permissions and approval stuff... |
| 1529 | 1601 | $becomesApproved = true; |
@@ -1546,49 +1618,50 @@ discard block |
||
| 1546 | 1618 | if (!empty($topic) && !isset($_REQUEST['msg'])) |
| 1547 | 1619 | { |
| 1548 | 1620 | // Don't allow a post if it's locked. |
| 1549 | - if ($topic_info['locked'] != 0 && !allowedTo('moderate_board')) |
|
| 1550 | - fatal_lang_error('topic_locked', false); |
|
| 1621 | + if ($topic_info['locked'] != 0 && !allowedTo('moderate_board')) { |
|
| 1622 | + fatal_lang_error('topic_locked', false); |
|
| 1623 | + } |
|
| 1551 | 1624 | |
| 1552 | 1625 | // Sorry, multiple polls aren't allowed... yet. You should stop giving me ideas :P. |
| 1553 | - if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0) |
|
| 1554 | - unset($_REQUEST['poll']); |
|
| 1555 | - |
|
| 1556 | - elseif ($topic_info['id_member_started'] != $user_info['id']) |
|
| 1557 | - { |
|
| 1558 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) |
|
| 1559 | - $becomesApproved = false; |
|
| 1560 | - |
|
| 1561 | - else |
|
| 1562 | - isAllowedTo('post_reply_any'); |
|
| 1563 | - } |
|
| 1564 | - elseif (!allowedTo('post_reply_any')) |
|
| 1626 | + if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0) { |
|
| 1627 | + unset($_REQUEST['poll']); |
|
| 1628 | + } elseif ($topic_info['id_member_started'] != $user_info['id']) |
|
| 1629 | + { |
|
| 1630 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) { |
|
| 1631 | + $becomesApproved = false; |
|
| 1632 | + } else { |
|
| 1633 | + isAllowedTo('post_reply_any'); |
|
| 1634 | + } |
|
| 1635 | + } elseif (!allowedTo('post_reply_any')) |
|
| 1565 | 1636 | { |
| 1566 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) |
|
| 1567 | - $becomesApproved = false; |
|
| 1568 | - |
|
| 1569 | - else |
|
| 1570 | - isAllowedTo('post_reply_own'); |
|
| 1637 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) { |
|
| 1638 | + $becomesApproved = false; |
|
| 1639 | + } else { |
|
| 1640 | + isAllowedTo('post_reply_own'); |
|
| 1641 | + } |
|
| 1571 | 1642 | } |
| 1572 | 1643 | |
| 1573 | 1644 | if (isset($_POST['lock'])) |
| 1574 | 1645 | { |
| 1575 | 1646 | // Nothing is changed to the lock. |
| 1576 | - if (empty($topic_info['locked']) == empty($_POST['lock'])) |
|
| 1577 | - unset($_POST['lock']); |
|
| 1647 | + if (empty($topic_info['locked']) == empty($_POST['lock'])) { |
|
| 1648 | + unset($_POST['lock']); |
|
| 1649 | + } |
|
| 1578 | 1650 | |
| 1579 | 1651 | // You're have no permission to lock this topic. |
| 1580 | - elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) |
|
| 1581 | - unset($_POST['lock']); |
|
| 1652 | + elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) { |
|
| 1653 | + unset($_POST['lock']); |
|
| 1654 | + } |
|
| 1582 | 1655 | |
| 1583 | 1656 | // You are allowed to (un)lock your own topic only. |
| 1584 | 1657 | elseif (!allowedTo('lock_any')) |
| 1585 | 1658 | { |
| 1586 | 1659 | // You cannot override a moderator lock. |
| 1587 | - if ($topic_info['locked'] == 1) |
|
| 1588 | - unset($_POST['lock']); |
|
| 1589 | - |
|
| 1590 | - else |
|
| 1591 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 1660 | + if ($topic_info['locked'] == 1) { |
|
| 1661 | + unset($_POST['lock']); |
|
| 1662 | + } else { |
|
| 1663 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 1664 | + } |
|
| 1592 | 1665 | } |
| 1593 | 1666 | // Hail mighty moderator, (un)lock this topic immediately. |
| 1594 | 1667 | else |
@@ -1596,19 +1669,21 @@ discard block |
||
| 1596 | 1669 | $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
| 1597 | 1670 | |
| 1598 | 1671 | // Did someone (un)lock this while you were posting? |
| 1599 | - if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) |
|
| 1600 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
| 1672 | + if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) { |
|
| 1673 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
| 1674 | + } |
|
| 1601 | 1675 | } |
| 1602 | 1676 | } |
| 1603 | 1677 | |
| 1604 | 1678 | // So you wanna (un)sticky this...let's see. |
| 1605 | - if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky'))) |
|
| 1606 | - unset($_POST['sticky']); |
|
| 1607 | - elseif (isset($_POST['sticky'])) |
|
| 1679 | + if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky'))) { |
|
| 1680 | + unset($_POST['sticky']); |
|
| 1681 | + } elseif (isset($_POST['sticky'])) |
|
| 1608 | 1682 | { |
| 1609 | 1683 | // Did someone (un)sticky this while you were posting? |
| 1610 | - if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) |
|
| 1611 | - $post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky'; |
|
| 1684 | + if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) { |
|
| 1685 | + $post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky'; |
|
| 1686 | + } |
|
| 1612 | 1687 | } |
| 1613 | 1688 | |
| 1614 | 1689 | // If drafts are enabled, then pass this off |
@@ -1635,26 +1710,31 @@ discard block |
||
| 1635 | 1710 | |
| 1636 | 1711 | // Do like, the permissions, for safety and stuff... |
| 1637 | 1712 | $becomesApproved = true; |
| 1638 | - if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) |
|
| 1639 | - $becomesApproved = false; |
|
| 1640 | - else |
|
| 1641 | - isAllowedTo('post_new'); |
|
| 1713 | + if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) { |
|
| 1714 | + $becomesApproved = false; |
|
| 1715 | + } else { |
|
| 1716 | + isAllowedTo('post_new'); |
|
| 1717 | + } |
|
| 1642 | 1718 | |
| 1643 | 1719 | if (isset($_POST['lock'])) |
| 1644 | 1720 | { |
| 1645 | 1721 | // New topics are by default not locked. |
| 1646 | - if (empty($_POST['lock'])) |
|
| 1647 | - unset($_POST['lock']); |
|
| 1722 | + if (empty($_POST['lock'])) { |
|
| 1723 | + unset($_POST['lock']); |
|
| 1724 | + } |
|
| 1648 | 1725 | // Besides, you need permission. |
| 1649 | - elseif (!allowedTo(array('lock_any', 'lock_own'))) |
|
| 1650 | - unset($_POST['lock']); |
|
| 1726 | + elseif (!allowedTo(array('lock_any', 'lock_own'))) { |
|
| 1727 | + unset($_POST['lock']); |
|
| 1728 | + } |
|
| 1651 | 1729 | // A moderator-lock (1) can override a user-lock (2). |
| 1652 | - else |
|
| 1653 | - $_POST['lock'] = allowedTo('lock_any') ? 1 : 2; |
|
| 1730 | + else { |
|
| 1731 | + $_POST['lock'] = allowedTo('lock_any') ? 1 : 2; |
|
| 1732 | + } |
|
| 1654 | 1733 | } |
| 1655 | 1734 | |
| 1656 | - if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky'))) |
|
| 1657 | - unset($_POST['sticky']); |
|
| 1735 | + if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky'))) { |
|
| 1736 | + unset($_POST['sticky']); |
|
| 1737 | + } |
|
| 1658 | 1738 | |
| 1659 | 1739 | // Saving your new topic as a draft first? |
| 1660 | 1740 | if (!empty($modSettings['drafts_post_enabled']) && isset($_POST['save_draft'])) |
@@ -1679,31 +1759,37 @@ discard block |
||
| 1679 | 1759 | 'id_msg' => $_REQUEST['msg'], |
| 1680 | 1760 | ) |
| 1681 | 1761 | ); |
| 1682 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1683 | - fatal_lang_error('cant_find_messages', false); |
|
| 1762 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1763 | + fatal_lang_error('cant_find_messages', false); |
|
| 1764 | + } |
|
| 1684 | 1765 | $row = $smcFunc['db_fetch_assoc']($request); |
| 1685 | 1766 | $smcFunc['db_free_result']($request); |
| 1686 | 1767 | |
| 1687 | - if (!empty($topic_info['locked']) && !allowedTo('moderate_board')) |
|
| 1688 | - fatal_lang_error('topic_locked', false); |
|
| 1768 | + if (!empty($topic_info['locked']) && !allowedTo('moderate_board')) { |
|
| 1769 | + fatal_lang_error('topic_locked', false); |
|
| 1770 | + } |
|
| 1689 | 1771 | |
| 1690 | 1772 | if (isset($_POST['lock'])) |
| 1691 | 1773 | { |
| 1692 | 1774 | // Nothing changes to the lock status. |
| 1693 | - if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) |
|
| 1694 | - unset($_POST['lock']); |
|
| 1775 | + if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) { |
|
| 1776 | + unset($_POST['lock']); |
|
| 1777 | + } |
|
| 1695 | 1778 | // You're simply not allowed to (un)lock this. |
| 1696 | - elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) |
|
| 1697 | - unset($_POST['lock']); |
|
| 1779 | + elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) { |
|
| 1780 | + unset($_POST['lock']); |
|
| 1781 | + } |
|
| 1698 | 1782 | // You're only allowed to lock your own topics. |
| 1699 | 1783 | elseif (!allowedTo('lock_any')) |
| 1700 | 1784 | { |
| 1701 | 1785 | // You're not allowed to break a moderator's lock. |
| 1702 | - if ($topic_info['locked'] == 1) |
|
| 1703 | - unset($_POST['lock']); |
|
| 1786 | + if ($topic_info['locked'] == 1) { |
|
| 1787 | + unset($_POST['lock']); |
|
| 1788 | + } |
|
| 1704 | 1789 | // Lock it with a soft lock or unlock it. |
| 1705 | - else |
|
| 1706 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 1790 | + else { |
|
| 1791 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 1792 | + } |
|
| 1707 | 1793 | } |
| 1708 | 1794 | // You must be the moderator. |
| 1709 | 1795 | else |
@@ -1711,44 +1797,46 @@ discard block |
||
| 1711 | 1797 | $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
| 1712 | 1798 | |
| 1713 | 1799 | // Did someone (un)lock this while you were posting? |
| 1714 | - if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) |
|
| 1715 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
| 1800 | + if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) { |
|
| 1801 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
| 1802 | + } |
|
| 1716 | 1803 | } |
| 1717 | 1804 | } |
| 1718 | 1805 | |
| 1719 | 1806 | // Change the sticky status of this topic? |
| 1720 | - if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky'])) |
|
| 1721 | - unset($_POST['sticky']); |
|
| 1722 | - elseif (isset($_POST['sticky'])) |
|
| 1807 | + if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky'])) { |
|
| 1808 | + unset($_POST['sticky']); |
|
| 1809 | + } elseif (isset($_POST['sticky'])) |
|
| 1723 | 1810 | { |
| 1724 | 1811 | // Did someone (un)sticky this while you were posting? |
| 1725 | - if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) |
|
| 1726 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied'; |
|
| 1812 | + if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) { |
|
| 1813 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied'; |
|
| 1814 | + } |
|
| 1727 | 1815 | } |
| 1728 | 1816 | |
| 1729 | 1817 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
| 1730 | 1818 | { |
| 1731 | - if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
| 1732 | - fatal_lang_error('modify_post_time_passed', false); |
|
| 1733 | - elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) |
|
| 1734 | - isAllowedTo('modify_replies'); |
|
| 1735 | - else |
|
| 1736 | - isAllowedTo('modify_own'); |
|
| 1737 | - } |
|
| 1738 | - elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 1819 | + if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
| 1820 | + fatal_lang_error('modify_post_time_passed', false); |
|
| 1821 | + } elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
| 1822 | + isAllowedTo('modify_replies'); |
|
| 1823 | + } else { |
|
| 1824 | + isAllowedTo('modify_own'); |
|
| 1825 | + } |
|
| 1826 | + } elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 1739 | 1827 | { |
| 1740 | 1828 | isAllowedTo('modify_replies'); |
| 1741 | 1829 | |
| 1742 | 1830 | // If you're modifying a reply, I say it better be logged... |
| 1743 | 1831 | $moderationAction = true; |
| 1744 | - } |
|
| 1745 | - else |
|
| 1832 | + } else |
|
| 1746 | 1833 | { |
| 1747 | 1834 | isAllowedTo('modify_any'); |
| 1748 | 1835 | |
| 1749 | 1836 | // Log it, assuming you're not modifying your own post. |
| 1750 | - if ($row['id_member'] != $user_info['id']) |
|
| 1751 | - $moderationAction = true; |
|
| 1837 | + if ($row['id_member'] != $user_info['id']) { |
|
| 1838 | + $moderationAction = true; |
|
| 1839 | + } |
|
| 1752 | 1840 | } |
| 1753 | 1841 | |
| 1754 | 1842 | // If drafts are enabled, then lets send this off to save |
@@ -1775,8 +1863,9 @@ discard block |
||
| 1775 | 1863 | // Update search api |
| 1776 | 1864 | require_once($sourcedir . '/Search.php'); |
| 1777 | 1865 | $searchAPI = findSearchAPI(); |
| 1778 | - if ($searchAPI->supportsMethod('postRemoved')) |
|
| 1779 | - $searchAPI->postRemoved($_REQUEST['msg']); |
|
| 1866 | + if ($searchAPI->supportsMethod('postRemoved')) { |
|
| 1867 | + $searchAPI->postRemoved($_REQUEST['msg']); |
|
| 1868 | + } |
|
| 1780 | 1869 | |
| 1781 | 1870 | } |
| 1782 | 1871 | |
@@ -1794,20 +1883,24 @@ discard block |
||
| 1794 | 1883 | $_POST['guestname'] = !isset($_POST['guestname']) ? '' : trim($_POST['guestname']); |
| 1795 | 1884 | $_POST['email'] = !isset($_POST['email']) ? '' : trim($_POST['email']); |
| 1796 | 1885 | |
| 1797 | - if ($_POST['guestname'] == '' || $_POST['guestname'] == '_') |
|
| 1798 | - $post_errors[] = 'no_name'; |
|
| 1799 | - if ($smcFunc['strlen']($_POST['guestname']) > 25) |
|
| 1800 | - $post_errors[] = 'long_name'; |
|
| 1886 | + if ($_POST['guestname'] == '' || $_POST['guestname'] == '_') { |
|
| 1887 | + $post_errors[] = 'no_name'; |
|
| 1888 | + } |
|
| 1889 | + if ($smcFunc['strlen']($_POST['guestname']) > 25) { |
|
| 1890 | + $post_errors[] = 'long_name'; |
|
| 1891 | + } |
|
| 1801 | 1892 | |
| 1802 | 1893 | if (empty($modSettings['guest_post_no_email'])) |
| 1803 | 1894 | { |
| 1804 | 1895 | // Only check if they changed it! |
| 1805 | 1896 | if (!isset($row) || $row['poster_email'] != $_POST['email']) |
| 1806 | 1897 | { |
| 1807 | - if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == '')) |
|
| 1808 | - $post_errors[] = 'no_email'; |
|
| 1809 | - if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) |
|
| 1810 | - $post_errors[] = 'bad_email'; |
|
| 1898 | + if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == '')) { |
|
| 1899 | + $post_errors[] = 'no_email'; |
|
| 1900 | + } |
|
| 1901 | + if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { |
|
| 1902 | + $post_errors[] = 'bad_email'; |
|
| 1903 | + } |
|
| 1811 | 1904 | } |
| 1812 | 1905 | |
| 1813 | 1906 | // Now make sure this email address is not banned from posting. |
@@ -1823,76 +1916,90 @@ discard block |
||
| 1823 | 1916 | } |
| 1824 | 1917 | |
| 1825 | 1918 | // Coming from the quickReply? |
| 1826 | - if (isset($_POST['quickReply'])) |
|
| 1827 | - $_POST['message'] = $_POST['quickReply']; |
|
| 1919 | + if (isset($_POST['quickReply'])) { |
|
| 1920 | + $_POST['message'] = $_POST['quickReply']; |
|
| 1921 | + } |
|
| 1828 | 1922 | |
| 1829 | 1923 | // Check the subject and message. |
| 1830 | - if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '') |
|
| 1831 | - $post_errors[] = 'no_subject'; |
|
| 1832 | - if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '') |
|
| 1833 | - $post_errors[] = 'no_message'; |
|
| 1834 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
| 1835 | - $post_errors[] = array('long_message', array($modSettings['max_messageLength'])); |
|
| 1836 | - else |
|
| 1924 | + if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '') { |
|
| 1925 | + $post_errors[] = 'no_subject'; |
|
| 1926 | + } |
|
| 1927 | + if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '') { |
|
| 1928 | + $post_errors[] = 'no_message'; |
|
| 1929 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) { |
|
| 1930 | + $post_errors[] = array('long_message', array($modSettings['max_messageLength'])); |
|
| 1931 | + } else |
|
| 1837 | 1932 | { |
| 1838 | 1933 | // Prepare the message a bit for some additional testing. |
| 1839 | 1934 | $_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES); |
| 1840 | 1935 | |
| 1841 | 1936 | // Preparse code. (Zef) |
| 1842 | - if ($user_info['is_guest']) |
|
| 1843 | - $user_info['name'] = $_POST['guestname']; |
|
| 1937 | + if ($user_info['is_guest']) { |
|
| 1938 | + $user_info['name'] = $_POST['guestname']; |
|
| 1939 | + } |
|
| 1844 | 1940 | preparsecode($_POST['message']); |
| 1845 | 1941 | |
| 1846 | 1942 | // Let's see if there's still some content left without the tags. |
| 1847 | - if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false)) |
|
| 1848 | - $post_errors[] = 'no_message'; |
|
| 1943 | + if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false)) { |
|
| 1944 | + $post_errors[] = 'no_message'; |
|
| 1945 | + } |
|
| 1849 | 1946 | |
| 1850 | 1947 | } |
| 1851 | - if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '') |
|
| 1852 | - $post_errors[] = 'no_event'; |
|
| 1948 | + if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '') { |
|
| 1949 | + $post_errors[] = 'no_event'; |
|
| 1950 | + } |
|
| 1853 | 1951 | // You are not! |
| 1854 | - if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin']) |
|
| 1855 | - fatal_error('Knave! Masquerader! Charlatan!', false); |
|
| 1952 | + if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin']) { |
|
| 1953 | + fatal_error('Knave! Masquerader! Charlatan!', false); |
|
| 1954 | + } |
|
| 1856 | 1955 | |
| 1857 | 1956 | // Validate the poll... |
| 1858 | 1957 | if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1') |
| 1859 | 1958 | { |
| 1860 | - if (!empty($topic) && !isset($_REQUEST['msg'])) |
|
| 1861 | - fatal_lang_error('no_access', false); |
|
| 1959 | + if (!empty($topic) && !isset($_REQUEST['msg'])) { |
|
| 1960 | + fatal_lang_error('no_access', false); |
|
| 1961 | + } |
|
| 1862 | 1962 | |
| 1863 | 1963 | // This is a new topic... so it's a new poll. |
| 1864 | - if (empty($topic)) |
|
| 1865 | - isAllowedTo('poll_post'); |
|
| 1964 | + if (empty($topic)) { |
|
| 1965 | + isAllowedTo('poll_post'); |
|
| 1966 | + } |
|
| 1866 | 1967 | // Can you add to your own topics? |
| 1867 | - elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any')) |
|
| 1868 | - isAllowedTo('poll_add_own'); |
|
| 1968 | + elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any')) { |
|
| 1969 | + isAllowedTo('poll_add_own'); |
|
| 1970 | + } |
|
| 1869 | 1971 | // Can you add polls to any topic, then? |
| 1870 | - else |
|
| 1871 | - isAllowedTo('poll_add_any'); |
|
| 1972 | + else { |
|
| 1973 | + isAllowedTo('poll_add_any'); |
|
| 1974 | + } |
|
| 1872 | 1975 | |
| 1873 | - if (!isset($_POST['question']) || trim($_POST['question']) == '') |
|
| 1874 | - $post_errors[] = 'no_question'; |
|
| 1976 | + if (!isset($_POST['question']) || trim($_POST['question']) == '') { |
|
| 1977 | + $post_errors[] = 'no_question'; |
|
| 1978 | + } |
|
| 1875 | 1979 | |
| 1876 | 1980 | $_POST['options'] = empty($_POST['options']) ? array() : htmltrim__recursive($_POST['options']); |
| 1877 | 1981 | |
| 1878 | 1982 | // Get rid of empty ones. |
| 1879 | - foreach ($_POST['options'] as $k => $option) |
|
| 1880 | - if ($option == '') |
|
| 1983 | + foreach ($_POST['options'] as $k => $option) { |
|
| 1984 | + if ($option == '') |
|
| 1881 | 1985 | unset($_POST['options'][$k], $_POST['options'][$k]); |
| 1986 | + } |
|
| 1882 | 1987 | |
| 1883 | 1988 | // What are you going to vote between with one choice?!? |
| 1884 | - if (count($_POST['options']) < 2) |
|
| 1885 | - $post_errors[] = 'poll_few'; |
|
| 1886 | - elseif (count($_POST['options']) > 256) |
|
| 1887 | - $post_errors[] = 'poll_many'; |
|
| 1989 | + if (count($_POST['options']) < 2) { |
|
| 1990 | + $post_errors[] = 'poll_few'; |
|
| 1991 | + } elseif (count($_POST['options']) > 256) { |
|
| 1992 | + $post_errors[] = 'poll_many'; |
|
| 1993 | + } |
|
| 1888 | 1994 | } |
| 1889 | 1995 | |
| 1890 | 1996 | if ($posterIsGuest) |
| 1891 | 1997 | { |
| 1892 | 1998 | // If user is a guest, make sure the chosen name isn't taken. |
| 1893 | 1999 | require_once($sourcedir . '/Subs-Members.php'); |
| 1894 | - if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name'])) |
|
| 1895 | - $post_errors[] = 'bad_name'; |
|
| 2000 | + if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name'])) { |
|
| 2001 | + $post_errors[] = 'bad_name'; |
|
| 2002 | + } |
|
| 1896 | 2003 | } |
| 1897 | 2004 | // If the user isn't a guest, get his or her name and email. |
| 1898 | 2005 | elseif (!isset($_REQUEST['msg'])) |
@@ -1923,8 +2030,9 @@ discard block |
||
| 1923 | 2030 | } |
| 1924 | 2031 | |
| 1925 | 2032 | // Make sure the user isn't spamming the board. |
| 1926 | - if (!isset($_REQUEST['msg'])) |
|
| 1927 | - spamProtection('post'); |
|
| 2033 | + if (!isset($_REQUEST['msg'])) { |
|
| 2034 | + spamProtection('post'); |
|
| 2035 | + } |
|
| 1928 | 2036 | |
| 1929 | 2037 | // At about this point, we're posting and that's that. |
| 1930 | 2038 | ignore_user_abort(true); |
@@ -1937,32 +2045,36 @@ discard block |
||
| 1937 | 2045 | $_POST['modify_reason'] = empty($_POST['modify_reason']) ? '' : strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => '')); |
| 1938 | 2046 | |
| 1939 | 2047 | // At this point, we want to make sure the subject isn't too long. |
| 1940 | - if ($smcFunc['strlen']($_POST['subject']) > 100) |
|
| 1941 | - $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
| 2048 | + if ($smcFunc['strlen']($_POST['subject']) > 100) { |
|
| 2049 | + $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
| 2050 | + } |
|
| 1942 | 2051 | |
| 1943 | 2052 | // Same with the "why did you edit this" text. |
| 1944 | - if ($smcFunc['strlen']($_POST['modify_reason']) > 100) |
|
| 1945 | - $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
| 2053 | + if ($smcFunc['strlen']($_POST['modify_reason']) > 100) { |
|
| 2054 | + $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
| 2055 | + } |
|
| 1946 | 2056 | |
| 1947 | 2057 | // Make the poll... |
| 1948 | 2058 | if (isset($_REQUEST['poll'])) |
| 1949 | 2059 | { |
| 1950 | 2060 | // Make sure that the user has not entered a ridiculous number of options.. |
| 1951 | - if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) |
|
| 1952 | - $_POST['poll_max_votes'] = 1; |
|
| 1953 | - elseif ($_POST['poll_max_votes'] > count($_POST['options'])) |
|
| 1954 | - $_POST['poll_max_votes'] = count($_POST['options']); |
|
| 1955 | - else |
|
| 1956 | - $_POST['poll_max_votes'] = (int) $_POST['poll_max_votes']; |
|
| 2061 | + if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) { |
|
| 2062 | + $_POST['poll_max_votes'] = 1; |
|
| 2063 | + } elseif ($_POST['poll_max_votes'] > count($_POST['options'])) { |
|
| 2064 | + $_POST['poll_max_votes'] = count($_POST['options']); |
|
| 2065 | + } else { |
|
| 2066 | + $_POST['poll_max_votes'] = (int) $_POST['poll_max_votes']; |
|
| 2067 | + } |
|
| 1957 | 2068 | |
| 1958 | 2069 | $_POST['poll_expire'] = (int) $_POST['poll_expire']; |
| 1959 | 2070 | $_POST['poll_expire'] = $_POST['poll_expire'] > 9999 ? 9999 : ($_POST['poll_expire'] < 0 ? 0 : $_POST['poll_expire']); |
| 1960 | 2071 | |
| 1961 | 2072 | // Just set it to zero if it's not there.. |
| 1962 | - if (!isset($_POST['poll_hide'])) |
|
| 1963 | - $_POST['poll_hide'] = 0; |
|
| 1964 | - else |
|
| 1965 | - $_POST['poll_hide'] = (int) $_POST['poll_hide']; |
|
| 2073 | + if (!isset($_POST['poll_hide'])) { |
|
| 2074 | + $_POST['poll_hide'] = 0; |
|
| 2075 | + } else { |
|
| 2076 | + $_POST['poll_hide'] = (int) $_POST['poll_hide']; |
|
| 2077 | + } |
|
| 1966 | 2078 | $_POST['poll_change_vote'] = isset($_POST['poll_change_vote']) ? 1 : 0; |
| 1967 | 2079 | |
| 1968 | 2080 | $_POST['poll_guest_vote'] = isset($_POST['poll_guest_vote']) ? 1 : 0; |
@@ -1971,16 +2083,19 @@ discard block |
||
| 1971 | 2083 | { |
| 1972 | 2084 | require_once($sourcedir . '/Subs-Members.php'); |
| 1973 | 2085 | $allowedVoteGroups = groupsAllowedTo('poll_vote', $board); |
| 1974 | - if (!in_array(-1, $allowedVoteGroups['allowed'])) |
|
| 1975 | - $_POST['poll_guest_vote'] = 0; |
|
| 2086 | + if (!in_array(-1, $allowedVoteGroups['allowed'])) { |
|
| 2087 | + $_POST['poll_guest_vote'] = 0; |
|
| 2088 | + } |
|
| 1976 | 2089 | } |
| 1977 | 2090 | |
| 1978 | 2091 | // If the user tries to set the poll too far in advance, don't let them. |
| 1979 | - if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1) |
|
| 1980 | - fatal_lang_error('poll_range_error', false); |
|
| 2092 | + if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1) { |
|
| 2093 | + fatal_lang_error('poll_range_error', false); |
|
| 2094 | + } |
|
| 1981 | 2095 | // Don't allow them to select option 2 for hidden results if it's not time limited. |
| 1982 | - elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) |
|
| 1983 | - $_POST['poll_hide'] = 1; |
|
| 2096 | + elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) { |
|
| 2097 | + $_POST['poll_hide'] = 1; |
|
| 2098 | + } |
|
| 1984 | 2099 | |
| 1985 | 2100 | // Clean up the question and answers. |
| 1986 | 2101 | $_POST['question'] = $smcFunc['htmlspecialchars']($_POST['question']); |
@@ -1994,13 +2109,15 @@ discard block |
||
| 1994 | 2109 | { |
| 1995 | 2110 | $attachIDs = array(); |
| 1996 | 2111 | $attach_errors = array(); |
| 1997 | - if (!empty($context['we_are_history'])) |
|
| 1998 | - $attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>'; |
|
| 2112 | + if (!empty($context['we_are_history'])) { |
|
| 2113 | + $attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>'; |
|
| 2114 | + } |
|
| 1999 | 2115 | |
| 2000 | 2116 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
| 2001 | 2117 | { |
| 2002 | - if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
| 2003 | - continue; |
|
| 2118 | + if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
| 2119 | + continue; |
|
| 2120 | + } |
|
| 2004 | 2121 | |
| 2005 | 2122 | // If there was an initial error just show that message. |
| 2006 | 2123 | if ($attachID == 'initial_error') |
@@ -2029,12 +2146,13 @@ discard block |
||
| 2029 | 2146 | if (createAttachment($attachmentOptions)) |
| 2030 | 2147 | { |
| 2031 | 2148 | $attachIDs[] = $attachmentOptions['id']; |
| 2032 | - if (!empty($attachmentOptions['thumb'])) |
|
| 2033 | - $attachIDs[] = $attachmentOptions['thumb']; |
|
| 2149 | + if (!empty($attachmentOptions['thumb'])) { |
|
| 2150 | + $attachIDs[] = $attachmentOptions['thumb']; |
|
| 2151 | + } |
|
| 2034 | 2152 | } |
| 2153 | + } else { |
|
| 2154 | + $attach_errors[] = '<dt> </dt>'; |
|
| 2035 | 2155 | } |
| 2036 | - else |
|
| 2037 | - $attach_errors[] = '<dt> </dt>'; |
|
| 2038 | 2156 | |
| 2039 | 2157 | if (!empty($attachmentOptions['errors'])) |
| 2040 | 2158 | { |
@@ -2046,14 +2164,16 @@ discard block |
||
| 2046 | 2164 | if (!is_array($error)) |
| 2047 | 2165 | { |
| 2048 | 2166 | $attach_errors[] = '<dd>' . $txt[$error] . '</dd>'; |
| 2049 | - if (in_array($error, $log_these)) |
|
| 2050 | - log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
| 2167 | + if (in_array($error, $log_these)) { |
|
| 2168 | + log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
| 2169 | + } |
|
| 2170 | + } else { |
|
| 2171 | + $attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>'; |
|
| 2051 | 2172 | } |
| 2052 | - else |
|
| 2053 | - $attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>'; |
|
| 2054 | 2173 | } |
| 2055 | - if (file_exists($attachment['tmp_name'])) |
|
| 2056 | - unlink($attachment['tmp_name']); |
|
| 2174 | + if (file_exists($attachment['tmp_name'])) { |
|
| 2175 | + unlink($attachment['tmp_name']); |
|
| 2176 | + } |
|
| 2057 | 2177 | } |
| 2058 | 2178 | } |
| 2059 | 2179 | unset($_SESSION['temp_attachments']); |
@@ -2094,24 +2214,24 @@ discard block |
||
| 2094 | 2214 | ); |
| 2095 | 2215 | |
| 2096 | 2216 | call_integration_hook('integrate_poll_add_edit', array($id_poll, false)); |
| 2217 | + } else { |
|
| 2218 | + $id_poll = 0; |
|
| 2097 | 2219 | } |
| 2098 | - else |
|
| 2099 | - $id_poll = 0; |
|
| 2100 | 2220 | |
| 2101 | 2221 | // Creating a new topic? |
| 2102 | 2222 | $newTopic = empty($_REQUEST['msg']) && empty($topic); |
| 2103 | 2223 | |
| 2104 | 2224 | // Check the icon. |
| 2105 | - if (!isset($_POST['icon'])) |
|
| 2106 | - $_POST['icon'] = 'xx'; |
|
| 2107 | - |
|
| 2108 | - else |
|
| 2225 | + if (!isset($_POST['icon'])) { |
|
| 2226 | + $_POST['icon'] = 'xx'; |
|
| 2227 | + } else |
|
| 2109 | 2228 | { |
| 2110 | 2229 | $_POST['icon'] = $smcFunc['htmlspecialchars']($_POST['icon']); |
| 2111 | 2230 | |
| 2112 | 2231 | // Need to figure it out if this is a valid icon name. |
| 2113 | - if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png'))) |
|
| 2114 | - $_POST['icon'] = 'xx'; |
|
| 2232 | + if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png'))) { |
|
| 2233 | + $_POST['icon'] = 'xx'; |
|
| 2234 | + } |
|
| 2115 | 2235 | } |
| 2116 | 2236 | |
| 2117 | 2237 | // Collect all parameters for the creation or modification of a post. |
@@ -2152,8 +2272,9 @@ discard block |
||
| 2152 | 2272 | } |
| 2153 | 2273 | |
| 2154 | 2274 | // This will save some time... |
| 2155 | - if (empty($approve_has_changed)) |
|
| 2156 | - unset($msgOptions['approved']); |
|
| 2275 | + if (empty($approve_has_changed)) { |
|
| 2276 | + unset($msgOptions['approved']); |
|
| 2277 | + } |
|
| 2157 | 2278 | |
| 2158 | 2279 | modifyPost($msgOptions, $topicOptions, $posterOptions); |
| 2159 | 2280 | } |
@@ -2162,8 +2283,9 @@ discard block |
||
| 2162 | 2283 | { |
| 2163 | 2284 | createPost($msgOptions, $topicOptions, $posterOptions); |
| 2164 | 2285 | |
| 2165 | - if (isset($topicOptions['id'])) |
|
| 2166 | - $topic = $topicOptions['id']; |
|
| 2286 | + if (isset($topicOptions['id'])) { |
|
| 2287 | + $topic = $topicOptions['id']; |
|
| 2288 | + } |
|
| 2167 | 2289 | } |
| 2168 | 2290 | |
| 2169 | 2291 | // Are there attachments already uploaded and waiting to be assigned? |
@@ -2175,8 +2297,9 @@ discard block |
||
| 2175 | 2297 | } |
| 2176 | 2298 | |
| 2177 | 2299 | // If we had a draft for this, its time to remove it since it was just posted |
| 2178 | - if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft'])) |
|
| 2179 | - DeleteDraft($_POST['id_draft']); |
|
| 2300 | + if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft'])) { |
|
| 2301 | + DeleteDraft($_POST['id_draft']); |
|
| 2302 | + } |
|
| 2180 | 2303 | |
| 2181 | 2304 | // Editing or posting an event? |
| 2182 | 2305 | if (isset($_POST['calendar']) && (!isset($_REQUEST['eventid']) || $_REQUEST['eventid'] == -1)) |
@@ -2195,8 +2318,7 @@ discard block |
||
| 2195 | 2318 | 'member' => $user_info['id'], |
| 2196 | 2319 | ); |
| 2197 | 2320 | insertEvent($eventOptions); |
| 2198 | - } |
|
| 2199 | - elseif (isset($_POST['calendar'])) |
|
| 2321 | + } elseif (isset($_POST['calendar'])) |
|
| 2200 | 2322 | { |
| 2201 | 2323 | $_REQUEST['eventid'] = (int) $_REQUEST['eventid']; |
| 2202 | 2324 | |
@@ -2224,14 +2346,15 @@ discard block |
||
| 2224 | 2346 | } |
| 2225 | 2347 | |
| 2226 | 2348 | // Delete it? |
| 2227 | - if (isset($_REQUEST['deleteevent'])) |
|
| 2228 | - $smcFunc['db_query']('', ' |
|
| 2349 | + if (isset($_REQUEST['deleteevent'])) { |
|
| 2350 | + $smcFunc['db_query']('', ' |
|
| 2229 | 2351 | DELETE FROM {db_prefix}calendar |
| 2230 | 2352 | WHERE id_event = {int:id_event}', |
| 2231 | 2353 | array( |
| 2232 | 2354 | 'id_event' => $_REQUEST['eventid'], |
| 2233 | 2355 | ) |
| 2234 | 2356 | ); |
| 2357 | + } |
|
| 2235 | 2358 | // ... or just update it? |
| 2236 | 2359 | else |
| 2237 | 2360 | { |
@@ -2273,9 +2396,8 @@ discard block |
||
| 2273 | 2396 | array($user_info['id'], $topic, 0), |
| 2274 | 2397 | array('id_member', 'id_topic', 'id_board') |
| 2275 | 2398 | ); |
| 2276 | - } |
|
| 2277 | - elseif (!$newTopic) |
|
| 2278 | - $smcFunc['db_query']('', ' |
|
| 2399 | + } elseif (!$newTopic) { |
|
| 2400 | + $smcFunc['db_query']('', ' |
|
| 2279 | 2401 | DELETE FROM {db_prefix}log_notify |
| 2280 | 2402 | WHERE id_member = {int:current_member} |
| 2281 | 2403 | AND id_topic = {int:current_topic}', |
@@ -2284,16 +2406,20 @@ discard block |
||
| 2284 | 2406 | 'current_topic' => $topic, |
| 2285 | 2407 | ) |
| 2286 | 2408 | ); |
| 2409 | + } |
|
| 2287 | 2410 | |
| 2288 | 2411 | // Log an act of moderation - modifying. |
| 2289 | - if (!empty($moderationAction)) |
|
| 2290 | - logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
| 2412 | + if (!empty($moderationAction)) { |
|
| 2413 | + logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
| 2414 | + } |
|
| 2291 | 2415 | |
| 2292 | - if (isset($_POST['lock']) && $_POST['lock'] != 2) |
|
| 2293 | - logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
| 2416 | + if (isset($_POST['lock']) && $_POST['lock'] != 2) { |
|
| 2417 | + logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
| 2418 | + } |
|
| 2294 | 2419 | |
| 2295 | - if (isset($_POST['sticky'])) |
|
| 2296 | - logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
| 2420 | + if (isset($_POST['sticky'])) { |
|
| 2421 | + logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
| 2422 | + } |
|
| 2297 | 2423 | |
| 2298 | 2424 | // Returning to the topic? |
| 2299 | 2425 | if (!empty($_REQUEST['goback'])) |
@@ -2312,26 +2438,31 @@ discard block |
||
| 2312 | 2438 | ); |
| 2313 | 2439 | } |
| 2314 | 2440 | |
| 2315 | - if ($board_info['num_topics'] == 0) |
|
| 2316 | - cache_put_data('board-' . $board, null, 120); |
|
| 2441 | + if ($board_info['num_topics'] == 0) { |
|
| 2442 | + cache_put_data('board-' . $board, null, 120); |
|
| 2443 | + } |
|
| 2317 | 2444 | |
| 2318 | 2445 | call_integration_hook('integrate_post2_end'); |
| 2319 | 2446 | |
| 2320 | - if (!empty($_POST['announce_topic']) && allowedTo('announce_topic')) |
|
| 2321 | - redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2447 | + if (!empty($_POST['announce_topic']) && allowedTo('announce_topic')) { |
|
| 2448 | + redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2449 | + } |
|
| 2322 | 2450 | |
| 2323 | - if (!empty($_POST['move']) && allowedTo('move_any')) |
|
| 2324 | - redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2451 | + if (!empty($_POST['move']) && allowedTo('move_any')) { |
|
| 2452 | + redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2453 | + } |
|
| 2325 | 2454 | |
| 2326 | 2455 | // Return to post if the mod is on. |
| 2327 | - if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback'])) |
|
| 2328 | - redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie')); |
|
| 2329 | - elseif (!empty($_REQUEST['goback'])) |
|
| 2330 | - redirectexit('topic=' . $topic . '.new#new', isBrowser('ie')); |
|
| 2456 | + if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback'])) { |
|
| 2457 | + redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie')); |
|
| 2458 | + } elseif (!empty($_REQUEST['goback'])) { |
|
| 2459 | + redirectexit('topic=' . $topic . '.new#new', isBrowser('ie')); |
|
| 2460 | + } |
|
| 2331 | 2461 | // Dut-dut-duh-duh-DUH-duh-dut-duh-duh! *dances to the Final Fantasy Fanfare...* |
| 2332 | - else |
|
| 2333 | - redirectexit('board=' . $board . '.0'); |
|
| 2334 | -} |
|
| 2462 | + else { |
|
| 2463 | + redirectexit('board=' . $board . '.0'); |
|
| 2464 | + } |
|
| 2465 | + } |
|
| 2335 | 2466 | |
| 2336 | 2467 | /** |
| 2337 | 2468 | * Handle the announce topic function (action=announce). |
@@ -2349,8 +2480,9 @@ discard block |
||
| 2349 | 2480 | |
| 2350 | 2481 | validateSession(); |
| 2351 | 2482 | |
| 2352 | - if (empty($topic)) |
|
| 2353 | - fatal_lang_error('topic_gone', false); |
|
| 2483 | + if (empty($topic)) { |
|
| 2484 | + fatal_lang_error('topic_gone', false); |
|
| 2485 | + } |
|
| 2354 | 2486 | |
| 2355 | 2487 | loadLanguage('Post'); |
| 2356 | 2488 | loadTemplate('Post'); |
@@ -2377,8 +2509,9 @@ discard block |
||
| 2377 | 2509 | global $txt, $context, $topic, $board_info, $smcFunc; |
| 2378 | 2510 | |
| 2379 | 2511 | $groups = array_merge($board_info['groups'], array(1)); |
| 2380 | - foreach ($groups as $id => $group) |
|
| 2381 | - $groups[$id] = (int) $group; |
|
| 2512 | + foreach ($groups as $id => $group) { |
|
| 2513 | + $groups[$id] = (int) $group; |
|
| 2514 | + } |
|
| 2382 | 2515 | |
| 2383 | 2516 | $context['groups'] = array(); |
| 2384 | 2517 | if (in_array(0, $groups)) |
@@ -2421,8 +2554,9 @@ discard block |
||
| 2421 | 2554 | 'group_list' => $groups, |
| 2422 | 2555 | ) |
| 2423 | 2556 | ); |
| 2424 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2425 | - $context['groups'][$row['id_group']]['name'] = $row['group_name']; |
|
| 2557 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2558 | + $context['groups'][$row['id_group']]['name'] = $row['group_name']; |
|
| 2559 | + } |
|
| 2426 | 2560 | $smcFunc['db_free_result']($request); |
| 2427 | 2561 | |
| 2428 | 2562 | // Get the subject of the topic we're about to announce. |
@@ -2464,16 +2598,19 @@ discard block |
||
| 2464 | 2598 | $context['start'] = empty($_REQUEST['start']) ? 0 : (int) $_REQUEST['start']; |
| 2465 | 2599 | $groups = array_merge($board_info['groups'], array(1)); |
| 2466 | 2600 | |
| 2467 | - if (isset($_POST['membergroups'])) |
|
| 2468 | - $_POST['who'] = explode(',', $_POST['membergroups']); |
|
| 2601 | + if (isset($_POST['membergroups'])) { |
|
| 2602 | + $_POST['who'] = explode(',', $_POST['membergroups']); |
|
| 2603 | + } |
|
| 2469 | 2604 | |
| 2470 | 2605 | // Check whether at least one membergroup was selected. |
| 2471 | - if (empty($_POST['who'])) |
|
| 2472 | - fatal_lang_error('no_membergroup_selected'); |
|
| 2606 | + if (empty($_POST['who'])) { |
|
| 2607 | + fatal_lang_error('no_membergroup_selected'); |
|
| 2608 | + } |
|
| 2473 | 2609 | |
| 2474 | 2610 | // Make sure all membergroups are integers and can access the board of the announcement. |
| 2475 | - foreach ($_POST['who'] as $id => $mg) |
|
| 2476 | - $_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0; |
|
| 2611 | + foreach ($_POST['who'] as $id => $mg) { |
|
| 2612 | + $_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0; |
|
| 2613 | + } |
|
| 2477 | 2614 | |
| 2478 | 2615 | // Get the topic subject and censor it. |
| 2479 | 2616 | $request = $smcFunc['db_query']('', ' |
@@ -2519,12 +2656,13 @@ discard block |
||
| 2519 | 2656 | if ($smcFunc['db_num_rows']($request) == 0) |
| 2520 | 2657 | { |
| 2521 | 2658 | logAction('announce_topic', array('topic' => $topic), 'user'); |
| 2522 | - if (!empty($_REQUEST['move']) && allowedTo('move_any')) |
|
| 2523 | - redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2524 | - elseif (!empty($_REQUEST['goback'])) |
|
| 2525 | - redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie')); |
|
| 2526 | - else |
|
| 2527 | - redirectexit('board=' . $board . '.0'); |
|
| 2659 | + if (!empty($_REQUEST['move']) && allowedTo('move_any')) { |
|
| 2660 | + redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2661 | + } elseif (!empty($_REQUEST['goback'])) { |
|
| 2662 | + redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie')); |
|
| 2663 | + } else { |
|
| 2664 | + redirectexit('board=' . $board . '.0'); |
|
| 2665 | + } |
|
| 2528 | 2666 | } |
| 2529 | 2667 | |
| 2530 | 2668 | $announcements = array(); |
@@ -2543,8 +2681,9 @@ discard block |
||
| 2543 | 2681 | foreach ($rows as $row) |
| 2544 | 2682 | { |
| 2545 | 2683 | // Force them to have it? |
| 2546 | - if (empty($prefs[$row['id_member']]['announcements'])) |
|
| 2547 | - continue; |
|
| 2684 | + if (empty($prefs[$row['id_member']]['announcements'])) { |
|
| 2685 | + continue; |
|
| 2686 | + } |
|
| 2548 | 2687 | |
| 2549 | 2688 | $cur_language = empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile']; |
| 2550 | 2689 | |
@@ -2572,8 +2711,9 @@ discard block |
||
| 2572 | 2711 | } |
| 2573 | 2712 | |
| 2574 | 2713 | // For each language send a different mail - low priority... |
| 2575 | - foreach ($announcements as $lang => $mail) |
|
| 2576 | - sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5); |
|
| 2714 | + foreach ($announcements as $lang => $mail) { |
|
| 2715 | + sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5); |
|
| 2716 | + } |
|
| 2577 | 2717 | |
| 2578 | 2718 | $context['percentage_done'] = round(100 * $context['start'] / $modSettings['latestMember'], 1); |
| 2579 | 2719 | |
@@ -2583,9 +2723,10 @@ discard block |
||
| 2583 | 2723 | $context['sub_template'] = 'announcement_send'; |
| 2584 | 2724 | |
| 2585 | 2725 | // Go back to the correct language for the user ;). |
| 2586 | - if (!empty($modSettings['userLanguage'])) |
|
| 2587 | - loadLanguage('Post'); |
|
| 2588 | -} |
|
| 2726 | + if (!empty($modSettings['userLanguage'])) { |
|
| 2727 | + loadLanguage('Post'); |
|
| 2728 | + } |
|
| 2729 | + } |
|
| 2589 | 2730 | |
| 2590 | 2731 | /** |
| 2591 | 2732 | * Get the topic for display purposes. |
@@ -2598,12 +2739,13 @@ discard block |
||
| 2598 | 2739 | { |
| 2599 | 2740 | global $topic, $modSettings, $context, $smcFunc, $counter, $options; |
| 2600 | 2741 | |
| 2601 | - if (isset($_REQUEST['xml'])) |
|
| 2602 | - $limit = ' |
|
| 2742 | + if (isset($_REQUEST['xml'])) { |
|
| 2743 | + $limit = ' |
|
| 2603 | 2744 | LIMIT ' . (empty($context['new_replies']) ? '0' : $context['new_replies']); |
| 2604 | - else |
|
| 2605 | - $limit = empty($modSettings['topicSummaryPosts']) ? '' : ' |
|
| 2745 | + } else { |
|
| 2746 | + $limit = empty($modSettings['topicSummaryPosts']) ? '' : ' |
|
| 2606 | 2747 | LIMIT ' . (int) $modSettings['topicSummaryPosts']; |
| 2748 | + } |
|
| 2607 | 2749 | |
| 2608 | 2750 | // If you're modifying, get only those posts before the current one. (otherwise get all.) |
| 2609 | 2751 | $request = $smcFunc['db_query']('', ' |
@@ -2641,8 +2783,9 @@ discard block |
||
| 2641 | 2783 | 'is_ignored' => !empty($modSettings['enable_buddylist']) && !empty($options['posts_apply_ignore_list']) && in_array($row['id_member'], $context['user']['ignoreusers']), |
| 2642 | 2784 | ); |
| 2643 | 2785 | |
| 2644 | - if (!empty($context['new_replies'])) |
|
| 2645 | - $context['new_replies']--; |
|
| 2786 | + if (!empty($context['new_replies'])) { |
|
| 2787 | + $context['new_replies']--; |
|
| 2788 | + } |
|
| 2646 | 2789 | } |
| 2647 | 2790 | $smcFunc['db_free_result']($request); |
| 2648 | 2791 | } |
@@ -2659,8 +2802,9 @@ discard block |
||
| 2659 | 2802 | global $sourcedir, $smcFunc; |
| 2660 | 2803 | |
| 2661 | 2804 | loadLanguage('Post'); |
| 2662 | - if (!isset($_REQUEST['xml'])) |
|
| 2663 | - loadTemplate('Post'); |
|
| 2805 | + if (!isset($_REQUEST['xml'])) { |
|
| 2806 | + loadTemplate('Post'); |
|
| 2807 | + } |
|
| 2664 | 2808 | |
| 2665 | 2809 | include_once($sourcedir . '/Subs-Post.php'); |
| 2666 | 2810 | |
@@ -2691,8 +2835,9 @@ discard block |
||
| 2691 | 2835 | $smcFunc['db_free_result']($request); |
| 2692 | 2836 | |
| 2693 | 2837 | $context['sub_template'] = 'quotefast'; |
| 2694 | - if (!empty($row)) |
|
| 2695 | - $can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']); |
|
| 2838 | + if (!empty($row)) { |
|
| 2839 | + $can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']); |
|
| 2840 | + } |
|
| 2696 | 2841 | |
| 2697 | 2842 | if (!empty($can_view_post)) |
| 2698 | 2843 | { |
@@ -2725,8 +2870,9 @@ discard block |
||
| 2725 | 2870 | } |
| 2726 | 2871 | |
| 2727 | 2872 | // Remove any nested quotes. |
| 2728 | - if (!empty($modSettings['removeNestedQuotes'])) |
|
| 2729 | - $row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']); |
|
| 2873 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
| 2874 | + $row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']); |
|
| 2875 | + } |
|
| 2730 | 2876 | |
| 2731 | 2877 | $lb = "\n"; |
| 2732 | 2878 | |
@@ -2752,14 +2898,14 @@ discard block |
||
| 2752 | 2898 | 'time' => '', |
| 2753 | 2899 | ), |
| 2754 | 2900 | ); |
| 2755 | - } |
|
| 2756 | - else |
|
| 2757 | - $context['quote'] = array( |
|
| 2901 | + } else { |
|
| 2902 | + $context['quote'] = array( |
|
| 2758 | 2903 | 'xml' => '', |
| 2759 | 2904 | 'mozilla' => '', |
| 2760 | 2905 | 'text' => '', |
| 2761 | 2906 | ); |
| 2762 | -} |
|
| 2907 | + } |
|
| 2908 | + } |
|
| 2763 | 2909 | |
| 2764 | 2910 | /** |
| 2765 | 2911 | * Used to edit the body or subject of a message inline |
@@ -2771,8 +2917,9 @@ discard block |
||
| 2771 | 2917 | global $user_info, $context, $smcFunc, $language, $board_info; |
| 2772 | 2918 | |
| 2773 | 2919 | // We have to have a topic! |
| 2774 | - if (empty($topic)) |
|
| 2775 | - obExit(false); |
|
| 2920 | + if (empty($topic)) { |
|
| 2921 | + obExit(false); |
|
| 2922 | + } |
|
| 2776 | 2923 | |
| 2777 | 2924 | checkSession('get'); |
| 2778 | 2925 | require_once($sourcedir . '/Subs-Post.php'); |
@@ -2798,31 +2945,35 @@ discard block |
||
| 2798 | 2945 | 'guest_id' => 0, |
| 2799 | 2946 | ) |
| 2800 | 2947 | ); |
| 2801 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 2802 | - fatal_lang_error('no_board', false); |
|
| 2948 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 2949 | + fatal_lang_error('no_board', false); |
|
| 2950 | + } |
|
| 2803 | 2951 | $row = $smcFunc['db_fetch_assoc']($request); |
| 2804 | 2952 | $smcFunc['db_free_result']($request); |
| 2805 | 2953 | |
| 2806 | 2954 | // Change either body or subject requires permissions to modify messages. |
| 2807 | 2955 | if (isset($_POST['message']) || isset($_POST['subject']) || isset($_REQUEST['icon'])) |
| 2808 | 2956 | { |
| 2809 | - if (!empty($row['locked'])) |
|
| 2810 | - isAllowedTo('moderate_board'); |
|
| 2957 | + if (!empty($row['locked'])) { |
|
| 2958 | + isAllowedTo('moderate_board'); |
|
| 2959 | + } |
|
| 2811 | 2960 | |
| 2812 | 2961 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
| 2813 | 2962 | { |
| 2814 | - if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
| 2815 | - fatal_lang_error('modify_post_time_passed', false); |
|
| 2816 | - elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) |
|
| 2817 | - isAllowedTo('modify_replies'); |
|
| 2818 | - else |
|
| 2819 | - isAllowedTo('modify_own'); |
|
| 2963 | + if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
| 2964 | + fatal_lang_error('modify_post_time_passed', false); |
|
| 2965 | + } elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
| 2966 | + isAllowedTo('modify_replies'); |
|
| 2967 | + } else { |
|
| 2968 | + isAllowedTo('modify_own'); |
|
| 2969 | + } |
|
| 2820 | 2970 | } |
| 2821 | 2971 | // Otherwise, they're locked out; someone who can modify the replies is needed. |
| 2822 | - elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 2823 | - isAllowedTo('modify_replies'); |
|
| 2824 | - else |
|
| 2825 | - isAllowedTo('modify_any'); |
|
| 2972 | + elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
| 2973 | + isAllowedTo('modify_replies'); |
|
| 2974 | + } else { |
|
| 2975 | + isAllowedTo('modify_any'); |
|
| 2976 | + } |
|
| 2826 | 2977 | |
| 2827 | 2978 | // Only log this action if it wasn't your message. |
| 2828 | 2979 | $moderationAction = $row['id_member'] != $user_info['id']; |
@@ -2834,10 +2985,10 @@ discard block |
||
| 2834 | 2985 | $_POST['subject'] = strtr($smcFunc['htmlspecialchars']($_POST['subject']), array("\r" => '', "\n" => '', "\t" => '')); |
| 2835 | 2986 | |
| 2836 | 2987 | // Maximum number of characters. |
| 2837 | - if ($smcFunc['strlen']($_POST['subject']) > 100) |
|
| 2838 | - $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
| 2839 | - } |
|
| 2840 | - elseif (isset($_POST['subject'])) |
|
| 2988 | + if ($smcFunc['strlen']($_POST['subject']) > 100) { |
|
| 2989 | + $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
| 2990 | + } |
|
| 2991 | + } elseif (isset($_POST['subject'])) |
|
| 2841 | 2992 | { |
| 2842 | 2993 | $post_errors[] = 'no_subject'; |
| 2843 | 2994 | unset($_POST['subject']); |
@@ -2849,13 +3000,11 @@ discard block |
||
| 2849 | 3000 | { |
| 2850 | 3001 | $post_errors[] = 'no_message'; |
| 2851 | 3002 | unset($_POST['message']); |
| 2852 | - } |
|
| 2853 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
| 3003 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
| 2854 | 3004 | { |
| 2855 | 3005 | $post_errors[] = 'long_message'; |
| 2856 | 3006 | unset($_POST['message']); |
| 2857 | - } |
|
| 2858 | - else |
|
| 3007 | + } else |
|
| 2859 | 3008 | { |
| 2860 | 3009 | $_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES); |
| 2861 | 3010 | |
@@ -2871,31 +3020,34 @@ discard block |
||
| 2871 | 3020 | |
| 2872 | 3021 | if (isset($_POST['lock'])) |
| 2873 | 3022 | { |
| 2874 | - if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member'])) |
|
| 2875 | - unset($_POST['lock']); |
|
| 2876 | - elseif (!allowedTo('lock_any')) |
|
| 3023 | + if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member'])) { |
|
| 3024 | + unset($_POST['lock']); |
|
| 3025 | + } elseif (!allowedTo('lock_any')) |
|
| 2877 | 3026 | { |
| 2878 | - if ($row['locked'] == 1) |
|
| 2879 | - unset($_POST['lock']); |
|
| 2880 | - else |
|
| 2881 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 3027 | + if ($row['locked'] == 1) { |
|
| 3028 | + unset($_POST['lock']); |
|
| 3029 | + } else { |
|
| 3030 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 3031 | + } |
|
| 3032 | + } elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked']) { |
|
| 3033 | + unset($_POST['lock']); |
|
| 3034 | + } else { |
|
| 3035 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
|
| 2882 | 3036 | } |
| 2883 | - elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked']) |
|
| 2884 | - unset($_POST['lock']); |
|
| 2885 | - else |
|
| 2886 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
|
| 2887 | 3037 | } |
| 2888 | 3038 | |
| 2889 | - if (isset($_POST['sticky']) && !allowedTo('make_sticky')) |
|
| 2890 | - unset($_POST['sticky']); |
|
| 3039 | + if (isset($_POST['sticky']) && !allowedTo('make_sticky')) { |
|
| 3040 | + unset($_POST['sticky']); |
|
| 3041 | + } |
|
| 2891 | 3042 | |
| 2892 | 3043 | if (isset($_POST['modify_reason'])) |
| 2893 | 3044 | { |
| 2894 | 3045 | $_POST['modify_reason'] = strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => '')); |
| 2895 | 3046 | |
| 2896 | 3047 | // Maximum number of characters. |
| 2897 | - if ($smcFunc['strlen']($_POST['modify_reason']) > 100) |
|
| 2898 | - $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
| 3048 | + if ($smcFunc['strlen']($_POST['modify_reason']) > 100) { |
|
| 3049 | + $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
| 3050 | + } |
|
| 2899 | 3051 | } |
| 2900 | 3052 | |
| 2901 | 3053 | if (empty($post_errors)) |
@@ -2932,8 +3084,9 @@ discard block |
||
| 2932 | 3084 | } |
| 2933 | 3085 | } |
| 2934 | 3086 | // If nothing was changed there's no need to add an entry to the moderation log. |
| 2935 | - else |
|
| 2936 | - $moderationAction = false; |
|
| 3087 | + else { |
|
| 3088 | + $moderationAction = false; |
|
| 3089 | + } |
|
| 2937 | 3090 | |
| 2938 | 3091 | modifyPost($msgOptions, $topicOptions, $posterOptions); |
| 2939 | 3092 | |
@@ -2951,9 +3104,9 @@ discard block |
||
| 2951 | 3104 | // Get the proper (default language) response prefix first. |
| 2952 | 3105 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
| 2953 | 3106 | { |
| 2954 | - if ($language === $user_info['language']) |
|
| 2955 | - $context['response_prefix'] = $txt['response_prefix']; |
|
| 2956 | - else |
|
| 3107 | + if ($language === $user_info['language']) { |
|
| 3108 | + $context['response_prefix'] = $txt['response_prefix']; |
|
| 3109 | + } else |
|
| 2957 | 3110 | { |
| 2958 | 3111 | loadLanguage('index', $language, false); |
| 2959 | 3112 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -2975,8 +3128,9 @@ discard block |
||
| 2975 | 3128 | ); |
| 2976 | 3129 | } |
| 2977 | 3130 | |
| 2978 | - if (!empty($moderationAction)) |
|
| 2979 | - logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
| 3131 | + if (!empty($moderationAction)) { |
|
| 3132 | + logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
| 3133 | + } |
|
| 2980 | 3134 | } |
| 2981 | 3135 | |
| 2982 | 3136 | if (isset($_REQUEST['xml'])) |
@@ -3017,8 +3171,7 @@ discard block |
||
| 3017 | 3171 | ); |
| 3018 | 3172 | |
| 3019 | 3173 | censorText($context['message']['subject']); |
| 3020 | - } |
|
| 3021 | - else |
|
| 3174 | + } else |
|
| 3022 | 3175 | { |
| 3023 | 3176 | $context['message'] = array( |
| 3024 | 3177 | 'id' => $row['id_msg'], |
@@ -3030,15 +3183,16 @@ discard block |
||
| 3030 | 3183 | loadLanguage('Errors'); |
| 3031 | 3184 | foreach ($post_errors as $post_error) |
| 3032 | 3185 | { |
| 3033 | - if ($post_error == 'long_message') |
|
| 3034 | - $context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']); |
|
| 3035 | - else |
|
| 3036 | - $context['message']['errors'][] = $txt['error_' . $post_error]; |
|
| 3186 | + if ($post_error == 'long_message') { |
|
| 3187 | + $context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']); |
|
| 3188 | + } else { |
|
| 3189 | + $context['message']['errors'][] = $txt['error_' . $post_error]; |
|
| 3190 | + } |
|
| 3037 | 3191 | } |
| 3038 | 3192 | } |
| 3193 | + } else { |
|
| 3194 | + obExit(false); |
|
| 3195 | + } |
|
| 3039 | 3196 | } |
| 3040 | - else |
|
| 3041 | - obExit(false); |
|
| 3042 | -} |
|
| 3043 | 3197 | |
| 3044 | 3198 | ?> |
| 3045 | 3199 | \ No newline at end of file |