@@ -1697,8 +1697,7 @@ discard block |
||
| 1697 | 1697 | updateStats('topic'); |
| 1698 | 1698 | |
| 1699 | 1699 | // This function is needed to do the updateStats('subject') call. |
| 1700 | - $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : |
|
| 1701 | - function($string){ |
|
| 1700 | + $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) { |
|
| 1702 | 1701 | global $sourcedir; |
| 1703 | 1702 | if (function_exists('mb_strtolower')) |
| 1704 | 1703 | return mb_strtolower($string, 'UTF-8'); |
@@ -1767,7 +1766,7 @@ discard block |
||
| 1767 | 1766 | if (trim($settingsArray[$i]) == 'if (file_exists(dirname(__FILE__) . \'/install.php\'))' && trim($settingsArray[$i + 1]) == '{' && trim($settingsArray[$i + 9]) == '}') |
| 1768 | 1767 | { |
| 1769 | 1768 | // Set the ten lines to nothing. |
| 1770 | - for ($j=0; $j < 10; $j++) |
|
| 1769 | + for ($j = 0; $j < 10; $j++) |
|
| 1771 | 1770 | $settingsArray[$i++] = ''; |
| 1772 | 1771 | |
| 1773 | 1772 | continue; |
@@ -20,8 +20,9 @@ discard block |
||
| 20 | 20 | // ><html dir="ltr"><head><title>Error!</title></head><body>Sorry, this installer requires PHP!<div style="display: none;"> |
| 21 | 21 | |
| 22 | 22 | // Let's pull in useful classes |
| 23 | -if (!defined('SMF')) |
|
| 23 | +if (!defined('SMF')) { |
|
| 24 | 24 | define('SMF', 1); |
| 25 | +} |
|
| 25 | 26 | |
| 26 | 27 | require_once('Sources/Class-Package.php'); |
| 27 | 28 | |
@@ -63,10 +64,11 @@ discard block |
||
| 63 | 64 | |
| 64 | 65 | list ($charcode) = pg_fetch_row($request); |
| 65 | 66 | |
| 66 | - if ($charcode == 'UTF8') |
|
| 67 | - return true; |
|
| 68 | - else |
|
| 69 | - return false; |
|
| 67 | + if ($charcode == 'UTF8') { |
|
| 68 | + return true; |
|
| 69 | + } else { |
|
| 70 | + return false; |
|
| 71 | + } |
|
| 70 | 72 | }, |
| 71 | 73 | 'utf8_version' => '8.0', |
| 72 | 74 | 'utf8_version_check' => '$request = pg_query(\'SELECT version()\'); list ($version) = pg_fetch_row($request); list($pgl, $version) = explode(" ", $version); return $version;', |
@@ -76,12 +78,14 @@ discard block |
||
| 76 | 78 | $value = preg_replace('~[^A-Za-z0-9_\$]~', '', $value); |
| 77 | 79 | |
| 78 | 80 | // Is it reserved? |
| 79 | - if ($value == 'pg_') |
|
| 80 | - return $txt['error_db_prefix_reserved']; |
|
| 81 | + if ($value == 'pg_') { |
|
| 82 | + return $txt['error_db_prefix_reserved']; |
|
| 83 | + } |
|
| 81 | 84 | |
| 82 | 85 | // Is the prefix numeric? |
| 83 | - if (preg_match('~^\d~', $value)) |
|
| 84 | - return $txt['error_db_prefix_numeric']; |
|
| 86 | + if (preg_match('~^\d~', $value)) { |
|
| 87 | + return $txt['error_db_prefix_numeric']; |
|
| 88 | + } |
|
| 85 | 89 | |
| 86 | 90 | return true; |
| 87 | 91 | }, |
@@ -128,10 +132,11 @@ discard block |
||
| 128 | 132 | $incontext['skip'] = false; |
| 129 | 133 | |
| 130 | 134 | // Call the step and if it returns false that means pause! |
| 131 | - if (function_exists($step[2]) && $step[2]() === false) |
|
| 132 | - break; |
|
| 133 | - elseif (function_exists($step[2])) |
|
| 134 | - $incontext['current_step']++; |
|
| 135 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
| 136 | + break; |
|
| 137 | + } elseif (function_exists($step[2])) { |
|
| 138 | + $incontext['current_step']++; |
|
| 139 | + } |
|
| 135 | 140 | |
| 136 | 141 | // No warnings pass on. |
| 137 | 142 | $incontext['warning'] = ''; |
@@ -147,8 +152,9 @@ discard block |
||
| 147 | 152 | global $databases; |
| 148 | 153 | |
| 149 | 154 | // Just so people using older versions of PHP aren't left in the cold. |
| 150 | - if (!isset($_SERVER['PHP_SELF'])) |
|
| 151 | - $_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php'; |
|
| 155 | + if (!isset($_SERVER['PHP_SELF'])) { |
|
| 156 | + $_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php'; |
|
| 157 | + } |
|
| 152 | 158 | |
| 153 | 159 | // Enable error reporting for fatal errors. |
| 154 | 160 | error_reporting(E_ERROR | E_PARSE); |
@@ -164,21 +170,23 @@ discard block |
||
| 164 | 170 | { |
| 165 | 171 | ob_start(); |
| 166 | 172 | |
| 167 | - if (ini_get('session.save_handler') == 'user') |
|
| 168 | - @ini_set('session.save_handler', 'files'); |
|
| 169 | - if (function_exists('session_start')) |
|
| 170 | - @session_start(); |
|
| 171 | - } |
|
| 172 | - else |
|
| 173 | + if (ini_get('session.save_handler') == 'user') { |
|
| 174 | + @ini_set('session.save_handler', 'files'); |
|
| 175 | + } |
|
| 176 | + if (function_exists('session_start')) { |
|
| 177 | + @session_start(); |
|
| 178 | + } |
|
| 179 | + } else |
|
| 173 | 180 | { |
| 174 | 181 | ob_start('ob_gzhandler'); |
| 175 | 182 | |
| 176 | - if (ini_get('session.save_handler') == 'user') |
|
| 177 | - @ini_set('session.save_handler', 'files'); |
|
| 183 | + if (ini_get('session.save_handler') == 'user') { |
|
| 184 | + @ini_set('session.save_handler', 'files'); |
|
| 185 | + } |
|
| 178 | 186 | session_start(); |
| 179 | 187 | |
| 180 | - if (!headers_sent()) |
|
| 181 | - echo '<!DOCTYPE html> |
|
| 188 | + if (!headers_sent()) { |
|
| 189 | + echo '<!DOCTYPE html> |
|
| 182 | 190 | <html> |
| 183 | 191 | <head> |
| 184 | 192 | <title>', htmlspecialchars($_GET['pass_string']), '</title> |
@@ -187,14 +195,16 @@ discard block |
||
| 187 | 195 | <strong>', htmlspecialchars($_GET['pass_string']), '</strong> |
| 188 | 196 | </body> |
| 189 | 197 | </html>'; |
| 198 | + } |
|
| 190 | 199 | exit; |
| 191 | 200 | } |
| 192 | 201 | |
| 193 | 202 | // Add slashes, as long as they aren't already being added. |
| 194 | - if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) |
|
| 195 | - foreach ($_POST as $k => $v) |
|
| 203 | + if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) { |
|
| 204 | + foreach ($_POST as $k => $v) |
|
| 196 | 205 | if (strpos($k, 'password') === false && strpos($k, 'db_passwd') === false) |
| 197 | 206 | $_POST[$k] = addslashes($v); |
| 207 | + } |
|
| 198 | 208 | |
| 199 | 209 | // This is really quite simple; if ?delete is on the URL, delete the installer... |
| 200 | 210 | if (isset($_GET['delete'])) |
@@ -215,8 +225,7 @@ discard block |
||
| 215 | 225 | $ftp->close(); |
| 216 | 226 | |
| 217 | 227 | unset($_SESSION['installer_temp_ftp']); |
| 218 | - } |
|
| 219 | - else |
|
| 228 | + } else |
|
| 220 | 229 | { |
| 221 | 230 | @unlink(__FILE__); |
| 222 | 231 | |
@@ -230,10 +239,11 @@ discard block |
||
| 230 | 239 | // Now just redirect to a blank.png... |
| 231 | 240 | $secure = false; |
| 232 | 241 | |
| 233 | - if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') |
|
| 234 | - $secure = true; |
|
| 235 | - elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') |
|
| 236 | - $secure = true; |
|
| 242 | + if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { |
|
| 243 | + $secure = true; |
|
| 244 | + } elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') { |
|
| 245 | + $secure = true; |
|
| 246 | + } |
|
| 237 | 247 | |
| 238 | 248 | header('Location: http' . ($secure ? 's' : '') . '://' . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT']) . dirname($_SERVER['PHP_SELF']) . '/Themes/default/images/blank.png'); |
| 239 | 249 | exit; |
@@ -244,10 +254,11 @@ discard block |
||
| 244 | 254 | { |
| 245 | 255 | // Get PHP's default timezone, if set |
| 246 | 256 | $ini_tz = ini_get('date.timezone'); |
| 247 | - if (!empty($ini_tz)) |
|
| 248 | - $timezone_id = $ini_tz; |
|
| 249 | - else |
|
| 250 | - $timezone_id = ''; |
|
| 257 | + if (!empty($ini_tz)) { |
|
| 258 | + $timezone_id = $ini_tz; |
|
| 259 | + } else { |
|
| 260 | + $timezone_id = ''; |
|
| 261 | + } |
|
| 251 | 262 | |
| 252 | 263 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
| 253 | 264 | if (!in_array($timezone_id, timezone_identifiers_list())) |
@@ -277,8 +288,9 @@ discard block |
||
| 277 | 288 | $dir = dir(dirname(__FILE__) . '/Themes/default/languages'); |
| 278 | 289 | while ($entry = $dir->read()) |
| 279 | 290 | { |
| 280 | - if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') |
|
| 281 | - $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
| 291 | + if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') { |
|
| 292 | + $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
| 293 | + } |
|
| 282 | 294 | } |
| 283 | 295 | $dir->close(); |
| 284 | 296 | } |
@@ -313,10 +325,11 @@ discard block |
||
| 313 | 325 | } |
| 314 | 326 | |
| 315 | 327 | // Override the language file? |
| 316 | - if (isset($_GET['lang_file'])) |
|
| 317 | - $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
| 318 | - elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) |
|
| 319 | - $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
| 328 | + if (isset($_GET['lang_file'])) { |
|
| 329 | + $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
| 330 | + } elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) { |
|
| 331 | + $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
| 332 | + } |
|
| 320 | 333 | |
| 321 | 334 | // Make sure it exists, if it doesn't reset it. |
| 322 | 335 | 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'])) |
@@ -325,8 +338,9 @@ discard block |
||
| 325 | 338 | list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
| 326 | 339 | |
| 327 | 340 | // If we have english and some other language, use the other language. We Americans hate english :P. |
| 328 | - if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) |
|
| 329 | - list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
| 341 | + if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) { |
|
| 342 | + list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
| 343 | + } |
|
| 330 | 344 | } |
| 331 | 345 | |
| 332 | 346 | // And now include the actual language file itself. |
@@ -343,15 +357,18 @@ discard block |
||
| 343 | 357 | global $db_prefix, $db_connection, $sourcedir, $smcFunc, $modSettings; |
| 344 | 358 | global $db_server, $db_passwd, $db_type, $db_name, $db_user, $db_persist; |
| 345 | 359 | |
| 346 | - if (empty($sourcedir)) |
|
| 347 | - $sourcedir = dirname(__FILE__) . '/Sources'; |
|
| 360 | + if (empty($sourcedir)) { |
|
| 361 | + $sourcedir = dirname(__FILE__) . '/Sources'; |
|
| 362 | + } |
|
| 348 | 363 | |
| 349 | 364 | // Need this to check whether we need the database password. |
| 350 | 365 | require(dirname(__FILE__) . '/Settings.php'); |
| 351 | - if (!defined('SMF')) |
|
| 352 | - define('SMF', 1); |
|
| 353 | - if (empty($smcFunc)) |
|
| 354 | - $smcFunc = array(); |
|
| 366 | + if (!defined('SMF')) { |
|
| 367 | + define('SMF', 1); |
|
| 368 | + } |
|
| 369 | + if (empty($smcFunc)) { |
|
| 370 | + $smcFunc = array(); |
|
| 371 | + } |
|
| 355 | 372 | |
| 356 | 373 | $modSettings['disableQueryCheck'] = true; |
| 357 | 374 | |
@@ -359,8 +376,9 @@ discard block |
||
| 359 | 376 | if (!$db_connection) |
| 360 | 377 | { |
| 361 | 378 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
| 362 | - if (version_compare(PHP_VERSION, '5', '<')) |
|
| 363 | - require_once($sourcedir . '/Subs-Compat.php'); |
|
| 379 | + if (version_compare(PHP_VERSION, '5', '<')) { |
|
| 380 | + require_once($sourcedir . '/Subs-Compat.php'); |
|
| 381 | + } |
|
| 364 | 382 | |
| 365 | 383 | $db_options = array('persist' => $db_persist); |
| 366 | 384 | $port = ''; |
@@ -371,19 +389,20 @@ discard block |
||
| 371 | 389 | if ($db_type == 'mysql') |
| 372 | 390 | { |
| 373 | 391 | $port = ((int) $_POST['db_port'] == ini_get($db_type . 'default_port')) ? '' : (int) $_POST['db_port']; |
| 374 | - } |
|
| 375 | - elseif ($db_type == 'postgresql') |
|
| 392 | + } elseif ($db_type == 'postgresql') |
|
| 376 | 393 | { |
| 377 | 394 | // PostgreSQL doesn't have a default port setting in php.ini, so just check against the default |
| 378 | 395 | $port = ((int) $_POST['db_port'] == 5432) ? '' : (int) $_POST['db_port']; |
| 379 | 396 | } |
| 380 | 397 | } |
| 381 | 398 | |
| 382 | - if (!empty($port)) |
|
| 383 | - $db_options['port'] = $port; |
|
| 399 | + if (!empty($port)) { |
|
| 400 | + $db_options['port'] = $port; |
|
| 401 | + } |
|
| 384 | 402 | |
| 385 | - if (!$db_connection) |
|
| 386 | - $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options); |
|
| 403 | + if (!$db_connection) { |
|
| 404 | + $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options); |
|
| 405 | + } |
|
| 387 | 406 | } |
| 388 | 407 | } |
| 389 | 408 | |
@@ -411,8 +430,9 @@ discard block |
||
| 411 | 430 | // @todo REMOVE THIS!! |
| 412 | 431 | else |
| 413 | 432 | { |
| 414 | - if (function_exists('doStep' . $_GET['step'])) |
|
| 415 | - call_user_func('doStep' . $_GET['step']); |
|
| 433 | + if (function_exists('doStep' . $_GET['step'])) { |
|
| 434 | + call_user_func('doStep' . $_GET['step']); |
|
| 435 | + } |
|
| 416 | 436 | } |
| 417 | 437 | // Show the footer. |
| 418 | 438 | template_install_below(); |
@@ -430,8 +450,9 @@ discard block |
||
| 430 | 450 | $incontext['sub_template'] = 'welcome_message'; |
| 431 | 451 | |
| 432 | 452 | // Done the submission? |
| 433 | - if (isset($_POST['contbutt'])) |
|
| 434 | - return true; |
|
| 453 | + if (isset($_POST['contbutt'])) { |
|
| 454 | + return true; |
|
| 455 | + } |
|
| 435 | 456 | |
| 436 | 457 | // See if we think they have already installed it? |
| 437 | 458 | if (is_readable(dirname(__FILE__) . '/Settings.php')) |
@@ -439,14 +460,17 @@ discard block |
||
| 439 | 460 | $probably_installed = 0; |
| 440 | 461 | foreach (file(dirname(__FILE__) . '/Settings.php') as $line) |
| 441 | 462 | { |
| 442 | - if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) |
|
| 443 | - $probably_installed++; |
|
| 444 | - if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) |
|
| 445 | - $probably_installed++; |
|
| 463 | + if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) { |
|
| 464 | + $probably_installed++; |
|
| 465 | + } |
|
| 466 | + if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) { |
|
| 467 | + $probably_installed++; |
|
| 468 | + } |
|
| 446 | 469 | } |
| 447 | 470 | |
| 448 | - if ($probably_installed == 2) |
|
| 449 | - $incontext['warning'] = $txt['error_already_installed']; |
|
| 471 | + if ($probably_installed == 2) { |
|
| 472 | + $incontext['warning'] = $txt['error_already_installed']; |
|
| 473 | + } |
|
| 450 | 474 | } |
| 451 | 475 | |
| 452 | 476 | // Is some database support even compiled in? |
@@ -461,45 +485,54 @@ discard block |
||
| 461 | 485 | $databases[$key]['supported'] = false; |
| 462 | 486 | $notFoundSQLFile = true; |
| 463 | 487 | $txt['error_db_script_missing'] = sprintf($txt['error_db_script_missing'], 'install_' . $GLOBALS['db_script_version'] . '_' . $type . '.sql'); |
| 488 | + } else { |
|
| 489 | + $incontext['supported_databases'][] = $db; |
|
| 464 | 490 | } |
| 465 | - else |
|
| 466 | - $incontext['supported_databases'][] = $db; |
|
| 467 | 491 | } |
| 468 | 492 | } |
| 469 | 493 | |
| 470 | 494 | // Check the PHP version. |
| 471 | - if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>='))) |
|
| 472 | - $error = 'error_php_too_low'; |
|
| 495 | + if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>='))) { |
|
| 496 | + $error = 'error_php_too_low'; |
|
| 497 | + } |
|
| 473 | 498 | // Make sure we have a supported database |
| 474 | - elseif (empty($incontext['supported_databases'])) |
|
| 475 | - $error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing'; |
|
| 499 | + elseif (empty($incontext['supported_databases'])) { |
|
| 500 | + $error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing'; |
|
| 501 | + } |
|
| 476 | 502 | // How about session support? Some crazy sysadmin remove it? |
| 477 | - elseif (!function_exists('session_start')) |
|
| 478 | - $error = 'error_session_missing'; |
|
| 503 | + elseif (!function_exists('session_start')) { |
|
| 504 | + $error = 'error_session_missing'; |
|
| 505 | + } |
|
| 479 | 506 | // Make sure they uploaded all the files. |
| 480 | - elseif (!file_exists(dirname(__FILE__) . '/index.php')) |
|
| 481 | - $error = 'error_missing_files'; |
|
| 507 | + elseif (!file_exists(dirname(__FILE__) . '/index.php')) { |
|
| 508 | + $error = 'error_missing_files'; |
|
| 509 | + } |
|
| 482 | 510 | // Very simple check on the session.save_path for Windows. |
| 483 | 511 | // @todo Move this down later if they don't use database-driven sessions? |
| 484 | - elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') |
|
| 485 | - $error = 'error_session_save_path'; |
|
| 512 | + elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') { |
|
| 513 | + $error = 'error_session_save_path'; |
|
| 514 | + } |
|
| 486 | 515 | |
| 487 | 516 | // Since each of the three messages would look the same, anyway... |
| 488 | - if (isset($error)) |
|
| 489 | - $incontext['error'] = $txt[$error]; |
|
| 517 | + if (isset($error)) { |
|
| 518 | + $incontext['error'] = $txt[$error]; |
|
| 519 | + } |
|
| 490 | 520 | |
| 491 | 521 | // Mod_security blocks everything that smells funny. Let SMF handle security. |
| 492 | - if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) |
|
| 493 | - $incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again']; |
|
| 522 | + if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) { |
|
| 523 | + $incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again']; |
|
| 524 | + } |
|
| 494 | 525 | |
| 495 | 526 | // Confirm mbstring is loaded... |
| 496 | - if (!extension_loaded('mbstring')) |
|
| 497 | - $incontext['error'] = $txt['install_no_mbstring']; |
|
| 527 | + if (!extension_loaded('mbstring')) { |
|
| 528 | + $incontext['error'] = $txt['install_no_mbstring']; |
|
| 529 | + } |
|
| 498 | 530 | |
| 499 | 531 | // Check for https stream support. |
| 500 | 532 | $supported_streams = stream_get_wrappers(); |
| 501 | - if (!in_array('https', $supported_streams)) |
|
| 502 | - $incontext['warning'] = $txt['install_no_https']; |
|
| 533 | + if (!in_array('https', $supported_streams)) { |
|
| 534 | + $incontext['warning'] = $txt['install_no_https']; |
|
| 535 | + } |
|
| 503 | 536 | |
| 504 | 537 | return false; |
| 505 | 538 | } |
@@ -524,12 +557,14 @@ discard block |
||
| 524 | 557 | 'Settings_bak.php', |
| 525 | 558 | ); |
| 526 | 559 | |
| 527 | - foreach ($incontext['detected_languages'] as $lang => $temp) |
|
| 528 | - $extra_files[] = 'Themes/default/languages/' . $lang; |
|
| 560 | + foreach ($incontext['detected_languages'] as $lang => $temp) { |
|
| 561 | + $extra_files[] = 'Themes/default/languages/' . $lang; |
|
| 562 | + } |
|
| 529 | 563 | |
| 530 | 564 | // With mod_security installed, we could attempt to fix it with .htaccess. |
| 531 | - if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) |
|
| 532 | - $writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.'; |
|
| 565 | + if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) { |
|
| 566 | + $writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.'; |
|
| 567 | + } |
|
| 533 | 568 | |
| 534 | 569 | $failed_files = array(); |
| 535 | 570 | |
@@ -541,20 +576,23 @@ discard block |
||
| 541 | 576 | foreach ($writable_files as $file) |
| 542 | 577 | { |
| 543 | 578 | // Some files won't exist, try to address up front |
| 544 | - if (!file_exists(dirname(__FILE__) . '/' . $file)) |
|
| 545 | - @touch(dirname(__FILE__) . '/' . $file); |
|
| 579 | + if (!file_exists(dirname(__FILE__) . '/' . $file)) { |
|
| 580 | + @touch(dirname(__FILE__) . '/' . $file); |
|
| 581 | + } |
|
| 546 | 582 | // NOW do the writable check... |
| 547 | 583 | if (!is_writable(dirname(__FILE__) . '/' . $file)) |
| 548 | 584 | { |
| 549 | 585 | @chmod(dirname(__FILE__) . '/' . $file, 0755); |
| 550 | 586 | |
| 551 | 587 | // Well, 755 hopefully worked... if not, try 777. |
| 552 | - if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) |
|
| 553 | - $failed_files[] = $file; |
|
| 588 | + if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) { |
|
| 589 | + $failed_files[] = $file; |
|
| 590 | + } |
|
| 554 | 591 | } |
| 555 | 592 | } |
| 556 | - foreach ($extra_files as $file) |
|
| 557 | - @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
| 593 | + foreach ($extra_files as $file) { |
|
| 594 | + @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
| 595 | + } |
|
| 558 | 596 | } |
| 559 | 597 | // Windows is trickier. Let's try opening for r+... |
| 560 | 598 | else |
@@ -564,30 +602,35 @@ discard block |
||
| 564 | 602 | foreach ($writable_files as $file) |
| 565 | 603 | { |
| 566 | 604 | // Folders can't be opened for write... but the index.php in them can ;) |
| 567 | - if (is_dir(dirname(__FILE__) . '/' . $file)) |
|
| 568 | - $file .= '/index.php'; |
|
| 605 | + if (is_dir(dirname(__FILE__) . '/' . $file)) { |
|
| 606 | + $file .= '/index.php'; |
|
| 607 | + } |
|
| 569 | 608 | |
| 570 | 609 | // Funny enough, chmod actually does do something on windows - it removes the read only attribute. |
| 571 | 610 | @chmod(dirname(__FILE__) . '/' . $file, 0777); |
| 572 | 611 | $fp = @fopen(dirname(__FILE__) . '/' . $file, 'r+'); |
| 573 | 612 | |
| 574 | 613 | // Hmm, okay, try just for write in that case... |
| 575 | - if (!is_resource($fp)) |
|
| 576 | - $fp = @fopen(dirname(__FILE__) . '/' . $file, 'w'); |
|
| 614 | + if (!is_resource($fp)) { |
|
| 615 | + $fp = @fopen(dirname(__FILE__) . '/' . $file, 'w'); |
|
| 616 | + } |
|
| 577 | 617 | |
| 578 | - if (!is_resource($fp)) |
|
| 579 | - $failed_files[] = $file; |
|
| 618 | + if (!is_resource($fp)) { |
|
| 619 | + $failed_files[] = $file; |
|
| 620 | + } |
|
| 580 | 621 | |
| 581 | 622 | @fclose($fp); |
| 582 | 623 | } |
| 583 | - foreach ($extra_files as $file) |
|
| 584 | - @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
| 624 | + foreach ($extra_files as $file) { |
|
| 625 | + @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
| 626 | + } |
|
| 585 | 627 | } |
| 586 | 628 | |
| 587 | 629 | $failure = count($failed_files) >= 1; |
| 588 | 630 | |
| 589 | - if (!isset($_SERVER)) |
|
| 590 | - return !$failure; |
|
| 631 | + if (!isset($_SERVER)) { |
|
| 632 | + return !$failure; |
|
| 633 | + } |
|
| 591 | 634 | |
| 592 | 635 | // Put the list into context. |
| 593 | 636 | $incontext['failed_files'] = $failed_files; |
@@ -635,19 +678,23 @@ discard block |
||
| 635 | 678 | |
| 636 | 679 | if (!isset($ftp) || $ftp->error !== false) |
| 637 | 680 | { |
| 638 | - if (!isset($ftp)) |
|
| 639 | - $ftp = new ftp_connection(null); |
|
| 681 | + if (!isset($ftp)) { |
|
| 682 | + $ftp = new ftp_connection(null); |
|
| 683 | + } |
|
| 640 | 684 | // Save the error so we can mess with listing... |
| 641 | - elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) |
|
| 642 | - $incontext['ftp_errors'][] = $ftp->last_message; |
|
| 685 | + elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) { |
|
| 686 | + $incontext['ftp_errors'][] = $ftp->last_message; |
|
| 687 | + } |
|
| 643 | 688 | |
| 644 | 689 | list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__)); |
| 645 | 690 | |
| 646 | - if (empty($_POST['ftp_path']) && $found_path) |
|
| 647 | - $_POST['ftp_path'] = $detect_path; |
|
| 691 | + if (empty($_POST['ftp_path']) && $found_path) { |
|
| 692 | + $_POST['ftp_path'] = $detect_path; |
|
| 693 | + } |
|
| 648 | 694 | |
| 649 | - if (!isset($_POST['ftp_username'])) |
|
| 650 | - $_POST['ftp_username'] = $username; |
|
| 695 | + if (!isset($_POST['ftp_username'])) { |
|
| 696 | + $_POST['ftp_username'] = $username; |
|
| 697 | + } |
|
| 651 | 698 | |
| 652 | 699 | // Set the username etc, into context. |
| 653 | 700 | $incontext['ftp'] = array( |
@@ -659,8 +706,7 @@ discard block |
||
| 659 | 706 | ); |
| 660 | 707 | |
| 661 | 708 | return false; |
| 662 | - } |
|
| 663 | - else |
|
| 709 | + } else |
|
| 664 | 710 | { |
| 665 | 711 | $_SESSION['installer_temp_ftp'] = array( |
| 666 | 712 | 'server' => $_POST['ftp_server'], |
@@ -674,10 +720,12 @@ discard block |
||
| 674 | 720 | |
| 675 | 721 | foreach ($failed_files as $file) |
| 676 | 722 | { |
| 677 | - if (!is_writable(dirname(__FILE__) . '/' . $file)) |
|
| 678 | - $ftp->chmod($file, 0755); |
|
| 679 | - if (!is_writable(dirname(__FILE__) . '/' . $file)) |
|
| 680 | - $ftp->chmod($file, 0777); |
|
| 723 | + if (!is_writable(dirname(__FILE__) . '/' . $file)) { |
|
| 724 | + $ftp->chmod($file, 0755); |
|
| 725 | + } |
|
| 726 | + if (!is_writable(dirname(__FILE__) . '/' . $file)) { |
|
| 727 | + $ftp->chmod($file, 0777); |
|
| 728 | + } |
|
| 681 | 729 | if (!is_writable(dirname(__FILE__) . '/' . $file)) |
| 682 | 730 | { |
| 683 | 731 | $failed_files_updated[] = $file; |
@@ -733,15 +781,17 @@ discard block |
||
| 733 | 781 | |
| 734 | 782 | if (!$foundOne) |
| 735 | 783 | { |
| 736 | - if (isset($db['default_host'])) |
|
| 737 | - $incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost'; |
|
| 784 | + if (isset($db['default_host'])) { |
|
| 785 | + $incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost'; |
|
| 786 | + } |
|
| 738 | 787 | if (isset($db['default_user'])) |
| 739 | 788 | { |
| 740 | 789 | $incontext['db']['user'] = ini_get($db['default_user']); |
| 741 | 790 | $incontext['db']['name'] = ini_get($db['default_user']); |
| 742 | 791 | } |
| 743 | - if (isset($db['default_password'])) |
|
| 744 | - $incontext['db']['pass'] = ini_get($db['default_password']); |
|
| 792 | + if (isset($db['default_password'])) { |
|
| 793 | + $incontext['db']['pass'] = ini_get($db['default_password']); |
|
| 794 | + } |
|
| 745 | 795 | |
| 746 | 796 | // For simplicity and less confusion, leave the port blank by default |
| 747 | 797 | $incontext['db']['port'] = ''; |
@@ -760,10 +810,10 @@ discard block |
||
| 760 | 810 | $incontext['db']['server'] = $_POST['db_server']; |
| 761 | 811 | $incontext['db']['prefix'] = $_POST['db_prefix']; |
| 762 | 812 | |
| 763 | - if (!empty($_POST['db_port'])) |
|
| 764 | - $incontext['db']['port'] = $_POST['db_port']; |
|
| 765 | - } |
|
| 766 | - else |
|
| 813 | + if (!empty($_POST['db_port'])) { |
|
| 814 | + $incontext['db']['port'] = $_POST['db_port']; |
|
| 815 | + } |
|
| 816 | + } else |
|
| 767 | 817 | { |
| 768 | 818 | $incontext['db']['prefix'] = 'smf_'; |
| 769 | 819 | } |
@@ -799,10 +849,11 @@ discard block |
||
| 799 | 849 | if (!empty($_POST['db_port'])) |
| 800 | 850 | { |
| 801 | 851 | // For MySQL, we can get the "default port" from PHP. PostgreSQL has no such option though. |
| 802 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) |
|
| 803 | - $vars['db_port'] = (int) $_POST['db_port']; |
|
| 804 | - elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) |
|
| 805 | - $vars['db_port'] = (int) $_POST['db_port']; |
|
| 852 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) { |
|
| 853 | + $vars['db_port'] = (int) $_POST['db_port']; |
|
| 854 | + } elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) { |
|
| 855 | + $vars['db_port'] = (int) $_POST['db_port']; |
|
| 856 | + } |
|
| 806 | 857 | } |
| 807 | 858 | |
| 808 | 859 | // God I hope it saved! |
@@ -815,8 +866,9 @@ discard block |
||
| 815 | 866 | // Make sure it works. |
| 816 | 867 | require(dirname(__FILE__) . '/Settings.php'); |
| 817 | 868 | |
| 818 | - if (empty($sourcedir)) |
|
| 819 | - $sourcedir = dirname(__FILE__) . '/Sources'; |
|
| 869 | + if (empty($sourcedir)) { |
|
| 870 | + $sourcedir = dirname(__FILE__) . '/Sources'; |
|
| 871 | + } |
|
| 820 | 872 | |
| 821 | 873 | // Better find the database file! |
| 822 | 874 | if (!file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
@@ -826,18 +878,21 @@ discard block |
||
| 826 | 878 | } |
| 827 | 879 | |
| 828 | 880 | // Now include it for database functions! |
| 829 | - if (!defined('SMF')) |
|
| 830 | - define('SMF', 1); |
|
| 881 | + if (!defined('SMF')) { |
|
| 882 | + define('SMF', 1); |
|
| 883 | + } |
|
| 831 | 884 | |
| 832 | 885 | $modSettings['disableQueryCheck'] = true; |
| 833 | - if (empty($smcFunc)) |
|
| 834 | - $smcFunc = array(); |
|
| 886 | + if (empty($smcFunc)) { |
|
| 887 | + $smcFunc = array(); |
|
| 888 | + } |
|
| 835 | 889 | |
| 836 | 890 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
| 837 | 891 | |
| 838 | 892 | // What - running PHP4? The shame! |
| 839 | - if (version_compare(PHP_VERSION, '5', '<')) |
|
| 840 | - require_once($sourcedir . '/Subs-Compat.php'); |
|
| 893 | + if (version_compare(PHP_VERSION, '5', '<')) { |
|
| 894 | + require_once($sourcedir . '/Subs-Compat.php'); |
|
| 895 | + } |
|
| 841 | 896 | |
| 842 | 897 | // Attempt a connection. |
| 843 | 898 | $needsDB = !empty($databases[$db_type]['always_has_db']); |
@@ -925,12 +980,14 @@ discard block |
||
| 925 | 980 | $incontext['page_title'] = $txt['install_settings']; |
| 926 | 981 | |
| 927 | 982 | // Let's see if we got the database type correct. |
| 928 | - if (isset($_POST['db_type'], $databases[$_POST['db_type']])) |
|
| 929 | - $db_type = $_POST['db_type']; |
|
| 983 | + if (isset($_POST['db_type'], $databases[$_POST['db_type']])) { |
|
| 984 | + $db_type = $_POST['db_type']; |
|
| 985 | + } |
|
| 930 | 986 | |
| 931 | 987 | // Else we'd better be able to get the connection. |
| 932 | - else |
|
| 933 | - load_database(); |
|
| 988 | + else { |
|
| 989 | + load_database(); |
|
| 990 | + } |
|
| 934 | 991 | |
| 935 | 992 | $db_type = isset($_POST['db_type']) ? $_POST['db_type'] : $db_type; |
| 936 | 993 | |
@@ -939,10 +996,11 @@ discard block |
||
| 939 | 996 | |
| 940 | 997 | $secure = false; |
| 941 | 998 | |
| 942 | - if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') |
|
| 943 | - $secure = true; |
|
| 944 | - elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') |
|
| 945 | - $secure = true; |
|
| 999 | + if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { |
|
| 1000 | + $secure = true; |
|
| 1001 | + } elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') { |
|
| 1002 | + $secure = true; |
|
| 1003 | + } |
|
| 946 | 1004 | |
| 947 | 1005 | // Now, to put what we've learned together... and add a path. |
| 948 | 1006 | $incontext['detected_url'] = 'http' . ($secure ? 's' : '') . '://' . $host . substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], '/')); |
@@ -974,18 +1032,21 @@ discard block |
||
| 974 | 1032 | // Submitting? |
| 975 | 1033 | if (isset($_POST['boardurl'])) |
| 976 | 1034 | { |
| 977 | - if (substr($_POST['boardurl'], -10) == '/index.php') |
|
| 978 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
| 979 | - elseif (substr($_POST['boardurl'], -1) == '/') |
|
| 980 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
| 981 | - if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') |
|
| 982 | - $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
| 1035 | + if (substr($_POST['boardurl'], -10) == '/index.php') { |
|
| 1036 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
| 1037 | + } elseif (substr($_POST['boardurl'], -1) == '/') { |
|
| 1038 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
| 1039 | + } |
|
| 1040 | + if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') { |
|
| 1041 | + $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
| 1042 | + } |
|
| 983 | 1043 | |
| 984 | 1044 | //Make sure boardurl is aligned with ssl setting |
| 985 | - if (empty($_POST['force_ssl'])) |
|
| 986 | - $_POST['boardurl'] = strtr($_POST['boardurl'], array('https://' => 'http://')); |
|
| 987 | - else |
|
| 988 | - $_POST['boardurl'] = strtr($_POST['boardurl'], array('http://' => 'https://')); |
|
| 1045 | + if (empty($_POST['force_ssl'])) { |
|
| 1046 | + $_POST['boardurl'] = strtr($_POST['boardurl'], array('https://' => 'http://')); |
|
| 1047 | + } else { |
|
| 1048 | + $_POST['boardurl'] = strtr($_POST['boardurl'], array('http://' => 'https://')); |
|
| 1049 | + } |
|
| 989 | 1050 | |
| 990 | 1051 | // Save these variables. |
| 991 | 1052 | $vars = array( |
@@ -1024,10 +1085,10 @@ discard block |
||
| 1024 | 1085 | { |
| 1025 | 1086 | $incontext['error'] = sprintf($txt['error_utf8_version'], $databases[$db_type]['utf8_version']); |
| 1026 | 1087 | return false; |
| 1027 | - } |
|
| 1028 | - else |
|
| 1029 | - // Set the character set here. |
|
| 1088 | + } else { |
|
| 1089 | + // Set the character set here. |
|
| 1030 | 1090 | updateSettingsFile(array('db_character_set' => 'utf8')); |
| 1091 | + } |
|
| 1031 | 1092 | } |
| 1032 | 1093 | |
| 1033 | 1094 | // Good, skip on. |
@@ -1047,8 +1108,9 @@ discard block |
||
| 1047 | 1108 | $incontext['continue'] = 1; |
| 1048 | 1109 | |
| 1049 | 1110 | // Already done? |
| 1050 | - if (isset($_POST['pop_done'])) |
|
| 1051 | - return true; |
|
| 1111 | + if (isset($_POST['pop_done'])) { |
|
| 1112 | + return true; |
|
| 1113 | + } |
|
| 1052 | 1114 | |
| 1053 | 1115 | // Reload settings. |
| 1054 | 1116 | require(dirname(__FILE__) . '/Settings.php'); |
@@ -1066,8 +1128,9 @@ discard block |
||
| 1066 | 1128 | $modSettings = array(); |
| 1067 | 1129 | if ($result !== false) |
| 1068 | 1130 | { |
| 1069 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 1070 | - $modSettings[$row['variable']] = $row['value']; |
|
| 1131 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 1132 | + $modSettings[$row['variable']] = $row['value']; |
|
| 1133 | + } |
|
| 1071 | 1134 | $smcFunc['db_free_result']($result); |
| 1072 | 1135 | |
| 1073 | 1136 | // Do they match? If so, this is just a refresh so charge on! |
@@ -1080,20 +1143,22 @@ discard block |
||
| 1080 | 1143 | $modSettings['disableQueryCheck'] = true; |
| 1081 | 1144 | |
| 1082 | 1145 | // If doing UTF8, select it. PostgreSQL requires passing it as a string... |
| 1083 | - if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) |
|
| 1084 | - $smcFunc['db_query']('', ' |
|
| 1146 | + if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) { |
|
| 1147 | + $smcFunc['db_query']('', ' |
|
| 1085 | 1148 | SET NAMES {string:utf8}', |
| 1086 | 1149 | array( |
| 1087 | 1150 | 'db_error_skip' => true, |
| 1088 | 1151 | 'utf8' => 'utf8', |
| 1089 | 1152 | ) |
| 1090 | 1153 | ); |
| 1154 | + } |
|
| 1091 | 1155 | |
| 1092 | 1156 | // Windows likes to leave the trailing slash, which yields to C:\path\to\SMF\/attachments... |
| 1093 | - if (substr(__DIR__, -1) == '\\') |
|
| 1094 | - $attachdir = __DIR__ . 'attachments'; |
|
| 1095 | - else |
|
| 1096 | - $attachdir = __DIR__ . '/attachments'; |
|
| 1157 | + if (substr(__DIR__, -1) == '\\') { |
|
| 1158 | + $attachdir = __DIR__ . 'attachments'; |
|
| 1159 | + } else { |
|
| 1160 | + $attachdir = __DIR__ . '/attachments'; |
|
| 1161 | + } |
|
| 1097 | 1162 | |
| 1098 | 1163 | $replaces = array( |
| 1099 | 1164 | '{$db_prefix}' => $db_prefix, |
@@ -1110,8 +1175,9 @@ discard block |
||
| 1110 | 1175 | |
| 1111 | 1176 | foreach ($txt as $key => $value) |
| 1112 | 1177 | { |
| 1113 | - if (substr($key, 0, 8) == 'default_') |
|
| 1114 | - $replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value); |
|
| 1178 | + if (substr($key, 0, 8) == 'default_') { |
|
| 1179 | + $replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value); |
|
| 1180 | + } |
|
| 1115 | 1181 | } |
| 1116 | 1182 | $replaces['{$default_reserved_names}'] = strtr($replaces['{$default_reserved_names}'], array('\\\\n' => '\\n')); |
| 1117 | 1183 | |
@@ -1126,8 +1192,9 @@ discard block |
||
| 1126 | 1192 | |
| 1127 | 1193 | while ($row = $smcFunc['db_fetch_assoc']($get_engines)) |
| 1128 | 1194 | { |
| 1129 | - if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') |
|
| 1130 | - $engines[] = $row['Engine']; |
|
| 1195 | + if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') { |
|
| 1196 | + $engines[] = $row['Engine']; |
|
| 1197 | + } |
|
| 1131 | 1198 | } |
| 1132 | 1199 | |
| 1133 | 1200 | // Done with this now |
@@ -1151,8 +1218,7 @@ discard block |
||
| 1151 | 1218 | $replaces['START TRANSACTION;'] = ''; |
| 1152 | 1219 | $replaces['COMMIT;'] = ''; |
| 1153 | 1220 | } |
| 1154 | - } |
|
| 1155 | - else |
|
| 1221 | + } else |
|
| 1156 | 1222 | { |
| 1157 | 1223 | $has_innodb = false; |
| 1158 | 1224 | } |
@@ -1174,21 +1240,24 @@ discard block |
||
| 1174 | 1240 | foreach ($sql_lines as $count => $line) |
| 1175 | 1241 | { |
| 1176 | 1242 | // No comments allowed! |
| 1177 | - if (substr(trim($line), 0, 1) != '#') |
|
| 1178 | - $current_statement .= "\n" . rtrim($line); |
|
| 1243 | + if (substr(trim($line), 0, 1) != '#') { |
|
| 1244 | + $current_statement .= "\n" . rtrim($line); |
|
| 1245 | + } |
|
| 1179 | 1246 | |
| 1180 | 1247 | // Is this the end of the query string? |
| 1181 | - if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) |
|
| 1182 | - continue; |
|
| 1248 | + if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) { |
|
| 1249 | + continue; |
|
| 1250 | + } |
|
| 1183 | 1251 | |
| 1184 | 1252 | // Does this table already exist? If so, don't insert more data into it! |
| 1185 | 1253 | if (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) != 0 && in_array($match[1], $exists)) |
| 1186 | 1254 | { |
| 1187 | 1255 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
| 1188 | - if (!empty($matches[0])) |
|
| 1189 | - $incontext['sql_results']['insert_dups'] += count($matches[0]); |
|
| 1190 | - else |
|
| 1191 | - $incontext['sql_results']['insert_dups']++; |
|
| 1256 | + if (!empty($matches[0])) { |
|
| 1257 | + $incontext['sql_results']['insert_dups'] += count($matches[0]); |
|
| 1258 | + } else { |
|
| 1259 | + $incontext['sql_results']['insert_dups']++; |
|
| 1260 | + } |
|
| 1192 | 1261 | |
| 1193 | 1262 | $current_statement = ''; |
| 1194 | 1263 | continue; |
@@ -1197,8 +1266,9 @@ discard block |
||
| 1197 | 1266 | if ($smcFunc['db_query']('', $current_statement, array('security_override' => true, 'db_error_skip' => true), $db_connection) === false) |
| 1198 | 1267 | { |
| 1199 | 1268 | // Use the appropriate function based on the DB type |
| 1200 | - if ($db_type == 'mysql' || $db_type == 'mysqli') |
|
| 1201 | - $db_errorno = $db_type . '_errno'; |
|
| 1269 | + if ($db_type == 'mysql' || $db_type == 'mysqli') { |
|
| 1270 | + $db_errorno = $db_type . '_errno'; |
|
| 1271 | + } |
|
| 1202 | 1272 | |
| 1203 | 1273 | // Error 1050: Table already exists! |
| 1204 | 1274 | // @todo Needs to be made better! |
@@ -1213,18 +1283,18 @@ discard block |
||
| 1213 | 1283 | // MySQLi requires a connection object. It's optional with MySQL and Postgres |
| 1214 | 1284 | $incontext['failures'][$count] = $smcFunc['db_error']($db_connection); |
| 1215 | 1285 | } |
| 1216 | - } |
|
| 1217 | - else |
|
| 1286 | + } else |
|
| 1218 | 1287 | { |
| 1219 | - if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
| 1220 | - $incontext['sql_results']['tables']++; |
|
| 1221 | - elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
| 1288 | + if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) { |
|
| 1289 | + $incontext['sql_results']['tables']++; |
|
| 1290 | + } elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
| 1222 | 1291 | { |
| 1223 | 1292 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
| 1224 | - if (!empty($matches[0])) |
|
| 1225 | - $incontext['sql_results']['inserts'] += count($matches[0]); |
|
| 1226 | - else |
|
| 1227 | - $incontext['sql_results']['inserts']++; |
|
| 1293 | + if (!empty($matches[0])) { |
|
| 1294 | + $incontext['sql_results']['inserts'] += count($matches[0]); |
|
| 1295 | + } else { |
|
| 1296 | + $incontext['sql_results']['inserts']++; |
|
| 1297 | + } |
|
| 1228 | 1298 | } |
| 1229 | 1299 | } |
| 1230 | 1300 | |
@@ -1237,15 +1307,17 @@ discard block |
||
| 1237 | 1307 | // Sort out the context for the SQL. |
| 1238 | 1308 | foreach ($incontext['sql_results'] as $key => $number) |
| 1239 | 1309 | { |
| 1240 | - if ($number == 0) |
|
| 1241 | - unset($incontext['sql_results'][$key]); |
|
| 1242 | - else |
|
| 1243 | - $incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number); |
|
| 1310 | + if ($number == 0) { |
|
| 1311 | + unset($incontext['sql_results'][$key]); |
|
| 1312 | + } else { |
|
| 1313 | + $incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number); |
|
| 1314 | + } |
|
| 1244 | 1315 | } |
| 1245 | 1316 | |
| 1246 | 1317 | // Make sure UTF will be used globally. |
| 1247 | - 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']))) |
|
| 1248 | - $newSettings[] = array('global_character_set', 'UTF-8'); |
|
| 1318 | + 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']))) { |
|
| 1319 | + $newSettings[] = array('global_character_set', 'UTF-8'); |
|
| 1320 | + } |
|
| 1249 | 1321 | |
| 1250 | 1322 | // Auto-detect local & global cookie settings |
| 1251 | 1323 | $url_parts = parse_url($boardurl); |
@@ -1274,15 +1346,19 @@ discard block |
||
| 1274 | 1346 | |
| 1275 | 1347 | // Look for subfolder, if found, set localCookie |
| 1276 | 1348 | // Checking for len > 1 ensures you don't have just a slash... |
| 1277 | - if (!empty($url_parts['path']) && strlen($url_parts['path']) > 1) |
|
| 1278 | - $localCookies = '1'; |
|
| 1349 | + if (!empty($url_parts['path']) && strlen($url_parts['path']) > 1) { |
|
| 1350 | + $localCookies = '1'; |
|
| 1351 | + } |
|
| 1279 | 1352 | |
| 1280 | - if (isset($globalCookies)) |
|
| 1281 | - $newSettings[] = array('globalCookies', $globalCookies); |
|
| 1282 | - if (isset($globalCookiesDomain)) |
|
| 1283 | - $newSettings[] = array('globalCookiesDomain', $globalCookiesDomain); |
|
| 1284 | - if (isset($localCookies)) |
|
| 1285 | - $newSettings[] = array('localCookies', $localCookies); |
|
| 1353 | + if (isset($globalCookies)) { |
|
| 1354 | + $newSettings[] = array('globalCookies', $globalCookies); |
|
| 1355 | + } |
|
| 1356 | + if (isset($globalCookiesDomain)) { |
|
| 1357 | + $newSettings[] = array('globalCookiesDomain', $globalCookiesDomain); |
|
| 1358 | + } |
|
| 1359 | + if (isset($localCookies)) { |
|
| 1360 | + $newSettings[] = array('localCookies', $localCookies); |
|
| 1361 | + } |
|
| 1286 | 1362 | } |
| 1287 | 1363 | |
| 1288 | 1364 | // Are we allowing stat collection? |
@@ -1300,16 +1376,17 @@ discard block |
||
| 1300 | 1376 | fwrite($fp, $out); |
| 1301 | 1377 | |
| 1302 | 1378 | $return_data = ''; |
| 1303 | - while (!feof($fp)) |
|
| 1304 | - $return_data .= fgets($fp, 128); |
|
| 1379 | + while (!feof($fp)) { |
|
| 1380 | + $return_data .= fgets($fp, 128); |
|
| 1381 | + } |
|
| 1305 | 1382 | |
| 1306 | 1383 | fclose($fp); |
| 1307 | 1384 | |
| 1308 | 1385 | // Get the unique site ID. |
| 1309 | 1386 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
| 1310 | 1387 | |
| 1311 | - if (!empty($ID[1])) |
|
| 1312 | - $smcFunc['db_insert']('replace', |
|
| 1388 | + if (!empty($ID[1])) { |
|
| 1389 | + $smcFunc['db_insert']('replace', |
|
| 1313 | 1390 | $db_prefix . 'settings', |
| 1314 | 1391 | array('variable' => 'string', 'value' => 'string'), |
| 1315 | 1392 | array( |
@@ -1318,11 +1395,12 @@ discard block |
||
| 1318 | 1395 | ), |
| 1319 | 1396 | array('variable') |
| 1320 | 1397 | ); |
| 1398 | + } |
|
| 1321 | 1399 | } |
| 1322 | 1400 | } |
| 1323 | 1401 | // Don't remove stat collection unless we unchecked the box for real, not from the loop. |
| 1324 | - elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) |
|
| 1325 | - $smcFunc['db_query']('', ' |
|
| 1402 | + elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) { |
|
| 1403 | + $smcFunc['db_query']('', ' |
|
| 1326 | 1404 | DELETE FROM {db_prefix}settings |
| 1327 | 1405 | WHERE variable = {string:enable_sm_stats}', |
| 1328 | 1406 | array( |
@@ -1330,20 +1408,23 @@ discard block |
||
| 1330 | 1408 | 'db_error_skip' => true, |
| 1331 | 1409 | ) |
| 1332 | 1410 | ); |
| 1411 | + } |
|
| 1333 | 1412 | |
| 1334 | 1413 | // Are we enabling SSL? |
| 1335 | - if (!empty($_POST['force_ssl'])) |
|
| 1336 | - $newSettings[] = array('force_ssl', 1); |
|
| 1414 | + if (!empty($_POST['force_ssl'])) { |
|
| 1415 | + $newSettings[] = array('force_ssl', 1); |
|
| 1416 | + } |
|
| 1337 | 1417 | |
| 1338 | 1418 | // Setting a timezone is required. |
| 1339 | 1419 | if (!isset($modSettings['default_timezone']) && function_exists('date_default_timezone_set')) |
| 1340 | 1420 | { |
| 1341 | 1421 | // Get PHP's default timezone, if set |
| 1342 | 1422 | $ini_tz = ini_get('date.timezone'); |
| 1343 | - if (!empty($ini_tz)) |
|
| 1344 | - $timezone_id = $ini_tz; |
|
| 1345 | - else |
|
| 1346 | - $timezone_id = ''; |
|
| 1423 | + if (!empty($ini_tz)) { |
|
| 1424 | + $timezone_id = $ini_tz; |
|
| 1425 | + } else { |
|
| 1426 | + $timezone_id = ''; |
|
| 1427 | + } |
|
| 1347 | 1428 | |
| 1348 | 1429 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
| 1349 | 1430 | if (!in_array($timezone_id, timezone_identifiers_list())) |
@@ -1352,8 +1433,9 @@ discard block |
||
| 1352 | 1433 | $timezone_id = timezone_name_from_abbr('', $server_offset, 0); |
| 1353 | 1434 | } |
| 1354 | 1435 | |
| 1355 | - if (date_default_timezone_set($timezone_id)) |
|
| 1356 | - $newSettings[] = array('default_timezone', $timezone_id); |
|
| 1436 | + if (date_default_timezone_set($timezone_id)) { |
|
| 1437 | + $newSettings[] = array('default_timezone', $timezone_id); |
|
| 1438 | + } |
|
| 1357 | 1439 | } |
| 1358 | 1440 | |
| 1359 | 1441 | if (!empty($newSettings)) |
@@ -1384,16 +1466,18 @@ discard block |
||
| 1384 | 1466 | } |
| 1385 | 1467 | |
| 1386 | 1468 | // MySQL specific stuff |
| 1387 | - if (substr($db_type, 0, 5) != 'mysql') |
|
| 1388 | - return false; |
|
| 1469 | + if (substr($db_type, 0, 5) != 'mysql') { |
|
| 1470 | + return false; |
|
| 1471 | + } |
|
| 1389 | 1472 | |
| 1390 | 1473 | // Find database user privileges. |
| 1391 | 1474 | $privs = array(); |
| 1392 | 1475 | $get_privs = $smcFunc['db_query']('', 'SHOW PRIVILEGES', array()); |
| 1393 | 1476 | while ($row = $smcFunc['db_fetch_assoc']($get_privs)) |
| 1394 | 1477 | { |
| 1395 | - if ($row['Privilege'] == 'Alter') |
|
| 1396 | - $privs[] = $row['Privilege']; |
|
| 1478 | + if ($row['Privilege'] == 'Alter') { |
|
| 1479 | + $privs[] = $row['Privilege']; |
|
| 1480 | + } |
|
| 1397 | 1481 | } |
| 1398 | 1482 | $smcFunc['db_free_result']($get_privs); |
| 1399 | 1483 | |
@@ -1423,8 +1507,9 @@ discard block |
||
| 1423 | 1507 | $incontext['continue'] = 1; |
| 1424 | 1508 | |
| 1425 | 1509 | // Skipping? |
| 1426 | - if (!empty($_POST['skip'])) |
|
| 1427 | - return true; |
|
| 1510 | + if (!empty($_POST['skip'])) { |
|
| 1511 | + return true; |
|
| 1512 | + } |
|
| 1428 | 1513 | |
| 1429 | 1514 | // Need this to check whether we need the database password. |
| 1430 | 1515 | require(dirname(__FILE__) . '/Settings.php'); |
@@ -1441,18 +1526,22 @@ discard block |
||
| 1441 | 1526 | // We need this to properly hash the password for Admin |
| 1442 | 1527 | $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) { |
| 1443 | 1528 | global $sourcedir; |
| 1444 | - if (function_exists('mb_strtolower')) |
|
| 1445 | - return mb_strtolower($string, 'UTF-8'); |
|
| 1529 | + if (function_exists('mb_strtolower')) { |
|
| 1530 | + return mb_strtolower($string, 'UTF-8'); |
|
| 1531 | + } |
|
| 1446 | 1532 | require_once($sourcedir . '/Subs-Charset.php'); |
| 1447 | 1533 | return utf8_strtolower($string); |
| 1448 | 1534 | }; |
| 1449 | 1535 | |
| 1450 | - if (!isset($_POST['username'])) |
|
| 1451 | - $_POST['username'] = ''; |
|
| 1452 | - if (!isset($_POST['email'])) |
|
| 1453 | - $_POST['email'] = ''; |
|
| 1454 | - if (!isset($_POST['server_email'])) |
|
| 1455 | - $_POST['server_email'] = ''; |
|
| 1536 | + if (!isset($_POST['username'])) { |
|
| 1537 | + $_POST['username'] = ''; |
|
| 1538 | + } |
|
| 1539 | + if (!isset($_POST['email'])) { |
|
| 1540 | + $_POST['email'] = ''; |
|
| 1541 | + } |
|
| 1542 | + if (!isset($_POST['server_email'])) { |
|
| 1543 | + $_POST['server_email'] = ''; |
|
| 1544 | + } |
|
| 1456 | 1545 | |
| 1457 | 1546 | $incontext['username'] = htmlspecialchars(stripslashes($_POST['username'])); |
| 1458 | 1547 | $incontext['email'] = htmlspecialchars(stripslashes($_POST['email'])); |
@@ -1471,8 +1560,9 @@ discard block |
||
| 1471 | 1560 | 'admin_group' => 1, |
| 1472 | 1561 | ) |
| 1473 | 1562 | ); |
| 1474 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 1475 | - $incontext['skip'] = 1; |
|
| 1563 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 1564 | + $incontext['skip'] = 1; |
|
| 1565 | + } |
|
| 1476 | 1566 | $smcFunc['db_free_result']($request); |
| 1477 | 1567 | |
| 1478 | 1568 | // Trying to create an account? |
@@ -1503,8 +1593,9 @@ discard block |
||
| 1503 | 1593 | } |
| 1504 | 1594 | |
| 1505 | 1595 | // Update the webmaster's email? |
| 1506 | - if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) |
|
| 1507 | - updateSettingsFile(array('webmaster_email' => $_POST['server_email'])); |
|
| 1596 | + if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) { |
|
| 1597 | + updateSettingsFile(array('webmaster_email' => $_POST['server_email'])); |
|
| 1598 | + } |
|
| 1508 | 1599 | |
| 1509 | 1600 | // Work out whether we're going to have dodgy characters and remove them. |
| 1510 | 1601 | $invalid_characters = preg_match('~[<>&"\'=\\\]~', $_POST['username']) != 0; |
@@ -1527,32 +1618,27 @@ discard block |
||
| 1527 | 1618 | $smcFunc['db_free_result']($result); |
| 1528 | 1619 | |
| 1529 | 1620 | $incontext['account_existed'] = $txt['error_user_settings_taken']; |
| 1530 | - } |
|
| 1531 | - elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) |
|
| 1621 | + } elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) |
|
| 1532 | 1622 | { |
| 1533 | 1623 | // Try the previous step again. |
| 1534 | 1624 | $incontext['error'] = $_POST['username'] == '' ? $txt['error_username_left_empty'] : $txt['error_username_too_long']; |
| 1535 | 1625 | return false; |
| 1536 | - } |
|
| 1537 | - elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) |
|
| 1626 | + } elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) |
|
| 1538 | 1627 | { |
| 1539 | 1628 | // Try the previous step again. |
| 1540 | 1629 | $incontext['error'] = $txt['error_invalid_characters_username']; |
| 1541 | 1630 | return false; |
| 1542 | - } |
|
| 1543 | - elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255) |
|
| 1631 | + } elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255) |
|
| 1544 | 1632 | { |
| 1545 | 1633 | // One step back, this time fill out a proper admin email address. |
| 1546 | 1634 | $incontext['error'] = sprintf($txt['error_valid_admin_email_needed'], $_POST['username']); |
| 1547 | 1635 | return false; |
| 1548 | - } |
|
| 1549 | - elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255) |
|
| 1636 | + } elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255) |
|
| 1550 | 1637 | { |
| 1551 | 1638 | // One step back, this time fill out a proper admin email address. |
| 1552 | 1639 | $incontext['error'] = $txt['error_valid_server_email_needed']; |
| 1553 | 1640 | return false; |
| 1554 | - } |
|
| 1555 | - elseif ($_POST['username'] != '') |
|
| 1641 | + } elseif ($_POST['username'] != '') |
|
| 1556 | 1642 | { |
| 1557 | 1643 | $incontext['member_salt'] = substr(md5(mt_rand()), 0, 4); |
| 1558 | 1644 | |
@@ -1620,17 +1706,19 @@ discard block |
||
| 1620 | 1706 | reloadSettings(); |
| 1621 | 1707 | |
| 1622 | 1708 | // Bring a warning over. |
| 1623 | - if (!empty($incontext['account_existed'])) |
|
| 1624 | - $incontext['warning'] = $incontext['account_existed']; |
|
| 1709 | + if (!empty($incontext['account_existed'])) { |
|
| 1710 | + $incontext['warning'] = $incontext['account_existed']; |
|
| 1711 | + } |
|
| 1625 | 1712 | |
| 1626 | - if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) |
|
| 1627 | - $smcFunc['db_query']('', ' |
|
| 1713 | + if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) { |
|
| 1714 | + $smcFunc['db_query']('', ' |
|
| 1628 | 1715 | SET NAMES {string:db_character_set}', |
| 1629 | 1716 | array( |
| 1630 | 1717 | 'db_character_set' => $db_character_set, |
| 1631 | 1718 | 'db_error_skip' => true, |
| 1632 | 1719 | ) |
| 1633 | 1720 | ); |
| 1721 | + } |
|
| 1634 | 1722 | |
| 1635 | 1723 | // As track stats is by default enabled let's add some activity. |
| 1636 | 1724 | $smcFunc['db_insert']('ignore', |
@@ -1651,14 +1739,16 @@ discard block |
||
| 1651 | 1739 | // Only proceed if we can load the data. |
| 1652 | 1740 | if ($request) |
| 1653 | 1741 | { |
| 1654 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 1655 | - $modSettings[$row[0]] = $row[1]; |
|
| 1742 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 1743 | + $modSettings[$row[0]] = $row[1]; |
|
| 1744 | + } |
|
| 1656 | 1745 | $smcFunc['db_free_result']($request); |
| 1657 | 1746 | } |
| 1658 | 1747 | |
| 1659 | 1748 | // Automatically log them in ;) |
| 1660 | - if (isset($incontext['member_id']) && isset($incontext['member_salt'])) |
|
| 1661 | - setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt'])); |
|
| 1749 | + if (isset($incontext['member_id']) && isset($incontext['member_salt'])) { |
|
| 1750 | + setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt'])); |
|
| 1751 | + } |
|
| 1662 | 1752 | |
| 1663 | 1753 | $result = $smcFunc['db_query']('', ' |
| 1664 | 1754 | SELECT value |
@@ -1669,13 +1759,14 @@ discard block |
||
| 1669 | 1759 | 'db_error_skip' => true, |
| 1670 | 1760 | ) |
| 1671 | 1761 | ); |
| 1672 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
| 1673 | - list ($db_sessions) = $smcFunc['db_fetch_row']($result); |
|
| 1762 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
| 1763 | + list ($db_sessions) = $smcFunc['db_fetch_row']($result); |
|
| 1764 | + } |
|
| 1674 | 1765 | $smcFunc['db_free_result']($result); |
| 1675 | 1766 | |
| 1676 | - if (empty($db_sessions)) |
|
| 1677 | - $_SESSION['admin_time'] = time(); |
|
| 1678 | - else |
|
| 1767 | + if (empty($db_sessions)) { |
|
| 1768 | + $_SESSION['admin_time'] = time(); |
|
| 1769 | + } else |
|
| 1679 | 1770 | { |
| 1680 | 1771 | $_SERVER['HTTP_USER_AGENT'] = substr($_SERVER['HTTP_USER_AGENT'], 0, 211); |
| 1681 | 1772 | |
@@ -1699,8 +1790,9 @@ discard block |
||
| 1699 | 1790 | $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : |
| 1700 | 1791 | function($string){ |
| 1701 | 1792 | global $sourcedir; |
| 1702 | - if (function_exists('mb_strtolower')) |
|
| 1703 | - return mb_strtolower($string, 'UTF-8'); |
|
| 1793 | + if (function_exists('mb_strtolower')) { |
|
| 1794 | + return mb_strtolower($string, 'UTF-8'); |
|
| 1795 | + } |
|
| 1704 | 1796 | require_once($sourcedir . '/Subs-Charset.php'); |
| 1705 | 1797 | return utf8_strtolower($string); |
| 1706 | 1798 | }; |
@@ -1716,8 +1808,9 @@ discard block |
||
| 1716 | 1808 | ) |
| 1717 | 1809 | ); |
| 1718 | 1810 | $context['utf8'] = $db_character_set === 'utf8' || $txt['lang_character_set'] === 'UTF-8'; |
| 1719 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
| 1720 | - updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject'])); |
|
| 1811 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
| 1812 | + updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject'])); |
|
| 1813 | + } |
|
| 1721 | 1814 | $smcFunc['db_free_result']($request); |
| 1722 | 1815 | |
| 1723 | 1816 | // Now is the perfect time to fetch the SM files. |
@@ -1736,8 +1829,9 @@ discard block |
||
| 1736 | 1829 | |
| 1737 | 1830 | // Check if we need some stupid MySQL fix. |
| 1738 | 1831 | $server_version = $smcFunc['db_server_info'](); |
| 1739 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
| 1740 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1832 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
| 1833 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1834 | + } |
|
| 1741 | 1835 | |
| 1742 | 1836 | // Some final context for the template. |
| 1743 | 1837 | $incontext['dir_still_writable'] = is_writable(dirname(__FILE__)) && substr(__FILE__, 1, 2) != ':\\'; |
@@ -1757,8 +1851,9 @@ discard block |
||
| 1757 | 1851 | $settingsArray = file(dirname(__FILE__) . '/Settings.php'); |
| 1758 | 1852 | |
| 1759 | 1853 | // @todo Do we just want to read the file in clean, and split it this way always? |
| 1760 | - if (count($settingsArray) == 1) |
|
| 1761 | - $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
| 1854 | + if (count($settingsArray) == 1) { |
|
| 1855 | + $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
| 1856 | + } |
|
| 1762 | 1857 | |
| 1763 | 1858 | for ($i = 0, $n = count($settingsArray); $i < $n; $i++) |
| 1764 | 1859 | { |
@@ -1766,25 +1861,29 @@ discard block |
||
| 1766 | 1861 | if (trim($settingsArray[$i]) == 'if (file_exists(dirname(__FILE__) . \'/install.php\'))' && trim($settingsArray[$i + 1]) == '{' && trim($settingsArray[$i + 9]) == '}') |
| 1767 | 1862 | { |
| 1768 | 1863 | // Set the ten lines to nothing. |
| 1769 | - for ($j=0; $j < 10; $j++) |
|
| 1770 | - $settingsArray[$i++] = ''; |
|
| 1864 | + for ($j=0; $j < 10; $j++) { |
|
| 1865 | + $settingsArray[$i++] = ''; |
|
| 1866 | + } |
|
| 1771 | 1867 | |
| 1772 | 1868 | continue; |
| 1773 | 1869 | } |
| 1774 | 1870 | |
| 1775 | - if (trim($settingsArray[$i]) == '?' . '>') |
|
| 1776 | - $settingsArray[$i] = ''; |
|
| 1871 | + if (trim($settingsArray[$i]) == '?' . '>') { |
|
| 1872 | + $settingsArray[$i] = ''; |
|
| 1873 | + } |
|
| 1777 | 1874 | |
| 1778 | 1875 | // Don't trim or bother with it if it's not a variable. |
| 1779 | - if (substr($settingsArray[$i], 0, 1) != '$') |
|
| 1780 | - continue; |
|
| 1876 | + if (substr($settingsArray[$i], 0, 1) != '$') { |
|
| 1877 | + continue; |
|
| 1878 | + } |
|
| 1781 | 1879 | |
| 1782 | 1880 | $settingsArray[$i] = rtrim($settingsArray[$i]) . "\n"; |
| 1783 | 1881 | |
| 1784 | - foreach ($vars as $var => $val) |
|
| 1785 | - if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
| 1882 | + foreach ($vars as $var => $val) { |
|
| 1883 | + if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
| 1786 | 1884 | { |
| 1787 | 1885 | $comment = strstr($settingsArray[$i], '#'); |
| 1886 | + } |
|
| 1788 | 1887 | $settingsArray[$i] = '$' . $var . ' = \'' . $val . '\';' . ($comment != '' ? "\t\t" . $comment : "\n"); |
| 1789 | 1888 | unset($vars[$var]); |
| 1790 | 1889 | } |
@@ -1794,36 +1893,41 @@ discard block |
||
| 1794 | 1893 | if (!empty($vars)) |
| 1795 | 1894 | { |
| 1796 | 1895 | $settingsArray[$i++] = ''; |
| 1797 | - foreach ($vars as $var => $val) |
|
| 1798 | - $settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n"; |
|
| 1896 | + foreach ($vars as $var => $val) { |
|
| 1897 | + $settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n"; |
|
| 1898 | + } |
|
| 1799 | 1899 | } |
| 1800 | 1900 | |
| 1801 | 1901 | // Blank out the file - done to fix a oddity with some servers. |
| 1802 | 1902 | $fp = @fopen(dirname(__FILE__) . '/Settings.php', 'w'); |
| 1803 | - if (!$fp) |
|
| 1804 | - return false; |
|
| 1903 | + if (!$fp) { |
|
| 1904 | + return false; |
|
| 1905 | + } |
|
| 1805 | 1906 | fclose($fp); |
| 1806 | 1907 | |
| 1807 | 1908 | $fp = fopen(dirname(__FILE__) . '/Settings.php', 'r+'); |
| 1808 | 1909 | |
| 1809 | 1910 | // Gotta have one of these ;) |
| 1810 | - if (trim($settingsArray[0]) != '<?php') |
|
| 1811 | - fwrite($fp, "<?php\n"); |
|
| 1911 | + if (trim($settingsArray[0]) != '<?php') { |
|
| 1912 | + fwrite($fp, "<?php\n"); |
|
| 1913 | + } |
|
| 1812 | 1914 | |
| 1813 | 1915 | $lines = count($settingsArray); |
| 1814 | 1916 | for ($i = 0; $i < $lines - 1; $i++) |
| 1815 | 1917 | { |
| 1816 | 1918 | // Don't just write a bunch of blank lines. |
| 1817 | - if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') |
|
| 1818 | - fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
| 1919 | + if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') { |
|
| 1920 | + fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
| 1921 | + } |
|
| 1819 | 1922 | } |
| 1820 | 1923 | fwrite($fp, $settingsArray[$i] . '?' . '>'); |
| 1821 | 1924 | fclose($fp); |
| 1822 | 1925 | |
| 1823 | 1926 | // Even though on normal installations the filemtime should prevent this being used by the installer incorrectly |
| 1824 | 1927 | // it seems that there are times it might not. So let's MAKE it dump the cache. |
| 1825 | - if (function_exists('opcache_invalidate')) |
|
| 1826 | - opcache_invalidate(dirname(__FILE__) . '/Settings.php', true); |
|
| 1928 | + if (function_exists('opcache_invalidate')) { |
|
| 1929 | + opcache_invalidate(dirname(__FILE__) . '/Settings.php', true); |
|
| 1930 | + } |
|
| 1827 | 1931 | |
| 1828 | 1932 | return true; |
| 1829 | 1933 | } |
@@ -1833,10 +1937,11 @@ discard block |
||
| 1833 | 1937 | global $cachedir; |
| 1834 | 1938 | |
| 1835 | 1939 | // Write out the db_last_error file with the error timestamp |
| 1836 | - if (!empty($cachedir) && is_writable($cachedir)) |
|
| 1837 | - file_put_contents($cachedir . '/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>'); |
|
| 1838 | - else |
|
| 1839 | - file_put_contents(dirname(__FILE__) . '/cache/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>'); |
|
| 1940 | + if (!empty($cachedir) && is_writable($cachedir)) { |
|
| 1941 | + file_put_contents($cachedir . '/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>'); |
|
| 1942 | + } else { |
|
| 1943 | + file_put_contents(dirname(__FILE__) . '/cache/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>'); |
|
| 1944 | + } |
|
| 1840 | 1945 | |
| 1841 | 1946 | return true; |
| 1842 | 1947 | } |
@@ -1853,9 +1958,9 @@ discard block |
||
| 1853 | 1958 | SecFilterScanPOST Off |
| 1854 | 1959 | </IfModule>'; |
| 1855 | 1960 | |
| 1856 | - if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) |
|
| 1857 | - return true; |
|
| 1858 | - elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess')) |
|
| 1961 | + if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) { |
|
| 1962 | + return true; |
|
| 1963 | + } elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess')) |
|
| 1859 | 1964 | { |
| 1860 | 1965 | $current_htaccess = implode('', file(dirname(__FILE__) . '/.htaccess')); |
| 1861 | 1966 | |
@@ -1867,29 +1972,28 @@ discard block |
||
| 1867 | 1972 | fwrite($ht_handle, $htaccess_addition); |
| 1868 | 1973 | fclose($ht_handle); |
| 1869 | 1974 | return true; |
| 1975 | + } else { |
|
| 1976 | + return false; |
|
| 1870 | 1977 | } |
| 1871 | - else |
|
| 1872 | - return false; |
|
| 1978 | + } else { |
|
| 1979 | + return true; |
|
| 1873 | 1980 | } |
| 1874 | - else |
|
| 1875 | - return true; |
|
| 1876 | - } |
|
| 1877 | - elseif (file_exists(dirname(__FILE__) . '/.htaccess')) |
|
| 1878 | - return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false; |
|
| 1879 | - elseif (is_writable(dirname(__FILE__))) |
|
| 1981 | + } elseif (file_exists(dirname(__FILE__) . '/.htaccess')) { |
|
| 1982 | + return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false; |
|
| 1983 | + } elseif (is_writable(dirname(__FILE__))) |
|
| 1880 | 1984 | { |
| 1881 | 1985 | if ($ht_handle = fopen(dirname(__FILE__) . '/.htaccess', 'w')) |
| 1882 | 1986 | { |
| 1883 | 1987 | fwrite($ht_handle, $htaccess_addition); |
| 1884 | 1988 | fclose($ht_handle); |
| 1885 | 1989 | return true; |
| 1990 | + } else { |
|
| 1991 | + return false; |
|
| 1886 | 1992 | } |
| 1887 | - else |
|
| 1993 | + } else { |
|
| 1888 | 1994 | return false; |
| 1889 | 1995 | } |
| 1890 | - else |
|
| 1891 | - return false; |
|
| 1892 | -} |
|
| 1996 | + } |
|
| 1893 | 1997 | |
| 1894 | 1998 | function template_install_above() |
| 1895 | 1999 | { |
@@ -1927,9 +2031,10 @@ discard block |
||
| 1927 | 2031 | <label for="installer_language">', $txt['installer_language'], ':</label> |
| 1928 | 2032 | <select id="installer_language" name="lang_file" onchange="location.href = \'', $installurl, '?lang_file=\' + this.options[this.selectedIndex].value;">'; |
| 1929 | 2033 | |
| 1930 | - foreach ($incontext['detected_languages'] as $lang => $name) |
|
| 1931 | - echo ' |
|
| 2034 | + foreach ($incontext['detected_languages'] as $lang => $name) { |
|
| 2035 | + echo ' |
|
| 1932 | 2036 | <option', isset($_SESSION['installer_temp_lang']) && $_SESSION['installer_temp_lang'] == $lang ? ' selected' : '', ' value="', $lang, '">', $name, '</option>'; |
| 2037 | + } |
|
| 1933 | 2038 | |
| 1934 | 2039 | echo ' |
| 1935 | 2040 | </select> |
@@ -1949,9 +2054,10 @@ discard block |
||
| 1949 | 2054 | <h2>', $txt['upgrade_progress'], '</h2> |
| 1950 | 2055 | <ul>'; |
| 1951 | 2056 | |
| 1952 | - foreach ($incontext['steps'] as $num => $step) |
|
| 1953 | - echo ' |
|
| 2057 | + foreach ($incontext['steps'] as $num => $step) { |
|
| 2058 | + echo ' |
|
| 1954 | 2059 | <li class="', $num < $incontext['current_step'] ? 'stepdone' : ($num == $incontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
| 2060 | + } |
|
| 1955 | 2061 | |
| 1956 | 2062 | echo ' |
| 1957 | 2063 | </ul> |
@@ -1976,20 +2082,23 @@ discard block |
||
| 1976 | 2082 | echo ' |
| 1977 | 2083 | <div class="floatright">'; |
| 1978 | 2084 | |
| 1979 | - if (!empty($incontext['continue'])) |
|
| 1980 | - echo ' |
|
| 2085 | + if (!empty($incontext['continue'])) { |
|
| 2086 | + echo ' |
|
| 1981 | 2087 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '" onclick="return submitThisOnce(this);" class="button" />'; |
| 1982 | - if (!empty($incontext['skip'])) |
|
| 1983 | - echo ' |
|
| 2088 | + } |
|
| 2089 | + if (!empty($incontext['skip'])) { |
|
| 2090 | + echo ' |
|
| 1984 | 2091 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="return submitThisOnce(this);" class="button" />'; |
| 2092 | + } |
|
| 1985 | 2093 | echo ' |
| 1986 | 2094 | </div>'; |
| 1987 | 2095 | } |
| 1988 | 2096 | |
| 1989 | 2097 | // Show the closing form tag and other data only if not in the last step |
| 1990 | - if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) |
|
| 1991 | - echo ' |
|
| 2098 | + if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) { |
|
| 2099 | + echo ' |
|
| 1992 | 2100 | </form>'; |
| 2101 | + } |
|
| 1993 | 2102 | |
| 1994 | 2103 | echo ' |
| 1995 | 2104 | </div> |
@@ -2024,13 +2133,15 @@ discard block |
||
| 2024 | 2133 | </div>'; |
| 2025 | 2134 | |
| 2026 | 2135 | // Show the warnings, or not. |
| 2027 | - if (template_warning_divs()) |
|
| 2028 | - echo ' |
|
| 2136 | + if (template_warning_divs()) { |
|
| 2137 | + echo ' |
|
| 2029 | 2138 | <h3>', $txt['install_all_lovely'], '</h3>'; |
| 2139 | + } |
|
| 2030 | 2140 | |
| 2031 | 2141 | // Say we want the continue button! |
| 2032 | - if (empty($incontext['error'])) |
|
| 2033 | - $incontext['continue'] = 1; |
|
| 2142 | + if (empty($incontext['error'])) { |
|
| 2143 | + $incontext['continue'] = 1; |
|
| 2144 | + } |
|
| 2034 | 2145 | |
| 2035 | 2146 | // For the latest version stuff. |
| 2036 | 2147 | echo ' |
@@ -2064,8 +2175,8 @@ discard block |
||
| 2064 | 2175 | global $txt, $incontext; |
| 2065 | 2176 | |
| 2066 | 2177 | // Errors are very serious.. |
| 2067 | - if (!empty($incontext['error'])) |
|
| 2068 | - echo ' |
|
| 2178 | + if (!empty($incontext['error'])) { |
|
| 2179 | + echo ' |
|
| 2069 | 2180 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 2070 | 2181 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 2071 | 2182 | <strong style="text-decoration: underline;">', $txt['upgrade_critical_error'], '</strong><br> |
@@ -2073,9 +2184,10 @@ discard block |
||
| 2073 | 2184 | ', $incontext['error'], ' |
| 2074 | 2185 | </div> |
| 2075 | 2186 | </div>'; |
| 2187 | + } |
|
| 2076 | 2188 | // A warning message? |
| 2077 | - elseif (!empty($incontext['warning'])) |
|
| 2078 | - echo ' |
|
| 2189 | + elseif (!empty($incontext['warning'])) { |
|
| 2190 | + echo ' |
|
| 2079 | 2191 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 2080 | 2192 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 2081 | 2193 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -2083,6 +2195,7 @@ discard block |
||
| 2083 | 2195 | ', $incontext['warning'], ' |
| 2084 | 2196 | </div> |
| 2085 | 2197 | </div>'; |
| 2198 | + } |
|
| 2086 | 2199 | |
| 2087 | 2200 | return empty($incontext['error']) && empty($incontext['warning']); |
| 2088 | 2201 | } |
@@ -2098,27 +2211,30 @@ discard block |
||
| 2098 | 2211 | <li>', $incontext['failed_files']), '</li> |
| 2099 | 2212 | </ul>'; |
| 2100 | 2213 | |
| 2101 | - if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') |
|
| 2102 | - echo ' |
|
| 2214 | + if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') { |
|
| 2215 | + echo ' |
|
| 2103 | 2216 | <hr> |
| 2104 | 2217 | <p>', $txt['chmod_linux_info'], '</p> |
| 2105 | 2218 | <tt># chmod a+w ', implode(' ' . $incontext['detected_path'] . '/', $incontext['failed_files']), '</tt>'; |
| 2219 | + } |
|
| 2106 | 2220 | |
| 2107 | 2221 | // This is serious! |
| 2108 | - if (!template_warning_divs()) |
|
| 2109 | - return; |
|
| 2222 | + if (!template_warning_divs()) { |
|
| 2223 | + return; |
|
| 2224 | + } |
|
| 2110 | 2225 | |
| 2111 | 2226 | echo ' |
| 2112 | 2227 | <hr> |
| 2113 | 2228 | <p>', $txt['ftp_setup_info'], '</p>'; |
| 2114 | 2229 | |
| 2115 | - if (!empty($incontext['ftp_errors'])) |
|
| 2116 | - echo ' |
|
| 2230 | + if (!empty($incontext['ftp_errors'])) { |
|
| 2231 | + echo ' |
|
| 2117 | 2232 | <div class="error_message"> |
| 2118 | 2233 | ', $txt['error_ftp_no_connect'], '<br><br> |
| 2119 | 2234 | <code>', implode('<br>', $incontext['ftp_errors']), '</code> |
| 2120 | 2235 | </div> |
| 2121 | 2236 | <br>'; |
| 2237 | + } |
|
| 2122 | 2238 | |
| 2123 | 2239 | echo ' |
| 2124 | 2240 | <form action="', $incontext['form_url'], '" method="post"> |
@@ -2178,17 +2294,17 @@ discard block |
||
| 2178 | 2294 | <td> |
| 2179 | 2295 | <select name="db_type" id="db_type_input" onchange="toggleDBInput();">'; |
| 2180 | 2296 | |
| 2181 | - foreach ($incontext['supported_databases'] as $key => $db) |
|
| 2182 | - echo ' |
|
| 2297 | + foreach ($incontext['supported_databases'] as $key => $db) { |
|
| 2298 | + echo ' |
|
| 2183 | 2299 | <option value="', $key, '"', isset($_POST['db_type']) && $_POST['db_type'] == $key ? ' selected' : '', '>', $db['name'], '</option>'; |
| 2300 | + } |
|
| 2184 | 2301 | |
| 2185 | 2302 | echo ' |
| 2186 | 2303 | </select> |
| 2187 | 2304 | <div class="smalltext block">', $txt['db_settings_type_info'], '</div> |
| 2188 | 2305 | </td> |
| 2189 | 2306 | </tr>'; |
| 2190 | - } |
|
| 2191 | - else |
|
| 2307 | + } else |
|
| 2192 | 2308 | { |
| 2193 | 2309 | echo ' |
| 2194 | 2310 | <tr style="display: none;"> |
@@ -2381,9 +2497,10 @@ discard block |
||
| 2381 | 2497 | <div style="color: red;">', $txt['error_db_queries'], '</div> |
| 2382 | 2498 | <ul>'; |
| 2383 | 2499 | |
| 2384 | - foreach ($incontext['failures'] as $line => $fail) |
|
| 2385 | - echo ' |
|
| 2500 | + foreach ($incontext['failures'] as $line => $fail) { |
|
| 2501 | + echo ' |
|
| 2386 | 2502 | <li><strong>', $txt['error_db_queries_line'], $line + 1, ':</strong> ', nl2br(htmlspecialchars($fail)), '</li>'; |
| 2503 | + } |
|
| 2387 | 2504 | |
| 2388 | 2505 | echo ' |
| 2389 | 2506 | </ul>'; |
@@ -2444,15 +2561,16 @@ discard block |
||
| 2444 | 2561 | </tr> |
| 2445 | 2562 | </table>'; |
| 2446 | 2563 | |
| 2447 | - if ($incontext['require_db_confirm']) |
|
| 2448 | - echo ' |
|
| 2564 | + if ($incontext['require_db_confirm']) { |
|
| 2565 | + echo ' |
|
| 2449 | 2566 | <h2>', $txt['user_settings_database'], '</h2> |
| 2450 | 2567 | <p>', $txt['user_settings_database_info'], '</p> |
| 2451 | 2568 | |
| 2452 | 2569 | <div style="margin-bottom: 2ex; padding-', $txt['lang_rtl'] == false ? 'left' : 'right', ': 50px;"> |
| 2453 | 2570 | <input type="password" name="password3" size="30" /> |
| 2454 | 2571 | </div>'; |
| 2455 | -} |
|
| 2572 | + } |
|
| 2573 | + } |
|
| 2456 | 2574 | |
| 2457 | 2575 | // Tell them it's done, and to delete. |
| 2458 | 2576 | function template_delete_install() |
@@ -2465,14 +2583,15 @@ discard block |
||
| 2465 | 2583 | template_warning_divs(); |
| 2466 | 2584 | |
| 2467 | 2585 | // Install directory still writable? |
| 2468 | - if ($incontext['dir_still_writable']) |
|
| 2469 | - echo ' |
|
| 2586 | + if ($incontext['dir_still_writable']) { |
|
| 2587 | + echo ' |
|
| 2470 | 2588 | <em>', $txt['still_writable'], '</em><br> |
| 2471 | 2589 | <br>'; |
| 2590 | + } |
|
| 2472 | 2591 | |
| 2473 | 2592 | // Don't show the box if it's like 99% sure it won't work :P. |
| 2474 | - if ($incontext['probably_delete_install']) |
|
| 2475 | - echo ' |
|
| 2593 | + if ($incontext['probably_delete_install']) { |
|
| 2594 | + echo ' |
|
| 2476 | 2595 | <div style="margin: 1ex; font-weight: bold;"> |
| 2477 | 2596 | <label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete();" /> ', $txt['delete_installer'], !isset($_SESSION['installer_temp_ftp']) ? ' ' . $txt['delete_installer_maybe'] : '', '</label> |
| 2478 | 2597 | </div> |
@@ -2488,6 +2607,7 @@ discard block |
||
| 2488 | 2607 | } |
| 2489 | 2608 | </script> |
| 2490 | 2609 | <br>'; |
| 2610 | + } |
|
| 2491 | 2611 | |
| 2492 | 2612 | echo ' |
| 2493 | 2613 | ', sprintf($txt['go_to_your_forum'], $boardurl . '/index.php'), '<br> |
@@ -255,8 +255,8 @@ discard block |
||
| 255 | 255 | |
| 256 | 256 | case 'datetime': |
| 257 | 257 | if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d) ([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $datetime_matches) === 1) |
| 258 | - return 'str_to_date('. |
|
| 259 | - sprintf('\'%04d-%02d-%02d %02d:%02d:%02d\'', $datetime_matches[1], $datetime_matches[2], $datetime_matches[3], $datetime_matches[4], $datetime_matches[5] ,$datetime_matches[6]). |
|
| 258 | + return 'str_to_date(' . |
|
| 259 | + sprintf('\'%04d-%02d-%02d %02d:%02d:%02d\'', $datetime_matches[1], $datetime_matches[2], $datetime_matches[3], $datetime_matches[4], $datetime_matches[5], $datetime_matches[6]) . |
|
| 260 | 260 | ',\'%Y-%m-%d %h:%i:%s\')'; |
| 261 | 261 | else |
| 262 | 262 | smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
@@ -460,7 +460,7 @@ discard block |
||
| 460 | 460 | $old_pos = 0; |
| 461 | 461 | $pos = -1; |
| 462 | 462 | // Remove the string escape for better runtime |
| 463 | - $db_string_1 = str_replace('\\\'','',$db_string); |
|
| 463 | + $db_string_1 = str_replace('\\\'', '', $db_string); |
|
| 464 | 464 | while (true) |
| 465 | 465 | { |
| 466 | 466 | $pos = strpos($db_string_1, '\'', $pos + 1); |
@@ -842,7 +842,7 @@ discard block |
||
| 842 | 842 | { |
| 843 | 843 | $count = count($insertRows); |
| 844 | 844 | $ai = 0; |
| 845 | - for($i = 0; $i < $count; $i++) |
|
| 845 | + for ($i = 0; $i < $count; $i++) |
|
| 846 | 846 | { |
| 847 | 847 | $old_id = $smcFunc['db_insert_id'](); |
| 848 | 848 | |
@@ -868,13 +868,13 @@ discard block |
||
| 868 | 868 | $count2 = count($indexed_columns); |
| 869 | 869 | for ($x = 0; $x < $count2; $x++) |
| 870 | 870 | { |
| 871 | - $where_string += key($indexed_columns[$x]) . ' = '. $insertRows[$i][$x]; |
|
| 871 | + $where_string += key($indexed_columns[$x]) . ' = ' . $insertRows[$i][$x]; |
|
| 872 | 872 | if (($x + 1) < $count2) |
| 873 | 873 | $where_string += ' AND '; |
| 874 | 874 | } |
| 875 | 875 | |
| 876 | - $request = $smcFunc['db_query']('',' |
|
| 877 | - SELECT `'. $keys[0] . '` FROM ' . $table .' |
|
| 876 | + $request = $smcFunc['db_query']('', ' |
|
| 877 | + SELECT `'. $keys[0] . '` FROM ' . $table . ' |
|
| 878 | 878 | WHERE ' . $where_string . ' LIMIT 1', |
| 879 | 879 | array() |
| 880 | 880 | ); |
@@ -903,7 +903,7 @@ discard block |
||
| 903 | 903 | $return_var = array(); |
| 904 | 904 | $count = count($insertRows); |
| 905 | 905 | $start = smf_db_insert_id($table, $keys[0]); |
| 906 | - for ($i = 0; $i < $count; $i++ ) |
|
| 906 | + for ($i = 0; $i < $count; $i++) |
|
| 907 | 907 | $return_var[] = $start + $i; |
| 908 | 908 | } |
| 909 | 909 | return $return_var; |
@@ -1036,7 +1036,7 @@ discard block |
||
| 1036 | 1036 | mysqli_stmt_bind_param($mysql_error_data_prep, 'iissssssi', |
| 1037 | 1037 | $error_array[0], $error_array[1], $error_array[2], $error_array[3], $error_array[4], $error_array[5], $error_array[6], |
| 1038 | 1038 | $error_array[7], $error_array[8]); |
| 1039 | - mysqli_stmt_execute ($mysql_error_data_prep); |
|
| 1039 | + mysqli_stmt_execute($mysql_error_data_prep); |
|
| 1040 | 1040 | } |
| 1041 | 1041 | |
| 1042 | 1042 | /** |
@@ -1050,7 +1050,7 @@ discard block |
||
| 1050 | 1050 | */ |
| 1051 | 1051 | function smf_db_custom_order($field, $array_values, $desc = false) |
| 1052 | 1052 | { |
| 1053 | - $return = 'CASE '. $field . ' '; |
|
| 1053 | + $return = 'CASE ' . $field . ' '; |
|
| 1054 | 1054 | $count = count($array_values); |
| 1055 | 1055 | $then = ($desc ? ' THEN -' : ' THEN '); |
| 1056 | 1056 | |
@@ -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 | * Maps the implementations in this file (smf_db_function_name) |
@@ -33,8 +34,8 @@ discard block |
||
| 33 | 34 | global $smcFunc; |
| 34 | 35 | |
| 35 | 36 | // Map some database specific functions, only do this once. |
| 36 | - if (!isset($smcFunc['db_fetch_assoc'])) |
|
| 37 | - $smcFunc += array( |
|
| 37 | + if (!isset($smcFunc['db_fetch_assoc'])) { |
|
| 38 | + $smcFunc += array( |
|
| 38 | 39 | 'db_query' => 'smf_db_query', |
| 39 | 40 | 'db_quote' => 'smf_db_quote', |
| 40 | 41 | 'db_fetch_assoc' => 'mysqli_fetch_assoc', |
@@ -63,9 +64,11 @@ discard block |
||
| 63 | 64 | 'db_error_insert' => 'smf_db_error_insert', |
| 64 | 65 | 'db_custom_order' => 'smf_db_custom_order', |
| 65 | 66 | ); |
| 67 | + } |
|
| 66 | 68 | |
| 67 | - if (!empty($db_options['persist'])) |
|
| 68 | - $db_server = 'p:' . $db_server; |
|
| 69 | + if (!empty($db_options['persist'])) { |
|
| 70 | + $db_server = 'p:' . $db_server; |
|
| 71 | + } |
|
| 69 | 72 | |
| 70 | 73 | $connection = mysqli_init(); |
| 71 | 74 | |
@@ -74,24 +77,27 @@ discard block |
||
| 74 | 77 | $success = false; |
| 75 | 78 | |
| 76 | 79 | if ($connection) { |
| 77 | - if (!empty($db_options['port'])) |
|
| 78 | - $success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, '', $db_options['port'], null, $flags); |
|
| 79 | - else |
|
| 80 | - $success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, '', 0, null, $flags); |
|
| 80 | + if (!empty($db_options['port'])) { |
|
| 81 | + $success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, '', $db_options['port'], null, $flags); |
|
| 82 | + } else { |
|
| 83 | + $success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, '', 0, null, $flags); |
|
| 84 | + } |
|
| 81 | 85 | } |
| 82 | 86 | |
| 83 | 87 | // Something's wrong, show an error if its fatal (which we assume it is) |
| 84 | 88 | if ($success === false) |
| 85 | 89 | { |
| 86 | - if (!empty($db_options['non_fatal'])) |
|
| 87 | - return null; |
|
| 88 | - else |
|
| 89 | - display_db_error(); |
|
| 90 | + if (!empty($db_options['non_fatal'])) { |
|
| 91 | + return null; |
|
| 92 | + } else { |
|
| 93 | + display_db_error(); |
|
| 94 | + } |
|
| 90 | 95 | } |
| 91 | 96 | |
| 92 | 97 | // Select the database, unless told not to |
| 93 | - if (empty($db_options['dont_select_db']) && !@mysqli_select_db($connection, $db_name) && empty($db_options['non_fatal'])) |
|
| 94 | - display_db_error(); |
|
| 98 | + if (empty($db_options['dont_select_db']) && !@mysqli_select_db($connection, $db_name) && empty($db_options['non_fatal'])) { |
|
| 99 | + display_db_error(); |
|
| 100 | + } |
|
| 95 | 101 | |
| 96 | 102 | $smcFunc['db_query']('', 'SET SESSION sql_mode = \'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION\'', |
| 97 | 103 | array(), |
@@ -167,34 +173,42 @@ discard block |
||
| 167 | 173 | global $db_callback, $user_info, $db_prefix, $smcFunc; |
| 168 | 174 | |
| 169 | 175 | list ($values, $connection) = $db_callback; |
| 170 | - if (!is_object($connection)) |
|
| 171 | - display_db_error(); |
|
| 176 | + if (!is_object($connection)) { |
|
| 177 | + display_db_error(); |
|
| 178 | + } |
|
| 172 | 179 | |
| 173 | - if ($matches[1] === 'db_prefix') |
|
| 174 | - return $db_prefix; |
|
| 180 | + if ($matches[1] === 'db_prefix') { |
|
| 181 | + return $db_prefix; |
|
| 182 | + } |
|
| 175 | 183 | |
| 176 | - if (isset($user_info[$matches[1]]) && strpos($matches[1], 'query_') !== false) |
|
| 177 | - return $user_info[$matches[1]]; |
|
| 184 | + if (isset($user_info[$matches[1]]) && strpos($matches[1], 'query_') !== false) { |
|
| 185 | + return $user_info[$matches[1]]; |
|
| 186 | + } |
|
| 178 | 187 | |
| 179 | - if ($matches[1] === 'empty') |
|
| 180 | - return '\'\''; |
|
| 188 | + if ($matches[1] === 'empty') { |
|
| 189 | + return '\'\''; |
|
| 190 | + } |
|
| 181 | 191 | |
| 182 | - if (!isset($matches[2])) |
|
| 183 | - smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 192 | + if (!isset($matches[2])) { |
|
| 193 | + smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 194 | + } |
|
| 184 | 195 | |
| 185 | - if ($matches[1] === 'literal') |
|
| 186 | - return '\'' . mysqli_real_escape_string($connection, $matches[2]) . '\''; |
|
| 196 | + if ($matches[1] === 'literal') { |
|
| 197 | + return '\'' . mysqli_real_escape_string($connection, $matches[2]) . '\''; |
|
| 198 | + } |
|
| 187 | 199 | |
| 188 | - if (!isset($values[$matches[2]])) |
|
| 189 | - smf_db_error_backtrace('The database value you\'re trying to insert does not exist: ' . (isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($matches[2]) : htmlspecialchars($matches[2])), '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 200 | + if (!isset($values[$matches[2]])) { |
|
| 201 | + smf_db_error_backtrace('The database value you\'re trying to insert does not exist: ' . (isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($matches[2]) : htmlspecialchars($matches[2])), '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 202 | + } |
|
| 190 | 203 | |
| 191 | 204 | $replacement = $values[$matches[2]]; |
| 192 | 205 | |
| 193 | 206 | switch ($matches[1]) |
| 194 | 207 | { |
| 195 | 208 | case 'int': |
| 196 | - if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement) |
|
| 197 | - smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 209 | + if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement) { |
|
| 210 | + smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 211 | + } |
|
| 198 | 212 | return (string) (int) $replacement; |
| 199 | 213 | break; |
| 200 | 214 | |
@@ -206,65 +220,73 @@ discard block |
||
| 206 | 220 | case 'array_int': |
| 207 | 221 | if (is_array($replacement)) |
| 208 | 222 | { |
| 209 | - if (empty($replacement)) |
|
| 210 | - smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 223 | + if (empty($replacement)) { |
|
| 224 | + smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 225 | + } |
|
| 211 | 226 | |
| 212 | 227 | foreach ($replacement as $key => $value) |
| 213 | 228 | { |
| 214 | - if (!is_numeric($value) || (string) $value !== (string) (int) $value) |
|
| 215 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 229 | + if (!is_numeric($value) || (string) $value !== (string) (int) $value) { |
|
| 230 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 231 | + } |
|
| 216 | 232 | |
| 217 | 233 | $replacement[$key] = (string) (int) $value; |
| 218 | 234 | } |
| 219 | 235 | |
| 220 | 236 | return implode(', ', $replacement); |
| 237 | + } else { |
|
| 238 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 221 | 239 | } |
| 222 | - else |
|
| 223 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 224 | 240 | |
| 225 | 241 | break; |
| 226 | 242 | |
| 227 | 243 | case 'array_string': |
| 228 | 244 | if (is_array($replacement)) |
| 229 | 245 | { |
| 230 | - if (empty($replacement)) |
|
| 231 | - smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 246 | + if (empty($replacement)) { |
|
| 247 | + smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 248 | + } |
|
| 232 | 249 | |
| 233 | - foreach ($replacement as $key => $value) |
|
| 234 | - $replacement[$key] = sprintf('\'%1$s\'', mysqli_real_escape_string($connection, $value)); |
|
| 250 | + foreach ($replacement as $key => $value) { |
|
| 251 | + $replacement[$key] = sprintf('\'%1$s\'', mysqli_real_escape_string($connection, $value)); |
|
| 252 | + } |
|
| 235 | 253 | |
| 236 | 254 | return implode(', ', $replacement); |
| 255 | + } else { |
|
| 256 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 237 | 257 | } |
| 238 | - else |
|
| 239 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 240 | 258 | break; |
| 241 | 259 | |
| 242 | 260 | case 'date': |
| 243 | - if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) |
|
| 244 | - return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]); |
|
| 245 | - else |
|
| 246 | - smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 261 | + if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) { |
|
| 262 | + return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]); |
|
| 263 | + } else { |
|
| 264 | + smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 265 | + } |
|
| 247 | 266 | break; |
| 248 | 267 | |
| 249 | 268 | case 'time': |
| 250 | - if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1) |
|
| 251 | - return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]); |
|
| 252 | - else |
|
| 253 | - smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 269 | + if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1) { |
|
| 270 | + return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]); |
|
| 271 | + } else { |
|
| 272 | + smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 273 | + } |
|
| 254 | 274 | break; |
| 255 | 275 | |
| 256 | 276 | case 'datetime': |
| 257 | - if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d) ([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $datetime_matches) === 1) |
|
| 258 | - return 'str_to_date('. |
|
| 277 | + if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d) ([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $datetime_matches) === 1) { |
|
| 278 | + return 'str_to_date('. |
|
| 259 | 279 | sprintf('\'%04d-%02d-%02d %02d:%02d:%02d\'', $datetime_matches[1], $datetime_matches[2], $datetime_matches[3], $datetime_matches[4], $datetime_matches[5] ,$datetime_matches[6]). |
| 260 | 280 | ',\'%Y-%m-%d %h:%i:%s\')'; |
| 261 | - else |
|
| 262 | - smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 281 | + } else { |
|
| 282 | + smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 283 | + } |
|
| 263 | 284 | break; |
| 264 | 285 | |
| 265 | 286 | case 'float': |
| 266 | - if (!is_numeric($replacement)) |
|
| 267 | - smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 287 | + if (!is_numeric($replacement)) { |
|
| 288 | + smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 289 | + } |
|
| 268 | 290 | return (string) (float) $replacement; |
| 269 | 291 | break; |
| 270 | 292 | |
@@ -278,32 +300,37 @@ discard block |
||
| 278 | 300 | break; |
| 279 | 301 | |
| 280 | 302 | case 'inet': |
| 281 | - if ($replacement == 'null' || $replacement == '') |
|
| 282 | - return 'null'; |
|
| 283 | - if (!isValidIP($replacement)) |
|
| 284 | - smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 303 | + if ($replacement == 'null' || $replacement == '') { |
|
| 304 | + return 'null'; |
|
| 305 | + } |
|
| 306 | + if (!isValidIP($replacement)) { |
|
| 307 | + smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 308 | + } |
|
| 285 | 309 | //we don't use the native support of mysql > 5.6.2 |
| 286 | 310 | return sprintf('unhex(\'%1$s\')', bin2hex(inet_pton($replacement))); |
| 287 | 311 | |
| 288 | 312 | case 'array_inet': |
| 289 | 313 | if (is_array($replacement)) |
| 290 | 314 | { |
| 291 | - if (empty($replacement)) |
|
| 292 | - smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 315 | + if (empty($replacement)) { |
|
| 316 | + smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 317 | + } |
|
| 293 | 318 | |
| 294 | 319 | foreach ($replacement as $key => $value) |
| 295 | 320 | { |
| 296 | - if ($replacement == 'null' || $replacement == '') |
|
| 297 | - $replacement[$key] = 'null'; |
|
| 298 | - if (!isValidIP($value)) |
|
| 299 | - smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 321 | + if ($replacement == 'null' || $replacement == '') { |
|
| 322 | + $replacement[$key] = 'null'; |
|
| 323 | + } |
|
| 324 | + if (!isValidIP($value)) { |
|
| 325 | + smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 326 | + } |
|
| 300 | 327 | $replacement[$key] = sprintf('unhex(\'%1$s\')', bin2hex(inet_pton($value))); |
| 301 | 328 | } |
| 302 | 329 | |
| 303 | 330 | return implode(', ', $replacement); |
| 331 | + } else { |
|
| 332 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 304 | 333 | } |
| 305 | - else |
|
| 306 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 307 | 334 | break; |
| 308 | 335 | |
| 309 | 336 | default: |
@@ -379,22 +406,25 @@ discard block |
||
| 379 | 406 | // Are we in SSI mode? If so try that username and password first |
| 380 | 407 | if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd)) |
| 381 | 408 | { |
| 382 | - if (empty($db_persist)) |
|
| 383 | - $db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd); |
|
| 384 | - else |
|
| 385 | - $db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd); |
|
| 409 | + if (empty($db_persist)) { |
|
| 410 | + $db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd); |
|
| 411 | + } else { |
|
| 412 | + $db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd); |
|
| 413 | + } |
|
| 386 | 414 | } |
| 387 | 415 | // Fall back to the regular username and password if need be |
| 388 | 416 | if (!$db_connection) |
| 389 | 417 | { |
| 390 | - if (empty($db_persist)) |
|
| 391 | - $db_connection = @mysqli_connect($db_server, $db_user, $db_passwd); |
|
| 392 | - else |
|
| 393 | - $db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd); |
|
| 418 | + if (empty($db_persist)) { |
|
| 419 | + $db_connection = @mysqli_connect($db_server, $db_user, $db_passwd); |
|
| 420 | + } else { |
|
| 421 | + $db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd); |
|
| 422 | + } |
|
| 394 | 423 | } |
| 395 | 424 | |
| 396 | - if (!$db_connection || !@mysqli_select_db($db_connection, $db_name)) |
|
| 397 | - $db_connection = false; |
|
| 425 | + if (!$db_connection || !@mysqli_select_db($db_connection, $db_name)) { |
|
| 426 | + $db_connection = false; |
|
| 427 | + } |
|
| 398 | 428 | |
| 399 | 429 | $connection = $db_connection; |
| 400 | 430 | } |
@@ -402,18 +432,20 @@ discard block |
||
| 402 | 432 | // One more query.... |
| 403 | 433 | $db_count = !isset($db_count) ? 1 : $db_count + 1; |
| 404 | 434 | |
| 405 | - if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override'])) |
|
| 406 | - smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__); |
|
| 435 | + if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override'])) { |
|
| 436 | + smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__); |
|
| 437 | + } |
|
| 407 | 438 | |
| 408 | 439 | // Use "ORDER BY null" to prevent Mysql doing filesorts for Group By clauses without an Order By |
| 409 | 440 | if (strpos($db_string, 'GROUP BY') !== false && strpos($db_string, 'ORDER BY') === false && preg_match('~^\s+SELECT~i', $db_string)) |
| 410 | 441 | { |
| 411 | 442 | // Add before LIMIT |
| 412 | - if ($pos = strpos($db_string, 'LIMIT ')) |
|
| 413 | - $db_string = substr($db_string, 0, $pos) . "\t\t\tORDER BY null\n" . substr($db_string, $pos, strlen($db_string)); |
|
| 414 | - else |
|
| 415 | - // Append it. |
|
| 443 | + if ($pos = strpos($db_string, 'LIMIT ')) { |
|
| 444 | + $db_string = substr($db_string, 0, $pos) . "\t\t\tORDER BY null\n" . substr($db_string, $pos, strlen($db_string)); |
|
| 445 | + } else { |
|
| 446 | + // Append it. |
|
| 416 | 447 | $db_string .= "\n\t\t\tORDER BY null"; |
| 448 | + } |
|
| 417 | 449 | } |
| 418 | 450 | |
| 419 | 451 | if (empty($db_values['security_override']) && (!empty($db_values) || strpos($db_string, '{db_prefix}') !== false)) |
@@ -439,17 +471,18 @@ discard block |
||
| 439 | 471 | while (true) |
| 440 | 472 | { |
| 441 | 473 | $pos = strpos($db_string_1, '\'', $pos + 1); |
| 442 | - if ($pos === false) |
|
| 443 | - break; |
|
| 474 | + if ($pos === false) { |
|
| 475 | + break; |
|
| 476 | + } |
|
| 444 | 477 | $clean .= substr($db_string_1, $old_pos, $pos - $old_pos); |
| 445 | 478 | |
| 446 | 479 | while (true) |
| 447 | 480 | { |
| 448 | 481 | $pos1 = strpos($db_string_1, '\'', $pos + 1); |
| 449 | 482 | $pos2 = strpos($db_string_1, '\\', $pos + 1); |
| 450 | - if ($pos1 === false) |
|
| 451 | - break; |
|
| 452 | - elseif ($pos2 === false || $pos2 > $pos1) |
|
| 483 | + if ($pos1 === false) { |
|
| 484 | + break; |
|
| 485 | + } elseif ($pos2 === false || $pos2 > $pos1) |
|
| 453 | 486 | { |
| 454 | 487 | $pos = $pos1; |
| 455 | 488 | break; |
@@ -465,16 +498,19 @@ discard block |
||
| 465 | 498 | $clean = trim(strtolower(preg_replace($allowed_comments_from, $allowed_comments_to, $clean))); |
| 466 | 499 | |
| 467 | 500 | // Comments? We don't use comments in our queries, we leave 'em outside! |
| 468 | - if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false) |
|
| 469 | - $fail = true; |
|
| 501 | + if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false) { |
|
| 502 | + $fail = true; |
|
| 503 | + } |
|
| 470 | 504 | // Trying to change passwords, slow us down, or something? |
| 471 | - elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0) |
|
| 472 | - $fail = true; |
|
| 473 | - elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0) |
|
| 474 | - $fail = true; |
|
| 505 | + elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0) { |
|
| 506 | + $fail = true; |
|
| 507 | + } elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0) { |
|
| 508 | + $fail = true; |
|
| 509 | + } |
|
| 475 | 510 | |
| 476 | - if (!empty($fail) && function_exists('log_error')) |
|
| 477 | - smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__); |
|
| 511 | + if (!empty($fail) && function_exists('log_error')) { |
|
| 512 | + smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__); |
|
| 513 | + } |
|
| 478 | 514 | } |
| 479 | 515 | |
| 480 | 516 | // Debugging. |
@@ -484,8 +520,9 @@ discard block |
||
| 484 | 520 | list ($file, $line) = smf_db_error_backtrace('', '', 'return', __FILE__, __LINE__); |
| 485 | 521 | |
| 486 | 522 | // Initialize $db_cache if not already initialized. |
| 487 | - if (!isset($db_cache)) |
|
| 488 | - $db_cache = array(); |
|
| 523 | + if (!isset($db_cache)) { |
|
| 524 | + $db_cache = array(); |
|
| 525 | + } |
|
| 489 | 526 | |
| 490 | 527 | if (!empty($_SESSION['debug_redirect'])) |
| 491 | 528 | { |
@@ -501,17 +538,20 @@ discard block |
||
| 501 | 538 | $db_cache[$db_count]['s'] = ($st = microtime(true)) - $time_start; |
| 502 | 539 | } |
| 503 | 540 | |
| 504 | - if (empty($db_unbuffered)) |
|
| 505 | - $ret = @mysqli_query($connection, $db_string); |
|
| 506 | - else |
|
| 507 | - $ret = @mysqli_query($connection, $db_string, MYSQLI_USE_RESULT); |
|
| 541 | + if (empty($db_unbuffered)) { |
|
| 542 | + $ret = @mysqli_query($connection, $db_string); |
|
| 543 | + } else { |
|
| 544 | + $ret = @mysqli_query($connection, $db_string, MYSQLI_USE_RESULT); |
|
| 545 | + } |
|
| 508 | 546 | |
| 509 | - if ($ret === false && empty($db_values['db_error_skip'])) |
|
| 510 | - $ret = smf_db_error($db_string, $connection); |
|
| 547 | + if ($ret === false && empty($db_values['db_error_skip'])) { |
|
| 548 | + $ret = smf_db_error($db_string, $connection); |
|
| 549 | + } |
|
| 511 | 550 | |
| 512 | 551 | // Debugging. |
| 513 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
| 514 | - $db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
| 552 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
| 553 | + $db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
| 554 | + } |
|
| 515 | 555 | |
| 516 | 556 | return $ret; |
| 517 | 557 | } |
@@ -558,12 +598,13 @@ discard block |
||
| 558 | 598 | // Decide which connection to use |
| 559 | 599 | $connection = $connection === null ? $db_connection : $connection; |
| 560 | 600 | |
| 561 | - if ($type == 'begin') |
|
| 562 | - return @mysqli_query($connection, 'BEGIN'); |
|
| 563 | - elseif ($type == 'rollback') |
|
| 564 | - return @mysqli_query($connection, 'ROLLBACK'); |
|
| 565 | - elseif ($type == 'commit') |
|
| 566 | - return @mysqli_query($connection, 'COMMIT'); |
|
| 601 | + if ($type == 'begin') { |
|
| 602 | + return @mysqli_query($connection, 'BEGIN'); |
|
| 603 | + } elseif ($type == 'rollback') { |
|
| 604 | + return @mysqli_query($connection, 'ROLLBACK'); |
|
| 605 | + } elseif ($type == 'commit') { |
|
| 606 | + return @mysqli_query($connection, 'COMMIT'); |
|
| 607 | + } |
|
| 567 | 608 | |
| 568 | 609 | return false; |
| 569 | 610 | } |
@@ -603,8 +644,9 @@ discard block |
||
| 603 | 644 | // 2013: Lost connection to server during query. |
| 604 | 645 | |
| 605 | 646 | // Log the error. |
| 606 | - if ($query_errno != 1213 && $query_errno != 1205 && function_exists('log_error')) |
|
| 607 | - log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n$db_string" : ''), 'database', $file, $line); |
|
| 647 | + if ($query_errno != 1213 && $query_errno != 1205 && function_exists('log_error')) { |
|
| 648 | + log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n$db_string" : ''), 'database', $file, $line); |
|
| 649 | + } |
|
| 608 | 650 | |
| 609 | 651 | // Database error auto fixing ;). |
| 610 | 652 | if (function_exists('cache_get_data') && (!isset($modSettings['autoFixDatabase']) || $modSettings['autoFixDatabase'] == '1')) |
@@ -613,8 +655,9 @@ discard block |
||
| 613 | 655 | $old_cache = @$modSettings['cache_enable']; |
| 614 | 656 | $modSettings['cache_enable'] = '1'; |
| 615 | 657 | |
| 616 | - if (($temp = cache_get_data('db_last_error', 600)) !== null) |
|
| 617 | - $db_last_error = max(@$db_last_error, $temp); |
|
| 658 | + if (($temp = cache_get_data('db_last_error', 600)) !== null) { |
|
| 659 | + $db_last_error = max(@$db_last_error, $temp); |
|
| 660 | + } |
|
| 618 | 661 | |
| 619 | 662 | if (@$db_last_error < time() - 3600 * 24 * 3) |
| 620 | 663 | { |
@@ -630,8 +673,9 @@ discard block |
||
| 630 | 673 | foreach ($tables as $table) |
| 631 | 674 | { |
| 632 | 675 | // Now, it's still theoretically possible this could be an injection. So backtick it! |
| 633 | - if (trim($table) != '') |
|
| 634 | - $fix_tables[] = '`' . strtr(trim($table), array('`' => '')) . '`'; |
|
| 676 | + if (trim($table) != '') { |
|
| 677 | + $fix_tables[] = '`' . strtr(trim($table), array('`' => '')) . '`'; |
|
| 678 | + } |
|
| 635 | 679 | } |
| 636 | 680 | } |
| 637 | 681 | |
@@ -640,8 +684,9 @@ discard block |
||
| 640 | 684 | // Table crashed. Let's try to fix it. |
| 641 | 685 | elseif ($query_errno == 1016) |
| 642 | 686 | { |
| 643 | - if (preg_match('~\'([^\.\']+)~', $query_error, $match) != 0) |
|
| 644 | - $fix_tables = array('`' . $match[1] . '`'); |
|
| 687 | + if (preg_match('~\'([^\.\']+)~', $query_error, $match) != 0) { |
|
| 688 | + $fix_tables = array('`' . $match[1] . '`'); |
|
| 689 | + } |
|
| 645 | 690 | } |
| 646 | 691 | // Indexes crashed. Should be easy to fix! |
| 647 | 692 | elseif ($query_errno == 1034 || $query_errno == 1035) |
@@ -660,13 +705,15 @@ discard block |
||
| 660 | 705 | |
| 661 | 706 | // Make a note of the REPAIR... |
| 662 | 707 | cache_put_data('db_last_error', time(), 600); |
| 663 | - if (($temp = cache_get_data('db_last_error', 600)) === null) |
|
| 664 | - updateSettingsFile(array('db_last_error' => time())); |
|
| 708 | + if (($temp = cache_get_data('db_last_error', 600)) === null) { |
|
| 709 | + updateSettingsFile(array('db_last_error' => time())); |
|
| 710 | + } |
|
| 665 | 711 | |
| 666 | 712 | // Attempt to find and repair the broken table. |
| 667 | - foreach ($fix_tables as $table) |
|
| 668 | - $smcFunc['db_query']('', " |
|
| 713 | + foreach ($fix_tables as $table) { |
|
| 714 | + $smcFunc['db_query']('', " |
|
| 669 | 715 | REPAIR TABLE $table", false, false); |
| 716 | + } |
|
| 670 | 717 | |
| 671 | 718 | // And send off an email! |
| 672 | 719 | sendmail($webmaster_email, $txt['database_error'], $txt['tried_to_repair'], null, 'dberror'); |
@@ -675,11 +722,12 @@ discard block |
||
| 675 | 722 | |
| 676 | 723 | // Try the query again...? |
| 677 | 724 | $ret = $smcFunc['db_query']('', $db_string, false, false); |
| 678 | - if ($ret !== false) |
|
| 679 | - return $ret; |
|
| 725 | + if ($ret !== false) { |
|
| 726 | + return $ret; |
|
| 727 | + } |
|
| 728 | + } else { |
|
| 729 | + $modSettings['cache_enable'] = $old_cache; |
|
| 680 | 730 | } |
| 681 | - else |
|
| 682 | - $modSettings['cache_enable'] = $old_cache; |
|
| 683 | 731 | |
| 684 | 732 | // Check for the "lost connection" or "deadlock found" errors - and try it just one more time. |
| 685 | 733 | if (in_array($query_errno, array(1205, 1213, 2006, 2013))) |
@@ -689,22 +737,25 @@ discard block |
||
| 689 | 737 | // Are we in SSI mode? If so try that username and password first |
| 690 | 738 | if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd)) |
| 691 | 739 | { |
| 692 | - if (empty($db_persist)) |
|
| 693 | - $db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd); |
|
| 694 | - else |
|
| 695 | - $db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd); |
|
| 740 | + if (empty($db_persist)) { |
|
| 741 | + $db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd); |
|
| 742 | + } else { |
|
| 743 | + $db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd); |
|
| 744 | + } |
|
| 696 | 745 | } |
| 697 | 746 | // Fall back to the regular username and password if need be |
| 698 | 747 | if (!$db_connection) |
| 699 | 748 | { |
| 700 | - if (empty($db_persist)) |
|
| 701 | - $db_connection = @mysqli_connect($db_server, $db_user, $db_passwd); |
|
| 702 | - else |
|
| 703 | - $db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd); |
|
| 749 | + if (empty($db_persist)) { |
|
| 750 | + $db_connection = @mysqli_connect($db_server, $db_user, $db_passwd); |
|
| 751 | + } else { |
|
| 752 | + $db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd); |
|
| 753 | + } |
|
| 704 | 754 | } |
| 705 | 755 | |
| 706 | - if (!$db_connection || !@mysqli_select_db($db_connection, $db_name)) |
|
| 707 | - $db_connection = false; |
|
| 756 | + if (!$db_connection || !@mysqli_select_db($db_connection, $db_name)) { |
|
| 757 | + $db_connection = false; |
|
| 758 | + } |
|
| 708 | 759 | } |
| 709 | 760 | |
| 710 | 761 | if ($db_connection) |
@@ -715,24 +766,27 @@ discard block |
||
| 715 | 766 | $ret = $smcFunc['db_query']('', $db_string, false, false); |
| 716 | 767 | |
| 717 | 768 | $new_errno = mysqli_errno($db_connection); |
| 718 | - if ($ret !== false || in_array($new_errno, array(1205, 1213))) |
|
| 719 | - break; |
|
| 769 | + if ($ret !== false || in_array($new_errno, array(1205, 1213))) { |
|
| 770 | + break; |
|
| 771 | + } |
|
| 720 | 772 | } |
| 721 | 773 | |
| 722 | 774 | // If it failed again, shucks to be you... we're not trying it over and over. |
| 723 | - if ($ret !== false) |
|
| 724 | - return $ret; |
|
| 775 | + if ($ret !== false) { |
|
| 776 | + return $ret; |
|
| 777 | + } |
|
| 725 | 778 | } |
| 726 | 779 | } |
| 727 | 780 | // Are they out of space, perhaps? |
| 728 | 781 | elseif ($query_errno == 1030 && (strpos($query_error, ' -1 ') !== false || strpos($query_error, ' 28 ') !== false || strpos($query_error, ' 12 ') !== false)) |
| 729 | 782 | { |
| 730 | - if (!isset($txt)) |
|
| 731 | - $query_error .= ' - check database storage space.'; |
|
| 732 | - else |
|
| 783 | + if (!isset($txt)) { |
|
| 784 | + $query_error .= ' - check database storage space.'; |
|
| 785 | + } else |
|
| 733 | 786 | { |
| 734 | - if (!isset($txt['mysql_error_space'])) |
|
| 735 | - loadLanguage('Errors'); |
|
| 787 | + if (!isset($txt['mysql_error_space'])) { |
|
| 788 | + loadLanguage('Errors'); |
|
| 789 | + } |
|
| 736 | 790 | |
| 737 | 791 | $query_error .= !isset($txt['mysql_error_space']) ? ' - check database storage space.' : $txt['mysql_error_space']; |
| 738 | 792 | } |
@@ -740,15 +794,17 @@ discard block |
||
| 740 | 794 | } |
| 741 | 795 | |
| 742 | 796 | // Nothing's defined yet... just die with it. |
| 743 | - if (empty($context) || empty($txt)) |
|
| 744 | - die($query_error); |
|
| 797 | + if (empty($context) || empty($txt)) { |
|
| 798 | + die($query_error); |
|
| 799 | + } |
|
| 745 | 800 | |
| 746 | 801 | // Show an error message, if possible. |
| 747 | 802 | $context['error_title'] = $txt['database_error']; |
| 748 | - if (allowedTo('admin_forum')) |
|
| 749 | - $context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line; |
|
| 750 | - else |
|
| 751 | - $context['error_message'] = $txt['try_again']; |
|
| 803 | + if (allowedTo('admin_forum')) { |
|
| 804 | + $context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line; |
|
| 805 | + } else { |
|
| 806 | + $context['error_message'] = $txt['try_again']; |
|
| 807 | + } |
|
| 752 | 808 | |
| 753 | 809 | if (allowedTo('admin_forum') && isset($db_show_debug) && $db_show_debug === true) |
| 754 | 810 | { |
@@ -780,8 +836,9 @@ discard block |
||
| 780 | 836 | $return_var = null; |
| 781 | 837 | |
| 782 | 838 | // With nothing to insert, simply return. |
| 783 | - if (empty($data)) |
|
| 784 | - return; |
|
| 839 | + if (empty($data)) { |
|
| 840 | + return; |
|
| 841 | + } |
|
| 785 | 842 | |
| 786 | 843 | // Replace the prefix holder with the actual prefix. |
| 787 | 844 | $table = str_replace('{db_prefix}', $db_prefix, $table); |
@@ -791,23 +848,26 @@ discard block |
||
| 791 | 848 | if (!empty($keys) && (count($keys) > 0) && $returnmode > 0) |
| 792 | 849 | { |
| 793 | 850 | $with_returning = true; |
| 794 | - if ($returnmode == 2) |
|
| 795 | - $return_var = array(); |
|
| 851 | + if ($returnmode == 2) { |
|
| 852 | + $return_var = array(); |
|
| 853 | + } |
|
| 796 | 854 | } |
| 797 | 855 | |
| 798 | 856 | // Inserting data as a single row can be done as a single array. |
| 799 | - if (!is_array($data[array_rand($data)])) |
|
| 800 | - $data = array($data); |
|
| 857 | + if (!is_array($data[array_rand($data)])) { |
|
| 858 | + $data = array($data); |
|
| 859 | + } |
|
| 801 | 860 | |
| 802 | 861 | // Create the mold for a single row insert. |
| 803 | 862 | $insertData = '('; |
| 804 | 863 | foreach ($columns as $columnName => $type) |
| 805 | 864 | { |
| 806 | 865 | // Are we restricting the length? |
| 807 | - if (strpos($type, 'string-') !== false) |
|
| 808 | - $insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName); |
|
| 809 | - else |
|
| 810 | - $insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName); |
|
| 866 | + if (strpos($type, 'string-') !== false) { |
|
| 867 | + $insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName); |
|
| 868 | + } else { |
|
| 869 | + $insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName); |
|
| 870 | + } |
|
| 811 | 871 | } |
| 812 | 872 | $insertData = substr($insertData, 0, -2) . ')'; |
| 813 | 873 | |
@@ -816,8 +876,9 @@ discard block |
||
| 816 | 876 | |
| 817 | 877 | // Here's where the variables are injected to the query. |
| 818 | 878 | $insertRows = array(); |
| 819 | - foreach ($data as $dataRow) |
|
| 820 | - $insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection); |
|
| 879 | + foreach ($data as $dataRow) { |
|
| 880 | + $insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection); |
|
| 881 | + } |
|
| 821 | 882 | |
| 822 | 883 | // Determine the method of insertion. |
| 823 | 884 | $queryTitle = $method == 'replace' ? 'REPLACE' : ($method == 'ignore' ? 'INSERT IGNORE' : 'INSERT'); |
@@ -836,8 +897,7 @@ discard block |
||
| 836 | 897 | ), |
| 837 | 898 | $connection |
| 838 | 899 | ); |
| 839 | - } |
|
| 840 | - else //special way for ignore method with returning |
|
| 900 | + } else //special way for ignore method with returning |
|
| 841 | 901 | { |
| 842 | 902 | $count = count($insertRows); |
| 843 | 903 | $ai = 0; |
@@ -857,19 +917,21 @@ discard block |
||
| 857 | 917 | ); |
| 858 | 918 | $new_id = $smcFunc['db_insert_id'](); |
| 859 | 919 | |
| 860 | - if ($last_id != $new_id) //the inserted value was new |
|
| 920 | + if ($last_id != $new_id) { |
|
| 921 | + //the inserted value was new |
|
| 861 | 922 | { |
| 862 | 923 | $ai = $new_id; |
| 863 | 924 | } |
| 864 | - else // the inserted value already exists we need to find the pk |
|
| 925 | + } else // the inserted value already exists we need to find the pk |
|
| 865 | 926 | { |
| 866 | 927 | $where_string = ''; |
| 867 | 928 | $count2 = count($indexed_columns); |
| 868 | 929 | for ($x = 0; $x < $count2; $x++) |
| 869 | 930 | { |
| 870 | 931 | $where_string += key($indexed_columns[$x]) . ' = '. $insertRows[$i][$x]; |
| 871 | - if (($x + 1) < $count2) |
|
| 872 | - $where_string += ' AND '; |
|
| 932 | + if (($x + 1) < $count2) { |
|
| 933 | + $where_string += ' AND '; |
|
| 934 | + } |
|
| 873 | 935 | } |
| 874 | 936 | |
| 875 | 937 | $request = $smcFunc['db_query']('',' |
@@ -885,25 +947,27 @@ discard block |
||
| 885 | 947 | } |
| 886 | 948 | } |
| 887 | 949 | |
| 888 | - if ($returnmode == 1) |
|
| 889 | - $return_var = $ai; |
|
| 890 | - else if ($returnmode == 2) |
|
| 891 | - $return_var[] = $ai; |
|
| 950 | + if ($returnmode == 1) { |
|
| 951 | + $return_var = $ai; |
|
| 952 | + } else if ($returnmode == 2) { |
|
| 953 | + $return_var[] = $ai; |
|
| 954 | + } |
|
| 892 | 955 | } |
| 893 | 956 | } |
| 894 | 957 | |
| 895 | 958 | |
| 896 | 959 | if ($with_returning) |
| 897 | 960 | { |
| 898 | - if ($returnmode == 1 && empty($return_var)) |
|
| 899 | - $return_var = smf_db_insert_id($table, $keys[0]) + count($insertRows) - 1; |
|
| 900 | - else if ($returnmode == 2 && empty($return_var)) |
|
| 961 | + if ($returnmode == 1 && empty($return_var)) { |
|
| 962 | + $return_var = smf_db_insert_id($table, $keys[0]) + count($insertRows) - 1; |
|
| 963 | + } else if ($returnmode == 2 && empty($return_var)) |
|
| 901 | 964 | { |
| 902 | 965 | $return_var = array(); |
| 903 | 966 | $count = count($insertRows); |
| 904 | 967 | $start = smf_db_insert_id($table, $keys[0]); |
| 905 | - for ($i = 0; $i < $count; $i++ ) |
|
| 906 | - $return_var[] = $start + $i; |
|
| 968 | + for ($i = 0; $i < $count; $i++ ) { |
|
| 969 | + $return_var[] = $start + $i; |
|
| 970 | + } |
|
| 907 | 971 | } |
| 908 | 972 | return $return_var; |
| 909 | 973 | } |
@@ -921,8 +985,9 @@ discard block |
||
| 921 | 985 | */ |
| 922 | 986 | function smf_db_error_backtrace($error_message, $log_message = '', $error_type = false, $file = null, $line = null) |
| 923 | 987 | { |
| 924 | - if (empty($log_message)) |
|
| 925 | - $log_message = $error_message; |
|
| 988 | + if (empty($log_message)) { |
|
| 989 | + $log_message = $error_message; |
|
| 990 | + } |
|
| 926 | 991 | |
| 927 | 992 | foreach (debug_backtrace() as $step) |
| 928 | 993 | { |
@@ -941,12 +1006,14 @@ discard block |
||
| 941 | 1006 | } |
| 942 | 1007 | |
| 943 | 1008 | // A special case - we want the file and line numbers for debugging. |
| 944 | - if ($error_type == 'return') |
|
| 945 | - return array($file, $line); |
|
| 1009 | + if ($error_type == 'return') { |
|
| 1010 | + return array($file, $line); |
|
| 1011 | + } |
|
| 946 | 1012 | |
| 947 | 1013 | // Is always a critical error. |
| 948 | - if (function_exists('log_error')) |
|
| 949 | - log_error($log_message, 'critical', $file, $line); |
|
| 1014 | + if (function_exists('log_error')) { |
|
| 1015 | + log_error($log_message, 'critical', $file, $line); |
|
| 1016 | + } |
|
| 950 | 1017 | |
| 951 | 1018 | if (function_exists('fatal_error')) |
| 952 | 1019 | { |
@@ -954,12 +1021,12 @@ discard block |
||
| 954 | 1021 | |
| 955 | 1022 | // Cannot continue... |
| 956 | 1023 | exit; |
| 1024 | + } elseif ($error_type) { |
|
| 1025 | + trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type); |
|
| 1026 | + } else { |
|
| 1027 | + trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : '')); |
|
| 1028 | + } |
|
| 957 | 1029 | } |
| 958 | - elseif ($error_type) |
|
| 959 | - trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type); |
|
| 960 | - else |
|
| 961 | - trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : '')); |
|
| 962 | -} |
|
| 963 | 1030 | |
| 964 | 1031 | /** |
| 965 | 1032 | * Escape the LIKE wildcards so that they match the character and not the wildcard. |
@@ -976,10 +1043,11 @@ discard block |
||
| 976 | 1043 | '\\' => '\\\\', |
| 977 | 1044 | ); |
| 978 | 1045 | |
| 979 | - if ($translate_human_wildcards) |
|
| 980 | - $replacements += array( |
|
| 1046 | + if ($translate_human_wildcards) { |
|
| 1047 | + $replacements += array( |
|
| 981 | 1048 | '*' => '%', |
| 982 | 1049 | ); |
| 1050 | + } |
|
| 983 | 1051 | |
| 984 | 1052 | return strtr($string, $replacements); |
| 985 | 1053 | } |
@@ -993,8 +1061,9 @@ discard block |
||
| 993 | 1061 | */ |
| 994 | 1062 | function smf_is_resource($result) |
| 995 | 1063 | { |
| 996 | - if ($result instanceof mysqli_result) |
|
| 997 | - return true; |
|
| 1064 | + if ($result instanceof mysqli_result) { |
|
| 1065 | + return true; |
|
| 1066 | + } |
|
| 998 | 1067 | |
| 999 | 1068 | return false; |
| 1000 | 1069 | } |
@@ -1022,16 +1091,18 @@ discard block |
||
| 1022 | 1091 | global $db_prefix, $db_connection; |
| 1023 | 1092 | static $mysql_error_data_prep; |
| 1024 | 1093 | |
| 1025 | - if (empty($mysql_error_data_prep)) |
|
| 1026 | - $mysql_error_data_prep = mysqli_prepare($db_connection, |
|
| 1094 | + if (empty($mysql_error_data_prep)) { |
|
| 1095 | + $mysql_error_data_prep = mysqli_prepare($db_connection, |
|
| 1027 | 1096 | 'INSERT INTO ' . $db_prefix . 'log_errors(id_member, log_time, ip, url, message, session, error_type, file, line) |
| 1028 | 1097 | VALUES( ?, ?, unhex(?), ?, ?, ?, ?, ?, ?)' |
| 1029 | 1098 | ); |
| 1099 | + } |
|
| 1030 | 1100 | |
| 1031 | - if (filter_var($error_array[2], FILTER_VALIDATE_IP) !== false) |
|
| 1032 | - $error_array[2] = bin2hex(inet_pton($error_array[2])); |
|
| 1033 | - else |
|
| 1034 | - $error_array[2] = null; |
|
| 1101 | + if (filter_var($error_array[2], FILTER_VALIDATE_IP) !== false) { |
|
| 1102 | + $error_array[2] = bin2hex(inet_pton($error_array[2])); |
|
| 1103 | + } else { |
|
| 1104 | + $error_array[2] = null; |
|
| 1105 | + } |
|
| 1035 | 1106 | mysqli_stmt_bind_param($mysql_error_data_prep, 'iissssssi', |
| 1036 | 1107 | $error_array[0], $error_array[1], $error_array[2], $error_array[3], $error_array[4], $error_array[5], $error_array[6], |
| 1037 | 1108 | $error_array[7], $error_array[8]); |
@@ -1053,8 +1124,9 @@ discard block |
||
| 1053 | 1124 | $count = count($array_values); |
| 1054 | 1125 | $then = ($desc ? ' THEN -' : ' THEN '); |
| 1055 | 1126 | |
| 1056 | - for ($i = 0; $i < $count; $i++) |
|
| 1057 | - $return .= 'WHEN ' . (int) $array_values[$i] . $then . $i . ' '; |
|
| 1127 | + for ($i = 0; $i < $count; $i++) { |
|
| 1128 | + $return .= 'WHEN ' . (int) $array_values[$i] . $then . $i . ' '; |
|
| 1129 | + } |
|
| 1058 | 1130 | |
| 1059 | 1131 | $return .= 'END'; |
| 1060 | 1132 | return $return; |
@@ -28,15 +28,17 @@ discard block |
||
| 28 | 28 | <form class="login" action="', $context['login_url'], '" name="frmLogin" id="frmLogin" method="post" accept-charset="', $context['character_set'], '">'; |
| 29 | 29 | |
| 30 | 30 | // Did they make a mistake last time? |
| 31 | - if (!empty($context['login_errors'])) |
|
| 32 | - echo ' |
|
| 31 | + if (!empty($context['login_errors'])) { |
|
| 32 | + echo ' |
|
| 33 | 33 | <div class="errorbox">', implode('<br>', $context['login_errors']), '</div> |
| 34 | 34 | <br>'; |
| 35 | + } |
|
| 35 | 36 | |
| 36 | 37 | // Or perhaps there's some special description for this time? |
| 37 | - if (isset($context['description'])) |
|
| 38 | - echo ' |
|
| 38 | + if (isset($context['description'])) { |
|
| 39 | + echo ' |
|
| 39 | 40 | <div class="information">', $context['description'], '</div>'; |
| 41 | + } |
|
| 40 | 42 | |
| 41 | 43 | // Now just get the basic information - username, password, etc. |
| 42 | 44 | echo ' |
@@ -61,10 +63,11 @@ discard block |
||
| 61 | 63 | </dd>'; |
| 62 | 64 | |
| 63 | 65 | // If they have deleted their account, give them a chance to change their mind. |
| 64 | - if (isset($context['login_show_undelete'])) |
|
| 65 | - echo ' |
|
| 66 | + if (isset($context['login_show_undelete'])) { |
|
| 67 | + echo ' |
|
| 66 | 68 | <dt class="alert">', $txt['undelete_account'], ':</dt> |
| 67 | 69 | <dd><input type="checkbox" name="undelete"></dd>'; |
| 70 | + } |
|
| 68 | 71 | |
| 69 | 72 | echo ' |
| 70 | 73 | </dl> |
@@ -82,8 +85,8 @@ discard block |
||
| 82 | 85 | document.getElementById("', !empty($context['from_ajax']) ? 'ajax_' : '', isset($context['default_username']) && $context['default_username'] != '' ? 'loginpass' : 'loginuser', '").focus(); |
| 83 | 86 | }, 150);'; |
| 84 | 87 | |
| 85 | - if (!empty($context['from_ajax'])) |
|
| 86 | - echo ' |
|
| 88 | + if (!empty($context['from_ajax'])) { |
|
| 89 | + echo ' |
|
| 87 | 90 | form = $("#frmLogin"); |
| 88 | 91 | form.submit(function(e) { |
| 89 | 92 | e.preventDefault(); |
@@ -116,16 +119,18 @@ discard block |
||
| 116 | 119 | |
| 117 | 120 | return false; |
| 118 | 121 | });'; |
| 122 | + } |
|
| 119 | 123 | |
| 120 | 124 | echo ' |
| 121 | 125 | </script> |
| 122 | 126 | </form>'; |
| 123 | 127 | |
| 124 | 128 | // It is a long story as to why we have this when we're clearly not going to use it. |
| 125 | - if (!empty($context['from_ajax'])) |
|
| 126 | - echo ' |
|
| 129 | + if (!empty($context['from_ajax'])) { |
|
| 130 | + echo ' |
|
| 127 | 131 | <br> |
| 128 | 132 | <a href="javascript:self.close();"></a>'; |
| 133 | + } |
|
| 129 | 134 | |
| 130 | 135 | echo ' |
| 131 | 136 | </div><!-- .roundframe --> |
@@ -148,11 +153,12 @@ discard block |
||
| 148 | 153 | </div> |
| 149 | 154 | <div class="roundframe noup">'; |
| 150 | 155 | |
| 151 | - if (!empty($context['tfa_error']) || !empty($context['tfa_backup_error'])) |
|
| 152 | - echo ' |
|
| 156 | + if (!empty($context['tfa_error']) || !empty($context['tfa_backup_error'])) { |
|
| 157 | + echo ' |
|
| 153 | 158 | <div class="error"> |
| 154 | 159 | ', $txt['tfa_' . (!empty($context['tfa_error']) ? 'code_' : 'backup_') . 'invalid'], ' |
| 155 | 160 | </div>'; |
| 161 | + } |
|
| 156 | 162 | |
| 157 | 163 | echo ' |
| 158 | 164 | <form action="', $context['tfa_url'], '" method="post" id="frmTfa"> |
@@ -181,8 +187,8 @@ discard block |
||
| 181 | 187 | <script> |
| 182 | 188 | form = $("#frmTfa");'; |
| 183 | 189 | |
| 184 | - if (!empty($context['from_ajax'])) |
|
| 185 | - echo ' |
|
| 190 | + if (!empty($context['from_ajax'])) { |
|
| 191 | + echo ' |
|
| 186 | 192 | form.submit(function(e) { |
| 187 | 193 | // If we are submitting backup code, let normal workflow follow since it redirects a couple times into a different page |
| 188 | 194 | if (form.find("input[name=tfa_backup]:first").val().length > 0) |
@@ -201,6 +207,7 @@ discard block |
||
| 201 | 207 | |
| 202 | 208 | return false; |
| 203 | 209 | });'; |
| 210 | + } |
|
| 204 | 211 | |
| 205 | 212 | echo ' |
| 206 | 213 | form.find("input[name=backup]").click(function(e) { |
@@ -232,10 +239,11 @@ discard block |
||
| 232 | 239 | <p class="information centertext"> |
| 233 | 240 | ', empty($context['kick_message']) ? $txt['only_members_can_access'] : $context['kick_message'], '<br>'; |
| 234 | 241 | |
| 235 | - if ($context['can_register']) |
|
| 236 | - echo sprintf($txt['login_below_or_register'], $scripturl . '?action=signup', $context['forum_name_html_safe']); |
|
| 237 | - else |
|
| 238 | - echo $txt['login_below']; |
|
| 242 | + if ($context['can_register']) { |
|
| 243 | + echo sprintf($txt['login_below_or_register'], $scripturl . '?action=signup', $context['forum_name_html_safe']); |
|
| 244 | + } else { |
|
| 245 | + echo $txt['login_below']; |
|
| 246 | + } |
|
| 239 | 247 | |
| 240 | 248 | // And now the login information. |
| 241 | 249 | echo ' |
@@ -335,9 +343,10 @@ discard block |
||
| 335 | 343 | </div> |
| 336 | 344 | <div class="roundframe centertext noup">'; |
| 337 | 345 | |
| 338 | - if (!empty($context['incorrect_password'])) |
|
| 339 | - echo ' |
|
| 346 | + if (!empty($context['incorrect_password'])) { |
|
| 347 | + echo ' |
|
| 340 | 348 | <div class="error">', $txt['admin_incorrect_password'], '</div>'; |
| 349 | + } |
|
| 341 | 350 | |
| 342 | 351 | echo ' |
| 343 | 352 | <strong>', $txt['password'], ':</strong> |
@@ -378,10 +387,11 @@ discard block |
||
| 378 | 387 | <dl>'; |
| 379 | 388 | |
| 380 | 389 | // You didn't even have an ID? |
| 381 | - if (empty($context['member_id'])) |
|
| 382 | - echo ' |
|
| 390 | + if (empty($context['member_id'])) { |
|
| 391 | + echo ' |
|
| 383 | 392 | <dt>', $txt['invalid_activation_username'], ':</dt> |
| 384 | 393 | <dd><input type="text" name="user" size="30"></dd>'; |
| 394 | + } |
|
| 385 | 395 | |
| 386 | 396 | echo ' |
| 387 | 397 | <dt>', $txt['invalid_activation_retry'], ':</dt> |
@@ -418,13 +428,14 @@ discard block |
||
| 418 | 428 | <dd><input type="password" name="passwd" size="30"></dd> |
| 419 | 429 | </dl>'; |
| 420 | 430 | |
| 421 | - if ($context['can_activate']) |
|
| 422 | - echo ' |
|
| 431 | + if ($context['can_activate']) { |
|
| 432 | + echo ' |
|
| 423 | 433 | <p>', $txt['invalid_activation_known'], '</p> |
| 424 | 434 | <dl> |
| 425 | 435 | <dt>', $txt['invalid_activation_retry'], ':</dt> |
| 426 | 436 | <dd><input type="text" name="code" size="30"></dd> |
| 427 | 437 | </dl>'; |
| 438 | + } |
|
| 428 | 439 | |
| 429 | 440 | echo ' |
| 430 | 441 | <p><input type="submit" value="', $txt['invalid_activation_resend'], '" class="button"></p> |
@@ -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 | * Used for the "custom search index" option |
@@ -54,8 +55,9 @@ discard block |
||
| 54 | 55 | return; |
| 55 | 56 | } |
| 56 | 57 | |
| 57 | - if (empty($modSettings['search_custom_index_config'])) |
|
| 58 | - return; |
|
| 58 | + if (empty($modSettings['search_custom_index_config'])) { |
|
| 59 | + return; |
|
| 60 | + } |
|
| 59 | 61 | |
| 60 | 62 | $this->indexSettings = $smcFunc['json_decode']($modSettings['search_custom_index_config'], true); |
| 61 | 63 | |
@@ -117,21 +119,23 @@ discard block |
||
| 117 | 119 | |
| 118 | 120 | $subwords = text2words($word, $this->min_word_length, true); |
| 119 | 121 | |
| 120 | - if (empty($modSettings['search_force_index'])) |
|
| 121 | - $wordsSearch['words'][] = $word; |
|
| 122 | + if (empty($modSettings['search_force_index'])) { |
|
| 123 | + $wordsSearch['words'][] = $word; |
|
| 124 | + } |
|
| 122 | 125 | |
| 123 | 126 | // Excluded phrases don't benefit from being split into subwords. |
| 124 | - if (count($subwords) > 1 && $isExcluded) |
|
| 125 | - continue; |
|
| 126 | - else |
|
| 127 | + if (count($subwords) > 1 && $isExcluded) { |
|
| 128 | + continue; |
|
| 129 | + } else |
|
| 127 | 130 | { |
| 128 | 131 | foreach ($subwords as $subword) |
| 129 | 132 | { |
| 130 | 133 | if ($smcFunc['strlen']($subword) >= $this->min_word_length && !in_array($subword, $this->bannedWords)) |
| 131 | 134 | { |
| 132 | 135 | $wordsSearch['indexed_words'][] = $subword; |
| 133 | - if ($isExcluded) |
|
| 134 | - $wordsExclude[] = $subword; |
|
| 136 | + if ($isExcluded) { |
|
| 137 | + $wordsExclude[] = $subword; |
|
| 138 | + } |
|
| 135 | 139 | } |
| 136 | 140 | } |
| 137 | 141 | } |
@@ -152,8 +156,9 @@ discard block |
||
| 152 | 156 | $query_where = array(); |
| 153 | 157 | $query_params = $search_data['params']; |
| 154 | 158 | |
| 155 | - if ($query_params['id_search']) |
|
| 156 | - $query_select['id_search'] = '{int:id_search}'; |
|
| 159 | + if ($query_params['id_search']) { |
|
| 160 | + $query_select['id_search'] = '{int:id_search}'; |
|
| 161 | + } |
|
| 157 | 162 | |
| 158 | 163 | $count = 0; |
| 159 | 164 | foreach ($words['words'] as $regularWord) |
@@ -162,30 +167,37 @@ discard block |
||
| 162 | 167 | $query_params['complex_body_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($regularWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $regularWord), '\\\'') . '[[:>:]]'; |
| 163 | 168 | } |
| 164 | 169 | |
| 165 | - if ($query_params['user_query']) |
|
| 166 | - $query_where[] = '{raw:user_query}'; |
|
| 167 | - if ($query_params['board_query']) |
|
| 168 | - $query_where[] = 'm.id_board {raw:board_query}'; |
|
| 170 | + if ($query_params['user_query']) { |
|
| 171 | + $query_where[] = '{raw:user_query}'; |
|
| 172 | + } |
|
| 173 | + if ($query_params['board_query']) { |
|
| 174 | + $query_where[] = 'm.id_board {raw:board_query}'; |
|
| 175 | + } |
|
| 169 | 176 | |
| 170 | - if ($query_params['topic']) |
|
| 171 | - $query_where[] = 'm.id_topic = {int:topic}'; |
|
| 172 | - if ($query_params['min_msg_id']) |
|
| 173 | - $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
| 174 | - if ($query_params['max_msg_id']) |
|
| 175 | - $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
| 177 | + if ($query_params['topic']) { |
|
| 178 | + $query_where[] = 'm.id_topic = {int:topic}'; |
|
| 179 | + } |
|
| 180 | + if ($query_params['min_msg_id']) { |
|
| 181 | + $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
| 182 | + } |
|
| 183 | + if ($query_params['max_msg_id']) { |
|
| 184 | + $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
| 185 | + } |
|
| 176 | 186 | |
| 177 | 187 | $count = 0; |
| 178 | - if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) |
|
| 179 | - foreach ($query_params['excluded_phrases'] as $phrase) |
|
| 188 | + if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) { |
|
| 189 | + foreach ($query_params['excluded_phrases'] as $phrase) |
|
| 180 | 190 | { |
| 181 | 191 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : ' RLIKE ') . '{string:exclude_subject_phrase_' . $count . '}'; |
| 192 | + } |
|
| 182 | 193 | $query_params['exclude_subject_phrase_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($phrase, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $phrase), '\\\'') . '[[:>:]]'; |
| 183 | 194 | } |
| 184 | 195 | $count = 0; |
| 185 | - if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) |
|
| 186 | - foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
| 196 | + if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) { |
|
| 197 | + foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
| 187 | 198 | { |
| 188 | 199 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : ' RLIKE ') . '{string:exclude_subject_words_' . $count . '}'; |
| 200 | + } |
|
| 189 | 201 | $query_params['exclude_subject_words_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($excludedWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $excludedWord), '\\\'') . '[[:>:]]'; |
| 190 | 202 | } |
| 191 | 203 | |
@@ -198,8 +210,7 @@ discard block |
||
| 198 | 210 | { |
| 199 | 211 | $query_left_join[] = '{db_prefix}log_search_words AS lsw' . $numTables . ' ON (lsw' . $numTables . '.id_word = ' . $indexedWord . ' AND lsw' . $numTables . '.id_msg = m.id_msg)'; |
| 200 | 212 | $query_where[] = '(lsw' . $numTables . '.id_word IS NULL)'; |
| 201 | - } |
|
| 202 | - else |
|
| 213 | + } else |
|
| 203 | 214 | { |
| 204 | 215 | $query_inner_join[] = '{db_prefix}log_search_words AS lsw' . $numTables . ' ON (lsw' . $numTables . '.id_msg = ' . ($prev_join === 0 ? 'm' : 'lsw' . $prev_join) . '.id_msg)'; |
| 205 | 216 | $query_where[] = 'lsw' . $numTables . '.id_word = ' . $indexedWord; |
@@ -235,16 +246,18 @@ discard block |
||
| 235 | 246 | $customIndexSettings = $smcFunc['json_decode']($modSettings['search_custom_index_config'], true); |
| 236 | 247 | |
| 237 | 248 | $inserts = array(); |
| 238 | - foreach (text2words($msgOptions['body'], $customIndexSettings['bytes_per_word'], true) as $word) |
|
| 239 | - $inserts[] = array($word, $msgOptions['id']); |
|
| 249 | + foreach (text2words($msgOptions['body'], $customIndexSettings['bytes_per_word'], true) as $word) { |
|
| 250 | + $inserts[] = array($word, $msgOptions['id']); |
|
| 251 | + } |
|
| 240 | 252 | |
| 241 | - if (!empty($inserts)) |
|
| 242 | - $smcFunc['db_insert']('ignore', |
|
| 253 | + if (!empty($inserts)) { |
|
| 254 | + $smcFunc['db_insert']('ignore', |
|
| 243 | 255 | '{db_prefix}log_search_words', |
| 244 | 256 | array('id_word' => 'int', 'id_msg' => 'int'), |
| 245 | 257 | $inserts, |
| 246 | 258 | array('id_word', 'id_msg') |
| 247 | 259 | ); |
| 260 | + } |
|
| 248 | 261 | } |
| 249 | 262 | |
| 250 | 263 | /** |
@@ -287,8 +300,9 @@ discard block |
||
| 287 | 300 | if (!empty($inserted_words)) |
| 288 | 301 | { |
| 289 | 302 | $inserts = array(); |
| 290 | - foreach ($inserted_words as $word) |
|
| 291 | - $inserts[] = array($word, $msgOptions['id']); |
|
| 303 | + foreach ($inserted_words as $word) { |
|
| 304 | + $inserts[] = array($word, $msgOptions['id']); |
|
| 305 | + } |
|
| 292 | 306 | $smcFunc['db_insert']('insert', |
| 293 | 307 | '{db_prefix}log_search_words', |
| 294 | 308 | array('id_word' => 'string', 'id_msg' => 'int'), |
@@ -430,8 +430,8 @@ |
||
| 430 | 430 | $real_name = $smcFunc['db_case_sensitive'] ? 'LOWER(real_name)' : 'real_name'; |
| 431 | 431 | |
| 432 | 432 | // Searches. |
| 433 | - $member_name_search = $member_name . ' ' . $comparison . ' ' . implode( ' OR ' . $member_name . ' ' . $comparison . ' ', $names_list); |
|
| 434 | - $real_name_search = $real_name . ' ' . $comparison . ' ' . implode( ' OR ' . $real_name . ' ' . $comparison . ' ', $names_list); |
|
| 433 | + $member_name_search = $member_name . ' ' . $comparison . ' ' . implode(' OR ' . $member_name . ' ' . $comparison . ' ', $names_list); |
|
| 434 | + $real_name_search = $real_name . ' ' . $comparison . ' ' . implode(' OR ' . $real_name . ' ' . $comparison . ' ', $names_list); |
|
| 435 | 435 | |
| 436 | 436 | // Search by username, display name, and email address. |
| 437 | 437 | $request = $smcFunc['db_query']('', ' |
@@ -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 | * Sets the SMF-style login cookie and session based on the id_member and password passed. |
@@ -47,8 +48,9 @@ discard block |
||
| 47 | 48 | if (isset($_COOKIE[$cookiename])) |
| 48 | 49 | { |
| 49 | 50 | // First check for 2.1 json-format cookie |
| 50 | - if (preg_match('~^{"0":\d+,"1":"[0-9a-f]*","2":\d+,"3":"[^"]+","4":"[^"]+"~', $_COOKIE[$cookiename]) === 1) |
|
| 51 | - list(,,, $old_domain, $old_path) = $smcFunc['json_decode']($_COOKIE[$cookiename], true); |
|
| 51 | + if (preg_match('~^{"0":\d+,"1":"[0-9a-f]*","2":\d+,"3":"[^"]+","4":"[^"]+"~', $_COOKIE[$cookiename]) === 1) { |
|
| 52 | + list(,,, $old_domain, $old_path) = $smcFunc['json_decode']($_COOKIE[$cookiename], true); |
|
| 53 | + } |
|
| 52 | 54 | |
| 53 | 55 | // Legacy format (for recent 2.0 --> 2.1 upgrades) |
| 54 | 56 | elseif (preg_match('~^a:[34]:\{i:0;i:\d+;i:1;s:(0|128):"([a-fA-F0-9]{128})?";i:2;[id]:\d+;(i:3;i:\d;)?~', $_COOKIE[$cookiename]) === 1) |
@@ -58,15 +60,17 @@ discard block |
||
| 58 | 60 | $cookie_state = (empty($modSettings['localCookies']) ? 0 : 1) | (empty($modSettings['globalCookies']) ? 0 : 2); |
| 59 | 61 | |
| 60 | 62 | // Maybe we need to temporarily pretend to be using local cookies |
| 61 | - if ($cookie_state == 0 && $old_state == 1) |
|
| 62 | - list($old_domain, $old_path) = url_parts(true, false); |
|
| 63 | - else |
|
| 64 | - list($old_domain, $old_path) = url_parts($old_state & 1 > 0, $old_state & 2 > 0); |
|
| 63 | + if ($cookie_state == 0 && $old_state == 1) { |
|
| 64 | + list($old_domain, $old_path) = url_parts(true, false); |
|
| 65 | + } else { |
|
| 66 | + list($old_domain, $old_path) = url_parts($old_state & 1 > 0, $old_state & 2 > 0); |
|
| 67 | + } |
|
| 65 | 68 | } |
| 66 | 69 | |
| 67 | 70 | // Out with the old, in with the new! |
| 68 | - if (isset($old_domain) && $old_domain != $cookie_url[0] || isset($old_path) && $old_path != $cookie_url[1]) |
|
| 69 | - smf_setcookie($cookiename, $smcFunc['json_encode'](array(0, '', 0, $old_domain, $old_path), JSON_FORCE_OBJECT), 1, $old_path, $old_domain); |
|
| 71 | + if (isset($old_domain) && $old_domain != $cookie_url[0] || isset($old_path) && $old_path != $cookie_url[1]) { |
|
| 72 | + smf_setcookie($cookiename, $smcFunc['json_encode'](array(0, '', 0, $old_domain, $old_path), JSON_FORCE_OBJECT), 1, $old_path, $old_domain); |
|
| 73 | + } |
|
| 70 | 74 | } |
| 71 | 75 | |
| 72 | 76 | // Get the data and path to set it on. |
@@ -82,8 +86,9 @@ discard block |
||
| 82 | 86 | smf_setcookie($cookiename, $data, $expiry_time, $cookie_url[1], $cookie_url[0]); |
| 83 | 87 | |
| 84 | 88 | // If subdomain-independent cookies are on, unset the subdomain-dependent cookie too. |
| 85 | - if (empty($id) && !empty($modSettings['globalCookies'])) |
|
| 86 | - smf_setcookie($cookiename, $data, $expiry_time, $cookie_url[1], ''); |
|
| 89 | + if (empty($id) && !empty($modSettings['globalCookies'])) { |
|
| 90 | + smf_setcookie($cookiename, $data, $expiry_time, $cookie_url[1], ''); |
|
| 91 | + } |
|
| 87 | 92 | |
| 88 | 93 | // Any alias URLs? This is mainly for use with frames, etc. |
| 89 | 94 | if (!empty($modSettings['forum_alias_urls'])) |
@@ -99,8 +104,9 @@ discard block |
||
| 99 | 104 | |
| 100 | 105 | $cookie_url = url_parts(!empty($modSettings['localCookies']), !empty($modSettings['globalCookies'])); |
| 101 | 106 | |
| 102 | - if ($cookie_url[0] == '') |
|
| 103 | - $cookie_url[0] = strtok($alias, '/'); |
|
| 107 | + if ($cookie_url[0] == '') { |
|
| 108 | + $cookie_url[0] = strtok($alias, '/'); |
|
| 109 | + } |
|
| 104 | 110 | |
| 105 | 111 | $alias_data = $smcFunc['json_decode']($data); |
| 106 | 112 | $alias_data[3] = $cookie_url[0]; |
@@ -151,8 +157,9 @@ discard block |
||
| 151 | 157 | $identifier = $cookiename . '_tfa'; |
| 152 | 158 | $cookie_url = url_parts(!empty($modSettings['localCookies']), !empty($modSettings['globalCookies'])); |
| 153 | 159 | |
| 154 | - if ($preserve) |
|
| 155 | - $cookie_length = 81600 * 30; |
|
| 160 | + if ($preserve) { |
|
| 161 | + $cookie_length = 81600 * 30; |
|
| 162 | + } |
|
| 156 | 163 | |
| 157 | 164 | // Get the data and path to set it on. |
| 158 | 165 | $data = $smcFunc['json_encode'](empty($id) ? array(0, '', 0, $cookie_url[0], $cookie_url[1], false) : array($id, $secret, time() + $cookie_length, $cookie_url[0], $cookie_url[1], $preserve), JSON_FORCE_OBJECT); |
@@ -161,8 +168,9 @@ discard block |
||
| 161 | 168 | smf_setcookie($identifier, $data, time() + $cookie_length, $cookie_url[1], $cookie_url[0]); |
| 162 | 169 | |
| 163 | 170 | // If subdomain-independent cookies are on, unset the subdomain-dependent cookie too. |
| 164 | - if (empty($id) && !empty($modSettings['globalCookies'])) |
|
| 165 | - smf_setcookie($identifier, $data, time() + $cookie_length, $cookie_url[1], ''); |
|
| 171 | + if (empty($id) && !empty($modSettings['globalCookies'])) { |
|
| 172 | + smf_setcookie($identifier, $data, time() + $cookie_length, $cookie_url[1], ''); |
|
| 173 | + } |
|
| 166 | 174 | |
| 167 | 175 | $_COOKIE[$identifier] = $data; |
| 168 | 176 | } |
@@ -184,23 +192,28 @@ discard block |
||
| 184 | 192 | $parsed_url = parse_url($boardurl); |
| 185 | 193 | |
| 186 | 194 | // Is local cookies off? |
| 187 | - if (empty($parsed_url['path']) || !$local) |
|
| 188 | - $parsed_url['path'] = ''; |
|
| 195 | + if (empty($parsed_url['path']) || !$local) { |
|
| 196 | + $parsed_url['path'] = ''; |
|
| 197 | + } |
|
| 189 | 198 | |
| 190 | - if (!empty($modSettings['globalCookiesDomain']) && strpos($boardurl, $modSettings['globalCookiesDomain']) !== false) |
|
| 191 | - $parsed_url['host'] = $modSettings['globalCookiesDomain']; |
|
| 199 | + if (!empty($modSettings['globalCookiesDomain']) && strpos($boardurl, $modSettings['globalCookiesDomain']) !== false) { |
|
| 200 | + $parsed_url['host'] = $modSettings['globalCookiesDomain']; |
|
| 201 | + } |
|
| 192 | 202 | |
| 193 | 203 | // Globalize cookies across domains (filter out IP-addresses)? |
| 194 | - elseif ($global && preg_match('~^\d{1,3}(\.\d{1,3}){3}$~', $parsed_url['host']) == 0 && preg_match('~(?:[^\.]+\.)?([^\.]{2,}\..+)\z~i', $parsed_url['host'], $parts) == 1) |
|
| 195 | - $parsed_url['host'] = '.' . $parts[1]; |
|
| 204 | + elseif ($global && preg_match('~^\d{1,3}(\.\d{1,3}){3}$~', $parsed_url['host']) == 0 && preg_match('~(?:[^\.]+\.)?([^\.]{2,}\..+)\z~i', $parsed_url['host'], $parts) == 1) { |
|
| 205 | + $parsed_url['host'] = '.' . $parts[1]; |
|
| 206 | + } |
|
| 196 | 207 | |
| 197 | 208 | // We shouldn't use a host at all if both options are off. |
| 198 | - elseif (!$local && !$global) |
|
| 199 | - $parsed_url['host'] = ''; |
|
| 209 | + elseif (!$local && !$global) { |
|
| 210 | + $parsed_url['host'] = ''; |
|
| 211 | + } |
|
| 200 | 212 | |
| 201 | 213 | // The host also shouldn't be set if there aren't any dots in it. |
| 202 | - elseif (!isset($parsed_url['host']) || strpos($parsed_url['host'], '.') === false) |
|
| 203 | - $parsed_url['host'] = ''; |
|
| 214 | + elseif (!isset($parsed_url['host']) || strpos($parsed_url['host'], '.') === false) { |
|
| 215 | + $parsed_url['host'] = ''; |
|
| 216 | + } |
|
| 204 | 217 | |
| 205 | 218 | return array($parsed_url['host'], $parsed_url['path'] . '/'); |
| 206 | 219 | } |
@@ -219,8 +232,9 @@ discard block |
||
| 219 | 232 | createToken('login'); |
| 220 | 233 | |
| 221 | 234 | // Never redirect to an attachment |
| 222 | - if (strpos($_SERVER['REQUEST_URL'], 'dlattach') === false) |
|
| 223 | - $_SESSION['login_url'] = $_SERVER['REQUEST_URL']; |
|
| 235 | + if (strpos($_SERVER['REQUEST_URL'], 'dlattach') === false) { |
|
| 236 | + $_SESSION['login_url'] = $_SERVER['REQUEST_URL']; |
|
| 237 | + } |
|
| 224 | 238 | |
| 225 | 239 | $context['sub_template'] = 'kick_guest'; |
| 226 | 240 | $context['page_title'] = $txt['login']; |
@@ -275,10 +289,12 @@ discard block |
||
| 275 | 289 | $txt['security_wrong'] = sprintf($txt['security_wrong'], isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : $txt['unknown'], $_SERVER['HTTP_USER_AGENT'], $user_info['ip']); |
| 276 | 290 | log_error($txt['security_wrong'], 'critical'); |
| 277 | 291 | |
| 278 | - if (isset($_POST[$type . '_hash_pass'])) |
|
| 279 | - unset($_POST[$type . '_hash_pass']); |
|
| 280 | - if (isset($_POST[$type . '_pass'])) |
|
| 281 | - unset($_POST[$type . '_pass']); |
|
| 292 | + if (isset($_POST[$type . '_hash_pass'])) { |
|
| 293 | + unset($_POST[$type . '_hash_pass']); |
|
| 294 | + } |
|
| 295 | + if (isset($_POST[$type . '_pass'])) { |
|
| 296 | + unset($_POST[$type . '_pass']); |
|
| 297 | + } |
|
| 282 | 298 | |
| 283 | 299 | $context['incorrect_password'] = true; |
| 284 | 300 | } |
@@ -291,15 +307,17 @@ discard block |
||
| 291 | 307 | |
| 292 | 308 | // Now go through $_POST. Make sure the session hash is sent. |
| 293 | 309 | $_POST[$context['session_var']] = $context['session_id']; |
| 294 | - foreach ($_POST as $k => $v) |
|
| 295 | - $context['post_data'] .= adminLogin_outputPostVars($k, $v); |
|
| 310 | + foreach ($_POST as $k => $v) { |
|
| 311 | + $context['post_data'] .= adminLogin_outputPostVars($k, $v); |
|
| 312 | + } |
|
| 296 | 313 | |
| 297 | 314 | // Now we'll use the admin_login sub template of the Login template. |
| 298 | 315 | $context['sub_template'] = 'admin_login'; |
| 299 | 316 | |
| 300 | 317 | // And title the page something like "Login". |
| 301 | - if (!isset($context['page_title'])) |
|
| 302 | - $context['page_title'] = $txt['login']; |
|
| 318 | + if (!isset($context['page_title'])) { |
|
| 319 | + $context['page_title'] = $txt['login']; |
|
| 320 | + } |
|
| 303 | 321 | |
| 304 | 322 | // The type of action. |
| 305 | 323 | $context['sessionCheckType'] = $type; |
@@ -322,14 +340,15 @@ discard block |
||
| 322 | 340 | { |
| 323 | 341 | global $smcFunc; |
| 324 | 342 | |
| 325 | - if (!is_array($v)) |
|
| 326 | - return ' |
|
| 343 | + if (!is_array($v)) { |
|
| 344 | + return ' |
|
| 327 | 345 | <input type="hidden" name="' . $smcFunc['htmlspecialchars']($k) . '" value="' . strtr($v, array('"' => '"', '<' => '<', '>' => '>')) . '">'; |
| 328 | - else |
|
| 346 | + } else |
|
| 329 | 347 | { |
| 330 | 348 | $ret = ''; |
| 331 | - foreach ($v as $k2 => $v2) |
|
| 332 | - $ret .= adminLogin_outputPostVars($k . '[' . $k2 . ']', $v2); |
|
| 349 | + foreach ($v as $k2 => $v2) { |
|
| 350 | + $ret .= adminLogin_outputPostVars($k . '[' . $k2 . ']', $v2); |
|
| 351 | + } |
|
| 333 | 352 | |
| 334 | 353 | return $ret; |
| 335 | 354 | } |
@@ -356,18 +375,20 @@ discard block |
||
| 356 | 375 | foreach ($get as $k => $v) |
| 357 | 376 | { |
| 358 | 377 | // Only if it's not already in the $scripturl! |
| 359 | - if (!isset($temp[$k])) |
|
| 360 | - $query_string .= urlencode($k) . '=' . urlencode($v) . ';'; |
|
| 378 | + if (!isset($temp[$k])) { |
|
| 379 | + $query_string .= urlencode($k) . '=' . urlencode($v) . ';'; |
|
| 380 | + } |
|
| 361 | 381 | // If it changed, put it out there, but with an ampersand. |
| 362 | - elseif ($temp[$k] != $get[$k]) |
|
| 363 | - $query_string .= urlencode($k) . '=' . urlencode($v) . '&'; |
|
| 382 | + elseif ($temp[$k] != $get[$k]) { |
|
| 383 | + $query_string .= urlencode($k) . '=' . urlencode($v) . '&'; |
|
| 384 | + } |
|
| 364 | 385 | } |
| 365 | - } |
|
| 366 | - else |
|
| 386 | + } else |
|
| 367 | 387 | { |
| 368 | 388 | // Add up all the data from $_GET into get_data. |
| 369 | - foreach ($get as $k => $v) |
|
| 370 | - $query_string .= urlencode($k) . '=' . urlencode($v) . ';'; |
|
| 389 | + foreach ($get as $k => $v) { |
|
| 390 | + $query_string .= urlencode($k) . '=' . urlencode($v) . ';'; |
|
| 391 | + } |
|
| 371 | 392 | } |
| 372 | 393 | |
| 373 | 394 | $query_string = substr($query_string, 0, -1); |
@@ -390,8 +411,9 @@ discard block |
||
| 390 | 411 | global $scripturl, $user_info, $smcFunc; |
| 391 | 412 | |
| 392 | 413 | // If it's not already an array, make it one. |
| 393 | - if (!is_array($names)) |
|
| 394 | - $names = explode(',', $names); |
|
| 414 | + if (!is_array($names)) { |
|
| 415 | + $names = explode(',', $names); |
|
| 416 | + } |
|
| 395 | 417 | |
| 396 | 418 | $maybe_email = false; |
| 397 | 419 | $names_list = array(); |
@@ -403,10 +425,11 @@ discard block |
||
| 403 | 425 | $maybe_email |= strpos($name, '@') !== false; |
| 404 | 426 | |
| 405 | 427 | // Make it so standard wildcards will work. (* and ?) |
| 406 | - if ($use_wildcards) |
|
| 407 | - $names[$i] = strtr($names[$i], array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_', '\'' => ''')); |
|
| 408 | - else |
|
| 409 | - $names[$i] = strtr($names[$i], array('\'' => ''')); |
|
| 428 | + if ($use_wildcards) { |
|
| 429 | + $names[$i] = strtr($names[$i], array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_', '\'' => ''')); |
|
| 430 | + } else { |
|
| 431 | + $names[$i] = strtr($names[$i], array('\'' => ''')); |
|
| 432 | + } |
|
| 410 | 433 | |
| 411 | 434 | $names_list[] = '{string:lookup_name_' . $i . '}'; |
| 412 | 435 | $where_params['lookup_name_' . $i] = $names[$i]; |
@@ -419,11 +442,12 @@ discard block |
||
| 419 | 442 | $results = array(); |
| 420 | 443 | |
| 421 | 444 | // This ensures you can't search someones email address if you can't see it. |
| 422 | - if (($use_wildcards || $maybe_email) && allowedTo('moderate_forum')) |
|
| 423 | - $email_condition = ' |
|
| 445 | + if (($use_wildcards || $maybe_email) && allowedTo('moderate_forum')) { |
|
| 446 | + $email_condition = ' |
|
| 424 | 447 | OR (email_address ' . $comparison . ' \'' . implode('\') OR (email_address ' . $comparison . ' \'', $names) . '\')'; |
| 425 | - else |
|
| 426 | - $email_condition = ''; |
|
| 448 | + } else { |
|
| 449 | + $email_condition = ''; |
|
| 450 | + } |
|
| 427 | 451 | |
| 428 | 452 | // Get the case of the columns right - but only if we need to as things like MySQL will go slow needlessly otherwise. |
| 429 | 453 | $member_name = $smcFunc['db_case_sensitive'] ? 'LOWER(member_name)' : 'member_name'; |
@@ -482,10 +506,11 @@ discard block |
||
| 482 | 506 | $context['template_layers'] = array(); |
| 483 | 507 | $context['sub_template'] = 'find_members'; |
| 484 | 508 | |
| 485 | - if (isset($_REQUEST['search'])) |
|
| 486 | - $context['last_search'] = $smcFunc['htmlspecialchars']($_REQUEST['search'], ENT_QUOTES); |
|
| 487 | - else |
|
| 488 | - $_REQUEST['start'] = 0; |
|
| 509 | + if (isset($_REQUEST['search'])) { |
|
| 510 | + $context['last_search'] = $smcFunc['htmlspecialchars']($_REQUEST['search'], ENT_QUOTES); |
|
| 511 | + } else { |
|
| 512 | + $_REQUEST['start'] = 0; |
|
| 513 | + } |
|
| 489 | 514 | |
| 490 | 515 | // Allow the user to pass the input to be added to to the box. |
| 491 | 516 | $context['input_box_name'] = isset($_REQUEST['input']) && preg_match('~^[\w-]+$~', $_REQUEST['input']) === 1 ? $_REQUEST['input'] : 'to'; |
@@ -526,10 +551,10 @@ discard block |
||
| 526 | 551 | ); |
| 527 | 552 | |
| 528 | 553 | $context['results'] = array_slice($context['results'], $_REQUEST['start'], 7); |
| 554 | + } else { |
|
| 555 | + $context['links']['up'] = $scripturl . '?action=pm;sa=send' . (empty($_REQUEST['u']) ? '' : ';u=' . $_REQUEST['u']); |
|
| 556 | + } |
|
| 529 | 557 | } |
| 530 | - else |
|
| 531 | - $context['links']['up'] = $scripturl . '?action=pm;sa=send' . (empty($_REQUEST['u']) ? '' : ';u=' . $_REQUEST['u']); |
|
| 532 | -} |
|
| 533 | 558 | |
| 534 | 559 | /** |
| 535 | 560 | * Outputs each member name on its own line. |
@@ -545,8 +570,9 @@ discard block |
||
| 545 | 570 | $_REQUEST['search'] = trim($smcFunc['strtolower']($_REQUEST['search'])); |
| 546 | 571 | $_REQUEST['search'] = strtr($_REQUEST['search'], array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_', '&' => '&')); |
| 547 | 572 | |
| 548 | - if (function_exists('iconv')) |
|
| 549 | - header('Content-Type: text/plain; charset=UTF-8'); |
|
| 573 | + if (function_exists('iconv')) { |
|
| 574 | + header('Content-Type: text/plain; charset=UTF-8'); |
|
| 575 | + } |
|
| 550 | 576 | |
| 551 | 577 | $request = $smcFunc['db_query']('', ' |
| 552 | 578 | SELECT real_name |
@@ -566,14 +592,16 @@ discard block |
||
| 566 | 592 | if (function_exists('iconv')) |
| 567 | 593 | { |
| 568 | 594 | $utf8 = iconv($txt['lang_character_set'], 'UTF-8', $row['real_name']); |
| 569 | - if ($utf8) |
|
| 570 | - $row['real_name'] = $utf8; |
|
| 595 | + if ($utf8) { |
|
| 596 | + $row['real_name'] = $utf8; |
|
| 597 | + } |
|
| 571 | 598 | } |
| 572 | 599 | |
| 573 | 600 | $row['real_name'] = strtr($row['real_name'], array('&' => '&', '<' => '<', '>' => '>', '"' => '"')); |
| 574 | 601 | |
| 575 | - if (preg_match('~&#\d+;~', $row['real_name']) != 0) |
|
| 576 | - $row['real_name'] = preg_replace_callback('~&#(\d+);~', 'fixchar__callback', $row['real_name']); |
|
| 602 | + if (preg_match('~&#\d+;~', $row['real_name']) != 0) { |
|
| 603 | + $row['real_name'] = preg_replace_callback('~&#(\d+);~', 'fixchar__callback', $row['real_name']); |
|
| 604 | + } |
|
| 577 | 605 | |
| 578 | 606 | echo $row['real_name'], "\n"; |
| 579 | 607 | } |
@@ -630,9 +658,9 @@ discard block |
||
| 630 | 658 | |
| 631 | 659 | // Update the database... |
| 632 | 660 | updateMemberData($memID, array('member_name' => $user, 'passwd' => $newPassword_sha1)); |
| 661 | + } else { |
|
| 662 | + updateMemberData($memID, array('passwd' => $newPassword_sha1)); |
|
| 633 | 663 | } |
| 634 | - else |
|
| 635 | - updateMemberData($memID, array('passwd' => $newPassword_sha1)); |
|
| 636 | 664 | |
| 637 | 665 | call_integration_hook('integrate_reset_pass', array($old_user, $user, $newPassword)); |
| 638 | 666 | |
@@ -663,31 +691,37 @@ discard block |
||
| 663 | 691 | $errors = array(); |
| 664 | 692 | |
| 665 | 693 | // Don't use too long a name. |
| 666 | - if ($smcFunc['strlen']($username) > 25) |
|
| 667 | - $errors[] = array('lang', 'error_long_name'); |
|
| 694 | + if ($smcFunc['strlen']($username) > 25) { |
|
| 695 | + $errors[] = array('lang', 'error_long_name'); |
|
| 696 | + } |
|
| 668 | 697 | |
| 669 | 698 | // No name?! How can you register with no name? |
| 670 | - if ($username == '') |
|
| 671 | - $errors[] = array('lang', 'need_username'); |
|
| 699 | + if ($username == '') { |
|
| 700 | + $errors[] = array('lang', 'need_username'); |
|
| 701 | + } |
|
| 672 | 702 | |
| 673 | 703 | // Only these characters are permitted. |
| 674 | - if (in_array($username, array('_', '|')) || preg_match('~[<>&"\'=\\\\]~', preg_replace('~&#(?:\\d{1,7}|x[0-9a-fA-F]{1,6});~', '', $username)) != 0 || strpos($username, '[code') !== false || strpos($username, '[/code') !== false) |
|
| 675 | - $errors[] = array('lang', 'error_invalid_characters_username'); |
|
| 704 | + if (in_array($username, array('_', '|')) || preg_match('~[<>&"\'=\\\\]~', preg_replace('~&#(?:\\d{1,7}|x[0-9a-fA-F]{1,6});~', '', $username)) != 0 || strpos($username, '[code') !== false || strpos($username, '[/code') !== false) { |
|
| 705 | + $errors[] = array('lang', 'error_invalid_characters_username'); |
|
| 706 | + } |
|
| 676 | 707 | |
| 677 | - if (stristr($username, $txt['guest_title']) !== false) |
|
| 678 | - $errors[] = array('lang', 'username_reserved', 'general', array($txt['guest_title'])); |
|
| 708 | + if (stristr($username, $txt['guest_title']) !== false) { |
|
| 709 | + $errors[] = array('lang', 'username_reserved', 'general', array($txt['guest_title'])); |
|
| 710 | + } |
|
| 679 | 711 | |
| 680 | 712 | if ($check_reserved_name) |
| 681 | 713 | { |
| 682 | 714 | require_once($sourcedir . '/Subs-Members.php'); |
| 683 | - if (isReservedName($username, $memID, false)) |
|
| 684 | - $errors[] = array('done', '(' . $smcFunc['htmlspecialchars']($username) . ') ' . $txt['name_in_use']); |
|
| 715 | + if (isReservedName($username, $memID, false)) { |
|
| 716 | + $errors[] = array('done', '(' . $smcFunc['htmlspecialchars']($username) . ') ' . $txt['name_in_use']); |
|
| 717 | + } |
|
| 685 | 718 | } |
| 686 | 719 | |
| 687 | - if ($return_error) |
|
| 688 | - return $errors; |
|
| 689 | - elseif (empty($errors)) |
|
| 690 | - return null; |
|
| 720 | + if ($return_error) { |
|
| 721 | + return $errors; |
|
| 722 | + } elseif (empty($errors)) { |
|
| 723 | + return null; |
|
| 724 | + } |
|
| 691 | 725 | |
| 692 | 726 | loadLanguage('Errors'); |
| 693 | 727 | $error = $errors[0]; |
@@ -713,22 +747,26 @@ discard block |
||
| 713 | 747 | global $modSettings, $smcFunc; |
| 714 | 748 | |
| 715 | 749 | // Perform basic requirements first. |
| 716 | - if ($smcFunc['strlen']($password) < (empty($modSettings['password_strength']) ? 4 : 8)) |
|
| 717 | - return 'short'; |
|
| 750 | + if ($smcFunc['strlen']($password) < (empty($modSettings['password_strength']) ? 4 : 8)) { |
|
| 751 | + return 'short'; |
|
| 752 | + } |
|
| 718 | 753 | |
| 719 | 754 | // Is this enough? |
| 720 | - if (empty($modSettings['password_strength'])) |
|
| 721 | - return null; |
|
| 755 | + if (empty($modSettings['password_strength'])) { |
|
| 756 | + return null; |
|
| 757 | + } |
|
| 722 | 758 | |
| 723 | 759 | // Otherwise, perform the medium strength test - checking if password appears in the restricted string. |
| 724 | - if (preg_match('~\b' . preg_quote($password, '~') . '\b~', implode(' ', $restrict_in)) != 0) |
|
| 725 | - return 'restricted_words'; |
|
| 726 | - elseif ($smcFunc['strpos']($password, $username) !== false) |
|
| 727 | - return 'restricted_words'; |
|
| 760 | + if (preg_match('~\b' . preg_quote($password, '~') . '\b~', implode(' ', $restrict_in)) != 0) { |
|
| 761 | + return 'restricted_words'; |
|
| 762 | + } elseif ($smcFunc['strpos']($password, $username) !== false) { |
|
| 763 | + return 'restricted_words'; |
|
| 764 | + } |
|
| 728 | 765 | |
| 729 | 766 | // If just medium, we're done. |
| 730 | - if ($modSettings['password_strength'] == 1) |
|
| 731 | - return null; |
|
| 767 | + if ($modSettings['password_strength'] == 1) { |
|
| 768 | + return null; |
|
| 769 | + } |
|
| 732 | 770 | |
| 733 | 771 | // Otherwise, hard test next, check for numbers and letters, uppercase too. |
| 734 | 772 | $good = preg_match('~(\D\d|\d\D)~', $password) != 0; |
@@ -760,14 +798,16 @@ discard block |
||
| 760 | 798 | ) |
| 761 | 799 | ); |
| 762 | 800 | $groups = array(); |
| 763 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 764 | - $groups[] = $row['id_group']; |
|
| 801 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 802 | + $groups[] = $row['id_group']; |
|
| 803 | + } |
|
| 765 | 804 | $smcFunc['db_free_result']($request); |
| 766 | 805 | |
| 767 | - if (empty($groups)) |
|
| 768 | - $group_query = '0=1'; |
|
| 769 | - else |
|
| 770 | - $group_query = 'id_group IN (' . implode(',', $groups) . ')'; |
|
| 806 | + if (empty($groups)) { |
|
| 807 | + $group_query = '0=1'; |
|
| 808 | + } else { |
|
| 809 | + $group_query = 'id_group IN (' . implode(',', $groups) . ')'; |
|
| 810 | + } |
|
| 771 | 811 | } |
| 772 | 812 | |
| 773 | 813 | // Then, same again, just the boards this time! |
@@ -777,10 +817,11 @@ discard block |
||
| 777 | 817 | { |
| 778 | 818 | $boards = boardsAllowedTo('moderate_board', true); |
| 779 | 819 | |
| 780 | - if (empty($boards)) |
|
| 781 | - $board_query = '0=1'; |
|
| 782 | - else |
|
| 783 | - $board_query = 'id_board IN (' . implode(',', $boards) . ')'; |
|
| 820 | + if (empty($boards)) { |
|
| 821 | + $board_query = '0=1'; |
|
| 822 | + } else { |
|
| 823 | + $board_query = 'id_board IN (' . implode(',', $boards) . ')'; |
|
| 824 | + } |
|
| 784 | 825 | } |
| 785 | 826 | |
| 786 | 827 | // What boards are they the moderator of? |
@@ -795,8 +836,9 @@ discard block |
||
| 795 | 836 | 'current_member' => $user_info['id'], |
| 796 | 837 | ) |
| 797 | 838 | ); |
| 798 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 799 | - $boards_mod[] = $row['id_board']; |
|
| 839 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 840 | + $boards_mod[] = $row['id_board']; |
|
| 841 | + } |
|
| 800 | 842 | $smcFunc['db_free_result']($request); |
| 801 | 843 | |
| 802 | 844 | // Can any of the groups they're in moderate any of the boards? |
@@ -808,8 +850,9 @@ discard block |
||
| 808 | 850 | 'groups' => $user_info['groups'], |
| 809 | 851 | ) |
| 810 | 852 | ); |
| 811 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 812 | - $boards_mod[] = $row['id_board']; |
|
| 853 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 854 | + $boards_mod[] = $row['id_board']; |
|
| 855 | + } |
|
| 813 | 856 | $smcFunc['db_free_result']($request); |
| 814 | 857 | |
| 815 | 858 | // Just in case we've got duplicates here... |
@@ -854,10 +897,12 @@ discard block |
||
| 854 | 897 | global $modSettings; |
| 855 | 898 | |
| 856 | 899 | // In case a customization wants to override the default settings |
| 857 | - if ($httponly === null) |
|
| 858 | - $httponly = !empty($modSettings['httponlyCookies']); |
|
| 859 | - if ($secure === null) |
|
| 860 | - $secure = !empty($modSettings['secureCookies']); |
|
| 900 | + if ($httponly === null) { |
|
| 901 | + $httponly = !empty($modSettings['httponlyCookies']); |
|
| 902 | + } |
|
| 903 | + if ($secure === null) { |
|
| 904 | + $secure = !empty($modSettings['secureCookies']); |
|
| 905 | + } |
|
| 861 | 906 | |
| 862 | 907 | // Intercept cookie? |
| 863 | 908 | call_integration_hook('integrate_cookie', array($name, $value, $expire, $path, $domain, $secure, $httponly)); |
@@ -877,8 +922,9 @@ discard block |
||
| 877 | 922 | function hash_password($username, $password, $cost = null) |
| 878 | 923 | { |
| 879 | 924 | global $sourcedir, $smcFunc, $modSettings; |
| 880 | - if (!function_exists('password_hash')) |
|
| 881 | - require_once($sourcedir . '/Subs-Password.php'); |
|
| 925 | + if (!function_exists('password_hash')) { |
|
| 926 | + require_once($sourcedir . '/Subs-Password.php'); |
|
| 927 | + } |
|
| 882 | 928 | |
| 883 | 929 | $cost = empty($cost) ? (empty($modSettings['bcrypt_hash_cost']) ? 10 : $modSettings['bcrypt_hash_cost']) : $cost; |
| 884 | 930 | |
@@ -910,8 +956,9 @@ discard block |
||
| 910 | 956 | function hash_verify_password($username, $password, $hash) |
| 911 | 957 | { |
| 912 | 958 | global $sourcedir, $smcFunc; |
| 913 | - if (!function_exists('password_verify')) |
|
| 914 | - require_once($sourcedir . '/Subs-Password.php'); |
|
| 959 | + if (!function_exists('password_verify')) { |
|
| 960 | + require_once($sourcedir . '/Subs-Password.php'); |
|
| 961 | + } |
|
| 915 | 962 | |
| 916 | 963 | return password_verify($smcFunc['strtolower']($username) . $password, $hash); |
| 917 | 964 | } |
@@ -185,17 +185,21 @@ discard block |
||
| 185 | 185 | $tasksdir = $sourcedir . '/tasks'; |
| 186 | 186 | |
| 187 | 187 | # Make sure the paths are correct... at least try to fix them. |
| 188 | -if (!file_exists($boarddir) && file_exists(dirname(__FILE__) . '/agreement.txt')) |
|
| 188 | +if (!file_exists($boarddir) && file_exists(dirname(__FILE__) . '/agreement.txt')) { |
|
| 189 | 189 | $boarddir = dirname(__FILE__); |
| 190 | -if (!file_exists($sourcedir) && file_exists($boarddir . '/Sources')) |
|
| 190 | +} |
|
| 191 | +if (!file_exists($sourcedir) && file_exists($boarddir . '/Sources')) { |
|
| 191 | 192 | $sourcedir = $boarddir . '/Sources'; |
| 192 | -if (!file_exists($cachedir) && file_exists($boarddir . '/cache')) |
|
| 193 | +} |
|
| 194 | +if (!file_exists($cachedir) && file_exists($boarddir . '/cache')) { |
|
| 193 | 195 | $cachedir = $boarddir . '/cache'; |
| 196 | +} |
|
| 194 | 197 | |
| 195 | 198 | ########## Error-Catching ########## |
| 196 | 199 | # Note: You shouldn't touch these settings. |
| 197 | -if (file_exists($cachedir . '/db_last_error.php')) |
|
| 200 | +if (file_exists($cachedir . '/db_last_error.php')) { |
|
| 198 | 201 | include($cachedir . '/db_last_error.php'); |
| 202 | +} |
|
| 199 | 203 | |
| 200 | 204 | if (!isset($db_last_error)) |
| 201 | 205 | { |
@@ -207,10 +211,11 @@ discard block |
||
| 207 | 211 | if (file_exists(dirname(__FILE__) . '/install.php')) |
| 208 | 212 | { |
| 209 | 213 | $secure = false; |
| 210 | - if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') |
|
| 211 | - $secure = true; |
|
| 212 | - elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') |
|
| 213 | - $secure = true; |
|
| 214 | + if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { |
|
| 215 | + $secure = true; |
|
| 216 | + } elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') { |
|
| 217 | + $secure = true; |
|
| 218 | + } |
|
| 214 | 219 | |
| 215 | 220 | header('Location: http' . ($secure ? 's' : '') . '://' . (empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] . (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT']) : $_SERVER['HTTP_HOST']) . (strtr(dirname($_SERVER['PHP_SELF']), '\\', '/') == '/' ? '' : strtr(dirname($_SERVER['PHP_SELF']), '\\', '/')) . '/install.php'); exit; |
| 216 | 221 | } |