@@ -20,8 +20,9 @@ discard block |
||
20 | 20 | // ><html dir="ltr"><head><title>Error!</title></head><body>Sorry, this installer requires PHP!<div style="display: none;"> |
21 | 21 | |
22 | 22 | // Let's pull in useful classes |
23 | -if (!defined('SMF')) |
|
23 | +if (!defined('SMF')) { |
|
24 | 24 | define('SMF', 1); |
25 | +} |
|
25 | 26 | |
26 | 27 | require_once('Sources/Class-Package.php'); |
27 | 28 | |
@@ -63,10 +64,11 @@ discard block |
||
63 | 64 | |
64 | 65 | list ($charcode) = pg_fetch_row($request); |
65 | 66 | |
66 | - if ($charcode == 'UTF8') |
|
67 | - return true; |
|
68 | - else |
|
69 | - return false; |
|
67 | + if ($charcode == 'UTF8') { |
|
68 | + return true; |
|
69 | + } else { |
|
70 | + return false; |
|
71 | + } |
|
70 | 72 | }, |
71 | 73 | 'utf8_version' => '8.0', |
72 | 74 | 'utf8_version_check' => '$request = pg_query(\'SELECT version()\'); list ($version) = pg_fetch_row($request); list($pgl, $version) = explode(" ", $version); return $version;', |
@@ -76,12 +78,14 @@ discard block |
||
76 | 78 | $value = preg_replace('~[^A-Za-z0-9_\$]~', '', $value); |
77 | 79 | |
78 | 80 | // Is it reserved? |
79 | - if ($value == 'pg_') |
|
80 | - return $txt['error_db_prefix_reserved']; |
|
81 | + if ($value == 'pg_') { |
|
82 | + return $txt['error_db_prefix_reserved']; |
|
83 | + } |
|
81 | 84 | |
82 | 85 | // Is the prefix numeric? |
83 | - if (preg_match('~^\d~', $value)) |
|
84 | - return $txt['error_db_prefix_numeric']; |
|
86 | + if (preg_match('~^\d~', $value)) { |
|
87 | + return $txt['error_db_prefix_numeric']; |
|
88 | + } |
|
85 | 89 | |
86 | 90 | return true; |
87 | 91 | }, |
@@ -128,10 +132,11 @@ discard block |
||
128 | 132 | $incontext['skip'] = false; |
129 | 133 | |
130 | 134 | // Call the step and if it returns false that means pause! |
131 | - if (function_exists($step[2]) && $step[2]() === false) |
|
132 | - break; |
|
133 | - elseif (function_exists($step[2])) |
|
134 | - $incontext['current_step']++; |
|
135 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
136 | + break; |
|
137 | + } elseif (function_exists($step[2])) { |
|
138 | + $incontext['current_step']++; |
|
139 | + } |
|
135 | 140 | |
136 | 141 | // No warnings pass on. |
137 | 142 | $incontext['warning'] = ''; |
@@ -147,8 +152,9 @@ discard block |
||
147 | 152 | global $databases; |
148 | 153 | |
149 | 154 | // Just so people using older versions of PHP aren't left in the cold. |
150 | - if (!isset($_SERVER['PHP_SELF'])) |
|
151 | - $_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php'; |
|
155 | + if (!isset($_SERVER['PHP_SELF'])) { |
|
156 | + $_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php'; |
|
157 | + } |
|
152 | 158 | |
153 | 159 | // Enable error reporting for fatal errors. |
154 | 160 | error_reporting(E_ERROR | E_PARSE); |
@@ -164,21 +170,23 @@ discard block |
||
164 | 170 | { |
165 | 171 | ob_start(); |
166 | 172 | |
167 | - if (ini_get('session.save_handler') == 'user') |
|
168 | - @ini_set('session.save_handler', 'files'); |
|
169 | - if (function_exists('session_start')) |
|
170 | - @session_start(); |
|
171 | - } |
|
172 | - else |
|
173 | + if (ini_get('session.save_handler') == 'user') { |
|
174 | + @ini_set('session.save_handler', 'files'); |
|
175 | + } |
|
176 | + if (function_exists('session_start')) { |
|
177 | + @session_start(); |
|
178 | + } |
|
179 | + } else |
|
173 | 180 | { |
174 | 181 | ob_start('ob_gzhandler'); |
175 | 182 | |
176 | - if (ini_get('session.save_handler') == 'user') |
|
177 | - @ini_set('session.save_handler', 'files'); |
|
183 | + if (ini_get('session.save_handler') == 'user') { |
|
184 | + @ini_set('session.save_handler', 'files'); |
|
185 | + } |
|
178 | 186 | session_start(); |
179 | 187 | |
180 | - if (!headers_sent()) |
|
181 | - echo '<!DOCTYPE html> |
|
188 | + if (!headers_sent()) { |
|
189 | + echo '<!DOCTYPE html> |
|
182 | 190 | <html> |
183 | 191 | <head> |
184 | 192 | <title>', htmlspecialchars($_GET['pass_string']), '</title> |
@@ -187,14 +195,16 @@ discard block |
||
187 | 195 | <strong>', htmlspecialchars($_GET['pass_string']), '</strong> |
188 | 196 | </body> |
189 | 197 | </html>'; |
198 | + } |
|
190 | 199 | exit; |
191 | 200 | } |
192 | 201 | |
193 | 202 | // Add slashes, as long as they aren't already being added. |
194 | - if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) |
|
195 | - foreach ($_POST as $k => $v) |
|
203 | + if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) { |
|
204 | + foreach ($_POST as $k => $v) |
|
196 | 205 | if (strpos($k, 'password') === false && strpos($k, 'db_passwd') === false) |
197 | 206 | $_POST[$k] = addslashes($v); |
207 | + } |
|
198 | 208 | |
199 | 209 | // This is really quite simple; if ?delete is on the URL, delete the installer... |
200 | 210 | if (isset($_GET['delete'])) |
@@ -215,8 +225,7 @@ discard block |
||
215 | 225 | $ftp->close(); |
216 | 226 | |
217 | 227 | unset($_SESSION['installer_temp_ftp']); |
218 | - } |
|
219 | - else |
|
228 | + } else |
|
220 | 229 | { |
221 | 230 | @unlink(__FILE__); |
222 | 231 | |
@@ -230,10 +239,11 @@ discard block |
||
230 | 239 | // Now just redirect to a blank.png... |
231 | 240 | $secure = false; |
232 | 241 | |
233 | - if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') |
|
234 | - $secure = true; |
|
235 | - elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') |
|
236 | - $secure = true; |
|
242 | + if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { |
|
243 | + $secure = true; |
|
244 | + } elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') { |
|
245 | + $secure = true; |
|
246 | + } |
|
237 | 247 | |
238 | 248 | header('location: http' . ($secure ? 's' : '') . '://' . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT']) . dirname($_SERVER['PHP_SELF']) . '/Themes/default/images/blank.png'); |
239 | 249 | exit; |
@@ -244,10 +254,11 @@ discard block |
||
244 | 254 | { |
245 | 255 | // Get PHP's default timezone, if set |
246 | 256 | $ini_tz = ini_get('date.timezone'); |
247 | - if (!empty($ini_tz)) |
|
248 | - $timezone_id = $ini_tz; |
|
249 | - else |
|
250 | - $timezone_id = ''; |
|
257 | + if (!empty($ini_tz)) { |
|
258 | + $timezone_id = $ini_tz; |
|
259 | + } else { |
|
260 | + $timezone_id = ''; |
|
261 | + } |
|
251 | 262 | |
252 | 263 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
253 | 264 | if (!in_array($timezone_id, timezone_identifiers_list())) |
@@ -277,8 +288,9 @@ discard block |
||
277 | 288 | $dir = dir(dirname(__FILE__) . '/Themes/default/languages'); |
278 | 289 | while ($entry = $dir->read()) |
279 | 290 | { |
280 | - if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') |
|
281 | - $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
291 | + if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') { |
|
292 | + $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
293 | + } |
|
282 | 294 | } |
283 | 295 | $dir->close(); |
284 | 296 | } |
@@ -325,10 +337,11 @@ discard block |
||
325 | 337 | } |
326 | 338 | |
327 | 339 | // Override the language file? |
328 | - if (isset($_GET['lang_file'])) |
|
329 | - $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
330 | - elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) |
|
331 | - $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
340 | + if (isset($_GET['lang_file'])) { |
|
341 | + $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
342 | + } elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) { |
|
343 | + $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
344 | + } |
|
332 | 345 | |
333 | 346 | // Make sure it exists, if it doesn't reset it. |
334 | 347 | if (!isset($_SESSION['installer_temp_lang']) || preg_match('~[^\\w_\\-.]~', $_SESSION['installer_temp_lang']) === 1 || !file_exists(dirname(__FILE__) . '/Themes/default/languages/' . $_SESSION['installer_temp_lang'])) |
@@ -337,8 +350,9 @@ discard block |
||
337 | 350 | list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
338 | 351 | |
339 | 352 | // If we have english and some other language, use the other language. We Americans hate english :P. |
340 | - if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) |
|
341 | - list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
353 | + if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) { |
|
354 | + list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
355 | + } |
|
342 | 356 | } |
343 | 357 | |
344 | 358 | // And now include the actual language file itself. |
@@ -355,15 +369,18 @@ discard block |
||
355 | 369 | global $db_prefix, $db_connection, $sourcedir, $smcFunc, $modSettings, $db_port; |
356 | 370 | global $db_server, $db_passwd, $db_type, $db_name, $db_user, $db_persist, $db_mb4; |
357 | 371 | |
358 | - if (empty($sourcedir)) |
|
359 | - $sourcedir = dirname(__FILE__) . '/Sources'; |
|
372 | + if (empty($sourcedir)) { |
|
373 | + $sourcedir = dirname(__FILE__) . '/Sources'; |
|
374 | + } |
|
360 | 375 | |
361 | 376 | // Need this to check whether we need the database password. |
362 | 377 | require(dirname(__FILE__) . '/Settings.php'); |
363 | - if (!defined('SMF')) |
|
364 | - define('SMF', 1); |
|
365 | - if (empty($smcFunc)) |
|
366 | - $smcFunc = array(); |
|
378 | + if (!defined('SMF')) { |
|
379 | + define('SMF', 1); |
|
380 | + } |
|
381 | + if (empty($smcFunc)) { |
|
382 | + $smcFunc = array(); |
|
383 | + } |
|
367 | 384 | |
368 | 385 | $modSettings['disableQueryCheck'] = true; |
369 | 386 | |
@@ -374,14 +391,17 @@ discard block |
||
374 | 391 | |
375 | 392 | $options = array('persist' => $db_persist); |
376 | 393 | |
377 | - if (!empty($db_port)) |
|
378 | - $options['port'] = $db_port; |
|
394 | + if (!empty($db_port)) { |
|
395 | + $options['port'] = $db_port; |
|
396 | + } |
|
379 | 397 | |
380 | - if (!empty($db_mb4)) |
|
381 | - $options['db_mb4'] = $db_mb4; |
|
398 | + if (!empty($db_mb4)) { |
|
399 | + $options['db_mb4'] = $db_mb4; |
|
400 | + } |
|
382 | 401 | |
383 | - if (!$db_connection) |
|
384 | - $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $options); |
|
402 | + if (!$db_connection) { |
|
403 | + $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $options); |
|
404 | + } |
|
385 | 405 | } |
386 | 406 | } |
387 | 407 | |
@@ -409,8 +429,9 @@ discard block |
||
409 | 429 | // @todo REMOVE THIS!! |
410 | 430 | else |
411 | 431 | { |
412 | - if (function_exists('doStep' . $_GET['step'])) |
|
413 | - call_user_func('doStep' . $_GET['step']); |
|
432 | + if (function_exists('doStep' . $_GET['step'])) { |
|
433 | + call_user_func('doStep' . $_GET['step']); |
|
434 | + } |
|
414 | 435 | } |
415 | 436 | // Show the footer. |
416 | 437 | template_install_below(); |
@@ -428,8 +449,9 @@ discard block |
||
428 | 449 | $incontext['sub_template'] = 'welcome_message'; |
429 | 450 | |
430 | 451 | // Done the submission? |
431 | - if (isset($_POST['contbutt'])) |
|
432 | - return true; |
|
452 | + if (isset($_POST['contbutt'])) { |
|
453 | + return true; |
|
454 | + } |
|
433 | 455 | |
434 | 456 | // See if we think they have already installed it? |
435 | 457 | if (is_readable(dirname(__FILE__) . '/Settings.php')) |
@@ -437,14 +459,17 @@ discard block |
||
437 | 459 | $probably_installed = 0; |
438 | 460 | foreach (file(dirname(__FILE__) . '/Settings.php') as $line) |
439 | 461 | { |
440 | - if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) |
|
441 | - $probably_installed++; |
|
442 | - if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) |
|
443 | - $probably_installed++; |
|
462 | + if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) { |
|
463 | + $probably_installed++; |
|
464 | + } |
|
465 | + if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) { |
|
466 | + $probably_installed++; |
|
467 | + } |
|
444 | 468 | } |
445 | 469 | |
446 | - if ($probably_installed == 2) |
|
447 | - $incontext['warning'] = $txt['error_already_installed']; |
|
470 | + if ($probably_installed == 2) { |
|
471 | + $incontext['warning'] = $txt['error_already_installed']; |
|
472 | + } |
|
448 | 473 | } |
449 | 474 | |
450 | 475 | // Is some database support even compiled in? |
@@ -459,45 +484,54 @@ discard block |
||
459 | 484 | $databases[$key]['supported'] = false; |
460 | 485 | $notFoundSQLFile = true; |
461 | 486 | $txt['error_db_script_missing'] = sprintf($txt['error_db_script_missing'], 'install_' . $GLOBALS['db_script_version'] . '_' . $type . '.sql'); |
487 | + } else { |
|
488 | + $incontext['supported_databases'][] = $db; |
|
462 | 489 | } |
463 | - else |
|
464 | - $incontext['supported_databases'][] = $db; |
|
465 | 490 | } |
466 | 491 | } |
467 | 492 | |
468 | 493 | // Check the PHP version. |
469 | - if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>='))) |
|
470 | - $error = 'error_php_too_low'; |
|
494 | + if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>='))) { |
|
495 | + $error = 'error_php_too_low'; |
|
496 | + } |
|
471 | 497 | // Make sure we have a supported database |
472 | - elseif (empty($incontext['supported_databases'])) |
|
473 | - $error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing'; |
|
498 | + elseif (empty($incontext['supported_databases'])) { |
|
499 | + $error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing'; |
|
500 | + } |
|
474 | 501 | // How about session support? Some crazy sysadmin remove it? |
475 | - elseif (!function_exists('session_start')) |
|
476 | - $error = 'error_session_missing'; |
|
502 | + elseif (!function_exists('session_start')) { |
|
503 | + $error = 'error_session_missing'; |
|
504 | + } |
|
477 | 505 | // Make sure they uploaded all the files. |
478 | - elseif (!file_exists(dirname(__FILE__) . '/index.php')) |
|
479 | - $error = 'error_missing_files'; |
|
506 | + elseif (!file_exists(dirname(__FILE__) . '/index.php')) { |
|
507 | + $error = 'error_missing_files'; |
|
508 | + } |
|
480 | 509 | // Very simple check on the session.save_path for Windows. |
481 | 510 | // @todo Move this down later if they don't use database-driven sessions? |
482 | - elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') |
|
483 | - $error = 'error_session_save_path'; |
|
511 | + elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') { |
|
512 | + $error = 'error_session_save_path'; |
|
513 | + } |
|
484 | 514 | |
485 | 515 | // Since each of the three messages would look the same, anyway... |
486 | - if (isset($error)) |
|
487 | - $incontext['error'] = $txt[$error]; |
|
516 | + if (isset($error)) { |
|
517 | + $incontext['error'] = $txt[$error]; |
|
518 | + } |
|
488 | 519 | |
489 | 520 | // Mod_security blocks everything that smells funny. Let SMF handle security. |
490 | - if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) |
|
491 | - $incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again']; |
|
521 | + if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) { |
|
522 | + $incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again']; |
|
523 | + } |
|
492 | 524 | |
493 | 525 | // Confirm mbstring is loaded... |
494 | - if (!extension_loaded('mbstring')) |
|
495 | - $incontext['error'] = $txt['install_no_mbstring']; |
|
526 | + if (!extension_loaded('mbstring')) { |
|
527 | + $incontext['error'] = $txt['install_no_mbstring']; |
|
528 | + } |
|
496 | 529 | |
497 | 530 | // Check for https stream support. |
498 | 531 | $supported_streams = stream_get_wrappers(); |
499 | - if (!in_array('https', $supported_streams)) |
|
500 | - $incontext['warning'] = $txt['install_no_https']; |
|
532 | + if (!in_array('https', $supported_streams)) { |
|
533 | + $incontext['warning'] = $txt['install_no_https']; |
|
534 | + } |
|
501 | 535 | |
502 | 536 | return false; |
503 | 537 | } |
@@ -522,12 +556,14 @@ discard block |
||
522 | 556 | 'Settings_bak.php', |
523 | 557 | ); |
524 | 558 | |
525 | - foreach ($incontext['detected_languages'] as $lang => $temp) |
|
526 | - $extra_files[] = 'Themes/default/languages/' . $lang; |
|
559 | + foreach ($incontext['detected_languages'] as $lang => $temp) { |
|
560 | + $extra_files[] = 'Themes/default/languages/' . $lang; |
|
561 | + } |
|
527 | 562 | |
528 | 563 | // With mod_security installed, we could attempt to fix it with .htaccess. |
529 | - if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) |
|
530 | - $writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.'; |
|
564 | + if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) { |
|
565 | + $writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.'; |
|
566 | + } |
|
531 | 567 | |
532 | 568 | $failed_files = array(); |
533 | 569 | |
@@ -539,20 +575,23 @@ discard block |
||
539 | 575 | foreach ($writable_files as $file) |
540 | 576 | { |
541 | 577 | // Some files won't exist, try to address up front |
542 | - if (!file_exists(dirname(__FILE__) . '/' . $file)) |
|
543 | - @touch(dirname(__FILE__) . '/' . $file); |
|
578 | + if (!file_exists(dirname(__FILE__) . '/' . $file)) { |
|
579 | + @touch(dirname(__FILE__) . '/' . $file); |
|
580 | + } |
|
544 | 581 | // NOW do the writable check... |
545 | 582 | if (!is_writable(dirname(__FILE__) . '/' . $file)) |
546 | 583 | { |
547 | 584 | @chmod(dirname(__FILE__) . '/' . $file, 0755); |
548 | 585 | |
549 | 586 | // Well, 755 hopefully worked... if not, try 777. |
550 | - if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) |
|
551 | - $failed_files[] = $file; |
|
587 | + if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) { |
|
588 | + $failed_files[] = $file; |
|
589 | + } |
|
552 | 590 | } |
553 | 591 | } |
554 | - foreach ($extra_files as $file) |
|
555 | - @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
592 | + foreach ($extra_files as $file) { |
|
593 | + @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
594 | + } |
|
556 | 595 | } |
557 | 596 | // Windows is trickier. Let's try opening for r+... |
558 | 597 | else |
@@ -562,30 +601,35 @@ discard block |
||
562 | 601 | foreach ($writable_files as $file) |
563 | 602 | { |
564 | 603 | // Folders can't be opened for write... but the index.php in them can ;) |
565 | - if (is_dir(dirname(__FILE__) . '/' . $file)) |
|
566 | - $file .= '/index.php'; |
|
604 | + if (is_dir(dirname(__FILE__) . '/' . $file)) { |
|
605 | + $file .= '/index.php'; |
|
606 | + } |
|
567 | 607 | |
568 | 608 | // Funny enough, chmod actually does do something on windows - it removes the read only attribute. |
569 | 609 | @chmod(dirname(__FILE__) . '/' . $file, 0777); |
570 | 610 | $fp = @fopen(dirname(__FILE__) . '/' . $file, 'r+'); |
571 | 611 | |
572 | 612 | // Hmm, okay, try just for write in that case... |
573 | - if (!is_resource($fp)) |
|
574 | - $fp = @fopen(dirname(__FILE__) . '/' . $file, 'w'); |
|
613 | + if (!is_resource($fp)) { |
|
614 | + $fp = @fopen(dirname(__FILE__) . '/' . $file, 'w'); |
|
615 | + } |
|
575 | 616 | |
576 | - if (!is_resource($fp)) |
|
577 | - $failed_files[] = $file; |
|
617 | + if (!is_resource($fp)) { |
|
618 | + $failed_files[] = $file; |
|
619 | + } |
|
578 | 620 | |
579 | 621 | @fclose($fp); |
580 | 622 | } |
581 | - foreach ($extra_files as $file) |
|
582 | - @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
623 | + foreach ($extra_files as $file) { |
|
624 | + @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
625 | + } |
|
583 | 626 | } |
584 | 627 | |
585 | 628 | $failure = count($failed_files) >= 1; |
586 | 629 | |
587 | - if (!isset($_SERVER)) |
|
588 | - return !$failure; |
|
630 | + if (!isset($_SERVER)) { |
|
631 | + return !$failure; |
|
632 | + } |
|
589 | 633 | |
590 | 634 | // Put the list into context. |
591 | 635 | $incontext['failed_files'] = $failed_files; |
@@ -633,19 +677,23 @@ discard block |
||
633 | 677 | |
634 | 678 | if (!isset($ftp) || $ftp->error !== false) |
635 | 679 | { |
636 | - if (!isset($ftp)) |
|
637 | - $ftp = new ftp_connection(null); |
|
680 | + if (!isset($ftp)) { |
|
681 | + $ftp = new ftp_connection(null); |
|
682 | + } |
|
638 | 683 | // Save the error so we can mess with listing... |
639 | - elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) |
|
640 | - $incontext['ftp_errors'][] = $ftp->last_message; |
|
684 | + elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) { |
|
685 | + $incontext['ftp_errors'][] = $ftp->last_message; |
|
686 | + } |
|
641 | 687 | |
642 | 688 | list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__)); |
643 | 689 | |
644 | - if (empty($_POST['ftp_path']) && $found_path) |
|
645 | - $_POST['ftp_path'] = $detect_path; |
|
690 | + if (empty($_POST['ftp_path']) && $found_path) { |
|
691 | + $_POST['ftp_path'] = $detect_path; |
|
692 | + } |
|
646 | 693 | |
647 | - if (!isset($_POST['ftp_username'])) |
|
648 | - $_POST['ftp_username'] = $username; |
|
694 | + if (!isset($_POST['ftp_username'])) { |
|
695 | + $_POST['ftp_username'] = $username; |
|
696 | + } |
|
649 | 697 | |
650 | 698 | // Set the username etc, into context. |
651 | 699 | $incontext['ftp'] = array( |
@@ -657,8 +705,7 @@ discard block |
||
657 | 705 | ); |
658 | 706 | |
659 | 707 | return false; |
660 | - } |
|
661 | - else |
|
708 | + } else |
|
662 | 709 | { |
663 | 710 | $_SESSION['installer_temp_ftp'] = array( |
664 | 711 | 'server' => $_POST['ftp_server'], |
@@ -672,10 +719,12 @@ discard block |
||
672 | 719 | |
673 | 720 | foreach ($failed_files as $file) |
674 | 721 | { |
675 | - if (!is_writable(dirname(__FILE__) . '/' . $file)) |
|
676 | - $ftp->chmod($file, 0755); |
|
677 | - if (!is_writable(dirname(__FILE__) . '/' . $file)) |
|
678 | - $ftp->chmod($file, 0777); |
|
722 | + if (!is_writable(dirname(__FILE__) . '/' . $file)) { |
|
723 | + $ftp->chmod($file, 0755); |
|
724 | + } |
|
725 | + if (!is_writable(dirname(__FILE__) . '/' . $file)) { |
|
726 | + $ftp->chmod($file, 0777); |
|
727 | + } |
|
679 | 728 | if (!is_writable(dirname(__FILE__) . '/' . $file)) |
680 | 729 | { |
681 | 730 | $failed_files_updated[] = $file; |
@@ -731,15 +780,17 @@ discard block |
||
731 | 780 | |
732 | 781 | if (!$foundOne) |
733 | 782 | { |
734 | - if (isset($db['default_host'])) |
|
735 | - $incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost'; |
|
783 | + if (isset($db['default_host'])) { |
|
784 | + $incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost'; |
|
785 | + } |
|
736 | 786 | if (isset($db['default_user'])) |
737 | 787 | { |
738 | 788 | $incontext['db']['user'] = ini_get($db['default_user']); |
739 | 789 | $incontext['db']['name'] = ini_get($db['default_user']); |
740 | 790 | } |
741 | - if (isset($db['default_password'])) |
|
742 | - $incontext['db']['pass'] = ini_get($db['default_password']); |
|
791 | + if (isset($db['default_password'])) { |
|
792 | + $incontext['db']['pass'] = ini_get($db['default_password']); |
|
793 | + } |
|
743 | 794 | |
744 | 795 | // For simplicity and less confusion, leave the port blank by default |
745 | 796 | $incontext['db']['port'] = ''; |
@@ -758,10 +809,10 @@ discard block |
||
758 | 809 | $incontext['db']['server'] = $_POST['db_server']; |
759 | 810 | $incontext['db']['prefix'] = $_POST['db_prefix']; |
760 | 811 | |
761 | - if (!empty($_POST['db_port'])) |
|
762 | - $incontext['db']['port'] = $_POST['db_port']; |
|
763 | - } |
|
764 | - else |
|
812 | + if (!empty($_POST['db_port'])) { |
|
813 | + $incontext['db']['port'] = $_POST['db_port']; |
|
814 | + } |
|
815 | + } else |
|
765 | 816 | { |
766 | 817 | $incontext['db']['prefix'] = 'smf_'; |
767 | 818 | } |
@@ -797,10 +848,11 @@ discard block |
||
797 | 848 | if (!empty($_POST['db_port'])) |
798 | 849 | { |
799 | 850 | // For MySQL, we can get the "default port" from PHP. PostgreSQL has no such option though. |
800 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) |
|
801 | - $vars['db_port'] = (int) $_POST['db_port']; |
|
802 | - elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) |
|
803 | - $vars['db_port'] = (int) $_POST['db_port']; |
|
851 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) { |
|
852 | + $vars['db_port'] = (int) $_POST['db_port']; |
|
853 | + } elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) { |
|
854 | + $vars['db_port'] = (int) $_POST['db_port']; |
|
855 | + } |
|
804 | 856 | } |
805 | 857 | |
806 | 858 | // God I hope it saved! |
@@ -813,8 +865,9 @@ discard block |
||
813 | 865 | // Make sure it works. |
814 | 866 | require(dirname(__FILE__) . '/Settings.php'); |
815 | 867 | |
816 | - if (empty($sourcedir)) |
|
817 | - $sourcedir = dirname(__FILE__) . '/Sources'; |
|
868 | + if (empty($sourcedir)) { |
|
869 | + $sourcedir = dirname(__FILE__) . '/Sources'; |
|
870 | + } |
|
818 | 871 | |
819 | 872 | // Better find the database file! |
820 | 873 | if (!file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
@@ -824,12 +877,14 @@ discard block |
||
824 | 877 | } |
825 | 878 | |
826 | 879 | // Now include it for database functions! |
827 | - if (!defined('SMF')) |
|
828 | - define('SMF', 1); |
|
880 | + if (!defined('SMF')) { |
|
881 | + define('SMF', 1); |
|
882 | + } |
|
829 | 883 | |
830 | 884 | $modSettings['disableQueryCheck'] = true; |
831 | - if (empty($smcFunc)) |
|
832 | - $smcFunc = array(); |
|
885 | + if (empty($smcFunc)) { |
|
886 | + $smcFunc = array(); |
|
887 | + } |
|
833 | 888 | |
834 | 889 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
835 | 890 | |
@@ -838,11 +893,13 @@ discard block |
||
838 | 893 | |
839 | 894 | $options = array('non_fatal' => true, 'dont_select_db' => !$needsDB); |
840 | 895 | // Add in the port if needed |
841 | - if (!empty($db_port)) |
|
842 | - $options['port'] = $db_port; |
|
896 | + if (!empty($db_port)) { |
|
897 | + $options['port'] = $db_port; |
|
898 | + } |
|
843 | 899 | |
844 | - if (!empty($db_mb4)) |
|
845 | - $options['db_mb4'] = $db_mb4; |
|
900 | + if (!empty($db_mb4)) { |
|
901 | + $options['db_mb4'] = $db_mb4; |
|
902 | + } |
|
846 | 903 | |
847 | 904 | $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $options); |
848 | 905 | |
@@ -928,12 +985,14 @@ discard block |
||
928 | 985 | $incontext['page_title'] = $txt['install_settings']; |
929 | 986 | |
930 | 987 | // Let's see if we got the database type correct. |
931 | - if (isset($_POST['db_type'], $databases[$_POST['db_type']])) |
|
932 | - $db_type = $_POST['db_type']; |
|
988 | + if (isset($_POST['db_type'], $databases[$_POST['db_type']])) { |
|
989 | + $db_type = $_POST['db_type']; |
|
990 | + } |
|
933 | 991 | |
934 | 992 | // Else we'd better be able to get the connection. |
935 | - else |
|
936 | - load_database(); |
|
993 | + else { |
|
994 | + load_database(); |
|
995 | + } |
|
937 | 996 | |
938 | 997 | $db_type = isset($_POST['db_type']) ? $_POST['db_type'] : $db_type; |
939 | 998 | |
@@ -942,10 +1001,11 @@ discard block |
||
942 | 1001 | |
943 | 1002 | $secure = false; |
944 | 1003 | |
945 | - if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') |
|
946 | - $secure = true; |
|
947 | - 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') |
|
948 | - $secure = true; |
|
1004 | + if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { |
|
1005 | + $secure = true; |
|
1006 | + } 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') { |
|
1007 | + $secure = true; |
|
1008 | + } |
|
949 | 1009 | |
950 | 1010 | // Now, to put what we've learned together... and add a path. |
951 | 1011 | $incontext['detected_url'] = 'http' . ($secure ? 's' : '') . '://' . $host . substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], '/')); |
@@ -977,18 +1037,21 @@ discard block |
||
977 | 1037 | // Submitting? |
978 | 1038 | if (isset($_POST['boardurl'])) |
979 | 1039 | { |
980 | - if (substr($_POST['boardurl'], -10) == '/index.php') |
|
981 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
982 | - elseif (substr($_POST['boardurl'], -1) == '/') |
|
983 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
984 | - if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') |
|
985 | - $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
1040 | + if (substr($_POST['boardurl'], -10) == '/index.php') { |
|
1041 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
1042 | + } elseif (substr($_POST['boardurl'], -1) == '/') { |
|
1043 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
1044 | + } |
|
1045 | + if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') { |
|
1046 | + $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
1047 | + } |
|
986 | 1048 | |
987 | 1049 | //Make sure boardurl is aligned with ssl setting |
988 | - if (empty($_POST['force_ssl'])) |
|
989 | - $_POST['boardurl'] = strtr($_POST['boardurl'], array('https://' => 'http://')); |
|
990 | - else |
|
991 | - $_POST['boardurl'] = strtr($_POST['boardurl'], array('http://' => 'https://')); |
|
1050 | + if (empty($_POST['force_ssl'])) { |
|
1051 | + $_POST['boardurl'] = strtr($_POST['boardurl'], array('https://' => 'http://')); |
|
1052 | + } else { |
|
1053 | + $_POST['boardurl'] = strtr($_POST['boardurl'], array('http://' => 'https://')); |
|
1054 | + } |
|
992 | 1055 | |
993 | 1056 | // Save these variables. |
994 | 1057 | $vars = array( |
@@ -1027,10 +1090,10 @@ discard block |
||
1027 | 1090 | { |
1028 | 1091 | $incontext['error'] = sprintf($txt['error_utf8_version'], $databases[$db_type]['utf8_version']); |
1029 | 1092 | return false; |
1030 | - } |
|
1031 | - else |
|
1032 | - // Set the character set here. |
|
1093 | + } else { |
|
1094 | + // Set the character set here. |
|
1033 | 1095 | updateSettingsFile(array('db_character_set' => 'utf8')); |
1096 | + } |
|
1034 | 1097 | } |
1035 | 1098 | |
1036 | 1099 | // Good, skip on. |
@@ -1050,8 +1113,9 @@ discard block |
||
1050 | 1113 | $incontext['continue'] = 1; |
1051 | 1114 | |
1052 | 1115 | // Already done? |
1053 | - if (isset($_POST['pop_done'])) |
|
1054 | - return true; |
|
1116 | + if (isset($_POST['pop_done'])) { |
|
1117 | + return true; |
|
1118 | + } |
|
1055 | 1119 | |
1056 | 1120 | // Reload settings. |
1057 | 1121 | require(dirname(__FILE__) . '/Settings.php'); |
@@ -1069,8 +1133,9 @@ discard block |
||
1069 | 1133 | $modSettings = array(); |
1070 | 1134 | if ($result !== false) |
1071 | 1135 | { |
1072 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
1073 | - $modSettings[$row['variable']] = $row['value']; |
|
1136 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
1137 | + $modSettings[$row['variable']] = $row['value']; |
|
1138 | + } |
|
1074 | 1139 | $smcFunc['db_free_result']($result); |
1075 | 1140 | |
1076 | 1141 | // Do they match? If so, this is just a refresh so charge on! |
@@ -1083,20 +1148,22 @@ discard block |
||
1083 | 1148 | $modSettings['disableQueryCheck'] = true; |
1084 | 1149 | |
1085 | 1150 | // If doing UTF8, select it. PostgreSQL requires passing it as a string... |
1086 | - if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) |
|
1087 | - $smcFunc['db_query']('', ' |
|
1151 | + if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) { |
|
1152 | + $smcFunc['db_query']('', ' |
|
1088 | 1153 | SET NAMES {string:utf8}', |
1089 | 1154 | array( |
1090 | 1155 | 'db_error_skip' => true, |
1091 | 1156 | 'utf8' => 'utf8', |
1092 | 1157 | ) |
1093 | 1158 | ); |
1159 | + } |
|
1094 | 1160 | |
1095 | 1161 | // Windows likes to leave the trailing slash, which yields to C:\path\to\SMF\/attachments... |
1096 | - if (substr(__DIR__, -1) == '\\') |
|
1097 | - $attachdir = __DIR__ . 'attachments'; |
|
1098 | - else |
|
1099 | - $attachdir = __DIR__ . '/attachments'; |
|
1162 | + if (substr(__DIR__, -1) == '\\') { |
|
1163 | + $attachdir = __DIR__ . 'attachments'; |
|
1164 | + } else { |
|
1165 | + $attachdir = __DIR__ . '/attachments'; |
|
1166 | + } |
|
1100 | 1167 | |
1101 | 1168 | $replaces = array( |
1102 | 1169 | '{$db_prefix}' => $db_prefix, |
@@ -1113,8 +1180,9 @@ discard block |
||
1113 | 1180 | |
1114 | 1181 | foreach ($txt as $key => $value) |
1115 | 1182 | { |
1116 | - if (substr($key, 0, 8) == 'default_') |
|
1117 | - $replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value); |
|
1183 | + if (substr($key, 0, 8) == 'default_') { |
|
1184 | + $replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value); |
|
1185 | + } |
|
1118 | 1186 | } |
1119 | 1187 | $replaces['{$default_reserved_names}'] = strtr($replaces['{$default_reserved_names}'], array('\\\\n' => '\\n')); |
1120 | 1188 | |
@@ -1129,8 +1197,9 @@ discard block |
||
1129 | 1197 | |
1130 | 1198 | while ($row = $smcFunc['db_fetch_assoc']($get_engines)) |
1131 | 1199 | { |
1132 | - if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') |
|
1133 | - $engines[] = $row['Engine']; |
|
1200 | + if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') { |
|
1201 | + $engines[] = $row['Engine']; |
|
1202 | + } |
|
1134 | 1203 | } |
1135 | 1204 | |
1136 | 1205 | // Done with this now |
@@ -1154,8 +1223,7 @@ discard block |
||
1154 | 1223 | $replaces['START TRANSACTION;'] = ''; |
1155 | 1224 | $replaces['COMMIT;'] = ''; |
1156 | 1225 | } |
1157 | - } |
|
1158 | - else |
|
1226 | + } else |
|
1159 | 1227 | { |
1160 | 1228 | $has_innodb = false; |
1161 | 1229 | } |
@@ -1177,21 +1245,24 @@ discard block |
||
1177 | 1245 | foreach ($sql_lines as $count => $line) |
1178 | 1246 | { |
1179 | 1247 | // No comments allowed! |
1180 | - if (substr(trim($line), 0, 1) != '#') |
|
1181 | - $current_statement .= "\n" . rtrim($line); |
|
1248 | + if (substr(trim($line), 0, 1) != '#') { |
|
1249 | + $current_statement .= "\n" . rtrim($line); |
|
1250 | + } |
|
1182 | 1251 | |
1183 | 1252 | // Is this the end of the query string? |
1184 | - if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) |
|
1185 | - continue; |
|
1253 | + if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) { |
|
1254 | + continue; |
|
1255 | + } |
|
1186 | 1256 | |
1187 | 1257 | // Does this table already exist? If so, don't insert more data into it! |
1188 | 1258 | if (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) != 0 && in_array($match[1], $exists)) |
1189 | 1259 | { |
1190 | 1260 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
1191 | - if (!empty($matches[0])) |
|
1192 | - $incontext['sql_results']['insert_dups'] += count($matches[0]); |
|
1193 | - else |
|
1194 | - $incontext['sql_results']['insert_dups']++; |
|
1261 | + if (!empty($matches[0])) { |
|
1262 | + $incontext['sql_results']['insert_dups'] += count($matches[0]); |
|
1263 | + } else { |
|
1264 | + $incontext['sql_results']['insert_dups']++; |
|
1265 | + } |
|
1195 | 1266 | |
1196 | 1267 | $current_statement = ''; |
1197 | 1268 | continue; |
@@ -1200,8 +1271,9 @@ discard block |
||
1200 | 1271 | if ($smcFunc['db_query']('', $current_statement, array('security_override' => true, 'db_error_skip' => true), $db_connection) === false) |
1201 | 1272 | { |
1202 | 1273 | // Use the appropriate function based on the DB type |
1203 | - if ($db_type == 'mysql' || $db_type == 'mysqli') |
|
1204 | - $db_errorno = $db_type . '_errno'; |
|
1274 | + if ($db_type == 'mysql' || $db_type == 'mysqli') { |
|
1275 | + $db_errorno = $db_type . '_errno'; |
|
1276 | + } |
|
1205 | 1277 | |
1206 | 1278 | // Error 1050: Table already exists! |
1207 | 1279 | // @todo Needs to be made better! |
@@ -1216,18 +1288,18 @@ discard block |
||
1216 | 1288 | // MySQLi requires a connection object. It's optional with MySQL and Postgres |
1217 | 1289 | $incontext['failures'][$count] = $smcFunc['db_error']($db_connection); |
1218 | 1290 | } |
1219 | - } |
|
1220 | - else |
|
1291 | + } else |
|
1221 | 1292 | { |
1222 | - if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
1223 | - $incontext['sql_results']['tables']++; |
|
1224 | - elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
1293 | + if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) { |
|
1294 | + $incontext['sql_results']['tables']++; |
|
1295 | + } elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
1225 | 1296 | { |
1226 | 1297 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
1227 | - if (!empty($matches[0])) |
|
1228 | - $incontext['sql_results']['inserts'] += count($matches[0]); |
|
1229 | - else |
|
1230 | - $incontext['sql_results']['inserts']++; |
|
1298 | + if (!empty($matches[0])) { |
|
1299 | + $incontext['sql_results']['inserts'] += count($matches[0]); |
|
1300 | + } else { |
|
1301 | + $incontext['sql_results']['inserts']++; |
|
1302 | + } |
|
1231 | 1303 | } |
1232 | 1304 | } |
1233 | 1305 | |
@@ -1240,15 +1312,17 @@ discard block |
||
1240 | 1312 | // Sort out the context for the SQL. |
1241 | 1313 | foreach ($incontext['sql_results'] as $key => $number) |
1242 | 1314 | { |
1243 | - if ($number == 0) |
|
1244 | - unset($incontext['sql_results'][$key]); |
|
1245 | - else |
|
1246 | - $incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number); |
|
1315 | + if ($number == 0) { |
|
1316 | + unset($incontext['sql_results'][$key]); |
|
1317 | + } else { |
|
1318 | + $incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number); |
|
1319 | + } |
|
1247 | 1320 | } |
1248 | 1321 | |
1249 | 1322 | // Make sure UTF will be used globally. |
1250 | - 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']))) |
|
1251 | - $newSettings[] = array('global_character_set', 'UTF-8'); |
|
1323 | + 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']))) { |
|
1324 | + $newSettings[] = array('global_character_set', 'UTF-8'); |
|
1325 | + } |
|
1252 | 1326 | |
1253 | 1327 | // Auto-detect local & global cookie settings |
1254 | 1328 | $url_parts = parse_url($boardurl); |
@@ -1277,15 +1351,19 @@ discard block |
||
1277 | 1351 | |
1278 | 1352 | // Look for subfolder, if found, set localCookie |
1279 | 1353 | // Checking for len > 1 ensures you don't have just a slash... |
1280 | - if (!empty($url_parts['path']) && strlen($url_parts['path']) > 1) |
|
1281 | - $localCookies = '1'; |
|
1354 | + if (!empty($url_parts['path']) && strlen($url_parts['path']) > 1) { |
|
1355 | + $localCookies = '1'; |
|
1356 | + } |
|
1282 | 1357 | |
1283 | - if (isset($globalCookies)) |
|
1284 | - $newSettings[] = array('globalCookies', $globalCookies); |
|
1285 | - if (isset($globalCookiesDomain)) |
|
1286 | - $newSettings[] = array('globalCookiesDomain', $globalCookiesDomain); |
|
1287 | - if (isset($localCookies)) |
|
1288 | - $newSettings[] = array('localCookies', $localCookies); |
|
1358 | + if (isset($globalCookies)) { |
|
1359 | + $newSettings[] = array('globalCookies', $globalCookies); |
|
1360 | + } |
|
1361 | + if (isset($globalCookiesDomain)) { |
|
1362 | + $newSettings[] = array('globalCookiesDomain', $globalCookiesDomain); |
|
1363 | + } |
|
1364 | + if (isset($localCookies)) { |
|
1365 | + $newSettings[] = array('localCookies', $localCookies); |
|
1366 | + } |
|
1289 | 1367 | } |
1290 | 1368 | |
1291 | 1369 | // Are we allowing stat collection? |
@@ -1303,16 +1381,17 @@ discard block |
||
1303 | 1381 | fwrite($fp, $out); |
1304 | 1382 | |
1305 | 1383 | $return_data = ''; |
1306 | - while (!feof($fp)) |
|
1307 | - $return_data .= fgets($fp, 128); |
|
1384 | + while (!feof($fp)) { |
|
1385 | + $return_data .= fgets($fp, 128); |
|
1386 | + } |
|
1308 | 1387 | |
1309 | 1388 | fclose($fp); |
1310 | 1389 | |
1311 | 1390 | // Get the unique site ID. |
1312 | 1391 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
1313 | 1392 | |
1314 | - if (!empty($ID[1])) |
|
1315 | - $smcFunc['db_insert']('replace', |
|
1393 | + if (!empty($ID[1])) { |
|
1394 | + $smcFunc['db_insert']('replace', |
|
1316 | 1395 | $db_prefix . 'settings', |
1317 | 1396 | array('variable' => 'string', 'value' => 'string'), |
1318 | 1397 | array( |
@@ -1321,11 +1400,12 @@ discard block |
||
1321 | 1400 | ), |
1322 | 1401 | array('variable') |
1323 | 1402 | ); |
1403 | + } |
|
1324 | 1404 | } |
1325 | 1405 | } |
1326 | 1406 | // Don't remove stat collection unless we unchecked the box for real, not from the loop. |
1327 | - elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) |
|
1328 | - $smcFunc['db_query']('', ' |
|
1407 | + elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) { |
|
1408 | + $smcFunc['db_query']('', ' |
|
1329 | 1409 | DELETE FROM {db_prefix}settings |
1330 | 1410 | WHERE variable = {string:enable_sm_stats}', |
1331 | 1411 | array( |
@@ -1333,20 +1413,23 @@ discard block |
||
1333 | 1413 | 'db_error_skip' => true, |
1334 | 1414 | ) |
1335 | 1415 | ); |
1416 | + } |
|
1336 | 1417 | |
1337 | 1418 | // Are we enabling SSL? |
1338 | - if (!empty($_POST['force_ssl'])) |
|
1339 | - $newSettings[] = array('force_ssl', 1); |
|
1419 | + if (!empty($_POST['force_ssl'])) { |
|
1420 | + $newSettings[] = array('force_ssl', 1); |
|
1421 | + } |
|
1340 | 1422 | |
1341 | 1423 | // Setting a timezone is required. |
1342 | 1424 | if (!isset($modSettings['default_timezone']) && function_exists('date_default_timezone_set')) |
1343 | 1425 | { |
1344 | 1426 | // Get PHP's default timezone, if set |
1345 | 1427 | $ini_tz = ini_get('date.timezone'); |
1346 | - if (!empty($ini_tz)) |
|
1347 | - $timezone_id = $ini_tz; |
|
1348 | - else |
|
1349 | - $timezone_id = ''; |
|
1428 | + if (!empty($ini_tz)) { |
|
1429 | + $timezone_id = $ini_tz; |
|
1430 | + } else { |
|
1431 | + $timezone_id = ''; |
|
1432 | + } |
|
1350 | 1433 | |
1351 | 1434 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
1352 | 1435 | if (!in_array($timezone_id, timezone_identifiers_list())) |
@@ -1355,8 +1438,9 @@ discard block |
||
1355 | 1438 | $timezone_id = timezone_name_from_abbr('', $server_offset, 0); |
1356 | 1439 | } |
1357 | 1440 | |
1358 | - if (date_default_timezone_set($timezone_id)) |
|
1359 | - $newSettings[] = array('default_timezone', $timezone_id); |
|
1441 | + if (date_default_timezone_set($timezone_id)) { |
|
1442 | + $newSettings[] = array('default_timezone', $timezone_id); |
|
1443 | + } |
|
1360 | 1444 | } |
1361 | 1445 | |
1362 | 1446 | if (!empty($newSettings)) |
@@ -1387,16 +1471,18 @@ discard block |
||
1387 | 1471 | } |
1388 | 1472 | |
1389 | 1473 | // MySQL specific stuff |
1390 | - if (substr($db_type, 0, 5) != 'mysql') |
|
1391 | - return false; |
|
1474 | + if (substr($db_type, 0, 5) != 'mysql') { |
|
1475 | + return false; |
|
1476 | + } |
|
1392 | 1477 | |
1393 | 1478 | // Find database user privileges. |
1394 | 1479 | $privs = array(); |
1395 | 1480 | $get_privs = $smcFunc['db_query']('', 'SHOW PRIVILEGES', array()); |
1396 | 1481 | while ($row = $smcFunc['db_fetch_assoc']($get_privs)) |
1397 | 1482 | { |
1398 | - if ($row['Privilege'] == 'Alter') |
|
1399 | - $privs[] = $row['Privilege']; |
|
1483 | + if ($row['Privilege'] == 'Alter') { |
|
1484 | + $privs[] = $row['Privilege']; |
|
1485 | + } |
|
1400 | 1486 | } |
1401 | 1487 | $smcFunc['db_free_result']($get_privs); |
1402 | 1488 | |
@@ -1426,8 +1512,9 @@ discard block |
||
1426 | 1512 | $incontext['continue'] = 1; |
1427 | 1513 | |
1428 | 1514 | // Skipping? |
1429 | - if (!empty($_POST['skip'])) |
|
1430 | - return true; |
|
1515 | + if (!empty($_POST['skip'])) { |
|
1516 | + return true; |
|
1517 | + } |
|
1431 | 1518 | |
1432 | 1519 | // Need this to check whether we need the database password. |
1433 | 1520 | require(dirname(__FILE__) . '/Settings.php'); |
@@ -1444,18 +1531,22 @@ discard block |
||
1444 | 1531 | // We need this to properly hash the password for Admin |
1445 | 1532 | $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) { |
1446 | 1533 | global $sourcedir; |
1447 | - if (function_exists('mb_strtolower')) |
|
1448 | - return mb_strtolower($string, 'UTF-8'); |
|
1534 | + if (function_exists('mb_strtolower')) { |
|
1535 | + return mb_strtolower($string, 'UTF-8'); |
|
1536 | + } |
|
1449 | 1537 | require_once($sourcedir . '/Subs-Charset.php'); |
1450 | 1538 | return utf8_strtolower($string); |
1451 | 1539 | }; |
1452 | 1540 | |
1453 | - if (!isset($_POST['username'])) |
|
1454 | - $_POST['username'] = ''; |
|
1455 | - if (!isset($_POST['email'])) |
|
1456 | - $_POST['email'] = ''; |
|
1457 | - if (!isset($_POST['server_email'])) |
|
1458 | - $_POST['server_email'] = ''; |
|
1541 | + if (!isset($_POST['username'])) { |
|
1542 | + $_POST['username'] = ''; |
|
1543 | + } |
|
1544 | + if (!isset($_POST['email'])) { |
|
1545 | + $_POST['email'] = ''; |
|
1546 | + } |
|
1547 | + if (!isset($_POST['server_email'])) { |
|
1548 | + $_POST['server_email'] = ''; |
|
1549 | + } |
|
1459 | 1550 | |
1460 | 1551 | $incontext['username'] = htmlspecialchars(stripslashes($_POST['username'])); |
1461 | 1552 | $incontext['email'] = htmlspecialchars(stripslashes($_POST['email'])); |
@@ -1474,8 +1565,9 @@ discard block |
||
1474 | 1565 | 'admin_group' => 1, |
1475 | 1566 | ) |
1476 | 1567 | ); |
1477 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
1478 | - $incontext['skip'] = 1; |
|
1568 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
1569 | + $incontext['skip'] = 1; |
|
1570 | + } |
|
1479 | 1571 | $smcFunc['db_free_result']($request); |
1480 | 1572 | |
1481 | 1573 | // Trying to create an account? |
@@ -1506,8 +1598,9 @@ discard block |
||
1506 | 1598 | } |
1507 | 1599 | |
1508 | 1600 | // Update the webmaster's email? |
1509 | - if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) |
|
1510 | - updateSettingsFile(array('webmaster_email' => $_POST['server_email'])); |
|
1601 | + if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) { |
|
1602 | + updateSettingsFile(array('webmaster_email' => $_POST['server_email'])); |
|
1603 | + } |
|
1511 | 1604 | |
1512 | 1605 | // Work out whether we're going to have dodgy characters and remove them. |
1513 | 1606 | $invalid_characters = preg_match('~[<>&"\'=\\\]~', $_POST['username']) != 0; |
@@ -1530,32 +1623,27 @@ discard block |
||
1530 | 1623 | $smcFunc['db_free_result']($result); |
1531 | 1624 | |
1532 | 1625 | $incontext['account_existed'] = $txt['error_user_settings_taken']; |
1533 | - } |
|
1534 | - elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) |
|
1626 | + } elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) |
|
1535 | 1627 | { |
1536 | 1628 | // Try the previous step again. |
1537 | 1629 | $incontext['error'] = $_POST['username'] == '' ? $txt['error_username_left_empty'] : $txt['error_username_too_long']; |
1538 | 1630 | return false; |
1539 | - } |
|
1540 | - elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) |
|
1631 | + } elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) |
|
1541 | 1632 | { |
1542 | 1633 | // Try the previous step again. |
1543 | 1634 | $incontext['error'] = $txt['error_invalid_characters_username']; |
1544 | 1635 | return false; |
1545 | - } |
|
1546 | - elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255) |
|
1636 | + } elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255) |
|
1547 | 1637 | { |
1548 | 1638 | // One step back, this time fill out a proper admin email address. |
1549 | 1639 | $incontext['error'] = sprintf($txt['error_valid_admin_email_needed'], $_POST['username']); |
1550 | 1640 | return false; |
1551 | - } |
|
1552 | - elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255) |
|
1641 | + } elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255) |
|
1553 | 1642 | { |
1554 | 1643 | // One step back, this time fill out a proper admin email address. |
1555 | 1644 | $incontext['error'] = $txt['error_valid_server_email_needed']; |
1556 | 1645 | return false; |
1557 | - } |
|
1558 | - elseif ($_POST['username'] != '') |
|
1646 | + } elseif ($_POST['username'] != '') |
|
1559 | 1647 | { |
1560 | 1648 | $incontext['member_salt'] = substr(md5(mt_rand()), 0, 4); |
1561 | 1649 | |
@@ -1623,17 +1711,19 @@ discard block |
||
1623 | 1711 | reloadSettings(); |
1624 | 1712 | |
1625 | 1713 | // Bring a warning over. |
1626 | - if (!empty($incontext['account_existed'])) |
|
1627 | - $incontext['warning'] = $incontext['account_existed']; |
|
1714 | + if (!empty($incontext['account_existed'])) { |
|
1715 | + $incontext['warning'] = $incontext['account_existed']; |
|
1716 | + } |
|
1628 | 1717 | |
1629 | - if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) |
|
1630 | - $smcFunc['db_query']('', ' |
|
1718 | + if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) { |
|
1719 | + $smcFunc['db_query']('', ' |
|
1631 | 1720 | SET NAMES {string:db_character_set}', |
1632 | 1721 | array( |
1633 | 1722 | 'db_character_set' => $db_character_set, |
1634 | 1723 | 'db_error_skip' => true, |
1635 | 1724 | ) |
1636 | 1725 | ); |
1726 | + } |
|
1637 | 1727 | |
1638 | 1728 | // As track stats is by default enabled let's add some activity. |
1639 | 1729 | $smcFunc['db_insert']('ignore', |
@@ -1654,14 +1744,16 @@ discard block |
||
1654 | 1744 | // Only proceed if we can load the data. |
1655 | 1745 | if ($request) |
1656 | 1746 | { |
1657 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
1658 | - $modSettings[$row[0]] = $row[1]; |
|
1747 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
1748 | + $modSettings[$row[0]] = $row[1]; |
|
1749 | + } |
|
1659 | 1750 | $smcFunc['db_free_result']($request); |
1660 | 1751 | } |
1661 | 1752 | |
1662 | 1753 | // Automatically log them in ;) |
1663 | - if (isset($incontext['member_id']) && isset($incontext['member_salt'])) |
|
1664 | - setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt'])); |
|
1754 | + if (isset($incontext['member_id']) && isset($incontext['member_salt'])) { |
|
1755 | + setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt'])); |
|
1756 | + } |
|
1665 | 1757 | |
1666 | 1758 | $result = $smcFunc['db_query']('', ' |
1667 | 1759 | SELECT value |
@@ -1672,13 +1764,14 @@ discard block |
||
1672 | 1764 | 'db_error_skip' => true, |
1673 | 1765 | ) |
1674 | 1766 | ); |
1675 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
1676 | - list ($db_sessions) = $smcFunc['db_fetch_row']($result); |
|
1767 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
1768 | + list ($db_sessions) = $smcFunc['db_fetch_row']($result); |
|
1769 | + } |
|
1677 | 1770 | $smcFunc['db_free_result']($result); |
1678 | 1771 | |
1679 | - if (empty($db_sessions)) |
|
1680 | - $_SESSION['admin_time'] = time(); |
|
1681 | - else |
|
1772 | + if (empty($db_sessions)) { |
|
1773 | + $_SESSION['admin_time'] = time(); |
|
1774 | + } else |
|
1682 | 1775 | { |
1683 | 1776 | $_SERVER['HTTP_USER_AGENT'] = substr($_SERVER['HTTP_USER_AGENT'], 0, 211); |
1684 | 1777 | |
@@ -1702,8 +1795,9 @@ discard block |
||
1702 | 1795 | $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : |
1703 | 1796 | function($string){ |
1704 | 1797 | global $sourcedir; |
1705 | - if (function_exists('mb_strtolower')) |
|
1706 | - return mb_strtolower($string, 'UTF-8'); |
|
1798 | + if (function_exists('mb_strtolower')) { |
|
1799 | + return mb_strtolower($string, 'UTF-8'); |
|
1800 | + } |
|
1707 | 1801 | require_once($sourcedir . '/Subs-Charset.php'); |
1708 | 1802 | return utf8_strtolower($string); |
1709 | 1803 | }; |
@@ -1719,8 +1813,9 @@ discard block |
||
1719 | 1813 | ) |
1720 | 1814 | ); |
1721 | 1815 | $context['utf8'] = $db_character_set === 'utf8' || $txt['lang_character_set'] === 'UTF-8'; |
1722 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
1723 | - updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject'])); |
|
1816 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
1817 | + updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject'])); |
|
1818 | + } |
|
1724 | 1819 | $smcFunc['db_free_result']($request); |
1725 | 1820 | |
1726 | 1821 | // Now is the perfect time to fetch the SM files. |
@@ -1739,8 +1834,9 @@ discard block |
||
1739 | 1834 | |
1740 | 1835 | // Check if we need some stupid MySQL fix. |
1741 | 1836 | $server_version = $smcFunc['db_server_info'](); |
1742 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
1743 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
1837 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
1838 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
1839 | + } |
|
1744 | 1840 | |
1745 | 1841 | // Some final context for the template. |
1746 | 1842 | $incontext['dir_still_writable'] = is_writable(dirname(__FILE__)) && substr(__FILE__, 1, 2) != ':\\'; |
@@ -1760,8 +1856,9 @@ discard block |
||
1760 | 1856 | $settingsArray = file(dirname(__FILE__) . '/Settings.php'); |
1761 | 1857 | |
1762 | 1858 | // @todo Do we just want to read the file in clean, and split it this way always? |
1763 | - if (count($settingsArray) == 1) |
|
1764 | - $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
1859 | + if (count($settingsArray) == 1) { |
|
1860 | + $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
1861 | + } |
|
1765 | 1862 | |
1766 | 1863 | for ($i = 0, $n = count($settingsArray); $i < $n; $i++) |
1767 | 1864 | { |
@@ -1769,25 +1866,29 @@ discard block |
||
1769 | 1866 | if (trim($settingsArray[$i]) == 'if (file_exists(dirname(__FILE__) . \'/install.php\'))' && trim($settingsArray[$i + 1]) == '{' && trim($settingsArray[$i + 9]) == '}') |
1770 | 1867 | { |
1771 | 1868 | // Set the ten lines to nothing. |
1772 | - for ($j=0; $j < 10; $j++) |
|
1773 | - $settingsArray[$i++] = ''; |
|
1869 | + for ($j=0; $j < 10; $j++) { |
|
1870 | + $settingsArray[$i++] = ''; |
|
1871 | + } |
|
1774 | 1872 | |
1775 | 1873 | continue; |
1776 | 1874 | } |
1777 | 1875 | |
1778 | - if (trim($settingsArray[$i]) == '?' . '>') |
|
1779 | - $settingsArray[$i] = ''; |
|
1876 | + if (trim($settingsArray[$i]) == '?' . '>') { |
|
1877 | + $settingsArray[$i] = ''; |
|
1878 | + } |
|
1780 | 1879 | |
1781 | 1880 | // Don't trim or bother with it if it's not a variable. |
1782 | - if (substr($settingsArray[$i], 0, 1) != '$') |
|
1783 | - continue; |
|
1881 | + if (substr($settingsArray[$i], 0, 1) != '$') { |
|
1882 | + continue; |
|
1883 | + } |
|
1784 | 1884 | |
1785 | 1885 | $settingsArray[$i] = rtrim($settingsArray[$i]) . "\n"; |
1786 | 1886 | |
1787 | - foreach ($vars as $var => $val) |
|
1788 | - if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
1887 | + foreach ($vars as $var => $val) { |
|
1888 | + if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
1789 | 1889 | { |
1790 | 1890 | $comment = strstr($settingsArray[$i], '#'); |
1891 | + } |
|
1791 | 1892 | $settingsArray[$i] = '$' . $var . ' = \'' . $val . '\';' . ($comment != '' ? "\t\t" . $comment : "\n"); |
1792 | 1893 | unset($vars[$var]); |
1793 | 1894 | } |
@@ -1797,36 +1898,41 @@ discard block |
||
1797 | 1898 | if (!empty($vars)) |
1798 | 1899 | { |
1799 | 1900 | $settingsArray[$i++] = ''; |
1800 | - foreach ($vars as $var => $val) |
|
1801 | - $settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n"; |
|
1901 | + foreach ($vars as $var => $val) { |
|
1902 | + $settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n"; |
|
1903 | + } |
|
1802 | 1904 | } |
1803 | 1905 | |
1804 | 1906 | // Blank out the file - done to fix a oddity with some servers. |
1805 | 1907 | $fp = @fopen(dirname(__FILE__) . '/Settings.php', 'w'); |
1806 | - if (!$fp) |
|
1807 | - return false; |
|
1908 | + if (!$fp) { |
|
1909 | + return false; |
|
1910 | + } |
|
1808 | 1911 | fclose($fp); |
1809 | 1912 | |
1810 | 1913 | $fp = fopen(dirname(__FILE__) . '/Settings.php', 'r+'); |
1811 | 1914 | |
1812 | 1915 | // Gotta have one of these ;) |
1813 | - if (trim($settingsArray[0]) != '<?php') |
|
1814 | - fwrite($fp, "<?php\n"); |
|
1916 | + if (trim($settingsArray[0]) != '<?php') { |
|
1917 | + fwrite($fp, "<?php\n"); |
|
1918 | + } |
|
1815 | 1919 | |
1816 | 1920 | $lines = count($settingsArray); |
1817 | 1921 | for ($i = 0; $i < $lines - 1; $i++) |
1818 | 1922 | { |
1819 | 1923 | // Don't just write a bunch of blank lines. |
1820 | - if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') |
|
1821 | - fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
1924 | + if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') { |
|
1925 | + fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
1926 | + } |
|
1822 | 1927 | } |
1823 | 1928 | fwrite($fp, $settingsArray[$i] . '?' . '>'); |
1824 | 1929 | fclose($fp); |
1825 | 1930 | |
1826 | 1931 | // Even though on normal installations the filemtime should prevent this being used by the installer incorrectly |
1827 | 1932 | // it seems that there are times it might not. So let's MAKE it dump the cache. |
1828 | - if (function_exists('opcache_invalidate')) |
|
1829 | - opcache_invalidate(dirname(__FILE__) . '/Settings.php', true); |
|
1933 | + if (function_exists('opcache_invalidate')) { |
|
1934 | + opcache_invalidate(dirname(__FILE__) . '/Settings.php', true); |
|
1935 | + } |
|
1830 | 1936 | |
1831 | 1937 | return true; |
1832 | 1938 | } |
@@ -1836,10 +1942,11 @@ discard block |
||
1836 | 1942 | global $cachedir; |
1837 | 1943 | |
1838 | 1944 | // Write out the db_last_error file with the error timestamp |
1839 | - if (!empty($cachedir) && is_writable($cachedir)) |
|
1840 | - file_put_contents($cachedir . '/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>'); |
|
1841 | - else |
|
1842 | - file_put_contents(dirname(__FILE__) . '/cache/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>'); |
|
1945 | + if (!empty($cachedir) && is_writable($cachedir)) { |
|
1946 | + file_put_contents($cachedir . '/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>'); |
|
1947 | + } else { |
|
1948 | + file_put_contents(dirname(__FILE__) . '/cache/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>'); |
|
1949 | + } |
|
1843 | 1950 | |
1844 | 1951 | return true; |
1845 | 1952 | } |
@@ -1856,9 +1963,9 @@ discard block |
||
1856 | 1963 | SecFilterScanPOST Off |
1857 | 1964 | </IfModule>'; |
1858 | 1965 | |
1859 | - if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) |
|
1860 | - return true; |
|
1861 | - elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess')) |
|
1966 | + if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) { |
|
1967 | + return true; |
|
1968 | + } elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess')) |
|
1862 | 1969 | { |
1863 | 1970 | $current_htaccess = implode('', file(dirname(__FILE__) . '/.htaccess')); |
1864 | 1971 | |
@@ -1870,29 +1977,28 @@ discard block |
||
1870 | 1977 | fwrite($ht_handle, $htaccess_addition); |
1871 | 1978 | fclose($ht_handle); |
1872 | 1979 | return true; |
1980 | + } else { |
|
1981 | + return false; |
|
1873 | 1982 | } |
1874 | - else |
|
1875 | - return false; |
|
1983 | + } else { |
|
1984 | + return true; |
|
1876 | 1985 | } |
1877 | - else |
|
1878 | - return true; |
|
1879 | - } |
|
1880 | - elseif (file_exists(dirname(__FILE__) . '/.htaccess')) |
|
1881 | - return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false; |
|
1882 | - elseif (is_writable(dirname(__FILE__))) |
|
1986 | + } elseif (file_exists(dirname(__FILE__) . '/.htaccess')) { |
|
1987 | + return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false; |
|
1988 | + } elseif (is_writable(dirname(__FILE__))) |
|
1883 | 1989 | { |
1884 | 1990 | if ($ht_handle = fopen(dirname(__FILE__) . '/.htaccess', 'w')) |
1885 | 1991 | { |
1886 | 1992 | fwrite($ht_handle, $htaccess_addition); |
1887 | 1993 | fclose($ht_handle); |
1888 | 1994 | return true; |
1995 | + } else { |
|
1996 | + return false; |
|
1889 | 1997 | } |
1890 | - else |
|
1998 | + } else { |
|
1891 | 1999 | return false; |
1892 | 2000 | } |
1893 | - else |
|
1894 | - return false; |
|
1895 | -} |
|
2001 | + } |
|
1896 | 2002 | |
1897 | 2003 | function template_install_above() |
1898 | 2004 | { |
@@ -1931,9 +2037,10 @@ discard block |
||
1931 | 2037 | <label for="installer_language">', $txt['installer_language'], ':</label> |
1932 | 2038 | <select id="installer_language" name="lang_file" onchange="location.href = \'', $installurl, '?lang_file=\' + this.options[this.selectedIndex].value;">'; |
1933 | 2039 | |
1934 | - foreach ($incontext['detected_languages'] as $lang => $name) |
|
1935 | - echo ' |
|
2040 | + foreach ($incontext['detected_languages'] as $lang => $name) { |
|
2041 | + echo ' |
|
1936 | 2042 | <option', isset($_SESSION['installer_temp_lang']) && $_SESSION['installer_temp_lang'] == $lang ? ' selected' : '', ' value="', $lang, '">', $name, '</option>'; |
2043 | + } |
|
1937 | 2044 | |
1938 | 2045 | echo ' |
1939 | 2046 | </select> |
@@ -1953,9 +2060,10 @@ discard block |
||
1953 | 2060 | <h2>', $txt['upgrade_progress'], '</h2> |
1954 | 2061 | <ul>'; |
1955 | 2062 | |
1956 | - foreach ($incontext['steps'] as $num => $step) |
|
1957 | - echo ' |
|
2063 | + foreach ($incontext['steps'] as $num => $step) { |
|
2064 | + echo ' |
|
1958 | 2065 | <li class="', $num < $incontext['current_step'] ? 'stepdone' : ($num == $incontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
2066 | + } |
|
1959 | 2067 | |
1960 | 2068 | echo ' |
1961 | 2069 | </ul> |
@@ -1981,20 +2089,23 @@ discard block |
||
1981 | 2089 | echo ' |
1982 | 2090 | <div class="floatright">'; |
1983 | 2091 | |
1984 | - if (!empty($incontext['continue'])) |
|
1985 | - echo ' |
|
2092 | + if (!empty($incontext['continue'])) { |
|
2093 | + echo ' |
|
1986 | 2094 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '" onclick="return submitThisOnce(this);" class="button">'; |
1987 | - if (!empty($incontext['skip'])) |
|
1988 | - echo ' |
|
2095 | + } |
|
2096 | + if (!empty($incontext['skip'])) { |
|
2097 | + echo ' |
|
1989 | 2098 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="return submitThisOnce(this);" class="button">'; |
2099 | + } |
|
1990 | 2100 | echo ' |
1991 | 2101 | </div>'; |
1992 | 2102 | } |
1993 | 2103 | |
1994 | 2104 | // Show the closing form tag and other data only if not in the last step |
1995 | - if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) |
|
1996 | - echo ' |
|
2105 | + if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) { |
|
2106 | + echo ' |
|
1997 | 2107 | </form>'; |
2108 | + } |
|
1998 | 2109 | |
1999 | 2110 | echo ' |
2000 | 2111 | </div><!-- .panel --> |
@@ -2027,13 +2138,15 @@ discard block |
||
2027 | 2138 | </div>'; |
2028 | 2139 | |
2029 | 2140 | // Show the warnings, or not. |
2030 | - if (template_warning_divs()) |
|
2031 | - echo ' |
|
2141 | + if (template_warning_divs()) { |
|
2142 | + echo ' |
|
2032 | 2143 | <h3>', $txt['install_all_lovely'], '</h3>'; |
2144 | + } |
|
2033 | 2145 | |
2034 | 2146 | // Say we want the continue button! |
2035 | - if (empty($incontext['error'])) |
|
2036 | - $incontext['continue'] = 1; |
|
2147 | + if (empty($incontext['error'])) { |
|
2148 | + $incontext['continue'] = 1; |
|
2149 | + } |
|
2037 | 2150 | |
2038 | 2151 | // For the latest version stuff. |
2039 | 2152 | echo ' |
@@ -2067,19 +2180,21 @@ discard block |
||
2067 | 2180 | global $txt, $incontext; |
2068 | 2181 | |
2069 | 2182 | // Errors are very serious.. |
2070 | - if (!empty($incontext['error'])) |
|
2071 | - echo ' |
|
2183 | + if (!empty($incontext['error'])) { |
|
2184 | + echo ' |
|
2072 | 2185 | <div class="errorbox"> |
2073 | 2186 | <h3>', $txt['upgrade_critical_error'], '</h3> |
2074 | 2187 | ', $incontext['error'], ' |
2075 | 2188 | </div>'; |
2189 | + } |
|
2076 | 2190 | // A warning message? |
2077 | - elseif (!empty($incontext['warning'])) |
|
2078 | - echo ' |
|
2191 | + elseif (!empty($incontext['warning'])) { |
|
2192 | + echo ' |
|
2079 | 2193 | <div class="errorbox"> |
2080 | 2194 | <h3>', $txt['upgrade_warning'], '</h3> |
2081 | 2195 | ', $incontext['warning'], ' |
2082 | 2196 | </div>'; |
2197 | + } |
|
2083 | 2198 | |
2084 | 2199 | return empty($incontext['error']) && empty($incontext['warning']); |
2085 | 2200 | } |
@@ -2095,26 +2210,29 @@ discard block |
||
2095 | 2210 | <li>', $incontext['failed_files']), '</li> |
2096 | 2211 | </ul>'; |
2097 | 2212 | |
2098 | - if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') |
|
2099 | - echo ' |
|
2213 | + if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') { |
|
2214 | + echo ' |
|
2100 | 2215 | <hr> |
2101 | 2216 | <p>', $txt['chmod_linux_info'], '</p> |
2102 | 2217 | <samp># chmod a+w ', implode(' ' . $incontext['detected_path'] . '/', $incontext['failed_files']), '</samp>'; |
2218 | + } |
|
2103 | 2219 | |
2104 | 2220 | // This is serious! |
2105 | - if (!template_warning_divs()) |
|
2106 | - return; |
|
2221 | + if (!template_warning_divs()) { |
|
2222 | + return; |
|
2223 | + } |
|
2107 | 2224 | |
2108 | 2225 | echo ' |
2109 | 2226 | <hr> |
2110 | 2227 | <p>', $txt['ftp_setup_info'], '</p>'; |
2111 | 2228 | |
2112 | - if (!empty($incontext['ftp_errors'])) |
|
2113 | - echo ' |
|
2229 | + if (!empty($incontext['ftp_errors'])) { |
|
2230 | + echo ' |
|
2114 | 2231 | <div class="error_message"> |
2115 | 2232 | ', $txt['error_ftp_no_connect'], '<br><br> |
2116 | 2233 | <code>', implode('<br>', $incontext['ftp_errors']), '</code> |
2117 | 2234 | </div>'; |
2235 | + } |
|
2118 | 2236 | |
2119 | 2237 | echo ' |
2120 | 2238 | <form action="', $incontext['form_url'], '" method="post"> |
@@ -2183,16 +2301,16 @@ discard block |
||
2183 | 2301 | <dd> |
2184 | 2302 | <select name="db_type" id="db_type_input" onchange="toggleDBInput();">'; |
2185 | 2303 | |
2186 | - foreach ($incontext['supported_databases'] as $key => $db) |
|
2187 | - echo ' |
|
2304 | + foreach ($incontext['supported_databases'] as $key => $db) { |
|
2305 | + echo ' |
|
2188 | 2306 | <option value="', $key, '"', isset($_POST['db_type']) && $_POST['db_type'] == $key ? ' selected' : '', '>', $db['name'], '</option>'; |
2307 | + } |
|
2189 | 2308 | |
2190 | 2309 | echo ' |
2191 | 2310 | </select> |
2192 | 2311 | <div class="smalltext">', $txt['db_settings_type_info'], '</div> |
2193 | 2312 | </dd>'; |
2194 | - } |
|
2195 | - else |
|
2313 | + } else |
|
2196 | 2314 | { |
2197 | 2315 | echo ' |
2198 | 2316 | <dd> |
@@ -2360,9 +2478,10 @@ discard block |
||
2360 | 2478 | <div class="red">', $txt['error_db_queries'], '</div> |
2361 | 2479 | <ul>'; |
2362 | 2480 | |
2363 | - foreach ($incontext['failures'] as $line => $fail) |
|
2364 | - echo ' |
|
2481 | + foreach ($incontext['failures'] as $line => $fail) { |
|
2482 | + echo ' |
|
2365 | 2483 | <li><strong>', $txt['error_db_queries_line'], $line + 1, ':</strong> ', nl2br(htmlspecialchars($fail)), '</li>'; |
2484 | + } |
|
2366 | 2485 | |
2367 | 2486 | echo ' |
2368 | 2487 | </ul>'; |
@@ -2427,15 +2546,16 @@ discard block |
||
2427 | 2546 | </dd> |
2428 | 2547 | </dl>'; |
2429 | 2548 | |
2430 | - if ($incontext['require_db_confirm']) |
|
2431 | - echo ' |
|
2549 | + if ($incontext['require_db_confirm']) { |
|
2550 | + echo ' |
|
2432 | 2551 | <h2>', $txt['user_settings_database'], '</h2> |
2433 | 2552 | <p>', $txt['user_settings_database_info'], '</p> |
2434 | 2553 | |
2435 | 2554 | <div class="lefttext"> |
2436 | 2555 | <input type="password" name="password3" size="30"> |
2437 | 2556 | </div>'; |
2438 | -} |
|
2557 | + } |
|
2558 | + } |
|
2439 | 2559 | |
2440 | 2560 | // Tell them it's done, and to delete. |
2441 | 2561 | function template_delete_install() |
@@ -2448,13 +2568,14 @@ discard block |
||
2448 | 2568 | template_warning_divs(); |
2449 | 2569 | |
2450 | 2570 | // Install directory still writable? |
2451 | - if ($incontext['dir_still_writable']) |
|
2452 | - echo ' |
|
2571 | + if ($incontext['dir_still_writable']) { |
|
2572 | + echo ' |
|
2453 | 2573 | <p><em>', $txt['still_writable'], '</em></p>'; |
2574 | + } |
|
2454 | 2575 | |
2455 | 2576 | // Don't show the box if it's like 99% sure it won't work :P. |
2456 | - if ($incontext['probably_delete_install']) |
|
2457 | - echo ' |
|
2577 | + if ($incontext['probably_delete_install']) { |
|
2578 | + echo ' |
|
2458 | 2579 | <label> |
2459 | 2580 | <input type="checkbox" id="delete_self" onclick="doTheDelete();"> |
2460 | 2581 | <strong>', $txt['delete_installer'], !isset($_SESSION['installer_temp_ftp']) ? ' ' . $txt['delete_installer_maybe'] : '', '</strong> |
@@ -2470,6 +2591,7 @@ discard block |
||
2470 | 2591 | theCheck.disabled = true; |
2471 | 2592 | } |
2472 | 2593 | </script>'; |
2594 | + } |
|
2473 | 2595 | |
2474 | 2596 | echo ' |
2475 | 2597 | <p>', sprintf($txt['go_to_your_forum'], $boardurl . '/index.php'), '</p> |
@@ -23,11 +23,13 @@ discard block |
||
23 | 23 | |
24 | 24 | $editor_context = &$context['controls']['richedit'][$editor_id]; |
25 | 25 | |
26 | - if ($smileyContainer === null) |
|
27 | - $editor_context['sce_options']['emoticonsEnabled'] = false; |
|
26 | + if ($smileyContainer === null) { |
|
27 | + $editor_context['sce_options']['emoticonsEnabled'] = false; |
|
28 | + } |
|
28 | 29 | |
29 | - if ($bbcContainer === null) |
|
30 | - $editor_context['sce_options']['toolbar'] = ''; |
|
30 | + if ($bbcContainer === null) { |
|
31 | + $editor_context['sce_options']['toolbar'] = ''; |
|
32 | + } |
|
31 | 33 | |
32 | 34 | echo ' |
33 | 35 | <textarea class="editor" name="', $editor_id, '" id="', $editor_id, '" cols="600" onselect="storeCaret(this);" onclick="storeCaret(this);" onkeyup="storeCaret(this);" onchange="storeCaret(this);" tabindex="', $context['tabindex']++, '" style="width: ', $editor_context['width'], '; height: ', $editor_context['height'], ';', isset($context['post_error']['no_message']) || isset($context['post_error']['long_message']) ? 'border: 1px solid red;' : '', '"', !empty($context['editor']['required']) ? ' required' : '', '>', $editor_context['value'], '</textarea> |
@@ -40,18 +42,21 @@ discard block |
||
40 | 42 | var textarea = $("#', $editor_id, '").get(0); |
41 | 43 | sceditor.create(textarea, ', $smcFunc['json_encode']($editor_context['sce_options'], JSON_PRETTY_PRINT), ');'; |
42 | 44 | |
43 | - if ($editor_context['sce_options']['emoticonsEnabled']) |
|
44 | - echo ' |
|
45 | + if ($editor_context['sce_options']['emoticonsEnabled']) { |
|
46 | + echo ' |
|
45 | 47 | sceditor.instance(textarea).createPermanentDropDown();'; |
48 | + } |
|
46 | 49 | |
47 | - if (empty($editor_context['rich_active'])) |
|
48 | - echo ' |
|
50 | + if (empty($editor_context['rich_active'])) { |
|
51 | + echo ' |
|
49 | 52 | sceditor.instance(textarea).toggleSourceMode();'; |
53 | + } |
|
50 | 54 | |
51 | - if (isset($context['post_error']['no_message']) || isset($context['post_error']['long_message'])) |
|
52 | - echo ' |
|
55 | + if (isset($context['post_error']['no_message']) || isset($context['post_error']['long_message'])) { |
|
56 | + echo ' |
|
53 | 57 | $(".sceditor-container").find("textarea").each(function() {$(this).css({border: "1px solid red"})}); |
54 | 58 | $(".sceditor-container").find("iframe").each(function() {$(this).css({border: "1px solid red"})});'; |
59 | + } |
|
55 | 60 | |
56 | 61 | echo ' |
57 | 62 | });'; |
@@ -88,42 +93,47 @@ discard block |
||
88 | 93 | |
89 | 94 | $tempTab = $context['tabindex']; |
90 | 95 | |
91 | - if (!empty($context['drafts_pm_save'])) |
|
92 | - $tempTab++; |
|
93 | - elseif (!empty($context['drafts_save'])) |
|
94 | - $tempTab++; |
|
95 | - elseif ($editor_context['preview_type']) |
|
96 | - $tempTab++; |
|
97 | - elseif ($context['show_spellchecking']) |
|
98 | - $tempTab++; |
|
96 | + if (!empty($context['drafts_pm_save'])) { |
|
97 | + $tempTab++; |
|
98 | + } elseif (!empty($context['drafts_save'])) { |
|
99 | + $tempTab++; |
|
100 | + } elseif ($editor_context['preview_type']) { |
|
101 | + $tempTab++; |
|
102 | + } elseif ($context['show_spellchecking']) { |
|
103 | + $tempTab++; |
|
104 | + } |
|
99 | 105 | |
100 | 106 | $tempTab++; |
101 | 107 | $context['tabindex'] = $tempTab; |
102 | 108 | |
103 | - if (!empty($context['drafts_pm_save'])) |
|
104 | - echo ' |
|
109 | + if (!empty($context['drafts_pm_save'])) { |
|
110 | + echo ' |
|
105 | 111 | <input type="submit" name="save_draft" value="', $txt['draft_save'], '" tabindex="', --$tempTab, '" onclick="submitThisOnce(this);" accesskey="d" class="button"> |
106 | 112 | <input type="hidden" id="id_pm_draft" name="id_pm_draft" value="', empty($context['id_pm_draft']) ? 0 : $context['id_pm_draft'], '">'; |
113 | + } |
|
107 | 114 | |
108 | - if (!empty($context['drafts_save'])) |
|
109 | - echo ' |
|
115 | + if (!empty($context['drafts_save'])) { |
|
116 | + echo ' |
|
110 | 117 | <input type="submit" name="save_draft" value="', $txt['draft_save'], '" tabindex="', --$tempTab, '" onclick="return confirm(' . JavaScriptEscape($txt['draft_save_note']) . ') && submitThisOnce(this);" accesskey="d" class="button"> |
111 | 118 | <input type="hidden" id="id_draft" name="id_draft" value="', empty($context['id_draft']) ? 0 : $context['id_draft'], '">'; |
119 | + } |
|
112 | 120 | |
113 | - if ($context['show_spellchecking']) |
|
114 | - echo ' |
|
121 | + if ($context['show_spellchecking']) { |
|
122 | + echo ' |
|
115 | 123 | <input type="button" value="', $txt['spell_check'], '" tabindex="', --$tempTab, '" onclick="oEditorHandle_', $editor_id, '.spellCheckStart();" class="button">'; |
124 | + } |
|
116 | 125 | |
117 | - if ($editor_context['preview_type']) |
|
118 | - echo ' |
|
126 | + if ($editor_context['preview_type']) { |
|
127 | + echo ' |
|
119 | 128 | <input type="submit" name="preview" value="', isset($editor_context['labels']['preview_button']) ? $editor_context['labels']['preview_button'] : $txt['preview'], '" tabindex="', --$tempTab, '" onclick="', $editor_context['preview_type'] == 2 ? '' : 'return submitThisOnce(this);', '" accesskey="p" class="button">'; |
129 | + } |
|
120 | 130 | |
121 | 131 | echo ' |
122 | 132 | <input type="submit" value="', isset($editor_context['labels']['post_button']) ? $editor_context['labels']['post_button'] : $txt['post'], '" name="post" tabindex="', --$tempTab, '" onclick="return submitThisOnce(this);" accesskey="s" class="button">'; |
123 | 133 | |
124 | 134 | // Load in the PM autosaver if it's enabled |
125 | - if (!empty($context['drafts_pm_save']) && !empty($context['drafts_autosave'])) |
|
126 | - echo ' |
|
135 | + if (!empty($context['drafts_pm_save']) && !empty($context['drafts_autosave'])) { |
|
136 | + echo ' |
|
127 | 137 | <span class="righttext padding" style="display: block"> |
128 | 138 | <span id="throbber" style="display:none"><img src="' . $settings['images_url'] . '/loading_sm.gif" alt="" class="centericon"></span> |
129 | 139 | <span id="draft_lastautosave" ></span> |
@@ -141,10 +151,11 @@ discard block |
||
141 | 151 | iFreq: ', (empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000), ' |
142 | 152 | }); |
143 | 153 | </script>'; |
154 | + } |
|
144 | 155 | |
145 | 156 | // Start an instance of the auto saver if its enabled |
146 | - if (!empty($context['drafts_save']) && !empty($context['drafts_autosave'])) |
|
147 | - echo ' |
|
157 | + if (!empty($context['drafts_save']) && !empty($context['drafts_autosave'])) { |
|
158 | + echo ' |
|
148 | 159 | <span class="righttext padding" style="display: block"> |
149 | 160 | <span id="throbber" style="display:none"><img src="', $settings['images_url'], '/loading_sm.gif" alt="" class="centericon"></span> |
150 | 161 | <span id="draft_lastautosave" ></span> |
@@ -161,7 +172,8 @@ discard block |
||
161 | 172 | iFreq: ', $context['drafts_autosave_frequency'], ' |
162 | 173 | }); |
163 | 174 | </script>'; |
164 | -} |
|
175 | + } |
|
176 | + } |
|
165 | 177 | |
166 | 178 | /** |
167 | 179 | * This template displays a verification form |
@@ -178,51 +190,57 @@ discard block |
||
178 | 190 | $verify_context = &$context['controls']['verification'][$verify_id]; |
179 | 191 | |
180 | 192 | // Keep track of where we are. |
181 | - if (empty($verify_context['tracking']) || $reset) |
|
182 | - $verify_context['tracking'] = 0; |
|
193 | + if (empty($verify_context['tracking']) || $reset) { |
|
194 | + $verify_context['tracking'] = 0; |
|
195 | + } |
|
183 | 196 | |
184 | 197 | // How many items are there to display in total. |
185 | 198 | $total_items = count($verify_context['questions']) + ($verify_context['show_visual'] || $verify_context['can_recaptcha'] ? 1 : 0); |
186 | 199 | |
187 | 200 | // If we've gone too far, stop. |
188 | - if ($verify_context['tracking'] > $total_items) |
|
189 | - return false; |
|
201 | + if ($verify_context['tracking'] > $total_items) { |
|
202 | + return false; |
|
203 | + } |
|
190 | 204 | |
191 | 205 | // Loop through each item to show them. |
192 | 206 | for ($i = 0; $i < $total_items; $i++) |
193 | 207 | { |
194 | 208 | // If we're after a single item only show it if we're in the right place. |
195 | - if ($display_type == 'single' && $verify_context['tracking'] != $i) |
|
196 | - continue; |
|
209 | + if ($display_type == 'single' && $verify_context['tracking'] != $i) { |
|
210 | + continue; |
|
211 | + } |
|
197 | 212 | |
198 | - if ($display_type != 'single') |
|
199 | - echo ' |
|
213 | + if ($display_type != 'single') { |
|
214 | + echo ' |
|
200 | 215 | <div id="verification_control_', $i, '" class="verification_control">'; |
216 | + } |
|
201 | 217 | |
202 | 218 | // Display empty field, but only if we have one, and it's the first time. |
203 | - if ($verify_context['empty_field'] && empty($i)) |
|
204 | - echo ' |
|
219 | + if ($verify_context['empty_field'] && empty($i)) { |
|
220 | + echo ' |
|
205 | 221 | <div class="smalltext vv_special"> |
206 | 222 | ', $txt['visual_verification_hidden'], ': |
207 | 223 | <input type="text" name="', $_SESSION[$verify_id . '_vv']['empty_field'], '" autocomplete="off" size="30" value=""> |
208 | 224 | </div>'; |
225 | + } |
|
209 | 226 | |
210 | 227 | // Do the actual stuff |
211 | 228 | if ($i == 0 && ($verify_context['show_visual'] || $verify_context['can_recaptcha'])) |
212 | 229 | { |
213 | 230 | if ($verify_context['show_visual']) |
214 | 231 | { |
215 | - if ($context['use_graphic_library']) |
|
216 | - echo ' |
|
232 | + if ($context['use_graphic_library']) { |
|
233 | + echo ' |
|
217 | 234 | <img src="', $verify_context['image_href'], '" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '">'; |
218 | - else |
|
219 | - echo ' |
|
235 | + } else { |
|
236 | + echo ' |
|
220 | 237 | <img src="', $verify_context['image_href'], ';letter=1" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_1"> |
221 | 238 | <img src="', $verify_context['image_href'], ';letter=2" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_2"> |
222 | 239 | <img src="', $verify_context['image_href'], ';letter=3" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_3"> |
223 | 240 | <img src="', $verify_context['image_href'], ';letter=4" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_4"> |
224 | 241 | <img src="', $verify_context['image_href'], ';letter=5" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_5"> |
225 | 242 | <img src="', $verify_context['image_href'], ';letter=6" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_6">'; |
243 | + } |
|
226 | 244 | |
227 | 245 | echo ' |
228 | 246 | <div class="smalltext" style="margin: 4px 0 8px 0;"> |
@@ -240,8 +258,7 @@ discard block |
||
240 | 258 | <br> |
241 | 259 | <script type="text/javascript" src="https://www.google.com/recaptcha/api.js?hl='.$lang.'"></script>'; |
242 | 260 | } |
243 | - } |
|
244 | - else |
|
261 | + } else |
|
245 | 262 | { |
246 | 263 | // Where in the question array is this question? |
247 | 264 | $qIndex = $verify_context['show_visual'] ? $i - 1 : $i; |
@@ -253,21 +270,24 @@ discard block |
||
253 | 270 | </div>'; |
254 | 271 | } |
255 | 272 | |
256 | - if ($display_type != 'single') |
|
257 | - echo ' |
|
273 | + if ($display_type != 'single') { |
|
274 | + echo ' |
|
258 | 275 | </div><!-- #verification_control_[i] -->'; |
276 | + } |
|
259 | 277 | |
260 | 278 | // If we were displaying just one and we did it, break. |
261 | - if ($display_type == 'single' && $verify_context['tracking'] == $i) |
|
262 | - break; |
|
279 | + if ($display_type == 'single' && $verify_context['tracking'] == $i) { |
|
280 | + break; |
|
281 | + } |
|
263 | 282 | } |
264 | 283 | |
265 | 284 | // Assume we found something, always. |
266 | 285 | $verify_context['tracking']++; |
267 | 286 | |
268 | 287 | // Tell something displaying piecemeal to keep going. |
269 | - if ($display_type == 'single') |
|
270 | - return true; |
|
271 | -} |
|
288 | + if ($display_type == 'single') { |
|
289 | + return true; |
|
290 | + } |
|
291 | + } |
|
272 | 292 | |
273 | 293 | ?> |
274 | 294 | \ No newline at end of file |
@@ -22,24 +22,26 @@ discard block |
||
22 | 22 | <script>'; |
23 | 23 | |
24 | 24 | // When using Go Back due to fatal_error, allow the form to be re-submitted with changes. |
25 | - if (isBrowser('is_firefox')) |
|
26 | - echo ' |
|
25 | + if (isBrowser('is_firefox')) { |
|
26 | + echo ' |
|
27 | 27 | window.addEventListener("pageshow", reActivate, false);'; |
28 | + } |
|
28 | 29 | |
29 | 30 | // Start with message icons - and any missing from this theme. |
30 | 31 | echo ' |
31 | 32 | var icon_urls = {'; |
32 | 33 | |
33 | - foreach ($context['icons'] as $icon) |
|
34 | - echo ' |
|
34 | + foreach ($context['icons'] as $icon) { |
|
35 | + echo ' |
|
35 | 36 | \'', $icon['value'], '\': \'', $icon['url'], '\'', $icon['is_last'] ? '' : ','; |
37 | + } |
|
36 | 38 | |
37 | 39 | echo ' |
38 | 40 | };'; |
39 | 41 | |
40 | 42 | // If this is a poll - use some javascript to ensure the user doesn't create a poll with illegal option combinations. |
41 | - if ($context['make_poll']) |
|
42 | - echo ' |
|
43 | + if ($context['make_poll']) { |
|
44 | + echo ' |
|
43 | 45 | var pollOptionNum = 0, pollTabIndex; |
44 | 46 | var pollOptionId = ', $context['last_choice_id'], '; |
45 | 47 | function addPollOption() |
@@ -58,11 +60,13 @@ discard block |
||
58 | 60 | |
59 | 61 | setOuterHTML(document.getElementById(\'pollMoreOptions\'), ', JavaScriptEscape('<dt><label for="options-'), ' + pollOptionId + ', JavaScriptEscape('">' . $txt['option'] . ' '), ' + pollOptionNum + ', JavaScriptEscape('</label>:</dt><dd><input type="text" name="options['), ' + pollOptionId + ', JavaScriptEscape(']" id="options-'), ' + pollOptionId + ', JavaScriptEscape('" value="" size="80" maxlength="255" tabindex="'), ' + pollTabIndex + ', JavaScriptEscape('"></dd><p id="pollMoreOptions"></p>'), '); |
60 | 62 | }'; |
63 | + } |
|
61 | 64 | |
62 | 65 | // If we are making a calendar event we want to ensure we show the current days in a month etc... this is done here. |
63 | - if ($context['make_event']) |
|
64 | - echo ' |
|
66 | + if ($context['make_event']) { |
|
67 | + echo ' |
|
65 | 68 | var monthLength = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];'; |
69 | + } |
|
66 | 70 | |
67 | 71 | // End of the javascript, start the form and display the link tree. |
68 | 72 | echo ' |
@@ -83,9 +87,10 @@ discard block |
||
83 | 87 | </div> |
84 | 88 | <br>'; |
85 | 89 | |
86 | - if ($context['make_event'] && (!$context['event']['new'] || !empty($context['current_board']))) |
|
87 | - echo ' |
|
90 | + if ($context['make_event'] && (!$context['event']['new'] || !empty($context['current_board']))) { |
|
91 | + echo ' |
|
88 | 92 | <input type="hidden" name="eventid" value="', $context['event']['id'], '">'; |
93 | + } |
|
89 | 94 | |
90 | 95 | // Start the main table. |
91 | 96 | echo ' |
@@ -110,26 +115,29 @@ discard block |
||
110 | 115 | </div>'; |
111 | 116 | |
112 | 117 | // If this won't be approved let them know! |
113 | - if (!$context['becomes_approved']) |
|
114 | - echo ' |
|
118 | + if (!$context['becomes_approved']) { |
|
119 | + echo ' |
|
115 | 120 | <div class="noticebox"> |
116 | 121 | <em>', $txt['wait_for_approval'], '</em> |
117 | 122 | <input type="hidden" name="not_approved" value="1"> |
118 | 123 | </div>'; |
124 | + } |
|
119 | 125 | |
120 | 126 | // If it's locked, show a message to warn the replier. |
121 | - if (!empty($context['locked'])) |
|
122 | - echo ' |
|
127 | + if (!empty($context['locked'])) { |
|
128 | + echo ' |
|
123 | 129 | <div class="errorbox"> |
124 | 130 | ', $txt['topic_locked_no_reply'], ' |
125 | 131 | </div>'; |
132 | + } |
|
126 | 133 | |
127 | - if (!empty($modSettings['drafts_post_enabled'])) |
|
128 | - echo ' |
|
134 | + if (!empty($modSettings['drafts_post_enabled'])) { |
|
135 | + echo ' |
|
129 | 136 | <div id="draft_section" class="infobox"', isset($context['draft_saved']) ? '' : ' style="display: none;"', '>', |
130 | 137 | sprintf($txt['draft_saved'], $scripturl . '?action=profile;u=' . $context['user']['id'] . ';area=showdrafts'), ' |
131 | 138 | ', (!empty($modSettings['drafts_keep_days']) ? ' <strong>' . sprintf($txt['draft_save_warning'], $modSettings['drafts_keep_days']) . '</strong>' : ''), ' |
132 | 139 | </div>'; |
140 | + } |
|
133 | 141 | |
134 | 142 | // The post header... important stuff |
135 | 143 | template_post_header(); |
@@ -162,9 +170,10 @@ discard block |
||
162 | 170 | echo ' |
163 | 171 | <optgroup label="', $category['name'], '">'; |
164 | 172 | |
165 | - foreach ($category['boards'] as $board) |
|
166 | - echo ' |
|
173 | + foreach ($category['boards'] as $board) { |
|
174 | + echo ' |
|
167 | 175 | <option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=>' : '', ' ', $board['name'], '</option>'; |
176 | + } |
|
168 | 177 | echo ' |
169 | 178 | </optgroup>'; |
170 | 179 | } |
@@ -200,9 +209,10 @@ discard block |
||
200 | 209 | <span class="label">', $txt['calendar_timezone'], '</span> |
201 | 210 | <select name="tz" id="tz"', !empty($context['event']['allday']) ? ' disabled' : '', '>'; |
202 | 211 | |
203 | - foreach ($context['all_timezones'] as $tz => $tzname) |
|
204 | - echo ' |
|
212 | + foreach ($context['all_timezones'] as $tz => $tzname) { |
|
213 | + echo ' |
|
205 | 214 | <option', is_numeric($tz) ? ' value="" disabled' : ' value="' . $tz . '"', $tz === $context['event']['tz'] ? ' selected' : '', '>', $tzname, '</option>'; |
215 | + } |
|
206 | 216 | |
207 | 217 | echo ' |
208 | 218 | </select> |
@@ -231,14 +241,15 @@ discard block |
||
231 | 241 | </dd>'; |
232 | 242 | |
233 | 243 | // Loop through all the choices and print them out. |
234 | - foreach ($context['choices'] as $choice) |
|
235 | - echo ' |
|
244 | + foreach ($context['choices'] as $choice) { |
|
245 | + echo ' |
|
236 | 246 | <dt> |
237 | 247 | <label for="options-', $choice['id'], '">', $txt['option'], ' ', $choice['number'], '</label>: |
238 | 248 | </dt> |
239 | 249 | <dd> |
240 | 250 | <input type="text" name="options[', $choice['id'], ']" id="options-', $choice['id'], '" value="', $choice['label'], '" tabindex="', $context['tabindex']++, '" size="80" maxlength="255"> |
241 | 251 | </dd>'; |
252 | + } |
|
242 | 253 | |
243 | 254 | echo ' |
244 | 255 | <p id="pollMoreOptions"></p> |
@@ -268,14 +279,15 @@ discard block |
||
268 | 279 | <input type="checkbox" id="poll_change_vote" name="poll_change_vote"', !empty($context['poll']['change_vote']) ? ' checked' : '', '> |
269 | 280 | </dd>'; |
270 | 281 | |
271 | - if ($context['poll_options']['guest_vote_enabled']) |
|
272 | - echo ' |
|
282 | + if ($context['poll_options']['guest_vote_enabled']) { |
|
283 | + echo ' |
|
273 | 284 | <dt> |
274 | 285 | <label for="poll_guest_vote">', $txt['poll_guest_vote'], ':</label> |
275 | 286 | </dt> |
276 | 287 | <dd> |
277 | 288 | <input type="checkbox" id="poll_guest_vote" name="poll_guest_vote"', !empty($context['poll_options']['guest_vote']) ? ' checked' : '', '> |
278 | 289 | </dd>'; |
290 | + } |
|
279 | 291 | |
280 | 292 | echo ' |
281 | 293 | <dt> |
@@ -296,8 +308,8 @@ discard block |
||
296 | 308 | ', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message'); |
297 | 309 | |
298 | 310 | // If we're editing and displaying edit details, show a box where they can say why |
299 | - if (isset($context['editing']) && $modSettings['show_modify']) |
|
300 | - echo ' |
|
311 | + if (isset($context['editing']) && $modSettings['show_modify']) { |
|
312 | + echo ' |
|
301 | 313 | <dl> |
302 | 314 | <dt class="clear"> |
303 | 315 | <span id="caption_edit_reason">', $txt['reason_for_edit'], ':</span> |
@@ -306,20 +318,23 @@ discard block |
||
306 | 318 | <input type="text" name="modify_reason"', isset($context['last_modified_reason']) ? ' value="' . $context['last_modified_reason'] . '"' : '', ' tabindex="', $context['tabindex']++, '" size="80" maxlength="80"> |
307 | 319 | </dd> |
308 | 320 | </dl>'; |
321 | + } |
|
309 | 322 | |
310 | 323 | // If this message has been edited in the past - display when it was. |
311 | - if (isset($context['last_modified'])) |
|
312 | - echo ' |
|
324 | + if (isset($context['last_modified'])) { |
|
325 | + echo ' |
|
313 | 326 | <div class="padding smalltext"> |
314 | 327 | ', $context['last_modified_text'], ' |
315 | 328 | </div>'; |
329 | + } |
|
316 | 330 | |
317 | 331 | // If the admin has enabled the hiding of the additional options - show a link and image for it. |
318 | - if (!empty($modSettings['additional_options_collapsable'])) |
|
319 | - echo ' |
|
332 | + if (!empty($modSettings['additional_options_collapsable'])) { |
|
333 | + echo ' |
|
320 | 334 | <div id="postAdditionalOptionsHeader"> |
321 | 335 | <strong><a href="#" id="postMoreExpandLink"> ', $context['can_post_attachment'] ? $txt['post_additionalopt_attach'] : $txt['post_additionalopt'], '</a></strong> |
322 | 336 | </div>'; |
337 | + } |
|
323 | 338 | |
324 | 339 | echo ' |
325 | 340 | <div id="postAdditionalOptions">'; |
@@ -352,19 +367,21 @@ discard block |
||
352 | 367 | ', $txt['uncheck_unwatchd_attach'], ': |
353 | 368 | </dd>'; |
354 | 369 | |
355 | - foreach ($context['current_attachments'] as $attachment) |
|
356 | - echo ' |
|
370 | + foreach ($context['current_attachments'] as $attachment) { |
|
371 | + echo ' |
|
357 | 372 | <dd class="smalltext"> |
358 | 373 | <label for="attachment_', $attachment['attachID'], '"><input type="checkbox" id="attachment_', $attachment['attachID'], '" name="attach_del[]" value="', $attachment['attachID'], '"', empty($attachment['unchecked']) ? ' checked' : '', '> ', $attachment['name'], (empty($attachment['approved']) ? ' (' . $txt['awaiting_approval'] . ')' : ''), |
359 | 374 | !empty($modSettings['attachmentPostLimit']) || !empty($modSettings['attachmentSizeLimit']) ? sprintf($txt['attach_kb'], comma_format(round(max($attachment['size'], 1024) / 1024), 0)) : '', '</label> |
360 | 375 | </dd>'; |
376 | + } |
|
361 | 377 | |
362 | 378 | echo ' |
363 | 379 | </dl>'; |
364 | 380 | |
365 | - if (!empty($context['files_in_session_warning'])) |
|
366 | - echo ' |
|
381 | + if (!empty($context['files_in_session_warning'])) { |
|
382 | + echo ' |
|
367 | 383 | <div class="smalltext">', $context['files_in_session_warning'], '</div>'; |
384 | + } |
|
368 | 385 | } |
369 | 386 | |
370 | 387 | // Is the user allowed to post any additional ones? If so give them the boxes to do it! |
@@ -429,13 +446,14 @@ discard block |
||
429 | 446 | <div class="fallback"> |
430 | 447 | <input type="file" multiple="multiple" name="attachment[]" id="attachment1" class="fallback"> (<a href="javascript:void(0);" onclick="cleanFileInput(\'attachment1\');">', $txt['clean_attach'], '</a>)'; |
431 | 448 | |
432 | - if (!empty($modSettings['attachmentSizeLimit'])) |
|
433 | - echo ' |
|
449 | + if (!empty($modSettings['attachmentSizeLimit'])) { |
|
450 | + echo ' |
|
434 | 451 | <input type="hidden" name="MAX_FILE_SIZE" value="' . $modSettings['attachmentSizeLimit'] * 1024 . '">'; |
452 | + } |
|
435 | 453 | |
436 | 454 | // Show more boxes if they aren't approaching that limit. |
437 | - if ($context['num_allowed_attachments'] > 1) |
|
438 | - echo ' |
|
455 | + if ($context['num_allowed_attachments'] > 1) { |
|
456 | + echo ' |
|
439 | 457 | <script> |
440 | 458 | var allowed_attachments = ', $context['num_allowed_attachments'], '; |
441 | 459 | var current_attachment = 1; |
@@ -455,6 +473,7 @@ discard block |
||
455 | 473 | <a href="#" onclick="addAttachment(); return false;">(', $txt['more_attachments'], ')</a> |
456 | 474 | </div><!-- .fallback --> |
457 | 475 | </div><!-- #attachUpload -->'; |
476 | + } |
|
458 | 477 | |
459 | 478 | echo ' |
460 | 479 | </dd>'; |
@@ -466,21 +485,25 @@ discard block |
||
466 | 485 | <dd class="smalltext">'; |
467 | 486 | |
468 | 487 | // Show some useful information such as allowed extensions, maximum size and amount of attachments allowed. |
469 | - if (!empty($modSettings['attachmentCheckExtensions'])) |
|
470 | - echo ' |
|
488 | + if (!empty($modSettings['attachmentCheckExtensions'])) { |
|
489 | + echo ' |
|
471 | 490 | ', $txt['allowed_types'], ': ', $context['allowed_extensions'], '<br>'; |
491 | + } |
|
472 | 492 | |
473 | - if (!empty($context['attachment_restrictions'])) |
|
474 | - echo ' |
|
493 | + if (!empty($context['attachment_restrictions'])) { |
|
494 | + echo ' |
|
475 | 495 | ', $txt['attach_restrictions'], ' ', implode(', ', $context['attachment_restrictions']), '<br>'; |
496 | + } |
|
476 | 497 | |
477 | - if ($context['num_allowed_attachments'] == 0) |
|
478 | - echo ' |
|
498 | + if ($context['num_allowed_attachments'] == 0) { |
|
499 | + echo ' |
|
479 | 500 | ', $txt['attach_limit_nag'], '<br>'; |
501 | + } |
|
480 | 502 | |
481 | - if (!$context['can_post_attachment_unapproved']) |
|
482 | - echo ' |
|
503 | + if (!$context['can_post_attachment_unapproved']) { |
|
504 | + echo ' |
|
483 | 505 | <span class="alert">', $txt['attachment_requires_approval'], '</span>', '<br>'; |
506 | + } |
|
484 | 507 | |
485 | 508 | echo ' |
486 | 509 | </dd> |
@@ -504,24 +527,26 @@ discard block |
||
504 | 527 | <dt><strong>', $txt['subject'], '</strong></dt> |
505 | 528 | <dd><strong>', $txt['draft_saved_on'], '</strong></dd>'; |
506 | 529 | |
507 | - foreach ($context['drafts'] as $draft) |
|
508 | - echo ' |
|
530 | + foreach ($context['drafts'] as $draft) { |
|
531 | + echo ' |
|
509 | 532 | <dt>', $draft['link'], '</dt> |
510 | 533 | <dd>', $draft['poster_time'], '</dd>'; |
534 | + } |
|
511 | 535 | echo ' |
512 | 536 | </dl> |
513 | 537 | </div>'; |
514 | 538 | } |
515 | 539 | |
516 | 540 | // Is visual verification enabled? |
517 | - if ($context['require_verification']) |
|
518 | - echo ' |
|
541 | + if ($context['require_verification']) { |
|
542 | + echo ' |
|
519 | 543 | <div class="post_verification"> |
520 | 544 | <span', !empty($context['post_error']['need_qr_verification']) ? ' class="error"' : '', '> |
521 | 545 | <strong>', $txt['verification'], ':</strong> |
522 | 546 | </span> |
523 | 547 | ', template_control_verification($context['visual_verification_id'], 'all'), ' |
524 | 548 | </div>'; |
549 | + } |
|
525 | 550 | |
526 | 551 | // Finally, the submit buttons. |
527 | 552 | echo ' |
@@ -530,9 +555,10 @@ discard block |
||
530 | 555 | ', template_control_richedit_buttons($context['post_box_name']); |
531 | 556 | |
532 | 557 | // Option to delete an event if user is editing one. |
533 | - if ($context['make_event'] && !$context['event']['new']) |
|
534 | - echo ' |
|
558 | + if ($context['make_event'] && !$context['event']['new']) { |
|
559 | + echo ' |
|
535 | 560 | <input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['event_delete_confirm'] ,'" class="button you_sure">'; |
561 | + } |
|
536 | 562 | |
537 | 563 | echo ' |
538 | 564 | </span> |
@@ -541,9 +567,10 @@ discard block |
||
541 | 567 | <br class="clear">'; |
542 | 568 | |
543 | 569 | // Assuming this isn't a new topic pass across the last message id. |
544 | - if (isset($context['topic_last_message'])) |
|
545 | - echo ' |
|
570 | + if (isset($context['topic_last_message'])) { |
|
571 | + echo ' |
|
546 | 572 | <input type="hidden" name="last_msg" value="', $context['topic_last_message'], '">'; |
573 | + } |
|
547 | 574 | |
548 | 575 | echo ' |
549 | 576 | <input type="hidden" name="additional_options" id="additional_options" value="', $context['show_additional_options'] ? '1' : '0', '"> |
@@ -564,13 +591,14 @@ discard block |
||
564 | 591 | </h5> |
565 | 592 | - %PostTime% » <span class="new_posts" id="image_new_%PostID%">' . $txt['new'] . '</span>'; |
566 | 593 | |
567 | - if ($context['can_quote']) |
|
568 | - $newPostsHTML .= ' |
|
594 | + if ($context['can_quote']) { |
|
595 | + $newPostsHTML .= ' |
|
569 | 596 | <ul class="quickbuttons sf-js-enabled sf-arrows" id="msg_%PostID%_quote" style="touch-action: pan-y;"> |
570 | 597 | <li id="post_modify"> |
571 | 598 | <a href="#postmodify" onclick="return insertQuoteFast(%PostID%);" class="quote_button"><span class="generic_icons quote"></span>' . $txt['quote'] . '</a> |
572 | 599 | </li> |
573 | 600 | </ul>'; |
601 | + } |
|
574 | 602 | |
575 | 603 | $newPostsHTML .= ' |
576 | 604 | <br class="clear"> |
@@ -596,16 +624,17 @@ discard block |
||
596 | 624 | sSessionVar: ', JavaScriptEscape($context['session_var']), ', |
597 | 625 | newPostsTemplate:', JavaScriptEscape($newPostsHTML); |
598 | 626 | |
599 | - if (!empty($context['current_board'])) |
|
600 | - echo ', |
|
627 | + if (!empty($context['current_board'])) { |
|
628 | + echo ', |
|
601 | 629 | iCurrentBoard: ', $context['current_board'], ''; |
630 | + } |
|
602 | 631 | |
603 | 632 | echo ' |
604 | 633 | });'; |
605 | 634 | |
606 | 635 | // Code for showing and hiding additional options. |
607 | - if (!empty($modSettings['additional_options_collapsable'])) |
|
608 | - echo ' |
|
636 | + if (!empty($modSettings['additional_options_collapsable'])) { |
|
637 | + echo ' |
|
609 | 638 | var oSwapAdditionalOptions = new smc_Toggle({ |
610 | 639 | bToggleEnabled: true, |
611 | 640 | bCurrentlyCollapsed: ', $context['show_additional_options'] ? 'false' : 'true', ', |
@@ -633,10 +662,11 @@ discard block |
||
633 | 662 | } |
634 | 663 | ] |
635 | 664 | });'; |
665 | + } |
|
636 | 666 | |
637 | 667 | // Code for showing and hiding drafts |
638 | - if (!empty($context['drafts'])) |
|
639 | - echo ' |
|
668 | + if (!empty($context['drafts'])) { |
|
669 | + echo ' |
|
640 | 670 | var oSwapDraftOptions = new smc_Toggle({ |
641 | 671 | bToggleEnabled: true, |
642 | 672 | bCurrentlyCollapsed: true, |
@@ -658,6 +688,7 @@ discard block |
||
658 | 688 | } |
659 | 689 | ] |
660 | 690 | });'; |
691 | + } |
|
661 | 692 | |
662 | 693 | echo ' |
663 | 694 | var oEditorID = "', $context['post_box_name'] ,'"; |
@@ -678,8 +709,9 @@ discard block |
||
678 | 709 | foreach ($context['previous_posts'] as $post) |
679 | 710 | { |
680 | 711 | $ignoring = false; |
681 | - if (!empty($post['is_ignored'])) |
|
682 | - $ignored_posts[] = $ignoring = $post['id']; |
|
712 | + if (!empty($post['is_ignored'])) { |
|
713 | + $ignored_posts[] = $ignoring = $post['id']; |
|
714 | + } |
|
683 | 715 | |
684 | 716 | echo ' |
685 | 717 | <div class="windowbg"> |
@@ -689,22 +721,24 @@ discard block |
||
689 | 721 | </h5> |
690 | 722 | - ', $post['time']; |
691 | 723 | |
692 | - if ($context['can_quote']) |
|
693 | - echo ' |
|
724 | + if ($context['can_quote']) { |
|
725 | + echo ' |
|
694 | 726 | <ul class="quickbuttons" id="msg_', $post['id'], '_quote"> |
695 | 727 | <li style="display:none;" id="quoteSelected_', $post['id'], '" data-msgid="', $post['id'], '"><a href="javascript:void(0)"><span class="generic_icons quote_selected"></span>', $txt['quote_selected_action'] ,'</a></li> |
696 | 728 | <li id="post_modify"><a href="#postmodify" onclick="return insertQuoteFast(', $post['id'], ');"><span class="generic_icons quote"></span>', $txt['quote'], '</a></li> |
697 | 729 | </ul>'; |
730 | + } |
|
698 | 731 | |
699 | 732 | echo ' |
700 | 733 | <br class="clear">'; |
701 | 734 | |
702 | - if ($ignoring) |
|
703 | - echo ' |
|
735 | + if ($ignoring) { |
|
736 | + echo ' |
|
704 | 737 | <div id="msg_', $post['id'], '_ignored_prompt" class="smalltext"> |
705 | 738 | ', $txt['ignoring_user'], ' |
706 | 739 | <a href="#" id="msg_', $post['id'], '_ignored_link" style="display: none;">', $txt['show_ignore_user_post'], '</a> |
707 | 740 | </div>'; |
741 | + } |
|
708 | 742 | |
709 | 743 | echo ' |
710 | 744 | <div class="list_posts smalltext" id="msg_', $post['id'], '_body" data-msgid="', $post['id'], '">', $post['message'], '</div> |
@@ -859,10 +893,10 @@ discard block |
||
859 | 893 | <div id="temporary_posting_area" style="display: none;"></div> |
860 | 894 | <script>'; |
861 | 895 | |
862 | - if ($context['close_window']) |
|
863 | - echo ' |
|
896 | + if ($context['close_window']) { |
|
897 | + echo ' |
|
864 | 898 | window.close();'; |
865 | - else |
|
899 | + } else |
|
866 | 900 | { |
867 | 901 | // Lucky for us, Internet Explorer has an "innerText" feature which basically converts entities <--> text. Use it if possible ;) |
868 | 902 | echo ' |
@@ -916,11 +950,12 @@ discard block |
||
916 | 950 | </p> |
917 | 951 | <ul>'; |
918 | 952 | |
919 | - foreach ($context['groups'] as $group) |
|
920 | - echo ' |
|
953 | + foreach ($context['groups'] as $group) { |
|
954 | + echo ' |
|
921 | 955 | <li> |
922 | 956 | <label for="who_', $group['id'], '"><input type="checkbox" name="who[', $group['id'], ']" id="who_', $group['id'], '" value="', $group['id'], '" checked> ', $group['name'], '</label> <em>(', $group['member_count'], ')</em> |
923 | 957 | </li>'; |
958 | + } |
|
924 | 959 | |
925 | 960 | echo ' |
926 | 961 | <li> |
@@ -1027,28 +1062,32 @@ discard block |
||
1027 | 1062 | foreach ($context['posting_fields'] as $pfid => $pf) |
1028 | 1063 | { |
1029 | 1064 | // We need both a label and an input |
1030 | - if (empty($pf['label']) || empty($pf['input'])) |
|
1031 | - continue; |
|
1065 | + if (empty($pf['label']) || empty($pf['input'])) { |
|
1066 | + continue; |
|
1067 | + } |
|
1032 | 1068 | |
1033 | 1069 | // The labels are pretty simple... |
1034 | 1070 | echo ' |
1035 | 1071 | <dt class="clear pf_', $pfid, '">'; |
1036 | 1072 | |
1037 | 1073 | // Any leading HTML before the label |
1038 | - if (!empty($pf['label']['before'])) |
|
1039 | - echo ' |
|
1074 | + if (!empty($pf['label']['before'])) { |
|
1075 | + echo ' |
|
1040 | 1076 | ', $pf['label']['before']; |
1077 | + } |
|
1041 | 1078 | |
1042 | - if (!empty($pf['label']['html'])) |
|
1043 | - echo $pf['label']['html']; |
|
1044 | - else |
|
1045 | - echo ' |
|
1079 | + if (!empty($pf['label']['html'])) { |
|
1080 | + echo $pf['label']['html']; |
|
1081 | + } else { |
|
1082 | + echo ' |
|
1046 | 1083 | <label for="', !empty($pf['input']['attributes']['name']) ? $pf['input']['attributes']['name'] : $pfid, '" id="caption_', $pfid, '"', !empty($pf['label']['class']) ? ' class="' . $pf['label']['class'] . '"' : '', '>', $pf['label']['text'], '</label>'; |
1084 | + } |
|
1047 | 1085 | |
1048 | 1086 | // Any trailing HTML after the label |
1049 | - if (!empty($pf['label']['after'])) |
|
1050 | - echo ' |
|
1087 | + if (!empty($pf['label']['after'])) { |
|
1088 | + echo ' |
|
1051 | 1089 | ', $pf['label']['after']; |
1090 | + } |
|
1052 | 1091 | |
1053 | 1092 | echo ' |
1054 | 1093 | </dt>'; |
@@ -1058,9 +1097,10 @@ discard block |
||
1058 | 1097 | <dd class="pf_', $pfid, '">'; |
1059 | 1098 | |
1060 | 1099 | // Any leading HTML before the main input |
1061 | - if (!empty($pf['input']['before'])) |
|
1062 | - echo ' |
|
1100 | + if (!empty($pf['input']['before'])) { |
|
1101 | + echo ' |
|
1063 | 1102 | ', $pf['input']['before']; |
1103 | + } |
|
1064 | 1104 | |
1065 | 1105 | // If there is a literal HTML string already defined, just print it. |
1066 | 1106 | if (!empty($pf['input']['html'])) |
@@ -1073,17 +1113,19 @@ discard block |
||
1073 | 1113 | echo ' |
1074 | 1114 | <input type="', $pf['input']['type'], '"'; |
1075 | 1115 | |
1076 | - if (empty($pf['input']['attributes']['name'])) |
|
1077 | - echo ' name="', $pfid, '"'; |
|
1116 | + if (empty($pf['input']['attributes']['name'])) { |
|
1117 | + echo ' name="', $pfid, '"'; |
|
1118 | + } |
|
1078 | 1119 | |
1079 | 1120 | if (!empty($pf['input']['attributes']) && is_array($pf['input']['attributes'])) |
1080 | 1121 | { |
1081 | 1122 | foreach ($pf['input']['attributes'] as $attribute => $value) |
1082 | 1123 | { |
1083 | - if (is_bool($value)) |
|
1084 | - echo $value ? ' ' . $attribute : ''; |
|
1085 | - else |
|
1086 | - echo ' ', $attribute, '="', $value, '"'; |
|
1124 | + if (is_bool($value)) { |
|
1125 | + echo $value ? ' ' . $attribute : ''; |
|
1126 | + } else { |
|
1127 | + echo ' ', $attribute, '="', $value, '"'; |
|
1128 | + } |
|
1087 | 1129 | } |
1088 | 1130 | } |
1089 | 1131 | |
@@ -1095,19 +1137,21 @@ discard block |
||
1095 | 1137 | echo ' |
1096 | 1138 | <textarea'; |
1097 | 1139 | |
1098 | - if (empty($pf['input']['attributes']['name'])) |
|
1099 | - echo ' name="', $pfid, '"'; |
|
1140 | + if (empty($pf['input']['attributes']['name'])) { |
|
1141 | + echo ' name="', $pfid, '"'; |
|
1142 | + } |
|
1100 | 1143 | |
1101 | 1144 | if (!empty($pf['input']['attributes']) && is_array($pf['input']['attributes'])) |
1102 | 1145 | { |
1103 | 1146 | foreach ($pf['input']['attributes'] as $attribute => $value) |
1104 | 1147 | { |
1105 | - if ($attribute === 'value') |
|
1106 | - continue; |
|
1107 | - elseif (is_bool($value)) |
|
1108 | - echo $value ? ' ' . $attribute : ''; |
|
1109 | - else |
|
1110 | - echo ' ', $attribute, '="', $value, '"'; |
|
1148 | + if ($attribute === 'value') { |
|
1149 | + continue; |
|
1150 | + } elseif (is_bool($value)) { |
|
1151 | + echo $value ? ' ' . $attribute : ''; |
|
1152 | + } else { |
|
1153 | + echo ' ', $attribute, '="', $value, '"'; |
|
1154 | + } |
|
1111 | 1155 | } |
1112 | 1156 | } |
1113 | 1157 | |
@@ -1120,17 +1164,19 @@ discard block |
||
1120 | 1164 | echo ' |
1121 | 1165 | <select'; |
1122 | 1166 | |
1123 | - if (empty($pf['input']['attributes']['name'])) |
|
1124 | - echo ' name="', $pfid, '"'; |
|
1167 | + if (empty($pf['input']['attributes']['name'])) { |
|
1168 | + echo ' name="', $pfid, '"'; |
|
1169 | + } |
|
1125 | 1170 | |
1126 | 1171 | if (!empty($pf['input']['attributes']) && is_array($pf['input']['attributes'])) |
1127 | 1172 | { |
1128 | 1173 | foreach ($pf['input']['attributes'] as $attribute => $value) |
1129 | 1174 | { |
1130 | - if (is_bool($value)) |
|
1131 | - echo $value ? ' ' . $attribute : ''; |
|
1132 | - else |
|
1133 | - echo ' ', $attribute, '="', $value, '"'; |
|
1175 | + if (is_bool($value)) { |
|
1176 | + echo $value ? ' ' . $attribute : ''; |
|
1177 | + } else { |
|
1178 | + echo ' ', $attribute, '="', $value, '"'; |
|
1179 | + } |
|
1134 | 1180 | } |
1135 | 1181 | } |
1136 | 1182 | |
@@ -1145,17 +1191,19 @@ discard block |
||
1145 | 1191 | echo ' |
1146 | 1192 | <optgroup'; |
1147 | 1193 | |
1148 | - if (empty($option['attributes']['label'])) |
|
1149 | - echo ' label="', $optlabel, '"'; |
|
1194 | + if (empty($option['attributes']['label'])) { |
|
1195 | + echo ' label="', $optlabel, '"'; |
|
1196 | + } |
|
1150 | 1197 | |
1151 | 1198 | if (!empty($option['attributes']) && is_array($option['attributes'])) |
1152 | 1199 | { |
1153 | 1200 | foreach ($option['attributes'] as $attribute => $value) |
1154 | 1201 | { |
1155 | - if (is_bool($value)) |
|
1156 | - echo $value ? ' ' . $attribute : ''; |
|
1157 | - else |
|
1158 | - echo ' ', $attribute, '="', $value, '"'; |
|
1202 | + if (is_bool($value)) { |
|
1203 | + echo $value ? ' ' . $attribute : ''; |
|
1204 | + } else { |
|
1205 | + echo ' ', $attribute, '="', $value, '"'; |
|
1206 | + } |
|
1159 | 1207 | } |
1160 | 1208 | } |
1161 | 1209 | |
@@ -1168,10 +1216,11 @@ discard block |
||
1168 | 1216 | |
1169 | 1217 | foreach ($grouped_option['attributes'] as $attribute => $value) |
1170 | 1218 | { |
1171 | - if (is_bool($value)) |
|
1172 | - echo $value ? ' ' . $attribute : ''; |
|
1173 | - else |
|
1174 | - echo ' ', $attribute, '="', $value, '"'; |
|
1219 | + if (is_bool($value)) { |
|
1220 | + echo $value ? ' ' . $attribute : ''; |
|
1221 | + } else { |
|
1222 | + echo ' ', $attribute, '="', $value, '"'; |
|
1223 | + } |
|
1175 | 1224 | } |
1176 | 1225 | |
1177 | 1226 | echo '>', $grouped_optlabel, '</option>'; |
@@ -1189,10 +1238,11 @@ discard block |
||
1189 | 1238 | |
1190 | 1239 | foreach ($option['attributes'] as $attribute => $value) |
1191 | 1240 | { |
1192 | - if (is_bool($value)) |
|
1193 | - echo $value ? ' ' . $attribute : ''; |
|
1194 | - else |
|
1195 | - echo ' ', $attribute, '="', $value, '"'; |
|
1241 | + if (is_bool($value)) { |
|
1242 | + echo $value ? ' ' . $attribute : ''; |
|
1243 | + } else { |
|
1244 | + echo ' ', $attribute, '="', $value, '"'; |
|
1245 | + } |
|
1196 | 1246 | } |
1197 | 1247 | |
1198 | 1248 | echo '>', $optlabel, '</option>'; |
@@ -1213,12 +1263,13 @@ discard block |
||
1213 | 1263 | { |
1214 | 1264 | foreach ($pf['input']['attributes'] as $attribute => $value) |
1215 | 1265 | { |
1216 | - if ($attribute === 'name') |
|
1217 | - continue; |
|
1218 | - elseif (is_bool($value)) |
|
1219 | - echo $value ? ' ' . $attribute : ''; |
|
1220 | - else |
|
1221 | - echo ' ', $attribute, '="', $value, '"'; |
|
1266 | + if ($attribute === 'name') { |
|
1267 | + continue; |
|
1268 | + } elseif (is_bool($value)) { |
|
1269 | + echo $value ? ' ' . $attribute : ''; |
|
1270 | + } else { |
|
1271 | + echo ' ', $attribute, '="', $value, '"'; |
|
1272 | + } |
|
1222 | 1273 | } |
1223 | 1274 | } |
1224 | 1275 | |
@@ -1231,10 +1282,11 @@ discard block |
||
1231 | 1282 | |
1232 | 1283 | foreach ($option['attributes'] as $attribute => $value) |
1233 | 1284 | { |
1234 | - if (is_bool($value)) |
|
1235 | - echo $value ? ' ' . $attribute : ''; |
|
1236 | - else |
|
1237 | - echo ' ', $attribute, '="', $value, '"'; |
|
1285 | + if (is_bool($value)) { |
|
1286 | + echo $value ? ' ' . $attribute : ''; |
|
1287 | + } else { |
|
1288 | + echo ' ', $attribute, '="', $value, '"'; |
|
1289 | + } |
|
1238 | 1290 | } |
1239 | 1291 | |
1240 | 1292 | echo ' tabindex="', $context['tabindex']++, '">', $optlabel, '</input>'; |
@@ -1245,9 +1297,10 @@ discard block |
||
1245 | 1297 | } |
1246 | 1298 | |
1247 | 1299 | // Any trailing HTML after the main input |
1248 | - if (!empty($pf['input']['after'])) |
|
1249 | - echo ' |
|
1300 | + if (!empty($pf['input']['after'])) { |
|
1301 | + echo ' |
|
1250 | 1302 | ', $pf['input']['after']; |
1303 | + } |
|
1251 | 1304 | |
1252 | 1305 | echo ' |
1253 | 1306 | </dd>'; |