@@ -20,8 +20,9 @@ discard block |
||
20 | 20 | // ><html dir="ltr"><head><title>Error!</title></head><body>Sorry, this installer requires PHP!<div style="display: none;"> |
21 | 21 | |
22 | 22 | // Let's pull in useful classes |
23 | -if (!defined('SMF')) |
|
23 | +if (!defined('SMF')) { |
|
24 | 24 | define('SMF', 1); |
25 | +} |
|
25 | 26 | |
26 | 27 | require_once('Sources/Class-Package.php'); |
27 | 28 | |
@@ -63,10 +64,11 @@ discard block |
||
63 | 64 | |
64 | 65 | list ($charcode) = pg_fetch_row($request); |
65 | 66 | |
66 | - if ($charcode == 'UTF8') |
|
67 | - return true; |
|
68 | - else |
|
69 | - return false; |
|
67 | + if ($charcode == 'UTF8') { |
|
68 | + return true; |
|
69 | + } else { |
|
70 | + return false; |
|
71 | + } |
|
70 | 72 | }, |
71 | 73 | 'utf8_version' => '8.0', |
72 | 74 | 'utf8_version_check' => '$request = pg_query(\'SELECT version()\'); list ($version) = pg_fetch_row($request); list($pgl, $version) = explode(" ", $version); return $version;', |
@@ -76,12 +78,14 @@ discard block |
||
76 | 78 | $value = preg_replace('~[^A-Za-z0-9_\$]~', '', $value); |
77 | 79 | |
78 | 80 | // Is it reserved? |
79 | - if ($value == 'pg_') |
|
80 | - return $txt['error_db_prefix_reserved']; |
|
81 | + if ($value == 'pg_') { |
|
82 | + return $txt['error_db_prefix_reserved']; |
|
83 | + } |
|
81 | 84 | |
82 | 85 | // Is the prefix numeric? |
83 | - if (preg_match('~^\d~', $value)) |
|
84 | - return $txt['error_db_prefix_numeric']; |
|
86 | + if (preg_match('~^\d~', $value)) { |
|
87 | + return $txt['error_db_prefix_numeric']; |
|
88 | + } |
|
85 | 89 | |
86 | 90 | return true; |
87 | 91 | }, |
@@ -128,10 +132,11 @@ discard block |
||
128 | 132 | $incontext['skip'] = false; |
129 | 133 | |
130 | 134 | // Call the step and if it returns false that means pause! |
131 | - if (function_exists($step[2]) && $step[2]() === false) |
|
132 | - break; |
|
133 | - elseif (function_exists($step[2])) |
|
134 | - $incontext['current_step']++; |
|
135 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
136 | + break; |
|
137 | + } elseif (function_exists($step[2])) { |
|
138 | + $incontext['current_step']++; |
|
139 | + } |
|
135 | 140 | |
136 | 141 | // No warnings pass on. |
137 | 142 | $incontext['warning'] = ''; |
@@ -147,8 +152,9 @@ discard block |
||
147 | 152 | global $databases; |
148 | 153 | |
149 | 154 | // Just so people using older versions of PHP aren't left in the cold. |
150 | - if (!isset($_SERVER['PHP_SELF'])) |
|
151 | - $_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php'; |
|
155 | + if (!isset($_SERVER['PHP_SELF'])) { |
|
156 | + $_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php'; |
|
157 | + } |
|
152 | 158 | |
153 | 159 | // Enable error reporting. |
154 | 160 | error_reporting(E_ALL); |
@@ -164,21 +170,23 @@ discard block |
||
164 | 170 | { |
165 | 171 | ob_start(); |
166 | 172 | |
167 | - if (ini_get('session.save_handler') == 'user') |
|
168 | - @ini_set('session.save_handler', 'files'); |
|
169 | - if (function_exists('session_start')) |
|
170 | - @session_start(); |
|
171 | - } |
|
172 | - else |
|
173 | + if (ini_get('session.save_handler') == 'user') { |
|
174 | + @ini_set('session.save_handler', 'files'); |
|
175 | + } |
|
176 | + if (function_exists('session_start')) { |
|
177 | + @session_start(); |
|
178 | + } |
|
179 | + } else |
|
173 | 180 | { |
174 | 181 | ob_start('ob_gzhandler'); |
175 | 182 | |
176 | - if (ini_get('session.save_handler') == 'user') |
|
177 | - @ini_set('session.save_handler', 'files'); |
|
183 | + if (ini_get('session.save_handler') == 'user') { |
|
184 | + @ini_set('session.save_handler', 'files'); |
|
185 | + } |
|
178 | 186 | session_start(); |
179 | 187 | |
180 | - if (!headers_sent()) |
|
181 | - echo '<!DOCTYPE html> |
|
188 | + if (!headers_sent()) { |
|
189 | + echo '<!DOCTYPE html> |
|
182 | 190 | <html> |
183 | 191 | <head> |
184 | 192 | <title>', htmlspecialchars($_GET['pass_string']), '</title> |
@@ -187,14 +195,16 @@ discard block |
||
187 | 195 | <strong>', htmlspecialchars($_GET['pass_string']), '</strong> |
188 | 196 | </body> |
189 | 197 | </html>'; |
198 | + } |
|
190 | 199 | exit; |
191 | 200 | } |
192 | 201 | |
193 | 202 | // Add slashes, as long as they aren't already being added. |
194 | - if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) |
|
195 | - foreach ($_POST as $k => $v) |
|
203 | + if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) { |
|
204 | + foreach ($_POST as $k => $v) |
|
196 | 205 | if (strpos($k, 'password') === false && strpos($k, 'db_passwd') === false) |
197 | 206 | $_POST[$k] = addslashes($v); |
207 | + } |
|
198 | 208 | |
199 | 209 | // This is really quite simple; if ?delete is on the URL, delete the installer... |
200 | 210 | if (isset($_GET['delete'])) |
@@ -215,8 +225,7 @@ discard block |
||
215 | 225 | $ftp->close(); |
216 | 226 | |
217 | 227 | unset($_SESSION['installer_temp_ftp']); |
218 | - } |
|
219 | - else |
|
228 | + } else |
|
220 | 229 | { |
221 | 230 | @unlink(__FILE__); |
222 | 231 | |
@@ -237,10 +246,11 @@ discard block |
||
237 | 246 | { |
238 | 247 | // Get PHP's default timezone, if set |
239 | 248 | $ini_tz = ini_get('date.timezone'); |
240 | - if (!empty($ini_tz)) |
|
241 | - $timezone_id = $ini_tz; |
|
242 | - else |
|
243 | - $timezone_id = ''; |
|
249 | + if (!empty($ini_tz)) { |
|
250 | + $timezone_id = $ini_tz; |
|
251 | + } else { |
|
252 | + $timezone_id = ''; |
|
253 | + } |
|
244 | 254 | |
245 | 255 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
246 | 256 | if (!in_array($timezone_id, timezone_identifiers_list())) |
@@ -270,8 +280,9 @@ discard block |
||
270 | 280 | $dir = dir(dirname(__FILE__) . '/Themes/default/languages'); |
271 | 281 | while ($entry = $dir->read()) |
272 | 282 | { |
273 | - if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') |
|
274 | - $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
283 | + if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') { |
|
284 | + $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
285 | + } |
|
275 | 286 | } |
276 | 287 | $dir->close(); |
277 | 288 | } |
@@ -306,10 +317,11 @@ discard block |
||
306 | 317 | } |
307 | 318 | |
308 | 319 | // Override the language file? |
309 | - if (isset($_GET['lang_file'])) |
|
310 | - $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
311 | - elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) |
|
312 | - $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
320 | + if (isset($_GET['lang_file'])) { |
|
321 | + $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
322 | + } elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) { |
|
323 | + $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
324 | + } |
|
313 | 325 | |
314 | 326 | // Make sure it exists, if it doesn't reset it. |
315 | 327 | if (!isset($_SESSION['installer_temp_lang']) || preg_match('~[^\\w_\\-.]~', $_SESSION['installer_temp_lang']) === 1 || !file_exists(dirname(__FILE__) . '/Themes/default/languages/' . $_SESSION['installer_temp_lang'])) |
@@ -318,8 +330,9 @@ discard block |
||
318 | 330 | list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
319 | 331 | |
320 | 332 | // If we have english and some other language, use the other language. We Americans hate english :P. |
321 | - if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) |
|
322 | - list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
333 | + if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) { |
|
334 | + list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
335 | + } |
|
323 | 336 | } |
324 | 337 | |
325 | 338 | // And now include the actual language file itself. |
@@ -332,15 +345,18 @@ discard block |
||
332 | 345 | global $db_prefix, $db_connection, $sourcedir, $smcFunc, $modSettings; |
333 | 346 | global $db_server, $db_passwd, $db_type, $db_name, $db_user, $db_persist; |
334 | 347 | |
335 | - if (empty($sourcedir)) |
|
336 | - $sourcedir = dirname(__FILE__) . '/Sources'; |
|
348 | + if (empty($sourcedir)) { |
|
349 | + $sourcedir = dirname(__FILE__) . '/Sources'; |
|
350 | + } |
|
337 | 351 | |
338 | 352 | // Need this to check whether we need the database password. |
339 | 353 | require(dirname(__FILE__) . '/Settings.php'); |
340 | - if (!defined('SMF')) |
|
341 | - define('SMF', 1); |
|
342 | - if (empty($smcFunc)) |
|
343 | - $smcFunc = array(); |
|
354 | + if (!defined('SMF')) { |
|
355 | + define('SMF', 1); |
|
356 | + } |
|
357 | + if (empty($smcFunc)) { |
|
358 | + $smcFunc = array(); |
|
359 | + } |
|
344 | 360 | |
345 | 361 | $modSettings['disableQueryCheck'] = true; |
346 | 362 | |
@@ -348,8 +364,9 @@ discard block |
||
348 | 364 | if (!$db_connection) |
349 | 365 | { |
350 | 366 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
351 | - if (version_compare(PHP_VERSION, '5', '<')) |
|
352 | - require_once($sourcedir . '/Subs-Compat.php'); |
|
367 | + if (version_compare(PHP_VERSION, '5', '<')) { |
|
368 | + require_once($sourcedir . '/Subs-Compat.php'); |
|
369 | + } |
|
353 | 370 | |
354 | 371 | $db_options = array('persist' => $db_persist); |
355 | 372 | $port = ''; |
@@ -360,19 +377,20 @@ discard block |
||
360 | 377 | if ($db_type == 'mysql') |
361 | 378 | { |
362 | 379 | $port = ((int) $_POST['db_port'] == ini_get($db_type . 'default_port')) ? '' : (int) $_POST['db_port']; |
363 | - } |
|
364 | - elseif ($db_type == 'postgresql') |
|
380 | + } elseif ($db_type == 'postgresql') |
|
365 | 381 | { |
366 | 382 | // PostgreSQL doesn't have a default port setting in php.ini, so just check against the default |
367 | 383 | $port = ((int) $_POST['db_port'] == 5432) ? '' : (int) $_POST['db_port']; |
368 | 384 | } |
369 | 385 | } |
370 | 386 | |
371 | - if (!empty($port)) |
|
372 | - $db_options['port'] = $port; |
|
387 | + if (!empty($port)) { |
|
388 | + $db_options['port'] = $port; |
|
389 | + } |
|
373 | 390 | |
374 | - if (!$db_connection) |
|
375 | - $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options); |
|
391 | + if (!$db_connection) { |
|
392 | + $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options); |
|
393 | + } |
|
376 | 394 | } |
377 | 395 | } |
378 | 396 | |
@@ -400,8 +418,9 @@ discard block |
||
400 | 418 | // @todo REMOVE THIS!! |
401 | 419 | else |
402 | 420 | { |
403 | - if (function_exists('doStep' . $_GET['step'])) |
|
404 | - call_user_func('doStep' . $_GET['step']); |
|
421 | + if (function_exists('doStep' . $_GET['step'])) { |
|
422 | + call_user_func('doStep' . $_GET['step']); |
|
423 | + } |
|
405 | 424 | } |
406 | 425 | // Show the footer. |
407 | 426 | template_install_below(); |
@@ -419,8 +438,9 @@ discard block |
||
419 | 438 | $incontext['sub_template'] = 'welcome_message'; |
420 | 439 | |
421 | 440 | // Done the submission? |
422 | - if (isset($_POST['contbutt'])) |
|
423 | - return true; |
|
441 | + if (isset($_POST['contbutt'])) { |
|
442 | + return true; |
|
443 | + } |
|
424 | 444 | |
425 | 445 | // See if we think they have already installed it? |
426 | 446 | if (is_readable(dirname(__FILE__) . '/Settings.php')) |
@@ -428,14 +448,17 @@ discard block |
||
428 | 448 | $probably_installed = 0; |
429 | 449 | foreach (file(dirname(__FILE__) . '/Settings.php') as $line) |
430 | 450 | { |
431 | - if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) |
|
432 | - $probably_installed++; |
|
433 | - if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) |
|
434 | - $probably_installed++; |
|
451 | + if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) { |
|
452 | + $probably_installed++; |
|
453 | + } |
|
454 | + if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) { |
|
455 | + $probably_installed++; |
|
456 | + } |
|
435 | 457 | } |
436 | 458 | |
437 | - if ($probably_installed == 2) |
|
438 | - $incontext['warning'] = $txt['error_already_installed']; |
|
459 | + if ($probably_installed == 2) { |
|
460 | + $incontext['warning'] = $txt['error_already_installed']; |
|
461 | + } |
|
439 | 462 | } |
440 | 463 | |
441 | 464 | // Is some database support even compiled in? |
@@ -450,36 +473,43 @@ discard block |
||
450 | 473 | $databases[$key]['supported'] = false; |
451 | 474 | $notFoundSQLFile = true; |
452 | 475 | $txt['error_db_script_missing'] = sprintf($txt['error_db_script_missing'], 'install_' . $GLOBALS['db_script_version'] . '_' . $type . '.sql'); |
476 | + } else { |
|
477 | + $incontext['supported_databases'][] = $db; |
|
453 | 478 | } |
454 | - else |
|
455 | - $incontext['supported_databases'][] = $db; |
|
456 | 479 | } |
457 | 480 | } |
458 | 481 | |
459 | 482 | // Check the PHP version. |
460 | - if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>'))) |
|
461 | - $error = 'error_php_too_low'; |
|
483 | + if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>'))) { |
|
484 | + $error = 'error_php_too_low'; |
|
485 | + } |
|
462 | 486 | // Make sure we have a supported database |
463 | - elseif (empty($incontext['supported_databases'])) |
|
464 | - $error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing'; |
|
487 | + elseif (empty($incontext['supported_databases'])) { |
|
488 | + $error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing'; |
|
489 | + } |
|
465 | 490 | // How about session support? Some crazy sysadmin remove it? |
466 | - elseif (!function_exists('session_start')) |
|
467 | - $error = 'error_session_missing'; |
|
491 | + elseif (!function_exists('session_start')) { |
|
492 | + $error = 'error_session_missing'; |
|
493 | + } |
|
468 | 494 | // Make sure they uploaded all the files. |
469 | - elseif (!file_exists(dirname(__FILE__) . '/index.php')) |
|
470 | - $error = 'error_missing_files'; |
|
495 | + elseif (!file_exists(dirname(__FILE__) . '/index.php')) { |
|
496 | + $error = 'error_missing_files'; |
|
497 | + } |
|
471 | 498 | // Very simple check on the session.save_path for Windows. |
472 | 499 | // @todo Move this down later if they don't use database-driven sessions? |
473 | - elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') |
|
474 | - $error = 'error_session_save_path'; |
|
500 | + elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') { |
|
501 | + $error = 'error_session_save_path'; |
|
502 | + } |
|
475 | 503 | |
476 | 504 | // Since each of the three messages would look the same, anyway... |
477 | - if (isset($error)) |
|
478 | - $incontext['error'] = $txt[$error]; |
|
505 | + if (isset($error)) { |
|
506 | + $incontext['error'] = $txt[$error]; |
|
507 | + } |
|
479 | 508 | |
480 | 509 | // Mod_security blocks everything that smells funny. Let SMF handle security. |
481 | - if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) |
|
482 | - $incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again']; |
|
510 | + if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) { |
|
511 | + $incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again']; |
|
512 | + } |
|
483 | 513 | |
484 | 514 | return false; |
485 | 515 | } |
@@ -505,12 +535,14 @@ discard block |
||
505 | 535 | 'db_last_error.php', |
506 | 536 | ); |
507 | 537 | |
508 | - foreach ($incontext['detected_languages'] as $lang => $temp) |
|
509 | - $extra_files[] = 'Themes/default/languages/' . $lang; |
|
538 | + foreach ($incontext['detected_languages'] as $lang => $temp) { |
|
539 | + $extra_files[] = 'Themes/default/languages/' . $lang; |
|
540 | + } |
|
510 | 541 | |
511 | 542 | // With mod_security installed, we could attempt to fix it with .htaccess. |
512 | - if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) |
|
513 | - $writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.'; |
|
543 | + if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) { |
|
544 | + $writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.'; |
|
545 | + } |
|
514 | 546 | |
515 | 547 | $failed_files = array(); |
516 | 548 | |
@@ -526,12 +558,14 @@ discard block |
||
526 | 558 | @chmod(dirname(__FILE__) . '/' . $file, 0755); |
527 | 559 | |
528 | 560 | // Well, 755 hopefully worked... if not, try 777. |
529 | - if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) |
|
530 | - $failed_files[] = $file; |
|
561 | + if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) { |
|
562 | + $failed_files[] = $file; |
|
563 | + } |
|
531 | 564 | } |
532 | 565 | } |
533 | - foreach ($extra_files as $file) |
|
534 | - @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
566 | + foreach ($extra_files as $file) { |
|
567 | + @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
568 | + } |
|
535 | 569 | } |
536 | 570 | // Windows is trickier. Let's try opening for r+... |
537 | 571 | else |
@@ -541,30 +575,35 @@ discard block |
||
541 | 575 | foreach ($writable_files as $file) |
542 | 576 | { |
543 | 577 | // Folders can't be opened for write... but the index.php in them can ;) |
544 | - if (is_dir(dirname(__FILE__) . '/' . $file)) |
|
545 | - $file .= '/index.php'; |
|
578 | + if (is_dir(dirname(__FILE__) . '/' . $file)) { |
|
579 | + $file .= '/index.php'; |
|
580 | + } |
|
546 | 581 | |
547 | 582 | // Funny enough, chmod actually does do something on windows - it removes the read only attribute. |
548 | 583 | @chmod(dirname(__FILE__) . '/' . $file, 0777); |
549 | 584 | $fp = @fopen(dirname(__FILE__) . '/' . $file, 'r+'); |
550 | 585 | |
551 | 586 | // Hmm, okay, try just for write in that case... |
552 | - if (!is_resource($fp)) |
|
553 | - $fp = @fopen(dirname(__FILE__) . '/' . $file, 'w'); |
|
587 | + if (!is_resource($fp)) { |
|
588 | + $fp = @fopen(dirname(__FILE__) . '/' . $file, 'w'); |
|
589 | + } |
|
554 | 590 | |
555 | - if (!is_resource($fp)) |
|
556 | - $failed_files[] = $file; |
|
591 | + if (!is_resource($fp)) { |
|
592 | + $failed_files[] = $file; |
|
593 | + } |
|
557 | 594 | |
558 | 595 | @fclose($fp); |
559 | 596 | } |
560 | - foreach ($extra_files as $file) |
|
561 | - @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
597 | + foreach ($extra_files as $file) { |
|
598 | + @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
599 | + } |
|
562 | 600 | } |
563 | 601 | |
564 | 602 | $failure = count($failed_files) >= 1; |
565 | 603 | |
566 | - if (!isset($_SERVER)) |
|
567 | - return !$failure; |
|
604 | + if (!isset($_SERVER)) { |
|
605 | + return !$failure; |
|
606 | + } |
|
568 | 607 | |
569 | 608 | // Put the list into context. |
570 | 609 | $incontext['failed_files'] = $failed_files; |
@@ -612,19 +651,23 @@ discard block |
||
612 | 651 | |
613 | 652 | if (!isset($ftp) || $ftp->error !== false) |
614 | 653 | { |
615 | - if (!isset($ftp)) |
|
616 | - $ftp = new ftp_connection(null); |
|
654 | + if (!isset($ftp)) { |
|
655 | + $ftp = new ftp_connection(null); |
|
656 | + } |
|
617 | 657 | // Save the error so we can mess with listing... |
618 | - elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) |
|
619 | - $incontext['ftp_errors'][] = $ftp->last_message; |
|
658 | + elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) { |
|
659 | + $incontext['ftp_errors'][] = $ftp->last_message; |
|
660 | + } |
|
620 | 661 | |
621 | 662 | list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__)); |
622 | 663 | |
623 | - if (empty($_POST['ftp_path']) && $found_path) |
|
624 | - $_POST['ftp_path'] = $detect_path; |
|
664 | + if (empty($_POST['ftp_path']) && $found_path) { |
|
665 | + $_POST['ftp_path'] = $detect_path; |
|
666 | + } |
|
625 | 667 | |
626 | - if (!isset($_POST['ftp_username'])) |
|
627 | - $_POST['ftp_username'] = $username; |
|
668 | + if (!isset($_POST['ftp_username'])) { |
|
669 | + $_POST['ftp_username'] = $username; |
|
670 | + } |
|
628 | 671 | |
629 | 672 | // Set the username etc, into context. |
630 | 673 | $incontext['ftp'] = array( |
@@ -636,8 +679,7 @@ discard block |
||
636 | 679 | ); |
637 | 680 | |
638 | 681 | return false; |
639 | - } |
|
640 | - else |
|
682 | + } else |
|
641 | 683 | { |
642 | 684 | $_SESSION['installer_temp_ftp'] = array( |
643 | 685 | 'server' => $_POST['ftp_server'], |
@@ -651,10 +693,12 @@ discard block |
||
651 | 693 | |
652 | 694 | foreach ($failed_files as $file) |
653 | 695 | { |
654 | - if (!is_writable(dirname(__FILE__) . '/' . $file)) |
|
655 | - $ftp->chmod($file, 0755); |
|
656 | - if (!is_writable(dirname(__FILE__) . '/' . $file)) |
|
657 | - $ftp->chmod($file, 0777); |
|
696 | + if (!is_writable(dirname(__FILE__) . '/' . $file)) { |
|
697 | + $ftp->chmod($file, 0755); |
|
698 | + } |
|
699 | + if (!is_writable(dirname(__FILE__) . '/' . $file)) { |
|
700 | + $ftp->chmod($file, 0777); |
|
701 | + } |
|
658 | 702 | if (!is_writable(dirname(__FILE__) . '/' . $file)) |
659 | 703 | { |
660 | 704 | $failed_files_updated[] = $file; |
@@ -710,15 +754,17 @@ discard block |
||
710 | 754 | |
711 | 755 | if (!$foundOne) |
712 | 756 | { |
713 | - if (isset($db['default_host'])) |
|
714 | - $incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost'; |
|
757 | + if (isset($db['default_host'])) { |
|
758 | + $incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost'; |
|
759 | + } |
|
715 | 760 | if (isset($db['default_user'])) |
716 | 761 | { |
717 | 762 | $incontext['db']['user'] = ini_get($db['default_user']); |
718 | 763 | $incontext['db']['name'] = ini_get($db['default_user']); |
719 | 764 | } |
720 | - if (isset($db['default_password'])) |
|
721 | - $incontext['db']['pass'] = ini_get($db['default_password']); |
|
765 | + if (isset($db['default_password'])) { |
|
766 | + $incontext['db']['pass'] = ini_get($db['default_password']); |
|
767 | + } |
|
722 | 768 | |
723 | 769 | // For simplicity and less confusion, leave the port blank by default |
724 | 770 | $incontext['db']['port'] = ''; |
@@ -737,10 +783,10 @@ discard block |
||
737 | 783 | $incontext['db']['server'] = $_POST['db_server']; |
738 | 784 | $incontext['db']['prefix'] = $_POST['db_prefix']; |
739 | 785 | |
740 | - if (!empty($_POST['db_port'])) |
|
741 | - $incontext['db']['port'] = $_POST['db_port']; |
|
742 | - } |
|
743 | - else |
|
786 | + if (!empty($_POST['db_port'])) { |
|
787 | + $incontext['db']['port'] = $_POST['db_port']; |
|
788 | + } |
|
789 | + } else |
|
744 | 790 | { |
745 | 791 | $incontext['db']['prefix'] = 'smf_'; |
746 | 792 | } |
@@ -776,10 +822,11 @@ discard block |
||
776 | 822 | if (!empty($_POST['db_port'])) |
777 | 823 | { |
778 | 824 | // For MySQL, we can get the "default port" from PHP. PostgreSQL has no such option though. |
779 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) |
|
780 | - $vars['db_port'] = (int) $_POST['db_port']; |
|
781 | - elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) |
|
782 | - $vars['db_port'] = (int) $_POST['db_port']; |
|
825 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) { |
|
826 | + $vars['db_port'] = (int) $_POST['db_port']; |
|
827 | + } elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) { |
|
828 | + $vars['db_port'] = (int) $_POST['db_port']; |
|
829 | + } |
|
783 | 830 | } |
784 | 831 | |
785 | 832 | // God I hope it saved! |
@@ -792,8 +839,9 @@ discard block |
||
792 | 839 | // Make sure it works. |
793 | 840 | require(dirname(__FILE__) . '/Settings.php'); |
794 | 841 | |
795 | - if (empty($sourcedir)) |
|
796 | - $sourcedir = dirname(__FILE__) . '/Sources'; |
|
842 | + if (empty($sourcedir)) { |
|
843 | + $sourcedir = dirname(__FILE__) . '/Sources'; |
|
844 | + } |
|
797 | 845 | |
798 | 846 | // Better find the database file! |
799 | 847 | if (!file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
@@ -803,18 +851,21 @@ discard block |
||
803 | 851 | } |
804 | 852 | |
805 | 853 | // Now include it for database functions! |
806 | - if (!defined('SMF')) |
|
807 | - define('SMF', 1); |
|
854 | + if (!defined('SMF')) { |
|
855 | + define('SMF', 1); |
|
856 | + } |
|
808 | 857 | |
809 | 858 | $modSettings['disableQueryCheck'] = true; |
810 | - if (empty($smcFunc)) |
|
811 | - $smcFunc = array(); |
|
859 | + if (empty($smcFunc)) { |
|
860 | + $smcFunc = array(); |
|
861 | + } |
|
812 | 862 | |
813 | 863 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
814 | 864 | |
815 | 865 | // What - running PHP4? The shame! |
816 | - if (version_compare(PHP_VERSION, '5', '<')) |
|
817 | - require_once($sourcedir . '/Subs-Compat.php'); |
|
866 | + if (version_compare(PHP_VERSION, '5', '<')) { |
|
867 | + require_once($sourcedir . '/Subs-Compat.php'); |
|
868 | + } |
|
818 | 869 | |
819 | 870 | // Attempt a connection. |
820 | 871 | $needsDB = !empty($databases[$db_type]['always_has_db']); |
@@ -902,12 +953,14 @@ discard block |
||
902 | 953 | $incontext['page_title'] = $txt['install_settings']; |
903 | 954 | |
904 | 955 | // Let's see if we got the database type correct. |
905 | - if (isset($_POST['db_type'], $databases[$_POST['db_type']])) |
|
906 | - $db_type = $_POST['db_type']; |
|
956 | + if (isset($_POST['db_type'], $databases[$_POST['db_type']])) { |
|
957 | + $db_type = $_POST['db_type']; |
|
958 | + } |
|
907 | 959 | |
908 | 960 | // Else we'd better be able to get the connection. |
909 | - else |
|
910 | - load_database(); |
|
961 | + else { |
|
962 | + load_database(); |
|
963 | + } |
|
911 | 964 | |
912 | 965 | $db_type = isset($_POST['db_type']) ? $_POST['db_type'] : $db_type; |
913 | 966 | |
@@ -927,12 +980,14 @@ discard block |
||
927 | 980 | // Submitting? |
928 | 981 | if (isset($_POST['boardurl'])) |
929 | 982 | { |
930 | - if (substr($_POST['boardurl'], -10) == '/index.php') |
|
931 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
932 | - elseif (substr($_POST['boardurl'], -1) == '/') |
|
933 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
934 | - if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') |
|
935 | - $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
983 | + if (substr($_POST['boardurl'], -10) == '/index.php') { |
|
984 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
985 | + } elseif (substr($_POST['boardurl'], -1) == '/') { |
|
986 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
987 | + } |
|
988 | + if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') { |
|
989 | + $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
990 | + } |
|
936 | 991 | |
937 | 992 | // Save these variables. |
938 | 993 | $vars = array( |
@@ -969,10 +1024,10 @@ discard block |
||
969 | 1024 | { |
970 | 1025 | $incontext['error'] = sprintf($txt['error_utf8_version'], $databases[$db_type]['utf8_version']); |
971 | 1026 | return false; |
972 | - } |
|
973 | - else |
|
974 | - // Set the character set here. |
|
1027 | + } else { |
|
1028 | + // Set the character set here. |
|
975 | 1029 | updateSettingsFile(array('db_character_set' => 'utf8')); |
1030 | + } |
|
976 | 1031 | } |
977 | 1032 | |
978 | 1033 | // Good, skip on. |
@@ -992,8 +1047,9 @@ discard block |
||
992 | 1047 | $incontext['continue'] = 1; |
993 | 1048 | |
994 | 1049 | // Already done? |
995 | - if (isset($_POST['pop_done'])) |
|
996 | - return true; |
|
1050 | + if (isset($_POST['pop_done'])) { |
|
1051 | + return true; |
|
1052 | + } |
|
997 | 1053 | |
998 | 1054 | // Reload settings. |
999 | 1055 | require(dirname(__FILE__) . '/Settings.php'); |
@@ -1011,8 +1067,9 @@ discard block |
||
1011 | 1067 | $modSettings = array(); |
1012 | 1068 | if ($result !== false) |
1013 | 1069 | { |
1014 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
1015 | - $modSettings[$row['variable']] = $row['value']; |
|
1070 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
1071 | + $modSettings[$row['variable']] = $row['value']; |
|
1072 | + } |
|
1016 | 1073 | $smcFunc['db_free_result']($result); |
1017 | 1074 | |
1018 | 1075 | // Do they match? If so, this is just a refresh so charge on! |
@@ -1025,20 +1082,22 @@ discard block |
||
1025 | 1082 | $modSettings['disableQueryCheck'] = true; |
1026 | 1083 | |
1027 | 1084 | // If doing UTF8, select it. PostgreSQL requires passing it as a string... |
1028 | - if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) |
|
1029 | - $smcFunc['db_query']('', ' |
|
1085 | + if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) { |
|
1086 | + $smcFunc['db_query']('', ' |
|
1030 | 1087 | SET NAMES {string:utf8}', |
1031 | 1088 | array( |
1032 | 1089 | 'db_error_skip' => true, |
1033 | 1090 | 'utf8' => 'utf8', |
1034 | 1091 | ) |
1035 | 1092 | ); |
1093 | + } |
|
1036 | 1094 | |
1037 | 1095 | // Windows likes to leave the trailing slash, which yields to C:\path\to\SMF\/attachments... |
1038 | - if (substr(__DIR__, -1) == '\\') |
|
1039 | - $attachdir = __DIR__ . 'attachments'; |
|
1040 | - else |
|
1041 | - $attachdir = __DIR__ . '/attachments'; |
|
1096 | + if (substr(__DIR__, -1) == '\\') { |
|
1097 | + $attachdir = __DIR__ . 'attachments'; |
|
1098 | + } else { |
|
1099 | + $attachdir = __DIR__ . '/attachments'; |
|
1100 | + } |
|
1042 | 1101 | |
1043 | 1102 | $replaces = array( |
1044 | 1103 | '{$db_prefix}' => $db_prefix, |
@@ -1055,8 +1114,9 @@ discard block |
||
1055 | 1114 | |
1056 | 1115 | foreach ($txt as $key => $value) |
1057 | 1116 | { |
1058 | - if (substr($key, 0, 8) == 'default_') |
|
1059 | - $replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value); |
|
1117 | + if (substr($key, 0, 8) == 'default_') { |
|
1118 | + $replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value); |
|
1119 | + } |
|
1060 | 1120 | } |
1061 | 1121 | $replaces['{$default_reserved_names}'] = strtr($replaces['{$default_reserved_names}'], array('\\\\n' => '\\n')); |
1062 | 1122 | |
@@ -1071,8 +1131,9 @@ discard block |
||
1071 | 1131 | |
1072 | 1132 | while ($row = $smcFunc['db_fetch_assoc']($get_engines)) |
1073 | 1133 | { |
1074 | - if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') |
|
1075 | - $engines[] = $row['Engine']; |
|
1134 | + if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') { |
|
1135 | + $engines[] = $row['Engine']; |
|
1136 | + } |
|
1076 | 1137 | } |
1077 | 1138 | |
1078 | 1139 | // Done with this now |
@@ -1096,8 +1157,7 @@ discard block |
||
1096 | 1157 | $replaces['START TRANSACTION;'] = ''; |
1097 | 1158 | $replaces['COMMIT;'] = ''; |
1098 | 1159 | } |
1099 | - } |
|
1100 | - else |
|
1160 | + } else |
|
1101 | 1161 | { |
1102 | 1162 | $has_innodb = false; |
1103 | 1163 | } |
@@ -1119,21 +1179,24 @@ discard block |
||
1119 | 1179 | foreach ($sql_lines as $count => $line) |
1120 | 1180 | { |
1121 | 1181 | // No comments allowed! |
1122 | - if (substr(trim($line), 0, 1) != '#') |
|
1123 | - $current_statement .= "\n" . rtrim($line); |
|
1182 | + if (substr(trim($line), 0, 1) != '#') { |
|
1183 | + $current_statement .= "\n" . rtrim($line); |
|
1184 | + } |
|
1124 | 1185 | |
1125 | 1186 | // Is this the end of the query string? |
1126 | - if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) |
|
1127 | - continue; |
|
1187 | + if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) { |
|
1188 | + continue; |
|
1189 | + } |
|
1128 | 1190 | |
1129 | 1191 | // Does this table already exist? If so, don't insert more data into it! |
1130 | 1192 | if (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) != 0 && in_array($match[1], $exists)) |
1131 | 1193 | { |
1132 | 1194 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
1133 | - if (!empty($matches[0])) |
|
1134 | - $incontext['sql_results']['insert_dups'] += count($matches[0]); |
|
1135 | - else |
|
1136 | - $incontext['sql_results']['insert_dups']++; |
|
1195 | + if (!empty($matches[0])) { |
|
1196 | + $incontext['sql_results']['insert_dups'] += count($matches[0]); |
|
1197 | + } else { |
|
1198 | + $incontext['sql_results']['insert_dups']++; |
|
1199 | + } |
|
1137 | 1200 | |
1138 | 1201 | $current_statement = ''; |
1139 | 1202 | continue; |
@@ -1142,8 +1205,9 @@ discard block |
||
1142 | 1205 | if ($smcFunc['db_query']('', $current_statement, array('security_override' => true, 'db_error_skip' => true), $db_connection) === false) |
1143 | 1206 | { |
1144 | 1207 | // Use the appropriate function based on the DB type |
1145 | - if ($db_type == 'mysql' || $db_type == 'mysqli') |
|
1146 | - $db_errorno = $db_type . '_errno'; |
|
1208 | + if ($db_type == 'mysql' || $db_type == 'mysqli') { |
|
1209 | + $db_errorno = $db_type . '_errno'; |
|
1210 | + } |
|
1147 | 1211 | |
1148 | 1212 | // Error 1050: Table already exists! |
1149 | 1213 | // @todo Needs to be made better! |
@@ -1158,18 +1222,18 @@ discard block |
||
1158 | 1222 | // MySQLi requires a connection object. It's optional with MySQL and Postgres |
1159 | 1223 | $incontext['failures'][$count] = $smcFunc['db_error']($db_connection); |
1160 | 1224 | } |
1161 | - } |
|
1162 | - else |
|
1225 | + } else |
|
1163 | 1226 | { |
1164 | - if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
1165 | - $incontext['sql_results']['tables']++; |
|
1166 | - elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
1227 | + if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) { |
|
1228 | + $incontext['sql_results']['tables']++; |
|
1229 | + } elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
1167 | 1230 | { |
1168 | 1231 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
1169 | - if (!empty($matches[0])) |
|
1170 | - $incontext['sql_results']['inserts'] += count($matches[0]); |
|
1171 | - else |
|
1172 | - $incontext['sql_results']['inserts']++; |
|
1232 | + if (!empty($matches[0])) { |
|
1233 | + $incontext['sql_results']['inserts'] += count($matches[0]); |
|
1234 | + } else { |
|
1235 | + $incontext['sql_results']['inserts']++; |
|
1236 | + } |
|
1173 | 1237 | } |
1174 | 1238 | } |
1175 | 1239 | |
@@ -1182,15 +1246,17 @@ discard block |
||
1182 | 1246 | // Sort out the context for the SQL. |
1183 | 1247 | foreach ($incontext['sql_results'] as $key => $number) |
1184 | 1248 | { |
1185 | - if ($number == 0) |
|
1186 | - unset($incontext['sql_results'][$key]); |
|
1187 | - else |
|
1188 | - $incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number); |
|
1249 | + if ($number == 0) { |
|
1250 | + unset($incontext['sql_results'][$key]); |
|
1251 | + } else { |
|
1252 | + $incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number); |
|
1253 | + } |
|
1189 | 1254 | } |
1190 | 1255 | |
1191 | 1256 | // Make sure UTF will be used globally. |
1192 | - 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']))) |
|
1193 | - $newSettings[] = array('global_character_set', 'UTF-8'); |
|
1257 | + 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']))) { |
|
1258 | + $newSettings[] = array('global_character_set', 'UTF-8'); |
|
1259 | + } |
|
1194 | 1260 | |
1195 | 1261 | // Maybe we can auto-detect better cookie settings? |
1196 | 1262 | preg_match('~^http[s]?://([^\.]+?)([^/]*?)(/.*)?$~', $boardurl, $matches); |
@@ -1201,16 +1267,20 @@ discard block |
||
1201 | 1267 | $globalCookies = false; |
1202 | 1268 | |
1203 | 1269 | // Okay... let's see. Using a subdomain other than www.? (not a perfect check.) |
1204 | - if ($matches[2] != '' && (strpos(substr($matches[2], 1), '.') === false || in_array($matches[1], array('forum', 'board', 'community', 'forums', 'support', 'chat', 'help', 'talk', 'boards', 'www')))) |
|
1205 | - $globalCookies = true; |
|
1270 | + if ($matches[2] != '' && (strpos(substr($matches[2], 1), '.') === false || in_array($matches[1], array('forum', 'board', 'community', 'forums', 'support', 'chat', 'help', 'talk', 'boards', 'www')))) { |
|
1271 | + $globalCookies = true; |
|
1272 | + } |
|
1206 | 1273 | // If there's a / in the middle of the path, or it starts with ~... we want local. |
1207 | - if (isset($matches[3]) && strlen($matches[3]) > 3 && (substr($matches[3], 0, 2) == '/~' || strpos(substr($matches[3], 1), '/') !== false)) |
|
1208 | - $localCookies = true; |
|
1274 | + if (isset($matches[3]) && strlen($matches[3]) > 3 && (substr($matches[3], 0, 2) == '/~' || strpos(substr($matches[3], 1), '/') !== false)) { |
|
1275 | + $localCookies = true; |
|
1276 | + } |
|
1209 | 1277 | |
1210 | - if ($globalCookies) |
|
1211 | - $newSettings[] = array('globalCookies', '1'); |
|
1212 | - if ($localCookies) |
|
1213 | - $newSettings[] = array('localCookies', '1'); |
|
1278 | + if ($globalCookies) { |
|
1279 | + $newSettings[] = array('globalCookies', '1'); |
|
1280 | + } |
|
1281 | + if ($localCookies) { |
|
1282 | + $newSettings[] = array('localCookies', '1'); |
|
1283 | + } |
|
1214 | 1284 | } |
1215 | 1285 | |
1216 | 1286 | // Are we allowing stat collection? |
@@ -1226,32 +1296,36 @@ discard block |
||
1226 | 1296 | fwrite($fp, $out); |
1227 | 1297 | |
1228 | 1298 | $return_data = ''; |
1229 | - while (!feof($fp)) |
|
1230 | - $return_data .= fgets($fp, 128); |
|
1299 | + while (!feof($fp)) { |
|
1300 | + $return_data .= fgets($fp, 128); |
|
1301 | + } |
|
1231 | 1302 | |
1232 | 1303 | fclose($fp); |
1233 | 1304 | |
1234 | 1305 | // Get the unique site ID. |
1235 | 1306 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
1236 | 1307 | |
1237 | - if (!empty($ID[1])) |
|
1238 | - $newSettings[] = array('allow_sm_stats', $ID[1]); |
|
1308 | + if (!empty($ID[1])) { |
|
1309 | + $newSettings[] = array('allow_sm_stats', $ID[1]); |
|
1310 | + } |
|
1239 | 1311 | } |
1240 | 1312 | } |
1241 | 1313 | |
1242 | 1314 | // Are we enabling SSL? |
1243 | - if (!empty($_POST['force_ssl'])) |
|
1244 | - $newSettings[] = array('force_ssl', 2); |
|
1315 | + if (!empty($_POST['force_ssl'])) { |
|
1316 | + $newSettings[] = array('force_ssl', 2); |
|
1317 | + } |
|
1245 | 1318 | |
1246 | 1319 | // Setting a timezone is required. |
1247 | 1320 | if (!isset($modSettings['default_timezone']) && function_exists('date_default_timezone_set')) |
1248 | 1321 | { |
1249 | 1322 | // Get PHP's default timezone, if set |
1250 | 1323 | $ini_tz = ini_get('date.timezone'); |
1251 | - if (!empty($ini_tz)) |
|
1252 | - $timezone_id = $ini_tz; |
|
1253 | - else |
|
1254 | - $timezone_id = ''; |
|
1324 | + if (!empty($ini_tz)) { |
|
1325 | + $timezone_id = $ini_tz; |
|
1326 | + } else { |
|
1327 | + $timezone_id = ''; |
|
1328 | + } |
|
1255 | 1329 | |
1256 | 1330 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
1257 | 1331 | if (!in_array($timezone_id, timezone_identifiers_list())) |
@@ -1260,8 +1334,9 @@ discard block |
||
1260 | 1334 | $timezone_id = timezone_name_from_abbr('', $server_offset, 0); |
1261 | 1335 | } |
1262 | 1336 | |
1263 | - if (date_default_timezone_set($timezone_id)) |
|
1264 | - $newSettings[] = array('default_timezone', $timezone_id); |
|
1337 | + if (date_default_timezone_set($timezone_id)) { |
|
1338 | + $newSettings[] = array('default_timezone', $timezone_id); |
|
1339 | + } |
|
1265 | 1340 | } |
1266 | 1341 | |
1267 | 1342 | if (!empty($newSettings)) |
@@ -1292,16 +1367,18 @@ discard block |
||
1292 | 1367 | } |
1293 | 1368 | |
1294 | 1369 | // MySQL specific stuff |
1295 | - if (substr($db_type, 0, 5) != 'mysql') |
|
1296 | - return false; |
|
1370 | + if (substr($db_type, 0, 5) != 'mysql') { |
|
1371 | + return false; |
|
1372 | + } |
|
1297 | 1373 | |
1298 | 1374 | // Find database user privileges. |
1299 | 1375 | $privs = array(); |
1300 | 1376 | $get_privs = $smcFunc['db_query']('', 'SHOW PRIVILEGES', array()); |
1301 | 1377 | while ($row = $smcFunc['db_fetch_assoc']($get_privs)) |
1302 | 1378 | { |
1303 | - if ($row['Privilege'] == 'Alter') |
|
1304 | - $privs[] = $row['Privilege']; |
|
1379 | + if ($row['Privilege'] == 'Alter') { |
|
1380 | + $privs[] = $row['Privilege']; |
|
1381 | + } |
|
1305 | 1382 | } |
1306 | 1383 | $smcFunc['db_free_result']($get_privs); |
1307 | 1384 | |
@@ -1331,8 +1408,9 @@ discard block |
||
1331 | 1408 | $incontext['continue'] = 1; |
1332 | 1409 | |
1333 | 1410 | // Skipping? |
1334 | - if (!empty($_POST['skip'])) |
|
1335 | - return true; |
|
1411 | + if (!empty($_POST['skip'])) { |
|
1412 | + return true; |
|
1413 | + } |
|
1336 | 1414 | |
1337 | 1415 | // Need this to check whether we need the database password. |
1338 | 1416 | require(dirname(__FILE__) . '/Settings.php'); |
@@ -1345,18 +1423,22 @@ discard block |
||
1345 | 1423 | // We need this to properly hash the password for Admin |
1346 | 1424 | $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) { |
1347 | 1425 | global $sourcedir; |
1348 | - if (function_exists('mb_strtolower')) |
|
1349 | - return mb_strtolower($string, 'UTF-8'); |
|
1426 | + if (function_exists('mb_strtolower')) { |
|
1427 | + return mb_strtolower($string, 'UTF-8'); |
|
1428 | + } |
|
1350 | 1429 | require_once($sourcedir . '/Subs-Charset.php'); |
1351 | 1430 | return utf8_strtolower($string); |
1352 | 1431 | }; |
1353 | 1432 | |
1354 | - if (!isset($_POST['username'])) |
|
1355 | - $_POST['username'] = ''; |
|
1356 | - if (!isset($_POST['email'])) |
|
1357 | - $_POST['email'] = ''; |
|
1358 | - if (!isset($_POST['server_email'])) |
|
1359 | - $_POST['server_email'] = ''; |
|
1433 | + if (!isset($_POST['username'])) { |
|
1434 | + $_POST['username'] = ''; |
|
1435 | + } |
|
1436 | + if (!isset($_POST['email'])) { |
|
1437 | + $_POST['email'] = ''; |
|
1438 | + } |
|
1439 | + if (!isset($_POST['server_email'])) { |
|
1440 | + $_POST['server_email'] = ''; |
|
1441 | + } |
|
1360 | 1442 | |
1361 | 1443 | $incontext['username'] = htmlspecialchars(stripslashes($_POST['username'])); |
1362 | 1444 | $incontext['email'] = htmlspecialchars(stripslashes($_POST['email'])); |
@@ -1375,8 +1457,9 @@ discard block |
||
1375 | 1457 | 'admin_group' => 1, |
1376 | 1458 | ) |
1377 | 1459 | ); |
1378 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
1379 | - $incontext['skip'] = 1; |
|
1460 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
1461 | + $incontext['skip'] = 1; |
|
1462 | + } |
|
1380 | 1463 | $smcFunc['db_free_result']($request); |
1381 | 1464 | |
1382 | 1465 | // Trying to create an account? |
@@ -1407,8 +1490,9 @@ discard block |
||
1407 | 1490 | } |
1408 | 1491 | |
1409 | 1492 | // Update the webmaster's email? |
1410 | - if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) |
|
1411 | - updateSettingsFile(array('webmaster_email' => $_POST['server_email'])); |
|
1493 | + if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) { |
|
1494 | + updateSettingsFile(array('webmaster_email' => $_POST['server_email'])); |
|
1495 | + } |
|
1412 | 1496 | |
1413 | 1497 | // Work out whether we're going to have dodgy characters and remove them. |
1414 | 1498 | $invalid_characters = preg_match('~[<>&"\'=\\\]~', $_POST['username']) != 0; |
@@ -1431,32 +1515,27 @@ discard block |
||
1431 | 1515 | $smcFunc['db_free_result']($result); |
1432 | 1516 | |
1433 | 1517 | $incontext['account_existed'] = $txt['error_user_settings_taken']; |
1434 | - } |
|
1435 | - elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) |
|
1518 | + } elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) |
|
1436 | 1519 | { |
1437 | 1520 | // Try the previous step again. |
1438 | 1521 | $incontext['error'] = $_POST['username'] == '' ? $txt['error_username_left_empty'] : $txt['error_username_too_long']; |
1439 | 1522 | return false; |
1440 | - } |
|
1441 | - elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) |
|
1523 | + } elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) |
|
1442 | 1524 | { |
1443 | 1525 | // Try the previous step again. |
1444 | 1526 | $incontext['error'] = $txt['error_invalid_characters_username']; |
1445 | 1527 | return false; |
1446 | - } |
|
1447 | - elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255) |
|
1528 | + } elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255) |
|
1448 | 1529 | { |
1449 | 1530 | // One step back, this time fill out a proper admin email address. |
1450 | 1531 | $incontext['error'] = sprintf($txt['error_valid_admin_email_needed'], $_POST['username']); |
1451 | 1532 | return false; |
1452 | - } |
|
1453 | - elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255) |
|
1533 | + } elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255) |
|
1454 | 1534 | { |
1455 | 1535 | // One step back, this time fill out a proper admin email address. |
1456 | 1536 | $incontext['error'] = $txt['error_valid_server_email_needed']; |
1457 | 1537 | return false; |
1458 | - } |
|
1459 | - elseif ($_POST['username'] != '') |
|
1538 | + } elseif ($_POST['username'] != '') |
|
1460 | 1539 | { |
1461 | 1540 | $incontext['member_salt'] = substr(md5(mt_rand()), 0, 4); |
1462 | 1541 | |
@@ -1521,17 +1600,19 @@ discard block |
||
1521 | 1600 | require_once($sourcedir . '/Subs-Auth.php'); |
1522 | 1601 | |
1523 | 1602 | // Bring a warning over. |
1524 | - if (!empty($incontext['account_existed'])) |
|
1525 | - $incontext['warning'] = $incontext['account_existed']; |
|
1603 | + if (!empty($incontext['account_existed'])) { |
|
1604 | + $incontext['warning'] = $incontext['account_existed']; |
|
1605 | + } |
|
1526 | 1606 | |
1527 | - if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) |
|
1528 | - $smcFunc['db_query']('', ' |
|
1607 | + if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) { |
|
1608 | + $smcFunc['db_query']('', ' |
|
1529 | 1609 | SET NAMES {string:db_character_set}', |
1530 | 1610 | array( |
1531 | 1611 | 'db_character_set' => $db_character_set, |
1532 | 1612 | 'db_error_skip' => true, |
1533 | 1613 | ) |
1534 | 1614 | ); |
1615 | + } |
|
1535 | 1616 | |
1536 | 1617 | // As track stats is by default enabled let's add some activity. |
1537 | 1618 | $smcFunc['db_insert']('ignore', |
@@ -1552,14 +1633,16 @@ discard block |
||
1552 | 1633 | // Only proceed if we can load the data. |
1553 | 1634 | if ($request) |
1554 | 1635 | { |
1555 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
1556 | - $modSettings[$row[0]] = $row[1]; |
|
1636 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
1637 | + $modSettings[$row[0]] = $row[1]; |
|
1638 | + } |
|
1557 | 1639 | $smcFunc['db_free_result']($request); |
1558 | 1640 | } |
1559 | 1641 | |
1560 | 1642 | // Automatically log them in ;) |
1561 | - if (isset($incontext['member_id']) && isset($incontext['member_salt'])) |
|
1562 | - setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt'])); |
|
1643 | + if (isset($incontext['member_id']) && isset($incontext['member_salt'])) { |
|
1644 | + setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt'])); |
|
1645 | + } |
|
1563 | 1646 | |
1564 | 1647 | $result = $smcFunc['db_query']('', ' |
1565 | 1648 | SELECT value |
@@ -1570,13 +1653,14 @@ discard block |
||
1570 | 1653 | 'db_error_skip' => true, |
1571 | 1654 | ) |
1572 | 1655 | ); |
1573 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
1574 | - list ($db_sessions) = $smcFunc['db_fetch_row']($result); |
|
1656 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
1657 | + list ($db_sessions) = $smcFunc['db_fetch_row']($result); |
|
1658 | + } |
|
1575 | 1659 | $smcFunc['db_free_result']($result); |
1576 | 1660 | |
1577 | - if (empty($db_sessions)) |
|
1578 | - $_SESSION['admin_time'] = time(); |
|
1579 | - else |
|
1661 | + if (empty($db_sessions)) { |
|
1662 | + $_SESSION['admin_time'] = time(); |
|
1663 | + } else |
|
1580 | 1664 | { |
1581 | 1665 | $_SERVER['HTTP_USER_AGENT'] = substr($_SERVER['HTTP_USER_AGENT'], 0, 211); |
1582 | 1666 | |
@@ -1600,8 +1684,9 @@ discard block |
||
1600 | 1684 | $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : |
1601 | 1685 | function($string){ |
1602 | 1686 | global $sourcedir; |
1603 | - if (function_exists('mb_strtolower')) |
|
1604 | - return mb_strtolower($string, 'UTF-8'); |
|
1687 | + if (function_exists('mb_strtolower')) { |
|
1688 | + return mb_strtolower($string, 'UTF-8'); |
|
1689 | + } |
|
1605 | 1690 | require_once($sourcedir . '/Subs-Charset.php'); |
1606 | 1691 | return utf8_strtolower($string); |
1607 | 1692 | }; |
@@ -1617,8 +1702,9 @@ discard block |
||
1617 | 1702 | ) |
1618 | 1703 | ); |
1619 | 1704 | $context['utf8'] = $db_character_set === 'utf8' || $txt['lang_character_set'] === 'UTF-8'; |
1620 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
1621 | - updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject'])); |
|
1705 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
1706 | + updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject'])); |
|
1707 | + } |
|
1622 | 1708 | $smcFunc['db_free_result']($request); |
1623 | 1709 | |
1624 | 1710 | // Now is the perfect time to fetch the SM files. |
@@ -1637,8 +1723,9 @@ discard block |
||
1637 | 1723 | |
1638 | 1724 | // Check if we need some stupid MySQL fix. |
1639 | 1725 | $server_version = $smcFunc['db_server_info'](); |
1640 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
1641 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
1726 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
1727 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
1728 | + } |
|
1642 | 1729 | |
1643 | 1730 | // Some final context for the template. |
1644 | 1731 | $incontext['dir_still_writable'] = is_writable(dirname(__FILE__)) && substr(__FILE__, 1, 2) != ':\\'; |
@@ -1658,8 +1745,9 @@ discard block |
||
1658 | 1745 | $settingsArray = file(dirname(__FILE__) . '/Settings.php'); |
1659 | 1746 | |
1660 | 1747 | // @todo Do we just want to read the file in clean, and split it this way always? |
1661 | - if (count($settingsArray) == 1) |
|
1662 | - $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
1748 | + if (count($settingsArray) == 1) { |
|
1749 | + $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
1750 | + } |
|
1663 | 1751 | |
1664 | 1752 | for ($i = 0, $n = count($settingsArray); $i < $n; $i++) |
1665 | 1753 | { |
@@ -1674,19 +1762,22 @@ discard block |
||
1674 | 1762 | continue; |
1675 | 1763 | } |
1676 | 1764 | |
1677 | - if (trim($settingsArray[$i]) == '?' . '>') |
|
1678 | - $settingsArray[$i] = ''; |
|
1765 | + if (trim($settingsArray[$i]) == '?' . '>') { |
|
1766 | + $settingsArray[$i] = ''; |
|
1767 | + } |
|
1679 | 1768 | |
1680 | 1769 | // Don't trim or bother with it if it's not a variable. |
1681 | - if (substr($settingsArray[$i], 0, 1) != '$') |
|
1682 | - continue; |
|
1770 | + if (substr($settingsArray[$i], 0, 1) != '$') { |
|
1771 | + continue; |
|
1772 | + } |
|
1683 | 1773 | |
1684 | 1774 | $settingsArray[$i] = rtrim($settingsArray[$i]) . "\n"; |
1685 | 1775 | |
1686 | - foreach ($vars as $var => $val) |
|
1687 | - if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
1776 | + foreach ($vars as $var => $val) { |
|
1777 | + if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
1688 | 1778 | { |
1689 | 1779 | $comment = strstr($settingsArray[$i], '#'); |
1780 | + } |
|
1690 | 1781 | $settingsArray[$i] = '$' . $var . ' = \'' . $val . '\';' . ($comment != '' ? "\t\t" . $comment : "\n"); |
1691 | 1782 | unset($vars[$var]); |
1692 | 1783 | } |
@@ -1696,36 +1787,41 @@ discard block |
||
1696 | 1787 | if (!empty($vars)) |
1697 | 1788 | { |
1698 | 1789 | $settingsArray[$i++] = ''; |
1699 | - foreach ($vars as $var => $val) |
|
1700 | - $settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n"; |
|
1790 | + foreach ($vars as $var => $val) { |
|
1791 | + $settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n"; |
|
1792 | + } |
|
1701 | 1793 | } |
1702 | 1794 | |
1703 | 1795 | // Blank out the file - done to fix a oddity with some servers. |
1704 | 1796 | $fp = @fopen(dirname(__FILE__) . '/Settings.php', 'w'); |
1705 | - if (!$fp) |
|
1706 | - return false; |
|
1797 | + if (!$fp) { |
|
1798 | + return false; |
|
1799 | + } |
|
1707 | 1800 | fclose($fp); |
1708 | 1801 | |
1709 | 1802 | $fp = fopen(dirname(__FILE__) . '/Settings.php', 'r+'); |
1710 | 1803 | |
1711 | 1804 | // Gotta have one of these ;) |
1712 | - if (trim($settingsArray[0]) != '<?php') |
|
1713 | - fwrite($fp, "<?php\n"); |
|
1805 | + if (trim($settingsArray[0]) != '<?php') { |
|
1806 | + fwrite($fp, "<?php\n"); |
|
1807 | + } |
|
1714 | 1808 | |
1715 | 1809 | $lines = count($settingsArray); |
1716 | 1810 | for ($i = 0; $i < $lines - 1; $i++) |
1717 | 1811 | { |
1718 | 1812 | // Don't just write a bunch of blank lines. |
1719 | - if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') |
|
1720 | - fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
1813 | + if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') { |
|
1814 | + fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
1815 | + } |
|
1721 | 1816 | } |
1722 | 1817 | fwrite($fp, $settingsArray[$i] . '?' . '>'); |
1723 | 1818 | fclose($fp); |
1724 | 1819 | |
1725 | 1820 | // Even though on normal installations the filemtime should prevent this being used by the installer incorrectly |
1726 | 1821 | // it seems that there are times it might not. So let's MAKE it dump the cache. |
1727 | - if (function_exists('opcache_invalidate')) |
|
1728 | - opcache_invalidate(dirname(__FILE__) . '/Settings.php', true); |
|
1822 | + if (function_exists('opcache_invalidate')) { |
|
1823 | + opcache_invalidate(dirname(__FILE__) . '/Settings.php', true); |
|
1824 | + } |
|
1729 | 1825 | |
1730 | 1826 | return true; |
1731 | 1827 | } |
@@ -1750,9 +1846,9 @@ discard block |
||
1750 | 1846 | SecFilterScanPOST Off |
1751 | 1847 | </IfModule>'; |
1752 | 1848 | |
1753 | - if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) |
|
1754 | - return true; |
|
1755 | - elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess')) |
|
1849 | + if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) { |
|
1850 | + return true; |
|
1851 | + } elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess')) |
|
1756 | 1852 | { |
1757 | 1853 | $current_htaccess = implode('', file(dirname(__FILE__) . '/.htaccess')); |
1758 | 1854 | |
@@ -1764,29 +1860,28 @@ discard block |
||
1764 | 1860 | fwrite($ht_handle, $htaccess_addition); |
1765 | 1861 | fclose($ht_handle); |
1766 | 1862 | return true; |
1863 | + } else { |
|
1864 | + return false; |
|
1767 | 1865 | } |
1768 | - else |
|
1769 | - return false; |
|
1866 | + } else { |
|
1867 | + return true; |
|
1770 | 1868 | } |
1771 | - else |
|
1772 | - return true; |
|
1773 | - } |
|
1774 | - elseif (file_exists(dirname(__FILE__) . '/.htaccess')) |
|
1775 | - return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false; |
|
1776 | - elseif (is_writable(dirname(__FILE__))) |
|
1869 | + } elseif (file_exists(dirname(__FILE__) . '/.htaccess')) { |
|
1870 | + return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false; |
|
1871 | + } elseif (is_writable(dirname(__FILE__))) |
|
1777 | 1872 | { |
1778 | 1873 | if ($ht_handle = fopen(dirname(__FILE__) . '/.htaccess', 'w')) |
1779 | 1874 | { |
1780 | 1875 | fwrite($ht_handle, $htaccess_addition); |
1781 | 1876 | fclose($ht_handle); |
1782 | 1877 | return true; |
1878 | + } else { |
|
1879 | + return false; |
|
1783 | 1880 | } |
1784 | - else |
|
1881 | + } else { |
|
1785 | 1882 | return false; |
1786 | 1883 | } |
1787 | - else |
|
1788 | - return false; |
|
1789 | -} |
|
1884 | + } |
|
1790 | 1885 | |
1791 | 1886 | function template_install_above() |
1792 | 1887 | { |
@@ -1824,9 +1919,10 @@ discard block |
||
1824 | 1919 | <label for="installer_language">', $txt['installer_language'], ':</label> |
1825 | 1920 | <select id="installer_language" name="lang_file" onchange="location.href = \'', $installurl, '?lang_file=\' + this.options[this.selectedIndex].value;">'; |
1826 | 1921 | |
1827 | - foreach ($incontext['detected_languages'] as $lang => $name) |
|
1828 | - echo ' |
|
1922 | + foreach ($incontext['detected_languages'] as $lang => $name) { |
|
1923 | + echo ' |
|
1829 | 1924 | <option', isset($_SESSION['installer_temp_lang']) && $_SESSION['installer_temp_lang'] == $lang ? ' selected' : '', ' value="', $lang, '">', $name, '</option>'; |
1925 | + } |
|
1830 | 1926 | |
1831 | 1927 | echo ' |
1832 | 1928 | </select> |
@@ -1846,9 +1942,10 @@ discard block |
||
1846 | 1942 | <h2>', $txt['upgrade_progress'], '</h2> |
1847 | 1943 | <ul>'; |
1848 | 1944 | |
1849 | - foreach ($incontext['steps'] as $num => $step) |
|
1850 | - echo ' |
|
1945 | + foreach ($incontext['steps'] as $num => $step) { |
|
1946 | + echo ' |
|
1851 | 1947 | <li class="', $num < $incontext['current_step'] ? 'stepdone' : ($num == $incontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
1948 | + } |
|
1852 | 1949 | |
1853 | 1950 | echo ' |
1854 | 1951 | </ul> |
@@ -1873,20 +1970,23 @@ discard block |
||
1873 | 1970 | echo ' |
1874 | 1971 | <div>'; |
1875 | 1972 | |
1876 | - if (!empty($incontext['continue'])) |
|
1877 | - echo ' |
|
1973 | + if (!empty($incontext['continue'])) { |
|
1974 | + echo ' |
|
1878 | 1975 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '" onclick="return submitThisOnce(this);" class="button_submit" />'; |
1879 | - if (!empty($incontext['skip'])) |
|
1880 | - echo ' |
|
1976 | + } |
|
1977 | + if (!empty($incontext['skip'])) { |
|
1978 | + echo ' |
|
1881 | 1979 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="return submitThisOnce(this);" class="button_submit" />'; |
1980 | + } |
|
1882 | 1981 | echo ' |
1883 | 1982 | </div>'; |
1884 | 1983 | } |
1885 | 1984 | |
1886 | 1985 | // Show the closing form tag and other data only if not in the last step |
1887 | - if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) |
|
1888 | - echo ' |
|
1986 | + if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) { |
|
1987 | + echo ' |
|
1889 | 1988 | </form>'; |
1989 | + } |
|
1890 | 1990 | |
1891 | 1991 | echo ' |
1892 | 1992 | </div> |
@@ -1921,13 +2021,15 @@ discard block |
||
1921 | 2021 | </div>'; |
1922 | 2022 | |
1923 | 2023 | // Show the warnings, or not. |
1924 | - if (template_warning_divs()) |
|
1925 | - echo ' |
|
2024 | + if (template_warning_divs()) { |
|
2025 | + echo ' |
|
1926 | 2026 | <h3>', $txt['install_all_lovely'], '</h3>'; |
2027 | + } |
|
1927 | 2028 | |
1928 | 2029 | // Say we want the continue button! |
1929 | - if (empty($incontext['error'])) |
|
1930 | - $incontext['continue'] = 1; |
|
2030 | + if (empty($incontext['error'])) { |
|
2031 | + $incontext['continue'] = 1; |
|
2032 | + } |
|
1931 | 2033 | |
1932 | 2034 | // For the latest version stuff. |
1933 | 2035 | echo ' |
@@ -1961,8 +2063,8 @@ discard block |
||
1961 | 2063 | global $txt, $incontext; |
1962 | 2064 | |
1963 | 2065 | // Errors are very serious.. |
1964 | - if (!empty($incontext['error'])) |
|
1965 | - echo ' |
|
2066 | + if (!empty($incontext['error'])) { |
|
2067 | + echo ' |
|
1966 | 2068 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
1967 | 2069 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
1968 | 2070 | <strong style="text-decoration: underline;">', $txt['upgrade_critical_error'], '</strong><br> |
@@ -1970,9 +2072,10 @@ discard block |
||
1970 | 2072 | ', $incontext['error'], ' |
1971 | 2073 | </div> |
1972 | 2074 | </div>'; |
2075 | + } |
|
1973 | 2076 | // A warning message? |
1974 | - elseif (!empty($incontext['warning'])) |
|
1975 | - echo ' |
|
2077 | + elseif (!empty($incontext['warning'])) { |
|
2078 | + echo ' |
|
1976 | 2079 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
1977 | 2080 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
1978 | 2081 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -1980,6 +2083,7 @@ discard block |
||
1980 | 2083 | ', $incontext['warning'], ' |
1981 | 2084 | </div> |
1982 | 2085 | </div>'; |
2086 | + } |
|
1983 | 2087 | |
1984 | 2088 | return empty($incontext['error']) && empty($incontext['warning']); |
1985 | 2089 | } |
@@ -1995,27 +2099,30 @@ discard block |
||
1995 | 2099 | <li>', $incontext['failed_files']), '</li> |
1996 | 2100 | </ul>'; |
1997 | 2101 | |
1998 | - if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') |
|
1999 | - echo ' |
|
2102 | + if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') { |
|
2103 | + echo ' |
|
2000 | 2104 | <hr> |
2001 | 2105 | <p>', $txt['chmod_linux_info'], '</p> |
2002 | 2106 | <tt># chmod a+w ', implode(' ' . $incontext['detected_path'] . '/', $incontext['failed_files']), '</tt>'; |
2107 | + } |
|
2003 | 2108 | |
2004 | 2109 | // This is serious! |
2005 | - if (!template_warning_divs()) |
|
2006 | - return; |
|
2110 | + if (!template_warning_divs()) { |
|
2111 | + return; |
|
2112 | + } |
|
2007 | 2113 | |
2008 | 2114 | echo ' |
2009 | 2115 | <hr> |
2010 | 2116 | <p>', $txt['ftp_setup_info'], '</p>'; |
2011 | 2117 | |
2012 | - if (!empty($incontext['ftp_errors'])) |
|
2013 | - echo ' |
|
2118 | + if (!empty($incontext['ftp_errors'])) { |
|
2119 | + echo ' |
|
2014 | 2120 | <div class="error_message"> |
2015 | 2121 | ', $txt['error_ftp_no_connect'], '<br><br> |
2016 | 2122 | <code>', implode('<br>', $incontext['ftp_errors']), '</code> |
2017 | 2123 | </div> |
2018 | 2124 | <br>'; |
2125 | + } |
|
2019 | 2126 | |
2020 | 2127 | echo ' |
2021 | 2128 | <form action="', $incontext['form_url'], '" method="post"> |
@@ -2075,17 +2182,17 @@ discard block |
||
2075 | 2182 | <td> |
2076 | 2183 | <select name="db_type" id="db_type_input" onchange="toggleDBInput();">'; |
2077 | 2184 | |
2078 | - foreach ($incontext['supported_databases'] as $key => $db) |
|
2079 | - echo ' |
|
2185 | + foreach ($incontext['supported_databases'] as $key => $db) { |
|
2186 | + echo ' |
|
2080 | 2187 | <option value="', $key, '"', isset($_POST['db_type']) && $_POST['db_type'] == $key ? ' selected' : '', '>', $db['name'], '</option>'; |
2188 | + } |
|
2081 | 2189 | |
2082 | 2190 | echo ' |
2083 | 2191 | </select> |
2084 | 2192 | <div class="smalltext block">', $txt['db_settings_type_info'], '</div> |
2085 | 2193 | </td> |
2086 | 2194 | </tr>'; |
2087 | - } |
|
2088 | - else |
|
2195 | + } else |
|
2089 | 2196 | { |
2090 | 2197 | echo ' |
2091 | 2198 | <tr style="display: none;"> |
@@ -2277,9 +2384,10 @@ discard block |
||
2277 | 2384 | <div style="color: red;">', $txt['error_db_queries'], '</div> |
2278 | 2385 | <ul>'; |
2279 | 2386 | |
2280 | - foreach ($incontext['failures'] as $line => $fail) |
|
2281 | - echo ' |
|
2387 | + foreach ($incontext['failures'] as $line => $fail) { |
|
2388 | + echo ' |
|
2282 | 2389 | <li><strong>', $txt['error_db_queries_line'], $line + 1, ':</strong> ', nl2br(htmlspecialchars($fail)), '</li>'; |
2390 | + } |
|
2283 | 2391 | |
2284 | 2392 | echo ' |
2285 | 2393 | </ul>'; |
@@ -2340,15 +2448,16 @@ discard block |
||
2340 | 2448 | </tr> |
2341 | 2449 | </table>'; |
2342 | 2450 | |
2343 | - if ($incontext['require_db_confirm']) |
|
2344 | - echo ' |
|
2451 | + if ($incontext['require_db_confirm']) { |
|
2452 | + echo ' |
|
2345 | 2453 | <h2>', $txt['user_settings_database'], '</h2> |
2346 | 2454 | <p>', $txt['user_settings_database_info'], '</p> |
2347 | 2455 | |
2348 | 2456 | <div style="margin-bottom: 2ex; padding-', $txt['lang_rtl'] == false ? 'left' : 'right', ': 50px;"> |
2349 | 2457 | <input type="password" name="password3" size="30" class="input_password" /> |
2350 | 2458 | </div>'; |
2351 | -} |
|
2459 | + } |
|
2460 | + } |
|
2352 | 2461 | |
2353 | 2462 | // Tell them it's done, and to delete. |
2354 | 2463 | function template_delete_install() |
@@ -2361,14 +2470,15 @@ discard block |
||
2361 | 2470 | template_warning_divs(); |
2362 | 2471 | |
2363 | 2472 | // Install directory still writable? |
2364 | - if ($incontext['dir_still_writable']) |
|
2365 | - echo ' |
|
2473 | + if ($incontext['dir_still_writable']) { |
|
2474 | + echo ' |
|
2366 | 2475 | <em>', $txt['still_writable'], '</em><br> |
2367 | 2476 | <br>'; |
2477 | + } |
|
2368 | 2478 | |
2369 | 2479 | // Don't show the box if it's like 99% sure it won't work :P. |
2370 | - if ($incontext['probably_delete_install']) |
|
2371 | - echo ' |
|
2480 | + if ($incontext['probably_delete_install']) { |
|
2481 | + echo ' |
|
2372 | 2482 | <div style="margin: 1ex; font-weight: bold;"> |
2373 | 2483 | <label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete();" class="input_check" /> ', $txt['delete_installer'], !isset($_SESSION['installer_temp_ftp']) ? ' ' . $txt['delete_installer_maybe'] : '', '</label> |
2374 | 2484 | </div> |
@@ -2384,6 +2494,7 @@ discard block |
||
2384 | 2494 | } |
2385 | 2495 | </script> |
2386 | 2496 | <br>'; |
2497 | + } |
|
2387 | 2498 | |
2388 | 2499 | echo ' |
2389 | 2500 | ', sprintf($txt['go_to_your_forum'], $boardurl . '/index.php'), '<br> |