@@ -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 | * Ask them for their login information. (shows a page for the user to type |
@@ -29,8 +30,9 @@ discard block |
||
| 29 | 30 | global $txt, $context, $scripturl, $user_info; |
| 30 | 31 | |
| 31 | 32 | // You are already logged in, go take a tour of the boards |
| 32 | - if (!empty($user_info['id'])) |
|
| 33 | - redirectexit(); |
|
| 33 | + if (!empty($user_info['id'])) { |
|
| 34 | + redirectexit(); |
|
| 35 | + } |
|
| 34 | 36 | |
| 35 | 37 | // We need to load the Login template/language file. |
| 36 | 38 | loadLanguage('Login'); |
@@ -57,10 +59,11 @@ discard block |
||
| 57 | 59 | ); |
| 58 | 60 | |
| 59 | 61 | // Set the login URL - will be used when the login process is done (but careful not to send us to an attachment). |
| 60 | - if (isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) |
|
| 61 | - $_SESSION['login_url'] = $_SESSION['old_url']; |
|
| 62 | - elseif (isset($_SESSION['login_url']) && strpos($_SESSION['login_url'], 'dlattach') !== false) |
|
| 63 | - unset($_SESSION['login_url']); |
|
| 62 | + if (isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) { |
|
| 63 | + $_SESSION['login_url'] = $_SESSION['old_url']; |
|
| 64 | + } elseif (isset($_SESSION['login_url']) && strpos($_SESSION['login_url'], 'dlattach') !== false) { |
|
| 65 | + unset($_SESSION['login_url']); |
|
| 66 | + } |
|
| 64 | 67 | |
| 65 | 68 | // Create a one time token. |
| 66 | 69 | createToken('login'); |
@@ -83,8 +86,9 @@ discard block |
||
| 83 | 86 | global $cookiename, $modSettings, $context, $sourcedir, $maintenance; |
| 84 | 87 | |
| 85 | 88 | // Check to ensure we're forcing SSL for authentication |
| 86 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
| 87 | - fatal_lang_error('login_ssl_required'); |
|
| 89 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
| 90 | + fatal_lang_error('login_ssl_required'); |
|
| 91 | + } |
|
| 88 | 92 | |
| 89 | 93 | // Load cookie authentication stuff. |
| 90 | 94 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -102,19 +106,20 @@ discard block |
||
| 102 | 106 | list (,, $timeout) = smf_json_decode($_COOKIE[$cookiename], true); |
| 103 | 107 | |
| 104 | 108 | // That didn't work... Maybe it's using serialize? |
| 105 | - if (is_null($timeout)) |
|
| 106 | - list (,, $timeout) = safe_unserialize($_COOKIE[$cookiename]); |
|
| 107 | - } |
|
| 108 | - elseif (isset($_SESSION['login_' . $cookiename])) |
|
| 109 | + if (is_null($timeout)) { |
|
| 110 | + list (,, $timeout) = safe_unserialize($_COOKIE[$cookiename]); |
|
| 111 | + } |
|
| 112 | + } elseif (isset($_SESSION['login_' . $cookiename])) |
|
| 109 | 113 | { |
| 110 | 114 | list (,, $timeout) = smf_json_decode($_SESSION['login_' . $cookiename]); |
| 111 | 115 | |
| 112 | 116 | // Try for old format |
| 113 | - if (is_null($timeout)) |
|
| 114 | - list (,, $timeout) = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
| 117 | + if (is_null($timeout)) { |
|
| 118 | + list (,, $timeout) = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
| 119 | + } |
|
| 120 | + } else { |
|
| 121 | + trigger_error('Login2(): Cannot be logged in without a session or cookie', E_USER_ERROR); |
|
| 115 | 122 | } |
| 116 | - else |
|
| 117 | - trigger_error('Login2(): Cannot be logged in without a session or cookie', E_USER_ERROR); |
|
| 118 | 123 | |
| 119 | 124 | $user_settings['password_salt'] = substr(md5(mt_rand()), 0, 4); |
| 120 | 125 | updateMemberData($user_info['id'], array('password_salt' => $user_settings['password_salt'])); |
@@ -125,16 +130,18 @@ discard block |
||
| 125 | 130 | $tfadata = smf_json_decode($_COOKIE[$cookiename . '_tfa'], true); |
| 126 | 131 | |
| 127 | 132 | // If that didn't work, try unserialize instead... |
| 128 | - if (is_null($tfadata)) |
|
| 129 | - $tfadata = safe_unserialize($_COOKIE[$cookiename . '_tfa']); |
|
| 133 | + if (is_null($tfadata)) { |
|
| 134 | + $tfadata = safe_unserialize($_COOKIE[$cookiename . '_tfa']); |
|
| 135 | + } |
|
| 130 | 136 | |
| 131 | 137 | list ($tfamember, $tfasecret, $exp, $state, $preserve) = $tfadata; |
| 132 | 138 | |
| 133 | 139 | // If we're preserving the cookie, reset it with updated salt |
| 134 | - if ($preserve && time() < $exp) |
|
| 135 | - setTFACookie(3153600, $user_info['password_salt'], hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']), true); |
|
| 136 | - else |
|
| 137 | - setTFACookie(-3600, 0, ''); |
|
| 140 | + if ($preserve && time() < $exp) { |
|
| 141 | + setTFACookie(3153600, $user_info['password_salt'], hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']), true); |
|
| 142 | + } else { |
|
| 143 | + setTFACookie(-3600, 0, ''); |
|
| 144 | + } |
|
| 138 | 145 | } |
| 139 | 146 | |
| 140 | 147 | setLoginCookie($timeout - time(), $user_info['id'], hash_salt($user_settings['passwd'], $user_settings['password_salt'])); |
@@ -145,20 +152,20 @@ discard block |
||
| 145 | 152 | elseif (isset($_GET['sa']) && $_GET['sa'] == 'check') |
| 146 | 153 | { |
| 147 | 154 | // Strike! You're outta there! |
| 148 | - if ($_GET['member'] != $user_info['id']) |
|
| 149 | - fatal_lang_error('login_cookie_error', false); |
|
| 155 | + if ($_GET['member'] != $user_info['id']) { |
|
| 156 | + fatal_lang_error('login_cookie_error', false); |
|
| 157 | + } |
|
| 150 | 158 | |
| 151 | 159 | $user_info['can_mod'] = allowedTo('access_mod_center') || (!$user_info['is_guest'] && ($user_info['mod_cache']['gq'] != '0=1' || $user_info['mod_cache']['bq'] != '0=1' || ($modSettings['postmod_active'] && !empty($user_info['mod_cache']['ap'])))); |
| 152 | 160 | |
| 153 | 161 | // Some whitelisting for login_url... |
| 154 | - if (empty($_SESSION['login_url'])) |
|
| 155 | - redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa'); |
|
| 156 | - elseif (!empty($_SESSION['login_url']) && (strpos($_SESSION['login_url'], 'http://') === false && strpos($_SESSION['login_url'], 'https://') === false)) |
|
| 162 | + if (empty($_SESSION['login_url'])) { |
|
| 163 | + redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa'); |
|
| 164 | + } elseif (!empty($_SESSION['login_url']) && (strpos($_SESSION['login_url'], 'http://') === false && strpos($_SESSION['login_url'], 'https://') === false)) |
|
| 157 | 165 | { |
| 158 | 166 | unset ($_SESSION['login_url']); |
| 159 | 167 | redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa'); |
| 160 | - } |
|
| 161 | - else |
|
| 168 | + } else |
|
| 162 | 169 | { |
| 163 | 170 | // Best not to clutter the session data too much... |
| 164 | 171 | $temp = $_SESSION['login_url']; |
@@ -169,8 +176,9 @@ discard block |
||
| 169 | 176 | } |
| 170 | 177 | |
| 171 | 178 | // Beyond this point you are assumed to be a guest trying to login. |
| 172 | - if (!$user_info['is_guest']) |
|
| 173 | - redirectexit(); |
|
| 179 | + if (!$user_info['is_guest']) { |
|
| 180 | + redirectexit(); |
|
| 181 | + } |
|
| 174 | 182 | |
| 175 | 183 | // Are you guessing with a script? |
| 176 | 184 | checkSession(); |
@@ -178,18 +186,21 @@ discard block |
||
| 178 | 186 | spamProtection('login'); |
| 179 | 187 | |
| 180 | 188 | // Set the login_url if it's not already set (but careful not to send us to an attachment). |
| 181 | - if ((empty($_SESSION['login_url']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) || (isset($_GET['quicklogin']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'login') === false)) |
|
| 182 | - $_SESSION['login_url'] = $_SESSION['old_url']; |
|
| 189 | + if ((empty($_SESSION['login_url']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) || (isset($_GET['quicklogin']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'login') === false)) { |
|
| 190 | + $_SESSION['login_url'] = $_SESSION['old_url']; |
|
| 191 | + } |
|
| 183 | 192 | |
| 184 | 193 | // Been guessing a lot, haven't we? |
| 185 | - if (isset($_SESSION['failed_login']) && $_SESSION['failed_login'] >= $modSettings['failed_login_threshold'] * 3) |
|
| 186 | - fatal_lang_error('login_threshold_fail', 'critical'); |
|
| 194 | + if (isset($_SESSION['failed_login']) && $_SESSION['failed_login'] >= $modSettings['failed_login_threshold'] * 3) { |
|
| 195 | + fatal_lang_error('login_threshold_fail', 'critical'); |
|
| 196 | + } |
|
| 187 | 197 | |
| 188 | 198 | // Set up the cookie length. (if it's invalid, just fall through and use the default.) |
| 189 | - if (isset($_POST['cookieneverexp']) || (!empty($_POST['cookielength']) && $_POST['cookielength'] == -1)) |
|
| 190 | - $modSettings['cookieTime'] = 3153600; |
|
| 191 | - elseif (!empty($_POST['cookielength']) && ($_POST['cookielength'] >= 1 && $_POST['cookielength'] <= 525600)) |
|
| 192 | - $modSettings['cookieTime'] = (int) $_POST['cookielength']; |
|
| 199 | + if (isset($_POST['cookieneverexp']) || (!empty($_POST['cookielength']) && $_POST['cookielength'] == -1)) { |
|
| 200 | + $modSettings['cookieTime'] = 3153600; |
|
| 201 | + } elseif (!empty($_POST['cookielength']) && ($_POST['cookielength'] >= 1 && $_POST['cookielength'] <= 525600)) { |
|
| 202 | + $modSettings['cookieTime'] = (int) $_POST['cookielength']; |
|
| 203 | + } |
|
| 193 | 204 | |
| 194 | 205 | loadLanguage('Login'); |
| 195 | 206 | // Load the template stuff. |
@@ -309,8 +320,9 @@ discard block |
||
| 309 | 320 | $other_passwords[] = crypt(md5($_POST['passwrd']), md5($_POST['passwrd'])); |
| 310 | 321 | |
| 311 | 322 | // Snitz style - SHA-256. Technically, this is a downgrade, but most PHP configurations don't support sha256 anyway. |
| 312 | - if (strlen($user_settings['passwd']) == 64 && function_exists('mhash') && defined('MHASH_SHA256')) |
|
| 313 | - $other_passwords[] = bin2hex(mhash(MHASH_SHA256, $_POST['passwrd'])); |
|
| 323 | + if (strlen($user_settings['passwd']) == 64 && function_exists('mhash') && defined('MHASH_SHA256')) { |
|
| 324 | + $other_passwords[] = bin2hex(mhash(MHASH_SHA256, $_POST['passwrd'])); |
|
| 325 | + } |
|
| 314 | 326 | |
| 315 | 327 | // phpBB3 users new hashing. We now support it as well ;). |
| 316 | 328 | $other_passwords[] = phpBB3_password_check($_POST['passwrd'], $user_settings['passwd']); |
@@ -330,27 +342,29 @@ discard block |
||
| 330 | 342 | // Some common md5 ones. |
| 331 | 343 | $other_passwords[] = md5($user_settings['password_salt'] . $_POST['passwrd']); |
| 332 | 344 | $other_passwords[] = md5($_POST['passwrd'] . $user_settings['password_salt']); |
| 333 | - } |
|
| 334 | - elseif (strlen($user_settings['passwd']) == 40) |
|
| 345 | + } elseif (strlen($user_settings['passwd']) == 40) |
|
| 335 | 346 | { |
| 336 | 347 | // Maybe they are using a hash from before the password fix. |
| 337 | 348 | // This is also valid for SMF 1.1 to 2.0 style of hashing, changed to bcrypt in SMF 2.1 |
| 338 | 349 | $other_passwords[] = sha1(strtolower($user_settings['member_name']) . un_htmlspecialchars($_POST['passwrd'])); |
| 339 | 350 | |
| 340 | 351 | // BurningBoard3 style of hashing. |
| 341 | - if (!empty($modSettings['enable_password_conversion'])) |
|
| 342 | - $other_passwords[] = sha1($user_settings['password_salt'] . sha1($user_settings['password_salt'] . sha1($_POST['passwrd']))); |
|
| 352 | + if (!empty($modSettings['enable_password_conversion'])) { |
|
| 353 | + $other_passwords[] = sha1($user_settings['password_salt'] . sha1($user_settings['password_salt'] . sha1($_POST['passwrd']))); |
|
| 354 | + } |
|
| 343 | 355 | |
| 344 | 356 | // Perhaps we converted to UTF-8 and have a valid password being hashed differently. |
| 345 | 357 | if ($context['character_set'] == 'UTF-8' && !empty($modSettings['previousCharacterSet']) && $modSettings['previousCharacterSet'] != 'utf8') |
| 346 | 358 | { |
| 347 | 359 | // Try iconv first, for no particular reason. |
| 348 | - if (function_exists('iconv')) |
|
| 349 | - $other_passwords['iconv'] = sha1(strtolower(iconv('UTF-8', $modSettings['previousCharacterSet'], $user_settings['member_name'])) . un_htmlspecialchars(iconv('UTF-8', $modSettings['previousCharacterSet'], $_POST['passwrd']))); |
|
| 360 | + if (function_exists('iconv')) { |
|
| 361 | + $other_passwords['iconv'] = sha1(strtolower(iconv('UTF-8', $modSettings['previousCharacterSet'], $user_settings['member_name'])) . un_htmlspecialchars(iconv('UTF-8', $modSettings['previousCharacterSet'], $_POST['passwrd']))); |
|
| 362 | + } |
|
| 350 | 363 | |
| 351 | 364 | // Say it aint so, iconv failed! |
| 352 | - if (empty($other_passwords['iconv']) && function_exists('mb_convert_encoding')) |
|
| 353 | - $other_passwords[] = sha1(strtolower(mb_convert_encoding($user_settings['member_name'], 'UTF-8', $modSettings['previousCharacterSet'])) . un_htmlspecialchars(mb_convert_encoding($_POST['passwrd'], 'UTF-8', $modSettings['previousCharacterSet']))); |
|
| 365 | + if (empty($other_passwords['iconv']) && function_exists('mb_convert_encoding')) { |
|
| 366 | + $other_passwords[] = sha1(strtolower(mb_convert_encoding($user_settings['member_name'], 'UTF-8', $modSettings['previousCharacterSet'])) . un_htmlspecialchars(mb_convert_encoding($_POST['passwrd'], 'UTF-8', $modSettings['previousCharacterSet']))); |
|
| 367 | + } |
|
| 354 | 368 | } |
| 355 | 369 | } |
| 356 | 370 | |
@@ -380,8 +394,9 @@ discard block |
||
| 380 | 394 | $_SESSION['failed_login'] = isset($_SESSION['failed_login']) ? ($_SESSION['failed_login'] + 1) : 1; |
| 381 | 395 | |
| 382 | 396 | // Hmm... don't remember it, do you? Here, try the password reminder ;). |
| 383 | - if ($_SESSION['failed_login'] >= $modSettings['failed_login_threshold']) |
|
| 384 | - redirectexit('action=reminder'); |
|
| 397 | + if ($_SESSION['failed_login'] >= $modSettings['failed_login_threshold']) { |
|
| 398 | + redirectexit('action=reminder'); |
|
| 399 | + } |
|
| 385 | 400 | // We'll give you another chance... |
| 386 | 401 | else |
| 387 | 402 | { |
@@ -392,8 +407,7 @@ discard block |
||
| 392 | 407 | return; |
| 393 | 408 | } |
| 394 | 409 | } |
| 395 | - } |
|
| 396 | - elseif (!empty($user_settings['passwd_flood'])) |
|
| 410 | + } elseif (!empty($user_settings['passwd_flood'])) |
|
| 397 | 411 | { |
| 398 | 412 | // Let's be sure they weren't a little hacker. |
| 399 | 413 | validatePasswordFlood($user_settings['id_member'], $user_settings['passwd_flood'], true); |
@@ -410,8 +424,9 @@ discard block |
||
| 410 | 424 | } |
| 411 | 425 | |
| 412 | 426 | // Check their activation status. |
| 413 | - if (!checkActivation()) |
|
| 414 | - return; |
|
| 427 | + if (!checkActivation()) { |
|
| 428 | + return; |
|
| 429 | + } |
|
| 415 | 430 | |
| 416 | 431 | DoLogin(); |
| 417 | 432 | } |
@@ -423,8 +438,9 @@ discard block |
||
| 423 | 438 | { |
| 424 | 439 | global $sourcedir, $txt, $context, $user_info, $modSettings, $scripturl; |
| 425 | 440 | |
| 426 | - if (!$user_info['is_guest'] || empty($context['tfa_member']) || empty($modSettings['tfa_mode'])) |
|
| 427 | - fatal_lang_error('no_access', false); |
|
| 441 | + if (!$user_info['is_guest'] || empty($context['tfa_member']) || empty($modSettings['tfa_mode'])) { |
|
| 442 | + fatal_lang_error('no_access', false); |
|
| 443 | + } |
|
| 428 | 444 | |
| 429 | 445 | loadLanguage('Profile'); |
| 430 | 446 | require_once($sourcedir . '/Class-TOTP.php'); |
@@ -432,8 +448,9 @@ discard block |
||
| 432 | 448 | $member = $context['tfa_member']; |
| 433 | 449 | |
| 434 | 450 | // Prevent replay attacks by limiting at least 2 minutes before they can log in again via 2FA |
| 435 | - if (time() - $member['last_login'] < 120) |
|
| 436 | - fatal_lang_error('tfa_wait', false); |
|
| 451 | + if (time() - $member['last_login'] < 120) { |
|
| 452 | + fatal_lang_error('tfa_wait', false); |
|
| 453 | + } |
|
| 437 | 454 | |
| 438 | 455 | $totp = new \TOTP\Auth($member['tfa_secret']); |
| 439 | 456 | $totp->setRange(1); |
@@ -447,8 +464,9 @@ discard block |
||
| 447 | 464 | if (!empty($_POST['tfa_code']) && empty($_POST['tfa_backup'])) |
| 448 | 465 | { |
| 449 | 466 | // Check to ensure we're forcing SSL for authentication |
| 450 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
| 451 | - fatal_lang_error('login_ssl_required'); |
|
| 467 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
| 468 | + fatal_lang_error('login_ssl_required'); |
|
| 469 | + } |
|
| 452 | 470 | |
| 453 | 471 | $code = $_POST['tfa_code']; |
| 454 | 472 | |
@@ -458,20 +476,19 @@ discard block |
||
| 458 | 476 | |
| 459 | 477 | setTFACookie(3153600, $member['id_member'], hash_salt($member['tfa_backup'], $member['password_salt']), !empty($_POST['tfa_preserve'])); |
| 460 | 478 | redirectexit(); |
| 461 | - } |
|
| 462 | - else |
|
| 479 | + } else |
|
| 463 | 480 | { |
| 464 | 481 | validatePasswordFlood($member['id_member'], $member['passwd_flood'], false, true); |
| 465 | 482 | |
| 466 | 483 | $context['tfa_error'] = true; |
| 467 | 484 | $context['tfa_value'] = $_POST['tfa_code']; |
| 468 | 485 | } |
| 469 | - } |
|
| 470 | - elseif (!empty($_POST['tfa_backup'])) |
|
| 486 | + } elseif (!empty($_POST['tfa_backup'])) |
|
| 471 | 487 | { |
| 472 | 488 | // Check to ensure we're forcing SSL for authentication |
| 473 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
| 474 | - fatal_lang_error('login_ssl_required'); |
|
| 489 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
| 490 | + fatal_lang_error('login_ssl_required'); |
|
| 491 | + } |
|
| 475 | 492 | |
| 476 | 493 | $backup = $_POST['tfa_backup']; |
| 477 | 494 | |
@@ -485,8 +502,7 @@ discard block |
||
| 485 | 502 | )); |
| 486 | 503 | setTFACookie(3153600, $member['id_member'], hash_salt($member['tfa_backup'], $member['password_salt'])); |
| 487 | 504 | redirectexit('action=profile;area=tfasetup;backup'); |
| 488 | - } |
|
| 489 | - else |
|
| 505 | + } else |
|
| 490 | 506 | { |
| 491 | 507 | validatePasswordFlood($member['id_member'], $member['passwd_flood'], false, true); |
| 492 | 508 | |
@@ -509,8 +525,9 @@ discard block |
||
| 509 | 525 | { |
| 510 | 526 | global $context, $txt, $scripturl, $user_settings, $modSettings; |
| 511 | 527 | |
| 512 | - if (!isset($context['login_errors'])) |
|
| 513 | - $context['login_errors'] = array(); |
|
| 528 | + if (!isset($context['login_errors'])) { |
|
| 529 | + $context['login_errors'] = array(); |
|
| 530 | + } |
|
| 514 | 531 | |
| 515 | 532 | // What is the true activation status of this account? |
| 516 | 533 | $activation_status = $user_settings['is_activated'] > 10 ? $user_settings['is_activated'] - 10 : $user_settings['is_activated']; |
@@ -522,8 +539,9 @@ discard block |
||
| 522 | 539 | return false; |
| 523 | 540 | } |
| 524 | 541 | // Awaiting approval still? |
| 525 | - elseif ($activation_status == 3) |
|
| 526 | - fatal_lang_error('still_awaiting_approval', 'user'); |
|
| 542 | + elseif ($activation_status == 3) { |
|
| 543 | + fatal_lang_error('still_awaiting_approval', 'user'); |
|
| 544 | + } |
|
| 527 | 545 | // Awaiting deletion, changed their mind? |
| 528 | 546 | elseif ($activation_status == 4) |
| 529 | 547 | { |
@@ -531,8 +549,7 @@ discard block |
||
| 531 | 549 | { |
| 532 | 550 | updateMemberData($user_settings['id_member'], array('is_activated' => 1)); |
| 533 | 551 | updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 0 ? $modSettings['unapprovedMembers'] - 1 : 0))); |
| 534 | - } |
|
| 535 | - else |
|
| 552 | + } else |
|
| 536 | 553 | { |
| 537 | 554 | $context['disable_login_hashing'] = true; |
| 538 | 555 | $context['login_errors'][] = $txt['awaiting_delete_account']; |
@@ -572,8 +589,9 @@ discard block |
||
| 572 | 589 | setLoginCookie(60 * $modSettings['cookieTime'], $user_settings['id_member'], hash_salt($user_settings['passwd'], $user_settings['password_salt'])); |
| 573 | 590 | |
| 574 | 591 | // Reset the login threshold. |
| 575 | - if (isset($_SESSION['failed_login'])) |
|
| 576 | - unset($_SESSION['failed_login']); |
|
| 592 | + if (isset($_SESSION['failed_login'])) { |
|
| 593 | + unset($_SESSION['failed_login']); |
|
| 594 | + } |
|
| 577 | 595 | |
| 578 | 596 | $user_info['is_guest'] = false; |
| 579 | 597 | $user_settings['additional_groups'] = explode(',', $user_settings['additional_groups']); |
@@ -595,16 +613,18 @@ discard block |
||
| 595 | 613 | 'id_member' => $user_info['id'], |
| 596 | 614 | ) |
| 597 | 615 | ); |
| 598 | - if ($smcFunc['db_num_rows']($request) == 1) |
|
| 599 | - $_SESSION['first_login'] = true; |
|
| 600 | - else |
|
| 601 | - unset($_SESSION['first_login']); |
|
| 616 | + if ($smcFunc['db_num_rows']($request) == 1) { |
|
| 617 | + $_SESSION['first_login'] = true; |
|
| 618 | + } else { |
|
| 619 | + unset($_SESSION['first_login']); |
|
| 620 | + } |
|
| 602 | 621 | $smcFunc['db_free_result']($request); |
| 603 | 622 | |
| 604 | 623 | // You've logged in, haven't you? |
| 605 | 624 | $update = array('member_ip' => $user_info['ip'], 'member_ip2' => $_SERVER['BAN_CHECK_IP']); |
| 606 | - if (empty($user_settings['tfa_secret'])) |
|
| 607 | - $update['last_login'] = time(); |
|
| 625 | + if (empty($user_settings['tfa_secret'])) { |
|
| 626 | + $update['last_login'] = time(); |
|
| 627 | + } |
|
| 608 | 628 | updateMemberData($user_info['id'], $update); |
| 609 | 629 | |
| 610 | 630 | // Get rid of the online entry for that old guest.... |
@@ -618,8 +638,8 @@ discard block |
||
| 618 | 638 | $_SESSION['log_time'] = 0; |
| 619 | 639 | |
| 620 | 640 | // Log this entry, only if we have it enabled. |
| 621 | - if (!empty($modSettings['loginHistoryDays'])) |
|
| 622 | - $smcFunc['db_insert']('insert', |
|
| 641 | + if (!empty($modSettings['loginHistoryDays'])) { |
|
| 642 | + $smcFunc['db_insert']('insert', |
|
| 623 | 643 | '{db_prefix}member_logins', |
| 624 | 644 | array( |
| 625 | 645 | 'id_member' => 'int', 'time' => 'int', 'ip' => 'inet', 'ip2' => 'inet', |
@@ -631,13 +651,15 @@ discard block |
||
| 631 | 651 | 'id_member', 'time' |
| 632 | 652 | ) |
| 633 | 653 | ); |
| 654 | + } |
|
| 634 | 655 | |
| 635 | 656 | // Just log you back out if it's in maintenance mode and you AREN'T an admin. |
| 636 | - if (empty($maintenance) || allowedTo('admin_forum')) |
|
| 637 | - redirectexit('action=login2;sa=check;member=' . $user_info['id'], $context['server']['needs_login_fix']); |
|
| 638 | - else |
|
| 639 | - redirectexit('action=logout;' . $context['session_var'] . '=' . $context['session_id'], $context['server']['needs_login_fix']); |
|
| 640 | -} |
|
| 657 | + if (empty($maintenance) || allowedTo('admin_forum')) { |
|
| 658 | + redirectexit('action=login2;sa=check;member=' . $user_info['id'], $context['server']['needs_login_fix']); |
|
| 659 | + } else { |
|
| 660 | + redirectexit('action=logout;' . $context['session_var'] . '=' . $context['session_id'], $context['server']['needs_login_fix']); |
|
| 661 | + } |
|
| 662 | + } |
|
| 641 | 663 | |
| 642 | 664 | /** |
| 643 | 665 | * Logs the current user out of their account. |
@@ -653,13 +675,15 @@ discard block |
||
| 653 | 675 | global $sourcedir, $user_info, $user_settings, $context, $smcFunc, $cookiename, $modSettings; |
| 654 | 676 | |
| 655 | 677 | // Make sure they aren't being auto-logged out. |
| 656 | - if (!$internal) |
|
| 657 | - checkSession('get'); |
|
| 678 | + if (!$internal) { |
|
| 679 | + checkSession('get'); |
|
| 680 | + } |
|
| 658 | 681 | |
| 659 | 682 | require_once($sourcedir . '/Subs-Auth.php'); |
| 660 | 683 | |
| 661 | - if (isset($_SESSION['pack_ftp'])) |
|
| 662 | - $_SESSION['pack_ftp'] = null; |
|
| 684 | + if (isset($_SESSION['pack_ftp'])) { |
|
| 685 | + $_SESSION['pack_ftp'] = null; |
|
| 686 | + } |
|
| 663 | 687 | |
| 664 | 688 | // It won't be first login anymore. |
| 665 | 689 | unset($_SESSION['first_login']); |
@@ -687,8 +711,9 @@ discard block |
||
| 687 | 711 | |
| 688 | 712 | // And some other housekeeping while we're at it. |
| 689 | 713 | $salt = substr(md5(mt_rand()), 0, 4); |
| 690 | - if (!empty($user_info['id'])) |
|
| 691 | - updateMemberData($user_info['id'], array('password_salt' => $salt)); |
|
| 714 | + if (!empty($user_info['id'])) { |
|
| 715 | + updateMemberData($user_info['id'], array('password_salt' => $salt)); |
|
| 716 | + } |
|
| 692 | 717 | |
| 693 | 718 | if (!empty($modSettings['tfa_mode']) && !empty($user_info['id']) && !empty($_COOKIE[$cookiename . '_tfa'])) |
| 694 | 719 | { |
@@ -697,10 +722,11 @@ discard block |
||
| 697 | 722 | list ($tfamember, $tfasecret, $exp, $state, $preserve) = $tfadata; |
| 698 | 723 | |
| 699 | 724 | // If we're preserving the cookie, reset it with updated salt |
| 700 | - if (isset($tfamember, $tfasecret, $exp, $state, $preserve) && $preserve && time() < $exp) |
|
| 701 | - setTFACookie(3153600, $user_info['id'], hash_salt($user_settings['tfa_backup'], $salt), true); |
|
| 702 | - else |
|
| 703 | - setTFACookie(-3600, 0, ''); |
|
| 725 | + if (isset($tfamember, $tfasecret, $exp, $state, $preserve) && $preserve && time() < $exp) { |
|
| 726 | + setTFACookie(3153600, $user_info['id'], hash_salt($user_settings['tfa_backup'], $salt), true); |
|
| 727 | + } else { |
|
| 728 | + setTFACookie(-3600, 0, ''); |
|
| 729 | + } |
|
| 704 | 730 | } |
| 705 | 731 | |
| 706 | 732 | session_destroy(); |
@@ -708,14 +734,13 @@ discard block |
||
| 708 | 734 | // Off to the merry board index we go! |
| 709 | 735 | if ($redirect) |
| 710 | 736 | { |
| 711 | - if (empty($_SESSION['logout_url'])) |
|
| 712 | - redirectexit('', $context['server']['needs_login_fix']); |
|
| 713 | - elseif (!empty($_SESSION['logout_url']) && (strpos($_SESSION['logout_url'], 'http://') === false && strpos($_SESSION['logout_url'], 'https://') === false)) |
|
| 737 | + if (empty($_SESSION['logout_url'])) { |
|
| 738 | + redirectexit('', $context['server']['needs_login_fix']); |
|
| 739 | + } elseif (!empty($_SESSION['logout_url']) && (strpos($_SESSION['logout_url'], 'http://') === false && strpos($_SESSION['logout_url'], 'https://') === false)) |
|
| 714 | 740 | { |
| 715 | 741 | unset ($_SESSION['logout_url']); |
| 716 | 742 | redirectexit(); |
| 717 | - } |
|
| 718 | - else |
|
| 743 | + } else |
|
| 719 | 744 | { |
| 720 | 745 | $temp = $_SESSION['logout_url']; |
| 721 | 746 | unset($_SESSION['logout_url']); |
@@ -748,8 +773,9 @@ discard block |
||
| 748 | 773 | function phpBB3_password_check($passwd, $passwd_hash) |
| 749 | 774 | { |
| 750 | 775 | // Too long or too short? |
| 751 | - if (strlen($passwd_hash) != 34) |
|
| 752 | - return; |
|
| 776 | + if (strlen($passwd_hash) != 34) { |
|
| 777 | + return; |
|
| 778 | + } |
|
| 753 | 779 | |
| 754 | 780 | // Range of characters allowed. |
| 755 | 781 | $range = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; |
@@ -760,8 +786,9 @@ discard block |
||
| 760 | 786 | $salt = substr($passwd_hash, 4, 8); |
| 761 | 787 | |
| 762 | 788 | $hash = md5($salt . $passwd, true); |
| 763 | - for (; $count != 0; --$count) |
|
| 764 | - $hash = md5($hash . $passwd, true); |
|
| 789 | + for (; $count != 0; --$count) { |
|
| 790 | + $hash = md5($hash . $passwd, true); |
|
| 791 | + } |
|
| 765 | 792 | |
| 766 | 793 | $output = substr($passwd_hash, 0, 12); |
| 767 | 794 | $i = 0; |
@@ -770,21 +797,25 @@ discard block |
||
| 770 | 797 | $value = ord($hash[$i++]); |
| 771 | 798 | $output .= $range[$value & 0x3f]; |
| 772 | 799 | |
| 773 | - if ($i < 16) |
|
| 774 | - $value |= ord($hash[$i]) << 8; |
|
| 800 | + if ($i < 16) { |
|
| 801 | + $value |= ord($hash[$i]) << 8; |
|
| 802 | + } |
|
| 775 | 803 | |
| 776 | 804 | $output .= $range[($value >> 6) & 0x3f]; |
| 777 | 805 | |
| 778 | - if ($i++ >= 16) |
|
| 779 | - break; |
|
| 806 | + if ($i++ >= 16) { |
|
| 807 | + break; |
|
| 808 | + } |
|
| 780 | 809 | |
| 781 | - if ($i < 16) |
|
| 782 | - $value |= ord($hash[$i]) << 16; |
|
| 810 | + if ($i < 16) { |
|
| 811 | + $value |= ord($hash[$i]) << 16; |
|
| 812 | + } |
|
| 783 | 813 | |
| 784 | 814 | $output .= $range[($value >> 12) & 0x3f]; |
| 785 | 815 | |
| 786 | - if ($i++ >= 16) |
|
| 787 | - break; |
|
| 816 | + if ($i++ >= 16) { |
|
| 817 | + break; |
|
| 818 | + } |
|
| 788 | 819 | |
| 789 | 820 | $output .= $range[($value >> 18) & 0x3f]; |
| 790 | 821 | } |
@@ -815,8 +846,9 @@ discard block |
||
| 815 | 846 | require_once($sourcedir . '/Subs-Auth.php'); |
| 816 | 847 | setLoginCookie(-3600, 0); |
| 817 | 848 | |
| 818 | - if (isset($_SESSION['login_' . $cookiename])) |
|
| 819 | - unset($_SESSION['login_' . $cookiename]); |
|
| 849 | + if (isset($_SESSION['login_' . $cookiename])) { |
|
| 850 | + unset($_SESSION['login_' . $cookiename]); |
|
| 851 | + } |
|
| 820 | 852 | } |
| 821 | 853 | |
| 822 | 854 | // We need a member! |
@@ -830,8 +862,9 @@ discard block |
||
| 830 | 862 | } |
| 831 | 863 | |
| 832 | 864 | // Right, have we got a flood value? |
| 833 | - if ($password_flood_value !== false) |
|
| 834 | - @list ($time_stamp, $number_tries) = explode('|', $password_flood_value); |
|
| 865 | + if ($password_flood_value !== false) { |
|
| 866 | + @list ($time_stamp, $number_tries) = explode('|', $password_flood_value); |
|
| 867 | + } |
|
| 835 | 868 | |
| 836 | 869 | // Timestamp or number of tries invalid? |
| 837 | 870 | if (empty($number_tries) || empty($time_stamp)) |
@@ -847,15 +880,17 @@ discard block |
||
| 847 | 880 | $number_tries = $time_stamp < time() - 20 ? 2 : $number_tries; |
| 848 | 881 | |
| 849 | 882 | // They are trying too fast, make them wait longer |
| 850 | - if ($time_stamp < time() - 10) |
|
| 851 | - $time_stamp = time(); |
|
| 883 | + if ($time_stamp < time() - 10) { |
|
| 884 | + $time_stamp = time(); |
|
| 885 | + } |
|
| 852 | 886 | } |
| 853 | 887 | |
| 854 | 888 | $number_tries++; |
| 855 | 889 | |
| 856 | 890 | // Broken the law? |
| 857 | - if ($number_tries > 5) |
|
| 858 | - fatal_lang_error('login_threshold_brute_fail', 'critical'); |
|
| 891 | + if ($number_tries > 5) { |
|
| 892 | + fatal_lang_error('login_threshold_brute_fail', 'critical'); |
|
| 893 | + } |
|
| 859 | 894 | |
| 860 | 895 | // Otherwise set the members data. If they correct on their first attempt then we actually clear it, otherwise we set it! |
| 861 | 896 | updateMemberData($id_member, array('passwd_flood' => $was_correct && $number_tries == 1 ? '' : $time_stamp . '|' . $number_tries)); |
@@ -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 | * Truncate the GET array to a specified length |
@@ -26,14 +27,15 @@ discard block |
||
| 26 | 27 | function truncateArray($arr, $max_length=1900) |
| 27 | 28 | { |
| 28 | 29 | $curr_length = array_sum(array_map("strlen", $arr)); |
| 29 | - if ($curr_length <= $max_length) |
|
| 30 | - return $arr; |
|
| 31 | - else |
|
| 30 | + if ($curr_length <= $max_length) { |
|
| 31 | + return $arr; |
|
| 32 | + } else |
|
| 32 | 33 | { |
| 33 | 34 | // Truncate each element's value to a reasonable length |
| 34 | 35 | $param_max = floor($max_length/count($arr)); |
| 35 | - foreach ($arr as $key => &$value) |
|
| 36 | - $value = substr($value, 0, $param_max - strlen($key) - 5); |
|
| 36 | + foreach ($arr as $key => &$value) { |
|
| 37 | + $value = substr($value, 0, $param_max - strlen($key) - 5); |
|
| 38 | + } |
|
| 37 | 39 | return $arr; |
| 38 | 40 | } |
| 39 | 41 | } |
@@ -55,8 +57,9 @@ discard block |
||
| 55 | 57 | // Don't update for every page - this isn't wholly accurate but who cares. |
| 56 | 58 | if ($topic) |
| 57 | 59 | { |
| 58 | - if (isset($_SESSION['last_topic_id']) && $_SESSION['last_topic_id'] == $topic) |
|
| 59 | - $force = false; |
|
| 60 | + if (isset($_SESSION['last_topic_id']) && $_SESSION['last_topic_id'] == $topic) { |
|
| 61 | + $force = false; |
|
| 62 | + } |
|
| 60 | 63 | $_SESSION['last_topic_id'] = $topic; |
| 61 | 64 | } |
| 62 | 65 | } |
@@ -69,22 +72,24 @@ discard block |
||
| 69 | 72 | } |
| 70 | 73 | |
| 71 | 74 | // Don't mark them as online more than every so often. |
| 72 | - if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= (time() - 8) && !$force) |
|
| 73 | - return; |
|
| 75 | + if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= (time() - 8) && !$force) { |
|
| 76 | + return; |
|
| 77 | + } |
|
| 74 | 78 | |
| 75 | 79 | if (!empty($modSettings['who_enabled'])) |
| 76 | 80 | { |
| 77 | 81 | $encoded_get = truncateArray($_GET) + array('USER_AGENT' => $_SERVER['HTTP_USER_AGENT']); |
| 78 | 82 | |
| 79 | 83 | // In the case of a dlattach action, session_var may not be set. |
| 80 | - if (!isset($context['session_var'])) |
|
| 81 | - $context['session_var'] = $_SESSION['session_var']; |
|
| 84 | + if (!isset($context['session_var'])) { |
|
| 85 | + $context['session_var'] = $_SESSION['session_var']; |
|
| 86 | + } |
|
| 82 | 87 | |
| 83 | 88 | unset($encoded_get['sesc'], $encoded_get[$context['session_var']]); |
| 84 | 89 | $encoded_get = json_encode($encoded_get); |
| 90 | + } else { |
|
| 91 | + $encoded_get = ''; |
|
| 85 | 92 | } |
| 86 | - else |
|
| 87 | - $encoded_get = ''; |
|
| 88 | 93 | |
| 89 | 94 | // Guests use 0, members use their session ID. |
| 90 | 95 | $session_id = $user_info['is_guest'] ? 'ip' . $user_info['ip'] : session_id(); |
@@ -124,17 +129,18 @@ discard block |
||
| 124 | 129 | ); |
| 125 | 130 | |
| 126 | 131 | // Guess it got deleted. |
| 127 | - if ($smcFunc['db_affected_rows']() == 0) |
|
| 132 | + if ($smcFunc['db_affected_rows']() == 0) { |
|
| 133 | + $_SESSION['log_time'] = 0; |
|
| 134 | + } |
|
| 135 | + } else { |
|
| 128 | 136 | $_SESSION['log_time'] = 0; |
| 129 | 137 | } |
| 130 | - else |
|
| 131 | - $_SESSION['log_time'] = 0; |
|
| 132 | 138 | |
| 133 | 139 | // Otherwise, we have to delete and insert. |
| 134 | 140 | if (empty($_SESSION['log_time'])) |
| 135 | 141 | { |
| 136 | - if ($do_delete || !empty($user_info['id'])) |
|
| 137 | - $smcFunc['db_query']('', ' |
|
| 142 | + if ($do_delete || !empty($user_info['id'])) { |
|
| 143 | + $smcFunc['db_query']('', ' |
|
| 138 | 144 | DELETE FROM {db_prefix}log_online |
| 139 | 145 | WHERE ' . ($do_delete ? 'log_time < {int:log_time}' : '') . ($do_delete && !empty($user_info['id']) ? ' OR ' : '') . (empty($user_info['id']) ? '' : 'id_member = {int:current_member}'), |
| 140 | 146 | array( |
@@ -142,6 +148,7 @@ discard block |
||
| 142 | 148 | 'log_time' => time() - $modSettings['lastActive'] * 60, |
| 143 | 149 | ) |
| 144 | 150 | ); |
| 151 | + } |
|
| 145 | 152 | |
| 146 | 153 | $smcFunc['db_insert']($do_delete ? 'ignore' : 'replace', |
| 147 | 154 | '{db_prefix}log_online', |
@@ -155,21 +162,24 @@ discard block |
||
| 155 | 162 | $_SESSION['log_time'] = time(); |
| 156 | 163 | |
| 157 | 164 | // Well, they are online now. |
| 158 | - if (empty($_SESSION['timeOnlineUpdated'])) |
|
| 159 | - $_SESSION['timeOnlineUpdated'] = time(); |
|
| 165 | + if (empty($_SESSION['timeOnlineUpdated'])) { |
|
| 166 | + $_SESSION['timeOnlineUpdated'] = time(); |
|
| 167 | + } |
|
| 160 | 168 | |
| 161 | 169 | // Set their login time, if not already done within the last minute. |
| 162 | 170 | if (SMF != 'SSI' && !empty($user_info['last_login']) && $user_info['last_login'] < time() - 60 && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('.xml', 'login2', 'logintfa')))) |
| 163 | 171 | { |
| 164 | 172 | // Don't count longer than 15 minutes. |
| 165 | - if (time() - $_SESSION['timeOnlineUpdated'] > 60 * 15) |
|
| 166 | - $_SESSION['timeOnlineUpdated'] = time(); |
|
| 173 | + if (time() - $_SESSION['timeOnlineUpdated'] > 60 * 15) { |
|
| 174 | + $_SESSION['timeOnlineUpdated'] = time(); |
|
| 175 | + } |
|
| 167 | 176 | |
| 168 | 177 | $user_settings['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated']; |
| 169 | 178 | updateMemberData($user_info['id'], array('last_login' => time(), 'member_ip' => $user_info['ip'], 'member_ip2' => $_SERVER['BAN_CHECK_IP'], 'total_time_logged_in' => $user_settings['total_time_logged_in'])); |
| 170 | 179 | |
| 171 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 172 | - cache_put_data('user_settings-' . $user_info['id'], $user_settings, 60); |
|
| 180 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 181 | + cache_put_data('user_settings-' . $user_info['id'], $user_settings, 60); |
|
| 182 | + } |
|
| 173 | 183 | |
| 174 | 184 | $user_info['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated']; |
| 175 | 185 | $_SESSION['timeOnlineUpdated'] = time(); |
@@ -206,8 +216,7 @@ discard block |
||
| 206 | 216 | // Oops. maybe we have no more disk space left, or some other troubles, troubles... |
| 207 | 217 | // Copy the file back and run for your life! |
| 208 | 218 | @copy($boarddir . '/db_last_error_bak.php', $boarddir . '/db_last_error.php'); |
| 209 | - } |
|
| 210 | - else |
|
| 219 | + } else |
|
| 211 | 220 | { |
| 212 | 221 | @touch($boarddir . '/' . 'Settings.php'); |
| 213 | 222 | return true; |
@@ -227,22 +236,27 @@ discard block |
||
| 227 | 236 | global $db_cache, $db_count, $cache_misses, $cache_count_misses, $db_show_debug, $cache_count, $cache_hits, $smcFunc, $txt; |
| 228 | 237 | |
| 229 | 238 | // Add to Settings.php if you want to show the debugging information. |
| 230 | - if (!isset($db_show_debug) || $db_show_debug !== true || (isset($_GET['action']) && $_GET['action'] == 'viewquery')) |
|
| 231 | - return; |
|
| 239 | + if (!isset($db_show_debug) || $db_show_debug !== true || (isset($_GET['action']) && $_GET['action'] == 'viewquery')) { |
|
| 240 | + return; |
|
| 241 | + } |
|
| 232 | 242 | |
| 233 | - if (empty($_SESSION['view_queries'])) |
|
| 234 | - $_SESSION['view_queries'] = 0; |
|
| 235 | - if (empty($context['debug']['language_files'])) |
|
| 236 | - $context['debug']['language_files'] = array(); |
|
| 237 | - if (empty($context['debug']['sheets'])) |
|
| 238 | - $context['debug']['sheets'] = array(); |
|
| 243 | + if (empty($_SESSION['view_queries'])) { |
|
| 244 | + $_SESSION['view_queries'] = 0; |
|
| 245 | + } |
|
| 246 | + if (empty($context['debug']['language_files'])) { |
|
| 247 | + $context['debug']['language_files'] = array(); |
|
| 248 | + } |
|
| 249 | + if (empty($context['debug']['sheets'])) { |
|
| 250 | + $context['debug']['sheets'] = array(); |
|
| 251 | + } |
|
| 239 | 252 | |
| 240 | 253 | $files = get_included_files(); |
| 241 | 254 | $total_size = 0; |
| 242 | 255 | for ($i = 0, $n = count($files); $i < $n; $i++) |
| 243 | 256 | { |
| 244 | - if (file_exists($files[$i])) |
|
| 245 | - $total_size += filesize($files[$i]); |
|
| 257 | + if (file_exists($files[$i])) { |
|
| 258 | + $total_size += filesize($files[$i]); |
|
| 259 | + } |
|
| 246 | 260 | $files[$i] = strtr($files[$i], array($boarddir => '.', $sourcedir => '(Sources)', $cachedir => '(Cache)', $settings['actual_theme_dir'] => '(Current Theme)')); |
| 247 | 261 | } |
| 248 | 262 | |
@@ -251,8 +265,9 @@ discard block |
||
| 251 | 265 | { |
| 252 | 266 | foreach ($db_cache as $q => $qq) |
| 253 | 267 | { |
| 254 | - if (!empty($qq['w'])) |
|
| 255 | - $warnings += count($qq['w']); |
|
| 268 | + if (!empty($qq['w'])) { |
|
| 269 | + $warnings += count($qq['w']); |
|
| 270 | + } |
|
| 256 | 271 | } |
| 257 | 272 | |
| 258 | 273 | $_SESSION['debug'] = &$db_cache; |
@@ -273,12 +288,14 @@ discard block |
||
| 273 | 288 | ',(isset($context['debug']['instances']) ? ($txt['debug_instances'] . (empty($context['debug']['instances']) ? 0 : count($context['debug']['instances'])) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_instances\').style.display = \'inline\'; this.style.display = \'none\'; return false;">'. $txt['debug_show'] .'</a><span id="debug_instances" style="display: none;"><em>'. implode('</em>, <em>', array_keys($context['debug']['instances'])) .'</em></span>)'. '<br>') : ''),' |
| 274 | 289 | ', $txt['debug_files_included'], count($files), ' - ', round($total_size / 1024), $txt['debug_kb'], ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_include_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_include_info" style="display: none;"><em>', implode('</em>, <em>', $files), '</em></span>)<br>'; |
| 275 | 290 | |
| 276 | - if (function_exists('memory_get_peak_usage')) |
|
| 277 | - echo $txt['debug_memory_use'], ceil(memory_get_peak_usage() / 1024), $txt['debug_kb'], '<br>'; |
|
| 291 | + if (function_exists('memory_get_peak_usage')) { |
|
| 292 | + echo $txt['debug_memory_use'], ceil(memory_get_peak_usage() / 1024), $txt['debug_kb'], '<br>'; |
|
| 293 | + } |
|
| 278 | 294 | |
| 279 | 295 | // What tokens are active? |
| 280 | - if (isset($_SESSION['token'])) |
|
| 281 | - echo $txt['debug_tokens'] . '<em>' . implode(',</em> <em>', array_keys($_SESSION['token'])), '</em>.<br>'; |
|
| 296 | + if (isset($_SESSION['token'])) { |
|
| 297 | + echo $txt['debug_tokens'] . '<em>' . implode(',</em> <em>', array_keys($_SESSION['token'])), '</em>.<br>'; |
|
| 298 | + } |
|
| 282 | 299 | |
| 283 | 300 | if (!empty($modSettings['cache_enable']) && !empty($cache_hits)) |
| 284 | 301 | { |
@@ -292,10 +309,12 @@ discard block |
||
| 292 | 309 | $total_t += $cache_hit['t']; |
| 293 | 310 | $total_s += $cache_hit['s']; |
| 294 | 311 | } |
| 295 | - if (!isset($cache_misses)) |
|
| 296 | - $cache_misses = array(); |
|
| 297 | - foreach ($cache_misses as $missed) |
|
| 298 | - $missed_entries[] = $missed['d'] . ' ' . $missed['k']; |
|
| 312 | + if (!isset($cache_misses)) { |
|
| 313 | + $cache_misses = array(); |
|
| 314 | + } |
|
| 315 | + foreach ($cache_misses as $missed) { |
|
| 316 | + $missed_entries[] = $missed['d'] . ' ' . $missed['k']; |
|
| 317 | + } |
|
| 299 | 318 | |
| 300 | 319 | echo ' |
| 301 | 320 | ', $txt['debug_cache_hits'], $cache_count, ': ', sprintf($txt['debug_cache_seconds_bytes_total'], comma_format($total_t, 5), comma_format($total_s)), ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_cache_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_cache_info" style="display: none;"><em>', implode('</em>, <em>', $entries), '</em></span>)<br> |
@@ -306,38 +325,44 @@ discard block |
||
| 306 | 325 | <a href="', $scripturl, '?action=viewquery" target="_blank" class="new_win">', $warnings == 0 ? sprintf($txt['debug_queries_used'], (int) $db_count) : sprintf($txt['debug_queries_used_and_warnings'], (int) $db_count, $warnings), '</a><br> |
| 307 | 326 | <br>'; |
| 308 | 327 | |
| 309 | - if ($_SESSION['view_queries'] == 1 && !empty($db_cache)) |
|
| 310 | - foreach ($db_cache as $q => $qq) |
|
| 328 | + if ($_SESSION['view_queries'] == 1 && !empty($db_cache)) { |
|
| 329 | + foreach ($db_cache as $q => $qq) |
|
| 311 | 330 | { |
| 312 | 331 | $is_select = strpos(trim($qq['q']), 'SELECT') === 0 || preg_match('~^INSERT(?: IGNORE)? INTO \w+(?:\s+\([^)]+\))?\s+SELECT .+$~s', trim($qq['q'])) != 0; |
| 332 | + } |
|
| 313 | 333 | // Temporary tables created in earlier queries are not explainable. |
| 314 | 334 | if ($is_select) |
| 315 | 335 | { |
| 316 | - foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) |
|
| 317 | - if (strpos(trim($qq['q']), $tmp) !== false) |
|
| 336 | + foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) { |
|
| 337 | + if (strpos(trim($qq['q']), $tmp) !== false) |
|
| 318 | 338 | { |
| 319 | 339 | $is_select = false; |
| 340 | + } |
|
| 320 | 341 | break; |
| 321 | 342 | } |
| 322 | 343 | } |
| 323 | 344 | // But actual creation of the temporary tables are. |
| 324 | - elseif (preg_match('~^CREATE TEMPORARY TABLE .+?SELECT .+$~s', trim($qq['q'])) != 0) |
|
| 325 | - $is_select = true; |
|
| 345 | + elseif (preg_match('~^CREATE TEMPORARY TABLE .+?SELECT .+$~s', trim($qq['q'])) != 0) { |
|
| 346 | + $is_select = true; |
|
| 347 | + } |
|
| 326 | 348 | |
| 327 | 349 | // Make the filenames look a bit better. |
| 328 | - if (isset($qq['f'])) |
|
| 329 | - $qq['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $qq['f']); |
|
| 350 | + if (isset($qq['f'])) { |
|
| 351 | + $qq['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $qq['f']); |
|
| 352 | + } |
|
| 330 | 353 | |
| 331 | 354 | echo ' |
| 332 | 355 | <strong>', $is_select ? '<a href="' . $scripturl . '?action=viewquery;qq=' . ($q + 1) . '#qq' . $q . '" target="_blank" class="new_win" style="text-decoration: none;">' : '', nl2br(str_replace("\t", ' ', $smcFunc['htmlspecialchars'](ltrim($qq['q'], "\n\r")))) . ($is_select ? '</a></strong>' : '</strong>') . '<br> |
| 333 | 356 | '; |
| 334 | - if (!empty($qq['f']) && !empty($qq['l'])) |
|
| 335 | - echo sprintf($txt['debug_query_in_line'], $qq['f'], $qq['l']); |
|
| 357 | + if (!empty($qq['f']) && !empty($qq['l'])) { |
|
| 358 | + echo sprintf($txt['debug_query_in_line'], $qq['f'], $qq['l']); |
|
| 359 | + } |
|
| 336 | 360 | |
| 337 | - if (isset($qq['s'], $qq['t']) && isset($txt['debug_query_which_took_at'])) |
|
| 338 | - echo sprintf($txt['debug_query_which_took_at'], round($qq['t'], 8), round($qq['s'], 8)) . '<br>'; |
|
| 339 | - elseif (isset($qq['t'])) |
|
| 340 | - echo sprintf($txt['debug_query_which_took'], round($qq['t'], 8)) . '<br>'; |
|
| 361 | + if (isset($qq['s'], $qq['t']) && isset($txt['debug_query_which_took_at'])) { |
|
| 362 | + echo sprintf($txt['debug_query_which_took_at'], round($qq['t'], 8), round($qq['s'], 8)) . '<br>'; |
|
| 363 | + } elseif (isset($qq['t'])) { |
|
| 364 | + echo sprintf($txt['debug_query_which_took'], round($qq['t'], 8)) . '<br>'; |
|
| 365 | + } |
|
| 341 | 366 | echo ' |
| 342 | 367 | <br>'; |
| 343 | 368 | } |
@@ -362,12 +387,14 @@ discard block |
||
| 362 | 387 | global $modSettings, $smcFunc; |
| 363 | 388 | static $cache_stats = array(); |
| 364 | 389 | |
| 365 | - if (empty($modSettings['trackStats'])) |
|
| 366 | - return false; |
|
| 367 | - if (!empty($stats)) |
|
| 368 | - return $cache_stats = array_merge($cache_stats, $stats); |
|
| 369 | - elseif (empty($cache_stats)) |
|
| 370 | - return false; |
|
| 390 | + if (empty($modSettings['trackStats'])) { |
|
| 391 | + return false; |
|
| 392 | + } |
|
| 393 | + if (!empty($stats)) { |
|
| 394 | + return $cache_stats = array_merge($cache_stats, $stats); |
|
| 395 | + } elseif (empty($cache_stats)) { |
|
| 396 | + return false; |
|
| 397 | + } |
|
| 371 | 398 | |
| 372 | 399 | $setStringUpdate = ''; |
| 373 | 400 | $insert_keys = array(); |
@@ -380,10 +407,11 @@ discard block |
||
| 380 | 407 | $setStringUpdate .= ' |
| 381 | 408 | ' . $field . ' = ' . ($change === '+' ? $field . ' + 1' : '{int:' . $field . '}') . ','; |
| 382 | 409 | |
| 383 | - if ($change === '+') |
|
| 384 | - $cache_stats[$field] = 1; |
|
| 385 | - else |
|
| 386 | - $update_parameters[$field] = $change; |
|
| 410 | + if ($change === '+') { |
|
| 411 | + $cache_stats[$field] = 1; |
|
| 412 | + } else { |
|
| 413 | + $update_parameters[$field] = $change; |
|
| 414 | + } |
|
| 387 | 415 | $insert_keys[$field] = 'int'; |
| 388 | 416 | } |
| 389 | 417 | |
@@ -447,43 +475,50 @@ discard block |
||
| 447 | 475 | ); |
| 448 | 476 | |
| 449 | 477 | // Make sure this particular log is enabled first... |
| 450 | - if (empty($modSettings['modlog_enabled'])) |
|
| 451 | - unset ($log_types['moderate']); |
|
| 452 | - if (empty($modSettings['userlog_enabled'])) |
|
| 453 | - unset ($log_types['user']); |
|
| 454 | - if (empty($modSettings['adminlog_enabled'])) |
|
| 455 | - unset ($log_types['admin']); |
|
| 478 | + if (empty($modSettings['modlog_enabled'])) { |
|
| 479 | + unset ($log_types['moderate']); |
|
| 480 | + } |
|
| 481 | + if (empty($modSettings['userlog_enabled'])) { |
|
| 482 | + unset ($log_types['user']); |
|
| 483 | + } |
|
| 484 | + if (empty($modSettings['adminlog_enabled'])) { |
|
| 485 | + unset ($log_types['admin']); |
|
| 486 | + } |
|
| 456 | 487 | |
| 457 | 488 | call_integration_hook('integrate_log_types', array(&$log_types)); |
| 458 | 489 | |
| 459 | 490 | foreach ($logs as $log) |
| 460 | 491 | { |
| 461 | - if (!isset($log_types[$log['log_type']])) |
|
| 462 | - return false; |
|
| 492 | + if (!isset($log_types[$log['log_type']])) { |
|
| 493 | + return false; |
|
| 494 | + } |
|
| 463 | 495 | |
| 464 | - if (!is_array($log['extra'])) |
|
| 465 | - trigger_error('logActions(): data is not an array with action \'' . $log['action'] . '\'', E_USER_NOTICE); |
|
| 496 | + if (!is_array($log['extra'])) { |
|
| 497 | + trigger_error('logActions(): data is not an array with action \'' . $log['action'] . '\'', E_USER_NOTICE); |
|
| 498 | + } |
|
| 466 | 499 | |
| 467 | 500 | // Pull out the parts we want to store separately, but also make sure that the data is proper |
| 468 | 501 | if (isset($log['extra']['topic'])) |
| 469 | 502 | { |
| 470 | - if (!is_numeric($log['extra']['topic'])) |
|
| 471 | - trigger_error('logActions(): data\'s topic is not a number', E_USER_NOTICE); |
|
| 503 | + if (!is_numeric($log['extra']['topic'])) { |
|
| 504 | + trigger_error('logActions(): data\'s topic is not a number', E_USER_NOTICE); |
|
| 505 | + } |
|
| 472 | 506 | $topic_id = empty($log['extra']['topic']) ? 0 : (int) $log['extra']['topic']; |
| 473 | 507 | unset($log['extra']['topic']); |
| 508 | + } else { |
|
| 509 | + $topic_id = 0; |
|
| 474 | 510 | } |
| 475 | - else |
|
| 476 | - $topic_id = 0; |
|
| 477 | 511 | |
| 478 | 512 | if (isset($log['extra']['message'])) |
| 479 | 513 | { |
| 480 | - if (!is_numeric($log['extra']['message'])) |
|
| 481 | - trigger_error('logActions(): data\'s message is not a number', E_USER_NOTICE); |
|
| 514 | + if (!is_numeric($log['extra']['message'])) { |
|
| 515 | + trigger_error('logActions(): data\'s message is not a number', E_USER_NOTICE); |
|
| 516 | + } |
|
| 482 | 517 | $msg_id = empty($log['extra']['message']) ? 0 : (int) $log['extra']['message']; |
| 483 | 518 | unset($log['extra']['message']); |
| 519 | + } else { |
|
| 520 | + $msg_id = 0; |
|
| 484 | 521 | } |
| 485 | - else |
|
| 486 | - $msg_id = 0; |
|
| 487 | 522 | |
| 488 | 523 | // @todo cache this? |
| 489 | 524 | // Is there an associated report on this? |
@@ -510,23 +545,26 @@ discard block |
||
| 510 | 545 | $smcFunc['db_free_result']($request); |
| 511 | 546 | } |
| 512 | 547 | |
| 513 | - if (isset($log['extra']['member']) && !is_numeric($log['extra']['member'])) |
|
| 514 | - trigger_error('logActions(): data\'s member is not a number', E_USER_NOTICE); |
|
| 548 | + if (isset($log['extra']['member']) && !is_numeric($log['extra']['member'])) { |
|
| 549 | + trigger_error('logActions(): data\'s member is not a number', E_USER_NOTICE); |
|
| 550 | + } |
|
| 515 | 551 | |
| 516 | 552 | if (isset($log['extra']['board'])) |
| 517 | 553 | { |
| 518 | - if (!is_numeric($log['extra']['board'])) |
|
| 519 | - trigger_error('logActions(): data\'s board is not a number', E_USER_NOTICE); |
|
| 554 | + if (!is_numeric($log['extra']['board'])) { |
|
| 555 | + trigger_error('logActions(): data\'s board is not a number', E_USER_NOTICE); |
|
| 556 | + } |
|
| 520 | 557 | $board_id = empty($log['extra']['board']) ? 0 : (int) $log['extra']['board']; |
| 521 | 558 | unset($log['extra']['board']); |
| 559 | + } else { |
|
| 560 | + $board_id = 0; |
|
| 522 | 561 | } |
| 523 | - else |
|
| 524 | - $board_id = 0; |
|
| 525 | 562 | |
| 526 | 563 | if (isset($log['extra']['board_to'])) |
| 527 | 564 | { |
| 528 | - if (!is_numeric($log['extra']['board_to'])) |
|
| 529 | - trigger_error('logActions(): data\'s board_to is not a number', E_USER_NOTICE); |
|
| 565 | + if (!is_numeric($log['extra']['board_to'])) { |
|
| 566 | + trigger_error('logActions(): data\'s board_to is not a number', E_USER_NOTICE); |
|
| 567 | + } |
|
| 530 | 568 | if (empty($board_id)) |
| 531 | 569 | { |
| 532 | 570 | $board_id = empty($log['extra']['board_to']) ? 0 : (int) $log['extra']['board_to']; |
@@ -534,10 +572,11 @@ discard block |
||
| 534 | 572 | } |
| 535 | 573 | } |
| 536 | 574 | |
| 537 | - if (isset($log['extra']['member_affected'])) |
|
| 538 | - $memID = $log['extra']['member_affected']; |
|
| 539 | - else |
|
| 540 | - $memID = $user_info['id']; |
|
| 575 | + if (isset($log['extra']['member_affected'])) { |
|
| 576 | + $memID = $log['extra']['member_affected']; |
|
| 577 | + } else { |
|
| 578 | + $memID = $user_info['id']; |
|
| 579 | + } |
|
| 541 | 580 | |
| 542 | 581 | $inserts[] = array( |
| 543 | 582 | time(), $log_types[$log['log_type']], $memID, $user_info['ip'], $log['action'], |
@@ -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 | * Create a menu. |
@@ -64,22 +65,26 @@ discard block |
||
| 64 | 65 | $menu_context['current_action'] = isset($menuOptions['action']) ? $menuOptions['action'] : $context['current_action']; |
| 65 | 66 | |
| 66 | 67 | // Allow extend *any* menu with a single hook |
| 67 | - if (!empty($menu_context['current_action'])) |
|
| 68 | - call_integration_hook('integrate_' . $menu_context['current_action'] . '_areas', array(&$menuData)); |
|
| 68 | + if (!empty($menu_context['current_action'])) { |
|
| 69 | + call_integration_hook('integrate_' . $menu_context['current_action'] . '_areas', array(&$menuData)); |
|
| 70 | + } |
|
| 69 | 71 | |
| 70 | 72 | // What is the current area selected? |
| 71 | - if (isset($menuOptions['current_area']) || isset($_GET['area'])) |
|
| 72 | - $menu_context['current_area'] = isset($menuOptions['current_area']) ? $menuOptions['current_area'] : $_GET['area']; |
|
| 73 | + if (isset($menuOptions['current_area']) || isset($_GET['area'])) { |
|
| 74 | + $menu_context['current_area'] = isset($menuOptions['current_area']) ? $menuOptions['current_area'] : $_GET['area']; |
|
| 75 | + } |
|
| 73 | 76 | |
| 74 | 77 | // Build a list of additional parameters that should go in the URL. |
| 75 | 78 | $menu_context['extra_parameters'] = ''; |
| 76 | - if (!empty($menuOptions['extra_url_parameters'])) |
|
| 77 | - foreach ($menuOptions['extra_url_parameters'] as $key => $value) |
|
| 79 | + if (!empty($menuOptions['extra_url_parameters'])) { |
|
| 80 | + foreach ($menuOptions['extra_url_parameters'] as $key => $value) |
|
| 78 | 81 | $menu_context['extra_parameters'] .= ';' . $key . '=' . $value; |
| 82 | + } |
|
| 79 | 83 | |
| 80 | 84 | // Only include the session ID in the URL if it's strictly necessary. |
| 81 | - if (empty($menuOptions['disable_url_session_check'])) |
|
| 82 | - $menu_context['extra_parameters'] .= ';' . $context['session_var'] . '=' . $context['session_id']; |
|
| 85 | + if (empty($menuOptions['disable_url_session_check'])) { |
|
| 86 | + $menu_context['extra_parameters'] .= ';' . $context['session_var'] . '=' . $context['session_id']; |
|
| 87 | + } |
|
| 83 | 88 | |
| 84 | 89 | $include_data = array(); |
| 85 | 90 | |
@@ -87,8 +92,9 @@ discard block |
||
| 87 | 92 | foreach ($menuData as $section_id => $section) |
| 88 | 93 | { |
| 89 | 94 | // Is this enabled - or has as permission check - which fails? |
| 90 | - if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($section['permission']) && !allowedTo($section['permission']))) |
|
| 91 | - continue; |
|
| 95 | + if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($section['permission']) && !allowedTo($section['permission']))) { |
|
| 96 | + continue; |
|
| 97 | + } |
|
| 92 | 98 | |
| 93 | 99 | // Now we cycle through the sections to pick the right area. |
| 94 | 100 | foreach ($section['areas'] as $area_id => $area) |
@@ -110,41 +116,45 @@ discard block |
||
| 110 | 116 | if (empty($area['hidden'])) |
| 111 | 117 | { |
| 112 | 118 | // First time this section? |
| 113 | - if (!isset($menu_context['sections'][$section_id])) |
|
| 114 | - $menu_context['sections'][$section_id]['title'] = $section['title']; |
|
| 119 | + if (!isset($menu_context['sections'][$section_id])) { |
|
| 120 | + $menu_context['sections'][$section_id]['title'] = $section['title']; |
|
| 121 | + } |
|
| 115 | 122 | |
| 116 | 123 | $menu_context['sections'][$section_id]['areas'][$area_id] = array('label' => isset($area['label']) ? $area['label'] : $txt[$area_id]); |
| 117 | 124 | // We'll need the ID as well... |
| 118 | 125 | $menu_context['sections'][$section_id]['id'] = $section_id; |
| 119 | 126 | // Does it have a custom URL? |
| 120 | - if (isset($area['custom_url'])) |
|
| 121 | - $menu_context['sections'][$section_id]['areas'][$area_id]['url'] = $area['custom_url']; |
|
| 127 | + if (isset($area['custom_url'])) { |
|
| 128 | + $menu_context['sections'][$section_id]['areas'][$area_id]['url'] = $area['custom_url']; |
|
| 129 | + } |
|
| 122 | 130 | |
| 123 | 131 | // Does this area have its own icon? |
| 124 | - if (!isset($area['force_menu_into_arms_of_another_menu']) && $user_info['name'] == 'iamanoompaloompa') |
|
| 125 | - $menu_context['sections'][$section_id]['areas'][$area_id] = smf_json_decode(base64_decode('eyJsYWJlbCI6Ik9vbXBhIExvb21wYSIsInVybCI6Imh0dHBzOlwvXC9lbi53aWtpcGVkaWEub3JnXC93aWtpXC9Pb21wYV9Mb29tcGFzPyIsImljb24iOiI8aW1nIHNyYz1cImh0dHBzOlwvXC93d3cuc2ltcGxlbWFjaGluZXMub3JnXC9pbWFnZXNcL29vbXBhLmdpZlwiIGFsdD1cIkknbSBhbiBPb21wYSBMb29tcGFcIiBcLz4ifQ=='), true); |
|
| 126 | - elseif (isset($area['icon']) && file_exists($settings['theme_dir'] . '/images/admin/' . $area['icon'])) |
|
| 127 | - $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<img src="' . $settings['images_url'] . '/admin/' . $area['icon'] . '" alt="">'; |
|
| 128 | - elseif (isset($area['icon']) && file_exists($settings['default_theme_dir'] . '/images/admin/' . $area['icon'])) |
|
| 129 | - $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<img src="' . $settings['default_images_url'] . '/admin/' . $area['icon'] . '" alt="">'; |
|
| 130 | - elseif (isset($area['icon'])) |
|
| 131 | - $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<span class="generic_icons ' . $area['icon'] . '"></span>'; |
|
| 132 | - else |
|
| 133 | - $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<span class="generic_icons ' . $area_id . '"></span>'; |
|
| 134 | - |
|
| 135 | - if (isset($area['icon_class']) && empty($menu_context['sections'][$section_id]['areas'][$area_id]['icon'])) |
|
| 136 | - $menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . $area['icon_class']; |
|
| 137 | - elseif (isset($area['icon'])) |
|
| 132 | + if (!isset($area['force_menu_into_arms_of_another_menu']) && $user_info['name'] == 'iamanoompaloompa') { |
|
| 133 | + $menu_context['sections'][$section_id]['areas'][$area_id] = smf_json_decode(base64_decode('eyJsYWJlbCI6Ik9vbXBhIExvb21wYSIsInVybCI6Imh0dHBzOlwvXC9lbi53aWtpcGVkaWEub3JnXC93aWtpXC9Pb21wYV9Mb29tcGFzPyIsImljb24iOiI8aW1nIHNyYz1cImh0dHBzOlwvXC93d3cuc2ltcGxlbWFjaGluZXMub3JnXC9pbWFnZXNcL29vbXBhLmdpZlwiIGFsdD1cIkknbSBhbiBPb21wYSBMb29tcGFcIiBcLz4ifQ=='), true); |
|
| 134 | + } elseif (isset($area['icon']) && file_exists($settings['theme_dir'] . '/images/admin/' . $area['icon'])) { |
|
| 135 | + $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<img src="' . $settings['images_url'] . '/admin/' . $area['icon'] . '" alt="">'; |
|
| 136 | + } elseif (isset($area['icon']) && file_exists($settings['default_theme_dir'] . '/images/admin/' . $area['icon'])) { |
|
| 137 | + $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<img src="' . $settings['default_images_url'] . '/admin/' . $area['icon'] . '" alt="">'; |
|
| 138 | + } elseif (isset($area['icon'])) { |
|
| 139 | + $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<span class="generic_icons ' . $area['icon'] . '"></span>'; |
|
| 140 | + } else { |
|
| 141 | + $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<span class="generic_icons ' . $area_id . '"></span>'; |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + if (isset($area['icon_class']) && empty($menu_context['sections'][$section_id]['areas'][$area_id]['icon'])) { |
|
| 145 | + $menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . $area['icon_class']; |
|
| 146 | + } elseif (isset($area['icon'])) |
|
| 138 | 147 | { |
| 139 | - if ((substr($area['icon'], -4) === '.png' || substr($area['icon'], -4) === '.gif') && file_exists($settings['theme_dir'] . '/images/admin/big/' . $area['icon'])) |
|
| 140 | - $menu_context['sections'][$section_id]['areas'][$area_id]['icon_file'] = $settings['theme_url'] . '/images/admin/big/' . $area['icon']; |
|
| 141 | - elseif ((substr($area['icon'], -4) === '.png' || substr($area['icon'], -4) === '.gif') && file_exists($settings['default_theme_dir'] . '/images/admin/big/' . $area['icon'])) |
|
| 142 | - $menu_context['sections'][$section_id]['areas'][$area_id]['icon_file'] = $settings['default_theme_url'] . '/images/admin/big/' . $area['icon']; |
|
| 148 | + if ((substr($area['icon'], -4) === '.png' || substr($area['icon'], -4) === '.gif') && file_exists($settings['theme_dir'] . '/images/admin/big/' . $area['icon'])) { |
|
| 149 | + $menu_context['sections'][$section_id]['areas'][$area_id]['icon_file'] = $settings['theme_url'] . '/images/admin/big/' . $area['icon']; |
|
| 150 | + } elseif ((substr($area['icon'], -4) === '.png' || substr($area['icon'], -4) === '.gif') && file_exists($settings['default_theme_dir'] . '/images/admin/big/' . $area['icon'])) { |
|
| 151 | + $menu_context['sections'][$section_id]['areas'][$area_id]['icon_file'] = $settings['default_theme_url'] . '/images/admin/big/' . $area['icon']; |
|
| 152 | + } |
|
| 143 | 153 | |
| 144 | 154 | $menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . str_replace(array('.png', '.gif'), '', $area['icon']); |
| 155 | + } else { |
|
| 156 | + $menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . str_replace(array('.png', '.gif'), '', $area_id); |
|
| 145 | 157 | } |
| 146 | - else |
|
| 147 | - $menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . str_replace(array('.png', '.gif'), '', $area_id); |
|
| 148 | 158 | |
| 149 | 159 | // Some areas may be listed but not active, which we show as greyed out. |
| 150 | 160 | $menu_context['sections'][$section_id]['areas'][$area_id]['inactive'] = !empty($area['inactive']); |
@@ -158,35 +168,41 @@ discard block |
||
| 158 | 168 | { |
| 159 | 169 | if ((empty($sub[1]) || allowedTo($sub[1])) && (!isset($sub['enabled']) || !empty($sub['enabled']))) |
| 160 | 170 | { |
| 161 | - if ($first_sa == null) |
|
| 162 | - $first_sa = $sa; |
|
| 171 | + if ($first_sa == null) { |
|
| 172 | + $first_sa = $sa; |
|
| 173 | + } |
|
| 163 | 174 | |
| 164 | 175 | $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa] = array('label' => $sub[0]); |
| 165 | 176 | // Custom URL? |
| 166 | - if (isset($sub['url'])) |
|
| 167 | - $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['url'] = $sub['url']; |
|
| 177 | + if (isset($sub['url'])) { |
|
| 178 | + $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['url'] = $sub['url']; |
|
| 179 | + } |
|
| 168 | 180 | |
| 169 | 181 | // A bit complicated - but is this set? |
| 170 | 182 | if ($menu_context['current_area'] == $area_id) |
| 171 | 183 | { |
| 172 | 184 | // Save which is the first... |
| 173 | - if (empty($first_sa)) |
|
| 174 | - $first_sa = $sa; |
|
| 185 | + if (empty($first_sa)) { |
|
| 186 | + $first_sa = $sa; |
|
| 187 | + } |
|
| 175 | 188 | |
| 176 | 189 | // Is this the current subsection? |
| 177 | - if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == $sa) |
|
| 178 | - $menu_context['current_subsection'] = $sa; |
|
| 190 | + if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == $sa) { |
|
| 191 | + $menu_context['current_subsection'] = $sa; |
|
| 192 | + } |
|
| 179 | 193 | // Otherwise is it the default? |
| 180 | - elseif (!isset($menu_context['current_subsection']) && !empty($sub[2])) |
|
| 181 | - $menu_context['current_subsection'] = $sa; |
|
| 194 | + elseif (!isset($menu_context['current_subsection']) && !empty($sub[2])) { |
|
| 195 | + $menu_context['current_subsection'] = $sa; |
|
| 196 | + } |
|
| 182 | 197 | } |
| 183 | 198 | |
| 184 | 199 | // Let's assume this is the last, for now. |
| 185 | 200 | $last_sa = $sa; |
| 186 | 201 | } |
| 187 | 202 | // Mark it as disabled... |
| 188 | - else |
|
| 189 | - $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['disabled'] = true; |
|
| 203 | + else { |
|
| 204 | + $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['disabled'] = true; |
|
| 205 | + } |
|
| 190 | 206 | } |
| 191 | 207 | |
| 192 | 208 | // Set which one is first, last and selected in the group. |
@@ -195,8 +211,9 @@ discard block |
||
| 195 | 211 | $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$context['right_to_left'] ? $last_sa : $first_sa]['is_first'] = true; |
| 196 | 212 | $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$context['right_to_left'] ? $first_sa : $last_sa]['is_last'] = true; |
| 197 | 213 | |
| 198 | - if ($menu_context['current_area'] == $area_id && !isset($menu_context['current_subsection'])) |
|
| 199 | - $menu_context['current_subsection'] = $first_sa; |
|
| 214 | + if ($menu_context['current_area'] == $area_id && !isset($menu_context['current_subsection'])) { |
|
| 215 | + $menu_context['current_subsection'] = $first_sa; |
|
| 216 | + } |
|
| 200 | 217 | } |
| 201 | 218 | } |
| 202 | 219 | } |
@@ -230,23 +247,26 @@ discard block |
||
| 230 | 247 | $menu_context['base_url'] = isset($menuOptions['base_url']) ? $menuOptions['base_url'] : $scripturl . '?action=' . $menu_context['current_action']; |
| 231 | 248 | |
| 232 | 249 | // If we didn't find the area we were looking for go to a default one. |
| 233 | - if (isset($backup_area) && empty($found_section)) |
|
| 234 | - $menu_context['current_area'] = $backup_area; |
|
| 250 | + if (isset($backup_area) && empty($found_section)) { |
|
| 251 | + $menu_context['current_area'] = $backup_area; |
|
| 252 | + } |
|
| 235 | 253 | |
| 236 | 254 | // If there are sections quickly goes through all the sections to check if the base menu has an url |
| 237 | 255 | if (!empty($menu_context['current_section'])) |
| 238 | 256 | { |
| 239 | 257 | $menu_context['sections'][$menu_context['current_section']]['selected'] = true; |
| 240 | 258 | $menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['selected'] = true; |
| 241 | - if (!empty($menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']])) |
|
| 242 | - $menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']]['selected'] = true; |
|
| 259 | + if (!empty($menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']])) { |
|
| 260 | + $menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']]['selected'] = true; |
|
| 261 | + } |
|
| 243 | 262 | |
| 244 | - foreach ($menu_context['sections'] as $section_id => $section) |
|
| 245 | - foreach ($section['areas'] as $area_id => $area) |
|
| 263 | + foreach ($menu_context['sections'] as $section_id => $section) { |
|
| 264 | + foreach ($section['areas'] as $area_id => $area) |
|
| 246 | 265 | { |
| 247 | 266 | if (!isset($menu_context['sections'][$section_id]['url'])) |
| 248 | 267 | { |
| 249 | 268 | $menu_context['sections'][$section_id]['url'] = isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $area_id; |
| 269 | + } |
|
| 250 | 270 | break; |
| 251 | 271 | } |
| 252 | 272 | } |
@@ -257,8 +277,9 @@ discard block |
||
| 257 | 277 | { |
| 258 | 278 | // Never happened! |
| 259 | 279 | $context['max_menu_id']--; |
| 260 | - if ($context['max_menu_id'] == 0) |
|
| 261 | - unset($context['max_menu_id']); |
|
| 280 | + if ($context['max_menu_id'] == 0) { |
|
| 281 | + unset($context['max_menu_id']); |
|
| 282 | + } |
|
| 262 | 283 | |
| 263 | 284 | return false; |
| 264 | 285 | } |
@@ -269,8 +290,9 @@ discard block |
||
| 269 | 290 | $context['template_layers'][] = $menu_context['layer_name']; |
| 270 | 291 | |
| 271 | 292 | // Check we had something - for sanity sake. |
| 272 | - if (empty($include_data)) |
|
| 273 | - return false; |
|
| 293 | + if (empty($include_data)) { |
|
| 294 | + return false; |
|
| 295 | + } |
|
| 274 | 296 | |
| 275 | 297 | // Finally - return information on the selected item. |
| 276 | 298 | $include_data += array( |
@@ -293,12 +315,14 @@ discard block |
||
| 293 | 315 | global $context; |
| 294 | 316 | |
| 295 | 317 | $menu_name = $menu_id == 'last' && isset($context['max_menu_id']) && isset($context['menu_data_' . $context['max_menu_id']]) ? 'menu_data_' . $context['max_menu_id'] : 'menu_data_' . $menu_id; |
| 296 | - if (!isset($context[$menu_name])) |
|
| 297 | - return false; |
|
| 318 | + if (!isset($context[$menu_name])) { |
|
| 319 | + return false; |
|
| 320 | + } |
|
| 298 | 321 | |
| 299 | 322 | $layer_index = array_search($context[$menu_name]['layer_name'], $context['template_layers']); |
| 300 | - if ($layer_index !== false) |
|
| 301 | - unset($context['template_layers'][$layer_index]); |
|
| 323 | + if ($layer_index !== false) { |
|
| 324 | + unset($context['template_layers'][$layer_index]); |
|
| 325 | + } |
|
| 302 | 326 | |
| 303 | 327 | unset($context[$menu_name]); |
| 304 | 328 | } |
@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 4 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('No direct access...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Converts the given UTF-8 string into lowercase. |
@@ -575,8 +576,8 @@ discard block |
||
| 575 | 576 | if (safe_unserialize($row['extra']) === false && preg_match('~^(a:3:{s:5:"topic";i:\d+;s:7:"subject";s:)(\d+):"(.+)"(;s:6:"member";s:5:"\d+";})$~', $row['extra'], $matches) === 1) |
| 576 | 577 | { |
| 577 | 578 | $temp = $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4]; |
| 578 | - if (safe_unserialize($temp) !== false) |
|
| 579 | - $smcFunc['db_query']('', ' |
|
| 579 | + if (safe_unserialize($temp) !== false) { |
|
| 580 | + $smcFunc['db_query']('', ' |
|
| 580 | 581 | UPDATE {db_prefix}log_actions |
| 581 | 582 | SET extra = {string:extra} |
| 582 | 583 | WHERE id_action = {int:current_action}', |
@@ -585,6 +586,7 @@ discard block |
||
| 585 | 586 | 'extra' => json_encode(safe_unserialize($temp)), |
| 586 | 587 | ) |
| 587 | 588 | ); |
| 589 | + } |
|
| 588 | 590 | } |
| 589 | 591 | } |
| 590 | 592 | $smcFunc['db_free_result']($request); |
@@ -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 | * Show the calendar. |
@@ -47,12 +48,14 @@ discard block |
||
| 47 | 48 | 'post' => 'CalendarPost', |
| 48 | 49 | ); |
| 49 | 50 | |
| 50 | - if (isset($_GET['sa']) && isset($subActions[$_GET['sa']])) |
|
| 51 | - return call_helper($subActions[$_GET['sa']]); |
|
| 51 | + if (isset($_GET['sa']) && isset($subActions[$_GET['sa']])) { |
|
| 52 | + return call_helper($subActions[$_GET['sa']]); |
|
| 53 | + } |
|
| 52 | 54 | |
| 53 | 55 | // You can't do anything if the calendar is off. |
| 54 | - if (empty($modSettings['cal_enabled'])) |
|
| 55 | - fatal_lang_error('calendar_off', false); |
|
| 56 | + if (empty($modSettings['cal_enabled'])) { |
|
| 57 | + fatal_lang_error('calendar_off', false); |
|
| 58 | + } |
|
| 56 | 59 | |
| 57 | 60 | // This is gonna be needed... |
| 58 | 61 | loadTemplate('Calendar'); |
@@ -88,22 +91,25 @@ discard block |
||
| 88 | 91 | $context['page_title'] = $txt['calendar']; |
| 89 | 92 | |
| 90 | 93 | // Ensure a default view is defined |
| 91 | - if (empty($modSettings['calendar_default_view'])) |
|
| 92 | - $modSettings['calendar_default_view'] = 'viewlist'; |
|
| 94 | + if (empty($modSettings['calendar_default_view'])) { |
|
| 95 | + $modSettings['calendar_default_view'] = 'viewlist'; |
|
| 96 | + } |
|
| 93 | 97 | |
| 94 | 98 | // What view do we want? |
| 95 | - if (isset($_GET['viewweek'])) |
|
| 96 | - $context['calendar_view'] = 'viewweek'; |
|
| 97 | - elseif (isset($_GET['viewmonth'])) |
|
| 98 | - $context['calendar_view'] = 'viewmonth'; |
|
| 99 | - elseif (isset($_GET['viewlist'])) |
|
| 100 | - $context['calendar_view'] = 'viewlist'; |
|
| 101 | - else |
|
| 102 | - $context['calendar_view'] = $modSettings['calendar_default_view']; |
|
| 99 | + if (isset($_GET['viewweek'])) { |
|
| 100 | + $context['calendar_view'] = 'viewweek'; |
|
| 101 | + } elseif (isset($_GET['viewmonth'])) { |
|
| 102 | + $context['calendar_view'] = 'viewmonth'; |
|
| 103 | + } elseif (isset($_GET['viewlist'])) { |
|
| 104 | + $context['calendar_view'] = 'viewlist'; |
|
| 105 | + } else { |
|
| 106 | + $context['calendar_view'] = $modSettings['calendar_default_view']; |
|
| 107 | + } |
|
| 103 | 108 | |
| 104 | 109 | // Don't let search engines index the non-default calendar pages |
| 105 | - if ($context['calendar_view'] !== $modSettings['calendar_default_view']) |
|
| 106 | - $context['robot_no_index'] = true; |
|
| 110 | + if ($context['calendar_view'] !== $modSettings['calendar_default_view']) { |
|
| 111 | + $context['robot_no_index'] = true; |
|
| 112 | + } |
|
| 107 | 113 | |
| 108 | 114 | // Get the current day of month... |
| 109 | 115 | require_once($sourcedir . '/Subs-Calendar.php'); |
@@ -164,16 +170,19 @@ discard block |
||
| 164 | 170 | ); |
| 165 | 171 | |
| 166 | 172 | // Make sure the year and month are in valid ranges. |
| 167 | - if ($curPage['month'] < 1 || $curPage['month'] > 12) |
|
| 168 | - fatal_lang_error('invalid_month', false); |
|
| 169 | - if ($curPage['year'] < $modSettings['cal_minyear'] || $curPage['year'] > $modSettings['cal_maxyear']) |
|
| 170 | - fatal_lang_error('invalid_year', false); |
|
| 173 | + if ($curPage['month'] < 1 || $curPage['month'] > 12) { |
|
| 174 | + fatal_lang_error('invalid_month', false); |
|
| 175 | + } |
|
| 176 | + if ($curPage['year'] < $modSettings['cal_minyear'] || $curPage['year'] > $modSettings['cal_maxyear']) { |
|
| 177 | + fatal_lang_error('invalid_year', false); |
|
| 178 | + } |
|
| 171 | 179 | // If we have a day clean that too. |
| 172 | 180 | if ($context['calendar_view'] != 'viewmonth') |
| 173 | 181 | { |
| 174 | 182 | $isValid = checkdate($curPage['month'], $curPage['day'], $curPage['year']); |
| 175 | - if (!$isValid) |
|
| 176 | - fatal_lang_error('invalid_day', false); |
|
| 183 | + if (!$isValid) { |
|
| 184 | + fatal_lang_error('invalid_day', false); |
|
| 185 | + } |
|
| 177 | 186 | } |
| 178 | 187 | |
| 179 | 188 | // Load all the context information needed to show the calendar grid. |
@@ -195,23 +204,26 @@ discard block |
||
| 195 | 204 | ); |
| 196 | 205 | |
| 197 | 206 | // Load up the main view. |
| 198 | - if ($context['calendar_view'] == 'viewlist') |
|
| 199 | - $context['calendar_grid_main'] = getCalendarList($curPage['start_date'], $curPage['end_date'], $calendarOptions); |
|
| 200 | - elseif ($context['calendar_view'] == 'viewweek') |
|
| 201 | - $context['calendar_grid_main'] = getCalendarWeek($curPage['month'], $curPage['year'], $curPage['day'], $calendarOptions); |
|
| 202 | - else |
|
| 203 | - $context['calendar_grid_main'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions); |
|
| 207 | + if ($context['calendar_view'] == 'viewlist') { |
|
| 208 | + $context['calendar_grid_main'] = getCalendarList($curPage['start_date'], $curPage['end_date'], $calendarOptions); |
|
| 209 | + } elseif ($context['calendar_view'] == 'viewweek') { |
|
| 210 | + $context['calendar_grid_main'] = getCalendarWeek($curPage['month'], $curPage['year'], $curPage['day'], $calendarOptions); |
|
| 211 | + } else { |
|
| 212 | + $context['calendar_grid_main'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions); |
|
| 213 | + } |
|
| 204 | 214 | |
| 205 | 215 | // Load up the previous and next months. |
| 206 | 216 | $context['calendar_grid_current'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions); |
| 207 | 217 | |
| 208 | 218 | // Only show previous month if it isn't pre-January of the min-year |
| 209 | - if ($context['calendar_grid_current']['previous_calendar']['year'] > $modSettings['cal_minyear'] || $curPage['month'] != 1) |
|
| 210 | - $context['calendar_grid_prev'] = getCalendarGrid($context['calendar_grid_current']['previous_calendar']['month'], $context['calendar_grid_current']['previous_calendar']['year'], $calendarOptions, true); |
|
| 219 | + if ($context['calendar_grid_current']['previous_calendar']['year'] > $modSettings['cal_minyear'] || $curPage['month'] != 1) { |
|
| 220 | + $context['calendar_grid_prev'] = getCalendarGrid($context['calendar_grid_current']['previous_calendar']['month'], $context['calendar_grid_current']['previous_calendar']['year'], $calendarOptions, true); |
|
| 221 | + } |
|
| 211 | 222 | |
| 212 | 223 | // Only show next month if it isn't post-December of the max-year |
| 213 | - if ($context['calendar_grid_current']['next_calendar']['year'] < $modSettings['cal_maxyear'] || $curPage['month'] != 12) |
|
| 214 | - $context['calendar_grid_next'] = getCalendarGrid($context['calendar_grid_current']['next_calendar']['month'], $context['calendar_grid_current']['next_calendar']['year'], $calendarOptions); |
|
| 224 | + if ($context['calendar_grid_current']['next_calendar']['year'] < $modSettings['cal_maxyear'] || $curPage['month'] != 12) { |
|
| 225 | + $context['calendar_grid_next'] = getCalendarGrid($context['calendar_grid_current']['next_calendar']['month'], $context['calendar_grid_current']['next_calendar']['year'], $calendarOptions); |
|
| 226 | + } |
|
| 215 | 227 | |
| 216 | 228 | // Basic template stuff. |
| 217 | 229 | $context['allow_calendar_event'] = allowedTo('calendar_post'); |
@@ -231,8 +243,9 @@ discard block |
||
| 231 | 243 | $context['blocks_disabled'] = !empty($modSettings['cal_disable_prev_next']) ? 1 : 0; |
| 232 | 244 | |
| 233 | 245 | // Set the page title to mention the month or week, too |
| 234 | - if ($context['calendar_view'] != 'viewlist') |
|
| 235 | - $context['page_title'] .= ' - ' . ($context['calendar_view'] == 'viewweek' ? $context['calendar_grid_main']['week_title'] : $txt['months'][$context['current_month']] . ' ' . $context['current_year']); |
|
| 246 | + if ($context['calendar_view'] != 'viewlist') { |
|
| 247 | + $context['page_title'] .= ' - ' . ($context['calendar_view'] == 'viewweek' ? $context['calendar_grid_main']['week_title'] : $txt['months'][$context['current_month']] . ' ' . $context['current_year']); |
|
| 248 | + } |
|
| 236 | 249 | |
| 237 | 250 | // Load up the linktree! |
| 238 | 251 | $context['linktree'][] = array( |
@@ -245,17 +258,19 @@ discard block |
||
| 245 | 258 | 'name' => $txt['months'][$context['current_month']] . ' ' . $context['current_year'] |
| 246 | 259 | ); |
| 247 | 260 | // If applicable, add the current week to the linktree. |
| 248 | - if ($context['calendar_view'] == 'viewweek') |
|
| 249 | - $context['linktree'][] = array( |
|
| 261 | + if ($context['calendar_view'] == 'viewweek') { |
|
| 262 | + $context['linktree'][] = array( |
|
| 250 | 263 | 'url' => $scripturl . '?action=calendar;viewweek;year=' . $context['current_year'] . ';month=' . $context['current_month'] . ';day=' . $context['current_day'], |
| 251 | 264 | 'name' => $context['calendar_grid_main']['week_title'], |
| 252 | 265 | ); |
| 266 | + } |
|
| 253 | 267 | |
| 254 | 268 | // Build the calendar button array. |
| 255 | 269 | $context['calendar_buttons'] = array(); |
| 256 | 270 | |
| 257 | - if ($context['can_post']) |
|
| 258 | - $context['calendar_buttons']['post_event'] = array('text' => 'calendar_post_event', 'image' => 'calendarpe.png', 'url' => $scripturl . '?action=calendar;sa=post;month=' . $context['current_month'] . ';year=' . $context['current_year'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 271 | + if ($context['can_post']) { |
|
| 272 | + $context['calendar_buttons']['post_event'] = array('text' => 'calendar_post_event', 'image' => 'calendarpe.png', 'url' => $scripturl . '?action=calendar;sa=post;month=' . $context['current_month'] . ';year=' . $context['current_year'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 273 | + } |
|
| 259 | 274 | |
| 260 | 275 | // Allow mods to add additional buttons here |
| 261 | 276 | call_integration_hook('integrate_calendar_buttons'); |
@@ -284,14 +299,16 @@ discard block |
||
| 284 | 299 | require_once($sourcedir . '/Subs.php'); |
| 285 | 300 | |
| 286 | 301 | // Cast this for safety... |
| 287 | - if (isset($_REQUEST['eventid'])) |
|
| 288 | - $_REQUEST['eventid'] = (int) $_REQUEST['eventid']; |
|
| 302 | + if (isset($_REQUEST['eventid'])) { |
|
| 303 | + $_REQUEST['eventid'] = (int) $_REQUEST['eventid']; |
|
| 304 | + } |
|
| 289 | 305 | |
| 290 | 306 | // We want a fairly compact version of the time, but as close as possible to the user's settings. |
| 291 | - if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
| 292 | - $time_string = '%k:%M'; |
|
| 293 | - else |
|
| 294 | - $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
| 307 | + if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
| 308 | + $time_string = '%k:%M'; |
|
| 309 | + } else { |
|
| 310 | + $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
| 311 | + } |
|
| 295 | 312 | |
| 296 | 313 | $js_time_string = str_replace( |
| 297 | 314 | array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
@@ -305,12 +322,14 @@ discard block |
||
| 305 | 322 | checkSession(); |
| 306 | 323 | |
| 307 | 324 | // Validate the post... |
| 308 | - if (!isset($_POST['link_to_board'])) |
|
| 309 | - validateEventPost(); |
|
| 325 | + if (!isset($_POST['link_to_board'])) { |
|
| 326 | + validateEventPost(); |
|
| 327 | + } |
|
| 310 | 328 | |
| 311 | 329 | // If you're not allowed to edit any events, you have to be the poster. |
| 312 | - if ($_REQUEST['eventid'] > 0 && !allowedTo('calendar_edit_any')) |
|
| 313 | - isAllowedTo('calendar_edit_' . (!empty($user_info['id']) && getEventPoster($_REQUEST['eventid']) == $user_info['id'] ? 'own' : 'any')); |
|
| 330 | + if ($_REQUEST['eventid'] > 0 && !allowedTo('calendar_edit_any')) { |
|
| 331 | + isAllowedTo('calendar_edit_' . (!empty($user_info['id']) && getEventPoster($_REQUEST['eventid']) == $user_info['id'] ? 'own' : 'any')); |
|
| 332 | + } |
|
| 314 | 333 | |
| 315 | 334 | // New - and directing? |
| 316 | 335 | if (isset($_POST['link_to_board']) || empty($modSettings['cal_allow_unlinked'])) |
@@ -333,8 +352,9 @@ discard block |
||
| 333 | 352 | } |
| 334 | 353 | |
| 335 | 354 | // Deleting... |
| 336 | - elseif (isset($_REQUEST['deleteevent'])) |
|
| 337 | - removeEvent($_REQUEST['eventid']); |
|
| 355 | + elseif (isset($_REQUEST['deleteevent'])) { |
|
| 356 | + removeEvent($_REQUEST['eventid']); |
|
| 357 | + } |
|
| 338 | 358 | |
| 339 | 359 | // ... or just update it? |
| 340 | 360 | else |
@@ -357,15 +377,13 @@ discard block |
||
| 357 | 377 | $year = $d['year']; |
| 358 | 378 | $month = $d['month']; |
| 359 | 379 | $day = $d['day']; |
| 360 | - } |
|
| 361 | - elseif (isset($_POST['start_datetime'])) |
|
| 380 | + } elseif (isset($_POST['start_datetime'])) |
|
| 362 | 381 | { |
| 363 | 382 | $d = date_parse($_POST['start_datetime']); |
| 364 | 383 | $year = $d['year']; |
| 365 | 384 | $month = $d['month']; |
| 366 | 385 | $day = $d['day']; |
| 367 | - } |
|
| 368 | - else |
|
| 386 | + } else |
|
| 369 | 387 | { |
| 370 | 388 | $today = getdate(); |
| 371 | 389 | $year = isset($_POST['year']) ? $_POST['year'] : $today['year']; |
@@ -399,13 +417,13 @@ discard block |
||
| 399 | 417 | $context['event'] = array_merge($context['event'], $eventDatetimes); |
| 400 | 418 | |
| 401 | 419 | $context['event']['last_day'] = (int) strftime('%d', mktime(0, 0, 0, $context['event']['month'] == 12 ? 1 : $context['event']['month'] + 1, 0, $context['event']['month'] == 12 ? $context['event']['year'] + 1 : $context['event']['year'])); |
| 402 | - } |
|
| 403 | - else |
|
| 420 | + } else |
|
| 404 | 421 | { |
| 405 | 422 | $context['event'] = getEventProperties($_REQUEST['eventid']); |
| 406 | 423 | |
| 407 | - if ($context['event'] === false) |
|
| 408 | - fatal_lang_error('no_access', false); |
|
| 424 | + if ($context['event'] === false) { |
|
| 425 | + fatal_lang_error('no_access', false); |
|
| 426 | + } |
|
| 409 | 427 | |
| 410 | 428 | // If it has a board, then they should be editing it within the topic. |
| 411 | 429 | if (!empty($context['event']['topic']['id']) && !empty($context['event']['topic']['first_msg'])) |
@@ -416,10 +434,11 @@ discard block |
||
| 416 | 434 | } |
| 417 | 435 | |
| 418 | 436 | // Make sure the user is allowed to edit this event. |
| 419 | - if ($context['event']['member'] != $user_info['id']) |
|
| 420 | - isAllowedTo('calendar_edit_any'); |
|
| 421 | - elseif (!allowedTo('calendar_edit_any')) |
|
| 422 | - isAllowedTo('calendar_edit_own'); |
|
| 437 | + if ($context['event']['member'] != $user_info['id']) { |
|
| 438 | + isAllowedTo('calendar_edit_any'); |
|
| 439 | + } elseif (!allowedTo('calendar_edit_any')) { |
|
| 440 | + isAllowedTo('calendar_edit_own'); |
|
| 441 | + } |
|
| 423 | 442 | } |
| 424 | 443 | |
| 425 | 444 | // An all day event? Set up some nice defaults in case the user wants to change that |
@@ -453,8 +472,7 @@ discard block |
||
| 453 | 472 | { |
| 454 | 473 | // You can post new events but can't link them to anything... |
| 455 | 474 | $context['event']['categories'] = array(); |
| 456 | - } |
|
| 457 | - else |
|
| 475 | + } else |
|
| 458 | 476 | { |
| 459 | 477 | // Load the list of boards and categories in the context. |
| 460 | 478 | require_once($sourcedir . '/Subs-MessageIndex.php'); |
@@ -541,12 +559,14 @@ discard block |
||
| 541 | 559 | global $smcFunc, $sourcedir, $forum_version, $modSettings, $webmaster_email, $mbname; |
| 542 | 560 | |
| 543 | 561 | // You can't export if the calendar export feature is off. |
| 544 | - if (empty($modSettings['cal_export'])) |
|
| 545 | - fatal_lang_error('calendar_export_off', false); |
|
| 562 | + if (empty($modSettings['cal_export'])) { |
|
| 563 | + fatal_lang_error('calendar_export_off', false); |
|
| 564 | + } |
|
| 546 | 565 | |
| 547 | 566 | // Goes without saying that this is required. |
| 548 | - if (!isset($_REQUEST['eventid'])) |
|
| 549 | - fatal_lang_error('no_access', false); |
|
| 567 | + if (!isset($_REQUEST['eventid'])) { |
|
| 568 | + fatal_lang_error('no_access', false); |
|
| 569 | + } |
|
| 550 | 570 | |
| 551 | 571 | // This is kinda wanted. |
| 552 | 572 | require_once($sourcedir . '/Subs-Calendar.php'); |
@@ -554,15 +574,17 @@ discard block |
||
| 554 | 574 | // Load up the event in question and check it exists. |
| 555 | 575 | $event = getEventProperties($_REQUEST['eventid']); |
| 556 | 576 | |
| 557 | - if ($event === false) |
|
| 558 | - fatal_lang_error('no_access', false); |
|
| 577 | + if ($event === false) { |
|
| 578 | + fatal_lang_error('no_access', false); |
|
| 579 | + } |
|
| 559 | 580 | |
| 560 | 581 | // Check the title isn't too long - iCal requires some formatting if so. |
| 561 | 582 | $title = str_split($event['title'], 30); |
| 562 | 583 | foreach ($title as $id => $line) |
| 563 | 584 | { |
| 564 | - if ($id != 0) |
|
| 565 | - $title[$id] = ' ' . $title[$id]; |
|
| 585 | + if ($id != 0) { |
|
| 586 | + $title[$id] = ' ' . $title[$id]; |
|
| 587 | + } |
|
| 566 | 588 | $title[$id] .= "\n"; |
| 567 | 589 | } |
| 568 | 590 | |
@@ -575,8 +597,7 @@ discard block |
||
| 575 | 597 | { |
| 576 | 598 | $datestart = date_format($start_date, 'Ymd\THis'); |
| 577 | 599 | $dateend = date_format($end_date, 'Ymd\THis'); |
| 578 | - } |
|
| 579 | - else |
|
| 600 | + } else |
|
| 580 | 601 | { |
| 581 | 602 | $datestart = date_format($start_date, 'Ymd'); |
| 582 | 603 | |
@@ -597,15 +618,18 @@ discard block |
||
| 597 | 618 | $filecontents .= 'DTSTART' . (!empty($event['start_time']) ? ';TZID=' . $event['tz'] : ';VALUE=DATE') . ':' . $datestart . "\n"; |
| 598 | 619 | |
| 599 | 620 | // event has a duration |
| 600 | - if ($event['start_iso_gmdate'] != $event['end_iso_gmdate']) |
|
| 601 | - $filecontents .= 'DTEND' . (!empty($event['end_time']) ? ';TZID=' . $event['tz'] : ';VALUE=DATE') . ':' . $dateend . "\n"; |
|
| 621 | + if ($event['start_iso_gmdate'] != $event['end_iso_gmdate']) { |
|
| 622 | + $filecontents .= 'DTEND' . (!empty($event['end_time']) ? ';TZID=' . $event['tz'] : ';VALUE=DATE') . ':' . $dateend . "\n"; |
|
| 623 | + } |
|
| 602 | 624 | |
| 603 | 625 | // event has changed? advance the sequence for this UID |
| 604 | - if ($event['sequence'] > 0) |
|
| 605 | - $filecontents .= 'SEQUENCE:' . $event['sequence'] . "\n"; |
|
| 626 | + if ($event['sequence'] > 0) { |
|
| 627 | + $filecontents .= 'SEQUENCE:' . $event['sequence'] . "\n"; |
|
| 628 | + } |
|
| 606 | 629 | |
| 607 | - if (!empty($event['location'])) |
|
| 608 | - $filecontents .= 'LOCATION:' . str_replace(',', '\,', $event['location']) . "\n"; |
|
| 630 | + if (!empty($event['location'])) { |
|
| 631 | + $filecontents .= 'LOCATION:' . str_replace(',', '\,', $event['location']) . "\n"; |
|
| 632 | + } |
|
| 609 | 633 | |
| 610 | 634 | $filecontents .= 'SUMMARY:' . implode('', $title); |
| 611 | 635 | $filecontents .= 'UID:' . $event['eventid'] . '@' . str_replace(' ', '-', $mbname) . "\n"; |
@@ -614,23 +638,26 @@ discard block |
||
| 614 | 638 | |
| 615 | 639 | // Send some standard headers. |
| 616 | 640 | ob_end_clean(); |
| 617 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
| 618 | - @ob_start('ob_gzhandler'); |
|
| 619 | - else |
|
| 620 | - ob_start(); |
|
| 641 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
| 642 | + @ob_start('ob_gzhandler'); |
|
| 643 | + } else { |
|
| 644 | + ob_start(); |
|
| 645 | + } |
|
| 621 | 646 | |
| 622 | 647 | // Send the file headers |
| 623 | 648 | header('Pragma: '); |
| 624 | 649 | header('Cache-Control: no-cache'); |
| 625 | - if (!isBrowser('gecko')) |
|
| 626 | - header('Content-Transfer-Encoding: binary'); |
|
| 650 | + if (!isBrowser('gecko')) { |
|
| 651 | + header('Content-Transfer-Encoding: binary'); |
|
| 652 | + } |
|
| 627 | 653 | header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT'); |
| 628 | 654 | header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . 'GMT'); |
| 629 | 655 | header('Accept-Ranges: bytes'); |
| 630 | 656 | header('Connection: close'); |
| 631 | 657 | header('Content-Disposition: attachment; filename="' . $event['title'] . '.ics"'); |
| 632 | - if (empty($modSettings['enableCompressedOutput'])) |
|
| 633 | - header('Content-Length: ' . $smcFunc['strlen']($filecontents)); |
|
| 658 | + if (empty($modSettings['enableCompressedOutput'])) { |
|
| 659 | + header('Content-Length: ' . $smcFunc['strlen']($filecontents)); |
|
| 660 | + } |
|
| 634 | 661 | |
| 635 | 662 | // This is a calendar item! |
| 636 | 663 | header('Content-Type: text/calendar'); |
@@ -669,20 +696,17 @@ discard block |
||
| 669 | 696 | $context['sub_template'] = 'bcd'; |
| 670 | 697 | $context['linktree'][] = array('url' => $scripturl . '?action=clock;bcd', 'name' => 'BCD'); |
| 671 | 698 | $context['clockicons'] = smf_json_decode(base64_decode('eyJoMSI6WzIsMV0sImgyIjpbOCw0LDIsMV0sIm0xIjpbNCwyLDFdLCJtMiI6WzgsNCwyLDFdLCJzMSI6WzQsMiwxXSwiczIiOls4LDQsMiwxXX0='), true); |
| 672 | - } |
|
| 673 | - elseif (!$omfg && !isset($_REQUEST['time'])) |
|
| 699 | + } elseif (!$omfg && !isset($_REQUEST['time'])) |
|
| 674 | 700 | { |
| 675 | 701 | $context['sub_template'] = 'hms'; |
| 676 | 702 | $context['linktree'][] = array('url' => $scripturl . '?action=clock', 'name' => 'Binary'); |
| 677 | 703 | $context['clockicons'] = smf_json_decode(base64_decode('eyJoIjpbMTYsOCw0LDIsMV0sIm0iOlszMiwxNiw4LDQsMiwxXSwicyI6WzMyLDE2LDgsNCwyLDFdfQ'), true); |
| 678 | - } |
|
| 679 | - elseif ($omfg) |
|
| 704 | + } elseif ($omfg) |
|
| 680 | 705 | { |
| 681 | 706 | $context['sub_template'] = 'omfg'; |
| 682 | 707 | $context['linktree'][] = array('url' => $scripturl . '?action=clock;omfg', 'name' => 'OMFG'); |
| 683 | 708 | $context['clockicons'] = smf_json_decode(base64_decode('eyJ5ZWFyIjpbNjQsMzIsMTYsOCw0LDIsMV0sIm1vbnRoIjpbOCw0LDIsMV0sImRheSI6WzE2LDgsNCwyLDFdLCJob3VyIjpbMTYsOCw0LDIsMV0sIm1pbiI6WzMyLDE2LDgsNCwyLDFdLCJzZWMiOlszMiwxNiw4LDQsMiwxXX0='), true); |
| 684 | - } |
|
| 685 | - elseif (isset($_REQUEST['time'])) |
|
| 709 | + } elseif (isset($_REQUEST['time'])) |
|
| 686 | 710 | { |
| 687 | 711 | $context['sub_template'] = 'thetime'; |
| 688 | 712 | $time = getdate($_REQUEST['time'] == 'now' ? time() : (int) $_REQUEST['time']); |
@@ -736,12 +760,13 @@ discard block |
||
| 736 | 760 | ), |
| 737 | 761 | ); |
| 738 | 762 | |
| 739 | - foreach ($context['clockicons'] as $t => $vs) |
|
| 740 | - foreach ($vs as $v => $dumb) |
|
| 763 | + foreach ($context['clockicons'] as $t => $vs) { |
|
| 764 | + foreach ($vs as $v => $dumb) |
|
| 741 | 765 | { |
| 742 | 766 | if ($$t >= $v) |
| 743 | 767 | { |
| 744 | 768 | $$t -= $v; |
| 769 | + } |
|
| 745 | 770 | $context['clockicons'][$t][$v] = true; |
| 746 | 771 | } |
| 747 | 772 | } |
@@ -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. |
| 154 | 160 | error_reporting(E_ALL); |
@@ -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 | |
@@ -237,10 +246,11 @@ discard block |
||
| 237 | 246 | { |
| 238 | 247 | // Get PHP's default timezone, if set |
| 239 | 248 | $ini_tz = ini_get('date.timezone'); |
| 240 | - if (!empty($ini_tz)) |
|
| 241 | - $timezone_id = $ini_tz; |
|
| 242 | - else |
|
| 243 | - $timezone_id = ''; |
|
| 249 | + if (!empty($ini_tz)) { |
|
| 250 | + $timezone_id = $ini_tz; |
|
| 251 | + } else { |
|
| 252 | + $timezone_id = ''; |
|
| 253 | + } |
|
| 244 | 254 | |
| 245 | 255 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
| 246 | 256 | if (!in_array($timezone_id, timezone_identifiers_list())) |
@@ -270,8 +280,9 @@ discard block |
||
| 270 | 280 | $dir = dir(dirname(__FILE__) . '/Themes/default/languages'); |
| 271 | 281 | while ($entry = $dir->read()) |
| 272 | 282 | { |
| 273 | - if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') |
|
| 274 | - $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
| 283 | + if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') { |
|
| 284 | + $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
| 285 | + } |
|
| 275 | 286 | } |
| 276 | 287 | $dir->close(); |
| 277 | 288 | } |
@@ -306,10 +317,11 @@ discard block |
||
| 306 | 317 | } |
| 307 | 318 | |
| 308 | 319 | // Override the language file? |
| 309 | - if (isset($_GET['lang_file'])) |
|
| 310 | - $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
| 311 | - elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) |
|
| 312 | - $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
| 320 | + if (isset($_GET['lang_file'])) { |
|
| 321 | + $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
| 322 | + } elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) { |
|
| 323 | + $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
| 324 | + } |
|
| 313 | 325 | |
| 314 | 326 | // Make sure it exists, if it doesn't reset it. |
| 315 | 327 | 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'])) |
@@ -318,8 +330,9 @@ discard block |
||
| 318 | 330 | list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
| 319 | 331 | |
| 320 | 332 | // If we have english and some other language, use the other language. We Americans hate english :P. |
| 321 | - if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) |
|
| 322 | - list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
| 333 | + if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) { |
|
| 334 | + list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
| 335 | + } |
|
| 323 | 336 | } |
| 324 | 337 | |
| 325 | 338 | // And now include the actual language file itself. |
@@ -332,15 +345,18 @@ discard block |
||
| 332 | 345 | global $db_prefix, $db_connection, $sourcedir, $smcFunc, $modSettings; |
| 333 | 346 | global $db_server, $db_passwd, $db_type, $db_name, $db_user, $db_persist; |
| 334 | 347 | |
| 335 | - if (empty($sourcedir)) |
|
| 336 | - $sourcedir = dirname(__FILE__) . '/Sources'; |
|
| 348 | + if (empty($sourcedir)) { |
|
| 349 | + $sourcedir = dirname(__FILE__) . '/Sources'; |
|
| 350 | + } |
|
| 337 | 351 | |
| 338 | 352 | // Need this to check whether we need the database password. |
| 339 | 353 | require(dirname(__FILE__) . '/Settings.php'); |
| 340 | - if (!defined('SMF')) |
|
| 341 | - define('SMF', 1); |
|
| 342 | - if (empty($smcFunc)) |
|
| 343 | - $smcFunc = array(); |
|
| 354 | + if (!defined('SMF')) { |
|
| 355 | + define('SMF', 1); |
|
| 356 | + } |
|
| 357 | + if (empty($smcFunc)) { |
|
| 358 | + $smcFunc = array(); |
|
| 359 | + } |
|
| 344 | 360 | |
| 345 | 361 | $modSettings['disableQueryCheck'] = true; |
| 346 | 362 | |
@@ -348,8 +364,9 @@ discard block |
||
| 348 | 364 | if (!$db_connection) |
| 349 | 365 | { |
| 350 | 366 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
| 351 | - if (version_compare(PHP_VERSION, '5', '<')) |
|
| 352 | - require_once($sourcedir . '/Subs-Compat.php'); |
|
| 367 | + if (version_compare(PHP_VERSION, '5', '<')) { |
|
| 368 | + require_once($sourcedir . '/Subs-Compat.php'); |
|
| 369 | + } |
|
| 353 | 370 | |
| 354 | 371 | $db_options = array('persist' => $db_persist); |
| 355 | 372 | $port = ''; |
@@ -360,19 +377,20 @@ discard block |
||
| 360 | 377 | if ($db_type == 'mysql') |
| 361 | 378 | { |
| 362 | 379 | $port = ((int) $_POST['db_port'] == ini_get($db_type . 'default_port')) ? '' : (int) $_POST['db_port']; |
| 363 | - } |
|
| 364 | - elseif ($db_type == 'postgresql') |
|
| 380 | + } elseif ($db_type == 'postgresql') |
|
| 365 | 381 | { |
| 366 | 382 | // PostgreSQL doesn't have a default port setting in php.ini, so just check against the default |
| 367 | 383 | $port = ((int) $_POST['db_port'] == 5432) ? '' : (int) $_POST['db_port']; |
| 368 | 384 | } |
| 369 | 385 | } |
| 370 | 386 | |
| 371 | - if (!empty($port)) |
|
| 372 | - $db_options['port'] = $port; |
|
| 387 | + if (!empty($port)) { |
|
| 388 | + $db_options['port'] = $port; |
|
| 389 | + } |
|
| 373 | 390 | |
| 374 | - if (!$db_connection) |
|
| 375 | - $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options); |
|
| 391 | + if (!$db_connection) { |
|
| 392 | + $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options); |
|
| 393 | + } |
|
| 376 | 394 | } |
| 377 | 395 | } |
| 378 | 396 | |
@@ -400,8 +418,9 @@ discard block |
||
| 400 | 418 | // @todo REMOVE THIS!! |
| 401 | 419 | else |
| 402 | 420 | { |
| 403 | - if (function_exists('doStep' . $_GET['step'])) |
|
| 404 | - call_user_func('doStep' . $_GET['step']); |
|
| 421 | + if (function_exists('doStep' . $_GET['step'])) { |
|
| 422 | + call_user_func('doStep' . $_GET['step']); |
|
| 423 | + } |
|
| 405 | 424 | } |
| 406 | 425 | // Show the footer. |
| 407 | 426 | template_install_below(); |
@@ -419,8 +438,9 @@ discard block |
||
| 419 | 438 | $incontext['sub_template'] = 'welcome_message'; |
| 420 | 439 | |
| 421 | 440 | // Done the submission? |
| 422 | - if (isset($_POST['contbutt'])) |
|
| 423 | - return true; |
|
| 441 | + if (isset($_POST['contbutt'])) { |
|
| 442 | + return true; |
|
| 443 | + } |
|
| 424 | 444 | |
| 425 | 445 | // See if we think they have already installed it? |
| 426 | 446 | if (is_readable(dirname(__FILE__) . '/Settings.php')) |
@@ -428,14 +448,17 @@ discard block |
||
| 428 | 448 | $probably_installed = 0; |
| 429 | 449 | foreach (file(dirname(__FILE__) . '/Settings.php') as $line) |
| 430 | 450 | { |
| 431 | - if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) |
|
| 432 | - $probably_installed++; |
|
| 433 | - if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) |
|
| 434 | - $probably_installed++; |
|
| 451 | + if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) { |
|
| 452 | + $probably_installed++; |
|
| 453 | + } |
|
| 454 | + if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) { |
|
| 455 | + $probably_installed++; |
|
| 456 | + } |
|
| 435 | 457 | } |
| 436 | 458 | |
| 437 | - if ($probably_installed == 2) |
|
| 438 | - $incontext['warning'] = $txt['error_already_installed']; |
|
| 459 | + if ($probably_installed == 2) { |
|
| 460 | + $incontext['warning'] = $txt['error_already_installed']; |
|
| 461 | + } |
|
| 439 | 462 | } |
| 440 | 463 | |
| 441 | 464 | // Is some database support even compiled in? |
@@ -450,45 +473,54 @@ discard block |
||
| 450 | 473 | $databases[$key]['supported'] = false; |
| 451 | 474 | $notFoundSQLFile = true; |
| 452 | 475 | $txt['error_db_script_missing'] = sprintf($txt['error_db_script_missing'], 'install_' . $GLOBALS['db_script_version'] . '_' . $type . '.sql'); |
| 476 | + } else { |
|
| 477 | + $incontext['supported_databases'][] = $db; |
|
| 453 | 478 | } |
| 454 | - else |
|
| 455 | - $incontext['supported_databases'][] = $db; |
|
| 456 | 479 | } |
| 457 | 480 | } |
| 458 | 481 | |
| 459 | 482 | // Check the PHP version. |
| 460 | - if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>='))) |
|
| 461 | - $error = 'error_php_too_low'; |
|
| 483 | + if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>='))) { |
|
| 484 | + $error = 'error_php_too_low'; |
|
| 485 | + } |
|
| 462 | 486 | // Make sure we have a supported database |
| 463 | - elseif (empty($incontext['supported_databases'])) |
|
| 464 | - $error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing'; |
|
| 487 | + elseif (empty($incontext['supported_databases'])) { |
|
| 488 | + $error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing'; |
|
| 489 | + } |
|
| 465 | 490 | // How about session support? Some crazy sysadmin remove it? |
| 466 | - elseif (!function_exists('session_start')) |
|
| 467 | - $error = 'error_session_missing'; |
|
| 491 | + elseif (!function_exists('session_start')) { |
|
| 492 | + $error = 'error_session_missing'; |
|
| 493 | + } |
|
| 468 | 494 | // Make sure they uploaded all the files. |
| 469 | - elseif (!file_exists(dirname(__FILE__) . '/index.php')) |
|
| 470 | - $error = 'error_missing_files'; |
|
| 495 | + elseif (!file_exists(dirname(__FILE__) . '/index.php')) { |
|
| 496 | + $error = 'error_missing_files'; |
|
| 497 | + } |
|
| 471 | 498 | // Very simple check on the session.save_path for Windows. |
| 472 | 499 | // @todo Move this down later if they don't use database-driven sessions? |
| 473 | - elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') |
|
| 474 | - $error = 'error_session_save_path'; |
|
| 500 | + elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') { |
|
| 501 | + $error = 'error_session_save_path'; |
|
| 502 | + } |
|
| 475 | 503 | |
| 476 | 504 | // Since each of the three messages would look the same, anyway... |
| 477 | - if (isset($error)) |
|
| 478 | - $incontext['error'] = $txt[$error]; |
|
| 505 | + if (isset($error)) { |
|
| 506 | + $incontext['error'] = $txt[$error]; |
|
| 507 | + } |
|
| 479 | 508 | |
| 480 | 509 | // Mod_security blocks everything that smells funny. Let SMF handle security. |
| 481 | - if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) |
|
| 482 | - $incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again']; |
|
| 510 | + if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) { |
|
| 511 | + $incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again']; |
|
| 512 | + } |
|
| 483 | 513 | |
| 484 | 514 | // Confirm mbstring is loaded... |
| 485 | - if (!extension_loaded('mbstring')) |
|
| 486 | - $incontext['error'] = $txt['install_no_mbstring']; |
|
| 515 | + if (!extension_loaded('mbstring')) { |
|
| 516 | + $incontext['error'] = $txt['install_no_mbstring']; |
|
| 517 | + } |
|
| 487 | 518 | |
| 488 | 519 | // Check for https stream support. |
| 489 | 520 | $supported_streams = stream_get_wrappers(); |
| 490 | - if (!in_array('https', $supported_streams)) |
|
| 491 | - $incontext['warning'] = $txt['install_no_https']; |
|
| 521 | + if (!in_array('https', $supported_streams)) { |
|
| 522 | + $incontext['warning'] = $txt['install_no_https']; |
|
| 523 | + } |
|
| 492 | 524 | |
| 493 | 525 | return false; |
| 494 | 526 | } |
@@ -514,12 +546,14 @@ discard block |
||
| 514 | 546 | 'db_last_error.php', |
| 515 | 547 | ); |
| 516 | 548 | |
| 517 | - foreach ($incontext['detected_languages'] as $lang => $temp) |
|
| 518 | - $extra_files[] = 'Themes/default/languages/' . $lang; |
|
| 549 | + foreach ($incontext['detected_languages'] as $lang => $temp) { |
|
| 550 | + $extra_files[] = 'Themes/default/languages/' . $lang; |
|
| 551 | + } |
|
| 519 | 552 | |
| 520 | 553 | // With mod_security installed, we could attempt to fix it with .htaccess. |
| 521 | - if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) |
|
| 522 | - $writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.'; |
|
| 554 | + if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) { |
|
| 555 | + $writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.'; |
|
| 556 | + } |
|
| 523 | 557 | |
| 524 | 558 | $failed_files = array(); |
| 525 | 559 | |
@@ -531,20 +565,23 @@ discard block |
||
| 531 | 565 | foreach ($writable_files as $file) |
| 532 | 566 | { |
| 533 | 567 | // Some files won't exist, try to address up front |
| 534 | - if (!file_exists(dirname(__FILE__) . '/' . $file)) |
|
| 535 | - @touch(dirname(__FILE__) . '/' . $file); |
|
| 568 | + if (!file_exists(dirname(__FILE__) . '/' . $file)) { |
|
| 569 | + @touch(dirname(__FILE__) . '/' . $file); |
|
| 570 | + } |
|
| 536 | 571 | // NOW do the writable check... |
| 537 | 572 | if (!is_writable(dirname(__FILE__) . '/' . $file)) |
| 538 | 573 | { |
| 539 | 574 | @chmod(dirname(__FILE__) . '/' . $file, 0755); |
| 540 | 575 | |
| 541 | 576 | // Well, 755 hopefully worked... if not, try 777. |
| 542 | - if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) |
|
| 543 | - $failed_files[] = $file; |
|
| 577 | + if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) { |
|
| 578 | + $failed_files[] = $file; |
|
| 579 | + } |
|
| 544 | 580 | } |
| 545 | 581 | } |
| 546 | - foreach ($extra_files as $file) |
|
| 547 | - @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
| 582 | + foreach ($extra_files as $file) { |
|
| 583 | + @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
| 584 | + } |
|
| 548 | 585 | } |
| 549 | 586 | // Windows is trickier. Let's try opening for r+... |
| 550 | 587 | else |
@@ -554,30 +591,35 @@ discard block |
||
| 554 | 591 | foreach ($writable_files as $file) |
| 555 | 592 | { |
| 556 | 593 | // Folders can't be opened for write... but the index.php in them can ;) |
| 557 | - if (is_dir(dirname(__FILE__) . '/' . $file)) |
|
| 558 | - $file .= '/index.php'; |
|
| 594 | + if (is_dir(dirname(__FILE__) . '/' . $file)) { |
|
| 595 | + $file .= '/index.php'; |
|
| 596 | + } |
|
| 559 | 597 | |
| 560 | 598 | // Funny enough, chmod actually does do something on windows - it removes the read only attribute. |
| 561 | 599 | @chmod(dirname(__FILE__) . '/' . $file, 0777); |
| 562 | 600 | $fp = @fopen(dirname(__FILE__) . '/' . $file, 'r+'); |
| 563 | 601 | |
| 564 | 602 | // Hmm, okay, try just for write in that case... |
| 565 | - if (!is_resource($fp)) |
|
| 566 | - $fp = @fopen(dirname(__FILE__) . '/' . $file, 'w'); |
|
| 603 | + if (!is_resource($fp)) { |
|
| 604 | + $fp = @fopen(dirname(__FILE__) . '/' . $file, 'w'); |
|
| 605 | + } |
|
| 567 | 606 | |
| 568 | - if (!is_resource($fp)) |
|
| 569 | - $failed_files[] = $file; |
|
| 607 | + if (!is_resource($fp)) { |
|
| 608 | + $failed_files[] = $file; |
|
| 609 | + } |
|
| 570 | 610 | |
| 571 | 611 | @fclose($fp); |
| 572 | 612 | } |
| 573 | - foreach ($extra_files as $file) |
|
| 574 | - @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
| 613 | + foreach ($extra_files as $file) { |
|
| 614 | + @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
| 615 | + } |
|
| 575 | 616 | } |
| 576 | 617 | |
| 577 | 618 | $failure = count($failed_files) >= 1; |
| 578 | 619 | |
| 579 | - if (!isset($_SERVER)) |
|
| 580 | - return !$failure; |
|
| 620 | + if (!isset($_SERVER)) { |
|
| 621 | + return !$failure; |
|
| 622 | + } |
|
| 581 | 623 | |
| 582 | 624 | // Put the list into context. |
| 583 | 625 | $incontext['failed_files'] = $failed_files; |
@@ -625,19 +667,23 @@ discard block |
||
| 625 | 667 | |
| 626 | 668 | if (!isset($ftp) || $ftp->error !== false) |
| 627 | 669 | { |
| 628 | - if (!isset($ftp)) |
|
| 629 | - $ftp = new ftp_connection(null); |
|
| 670 | + if (!isset($ftp)) { |
|
| 671 | + $ftp = new ftp_connection(null); |
|
| 672 | + } |
|
| 630 | 673 | // Save the error so we can mess with listing... |
| 631 | - elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) |
|
| 632 | - $incontext['ftp_errors'][] = $ftp->last_message; |
|
| 674 | + elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) { |
|
| 675 | + $incontext['ftp_errors'][] = $ftp->last_message; |
|
| 676 | + } |
|
| 633 | 677 | |
| 634 | 678 | list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__)); |
| 635 | 679 | |
| 636 | - if (empty($_POST['ftp_path']) && $found_path) |
|
| 637 | - $_POST['ftp_path'] = $detect_path; |
|
| 680 | + if (empty($_POST['ftp_path']) && $found_path) { |
|
| 681 | + $_POST['ftp_path'] = $detect_path; |
|
| 682 | + } |
|
| 638 | 683 | |
| 639 | - if (!isset($_POST['ftp_username'])) |
|
| 640 | - $_POST['ftp_username'] = $username; |
|
| 684 | + if (!isset($_POST['ftp_username'])) { |
|
| 685 | + $_POST['ftp_username'] = $username; |
|
| 686 | + } |
|
| 641 | 687 | |
| 642 | 688 | // Set the username etc, into context. |
| 643 | 689 | $incontext['ftp'] = array( |
@@ -649,8 +695,7 @@ discard block |
||
| 649 | 695 | ); |
| 650 | 696 | |
| 651 | 697 | return false; |
| 652 | - } |
|
| 653 | - else |
|
| 698 | + } else |
|
| 654 | 699 | { |
| 655 | 700 | $_SESSION['installer_temp_ftp'] = array( |
| 656 | 701 | 'server' => $_POST['ftp_server'], |
@@ -664,10 +709,12 @@ discard block |
||
| 664 | 709 | |
| 665 | 710 | foreach ($failed_files as $file) |
| 666 | 711 | { |
| 667 | - if (!is_writable(dirname(__FILE__) . '/' . $file)) |
|
| 668 | - $ftp->chmod($file, 0755); |
|
| 669 | - if (!is_writable(dirname(__FILE__) . '/' . $file)) |
|
| 670 | - $ftp->chmod($file, 0777); |
|
| 712 | + if (!is_writable(dirname(__FILE__) . '/' . $file)) { |
|
| 713 | + $ftp->chmod($file, 0755); |
|
| 714 | + } |
|
| 715 | + if (!is_writable(dirname(__FILE__) . '/' . $file)) { |
|
| 716 | + $ftp->chmod($file, 0777); |
|
| 717 | + } |
|
| 671 | 718 | if (!is_writable(dirname(__FILE__) . '/' . $file)) |
| 672 | 719 | { |
| 673 | 720 | $failed_files_updated[] = $file; |
@@ -723,15 +770,17 @@ discard block |
||
| 723 | 770 | |
| 724 | 771 | if (!$foundOne) |
| 725 | 772 | { |
| 726 | - if (isset($db['default_host'])) |
|
| 727 | - $incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost'; |
|
| 773 | + if (isset($db['default_host'])) { |
|
| 774 | + $incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost'; |
|
| 775 | + } |
|
| 728 | 776 | if (isset($db['default_user'])) |
| 729 | 777 | { |
| 730 | 778 | $incontext['db']['user'] = ini_get($db['default_user']); |
| 731 | 779 | $incontext['db']['name'] = ini_get($db['default_user']); |
| 732 | 780 | } |
| 733 | - if (isset($db['default_password'])) |
|
| 734 | - $incontext['db']['pass'] = ini_get($db['default_password']); |
|
| 781 | + if (isset($db['default_password'])) { |
|
| 782 | + $incontext['db']['pass'] = ini_get($db['default_password']); |
|
| 783 | + } |
|
| 735 | 784 | |
| 736 | 785 | // For simplicity and less confusion, leave the port blank by default |
| 737 | 786 | $incontext['db']['port'] = ''; |
@@ -750,10 +799,10 @@ discard block |
||
| 750 | 799 | $incontext['db']['server'] = $_POST['db_server']; |
| 751 | 800 | $incontext['db']['prefix'] = $_POST['db_prefix']; |
| 752 | 801 | |
| 753 | - if (!empty($_POST['db_port'])) |
|
| 754 | - $incontext['db']['port'] = $_POST['db_port']; |
|
| 755 | - } |
|
| 756 | - else |
|
| 802 | + if (!empty($_POST['db_port'])) { |
|
| 803 | + $incontext['db']['port'] = $_POST['db_port']; |
|
| 804 | + } |
|
| 805 | + } else |
|
| 757 | 806 | { |
| 758 | 807 | $incontext['db']['prefix'] = 'smf_'; |
| 759 | 808 | } |
@@ -789,10 +838,11 @@ discard block |
||
| 789 | 838 | if (!empty($_POST['db_port'])) |
| 790 | 839 | { |
| 791 | 840 | // For MySQL, we can get the "default port" from PHP. PostgreSQL has no such option though. |
| 792 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) |
|
| 793 | - $vars['db_port'] = (int) $_POST['db_port']; |
|
| 794 | - elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) |
|
| 795 | - $vars['db_port'] = (int) $_POST['db_port']; |
|
| 841 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) { |
|
| 842 | + $vars['db_port'] = (int) $_POST['db_port']; |
|
| 843 | + } elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) { |
|
| 844 | + $vars['db_port'] = (int) $_POST['db_port']; |
|
| 845 | + } |
|
| 796 | 846 | } |
| 797 | 847 | |
| 798 | 848 | // God I hope it saved! |
@@ -805,8 +855,9 @@ discard block |
||
| 805 | 855 | // Make sure it works. |
| 806 | 856 | require(dirname(__FILE__) . '/Settings.php'); |
| 807 | 857 | |
| 808 | - if (empty($sourcedir)) |
|
| 809 | - $sourcedir = dirname(__FILE__) . '/Sources'; |
|
| 858 | + if (empty($sourcedir)) { |
|
| 859 | + $sourcedir = dirname(__FILE__) . '/Sources'; |
|
| 860 | + } |
|
| 810 | 861 | |
| 811 | 862 | // Better find the database file! |
| 812 | 863 | if (!file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
@@ -816,18 +867,21 @@ discard block |
||
| 816 | 867 | } |
| 817 | 868 | |
| 818 | 869 | // Now include it for database functions! |
| 819 | - if (!defined('SMF')) |
|
| 820 | - define('SMF', 1); |
|
| 870 | + if (!defined('SMF')) { |
|
| 871 | + define('SMF', 1); |
|
| 872 | + } |
|
| 821 | 873 | |
| 822 | 874 | $modSettings['disableQueryCheck'] = true; |
| 823 | - if (empty($smcFunc)) |
|
| 824 | - $smcFunc = array(); |
|
| 875 | + if (empty($smcFunc)) { |
|
| 876 | + $smcFunc = array(); |
|
| 877 | + } |
|
| 825 | 878 | |
| 826 | 879 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
| 827 | 880 | |
| 828 | 881 | // What - running PHP4? The shame! |
| 829 | - if (version_compare(PHP_VERSION, '5', '<')) |
|
| 830 | - require_once($sourcedir . '/Subs-Compat.php'); |
|
| 882 | + if (version_compare(PHP_VERSION, '5', '<')) { |
|
| 883 | + require_once($sourcedir . '/Subs-Compat.php'); |
|
| 884 | + } |
|
| 831 | 885 | |
| 832 | 886 | // Attempt a connection. |
| 833 | 887 | $needsDB = !empty($databases[$db_type]['always_has_db']); |
@@ -915,12 +969,14 @@ discard block |
||
| 915 | 969 | $incontext['page_title'] = $txt['install_settings']; |
| 916 | 970 | |
| 917 | 971 | // Let's see if we got the database type correct. |
| 918 | - if (isset($_POST['db_type'], $databases[$_POST['db_type']])) |
|
| 919 | - $db_type = $_POST['db_type']; |
|
| 972 | + if (isset($_POST['db_type'], $databases[$_POST['db_type']])) { |
|
| 973 | + $db_type = $_POST['db_type']; |
|
| 974 | + } |
|
| 920 | 975 | |
| 921 | 976 | // Else we'd better be able to get the connection. |
| 922 | - else |
|
| 923 | - load_database(); |
|
| 977 | + else { |
|
| 978 | + load_database(); |
|
| 979 | + } |
|
| 924 | 980 | |
| 925 | 981 | $db_type = isset($_POST['db_type']) ? $_POST['db_type'] : $db_type; |
| 926 | 982 | |
@@ -940,12 +996,14 @@ discard block |
||
| 940 | 996 | // Submitting? |
| 941 | 997 | if (isset($_POST['boardurl'])) |
| 942 | 998 | { |
| 943 | - if (substr($_POST['boardurl'], -10) == '/index.php') |
|
| 944 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
| 945 | - elseif (substr($_POST['boardurl'], -1) == '/') |
|
| 946 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
| 947 | - if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') |
|
| 948 | - $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
| 999 | + if (substr($_POST['boardurl'], -10) == '/index.php') { |
|
| 1000 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
| 1001 | + } elseif (substr($_POST['boardurl'], -1) == '/') { |
|
| 1002 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
| 1003 | + } |
|
| 1004 | + if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') { |
|
| 1005 | + $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
| 1006 | + } |
|
| 949 | 1007 | |
| 950 | 1008 | // Save these variables. |
| 951 | 1009 | $vars = array( |
@@ -984,10 +1042,10 @@ discard block |
||
| 984 | 1042 | { |
| 985 | 1043 | $incontext['error'] = sprintf($txt['error_utf8_version'], $databases[$db_type]['utf8_version']); |
| 986 | 1044 | return false; |
| 987 | - } |
|
| 988 | - else |
|
| 989 | - // Set the character set here. |
|
| 1045 | + } else { |
|
| 1046 | + // Set the character set here. |
|
| 990 | 1047 | updateSettingsFile(array('db_character_set' => 'utf8')); |
| 1048 | + } |
|
| 991 | 1049 | } |
| 992 | 1050 | |
| 993 | 1051 | // Good, skip on. |
@@ -1007,8 +1065,9 @@ discard block |
||
| 1007 | 1065 | $incontext['continue'] = 1; |
| 1008 | 1066 | |
| 1009 | 1067 | // Already done? |
| 1010 | - if (isset($_POST['pop_done'])) |
|
| 1011 | - return true; |
|
| 1068 | + if (isset($_POST['pop_done'])) { |
|
| 1069 | + return true; |
|
| 1070 | + } |
|
| 1012 | 1071 | |
| 1013 | 1072 | // Reload settings. |
| 1014 | 1073 | require(dirname(__FILE__) . '/Settings.php'); |
@@ -1026,8 +1085,9 @@ discard block |
||
| 1026 | 1085 | $modSettings = array(); |
| 1027 | 1086 | if ($result !== false) |
| 1028 | 1087 | { |
| 1029 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 1030 | - $modSettings[$row['variable']] = $row['value']; |
|
| 1088 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 1089 | + $modSettings[$row['variable']] = $row['value']; |
|
| 1090 | + } |
|
| 1031 | 1091 | $smcFunc['db_free_result']($result); |
| 1032 | 1092 | |
| 1033 | 1093 | // Do they match? If so, this is just a refresh so charge on! |
@@ -1040,20 +1100,22 @@ discard block |
||
| 1040 | 1100 | $modSettings['disableQueryCheck'] = true; |
| 1041 | 1101 | |
| 1042 | 1102 | // If doing UTF8, select it. PostgreSQL requires passing it as a string... |
| 1043 | - if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) |
|
| 1044 | - $smcFunc['db_query']('', ' |
|
| 1103 | + if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) { |
|
| 1104 | + $smcFunc['db_query']('', ' |
|
| 1045 | 1105 | SET NAMES {string:utf8}', |
| 1046 | 1106 | array( |
| 1047 | 1107 | 'db_error_skip' => true, |
| 1048 | 1108 | 'utf8' => 'utf8', |
| 1049 | 1109 | ) |
| 1050 | 1110 | ); |
| 1111 | + } |
|
| 1051 | 1112 | |
| 1052 | 1113 | // Windows likes to leave the trailing slash, which yields to C:\path\to\SMF\/attachments... |
| 1053 | - if (substr(__DIR__, -1) == '\\') |
|
| 1054 | - $attachdir = __DIR__ . 'attachments'; |
|
| 1055 | - else |
|
| 1056 | - $attachdir = __DIR__ . '/attachments'; |
|
| 1114 | + if (substr(__DIR__, -1) == '\\') { |
|
| 1115 | + $attachdir = __DIR__ . 'attachments'; |
|
| 1116 | + } else { |
|
| 1117 | + $attachdir = __DIR__ . '/attachments'; |
|
| 1118 | + } |
|
| 1057 | 1119 | |
| 1058 | 1120 | $replaces = array( |
| 1059 | 1121 | '{$db_prefix}' => $db_prefix, |
@@ -1070,8 +1132,9 @@ discard block |
||
| 1070 | 1132 | |
| 1071 | 1133 | foreach ($txt as $key => $value) |
| 1072 | 1134 | { |
| 1073 | - if (substr($key, 0, 8) == 'default_') |
|
| 1074 | - $replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value); |
|
| 1135 | + if (substr($key, 0, 8) == 'default_') { |
|
| 1136 | + $replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value); |
|
| 1137 | + } |
|
| 1075 | 1138 | } |
| 1076 | 1139 | $replaces['{$default_reserved_names}'] = strtr($replaces['{$default_reserved_names}'], array('\\\\n' => '\\n')); |
| 1077 | 1140 | |
@@ -1086,8 +1149,9 @@ discard block |
||
| 1086 | 1149 | |
| 1087 | 1150 | while ($row = $smcFunc['db_fetch_assoc']($get_engines)) |
| 1088 | 1151 | { |
| 1089 | - if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') |
|
| 1090 | - $engines[] = $row['Engine']; |
|
| 1152 | + if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') { |
|
| 1153 | + $engines[] = $row['Engine']; |
|
| 1154 | + } |
|
| 1091 | 1155 | } |
| 1092 | 1156 | |
| 1093 | 1157 | // Done with this now |
@@ -1111,8 +1175,7 @@ discard block |
||
| 1111 | 1175 | $replaces['START TRANSACTION;'] = ''; |
| 1112 | 1176 | $replaces['COMMIT;'] = ''; |
| 1113 | 1177 | } |
| 1114 | - } |
|
| 1115 | - else |
|
| 1178 | + } else |
|
| 1116 | 1179 | { |
| 1117 | 1180 | $has_innodb = false; |
| 1118 | 1181 | } |
@@ -1134,21 +1197,24 @@ discard block |
||
| 1134 | 1197 | foreach ($sql_lines as $count => $line) |
| 1135 | 1198 | { |
| 1136 | 1199 | // No comments allowed! |
| 1137 | - if (substr(trim($line), 0, 1) != '#') |
|
| 1138 | - $current_statement .= "\n" . rtrim($line); |
|
| 1200 | + if (substr(trim($line), 0, 1) != '#') { |
|
| 1201 | + $current_statement .= "\n" . rtrim($line); |
|
| 1202 | + } |
|
| 1139 | 1203 | |
| 1140 | 1204 | // Is this the end of the query string? |
| 1141 | - if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) |
|
| 1142 | - continue; |
|
| 1205 | + if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) { |
|
| 1206 | + continue; |
|
| 1207 | + } |
|
| 1143 | 1208 | |
| 1144 | 1209 | // Does this table already exist? If so, don't insert more data into it! |
| 1145 | 1210 | if (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) != 0 && in_array($match[1], $exists)) |
| 1146 | 1211 | { |
| 1147 | 1212 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
| 1148 | - if (!empty($matches[0])) |
|
| 1149 | - $incontext['sql_results']['insert_dups'] += count($matches[0]); |
|
| 1150 | - else |
|
| 1151 | - $incontext['sql_results']['insert_dups']++; |
|
| 1213 | + if (!empty($matches[0])) { |
|
| 1214 | + $incontext['sql_results']['insert_dups'] += count($matches[0]); |
|
| 1215 | + } else { |
|
| 1216 | + $incontext['sql_results']['insert_dups']++; |
|
| 1217 | + } |
|
| 1152 | 1218 | |
| 1153 | 1219 | $current_statement = ''; |
| 1154 | 1220 | continue; |
@@ -1157,8 +1223,9 @@ discard block |
||
| 1157 | 1223 | if ($smcFunc['db_query']('', $current_statement, array('security_override' => true, 'db_error_skip' => true), $db_connection) === false) |
| 1158 | 1224 | { |
| 1159 | 1225 | // Use the appropriate function based on the DB type |
| 1160 | - if ($db_type == 'mysql' || $db_type == 'mysqli') |
|
| 1161 | - $db_errorno = $db_type . '_errno'; |
|
| 1226 | + if ($db_type == 'mysql' || $db_type == 'mysqli') { |
|
| 1227 | + $db_errorno = $db_type . '_errno'; |
|
| 1228 | + } |
|
| 1162 | 1229 | |
| 1163 | 1230 | // Error 1050: Table already exists! |
| 1164 | 1231 | // @todo Needs to be made better! |
@@ -1173,18 +1240,18 @@ discard block |
||
| 1173 | 1240 | // MySQLi requires a connection object. It's optional with MySQL and Postgres |
| 1174 | 1241 | $incontext['failures'][$count] = $smcFunc['db_error']($db_connection); |
| 1175 | 1242 | } |
| 1176 | - } |
|
| 1177 | - else |
|
| 1243 | + } else |
|
| 1178 | 1244 | { |
| 1179 | - if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
| 1180 | - $incontext['sql_results']['tables']++; |
|
| 1181 | - elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
| 1245 | + if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) { |
|
| 1246 | + $incontext['sql_results']['tables']++; |
|
| 1247 | + } elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
| 1182 | 1248 | { |
| 1183 | 1249 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
| 1184 | - if (!empty($matches[0])) |
|
| 1185 | - $incontext['sql_results']['inserts'] += count($matches[0]); |
|
| 1186 | - else |
|
| 1187 | - $incontext['sql_results']['inserts']++; |
|
| 1250 | + if (!empty($matches[0])) { |
|
| 1251 | + $incontext['sql_results']['inserts'] += count($matches[0]); |
|
| 1252 | + } else { |
|
| 1253 | + $incontext['sql_results']['inserts']++; |
|
| 1254 | + } |
|
| 1188 | 1255 | } |
| 1189 | 1256 | } |
| 1190 | 1257 | |
@@ -1197,15 +1264,17 @@ discard block |
||
| 1197 | 1264 | // Sort out the context for the SQL. |
| 1198 | 1265 | foreach ($incontext['sql_results'] as $key => $number) |
| 1199 | 1266 | { |
| 1200 | - if ($number == 0) |
|
| 1201 | - unset($incontext['sql_results'][$key]); |
|
| 1202 | - else |
|
| 1203 | - $incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number); |
|
| 1267 | + if ($number == 0) { |
|
| 1268 | + unset($incontext['sql_results'][$key]); |
|
| 1269 | + } else { |
|
| 1270 | + $incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number); |
|
| 1271 | + } |
|
| 1204 | 1272 | } |
| 1205 | 1273 | |
| 1206 | 1274 | // Make sure UTF will be used globally. |
| 1207 | - 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']))) |
|
| 1208 | - $newSettings[] = array('global_character_set', 'UTF-8'); |
|
| 1275 | + 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']))) { |
|
| 1276 | + $newSettings[] = array('global_character_set', 'UTF-8'); |
|
| 1277 | + } |
|
| 1209 | 1278 | |
| 1210 | 1279 | // Maybe we can auto-detect better cookie settings? |
| 1211 | 1280 | preg_match('~^http[s]?://([^\.]+?)([^/]*?)(/.*)?$~', $boardurl, $matches); |
@@ -1216,16 +1285,20 @@ discard block |
||
| 1216 | 1285 | $globalCookies = false; |
| 1217 | 1286 | |
| 1218 | 1287 | // Okay... let's see. Using a subdomain other than www.? (not a perfect check.) |
| 1219 | - if ($matches[2] != '' && (strpos(substr($matches[2], 1), '.') === false || in_array($matches[1], array('forum', 'board', 'community', 'forums', 'support', 'chat', 'help', 'talk', 'boards', 'www')))) |
|
| 1220 | - $globalCookies = true; |
|
| 1288 | + if ($matches[2] != '' && (strpos(substr($matches[2], 1), '.') === false || in_array($matches[1], array('forum', 'board', 'community', 'forums', 'support', 'chat', 'help', 'talk', 'boards', 'www')))) { |
|
| 1289 | + $globalCookies = true; |
|
| 1290 | + } |
|
| 1221 | 1291 | // If there's a / in the middle of the path, or it starts with ~... we want local. |
| 1222 | - if (isset($matches[3]) && strlen($matches[3]) > 3 && (substr($matches[3], 0, 2) == '/~' || strpos(substr($matches[3], 1), '/') !== false)) |
|
| 1223 | - $localCookies = true; |
|
| 1292 | + if (isset($matches[3]) && strlen($matches[3]) > 3 && (substr($matches[3], 0, 2) == '/~' || strpos(substr($matches[3], 1), '/') !== false)) { |
|
| 1293 | + $localCookies = true; |
|
| 1294 | + } |
|
| 1224 | 1295 | |
| 1225 | - if ($globalCookies) |
|
| 1226 | - $newSettings[] = array('globalCookies', '1'); |
|
| 1227 | - if ($localCookies) |
|
| 1228 | - $newSettings[] = array('localCookies', '1'); |
|
| 1296 | + if ($globalCookies) { |
|
| 1297 | + $newSettings[] = array('globalCookies', '1'); |
|
| 1298 | + } |
|
| 1299 | + if ($localCookies) { |
|
| 1300 | + $newSettings[] = array('localCookies', '1'); |
|
| 1301 | + } |
|
| 1229 | 1302 | } |
| 1230 | 1303 | |
| 1231 | 1304 | // Are we allowing stat collection? |
@@ -1243,16 +1316,17 @@ discard block |
||
| 1243 | 1316 | fwrite($fp, $out); |
| 1244 | 1317 | |
| 1245 | 1318 | $return_data = ''; |
| 1246 | - while (!feof($fp)) |
|
| 1247 | - $return_data .= fgets($fp, 128); |
|
| 1319 | + while (!feof($fp)) { |
|
| 1320 | + $return_data .= fgets($fp, 128); |
|
| 1321 | + } |
|
| 1248 | 1322 | |
| 1249 | 1323 | fclose($fp); |
| 1250 | 1324 | |
| 1251 | 1325 | // Get the unique site ID. |
| 1252 | 1326 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
| 1253 | 1327 | |
| 1254 | - if (!empty($ID[1])) |
|
| 1255 | - $smcFunc['db_insert']('replace', |
|
| 1328 | + if (!empty($ID[1])) { |
|
| 1329 | + $smcFunc['db_insert']('replace', |
|
| 1256 | 1330 | $db_prefix . 'settings', |
| 1257 | 1331 | array('variable' => 'string', 'value' => 'string'), |
| 1258 | 1332 | array( |
@@ -1261,11 +1335,12 @@ discard block |
||
| 1261 | 1335 | ), |
| 1262 | 1336 | array('variable') |
| 1263 | 1337 | ); |
| 1338 | + } |
|
| 1264 | 1339 | } |
| 1265 | 1340 | } |
| 1266 | 1341 | // Don't remove stat collection unless we unchecked the box for real, not from the loop. |
| 1267 | - elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) |
|
| 1268 | - $smcFunc['db_query']('', ' |
|
| 1342 | + elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) { |
|
| 1343 | + $smcFunc['db_query']('', ' |
|
| 1269 | 1344 | DELETE FROM {db_prefix}settings |
| 1270 | 1345 | WHERE variable = {string:enable_sm_stats}', |
| 1271 | 1346 | array( |
@@ -1273,20 +1348,23 @@ discard block |
||
| 1273 | 1348 | 'db_error_skip' => true, |
| 1274 | 1349 | ) |
| 1275 | 1350 | ); |
| 1351 | + } |
|
| 1276 | 1352 | |
| 1277 | 1353 | // Are we enabling SSL? |
| 1278 | - if (!empty($_POST['force_ssl'])) |
|
| 1279 | - $newSettings[] = array('force_ssl', 2); |
|
| 1354 | + if (!empty($_POST['force_ssl'])) { |
|
| 1355 | + $newSettings[] = array('force_ssl', 2); |
|
| 1356 | + } |
|
| 1280 | 1357 | |
| 1281 | 1358 | // Setting a timezone is required. |
| 1282 | 1359 | if (!isset($modSettings['default_timezone']) && function_exists('date_default_timezone_set')) |
| 1283 | 1360 | { |
| 1284 | 1361 | // Get PHP's default timezone, if set |
| 1285 | 1362 | $ini_tz = ini_get('date.timezone'); |
| 1286 | - if (!empty($ini_tz)) |
|
| 1287 | - $timezone_id = $ini_tz; |
|
| 1288 | - else |
|
| 1289 | - $timezone_id = ''; |
|
| 1363 | + if (!empty($ini_tz)) { |
|
| 1364 | + $timezone_id = $ini_tz; |
|
| 1365 | + } else { |
|
| 1366 | + $timezone_id = ''; |
|
| 1367 | + } |
|
| 1290 | 1368 | |
| 1291 | 1369 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
| 1292 | 1370 | if (!in_array($timezone_id, timezone_identifiers_list())) |
@@ -1295,8 +1373,9 @@ discard block |
||
| 1295 | 1373 | $timezone_id = timezone_name_from_abbr('', $server_offset, 0); |
| 1296 | 1374 | } |
| 1297 | 1375 | |
| 1298 | - if (date_default_timezone_set($timezone_id)) |
|
| 1299 | - $newSettings[] = array('default_timezone', $timezone_id); |
|
| 1376 | + if (date_default_timezone_set($timezone_id)) { |
|
| 1377 | + $newSettings[] = array('default_timezone', $timezone_id); |
|
| 1378 | + } |
|
| 1300 | 1379 | } |
| 1301 | 1380 | |
| 1302 | 1381 | if (!empty($newSettings)) |
@@ -1327,16 +1406,18 @@ discard block |
||
| 1327 | 1406 | } |
| 1328 | 1407 | |
| 1329 | 1408 | // MySQL specific stuff |
| 1330 | - if (substr($db_type, 0, 5) != 'mysql') |
|
| 1331 | - return false; |
|
| 1409 | + if (substr($db_type, 0, 5) != 'mysql') { |
|
| 1410 | + return false; |
|
| 1411 | + } |
|
| 1332 | 1412 | |
| 1333 | 1413 | // Find database user privileges. |
| 1334 | 1414 | $privs = array(); |
| 1335 | 1415 | $get_privs = $smcFunc['db_query']('', 'SHOW PRIVILEGES', array()); |
| 1336 | 1416 | while ($row = $smcFunc['db_fetch_assoc']($get_privs)) |
| 1337 | 1417 | { |
| 1338 | - if ($row['Privilege'] == 'Alter') |
|
| 1339 | - $privs[] = $row['Privilege']; |
|
| 1418 | + if ($row['Privilege'] == 'Alter') { |
|
| 1419 | + $privs[] = $row['Privilege']; |
|
| 1420 | + } |
|
| 1340 | 1421 | } |
| 1341 | 1422 | $smcFunc['db_free_result']($get_privs); |
| 1342 | 1423 | |
@@ -1366,8 +1447,9 @@ discard block |
||
| 1366 | 1447 | $incontext['continue'] = 1; |
| 1367 | 1448 | |
| 1368 | 1449 | // Skipping? |
| 1369 | - if (!empty($_POST['skip'])) |
|
| 1370 | - return true; |
|
| 1450 | + if (!empty($_POST['skip'])) { |
|
| 1451 | + return true; |
|
| 1452 | + } |
|
| 1371 | 1453 | |
| 1372 | 1454 | // Need this to check whether we need the database password. |
| 1373 | 1455 | require(dirname(__FILE__) . '/Settings.php'); |
@@ -1384,18 +1466,22 @@ discard block |
||
| 1384 | 1466 | // We need this to properly hash the password for Admin |
| 1385 | 1467 | $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) { |
| 1386 | 1468 | global $sourcedir; |
| 1387 | - if (function_exists('mb_strtolower')) |
|
| 1388 | - return mb_strtolower($string, 'UTF-8'); |
|
| 1469 | + if (function_exists('mb_strtolower')) { |
|
| 1470 | + return mb_strtolower($string, 'UTF-8'); |
|
| 1471 | + } |
|
| 1389 | 1472 | require_once($sourcedir . '/Subs-Charset.php'); |
| 1390 | 1473 | return utf8_strtolower($string); |
| 1391 | 1474 | }; |
| 1392 | 1475 | |
| 1393 | - if (!isset($_POST['username'])) |
|
| 1394 | - $_POST['username'] = ''; |
|
| 1395 | - if (!isset($_POST['email'])) |
|
| 1396 | - $_POST['email'] = ''; |
|
| 1397 | - if (!isset($_POST['server_email'])) |
|
| 1398 | - $_POST['server_email'] = ''; |
|
| 1476 | + if (!isset($_POST['username'])) { |
|
| 1477 | + $_POST['username'] = ''; |
|
| 1478 | + } |
|
| 1479 | + if (!isset($_POST['email'])) { |
|
| 1480 | + $_POST['email'] = ''; |
|
| 1481 | + } |
|
| 1482 | + if (!isset($_POST['server_email'])) { |
|
| 1483 | + $_POST['server_email'] = ''; |
|
| 1484 | + } |
|
| 1399 | 1485 | |
| 1400 | 1486 | $incontext['username'] = htmlspecialchars(stripslashes($_POST['username'])); |
| 1401 | 1487 | $incontext['email'] = htmlspecialchars(stripslashes($_POST['email'])); |
@@ -1414,8 +1500,9 @@ discard block |
||
| 1414 | 1500 | 'admin_group' => 1, |
| 1415 | 1501 | ) |
| 1416 | 1502 | ); |
| 1417 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 1418 | - $incontext['skip'] = 1; |
|
| 1503 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 1504 | + $incontext['skip'] = 1; |
|
| 1505 | + } |
|
| 1419 | 1506 | $smcFunc['db_free_result']($request); |
| 1420 | 1507 | |
| 1421 | 1508 | // Trying to create an account? |
@@ -1446,8 +1533,9 @@ discard block |
||
| 1446 | 1533 | } |
| 1447 | 1534 | |
| 1448 | 1535 | // Update the webmaster's email? |
| 1449 | - if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) |
|
| 1450 | - updateSettingsFile(array('webmaster_email' => $_POST['server_email'])); |
|
| 1536 | + if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) { |
|
| 1537 | + updateSettingsFile(array('webmaster_email' => $_POST['server_email'])); |
|
| 1538 | + } |
|
| 1451 | 1539 | |
| 1452 | 1540 | // Work out whether we're going to have dodgy characters and remove them. |
| 1453 | 1541 | $invalid_characters = preg_match('~[<>&"\'=\\\]~', $_POST['username']) != 0; |
@@ -1470,32 +1558,27 @@ discard block |
||
| 1470 | 1558 | $smcFunc['db_free_result']($result); |
| 1471 | 1559 | |
| 1472 | 1560 | $incontext['account_existed'] = $txt['error_user_settings_taken']; |
| 1473 | - } |
|
| 1474 | - elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) |
|
| 1561 | + } elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) |
|
| 1475 | 1562 | { |
| 1476 | 1563 | // Try the previous step again. |
| 1477 | 1564 | $incontext['error'] = $_POST['username'] == '' ? $txt['error_username_left_empty'] : $txt['error_username_too_long']; |
| 1478 | 1565 | return false; |
| 1479 | - } |
|
| 1480 | - elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) |
|
| 1566 | + } elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) |
|
| 1481 | 1567 | { |
| 1482 | 1568 | // Try the previous step again. |
| 1483 | 1569 | $incontext['error'] = $txt['error_invalid_characters_username']; |
| 1484 | 1570 | return false; |
| 1485 | - } |
|
| 1486 | - elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255) |
|
| 1571 | + } elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255) |
|
| 1487 | 1572 | { |
| 1488 | 1573 | // One step back, this time fill out a proper admin email address. |
| 1489 | 1574 | $incontext['error'] = sprintf($txt['error_valid_admin_email_needed'], $_POST['username']); |
| 1490 | 1575 | return false; |
| 1491 | - } |
|
| 1492 | - elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255) |
|
| 1576 | + } elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255) |
|
| 1493 | 1577 | { |
| 1494 | 1578 | // One step back, this time fill out a proper admin email address. |
| 1495 | 1579 | $incontext['error'] = $txt['error_valid_server_email_needed']; |
| 1496 | 1580 | return false; |
| 1497 | - } |
|
| 1498 | - elseif ($_POST['username'] != '') |
|
| 1581 | + } elseif ($_POST['username'] != '') |
|
| 1499 | 1582 | { |
| 1500 | 1583 | $incontext['member_salt'] = substr(md5(mt_rand()), 0, 4); |
| 1501 | 1584 | |
@@ -1563,17 +1646,19 @@ discard block |
||
| 1563 | 1646 | reloadSettings(); |
| 1564 | 1647 | |
| 1565 | 1648 | // Bring a warning over. |
| 1566 | - if (!empty($incontext['account_existed'])) |
|
| 1567 | - $incontext['warning'] = $incontext['account_existed']; |
|
| 1649 | + if (!empty($incontext['account_existed'])) { |
|
| 1650 | + $incontext['warning'] = $incontext['account_existed']; |
|
| 1651 | + } |
|
| 1568 | 1652 | |
| 1569 | - if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) |
|
| 1570 | - $smcFunc['db_query']('', ' |
|
| 1653 | + if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) { |
|
| 1654 | + $smcFunc['db_query']('', ' |
|
| 1571 | 1655 | SET NAMES {string:db_character_set}', |
| 1572 | 1656 | array( |
| 1573 | 1657 | 'db_character_set' => $db_character_set, |
| 1574 | 1658 | 'db_error_skip' => true, |
| 1575 | 1659 | ) |
| 1576 | 1660 | ); |
| 1661 | + } |
|
| 1577 | 1662 | |
| 1578 | 1663 | // As track stats is by default enabled let's add some activity. |
| 1579 | 1664 | $smcFunc['db_insert']('ignore', |
@@ -1594,14 +1679,16 @@ discard block |
||
| 1594 | 1679 | // Only proceed if we can load the data. |
| 1595 | 1680 | if ($request) |
| 1596 | 1681 | { |
| 1597 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 1598 | - $modSettings[$row[0]] = $row[1]; |
|
| 1682 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 1683 | + $modSettings[$row[0]] = $row[1]; |
|
| 1684 | + } |
|
| 1599 | 1685 | $smcFunc['db_free_result']($request); |
| 1600 | 1686 | } |
| 1601 | 1687 | |
| 1602 | 1688 | // Automatically log them in ;) |
| 1603 | - if (isset($incontext['member_id']) && isset($incontext['member_salt'])) |
|
| 1604 | - setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt'])); |
|
| 1689 | + if (isset($incontext['member_id']) && isset($incontext['member_salt'])) { |
|
| 1690 | + setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt'])); |
|
| 1691 | + } |
|
| 1605 | 1692 | |
| 1606 | 1693 | $result = $smcFunc['db_query']('', ' |
| 1607 | 1694 | SELECT value |
@@ -1612,13 +1699,14 @@ discard block |
||
| 1612 | 1699 | 'db_error_skip' => true, |
| 1613 | 1700 | ) |
| 1614 | 1701 | ); |
| 1615 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
| 1616 | - list ($db_sessions) = $smcFunc['db_fetch_row']($result); |
|
| 1702 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
| 1703 | + list ($db_sessions) = $smcFunc['db_fetch_row']($result); |
|
| 1704 | + } |
|
| 1617 | 1705 | $smcFunc['db_free_result']($result); |
| 1618 | 1706 | |
| 1619 | - if (empty($db_sessions)) |
|
| 1620 | - $_SESSION['admin_time'] = time(); |
|
| 1621 | - else |
|
| 1707 | + if (empty($db_sessions)) { |
|
| 1708 | + $_SESSION['admin_time'] = time(); |
|
| 1709 | + } else |
|
| 1622 | 1710 | { |
| 1623 | 1711 | $_SERVER['HTTP_USER_AGENT'] = substr($_SERVER['HTTP_USER_AGENT'], 0, 211); |
| 1624 | 1712 | |
@@ -1642,8 +1730,9 @@ discard block |
||
| 1642 | 1730 | $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : |
| 1643 | 1731 | function($string){ |
| 1644 | 1732 | global $sourcedir; |
| 1645 | - if (function_exists('mb_strtolower')) |
|
| 1646 | - return mb_strtolower($string, 'UTF-8'); |
|
| 1733 | + if (function_exists('mb_strtolower')) { |
|
| 1734 | + return mb_strtolower($string, 'UTF-8'); |
|
| 1735 | + } |
|
| 1647 | 1736 | require_once($sourcedir . '/Subs-Charset.php'); |
| 1648 | 1737 | return utf8_strtolower($string); |
| 1649 | 1738 | }; |
@@ -1659,8 +1748,9 @@ discard block |
||
| 1659 | 1748 | ) |
| 1660 | 1749 | ); |
| 1661 | 1750 | $context['utf8'] = $db_character_set === 'utf8' || $txt['lang_character_set'] === 'UTF-8'; |
| 1662 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
| 1663 | - updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject'])); |
|
| 1751 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
| 1752 | + updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject'])); |
|
| 1753 | + } |
|
| 1664 | 1754 | $smcFunc['db_free_result']($request); |
| 1665 | 1755 | |
| 1666 | 1756 | // Now is the perfect time to fetch the SM files. |
@@ -1679,8 +1769,9 @@ discard block |
||
| 1679 | 1769 | |
| 1680 | 1770 | // Check if we need some stupid MySQL fix. |
| 1681 | 1771 | $server_version = $smcFunc['db_server_info'](); |
| 1682 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
| 1683 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1772 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
| 1773 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1774 | + } |
|
| 1684 | 1775 | |
| 1685 | 1776 | // Some final context for the template. |
| 1686 | 1777 | $incontext['dir_still_writable'] = is_writable(dirname(__FILE__)) && substr(__FILE__, 1, 2) != ':\\'; |
@@ -1700,8 +1791,9 @@ discard block |
||
| 1700 | 1791 | $settingsArray = file(dirname(__FILE__) . '/Settings.php'); |
| 1701 | 1792 | |
| 1702 | 1793 | // @todo Do we just want to read the file in clean, and split it this way always? |
| 1703 | - if (count($settingsArray) == 1) |
|
| 1704 | - $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
| 1794 | + if (count($settingsArray) == 1) { |
|
| 1795 | + $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
| 1796 | + } |
|
| 1705 | 1797 | |
| 1706 | 1798 | for ($i = 0, $n = count($settingsArray); $i < $n; $i++) |
| 1707 | 1799 | { |
@@ -1716,19 +1808,22 @@ discard block |
||
| 1716 | 1808 | continue; |
| 1717 | 1809 | } |
| 1718 | 1810 | |
| 1719 | - if (trim($settingsArray[$i]) == '?' . '>') |
|
| 1720 | - $settingsArray[$i] = ''; |
|
| 1811 | + if (trim($settingsArray[$i]) == '?' . '>') { |
|
| 1812 | + $settingsArray[$i] = ''; |
|
| 1813 | + } |
|
| 1721 | 1814 | |
| 1722 | 1815 | // Don't trim or bother with it if it's not a variable. |
| 1723 | - if (substr($settingsArray[$i], 0, 1) != '$') |
|
| 1724 | - continue; |
|
| 1816 | + if (substr($settingsArray[$i], 0, 1) != '$') { |
|
| 1817 | + continue; |
|
| 1818 | + } |
|
| 1725 | 1819 | |
| 1726 | 1820 | $settingsArray[$i] = rtrim($settingsArray[$i]) . "\n"; |
| 1727 | 1821 | |
| 1728 | - foreach ($vars as $var => $val) |
|
| 1729 | - if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
| 1822 | + foreach ($vars as $var => $val) { |
|
| 1823 | + if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
| 1730 | 1824 | { |
| 1731 | 1825 | $comment = strstr($settingsArray[$i], '#'); |
| 1826 | + } |
|
| 1732 | 1827 | $settingsArray[$i] = '$' . $var . ' = \'' . $val . '\';' . ($comment != '' ? "\t\t" . $comment : "\n"); |
| 1733 | 1828 | unset($vars[$var]); |
| 1734 | 1829 | } |
@@ -1738,36 +1833,41 @@ discard block |
||
| 1738 | 1833 | if (!empty($vars)) |
| 1739 | 1834 | { |
| 1740 | 1835 | $settingsArray[$i++] = ''; |
| 1741 | - foreach ($vars as $var => $val) |
|
| 1742 | - $settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n"; |
|
| 1836 | + foreach ($vars as $var => $val) { |
|
| 1837 | + $settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n"; |
|
| 1838 | + } |
|
| 1743 | 1839 | } |
| 1744 | 1840 | |
| 1745 | 1841 | // Blank out the file - done to fix a oddity with some servers. |
| 1746 | 1842 | $fp = @fopen(dirname(__FILE__) . '/Settings.php', 'w'); |
| 1747 | - if (!$fp) |
|
| 1748 | - return false; |
|
| 1843 | + if (!$fp) { |
|
| 1844 | + return false; |
|
| 1845 | + } |
|
| 1749 | 1846 | fclose($fp); |
| 1750 | 1847 | |
| 1751 | 1848 | $fp = fopen(dirname(__FILE__) . '/Settings.php', 'r+'); |
| 1752 | 1849 | |
| 1753 | 1850 | // Gotta have one of these ;) |
| 1754 | - if (trim($settingsArray[0]) != '<?php') |
|
| 1755 | - fwrite($fp, "<?php\n"); |
|
| 1851 | + if (trim($settingsArray[0]) != '<?php') { |
|
| 1852 | + fwrite($fp, "<?php\n"); |
|
| 1853 | + } |
|
| 1756 | 1854 | |
| 1757 | 1855 | $lines = count($settingsArray); |
| 1758 | 1856 | for ($i = 0; $i < $lines - 1; $i++) |
| 1759 | 1857 | { |
| 1760 | 1858 | // Don't just write a bunch of blank lines. |
| 1761 | - if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') |
|
| 1762 | - fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
| 1859 | + if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') { |
|
| 1860 | + fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
| 1861 | + } |
|
| 1763 | 1862 | } |
| 1764 | 1863 | fwrite($fp, $settingsArray[$i] . '?' . '>'); |
| 1765 | 1864 | fclose($fp); |
| 1766 | 1865 | |
| 1767 | 1866 | // Even though on normal installations the filemtime should prevent this being used by the installer incorrectly |
| 1768 | 1867 | // it seems that there are times it might not. So let's MAKE it dump the cache. |
| 1769 | - if (function_exists('opcache_invalidate')) |
|
| 1770 | - opcache_invalidate(dirname(__FILE__) . '/Settings.php', true); |
|
| 1868 | + if (function_exists('opcache_invalidate')) { |
|
| 1869 | + opcache_invalidate(dirname(__FILE__) . '/Settings.php', true); |
|
| 1870 | + } |
|
| 1771 | 1871 | |
| 1772 | 1872 | return true; |
| 1773 | 1873 | } |
@@ -1792,9 +1892,9 @@ discard block |
||
| 1792 | 1892 | SecFilterScanPOST Off |
| 1793 | 1893 | </IfModule>'; |
| 1794 | 1894 | |
| 1795 | - if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) |
|
| 1796 | - return true; |
|
| 1797 | - elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess')) |
|
| 1895 | + if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) { |
|
| 1896 | + return true; |
|
| 1897 | + } elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess')) |
|
| 1798 | 1898 | { |
| 1799 | 1899 | $current_htaccess = implode('', file(dirname(__FILE__) . '/.htaccess')); |
| 1800 | 1900 | |
@@ -1806,29 +1906,28 @@ discard block |
||
| 1806 | 1906 | fwrite($ht_handle, $htaccess_addition); |
| 1807 | 1907 | fclose($ht_handle); |
| 1808 | 1908 | return true; |
| 1909 | + } else { |
|
| 1910 | + return false; |
|
| 1809 | 1911 | } |
| 1810 | - else |
|
| 1811 | - return false; |
|
| 1912 | + } else { |
|
| 1913 | + return true; |
|
| 1812 | 1914 | } |
| 1813 | - else |
|
| 1814 | - return true; |
|
| 1815 | - } |
|
| 1816 | - elseif (file_exists(dirname(__FILE__) . '/.htaccess')) |
|
| 1817 | - return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false; |
|
| 1818 | - elseif (is_writable(dirname(__FILE__))) |
|
| 1915 | + } elseif (file_exists(dirname(__FILE__) . '/.htaccess')) { |
|
| 1916 | + return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false; |
|
| 1917 | + } elseif (is_writable(dirname(__FILE__))) |
|
| 1819 | 1918 | { |
| 1820 | 1919 | if ($ht_handle = fopen(dirname(__FILE__) . '/.htaccess', 'w')) |
| 1821 | 1920 | { |
| 1822 | 1921 | fwrite($ht_handle, $htaccess_addition); |
| 1823 | 1922 | fclose($ht_handle); |
| 1824 | 1923 | return true; |
| 1924 | + } else { |
|
| 1925 | + return false; |
|
| 1825 | 1926 | } |
| 1826 | - else |
|
| 1927 | + } else { |
|
| 1827 | 1928 | return false; |
| 1828 | 1929 | } |
| 1829 | - else |
|
| 1830 | - return false; |
|
| 1831 | -} |
|
| 1930 | + } |
|
| 1832 | 1931 | |
| 1833 | 1932 | function template_install_above() |
| 1834 | 1933 | { |
@@ -1866,9 +1965,10 @@ discard block |
||
| 1866 | 1965 | <label for="installer_language">', $txt['installer_language'], ':</label> |
| 1867 | 1966 | <select id="installer_language" name="lang_file" onchange="location.href = \'', $installurl, '?lang_file=\' + this.options[this.selectedIndex].value;">'; |
| 1868 | 1967 | |
| 1869 | - foreach ($incontext['detected_languages'] as $lang => $name) |
|
| 1870 | - echo ' |
|
| 1968 | + foreach ($incontext['detected_languages'] as $lang => $name) { |
|
| 1969 | + echo ' |
|
| 1871 | 1970 | <option', isset($_SESSION['installer_temp_lang']) && $_SESSION['installer_temp_lang'] == $lang ? ' selected' : '', ' value="', $lang, '">', $name, '</option>'; |
| 1971 | + } |
|
| 1872 | 1972 | |
| 1873 | 1973 | echo ' |
| 1874 | 1974 | </select> |
@@ -1888,9 +1988,10 @@ discard block |
||
| 1888 | 1988 | <h2>', $txt['upgrade_progress'], '</h2> |
| 1889 | 1989 | <ul>'; |
| 1890 | 1990 | |
| 1891 | - foreach ($incontext['steps'] as $num => $step) |
|
| 1892 | - echo ' |
|
| 1991 | + foreach ($incontext['steps'] as $num => $step) { |
|
| 1992 | + echo ' |
|
| 1893 | 1993 | <li class="', $num < $incontext['current_step'] ? 'stepdone' : ($num == $incontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
| 1994 | + } |
|
| 1894 | 1995 | |
| 1895 | 1996 | echo ' |
| 1896 | 1997 | </ul> |
@@ -1915,20 +2016,23 @@ discard block |
||
| 1915 | 2016 | echo ' |
| 1916 | 2017 | <div>'; |
| 1917 | 2018 | |
| 1918 | - if (!empty($incontext['continue'])) |
|
| 1919 | - echo ' |
|
| 2019 | + if (!empty($incontext['continue'])) { |
|
| 2020 | + echo ' |
|
| 1920 | 2021 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '" onclick="return submitThisOnce(this);" class="button_submit" />'; |
| 1921 | - if (!empty($incontext['skip'])) |
|
| 1922 | - echo ' |
|
| 2022 | + } |
|
| 2023 | + if (!empty($incontext['skip'])) { |
|
| 2024 | + echo ' |
|
| 1923 | 2025 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="return submitThisOnce(this);" class="button_submit" />'; |
| 2026 | + } |
|
| 1924 | 2027 | echo ' |
| 1925 | 2028 | </div>'; |
| 1926 | 2029 | } |
| 1927 | 2030 | |
| 1928 | 2031 | // Show the closing form tag and other data only if not in the last step |
| 1929 | - if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) |
|
| 1930 | - echo ' |
|
| 2032 | + if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) { |
|
| 2033 | + echo ' |
|
| 1931 | 2034 | </form>'; |
| 2035 | + } |
|
| 1932 | 2036 | |
| 1933 | 2037 | echo ' |
| 1934 | 2038 | </div> |
@@ -1963,13 +2067,15 @@ discard block |
||
| 1963 | 2067 | </div>'; |
| 1964 | 2068 | |
| 1965 | 2069 | // Show the warnings, or not. |
| 1966 | - if (template_warning_divs()) |
|
| 1967 | - echo ' |
|
| 2070 | + if (template_warning_divs()) { |
|
| 2071 | + echo ' |
|
| 1968 | 2072 | <h3>', $txt['install_all_lovely'], '</h3>'; |
| 2073 | + } |
|
| 1969 | 2074 | |
| 1970 | 2075 | // Say we want the continue button! |
| 1971 | - if (empty($incontext['error'])) |
|
| 1972 | - $incontext['continue'] = 1; |
|
| 2076 | + if (empty($incontext['error'])) { |
|
| 2077 | + $incontext['continue'] = 1; |
|
| 2078 | + } |
|
| 1973 | 2079 | |
| 1974 | 2080 | // For the latest version stuff. |
| 1975 | 2081 | echo ' |
@@ -2003,8 +2109,8 @@ discard block |
||
| 2003 | 2109 | global $txt, $incontext; |
| 2004 | 2110 | |
| 2005 | 2111 | // Errors are very serious.. |
| 2006 | - if (!empty($incontext['error'])) |
|
| 2007 | - echo ' |
|
| 2112 | + if (!empty($incontext['error'])) { |
|
| 2113 | + echo ' |
|
| 2008 | 2114 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 2009 | 2115 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 2010 | 2116 | <strong style="text-decoration: underline;">', $txt['upgrade_critical_error'], '</strong><br> |
@@ -2012,9 +2118,10 @@ discard block |
||
| 2012 | 2118 | ', $incontext['error'], ' |
| 2013 | 2119 | </div> |
| 2014 | 2120 | </div>'; |
| 2121 | + } |
|
| 2015 | 2122 | // A warning message? |
| 2016 | - elseif (!empty($incontext['warning'])) |
|
| 2017 | - echo ' |
|
| 2123 | + elseif (!empty($incontext['warning'])) { |
|
| 2124 | + echo ' |
|
| 2018 | 2125 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 2019 | 2126 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 2020 | 2127 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -2022,6 +2129,7 @@ discard block |
||
| 2022 | 2129 | ', $incontext['warning'], ' |
| 2023 | 2130 | </div> |
| 2024 | 2131 | </div>'; |
| 2132 | + } |
|
| 2025 | 2133 | |
| 2026 | 2134 | return empty($incontext['error']) && empty($incontext['warning']); |
| 2027 | 2135 | } |
@@ -2037,27 +2145,30 @@ discard block |
||
| 2037 | 2145 | <li>', $incontext['failed_files']), '</li> |
| 2038 | 2146 | </ul>'; |
| 2039 | 2147 | |
| 2040 | - if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') |
|
| 2041 | - echo ' |
|
| 2148 | + if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') { |
|
| 2149 | + echo ' |
|
| 2042 | 2150 | <hr> |
| 2043 | 2151 | <p>', $txt['chmod_linux_info'], '</p> |
| 2044 | 2152 | <tt># chmod a+w ', implode(' ' . $incontext['detected_path'] . '/', $incontext['failed_files']), '</tt>'; |
| 2153 | + } |
|
| 2045 | 2154 | |
| 2046 | 2155 | // This is serious! |
| 2047 | - if (!template_warning_divs()) |
|
| 2048 | - return; |
|
| 2156 | + if (!template_warning_divs()) { |
|
| 2157 | + return; |
|
| 2158 | + } |
|
| 2049 | 2159 | |
| 2050 | 2160 | echo ' |
| 2051 | 2161 | <hr> |
| 2052 | 2162 | <p>', $txt['ftp_setup_info'], '</p>'; |
| 2053 | 2163 | |
| 2054 | - if (!empty($incontext['ftp_errors'])) |
|
| 2055 | - echo ' |
|
| 2164 | + if (!empty($incontext['ftp_errors'])) { |
|
| 2165 | + echo ' |
|
| 2056 | 2166 | <div class="error_message"> |
| 2057 | 2167 | ', $txt['error_ftp_no_connect'], '<br><br> |
| 2058 | 2168 | <code>', implode('<br>', $incontext['ftp_errors']), '</code> |
| 2059 | 2169 | </div> |
| 2060 | 2170 | <br>'; |
| 2171 | + } |
|
| 2061 | 2172 | |
| 2062 | 2173 | echo ' |
| 2063 | 2174 | <form action="', $incontext['form_url'], '" method="post"> |
@@ -2117,17 +2228,17 @@ discard block |
||
| 2117 | 2228 | <td> |
| 2118 | 2229 | <select name="db_type" id="db_type_input" onchange="toggleDBInput();">'; |
| 2119 | 2230 | |
| 2120 | - foreach ($incontext['supported_databases'] as $key => $db) |
|
| 2121 | - echo ' |
|
| 2231 | + foreach ($incontext['supported_databases'] as $key => $db) { |
|
| 2232 | + echo ' |
|
| 2122 | 2233 | <option value="', $key, '"', isset($_POST['db_type']) && $_POST['db_type'] == $key ? ' selected' : '', '>', $db['name'], '</option>'; |
| 2234 | + } |
|
| 2123 | 2235 | |
| 2124 | 2236 | echo ' |
| 2125 | 2237 | </select> |
| 2126 | 2238 | <div class="smalltext block">', $txt['db_settings_type_info'], '</div> |
| 2127 | 2239 | </td> |
| 2128 | 2240 | </tr>'; |
| 2129 | - } |
|
| 2130 | - else |
|
| 2241 | + } else |
|
| 2131 | 2242 | { |
| 2132 | 2243 | echo ' |
| 2133 | 2244 | <tr style="display: none;"> |
@@ -2319,9 +2430,10 @@ discard block |
||
| 2319 | 2430 | <div style="color: red;">', $txt['error_db_queries'], '</div> |
| 2320 | 2431 | <ul>'; |
| 2321 | 2432 | |
| 2322 | - foreach ($incontext['failures'] as $line => $fail) |
|
| 2323 | - echo ' |
|
| 2433 | + foreach ($incontext['failures'] as $line => $fail) { |
|
| 2434 | + echo ' |
|
| 2324 | 2435 | <li><strong>', $txt['error_db_queries_line'], $line + 1, ':</strong> ', nl2br(htmlspecialchars($fail)), '</li>'; |
| 2436 | + } |
|
| 2325 | 2437 | |
| 2326 | 2438 | echo ' |
| 2327 | 2439 | </ul>'; |
@@ -2382,15 +2494,16 @@ discard block |
||
| 2382 | 2494 | </tr> |
| 2383 | 2495 | </table>'; |
| 2384 | 2496 | |
| 2385 | - if ($incontext['require_db_confirm']) |
|
| 2386 | - echo ' |
|
| 2497 | + if ($incontext['require_db_confirm']) { |
|
| 2498 | + echo ' |
|
| 2387 | 2499 | <h2>', $txt['user_settings_database'], '</h2> |
| 2388 | 2500 | <p>', $txt['user_settings_database_info'], '</p> |
| 2389 | 2501 | |
| 2390 | 2502 | <div style="margin-bottom: 2ex; padding-', $txt['lang_rtl'] == false ? 'left' : 'right', ': 50px;"> |
| 2391 | 2503 | <input type="password" name="password3" size="30" class="input_password" /> |
| 2392 | 2504 | </div>'; |
| 2393 | -} |
|
| 2505 | + } |
|
| 2506 | + } |
|
| 2394 | 2507 | |
| 2395 | 2508 | // Tell them it's done, and to delete. |
| 2396 | 2509 | function template_delete_install() |
@@ -2403,14 +2516,15 @@ discard block |
||
| 2403 | 2516 | template_warning_divs(); |
| 2404 | 2517 | |
| 2405 | 2518 | // Install directory still writable? |
| 2406 | - if ($incontext['dir_still_writable']) |
|
| 2407 | - echo ' |
|
| 2519 | + if ($incontext['dir_still_writable']) { |
|
| 2520 | + echo ' |
|
| 2408 | 2521 | <em>', $txt['still_writable'], '</em><br> |
| 2409 | 2522 | <br>'; |
| 2523 | + } |
|
| 2410 | 2524 | |
| 2411 | 2525 | // Don't show the box if it's like 99% sure it won't work :P. |
| 2412 | - if ($incontext['probably_delete_install']) |
|
| 2413 | - echo ' |
|
| 2526 | + if ($incontext['probably_delete_install']) { |
|
| 2527 | + echo ' |
|
| 2414 | 2528 | <div style="margin: 1ex; font-weight: bold;"> |
| 2415 | 2529 | <label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete();" class="input_check" /> ', $txt['delete_installer'], !isset($_SESSION['installer_temp_ftp']) ? ' ' . $txt['delete_installer_maybe'] : '', '</label> |
| 2416 | 2530 | </div> |
@@ -2426,6 +2540,7 @@ discard block |
||
| 2426 | 2540 | } |
| 2427 | 2541 | </script> |
| 2428 | 2542 | <br>'; |
| 2543 | + } |
|
| 2429 | 2544 | |
| 2430 | 2545 | echo ' |
| 2431 | 2546 | ', sprintf($txt['go_to_your_forum'], $boardurl . '/index.php'), '<br> |
@@ -75,8 +75,9 @@ discard block |
||
| 75 | 75 | $upcontext['inactive_timeout'] = 10; |
| 76 | 76 | |
| 77 | 77 | // The helper is crucial. Include it first thing. |
| 78 | -if (!file_exists($upgrade_path . '/upgrade-helper.php')) |
|
| 78 | +if (!file_exists($upgrade_path . '/upgrade-helper.php')) { |
|
| 79 | 79 | die('upgrade-helper.php not found where it was expected: ' . $upgrade_path . '/upgrade-helper.php! Make sure you have uploaded ALL files from the upgrade package. The upgrader cannot continue.'); |
| 80 | +} |
|
| 80 | 81 | |
| 81 | 82 | require_once($upgrade_path . '/upgrade-helper.php'); |
| 82 | 83 | |
@@ -100,11 +101,14 @@ discard block |
||
| 100 | 101 | ini_set('default_socket_timeout', 900); |
| 101 | 102 | } |
| 102 | 103 | // Clean the upgrade path if this is from the client. |
| 103 | -if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) |
|
| 104 | - for ($i = 1; $i < $_SERVER['argc']; $i++) |
|
| 104 | +if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) { |
|
| 105 | + for ($i = 1; |
|
| 106 | +} |
|
| 107 | +$i < $_SERVER['argc']; $i++) |
|
| 105 | 108 | { |
| 106 | - if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) |
|
| 107 | - $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
| 109 | + if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) { |
|
| 110 | + $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
| 111 | + } |
|
| 108 | 112 | } |
| 109 | 113 | |
| 110 | 114 | // Are we from the client? |
@@ -112,16 +116,17 @@ discard block |
||
| 112 | 116 | { |
| 113 | 117 | $command_line = true; |
| 114 | 118 | $disable_security = true; |
| 115 | -} |
|
| 116 | -else |
|
| 119 | +} else { |
|
| 117 | 120 | $command_line = false; |
| 121 | +} |
|
| 118 | 122 | |
| 119 | 123 | // Load this now just because we can. |
| 120 | 124 | require_once($upgrade_path . '/Settings.php'); |
| 121 | 125 | |
| 122 | 126 | // We don't use "-utf8" anymore... Tweak the entry that may have been loaded by Settings.php |
| 123 | -if (isset($language)) |
|
| 127 | +if (isset($language)) { |
|
| 124 | 128 | $language = str_ireplace('-utf8', '', $language); |
| 129 | +} |
|
| 125 | 130 | |
| 126 | 131 | // Are we logged in? |
| 127 | 132 | if (isset($upgradeData)) |
@@ -129,10 +134,12 @@ discard block |
||
| 129 | 134 | $upcontext['user'] = json_decode(base64_decode($upgradeData), true); |
| 130 | 135 | |
| 131 | 136 | // Check for sensible values. |
| 132 | - if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) |
|
| 133 | - $upcontext['user']['started'] = time(); |
|
| 134 | - if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) |
|
| 135 | - $upcontext['user']['updated'] = 0; |
|
| 137 | + if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) { |
|
| 138 | + $upcontext['user']['started'] = time(); |
|
| 139 | + } |
|
| 140 | + if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) { |
|
| 141 | + $upcontext['user']['updated'] = 0; |
|
| 142 | + } |
|
| 136 | 143 | |
| 137 | 144 | $upcontext['started'] = $upcontext['user']['started']; |
| 138 | 145 | $upcontext['updated'] = $upcontext['user']['updated']; |
@@ -190,8 +197,9 @@ discard block |
||
| 190 | 197 | 'db_error_skip' => true, |
| 191 | 198 | ) |
| 192 | 199 | ); |
| 193 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 194 | - $modSettings[$row['variable']] = $row['value']; |
|
| 200 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 201 | + $modSettings[$row['variable']] = $row['value']; |
|
| 202 | + } |
|
| 195 | 203 | $smcFunc['db_free_result']($request); |
| 196 | 204 | } |
| 197 | 205 | |
@@ -201,10 +209,12 @@ discard block |
||
| 201 | 209 | $modSettings['theme_url'] = 'Themes/default'; |
| 202 | 210 | $modSettings['images_url'] = 'Themes/default/images'; |
| 203 | 211 | } |
| 204 | -if (!isset($settings['default_theme_url'])) |
|
| 212 | +if (!isset($settings['default_theme_url'])) { |
|
| 205 | 213 | $settings['default_theme_url'] = $modSettings['theme_url']; |
| 206 | -if (!isset($settings['default_theme_dir'])) |
|
| 214 | +} |
|
| 215 | +if (!isset($settings['default_theme_dir'])) { |
|
| 207 | 216 | $settings['default_theme_dir'] = $modSettings['theme_dir']; |
| 217 | +} |
|
| 208 | 218 | |
| 209 | 219 | $upcontext['is_large_forum'] = (empty($modSettings['smfVersion']) || $modSettings['smfVersion'] <= '1.1 RC1') && !empty($modSettings['totalMessages']) && $modSettings['totalMessages'] > 75000; |
| 210 | 220 | // Default title... |
@@ -222,13 +232,15 @@ discard block |
||
| 222 | 232 | $support_js = $upcontext['upgrade_status']['js']; |
| 223 | 233 | |
| 224 | 234 | // Only set this if the upgrader status says so. |
| 225 | - if (empty($is_debug)) |
|
| 226 | - $is_debug = $upcontext['upgrade_status']['debug']; |
|
| 235 | + if (empty($is_debug)) { |
|
| 236 | + $is_debug = $upcontext['upgrade_status']['debug']; |
|
| 237 | + } |
|
| 227 | 238 | |
| 228 | 239 | // Load the language. |
| 229 | - if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 230 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 231 | -} |
|
| 240 | + if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 241 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 242 | + } |
|
| 243 | + } |
|
| 232 | 244 | // Set the defaults. |
| 233 | 245 | else |
| 234 | 246 | { |
@@ -246,15 +258,18 @@ discard block |
||
| 246 | 258 | } |
| 247 | 259 | |
| 248 | 260 | // If this isn't the first stage see whether they are logging in and resuming. |
| 249 | -if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) |
|
| 261 | +if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) { |
|
| 250 | 262 | checkLogin(); |
| 263 | +} |
|
| 251 | 264 | |
| 252 | -if ($command_line) |
|
| 265 | +if ($command_line) { |
|
| 253 | 266 | cmdStep0(); |
| 267 | +} |
|
| 254 | 268 | |
| 255 | 269 | // Don't error if we're using xml. |
| 256 | -if (isset($_GET['xml'])) |
|
| 270 | +if (isset($_GET['xml'])) { |
|
| 257 | 271 | $upcontext['return_error'] = true; |
| 272 | +} |
|
| 258 | 273 | |
| 259 | 274 | // Loop through all the steps doing each one as required. |
| 260 | 275 | $upcontext['overall_percent'] = 0; |
@@ -275,9 +290,9 @@ discard block |
||
| 275 | 290 | } |
| 276 | 291 | |
| 277 | 292 | // Call the step and if it returns false that means pause! |
| 278 | - if (function_exists($step[2]) && $step[2]() === false) |
|
| 279 | - break; |
|
| 280 | - elseif (function_exists($step[2])) { |
|
| 293 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
| 294 | + break; |
|
| 295 | + } elseif (function_exists($step[2])) { |
|
| 281 | 296 | //Start each new step with this unset, so the 'normal' template is called first |
| 282 | 297 | unset($_GET['xml']); |
| 283 | 298 | //Clear out warnings at the start of each step |
@@ -323,17 +338,18 @@ discard block |
||
| 323 | 338 | // This should not happen my dear... HELP ME DEVELOPERS!! |
| 324 | 339 | if (!empty($command_line)) |
| 325 | 340 | { |
| 326 | - if (function_exists('debug_print_backtrace')) |
|
| 327 | - debug_print_backtrace(); |
|
| 341 | + if (function_exists('debug_print_backtrace')) { |
|
| 342 | + debug_print_backtrace(); |
|
| 343 | + } |
|
| 328 | 344 | |
| 329 | 345 | echo "\n" . 'Error: Unexpected call to use the ' . (isset($upcontext['sub_template']) ? $upcontext['sub_template'] : '') . ' template. Please copy and paste all the text above and visit the SMF support forum to tell the Developers that they\'ve made a boo boo; they\'ll get you up and running again.'; |
| 330 | 346 | flush(); |
| 331 | 347 | die(); |
| 332 | 348 | } |
| 333 | 349 | |
| 334 | - if (!isset($_GET['xml'])) |
|
| 335 | - template_upgrade_above(); |
|
| 336 | - else |
|
| 350 | + if (!isset($_GET['xml'])) { |
|
| 351 | + template_upgrade_above(); |
|
| 352 | + } else |
|
| 337 | 353 | { |
| 338 | 354 | header('Content-Type: text/xml; charset=UTF-8'); |
| 339 | 355 | // Sadly we need to retain the $_GET data thanks to the old upgrade scripts. |
@@ -355,25 +371,29 @@ discard block |
||
| 355 | 371 | $upcontext['form_url'] = $upgradeurl . '?step=' . $upcontext['current_step'] . '&substep=' . $_GET['substep'] . '&data=' . base64_encode(json_encode($upcontext['upgrade_status'])); |
| 356 | 372 | |
| 357 | 373 | // Custom stuff to pass back? |
| 358 | - if (!empty($upcontext['query_string'])) |
|
| 359 | - $upcontext['form_url'] .= $upcontext['query_string']; |
|
| 374 | + if (!empty($upcontext['query_string'])) { |
|
| 375 | + $upcontext['form_url'] .= $upcontext['query_string']; |
|
| 376 | + } |
|
| 360 | 377 | |
| 361 | 378 | // Call the appropriate subtemplate |
| 362 | - if (is_callable('template_' . $upcontext['sub_template'])) |
|
| 363 | - call_user_func('template_' . $upcontext['sub_template']); |
|
| 364 | - else |
|
| 365 | - die('Upgrade aborted! Invalid template: template_' . $upcontext['sub_template']); |
|
| 379 | + if (is_callable('template_' . $upcontext['sub_template'])) { |
|
| 380 | + call_user_func('template_' . $upcontext['sub_template']); |
|
| 381 | + } else { |
|
| 382 | + die('Upgrade aborted! Invalid template: template_' . $upcontext['sub_template']); |
|
| 383 | + } |
|
| 366 | 384 | } |
| 367 | 385 | |
| 368 | 386 | // Was there an error? |
| 369 | - if (!empty($upcontext['forced_error_message'])) |
|
| 370 | - echo $upcontext['forced_error_message']; |
|
| 387 | + if (!empty($upcontext['forced_error_message'])) { |
|
| 388 | + echo $upcontext['forced_error_message']; |
|
| 389 | + } |
|
| 371 | 390 | |
| 372 | 391 | // Show the footer. |
| 373 | - if (!isset($_GET['xml'])) |
|
| 374 | - template_upgrade_below(); |
|
| 375 | - else |
|
| 376 | - template_xml_below(); |
|
| 392 | + if (!isset($_GET['xml'])) { |
|
| 393 | + template_upgrade_below(); |
|
| 394 | + } else { |
|
| 395 | + template_xml_below(); |
|
| 396 | + } |
|
| 377 | 397 | } |
| 378 | 398 | |
| 379 | 399 | |
@@ -385,15 +405,19 @@ discard block |
||
| 385 | 405 | $seconds = intval($active % 60); |
| 386 | 406 | |
| 387 | 407 | $totalTime = ''; |
| 388 | - if ($hours > 0) |
|
| 389 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 390 | - if ($minutes > 0) |
|
| 391 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 392 | - if ($seconds > 0) |
|
| 393 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 408 | + if ($hours > 0) { |
|
| 409 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 410 | + } |
|
| 411 | + if ($minutes > 0) { |
|
| 412 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 413 | + } |
|
| 414 | + if ($seconds > 0) { |
|
| 415 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 416 | + } |
|
| 394 | 417 | |
| 395 | - if (!empty($totalTime)) |
|
| 396 | - echo "\n" . 'Upgrade completed in ' . $totalTime . "\n"; |
|
| 418 | + if (!empty($totalTime)) { |
|
| 419 | + echo "\n" . 'Upgrade completed in ' . $totalTime . "\n"; |
|
| 420 | + } |
|
| 397 | 421 | } |
| 398 | 422 | |
| 399 | 423 | // Bang - gone! |
@@ -406,8 +430,9 @@ discard block |
||
| 406 | 430 | global $upgradeurl, $upcontext, $command_line; |
| 407 | 431 | |
| 408 | 432 | // Command line users can't be redirected. |
| 409 | - if ($command_line) |
|
| 410 | - upgradeExit(true); |
|
| 433 | + if ($command_line) { |
|
| 434 | + upgradeExit(true); |
|
| 435 | + } |
|
| 411 | 436 | |
| 412 | 437 | // Are we providing the core info? |
| 413 | 438 | if ($addForm) |
@@ -433,12 +458,14 @@ discard block |
||
| 433 | 458 | define('SMF', 1); |
| 434 | 459 | |
| 435 | 460 | // Start the session. |
| 436 | - if (@ini_get('session.save_handler') == 'user') |
|
| 437 | - @ini_set('session.save_handler', 'files'); |
|
| 461 | + if (@ini_get('session.save_handler') == 'user') { |
|
| 462 | + @ini_set('session.save_handler', 'files'); |
|
| 463 | + } |
|
| 438 | 464 | @session_start(); |
| 439 | 465 | |
| 440 | - if (empty($smcFunc)) |
|
| 441 | - $smcFunc = array(); |
|
| 466 | + if (empty($smcFunc)) { |
|
| 467 | + $smcFunc = array(); |
|
| 468 | + } |
|
| 442 | 469 | |
| 443 | 470 | // We need this for authentication and some upgrade code |
| 444 | 471 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -465,24 +492,27 @@ discard block |
||
| 465 | 492 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
| 466 | 493 | |
| 467 | 494 | // Make the connection... |
| 468 | - if (empty($db_connection)) |
|
| 469 | - $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true)); |
|
| 470 | - else |
|
| 471 | - // If we've returned here, ping/reconnect to be safe |
|
| 495 | + if (empty($db_connection)) { |
|
| 496 | + $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true)); |
|
| 497 | + } else { |
|
| 498 | + // If we've returned here, ping/reconnect to be safe |
|
| 472 | 499 | $smcFunc['db_ping']($db_connection); |
| 500 | + } |
|
| 473 | 501 | |
| 474 | 502 | // Oh dear god!! |
| 475 | - if ($db_connection === null) |
|
| 476 | - die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
| 503 | + if ($db_connection === null) { |
|
| 504 | + die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
| 505 | + } |
|
| 477 | 506 | |
| 478 | - if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) |
|
| 479 | - $smcFunc['db_query']('', ' |
|
| 507 | + if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) { |
|
| 508 | + $smcFunc['db_query']('', ' |
|
| 480 | 509 | SET NAMES {string:db_character_set}', |
| 481 | 510 | array( |
| 482 | 511 | 'db_error_skip' => true, |
| 483 | 512 | 'db_character_set' => $db_character_set, |
| 484 | 513 | ) |
| 485 | 514 | ); |
| 515 | + } |
|
| 486 | 516 | |
| 487 | 517 | // Load the modSettings data... |
| 488 | 518 | $request = $smcFunc['db_query']('', ' |
@@ -493,11 +523,11 @@ discard block |
||
| 493 | 523 | ) |
| 494 | 524 | ); |
| 495 | 525 | $modSettings = array(); |
| 496 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 497 | - $modSettings[$row['variable']] = $row['value']; |
|
| 526 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 527 | + $modSettings[$row['variable']] = $row['value']; |
|
| 528 | + } |
|
| 498 | 529 | $smcFunc['db_free_result']($request); |
| 499 | - } |
|
| 500 | - else |
|
| 530 | + } else |
|
| 501 | 531 | { |
| 502 | 532 | return throw_error('Cannot find ' . $sourcedir . '/Subs-Db-' . $db_type . '.php' . '. Please check you have uploaded all source files and have the correct paths set.'); |
| 503 | 533 | } |
@@ -511,9 +541,10 @@ discard block |
||
| 511 | 541 | cleanRequest(); |
| 512 | 542 | } |
| 513 | 543 | |
| 514 | - if (!isset($_GET['substep'])) |
|
| 515 | - $_GET['substep'] = 0; |
|
| 516 | -} |
|
| 544 | + if (!isset($_GET['substep'])) { |
|
| 545 | + $_GET['substep'] = 0; |
|
| 546 | + } |
|
| 547 | + } |
|
| 517 | 548 | |
| 518 | 549 | function initialize_inputs() |
| 519 | 550 | { |
@@ -543,8 +574,9 @@ discard block |
||
| 543 | 574 | $dh = opendir(dirname(__FILE__)); |
| 544 | 575 | while ($file = readdir($dh)) |
| 545 | 576 | { |
| 546 | - if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) |
|
| 547 | - @unlink(dirname(__FILE__) . '/' . $file); |
|
| 577 | + if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) { |
|
| 578 | + @unlink(dirname(__FILE__) . '/' . $file); |
|
| 579 | + } |
|
| 548 | 580 | } |
| 549 | 581 | closedir($dh); |
| 550 | 582 | |
@@ -573,8 +605,9 @@ discard block |
||
| 573 | 605 | $temp = 'upgrade_php?step'; |
| 574 | 606 | while (strlen($temp) > 4) |
| 575 | 607 | { |
| 576 | - if (isset($_GET[$temp])) |
|
| 577 | - unset($_GET[$temp]); |
|
| 608 | + if (isset($_GET[$temp])) { |
|
| 609 | + unset($_GET[$temp]); |
|
| 610 | + } |
|
| 578 | 611 | $temp = substr($temp, 1); |
| 579 | 612 | } |
| 580 | 613 | |
@@ -601,32 +634,39 @@ discard block |
||
| 601 | 634 | && @file_exists(dirname(__FILE__) . '/upgrade_2-1_' . $db_type . '.sql'); |
| 602 | 635 | |
| 603 | 636 | // Need legacy scripts? |
| 604 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) |
|
| 605 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
| 606 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) |
|
| 607 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
| 608 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) |
|
| 609 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
| 637 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) { |
|
| 638 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
| 639 | + } |
|
| 640 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) { |
|
| 641 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
| 642 | + } |
|
| 643 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) { |
|
| 644 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
| 645 | + } |
|
| 610 | 646 | |
| 611 | 647 | // We don't need "-utf8" files anymore... |
| 612 | 648 | $upcontext['language'] = str_ireplace('-utf8', '', $upcontext['language']); |
| 613 | 649 | |
| 614 | 650 | // This needs to exist! |
| 615 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 616 | - return throw_error('The upgrader could not find the "Install" language file for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
| 617 | - else |
|
| 618 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 651 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 652 | + return throw_error('The upgrader could not find the "Install" language file for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
| 653 | + } else { |
|
| 654 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 655 | + } |
|
| 619 | 656 | |
| 620 | - if (!$check) |
|
| 621 | - // Don't tell them what files exactly because it's a spot check - just like teachers don't tell which problems they are spot checking, that's dumb. |
|
| 657 | + if (!$check) { |
|
| 658 | + // Don't tell them what files exactly because it's a spot check - just like teachers don't tell which problems they are spot checking, that's dumb. |
|
| 622 | 659 | return throw_error('The upgrader was unable to find some crucial files.<br><br>Please make sure you uploaded all of the files included in the package, including the Themes, Sources, and other directories.'); |
| 660 | + } |
|
| 623 | 661 | |
| 624 | 662 | // Do they meet the install requirements? |
| 625 | - if (!php_version_check()) |
|
| 626 | - return throw_error('Warning! You do not appear to have a version of PHP installed on your webserver that meets SMF\'s minimum installations requirements.<br><br>Please ask your host to upgrade.'); |
|
| 663 | + if (!php_version_check()) { |
|
| 664 | + return throw_error('Warning! You do not appear to have a version of PHP installed on your webserver that meets SMF\'s minimum installations requirements.<br><br>Please ask your host to upgrade.'); |
|
| 665 | + } |
|
| 627 | 666 | |
| 628 | - if (!db_version_check()) |
|
| 629 | - return throw_error('Your ' . $databases[$db_type]['name'] . ' version does not meet the minimum requirements of SMF.<br><br>Please ask your host to upgrade.'); |
|
| 667 | + if (!db_version_check()) { |
|
| 668 | + return throw_error('Your ' . $databases[$db_type]['name'] . ' version does not meet the minimum requirements of SMF.<br><br>Please ask your host to upgrade.'); |
|
| 669 | + } |
|
| 630 | 670 | |
| 631 | 671 | // Do some checks to make sure they have proper privileges |
| 632 | 672 | db_extend('packages'); |
@@ -641,14 +681,16 @@ discard block |
||
| 641 | 681 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
| 642 | 682 | |
| 643 | 683 | // Sorry... we need CREATE, ALTER and DROP |
| 644 | - if (!$create || !$alter || !$drop) |
|
| 645 | - return throw_error('The ' . $databases[$db_type]['name'] . ' user you have set in Settings.php does not have proper privileges.<br><br>Please ask your host to give this user the ALTER, CREATE, and DROP privileges.'); |
|
| 684 | + if (!$create || !$alter || !$drop) { |
|
| 685 | + return throw_error('The ' . $databases[$db_type]['name'] . ' user you have set in Settings.php does not have proper privileges.<br><br>Please ask your host to give this user the ALTER, CREATE, and DROP privileges.'); |
|
| 686 | + } |
|
| 646 | 687 | |
| 647 | 688 | // Do a quick version spot check. |
| 648 | 689 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
| 649 | 690 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
| 650 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
| 651 | - return throw_error('The upgrader found some old or outdated files.<br><br>Please make certain you uploaded the new versions of all the files included in the package.'); |
|
| 691 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
| 692 | + return throw_error('The upgrader found some old or outdated files.<br><br>Please make certain you uploaded the new versions of all the files included in the package.'); |
|
| 693 | + } |
|
| 652 | 694 | |
| 653 | 695 | // What absolutely needs to be writable? |
| 654 | 696 | $writable_files = array( |
@@ -670,12 +712,13 @@ discard block |
||
| 670 | 712 | quickFileWritable($custom_av_dir); |
| 671 | 713 | |
| 672 | 714 | // Are we good now? |
| 673 | - if (!is_writable($custom_av_dir)) |
|
| 674 | - return throw_error(sprintf('The directory: %1$s has to be writable to continue the upgrade. Please make sure permissions are correctly set to allow this.', $custom_av_dir)); |
|
| 675 | - elseif ($need_settings_update) |
|
| 715 | + if (!is_writable($custom_av_dir)) { |
|
| 716 | + return throw_error(sprintf('The directory: %1$s has to be writable to continue the upgrade. Please make sure permissions are correctly set to allow this.', $custom_av_dir)); |
|
| 717 | + } elseif ($need_settings_update) |
|
| 676 | 718 | { |
| 677 | - if (!function_exists('cache_put_data')) |
|
| 678 | - require_once($sourcedir . '/Load.php'); |
|
| 719 | + if (!function_exists('cache_put_data')) { |
|
| 720 | + require_once($sourcedir . '/Load.php'); |
|
| 721 | + } |
|
| 679 | 722 | updateSettings(array('custom_avatar_dir' => $custom_av_dir)); |
| 680 | 723 | updateSettings(array('custom_avatar_url' => $custom_av_url)); |
| 681 | 724 | } |
@@ -684,28 +727,33 @@ discard block |
||
| 684 | 727 | |
| 685 | 728 | // Check the cache directory. |
| 686 | 729 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
| 687 | - if (!file_exists($cachedir_temp)) |
|
| 688 | - @mkdir($cachedir_temp); |
|
| 689 | - if (!file_exists($cachedir_temp)) |
|
| 690 | - return throw_error('The cache directory could not be found.<br><br>Please make sure you have a directory called "cache" in your forum directory before continuing.'); |
|
| 691 | - |
|
| 692 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
| 693 | - return throw_error('The upgrader was unable to find language files for the language specified in Settings.php.<br>SMF will not work without the primary language files installed.<br><br>Please either install them, or <a href="' . $upgradeurl . '?step=0;lang=english">use english instead</a>.'); |
|
| 694 | - elseif (!isset($_GET['skiplang'])) |
|
| 730 | + if (!file_exists($cachedir_temp)) { |
|
| 731 | + @mkdir($cachedir_temp); |
|
| 732 | + } |
|
| 733 | + if (!file_exists($cachedir_temp)) { |
|
| 734 | + return throw_error('The cache directory could not be found.<br><br>Please make sure you have a directory called "cache" in your forum directory before continuing.'); |
|
| 735 | + } |
|
| 736 | + |
|
| 737 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
| 738 | + return throw_error('The upgrader was unable to find language files for the language specified in Settings.php.<br>SMF will not work without the primary language files installed.<br><br>Please either install them, or <a href="' . $upgradeurl . '?step=0;lang=english">use english instead</a>.'); |
|
| 739 | + } elseif (!isset($_GET['skiplang'])) |
|
| 695 | 740 | { |
| 696 | 741 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
| 697 | 742 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 698 | 743 | |
| 699 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 700 | - return throw_error('The upgrader found some old or outdated language files, for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded the new versions of all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?skiplang">SKIP</a>] [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
| 744 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 745 | + return throw_error('The upgrader found some old or outdated language files, for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded the new versions of all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?skiplang">SKIP</a>] [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
| 746 | + } |
|
| 701 | 747 | } |
| 702 | 748 | |
| 703 | - if (!makeFilesWritable($writable_files)) |
|
| 704 | - return false; |
|
| 749 | + if (!makeFilesWritable($writable_files)) { |
|
| 750 | + return false; |
|
| 751 | + } |
|
| 705 | 752 | |
| 706 | 753 | // Check agreement.txt. (it may not exist, in which case $boarddir must be writable.) |
| 707 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
| 708 | - return throw_error('The upgrader was unable to obtain write access to agreement.txt.<br><br>If you are using a linux or unix based server, please ensure that the file is chmod\'d to 777, or if it does not exist that the directory this upgrader is in is 777.<br>If your server is running Windows, please ensure that the internet guest account has the proper permissions on it or its folder.'); |
|
| 754 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
| 755 | + return throw_error('The upgrader was unable to obtain write access to agreement.txt.<br><br>If you are using a linux or unix based server, please ensure that the file is chmod\'d to 777, or if it does not exist that the directory this upgrader is in is 777.<br>If your server is running Windows, please ensure that the internet guest account has the proper permissions on it or its folder.'); |
|
| 756 | + } |
|
| 709 | 757 | |
| 710 | 758 | // Upgrade the agreement. |
| 711 | 759 | elseif (isset($modSettings['agreement'])) |
@@ -716,8 +764,8 @@ discard block |
||
| 716 | 764 | } |
| 717 | 765 | |
| 718 | 766 | // We're going to check that their board dir setting is right in case they've been moving stuff around. |
| 719 | - if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) |
|
| 720 | - $upcontext['warning'] = ' |
|
| 767 | + if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) { |
|
| 768 | + $upcontext['warning'] = ' |
|
| 721 | 769 | It looks as if your board directory settings <em>might</em> be incorrect. Your board directory is currently set to "' . $boarddir . '" but should probably be "' . dirname(__FILE__) . '". Settings.php currently lists your paths as:<br> |
| 722 | 770 | <ul> |
| 723 | 771 | <li>Board Directory: ' . $boarddir . '</li> |
@@ -725,19 +773,23 @@ discard block |
||
| 725 | 773 | <li>Cache Directory: ' . $cachedir_temp . '</li> |
| 726 | 774 | </ul> |
| 727 | 775 | If these seem incorrect please open Settings.php in a text editor before proceeding with this upgrade. If they are incorrect due to you moving your forum to a new location please download and execute the <a href="https://download.simplemachines.org/?tools">Repair Settings</a> tool from the Simple Machines website before continuing.'; |
| 776 | + } |
|
| 728 | 777 | |
| 729 | 778 | // Confirm mbstring is loaded... |
| 730 | - if (!extension_loaded('mbstring')) |
|
| 731 | - return throw_error($txt['install_no_mbstring']); |
|
| 779 | + if (!extension_loaded('mbstring')) { |
|
| 780 | + return throw_error($txt['install_no_mbstring']); |
|
| 781 | + } |
|
| 732 | 782 | |
| 733 | 783 | // Check for https stream support. |
| 734 | 784 | $supported_streams = stream_get_wrappers(); |
| 735 | - if (!in_array('https', $supported_streams)) |
|
| 736 | - $upcontext['custom_warning'] = $txt['install_no_https']; |
|
| 785 | + if (!in_array('https', $supported_streams)) { |
|
| 786 | + $upcontext['custom_warning'] = $txt['install_no_https']; |
|
| 787 | + } |
|
| 737 | 788 | |
| 738 | 789 | // Either we're logged in or we're going to present the login. |
| 739 | - if (checkLogin()) |
|
| 740 | - return true; |
|
| 790 | + if (checkLogin()) { |
|
| 791 | + return true; |
|
| 792 | + } |
|
| 741 | 793 | |
| 742 | 794 | $upcontext += createToken('login'); |
| 743 | 795 | |
@@ -751,15 +803,17 @@ discard block |
||
| 751 | 803 | global $smcFunc, $db_type, $support_js; |
| 752 | 804 | |
| 753 | 805 | // Don't bother if the security is disabled. |
| 754 | - if ($disable_security) |
|
| 755 | - return true; |
|
| 806 | + if ($disable_security) { |
|
| 807 | + return true; |
|
| 808 | + } |
|
| 756 | 809 | |
| 757 | 810 | // Are we trying to login? |
| 758 | 811 | if (isset($_POST['contbutt']) && (!empty($_POST['user']))) |
| 759 | 812 | { |
| 760 | 813 | // If we've disabled security pick a suitable name! |
| 761 | - if (empty($_POST['user'])) |
|
| 762 | - $_POST['user'] = 'Administrator'; |
|
| 814 | + if (empty($_POST['user'])) { |
|
| 815 | + $_POST['user'] = 'Administrator'; |
|
| 816 | + } |
|
| 763 | 817 | |
| 764 | 818 | // Before 2.0 these column names were different! |
| 765 | 819 | $oldDB = false; |
@@ -774,16 +828,17 @@ discard block |
||
| 774 | 828 | 'db_error_skip' => true, |
| 775 | 829 | ) |
| 776 | 830 | ); |
| 777 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 778 | - $oldDB = true; |
|
| 831 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 832 | + $oldDB = true; |
|
| 833 | + } |
|
| 779 | 834 | $smcFunc['db_free_result']($request); |
| 780 | 835 | } |
| 781 | 836 | |
| 782 | 837 | // Get what we believe to be their details. |
| 783 | 838 | if (!$disable_security) |
| 784 | 839 | { |
| 785 | - if ($oldDB) |
|
| 786 | - $request = $smcFunc['db_query']('', ' |
|
| 840 | + if ($oldDB) { |
|
| 841 | + $request = $smcFunc['db_query']('', ' |
|
| 787 | 842 | SELECT id_member, memberName AS member_name, passwd, id_group, |
| 788 | 843 | additionalGroups AS additional_groups, lngfile |
| 789 | 844 | FROM {db_prefix}members |
@@ -793,8 +848,8 @@ discard block |
||
| 793 | 848 | 'db_error_skip' => true, |
| 794 | 849 | ) |
| 795 | 850 | ); |
| 796 | - else |
|
| 797 | - $request = $smcFunc['db_query']('', ' |
|
| 851 | + } else { |
|
| 852 | + $request = $smcFunc['db_query']('', ' |
|
| 798 | 853 | SELECT id_member, member_name, passwd, id_group, additional_groups, lngfile |
| 799 | 854 | FROM {db_prefix}members |
| 800 | 855 | WHERE member_name = {string:member_name}', |
@@ -803,6 +858,7 @@ discard block |
||
| 803 | 858 | 'db_error_skip' => true, |
| 804 | 859 | ) |
| 805 | 860 | ); |
| 861 | + } |
|
| 806 | 862 | if ($smcFunc['db_num_rows']($request) != 0) |
| 807 | 863 | { |
| 808 | 864 | list ($id_member, $name, $password, $id_group, $addGroups, $user_language) = $smcFunc['db_fetch_row']($request); |
@@ -810,16 +866,17 @@ discard block |
||
| 810 | 866 | $groups = explode(',', $addGroups); |
| 811 | 867 | $groups[] = $id_group; |
| 812 | 868 | |
| 813 | - foreach ($groups as $k => $v) |
|
| 814 | - $groups[$k] = (int) $v; |
|
| 869 | + foreach ($groups as $k => $v) { |
|
| 870 | + $groups[$k] = (int) $v; |
|
| 871 | + } |
|
| 815 | 872 | |
| 816 | 873 | $sha_passwd = sha1(strtolower($name) . un_htmlspecialchars($_REQUEST['passwrd'])); |
| 817 | 874 | |
| 818 | 875 | // We don't use "-utf8" anymore... |
| 819 | 876 | $user_language = str_ireplace('-utf8', '', $user_language); |
| 877 | + } else { |
|
| 878 | + $upcontext['username_incorrect'] = true; |
|
| 820 | 879 | } |
| 821 | - else |
|
| 822 | - $upcontext['username_incorrect'] = true; |
|
| 823 | 880 | $smcFunc['db_free_result']($request); |
| 824 | 881 | } |
| 825 | 882 | $upcontext['username'] = $_POST['user']; |
@@ -829,13 +886,14 @@ discard block |
||
| 829 | 886 | { |
| 830 | 887 | $upcontext['upgrade_status']['js'] = 1; |
| 831 | 888 | $support_js = 1; |
| 889 | + } else { |
|
| 890 | + $support_js = 0; |
|
| 832 | 891 | } |
| 833 | - else |
|
| 834 | - $support_js = 0; |
|
| 835 | 892 | |
| 836 | 893 | // Note down the version we are coming from. |
| 837 | - if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) |
|
| 838 | - $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
| 894 | + if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) { |
|
| 895 | + $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
| 896 | + } |
|
| 839 | 897 | |
| 840 | 898 | // Didn't get anywhere? |
| 841 | 899 | if (!$disable_security && (empty($sha_passwd) || (!empty($password) ? $password : '') != $sha_passwd) && !hash_verify_password((!empty($name) ? $name : ''), $_REQUEST['passwrd'], (!empty($password) ? $password : '')) && empty($upcontext['username_incorrect'])) |
@@ -869,15 +927,15 @@ discard block |
||
| 869 | 927 | 'db_error_skip' => true, |
| 870 | 928 | ) |
| 871 | 929 | ); |
| 872 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 873 | - return throw_error('You need to be an admin to perform an upgrade!'); |
|
| 930 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 931 | + return throw_error('You need to be an admin to perform an upgrade!'); |
|
| 932 | + } |
|
| 874 | 933 | $smcFunc['db_free_result']($request); |
| 875 | 934 | } |
| 876 | 935 | |
| 877 | 936 | $upcontext['user']['id'] = $id_member; |
| 878 | 937 | $upcontext['user']['name'] = $name; |
| 879 | - } |
|
| 880 | - else |
|
| 938 | + } else |
|
| 881 | 939 | { |
| 882 | 940 | $upcontext['user']['id'] = 1; |
| 883 | 941 | $upcontext['user']['name'] = 'Administrator'; |
@@ -893,11 +951,11 @@ discard block |
||
| 893 | 951 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $user_language . '.php')), 0, 4096); |
| 894 | 952 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 895 | 953 | |
| 896 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 897 | - $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been updated to the latest version. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
| 898 | - elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) |
|
| 899 | - $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been uploaded/updated as the "Install" language file is missing. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
| 900 | - else |
|
| 954 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 955 | + $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been updated to the latest version. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
| 956 | + } elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) { |
|
| 957 | + $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been uploaded/updated as the "Install" language file is missing. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
| 958 | + } else |
|
| 901 | 959 | { |
| 902 | 960 | // Set this as the new language. |
| 903 | 961 | $upcontext['language'] = $user_language; |
@@ -941,8 +999,9 @@ discard block |
||
| 941 | 999 | unset($member_columns); |
| 942 | 1000 | |
| 943 | 1001 | // If we've not submitted then we're done. |
| 944 | - if (empty($_POST['upcont'])) |
|
| 945 | - return false; |
|
| 1002 | + if (empty($_POST['upcont'])) { |
|
| 1003 | + return false; |
|
| 1004 | + } |
|
| 946 | 1005 | |
| 947 | 1006 | // Firstly, if they're enabling SM stat collection just do it. |
| 948 | 1007 | if (!empty($_POST['stats']) && substr($boardurl, 0, 16) != 'http://localhost' && empty($modSettings['allow_sm_stats']) && empty($modSettings['enable_sm_stats'])) |
@@ -962,16 +1021,17 @@ discard block |
||
| 962 | 1021 | fwrite($fp, $out); |
| 963 | 1022 | |
| 964 | 1023 | $return_data = ''; |
| 965 | - while (!feof($fp)) |
|
| 966 | - $return_data .= fgets($fp, 128); |
|
| 1024 | + while (!feof($fp)) { |
|
| 1025 | + $return_data .= fgets($fp, 128); |
|
| 1026 | + } |
|
| 967 | 1027 | |
| 968 | 1028 | fclose($fp); |
| 969 | 1029 | |
| 970 | 1030 | // Get the unique site ID. |
| 971 | 1031 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
| 972 | 1032 | |
| 973 | - if (!empty($ID[1])) |
|
| 974 | - $smcFunc['db_insert']('replace', |
|
| 1033 | + if (!empty($ID[1])) { |
|
| 1034 | + $smcFunc['db_insert']('replace', |
|
| 975 | 1035 | $db_prefix . 'settings', |
| 976 | 1036 | array('variable' => 'string', 'value' => 'string'), |
| 977 | 1037 | array( |
@@ -980,9 +1040,9 @@ discard block |
||
| 980 | 1040 | ), |
| 981 | 1041 | array('variable') |
| 982 | 1042 | ); |
| 1043 | + } |
|
| 983 | 1044 | } |
| 984 | - } |
|
| 985 | - else |
|
| 1045 | + } else |
|
| 986 | 1046 | { |
| 987 | 1047 | $smcFunc['db_insert']('replace', |
| 988 | 1048 | $db_prefix . 'settings', |
@@ -993,8 +1053,8 @@ discard block |
||
| 993 | 1053 | } |
| 994 | 1054 | } |
| 995 | 1055 | // Don't remove stat collection unless we unchecked the box for real, not from the loop. |
| 996 | - elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) |
|
| 997 | - $smcFunc['db_query']('', ' |
|
| 1056 | + elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) { |
|
| 1057 | + $smcFunc['db_query']('', ' |
|
| 998 | 1058 | DELETE FROM {db_prefix}settings |
| 999 | 1059 | WHERE variable = {string:enable_sm_stats}', |
| 1000 | 1060 | array( |
@@ -1002,6 +1062,7 @@ discard block |
||
| 1002 | 1062 | 'db_error_skip' => true, |
| 1003 | 1063 | ) |
| 1004 | 1064 | ); |
| 1065 | + } |
|
| 1005 | 1066 | |
| 1006 | 1067 | // Deleting old karma stuff? |
| 1007 | 1068 | if (!empty($_POST['delete_karma'])) |
@@ -1016,20 +1077,22 @@ discard block |
||
| 1016 | 1077 | ); |
| 1017 | 1078 | |
| 1018 | 1079 | // Cleaning up old karma member settings. |
| 1019 | - if ($upcontext['karma_installed']['good']) |
|
| 1020 | - $smcFunc['db_query']('', ' |
|
| 1080 | + if ($upcontext['karma_installed']['good']) { |
|
| 1081 | + $smcFunc['db_query']('', ' |
|
| 1021 | 1082 | ALTER TABLE {db_prefix}members |
| 1022 | 1083 | DROP karma_good', |
| 1023 | 1084 | array() |
| 1024 | 1085 | ); |
| 1086 | + } |
|
| 1025 | 1087 | |
| 1026 | 1088 | // Does karma bad was enable? |
| 1027 | - if ($upcontext['karma_installed']['bad']) |
|
| 1028 | - $smcFunc['db_query']('', ' |
|
| 1089 | + if ($upcontext['karma_installed']['bad']) { |
|
| 1090 | + $smcFunc['db_query']('', ' |
|
| 1029 | 1091 | ALTER TABLE {db_prefix}members |
| 1030 | 1092 | DROP karma_bad', |
| 1031 | 1093 | array() |
| 1032 | 1094 | ); |
| 1095 | + } |
|
| 1033 | 1096 | |
| 1034 | 1097 | // Cleaning up old karma permissions. |
| 1035 | 1098 | $smcFunc['db_query']('', ' |
@@ -1042,26 +1105,29 @@ discard block |
||
| 1042 | 1105 | } |
| 1043 | 1106 | |
| 1044 | 1107 | // Emptying the error log? |
| 1045 | - if (!empty($_POST['empty_error'])) |
|
| 1046 | - $smcFunc['db_query']('truncate_table', ' |
|
| 1108 | + if (!empty($_POST['empty_error'])) { |
|
| 1109 | + $smcFunc['db_query']('truncate_table', ' |
|
| 1047 | 1110 | TRUNCATE {db_prefix}log_errors', |
| 1048 | 1111 | array( |
| 1049 | 1112 | ) |
| 1050 | 1113 | ); |
| 1114 | + } |
|
| 1051 | 1115 | |
| 1052 | 1116 | $changes = array(); |
| 1053 | 1117 | |
| 1054 | 1118 | // Add proxy settings. |
| 1055 | - if (!isset($GLOBALS['image_proxy_maxsize'])) |
|
| 1056 | - $changes += array( |
|
| 1119 | + if (!isset($GLOBALS['image_proxy_maxsize'])) { |
|
| 1120 | + $changes += array( |
|
| 1057 | 1121 | 'image_proxy_secret' => '\'' . substr(sha1(mt_rand()), 0, 20) . '\'', |
| 1058 | 1122 | 'image_proxy_maxsize' => 5190, |
| 1059 | 1123 | 'image_proxy_enabled' => 0, |
| 1060 | 1124 | ); |
| 1125 | + } |
|
| 1061 | 1126 | |
| 1062 | 1127 | // If we're overriding the language follow it through. |
| 1063 | - if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) |
|
| 1064 | - $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
| 1128 | + if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) { |
|
| 1129 | + $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
| 1130 | + } |
|
| 1065 | 1131 | |
| 1066 | 1132 | if (!empty($_POST['maint'])) |
| 1067 | 1133 | { |
@@ -1073,26 +1139,29 @@ discard block |
||
| 1073 | 1139 | { |
| 1074 | 1140 | $changes['mtitle'] = '\'' . addslashes($_POST['maintitle']) . '\''; |
| 1075 | 1141 | $changes['mmessage'] = '\'' . addslashes($_POST['mainmessage']) . '\''; |
| 1076 | - } |
|
| 1077 | - else |
|
| 1142 | + } else |
|
| 1078 | 1143 | { |
| 1079 | 1144 | $changes['mtitle'] = '\'Upgrading the forum...\''; |
| 1080 | 1145 | $changes['mmessage'] = '\'Don\\\'t worry, we will be back shortly with an updated forum. It will only be a minute ;).\''; |
| 1081 | 1146 | } |
| 1082 | 1147 | } |
| 1083 | 1148 | |
| 1084 | - if ($command_line) |
|
| 1085 | - echo ' * Updating Settings.php...'; |
|
| 1149 | + if ($command_line) { |
|
| 1150 | + echo ' * Updating Settings.php...'; |
|
| 1151 | + } |
|
| 1086 | 1152 | |
| 1087 | 1153 | // Fix some old paths. |
| 1088 | - if (substr($boarddir, 0, 1) == '.') |
|
| 1089 | - $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
| 1154 | + if (substr($boarddir, 0, 1) == '.') { |
|
| 1155 | + $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
| 1156 | + } |
|
| 1090 | 1157 | |
| 1091 | - if (substr($sourcedir, 0, 1) == '.') |
|
| 1092 | - $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
| 1158 | + if (substr($sourcedir, 0, 1) == '.') { |
|
| 1159 | + $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
| 1160 | + } |
|
| 1093 | 1161 | |
| 1094 | - if (empty($cachedir) || substr($cachedir, 0, 1) == '.') |
|
| 1095 | - $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
| 1162 | + if (empty($cachedir) || substr($cachedir, 0, 1) == '.') { |
|
| 1163 | + $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
| 1164 | + } |
|
| 1096 | 1165 | |
| 1097 | 1166 | // If they have a "host:port" setup for the host, split that into separate values |
| 1098 | 1167 | // You should never have a : in the hostname if you're not on MySQL, but better safe than sorry |
@@ -1103,32 +1172,36 @@ discard block |
||
| 1103 | 1172 | $changes['db_server'] = '\'' . $db_server . '\''; |
| 1104 | 1173 | |
| 1105 | 1174 | // Only set this if we're not using the default port |
| 1106 | - if ($db_port != ini_get('mysqli.default_port')) |
|
| 1107 | - $changes['db_port'] = (int) $db_port; |
|
| 1108 | - } |
|
| 1109 | - elseif (!empty($db_port)) |
|
| 1175 | + if ($db_port != ini_get('mysqli.default_port')) { |
|
| 1176 | + $changes['db_port'] = (int) $db_port; |
|
| 1177 | + } |
|
| 1178 | + } elseif (!empty($db_port)) |
|
| 1110 | 1179 | { |
| 1111 | 1180 | // If db_port is set and is the same as the default, set it to '' |
| 1112 | 1181 | if ($db_type == 'mysql') |
| 1113 | 1182 | { |
| 1114 | - if ($db_port == ini_get('mysqli.default_port')) |
|
| 1115 | - $changes['db_port'] = '\'\''; |
|
| 1116 | - elseif ($db_type == 'postgresql' && $db_port == 5432) |
|
| 1117 | - $changes['db_port'] = '\'\''; |
|
| 1183 | + if ($db_port == ini_get('mysqli.default_port')) { |
|
| 1184 | + $changes['db_port'] = '\'\''; |
|
| 1185 | + } elseif ($db_type == 'postgresql' && $db_port == 5432) { |
|
| 1186 | + $changes['db_port'] = '\'\''; |
|
| 1187 | + } |
|
| 1118 | 1188 | } |
| 1119 | 1189 | } |
| 1120 | 1190 | |
| 1121 | 1191 | // Maybe we haven't had this option yet? |
| 1122 | - if (empty($packagesdir)) |
|
| 1123 | - $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
| 1192 | + if (empty($packagesdir)) { |
|
| 1193 | + $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
| 1194 | + } |
|
| 1124 | 1195 | |
| 1125 | 1196 | // Add support for $tasksdir var. |
| 1126 | - if (empty($tasksdir)) |
|
| 1127 | - $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
| 1197 | + if (empty($tasksdir)) { |
|
| 1198 | + $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
| 1199 | + } |
|
| 1128 | 1200 | |
| 1129 | 1201 | // Make sure we fix the language as well. |
| 1130 | - if (stristr($language, '-utf8')) |
|
| 1131 | - $changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\''; |
|
| 1202 | + if (stristr($language, '-utf8')) { |
|
| 1203 | + $changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\''; |
|
| 1204 | + } |
|
| 1132 | 1205 | |
| 1133 | 1206 | // @todo Maybe change the cookie name if going to 1.1, too? |
| 1134 | 1207 | |
@@ -1136,8 +1209,9 @@ discard block |
||
| 1136 | 1209 | require_once($sourcedir . '/Subs-Admin.php'); |
| 1137 | 1210 | updateSettingsFile($changes); |
| 1138 | 1211 | |
| 1139 | - if ($command_line) |
|
| 1140 | - echo ' Successful.' . "\n"; |
|
| 1212 | + if ($command_line) { |
|
| 1213 | + echo ' Successful.' . "\n"; |
|
| 1214 | + } |
|
| 1141 | 1215 | |
| 1142 | 1216 | // Are we doing debug? |
| 1143 | 1217 | if (isset($_POST['debug'])) |
@@ -1147,8 +1221,9 @@ discard block |
||
| 1147 | 1221 | } |
| 1148 | 1222 | |
| 1149 | 1223 | // If we're not backing up then jump one. |
| 1150 | - if (empty($_POST['backup'])) |
|
| 1151 | - $upcontext['current_step']++; |
|
| 1224 | + if (empty($_POST['backup'])) { |
|
| 1225 | + $upcontext['current_step']++; |
|
| 1226 | + } |
|
| 1152 | 1227 | |
| 1153 | 1228 | // If we've got here then let's proceed to the next step! |
| 1154 | 1229 | return true; |
@@ -1163,8 +1238,9 @@ discard block |
||
| 1163 | 1238 | $upcontext['page_title'] = 'Backup Database'; |
| 1164 | 1239 | |
| 1165 | 1240 | // Done it already - js wise? |
| 1166 | - if (!empty($_POST['backup_done'])) |
|
| 1167 | - return true; |
|
| 1241 | + if (!empty($_POST['backup_done'])) { |
|
| 1242 | + return true; |
|
| 1243 | + } |
|
| 1168 | 1244 | |
| 1169 | 1245 | // Some useful stuff here. |
| 1170 | 1246 | db_extend(); |
@@ -1178,9 +1254,10 @@ discard block |
||
| 1178 | 1254 | $tables = $smcFunc['db_list_tables']($db, $filter); |
| 1179 | 1255 | |
| 1180 | 1256 | $table_names = array(); |
| 1181 | - foreach ($tables as $table) |
|
| 1182 | - if (substr($table, 0, 7) !== 'backup_') |
|
| 1257 | + foreach ($tables as $table) { |
|
| 1258 | + if (substr($table, 0, 7) !== 'backup_') |
|
| 1183 | 1259 | $table_names[] = $table; |
| 1260 | + } |
|
| 1184 | 1261 | |
| 1185 | 1262 | $upcontext['table_count'] = count($table_names); |
| 1186 | 1263 | $upcontext['cur_table_num'] = $_GET['substep']; |
@@ -1190,12 +1267,14 @@ discard block |
||
| 1190 | 1267 | $file_steps = $upcontext['table_count']; |
| 1191 | 1268 | |
| 1192 | 1269 | // What ones have we already done? |
| 1193 | - foreach ($table_names as $id => $table) |
|
| 1194 | - if ($id < $_GET['substep']) |
|
| 1270 | + foreach ($table_names as $id => $table) { |
|
| 1271 | + if ($id < $_GET['substep']) |
|
| 1195 | 1272 | $upcontext['previous_tables'][] = $table; |
| 1273 | + } |
|
| 1196 | 1274 | |
| 1197 | - if ($command_line) |
|
| 1198 | - echo 'Backing Up Tables.'; |
|
| 1275 | + if ($command_line) { |
|
| 1276 | + echo 'Backing Up Tables.'; |
|
| 1277 | + } |
|
| 1199 | 1278 | |
| 1200 | 1279 | // If we don't support javascript we backup here. |
| 1201 | 1280 | if (!$support_js || isset($_GET['xml'])) |
@@ -1214,8 +1293,9 @@ discard block |
||
| 1214 | 1293 | backupTable($table_names[$substep]); |
| 1215 | 1294 | |
| 1216 | 1295 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 1217 | - if (isset($_GET['xml'])) |
|
| 1218 | - return upgradeExit(); |
|
| 1296 | + if (isset($_GET['xml'])) { |
|
| 1297 | + return upgradeExit(); |
|
| 1298 | + } |
|
| 1219 | 1299 | } |
| 1220 | 1300 | |
| 1221 | 1301 | if ($command_line) |
@@ -1248,9 +1328,10 @@ discard block |
||
| 1248 | 1328 | |
| 1249 | 1329 | $smcFunc['db_backup_table']($table, 'backup_' . $table); |
| 1250 | 1330 | |
| 1251 | - if ($command_line) |
|
| 1252 | - echo ' done.'; |
|
| 1253 | -} |
|
| 1331 | + if ($command_line) { |
|
| 1332 | + echo ' done.'; |
|
| 1333 | + } |
|
| 1334 | + } |
|
| 1254 | 1335 | |
| 1255 | 1336 | // Step 2: Everything. |
| 1256 | 1337 | function DatabaseChanges() |
@@ -1259,8 +1340,9 @@ discard block |
||
| 1259 | 1340 | global $upcontext, $support_js, $db_type; |
| 1260 | 1341 | |
| 1261 | 1342 | // Have we just completed this? |
| 1262 | - if (!empty($_POST['database_done'])) |
|
| 1263 | - return true; |
|
| 1343 | + if (!empty($_POST['database_done'])) { |
|
| 1344 | + return true; |
|
| 1345 | + } |
|
| 1264 | 1346 | |
| 1265 | 1347 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'database_xml' : 'database_changes'; |
| 1266 | 1348 | $upcontext['page_title'] = 'Database Changes'; |
@@ -1275,15 +1357,16 @@ discard block |
||
| 1275 | 1357 | ); |
| 1276 | 1358 | |
| 1277 | 1359 | // How many files are there in total? |
| 1278 | - if (isset($_GET['filecount'])) |
|
| 1279 | - $upcontext['file_count'] = (int) $_GET['filecount']; |
|
| 1280 | - else |
|
| 1360 | + if (isset($_GET['filecount'])) { |
|
| 1361 | + $upcontext['file_count'] = (int) $_GET['filecount']; |
|
| 1362 | + } else |
|
| 1281 | 1363 | { |
| 1282 | 1364 | $upcontext['file_count'] = 0; |
| 1283 | 1365 | foreach ($files as $file) |
| 1284 | 1366 | { |
| 1285 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) |
|
| 1286 | - $upcontext['file_count']++; |
|
| 1367 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) { |
|
| 1368 | + $upcontext['file_count']++; |
|
| 1369 | + } |
|
| 1287 | 1370 | } |
| 1288 | 1371 | } |
| 1289 | 1372 | |
@@ -1293,9 +1376,9 @@ discard block |
||
| 1293 | 1376 | $upcontext['cur_file_num'] = 0; |
| 1294 | 1377 | foreach ($files as $file) |
| 1295 | 1378 | { |
| 1296 | - if ($did_not_do) |
|
| 1297 | - $did_not_do--; |
|
| 1298 | - else |
|
| 1379 | + if ($did_not_do) { |
|
| 1380 | + $did_not_do--; |
|
| 1381 | + } else |
|
| 1299 | 1382 | { |
| 1300 | 1383 | $upcontext['cur_file_num']++; |
| 1301 | 1384 | $upcontext['cur_file_name'] = $file[0]; |
@@ -1322,12 +1405,13 @@ discard block |
||
| 1322 | 1405 | // Flag to move on to the next. |
| 1323 | 1406 | $upcontext['completed_step'] = true; |
| 1324 | 1407 | // Did we complete the whole file? |
| 1325 | - if ($nextFile) |
|
| 1326 | - $upcontext['current_debug_item_num'] = -1; |
|
| 1408 | + if ($nextFile) { |
|
| 1409 | + $upcontext['current_debug_item_num'] = -1; |
|
| 1410 | + } |
|
| 1327 | 1411 | return upgradeExit(); |
| 1412 | + } elseif ($support_js) { |
|
| 1413 | + break; |
|
| 1328 | 1414 | } |
| 1329 | - elseif ($support_js) |
|
| 1330 | - break; |
|
| 1331 | 1415 | } |
| 1332 | 1416 | // Set the progress bar to be right as if we had - even if we hadn't... |
| 1333 | 1417 | $upcontext['step_progress'] = ($upcontext['cur_file_num'] / $upcontext['file_count']) * 100; |
@@ -1352,8 +1436,9 @@ discard block |
||
| 1352 | 1436 | global $command_line, $language, $upcontext, $sourcedir, $forum_version, $user_info, $maintenance, $smcFunc, $db_type; |
| 1353 | 1437 | |
| 1354 | 1438 | // Now it's nice to have some of the basic SMF source files. |
| 1355 | - if (!isset($_GET['ssi']) && !$command_line) |
|
| 1356 | - redirectLocation('&ssi=1'); |
|
| 1439 | + if (!isset($_GET['ssi']) && !$command_line) { |
|
| 1440 | + redirectLocation('&ssi=1'); |
|
| 1441 | + } |
|
| 1357 | 1442 | |
| 1358 | 1443 | $upcontext['sub_template'] = 'upgrade_complete'; |
| 1359 | 1444 | $upcontext['page_title'] = 'Upgrade Complete'; |
@@ -1369,14 +1454,16 @@ discard block |
||
| 1369 | 1454 | // Are we in maintenance mode? |
| 1370 | 1455 | if (isset($upcontext['user']['main'])) |
| 1371 | 1456 | { |
| 1372 | - if ($command_line) |
|
| 1373 | - echo ' * '; |
|
| 1457 | + if ($command_line) { |
|
| 1458 | + echo ' * '; |
|
| 1459 | + } |
|
| 1374 | 1460 | $upcontext['removed_maintenance'] = true; |
| 1375 | 1461 | $changes['maintenance'] = $upcontext['user']['main']; |
| 1376 | 1462 | } |
| 1377 | 1463 | // Otherwise if somehow we are in 2 let's go to 1. |
| 1378 | - elseif (!empty($maintenance) && $maintenance == 2) |
|
| 1379 | - $changes['maintenance'] = 1; |
|
| 1464 | + elseif (!empty($maintenance) && $maintenance == 2) { |
|
| 1465 | + $changes['maintenance'] = 1; |
|
| 1466 | + } |
|
| 1380 | 1467 | |
| 1381 | 1468 | // Wipe this out... |
| 1382 | 1469 | $upcontext['user'] = array(); |
@@ -1391,9 +1478,9 @@ discard block |
||
| 1391 | 1478 | $upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__); |
| 1392 | 1479 | |
| 1393 | 1480 | // Now is the perfect time to fetch the SM files. |
| 1394 | - if ($command_line) |
|
| 1395 | - cli_scheduled_fetchSMfiles(); |
|
| 1396 | - else |
|
| 1481 | + if ($command_line) { |
|
| 1482 | + cli_scheduled_fetchSMfiles(); |
|
| 1483 | + } else |
|
| 1397 | 1484 | { |
| 1398 | 1485 | require_once($sourcedir . '/ScheduledTasks.php'); |
| 1399 | 1486 | $forum_version = SMF_VERSION; // The variable is usually defined in index.php so lets just use the constant to do it for us. |
@@ -1401,8 +1488,9 @@ discard block |
||
| 1401 | 1488 | } |
| 1402 | 1489 | |
| 1403 | 1490 | // Log what we've done. |
| 1404 | - if (empty($user_info['id'])) |
|
| 1405 | - $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
| 1491 | + if (empty($user_info['id'])) { |
|
| 1492 | + $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
| 1493 | + } |
|
| 1406 | 1494 | |
| 1407 | 1495 | // Log the action manually, so CLI still works. |
| 1408 | 1496 | $smcFunc['db_insert']('', |
@@ -1421,8 +1509,9 @@ discard block |
||
| 1421 | 1509 | |
| 1422 | 1510 | // Save the current database version. |
| 1423 | 1511 | $server_version = $smcFunc['db_server_info'](); |
| 1424 | - if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
| 1425 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1512 | + if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
| 1513 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1514 | + } |
|
| 1426 | 1515 | |
| 1427 | 1516 | if ($command_line) |
| 1428 | 1517 | { |
@@ -1434,8 +1523,9 @@ discard block |
||
| 1434 | 1523 | |
| 1435 | 1524 | // Make sure it says we're done. |
| 1436 | 1525 | $upcontext['overall_percent'] = 100; |
| 1437 | - if (isset($upcontext['step_progress'])) |
|
| 1438 | - unset($upcontext['step_progress']); |
|
| 1526 | + if (isset($upcontext['step_progress'])) { |
|
| 1527 | + unset($upcontext['step_progress']); |
|
| 1528 | + } |
|
| 1439 | 1529 | |
| 1440 | 1530 | $_GET['substep'] = 0; |
| 1441 | 1531 | return false; |
@@ -1446,8 +1536,9 @@ discard block |
||
| 1446 | 1536 | { |
| 1447 | 1537 | global $sourcedir, $language, $forum_version, $modSettings, $smcFunc; |
| 1448 | 1538 | |
| 1449 | - if (empty($modSettings['time_format'])) |
|
| 1450 | - $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
| 1539 | + if (empty($modSettings['time_format'])) { |
|
| 1540 | + $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
| 1541 | + } |
|
| 1451 | 1542 | |
| 1452 | 1543 | // What files do we want to get |
| 1453 | 1544 | $request = $smcFunc['db_query']('', ' |
@@ -1481,8 +1572,9 @@ discard block |
||
| 1481 | 1572 | $file_data = fetch_web_data($url); |
| 1482 | 1573 | |
| 1483 | 1574 | // If we got an error - give up - the site might be down. |
| 1484 | - if ($file_data === false) |
|
| 1485 | - return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
| 1575 | + if ($file_data === false) { |
|
| 1576 | + return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
| 1577 | + } |
|
| 1486 | 1578 | |
| 1487 | 1579 | // Save the file to the database. |
| 1488 | 1580 | $smcFunc['db_query']('substring', ' |
@@ -1524,8 +1616,9 @@ discard block |
||
| 1524 | 1616 | $themeData = array(); |
| 1525 | 1617 | foreach ($values as $variable => $value) |
| 1526 | 1618 | { |
| 1527 | - if (!isset($value) || $value === null) |
|
| 1528 | - $value = 0; |
|
| 1619 | + if (!isset($value) || $value === null) { |
|
| 1620 | + $value = 0; |
|
| 1621 | + } |
|
| 1529 | 1622 | |
| 1530 | 1623 | $themeData[] = array(0, 1, $variable, $value); |
| 1531 | 1624 | } |
@@ -1554,8 +1647,9 @@ discard block |
||
| 1554 | 1647 | |
| 1555 | 1648 | foreach ($values as $variable => $value) |
| 1556 | 1649 | { |
| 1557 | - if (empty($modSettings[$value[0]])) |
|
| 1558 | - continue; |
|
| 1650 | + if (empty($modSettings[$value[0]])) { |
|
| 1651 | + continue; |
|
| 1652 | + } |
|
| 1559 | 1653 | |
| 1560 | 1654 | $smcFunc['db_query']('', ' |
| 1561 | 1655 | INSERT IGNORE INTO {db_prefix}themes |
@@ -1641,19 +1735,21 @@ discard block |
||
| 1641 | 1735 | set_error_handler( |
| 1642 | 1736 | function ($errno, $errstr, $errfile, $errline) use ($support_js) |
| 1643 | 1737 | { |
| 1644 | - if ($support_js) |
|
| 1645 | - return true; |
|
| 1646 | - else |
|
| 1647 | - echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
| 1738 | + if ($support_js) { |
|
| 1739 | + return true; |
|
| 1740 | + } else { |
|
| 1741 | + echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
| 1742 | + } |
|
| 1648 | 1743 | } |
| 1649 | 1744 | ); |
| 1650 | 1745 | |
| 1651 | 1746 | // If we're on MySQL, set {db_collation}; this approach is used throughout upgrade_2-0_mysql.php to set new tables to utf8 |
| 1652 | 1747 | // Note it is expected to be in the format: ENGINE=MyISAM{$db_collation}; |
| 1653 | - if ($db_type == 'mysql') |
|
| 1654 | - $db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
| 1655 | - else |
|
| 1656 | - $db_collation = ''; |
|
| 1748 | + if ($db_type == 'mysql') { |
|
| 1749 | + $db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
| 1750 | + } else { |
|
| 1751 | + $db_collation = ''; |
|
| 1752 | + } |
|
| 1657 | 1753 | |
| 1658 | 1754 | $endl = $command_line ? "\n" : '<br>' . "\n"; |
| 1659 | 1755 | |
@@ -1665,8 +1761,9 @@ discard block |
||
| 1665 | 1761 | $last_step = ''; |
| 1666 | 1762 | |
| 1667 | 1763 | // Make sure all newly created tables will have the proper characters set; this approach is used throughout upgrade_2-1_mysql.php |
| 1668 | - if (isset($db_character_set) && $db_character_set === 'utf8') |
|
| 1669 | - $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
| 1764 | + if (isset($db_character_set) && $db_character_set === 'utf8') { |
|
| 1765 | + $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
| 1766 | + } |
|
| 1670 | 1767 | |
| 1671 | 1768 | // Count the total number of steps within this file - for progress. |
| 1672 | 1769 | $file_steps = substr_count(implode('', $lines), '---#'); |
@@ -1686,15 +1783,18 @@ discard block |
||
| 1686 | 1783 | $do_current = $substep >= $_GET['substep']; |
| 1687 | 1784 | |
| 1688 | 1785 | // Get rid of any comments in the beginning of the line... |
| 1689 | - if (substr(trim($line), 0, 2) === '/*') |
|
| 1690 | - $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
| 1786 | + if (substr(trim($line), 0, 2) === '/*') { |
|
| 1787 | + $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
| 1788 | + } |
|
| 1691 | 1789 | |
| 1692 | 1790 | // Always flush. Flush, flush, flush. Flush, flush, flush, flush! FLUSH! |
| 1693 | - if ($is_debug && !$support_js && $command_line) |
|
| 1694 | - flush(); |
|
| 1791 | + if ($is_debug && !$support_js && $command_line) { |
|
| 1792 | + flush(); |
|
| 1793 | + } |
|
| 1695 | 1794 | |
| 1696 | - if (trim($line) === '') |
|
| 1697 | - continue; |
|
| 1795 | + if (trim($line) === '') { |
|
| 1796 | + continue; |
|
| 1797 | + } |
|
| 1698 | 1798 | |
| 1699 | 1799 | if (trim(substr($line, 0, 3)) === '---') |
| 1700 | 1800 | { |
@@ -1704,8 +1804,9 @@ discard block |
||
| 1704 | 1804 | if (trim($current_data) != '' && $type !== '}') |
| 1705 | 1805 | { |
| 1706 | 1806 | $upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl; |
| 1707 | - if ($command_line) |
|
| 1708 | - echo $upcontext['error_message']; |
|
| 1807 | + if ($command_line) { |
|
| 1808 | + echo $upcontext['error_message']; |
|
| 1809 | + } |
|
| 1709 | 1810 | } |
| 1710 | 1811 | |
| 1711 | 1812 | if ($type == ' ') |
@@ -1723,17 +1824,18 @@ discard block |
||
| 1723 | 1824 | if ($do_current) |
| 1724 | 1825 | { |
| 1725 | 1826 | $upcontext['actioned_items'][] = $last_step; |
| 1726 | - if ($command_line) |
|
| 1727 | - echo ' * '; |
|
| 1827 | + if ($command_line) { |
|
| 1828 | + echo ' * '; |
|
| 1829 | + } |
|
| 1728 | 1830 | } |
| 1729 | - } |
|
| 1730 | - elseif ($type == '#') |
|
| 1831 | + } elseif ($type == '#') |
|
| 1731 | 1832 | { |
| 1732 | 1833 | $upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps; |
| 1733 | 1834 | |
| 1734 | 1835 | $upcontext['current_debug_item_num']++; |
| 1735 | - if (trim($line) != '---#') |
|
| 1736 | - $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1836 | + if (trim($line) != '---#') { |
|
| 1837 | + $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1838 | + } |
|
| 1737 | 1839 | |
| 1738 | 1840 | // Have we already done something? |
| 1739 | 1841 | if (isset($_GET['xml']) && $done_something) |
@@ -1744,34 +1846,36 @@ discard block |
||
| 1744 | 1846 | |
| 1745 | 1847 | if ($do_current) |
| 1746 | 1848 | { |
| 1747 | - if (trim($line) == '---#' && $command_line) |
|
| 1748 | - echo ' done.', $endl; |
|
| 1749 | - elseif ($command_line) |
|
| 1750 | - echo ' +++ ', rtrim(substr($line, 4)); |
|
| 1751 | - elseif (trim($line) != '---#') |
|
| 1849 | + if (trim($line) == '---#' && $command_line) { |
|
| 1850 | + echo ' done.', $endl; |
|
| 1851 | + } elseif ($command_line) { |
|
| 1852 | + echo ' +++ ', rtrim(substr($line, 4)); |
|
| 1853 | + } elseif (trim($line) != '---#') |
|
| 1752 | 1854 | { |
| 1753 | - if ($is_debug) |
|
| 1754 | - $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1855 | + if ($is_debug) { |
|
| 1856 | + $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1857 | + } |
|
| 1755 | 1858 | } |
| 1756 | 1859 | } |
| 1757 | 1860 | |
| 1758 | 1861 | if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep']) |
| 1759 | 1862 | { |
| 1760 | - if ($command_line) |
|
| 1761 | - echo ' * '; |
|
| 1762 | - else |
|
| 1763 | - $upcontext['actioned_items'][] = $last_step; |
|
| 1863 | + if ($command_line) { |
|
| 1864 | + echo ' * '; |
|
| 1865 | + } else { |
|
| 1866 | + $upcontext['actioned_items'][] = $last_step; |
|
| 1867 | + } |
|
| 1764 | 1868 | } |
| 1765 | 1869 | |
| 1766 | 1870 | // Small step - only if we're actually doing stuff. |
| 1767 | - if ($do_current) |
|
| 1768 | - nextSubstep(++$substep); |
|
| 1769 | - else |
|
| 1770 | - $substep++; |
|
| 1771 | - } |
|
| 1772 | - elseif ($type == '{') |
|
| 1773 | - $current_type = 'code'; |
|
| 1774 | - elseif ($type == '}') |
|
| 1871 | + if ($do_current) { |
|
| 1872 | + nextSubstep(++$substep); |
|
| 1873 | + } else { |
|
| 1874 | + $substep++; |
|
| 1875 | + } |
|
| 1876 | + } elseif ($type == '{') { |
|
| 1877 | + $current_type = 'code'; |
|
| 1878 | + } elseif ($type == '}') |
|
| 1775 | 1879 | { |
| 1776 | 1880 | $current_type = 'sql'; |
| 1777 | 1881 | |
@@ -1784,8 +1888,9 @@ discard block |
||
| 1784 | 1888 | if (eval('global $db_prefix, $modSettings, $smcFunc; ' . $current_data) === false) |
| 1785 | 1889 | { |
| 1786 | 1890 | $upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl; |
| 1787 | - if ($command_line) |
|
| 1788 | - echo $upcontext['error_message']; |
|
| 1891 | + if ($command_line) { |
|
| 1892 | + echo $upcontext['error_message']; |
|
| 1893 | + } |
|
| 1789 | 1894 | } |
| 1790 | 1895 | |
| 1791 | 1896 | // Done with code! |
@@ -1865,8 +1970,9 @@ discard block |
||
| 1865 | 1970 | $db_unbuffered = false; |
| 1866 | 1971 | |
| 1867 | 1972 | // Failure?! |
| 1868 | - if ($result !== false) |
|
| 1869 | - return $result; |
|
| 1973 | + if ($result !== false) { |
|
| 1974 | + return $result; |
|
| 1975 | + } |
|
| 1870 | 1976 | |
| 1871 | 1977 | $db_error_message = $smcFunc['db_error']($db_connection); |
| 1872 | 1978 | // If MySQL we do something more clever. |
@@ -1894,54 +2000,61 @@ discard block |
||
| 1894 | 2000 | { |
| 1895 | 2001 | mysqli_query($db_connection, 'REPAIR TABLE `' . $match[1] . '`'); |
| 1896 | 2002 | $result = mysqli_query($db_connection, $string); |
| 1897 | - if ($result !== false) |
|
| 1898 | - return $result; |
|
| 2003 | + if ($result !== false) { |
|
| 2004 | + return $result; |
|
| 2005 | + } |
|
| 1899 | 2006 | } |
| 1900 | - } |
|
| 1901 | - elseif ($mysqli_errno == 2013) |
|
| 2007 | + } elseif ($mysqli_errno == 2013) |
|
| 1902 | 2008 | { |
| 1903 | 2009 | $db_connection = mysqli_connect($db_server, $db_user, $db_passwd); |
| 1904 | 2010 | mysqli_select_db($db_connection, $db_name); |
| 1905 | 2011 | if ($db_connection) |
| 1906 | 2012 | { |
| 1907 | 2013 | $result = mysqli_query($db_connection, $string); |
| 1908 | - if ($result !== false) |
|
| 1909 | - return $result; |
|
| 2014 | + if ($result !== false) { |
|
| 2015 | + return $result; |
|
| 2016 | + } |
|
| 1910 | 2017 | } |
| 1911 | 2018 | } |
| 1912 | 2019 | // Duplicate column name... should be okay ;). |
| 1913 | - elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) |
|
| 1914 | - return false; |
|
| 2020 | + elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) { |
|
| 2021 | + return false; |
|
| 2022 | + } |
|
| 1915 | 2023 | // Duplicate insert... make sure it's the proper type of query ;). |
| 1916 | - elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) |
|
| 1917 | - return false; |
|
| 2024 | + elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) { |
|
| 2025 | + return false; |
|
| 2026 | + } |
|
| 1918 | 2027 | // Creating an index on a non-existent column. |
| 1919 | - elseif ($mysqli_errno == 1072) |
|
| 1920 | - return false; |
|
| 1921 | - elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') |
|
| 1922 | - return false; |
|
| 2028 | + elseif ($mysqli_errno == 1072) { |
|
| 2029 | + return false; |
|
| 2030 | + } elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') { |
|
| 2031 | + return false; |
|
| 2032 | + } |
|
| 1923 | 2033 | } |
| 1924 | 2034 | // If a table already exists don't go potty. |
| 1925 | 2035 | else |
| 1926 | 2036 | { |
| 1927 | 2037 | if (in_array(substr(trim($string), 0, 8), array('CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U'))) |
| 1928 | 2038 | { |
| 1929 | - if (strpos($db_error_message, 'exist') !== false) |
|
| 1930 | - return true; |
|
| 1931 | - } |
|
| 1932 | - elseif (strpos(trim($string), 'INSERT ') !== false) |
|
| 2039 | + if (strpos($db_error_message, 'exist') !== false) { |
|
| 2040 | + return true; |
|
| 2041 | + } |
|
| 2042 | + } elseif (strpos(trim($string), 'INSERT ') !== false) |
|
| 1933 | 2043 | { |
| 1934 | - if (strpos($db_error_message, 'duplicate') !== false) |
|
| 1935 | - return true; |
|
| 2044 | + if (strpos($db_error_message, 'duplicate') !== false) { |
|
| 2045 | + return true; |
|
| 2046 | + } |
|
| 1936 | 2047 | } |
| 1937 | 2048 | } |
| 1938 | 2049 | |
| 1939 | 2050 | // Get the query string so we pass everything. |
| 1940 | 2051 | $query_string = ''; |
| 1941 | - foreach ($_GET as $k => $v) |
|
| 1942 | - $query_string .= ';' . $k . '=' . $v; |
|
| 1943 | - if (strlen($query_string) != 0) |
|
| 1944 | - $query_string = '?' . substr($query_string, 1); |
|
| 2052 | + foreach ($_GET as $k => $v) { |
|
| 2053 | + $query_string .= ';' . $k . '=' . $v; |
|
| 2054 | + } |
|
| 2055 | + if (strlen($query_string) != 0) { |
|
| 2056 | + $query_string = '?' . substr($query_string, 1); |
|
| 2057 | + } |
|
| 1945 | 2058 | |
| 1946 | 2059 | if ($command_line) |
| 1947 | 2060 | { |
@@ -1996,16 +2109,18 @@ discard block |
||
| 1996 | 2109 | { |
| 1997 | 2110 | $found |= 1; |
| 1998 | 2111 | // Do some checks on the data if we have it set. |
| 1999 | - if (isset($change['col_type'])) |
|
| 2000 | - $found &= $change['col_type'] === $column['type']; |
|
| 2001 | - if (isset($change['null_allowed'])) |
|
| 2002 | - $found &= $column['null'] == $change['null_allowed']; |
|
| 2003 | - if (isset($change['default'])) |
|
| 2004 | - $found &= $change['default'] === $column['default']; |
|
| 2112 | + if (isset($change['col_type'])) { |
|
| 2113 | + $found &= $change['col_type'] === $column['type']; |
|
| 2114 | + } |
|
| 2115 | + if (isset($change['null_allowed'])) { |
|
| 2116 | + $found &= $column['null'] == $change['null_allowed']; |
|
| 2117 | + } |
|
| 2118 | + if (isset($change['default'])) { |
|
| 2119 | + $found &= $change['default'] === $column['default']; |
|
| 2120 | + } |
|
| 2005 | 2121 | } |
| 2006 | 2122 | } |
| 2007 | - } |
|
| 2008 | - elseif ($change['type'] === 'index') |
|
| 2123 | + } elseif ($change['type'] === 'index') |
|
| 2009 | 2124 | { |
| 2010 | 2125 | $request = upgrade_query(' |
| 2011 | 2126 | SHOW INDEX |
@@ -2014,9 +2129,10 @@ discard block |
||
| 2014 | 2129 | { |
| 2015 | 2130 | $cur_index = array(); |
| 2016 | 2131 | |
| 2017 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2018 | - if ($row['Key_name'] === $change['name']) |
|
| 2132 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2133 | + if ($row['Key_name'] === $change['name']) |
|
| 2019 | 2134 | $cur_index[(int) $row['Seq_in_index']] = $row['Column_name']; |
| 2135 | + } |
|
| 2020 | 2136 | |
| 2021 | 2137 | ksort($cur_index, SORT_NUMERIC); |
| 2022 | 2138 | $found = array_values($cur_index) === $change['target_columns']; |
@@ -2026,14 +2142,17 @@ discard block |
||
| 2026 | 2142 | } |
| 2027 | 2143 | |
| 2028 | 2144 | // If we're trying to add and it's added, we're done. |
| 2029 | - if ($found && in_array($change['method'], array('add', 'change'))) |
|
| 2030 | - return true; |
|
| 2145 | + if ($found && in_array($change['method'], array('add', 'change'))) { |
|
| 2146 | + return true; |
|
| 2147 | + } |
|
| 2031 | 2148 | // Otherwise if we're removing and it wasn't found we're also done. |
| 2032 | - elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) |
|
| 2033 | - return true; |
|
| 2149 | + elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) { |
|
| 2150 | + return true; |
|
| 2151 | + } |
|
| 2034 | 2152 | // Otherwise is it just a test? |
| 2035 | - elseif ($is_test) |
|
| 2036 | - return false; |
|
| 2153 | + elseif ($is_test) { |
|
| 2154 | + return false; |
|
| 2155 | + } |
|
| 2037 | 2156 | |
| 2038 | 2157 | // Not found it yet? Bummer! How about we see if we're currently doing it? |
| 2039 | 2158 | $running = false; |
@@ -2044,8 +2163,9 @@ discard block |
||
| 2044 | 2163 | SHOW FULL PROCESSLIST'); |
| 2045 | 2164 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2046 | 2165 | { |
| 2047 | - if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) |
|
| 2048 | - $found = true; |
|
| 2166 | + if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) { |
|
| 2167 | + $found = true; |
|
| 2168 | + } |
|
| 2049 | 2169 | } |
| 2050 | 2170 | |
| 2051 | 2171 | // Can't find it? Then we need to run it fools! |
@@ -2057,8 +2177,9 @@ discard block |
||
| 2057 | 2177 | ALTER TABLE ' . $db_prefix . $change['table'] . ' |
| 2058 | 2178 | ' . $change['text'], true) !== false; |
| 2059 | 2179 | |
| 2060 | - if (!$success) |
|
| 2061 | - return false; |
|
| 2180 | + if (!$success) { |
|
| 2181 | + return false; |
|
| 2182 | + } |
|
| 2062 | 2183 | |
| 2063 | 2184 | // Return |
| 2064 | 2185 | $running = true; |
@@ -2100,8 +2221,9 @@ discard block |
||
| 2100 | 2221 | 'db_error_skip' => true, |
| 2101 | 2222 | ) |
| 2102 | 2223 | ); |
| 2103 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 2104 | - die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
| 2224 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 2225 | + die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
| 2226 | + } |
|
| 2105 | 2227 | $table_row = $smcFunc['db_fetch_assoc']($request); |
| 2106 | 2228 | $smcFunc['db_free_result']($request); |
| 2107 | 2229 | |
@@ -2123,18 +2245,19 @@ discard block |
||
| 2123 | 2245 | ) |
| 2124 | 2246 | ); |
| 2125 | 2247 | // No results? Just forget it all together. |
| 2126 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 2127 | - unset($table_row['Collation']); |
|
| 2128 | - else |
|
| 2129 | - $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 2248 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 2249 | + unset($table_row['Collation']); |
|
| 2250 | + } else { |
|
| 2251 | + $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 2252 | + } |
|
| 2130 | 2253 | $smcFunc['db_free_result']($request); |
| 2131 | 2254 | } |
| 2132 | 2255 | |
| 2133 | 2256 | if ($column_fix) |
| 2134 | 2257 | { |
| 2135 | 2258 | // Make sure there are no NULL's left. |
| 2136 | - if ($null_fix) |
|
| 2137 | - $smcFunc['db_query']('', ' |
|
| 2259 | + if ($null_fix) { |
|
| 2260 | + $smcFunc['db_query']('', ' |
|
| 2138 | 2261 | UPDATE {db_prefix}' . $change['table'] . ' |
| 2139 | 2262 | SET ' . $change['column'] . ' = {string:default} |
| 2140 | 2263 | WHERE ' . $change['column'] . ' IS NULL', |
@@ -2143,6 +2266,7 @@ discard block |
||
| 2143 | 2266 | 'db_error_skip' => true, |
| 2144 | 2267 | ) |
| 2145 | 2268 | ); |
| 2269 | + } |
|
| 2146 | 2270 | |
| 2147 | 2271 | // Do the actual alteration. |
| 2148 | 2272 | $smcFunc['db_query']('', ' |
@@ -2171,8 +2295,9 @@ discard block |
||
| 2171 | 2295 | } |
| 2172 | 2296 | |
| 2173 | 2297 | // Not a column we need to check on? |
| 2174 | - if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) |
|
| 2175 | - return; |
|
| 2298 | + if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) { |
|
| 2299 | + return; |
|
| 2300 | + } |
|
| 2176 | 2301 | |
| 2177 | 2302 | // Break it up you (six|seven). |
| 2178 | 2303 | $temp = explode(' ', str_replace('NOT NULL', 'NOT_NULL', $change['text'])); |
@@ -2191,13 +2316,13 @@ discard block |
||
| 2191 | 2316 | 'new_name' => $temp[2], |
| 2192 | 2317 | )); |
| 2193 | 2318 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
| 2194 | - if ($smcFunc['db_num_rows'] != 1) |
|
| 2195 | - return; |
|
| 2319 | + if ($smcFunc['db_num_rows'] != 1) { |
|
| 2320 | + return; |
|
| 2321 | + } |
|
| 2196 | 2322 | |
| 2197 | 2323 | list (, $current_type) = $smcFunc['db_fetch_assoc']($request); |
| 2198 | 2324 | $smcFunc['db_free_result']($request); |
| 2199 | - } |
|
| 2200 | - else |
|
| 2325 | + } else |
|
| 2201 | 2326 | { |
| 2202 | 2327 | // Do this the old fashion, sure method way. |
| 2203 | 2328 | $request = $smcFunc['db_query']('', ' |
@@ -2208,21 +2333,24 @@ discard block |
||
| 2208 | 2333 | )); |
| 2209 | 2334 | // Mayday! |
| 2210 | 2335 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
| 2211 | - if ($smcFunc['db_num_rows'] == 0) |
|
| 2212 | - return; |
|
| 2336 | + if ($smcFunc['db_num_rows'] == 0) { |
|
| 2337 | + return; |
|
| 2338 | + } |
|
| 2213 | 2339 | |
| 2214 | 2340 | // Oh where, oh where has my little field gone. Oh where can it be... |
| 2215 | - while ($row = $smcFunc['db_query']($request)) |
|
| 2216 | - if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
| 2341 | + while ($row = $smcFunc['db_query']($request)) { |
|
| 2342 | + if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
| 2217 | 2343 | { |
| 2218 | 2344 | $current_type = $row['Type']; |
| 2345 | + } |
|
| 2219 | 2346 | break; |
| 2220 | 2347 | } |
| 2221 | 2348 | } |
| 2222 | 2349 | |
| 2223 | 2350 | // If this doesn't match, the column may of been altered for a reason. |
| 2224 | - if (trim($current_type) != trim($temp[3])) |
|
| 2225 | - $temp[3] = $current_type; |
|
| 2351 | + if (trim($current_type) != trim($temp[3])) { |
|
| 2352 | + $temp[3] = $current_type; |
|
| 2353 | + } |
|
| 2226 | 2354 | |
| 2227 | 2355 | // Piece this back together. |
| 2228 | 2356 | $change['text'] = str_replace('NOT_NULL', 'NOT NULL', implode(' ', $temp)); |
@@ -2234,8 +2362,9 @@ discard block |
||
| 2234 | 2362 | global $start_time, $timeLimitThreshold, $command_line, $custom_warning; |
| 2235 | 2363 | global $step_progress, $is_debug, $upcontext; |
| 2236 | 2364 | |
| 2237 | - if ($_GET['substep'] < $substep) |
|
| 2238 | - $_GET['substep'] = $substep; |
|
| 2365 | + if ($_GET['substep'] < $substep) { |
|
| 2366 | + $_GET['substep'] = $substep; |
|
| 2367 | + } |
|
| 2239 | 2368 | |
| 2240 | 2369 | if ($command_line) |
| 2241 | 2370 | { |
@@ -2248,29 +2377,33 @@ discard block |
||
| 2248 | 2377 | } |
| 2249 | 2378 | |
| 2250 | 2379 | @set_time_limit(300); |
| 2251 | - if (function_exists('apache_reset_timeout')) |
|
| 2252 | - @apache_reset_timeout(); |
|
| 2380 | + if (function_exists('apache_reset_timeout')) { |
|
| 2381 | + @apache_reset_timeout(); |
|
| 2382 | + } |
|
| 2253 | 2383 | |
| 2254 | - if (time() - $start_time <= $timeLimitThreshold) |
|
| 2255 | - return; |
|
| 2384 | + if (time() - $start_time <= $timeLimitThreshold) { |
|
| 2385 | + return; |
|
| 2386 | + } |
|
| 2256 | 2387 | |
| 2257 | 2388 | // Do we have some custom step progress stuff? |
| 2258 | 2389 | if (!empty($step_progress)) |
| 2259 | 2390 | { |
| 2260 | 2391 | $upcontext['substep_progress'] = 0; |
| 2261 | 2392 | $upcontext['substep_progress_name'] = $step_progress['name']; |
| 2262 | - if ($step_progress['current'] > $step_progress['total']) |
|
| 2263 | - $upcontext['substep_progress'] = 99.9; |
|
| 2264 | - else |
|
| 2265 | - $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
| 2393 | + if ($step_progress['current'] > $step_progress['total']) { |
|
| 2394 | + $upcontext['substep_progress'] = 99.9; |
|
| 2395 | + } else { |
|
| 2396 | + $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
| 2397 | + } |
|
| 2266 | 2398 | |
| 2267 | 2399 | // Make it nicely rounded. |
| 2268 | 2400 | $upcontext['substep_progress'] = round($upcontext['substep_progress'], 1); |
| 2269 | 2401 | } |
| 2270 | 2402 | |
| 2271 | 2403 | // If this is XML we just exit right away! |
| 2272 | - if (isset($_GET['xml'])) |
|
| 2273 | - return upgradeExit(); |
|
| 2404 | + if (isset($_GET['xml'])) { |
|
| 2405 | + return upgradeExit(); |
|
| 2406 | + } |
|
| 2274 | 2407 | |
| 2275 | 2408 | // We're going to pause after this! |
| 2276 | 2409 | $upcontext['pause'] = true; |
@@ -2278,13 +2411,15 @@ discard block |
||
| 2278 | 2411 | $upcontext['query_string'] = ''; |
| 2279 | 2412 | foreach ($_GET as $k => $v) |
| 2280 | 2413 | { |
| 2281 | - if ($k != 'data' && $k != 'substep' && $k != 'step') |
|
| 2282 | - $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
| 2414 | + if ($k != 'data' && $k != 'substep' && $k != 'step') { |
|
| 2415 | + $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
| 2416 | + } |
|
| 2283 | 2417 | } |
| 2284 | 2418 | |
| 2285 | 2419 | // Custom warning? |
| 2286 | - if (!empty($custom_warning)) |
|
| 2287 | - $upcontext['custom_warning'] = $custom_warning; |
|
| 2420 | + if (!empty($custom_warning)) { |
|
| 2421 | + $upcontext['custom_warning'] = $custom_warning; |
|
| 2422 | + } |
|
| 2288 | 2423 | |
| 2289 | 2424 | upgradeExit(); |
| 2290 | 2425 | } |
@@ -2299,25 +2434,26 @@ discard block |
||
| 2299 | 2434 | ob_implicit_flush(true); |
| 2300 | 2435 | @set_time_limit(600); |
| 2301 | 2436 | |
| 2302 | - if (!isset($_SERVER['argv'])) |
|
| 2303 | - $_SERVER['argv'] = array(); |
|
| 2437 | + if (!isset($_SERVER['argv'])) { |
|
| 2438 | + $_SERVER['argv'] = array(); |
|
| 2439 | + } |
|
| 2304 | 2440 | $_GET['maint'] = 1; |
| 2305 | 2441 | |
| 2306 | 2442 | foreach ($_SERVER['argv'] as $i => $arg) |
| 2307 | 2443 | { |
| 2308 | - if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) |
|
| 2309 | - $_GET['lang'] = $match[1]; |
|
| 2310 | - elseif (preg_match('~^--path=(.+)$~', $arg) != 0) |
|
| 2311 | - continue; |
|
| 2312 | - elseif ($arg == '--no-maintenance') |
|
| 2313 | - $_GET['maint'] = 0; |
|
| 2314 | - elseif ($arg == '--debug') |
|
| 2315 | - $is_debug = true; |
|
| 2316 | - elseif ($arg == '--backup') |
|
| 2317 | - $_POST['backup'] = 1; |
|
| 2318 | - elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) |
|
| 2319 | - $_GET['conv'] = 1; |
|
| 2320 | - elseif ($i != 0) |
|
| 2444 | + if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) { |
|
| 2445 | + $_GET['lang'] = $match[1]; |
|
| 2446 | + } elseif (preg_match('~^--path=(.+)$~', $arg) != 0) { |
|
| 2447 | + continue; |
|
| 2448 | + } elseif ($arg == '--no-maintenance') { |
|
| 2449 | + $_GET['maint'] = 0; |
|
| 2450 | + } elseif ($arg == '--debug') { |
|
| 2451 | + $is_debug = true; |
|
| 2452 | + } elseif ($arg == '--backup') { |
|
| 2453 | + $_POST['backup'] = 1; |
|
| 2454 | + } elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) { |
|
| 2455 | + $_GET['conv'] = 1; |
|
| 2456 | + } elseif ($i != 0) |
|
| 2321 | 2457 | { |
| 2322 | 2458 | echo 'SMF Command-line Upgrader |
| 2323 | 2459 | Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]... |
@@ -2331,10 +2467,12 @@ discard block |
||
| 2331 | 2467 | } |
| 2332 | 2468 | } |
| 2333 | 2469 | |
| 2334 | - if (!php_version_check()) |
|
| 2335 | - print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
| 2336 | - if (!db_version_check()) |
|
| 2337 | - print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
| 2470 | + if (!php_version_check()) { |
|
| 2471 | + print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
| 2472 | + } |
|
| 2473 | + if (!db_version_check()) { |
|
| 2474 | + print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
| 2475 | + } |
|
| 2338 | 2476 | |
| 2339 | 2477 | // Do some checks to make sure they have proper privileges |
| 2340 | 2478 | db_extend('packages'); |
@@ -2349,39 +2487,45 @@ discard block |
||
| 2349 | 2487 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
| 2350 | 2488 | |
| 2351 | 2489 | // Sorry... we need CREATE, ALTER and DROP |
| 2352 | - if (!$create || !$alter || !$drop) |
|
| 2353 | - print_error("The " . $databases[$db_type]['name'] . " user you have set in Settings.php does not have proper privileges.\n\nPlease ask your host to give this user the ALTER, CREATE, and DROP privileges.", true); |
|
| 2490 | + if (!$create || !$alter || !$drop) { |
|
| 2491 | + print_error("The " . $databases[$db_type]['name'] . " user you have set in Settings.php does not have proper privileges.\n\nPlease ask your host to give this user the ALTER, CREATE, and DROP privileges.", true); |
|
| 2492 | + } |
|
| 2354 | 2493 | |
| 2355 | 2494 | $check = @file_exists($modSettings['theme_dir'] . '/index.template.php') |
| 2356 | 2495 | && @file_exists($sourcedir . '/QueryString.php') |
| 2357 | 2496 | && @file_exists($sourcedir . '/ManageBoards.php'); |
| 2358 | - if (!$check && !isset($modSettings['smfVersion'])) |
|
| 2359 | - print_error('Error: Some files are missing or out-of-date.', true); |
|
| 2497 | + if (!$check && !isset($modSettings['smfVersion'])) { |
|
| 2498 | + print_error('Error: Some files are missing or out-of-date.', true); |
|
| 2499 | + } |
|
| 2360 | 2500 | |
| 2361 | 2501 | // Do a quick version spot check. |
| 2362 | 2502 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
| 2363 | 2503 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
| 2364 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
| 2365 | - print_error('Error: Some files have not yet been updated properly.'); |
|
| 2504 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
| 2505 | + print_error('Error: Some files have not yet been updated properly.'); |
|
| 2506 | + } |
|
| 2366 | 2507 | |
| 2367 | 2508 | // Make sure Settings.php is writable. |
| 2368 | 2509 | quickFileWritable($boarddir . '/Settings.php'); |
| 2369 | - if (!is_writable($boarddir . '/Settings.php')) |
|
| 2370 | - print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
| 2510 | + if (!is_writable($boarddir . '/Settings.php')) { |
|
| 2511 | + print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
| 2512 | + } |
|
| 2371 | 2513 | |
| 2372 | 2514 | // Make sure Settings_bak.php is writable. |
| 2373 | 2515 | quickFileWritable($boarddir . '/Settings_bak.php'); |
| 2374 | - if (!is_writable($boarddir . '/Settings_bak.php')) |
|
| 2375 | - print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
| 2516 | + if (!is_writable($boarddir . '/Settings_bak.php')) { |
|
| 2517 | + print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
| 2518 | + } |
|
| 2376 | 2519 | |
| 2377 | 2520 | // Make sure db_last_error.php is writable. |
| 2378 | 2521 | quickFileWritable($boarddir . '/db_last_error.php'); |
| 2379 | - if (!is_writable($boarddir . '/db_last_error.php')) |
|
| 2380 | - print_error('Error: Unable to obtain write access to "db_last_error.php".'); |
|
| 2522 | + if (!is_writable($boarddir . '/db_last_error.php')) { |
|
| 2523 | + print_error('Error: Unable to obtain write access to "db_last_error.php".'); |
|
| 2524 | + } |
|
| 2381 | 2525 | |
| 2382 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
| 2383 | - print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
| 2384 | - elseif (isset($modSettings['agreement'])) |
|
| 2526 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
| 2527 | + print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
| 2528 | + } elseif (isset($modSettings['agreement'])) |
|
| 2385 | 2529 | { |
| 2386 | 2530 | $fp = fopen($boarddir . '/agreement.txt', 'w'); |
| 2387 | 2531 | fwrite($fp, $modSettings['agreement']); |
@@ -2391,31 +2535,36 @@ discard block |
||
| 2391 | 2535 | // Make sure Themes is writable. |
| 2392 | 2536 | quickFileWritable($modSettings['theme_dir']); |
| 2393 | 2537 | |
| 2394 | - if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) |
|
| 2395 | - print_error('Error: Unable to obtain write access to "Themes".'); |
|
| 2538 | + if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) { |
|
| 2539 | + print_error('Error: Unable to obtain write access to "Themes".'); |
|
| 2540 | + } |
|
| 2396 | 2541 | |
| 2397 | 2542 | // Make sure cache directory exists and is writable! |
| 2398 | 2543 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
| 2399 | - if (!file_exists($cachedir_temp)) |
|
| 2400 | - @mkdir($cachedir_temp); |
|
| 2544 | + if (!file_exists($cachedir_temp)) { |
|
| 2545 | + @mkdir($cachedir_temp); |
|
| 2546 | + } |
|
| 2401 | 2547 | |
| 2402 | 2548 | // Make sure the cache temp dir is writable. |
| 2403 | 2549 | quickFileWritable($cachedir_temp); |
| 2404 | 2550 | |
| 2405 | - if (!is_writable($cachedir_temp)) |
|
| 2406 | - print_error('Error: Unable to obtain write access to "cache".', true); |
|
| 2551 | + if (!is_writable($cachedir_temp)) { |
|
| 2552 | + print_error('Error: Unable to obtain write access to "cache".', true); |
|
| 2553 | + } |
|
| 2407 | 2554 | |
| 2408 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
| 2409 | - print_error('Error: Unable to find language files!', true); |
|
| 2410 | - else |
|
| 2555 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
| 2556 | + print_error('Error: Unable to find language files!', true); |
|
| 2557 | + } else |
|
| 2411 | 2558 | { |
| 2412 | 2559 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
| 2413 | 2560 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 2414 | 2561 | |
| 2415 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 2416 | - print_error('Error: Language files out of date.', true); |
|
| 2417 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 2418 | - print_error('Error: Install language is missing for selected language.', true); |
|
| 2562 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 2563 | + print_error('Error: Language files out of date.', true); |
|
| 2564 | + } |
|
| 2565 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 2566 | + print_error('Error: Install language is missing for selected language.', true); |
|
| 2567 | + } |
|
| 2419 | 2568 | |
| 2420 | 2569 | // Otherwise include it! |
| 2421 | 2570 | require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
@@ -2434,8 +2583,9 @@ discard block |
||
| 2434 | 2583 | global $upcontext, $db_character_set, $sourcedir, $smcFunc, $modSettings, $language, $db_prefix, $db_type, $command_line, $support_js; |
| 2435 | 2584 | |
| 2436 | 2585 | // Done it already? |
| 2437 | - if (!empty($_POST['utf8_done'])) |
|
| 2438 | - return true; |
|
| 2586 | + if (!empty($_POST['utf8_done'])) { |
|
| 2587 | + return true; |
|
| 2588 | + } |
|
| 2439 | 2589 | |
| 2440 | 2590 | // First make sure they aren't already on UTF-8 before we go anywhere... |
| 2441 | 2591 | if ($db_type == 'postgresql' || ($db_character_set === 'utf8' && !empty($modSettings['global_character_set']) && $modSettings['global_character_set'] === 'UTF-8')) |
@@ -2448,8 +2598,7 @@ discard block |
||
| 2448 | 2598 | ); |
| 2449 | 2599 | |
| 2450 | 2600 | return true; |
| 2451 | - } |
|
| 2452 | - else |
|
| 2601 | + } else |
|
| 2453 | 2602 | { |
| 2454 | 2603 | $upcontext['page_title'] = 'Converting to UTF8'; |
| 2455 | 2604 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'convert_xml' : 'convert_utf8'; |
@@ -2493,8 +2642,9 @@ discard block |
||
| 2493 | 2642 | ) |
| 2494 | 2643 | ); |
| 2495 | 2644 | $db_charsets = array(); |
| 2496 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2497 | - $db_charsets[] = $row['Charset']; |
|
| 2645 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2646 | + $db_charsets[] = $row['Charset']; |
|
| 2647 | + } |
|
| 2498 | 2648 | |
| 2499 | 2649 | $smcFunc['db_free_result']($request); |
| 2500 | 2650 | |
@@ -2530,13 +2680,15 @@ discard block |
||
| 2530 | 2680 | // If there's a fulltext index, we need to drop it first... |
| 2531 | 2681 | if ($request !== false || $smcFunc['db_num_rows']($request) != 0) |
| 2532 | 2682 | { |
| 2533 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2534 | - if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 2683 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2684 | + if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 2535 | 2685 | $upcontext['fulltext_index'][] = $row['Key_name']; |
| 2686 | + } |
|
| 2536 | 2687 | $smcFunc['db_free_result']($request); |
| 2537 | 2688 | |
| 2538 | - if (isset($upcontext['fulltext_index'])) |
|
| 2539 | - $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
| 2689 | + if (isset($upcontext['fulltext_index'])) { |
|
| 2690 | + $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
| 2691 | + } |
|
| 2540 | 2692 | } |
| 2541 | 2693 | |
| 2542 | 2694 | // Drop it and make a note... |
@@ -2726,8 +2878,9 @@ discard block |
||
| 2726 | 2878 | $replace = '%field%'; |
| 2727 | 2879 | |
| 2728 | 2880 | // Build a huge REPLACE statement... |
| 2729 | - foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) |
|
| 2730 | - $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
| 2881 | + foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) { |
|
| 2882 | + $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
| 2883 | + } |
|
| 2731 | 2884 | } |
| 2732 | 2885 | |
| 2733 | 2886 | // Get a list of table names ahead of time... This makes it easier to set our substep and such |
@@ -2737,9 +2890,10 @@ discard block |
||
| 2737 | 2890 | $upcontext['table_count'] = count($queryTables); |
| 2738 | 2891 | |
| 2739 | 2892 | // What ones have we already done? |
| 2740 | - foreach ($queryTables as $id => $table) |
|
| 2741 | - if ($id < $_GET['substep']) |
|
| 2893 | + foreach ($queryTables as $id => $table) { |
|
| 2894 | + if ($id < $_GET['substep']) |
|
| 2742 | 2895 | $upcontext['previous_tables'][] = $table; |
| 2896 | + } |
|
| 2743 | 2897 | |
| 2744 | 2898 | $upcontext['cur_table_num'] = $_GET['substep']; |
| 2745 | 2899 | $upcontext['cur_table_name'] = str_replace($db_prefix, '', $queryTables[$_GET['substep']]); |
@@ -2776,8 +2930,9 @@ discard block |
||
| 2776 | 2930 | nextSubstep($substep); |
| 2777 | 2931 | |
| 2778 | 2932 | // Just to make sure it doesn't time out. |
| 2779 | - if (function_exists('apache_reset_timeout')) |
|
| 2780 | - @apache_reset_timeout(); |
|
| 2933 | + if (function_exists('apache_reset_timeout')) { |
|
| 2934 | + @apache_reset_timeout(); |
|
| 2935 | + } |
|
| 2781 | 2936 | |
| 2782 | 2937 | $table_charsets = array(); |
| 2783 | 2938 | |
@@ -2800,8 +2955,9 @@ discard block |
||
| 2800 | 2955 | |
| 2801 | 2956 | // Build structure of columns to operate on organized by charset; only operate on columns not yet utf8 |
| 2802 | 2957 | if ($charset != 'utf8') { |
| 2803 | - if (!isset($table_charsets[$charset])) |
|
| 2804 | - $table_charsets[$charset] = array(); |
|
| 2958 | + if (!isset($table_charsets[$charset])) { |
|
| 2959 | + $table_charsets[$charset] = array(); |
|
| 2960 | + } |
|
| 2805 | 2961 | |
| 2806 | 2962 | $table_charsets[$charset][] = $column_info; |
| 2807 | 2963 | } |
@@ -2842,10 +2998,11 @@ discard block |
||
| 2842 | 2998 | if (isset($translation_tables[$upcontext['charset_detected']])) |
| 2843 | 2999 | { |
| 2844 | 3000 | $update = ''; |
| 2845 | - foreach ($table_charsets as $charset => $columns) |
|
| 2846 | - foreach ($columns as $column) |
|
| 3001 | + foreach ($table_charsets as $charset => $columns) { |
|
| 3002 | + foreach ($columns as $column) |
|
| 2847 | 3003 | $update .= ' |
| 2848 | 3004 | ' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ','; |
| 3005 | + } |
|
| 2849 | 3006 | |
| 2850 | 3007 | $smcFunc['db_query']('', ' |
| 2851 | 3008 | UPDATE {raw:table_name} |
@@ -2870,8 +3027,9 @@ discard block |
||
| 2870 | 3027 | // Now do the actual conversion (if still needed). |
| 2871 | 3028 | if ($charsets[$upcontext['charset_detected']] !== 'utf8') |
| 2872 | 3029 | { |
| 2873 | - if ($command_line) |
|
| 2874 | - echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
| 3030 | + if ($command_line) { |
|
| 3031 | + echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
| 3032 | + } |
|
| 2875 | 3033 | |
| 2876 | 3034 | $smcFunc['db_query']('', ' |
| 2877 | 3035 | ALTER TABLE {raw:table_name} |
@@ -2881,12 +3039,14 @@ discard block |
||
| 2881 | 3039 | ) |
| 2882 | 3040 | ); |
| 2883 | 3041 | |
| 2884 | - if ($command_line) |
|
| 2885 | - echo " done.\n"; |
|
| 3042 | + if ($command_line) { |
|
| 3043 | + echo " done.\n"; |
|
| 3044 | + } |
|
| 2886 | 3045 | } |
| 2887 | 3046 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 2888 | - if (isset($_GET['xml']) && $upcontext['cur_table_num'] < $upcontext['table_count']) |
|
| 2889 | - return upgradeExit(); |
|
| 3047 | + if (isset($_GET['xml']) && $upcontext['cur_table_num'] < $upcontext['table_count']) { |
|
| 3048 | + return upgradeExit(); |
|
| 3049 | + } |
|
| 2890 | 3050 | } |
| 2891 | 3051 | |
| 2892 | 3052 | $prev_charset = empty($translation_tables[$upcontext['charset_detected']]) ? $charsets[$upcontext['charset_detected']] : $translation_tables[$upcontext['charset_detected']]; |
@@ -2915,8 +3075,8 @@ discard block |
||
| 2915 | 3075 | ); |
| 2916 | 3076 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2917 | 3077 | { |
| 2918 | - if (@safe_unserialize($row['extra']) === false && preg_match('~^(a:3:{s:5:"topic";i:\d+;s:7:"subject";s:)(\d+):"(.+)"(;s:6:"member";s:5:"\d+";})$~', $row['extra'], $matches) === 1) |
|
| 2919 | - $smcFunc['db_query']('', ' |
|
| 3078 | + if (@safe_unserialize($row['extra']) === false && preg_match('~^(a:3:{s:5:"topic";i:\d+;s:7:"subject";s:)(\d+):"(.+)"(;s:6:"member";s:5:"\d+";})$~', $row['extra'], $matches) === 1) { |
|
| 3079 | + $smcFunc['db_query']('', ' |
|
| 2920 | 3080 | UPDATE {db_prefix}log_actions |
| 2921 | 3081 | SET extra = {string:extra} |
| 2922 | 3082 | WHERE id_action = {int:current_action}', |
@@ -2925,6 +3085,7 @@ discard block |
||
| 2925 | 3085 | 'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4], |
| 2926 | 3086 | ) |
| 2927 | 3087 | ); |
| 3088 | + } |
|
| 2928 | 3089 | } |
| 2929 | 3090 | $smcFunc['db_free_result']($request); |
| 2930 | 3091 | |
@@ -2946,15 +3107,17 @@ discard block |
||
| 2946 | 3107 | // First thing's first - did we already do this? |
| 2947 | 3108 | if (!empty($modSettings['json_done'])) |
| 2948 | 3109 | { |
| 2949 | - if ($command_line) |
|
| 2950 | - return DeleteUpgrade(); |
|
| 2951 | - else |
|
| 2952 | - return true; |
|
| 3110 | + if ($command_line) { |
|
| 3111 | + return DeleteUpgrade(); |
|
| 3112 | + } else { |
|
| 3113 | + return true; |
|
| 3114 | + } |
|
| 2953 | 3115 | } |
| 2954 | 3116 | |
| 2955 | 3117 | // Done it already - js wise? |
| 2956 | - if (!empty($_POST['json_done'])) |
|
| 2957 | - return true; |
|
| 3118 | + if (!empty($_POST['json_done'])) { |
|
| 3119 | + return true; |
|
| 3120 | + } |
|
| 2958 | 3121 | |
| 2959 | 3122 | // List of tables affected by this function |
| 2960 | 3123 | // name => array('key', col1[,col2|true[,col3]]) |
@@ -2986,12 +3149,14 @@ discard block |
||
| 2986 | 3149 | $upcontext['cur_table_name'] = isset($keys[$_GET['substep']]) ? $keys[$_GET['substep']] : $keys[0]; |
| 2987 | 3150 | $upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100); |
| 2988 | 3151 | |
| 2989 | - foreach ($keys as $id => $table) |
|
| 2990 | - if ($id < $_GET['substep']) |
|
| 3152 | + foreach ($keys as $id => $table) { |
|
| 3153 | + if ($id < $_GET['substep']) |
|
| 2991 | 3154 | $upcontext['previous_tables'][] = $table; |
| 3155 | + } |
|
| 2992 | 3156 | |
| 2993 | - if ($command_line) |
|
| 2994 | - echo 'Converting data from serialize() to json_encode().'; |
|
| 3157 | + if ($command_line) { |
|
| 3158 | + echo 'Converting data from serialize() to json_encode().'; |
|
| 3159 | + } |
|
| 2995 | 3160 | |
| 2996 | 3161 | if (!$support_js || isset($_GET['xml'])) |
| 2997 | 3162 | { |
@@ -3031,8 +3196,9 @@ discard block |
||
| 3031 | 3196 | |
| 3032 | 3197 | // Loop through and fix these... |
| 3033 | 3198 | $new_settings = array(); |
| 3034 | - if ($command_line) |
|
| 3035 | - echo "\n" . 'Fixing some settings...'; |
|
| 3199 | + if ($command_line) { |
|
| 3200 | + echo "\n" . 'Fixing some settings...'; |
|
| 3201 | + } |
|
| 3036 | 3202 | |
| 3037 | 3203 | foreach ($serialized_settings as $var) |
| 3038 | 3204 | { |
@@ -3040,22 +3206,24 @@ discard block |
||
| 3040 | 3206 | { |
| 3041 | 3207 | // Attempt to unserialize the setting |
| 3042 | 3208 | $temp = @safe_unserialize($modSettings[$var]); |
| 3043 | - if (!$temp && $command_line) |
|
| 3044 | - echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
| 3045 | - elseif ($temp !== false) |
|
| 3046 | - $new_settings[$var] = json_encode($temp); |
|
| 3209 | + if (!$temp && $command_line) { |
|
| 3210 | + echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
| 3211 | + } elseif ($temp !== false) { |
|
| 3212 | + $new_settings[$var] = json_encode($temp); |
|
| 3213 | + } |
|
| 3047 | 3214 | } |
| 3048 | 3215 | } |
| 3049 | 3216 | |
| 3050 | 3217 | // Update everything at once |
| 3051 | - if (!function_exists('cache_put_data')) |
|
| 3052 | - require_once($sourcedir . '/Load.php'); |
|
| 3218 | + if (!function_exists('cache_put_data')) { |
|
| 3219 | + require_once($sourcedir . '/Load.php'); |
|
| 3220 | + } |
|
| 3053 | 3221 | updateSettings($new_settings, true); |
| 3054 | 3222 | |
| 3055 | - if ($command_line) |
|
| 3056 | - echo ' done.'; |
|
| 3057 | - } |
|
| 3058 | - elseif ($table == 'themes') |
|
| 3223 | + if ($command_line) { |
|
| 3224 | + echo ' done.'; |
|
| 3225 | + } |
|
| 3226 | + } elseif ($table == 'themes') |
|
| 3059 | 3227 | { |
| 3060 | 3228 | // Finally, fix the admin prefs. Unfortunately this is stored per theme, but hopefully they only have one theme installed at this point... |
| 3061 | 3229 | $query = $smcFunc['db_query']('', ' |
@@ -3074,10 +3242,11 @@ discard block |
||
| 3074 | 3242 | |
| 3075 | 3243 | if ($command_line) |
| 3076 | 3244 | { |
| 3077 | - if ($temp === false) |
|
| 3078 | - echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
| 3079 | - else |
|
| 3080 | - echo "\n" . 'Fixing admin preferences...'; |
|
| 3245 | + if ($temp === false) { |
|
| 3246 | + echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
| 3247 | + } else { |
|
| 3248 | + echo "\n" . 'Fixing admin preferences...'; |
|
| 3249 | + } |
|
| 3081 | 3250 | } |
| 3082 | 3251 | |
| 3083 | 3252 | if ($temp !== false) |
@@ -3099,15 +3268,15 @@ discard block |
||
| 3099 | 3268 | ) |
| 3100 | 3269 | ); |
| 3101 | 3270 | |
| 3102 | - if ($command_line) |
|
| 3103 | - echo ' done.'; |
|
| 3271 | + if ($command_line) { |
|
| 3272 | + echo ' done.'; |
|
| 3273 | + } |
|
| 3104 | 3274 | } |
| 3105 | 3275 | } |
| 3106 | 3276 | |
| 3107 | 3277 | $smcFunc['db_free_result']($query); |
| 3108 | 3278 | } |
| 3109 | - } |
|
| 3110 | - else |
|
| 3279 | + } else |
|
| 3111 | 3280 | { |
| 3112 | 3281 | // First item is always the key... |
| 3113 | 3282 | $key = $info[0]; |
@@ -3118,8 +3287,7 @@ discard block |
||
| 3118 | 3287 | { |
| 3119 | 3288 | $col_select = $info[1]; |
| 3120 | 3289 | $where = ' WHERE ' . $info[1] . ' != {empty}'; |
| 3121 | - } |
|
| 3122 | - else |
|
| 3290 | + } else |
|
| 3123 | 3291 | { |
| 3124 | 3292 | $col_select = implode(', ', $info); |
| 3125 | 3293 | } |
@@ -3152,8 +3320,7 @@ discard block |
||
| 3152 | 3320 | if ($temp === false && $command_line) |
| 3153 | 3321 | { |
| 3154 | 3322 | echo "\nFailed to unserialize " . $row[$col] . "... Skipping\n"; |
| 3155 | - } |
|
| 3156 | - else |
|
| 3323 | + } else |
|
| 3157 | 3324 | { |
| 3158 | 3325 | $row[$col] = json_encode($temp); |
| 3159 | 3326 | |
@@ -3178,16 +3345,18 @@ discard block |
||
| 3178 | 3345 | } |
| 3179 | 3346 | } |
| 3180 | 3347 | |
| 3181 | - if ($command_line) |
|
| 3182 | - echo ' done.'; |
|
| 3348 | + if ($command_line) { |
|
| 3349 | + echo ' done.'; |
|
| 3350 | + } |
|
| 3183 | 3351 | |
| 3184 | 3352 | // Free up some memory... |
| 3185 | 3353 | $smcFunc['db_free_result']($query); |
| 3186 | 3354 | } |
| 3187 | 3355 | } |
| 3188 | 3356 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 3189 | - if (isset($_GET['xml'])) |
|
| 3190 | - return upgradeExit(); |
|
| 3357 | + if (isset($_GET['xml'])) { |
|
| 3358 | + return upgradeExit(); |
|
| 3359 | + } |
|
| 3191 | 3360 | } |
| 3192 | 3361 | |
| 3193 | 3362 | if ($command_line) |
@@ -3202,8 +3371,9 @@ discard block |
||
| 3202 | 3371 | |
| 3203 | 3372 | $_GET['substep'] = 0; |
| 3204 | 3373 | // Make sure we move on! |
| 3205 | - if ($command_line) |
|
| 3206 | - return DeleteUpgrade(); |
|
| 3374 | + if ($command_line) { |
|
| 3375 | + return DeleteUpgrade(); |
|
| 3376 | + } |
|
| 3207 | 3377 | |
| 3208 | 3378 | return true; |
| 3209 | 3379 | } |
@@ -3223,14 +3393,16 @@ discard block |
||
| 3223 | 3393 | global $upcontext, $txt, $settings; |
| 3224 | 3394 | |
| 3225 | 3395 | // Don't call me twice! |
| 3226 | - if (!empty($upcontext['chmod_called'])) |
|
| 3227 | - return; |
|
| 3396 | + if (!empty($upcontext['chmod_called'])) { |
|
| 3397 | + return; |
|
| 3398 | + } |
|
| 3228 | 3399 | |
| 3229 | 3400 | $upcontext['chmod_called'] = true; |
| 3230 | 3401 | |
| 3231 | 3402 | // Nothing? |
| 3232 | - if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) |
|
| 3233 | - return; |
|
| 3403 | + if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) { |
|
| 3404 | + return; |
|
| 3405 | + } |
|
| 3234 | 3406 | |
| 3235 | 3407 | // Was it a problem with Windows? |
| 3236 | 3408 | if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess') |
@@ -3262,11 +3434,12 @@ discard block |
||
| 3262 | 3434 | content.write(\'<div class="windowbg description">\n\t\t\t<h4>The following files needs to be made writable to continue:</h4>\n\t\t\t\'); |
| 3263 | 3435 | content.write(\'<p>', implode('<br>\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');'; |
| 3264 | 3436 | |
| 3265 | - if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') |
|
| 3266 | - echo ' |
|
| 3437 | + if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') { |
|
| 3438 | + echo ' |
|
| 3267 | 3439 | content.write(\'<hr>\n\t\t\t\'); |
| 3268 | 3440 | content.write(\'<p>If you have a shell account, the convenient below command can automatically correct permissions on these files</p>\n\t\t\t\'); |
| 3269 | 3441 | content.write(\'<tt># chmod a+w ', implode(' ', $upcontext['chmod']['files']), '</tt>\n\t\t\t\');'; |
| 3442 | + } |
|
| 3270 | 3443 | |
| 3271 | 3444 | echo ' |
| 3272 | 3445 | content.write(\'<a href="javascript:self.close();">close</a>\n\t\t</div>\n\t</body>\n</html>\'); |
@@ -3274,17 +3447,19 @@ discard block |
||
| 3274 | 3447 | } |
| 3275 | 3448 | </script>'; |
| 3276 | 3449 | |
| 3277 | - if (!empty($upcontext['chmod']['ftp_error'])) |
|
| 3278 | - echo ' |
|
| 3450 | + if (!empty($upcontext['chmod']['ftp_error'])) { |
|
| 3451 | + echo ' |
|
| 3279 | 3452 | <div class="error_message red"> |
| 3280 | 3453 | The following error was encountered when trying to connect:<br><br> |
| 3281 | 3454 | <code>', $upcontext['chmod']['ftp_error'], '</code> |
| 3282 | 3455 | </div> |
| 3283 | 3456 | <br>'; |
| 3457 | + } |
|
| 3284 | 3458 | |
| 3285 | - if (empty($upcontext['chmod_in_form'])) |
|
| 3286 | - echo ' |
|
| 3459 | + if (empty($upcontext['chmod_in_form'])) { |
|
| 3460 | + echo ' |
|
| 3287 | 3461 | <form action="', $upcontext['form_url'], '" method="post">'; |
| 3462 | + } |
|
| 3288 | 3463 | |
| 3289 | 3464 | echo ' |
| 3290 | 3465 | <table width="520" border="0" align="center" style="margin-bottom: 1ex;"> |
@@ -3319,10 +3494,11 @@ discard block |
||
| 3319 | 3494 | <div class="righttext" style="margin: 1ex;"><input type="submit" value="', $txt['ftp_connect'], '" class="button_submit"></div> |
| 3320 | 3495 | </div>'; |
| 3321 | 3496 | |
| 3322 | - if (empty($upcontext['chmod_in_form'])) |
|
| 3323 | - echo ' |
|
| 3497 | + if (empty($upcontext['chmod_in_form'])) { |
|
| 3498 | + echo ' |
|
| 3324 | 3499 | </form>'; |
| 3325 | -} |
|
| 3500 | + } |
|
| 3501 | + } |
|
| 3326 | 3502 | |
| 3327 | 3503 | function template_upgrade_above() |
| 3328 | 3504 | { |
@@ -3382,9 +3558,10 @@ discard block |
||
| 3382 | 3558 | <h2>', $txt['upgrade_progress'], '</h2> |
| 3383 | 3559 | <ul>'; |
| 3384 | 3560 | |
| 3385 | - foreach ($upcontext['steps'] as $num => $step) |
|
| 3386 | - echo ' |
|
| 3561 | + foreach ($upcontext['steps'] as $num => $step) { |
|
| 3562 | + echo ' |
|
| 3387 | 3563 | <li class="', $num < $upcontext['current_step'] ? 'stepdone' : ($num == $upcontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
| 3564 | + } |
|
| 3388 | 3565 | |
| 3389 | 3566 | echo ' |
| 3390 | 3567 | </ul> |
@@ -3397,8 +3574,8 @@ discard block |
||
| 3397 | 3574 | </div> |
| 3398 | 3575 | </div>'; |
| 3399 | 3576 | |
| 3400 | - if (isset($upcontext['step_progress'])) |
|
| 3401 | - echo ' |
|
| 3577 | + if (isset($upcontext['step_progress'])) { |
|
| 3578 | + echo ' |
|
| 3402 | 3579 | <br> |
| 3403 | 3580 | <br> |
| 3404 | 3581 | <div id="progress_bar_step"> |
@@ -3407,6 +3584,7 @@ discard block |
||
| 3407 | 3584 | <span>', $txt['upgrade_step_progress'], '</span> |
| 3408 | 3585 | </div> |
| 3409 | 3586 | </div>'; |
| 3587 | + } |
|
| 3410 | 3588 | |
| 3411 | 3589 | echo ' |
| 3412 | 3590 | <div id="substep_bar_div" class="smalltext" style="float: left;width: 50%;margin-top: 0.6em;display: ', isset($upcontext['substep_progress']) ? '' : 'none', ';">', isset($upcontext['substep_progress_name']) ? trim(strtr($upcontext['substep_progress_name'], array('.' => ''))) : '', ':</div> |
@@ -3437,32 +3615,36 @@ discard block |
||
| 3437 | 3615 | { |
| 3438 | 3616 | global $upcontext, $txt; |
| 3439 | 3617 | |
| 3440 | - if (!empty($upcontext['pause'])) |
|
| 3441 | - echo ' |
|
| 3618 | + if (!empty($upcontext['pause'])) { |
|
| 3619 | + echo ' |
|
| 3442 | 3620 | <em>', $txt['upgrade_incomplete'], '.</em><br> |
| 3443 | 3621 | |
| 3444 | 3622 | <h2 style="margin-top: 2ex;">', $txt['upgrade_not_quite_done'], '</h2> |
| 3445 | 3623 | <h3> |
| 3446 | 3624 | ', $txt['upgrade_paused_overload'], ' |
| 3447 | 3625 | </h3>'; |
| 3626 | + } |
|
| 3448 | 3627 | |
| 3449 | - if (!empty($upcontext['custom_warning'])) |
|
| 3450 | - echo ' |
|
| 3628 | + if (!empty($upcontext['custom_warning'])) { |
|
| 3629 | + echo ' |
|
| 3451 | 3630 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3452 | 3631 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3453 | 3632 | <strong style="text-decoration: underline;">', $txt['upgrade_note'], '</strong><br> |
| 3454 | 3633 | <div style="padding-left: 6ex;">', $upcontext['custom_warning'], '</div> |
| 3455 | 3634 | </div>'; |
| 3635 | + } |
|
| 3456 | 3636 | |
| 3457 | 3637 | echo ' |
| 3458 | 3638 | <div class="righttext" style="margin: 1ex;">'; |
| 3459 | 3639 | |
| 3460 | - if (!empty($upcontext['continue'])) |
|
| 3461 | - echo ' |
|
| 3640 | + if (!empty($upcontext['continue'])) { |
|
| 3641 | + echo ' |
|
| 3462 | 3642 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled' : '', ' class="button_submit">'; |
| 3463 | - if (!empty($upcontext['skip'])) |
|
| 3464 | - echo ' |
|
| 3643 | + } |
|
| 3644 | + if (!empty($upcontext['skip'])) { |
|
| 3645 | + echo ' |
|
| 3465 | 3646 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button_submit">'; |
| 3647 | + } |
|
| 3466 | 3648 | |
| 3467 | 3649 | echo ' |
| 3468 | 3650 | </div> |
@@ -3512,11 +3694,12 @@ discard block |
||
| 3512 | 3694 | echo '<', '?xml version="1.0" encoding="UTF-8"?', '> |
| 3513 | 3695 | <smf>'; |
| 3514 | 3696 | |
| 3515 | - if (!empty($upcontext['get_data'])) |
|
| 3516 | - foreach ($upcontext['get_data'] as $k => $v) |
|
| 3697 | + if (!empty($upcontext['get_data'])) { |
|
| 3698 | + foreach ($upcontext['get_data'] as $k => $v) |
|
| 3517 | 3699 | echo ' |
| 3518 | 3700 | <get key="', $k, '">', $v, '</get>'; |
| 3519 | -} |
|
| 3701 | + } |
|
| 3702 | + } |
|
| 3520 | 3703 | |
| 3521 | 3704 | function template_xml_below() |
| 3522 | 3705 | { |
@@ -3557,8 +3740,8 @@ discard block |
||
| 3557 | 3740 | template_chmod(); |
| 3558 | 3741 | |
| 3559 | 3742 | // For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade! |
| 3560 | - if ($upcontext['is_large_forum']) |
|
| 3561 | - echo ' |
|
| 3743 | + if ($upcontext['is_large_forum']) { |
|
| 3744 | + echo ' |
|
| 3562 | 3745 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3563 | 3746 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3564 | 3747 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -3566,10 +3749,11 @@ discard block |
||
| 3566 | 3749 | ', $txt['upgrade_warning_lots_data'], ' |
| 3567 | 3750 | </div> |
| 3568 | 3751 | </div>'; |
| 3752 | + } |
|
| 3569 | 3753 | |
| 3570 | 3754 | // A warning message? |
| 3571 | - if (!empty($upcontext['warning'])) |
|
| 3572 | - echo ' |
|
| 3755 | + if (!empty($upcontext['warning'])) { |
|
| 3756 | + echo ' |
|
| 3573 | 3757 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3574 | 3758 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3575 | 3759 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -3577,6 +3761,7 @@ discard block |
||
| 3577 | 3761 | ', $upcontext['warning'], ' |
| 3578 | 3762 | </div> |
| 3579 | 3763 | </div>'; |
| 3764 | + } |
|
| 3580 | 3765 | |
| 3581 | 3766 | // Paths are incorrect? |
| 3582 | 3767 | echo ' |
@@ -3592,20 +3777,22 @@ discard block |
||
| 3592 | 3777 | if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600)) |
| 3593 | 3778 | { |
| 3594 | 3779 | $ago = time() - $upcontext['started']; |
| 3595 | - if ($ago < 60) |
|
| 3596 | - $ago = $ago . ' seconds'; |
|
| 3597 | - elseif ($ago < 3600) |
|
| 3598 | - $ago = (int) ($ago / 60) . ' minutes'; |
|
| 3599 | - else |
|
| 3600 | - $ago = (int) ($ago / 3600) . ' hours'; |
|
| 3780 | + if ($ago < 60) { |
|
| 3781 | + $ago = $ago . ' seconds'; |
|
| 3782 | + } elseif ($ago < 3600) { |
|
| 3783 | + $ago = (int) ($ago / 60) . ' minutes'; |
|
| 3784 | + } else { |
|
| 3785 | + $ago = (int) ($ago / 3600) . ' hours'; |
|
| 3786 | + } |
|
| 3601 | 3787 | |
| 3602 | 3788 | $active = time() - $upcontext['updated']; |
| 3603 | - if ($active < 60) |
|
| 3604 | - $updated = $active . ' seconds'; |
|
| 3605 | - elseif ($active < 3600) |
|
| 3606 | - $updated = (int) ($active / 60) . ' minutes'; |
|
| 3607 | - else |
|
| 3608 | - $updated = (int) ($active / 3600) . ' hours'; |
|
| 3789 | + if ($active < 60) { |
|
| 3790 | + $updated = $active . ' seconds'; |
|
| 3791 | + } elseif ($active < 3600) { |
|
| 3792 | + $updated = (int) ($active / 60) . ' minutes'; |
|
| 3793 | + } else { |
|
| 3794 | + $updated = (int) ($active / 3600) . ' hours'; |
|
| 3795 | + } |
|
| 3609 | 3796 | |
| 3610 | 3797 | echo ' |
| 3611 | 3798 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
@@ -3614,16 +3801,18 @@ discard block |
||
| 3614 | 3801 | <div style="padding-left: 6ex;"> |
| 3615 | 3802 | "', $upcontext['user']['name'], '" has been running the upgrade script for the last ', $ago, ' - and was last active ', $updated, ' ago.'; |
| 3616 | 3803 | |
| 3617 | - if ($active < 600) |
|
| 3618 | - echo ' |
|
| 3804 | + if ($active < 600) { |
|
| 3805 | + echo ' |
|
| 3619 | 3806 | We recommend that you do not run this script unless you are sure that ', $upcontext['user']['name'], ' has completed their upgrade.'; |
| 3807 | + } |
|
| 3620 | 3808 | |
| 3621 | - if ($active > $upcontext['inactive_timeout']) |
|
| 3622 | - echo ' |
|
| 3809 | + if ($active > $upcontext['inactive_timeout']) { |
|
| 3810 | + echo ' |
|
| 3623 | 3811 | <br><br>You can choose to either run the upgrade again from the beginning - or alternatively continue from the last step reached during the last upgrade.'; |
| 3624 | - else |
|
| 3625 | - echo ' |
|
| 3812 | + } else { |
|
| 3813 | + echo ' |
|
| 3626 | 3814 | <br><br>This upgrade script cannot be run until ', $upcontext['user']['name'], ' has been inactive for at least ', ($upcontext['inactive_timeout'] > 120 ? round($upcontext['inactive_timeout'] / 60, 1) . ' minutes!' : $upcontext['inactive_timeout'] . ' seconds!'); |
| 3815 | + } |
|
| 3627 | 3816 | |
| 3628 | 3817 | echo ' |
| 3629 | 3818 | </div> |
@@ -3639,9 +3828,10 @@ discard block |
||
| 3639 | 3828 | <td> |
| 3640 | 3829 | <input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '"', $disable_security ? ' disabled' : '', ' class="input_text">'; |
| 3641 | 3830 | |
| 3642 | - if (!empty($upcontext['username_incorrect'])) |
|
| 3643 | - echo ' |
|
| 3831 | + if (!empty($upcontext['username_incorrect'])) { |
|
| 3832 | + echo ' |
|
| 3644 | 3833 | <div class="smalltext" style="color: red;">Username Incorrect</div>'; |
| 3834 | + } |
|
| 3645 | 3835 | |
| 3646 | 3836 | echo ' |
| 3647 | 3837 | </td> |
@@ -3652,9 +3842,10 @@ discard block |
||
| 3652 | 3842 | <input type="password" name="passwrd" value=""', $disable_security ? ' disabled' : '', ' class="input_password"> |
| 3653 | 3843 | <input type="hidden" name="hash_passwrd" value="">'; |
| 3654 | 3844 | |
| 3655 | - if (!empty($upcontext['password_failed'])) |
|
| 3656 | - echo ' |
|
| 3845 | + if (!empty($upcontext['password_failed'])) { |
|
| 3846 | + echo ' |
|
| 3657 | 3847 | <div class="smalltext" style="color: red;">Password Incorrect</div>'; |
| 3848 | + } |
|
| 3658 | 3849 | |
| 3659 | 3850 | echo ' |
| 3660 | 3851 | </td> |
@@ -3725,8 +3916,8 @@ discard block |
||
| 3725 | 3916 | <form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">'; |
| 3726 | 3917 | |
| 3727 | 3918 | // Warning message? |
| 3728 | - if (!empty($upcontext['upgrade_options_warning'])) |
|
| 3729 | - echo ' |
|
| 3919 | + if (!empty($upcontext['upgrade_options_warning'])) { |
|
| 3920 | + echo ' |
|
| 3730 | 3921 | <div style="margin: 1ex; padding: 1ex; border: 1px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3731 | 3922 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3732 | 3923 | <strong style="text-decoration: underline;">Warning!</strong><br> |
@@ -3734,6 +3925,7 @@ discard block |
||
| 3734 | 3925 | ', $upcontext['upgrade_options_warning'], ' |
| 3735 | 3926 | </div> |
| 3736 | 3927 | </div>'; |
| 3928 | + } |
|
| 3737 | 3929 | |
| 3738 | 3930 | echo ' |
| 3739 | 3931 | <table> |
@@ -3776,8 +3968,8 @@ discard block |
||
| 3776 | 3968 | </td> |
| 3777 | 3969 | </tr>'; |
| 3778 | 3970 | |
| 3779 | - if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) |
|
| 3780 | - echo ' |
|
| 3971 | + if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) { |
|
| 3972 | + echo ' |
|
| 3781 | 3973 | <tr valign="top"> |
| 3782 | 3974 | <td width="2%"> |
| 3783 | 3975 | <input type="checkbox" name="delete_karma" id="delete_karma" value="1" class="input_check"> |
@@ -3786,6 +3978,7 @@ discard block |
||
| 3786 | 3978 | <label for="delete_karma">Delete all karma settings and info from the DB</label> |
| 3787 | 3979 | </td> |
| 3788 | 3980 | </tr>'; |
| 3981 | + } |
|
| 3789 | 3982 | |
| 3790 | 3983 | echo ' |
| 3791 | 3984 | <tr valign="top"> |
@@ -3823,10 +4016,11 @@ discard block |
||
| 3823 | 4016 | </div>'; |
| 3824 | 4017 | |
| 3825 | 4018 | // Dont any tables so far? |
| 3826 | - if (!empty($upcontext['previous_tables'])) |
|
| 3827 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4019 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4020 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 3828 | 4021 | echo ' |
| 3829 | 4022 | <br>Completed Table: "', $table, '".'; |
| 4023 | + } |
|
| 3830 | 4024 | |
| 3831 | 4025 | echo ' |
| 3832 | 4026 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
@@ -3863,12 +4057,13 @@ discard block |
||
| 3863 | 4057 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 3864 | 4058 | |
| 3865 | 4059 | // If debug flood the screen. |
| 3866 | - if ($is_debug) |
|
| 3867 | - echo ' |
|
| 4060 | + if ($is_debug) { |
|
| 4061 | + echo ' |
|
| 3868 | 4062 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 3869 | 4063 | |
| 3870 | 4064 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 3871 | 4065 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4066 | + } |
|
| 3872 | 4067 | |
| 3873 | 4068 | echo ' |
| 3874 | 4069 | // Get the next update... |
@@ -3901,8 +4096,9 @@ discard block |
||
| 3901 | 4096 | { |
| 3902 | 4097 | global $upcontext, $support_js, $is_debug, $timeLimitThreshold; |
| 3903 | 4098 | |
| 3904 | - if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) |
|
| 3905 | - $is_debug = true; |
|
| 4099 | + if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) { |
|
| 4100 | + $is_debug = true; |
|
| 4101 | + } |
|
| 3906 | 4102 | |
| 3907 | 4103 | echo ' |
| 3908 | 4104 | <h3>Executing database changes</h3> |
@@ -3917,8 +4113,9 @@ discard block |
||
| 3917 | 4113 | { |
| 3918 | 4114 | foreach ($upcontext['actioned_items'] as $num => $item) |
| 3919 | 4115 | { |
| 3920 | - if ($num != 0) |
|
| 3921 | - echo ' Successful!'; |
|
| 4116 | + if ($num != 0) { |
|
| 4117 | + echo ' Successful!'; |
|
| 4118 | + } |
|
| 3922 | 4119 | echo '<br>' . $item; |
| 3923 | 4120 | } |
| 3924 | 4121 | if (!empty($upcontext['changes_complete'])) |
@@ -3931,28 +4128,32 @@ discard block |
||
| 3931 | 4128 | $seconds = intval($active % 60); |
| 3932 | 4129 | |
| 3933 | 4130 | $totalTime = ''; |
| 3934 | - if ($hours > 0) |
|
| 3935 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 3936 | - if ($minutes > 0) |
|
| 3937 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 3938 | - if ($seconds > 0) |
|
| 3939 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4131 | + if ($hours > 0) { |
|
| 4132 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4133 | + } |
|
| 4134 | + if ($minutes > 0) { |
|
| 4135 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4136 | + } |
|
| 4137 | + if ($seconds > 0) { |
|
| 4138 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4139 | + } |
|
| 3940 | 4140 | } |
| 3941 | 4141 | |
| 3942 | - if ($is_debug && !empty($totalTime)) |
|
| 3943 | - echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
| 3944 | - else |
|
| 3945 | - echo ' Successful!<br><br>'; |
|
| 4142 | + if ($is_debug && !empty($totalTime)) { |
|
| 4143 | + echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
| 4144 | + } else { |
|
| 4145 | + echo ' Successful!<br><br>'; |
|
| 4146 | + } |
|
| 3946 | 4147 | |
| 3947 | 4148 | echo '<span id="commess" style="font-weight: bold;">1 Database Updates Complete! Click Continue to Proceed.</span><br>'; |
| 3948 | 4149 | } |
| 3949 | - } |
|
| 3950 | - else |
|
| 4150 | + } else |
|
| 3951 | 4151 | { |
| 3952 | 4152 | // Tell them how many files we have in total. |
| 3953 | - if ($upcontext['file_count'] > 1) |
|
| 3954 | - echo ' |
|
| 4153 | + if ($upcontext['file_count'] > 1) { |
|
| 4154 | + echo ' |
|
| 3955 | 4155 | <strong id="info1">Executing upgrade script <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>'; |
| 4156 | + } |
|
| 3956 | 4157 | |
| 3957 | 4158 | echo ' |
| 3958 | 4159 | <h3 id="info2"><strong>Executing:</strong> "<span id="cur_item_name">', $upcontext['current_item_name'], '</span>" (<span id="item_num">', $upcontext['current_item_num'], '</span> of <span id="total_items"><span id="item_count">', $upcontext['total_items'], '</span>', $upcontext['file_count'] > 1 ? ' - of this script' : '', ')</span></h3> |
@@ -3968,19 +4169,23 @@ discard block |
||
| 3968 | 4169 | $seconds = intval($active % 60); |
| 3969 | 4170 | |
| 3970 | 4171 | $totalTime = ''; |
| 3971 | - if ($hours > 0) |
|
| 3972 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 3973 | - if ($minutes > 0) |
|
| 3974 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 3975 | - if ($seconds > 0) |
|
| 3976 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4172 | + if ($hours > 0) { |
|
| 4173 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4174 | + } |
|
| 4175 | + if ($minutes > 0) { |
|
| 4176 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4177 | + } |
|
| 4178 | + if ($seconds > 0) { |
|
| 4179 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4180 | + } |
|
| 3977 | 4181 | } |
| 3978 | 4182 | |
| 3979 | 4183 | echo ' |
| 3980 | 4184 | <br><span id="upgradeCompleted">'; |
| 3981 | 4185 | |
| 3982 | - if (!empty($totalTime)) |
|
| 3983 | - echo 'Completed in ', $totalTime, '<br>'; |
|
| 4186 | + if (!empty($totalTime)) { |
|
| 4187 | + echo 'Completed in ', $totalTime, '<br>'; |
|
| 4188 | + } |
|
| 3984 | 4189 | |
| 3985 | 4190 | echo '</span> |
| 3986 | 4191 | <div id="debug_section" style="height: 59px; overflow: auto;"> |
@@ -4017,9 +4222,10 @@ discard block |
||
| 4017 | 4222 | var getData = ""; |
| 4018 | 4223 | var debugItems = ', $upcontext['debug_items'], ';'; |
| 4019 | 4224 | |
| 4020 | - if ($is_debug) |
|
| 4021 | - echo ' |
|
| 4225 | + if ($is_debug) { |
|
| 4226 | + echo ' |
|
| 4022 | 4227 | var upgradeStartTime = ' . $upcontext['started'] . ';'; |
| 4228 | + } |
|
| 4023 | 4229 | |
| 4024 | 4230 | echo ' |
| 4025 | 4231 | function getNextItem() |
@@ -4059,9 +4265,10 @@ discard block |
||
| 4059 | 4265 | document.getElementById("error_block").style.display = ""; |
| 4060 | 4266 | setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));'; |
| 4061 | 4267 | |
| 4062 | - if ($is_debug) |
|
| 4063 | - echo ' |
|
| 4268 | + if ($is_debug) { |
|
| 4269 | + echo ' |
|
| 4064 | 4270 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
| 4271 | + } |
|
| 4065 | 4272 | |
| 4066 | 4273 | echo ' |
| 4067 | 4274 | } |
@@ -4082,9 +4289,10 @@ discard block |
||
| 4082 | 4289 | document.getElementById("error_block").style.display = ""; |
| 4083 | 4290 | setInnerHTML(document.getElementById("error_message"), "Upgrade script appears to be going into a loop - step: " + sDebugName);'; |
| 4084 | 4291 | |
| 4085 | - if ($is_debug) |
|
| 4086 | - echo ' |
|
| 4292 | + if ($is_debug) { |
|
| 4293 | + echo ' |
|
| 4087 | 4294 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
| 4295 | + } |
|
| 4088 | 4296 | |
| 4089 | 4297 | echo ' |
| 4090 | 4298 | } |
@@ -4143,8 +4351,8 @@ discard block |
||
| 4143 | 4351 | if (bIsComplete && iDebugNum == -1 && curFile >= ', $upcontext['file_count'], ') |
| 4144 | 4352 | {'; |
| 4145 | 4353 | |
| 4146 | - if ($is_debug) |
|
| 4147 | - echo ' |
|
| 4354 | + if ($is_debug) { |
|
| 4355 | + echo ' |
|
| 4148 | 4356 | document.getElementById(\'debug_section\').style.display = "none"; |
| 4149 | 4357 | |
| 4150 | 4358 | var upgradeFinishedTime = parseInt(oXMLDoc.getElementsByTagName("curtime")[0].childNodes[0].nodeValue); |
@@ -4162,6 +4370,7 @@ discard block |
||
| 4162 | 4370 | totalTime = totalTime + diffSeconds + " second" + (diffSeconds > 1 ? "s" : ""); |
| 4163 | 4371 | |
| 4164 | 4372 | setInnerHTML(document.getElementById("upgradeCompleted"), "Completed in " + totalTime);'; |
| 4373 | + } |
|
| 4165 | 4374 | |
| 4166 | 4375 | echo ' |
| 4167 | 4376 | |
@@ -4169,9 +4378,10 @@ discard block |
||
| 4169 | 4378 | document.getElementById(\'contbutt\').disabled = 0; |
| 4170 | 4379 | document.getElementById(\'database_done\').value = 1;'; |
| 4171 | 4380 | |
| 4172 | - if ($upcontext['file_count'] > 1) |
|
| 4173 | - echo ' |
|
| 4381 | + if ($upcontext['file_count'] > 1) { |
|
| 4382 | + echo ' |
|
| 4174 | 4383 | document.getElementById(\'info1\').style.display = "none";'; |
| 4384 | + } |
|
| 4175 | 4385 | |
| 4176 | 4386 | echo ' |
| 4177 | 4387 | document.getElementById(\'info2\').style.display = "none"; |
@@ -4184,9 +4394,10 @@ discard block |
||
| 4184 | 4394 | lastItem = 0; |
| 4185 | 4395 | prevFile = curFile;'; |
| 4186 | 4396 | |
| 4187 | - if ($is_debug) |
|
| 4188 | - echo ' |
|
| 4397 | + if ($is_debug) { |
|
| 4398 | + echo ' |
|
| 4189 | 4399 | setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br><span id="debuginfo"><\' + \'/span>\');'; |
| 4400 | + } |
|
| 4190 | 4401 | |
| 4191 | 4402 | echo ' |
| 4192 | 4403 | getNextItem(); |
@@ -4194,8 +4405,8 @@ discard block |
||
| 4194 | 4405 | }'; |
| 4195 | 4406 | |
| 4196 | 4407 | // If debug scroll the screen. |
| 4197 | - if ($is_debug) |
|
| 4198 | - echo ' |
|
| 4408 | + if ($is_debug) { |
|
| 4409 | + echo ' |
|
| 4199 | 4410 | if (iLastSubStepProgress == -1) |
| 4200 | 4411 | { |
| 4201 | 4412 | // Give it consistent dots. |
@@ -4214,6 +4425,7 @@ discard block |
||
| 4214 | 4425 | |
| 4215 | 4426 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4216 | 4427 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4428 | + } |
|
| 4217 | 4429 | |
| 4218 | 4430 | echo ' |
| 4219 | 4431 | // Update the page. |
@@ -4274,9 +4486,10 @@ discard block |
||
| 4274 | 4486 | }'; |
| 4275 | 4487 | |
| 4276 | 4488 | // Start things off assuming we've not errored. |
| 4277 | - if (empty($upcontext['error_message'])) |
|
| 4278 | - echo ' |
|
| 4489 | + if (empty($upcontext['error_message'])) { |
|
| 4490 | + echo ' |
|
| 4279 | 4491 | getNextItem();'; |
| 4492 | + } |
|
| 4280 | 4493 | |
| 4281 | 4494 | echo ' |
| 4282 | 4495 | //# sourceURL=dynamicScript-dbch.js |
@@ -4294,18 +4507,21 @@ discard block |
||
| 4294 | 4507 | <item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item> |
| 4295 | 4508 | <debug num="', $upcontext['current_debug_item_num'], '" percent="', isset($upcontext['substep_progress']) ? $upcontext['substep_progress'] : '-1', '" complete="', empty($upcontext['completed_step']) ? 0 : 1, '">', $upcontext['current_debug_item_name'], '</debug>'; |
| 4296 | 4509 | |
| 4297 | - if (!empty($upcontext['error_message'])) |
|
| 4298 | - echo ' |
|
| 4510 | + if (!empty($upcontext['error_message'])) { |
|
| 4511 | + echo ' |
|
| 4299 | 4512 | <error>', $upcontext['error_message'], '</error>'; |
| 4513 | + } |
|
| 4300 | 4514 | |
| 4301 | - if (!empty($upcontext['error_string'])) |
|
| 4302 | - echo ' |
|
| 4515 | + if (!empty($upcontext['error_string'])) { |
|
| 4516 | + echo ' |
|
| 4303 | 4517 | <sql>', $upcontext['error_string'], '</sql>'; |
| 4518 | + } |
|
| 4304 | 4519 | |
| 4305 | - if ($is_debug) |
|
| 4306 | - echo ' |
|
| 4520 | + if ($is_debug) { |
|
| 4521 | + echo ' |
|
| 4307 | 4522 | <curtime>', time(), '</curtime>'; |
| 4308 | -} |
|
| 4523 | + } |
|
| 4524 | + } |
|
| 4309 | 4525 | |
| 4310 | 4526 | // Template for the UTF-8 conversion step. Basically a copy of the backup stuff with slight modifications.... |
| 4311 | 4527 | function template_convert_utf8() |
@@ -4324,18 +4540,20 @@ discard block |
||
| 4324 | 4540 | </div>'; |
| 4325 | 4541 | |
| 4326 | 4542 | // Done any tables so far? |
| 4327 | - if (!empty($upcontext['previous_tables'])) |
|
| 4328 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4543 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4544 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 4329 | 4545 | echo ' |
| 4330 | 4546 | <br>Completed Table: "', $table, '".'; |
| 4547 | + } |
|
| 4331 | 4548 | |
| 4332 | 4549 | echo ' |
| 4333 | 4550 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3>'; |
| 4334 | 4551 | |
| 4335 | 4552 | // If we dropped their index, let's let them know |
| 4336 | - if ($upcontext['dropping_index']) |
|
| 4337 | - echo ' |
|
| 4553 | + if ($upcontext['dropping_index']) { |
|
| 4554 | + echo ' |
|
| 4338 | 4555 | <br><span id="indexmsg" style="font-weight: bold; font-style: italic; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">Please note that your fulltext index was dropped to facilitate the conversion and will need to be recreated in the admin area after the upgrade is complete.</span>'; |
| 4556 | + } |
|
| 4339 | 4557 | |
| 4340 | 4558 | // Completion notification |
| 4341 | 4559 | echo ' |
@@ -4372,12 +4590,13 @@ discard block |
||
| 4372 | 4590 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 4373 | 4591 | |
| 4374 | 4592 | // If debug flood the screen. |
| 4375 | - if ($is_debug) |
|
| 4376 | - echo ' |
|
| 4593 | + if ($is_debug) { |
|
| 4594 | + echo ' |
|
| 4377 | 4595 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 4378 | 4596 | |
| 4379 | 4597 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4380 | 4598 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4599 | + } |
|
| 4381 | 4600 | |
| 4382 | 4601 | echo ' |
| 4383 | 4602 | // Get the next update... |
@@ -4425,19 +4644,21 @@ discard block |
||
| 4425 | 4644 | </div>'; |
| 4426 | 4645 | |
| 4427 | 4646 | // Dont any tables so far? |
| 4428 | - if (!empty($upcontext['previous_tables'])) |
|
| 4429 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4647 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4648 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 4430 | 4649 | echo ' |
| 4431 | 4650 | <br>Completed Table: "', $table, '".'; |
| 4651 | + } |
|
| 4432 | 4652 | |
| 4433 | 4653 | echo ' |
| 4434 | 4654 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
| 4435 | 4655 | <br><span id="commess" style="font-weight: bold; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">Convert to JSON Complete! Click Continue to Proceed.</span>'; |
| 4436 | 4656 | |
| 4437 | 4657 | // Try to make sure substep was reset. |
| 4438 | - if ($upcontext['cur_table_num'] == $upcontext['table_count']) |
|
| 4439 | - echo ' |
|
| 4658 | + if ($upcontext['cur_table_num'] == $upcontext['table_count']) { |
|
| 4659 | + echo ' |
|
| 4440 | 4660 | <input type="hidden" name="substep" id="substep" value="0">'; |
| 4661 | + } |
|
| 4441 | 4662 | |
| 4442 | 4663 | // Continue please! |
| 4443 | 4664 | $upcontext['continue'] = $support_js ? 2 : 1; |
@@ -4470,12 +4691,13 @@ discard block |
||
| 4470 | 4691 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 4471 | 4692 | |
| 4472 | 4693 | // If debug flood the screen. |
| 4473 | - if ($is_debug) |
|
| 4474 | - echo ' |
|
| 4694 | + if ($is_debug) { |
|
| 4695 | + echo ' |
|
| 4475 | 4696 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 4476 | 4697 | |
| 4477 | 4698 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4478 | 4699 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4700 | + } |
|
| 4479 | 4701 | |
| 4480 | 4702 | echo ' |
| 4481 | 4703 | // Get the next update... |
@@ -4511,8 +4733,8 @@ discard block |
||
| 4511 | 4733 | <h3>That wasn\'t so hard, was it? Now you are ready to use <a href="', $boardurl, '/index.php">your installation of SMF</a>. Hope you like it!</h3> |
| 4512 | 4734 | <form action="', $boardurl, '/index.php">'; |
| 4513 | 4735 | |
| 4514 | - if (!empty($upcontext['can_delete_script'])) |
|
| 4515 | - echo ' |
|
| 4736 | + if (!empty($upcontext['can_delete_script'])) { |
|
| 4737 | + echo ' |
|
| 4516 | 4738 | <label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete(this);" class="input_check"> Delete upgrade.php and its data files now</label> <em>(doesn\'t work on all servers).</em> |
| 4517 | 4739 | <script> |
| 4518 | 4740 | function doTheDelete(theCheck) |
@@ -4524,6 +4746,7 @@ discard block |
||
| 4524 | 4746 | } |
| 4525 | 4747 | </script> |
| 4526 | 4748 | <img src="', $settings['default_theme_url'], '/images/blank.png" alt="" id="delete_upgrader"><br>'; |
| 4749 | + } |
|
| 4527 | 4750 | |
| 4528 | 4751 | $active = time() - $upcontext['started']; |
| 4529 | 4752 | $hours = floor($active / 3600); |
@@ -4533,16 +4756,20 @@ discard block |
||
| 4533 | 4756 | if ($is_debug) |
| 4534 | 4757 | { |
| 4535 | 4758 | $totalTime = ''; |
| 4536 | - if ($hours > 0) |
|
| 4537 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4538 | - if ($minutes > 0) |
|
| 4539 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4540 | - if ($seconds > 0) |
|
| 4541 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4759 | + if ($hours > 0) { |
|
| 4760 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4761 | + } |
|
| 4762 | + if ($minutes > 0) { |
|
| 4763 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4764 | + } |
|
| 4765 | + if ($seconds > 0) { |
|
| 4766 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4767 | + } |
|
| 4542 | 4768 | } |
| 4543 | 4769 | |
| 4544 | - if ($is_debug && !empty($totalTime)) |
|
| 4545 | - echo '<br> Upgrade completed in ', $totalTime, '<br><br>'; |
|
| 4770 | + if ($is_debug && !empty($totalTime)) { |
|
| 4771 | + echo '<br> Upgrade completed in ', $totalTime, '<br><br>'; |
|
| 4772 | + } |
|
| 4546 | 4773 | |
| 4547 | 4774 | echo '<br> |
| 4548 | 4775 | If you had any problems with this upgrade, or have any problems using SMF, please don\'t hesitate to <a href="https://www.simplemachines.org/community/index.php">look to us for assistance</a>.<br> |
@@ -4569,8 +4796,9 @@ discard block |
||
| 4569 | 4796 | |
| 4570 | 4797 | $current_substep = $_GET['substep']; |
| 4571 | 4798 | |
| 4572 | - if (empty($_GET['a'])) |
|
| 4573 | - $_GET['a'] = 0; |
|
| 4799 | + if (empty($_GET['a'])) { |
|
| 4800 | + $_GET['a'] = 0; |
|
| 4801 | + } |
|
| 4574 | 4802 | $step_progress['name'] = 'Converting ips'; |
| 4575 | 4803 | $step_progress['current'] = $_GET['a']; |
| 4576 | 4804 | |
@@ -4613,16 +4841,19 @@ discard block |
||
| 4613 | 4841 | 'empty' => '', |
| 4614 | 4842 | 'limit' => $limit, |
| 4615 | 4843 | )); |
| 4616 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 4617 | - $arIp[] = $row[$oldCol]; |
|
| 4844 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 4845 | + $arIp[] = $row[$oldCol]; |
|
| 4846 | + } |
|
| 4618 | 4847 | $smcFunc['db_free_result']($request); |
| 4619 | 4848 | |
| 4620 | 4849 | // Special case, null ip could keep us in a loop. |
| 4621 | - if (is_null($arIp[0])) |
|
| 4622 | - unset($arIp[0]); |
|
| 4850 | + if (is_null($arIp[0])) { |
|
| 4851 | + unset($arIp[0]); |
|
| 4852 | + } |
|
| 4623 | 4853 | |
| 4624 | - if (empty($arIp)) |
|
| 4625 | - $is_done = true; |
|
| 4854 | + if (empty($arIp)) { |
|
| 4855 | + $is_done = true; |
|
| 4856 | + } |
|
| 4626 | 4857 | |
| 4627 | 4858 | $updates = array(); |
| 4628 | 4859 | $cases = array(); |
@@ -4631,16 +4862,18 @@ discard block |
||
| 4631 | 4862 | { |
| 4632 | 4863 | $arIp[$i] = trim($arIp[$i]); |
| 4633 | 4864 | |
| 4634 | - if (empty($arIp[$i])) |
|
| 4635 | - continue; |
|
| 4865 | + if (empty($arIp[$i])) { |
|
| 4866 | + continue; |
|
| 4867 | + } |
|
| 4636 | 4868 | |
| 4637 | 4869 | $updates['ip' . $i] = $arIp[$i]; |
| 4638 | 4870 | $cases[$arIp[$i]] = 'WHEN ' . $oldCol . ' = {string:ip' . $i . '} THEN {inet:ip' . $i . '}'; |
| 4639 | 4871 | |
| 4640 | 4872 | if ($setSize > 0 && $i % $setSize === 0) |
| 4641 | 4873 | { |
| 4642 | - if (count($updates) == 1) |
|
| 4643 | - continue; |
|
| 4874 | + if (count($updates) == 1) { |
|
| 4875 | + continue; |
|
| 4876 | + } |
|
| 4644 | 4877 | |
| 4645 | 4878 | $updates['whereSet'] = array_values($updates); |
| 4646 | 4879 | $smcFunc['db_query']('', ' |
@@ -4674,8 +4907,7 @@ discard block |
||
| 4674 | 4907 | 'ip' => $ip |
| 4675 | 4908 | )); |
| 4676 | 4909 | } |
| 4677 | - } |
|
| 4678 | - else |
|
| 4910 | + } else |
|
| 4679 | 4911 | { |
| 4680 | 4912 | $updates['whereSet'] = array_values($updates); |
| 4681 | 4913 | $smcFunc['db_query']('', ' |
@@ -4689,9 +4921,9 @@ discard block |
||
| 4689 | 4921 | $updates |
| 4690 | 4922 | ); |
| 4691 | 4923 | } |
| 4924 | + } else { |
|
| 4925 | + $is_done = true; |
|
| 4692 | 4926 | } |
| 4693 | - else |
|
| 4694 | - $is_done = true; |
|
| 4695 | 4927 | |
| 4696 | 4928 | $_GET['a'] += $limit; |
| 4697 | 4929 | $step_progress['current'] = $_GET['a']; |
@@ -4717,10 +4949,11 @@ discard block |
||
| 4717 | 4949 | |
| 4718 | 4950 | $columns = $smcFunc['db_list_columns']($targetTable, true); |
| 4719 | 4951 | |
| 4720 | - if (isset($columns[$column])) |
|
| 4721 | - return $columns[$column]; |
|
| 4722 | - else |
|
| 4723 | - return null; |
|
| 4724 | -} |
|
| 4952 | + if (isset($columns[$column])) { |
|
| 4953 | + return $columns[$column]; |
|
| 4954 | + } else { |
|
| 4955 | + return null; |
|
| 4956 | + } |
|
| 4957 | + } |
|
| 4725 | 4958 | |
| 4726 | 4959 | ?> |
| 4727 | 4960 | \ No newline at end of file |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * This file contains helper functions for upgrade.php |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF_VERSION')) |
|
| 16 | +if (!defined('SMF_VERSION')) { |
|
| 17 | 17 | die('No direct access!'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Clean the cache using the SMF 2.1 CacheAPI. |
@@ -45,8 +46,9 @@ discard block |
||
| 45 | 46 | global $smcFunc; |
| 46 | 47 | static $member_groups = array(); |
| 47 | 48 | |
| 48 | - if (!empty($member_groups)) |
|
| 49 | - return $member_groups; |
|
| 49 | + if (!empty($member_groups)) { |
|
| 50 | + return $member_groups; |
|
| 51 | + } |
|
| 50 | 52 | |
| 51 | 53 | $request = $smcFunc['db_query']('', ' |
| 52 | 54 | SELECT group_name, id_group |
@@ -71,8 +73,9 @@ discard block |
||
| 71 | 73 | ) |
| 72 | 74 | ); |
| 73 | 75 | } |
| 74 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 75 | - $member_groups[trim($row[0])] = $row[1]; |
|
| 76 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 77 | + $member_groups[trim($row[0])] = $row[1]; |
|
| 78 | + } |
|
| 76 | 79 | $smcFunc['db_free_result']($request); |
| 77 | 80 | |
| 78 | 81 | return $member_groups; |
@@ -88,8 +91,9 @@ discard block |
||
| 88 | 91 | { |
| 89 | 92 | global $upcontext, $boarddir, $sourcedir; |
| 90 | 93 | |
| 91 | - if (empty($files)) |
|
| 92 | - return true; |
|
| 94 | + if (empty($files)) { |
|
| 95 | + return true; |
|
| 96 | + } |
|
| 93 | 97 | |
| 94 | 98 | $failure = false; |
| 95 | 99 | // On linux, it's easy - just use is_writable! |
@@ -100,22 +104,25 @@ discard block |
||
| 100 | 104 | foreach ($files as $k => $file) |
| 101 | 105 | { |
| 102 | 106 | // Some files won't exist, try to address up front |
| 103 | - if (!file_exists($file)) |
|
| 104 | - @touch($file); |
|
| 107 | + if (!file_exists($file)) { |
|
| 108 | + @touch($file); |
|
| 109 | + } |
|
| 105 | 110 | // NOW do the writable check... |
| 106 | 111 | if (!is_writable($file)) |
| 107 | 112 | { |
| 108 | 113 | @chmod($file, 0755); |
| 109 | 114 | |
| 110 | 115 | // Well, 755 hopefully worked... if not, try 777. |
| 111 | - if (!is_writable($file) && !@chmod($file, 0777)) |
|
| 112 | - $failure = true; |
|
| 116 | + if (!is_writable($file) && !@chmod($file, 0777)) { |
|
| 117 | + $failure = true; |
|
| 118 | + } |
|
| 113 | 119 | // Otherwise remove it as it's good! |
| 114 | - else |
|
| 115 | - unset($files[$k]); |
|
| 120 | + else { |
|
| 121 | + unset($files[$k]); |
|
| 122 | + } |
|
| 123 | + } else { |
|
| 124 | + unset($files[$k]); |
|
| 116 | 125 | } |
| 117 | - else |
|
| 118 | - unset($files[$k]); |
|
| 119 | 126 | } |
| 120 | 127 | } |
| 121 | 128 | // Windows is trickier. Let's try opening for r+... |
@@ -126,30 +133,35 @@ discard block |
||
| 126 | 133 | foreach ($files as $k => $file) |
| 127 | 134 | { |
| 128 | 135 | // Folders can't be opened for write... but the index.php in them can ;). |
| 129 | - if (is_dir($file)) |
|
| 130 | - $file .= '/index.php'; |
|
| 136 | + if (is_dir($file)) { |
|
| 137 | + $file .= '/index.php'; |
|
| 138 | + } |
|
| 131 | 139 | |
| 132 | 140 | // Funny enough, chmod actually does do something on windows - it removes the read only attribute. |
| 133 | 141 | @chmod($file, 0777); |
| 134 | 142 | $fp = @fopen($file, 'r+'); |
| 135 | 143 | |
| 136 | 144 | // Hmm, okay, try just for write in that case... |
| 137 | - if (!$fp) |
|
| 138 | - $fp = @fopen($file, 'w'); |
|
| 145 | + if (!$fp) { |
|
| 146 | + $fp = @fopen($file, 'w'); |
|
| 147 | + } |
|
| 139 | 148 | |
| 140 | - if (!$fp) |
|
| 141 | - $failure = true; |
|
| 142 | - else |
|
| 143 | - unset($files[$k]); |
|
| 149 | + if (!$fp) { |
|
| 150 | + $failure = true; |
|
| 151 | + } else { |
|
| 152 | + unset($files[$k]); |
|
| 153 | + } |
|
| 144 | 154 | @fclose($fp); |
| 145 | 155 | } |
| 146 | 156 | } |
| 147 | 157 | |
| 148 | - if (empty($files)) |
|
| 149 | - return true; |
|
| 158 | + if (empty($files)) { |
|
| 159 | + return true; |
|
| 160 | + } |
|
| 150 | 161 | |
| 151 | - if (!isset($_SERVER)) |
|
| 152 | - return !$failure; |
|
| 162 | + if (!isset($_SERVER)) { |
|
| 163 | + return !$failure; |
|
| 164 | + } |
|
| 153 | 165 | |
| 154 | 166 | // What still needs to be done? |
| 155 | 167 | $upcontext['chmod']['files'] = $files; |
@@ -201,36 +213,40 @@ discard block |
||
| 201 | 213 | |
| 202 | 214 | if (!isset($ftp) || $ftp->error !== false) |
| 203 | 215 | { |
| 204 | - if (!isset($ftp)) |
|
| 205 | - $ftp = new ftp_connection(null); |
|
| 216 | + if (!isset($ftp)) { |
|
| 217 | + $ftp = new ftp_connection(null); |
|
| 218 | + } |
|
| 206 | 219 | // Save the error so we can mess with listing... |
| 207 | - elseif ($ftp->error !== false && !isset($upcontext['chmod']['ftp_error'])) |
|
| 208 | - $upcontext['chmod']['ftp_error'] = $ftp->last_message === null ? '' : $ftp->last_message; |
|
| 220 | + elseif ($ftp->error !== false && !isset($upcontext['chmod']['ftp_error'])) { |
|
| 221 | + $upcontext['chmod']['ftp_error'] = $ftp->last_message === null ? '' : $ftp->last_message; |
|
| 222 | + } |
|
| 209 | 223 | |
| 210 | 224 | list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__)); |
| 211 | 225 | |
| 212 | - if ($found_path || !isset($upcontext['chmod']['path'])) |
|
| 213 | - $upcontext['chmod']['path'] = $detect_path; |
|
| 226 | + if ($found_path || !isset($upcontext['chmod']['path'])) { |
|
| 227 | + $upcontext['chmod']['path'] = $detect_path; |
|
| 228 | + } |
|
| 214 | 229 | |
| 215 | - if (!isset($upcontext['chmod']['username'])) |
|
| 216 | - $upcontext['chmod']['username'] = $username; |
|
| 230 | + if (!isset($upcontext['chmod']['username'])) { |
|
| 231 | + $upcontext['chmod']['username'] = $username; |
|
| 232 | + } |
|
| 217 | 233 | |
| 218 | 234 | // Don't forget the login token. |
| 219 | 235 | $upcontext += createToken('login'); |
| 220 | 236 | |
| 221 | 237 | return false; |
| 222 | - } |
|
| 223 | - else |
|
| 238 | + } else |
|
| 224 | 239 | { |
| 225 | 240 | // We want to do a relative path for FTP. |
| 226 | 241 | if (!in_array($upcontext['chmod']['path'], array('', '/'))) |
| 227 | 242 | { |
| 228 | 243 | $ftp_root = strtr($boarddir, array($upcontext['chmod']['path'] => '')); |
| 229 | - if (substr($ftp_root, -1) == '/' && ($upcontext['chmod']['path'] == '' || $upcontext['chmod']['path'][0] === '/')) |
|
| 230 | - $ftp_root = substr($ftp_root, 0, -1); |
|
| 244 | + if (substr($ftp_root, -1) == '/' && ($upcontext['chmod']['path'] == '' || $upcontext['chmod']['path'][0] === '/')) { |
|
| 245 | + $ftp_root = substr($ftp_root, 0, -1); |
|
| 246 | + } |
|
| 247 | + } else { |
|
| 248 | + $ftp_root = $boarddir; |
|
| 231 | 249 | } |
| 232 | - else |
|
| 233 | - $ftp_root = $boarddir; |
|
| 234 | 250 | |
| 235 | 251 | // Save the info for next time! |
| 236 | 252 | $_SESSION['installer_temp_ftp'] = array( |
@@ -244,10 +260,12 @@ discard block |
||
| 244 | 260 | |
| 245 | 261 | foreach ($files as $k => $file) |
| 246 | 262 | { |
| 247 | - if (!is_writable($file)) |
|
| 248 | - $ftp->chmod($file, 0755); |
|
| 249 | - if (!is_writable($file)) |
|
| 250 | - $ftp->chmod($file, 0777); |
|
| 263 | + if (!is_writable($file)) { |
|
| 264 | + $ftp->chmod($file, 0755); |
|
| 265 | + } |
|
| 266 | + if (!is_writable($file)) { |
|
| 267 | + $ftp->chmod($file, 0777); |
|
| 268 | + } |
|
| 251 | 269 | |
| 252 | 270 | // Assuming that didn't work calculate the path without the boarddir. |
| 253 | 271 | if (!is_writable($file)) |
@@ -256,19 +274,23 @@ discard block |
||
| 256 | 274 | { |
| 257 | 275 | $ftp_file = strtr($file, array($_SESSION['installer_temp_ftp']['root'] => '')); |
| 258 | 276 | $ftp->chmod($ftp_file, 0755); |
| 259 | - if (!is_writable($file)) |
|
| 260 | - $ftp->chmod($ftp_file, 0777); |
|
| 277 | + if (!is_writable($file)) { |
|
| 278 | + $ftp->chmod($ftp_file, 0777); |
|
| 279 | + } |
|
| 261 | 280 | // Sometimes an extra slash can help... |
| 262 | 281 | $ftp_file = '/' . $ftp_file; |
| 263 | - if (!is_writable($file)) |
|
| 264 | - $ftp->chmod($ftp_file, 0755); |
|
| 265 | - if (!is_writable($file)) |
|
| 266 | - $ftp->chmod($ftp_file, 0777); |
|
| 282 | + if (!is_writable($file)) { |
|
| 283 | + $ftp->chmod($ftp_file, 0755); |
|
| 284 | + } |
|
| 285 | + if (!is_writable($file)) { |
|
| 286 | + $ftp->chmod($ftp_file, 0777); |
|
| 287 | + } |
|
| 267 | 288 | } |
| 268 | 289 | } |
| 269 | 290 | |
| 270 | - if (is_writable($file)) |
|
| 271 | - unset($files[$k]); |
|
| 291 | + if (is_writable($file)) { |
|
| 292 | + unset($files[$k]); |
|
| 293 | + } |
|
| 272 | 294 | } |
| 273 | 295 | |
| 274 | 296 | $ftp->close(); |
@@ -278,8 +300,9 @@ discard block |
||
| 278 | 300 | // What remains? |
| 279 | 301 | $upcontext['chmod']['files'] = $files; |
| 280 | 302 | |
| 281 | - if (empty($files)) |
|
| 282 | - return true; |
|
| 303 | + if (empty($files)) { |
|
| 304 | + return true; |
|
| 305 | + } |
|
| 283 | 306 | |
| 284 | 307 | return false; |
| 285 | 308 | } |
@@ -294,12 +317,14 @@ discard block |
||
| 294 | 317 | { |
| 295 | 318 | |
| 296 | 319 | // Some files won't exist, try to address up front |
| 297 | - if (!file_exists($file)) |
|
| 298 | - @touch($file); |
|
| 320 | + if (!file_exists($file)) { |
|
| 321 | + @touch($file); |
|
| 322 | + } |
|
| 299 | 323 | |
| 300 | 324 | // NOW do the writable check... |
| 301 | - if (is_writable($file)) |
|
| 302 | - return true; |
|
| 325 | + if (is_writable($file)) { |
|
| 326 | + return true; |
|
| 327 | + } |
|
| 303 | 328 | |
| 304 | 329 | @chmod($file, 0755); |
| 305 | 330 | |
@@ -309,10 +334,11 @@ discard block |
||
| 309 | 334 | foreach ($chmod_values as $val) |
| 310 | 335 | { |
| 311 | 336 | // If it's writable, break out of the loop |
| 312 | - if (is_writable($file)) |
|
| 313 | - break; |
|
| 314 | - else |
|
| 315 | - @chmod($file, $val); |
|
| 337 | + if (is_writable($file)) { |
|
| 338 | + break; |
|
| 339 | + } else { |
|
| 340 | + @chmod($file, $val); |
|
| 341 | + } |
|
| 316 | 342 | } |
| 317 | 343 | |
| 318 | 344 | return is_writable($file); |
@@ -339,14 +365,16 @@ discard block |
||
| 339 | 365 | { |
| 340 | 366 | static $fp = null; |
| 341 | 367 | |
| 342 | - if ($fp === null) |
|
| 343 | - $fp = fopen('php://stderr', 'wb'); |
|
| 368 | + if ($fp === null) { |
|
| 369 | + $fp = fopen('php://stderr', 'wb'); |
|
| 370 | + } |
|
| 344 | 371 | |
| 345 | 372 | fwrite($fp, $message . "\n"); |
| 346 | 373 | |
| 347 | - if ($fatal) |
|
| 348 | - exit; |
|
| 349 | -} |
|
| 374 | + if ($fatal) { |
|
| 375 | + exit; |
|
| 376 | + } |
|
| 377 | + } |
|
| 350 | 378 | |
| 351 | 379 | /** |
| 352 | 380 | * Throws a graphical error message. |
@@ -67,8 +67,9 @@ discard block |
||
| 67 | 67 | foreach ($context['categories'] as $category) |
| 68 | 68 | { |
| 69 | 69 | // If theres no parent boards we can see, avoid showing an empty category (unless its collapsed) |
| 70 | - if (empty($category['boards']) && !$category['is_collapsed']) |
|
| 71 | - continue; |
|
| 70 | + if (empty($category['boards']) && !$category['is_collapsed']) { |
|
| 71 | + continue; |
|
| 72 | + } |
|
| 72 | 73 | |
| 73 | 74 | echo ' |
| 74 | 75 | <div class="main_container"> |
@@ -76,9 +77,10 @@ discard block |
||
| 76 | 77 | <h3 class="catbg">'; |
| 77 | 78 | |
| 78 | 79 | // If this category even can collapse, show a link to collapse it. |
| 79 | - if ($category['can_collapse']) |
|
| 80 | - echo ' |
|
| 80 | + if ($category['can_collapse']) { |
|
| 81 | + echo ' |
|
| 81 | 82 | <span id="category_', $category['id'], '_upshrink" class="', $category['is_collapsed'] ? 'toggle_down' : 'toggle_up', ' floatright" data-collapsed="', (int) $category['is_collapsed'], '" title="', !$category['is_collapsed'] ? $txt['hide_category'] : $txt['show_category'], '" style="display: none;"></span>'; |
| 83 | + } |
|
| 82 | 84 | |
| 83 | 85 | echo ' |
| 84 | 86 | ', $category['link'], ' |
@@ -105,17 +107,19 @@ discard block |
||
| 105 | 107 | </a>'; |
| 106 | 108 | |
| 107 | 109 | // Has it outstanding posts for approval? |
| 108 | - if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics'])) |
|
| 109 | - echo ' |
|
| 110 | + if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics'])) { |
|
| 111 | + echo ' |
|
| 110 | 112 | <a href="', $scripturl, '?action=moderate;area=postmod;sa=', ($board['unapproved_topics'] > 0 ? 'topics' : 'posts'), ';brd=', $board['id'], ';', $context['session_var'], '=', $context['session_id'], '" title="', sprintf($txt['unapproved_posts'], $board['unapproved_topics'], $board['unapproved_posts']), '" class="moderation_link">(!)</a>'; |
| 113 | + } |
|
| 111 | 114 | |
| 112 | 115 | echo ' |
| 113 | 116 | <p class="board_description">', $board['description'], '</p>'; |
| 114 | 117 | |
| 115 | 118 | // Show the "Moderators: ". Each has name, href, link, and id. (but we're gonna use link_moderators.) |
| 116 | - if (!empty($board['link_moderators'])) |
|
| 117 | - echo ' |
|
| 119 | + if (!empty($board['link_moderators'])) { |
|
| 120 | + echo ' |
|
| 118 | 121 | <p class="moderators">', count($board['link_moderators']) == 1 ? $txt['moderator'] : $txt['moderators'], ': ', implode(', ', $board['link_moderators']), '</p>'; |
| 122 | + } |
|
| 119 | 123 | |
| 120 | 124 | // Show some basic information about the number of posts, etc. |
| 121 | 125 | echo ' |
@@ -127,9 +131,10 @@ discard block |
||
| 127 | 131 | </div> |
| 128 | 132 | <div class="lastpost ',!empty($board['last_post']['id']) ? 'lpr_border' : 'hidden', '">'; |
| 129 | 133 | |
| 130 | - if (!empty($board['last_post']['id'])) |
|
| 131 | - echo ' |
|
| 134 | + if (!empty($board['last_post']['id'])) { |
|
| 135 | + echo ' |
|
| 132 | 136 | <p>', $board['last_post']['last_post_message'], '</p>'; |
| 137 | + } |
|
| 133 | 138 | echo ' |
| 134 | 139 | </div>'; |
| 135 | 140 | // Show the "Child Boards: ". (there's a link_children but we're going to bold the new ones...) |
@@ -141,14 +146,16 @@ discard block |
||
| 141 | 146 | id, name, description, new (is it new?), topics (#), posts (#), href, link, and last_post. */ |
| 142 | 147 | foreach ($board['children'] as $child) |
| 143 | 148 | { |
| 144 | - if (!$child['is_redirect']) |
|
| 145 | - $child['link'] = '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . ($child['new'] ? '</a> <a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span>' : '') . '</a>'; |
|
| 146 | - else |
|
| 147 | - $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . ' - ' . $child['short_description'] . '">' . $child['name'] . '</a>'; |
|
| 149 | + if (!$child['is_redirect']) { |
|
| 150 | + $child['link'] = '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . ($child['new'] ? '</a> <a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span>' : '') . '</a>'; |
|
| 151 | + } else { |
|
| 152 | + $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . ' - ' . $child['short_description'] . '">' . $child['name'] . '</a>'; |
|
| 153 | + } |
|
| 148 | 154 | |
| 149 | 155 | // Has it posts awaiting approval? |
| 150 | - if ($child['can_approve_posts'] && ($child['unapproved_posts'] || $child['unapproved_topics'])) |
|
| 151 | - $child['link'] .= ' <a href="' . $scripturl . '?action=moderate;area=postmod;sa=' . ($child['unapproved_topics'] > 0 ? 'topics' : 'posts') . ';brd=' . $child['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" title="' . sprintf($txt['unapproved_posts'], $child['unapproved_topics'], $child['unapproved_posts']) . '" class="moderation_link">(!)</a>'; |
|
| 156 | + if ($child['can_approve_posts'] && ($child['unapproved_posts'] || $child['unapproved_topics'])) { |
|
| 157 | + $child['link'] .= ' <a href="' . $scripturl . '?action=moderate;area=postmod;sa=' . ($child['unapproved_topics'] > 0 ? 'topics' : 'posts') . ';brd=' . $child['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" title="' . sprintf($txt['unapproved_posts'], $child['unapproved_topics'], $child['unapproved_posts']) . '" class="moderation_link">(!)</a>'; |
|
| 158 | + } |
|
| 152 | 159 | |
| 153 | 160 | $children[] = $child['new'] ? '<span class="strong">' . $child['link'] . '</span>' : '<span>' . $child['link'] . '</span>'; |
| 154 | 161 | } |
@@ -172,10 +179,11 @@ discard block |
||
| 172 | 179 | </div>'; |
| 173 | 180 | |
| 174 | 181 | // Show the mark all as read button? |
| 175 | - if ($context['user']['is_logged'] && !empty($context['categories'])) |
|
| 176 | - echo ' |
|
| 182 | + if ($context['user']['is_logged'] && !empty($context['categories'])) { |
|
| 183 | + echo ' |
|
| 177 | 184 | <div class="mark_read">', template_button_strip($context['mark_read_button'], 'right'), '</div>'; |
| 178 | -} |
|
| 185 | + } |
|
| 186 | + } |
|
| 179 | 187 | |
| 180 | 188 | /** |
| 181 | 189 | * The lower part of the outer layer of the board index |
@@ -192,8 +200,9 @@ discard block |
||
| 192 | 200 | { |
| 193 | 201 | global $context, $options, $txt; |
| 194 | 202 | |
| 195 | - if (empty($context['info_center'])) |
|
| 196 | - return; |
|
| 203 | + if (empty($context['info_center'])) { |
|
| 204 | + return; |
|
| 205 | + } |
|
| 197 | 206 | |
| 198 | 207 | // Here's where the "Info Center" starts... |
| 199 | 208 | echo ' |
@@ -293,14 +302,15 @@ discard block |
||
| 293 | 302 | /* Each post in latest_posts has: |
| 294 | 303 | board (with an id, name, and link.), topic (the topic's id.), poster (with id, name, and link.), |
| 295 | 304 | subject, short_subject (shortened with...), time, link, and href. */ |
| 296 | - foreach ($context['latest_posts'] as $post) |
|
| 297 | - echo ' |
|
| 305 | + foreach ($context['latest_posts'] as $post) { |
|
| 306 | + echo ' |
|
| 298 | 307 | <tr class="windowbg"> |
| 299 | 308 | <td class="recentpost"><strong>', $post['link'], '</strong></td> |
| 300 | 309 | <td class="recentposter">', $post['poster']['link'], '</td> |
| 301 | 310 | <td class="recentboard">', $post['board']['link'], '</td> |
| 302 | 311 | <td class="recenttime">', $post['time'], '</td> |
| 303 | 312 | </tr>'; |
| 313 | + } |
|
| 304 | 314 | echo ' |
| 305 | 315 | </table>'; |
| 306 | 316 | } |
@@ -324,9 +334,10 @@ discard block |
||
| 324 | 334 | </div>'; |
| 325 | 335 | |
| 326 | 336 | // Holidays like "Christmas", "Chanukah", and "We Love [Unknown] Day" :P. |
| 327 | - if (!empty($context['calendar_holidays'])) |
|
| 328 | - echo ' |
|
| 337 | + if (!empty($context['calendar_holidays'])) { |
|
| 338 | + echo ' |
|
| 329 | 339 | <p class="inline holiday"><span>', $txt['calendar_prompt'], '</span> ', implode(', ', $context['calendar_holidays']), '</p>'; |
| 340 | + } |
|
| 330 | 341 | |
| 331 | 342 | // People's birthdays. Like mine. And yours, I guess. Kidding. |
| 332 | 343 | if (!empty($context['calendar_birthdays'])) |
@@ -335,9 +346,10 @@ discard block |
||
| 335 | 346 | <p class="inline"> |
| 336 | 347 | <span class="birthday">', $context['calendar_only_today'] ? $txt['birthdays'] : $txt['birthdays_upcoming'], '</span>'; |
| 337 | 348 | // Each member in calendar_birthdays has: id, name (person), age (if they have one set?), is_last. (last in list?), and is_today (birthday is today?) |
| 338 | - foreach ($context['calendar_birthdays'] as $member) |
|
| 339 | - echo ' |
|
| 349 | + foreach ($context['calendar_birthdays'] as $member) { |
|
| 350 | + echo ' |
|
| 340 | 351 | <a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['is_today'] ? '<strong class="fix_rtl_names">' : '', $member['name'], $member['is_today'] ? '</strong>' : '', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', $member['is_last'] ? '' : ', '; |
| 352 | + } |
|
| 341 | 353 | echo ' |
| 342 | 354 | </p>'; |
| 343 | 355 | } |
@@ -351,9 +363,10 @@ discard block |
||
| 351 | 363 | |
| 352 | 364 | // Each event in calendar_events should have: |
| 353 | 365 | // title, href, is_last, can_edit (are they allowed?), modify_href, and is_today. |
| 354 | - foreach ($context['calendar_events'] as $event) |
|
| 355 | - echo ' |
|
| 366 | + foreach ($context['calendar_events'] as $event) { |
|
| 367 | + echo ' |
|
| 356 | 368 | ', $event['can_edit'] ? '<a href="' . $event['modify_href'] . '" title="' . $txt['calendar_edit'] . '"><span class="generic_icons calendar_modify"></span></a> ' : '', $event['href'] == '' ? '' : '<a href="' . $event['href'] . '">', $event['is_today'] ? '<strong>' . $event['title'] . '</strong>' : $event['title'], $event['href'] == '' ? '' : '</a>', $event['is_last'] ? '<br>' : ', '; |
| 369 | + } |
|
| 357 | 370 | echo ' |
| 358 | 371 | </p>'; |
| 359 | 372 | } |
@@ -398,15 +411,19 @@ discard block |
||
| 398 | 411 | |
| 399 | 412 | // Handle hidden users and buddies. |
| 400 | 413 | $bracketList = array(); |
| 401 | - if ($context['show_buddies']) |
|
| 402 | - $bracketList[] = comma_format($context['num_buddies']) . ' ' . ($context['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']); |
|
| 403 | - if (!empty($context['num_spiders'])) |
|
| 404 | - $bracketList[] = comma_format($context['num_spiders']) . ' ' . ($context['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']); |
|
| 405 | - if (!empty($context['num_users_hidden'])) |
|
| 406 | - $bracketList[] = comma_format($context['num_users_hidden']) . ' ' . ($context['num_spiders'] == 1 ? $txt['hidden'] : $txt['hidden_s']); |
|
| 414 | + if ($context['show_buddies']) { |
|
| 415 | + $bracketList[] = comma_format($context['num_buddies']) . ' ' . ($context['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']); |
|
| 416 | + } |
|
| 417 | + if (!empty($context['num_spiders'])) { |
|
| 418 | + $bracketList[] = comma_format($context['num_spiders']) . ' ' . ($context['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']); |
|
| 419 | + } |
|
| 420 | + if (!empty($context['num_users_hidden'])) { |
|
| 421 | + $bracketList[] = comma_format($context['num_users_hidden']) . ' ' . ($context['num_spiders'] == 1 ? $txt['hidden'] : $txt['hidden_s']); |
|
| 422 | + } |
|
| 407 | 423 | |
| 408 | - if (!empty($bracketList)) |
|
| 409 | - echo ' (' . implode(', ', $bracketList) . ')'; |
|
| 424 | + if (!empty($bracketList)) { |
|
| 425 | + echo ' (' . implode(', ', $bracketList) . ')'; |
|
| 426 | + } |
|
| 410 | 427 | |
| 411 | 428 | echo $context['show_who'] ? '</a>' : '', ' |
| 412 | 429 | |
@@ -420,9 +437,10 @@ discard block |
||
| 420 | 437 | ', sprintf($txt['users_active'], $modSettings['lastActive']), ': ', implode(', ', $context['list_users_online']); |
| 421 | 438 | |
| 422 | 439 | // Showing membergroups? |
| 423 | - if (!empty($settings['show_group_key']) && !empty($context['membergroups'])) |
|
| 424 | - echo ' |
|
| 440 | + if (!empty($settings['show_group_key']) && !empty($context['membergroups'])) { |
|
| 441 | + echo ' |
|
| 425 | 442 | <span class="membergroups">' . implode(', ', $context['membergroups']) . '</span>'; |
| 443 | + } |
|
| 426 | 444 | } |
| 427 | 445 | |
| 428 | 446 | echo ' |