@@ -75,8 +75,9 @@ discard block |
||
75 | 75 | $upcontext['inactive_timeout'] = 10; |
76 | 76 | |
77 | 77 | // The helper is crucial. Include it first thing. |
78 | -if (!file_exists($upgrade_path . '/upgrade-helper.php')) |
|
78 | +if (!file_exists($upgrade_path . '/upgrade-helper.php')) { |
|
79 | 79 | die('upgrade-helper.php not found where it was expected: ' . $upgrade_path . '/upgrade-helper.php! Make sure you have uploaded ALL files from the upgrade package. The upgrader cannot continue.'); |
80 | +} |
|
80 | 81 | |
81 | 82 | require_once($upgrade_path . '/upgrade-helper.php'); |
82 | 83 | |
@@ -107,11 +108,14 @@ discard block |
||
107 | 108 | ini_set('default_socket_timeout', 900); |
108 | 109 | } |
109 | 110 | // Clean the upgrade path if this is from the client. |
110 | -if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) |
|
111 | - for ($i = 1; $i < $_SERVER['argc']; $i++) |
|
111 | +if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) { |
|
112 | + for ($i = 1; |
|
113 | +} |
|
114 | +$i < $_SERVER['argc']; $i++) |
|
112 | 115 | { |
113 | - if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) |
|
114 | - $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
116 | + if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) { |
|
117 | + $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
118 | + } |
|
115 | 119 | } |
116 | 120 | |
117 | 121 | // Are we from the client? |
@@ -119,16 +123,17 @@ discard block |
||
119 | 123 | { |
120 | 124 | $command_line = true; |
121 | 125 | $disable_security = true; |
122 | -} |
|
123 | -else |
|
126 | +} else { |
|
124 | 127 | $command_line = false; |
128 | +} |
|
125 | 129 | |
126 | 130 | // Load this now just because we can. |
127 | 131 | require_once($upgrade_path . '/Settings.php'); |
128 | 132 | |
129 | 133 | // We don't use "-utf8" anymore... Tweak the entry that may have been loaded by Settings.php |
130 | -if (isset($language)) |
|
134 | +if (isset($language)) { |
|
131 | 135 | $language = str_ireplace('-utf8', '', $language); |
136 | +} |
|
132 | 137 | |
133 | 138 | // Are we logged in? |
134 | 139 | if (isset($upgradeData)) |
@@ -136,10 +141,12 @@ discard block |
||
136 | 141 | $upcontext['user'] = json_decode(base64_decode($upgradeData), true); |
137 | 142 | |
138 | 143 | // Check for sensible values. |
139 | - if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) |
|
140 | - $upcontext['user']['started'] = time(); |
|
141 | - if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) |
|
142 | - $upcontext['user']['updated'] = 0; |
|
144 | + if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) { |
|
145 | + $upcontext['user']['started'] = time(); |
|
146 | + } |
|
147 | + if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) { |
|
148 | + $upcontext['user']['updated'] = 0; |
|
149 | + } |
|
143 | 150 | |
144 | 151 | $upcontext['started'] = $upcontext['user']['started']; |
145 | 152 | $upcontext['updated'] = $upcontext['user']['updated']; |
@@ -204,8 +211,9 @@ discard block |
||
204 | 211 | 'db_error_skip' => true, |
205 | 212 | ) |
206 | 213 | ); |
207 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
208 | - $modSettings[$row['variable']] = $row['value']; |
|
214 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
215 | + $modSettings[$row['variable']] = $row['value']; |
|
216 | + } |
|
209 | 217 | $smcFunc['db_free_result']($request); |
210 | 218 | } |
211 | 219 | |
@@ -215,14 +223,17 @@ discard block |
||
215 | 223 | $modSettings['theme_url'] = 'Themes/default'; |
216 | 224 | $modSettings['images_url'] = 'Themes/default/images'; |
217 | 225 | } |
218 | -if (!isset($settings['default_theme_url'])) |
|
226 | +if (!isset($settings['default_theme_url'])) { |
|
219 | 227 | $settings['default_theme_url'] = $modSettings['theme_url']; |
220 | -if (!isset($settings['default_theme_dir'])) |
|
228 | +} |
|
229 | +if (!isset($settings['default_theme_dir'])) { |
|
221 | 230 | $settings['default_theme_dir'] = $modSettings['theme_dir']; |
231 | +} |
|
222 | 232 | |
223 | 233 | // This is needed in case someone invokes the upgrader using https when upgrading an http forum |
224 | -if (httpsOn()) |
|
234 | +if (httpsOn()) { |
|
225 | 235 | $settings['default_theme_url'] = strtr($settings['default_theme_url'], array('http://' => 'https://')); |
236 | +} |
|
226 | 237 | |
227 | 238 | $upcontext['is_large_forum'] = (empty($modSettings['smfVersion']) || $modSettings['smfVersion'] <= '1.1 RC1') && !empty($modSettings['totalMessages']) && $modSettings['totalMessages'] > 75000; |
228 | 239 | // Default title... |
@@ -240,13 +251,15 @@ discard block |
||
240 | 251 | $support_js = $upcontext['upgrade_status']['js']; |
241 | 252 | |
242 | 253 | // Only set this if the upgrader status says so. |
243 | - if (empty($is_debug)) |
|
244 | - $is_debug = $upcontext['upgrade_status']['debug']; |
|
254 | + if (empty($is_debug)) { |
|
255 | + $is_debug = $upcontext['upgrade_status']['debug']; |
|
256 | + } |
|
245 | 257 | |
246 | 258 | // Load the language. |
247 | - if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
248 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
249 | -} |
|
259 | + if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
260 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
261 | + } |
|
262 | + } |
|
250 | 263 | // Set the defaults. |
251 | 264 | else |
252 | 265 | { |
@@ -264,15 +277,18 @@ discard block |
||
264 | 277 | } |
265 | 278 | |
266 | 279 | // If this isn't the first stage see whether they are logging in and resuming. |
267 | -if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) |
|
280 | +if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) { |
|
268 | 281 | checkLogin(); |
282 | +} |
|
269 | 283 | |
270 | -if ($command_line) |
|
284 | +if ($command_line) { |
|
271 | 285 | cmdStep0(); |
286 | +} |
|
272 | 287 | |
273 | 288 | // Don't error if we're using xml. |
274 | -if (isset($_GET['xml'])) |
|
289 | +if (isset($_GET['xml'])) { |
|
275 | 290 | $upcontext['return_error'] = true; |
291 | +} |
|
276 | 292 | |
277 | 293 | // Loop through all the steps doing each one as required. |
278 | 294 | $upcontext['overall_percent'] = 0; |
@@ -293,9 +309,9 @@ discard block |
||
293 | 309 | } |
294 | 310 | |
295 | 311 | // Call the step and if it returns false that means pause! |
296 | - if (function_exists($step[2]) && $step[2]() === false) |
|
297 | - break; |
|
298 | - elseif (function_exists($step[2])) { |
|
312 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
313 | + break; |
|
314 | + } elseif (function_exists($step[2])) { |
|
299 | 315 | //Start each new step with this unset, so the 'normal' template is called first |
300 | 316 | unset($_GET['xml']); |
301 | 317 | //Clear out warnings at the start of each step |
@@ -341,17 +357,18 @@ discard block |
||
341 | 357 | // This should not happen my dear... HELP ME DEVELOPERS!! |
342 | 358 | if (!empty($command_line)) |
343 | 359 | { |
344 | - if (function_exists('debug_print_backtrace')) |
|
345 | - debug_print_backtrace(); |
|
360 | + if (function_exists('debug_print_backtrace')) { |
|
361 | + debug_print_backtrace(); |
|
362 | + } |
|
346 | 363 | |
347 | 364 | echo "\n" . 'Error: Unexpected call to use the ' . (isset($upcontext['sub_template']) ? $upcontext['sub_template'] : '') . ' template. Please copy and paste all the text above and visit the SMF support forum to tell the Developers that they\'ve made a boo boo; they\'ll get you up and running again.'; |
348 | 365 | flush(); |
349 | 366 | die(); |
350 | 367 | } |
351 | 368 | |
352 | - if (!isset($_GET['xml'])) |
|
353 | - template_upgrade_above(); |
|
354 | - else |
|
369 | + if (!isset($_GET['xml'])) { |
|
370 | + template_upgrade_above(); |
|
371 | + } else |
|
355 | 372 | { |
356 | 373 | header('content-type: text/xml; charset=UTF-8'); |
357 | 374 | // Sadly we need to retain the $_GET data thanks to the old upgrade scripts. |
@@ -373,25 +390,29 @@ discard block |
||
373 | 390 | $upcontext['form_url'] = $upgradeurl . '?step=' . $upcontext['current_step'] . '&substep=' . $_GET['substep'] . '&data=' . base64_encode(json_encode($upcontext['upgrade_status'])); |
374 | 391 | |
375 | 392 | // Custom stuff to pass back? |
376 | - if (!empty($upcontext['query_string'])) |
|
377 | - $upcontext['form_url'] .= $upcontext['query_string']; |
|
393 | + if (!empty($upcontext['query_string'])) { |
|
394 | + $upcontext['form_url'] .= $upcontext['query_string']; |
|
395 | + } |
|
378 | 396 | |
379 | 397 | // Call the appropriate subtemplate |
380 | - if (is_callable('template_' . $upcontext['sub_template'])) |
|
381 | - call_user_func('template_' . $upcontext['sub_template']); |
|
382 | - else |
|
383 | - die('Upgrade aborted! Invalid template: template_' . $upcontext['sub_template']); |
|
398 | + if (is_callable('template_' . $upcontext['sub_template'])) { |
|
399 | + call_user_func('template_' . $upcontext['sub_template']); |
|
400 | + } else { |
|
401 | + die('Upgrade aborted! Invalid template: template_' . $upcontext['sub_template']); |
|
402 | + } |
|
384 | 403 | } |
385 | 404 | |
386 | 405 | // Was there an error? |
387 | - if (!empty($upcontext['forced_error_message'])) |
|
388 | - echo $upcontext['forced_error_message']; |
|
406 | + if (!empty($upcontext['forced_error_message'])) { |
|
407 | + echo $upcontext['forced_error_message']; |
|
408 | + } |
|
389 | 409 | |
390 | 410 | // Show the footer. |
391 | - if (!isset($_GET['xml'])) |
|
392 | - template_upgrade_below(); |
|
393 | - else |
|
394 | - template_xml_below(); |
|
411 | + if (!isset($_GET['xml'])) { |
|
412 | + template_upgrade_below(); |
|
413 | + } else { |
|
414 | + template_xml_below(); |
|
415 | + } |
|
395 | 416 | } |
396 | 417 | |
397 | 418 | |
@@ -403,15 +424,19 @@ discard block |
||
403 | 424 | $seconds = intval($active % 60); |
404 | 425 | |
405 | 426 | $totalTime = ''; |
406 | - if ($hours > 0) |
|
407 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
408 | - if ($minutes > 0) |
|
409 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
410 | - if ($seconds > 0) |
|
411 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
427 | + if ($hours > 0) { |
|
428 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
429 | + } |
|
430 | + if ($minutes > 0) { |
|
431 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
432 | + } |
|
433 | + if ($seconds > 0) { |
|
434 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
435 | + } |
|
412 | 436 | |
413 | - if (!empty($totalTime)) |
|
414 | - echo "\n" . '', $txt['upgrade_completed_time'], ' ' . $totalTime . "\n"; |
|
437 | + if (!empty($totalTime)) { |
|
438 | + echo "\n" . '', $txt['upgrade_completed_time'], ' ' . $totalTime . "\n"; |
|
439 | + } |
|
415 | 440 | } |
416 | 441 | |
417 | 442 | // Bang - gone! |
@@ -432,8 +457,9 @@ discard block |
||
432 | 457 | $dir = dir(dirname(__FILE__) . '/Themes/default/languages'); |
433 | 458 | while ($entry = $dir->read()) |
434 | 459 | { |
435 | - if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') |
|
436 | - $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
460 | + if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') { |
|
461 | + $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
462 | + } |
|
437 | 463 | } |
438 | 464 | $dir->close(); |
439 | 465 | } |
@@ -468,10 +494,11 @@ discard block |
||
468 | 494 | } |
469 | 495 | |
470 | 496 | // Override the language file? |
471 | - if (isset($_GET['lang_file'])) |
|
472 | - $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
473 | - elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) |
|
474 | - $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
497 | + if (isset($_GET['lang_file'])) { |
|
498 | + $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
499 | + } elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) { |
|
500 | + $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
501 | + } |
|
475 | 502 | |
476 | 503 | // Make sure it exists, if it doesn't reset it. |
477 | 504 | 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'])) |
@@ -480,12 +507,14 @@ discard block |
||
480 | 507 | list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
481 | 508 | |
482 | 509 | // If we have english and some other language, use the other language. We Americans hate english :P. |
483 | - if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) |
|
484 | - list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
510 | + if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) { |
|
511 | + list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
512 | + } |
|
485 | 513 | |
486 | 514 | // For backup we load the english at first -> second language overwrite the english one |
487 | - if (count($incontext['detected_languages']) > 1) |
|
488 | - require_once(dirname(__FILE__) . '/Themes/default/languages/Install.english.php'); |
|
515 | + if (count($incontext['detected_languages']) > 1) { |
|
516 | + require_once(dirname(__FILE__) . '/Themes/default/languages/Install.english.php'); |
|
517 | + } |
|
489 | 518 | } |
490 | 519 | |
491 | 520 | // And now include the actual language file itself. |
@@ -493,11 +522,12 @@ discard block |
||
493 | 522 | |
494 | 523 | // Which language did we load? Assume that he likes his language. |
495 | 524 | preg_match('~^Install\.(.+[^-utf8])\.php$~', $_SESSION['installer_temp_lang'], $matches); |
496 | - if (empty($matches[1])) |
|
497 | - $matches = [ |
|
525 | + if (empty($matches[1])) { |
|
526 | + $matches = [ |
|
498 | 527 | 0 => 'nothing', |
499 | 528 | 1 => 'english', |
500 | 529 | ]; |
530 | + } |
|
501 | 531 | $user_info['language'] = $matches[1]; |
502 | 532 | } |
503 | 533 | |
@@ -507,8 +537,9 @@ discard block |
||
507 | 537 | global $upgradeurl, $upcontext, $command_line; |
508 | 538 | |
509 | 539 | // Command line users can't be redirected. |
510 | - if ($command_line) |
|
511 | - upgradeExit(true); |
|
540 | + if ($command_line) { |
|
541 | + upgradeExit(true); |
|
542 | + } |
|
512 | 543 | |
513 | 544 | // Are we providing the core info? |
514 | 545 | if ($addForm) |
@@ -534,12 +565,14 @@ discard block |
||
534 | 565 | define('SMF', 1); |
535 | 566 | |
536 | 567 | // Start the session. |
537 | - if (@ini_get('session.save_handler') == 'user') |
|
538 | - @ini_set('session.save_handler', 'files'); |
|
568 | + if (@ini_get('session.save_handler') == 'user') { |
|
569 | + @ini_set('session.save_handler', 'files'); |
|
570 | + } |
|
539 | 571 | @session_start(); |
540 | 572 | |
541 | - if (empty($smcFunc)) |
|
542 | - $smcFunc = array(); |
|
573 | + if (empty($smcFunc)) { |
|
574 | + $smcFunc = array(); |
|
575 | + } |
|
543 | 576 | |
544 | 577 | // We need this for authentication and some upgrade code |
545 | 578 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -566,24 +599,27 @@ discard block |
||
566 | 599 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
567 | 600 | |
568 | 601 | // Make the connection... |
569 | - if (empty($db_connection)) |
|
570 | - $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true)); |
|
571 | - else |
|
572 | - // If we've returned here, ping/reconnect to be safe |
|
602 | + if (empty($db_connection)) { |
|
603 | + $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true)); |
|
604 | + } else { |
|
605 | + // If we've returned here, ping/reconnect to be safe |
|
573 | 606 | $smcFunc['db_ping']($db_connection); |
607 | + } |
|
574 | 608 | |
575 | 609 | // Oh dear god!! |
576 | - if ($db_connection === null) |
|
577 | - die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
610 | + if ($db_connection === null) { |
|
611 | + die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
612 | + } |
|
578 | 613 | |
579 | - if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) |
|
580 | - $smcFunc['db_query']('', ' |
|
614 | + if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) { |
|
615 | + $smcFunc['db_query']('', ' |
|
581 | 616 | SET NAMES {string:db_character_set}', |
582 | 617 | array( |
583 | 618 | 'db_error_skip' => true, |
584 | 619 | 'db_character_set' => $db_character_set, |
585 | 620 | ) |
586 | 621 | ); |
622 | + } |
|
587 | 623 | |
588 | 624 | // Load the modSettings data... |
589 | 625 | $request = $smcFunc['db_query']('', ' |
@@ -594,11 +630,11 @@ discard block |
||
594 | 630 | ) |
595 | 631 | ); |
596 | 632 | $modSettings = array(); |
597 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
598 | - $modSettings[$row['variable']] = $row['value']; |
|
633 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
634 | + $modSettings[$row['variable']] = $row['value']; |
|
635 | + } |
|
599 | 636 | $smcFunc['db_free_result']($request); |
600 | - } |
|
601 | - else |
|
637 | + } else |
|
602 | 638 | { |
603 | 639 | return throw_error('Cannot find ' . $sourcedir . '/Subs-Db-' . $db_type . '.php' . '. Please check you have uploaded all source files and have the correct paths set.'); |
604 | 640 | } |
@@ -612,9 +648,10 @@ discard block |
||
612 | 648 | cleanRequest(); |
613 | 649 | } |
614 | 650 | |
615 | - if (!isset($_GET['substep'])) |
|
616 | - $_GET['substep'] = 0; |
|
617 | -} |
|
651 | + if (!isset($_GET['substep'])) { |
|
652 | + $_GET['substep'] = 0; |
|
653 | + } |
|
654 | + } |
|
618 | 655 | |
619 | 656 | function initialize_inputs() |
620 | 657 | { |
@@ -644,8 +681,9 @@ discard block |
||
644 | 681 | $dh = opendir(dirname(__FILE__)); |
645 | 682 | while ($file = readdir($dh)) |
646 | 683 | { |
647 | - if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) |
|
648 | - @unlink(dirname(__FILE__) . '/' . $file); |
|
684 | + if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) { |
|
685 | + @unlink(dirname(__FILE__) . '/' . $file); |
|
686 | + } |
|
649 | 687 | } |
650 | 688 | closedir($dh); |
651 | 689 | |
@@ -674,8 +712,9 @@ discard block |
||
674 | 712 | $temp = 'upgrade_php?step'; |
675 | 713 | while (strlen($temp) > 4) |
676 | 714 | { |
677 | - if (isset($_GET[$temp])) |
|
678 | - unset($_GET[$temp]); |
|
715 | + if (isset($_GET[$temp])) { |
|
716 | + unset($_GET[$temp]); |
|
717 | + } |
|
679 | 718 | $temp = substr($temp, 1); |
680 | 719 | } |
681 | 720 | |
@@ -702,32 +741,39 @@ discard block |
||
702 | 741 | && @file_exists(dirname(__FILE__) . '/upgrade_2-1_' . $db_type . '.sql'); |
703 | 742 | |
704 | 743 | // Need legacy scripts? |
705 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) |
|
706 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
707 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) |
|
708 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
709 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) |
|
710 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
744 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) { |
|
745 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
746 | + } |
|
747 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) { |
|
748 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
749 | + } |
|
750 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) { |
|
751 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
752 | + } |
|
711 | 753 | |
712 | 754 | // We don't need "-utf8" files anymore... |
713 | 755 | $upcontext['language'] = str_ireplace('-utf8', '', $upcontext['language']); |
714 | 756 | |
715 | 757 | // This needs to exist! |
716 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
717 | - return throw_error('The upgrader could not find the "Install" language file for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
718 | - else |
|
719 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
758 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
759 | + return throw_error('The upgrader could not find the "Install" language file for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
760 | + } else { |
|
761 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
762 | + } |
|
720 | 763 | |
721 | - if (!$check) |
|
722 | - // Don't tell them what files exactly because it's a spot check - just like teachers don't tell which problems they are spot checking, that's dumb. |
|
764 | + if (!$check) { |
|
765 | + // Don't tell them what files exactly because it's a spot check - just like teachers don't tell which problems they are spot checking, that's dumb. |
|
723 | 766 | return throw_error('The upgrader was unable to find some crucial files.<br><br>Please make sure you uploaded all of the files included in the package, including the Themes, Sources, and other directories.'); |
767 | + } |
|
724 | 768 | |
725 | 769 | // Do they meet the install requirements? |
726 | - if (!php_version_check()) |
|
727 | - return throw_error('Warning! You do not appear to have a version of PHP installed on your webserver that meets SMF\'s minimum installations requirements.<br><br>Please ask your host to upgrade.'); |
|
770 | + if (!php_version_check()) { |
|
771 | + return throw_error('Warning! You do not appear to have a version of PHP installed on your webserver that meets SMF\'s minimum installations requirements.<br><br>Please ask your host to upgrade.'); |
|
772 | + } |
|
728 | 773 | |
729 | - if (!db_version_check()) |
|
730 | - return throw_error('Your ' . $databases[$db_type]['name'] . ' version does not meet the minimum requirements of SMF.<br><br>Please ask your host to upgrade.'); |
|
774 | + if (!db_version_check()) { |
|
775 | + return throw_error('Your ' . $databases[$db_type]['name'] . ' version does not meet the minimum requirements of SMF.<br><br>Please ask your host to upgrade.'); |
|
776 | + } |
|
731 | 777 | |
732 | 778 | // Do some checks to make sure they have proper privileges |
733 | 779 | db_extend('packages'); |
@@ -742,14 +788,16 @@ discard block |
||
742 | 788 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
743 | 789 | |
744 | 790 | // Sorry... we need CREATE, ALTER and DROP |
745 | - if (!$create || !$alter || !$drop) |
|
746 | - return throw_error('The ' . $databases[$db_type]['name'] . ' user you have set in Settings.php does not have proper privileges.<br><br>Please ask your host to give this user the ALTER, CREATE, and DROP privileges.'); |
|
791 | + if (!$create || !$alter || !$drop) { |
|
792 | + return throw_error('The ' . $databases[$db_type]['name'] . ' user you have set in Settings.php does not have proper privileges.<br><br>Please ask your host to give this user the ALTER, CREATE, and DROP privileges.'); |
|
793 | + } |
|
747 | 794 | |
748 | 795 | // Do a quick version spot check. |
749 | 796 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
750 | 797 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
751 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
752 | - return throw_error('The upgrader found some old or outdated files.<br><br>Please make certain you uploaded the new versions of all the files included in the package.'); |
|
798 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
799 | + return throw_error('The upgrader found some old or outdated files.<br><br>Please make certain you uploaded the new versions of all the files included in the package.'); |
|
800 | + } |
|
753 | 801 | |
754 | 802 | // What absolutely needs to be writable? |
755 | 803 | $writable_files = array( |
@@ -758,12 +806,13 @@ discard block |
||
758 | 806 | ); |
759 | 807 | |
760 | 808 | // Only check for minified writable files if we have it enabled or not set. |
761 | - if (!empty($modSettings['minimize_files']) || !isset($modSettings['minimize_files'])) |
|
762 | - $writable_files += array( |
|
809 | + if (!empty($modSettings['minimize_files']) || !isset($modSettings['minimize_files'])) { |
|
810 | + $writable_files += array( |
|
763 | 811 | $modSettings['theme_dir'] . '/css/minified.css', |
764 | 812 | $modSettings['theme_dir'] . '/scripts/minified.js', |
765 | 813 | $modSettings['theme_dir'] . '/scripts/minified_deferred.js', |
766 | 814 | ); |
815 | + } |
|
767 | 816 | |
768 | 817 | // Do we need to add this setting? |
769 | 818 | $need_settings_update = empty($modSettings['custom_avatar_dir']); |
@@ -775,12 +824,13 @@ discard block |
||
775 | 824 | quickFileWritable($custom_av_dir); |
776 | 825 | |
777 | 826 | // Are we good now? |
778 | - if (!is_writable($custom_av_dir)) |
|
779 | - return throw_error(sprintf('The directory: %1$s has to be writable to continue the upgrade. Please make sure permissions are correctly set to allow this.', $custom_av_dir)); |
|
780 | - elseif ($need_settings_update) |
|
827 | + if (!is_writable($custom_av_dir)) { |
|
828 | + return throw_error(sprintf('The directory: %1$s has to be writable to continue the upgrade. Please make sure permissions are correctly set to allow this.', $custom_av_dir)); |
|
829 | + } elseif ($need_settings_update) |
|
781 | 830 | { |
782 | - if (!function_exists('cache_put_data')) |
|
783 | - require_once($sourcedir . '/Load.php'); |
|
831 | + if (!function_exists('cache_put_data')) { |
|
832 | + require_once($sourcedir . '/Load.php'); |
|
833 | + } |
|
784 | 834 | updateSettings(array('custom_avatar_dir' => $custom_av_dir)); |
785 | 835 | updateSettings(array('custom_avatar_url' => $custom_av_url)); |
786 | 836 | } |
@@ -789,28 +839,33 @@ discard block |
||
789 | 839 | |
790 | 840 | // Check the cache directory. |
791 | 841 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
792 | - if (!file_exists($cachedir_temp)) |
|
793 | - @mkdir($cachedir_temp); |
|
794 | - if (!file_exists($cachedir_temp)) |
|
795 | - return throw_error('The cache directory could not be found.<br><br>Please make sure you have a directory called "cache" in your forum directory before continuing.'); |
|
796 | - |
|
797 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
798 | - return throw_error('The upgrader was unable to find language files for the language specified in Settings.php.<br>SMF will not work without the primary language files installed.<br><br>Please either install them, or <a href="' . $upgradeurl . '?step=0;lang=english">use english instead</a>.'); |
|
799 | - elseif (!isset($_GET['skiplang'])) |
|
842 | + if (!file_exists($cachedir_temp)) { |
|
843 | + @mkdir($cachedir_temp); |
|
844 | + } |
|
845 | + if (!file_exists($cachedir_temp)) { |
|
846 | + return throw_error('The cache directory could not be found.<br><br>Please make sure you have a directory called "cache" in your forum directory before continuing.'); |
|
847 | + } |
|
848 | + |
|
849 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
850 | + return throw_error('The upgrader was unable to find language files for the language specified in Settings.php.<br>SMF will not work without the primary language files installed.<br><br>Please either install them, or <a href="' . $upgradeurl . '?step=0;lang=english">use english instead</a>.'); |
|
851 | + } elseif (!isset($_GET['skiplang'])) |
|
800 | 852 | { |
801 | 853 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
802 | 854 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
803 | 855 | |
804 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
805 | - return throw_error('The upgrader found some old or outdated language files, for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded the new versions of all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?skiplang">SKIP</a>] [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
856 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
857 | + return throw_error('The upgrader found some old or outdated language files, for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded the new versions of all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?skiplang">SKIP</a>] [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
858 | + } |
|
806 | 859 | } |
807 | 860 | |
808 | - if (!makeFilesWritable($writable_files)) |
|
809 | - return false; |
|
861 | + if (!makeFilesWritable($writable_files)) { |
|
862 | + return false; |
|
863 | + } |
|
810 | 864 | |
811 | 865 | // Check agreement.txt. (it may not exist, in which case $boarddir must be writable.) |
812 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
813 | - return throw_error('The upgrader was unable to obtain write access to agreement.txt.<br><br>If you are using a linux or unix based server, please ensure that the file is chmod\'d to 777, or if it does not exist that the directory this upgrader is in is 777.<br>If your server is running Windows, please ensure that the internet guest account has the proper permissions on it or its folder.'); |
|
866 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
867 | + return throw_error('The upgrader was unable to obtain write access to agreement.txt.<br><br>If you are using a linux or unix based server, please ensure that the file is chmod\'d to 777, or if it does not exist that the directory this upgrader is in is 777.<br>If your server is running Windows, please ensure that the internet guest account has the proper permissions on it or its folder.'); |
|
868 | + } |
|
814 | 869 | |
815 | 870 | // Upgrade the agreement. |
816 | 871 | elseif (isset($modSettings['agreement'])) |
@@ -821,8 +876,8 @@ discard block |
||
821 | 876 | } |
822 | 877 | |
823 | 878 | // We're going to check that their board dir setting is right in case they've been moving stuff around. |
824 | - if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) |
|
825 | - $upcontext['warning'] = ' |
|
879 | + if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) { |
|
880 | + $upcontext['warning'] = ' |
|
826 | 881 | It looks as if your board directory settings <em>might</em> be incorrect. Your board directory is currently set to "' . $boarddir . '" but should probably be "' . dirname(__FILE__) . '". Settings.php currently lists your paths as:<br> |
827 | 882 | <ul> |
828 | 883 | <li>Board Directory: ' . $boarddir . '</li> |
@@ -830,19 +885,23 @@ discard block |
||
830 | 885 | <li>Cache Directory: ' . $cachedir_temp . '</li> |
831 | 886 | </ul> |
832 | 887 | If these seem incorrect please open Settings.php in a text editor before proceeding with this upgrade. If they are incorrect due to you moving your forum to a new location please download and execute the <a href="https://download.simplemachines.org/?tools">Repair Settings</a> tool from the Simple Machines website before continuing.'; |
888 | + } |
|
833 | 889 | |
834 | 890 | // Confirm mbstring is loaded... |
835 | - if (!extension_loaded('mbstring')) |
|
836 | - return throw_error($txt['install_no_mbstring']); |
|
891 | + if (!extension_loaded('mbstring')) { |
|
892 | + return throw_error($txt['install_no_mbstring']); |
|
893 | + } |
|
837 | 894 | |
838 | 895 | // Check for https stream support. |
839 | 896 | $supported_streams = stream_get_wrappers(); |
840 | - if (!in_array('https', $supported_streams)) |
|
841 | - $upcontext['custom_warning'] = $txt['install_no_https']; |
|
897 | + if (!in_array('https', $supported_streams)) { |
|
898 | + $upcontext['custom_warning'] = $txt['install_no_https']; |
|
899 | + } |
|
842 | 900 | |
843 | 901 | // Either we're logged in or we're going to present the login. |
844 | - if (checkLogin()) |
|
845 | - return true; |
|
902 | + if (checkLogin()) { |
|
903 | + return true; |
|
904 | + } |
|
846 | 905 | |
847 | 906 | $upcontext += createToken('login'); |
848 | 907 | |
@@ -856,15 +915,17 @@ discard block |
||
856 | 915 | global $smcFunc, $db_type, $support_js; |
857 | 916 | |
858 | 917 | // Don't bother if the security is disabled. |
859 | - if ($disable_security) |
|
860 | - return true; |
|
918 | + if ($disable_security) { |
|
919 | + return true; |
|
920 | + } |
|
861 | 921 | |
862 | 922 | // Are we trying to login? |
863 | 923 | if (isset($_POST['contbutt']) && (!empty($_POST['user']))) |
864 | 924 | { |
865 | 925 | // If we've disabled security pick a suitable name! |
866 | - if (empty($_POST['user'])) |
|
867 | - $_POST['user'] = 'Administrator'; |
|
926 | + if (empty($_POST['user'])) { |
|
927 | + $_POST['user'] = 'Administrator'; |
|
928 | + } |
|
868 | 929 | |
869 | 930 | // Before 2.0 these column names were different! |
870 | 931 | $oldDB = false; |
@@ -879,16 +940,17 @@ discard block |
||
879 | 940 | 'db_error_skip' => true, |
880 | 941 | ) |
881 | 942 | ); |
882 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
883 | - $oldDB = true; |
|
943 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
944 | + $oldDB = true; |
|
945 | + } |
|
884 | 946 | $smcFunc['db_free_result']($request); |
885 | 947 | } |
886 | 948 | |
887 | 949 | // Get what we believe to be their details. |
888 | 950 | if (!$disable_security) |
889 | 951 | { |
890 | - if ($oldDB) |
|
891 | - $request = $smcFunc['db_query']('', ' |
|
952 | + if ($oldDB) { |
|
953 | + $request = $smcFunc['db_query']('', ' |
|
892 | 954 | SELECT id_member, memberName AS member_name, passwd, id_group, |
893 | 955 | additionalGroups AS additional_groups, lngfile |
894 | 956 | FROM {db_prefix}members |
@@ -898,8 +960,8 @@ discard block |
||
898 | 960 | 'db_error_skip' => true, |
899 | 961 | ) |
900 | 962 | ); |
901 | - else |
|
902 | - $request = $smcFunc['db_query']('', ' |
|
963 | + } else { |
|
964 | + $request = $smcFunc['db_query']('', ' |
|
903 | 965 | SELECT id_member, member_name, passwd, id_group, additional_groups, lngfile |
904 | 966 | FROM {db_prefix}members |
905 | 967 | WHERE member_name = {string:member_name}', |
@@ -908,6 +970,7 @@ discard block |
||
908 | 970 | 'db_error_skip' => true, |
909 | 971 | ) |
910 | 972 | ); |
973 | + } |
|
911 | 974 | if ($smcFunc['db_num_rows']($request) != 0) |
912 | 975 | { |
913 | 976 | list ($id_member, $name, $password, $id_group, $addGroups, $user_language) = $smcFunc['db_fetch_row']($request); |
@@ -915,16 +978,17 @@ discard block |
||
915 | 978 | $groups = explode(',', $addGroups); |
916 | 979 | $groups[] = $id_group; |
917 | 980 | |
918 | - foreach ($groups as $k => $v) |
|
919 | - $groups[$k] = (int) $v; |
|
981 | + foreach ($groups as $k => $v) { |
|
982 | + $groups[$k] = (int) $v; |
|
983 | + } |
|
920 | 984 | |
921 | 985 | $sha_passwd = sha1(strtolower($name) . un_htmlspecialchars($_REQUEST['passwrd'])); |
922 | 986 | |
923 | 987 | // We don't use "-utf8" anymore... |
924 | 988 | $user_language = str_ireplace('-utf8', '', $user_language); |
989 | + } else { |
|
990 | + $upcontext['username_incorrect'] = true; |
|
925 | 991 | } |
926 | - else |
|
927 | - $upcontext['username_incorrect'] = true; |
|
928 | 992 | $smcFunc['db_free_result']($request); |
929 | 993 | } |
930 | 994 | $upcontext['username'] = $_POST['user']; |
@@ -934,13 +998,14 @@ discard block |
||
934 | 998 | { |
935 | 999 | $upcontext['upgrade_status']['js'] = 1; |
936 | 1000 | $support_js = 1; |
1001 | + } else { |
|
1002 | + $support_js = 0; |
|
937 | 1003 | } |
938 | - else |
|
939 | - $support_js = 0; |
|
940 | 1004 | |
941 | 1005 | // Note down the version we are coming from. |
942 | - if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) |
|
943 | - $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
1006 | + if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) { |
|
1007 | + $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
1008 | + } |
|
944 | 1009 | |
945 | 1010 | // Didn't get anywhere? |
946 | 1011 | if (!$disable_security && (empty($sha_passwd) || (!empty($password) ? $password : '') != $sha_passwd) && !hash_verify_password((!empty($name) ? $name : ''), $_REQUEST['passwrd'], (!empty($password) ? $password : '')) && empty($upcontext['username_incorrect'])) |
@@ -974,15 +1039,15 @@ discard block |
||
974 | 1039 | 'db_error_skip' => true, |
975 | 1040 | ) |
976 | 1041 | ); |
977 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
978 | - return throw_error('You need to be an admin to perform an upgrade!'); |
|
1042 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1043 | + return throw_error('You need to be an admin to perform an upgrade!'); |
|
1044 | + } |
|
979 | 1045 | $smcFunc['db_free_result']($request); |
980 | 1046 | } |
981 | 1047 | |
982 | 1048 | $upcontext['user']['id'] = $id_member; |
983 | 1049 | $upcontext['user']['name'] = $name; |
984 | - } |
|
985 | - else |
|
1050 | + } else |
|
986 | 1051 | { |
987 | 1052 | $upcontext['user']['id'] = 1; |
988 | 1053 | $upcontext['user']['name'] = 'Administrator'; |
@@ -998,11 +1063,11 @@ discard block |
||
998 | 1063 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $user_language . '.php')), 0, 4096); |
999 | 1064 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
1000 | 1065 | |
1001 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
1002 | - $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been updated to the latest version. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
1003 | - elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) |
|
1004 | - $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been uploaded/updated as the "Install" language file is missing. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
1005 | - else |
|
1066 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
1067 | + $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been updated to the latest version. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
1068 | + } elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) { |
|
1069 | + $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been uploaded/updated as the "Install" language file is missing. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
1070 | + } else |
|
1006 | 1071 | { |
1007 | 1072 | // Set this as the new language. |
1008 | 1073 | $upcontext['language'] = $user_language; |
@@ -1046,8 +1111,9 @@ discard block |
||
1046 | 1111 | unset($member_columns); |
1047 | 1112 | |
1048 | 1113 | // If we've not submitted then we're done. |
1049 | - if (empty($_POST['upcont'])) |
|
1050 | - return false; |
|
1114 | + if (empty($_POST['upcont'])) { |
|
1115 | + return false; |
|
1116 | + } |
|
1051 | 1117 | |
1052 | 1118 | // Firstly, if they're enabling SM stat collection just do it. |
1053 | 1119 | if (!empty($_POST['stats']) && substr($boardurl, 0, 16) != 'http://localhost' && empty($modSettings['allow_sm_stats']) && empty($modSettings['enable_sm_stats'])) |
@@ -1067,16 +1133,17 @@ discard block |
||
1067 | 1133 | fwrite($fp, $out); |
1068 | 1134 | |
1069 | 1135 | $return_data = ''; |
1070 | - while (!feof($fp)) |
|
1071 | - $return_data .= fgets($fp, 128); |
|
1136 | + while (!feof($fp)) { |
|
1137 | + $return_data .= fgets($fp, 128); |
|
1138 | + } |
|
1072 | 1139 | |
1073 | 1140 | fclose($fp); |
1074 | 1141 | |
1075 | 1142 | // Get the unique site ID. |
1076 | 1143 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
1077 | 1144 | |
1078 | - if (!empty($ID[1])) |
|
1079 | - $smcFunc['db_insert']('replace', |
|
1145 | + if (!empty($ID[1])) { |
|
1146 | + $smcFunc['db_insert']('replace', |
|
1080 | 1147 | $db_prefix . 'settings', |
1081 | 1148 | array('variable' => 'string', 'value' => 'string'), |
1082 | 1149 | array( |
@@ -1085,9 +1152,9 @@ discard block |
||
1085 | 1152 | ), |
1086 | 1153 | array('variable') |
1087 | 1154 | ); |
1155 | + } |
|
1088 | 1156 | } |
1089 | - } |
|
1090 | - else |
|
1157 | + } else |
|
1091 | 1158 | { |
1092 | 1159 | $smcFunc['db_insert']('replace', |
1093 | 1160 | $db_prefix . 'settings', |
@@ -1098,8 +1165,8 @@ discard block |
||
1098 | 1165 | } |
1099 | 1166 | } |
1100 | 1167 | // Don't remove stat collection unless we unchecked the box for real, not from the loop. |
1101 | - elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) |
|
1102 | - $smcFunc['db_query']('', ' |
|
1168 | + elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) { |
|
1169 | + $smcFunc['db_query']('', ' |
|
1103 | 1170 | DELETE FROM {db_prefix}settings |
1104 | 1171 | WHERE variable = {string:enable_sm_stats}', |
1105 | 1172 | array( |
@@ -1107,6 +1174,7 @@ discard block |
||
1107 | 1174 | 'db_error_skip' => true, |
1108 | 1175 | ) |
1109 | 1176 | ); |
1177 | + } |
|
1110 | 1178 | |
1111 | 1179 | // Deleting old karma stuff? |
1112 | 1180 | if (!empty($_POST['delete_karma'])) |
@@ -1121,20 +1189,22 @@ discard block |
||
1121 | 1189 | ); |
1122 | 1190 | |
1123 | 1191 | // Cleaning up old karma member settings. |
1124 | - if ($upcontext['karma_installed']['good']) |
|
1125 | - $smcFunc['db_query']('', ' |
|
1192 | + if ($upcontext['karma_installed']['good']) { |
|
1193 | + $smcFunc['db_query']('', ' |
|
1126 | 1194 | ALTER TABLE {db_prefix}members |
1127 | 1195 | DROP karma_good', |
1128 | 1196 | array() |
1129 | 1197 | ); |
1198 | + } |
|
1130 | 1199 | |
1131 | 1200 | // Does karma bad was enable? |
1132 | - if ($upcontext['karma_installed']['bad']) |
|
1133 | - $smcFunc['db_query']('', ' |
|
1201 | + if ($upcontext['karma_installed']['bad']) { |
|
1202 | + $smcFunc['db_query']('', ' |
|
1134 | 1203 | ALTER TABLE {db_prefix}members |
1135 | 1204 | DROP karma_bad', |
1136 | 1205 | array() |
1137 | 1206 | ); |
1207 | + } |
|
1138 | 1208 | |
1139 | 1209 | // Cleaning up old karma permissions. |
1140 | 1210 | $smcFunc['db_query']('', ' |
@@ -1152,32 +1222,37 @@ discard block |
||
1152 | 1222 | } |
1153 | 1223 | |
1154 | 1224 | // Emptying the error log? |
1155 | - if (!empty($_POST['empty_error'])) |
|
1156 | - $smcFunc['db_query']('truncate_table', ' |
|
1225 | + if (!empty($_POST['empty_error'])) { |
|
1226 | + $smcFunc['db_query']('truncate_table', ' |
|
1157 | 1227 | TRUNCATE {db_prefix}log_errors', |
1158 | 1228 | array( |
1159 | 1229 | ) |
1160 | 1230 | ); |
1231 | + } |
|
1161 | 1232 | |
1162 | 1233 | $changes = array(); |
1163 | 1234 | |
1164 | 1235 | // Add proxy settings. |
1165 | - if (!isset($GLOBALS['image_proxy_maxsize'])) |
|
1166 | - $changes += array( |
|
1236 | + if (!isset($GLOBALS['image_proxy_maxsize'])) { |
|
1237 | + $changes += array( |
|
1167 | 1238 | 'image_proxy_secret' => '\'' . substr(sha1(mt_rand()), 0, 20) . '\'', |
1168 | 1239 | 'image_proxy_maxsize' => 5190, |
1169 | 1240 | 'image_proxy_enabled' => 0, |
1170 | 1241 | ); |
1242 | + } |
|
1171 | 1243 | |
1172 | 1244 | // If $boardurl reflects https, set force_ssl |
1173 | - if (!function_exists('cache_put_data')) |
|
1174 | - require_once($sourcedir . '/Load.php'); |
|
1175 | - if (stripos($boardurl, 'https://') !== false) |
|
1176 | - updateSettings(array('force_ssl' => '1')); |
|
1245 | + if (!function_exists('cache_put_data')) { |
|
1246 | + require_once($sourcedir . '/Load.php'); |
|
1247 | + } |
|
1248 | + if (stripos($boardurl, 'https://') !== false) { |
|
1249 | + updateSettings(array('force_ssl' => '1')); |
|
1250 | + } |
|
1177 | 1251 | |
1178 | 1252 | // If we're overriding the language follow it through. |
1179 | - if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) |
|
1180 | - $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
1253 | + if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) { |
|
1254 | + $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
1255 | + } |
|
1181 | 1256 | |
1182 | 1257 | if (!empty($_POST['maint'])) |
1183 | 1258 | { |
@@ -1189,26 +1264,29 @@ discard block |
||
1189 | 1264 | { |
1190 | 1265 | $changes['mtitle'] = '\'' . addslashes($_POST['maintitle']) . '\''; |
1191 | 1266 | $changes['mmessage'] = '\'' . addslashes($_POST['mainmessage']) . '\''; |
1192 | - } |
|
1193 | - else |
|
1267 | + } else |
|
1194 | 1268 | { |
1195 | 1269 | $changes['mtitle'] = '\'Upgrading the forum...\''; |
1196 | 1270 | $changes['mmessage'] = '\'Don\\\'t worry, we will be back shortly with an updated forum. It will only be a minute ;).\''; |
1197 | 1271 | } |
1198 | 1272 | } |
1199 | 1273 | |
1200 | - if ($command_line) |
|
1201 | - echo ' * Updating Settings.php...'; |
|
1274 | + if ($command_line) { |
|
1275 | + echo ' * Updating Settings.php...'; |
|
1276 | + } |
|
1202 | 1277 | |
1203 | 1278 | // Fix some old paths. |
1204 | - if (substr($boarddir, 0, 1) == '.') |
|
1205 | - $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
1279 | + if (substr($boarddir, 0, 1) == '.') { |
|
1280 | + $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
1281 | + } |
|
1206 | 1282 | |
1207 | - if (substr($sourcedir, 0, 1) == '.') |
|
1208 | - $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
1283 | + if (substr($sourcedir, 0, 1) == '.') { |
|
1284 | + $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
1285 | + } |
|
1209 | 1286 | |
1210 | - if (empty($cachedir) || substr($cachedir, 0, 1) == '.') |
|
1211 | - $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
1287 | + if (empty($cachedir) || substr($cachedir, 0, 1) == '.') { |
|
1288 | + $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
1289 | + } |
|
1212 | 1290 | |
1213 | 1291 | // If they have a "host:port" setup for the host, split that into separate values |
1214 | 1292 | // You should never have a : in the hostname if you're not on MySQL, but better safe than sorry |
@@ -1219,32 +1297,36 @@ discard block |
||
1219 | 1297 | $changes['db_server'] = '\'' . $db_server . '\''; |
1220 | 1298 | |
1221 | 1299 | // Only set this if we're not using the default port |
1222 | - if ($db_port != ini_get('mysqli.default_port')) |
|
1223 | - $changes['db_port'] = (int) $db_port; |
|
1224 | - } |
|
1225 | - elseif (!empty($db_port)) |
|
1300 | + if ($db_port != ini_get('mysqli.default_port')) { |
|
1301 | + $changes['db_port'] = (int) $db_port; |
|
1302 | + } |
|
1303 | + } elseif (!empty($db_port)) |
|
1226 | 1304 | { |
1227 | 1305 | // If db_port is set and is the same as the default, set it to '' |
1228 | 1306 | if ($db_type == 'mysql') |
1229 | 1307 | { |
1230 | - if ($db_port == ini_get('mysqli.default_port')) |
|
1231 | - $changes['db_port'] = '\'\''; |
|
1232 | - elseif ($db_type == 'postgresql' && $db_port == 5432) |
|
1233 | - $changes['db_port'] = '\'\''; |
|
1308 | + if ($db_port == ini_get('mysqli.default_port')) { |
|
1309 | + $changes['db_port'] = '\'\''; |
|
1310 | + } elseif ($db_type == 'postgresql' && $db_port == 5432) { |
|
1311 | + $changes['db_port'] = '\'\''; |
|
1312 | + } |
|
1234 | 1313 | } |
1235 | 1314 | } |
1236 | 1315 | |
1237 | 1316 | // Maybe we haven't had this option yet? |
1238 | - if (empty($packagesdir)) |
|
1239 | - $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
1317 | + if (empty($packagesdir)) { |
|
1318 | + $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
1319 | + } |
|
1240 | 1320 | |
1241 | 1321 | // Add support for $tasksdir var. |
1242 | - if (empty($tasksdir)) |
|
1243 | - $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
1322 | + if (empty($tasksdir)) { |
|
1323 | + $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
1324 | + } |
|
1244 | 1325 | |
1245 | 1326 | // Make sure we fix the language as well. |
1246 | - if (stristr($language, '-utf8')) |
|
1247 | - $changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\''; |
|
1327 | + if (stristr($language, '-utf8')) { |
|
1328 | + $changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\''; |
|
1329 | + } |
|
1248 | 1330 | |
1249 | 1331 | // @todo Maybe change the cookie name if going to 1.1, too? |
1250 | 1332 | |
@@ -1255,8 +1337,9 @@ discard block |
||
1255 | 1337 | // Tell Settings.php to store db_last_error.php in the cache |
1256 | 1338 | move_db_last_error_to_cachedir(); |
1257 | 1339 | |
1258 | - if ($command_line) |
|
1259 | - echo ' Successful.' . "\n"; |
|
1340 | + if ($command_line) { |
|
1341 | + echo ' Successful.' . "\n"; |
|
1342 | + } |
|
1260 | 1343 | |
1261 | 1344 | // Are we doing debug? |
1262 | 1345 | if (isset($_POST['debug'])) |
@@ -1266,8 +1349,9 @@ discard block |
||
1266 | 1349 | } |
1267 | 1350 | |
1268 | 1351 | // If we're not backing up then jump one. |
1269 | - if (empty($_POST['backup'])) |
|
1270 | - $upcontext['current_step']++; |
|
1352 | + if (empty($_POST['backup'])) { |
|
1353 | + $upcontext['current_step']++; |
|
1354 | + } |
|
1271 | 1355 | |
1272 | 1356 | // If we've got here then let's proceed to the next step! |
1273 | 1357 | return true; |
@@ -1282,8 +1366,9 @@ discard block |
||
1282 | 1366 | $upcontext['page_title'] = $txt['backup_database']; |
1283 | 1367 | |
1284 | 1368 | // Done it already - js wise? |
1285 | - if (!empty($_POST['backup_done'])) |
|
1286 | - return true; |
|
1369 | + if (!empty($_POST['backup_done'])) { |
|
1370 | + return true; |
|
1371 | + } |
|
1287 | 1372 | |
1288 | 1373 | // Some useful stuff here. |
1289 | 1374 | db_extend(); |
@@ -1297,9 +1382,10 @@ discard block |
||
1297 | 1382 | $tables = $smcFunc['db_list_tables']($db, $filter); |
1298 | 1383 | |
1299 | 1384 | $table_names = array(); |
1300 | - foreach ($tables as $table) |
|
1301 | - if (substr($table, 0, 7) !== 'backup_') |
|
1385 | + foreach ($tables as $table) { |
|
1386 | + if (substr($table, 0, 7) !== 'backup_') |
|
1302 | 1387 | $table_names[] = $table; |
1388 | + } |
|
1303 | 1389 | |
1304 | 1390 | $upcontext['table_count'] = count($table_names); |
1305 | 1391 | $upcontext['cur_table_num'] = $_GET['substep']; |
@@ -1309,12 +1395,14 @@ discard block |
||
1309 | 1395 | $file_steps = $upcontext['table_count']; |
1310 | 1396 | |
1311 | 1397 | // What ones have we already done? |
1312 | - foreach ($table_names as $id => $table) |
|
1313 | - if ($id < $_GET['substep']) |
|
1398 | + foreach ($table_names as $id => $table) { |
|
1399 | + if ($id < $_GET['substep']) |
|
1314 | 1400 | $upcontext['previous_tables'][] = $table; |
1401 | + } |
|
1315 | 1402 | |
1316 | - if ($command_line) |
|
1317 | - echo 'Backing Up Tables.'; |
|
1403 | + if ($command_line) { |
|
1404 | + echo 'Backing Up Tables.'; |
|
1405 | + } |
|
1318 | 1406 | |
1319 | 1407 | // If we don't support javascript we backup here. |
1320 | 1408 | if (!$support_js || isset($_GET['xml'])) |
@@ -1333,8 +1421,9 @@ discard block |
||
1333 | 1421 | backupTable($table_names[$substep]); |
1334 | 1422 | |
1335 | 1423 | // If this is XML to keep it nice for the user do one table at a time anyway! |
1336 | - if (isset($_GET['xml'])) |
|
1337 | - return upgradeExit(); |
|
1424 | + if (isset($_GET['xml'])) { |
|
1425 | + return upgradeExit(); |
|
1426 | + } |
|
1338 | 1427 | } |
1339 | 1428 | |
1340 | 1429 | if ($command_line) |
@@ -1367,9 +1456,10 @@ discard block |
||
1367 | 1456 | |
1368 | 1457 | $smcFunc['db_backup_table']($table, 'backup_' . $table); |
1369 | 1458 | |
1370 | - if ($command_line) |
|
1371 | - echo ' done.'; |
|
1372 | -} |
|
1459 | + if ($command_line) { |
|
1460 | + echo ' done.'; |
|
1461 | + } |
|
1462 | + } |
|
1373 | 1463 | |
1374 | 1464 | // Step 2: Everything. |
1375 | 1465 | function DatabaseChanges() |
@@ -1378,8 +1468,9 @@ discard block |
||
1378 | 1468 | global $upcontext, $support_js, $db_type; |
1379 | 1469 | |
1380 | 1470 | // Have we just completed this? |
1381 | - if (!empty($_POST['database_done'])) |
|
1382 | - return true; |
|
1471 | + if (!empty($_POST['database_done'])) { |
|
1472 | + return true; |
|
1473 | + } |
|
1383 | 1474 | |
1384 | 1475 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'database_xml' : 'database_changes'; |
1385 | 1476 | $upcontext['page_title'] = $txt['database_changes']; |
@@ -1394,15 +1485,16 @@ discard block |
||
1394 | 1485 | ); |
1395 | 1486 | |
1396 | 1487 | // How many files are there in total? |
1397 | - if (isset($_GET['filecount'])) |
|
1398 | - $upcontext['file_count'] = (int) $_GET['filecount']; |
|
1399 | - else |
|
1488 | + if (isset($_GET['filecount'])) { |
|
1489 | + $upcontext['file_count'] = (int) $_GET['filecount']; |
|
1490 | + } else |
|
1400 | 1491 | { |
1401 | 1492 | $upcontext['file_count'] = 0; |
1402 | 1493 | foreach ($files as $file) |
1403 | 1494 | { |
1404 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) |
|
1405 | - $upcontext['file_count']++; |
|
1495 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) { |
|
1496 | + $upcontext['file_count']++; |
|
1497 | + } |
|
1406 | 1498 | } |
1407 | 1499 | } |
1408 | 1500 | |
@@ -1412,9 +1504,9 @@ discard block |
||
1412 | 1504 | $upcontext['cur_file_num'] = 0; |
1413 | 1505 | foreach ($files as $file) |
1414 | 1506 | { |
1415 | - if ($did_not_do) |
|
1416 | - $did_not_do--; |
|
1417 | - else |
|
1507 | + if ($did_not_do) { |
|
1508 | + $did_not_do--; |
|
1509 | + } else |
|
1418 | 1510 | { |
1419 | 1511 | $upcontext['cur_file_num']++; |
1420 | 1512 | $upcontext['cur_file_name'] = $file[0]; |
@@ -1441,12 +1533,13 @@ discard block |
||
1441 | 1533 | // Flag to move on to the next. |
1442 | 1534 | $upcontext['completed_step'] = true; |
1443 | 1535 | // Did we complete the whole file? |
1444 | - if ($nextFile) |
|
1445 | - $upcontext['current_debug_item_num'] = -1; |
|
1536 | + if ($nextFile) { |
|
1537 | + $upcontext['current_debug_item_num'] = -1; |
|
1538 | + } |
|
1446 | 1539 | return upgradeExit(); |
1540 | + } elseif ($support_js) { |
|
1541 | + break; |
|
1447 | 1542 | } |
1448 | - elseif ($support_js) |
|
1449 | - break; |
|
1450 | 1543 | } |
1451 | 1544 | // Set the progress bar to be right as if we had - even if we hadn't... |
1452 | 1545 | $upcontext['step_progress'] = ($upcontext['cur_file_num'] / $upcontext['file_count']) * 100; |
@@ -1472,8 +1565,9 @@ discard block |
||
1472 | 1565 | global $user_info, $maintenance, $smcFunc, $db_type, $txt, $settings; |
1473 | 1566 | |
1474 | 1567 | // Now it's nice to have some of the basic SMF source files. |
1475 | - if (!isset($_GET['ssi']) && !$command_line) |
|
1476 | - redirectLocation('&ssi=1'); |
|
1568 | + if (!isset($_GET['ssi']) && !$command_line) { |
|
1569 | + redirectLocation('&ssi=1'); |
|
1570 | + } |
|
1477 | 1571 | |
1478 | 1572 | $upcontext['sub_template'] = 'upgrade_complete'; |
1479 | 1573 | $upcontext['page_title'] = $txt['upgrade_complete']; |
@@ -1489,14 +1583,16 @@ discard block |
||
1489 | 1583 | // Are we in maintenance mode? |
1490 | 1584 | if (isset($upcontext['user']['main'])) |
1491 | 1585 | { |
1492 | - if ($command_line) |
|
1493 | - echo ' * '; |
|
1586 | + if ($command_line) { |
|
1587 | + echo ' * '; |
|
1588 | + } |
|
1494 | 1589 | $upcontext['removed_maintenance'] = true; |
1495 | 1590 | $changes['maintenance'] = $upcontext['user']['main']; |
1496 | 1591 | } |
1497 | 1592 | // Otherwise if somehow we are in 2 let's go to 1. |
1498 | - elseif (!empty($maintenance) && $maintenance == 2) |
|
1499 | - $changes['maintenance'] = 1; |
|
1593 | + elseif (!empty($maintenance) && $maintenance == 2) { |
|
1594 | + $changes['maintenance'] = 1; |
|
1595 | + } |
|
1500 | 1596 | |
1501 | 1597 | // Wipe this out... |
1502 | 1598 | $upcontext['user'] = array(); |
@@ -1511,21 +1607,23 @@ discard block |
||
1511 | 1607 | $upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__); |
1512 | 1608 | |
1513 | 1609 | // Now is the perfect time to fetch the SM files. |
1514 | - if ($command_line) |
|
1515 | - cli_scheduled_fetchSMfiles(); |
|
1516 | - else |
|
1610 | + if ($command_line) { |
|
1611 | + cli_scheduled_fetchSMfiles(); |
|
1612 | + } else |
|
1517 | 1613 | { |
1518 | 1614 | require_once($sourcedir . '/ScheduledTasks.php'); |
1519 | 1615 | $forum_version = SMF_VERSION; // The variable is usually defined in index.php so lets just use the constant to do it for us. |
1520 | 1616 | scheduled_fetchSMfiles(); // Now go get those files! |
1521 | 1617 | // This is needed in case someone invokes the upgrader using https when upgrading an http forum |
1522 | - if (httpsOn()) |
|
1523 | - $settings['default_theme_url'] = strtr($settings['default_theme_url'], array('http://' => 'https://')); |
|
1618 | + if (httpsOn()) { |
|
1619 | + $settings['default_theme_url'] = strtr($settings['default_theme_url'], array('http://' => 'https://')); |
|
1620 | + } |
|
1524 | 1621 | } |
1525 | 1622 | |
1526 | 1623 | // Log what we've done. |
1527 | - if (empty($user_info['id'])) |
|
1528 | - $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
1624 | + if (empty($user_info['id'])) { |
|
1625 | + $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
1626 | + } |
|
1529 | 1627 | |
1530 | 1628 | // Log the action manually, so CLI still works. |
1531 | 1629 | $smcFunc['db_insert']('', |
@@ -1544,8 +1642,9 @@ discard block |
||
1544 | 1642 | |
1545 | 1643 | // Save the current database version. |
1546 | 1644 | $server_version = $smcFunc['db_server_info'](); |
1547 | - if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
1548 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
1645 | + if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
1646 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
1647 | + } |
|
1549 | 1648 | |
1550 | 1649 | if ($command_line) |
1551 | 1650 | { |
@@ -1557,8 +1656,9 @@ discard block |
||
1557 | 1656 | |
1558 | 1657 | // Make sure it says we're done. |
1559 | 1658 | $upcontext['overall_percent'] = 100; |
1560 | - if (isset($upcontext['step_progress'])) |
|
1561 | - unset($upcontext['step_progress']); |
|
1659 | + if (isset($upcontext['step_progress'])) { |
|
1660 | + unset($upcontext['step_progress']); |
|
1661 | + } |
|
1562 | 1662 | |
1563 | 1663 | $_GET['substep'] = 0; |
1564 | 1664 | return false; |
@@ -1569,8 +1669,9 @@ discard block |
||
1569 | 1669 | { |
1570 | 1670 | global $sourcedir, $language, $forum_version, $modSettings, $smcFunc; |
1571 | 1671 | |
1572 | - if (empty($modSettings['time_format'])) |
|
1573 | - $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
1672 | + if (empty($modSettings['time_format'])) { |
|
1673 | + $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
1674 | + } |
|
1574 | 1675 | |
1575 | 1676 | // What files do we want to get |
1576 | 1677 | $request = $smcFunc['db_query']('', ' |
@@ -1604,8 +1705,9 @@ discard block |
||
1604 | 1705 | $file_data = fetch_web_data($url); |
1605 | 1706 | |
1606 | 1707 | // If we got an error - give up - the site might be down. |
1607 | - if ($file_data === false) |
|
1608 | - return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
1708 | + if ($file_data === false) { |
|
1709 | + return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
1710 | + } |
|
1609 | 1711 | |
1610 | 1712 | // Save the file to the database. |
1611 | 1713 | $smcFunc['db_query']('substring', ' |
@@ -1647,8 +1749,9 @@ discard block |
||
1647 | 1749 | $themeData = array(); |
1648 | 1750 | foreach ($values as $variable => $value) |
1649 | 1751 | { |
1650 | - if (!isset($value) || $value === null) |
|
1651 | - $value = 0; |
|
1752 | + if (!isset($value) || $value === null) { |
|
1753 | + $value = 0; |
|
1754 | + } |
|
1652 | 1755 | |
1653 | 1756 | $themeData[] = array(0, 1, $variable, $value); |
1654 | 1757 | } |
@@ -1677,8 +1780,9 @@ discard block |
||
1677 | 1780 | |
1678 | 1781 | foreach ($values as $variable => $value) |
1679 | 1782 | { |
1680 | - if (empty($modSettings[$value[0]])) |
|
1681 | - continue; |
|
1783 | + if (empty($modSettings[$value[0]])) { |
|
1784 | + continue; |
|
1785 | + } |
|
1682 | 1786 | |
1683 | 1787 | $smcFunc['db_query']('', ' |
1684 | 1788 | INSERT IGNORE INTO {db_prefix}themes |
@@ -1764,19 +1868,21 @@ discard block |
||
1764 | 1868 | set_error_handler( |
1765 | 1869 | function ($errno, $errstr, $errfile, $errline) use ($support_js) |
1766 | 1870 | { |
1767 | - if ($support_js) |
|
1768 | - return true; |
|
1769 | - else |
|
1770 | - echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
1871 | + if ($support_js) { |
|
1872 | + return true; |
|
1873 | + } else { |
|
1874 | + echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
1875 | + } |
|
1771 | 1876 | } |
1772 | 1877 | ); |
1773 | 1878 | |
1774 | 1879 | // If we're on MySQL, set {db_collation}; this approach is used throughout upgrade_2-0_mysql.php to set new tables to utf8 |
1775 | 1880 | // Note it is expected to be in the format: ENGINE=MyISAM{$db_collation}; |
1776 | - if ($db_type == 'mysql') |
|
1777 | - $db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
1778 | - else |
|
1779 | - $db_collation = ''; |
|
1881 | + if ($db_type == 'mysql') { |
|
1882 | + $db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
1883 | + } else { |
|
1884 | + $db_collation = ''; |
|
1885 | + } |
|
1780 | 1886 | |
1781 | 1887 | $endl = $command_line ? "\n" : '<br>' . "\n"; |
1782 | 1888 | |
@@ -1788,8 +1894,9 @@ discard block |
||
1788 | 1894 | $last_step = ''; |
1789 | 1895 | |
1790 | 1896 | // Make sure all newly created tables will have the proper characters set; this approach is used throughout upgrade_2-1_mysql.php |
1791 | - if (isset($db_character_set) && $db_character_set === 'utf8') |
|
1792 | - $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
1897 | + if (isset($db_character_set) && $db_character_set === 'utf8') { |
|
1898 | + $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
1899 | + } |
|
1793 | 1900 | |
1794 | 1901 | // Count the total number of steps within this file - for progress. |
1795 | 1902 | $file_steps = substr_count(implode('', $lines), '---#'); |
@@ -1809,15 +1916,18 @@ discard block |
||
1809 | 1916 | $do_current = $substep >= $_GET['substep']; |
1810 | 1917 | |
1811 | 1918 | // Get rid of any comments in the beginning of the line... |
1812 | - if (substr(trim($line), 0, 2) === '/*') |
|
1813 | - $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
1919 | + if (substr(trim($line), 0, 2) === '/*') { |
|
1920 | + $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
1921 | + } |
|
1814 | 1922 | |
1815 | 1923 | // Always flush. Flush, flush, flush. Flush, flush, flush, flush! FLUSH! |
1816 | - if ($is_debug && !$support_js && $command_line) |
|
1817 | - flush(); |
|
1924 | + if ($is_debug && !$support_js && $command_line) { |
|
1925 | + flush(); |
|
1926 | + } |
|
1818 | 1927 | |
1819 | - if (trim($line) === '') |
|
1820 | - continue; |
|
1928 | + if (trim($line) === '') { |
|
1929 | + continue; |
|
1930 | + } |
|
1821 | 1931 | |
1822 | 1932 | if (trim(substr($line, 0, 3)) === '---') |
1823 | 1933 | { |
@@ -1827,8 +1937,9 @@ discard block |
||
1827 | 1937 | if (trim($current_data) != '' && $type !== '}') |
1828 | 1938 | { |
1829 | 1939 | $upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl; |
1830 | - if ($command_line) |
|
1831 | - echo $upcontext['error_message']; |
|
1940 | + if ($command_line) { |
|
1941 | + echo $upcontext['error_message']; |
|
1942 | + } |
|
1832 | 1943 | } |
1833 | 1944 | |
1834 | 1945 | if ($type == ' ') |
@@ -1846,17 +1957,18 @@ discard block |
||
1846 | 1957 | if ($do_current) |
1847 | 1958 | { |
1848 | 1959 | $upcontext['actioned_items'][] = $last_step; |
1849 | - if ($command_line) |
|
1850 | - echo ' * '; |
|
1960 | + if ($command_line) { |
|
1961 | + echo ' * '; |
|
1962 | + } |
|
1851 | 1963 | } |
1852 | - } |
|
1853 | - elseif ($type == '#') |
|
1964 | + } elseif ($type == '#') |
|
1854 | 1965 | { |
1855 | 1966 | $upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps; |
1856 | 1967 | |
1857 | 1968 | $upcontext['current_debug_item_num']++; |
1858 | - if (trim($line) != '---#') |
|
1859 | - $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
1969 | + if (trim($line) != '---#') { |
|
1970 | + $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
1971 | + } |
|
1860 | 1972 | |
1861 | 1973 | // Have we already done something? |
1862 | 1974 | if (isset($_GET['xml']) && $done_something) |
@@ -1867,34 +1979,36 @@ discard block |
||
1867 | 1979 | |
1868 | 1980 | if ($do_current) |
1869 | 1981 | { |
1870 | - if (trim($line) == '---#' && $command_line) |
|
1871 | - echo ' done.', $endl; |
|
1872 | - elseif ($command_line) |
|
1873 | - echo ' +++ ', rtrim(substr($line, 4)); |
|
1874 | - elseif (trim($line) != '---#') |
|
1982 | + if (trim($line) == '---#' && $command_line) { |
|
1983 | + echo ' done.', $endl; |
|
1984 | + } elseif ($command_line) { |
|
1985 | + echo ' +++ ', rtrim(substr($line, 4)); |
|
1986 | + } elseif (trim($line) != '---#') |
|
1875 | 1987 | { |
1876 | - if ($is_debug) |
|
1877 | - $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
1988 | + if ($is_debug) { |
|
1989 | + $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
1990 | + } |
|
1878 | 1991 | } |
1879 | 1992 | } |
1880 | 1993 | |
1881 | 1994 | if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep']) |
1882 | 1995 | { |
1883 | - if ($command_line) |
|
1884 | - echo ' * '; |
|
1885 | - else |
|
1886 | - $upcontext['actioned_items'][] = $last_step; |
|
1996 | + if ($command_line) { |
|
1997 | + echo ' * '; |
|
1998 | + } else { |
|
1999 | + $upcontext['actioned_items'][] = $last_step; |
|
2000 | + } |
|
1887 | 2001 | } |
1888 | 2002 | |
1889 | 2003 | // Small step - only if we're actually doing stuff. |
1890 | - if ($do_current) |
|
1891 | - nextSubstep(++$substep); |
|
1892 | - else |
|
1893 | - $substep++; |
|
1894 | - } |
|
1895 | - elseif ($type == '{') |
|
1896 | - $current_type = 'code'; |
|
1897 | - elseif ($type == '}') |
|
2004 | + if ($do_current) { |
|
2005 | + nextSubstep(++$substep); |
|
2006 | + } else { |
|
2007 | + $substep++; |
|
2008 | + } |
|
2009 | + } elseif ($type == '{') { |
|
2010 | + $current_type = 'code'; |
|
2011 | + } elseif ($type == '}') |
|
1898 | 2012 | { |
1899 | 2013 | $current_type = 'sql'; |
1900 | 2014 | |
@@ -1907,8 +2021,9 @@ discard block |
||
1907 | 2021 | if (eval('global $db_prefix, $modSettings, $smcFunc; ' . $current_data) === false) |
1908 | 2022 | { |
1909 | 2023 | $upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl; |
1910 | - if ($command_line) |
|
1911 | - echo $upcontext['error_message']; |
|
2024 | + if ($command_line) { |
|
2025 | + echo $upcontext['error_message']; |
|
2026 | + } |
|
1912 | 2027 | } |
1913 | 2028 | |
1914 | 2029 | // Done with code! |
@@ -1995,8 +2110,9 @@ discard block |
||
1995 | 2110 | $db_unbuffered = false; |
1996 | 2111 | |
1997 | 2112 | // Failure?! |
1998 | - if ($result !== false) |
|
1999 | - return $result; |
|
2113 | + if ($result !== false) { |
|
2114 | + return $result; |
|
2115 | + } |
|
2000 | 2116 | |
2001 | 2117 | $db_error_message = $smcFunc['db_error']($db_connection); |
2002 | 2118 | // If MySQL we do something more clever. |
@@ -2024,54 +2140,61 @@ discard block |
||
2024 | 2140 | { |
2025 | 2141 | mysqli_query($db_connection, 'REPAIR TABLE `' . $match[1] . '`'); |
2026 | 2142 | $result = mysqli_query($db_connection, $string); |
2027 | - if ($result !== false) |
|
2028 | - return $result; |
|
2143 | + if ($result !== false) { |
|
2144 | + return $result; |
|
2145 | + } |
|
2029 | 2146 | } |
2030 | - } |
|
2031 | - elseif ($mysqli_errno == 2013) |
|
2147 | + } elseif ($mysqli_errno == 2013) |
|
2032 | 2148 | { |
2033 | 2149 | $db_connection = mysqli_connect($db_server, $db_user, $db_passwd); |
2034 | 2150 | mysqli_select_db($db_connection, $db_name); |
2035 | 2151 | if ($db_connection) |
2036 | 2152 | { |
2037 | 2153 | $result = mysqli_query($db_connection, $string); |
2038 | - if ($result !== false) |
|
2039 | - return $result; |
|
2154 | + if ($result !== false) { |
|
2155 | + return $result; |
|
2156 | + } |
|
2040 | 2157 | } |
2041 | 2158 | } |
2042 | 2159 | // Duplicate column name... should be okay ;). |
2043 | - elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) |
|
2044 | - return false; |
|
2160 | + elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) { |
|
2161 | + return false; |
|
2162 | + } |
|
2045 | 2163 | // Duplicate insert... make sure it's the proper type of query ;). |
2046 | - elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) |
|
2047 | - return false; |
|
2164 | + elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) { |
|
2165 | + return false; |
|
2166 | + } |
|
2048 | 2167 | // Creating an index on a non-existent column. |
2049 | - elseif ($mysqli_errno == 1072) |
|
2050 | - return false; |
|
2051 | - elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') |
|
2052 | - return false; |
|
2168 | + elseif ($mysqli_errno == 1072) { |
|
2169 | + return false; |
|
2170 | + } elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') { |
|
2171 | + return false; |
|
2172 | + } |
|
2053 | 2173 | } |
2054 | 2174 | // If a table already exists don't go potty. |
2055 | 2175 | else |
2056 | 2176 | { |
2057 | 2177 | if (in_array(substr(trim($string), 0, 8), array('CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U'))) |
2058 | 2178 | { |
2059 | - if (strpos($db_error_message, 'exist') !== false) |
|
2060 | - return true; |
|
2061 | - } |
|
2062 | - elseif (strpos(trim($string), 'INSERT ') !== false) |
|
2179 | + if (strpos($db_error_message, 'exist') !== false) { |
|
2180 | + return true; |
|
2181 | + } |
|
2182 | + } elseif (strpos(trim($string), 'INSERT ') !== false) |
|
2063 | 2183 | { |
2064 | - if (strpos($db_error_message, 'duplicate') !== false || $ignore_insert_error) |
|
2065 | - return true; |
|
2184 | + if (strpos($db_error_message, 'duplicate') !== false || $ignore_insert_error) { |
|
2185 | + return true; |
|
2186 | + } |
|
2066 | 2187 | } |
2067 | 2188 | } |
2068 | 2189 | |
2069 | 2190 | // Get the query string so we pass everything. |
2070 | 2191 | $query_string = ''; |
2071 | - foreach ($_GET as $k => $v) |
|
2072 | - $query_string .= ';' . $k . '=' . $v; |
|
2073 | - if (strlen($query_string) != 0) |
|
2074 | - $query_string = '?' . substr($query_string, 1); |
|
2192 | + foreach ($_GET as $k => $v) { |
|
2193 | + $query_string .= ';' . $k . '=' . $v; |
|
2194 | + } |
|
2195 | + if (strlen($query_string) != 0) { |
|
2196 | + $query_string = '?' . substr($query_string, 1); |
|
2197 | + } |
|
2075 | 2198 | |
2076 | 2199 | if ($command_line) |
2077 | 2200 | { |
@@ -2126,16 +2249,18 @@ discard block |
||
2126 | 2249 | { |
2127 | 2250 | $found |= 1; |
2128 | 2251 | // Do some checks on the data if we have it set. |
2129 | - if (isset($change['col_type'])) |
|
2130 | - $found &= $change['col_type'] === $column['type']; |
|
2131 | - if (isset($change['null_allowed'])) |
|
2132 | - $found &= $column['null'] == $change['null_allowed']; |
|
2133 | - if (isset($change['default'])) |
|
2134 | - $found &= $change['default'] === $column['default']; |
|
2252 | + if (isset($change['col_type'])) { |
|
2253 | + $found &= $change['col_type'] === $column['type']; |
|
2254 | + } |
|
2255 | + if (isset($change['null_allowed'])) { |
|
2256 | + $found &= $column['null'] == $change['null_allowed']; |
|
2257 | + } |
|
2258 | + if (isset($change['default'])) { |
|
2259 | + $found &= $change['default'] === $column['default']; |
|
2260 | + } |
|
2135 | 2261 | } |
2136 | 2262 | } |
2137 | - } |
|
2138 | - elseif ($change['type'] === 'index') |
|
2263 | + } elseif ($change['type'] === 'index') |
|
2139 | 2264 | { |
2140 | 2265 | $request = upgrade_query(' |
2141 | 2266 | SHOW INDEX |
@@ -2144,9 +2269,10 @@ discard block |
||
2144 | 2269 | { |
2145 | 2270 | $cur_index = array(); |
2146 | 2271 | |
2147 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2148 | - if ($row['Key_name'] === $change['name']) |
|
2272 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2273 | + if ($row['Key_name'] === $change['name']) |
|
2149 | 2274 | $cur_index[(int) $row['Seq_in_index']] = $row['Column_name']; |
2275 | + } |
|
2150 | 2276 | |
2151 | 2277 | ksort($cur_index, SORT_NUMERIC); |
2152 | 2278 | $found = array_values($cur_index) === $change['target_columns']; |
@@ -2156,14 +2282,17 @@ discard block |
||
2156 | 2282 | } |
2157 | 2283 | |
2158 | 2284 | // If we're trying to add and it's added, we're done. |
2159 | - if ($found && in_array($change['method'], array('add', 'change'))) |
|
2160 | - return true; |
|
2285 | + if ($found && in_array($change['method'], array('add', 'change'))) { |
|
2286 | + return true; |
|
2287 | + } |
|
2161 | 2288 | // Otherwise if we're removing and it wasn't found we're also done. |
2162 | - elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) |
|
2163 | - return true; |
|
2289 | + elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) { |
|
2290 | + return true; |
|
2291 | + } |
|
2164 | 2292 | // Otherwise is it just a test? |
2165 | - elseif ($is_test) |
|
2166 | - return false; |
|
2293 | + elseif ($is_test) { |
|
2294 | + return false; |
|
2295 | + } |
|
2167 | 2296 | |
2168 | 2297 | // Not found it yet? Bummer! How about we see if we're currently doing it? |
2169 | 2298 | $running = false; |
@@ -2174,8 +2303,9 @@ discard block |
||
2174 | 2303 | SHOW FULL PROCESSLIST'); |
2175 | 2304 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2176 | 2305 | { |
2177 | - if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) |
|
2178 | - $found = true; |
|
2306 | + if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) { |
|
2307 | + $found = true; |
|
2308 | + } |
|
2179 | 2309 | } |
2180 | 2310 | |
2181 | 2311 | // Can't find it? Then we need to run it fools! |
@@ -2187,8 +2317,9 @@ discard block |
||
2187 | 2317 | ALTER TABLE ' . $db_prefix . $change['table'] . ' |
2188 | 2318 | ' . $change['text'], true) !== false; |
2189 | 2319 | |
2190 | - if (!$success) |
|
2191 | - return false; |
|
2320 | + if (!$success) { |
|
2321 | + return false; |
|
2322 | + } |
|
2192 | 2323 | |
2193 | 2324 | // Return |
2194 | 2325 | $running = true; |
@@ -2230,8 +2361,9 @@ discard block |
||
2230 | 2361 | 'db_error_skip' => true, |
2231 | 2362 | ) |
2232 | 2363 | ); |
2233 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
2234 | - die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
2364 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
2365 | + die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
2366 | + } |
|
2235 | 2367 | $table_row = $smcFunc['db_fetch_assoc']($request); |
2236 | 2368 | $smcFunc['db_free_result']($request); |
2237 | 2369 | |
@@ -2253,18 +2385,19 @@ discard block |
||
2253 | 2385 | ) |
2254 | 2386 | ); |
2255 | 2387 | // No results? Just forget it all together. |
2256 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
2257 | - unset($table_row['Collation']); |
|
2258 | - else |
|
2259 | - $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
2388 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
2389 | + unset($table_row['Collation']); |
|
2390 | + } else { |
|
2391 | + $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
2392 | + } |
|
2260 | 2393 | $smcFunc['db_free_result']($request); |
2261 | 2394 | } |
2262 | 2395 | |
2263 | 2396 | if ($column_fix) |
2264 | 2397 | { |
2265 | 2398 | // Make sure there are no NULL's left. |
2266 | - if ($null_fix) |
|
2267 | - $smcFunc['db_query']('', ' |
|
2399 | + if ($null_fix) { |
|
2400 | + $smcFunc['db_query']('', ' |
|
2268 | 2401 | UPDATE {db_prefix}' . $change['table'] . ' |
2269 | 2402 | SET ' . $change['column'] . ' = {string:default} |
2270 | 2403 | WHERE ' . $change['column'] . ' IS NULL', |
@@ -2273,6 +2406,7 @@ discard block |
||
2273 | 2406 | 'db_error_skip' => true, |
2274 | 2407 | ) |
2275 | 2408 | ); |
2409 | + } |
|
2276 | 2410 | |
2277 | 2411 | // Do the actual alteration. |
2278 | 2412 | $smcFunc['db_query']('', ' |
@@ -2301,8 +2435,9 @@ discard block |
||
2301 | 2435 | } |
2302 | 2436 | |
2303 | 2437 | // Not a column we need to check on? |
2304 | - if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) |
|
2305 | - return; |
|
2438 | + if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) { |
|
2439 | + return; |
|
2440 | + } |
|
2306 | 2441 | |
2307 | 2442 | // Break it up you (six|seven). |
2308 | 2443 | $temp = explode(' ', str_replace('NOT NULL', 'NOT_NULL', $change['text'])); |
@@ -2321,13 +2456,13 @@ discard block |
||
2321 | 2456 | 'new_name' => $temp[2], |
2322 | 2457 | )); |
2323 | 2458 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
2324 | - if ($smcFunc['db_num_rows'] != 1) |
|
2325 | - return; |
|
2459 | + if ($smcFunc['db_num_rows'] != 1) { |
|
2460 | + return; |
|
2461 | + } |
|
2326 | 2462 | |
2327 | 2463 | list (, $current_type) = $smcFunc['db_fetch_assoc']($request); |
2328 | 2464 | $smcFunc['db_free_result']($request); |
2329 | - } |
|
2330 | - else |
|
2465 | + } else |
|
2331 | 2466 | { |
2332 | 2467 | // Do this the old fashion, sure method way. |
2333 | 2468 | $request = $smcFunc['db_query']('', ' |
@@ -2338,21 +2473,24 @@ discard block |
||
2338 | 2473 | )); |
2339 | 2474 | // Mayday! |
2340 | 2475 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
2341 | - if ($smcFunc['db_num_rows'] == 0) |
|
2342 | - return; |
|
2476 | + if ($smcFunc['db_num_rows'] == 0) { |
|
2477 | + return; |
|
2478 | + } |
|
2343 | 2479 | |
2344 | 2480 | // Oh where, oh where has my little field gone. Oh where can it be... |
2345 | - while ($row = $smcFunc['db_query']($request)) |
|
2346 | - if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
2481 | + while ($row = $smcFunc['db_query']($request)) { |
|
2482 | + if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
2347 | 2483 | { |
2348 | 2484 | $current_type = $row['Type']; |
2485 | + } |
|
2349 | 2486 | break; |
2350 | 2487 | } |
2351 | 2488 | } |
2352 | 2489 | |
2353 | 2490 | // If this doesn't match, the column may of been altered for a reason. |
2354 | - if (trim($current_type) != trim($temp[3])) |
|
2355 | - $temp[3] = $current_type; |
|
2491 | + if (trim($current_type) != trim($temp[3])) { |
|
2492 | + $temp[3] = $current_type; |
|
2493 | + } |
|
2356 | 2494 | |
2357 | 2495 | // Piece this back together. |
2358 | 2496 | $change['text'] = str_replace('NOT_NULL', 'NOT NULL', implode(' ', $temp)); |
@@ -2364,8 +2502,9 @@ discard block |
||
2364 | 2502 | global $start_time, $timeLimitThreshold, $command_line, $custom_warning; |
2365 | 2503 | global $step_progress, $is_debug, $upcontext; |
2366 | 2504 | |
2367 | - if ($_GET['substep'] < $substep) |
|
2368 | - $_GET['substep'] = $substep; |
|
2505 | + if ($_GET['substep'] < $substep) { |
|
2506 | + $_GET['substep'] = $substep; |
|
2507 | + } |
|
2369 | 2508 | |
2370 | 2509 | if ($command_line) |
2371 | 2510 | { |
@@ -2378,29 +2517,33 @@ discard block |
||
2378 | 2517 | } |
2379 | 2518 | |
2380 | 2519 | @set_time_limit(300); |
2381 | - if (function_exists('apache_reset_timeout')) |
|
2382 | - @apache_reset_timeout(); |
|
2520 | + if (function_exists('apache_reset_timeout')) { |
|
2521 | + @apache_reset_timeout(); |
|
2522 | + } |
|
2383 | 2523 | |
2384 | - if (time() - $start_time <= $timeLimitThreshold) |
|
2385 | - return; |
|
2524 | + if (time() - $start_time <= $timeLimitThreshold) { |
|
2525 | + return; |
|
2526 | + } |
|
2386 | 2527 | |
2387 | 2528 | // Do we have some custom step progress stuff? |
2388 | 2529 | if (!empty($step_progress)) |
2389 | 2530 | { |
2390 | 2531 | $upcontext['substep_progress'] = 0; |
2391 | 2532 | $upcontext['substep_progress_name'] = $step_progress['name']; |
2392 | - if ($step_progress['current'] > $step_progress['total']) |
|
2393 | - $upcontext['substep_progress'] = 99.9; |
|
2394 | - else |
|
2395 | - $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
2533 | + if ($step_progress['current'] > $step_progress['total']) { |
|
2534 | + $upcontext['substep_progress'] = 99.9; |
|
2535 | + } else { |
|
2536 | + $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
2537 | + } |
|
2396 | 2538 | |
2397 | 2539 | // Make it nicely rounded. |
2398 | 2540 | $upcontext['substep_progress'] = round($upcontext['substep_progress'], 1); |
2399 | 2541 | } |
2400 | 2542 | |
2401 | 2543 | // If this is XML we just exit right away! |
2402 | - if (isset($_GET['xml'])) |
|
2403 | - return upgradeExit(); |
|
2544 | + if (isset($_GET['xml'])) { |
|
2545 | + return upgradeExit(); |
|
2546 | + } |
|
2404 | 2547 | |
2405 | 2548 | // We're going to pause after this! |
2406 | 2549 | $upcontext['pause'] = true; |
@@ -2408,13 +2551,15 @@ discard block |
||
2408 | 2551 | $upcontext['query_string'] = ''; |
2409 | 2552 | foreach ($_GET as $k => $v) |
2410 | 2553 | { |
2411 | - if ($k != 'data' && $k != 'substep' && $k != 'step') |
|
2412 | - $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
2554 | + if ($k != 'data' && $k != 'substep' && $k != 'step') { |
|
2555 | + $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
2556 | + } |
|
2413 | 2557 | } |
2414 | 2558 | |
2415 | 2559 | // Custom warning? |
2416 | - if (!empty($custom_warning)) |
|
2417 | - $upcontext['custom_warning'] = $custom_warning; |
|
2560 | + if (!empty($custom_warning)) { |
|
2561 | + $upcontext['custom_warning'] = $custom_warning; |
|
2562 | + } |
|
2418 | 2563 | |
2419 | 2564 | upgradeExit(); |
2420 | 2565 | } |
@@ -2429,25 +2574,26 @@ discard block |
||
2429 | 2574 | ob_implicit_flush(true); |
2430 | 2575 | @set_time_limit(600); |
2431 | 2576 | |
2432 | - if (!isset($_SERVER['argv'])) |
|
2433 | - $_SERVER['argv'] = array(); |
|
2577 | + if (!isset($_SERVER['argv'])) { |
|
2578 | + $_SERVER['argv'] = array(); |
|
2579 | + } |
|
2434 | 2580 | $_GET['maint'] = 1; |
2435 | 2581 | |
2436 | 2582 | foreach ($_SERVER['argv'] as $i => $arg) |
2437 | 2583 | { |
2438 | - if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) |
|
2439 | - $_GET['lang'] = $match[1]; |
|
2440 | - elseif (preg_match('~^--path=(.+)$~', $arg) != 0) |
|
2441 | - continue; |
|
2442 | - elseif ($arg == '--no-maintenance') |
|
2443 | - $_GET['maint'] = 0; |
|
2444 | - elseif ($arg == '--debug') |
|
2445 | - $is_debug = true; |
|
2446 | - elseif ($arg == '--backup') |
|
2447 | - $_POST['backup'] = 1; |
|
2448 | - elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) |
|
2449 | - $_GET['conv'] = 1; |
|
2450 | - elseif ($i != 0) |
|
2584 | + if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) { |
|
2585 | + $_GET['lang'] = $match[1]; |
|
2586 | + } elseif (preg_match('~^--path=(.+)$~', $arg) != 0) { |
|
2587 | + continue; |
|
2588 | + } elseif ($arg == '--no-maintenance') { |
|
2589 | + $_GET['maint'] = 0; |
|
2590 | + } elseif ($arg == '--debug') { |
|
2591 | + $is_debug = true; |
|
2592 | + } elseif ($arg == '--backup') { |
|
2593 | + $_POST['backup'] = 1; |
|
2594 | + } elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) { |
|
2595 | + $_GET['conv'] = 1; |
|
2596 | + } elseif ($i != 0) |
|
2451 | 2597 | { |
2452 | 2598 | echo 'SMF Command-line Upgrader |
2453 | 2599 | Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]... |
@@ -2461,10 +2607,12 @@ discard block |
||
2461 | 2607 | } |
2462 | 2608 | } |
2463 | 2609 | |
2464 | - if (!php_version_check()) |
|
2465 | - print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
2466 | - if (!db_version_check()) |
|
2467 | - print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
2610 | + if (!php_version_check()) { |
|
2611 | + print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
2612 | + } |
|
2613 | + if (!db_version_check()) { |
|
2614 | + print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
2615 | + } |
|
2468 | 2616 | |
2469 | 2617 | // Do some checks to make sure they have proper privileges |
2470 | 2618 | db_extend('packages'); |
@@ -2479,34 +2627,39 @@ discard block |
||
2479 | 2627 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
2480 | 2628 | |
2481 | 2629 | // Sorry... we need CREATE, ALTER and DROP |
2482 | - if (!$create || !$alter || !$drop) |
|
2483 | - print_error("The " . $databases[$db_type]['name'] . " user you have set in Settings.php does not have proper privileges.\n\nPlease ask your host to give this user the ALTER, CREATE, and DROP privileges.", true); |
|
2630 | + if (!$create || !$alter || !$drop) { |
|
2631 | + print_error("The " . $databases[$db_type]['name'] . " user you have set in Settings.php does not have proper privileges.\n\nPlease ask your host to give this user the ALTER, CREATE, and DROP privileges.", true); |
|
2632 | + } |
|
2484 | 2633 | |
2485 | 2634 | $check = @file_exists($modSettings['theme_dir'] . '/index.template.php') |
2486 | 2635 | && @file_exists($sourcedir . '/QueryString.php') |
2487 | 2636 | && @file_exists($sourcedir . '/ManageBoards.php'); |
2488 | - if (!$check && !isset($modSettings['smfVersion'])) |
|
2489 | - print_error('Error: Some files are missing or out-of-date.', true); |
|
2637 | + if (!$check && !isset($modSettings['smfVersion'])) { |
|
2638 | + print_error('Error: Some files are missing or out-of-date.', true); |
|
2639 | + } |
|
2490 | 2640 | |
2491 | 2641 | // Do a quick version spot check. |
2492 | 2642 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
2493 | 2643 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
2494 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
2495 | - print_error('Error: Some files have not yet been updated properly.'); |
|
2644 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
2645 | + print_error('Error: Some files have not yet been updated properly.'); |
|
2646 | + } |
|
2496 | 2647 | |
2497 | 2648 | // Make sure Settings.php is writable. |
2498 | 2649 | quickFileWritable($boarddir . '/Settings.php'); |
2499 | - if (!is_writable($boarddir . '/Settings.php')) |
|
2500 | - print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
2650 | + if (!is_writable($boarddir . '/Settings.php')) { |
|
2651 | + print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
2652 | + } |
|
2501 | 2653 | |
2502 | 2654 | // Make sure Settings_bak.php is writable. |
2503 | 2655 | quickFileWritable($boarddir . '/Settings_bak.php'); |
2504 | - if (!is_writable($boarddir . '/Settings_bak.php')) |
|
2505 | - print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
2656 | + if (!is_writable($boarddir . '/Settings_bak.php')) { |
|
2657 | + print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
2658 | + } |
|
2506 | 2659 | |
2507 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
2508 | - print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
2509 | - elseif (isset($modSettings['agreement'])) |
|
2660 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
2661 | + print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
2662 | + } elseif (isset($modSettings['agreement'])) |
|
2510 | 2663 | { |
2511 | 2664 | $fp = fopen($boarddir . '/agreement.txt', 'w'); |
2512 | 2665 | fwrite($fp, $modSettings['agreement']); |
@@ -2516,36 +2669,42 @@ discard block |
||
2516 | 2669 | // Make sure Themes is writable. |
2517 | 2670 | quickFileWritable($modSettings['theme_dir']); |
2518 | 2671 | |
2519 | - if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) |
|
2520 | - print_error('Error: Unable to obtain write access to "Themes".'); |
|
2672 | + if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) { |
|
2673 | + print_error('Error: Unable to obtain write access to "Themes".'); |
|
2674 | + } |
|
2521 | 2675 | |
2522 | 2676 | // Make sure cache directory exists and is writable! |
2523 | 2677 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
2524 | - if (!file_exists($cachedir_temp)) |
|
2525 | - @mkdir($cachedir_temp); |
|
2678 | + if (!file_exists($cachedir_temp)) { |
|
2679 | + @mkdir($cachedir_temp); |
|
2680 | + } |
|
2526 | 2681 | |
2527 | 2682 | // Make sure the cache temp dir is writable. |
2528 | 2683 | quickFileWritable($cachedir_temp); |
2529 | 2684 | |
2530 | - if (!is_writable($cachedir_temp)) |
|
2531 | - print_error('Error: Unable to obtain write access to "cache".', true); |
|
2685 | + if (!is_writable($cachedir_temp)) { |
|
2686 | + print_error('Error: Unable to obtain write access to "cache".', true); |
|
2687 | + } |
|
2532 | 2688 | |
2533 | 2689 | // Make sure db_last_error.php is writable. |
2534 | 2690 | quickFileWritable($cachedir_temp . '/db_last_error.php'); |
2535 | - if (!is_writable($cachedir_temp . '/db_last_error.php')) |
|
2536 | - print_error('Error: Unable to obtain write access to "db_last_error.php".'); |
|
2691 | + if (!is_writable($cachedir_temp . '/db_last_error.php')) { |
|
2692 | + print_error('Error: Unable to obtain write access to "db_last_error.php".'); |
|
2693 | + } |
|
2537 | 2694 | |
2538 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
2539 | - print_error('Error: Unable to find language files!', true); |
|
2540 | - else |
|
2695 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
2696 | + print_error('Error: Unable to find language files!', true); |
|
2697 | + } else |
|
2541 | 2698 | { |
2542 | 2699 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
2543 | 2700 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
2544 | 2701 | |
2545 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
2546 | - print_error('Error: Language files out of date.', true); |
|
2547 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
2548 | - print_error('Error: Install language is missing for selected language.', true); |
|
2702 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
2703 | + print_error('Error: Language files out of date.', true); |
|
2704 | + } |
|
2705 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
2706 | + print_error('Error: Install language is missing for selected language.', true); |
|
2707 | + } |
|
2549 | 2708 | |
2550 | 2709 | // Otherwise include it! |
2551 | 2710 | require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
@@ -2565,8 +2724,9 @@ discard block |
||
2565 | 2724 | global $db_prefix, $db_type, $command_line, $support_js, $txt; |
2566 | 2725 | |
2567 | 2726 | // Done it already? |
2568 | - if (!empty($_POST['utf8_done'])) |
|
2569 | - return true; |
|
2727 | + if (!empty($_POST['utf8_done'])) { |
|
2728 | + return true; |
|
2729 | + } |
|
2570 | 2730 | |
2571 | 2731 | // First make sure they aren't already on UTF-8 before we go anywhere... |
2572 | 2732 | if ($db_type == 'postgresql' || ($db_character_set === 'utf8' && !empty($modSettings['global_character_set']) && $modSettings['global_character_set'] === 'UTF-8')) |
@@ -2579,8 +2739,7 @@ discard block |
||
2579 | 2739 | ); |
2580 | 2740 | |
2581 | 2741 | return true; |
2582 | - } |
|
2583 | - else |
|
2742 | + } else |
|
2584 | 2743 | { |
2585 | 2744 | $upcontext['page_title'] = $txt['converting_utf8']; |
2586 | 2745 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'convert_xml' : 'convert_utf8'; |
@@ -2624,8 +2783,9 @@ discard block |
||
2624 | 2783 | ) |
2625 | 2784 | ); |
2626 | 2785 | $db_charsets = array(); |
2627 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2628 | - $db_charsets[] = $row['Charset']; |
|
2786 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2787 | + $db_charsets[] = $row['Charset']; |
|
2788 | + } |
|
2629 | 2789 | |
2630 | 2790 | $smcFunc['db_free_result']($request); |
2631 | 2791 | |
@@ -2661,13 +2821,15 @@ discard block |
||
2661 | 2821 | // If there's a fulltext index, we need to drop it first... |
2662 | 2822 | if ($request !== false || $smcFunc['db_num_rows']($request) != 0) |
2663 | 2823 | { |
2664 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2665 | - if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
2824 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2825 | + if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
2666 | 2826 | $upcontext['fulltext_index'][] = $row['Key_name']; |
2827 | + } |
|
2667 | 2828 | $smcFunc['db_free_result']($request); |
2668 | 2829 | |
2669 | - if (isset($upcontext['fulltext_index'])) |
|
2670 | - $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
2830 | + if (isset($upcontext['fulltext_index'])) { |
|
2831 | + $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
2832 | + } |
|
2671 | 2833 | } |
2672 | 2834 | |
2673 | 2835 | // Drop it and make a note... |
@@ -2857,8 +3019,9 @@ discard block |
||
2857 | 3019 | $replace = '%field%'; |
2858 | 3020 | |
2859 | 3021 | // Build a huge REPLACE statement... |
2860 | - foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) |
|
2861 | - $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
3022 | + foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) { |
|
3023 | + $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
3024 | + } |
|
2862 | 3025 | } |
2863 | 3026 | |
2864 | 3027 | // Get a list of table names ahead of time... This makes it easier to set our substep and such |
@@ -2868,9 +3031,10 @@ discard block |
||
2868 | 3031 | $upcontext['table_count'] = count($queryTables); |
2869 | 3032 | |
2870 | 3033 | // What ones have we already done? |
2871 | - foreach ($queryTables as $id => $table) |
|
2872 | - if ($id < $_GET['substep']) |
|
3034 | + foreach ($queryTables as $id => $table) { |
|
3035 | + if ($id < $_GET['substep']) |
|
2873 | 3036 | $upcontext['previous_tables'][] = $table; |
3037 | + } |
|
2874 | 3038 | |
2875 | 3039 | $upcontext['cur_table_num'] = $_GET['substep']; |
2876 | 3040 | $upcontext['cur_table_name'] = str_replace($db_prefix, '', $queryTables[$_GET['substep']]); |
@@ -2907,8 +3071,9 @@ discard block |
||
2907 | 3071 | nextSubstep($substep); |
2908 | 3072 | |
2909 | 3073 | // Just to make sure it doesn't time out. |
2910 | - if (function_exists('apache_reset_timeout')) |
|
2911 | - @apache_reset_timeout(); |
|
3074 | + if (function_exists('apache_reset_timeout')) { |
|
3075 | + @apache_reset_timeout(); |
|
3076 | + } |
|
2912 | 3077 | |
2913 | 3078 | $table_charsets = array(); |
2914 | 3079 | |
@@ -2931,8 +3096,9 @@ discard block |
||
2931 | 3096 | |
2932 | 3097 | // Build structure of columns to operate on organized by charset; only operate on columns not yet utf8 |
2933 | 3098 | if ($charset != 'utf8') { |
2934 | - if (!isset($table_charsets[$charset])) |
|
2935 | - $table_charsets[$charset] = array(); |
|
3099 | + if (!isset($table_charsets[$charset])) { |
|
3100 | + $table_charsets[$charset] = array(); |
|
3101 | + } |
|
2936 | 3102 | |
2937 | 3103 | $table_charsets[$charset][] = $column_info; |
2938 | 3104 | } |
@@ -2973,10 +3139,11 @@ discard block |
||
2973 | 3139 | if (isset($translation_tables[$upcontext['charset_detected']])) |
2974 | 3140 | { |
2975 | 3141 | $update = ''; |
2976 | - foreach ($table_charsets as $charset => $columns) |
|
2977 | - foreach ($columns as $column) |
|
3142 | + foreach ($table_charsets as $charset => $columns) { |
|
3143 | + foreach ($columns as $column) |
|
2978 | 3144 | $update .= ' |
2979 | 3145 | ' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ','; |
3146 | + } |
|
2980 | 3147 | |
2981 | 3148 | $smcFunc['db_query']('', ' |
2982 | 3149 | UPDATE {raw:table_name} |
@@ -3001,8 +3168,9 @@ discard block |
||
3001 | 3168 | // Now do the actual conversion (if still needed). |
3002 | 3169 | if ($charsets[$upcontext['charset_detected']] !== 'utf8') |
3003 | 3170 | { |
3004 | - if ($command_line) |
|
3005 | - echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
3171 | + if ($command_line) { |
|
3172 | + echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
3173 | + } |
|
3006 | 3174 | |
3007 | 3175 | $smcFunc['db_query']('', ' |
3008 | 3176 | ALTER TABLE {raw:table_name} |
@@ -3012,12 +3180,14 @@ discard block |
||
3012 | 3180 | ) |
3013 | 3181 | ); |
3014 | 3182 | |
3015 | - if ($command_line) |
|
3016 | - echo " done.\n"; |
|
3183 | + if ($command_line) { |
|
3184 | + echo " done.\n"; |
|
3185 | + } |
|
3017 | 3186 | } |
3018 | 3187 | // If this is XML to keep it nice for the user do one table at a time anyway! |
3019 | - if (isset($_GET['xml']) && $upcontext['cur_table_num'] < $upcontext['table_count']) |
|
3020 | - return upgradeExit(); |
|
3188 | + if (isset($_GET['xml']) && $upcontext['cur_table_num'] < $upcontext['table_count']) { |
|
3189 | + return upgradeExit(); |
|
3190 | + } |
|
3021 | 3191 | } |
3022 | 3192 | |
3023 | 3193 | $prev_charset = empty($translation_tables[$upcontext['charset_detected']]) ? $charsets[$upcontext['charset_detected']] : $translation_tables[$upcontext['charset_detected']]; |
@@ -3046,8 +3216,8 @@ discard block |
||
3046 | 3216 | ); |
3047 | 3217 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
3048 | 3218 | { |
3049 | - if (@safe_unserialize($row['extra']) === false && preg_match('~^(a:3:{s:5:"topic";i:\d+;s:7:"subject";s:)(\d+):"(.+)"(;s:6:"member";s:5:"\d+";})$~', $row['extra'], $matches) === 1) |
|
3050 | - $smcFunc['db_query']('', ' |
|
3219 | + if (@safe_unserialize($row['extra']) === false && preg_match('~^(a:3:{s:5:"topic";i:\d+;s:7:"subject";s:)(\d+):"(.+)"(;s:6:"member";s:5:"\d+";})$~', $row['extra'], $matches) === 1) { |
|
3220 | + $smcFunc['db_query']('', ' |
|
3051 | 3221 | UPDATE {db_prefix}log_actions |
3052 | 3222 | SET extra = {string:extra} |
3053 | 3223 | WHERE id_action = {int:current_action}', |
@@ -3056,6 +3226,7 @@ discard block |
||
3056 | 3226 | 'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4], |
3057 | 3227 | ) |
3058 | 3228 | ); |
3229 | + } |
|
3059 | 3230 | } |
3060 | 3231 | $smcFunc['db_free_result']($request); |
3061 | 3232 | |
@@ -3077,15 +3248,17 @@ discard block |
||
3077 | 3248 | // First thing's first - did we already do this? |
3078 | 3249 | if (!empty($modSettings['json_done'])) |
3079 | 3250 | { |
3080 | - if ($command_line) |
|
3081 | - return DeleteUpgrade(); |
|
3082 | - else |
|
3083 | - return true; |
|
3251 | + if ($command_line) { |
|
3252 | + return DeleteUpgrade(); |
|
3253 | + } else { |
|
3254 | + return true; |
|
3255 | + } |
|
3084 | 3256 | } |
3085 | 3257 | |
3086 | 3258 | // Done it already - js wise? |
3087 | - if (!empty($_POST['json_done'])) |
|
3088 | - return true; |
|
3259 | + if (!empty($_POST['json_done'])) { |
|
3260 | + return true; |
|
3261 | + } |
|
3089 | 3262 | |
3090 | 3263 | // List of tables affected by this function |
3091 | 3264 | // name => array('key', col1[,col2|true[,col3]]) |
@@ -3117,12 +3290,14 @@ discard block |
||
3117 | 3290 | $upcontext['cur_table_name'] = isset($keys[$_GET['substep']]) ? $keys[$_GET['substep']] : $keys[0]; |
3118 | 3291 | $upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100); |
3119 | 3292 | |
3120 | - foreach ($keys as $id => $table) |
|
3121 | - if ($id < $_GET['substep']) |
|
3293 | + foreach ($keys as $id => $table) { |
|
3294 | + if ($id < $_GET['substep']) |
|
3122 | 3295 | $upcontext['previous_tables'][] = $table; |
3296 | + } |
|
3123 | 3297 | |
3124 | - if ($command_line) |
|
3125 | - echo 'Converting data from serialize() to json_encode().'; |
|
3298 | + if ($command_line) { |
|
3299 | + echo 'Converting data from serialize() to json_encode().'; |
|
3300 | + } |
|
3126 | 3301 | |
3127 | 3302 | if (!$support_js || isset($_GET['xml'])) |
3128 | 3303 | { |
@@ -3162,8 +3337,9 @@ discard block |
||
3162 | 3337 | |
3163 | 3338 | // Loop through and fix these... |
3164 | 3339 | $new_settings = array(); |
3165 | - if ($command_line) |
|
3166 | - echo "\n" . 'Fixing some settings...'; |
|
3340 | + if ($command_line) { |
|
3341 | + echo "\n" . 'Fixing some settings...'; |
|
3342 | + } |
|
3167 | 3343 | |
3168 | 3344 | foreach ($serialized_settings as $var) |
3169 | 3345 | { |
@@ -3171,22 +3347,24 @@ discard block |
||
3171 | 3347 | { |
3172 | 3348 | // Attempt to unserialize the setting |
3173 | 3349 | $temp = @safe_unserialize($modSettings[$var]); |
3174 | - if (!$temp && $command_line) |
|
3175 | - echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
3176 | - elseif ($temp !== false) |
|
3177 | - $new_settings[$var] = json_encode($temp); |
|
3350 | + if (!$temp && $command_line) { |
|
3351 | + echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
3352 | + } elseif ($temp !== false) { |
|
3353 | + $new_settings[$var] = json_encode($temp); |
|
3354 | + } |
|
3178 | 3355 | } |
3179 | 3356 | } |
3180 | 3357 | |
3181 | 3358 | // Update everything at once |
3182 | - if (!function_exists('cache_put_data')) |
|
3183 | - require_once($sourcedir . '/Load.php'); |
|
3359 | + if (!function_exists('cache_put_data')) { |
|
3360 | + require_once($sourcedir . '/Load.php'); |
|
3361 | + } |
|
3184 | 3362 | updateSettings($new_settings, true); |
3185 | 3363 | |
3186 | - if ($command_line) |
|
3187 | - echo ' done.'; |
|
3188 | - } |
|
3189 | - elseif ($table == 'themes') |
|
3364 | + if ($command_line) { |
|
3365 | + echo ' done.'; |
|
3366 | + } |
|
3367 | + } elseif ($table == 'themes') |
|
3190 | 3368 | { |
3191 | 3369 | // Finally, fix the admin prefs. Unfortunately this is stored per theme, but hopefully they only have one theme installed at this point... |
3192 | 3370 | $query = $smcFunc['db_query']('', ' |
@@ -3205,10 +3383,11 @@ discard block |
||
3205 | 3383 | |
3206 | 3384 | if ($command_line) |
3207 | 3385 | { |
3208 | - if ($temp === false) |
|
3209 | - echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
3210 | - else |
|
3211 | - echo "\n" . 'Fixing admin preferences...'; |
|
3386 | + if ($temp === false) { |
|
3387 | + echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
3388 | + } else { |
|
3389 | + echo "\n" . 'Fixing admin preferences...'; |
|
3390 | + } |
|
3212 | 3391 | } |
3213 | 3392 | |
3214 | 3393 | if ($temp !== false) |
@@ -3230,15 +3409,15 @@ discard block |
||
3230 | 3409 | ) |
3231 | 3410 | ); |
3232 | 3411 | |
3233 | - if ($command_line) |
|
3234 | - echo ' done.'; |
|
3412 | + if ($command_line) { |
|
3413 | + echo ' done.'; |
|
3414 | + } |
|
3235 | 3415 | } |
3236 | 3416 | } |
3237 | 3417 | |
3238 | 3418 | $smcFunc['db_free_result']($query); |
3239 | 3419 | } |
3240 | - } |
|
3241 | - else |
|
3420 | + } else |
|
3242 | 3421 | { |
3243 | 3422 | // First item is always the key... |
3244 | 3423 | $key = $info[0]; |
@@ -3249,8 +3428,7 @@ discard block |
||
3249 | 3428 | { |
3250 | 3429 | $col_select = $info[1]; |
3251 | 3430 | $where = ' WHERE ' . $info[1] . ' != {empty}'; |
3252 | - } |
|
3253 | - else |
|
3431 | + } else |
|
3254 | 3432 | { |
3255 | 3433 | $col_select = implode(', ', $info); |
3256 | 3434 | } |
@@ -3283,8 +3461,7 @@ discard block |
||
3283 | 3461 | if ($temp === false && $command_line) |
3284 | 3462 | { |
3285 | 3463 | echo "\nFailed to unserialize " . $row[$col] . "... Skipping\n"; |
3286 | - } |
|
3287 | - else |
|
3464 | + } else |
|
3288 | 3465 | { |
3289 | 3466 | $row[$col] = json_encode($temp); |
3290 | 3467 | |
@@ -3309,16 +3486,18 @@ discard block |
||
3309 | 3486 | } |
3310 | 3487 | } |
3311 | 3488 | |
3312 | - if ($command_line) |
|
3313 | - echo ' done.'; |
|
3489 | + if ($command_line) { |
|
3490 | + echo ' done.'; |
|
3491 | + } |
|
3314 | 3492 | |
3315 | 3493 | // Free up some memory... |
3316 | 3494 | $smcFunc['db_free_result']($query); |
3317 | 3495 | } |
3318 | 3496 | } |
3319 | 3497 | // If this is XML to keep it nice for the user do one table at a time anyway! |
3320 | - if (isset($_GET['xml'])) |
|
3321 | - return upgradeExit(); |
|
3498 | + if (isset($_GET['xml'])) { |
|
3499 | + return upgradeExit(); |
|
3500 | + } |
|
3322 | 3501 | } |
3323 | 3502 | |
3324 | 3503 | if ($command_line) |
@@ -3333,8 +3512,9 @@ discard block |
||
3333 | 3512 | |
3334 | 3513 | $_GET['substep'] = 0; |
3335 | 3514 | // Make sure we move on! |
3336 | - if ($command_line) |
|
3337 | - return DeleteUpgrade(); |
|
3515 | + if ($command_line) { |
|
3516 | + return DeleteUpgrade(); |
|
3517 | + } |
|
3338 | 3518 | |
3339 | 3519 | return true; |
3340 | 3520 | } |
@@ -3391,14 +3571,16 @@ discard block |
||
3391 | 3571 | global $upcontext, $txt, $settings; |
3392 | 3572 | |
3393 | 3573 | // Don't call me twice! |
3394 | - if (!empty($upcontext['chmod_called'])) |
|
3395 | - return; |
|
3574 | + if (!empty($upcontext['chmod_called'])) { |
|
3575 | + return; |
|
3576 | + } |
|
3396 | 3577 | |
3397 | 3578 | $upcontext['chmod_called'] = true; |
3398 | 3579 | |
3399 | 3580 | // Nothing? |
3400 | - if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) |
|
3401 | - return; |
|
3581 | + if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) { |
|
3582 | + return; |
|
3583 | + } |
|
3402 | 3584 | |
3403 | 3585 | // Was it a problem with Windows? |
3404 | 3586 | if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess') |
@@ -3430,11 +3612,12 @@ discard block |
||
3430 | 3612 | content.write(\'<div class="windowbg description">\n\t\t\t<h4>', $txt['upgrade_ftp_files'], '</h4>\n\t\t\t\'); |
3431 | 3613 | content.write(\'<p>', implode('<br>\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');'; |
3432 | 3614 | |
3433 | - if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') |
|
3434 | - echo ' |
|
3615 | + if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') { |
|
3616 | + echo ' |
|
3435 | 3617 | content.write(\'<hr>\n\t\t\t\'); |
3436 | 3618 | content.write(\'<p>', $txt['upgrade_ftp_shell'], '</p>\n\t\t\t\'); |
3437 | 3619 | content.write(\'<tt># chmod a+w ', implode(' ', $upcontext['chmod']['files']), '</tt>\n\t\t\t\');'; |
3620 | + } |
|
3438 | 3621 | |
3439 | 3622 | echo ' |
3440 | 3623 | content.write(\'<a href="javascript:self.close();">close</a>\n\t\t</div>\n\t</body>\n</html>\'); |
@@ -3442,17 +3625,19 @@ discard block |
||
3442 | 3625 | } |
3443 | 3626 | </script>'; |
3444 | 3627 | |
3445 | - if (!empty($upcontext['chmod']['ftp_error'])) |
|
3446 | - echo ' |
|
3628 | + if (!empty($upcontext['chmod']['ftp_error'])) { |
|
3629 | + echo ' |
|
3447 | 3630 | <div class="error_message red"> |
3448 | 3631 | ', $txt['upgrade_ftp_error'], '<br><br> |
3449 | 3632 | <code>', $upcontext['chmod']['ftp_error'], '</code> |
3450 | 3633 | </div> |
3451 | 3634 | <br>'; |
3635 | + } |
|
3452 | 3636 | |
3453 | - if (empty($upcontext['chmod_in_form'])) |
|
3454 | - echo ' |
|
3637 | + if (empty($upcontext['chmod_in_form'])) { |
|
3638 | + echo ' |
|
3455 | 3639 | <form action="', $upcontext['form_url'], '" method="post">'; |
3640 | + } |
|
3456 | 3641 | |
3457 | 3642 | echo ' |
3458 | 3643 | <table width="520" border="0" align="center" style="margin-bottom: 1ex;"> |
@@ -3487,10 +3672,11 @@ discard block |
||
3487 | 3672 | <div class="righttext" style="margin: 1ex;"><input type="submit" value="', $txt['ftp_connect'], '" class="button"></div> |
3488 | 3673 | </div>'; |
3489 | 3674 | |
3490 | - if (empty($upcontext['chmod_in_form'])) |
|
3491 | - echo ' |
|
3675 | + if (empty($upcontext['chmod_in_form'])) { |
|
3676 | + echo ' |
|
3492 | 3677 | </form>'; |
3493 | -} |
|
3678 | + } |
|
3679 | + } |
|
3494 | 3680 | |
3495 | 3681 | function template_upgrade_above() |
3496 | 3682 | { |
@@ -3550,9 +3736,10 @@ discard block |
||
3550 | 3736 | <h2>', $txt['upgrade_progress'], '</h2> |
3551 | 3737 | <ul>'; |
3552 | 3738 | |
3553 | - foreach ($upcontext['steps'] as $num => $step) |
|
3554 | - echo ' |
|
3739 | + foreach ($upcontext['steps'] as $num => $step) { |
|
3740 | + echo ' |
|
3555 | 3741 | <li class="', $num < $upcontext['current_step'] ? 'stepdone' : ($num == $upcontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
3742 | + } |
|
3556 | 3743 | |
3557 | 3744 | echo ' |
3558 | 3745 | </ul> |
@@ -3565,8 +3752,8 @@ discard block |
||
3565 | 3752 | </div> |
3566 | 3753 | </div>'; |
3567 | 3754 | |
3568 | - if (isset($upcontext['step_progress'])) |
|
3569 | - echo ' |
|
3755 | + if (isset($upcontext['step_progress'])) { |
|
3756 | + echo ' |
|
3570 | 3757 | <br> |
3571 | 3758 | <br> |
3572 | 3759 | <div id="progress_bar_step"> |
@@ -3575,6 +3762,7 @@ discard block |
||
3575 | 3762 | <span>', $txt['upgrade_step_progress'], '</span> |
3576 | 3763 | </div> |
3577 | 3764 | </div>'; |
3765 | + } |
|
3578 | 3766 | |
3579 | 3767 | echo ' |
3580 | 3768 | <div id="substep_bar_div" class="smalltext" style="float: left;width: 50%;margin-top: 0.6em;display: ', isset($upcontext['substep_progress']) ? '' : 'none', ';">', isset($upcontext['substep_progress_name']) ? trim(strtr($upcontext['substep_progress_name'], array('.' => ''))) : '', ':</div> |
@@ -3605,32 +3793,36 @@ discard block |
||
3605 | 3793 | { |
3606 | 3794 | global $upcontext, $txt; |
3607 | 3795 | |
3608 | - if (!empty($upcontext['pause'])) |
|
3609 | - echo ' |
|
3796 | + if (!empty($upcontext['pause'])) { |
|
3797 | + echo ' |
|
3610 | 3798 | <em>', $txt['upgrade_incomplete'], '.</em><br> |
3611 | 3799 | |
3612 | 3800 | <h2 style="margin-top: 2ex;">', $txt['upgrade_not_quite_done'], '</h2> |
3613 | 3801 | <h3> |
3614 | 3802 | ', $txt['upgrade_paused_overload'], ' |
3615 | 3803 | </h3>'; |
3804 | + } |
|
3616 | 3805 | |
3617 | - if (!empty($upcontext['custom_warning'])) |
|
3618 | - echo ' |
|
3806 | + if (!empty($upcontext['custom_warning'])) { |
|
3807 | + echo ' |
|
3619 | 3808 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
3620 | 3809 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
3621 | 3810 | <strong style="text-decoration: underline;">', $txt['upgrade_note'], '</strong><br> |
3622 | 3811 | <div style="padding-left: 6ex;">', $upcontext['custom_warning'], '</div> |
3623 | 3812 | </div>'; |
3813 | + } |
|
3624 | 3814 | |
3625 | 3815 | echo ' |
3626 | 3816 | <div class="righttext" style="margin: 1ex;">'; |
3627 | 3817 | |
3628 | - if (!empty($upcontext['continue'])) |
|
3629 | - echo ' |
|
3818 | + if (!empty($upcontext['continue'])) { |
|
3819 | + echo ' |
|
3630 | 3820 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled' : '', ' class="button">'; |
3631 | - if (!empty($upcontext['skip'])) |
|
3632 | - echo ' |
|
3821 | + } |
|
3822 | + if (!empty($upcontext['skip'])) { |
|
3823 | + echo ' |
|
3633 | 3824 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button">'; |
3825 | + } |
|
3634 | 3826 | |
3635 | 3827 | echo ' |
3636 | 3828 | </div> |
@@ -3680,11 +3872,12 @@ discard block |
||
3680 | 3872 | echo '<', '?xml version="1.0" encoding="UTF-8"?', '> |
3681 | 3873 | <smf>'; |
3682 | 3874 | |
3683 | - if (!empty($upcontext['get_data'])) |
|
3684 | - foreach ($upcontext['get_data'] as $k => $v) |
|
3875 | + if (!empty($upcontext['get_data'])) { |
|
3876 | + foreach ($upcontext['get_data'] as $k => $v) |
|
3685 | 3877 | echo ' |
3686 | 3878 | <get key="', $k, '">', $v, '</get>'; |
3687 | -} |
|
3879 | + } |
|
3880 | + } |
|
3688 | 3881 | |
3689 | 3882 | function template_xml_below() |
3690 | 3883 | { |
@@ -3725,8 +3918,8 @@ discard block |
||
3725 | 3918 | template_chmod(); |
3726 | 3919 | |
3727 | 3920 | // For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade! |
3728 | - if ($upcontext['is_large_forum']) |
|
3729 | - echo ' |
|
3921 | + if ($upcontext['is_large_forum']) { |
|
3922 | + echo ' |
|
3730 | 3923 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
3731 | 3924 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
3732 | 3925 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -3734,10 +3927,11 @@ discard block |
||
3734 | 3927 | ', $txt['upgrade_warning_lots_data'], ' |
3735 | 3928 | </div> |
3736 | 3929 | </div>'; |
3930 | + } |
|
3737 | 3931 | |
3738 | 3932 | // A warning message? |
3739 | - if (!empty($upcontext['warning'])) |
|
3740 | - echo ' |
|
3933 | + if (!empty($upcontext['warning'])) { |
|
3934 | + echo ' |
|
3741 | 3935 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
3742 | 3936 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
3743 | 3937 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -3745,6 +3939,7 @@ discard block |
||
3745 | 3939 | ', $upcontext['warning'], ' |
3746 | 3940 | </div> |
3747 | 3941 | </div>'; |
3942 | + } |
|
3748 | 3943 | |
3749 | 3944 | // Paths are incorrect? |
3750 | 3945 | echo ' |
@@ -3760,20 +3955,22 @@ discard block |
||
3760 | 3955 | if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600)) |
3761 | 3956 | { |
3762 | 3957 | $ago = time() - $upcontext['started']; |
3763 | - if ($ago < 60) |
|
3764 | - $ago = $ago . ' seconds'; |
|
3765 | - elseif ($ago < 3600) |
|
3766 | - $ago = (int) ($ago / 60) . ' minutes'; |
|
3767 | - else |
|
3768 | - $ago = (int) ($ago / 3600) . ' hours'; |
|
3958 | + if ($ago < 60) { |
|
3959 | + $ago = $ago . ' seconds'; |
|
3960 | + } elseif ($ago < 3600) { |
|
3961 | + $ago = (int) ($ago / 60) . ' minutes'; |
|
3962 | + } else { |
|
3963 | + $ago = (int) ($ago / 3600) . ' hours'; |
|
3964 | + } |
|
3769 | 3965 | |
3770 | 3966 | $active = time() - $upcontext['updated']; |
3771 | - if ($active < 60) |
|
3772 | - $updated = $active . ' seconds'; |
|
3773 | - elseif ($active < 3600) |
|
3774 | - $updated = (int) ($active / 60) . ' minutes'; |
|
3775 | - else |
|
3776 | - $updated = (int) ($active / 3600) . ' hours'; |
|
3967 | + if ($active < 60) { |
|
3968 | + $updated = $active . ' seconds'; |
|
3969 | + } elseif ($active < 3600) { |
|
3970 | + $updated = (int) ($active / 60) . ' minutes'; |
|
3971 | + } else { |
|
3972 | + $updated = (int) ($active / 3600) . ' hours'; |
|
3973 | + } |
|
3777 | 3974 | |
3778 | 3975 | echo ' |
3779 | 3976 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
@@ -3782,16 +3979,18 @@ discard block |
||
3782 | 3979 | <div style="padding-left: 6ex;"> |
3783 | 3980 | "', $upcontext['user']['name'], '" has been running the upgrade script for the last ', $ago, ' - and was last active ', $updated, ' ago.'; |
3784 | 3981 | |
3785 | - if ($active < 600) |
|
3786 | - echo ' |
|
3982 | + if ($active < 600) { |
|
3983 | + echo ' |
|
3787 | 3984 | ', $txt['upgrade_run_script'], ' ', $upcontext['user']['name'],' ', $txt['upgrade_run_script2'], ''; |
3985 | + } |
|
3788 | 3986 | |
3789 | - if ($active > $upcontext['inactive_timeout']) |
|
3790 | - echo ' |
|
3987 | + if ($active > $upcontext['inactive_timeout']) { |
|
3988 | + echo ' |
|
3791 | 3989 | <br><br>',$txt['upgrade_run'], ''; |
3792 | - else |
|
3793 | - echo ' |
|
3990 | + } else { |
|
3991 | + echo ' |
|
3794 | 3992 | <br><br>', $txt['upgrade_script_timeout'], ' ', $upcontext['user']['name'], ' ', $txt['upgrade_script_timeout2'], ' ', ($upcontext['inactive_timeout'] > 120 ? round($upcontext['inactive_timeout'] / 60, 1) . ' minutes!' : $upcontext['inactive_timeout'] . ' seconds!'); |
3993 | + } |
|
3795 | 3994 | |
3796 | 3995 | echo ' |
3797 | 3996 | </div> |
@@ -3807,9 +4006,10 @@ discard block |
||
3807 | 4006 | <td> |
3808 | 4007 | <input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '"', $disable_security ? ' disabled' : '', '>'; |
3809 | 4008 | |
3810 | - if (!empty($upcontext['username_incorrect'])) |
|
3811 | - echo ' |
|
4009 | + if (!empty($upcontext['username_incorrect'])) { |
|
4010 | + echo ' |
|
3812 | 4011 | <div class="smalltext" style="color: red;">', $txt['upgrade_wrong_username'], '</div>'; |
4012 | + } |
|
3813 | 4013 | |
3814 | 4014 | echo ' |
3815 | 4015 | </td> |
@@ -3820,9 +4020,10 @@ discard block |
||
3820 | 4020 | <input type="password" name="passwrd" value=""', $disable_security ? ' disabled' : '', '> |
3821 | 4021 | <input type="hidden" name="hash_passwrd" value="">'; |
3822 | 4022 | |
3823 | - if (!empty($upcontext['password_failed'])) |
|
3824 | - echo ' |
|
4023 | + if (!empty($upcontext['password_failed'])) { |
|
4024 | + echo ' |
|
3825 | 4025 | <div class="smalltext" style="color: red;">', $txt['upgrade_wrong_password'], '</div>'; |
4026 | + } |
|
3826 | 4027 | |
3827 | 4028 | echo ' |
3828 | 4029 | </td> |
@@ -3893,8 +4094,8 @@ discard block |
||
3893 | 4094 | <form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">'; |
3894 | 4095 | |
3895 | 4096 | // Warning message? |
3896 | - if (!empty($upcontext['upgrade_options_warning'])) |
|
3897 | - echo ' |
|
4097 | + if (!empty($upcontext['upgrade_options_warning'])) { |
|
4098 | + echo ' |
|
3898 | 4099 | <div style="margin: 1ex; padding: 1ex; border: 1px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
3899 | 4100 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
3900 | 4101 | <strong style="text-decoration: underline;">Warning!</strong><br> |
@@ -3902,6 +4103,7 @@ discard block |
||
3902 | 4103 | ', $upcontext['upgrade_options_warning'], ' |
3903 | 4104 | </div> |
3904 | 4105 | </div>'; |
4106 | + } |
|
3905 | 4107 | |
3906 | 4108 | echo ' |
3907 | 4109 | <table> |
@@ -3944,8 +4146,8 @@ discard block |
||
3944 | 4146 | </td> |
3945 | 4147 | </tr>'; |
3946 | 4148 | |
3947 | - if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) |
|
3948 | - echo ' |
|
4149 | + if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) { |
|
4150 | + echo ' |
|
3949 | 4151 | <tr valign="top"> |
3950 | 4152 | <td width="2%"> |
3951 | 4153 | <input type="checkbox" name="delete_karma" id="delete_karma" value="1"> |
@@ -3954,6 +4156,7 @@ discard block |
||
3954 | 4156 | <label for="delete_karma">', $txt['upgrade_delete_karma'], '</label> |
3955 | 4157 | </td> |
3956 | 4158 | </tr>'; |
4159 | + } |
|
3957 | 4160 | |
3958 | 4161 | echo ' |
3959 | 4162 | <tr valign="top"> |
@@ -3991,10 +4194,11 @@ discard block |
||
3991 | 4194 | </div>'; |
3992 | 4195 | |
3993 | 4196 | // Dont any tables so far? |
3994 | - if (!empty($upcontext['previous_tables'])) |
|
3995 | - foreach ($upcontext['previous_tables'] as $table) |
|
4197 | + if (!empty($upcontext['previous_tables'])) { |
|
4198 | + foreach ($upcontext['previous_tables'] as $table) |
|
3996 | 4199 | echo ' |
3997 | 4200 | <br>', $txt['upgrade_completed_table'], ' "', $table, '".'; |
4201 | + } |
|
3998 | 4202 | |
3999 | 4203 | echo ' |
4000 | 4204 | <h3 id="current_tab_div">', $txt['upgrade_current_table'], ' "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
@@ -4031,12 +4235,13 @@ discard block |
||
4031 | 4235 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
4032 | 4236 | |
4033 | 4237 | // If debug flood the screen. |
4034 | - if ($is_debug) |
|
4035 | - echo ' |
|
4238 | + if ($is_debug) { |
|
4239 | + echo ' |
|
4036 | 4240 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
4037 | 4241 | |
4038 | 4242 | if (document.getElementById(\'debug_section\').scrollHeight) |
4039 | 4243 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
4244 | + } |
|
4040 | 4245 | |
4041 | 4246 | echo ' |
4042 | 4247 | // Get the next update... |
@@ -4069,8 +4274,9 @@ discard block |
||
4069 | 4274 | { |
4070 | 4275 | global $upcontext, $support_js, $is_debug, $timeLimitThreshold, $txt; |
4071 | 4276 | |
4072 | - if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) |
|
4073 | - $is_debug = true; |
|
4277 | + if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) { |
|
4278 | + $is_debug = true; |
|
4279 | + } |
|
4074 | 4280 | |
4075 | 4281 | echo ' |
4076 | 4282 | <h3>', $txt['upgrade_db_changes'], '</h3> |
@@ -4085,8 +4291,9 @@ discard block |
||
4085 | 4291 | { |
4086 | 4292 | foreach ($upcontext['actioned_items'] as $num => $item) |
4087 | 4293 | { |
4088 | - if ($num != 0) |
|
4089 | - echo ' Successful!'; |
|
4294 | + if ($num != 0) { |
|
4295 | + echo ' Successful!'; |
|
4296 | + } |
|
4090 | 4297 | echo '<br>' . $item; |
4091 | 4298 | } |
4092 | 4299 | if (!empty($upcontext['changes_complete'])) |
@@ -4099,28 +4306,32 @@ discard block |
||
4099 | 4306 | $seconds = intval($active % 60); |
4100 | 4307 | |
4101 | 4308 | $totalTime = ''; |
4102 | - if ($hours > 0) |
|
4103 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
4104 | - if ($minutes > 0) |
|
4105 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
4106 | - if ($seconds > 0) |
|
4107 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4309 | + if ($hours > 0) { |
|
4310 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
4311 | + } |
|
4312 | + if ($minutes > 0) { |
|
4313 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
4314 | + } |
|
4315 | + if ($seconds > 0) { |
|
4316 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4317 | + } |
|
4108 | 4318 | } |
4109 | 4319 | |
4110 | - if ($is_debug && !empty($totalTime)) |
|
4111 | - echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
4112 | - else |
|
4113 | - echo ' Successful!<br><br>'; |
|
4320 | + if ($is_debug && !empty($totalTime)) { |
|
4321 | + echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
4322 | + } else { |
|
4323 | + echo ' Successful!<br><br>'; |
|
4324 | + } |
|
4114 | 4325 | |
4115 | 4326 | echo '<span id="commess" style="font-weight: bold;">', $txt['upgrade_db_complete'], '</span><br>'; |
4116 | 4327 | } |
4117 | - } |
|
4118 | - else |
|
4328 | + } else |
|
4119 | 4329 | { |
4120 | 4330 | // Tell them how many files we have in total. |
4121 | - if ($upcontext['file_count'] > 1) |
|
4122 | - echo ' |
|
4331 | + if ($upcontext['file_count'] > 1) { |
|
4332 | + echo ' |
|
4123 | 4333 | <strong id="info1">', $txt['upgrade_script'], ' <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>'; |
4334 | + } |
|
4124 | 4335 | |
4125 | 4336 | echo ' |
4126 | 4337 | <h3 id="info2"><strong>', $txt['upgrade_executing'], '</strong> "<span id="cur_item_name">', $upcontext['current_item_name'], '</span>" (<span id="item_num">', $upcontext['current_item_num'], '</span> ', $txt['upgrade_of'], ' <span id="total_items"><span id="item_count">', $upcontext['total_items'], '</span>', $upcontext['file_count'] > 1 ? ' - of this script' : '', ')</span></h3> |
@@ -4136,19 +4347,23 @@ discard block |
||
4136 | 4347 | $seconds = intval($active % 60); |
4137 | 4348 | |
4138 | 4349 | $totalTime = ''; |
4139 | - if ($hours > 0) |
|
4140 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
4141 | - if ($minutes > 0) |
|
4142 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
4143 | - if ($seconds > 0) |
|
4144 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4350 | + if ($hours > 0) { |
|
4351 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
4352 | + } |
|
4353 | + if ($minutes > 0) { |
|
4354 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
4355 | + } |
|
4356 | + if ($seconds > 0) { |
|
4357 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4358 | + } |
|
4145 | 4359 | } |
4146 | 4360 | |
4147 | 4361 | echo ' |
4148 | 4362 | <br><span id="upgradeCompleted">'; |
4149 | 4363 | |
4150 | - if (!empty($totalTime)) |
|
4151 | - echo 'Completed in ', $totalTime, '<br>'; |
|
4364 | + if (!empty($totalTime)) { |
|
4365 | + echo 'Completed in ', $totalTime, '<br>'; |
|
4366 | + } |
|
4152 | 4367 | |
4153 | 4368 | echo '</span> |
4154 | 4369 | <div id="debug_section" style="height: 59px; overflow: auto;"> |
@@ -4185,9 +4400,10 @@ discard block |
||
4185 | 4400 | var getData = ""; |
4186 | 4401 | var debugItems = ', $upcontext['debug_items'], ';'; |
4187 | 4402 | |
4188 | - if ($is_debug) |
|
4189 | - echo ' |
|
4403 | + if ($is_debug) { |
|
4404 | + echo ' |
|
4190 | 4405 | var upgradeStartTime = ' . $upcontext['started'] . ';'; |
4406 | + } |
|
4191 | 4407 | |
4192 | 4408 | echo ' |
4193 | 4409 | function getNextItem() |
@@ -4227,9 +4443,10 @@ discard block |
||
4227 | 4443 | document.getElementById("error_block").style.display = ""; |
4228 | 4444 | setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));'; |
4229 | 4445 | |
4230 | - if ($is_debug) |
|
4231 | - echo ' |
|
4446 | + if ($is_debug) { |
|
4447 | + echo ' |
|
4232 | 4448 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
4449 | + } |
|
4233 | 4450 | |
4234 | 4451 | echo ' |
4235 | 4452 | } |
@@ -4250,9 +4467,10 @@ discard block |
||
4250 | 4467 | document.getElementById("error_block").style.display = ""; |
4251 | 4468 | setInnerHTML(document.getElementById("error_message"), "Upgrade script appears to be going into a loop - step: " + sDebugName);'; |
4252 | 4469 | |
4253 | - if ($is_debug) |
|
4254 | - echo ' |
|
4470 | + if ($is_debug) { |
|
4471 | + echo ' |
|
4255 | 4472 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
4473 | + } |
|
4256 | 4474 | |
4257 | 4475 | echo ' |
4258 | 4476 | } |
@@ -4311,8 +4529,8 @@ discard block |
||
4311 | 4529 | if (bIsComplete && iDebugNum == -1 && curFile >= ', $upcontext['file_count'], ') |
4312 | 4530 | {'; |
4313 | 4531 | |
4314 | - if ($is_debug) |
|
4315 | - echo ' |
|
4532 | + if ($is_debug) { |
|
4533 | + echo ' |
|
4316 | 4534 | document.getElementById(\'debug_section\').style.display = "none"; |
4317 | 4535 | |
4318 | 4536 | var upgradeFinishedTime = parseInt(oXMLDoc.getElementsByTagName("curtime")[0].childNodes[0].nodeValue); |
@@ -4330,6 +4548,7 @@ discard block |
||
4330 | 4548 | totalTime = totalTime + diffSeconds + " second" + (diffSeconds > 1 ? "s" : ""); |
4331 | 4549 | |
4332 | 4550 | setInnerHTML(document.getElementById("upgradeCompleted"), "Completed in " + totalTime);'; |
4551 | + } |
|
4333 | 4552 | |
4334 | 4553 | echo ' |
4335 | 4554 | |
@@ -4337,9 +4556,10 @@ discard block |
||
4337 | 4556 | document.getElementById(\'contbutt\').disabled = 0; |
4338 | 4557 | document.getElementById(\'database_done\').value = 1;'; |
4339 | 4558 | |
4340 | - if ($upcontext['file_count'] > 1) |
|
4341 | - echo ' |
|
4559 | + if ($upcontext['file_count'] > 1) { |
|
4560 | + echo ' |
|
4342 | 4561 | document.getElementById(\'info1\').style.display = "none";'; |
4562 | + } |
|
4343 | 4563 | |
4344 | 4564 | echo ' |
4345 | 4565 | document.getElementById(\'info2\').style.display = "none"; |
@@ -4352,9 +4572,10 @@ discard block |
||
4352 | 4572 | lastItem = 0; |
4353 | 4573 | prevFile = curFile;'; |
4354 | 4574 | |
4355 | - if ($is_debug) |
|
4356 | - echo ' |
|
4575 | + if ($is_debug) { |
|
4576 | + echo ' |
|
4357 | 4577 | setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br><span id="debuginfo"><\' + \'/span>\');'; |
4578 | + } |
|
4358 | 4579 | |
4359 | 4580 | echo ' |
4360 | 4581 | getNextItem(); |
@@ -4362,8 +4583,8 @@ discard block |
||
4362 | 4583 | }'; |
4363 | 4584 | |
4364 | 4585 | // If debug scroll the screen. |
4365 | - if ($is_debug) |
|
4366 | - echo ' |
|
4586 | + if ($is_debug) { |
|
4587 | + echo ' |
|
4367 | 4588 | if (iLastSubStepProgress == -1) |
4368 | 4589 | { |
4369 | 4590 | // Give it consistent dots. |
@@ -4382,6 +4603,7 @@ discard block |
||
4382 | 4603 | |
4383 | 4604 | if (document.getElementById(\'debug_section\').scrollHeight) |
4384 | 4605 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
4606 | + } |
|
4385 | 4607 | |
4386 | 4608 | echo ' |
4387 | 4609 | // Update the page. |
@@ -4442,9 +4664,10 @@ discard block |
||
4442 | 4664 | }'; |
4443 | 4665 | |
4444 | 4666 | // Start things off assuming we've not errored. |
4445 | - if (empty($upcontext['error_message'])) |
|
4446 | - echo ' |
|
4667 | + if (empty($upcontext['error_message'])) { |
|
4668 | + echo ' |
|
4447 | 4669 | getNextItem();'; |
4670 | + } |
|
4448 | 4671 | |
4449 | 4672 | echo ' |
4450 | 4673 | //# sourceURL=dynamicScript-dbch.js |
@@ -4462,18 +4685,21 @@ discard block |
||
4462 | 4685 | <item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item> |
4463 | 4686 | <debug num="', $upcontext['current_debug_item_num'], '" percent="', isset($upcontext['substep_progress']) ? $upcontext['substep_progress'] : '-1', '" complete="', empty($upcontext['completed_step']) ? 0 : 1, '">', $upcontext['current_debug_item_name'], '</debug>'; |
4464 | 4687 | |
4465 | - if (!empty($upcontext['error_message'])) |
|
4466 | - echo ' |
|
4688 | + if (!empty($upcontext['error_message'])) { |
|
4689 | + echo ' |
|
4467 | 4690 | <error>', $upcontext['error_message'], '</error>'; |
4691 | + } |
|
4468 | 4692 | |
4469 | - if (!empty($upcontext['error_string'])) |
|
4470 | - echo ' |
|
4693 | + if (!empty($upcontext['error_string'])) { |
|
4694 | + echo ' |
|
4471 | 4695 | <sql>', $upcontext['error_string'], '</sql>'; |
4696 | + } |
|
4472 | 4697 | |
4473 | - if ($is_debug) |
|
4474 | - echo ' |
|
4698 | + if ($is_debug) { |
|
4699 | + echo ' |
|
4475 | 4700 | <curtime>', time(), '</curtime>'; |
4476 | -} |
|
4701 | + } |
|
4702 | + } |
|
4477 | 4703 | |
4478 | 4704 | // Template for the UTF-8 conversion step. Basically a copy of the backup stuff with slight modifications.... |
4479 | 4705 | function template_convert_utf8() |
@@ -4492,18 +4718,20 @@ discard block |
||
4492 | 4718 | </div>'; |
4493 | 4719 | |
4494 | 4720 | // Done any tables so far? |
4495 | - if (!empty($upcontext['previous_tables'])) |
|
4496 | - foreach ($upcontext['previous_tables'] as $table) |
|
4721 | + if (!empty($upcontext['previous_tables'])) { |
|
4722 | + foreach ($upcontext['previous_tables'] as $table) |
|
4497 | 4723 | echo ' |
4498 | 4724 | <br>', $txt['upgrade_completed_table'], ' "', $table, '".'; |
4725 | + } |
|
4499 | 4726 | |
4500 | 4727 | echo ' |
4501 | 4728 | <h3 id="current_tab_div">', $txt['upgrade_current_table'], ' "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3>'; |
4502 | 4729 | |
4503 | 4730 | // If we dropped their index, let's let them know |
4504 | - if ($upcontext['dropping_index']) |
|
4505 | - echo ' |
|
4731 | + if ($upcontext['dropping_index']) { |
|
4732 | + echo ' |
|
4506 | 4733 | <br><span id="indexmsg" style="font-weight: bold; font-style: italic; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">', $txt['upgrade_fulltext'], '</span>'; |
4734 | + } |
|
4507 | 4735 | |
4508 | 4736 | // Completion notification |
4509 | 4737 | echo ' |
@@ -4540,12 +4768,13 @@ discard block |
||
4540 | 4768 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
4541 | 4769 | |
4542 | 4770 | // If debug flood the screen. |
4543 | - if ($is_debug) |
|
4544 | - echo ' |
|
4771 | + if ($is_debug) { |
|
4772 | + echo ' |
|
4545 | 4773 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
4546 | 4774 | |
4547 | 4775 | if (document.getElementById(\'debug_section\').scrollHeight) |
4548 | 4776 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
4777 | + } |
|
4549 | 4778 | |
4550 | 4779 | echo ' |
4551 | 4780 | // Get the next update... |
@@ -4593,19 +4822,21 @@ discard block |
||
4593 | 4822 | </div>'; |
4594 | 4823 | |
4595 | 4824 | // Dont any tables so far? |
4596 | - if (!empty($upcontext['previous_tables'])) |
|
4597 | - foreach ($upcontext['previous_tables'] as $table) |
|
4825 | + if (!empty($upcontext['previous_tables'])) { |
|
4826 | + foreach ($upcontext['previous_tables'] as $table) |
|
4598 | 4827 | echo ' |
4599 | 4828 | <br>', $txt['upgrade_completed_table'], ' "', $table, '".'; |
4829 | + } |
|
4600 | 4830 | |
4601 | 4831 | echo ' |
4602 | 4832 | <h3 id="current_tab_div">', $txt['upgrade_current_table'], ' "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
4603 | 4833 | <br><span id="commess" style="font-weight: bold; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">', $txt['upgrade_json_completed'], '</span>'; |
4604 | 4834 | |
4605 | 4835 | // Try to make sure substep was reset. |
4606 | - if ($upcontext['cur_table_num'] == $upcontext['table_count']) |
|
4607 | - echo ' |
|
4836 | + if ($upcontext['cur_table_num'] == $upcontext['table_count']) { |
|
4837 | + echo ' |
|
4608 | 4838 | <input type="hidden" name="substep" id="substep" value="0">'; |
4839 | + } |
|
4609 | 4840 | |
4610 | 4841 | // Continue please! |
4611 | 4842 | $upcontext['continue'] = $support_js ? 2 : 1; |
@@ -4638,12 +4869,13 @@ discard block |
||
4638 | 4869 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
4639 | 4870 | |
4640 | 4871 | // If debug flood the screen. |
4641 | - if ($is_debug) |
|
4642 | - echo ' |
|
4872 | + if ($is_debug) { |
|
4873 | + echo ' |
|
4643 | 4874 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>', $txt['upgrade_completed_table'], ' "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
4644 | 4875 | |
4645 | 4876 | if (document.getElementById(\'debug_section\').scrollHeight) |
4646 | 4877 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
4878 | + } |
|
4647 | 4879 | |
4648 | 4880 | echo ' |
4649 | 4881 | // Get the next update... |
@@ -4679,8 +4911,8 @@ discard block |
||
4679 | 4911 | <h3>', $txt['upgrade_done'], ' <a href="', $boardurl, '/index.php">', $txt['upgrade_done2'], '</a>. ', $txt['upgrade_done3'], '</h3> |
4680 | 4912 | <form action="', $boardurl, '/index.php">'; |
4681 | 4913 | |
4682 | - if (!empty($upcontext['can_delete_script'])) |
|
4683 | - echo ' |
|
4914 | + if (!empty($upcontext['can_delete_script'])) { |
|
4915 | + echo ' |
|
4684 | 4916 | <label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete(this);"> ', $txt['upgrade_delete_now'], '</label> <em>', $txt['upgrade_delete_server'], '</em> |
4685 | 4917 | <script> |
4686 | 4918 | function doTheDelete(theCheck) |
@@ -4692,6 +4924,7 @@ discard block |
||
4692 | 4924 | } |
4693 | 4925 | </script> |
4694 | 4926 | <img src="', $settings['default_theme_url'], '/images/blank.png" alt="" id="delete_upgrader"><br>'; |
4927 | + } |
|
4695 | 4928 | |
4696 | 4929 | $active = time() - $upcontext['started']; |
4697 | 4930 | $hours = floor($active / 3600); |
@@ -4701,16 +4934,20 @@ discard block |
||
4701 | 4934 | if ($is_debug) |
4702 | 4935 | { |
4703 | 4936 | $totalTime = ''; |
4704 | - if ($hours > 0) |
|
4705 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
4706 | - if ($minutes > 0) |
|
4707 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
4708 | - if ($seconds > 0) |
|
4709 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4937 | + if ($hours > 0) { |
|
4938 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
4939 | + } |
|
4940 | + if ($minutes > 0) { |
|
4941 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
4942 | + } |
|
4943 | + if ($seconds > 0) { |
|
4944 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4945 | + } |
|
4710 | 4946 | } |
4711 | 4947 | |
4712 | - if ($is_debug && !empty($totalTime)) |
|
4713 | - echo '<br> ', $txt['upgrade_completed_time'], ' ', $totalTime, '<br><br>'; |
|
4948 | + if ($is_debug && !empty($totalTime)) { |
|
4949 | + echo '<br> ', $txt['upgrade_completed_time'], ' ', $totalTime, '<br><br>'; |
|
4950 | + } |
|
4714 | 4951 | |
4715 | 4952 | echo '<br> |
4716 | 4953 | ', sprintf($txt['upgrade_problems'], 'http://simplemachines.org'), '<br> |
@@ -4737,8 +4974,9 @@ discard block |
||
4737 | 4974 | |
4738 | 4975 | $current_substep = $_GET['substep']; |
4739 | 4976 | |
4740 | - if (empty($_GET['a'])) |
|
4741 | - $_GET['a'] = 0; |
|
4977 | + if (empty($_GET['a'])) { |
|
4978 | + $_GET['a'] = 0; |
|
4979 | + } |
|
4742 | 4980 | $step_progress['name'] = 'Converting ips'; |
4743 | 4981 | $step_progress['current'] = $_GET['a']; |
4744 | 4982 | |
@@ -4781,16 +5019,19 @@ discard block |
||
4781 | 5019 | 'empty' => '', |
4782 | 5020 | 'limit' => $limit, |
4783 | 5021 | )); |
4784 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
4785 | - $arIp[] = $row[$oldCol]; |
|
5022 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
5023 | + $arIp[] = $row[$oldCol]; |
|
5024 | + } |
|
4786 | 5025 | $smcFunc['db_free_result']($request); |
4787 | 5026 | |
4788 | 5027 | // Special case, null ip could keep us in a loop. |
4789 | - if (is_null($arIp[0])) |
|
4790 | - unset($arIp[0]); |
|
5028 | + if (is_null($arIp[0])) { |
|
5029 | + unset($arIp[0]); |
|
5030 | + } |
|
4791 | 5031 | |
4792 | - if (empty($arIp)) |
|
4793 | - $is_done = true; |
|
5032 | + if (empty($arIp)) { |
|
5033 | + $is_done = true; |
|
5034 | + } |
|
4794 | 5035 | |
4795 | 5036 | $updates = array(); |
4796 | 5037 | $cases = array(); |
@@ -4799,16 +5040,18 @@ discard block |
||
4799 | 5040 | { |
4800 | 5041 | $arIp[$i] = trim($arIp[$i]); |
4801 | 5042 | |
4802 | - if (empty($arIp[$i])) |
|
4803 | - continue; |
|
5043 | + if (empty($arIp[$i])) { |
|
5044 | + continue; |
|
5045 | + } |
|
4804 | 5046 | |
4805 | 5047 | $updates['ip' . $i] = $arIp[$i]; |
4806 | 5048 | $cases[$arIp[$i]] = 'WHEN ' . $oldCol . ' = {string:ip' . $i . '} THEN {inet:ip' . $i . '}'; |
4807 | 5049 | |
4808 | 5050 | if ($setSize > 0 && $i % $setSize === 0) |
4809 | 5051 | { |
4810 | - if (count($updates) == 1) |
|
4811 | - continue; |
|
5052 | + if (count($updates) == 1) { |
|
5053 | + continue; |
|
5054 | + } |
|
4812 | 5055 | |
4813 | 5056 | $updates['whereSet'] = array_values($updates); |
4814 | 5057 | $smcFunc['db_query']('', ' |
@@ -4842,8 +5085,7 @@ discard block |
||
4842 | 5085 | 'ip' => $ip |
4843 | 5086 | )); |
4844 | 5087 | } |
4845 | - } |
|
4846 | - else |
|
5088 | + } else |
|
4847 | 5089 | { |
4848 | 5090 | $updates['whereSet'] = array_values($updates); |
4849 | 5091 | $smcFunc['db_query']('', ' |
@@ -4857,9 +5099,9 @@ discard block |
||
4857 | 5099 | $updates |
4858 | 5100 | ); |
4859 | 5101 | } |
5102 | + } else { |
|
5103 | + $is_done = true; |
|
4860 | 5104 | } |
4861 | - else |
|
4862 | - $is_done = true; |
|
4863 | 5105 | |
4864 | 5106 | $_GET['a'] += $limit; |
4865 | 5107 | $step_progress['current'] = $_GET['a']; |
@@ -4885,10 +5127,11 @@ discard block |
||
4885 | 5127 | |
4886 | 5128 | $columns = $smcFunc['db_list_columns']($targetTable, true); |
4887 | 5129 | |
4888 | - if (isset($columns[$column])) |
|
4889 | - return $columns[$column]; |
|
4890 | - else |
|
4891 | - return null; |
|
4892 | -} |
|
5130 | + if (isset($columns[$column])) { |
|
5131 | + return $columns[$column]; |
|
5132 | + } else { |
|
5133 | + return null; |
|
5134 | + } |
|
5135 | + } |
|
4893 | 5136 | |
4894 | 5137 | ?> |
4895 | 5138 | \ No newline at end of file |
@@ -23,15 +23,15 @@ discard block |
||
23 | 23 | { |
24 | 24 | global $context, $txt; |
25 | 25 | |
26 | - if (!empty($context['simple_action'])) |
|
27 | - echo ' |
|
26 | + if (!empty($context['simple_action'])) { |
|
27 | + echo ' |
|
28 | 28 | <strong> |
29 | 29 | ', $context['error_title'], ' |
30 | 30 | </strong><br> |
31 | 31 | <div ', $context['error_code'], 'class="padding"> |
32 | 32 | ', $context['error_message'], ' |
33 | 33 | </div>'; |
34 | - else |
|
34 | + } else |
|
35 | 35 | { |
36 | 36 | echo ' |
37 | 37 | <div id="fatal_error"> |
@@ -85,21 +85,23 @@ discard block |
||
85 | 85 | |
86 | 86 | $error_types = array(); |
87 | 87 | |
88 | - foreach ($context['error_types'] as $type => $details) |
|
89 | - $error_types[] = ($details['is_selected'] ? '<img src="' . $settings['images_url'] . '/selected.png" alt=""> ' : '') . '<a href="' . $details['url'] . '" ' . ($details['is_selected'] ? 'style="font-weight: bold;"' : '') . ' title="' . $details['description'] . '">' . $details['label'] . '</a>'; |
|
88 | + foreach ($context['error_types'] as $type => $details) { |
|
89 | + $error_types[] = ($details['is_selected'] ? '<img src="' . $settings['images_url'] . '/selected.png" alt=""> ' : '') . '<a href="' . $details['url'] . '" ' . ($details['is_selected'] ? 'style="font-weight: bold;"' : '') . ' title="' . $details['description'] . '">' . $details['label'] . '</a>'; |
|
90 | + } |
|
90 | 91 | |
91 | 92 | echo ' |
92 | 93 | ', implode(' | ', $error_types), ' |
93 | 94 | </td> |
94 | 95 | </tr>'; |
95 | 96 | |
96 | - if ($context['has_filter']) |
|
97 | - echo ' |
|
97 | + if ($context['has_filter']) { |
|
98 | + echo ' |
|
98 | 99 | <tr> |
99 | 100 | <td colspan="3" class="windowbg"> |
100 | 101 | <strong>', $txt['applying_filter'], ':</strong> ', $context['filter']['entity'], ' ', $context['filter']['value']['html'], ' [<a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', '">', $txt['clear_filter'], '</a>] |
101 | 102 | </td> |
102 | 103 | </tr>'; |
104 | + } |
|
103 | 105 | |
104 | 106 | echo ' |
105 | 107 | <tr> |
@@ -110,11 +112,12 @@ discard block |
||
110 | 112 | </tr>'; |
111 | 113 | |
112 | 114 | // No errors, then show a message |
113 | - if (count($context['errors']) == 0) |
|
114 | - echo ' |
|
115 | + if (count($context['errors']) == 0) { |
|
116 | + echo ' |
|
115 | 117 | <tr class="windowbg"> |
116 | 118 | <td class="centertext" colspan="2">', $txt['errlog_no_entries'], '</td> |
117 | 119 | </tr>'; |
120 | + } |
|
118 | 121 | |
119 | 122 | // We have some errors, must be some mods installed :P |
120 | 123 | foreach ($context['errors'] as $error) |
@@ -128,16 +131,18 @@ discard block |
||
128 | 131 | <a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? '' : ';desc', $context['has_filter'] ? $context['filter']['href'] : '', '" title="', $txt['reverse_direction'], '"><span class="generic_icons sort_' . $context['sort_direction'] . '"></span></a> |
129 | 132 | ', $error['time'], '<br>'; |
130 | 133 | |
131 | - if (!empty($error['member']['ip'])) |
|
132 | - echo ' |
|
134 | + if (!empty($error['member']['ip'])) { |
|
135 | + echo ' |
|
133 | 136 | <a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';filter=ip;value=', $error['member']['ip'], '" title="', $txt['apply_filter'], ': ', $txt['filter_only_ip'], '"><span class="generic_icons filter centericon"></span></a> |
134 | 137 | <strong><a href="', $scripturl, '?action=trackip;searchip=', $error['member']['ip'], '">', $error['member']['ip'], '</a></strong>'; |
138 | + } |
|
135 | 139 | |
136 | - if ($error['member']['session'] != '') |
|
137 | - echo ' |
|
140 | + if ($error['member']['session'] != '') { |
|
141 | + echo ' |
|
138 | 142 | <br> |
139 | 143 | <a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';filter=session;value=', $error['member']['session'], '" title="', $txt['apply_filter'], ': ', $txt['filter_only_session'], '"><span class="generic_icons filter centericon"></span></a> |
140 | 144 | ', $error['member']['session'], '<br>'; |
145 | + } |
|
141 | 146 | |
142 | 147 | echo ' |
143 | 148 | </div> |
@@ -152,12 +157,13 @@ discard block |
||
152 | 157 | <a href="', $error['url']['html'], '">', $error['url']['html'], '</a> |
153 | 158 | '; |
154 | 159 | |
155 | - if (!empty($error['file'])) |
|
156 | - echo ' |
|
160 | + if (!empty($error['file'])) { |
|
161 | + echo ' |
|
157 | 162 | <div> |
158 | 163 | <a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';filter=file;value=', $error['file']['search'], '" title="', $txt['apply_filter'], ': ', $txt['filter_only_file'], '">' |
159 | 164 | . ' <span class="generic_icons filter"></span></a> ', $error['file']['link'], ' (', $txt['line'], ' ', $error['file']['line'], ') |
160 | 165 | </div>'; |
166 | + } |
|
161 | 167 | |
162 | 168 | echo ' |
163 | 169 | </div> |
@@ -186,9 +192,10 @@ discard block |
||
186 | 192 | </div> |
187 | 193 | </div>'; |
188 | 194 | |
189 | - if ($context['sort_direction'] == 'down') |
|
190 | - echo ' |
|
195 | + if ($context['sort_direction'] == 'down') { |
|
196 | + echo ' |
|
191 | 197 | <input type="hidden" name="desc" value="1">'; |
198 | + } |
|
192 | 199 | |
193 | 200 | echo ' |
194 | 201 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -249,9 +256,10 @@ discard block |
||
249 | 256 | $context['error_message'], ' |
250 | 257 | </div>'; |
251 | 258 | |
252 | - if (!empty($context['back_link'])) |
|
253 | - echo ' |
|
259 | + if (!empty($context['back_link'])) { |
|
260 | + echo ' |
|
254 | 261 | <a class="button" href="', $scripturl, $context['back_link'], '">', $txt['back'], '</a>'; |
262 | + } |
|
255 | 263 | |
256 | 264 | echo ' |
257 | 265 | <span style="float: right; margin:.5em;"></span> |
@@ -288,25 +296,30 @@ discard block |
||
288 | 296 | <div class="windowbg noup"> |
289 | 297 | <ul class="padding">'; |
290 | 298 | |
291 | - if (!empty($context['error_info']['error_type'])) |
|
292 | - echo ' |
|
299 | + if (!empty($context['error_info']['error_type'])) { |
|
300 | + echo ' |
|
293 | 301 | <li>', $txt['error_type'], ': ', ucfirst($context['error_info']['error_type']), '</li>'; |
302 | + } |
|
294 | 303 | |
295 | - if (!empty($context['error_info']['message'])) |
|
296 | - echo ' |
|
304 | + if (!empty($context['error_info']['message'])) { |
|
305 | + echo ' |
|
297 | 306 | <li>', $txt['error_message'], ': ', $context['error_info']['message'], '</li>'; |
307 | + } |
|
298 | 308 | |
299 | - if (!empty($context['error_info']['file'])) |
|
300 | - echo ' |
|
309 | + if (!empty($context['error_info']['file'])) { |
|
310 | + echo ' |
|
301 | 311 | <li>', $txt['error_file'], ': ', $context['error_info']['file'], '</li>'; |
312 | + } |
|
302 | 313 | |
303 | - if (!empty($context['error_info']['line'])) |
|
304 | - echo ' |
|
314 | + if (!empty($context['error_info']['line'])) { |
|
315 | + echo ' |
|
305 | 316 | <li>', $txt['error_line'], ': ', $context['error_info']['line'], '</li>'; |
317 | + } |
|
306 | 318 | |
307 | - if (!empty($context['error_info']['url'])) |
|
308 | - echo ' |
|
319 | + if (!empty($context['error_info']['url'])) { |
|
320 | + echo ' |
|
309 | 321 | <li>', $txt['error_url'], ': ', $context['error_info']['url'], '</li>'; |
322 | + } |
|
310 | 323 | |
311 | 324 | |
312 | 325 | echo ' |
@@ -328,10 +341,12 @@ discard block |
||
328 | 341 | foreach ($context['error_info']['backtrace'] as $key => $value) |
329 | 342 | { |
330 | 343 | //Check for existing |
331 | - if (empty($value->file)) |
|
332 | - $value->file = $txt['unknown']; |
|
333 | - if (empty($value->line)) |
|
334 | - $value->line = -1; |
|
344 | + if (empty($value->file)) { |
|
345 | + $value->file = $txt['unknown']; |
|
346 | + } |
|
347 | + if (empty($value->line)) { |
|
348 | + $value->line = -1; |
|
349 | + } |
|
335 | 350 | |
336 | 351 | echo ' |
337 | 352 | <li class="backtrace">', sprintf($txt['backtrace_info'], $key, $value->function, $value->file, $value->line, base64_encode($value->file)), '</li>'; |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * !!!Compatibility!!! |
@@ -30,8 +31,9 @@ discard block |
||
30 | 31 | { |
31 | 32 | global $modSettings; |
32 | 33 | |
33 | - if (!$compat_mode) |
|
34 | - return $text; |
|
34 | + if (!$compat_mode) { |
|
35 | + return $text; |
|
36 | + } |
|
35 | 37 | |
36 | 38 | // Turn line breaks back into br's. |
37 | 39 | $text = strtr($text, array("\r" => '', "\n" => '<br>')); |
@@ -48,8 +50,9 @@ discard block |
||
48 | 50 | for ($i = 0, $n = count($parts); $i < $n; $i++) |
49 | 51 | { |
50 | 52 | // Value of 2 means we're inside the tag. |
51 | - if ($i % 4 == 2) |
|
52 | - $parts[$i] = strtr($parts[$i], array('[' => '[', ']' => ']', "'" => "'")); |
|
53 | + if ($i % 4 == 2) { |
|
54 | + $parts[$i] = strtr($parts[$i], array('[' => '[', ']' => ']', "'" => "'")); |
|
55 | + } |
|
53 | 56 | } |
54 | 57 | // Put our humpty dumpty message back together again. |
55 | 58 | $text = implode('', $parts); |
@@ -107,8 +110,9 @@ discard block |
||
107 | 110 | $text = preg_replace('~</p>\s*(?!<)~i', '</p><br>', $text); |
108 | 111 | |
109 | 112 | // Safari/webkit wraps lines in Wysiwyg in <div>'s. |
110 | - if (isBrowser('webkit')) |
|
111 | - $text = preg_replace(array('~<div(?:\s(?:[^<>]*?))?' . '>~i', '</div>'), array('<br>', ''), $text); |
|
113 | + if (isBrowser('webkit')) { |
|
114 | + $text = preg_replace(array('~<div(?:\s(?:[^<>]*?))?' . '>~i', '</div>'), array('<br>', ''), $text); |
|
115 | + } |
|
112 | 116 | |
113 | 117 | // If there's a trailing break get rid of it - Firefox tends to add one. |
114 | 118 | $text = preg_replace('~<br\s?/?' . '>$~i', '', $text); |
@@ -123,8 +127,9 @@ discard block |
||
123 | 127 | for ($i = 0, $n = count($parts); $i < $n; $i++) |
124 | 128 | { |
125 | 129 | // Value of 2 means we're inside the tag. |
126 | - if ($i % 4 == 2) |
|
127 | - $parts[$i] = strip_tags($parts[$i]); |
|
130 | + if ($i % 4 == 2) { |
|
131 | + $parts[$i] = strip_tags($parts[$i]); |
|
132 | + } |
|
128 | 133 | } |
129 | 134 | |
130 | 135 | $text = strtr(implode('', $parts), array('#smf_br_spec_grudge_cool!#' => '<br>')); |
@@ -150,18 +155,19 @@ discard block |
||
150 | 155 | { |
151 | 156 | $found = array_search($file, $smileysto); |
152 | 157 | // Note the weirdness here is to stop double spaces between smileys. |
153 | - if ($found) |
|
154 | - $matches[1][$k] = '-[]-smf_smily_start#|#' . $smcFunc['htmlspecialchars']($smileysfrom[$found]) . '-[]-smf_smily_end#|#'; |
|
155 | - else |
|
156 | - $matches[1][$k] = ''; |
|
158 | + if ($found) { |
|
159 | + $matches[1][$k] = '-[]-smf_smily_start#|#' . $smcFunc['htmlspecialchars']($smileysfrom[$found]) . '-[]-smf_smily_end#|#'; |
|
160 | + } else { |
|
161 | + $matches[1][$k] = ''; |
|
162 | + } |
|
157 | 163 | } |
158 | - } |
|
159 | - else |
|
164 | + } else |
|
160 | 165 | { |
161 | 166 | // Load all the smileys. |
162 | 167 | $names = array(); |
163 | - foreach ($matches[1] as $file) |
|
164 | - $names[] = $file; |
|
168 | + foreach ($matches[1] as $file) { |
|
169 | + $names[] = $file; |
|
170 | + } |
|
165 | 171 | $names = array_unique($names); |
166 | 172 | |
167 | 173 | if (!empty($names)) |
@@ -175,13 +181,15 @@ discard block |
||
175 | 181 | ) |
176 | 182 | ); |
177 | 183 | $mappings = array(); |
178 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
179 | - $mappings[$row['filename']] = $smcFunc['htmlspecialchars']($row['code']); |
|
184 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
185 | + $mappings[$row['filename']] = $smcFunc['htmlspecialchars']($row['code']); |
|
186 | + } |
|
180 | 187 | $smcFunc['db_free_result']($request); |
181 | 188 | |
182 | - foreach ($matches[1] as $k => $file) |
|
183 | - if (isset($mappings[$file])) |
|
189 | + foreach ($matches[1] as $k => $file) { |
|
190 | + if (isset($mappings[$file])) |
|
184 | 191 | $matches[1][$k] = '-[]-smf_smily_start#|#' . $mappings[$file] . '-[]-smf_smily_end#|#'; |
192 | + } |
|
185 | 193 | } |
186 | 194 | } |
187 | 195 | |
@@ -193,8 +201,9 @@ discard block |
||
193 | 201 | } |
194 | 202 | |
195 | 203 | // Only try to buy more time if the client didn't quit. |
196 | - if (connection_aborted() && $context['server']['is_apache']) |
|
197 | - @apache_reset_timeout(); |
|
204 | + if (connection_aborted() && $context['server']['is_apache']) { |
|
205 | + @apache_reset_timeout(); |
|
206 | + } |
|
198 | 207 | |
199 | 208 | $parts = preg_split('~(<[A-Za-z]+\s*[^<>]*?style="?[^<>"]+"?[^<>]*?(?:/?)>|</[A-Za-z]+>)~', $text, -1, PREG_SPLIT_DELIM_CAPTURE); |
200 | 209 | $replacement = ''; |
@@ -205,9 +214,9 @@ discard block |
||
205 | 214 | if (preg_match('~(<([A-Za-z]+)\s*[^<>]*?)style="?([^<>"]+)"?([^<>]*?(/?)>)~', $part, $matches) === 1) |
206 | 215 | { |
207 | 216 | // If it's being closed instantly, we can't deal with it...yet. |
208 | - if ($matches[5] === '/') |
|
209 | - continue; |
|
210 | - else |
|
217 | + if ($matches[5] === '/') { |
|
218 | + continue; |
|
219 | + } else |
|
211 | 220 | { |
212 | 221 | // Get an array of styles that apply to this element. (The strtr is there to combat HTML generated by Word.) |
213 | 222 | $styles = explode(';', strtr($matches[3], array('"' => ''))); |
@@ -223,8 +232,9 @@ discard block |
||
223 | 232 | $clean_type_value_pair = strtolower(strtr(trim($type_value_pair), '=', ':')); |
224 | 233 | |
225 | 234 | // Something like 'font-weight: bold' is expected here. |
226 | - if (strpos($clean_type_value_pair, ':') === false) |
|
227 | - continue; |
|
235 | + if (strpos($clean_type_value_pair, ':') === false) { |
|
236 | + continue; |
|
237 | + } |
|
228 | 238 | |
229 | 239 | // Capture the elements of a single style item (e.g. 'font-weight' and 'bold'). |
230 | 240 | list ($style_type, $style_value) = explode(':', $type_value_pair); |
@@ -246,8 +256,7 @@ discard block |
||
246 | 256 | { |
247 | 257 | $curCloseTags .= '[/u]'; |
248 | 258 | $replacement .= '[u]'; |
249 | - } |
|
250 | - elseif ($style_value == 'line-through') |
|
259 | + } elseif ($style_value == 'line-through') |
|
251 | 260 | { |
252 | 261 | $curCloseTags .= '[/s]'; |
253 | 262 | $replacement .= '[s]'; |
@@ -259,13 +268,11 @@ discard block |
||
259 | 268 | { |
260 | 269 | $curCloseTags .= '[/left]'; |
261 | 270 | $replacement .= '[left]'; |
262 | - } |
|
263 | - elseif ($style_value == 'center') |
|
271 | + } elseif ($style_value == 'center') |
|
264 | 272 | { |
265 | 273 | $curCloseTags .= '[/center]'; |
266 | 274 | $replacement .= '[center]'; |
267 | - } |
|
268 | - elseif ($style_value == 'right') |
|
275 | + } elseif ($style_value == 'right') |
|
269 | 276 | { |
270 | 277 | $curCloseTags .= '[/right]'; |
271 | 278 | $replacement .= '[right]'; |
@@ -287,8 +294,9 @@ discard block |
||
287 | 294 | |
288 | 295 | case 'font-size': |
289 | 296 | // Sometimes people put decimals where decimals should not be. |
290 | - if (preg_match('~(\d)+\.\d+(p[xt])~i', $style_value, $dec_matches) === 1) |
|
291 | - $style_value = $dec_matches[1] . $dec_matches[2]; |
|
297 | + if (preg_match('~(\d)+\.\d+(p[xt])~i', $style_value, $dec_matches) === 1) { |
|
298 | + $style_value = $dec_matches[1] . $dec_matches[2]; |
|
299 | + } |
|
292 | 300 | |
293 | 301 | $curCloseTags .= '[/size]'; |
294 | 302 | $replacement .= '[size=' . $style_value . ']'; |
@@ -296,8 +304,9 @@ discard block |
||
296 | 304 | |
297 | 305 | case 'font-family': |
298 | 306 | // Only get the first freaking font if there's a list! |
299 | - if (strpos($style_value, ',') !== false) |
|
300 | - $style_value = substr($style_value, 0, strpos($style_value, ',')); |
|
307 | + if (strpos($style_value, ',') !== false) { |
|
308 | + $style_value = substr($style_value, 0, strpos($style_value, ',')); |
|
309 | + } |
|
301 | 310 | |
302 | 311 | $curCloseTags .= '[/font]'; |
303 | 312 | $replacement .= '[font=' . strtr($style_value, array("'" => '')) . ']'; |
@@ -306,13 +315,15 @@ discard block |
||
306 | 315 | // This is a hack for images with dimensions embedded. |
307 | 316 | case 'width': |
308 | 317 | case 'height': |
309 | - if (preg_match('~[1-9]\d*~i', $style_value, $dimension) === 1) |
|
310 | - $extra_attr .= ' ' . $style_type . '="' . $dimension[0] . '"'; |
|
318 | + if (preg_match('~[1-9]\d*~i', $style_value, $dimension) === 1) { |
|
319 | + $extra_attr .= ' ' . $style_type . '="' . $dimension[0] . '"'; |
|
320 | + } |
|
311 | 321 | break; |
312 | 322 | |
313 | 323 | case 'list-style-type': |
314 | - if (preg_match('~none|disc|circle|square|decimal|decimal-leading-zero|lower-roman|upper-roman|lower-alpha|upper-alpha|lower-greek|lower-latin|upper-latin|hebrew|armenian|georgian|cjk-ideographic|hiragana|katakana|hiragana-iroha|katakana-iroha~i', $style_value, $listType) === 1) |
|
315 | - $extra_attr .= ' listtype="' . $listType[0] . '"'; |
|
324 | + if (preg_match('~none|disc|circle|square|decimal|decimal-leading-zero|lower-roman|upper-roman|lower-alpha|upper-alpha|lower-greek|lower-latin|upper-latin|hebrew|armenian|georgian|cjk-ideographic|hiragana|katakana|hiragana-iroha|katakana-iroha~i', $style_value, $listType) === 1) { |
|
325 | + $extra_attr .= ' listtype="' . $listType[0] . '"'; |
|
326 | + } |
|
316 | 327 | break; |
317 | 328 | } |
318 | 329 | } |
@@ -325,18 +336,17 @@ discard block |
||
325 | 336 | } |
326 | 337 | |
327 | 338 | // If there's something that still needs closing, push it to the stack. |
328 | - if (!empty($curCloseTags)) |
|
329 | - array_push($stack, array( |
|
339 | + if (!empty($curCloseTags)) { |
|
340 | + array_push($stack, array( |
|
330 | 341 | 'element' => strtolower($curElement), |
331 | 342 | 'closeTags' => $curCloseTags |
332 | 343 | ) |
333 | 344 | ); |
334 | - elseif (!empty($extra_attr)) |
|
335 | - $replacement .= $precedingStyle . $extra_attr . $afterStyle; |
|
345 | + } elseif (!empty($extra_attr)) { |
|
346 | + $replacement .= $precedingStyle . $extra_attr . $afterStyle; |
|
347 | + } |
|
336 | 348 | } |
337 | - } |
|
338 | - |
|
339 | - elseif (preg_match('~</([A-Za-z]+)>~', $part, $matches) === 1) |
|
349 | + } elseif (preg_match('~</([A-Za-z]+)>~', $part, $matches) === 1) |
|
340 | 350 | { |
341 | 351 | // Is this the element that we've been waiting for to be closed? |
342 | 352 | if (!empty($stack) && strtolower($matches[1]) === $stack[count($stack) - 1]['element']) |
@@ -346,28 +356,32 @@ discard block |
||
346 | 356 | } |
347 | 357 | |
348 | 358 | // Must've been something else. |
349 | - else |
|
350 | - $replacement .= $part; |
|
359 | + else { |
|
360 | + $replacement .= $part; |
|
361 | + } |
|
351 | 362 | } |
352 | 363 | // In all other cases, just add the part to the replacement. |
353 | - else |
|
354 | - $replacement .= $part; |
|
364 | + else { |
|
365 | + $replacement .= $part; |
|
366 | + } |
|
355 | 367 | } |
356 | 368 | |
357 | 369 | // Now put back the replacement in the text. |
358 | 370 | $text = $replacement; |
359 | 371 | |
360 | 372 | // We are not finished yet, request more time. |
361 | - if (connection_aborted() && $context['server']['is_apache']) |
|
362 | - @apache_reset_timeout(); |
|
373 | + if (connection_aborted() && $context['server']['is_apache']) { |
|
374 | + @apache_reset_timeout(); |
|
375 | + } |
|
363 | 376 | |
364 | 377 | // Let's pull out any legacy alignments. |
365 | 378 | while (preg_match('~<([A-Za-z]+)\s+[^<>]*?(align="*(left|center|right)"*)[^<>]*?(/?)>~i', $text, $matches) === 1) |
366 | 379 | { |
367 | 380 | // Find the position in the text of this tag over again. |
368 | 381 | $start_pos = strpos($text, $matches[0]); |
369 | - if ($start_pos === false) |
|
370 | - break; |
|
382 | + if ($start_pos === false) { |
|
383 | + break; |
|
384 | + } |
|
371 | 385 | |
372 | 386 | // End tag? |
373 | 387 | if ($matches[4] != '/' && strpos($text, '</' . $matches[1] . '>', $start_pos) !== false) |
@@ -381,8 +395,7 @@ discard block |
||
381 | 395 | |
382 | 396 | // Put the tags back into the body. |
383 | 397 | $text = substr($text, 0, $start_pos) . $tag . '[' . $matches[3] . ']' . $content . '[/' . $matches[3] . ']' . substr($text, $end_pos); |
384 | - } |
|
385 | - else |
|
398 | + } else |
|
386 | 399 | { |
387 | 400 | // Just get rid of this evil tag. |
388 | 401 | $text = substr($text, 0, $start_pos) . substr($text, $start_pos + strlen($matches[0])); |
@@ -395,8 +408,9 @@ discard block |
||
395 | 408 | // Find the position of this again. |
396 | 409 | $start_pos = strpos($text, $matches[0]); |
397 | 410 | $end_pos = false; |
398 | - if ($start_pos === false) |
|
399 | - break; |
|
411 | + if ($start_pos === false) { |
|
412 | + break; |
|
413 | + } |
|
400 | 414 | |
401 | 415 | // This must have an end tag - and we must find the right one. |
402 | 416 | $lower_text = strtolower($text); |
@@ -429,8 +443,9 @@ discard block |
||
429 | 443 | break; |
430 | 444 | } |
431 | 445 | } |
432 | - if ($end_pos === false) |
|
433 | - break; |
|
446 | + if ($end_pos === false) { |
|
447 | + break; |
|
448 | + } |
|
434 | 449 | |
435 | 450 | // Now work out what the attributes are. |
436 | 451 | $attribs = fetchTagAttributes($matches[1]); |
@@ -444,11 +459,11 @@ discard block |
||
444 | 459 | $v = (int) trim($v); |
445 | 460 | $v = empty($v) ? 1 : $v; |
446 | 461 | $tags[] = array('[size=' . $sizes_equivalence[$v] . ']', '[/size]'); |
462 | + } elseif ($s == 'face') { |
|
463 | + $tags[] = array('[font=' . trim(strtolower($v)) . ']', '[/font]'); |
|
464 | + } elseif ($s == 'color') { |
|
465 | + $tags[] = array('[color=' . trim(strtolower($v)) . ']', '[/color]'); |
|
447 | 466 | } |
448 | - elseif ($s == 'face') |
|
449 | - $tags[] = array('[font=' . trim(strtolower($v)) . ']', '[/font]'); |
|
450 | - elseif ($s == 'color') |
|
451 | - $tags[] = array('[color=' . trim(strtolower($v)) . ']', '[/color]'); |
|
452 | 467 | } |
453 | 468 | |
454 | 469 | // As before add in our tags. |
@@ -456,8 +471,9 @@ discard block |
||
456 | 471 | foreach ($tags as $tag) |
457 | 472 | { |
458 | 473 | $before .= $tag[0]; |
459 | - if (isset($tag[1])) |
|
460 | - $after = $tag[1] . $after; |
|
474 | + if (isset($tag[1])) { |
|
475 | + $after = $tag[1] . $after; |
|
476 | + } |
|
461 | 477 | } |
462 | 478 | |
463 | 479 | // Remove the tag so it's never checked again. |
@@ -468,8 +484,9 @@ discard block |
||
468 | 484 | } |
469 | 485 | |
470 | 486 | // Almost there, just a little more time. |
471 | - if (connection_aborted() && $context['server']['is_apache']) |
|
472 | - @apache_reset_timeout(); |
|
487 | + if (connection_aborted() && $context['server']['is_apache']) { |
|
488 | + @apache_reset_timeout(); |
|
489 | + } |
|
473 | 490 | |
474 | 491 | if (count($parts = preg_split('~<(/?)(li|ol|ul)([^>]*)>~i', $text, null, PREG_SPLIT_DELIM_CAPTURE)) > 1) |
475 | 492 | { |
@@ -525,12 +542,13 @@ discard block |
||
525 | 542 | { |
526 | 543 | $inList = true; |
527 | 544 | |
528 | - if ($tag === 'ol') |
|
529 | - $listType = 'decimal'; |
|
530 | - elseif (preg_match('~type="?(' . implode('|', array_keys($listTypeMapping)) . ')"?~', $parts[$i + 3], $match) === 1) |
|
531 | - $listType = $listTypeMapping[$match[1]]; |
|
532 | - else |
|
533 | - $listType = null; |
|
545 | + if ($tag === 'ol') { |
|
546 | + $listType = 'decimal'; |
|
547 | + } elseif (preg_match('~type="?(' . implode('|', array_keys($listTypeMapping)) . ')"?~', $parts[$i + 3], $match) === 1) { |
|
548 | + $listType = $listTypeMapping[$match[1]]; |
|
549 | + } else { |
|
550 | + $listType = null; |
|
551 | + } |
|
534 | 552 | |
535 | 553 | $listDepth++; |
536 | 554 | |
@@ -594,9 +612,7 @@ discard block |
||
594 | 612 | $parts[$i + 1] = ''; |
595 | 613 | $parts[$i + 2] = str_repeat("\t", $listDepth) . '[/list]'; |
596 | 614 | $parts[$i + 3] = ''; |
597 | - } |
|
598 | - |
|
599 | - else |
|
615 | + } else |
|
600 | 616 | { |
601 | 617 | // We're in a list item. |
602 | 618 | if ($listDepth > 0) |
@@ -633,9 +649,7 @@ discard block |
||
633 | 649 | $parts[$i + 1] = ''; |
634 | 650 | $parts[$i + 2] = ''; |
635 | 651 | $parts[$i + 3] = ''; |
636 | - } |
|
637 | - |
|
638 | - else |
|
652 | + } else |
|
639 | 653 | { |
640 | 654 | // Remove the trailing breaks from the list item. |
641 | 655 | $parts[$i] = preg_replace('~\s*<br\s*' . '/?' . '>\s*$~', '', $parts[$i]); |
@@ -673,8 +687,9 @@ discard block |
||
673 | 687 | $text .= str_repeat("\t", $listDepth) . '[/list]'; |
674 | 688 | } |
675 | 689 | |
676 | - for ($i = $listDepth; $i > 0; $i--) |
|
677 | - $text .= '[/li]' . "\n" . str_repeat("\t", $i - 1) . '[/list]'; |
|
690 | + for ($i = $listDepth; $i > 0; $i--) { |
|
691 | + $text .= '[/li]' . "\n" . str_repeat("\t", $i - 1) . '[/list]'; |
|
692 | + } |
|
678 | 693 | } |
679 | 694 | |
680 | 695 | // I love my own image... |
@@ -682,8 +697,9 @@ discard block |
||
682 | 697 | { |
683 | 698 | // Find the position of the image. |
684 | 699 | $start_pos = strpos($text, $matches[0]); |
685 | - if ($start_pos === false) |
|
686 | - break; |
|
700 | + if ($start_pos === false) { |
|
701 | + break; |
|
702 | + } |
|
687 | 703 | $end_pos = $start_pos + strlen($matches[0]); |
688 | 704 | |
689 | 705 | $params = ''; |
@@ -692,12 +708,13 @@ discard block |
||
692 | 708 | $attrs = fetchTagAttributes($matches[1]); |
693 | 709 | foreach ($attrs as $attrib => $value) |
694 | 710 | { |
695 | - if (in_array($attrib, array('width', 'height'))) |
|
696 | - $params .= ' ' . $attrib . '=' . (int) $value; |
|
697 | - elseif ($attrib == 'alt' && trim($value) != '') |
|
698 | - $params .= ' alt=' . trim($value); |
|
699 | - elseif ($attrib == 'src') |
|
700 | - $src = trim($value); |
|
711 | + if (in_array($attrib, array('width', 'height'))) { |
|
712 | + $params .= ' ' . $attrib . '=' . (int) $value; |
|
713 | + } elseif ($attrib == 'alt' && trim($value) != '') { |
|
714 | + $params .= ' alt=' . trim($value); |
|
715 | + } elseif ($attrib == 'src') { |
|
716 | + $src = trim($value); |
|
717 | + } |
|
701 | 718 | } |
702 | 719 | |
703 | 720 | $tag = ''; |
@@ -708,10 +725,11 @@ discard block |
||
708 | 725 | { |
709 | 726 | $baseURL = (isset($parsedURL['scheme']) ? $parsedURL['scheme'] : 'http') . '://' . $parsedURL['host'] . (empty($parsedURL['port']) ? '' : ':' . $parsedURL['port']); |
710 | 727 | |
711 | - if (substr($src, 0, 1) === '/') |
|
712 | - $src = $baseURL . $src; |
|
713 | - else |
|
714 | - $src = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $src; |
|
728 | + if (substr($src, 0, 1) === '/') { |
|
729 | + $src = $baseURL . $src; |
|
730 | + } else { |
|
731 | + $src = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $src; |
|
732 | + } |
|
715 | 733 | } |
716 | 734 | |
717 | 735 | $tag = '[img' . $params . ']' . $src . '[/img]'; |
@@ -889,20 +907,23 @@ discard block |
||
889 | 907 | }, |
890 | 908 | ); |
891 | 909 | |
892 | - foreach ($tags as $tag => $replace) |
|
893 | - $text = preg_replace_callback($tag, $replace, $text); |
|
910 | + foreach ($tags as $tag => $replace) { |
|
911 | + $text = preg_replace_callback($tag, $replace, $text); |
|
912 | + } |
|
894 | 913 | |
895 | 914 | // Please give us just a little more time. |
896 | - if (connection_aborted() && $context['server']['is_apache']) |
|
897 | - @apache_reset_timeout(); |
|
915 | + if (connection_aborted() && $context['server']['is_apache']) { |
|
916 | + @apache_reset_timeout(); |
|
917 | + } |
|
898 | 918 | |
899 | 919 | // What about URL's - the pain in the ass of the tag world. |
900 | 920 | while (preg_match('~<a\s+([^<>]*)>([^<>]*)</a>~i', $text, $matches) === 1) |
901 | 921 | { |
902 | 922 | // Find the position of the URL. |
903 | 923 | $start_pos = strpos($text, $matches[0]); |
904 | - if ($start_pos === false) |
|
905 | - break; |
|
924 | + if ($start_pos === false) { |
|
925 | + break; |
|
926 | + } |
|
906 | 927 | $end_pos = $start_pos + strlen($matches[0]); |
907 | 928 | |
908 | 929 | $tag_type = 'url'; |
@@ -916,8 +937,9 @@ discard block |
||
916 | 937 | $href = trim($value); |
917 | 938 | |
918 | 939 | // Are we dealing with an FTP link? |
919 | - if (preg_match('~^ftps?://~', $href) === 1) |
|
920 | - $tag_type = 'ftp'; |
|
940 | + if (preg_match('~^ftps?://~', $href) === 1) { |
|
941 | + $tag_type = 'ftp'; |
|
942 | + } |
|
921 | 943 | |
922 | 944 | // Or is this a link to an email address? |
923 | 945 | elseif (substr($href, 0, 7) == 'mailto:') |
@@ -931,28 +953,31 @@ discard block |
||
931 | 953 | { |
932 | 954 | $baseURL = (isset($parsedURL['scheme']) ? $parsedURL['scheme'] : 'http') . '://' . $parsedURL['host'] . (empty($parsedURL['port']) ? '' : ':' . $parsedURL['port']); |
933 | 955 | |
934 | - if (substr($href, 0, 1) === '/') |
|
935 | - $href = $baseURL . $href; |
|
936 | - else |
|
937 | - $href = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $href; |
|
956 | + if (substr($href, 0, 1) === '/') { |
|
957 | + $href = $baseURL . $href; |
|
958 | + } else { |
|
959 | + $href = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $href; |
|
960 | + } |
|
938 | 961 | } |
939 | 962 | } |
940 | 963 | |
941 | 964 | // External URL? |
942 | 965 | if ($attrib == 'target' && $tag_type == 'url') |
943 | 966 | { |
944 | - if (trim($value) == '_blank') |
|
945 | - $tag_type == 'iurl'; |
|
967 | + if (trim($value) == '_blank') { |
|
968 | + $tag_type == 'iurl'; |
|
969 | + } |
|
946 | 970 | } |
947 | 971 | } |
948 | 972 | |
949 | 973 | $tag = ''; |
950 | 974 | if ($href != '') |
951 | 975 | { |
952 | - if ($matches[2] == $href) |
|
953 | - $tag = '[' . $tag_type . ']' . $href . '[/' . $tag_type . ']'; |
|
954 | - else |
|
955 | - $tag = '[' . $tag_type . '=' . $href . ']' . $matches[2] . '[/' . $tag_type . ']'; |
|
976 | + if ($matches[2] == $href) { |
|
977 | + $tag = '[' . $tag_type . ']' . $href . '[/' . $tag_type . ']'; |
|
978 | + } else { |
|
979 | + $tag = '[' . $tag_type . '=' . $href . ']' . $matches[2] . '[/' . $tag_type . ']'; |
|
980 | + } |
|
956 | 981 | } |
957 | 982 | |
958 | 983 | // Replace the tag |
@@ -991,17 +1016,18 @@ discard block |
||
991 | 1016 | // We're either moving from the key to the attribute or we're in a string and this is fine. |
992 | 1017 | if ($text[$i] == '=') |
993 | 1018 | { |
994 | - if ($tag_state == 0) |
|
995 | - $tag_state = 1; |
|
996 | - elseif ($tag_state == 2) |
|
997 | - $value .= '='; |
|
1019 | + if ($tag_state == 0) { |
|
1020 | + $tag_state = 1; |
|
1021 | + } elseif ($tag_state == 2) { |
|
1022 | + $value .= '='; |
|
1023 | + } |
|
998 | 1024 | } |
999 | 1025 | // A space is either moving from an attribute back to a potential key or in a string is fine. |
1000 | 1026 | elseif ($text[$i] == ' ') |
1001 | 1027 | { |
1002 | - if ($tag_state == 2) |
|
1003 | - $value .= ' '; |
|
1004 | - elseif ($tag_state == 1) |
|
1028 | + if ($tag_state == 2) { |
|
1029 | + $value .= ' '; |
|
1030 | + } elseif ($tag_state == 1) |
|
1005 | 1031 | { |
1006 | 1032 | $attribs[$key] = $value; |
1007 | 1033 | $key = $value = ''; |
@@ -1012,24 +1038,27 @@ discard block |
||
1012 | 1038 | elseif ($text[$i] == '"') |
1013 | 1039 | { |
1014 | 1040 | // Must be either going into or out of a string. |
1015 | - if ($tag_state == 1) |
|
1016 | - $tag_state = 2; |
|
1017 | - else |
|
1018 | - $tag_state = 1; |
|
1041 | + if ($tag_state == 1) { |
|
1042 | + $tag_state = 2; |
|
1043 | + } else { |
|
1044 | + $tag_state = 1; |
|
1045 | + } |
|
1019 | 1046 | } |
1020 | 1047 | // Otherwise it's fine. |
1021 | 1048 | else |
1022 | 1049 | { |
1023 | - if ($tag_state == 0) |
|
1024 | - $key .= $text[$i]; |
|
1025 | - else |
|
1026 | - $value .= $text[$i]; |
|
1050 | + if ($tag_state == 0) { |
|
1051 | + $key .= $text[$i]; |
|
1052 | + } else { |
|
1053 | + $value .= $text[$i]; |
|
1054 | + } |
|
1027 | 1055 | } |
1028 | 1056 | } |
1029 | 1057 | |
1030 | 1058 | // Anything left? |
1031 | - if ($key != '' && $value != '') |
|
1032 | - $attribs[$key] = $value; |
|
1059 | + if ($key != '' && $value != '') { |
|
1060 | + $attribs[$key] = $value; |
|
1061 | + } |
|
1033 | 1062 | |
1034 | 1063 | return $attribs; |
1035 | 1064 | } |
@@ -1045,15 +1074,17 @@ discard block |
||
1045 | 1074 | global $modSettings; |
1046 | 1075 | |
1047 | 1076 | // Don't care about the texts that are too short. |
1048 | - if (strlen($text) < 3) |
|
1049 | - return $text; |
|
1077 | + if (strlen($text) < 3) { |
|
1078 | + return $text; |
|
1079 | + } |
|
1050 | 1080 | |
1051 | 1081 | // A list of tags that's disabled by the admin. |
1052 | 1082 | $disabled = empty($modSettings['disabledBBC']) ? array() : array_flip(explode(',', strtolower($modSettings['disabledBBC']))); |
1053 | 1083 | |
1054 | 1084 | // Add flash if it's disabled as embedded tag. |
1055 | - if (empty($modSettings['enableEmbeddedFlash'])) |
|
1056 | - $disabled['flash'] = true; |
|
1085 | + if (empty($modSettings['enableEmbeddedFlash'])) { |
|
1086 | + $disabled['flash'] = true; |
|
1087 | + } |
|
1057 | 1088 | |
1058 | 1089 | // Get a list of all the tags that are not disabled. |
1059 | 1090 | $all_tags = parse_bbc(false); |
@@ -1061,10 +1092,12 @@ discard block |
||
1061 | 1092 | $self_closing_tags = array(); |
1062 | 1093 | foreach ($all_tags as $tag) |
1063 | 1094 | { |
1064 | - if (!isset($disabled[$tag['tag']])) |
|
1065 | - $valid_tags[$tag['tag']] = !empty($tag['block_level']); |
|
1066 | - if (isset($tag['type']) && $tag['type'] == 'closed') |
|
1067 | - $self_closing_tags[] = $tag['tag']; |
|
1095 | + if (!isset($disabled[$tag['tag']])) { |
|
1096 | + $valid_tags[$tag['tag']] = !empty($tag['block_level']); |
|
1097 | + } |
|
1098 | + if (isset($tag['type']) && $tag['type'] == 'closed') { |
|
1099 | + $self_closing_tags[] = $tag['tag']; |
|
1100 | + } |
|
1068 | 1101 | } |
1069 | 1102 | |
1070 | 1103 | // Right - we're going to start by going through the whole lot to make sure we don't have align stuff crossed as this happens load and is stupid! |
@@ -1091,16 +1124,19 @@ discard block |
||
1091 | 1124 | $tagName = substr($match, $isClosingTag ? 2 : 1, -1); |
1092 | 1125 | |
1093 | 1126 | // We're closing the exact same tag that we opened. |
1094 | - if ($isClosingTag && $insideTag === $tagName) |
|
1095 | - $insideTag = null; |
|
1127 | + if ($isClosingTag && $insideTag === $tagName) { |
|
1128 | + $insideTag = null; |
|
1129 | + } |
|
1096 | 1130 | |
1097 | 1131 | // We're opening a tag and we're not yet inside one either |
1098 | - elseif (!$isClosingTag && $insideTag === null) |
|
1099 | - $insideTag = $tagName; |
|
1132 | + elseif (!$isClosingTag && $insideTag === null) { |
|
1133 | + $insideTag = $tagName; |
|
1134 | + } |
|
1100 | 1135 | |
1101 | 1136 | // In all other cases, this tag must be invalid |
1102 | - else |
|
1103 | - unset($matches[$i]); |
|
1137 | + else { |
|
1138 | + unset($matches[$i]); |
|
1139 | + } |
|
1104 | 1140 | } |
1105 | 1141 | |
1106 | 1142 | // The next one is gonna be the other one. |
@@ -1108,8 +1144,9 @@ discard block |
||
1108 | 1144 | } |
1109 | 1145 | |
1110 | 1146 | // We're still inside a tag and had no chance for closure? |
1111 | - if ($insideTag !== null) |
|
1112 | - $matches[] = '[/' . $insideTag . ']'; |
|
1147 | + if ($insideTag !== null) { |
|
1148 | + $matches[] = '[/' . $insideTag . ']'; |
|
1149 | + } |
|
1113 | 1150 | |
1114 | 1151 | // And a complete text string again. |
1115 | 1152 | $text = implode('', $matches); |
@@ -1118,8 +1155,9 @@ discard block |
||
1118 | 1155 | // Quickly remove any tags which are back to back. |
1119 | 1156 | $backToBackPattern = '~\\[(' . implode('|', array_diff(array_keys($valid_tags), array('td', 'anchor'))) . ')[^<>\\[\\]]*\\]\s*\\[/\\1\\]~'; |
1120 | 1157 | $lastlen = 0; |
1121 | - while (strlen($text) !== $lastlen) |
|
1122 | - $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
1158 | + while (strlen($text) !== $lastlen) { |
|
1159 | + $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
1160 | + } |
|
1123 | 1161 | |
1124 | 1162 | // Need to sort the tags my name length. |
1125 | 1163 | uksort($valid_tags, 'sort_array_length'); |
@@ -1156,8 +1194,9 @@ discard block |
||
1156 | 1194 | $isCompetingTag = in_array($tag, $competing_tags); |
1157 | 1195 | |
1158 | 1196 | // Check if this might be one of those cleaned out tags. |
1159 | - if ($tag === '') |
|
1160 | - continue; |
|
1197 | + if ($tag === '') { |
|
1198 | + continue; |
|
1199 | + } |
|
1161 | 1200 | |
1162 | 1201 | // Special case: inside [code] blocks any code is left untouched. |
1163 | 1202 | elseif ($tag === 'code') |
@@ -1168,8 +1207,9 @@ discard block |
||
1168 | 1207 | $inCode = false; |
1169 | 1208 | |
1170 | 1209 | // Reopen tags that were closed before the code block. |
1171 | - if (!empty($inlineElements)) |
|
1172 | - $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
1210 | + if (!empty($inlineElements)) { |
|
1211 | + $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
1212 | + } |
|
1173 | 1213 | } |
1174 | 1214 | |
1175 | 1215 | // We're outside a coding and nobbc block and opening it. |
@@ -1198,8 +1238,9 @@ discard block |
||
1198 | 1238 | $inNoBbc = false; |
1199 | 1239 | |
1200 | 1240 | // Some inline elements might've been closed that need reopening. |
1201 | - if (!empty($inlineElements)) |
|
1202 | - $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
1241 | + if (!empty($inlineElements)) { |
|
1242 | + $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
1243 | + } |
|
1203 | 1244 | } |
1204 | 1245 | |
1205 | 1246 | // We're outside a nobbc and coding block and opening it. |
@@ -1219,8 +1260,9 @@ discard block |
||
1219 | 1260 | } |
1220 | 1261 | |
1221 | 1262 | // So, we're inside one of the special blocks: ignore any tag. |
1222 | - elseif ($inCode || $inNoBbc) |
|
1223 | - continue; |
|
1263 | + elseif ($inCode || $inNoBbc) { |
|
1264 | + continue; |
|
1265 | + } |
|
1224 | 1266 | |
1225 | 1267 | // We're dealing with an opening tag. |
1226 | 1268 | if ($isOpeningTag) |
@@ -1261,8 +1303,9 @@ discard block |
||
1261 | 1303 | if ($parts[$j + 3] === $tag) |
1262 | 1304 | { |
1263 | 1305 | // If it's an opening tag, increase the level. |
1264 | - if ($parts[$j + 2] === '') |
|
1265 | - $curLevel++; |
|
1306 | + if ($parts[$j + 2] === '') { |
|
1307 | + $curLevel++; |
|
1308 | + } |
|
1266 | 1309 | |
1267 | 1310 | // A closing tag, decrease the level. |
1268 | 1311 | else |
@@ -1285,13 +1328,15 @@ discard block |
||
1285 | 1328 | { |
1286 | 1329 | if ($isCompetingTag) |
1287 | 1330 | { |
1288 | - if (!isset($competingElements[$tag])) |
|
1289 | - $competingElements[$tag] = array(); |
|
1331 | + if (!isset($competingElements[$tag])) { |
|
1332 | + $competingElements[$tag] = array(); |
|
1333 | + } |
|
1290 | 1334 | |
1291 | 1335 | $competingElements[$tag][] = $parts[$i + 4]; |
1292 | 1336 | |
1293 | - if (count($competingElements[$tag]) > 1) |
|
1294 | - $parts[$i] .= '[/' . $tag . ']'; |
|
1337 | + if (count($competingElements[$tag]) > 1) { |
|
1338 | + $parts[$i] .= '[/' . $tag . ']'; |
|
1339 | + } |
|
1295 | 1340 | } |
1296 | 1341 | |
1297 | 1342 | $inlineElements[$elementContent] = $tag; |
@@ -1311,15 +1356,17 @@ discard block |
||
1311 | 1356 | $addClosingTags = array(); |
1312 | 1357 | while ($element = array_pop($blockElements)) |
1313 | 1358 | { |
1314 | - if ($element === $tag) |
|
1315 | - break; |
|
1359 | + if ($element === $tag) { |
|
1360 | + break; |
|
1361 | + } |
|
1316 | 1362 | |
1317 | 1363 | // Still a block tag was open not equal to this tag. |
1318 | 1364 | $addClosingTags[] = $element['type']; |
1319 | 1365 | } |
1320 | 1366 | |
1321 | - if (!empty($addClosingTags)) |
|
1322 | - $parts[$i + 1] = '[/' . implode('][/', array_reverse($addClosingTags)) . ']' . $parts[$i + 1]; |
|
1367 | + if (!empty($addClosingTags)) { |
|
1368 | + $parts[$i + 1] = '[/' . implode('][/', array_reverse($addClosingTags)) . ']' . $parts[$i + 1]; |
|
1369 | + } |
|
1323 | 1370 | |
1324 | 1371 | // Apparently the closing tag was not found on the stack. |
1325 | 1372 | if (!is_string($element) || $element !== $tag) |
@@ -1329,8 +1376,7 @@ discard block |
||
1329 | 1376 | $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
1330 | 1377 | continue; |
1331 | 1378 | } |
1332 | - } |
|
1333 | - else |
|
1379 | + } else |
|
1334 | 1380 | { |
1335 | 1381 | // Get rid of this closing tag! |
1336 | 1382 | $parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
@@ -1359,53 +1405,62 @@ discard block |
||
1359 | 1405 | unset($inlineElements[$tagContentToBeClosed]); |
1360 | 1406 | |
1361 | 1407 | // Was this the tag we were looking for? |
1362 | - if ($tagToBeClosed === $tag) |
|
1363 | - break; |
|
1408 | + if ($tagToBeClosed === $tag) { |
|
1409 | + break; |
|
1410 | + } |
|
1364 | 1411 | |
1365 | 1412 | // Nope, close it and look further! |
1366 | - else |
|
1367 | - $parts[$i] .= '[/' . $tagToBeClosed . ']'; |
|
1413 | + else { |
|
1414 | + $parts[$i] .= '[/' . $tagToBeClosed . ']'; |
|
1415 | + } |
|
1368 | 1416 | } |
1369 | 1417 | |
1370 | 1418 | if ($isCompetingTag && !empty($competingElements[$tag])) |
1371 | 1419 | { |
1372 | 1420 | array_pop($competingElements[$tag]); |
1373 | 1421 | |
1374 | - if (count($competingElements[$tag]) > 0) |
|
1375 | - $parts[$i + 5] = '[' . $tag . $competingElements[$tag][count($competingElements[$tag]) - 1] . $parts[$i + 5]; |
|
1422 | + if (count($competingElements[$tag]) > 0) { |
|
1423 | + $parts[$i + 5] = '[' . $tag . $competingElements[$tag][count($competingElements[$tag]) - 1] . $parts[$i + 5]; |
|
1424 | + } |
|
1376 | 1425 | } |
1377 | 1426 | } |
1378 | 1427 | |
1379 | 1428 | // Unexpected closing tag, ex-ter-mi-nate. |
1380 | - else |
|
1381 | - $parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
|
1429 | + else { |
|
1430 | + $parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
|
1431 | + } |
|
1382 | 1432 | } |
1383 | 1433 | } |
1384 | 1434 | } |
1385 | 1435 | |
1386 | 1436 | // Close the code tags. |
1387 | - if ($inCode) |
|
1388 | - $parts[$i] .= '[/code]'; |
|
1437 | + if ($inCode) { |
|
1438 | + $parts[$i] .= '[/code]'; |
|
1439 | + } |
|
1389 | 1440 | |
1390 | 1441 | // The same for nobbc tags. |
1391 | - elseif ($inNoBbc) |
|
1392 | - $parts[$i] .= '[/nobbc]'; |
|
1442 | + elseif ($inNoBbc) { |
|
1443 | + $parts[$i] .= '[/nobbc]'; |
|
1444 | + } |
|
1393 | 1445 | |
1394 | 1446 | // Still inline tags left unclosed? Close them now, better late than never. |
1395 | - elseif (!empty($inlineElements)) |
|
1396 | - $parts[$i] .= '[/' . implode('][/', array_reverse($inlineElements)) . ']'; |
|
1447 | + elseif (!empty($inlineElements)) { |
|
1448 | + $parts[$i] .= '[/' . implode('][/', array_reverse($inlineElements)) . ']'; |
|
1449 | + } |
|
1397 | 1450 | |
1398 | 1451 | // Now close the block elements. |
1399 | - if (!empty($blockElements)) |
|
1400 | - $parts[$i] .= '[/' . implode('][/', array_reverse($blockElements)) . ']'; |
|
1452 | + if (!empty($blockElements)) { |
|
1453 | + $parts[$i] .= '[/' . implode('][/', array_reverse($blockElements)) . ']'; |
|
1454 | + } |
|
1401 | 1455 | |
1402 | 1456 | $text = implode('', $parts); |
1403 | 1457 | } |
1404 | 1458 | |
1405 | 1459 | // Final clean up of back to back tags. |
1406 | 1460 | $lastlen = 0; |
1407 | - while (strlen($text) !== $lastlen) |
|
1408 | - $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
1461 | + while (strlen($text) !== $lastlen) { |
|
1462 | + $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
1463 | + } |
|
1409 | 1464 | |
1410 | 1465 | return $text; |
1411 | 1466 | } |
@@ -1434,22 +1489,25 @@ discard block |
||
1434 | 1489 | $context['template_layers'] = array(); |
1435 | 1490 | // Lets make sure we aren't going to output anything nasty. |
1436 | 1491 | @ob_end_clean(); |
1437 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
1438 | - @ob_start('ob_gzhandler'); |
|
1439 | - else |
|
1440 | - @ob_start(); |
|
1492 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
1493 | + @ob_start('ob_gzhandler'); |
|
1494 | + } else { |
|
1495 | + @ob_start(); |
|
1496 | + } |
|
1441 | 1497 | |
1442 | 1498 | // If we don't have any locale better avoid broken js |
1443 | - if (empty($txt['lang_locale'])) |
|
1444 | - die(); |
|
1499 | + if (empty($txt['lang_locale'])) { |
|
1500 | + die(); |
|
1501 | + } |
|
1445 | 1502 | |
1446 | 1503 | $file_data = '(function ($) { |
1447 | 1504 | \'use strict\'; |
1448 | 1505 | |
1449 | 1506 | $.sceditor.locale[' . JavaScriptEscape($txt['lang_locale']) . '] = {'; |
1450 | - foreach ($editortxt as $key => $val) |
|
1451 | - $file_data .= ' |
|
1507 | + foreach ($editortxt as $key => $val) { |
|
1508 | + $file_data .= ' |
|
1452 | 1509 | ' . JavaScriptEscape($key) . ': ' . JavaScriptEscape($val) . ','; |
1510 | + } |
|
1453 | 1511 | |
1454 | 1512 | $file_data .= ' |
1455 | 1513 | dateFormat: "day.month.year" |
@@ -1517,8 +1575,9 @@ discard block |
||
1517 | 1575 | ) |
1518 | 1576 | ); |
1519 | 1577 | $icon_data = array(); |
1520 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1521 | - $icon_data[] = $row; |
|
1578 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1579 | + $icon_data[] = $row; |
|
1580 | + } |
|
1522 | 1581 | $smcFunc['db_free_result']($request); |
1523 | 1582 | |
1524 | 1583 | $icons = array(); |
@@ -1533,9 +1592,9 @@ discard block |
||
1533 | 1592 | } |
1534 | 1593 | |
1535 | 1594 | cache_put_data('posting_icons-' . $board_id, $icons, 480); |
1595 | + } else { |
|
1596 | + $icons = $temp; |
|
1536 | 1597 | } |
1537 | - else |
|
1538 | - $icons = $temp; |
|
1539 | 1598 | } |
1540 | 1599 | call_integration_hook('integrate_load_message_icons', array(&$icons)); |
1541 | 1600 | |
@@ -1577,8 +1636,9 @@ discard block |
||
1577 | 1636 | { |
1578 | 1637 | // Some general stuff. |
1579 | 1638 | $settings['smileys_url'] = $modSettings['smileys_url'] . '/' . $user_info['smiley_set']; |
1580 | - if (!empty($context['drafts_autosave'])) |
|
1581 | - $context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000; |
|
1639 | + if (!empty($context['drafts_autosave'])) { |
|
1640 | + $context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000; |
|
1641 | + } |
|
1582 | 1642 | |
1583 | 1643 | // This really has some WYSIWYG stuff. |
1584 | 1644 | loadCSSFile('jquery.sceditor.css', array('force_current' => false, 'validate' => true), 'smf_jquery_sceditor'); |
@@ -1596,8 +1656,9 @@ discard block |
||
1596 | 1656 | var bbc_quote = \'' . addcslashes($txt['quote'], "'") . '\'; |
1597 | 1657 | var bbc_search_on = \'' . addcslashes($txt['search_on'], "'") . '\';'); |
1598 | 1658 | // editor language file |
1599 | - if (!empty($txt['lang_locale']) && $txt['lang_locale'] != 'en_US') |
|
1600 | - loadJavaScriptFile($scripturl . '?action=loadeditorlocale', array('external' => true), 'sceditor_language'); |
|
1659 | + if (!empty($txt['lang_locale']) && $txt['lang_locale'] != 'en_US') { |
|
1660 | + loadJavaScriptFile($scripturl . '?action=loadeditorlocale', array('external' => true), 'sceditor_language'); |
|
1661 | + } |
|
1601 | 1662 | |
1602 | 1663 | $context['shortcuts_text'] = $txt['shortcuts' . (!empty($context['drafts_save']) ? '_drafts' : '') . (stripos($_SERVER['HTTP_USER_AGENT'], 'Macintosh') !== false ? '_mac' : (isBrowser('is_firefox') ? '_firefox' : ''))]; |
1603 | 1664 | $context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && (function_exists('pspell_new') || (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv')))); |
@@ -1606,11 +1667,12 @@ discard block |
||
1606 | 1667 | loadJavaScriptFile('spellcheck.js', array('minimize' => true), 'smf_spellcheck'); |
1607 | 1668 | |
1608 | 1669 | // Some hidden information is needed in order to make the spell checking work. |
1609 | - if (!isset($_REQUEST['xml'])) |
|
1610 | - $context['insert_after_template'] .= ' |
|
1670 | + if (!isset($_REQUEST['xml'])) { |
|
1671 | + $context['insert_after_template'] .= ' |
|
1611 | 1672 | <form name="spell_form" id="spell_form" method="post" accept-charset="' . $context['character_set'] . '" target="spellWindow" action="' . $scripturl . '?action=spellcheck"> |
1612 | 1673 | <input type="hidden" name="spellstring" value=""> |
1613 | 1674 | </form>'; |
1675 | + } |
|
1614 | 1676 | } |
1615 | 1677 | } |
1616 | 1678 | |
@@ -1802,10 +1864,12 @@ discard block |
||
1802 | 1864 | |
1803 | 1865 | // Generate a list of buttons that shouldn't be shown - this should be the fastest way to do this. |
1804 | 1866 | $disabled_tags = array(); |
1805 | - if (!empty($modSettings['disabledBBC'])) |
|
1806 | - $disabled_tags = explode(',', $modSettings['disabledBBC']); |
|
1807 | - if (empty($modSettings['enableEmbeddedFlash'])) |
|
1808 | - $disabled_tags[] = 'flash'; |
|
1867 | + if (!empty($modSettings['disabledBBC'])) { |
|
1868 | + $disabled_tags = explode(',', $modSettings['disabledBBC']); |
|
1869 | + } |
|
1870 | + if (empty($modSettings['enableEmbeddedFlash'])) { |
|
1871 | + $disabled_tags[] = 'flash'; |
|
1872 | + } |
|
1809 | 1873 | |
1810 | 1874 | foreach ($disabled_tags as $tag) |
1811 | 1875 | { |
@@ -1817,9 +1881,10 @@ discard block |
||
1817 | 1881 | $context['disabled_tags']['orderedlist'] = true; |
1818 | 1882 | } |
1819 | 1883 | |
1820 | - foreach ($editor_tag_map as $thisTag => $tagNameBBC) |
|
1821 | - if ($tag === $thisTag) |
|
1884 | + foreach ($editor_tag_map as $thisTag => $tagNameBBC) { |
|
1885 | + if ($tag === $thisTag) |
|
1822 | 1886 | $context['disabled_tags'][$tagNameBBC] = true; |
1887 | + } |
|
1823 | 1888 | |
1824 | 1889 | $context['disabled_tags'][$tag] = true; |
1825 | 1890 | } |
@@ -1830,8 +1895,9 @@ discard block |
||
1830 | 1895 | |
1831 | 1896 | foreach ($context['bbc_tags'] as $row => $tagRow) |
1832 | 1897 | { |
1833 | - if (!isset($context['bbc_toolbar'][$row])) |
|
1834 | - $context['bbc_toolbar'][$row] = array(); |
|
1898 | + if (!isset($context['bbc_toolbar'][$row])) { |
|
1899 | + $context['bbc_toolbar'][$row] = array(); |
|
1900 | + } |
|
1835 | 1901 | |
1836 | 1902 | $tagsRow = array(); |
1837 | 1903 | |
@@ -1867,20 +1933,21 @@ discard block |
||
1867 | 1933 | |
1868 | 1934 | $context['bbcodes_handlers'] .= ' |
1869 | 1935 | });'; |
1870 | - } |
|
1871 | - else |
|
1936 | + } else |
|
1872 | 1937 | { |
1873 | 1938 | $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
1874 | 1939 | $tagsRow = array(); |
1875 | 1940 | } |
1876 | 1941 | } |
1877 | 1942 | |
1878 | - if (!empty($tagsRow)) |
|
1879 | - $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
|
1943 | + if (!empty($tagsRow)) { |
|
1944 | + $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
|
1945 | + } |
|
1880 | 1946 | } |
1881 | 1947 | |
1882 | - if (!empty($bbcodes_styles)) |
|
1883 | - addInlineCss($bbcodes_styles); |
|
1948 | + if (!empty($bbcodes_styles)) { |
|
1949 | + addInlineCss($bbcodes_styles); |
|
1950 | + } |
|
1884 | 1951 | } |
1885 | 1952 | |
1886 | 1953 | // Initialize smiley array... if not loaded before. |
@@ -1892,8 +1959,8 @@ discard block |
||
1892 | 1959 | ); |
1893 | 1960 | |
1894 | 1961 | // Load smileys - don't bother to run a query if we're not using the database's ones anyhow. |
1895 | - if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none') |
|
1896 | - $context['smileys']['postform'][] = array( |
|
1962 | + if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none') { |
|
1963 | + $context['smileys']['postform'][] = array( |
|
1897 | 1964 | 'smileys' => array( |
1898 | 1965 | array( |
1899 | 1966 | 'code' => ':)', |
@@ -1979,7 +2046,7 @@ discard block |
||
1979 | 2046 | ), |
1980 | 2047 | 'isLast' => true, |
1981 | 2048 | ); |
1982 | - elseif ($user_info['smiley_set'] != 'none') |
|
2049 | + } elseif ($user_info['smiley_set'] != 'none') |
|
1983 | 2050 | { |
1984 | 2051 | if (($temp = cache_get_data('posting_smileys', 480)) == null) |
1985 | 2052 | { |
@@ -2002,17 +2069,19 @@ discard block |
||
2002 | 2069 | |
2003 | 2070 | foreach ($context['smileys'] as $section => $smileyRows) |
2004 | 2071 | { |
2005 | - foreach ($smileyRows as $rowIndex => $smileys) |
|
2006 | - $context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true; |
|
2072 | + foreach ($smileyRows as $rowIndex => $smileys) { |
|
2073 | + $context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true; |
|
2074 | + } |
|
2007 | 2075 | |
2008 | - if (!empty($smileyRows)) |
|
2009 | - $context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true; |
|
2076 | + if (!empty($smileyRows)) { |
|
2077 | + $context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true; |
|
2078 | + } |
|
2010 | 2079 | } |
2011 | 2080 | |
2012 | 2081 | cache_put_data('posting_smileys', $context['smileys'], 480); |
2082 | + } else { |
|
2083 | + $context['smileys'] = $temp; |
|
2013 | 2084 | } |
2014 | - else |
|
2015 | - $context['smileys'] = $temp; |
|
2016 | 2085 | } |
2017 | 2086 | } |
2018 | 2087 | |
@@ -2028,12 +2097,15 @@ discard block |
||
2028 | 2097 | 'plugins' => 'undo', |
2029 | 2098 | 'bbcodeTrim' => true, |
2030 | 2099 | ); |
2031 | - if (!empty($context['controls']['richedit'][$editorOptions['id']]['locale'])) |
|
2032 | - $sce_options['locale'] = $context['controls']['richedit'][$editorOptions['id']]['locale']; |
|
2033 | - if (!empty($context['right_to_left'])) |
|
2034 | - $sce_options['rtl'] = true; |
|
2035 | - if ($editorOptions['id'] != 'quickReply') |
|
2036 | - $sce_options['autofocus'] = true; |
|
2100 | + if (!empty($context['controls']['richedit'][$editorOptions['id']]['locale'])) { |
|
2101 | + $sce_options['locale'] = $context['controls']['richedit'][$editorOptions['id']]['locale']; |
|
2102 | + } |
|
2103 | + if (!empty($context['right_to_left'])) { |
|
2104 | + $sce_options['rtl'] = true; |
|
2105 | + } |
|
2106 | + if ($editorOptions['id'] != 'quickReply') { |
|
2107 | + $sce_options['autofocus'] = true; |
|
2108 | + } |
|
2037 | 2109 | |
2038 | 2110 | $sce_options['emoticons'] = array(); |
2039 | 2111 | $sce_options['emoticonsDescriptions'] = array(); |
@@ -2050,10 +2122,11 @@ discard block |
||
2050 | 2122 | $countLocations--; |
2051 | 2123 | |
2052 | 2124 | unset($smiley_location); |
2053 | - if ($location == 'postform') |
|
2054 | - $smiley_location = &$sce_options['emoticons']['dropdown']; |
|
2055 | - elseif ($location == 'popup') |
|
2056 | - $smiley_location = &$sce_options['emoticons']['popup']; |
|
2125 | + if ($location == 'postform') { |
|
2126 | + $smiley_location = &$sce_options['emoticons']['dropdown']; |
|
2127 | + } elseif ($location == 'popup') { |
|
2128 | + $smiley_location = &$sce_options['emoticons']['popup']; |
|
2129 | + } |
|
2057 | 2130 | |
2058 | 2131 | $numRows = count($smileyRows); |
2059 | 2132 | |
@@ -2067,8 +2140,9 @@ discard block |
||
2067 | 2140 | $sce_options['emoticonsDescriptions'][$smiley['code']] = $smiley['description']; |
2068 | 2141 | } |
2069 | 2142 | |
2070 | - if (empty($smileyRow['isLast']) && $numRows != 1) |
|
2071 | - $smiley_location['-' . $emptyPlaceholder++] = ''; |
|
2143 | + if (empty($smileyRow['isLast']) && $numRows != 1) { |
|
2144 | + $smiley_location['-' . $emptyPlaceholder++] = ''; |
|
2145 | + } |
|
2072 | 2146 | } |
2073 | 2147 | } |
2074 | 2148 | } |
@@ -2083,8 +2157,9 @@ discard block |
||
2083 | 2157 | |
2084 | 2158 | $count_tags--; |
2085 | 2159 | |
2086 | - if (!empty($count_tags)) |
|
2087 | - $sce_options['toolbar'] .= '||'; |
|
2160 | + if (!empty($count_tags)) { |
|
2161 | + $sce_options['toolbar'] .= '||'; |
|
2162 | + } |
|
2088 | 2163 | } |
2089 | 2164 | } |
2090 | 2165 | |
@@ -2112,8 +2187,9 @@ discard block |
||
2112 | 2187 | loadTemplate('GenericControls'); |
2113 | 2188 | |
2114 | 2189 | // Some javascript ma'am? |
2115 | - if (!empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual']))) |
|
2116 | - loadJavaScriptFile('captcha.js', array('minimize' => true), 'smf_captcha'); |
|
2190 | + if (!empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual']))) { |
|
2191 | + loadJavaScriptFile('captcha.js', array('minimize' => true), 'smf_captcha'); |
|
2192 | + } |
|
2117 | 2193 | |
2118 | 2194 | $context['use_graphic_library'] = in_array('gd', get_loaded_extensions()); |
2119 | 2195 | |
@@ -2126,8 +2202,8 @@ discard block |
||
2126 | 2202 | $isNew = !isset($context['controls']['verification'][$verificationOptions['id']]); |
2127 | 2203 | |
2128 | 2204 | // Log this into our collection. |
2129 | - if ($isNew) |
|
2130 | - $context['controls']['verification'][$verificationOptions['id']] = array( |
|
2205 | + if ($isNew) { |
|
2206 | + $context['controls']['verification'][$verificationOptions['id']] = array( |
|
2131 | 2207 | 'id' => $verificationOptions['id'], |
2132 | 2208 | 'empty_field' => empty($verificationOptions['no_empty_field']), |
2133 | 2209 | 'show_visual' => !empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual'])), |
@@ -2138,13 +2214,15 @@ discard block |
||
2138 | 2214 | 'questions' => array(), |
2139 | 2215 | 'can_recaptcha' => !empty($modSettings['recaptcha_enabled']) && !empty($modSettings['recaptcha_site_key']) && !empty($modSettings['recaptcha_secret_key']), |
2140 | 2216 | ); |
2217 | + } |
|
2141 | 2218 | $thisVerification = &$context['controls']['verification'][$verificationOptions['id']]; |
2142 | 2219 | |
2143 | 2220 | // Is there actually going to be anything? |
2144 | - if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']) && empty($thisVerification['can_recaptcha'])) |
|
2145 | - return false; |
|
2146 | - elseif (!$isNew && !$do_test) |
|
2147 | - return true; |
|
2221 | + if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']) && empty($thisVerification['can_recaptcha'])) { |
|
2222 | + return false; |
|
2223 | + } elseif (!$isNew && !$do_test) { |
|
2224 | + return true; |
|
2225 | + } |
|
2148 | 2226 | |
2149 | 2227 | // Sanitize reCAPTCHA fields? |
2150 | 2228 | if ($thisVerification['can_recaptcha']) |
@@ -2157,11 +2235,12 @@ discard block |
||
2157 | 2235 | } |
2158 | 2236 | |
2159 | 2237 | // Add javascript for the object. |
2160 | - if ($context['controls']['verification'][$verificationOptions['id']]['show_visual']) |
|
2161 | - $context['insert_after_template'] .= ' |
|
2238 | + if ($context['controls']['verification'][$verificationOptions['id']]['show_visual']) { |
|
2239 | + $context['insert_after_template'] .= ' |
|
2162 | 2240 | <script> |
2163 | 2241 | var verification' . $verificationOptions['id'] . 'Handle = new smfCaptcha("' . $thisVerification['image_href'] . '", "' . $verificationOptions['id'] . '", ' . ($context['use_graphic_library'] ? 1 : 0) . '); |
2164 | 2242 | </script>'; |
2243 | + } |
|
2165 | 2244 | |
2166 | 2245 | // If we want questions do we have a cache of all the IDs? |
2167 | 2246 | if (!empty($thisVerification['number_questions']) && empty($modSettings['question_id_cache'])) |
@@ -2184,8 +2263,9 @@ discard block |
||
2184 | 2263 | unset ($row['id_question']); |
2185 | 2264 | // Make them all lowercase. We can't directly use $smcFunc['strtolower'] with array_walk, so do it manually, eh? |
2186 | 2265 | $row['answers'] = $smcFunc['json_decode']($row['answers'], true); |
2187 | - foreach ($row['answers'] as $k => $v) |
|
2188 | - $row['answers'][$k] = $smcFunc['strtolower']($v); |
|
2266 | + foreach ($row['answers'] as $k => $v) { |
|
2267 | + $row['answers'][$k] = $smcFunc['strtolower']($v); |
|
2268 | + } |
|
2189 | 2269 | |
2190 | 2270 | $modSettings['question_id_cache']['questions'][$id_question] = $row; |
2191 | 2271 | $modSettings['question_id_cache']['langs'][$row['lngfile']][] = $id_question; |
@@ -2196,35 +2276,42 @@ discard block |
||
2196 | 2276 | } |
2197 | 2277 | } |
2198 | 2278 | |
2199 | - if (!isset($_SESSION[$verificationOptions['id'] . '_vv'])) |
|
2200 | - $_SESSION[$verificationOptions['id'] . '_vv'] = array(); |
|
2279 | + if (!isset($_SESSION[$verificationOptions['id'] . '_vv'])) { |
|
2280 | + $_SESSION[$verificationOptions['id'] . '_vv'] = array(); |
|
2281 | + } |
|
2201 | 2282 | |
2202 | 2283 | // Do we need to refresh the verification? |
2203 | - if (!$do_test && (!empty($_SESSION[$verificationOptions['id'] . '_vv']['did_pass']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) || $_SESSION[$verificationOptions['id'] . '_vv']['count'] > 3) && empty($verificationOptions['dont_refresh'])) |
|
2204 | - $force_refresh = true; |
|
2205 | - else |
|
2206 | - $force_refresh = false; |
|
2284 | + if (!$do_test && (!empty($_SESSION[$verificationOptions['id'] . '_vv']['did_pass']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) || $_SESSION[$verificationOptions['id'] . '_vv']['count'] > 3) && empty($verificationOptions['dont_refresh'])) { |
|
2285 | + $force_refresh = true; |
|
2286 | + } else { |
|
2287 | + $force_refresh = false; |
|
2288 | + } |
|
2207 | 2289 | |
2208 | 2290 | // This can also force a fresh, although unlikely. |
2209 | - if (($thisVerification['show_visual'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['code'])) || ($thisVerification['number_questions'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['q']))) |
|
2210 | - $force_refresh = true; |
|
2291 | + if (($thisVerification['show_visual'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['code'])) || ($thisVerification['number_questions'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['q']))) { |
|
2292 | + $force_refresh = true; |
|
2293 | + } |
|
2211 | 2294 | |
2212 | 2295 | $verification_errors = array(); |
2213 | 2296 | // Start with any testing. |
2214 | 2297 | if ($do_test) |
2215 | 2298 | { |
2216 | 2299 | // This cannot happen! |
2217 | - if (!isset($_SESSION[$verificationOptions['id'] . '_vv']['count'])) |
|
2218 | - fatal_lang_error('no_access', false); |
|
2300 | + if (!isset($_SESSION[$verificationOptions['id'] . '_vv']['count'])) { |
|
2301 | + fatal_lang_error('no_access', false); |
|
2302 | + } |
|
2219 | 2303 | // ... nor this! |
2220 | - if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q']))) |
|
2221 | - fatal_lang_error('no_access', false); |
|
2304 | + if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q']))) { |
|
2305 | + fatal_lang_error('no_access', false); |
|
2306 | + } |
|
2222 | 2307 | // Hmm, it's requested but not actually declared. This shouldn't happen. |
2223 | - if ($thisVerification['empty_field'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) |
|
2224 | - fatal_lang_error('no_access', false); |
|
2308 | + if ($thisVerification['empty_field'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) { |
|
2309 | + fatal_lang_error('no_access', false); |
|
2310 | + } |
|
2225 | 2311 | // While we're here, did the user do something bad? |
2226 | - if ($thisVerification['empty_field'] && !empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']) && !empty($_REQUEST[$_SESSION[$verificationOptions['id'] . '_vv']['empty_field']])) |
|
2227 | - $verification_errors[] = 'wrong_verification_answer'; |
|
2312 | + if ($thisVerification['empty_field'] && !empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']) && !empty($_REQUEST[$_SESSION[$verificationOptions['id'] . '_vv']['empty_field']])) { |
|
2313 | + $verification_errors[] = 'wrong_verification_answer'; |
|
2314 | + } |
|
2228 | 2315 | |
2229 | 2316 | if ($thisVerification['can_recaptcha']) |
2230 | 2317 | { |
@@ -2235,22 +2322,25 @@ discard block |
||
2235 | 2322 | { |
2236 | 2323 | $resp = $reCaptcha->verify($_POST['g-recaptcha-response'], $user_info['ip']); |
2237 | 2324 | |
2238 | - if (!$resp->isSuccess()) |
|
2239 | - $verification_errors[] = 'wrong_verification_code'; |
|
2325 | + if (!$resp->isSuccess()) { |
|
2326 | + $verification_errors[] = 'wrong_verification_code'; |
|
2327 | + } |
|
2328 | + } else { |
|
2329 | + $verification_errors[] = 'wrong_verification_code'; |
|
2240 | 2330 | } |
2241 | - else |
|
2242 | - $verification_errors[] = 'wrong_verification_code'; |
|
2243 | 2331 | } |
2244 | - if ($thisVerification['show_visual'] && (empty($_REQUEST[$verificationOptions['id'] . '_vv']['code']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['code']) || strtoupper($_REQUEST[$verificationOptions['id'] . '_vv']['code']) !== $_SESSION[$verificationOptions['id'] . '_vv']['code'])) |
|
2245 | - $verification_errors[] = 'wrong_verification_code'; |
|
2332 | + if ($thisVerification['show_visual'] && (empty($_REQUEST[$verificationOptions['id'] . '_vv']['code']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['code']) || strtoupper($_REQUEST[$verificationOptions['id'] . '_vv']['code']) !== $_SESSION[$verificationOptions['id'] . '_vv']['code'])) { |
|
2333 | + $verification_errors[] = 'wrong_verification_code'; |
|
2334 | + } |
|
2246 | 2335 | if ($thisVerification['number_questions']) |
2247 | 2336 | { |
2248 | 2337 | $incorrectQuestions = array(); |
2249 | 2338 | foreach ($_SESSION[$verificationOptions['id'] . '_vv']['q'] as $q) |
2250 | 2339 | { |
2251 | 2340 | // We don't have this question any more, thus no answers. |
2252 | - if (!isset($modSettings['question_id_cache']['questions'][$q])) |
|
2253 | - continue; |
|
2341 | + if (!isset($modSettings['question_id_cache']['questions'][$q])) { |
|
2342 | + continue; |
|
2343 | + } |
|
2254 | 2344 | // This is quite complex. We have our question but it might have multiple answers. |
2255 | 2345 | // First, did they actually answer this question? |
2256 | 2346 | if (!isset($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) || trim($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) == '') |
@@ -2262,24 +2352,28 @@ discard block |
||
2262 | 2352 | else |
2263 | 2353 | { |
2264 | 2354 | $given_answer = trim($smcFunc['htmlspecialchars'](strtolower($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]))); |
2265 | - if (!in_array($given_answer, $modSettings['question_id_cache']['questions'][$q]['answers'])) |
|
2266 | - $incorrectQuestions[] = $q; |
|
2355 | + if (!in_array($given_answer, $modSettings['question_id_cache']['questions'][$q]['answers'])) { |
|
2356 | + $incorrectQuestions[] = $q; |
|
2357 | + } |
|
2267 | 2358 | } |
2268 | 2359 | } |
2269 | 2360 | |
2270 | - if (!empty($incorrectQuestions)) |
|
2271 | - $verification_errors[] = 'wrong_verification_answer'; |
|
2361 | + if (!empty($incorrectQuestions)) { |
|
2362 | + $verification_errors[] = 'wrong_verification_answer'; |
|
2363 | + } |
|
2272 | 2364 | } |
2273 | 2365 | } |
2274 | 2366 | |
2275 | 2367 | // Any errors means we refresh potentially. |
2276 | 2368 | if (!empty($verification_errors)) |
2277 | 2369 | { |
2278 | - if (empty($_SESSION[$verificationOptions['id'] . '_vv']['errors'])) |
|
2279 | - $_SESSION[$verificationOptions['id'] . '_vv']['errors'] = 0; |
|
2370 | + if (empty($_SESSION[$verificationOptions['id'] . '_vv']['errors'])) { |
|
2371 | + $_SESSION[$verificationOptions['id'] . '_vv']['errors'] = 0; |
|
2372 | + } |
|
2280 | 2373 | // Too many errors? |
2281 | - elseif ($_SESSION[$verificationOptions['id'] . '_vv']['errors'] > $thisVerification['max_errors']) |
|
2282 | - $force_refresh = true; |
|
2374 | + elseif ($_SESSION[$verificationOptions['id'] . '_vv']['errors'] > $thisVerification['max_errors']) { |
|
2375 | + $force_refresh = true; |
|
2376 | + } |
|
2283 | 2377 | |
2284 | 2378 | // Keep a track of these. |
2285 | 2379 | $_SESSION[$verificationOptions['id'] . '_vv']['errors']++; |
@@ -2312,8 +2406,9 @@ discard block |
||
2312 | 2406 | // Are we overriding the range? |
2313 | 2407 | $character_range = !empty($verificationOptions['override_range']) ? $verificationOptions['override_range'] : $context['standard_captcha_range']; |
2314 | 2408 | |
2315 | - for ($i = 0; $i < 6; $i++) |
|
2316 | - $_SESSION[$verificationOptions['id'] . '_vv']['code'] .= $character_range[array_rand($character_range)]; |
|
2409 | + for ($i = 0; $i < 6; $i++) { |
|
2410 | + $_SESSION[$verificationOptions['id'] . '_vv']['code'] .= $character_range[array_rand($character_range)]; |
|
2411 | + } |
|
2317 | 2412 | } |
2318 | 2413 | |
2319 | 2414 | // Getting some new questions? |
@@ -2321,8 +2416,9 @@ discard block |
||
2321 | 2416 | { |
2322 | 2417 | // Attempt to try the current page's language, followed by the user's preference, followed by the site default. |
2323 | 2418 | $possible_langs = array(); |
2324 | - if (isset($_SESSION['language'])) |
|
2325 | - $possible_langs[] = strtr($_SESSION['language'], array('-utf8' => '')); |
|
2419 | + if (isset($_SESSION['language'])) { |
|
2420 | + $possible_langs[] = strtr($_SESSION['language'], array('-utf8' => '')); |
|
2421 | + } |
|
2326 | 2422 | if (!empty($user_info['language'])); |
2327 | 2423 | $possible_langs[] = $user_info['language']; |
2328 | 2424 | $possible_langs[] = $language; |
@@ -2341,8 +2437,7 @@ discard block |
||
2341 | 2437 | } |
2342 | 2438 | } |
2343 | 2439 | } |
2344 | - } |
|
2345 | - else |
|
2440 | + } else |
|
2346 | 2441 | { |
2347 | 2442 | // Same questions as before. |
2348 | 2443 | $questionIDs = !empty($_SESSION[$verificationOptions['id'] . '_vv']['q']) ? $_SESSION[$verificationOptions['id'] . '_vv']['q'] : array(); |
@@ -2352,8 +2447,9 @@ discard block |
||
2352 | 2447 | // If we do have an empty field, it would be nice to hide it from legitimate users who shouldn't be populating it anyway. |
2353 | 2448 | if (!empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) |
2354 | 2449 | { |
2355 | - if (!isset($context['html_headers'])) |
|
2356 | - $context['html_headers'] = ''; |
|
2450 | + if (!isset($context['html_headers'])) { |
|
2451 | + $context['html_headers'] = ''; |
|
2452 | + } |
|
2357 | 2453 | $context['html_headers'] .= '<style>.vv_special { display:none; }</style>'; |
2358 | 2454 | } |
2359 | 2455 | |
@@ -2379,11 +2475,13 @@ discard block |
||
2379 | 2475 | $_SESSION[$verificationOptions['id'] . '_vv']['count'] = empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) ? 1 : $_SESSION[$verificationOptions['id'] . '_vv']['count'] + 1; |
2380 | 2476 | |
2381 | 2477 | // Return errors if we have them. |
2382 | - if (!empty($verification_errors)) |
|
2383 | - return $verification_errors; |
|
2478 | + if (!empty($verification_errors)) { |
|
2479 | + return $verification_errors; |
|
2480 | + } |
|
2384 | 2481 | // If we had a test that one, make a note. |
2385 | - elseif ($do_test) |
|
2386 | - $_SESSION[$verificationOptions['id'] . '_vv']['did_pass'] = true; |
|
2482 | + elseif ($do_test) { |
|
2483 | + $_SESSION[$verificationOptions['id'] . '_vv']['did_pass'] = true; |
|
2484 | + } |
|
2387 | 2485 | |
2388 | 2486 | // Say that everything went well chaps. |
2389 | 2487 | return true; |
@@ -2408,8 +2506,9 @@ discard block |
||
2408 | 2506 | call_integration_hook('integrate_autosuggest', array(&$searchTypes)); |
2409 | 2507 | |
2410 | 2508 | // If we're just checking the callback function is registered return true or false. |
2411 | - if ($checkRegistered != null) |
|
2412 | - return isset($searchTypes[$checkRegistered]) && function_exists('AutoSuggest_Search_' . $checkRegistered); |
|
2509 | + if ($checkRegistered != null) { |
|
2510 | + return isset($searchTypes[$checkRegistered]) && function_exists('AutoSuggest_Search_' . $checkRegistered); |
|
2511 | + } |
|
2413 | 2512 | |
2414 | 2513 | checkSession('get'); |
2415 | 2514 | loadTemplate('Xml'); |
@@ -2560,24 +2659,27 @@ discard block |
||
2560 | 2659 | foreach ($possible_versions as $ver) |
2561 | 2660 | { |
2562 | 2661 | $ver = trim($ver); |
2563 | - if (strpos($ver, 'SMF') === 0) |
|
2564 | - $versions[] = $ver; |
|
2662 | + if (strpos($ver, 'SMF') === 0) { |
|
2663 | + $versions[] = $ver; |
|
2664 | + } |
|
2565 | 2665 | } |
2566 | 2666 | } |
2567 | 2667 | $smcFunc['db_free_result']($request); |
2568 | 2668 | |
2569 | 2669 | // Just in case we don't have ANYthing. |
2570 | - if (empty($versions)) |
|
2571 | - $versions = array('SMF 2.0'); |
|
2670 | + if (empty($versions)) { |
|
2671 | + $versions = array('SMF 2.0'); |
|
2672 | + } |
|
2572 | 2673 | |
2573 | - foreach ($versions as $id => $version) |
|
2574 | - if (strpos($version, strtoupper($_REQUEST['search'])) !== false) |
|
2674 | + foreach ($versions as $id => $version) { |
|
2675 | + if (strpos($version, strtoupper($_REQUEST['search'])) !== false) |
|
2575 | 2676 | $xml_data['items']['children'][] = array( |
2576 | 2677 | 'attributes' => array( |
2577 | 2678 | 'id' => $id, |
2578 | 2679 | ), |
2579 | 2680 | 'value' => $version, |
2580 | 2681 | ); |
2682 | + } |
|
2581 | 2683 | |
2582 | 2684 | return $xml_data; |
2583 | 2685 | } |
@@ -15,8 +15,9 @@ discard block |
||
15 | 15 | * @version 2.1 Beta 4 |
16 | 16 | */ |
17 | 17 | |
18 | -if (!defined('SMF')) |
|
18 | +if (!defined('SMF')) { |
|
19 | 19 | die('No direct access...'); |
20 | +} |
|
20 | 21 | |
21 | 22 | /** |
22 | 23 | * Log an error, if the error logging is enabled. |
@@ -39,10 +40,11 @@ discard block |
||
39 | 40 | $error_call++; |
40 | 41 | |
41 | 42 | // Collect a backtrace |
42 | - if (!isset($db_show_debug) || $db_show_debug === false) |
|
43 | - $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); |
|
44 | - else |
|
45 | - $backtrace = debug_backtrace(); |
|
43 | + if (!isset($db_show_debug) || $db_show_debug === false) { |
|
44 | + $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); |
|
45 | + } else { |
|
46 | + $backtrace = debug_backtrace(); |
|
47 | + } |
|
46 | 48 | |
47 | 49 | // are we in a loop? |
48 | 50 | if($error_call > 2) |
@@ -52,8 +54,9 @@ discard block |
||
52 | 54 | } |
53 | 55 | |
54 | 56 | // Check if error logging is actually on. |
55 | - if (empty($modSettings['enableErrorLogging'])) |
|
56 | - return $error_message; |
|
57 | + if (empty($modSettings['enableErrorLogging'])) { |
|
58 | + return $error_message; |
|
59 | + } |
|
57 | 60 | |
58 | 61 | // Basically, htmlspecialchars it minus &. (for entities!) |
59 | 62 | $error_message = strtr($error_message, array('<' => '<', '>' => '>', '"' => '"')); |
@@ -61,33 +64,39 @@ discard block |
||
61 | 64 | |
62 | 65 | // Add a file and line to the error message? |
63 | 66 | // Don't use the actual txt entries for file and line but instead use %1$s for file and %2$s for line |
64 | - if ($file == null) |
|
65 | - $file = ''; |
|
66 | - else |
|
67 | - // Window style slashes don't play well, lets convert them to the unix style. |
|
67 | + if ($file == null) { |
|
68 | + $file = ''; |
|
69 | + } else { |
|
70 | + // Window style slashes don't play well, lets convert them to the unix style. |
|
68 | 71 | $file = str_replace('\\', '/', $file); |
72 | + } |
|
69 | 73 | |
70 | - if ($line == null) |
|
71 | - $line = 0; |
|
72 | - else |
|
73 | - $line = (int) $line; |
|
74 | + if ($line == null) { |
|
75 | + $line = 0; |
|
76 | + } else { |
|
77 | + $line = (int) $line; |
|
78 | + } |
|
74 | 79 | |
75 | 80 | // Just in case there's no id_member or IP set yet. |
76 | - if (empty($user_info['id'])) |
|
77 | - $user_info['id'] = 0; |
|
78 | - if (empty($user_info['ip'])) |
|
79 | - $user_info['ip'] = ''; |
|
81 | + if (empty($user_info['id'])) { |
|
82 | + $user_info['id'] = 0; |
|
83 | + } |
|
84 | + if (empty($user_info['ip'])) { |
|
85 | + $user_info['ip'] = ''; |
|
86 | + } |
|
80 | 87 | |
81 | 88 | // Find the best query string we can... |
82 | 89 | $query_string = empty($_SERVER['QUERY_STRING']) ? (empty($_SERVER['REQUEST_URL']) ? '' : str_replace($scripturl, '', $_SERVER['REQUEST_URL'])) : $_SERVER['QUERY_STRING']; |
83 | 90 | |
84 | 91 | // Don't log the session hash in the url twice, it's a waste. |
85 | - if (!empty($smcFunc['htmlspecialchars'])) |
|
86 | - $query_string = $smcFunc['htmlspecialchars']((SMF == 'SSI' || SMF == 'BACKGROUND' ? '' : '?') . preg_replace(array('~;sesc=[^&;]+~', '~' . session_name() . '=' . session_id() . '[&;]~'), array(';sesc', ''), $query_string)); |
|
92 | + if (!empty($smcFunc['htmlspecialchars'])) { |
|
93 | + $query_string = $smcFunc['htmlspecialchars']((SMF == 'SSI' || SMF == 'BACKGROUND' ? '' : '?') . preg_replace(array('~;sesc=[^&;]+~', '~' . session_name() . '=' . session_id() . '[&;]~'), array(';sesc', ''), $query_string)); |
|
94 | + } |
|
87 | 95 | |
88 | 96 | // Just so we know what board error messages are from. |
89 | - if (isset($_POST['board']) && !isset($_GET['board'])) |
|
90 | - $query_string .= ($query_string == '' ? 'board=' : ';board=') . $_POST['board']; |
|
97 | + if (isset($_POST['board']) && !isset($_GET['board'])) { |
|
98 | + $query_string .= ($query_string == '' ? 'board=' : ';board=') . $_POST['board']; |
|
99 | + } |
|
91 | 100 | |
92 | 101 | // What types of categories do we have? |
93 | 102 | $known_error_types = array( |
@@ -140,9 +149,9 @@ discard block |
||
140 | 149 | |
141 | 150 | list($context['num_errors']) = $smcFunc['db_fetch_row']($query); |
142 | 151 | $smcFunc['db_free_result']($query); |
152 | + } else { |
|
153 | + $context['num_errors']++; |
|
143 | 154 | } |
144 | - else |
|
145 | - $context['num_errors']++; |
|
146 | 155 | } |
147 | 156 | |
148 | 157 | // reset error call |
@@ -164,12 +173,14 @@ discard block |
||
164 | 173 | global $txt; |
165 | 174 | |
166 | 175 | // Send the appropriate HTTP status header - set this to 0 or false if you don't want to send one at all |
167 | - if (!empty($status)) |
|
168 | - send_http_status($status); |
|
176 | + if (!empty($status)) { |
|
177 | + send_http_status($status); |
|
178 | + } |
|
169 | 179 | |
170 | 180 | // We don't have $txt yet, but that's okay... |
171 | - if (empty($txt)) |
|
172 | - die($error); |
|
181 | + if (empty($txt)) { |
|
182 | + die($error); |
|
183 | + } |
|
173 | 184 | |
174 | 185 | log_error_online($error, false); |
175 | 186 | setup_fatal_error_context($log ? log_error($error, $log) : $error); |
@@ -196,8 +207,9 @@ discard block |
||
196 | 207 | static $fatal_error_called = false; |
197 | 208 | |
198 | 209 | // Send the status header - set this to 0 or false if you don't want to send one at all |
199 | - if (!empty($status)) |
|
200 | - send_http_status($status); |
|
210 | + if (!empty($status)) { |
|
211 | + send_http_status($status); |
|
212 | + } |
|
201 | 213 | |
202 | 214 | // Try to load a theme if we don't have one. |
203 | 215 | if (empty($context['theme_loaded']) && empty($fatal_error_called)) |
@@ -207,8 +219,9 @@ discard block |
||
207 | 219 | } |
208 | 220 | |
209 | 221 | // If we have no theme stuff we can't have the language file... |
210 | - if (empty($context['theme_loaded'])) |
|
211 | - die($error); |
|
222 | + if (empty($context['theme_loaded'])) { |
|
223 | + die($error); |
|
224 | + } |
|
212 | 225 | |
213 | 226 | $reload_lang_file = true; |
214 | 227 | // Log the error in the forum's language, but don't waste the time if we aren't logging |
@@ -244,8 +257,9 @@ discard block |
||
244 | 257 | global $settings, $modSettings, $db_show_debug; |
245 | 258 | |
246 | 259 | // Ignore errors if we're ignoring them or they are strict notices from PHP 5 |
247 | - if (error_reporting() == 0) |
|
248 | - return; |
|
260 | + if (error_reporting() == 0) { |
|
261 | + return; |
|
262 | + } |
|
249 | 263 | |
250 | 264 | if (strpos($file, 'eval()') !== false && !empty($settings['current_include_filename'])) |
251 | 265 | { |
@@ -253,19 +267,22 @@ discard block |
||
253 | 267 | $count = count($array); |
254 | 268 | for ($i = 0; $i < $count; $i++) |
255 | 269 | { |
256 | - if ($array[$i]['function'] != 'loadSubTemplate') |
|
257 | - continue; |
|
270 | + if ($array[$i]['function'] != 'loadSubTemplate') { |
|
271 | + continue; |
|
272 | + } |
|
258 | 273 | |
259 | 274 | // This is a bug in PHP, with eval, it seems! |
260 | - if (empty($array[$i]['args'])) |
|
261 | - $i++; |
|
275 | + if (empty($array[$i]['args'])) { |
|
276 | + $i++; |
|
277 | + } |
|
262 | 278 | break; |
263 | 279 | } |
264 | 280 | |
265 | - if (isset($array[$i]) && !empty($array[$i]['args'])) |
|
266 | - $file = realpath($settings['current_include_filename']) . ' (' . $array[$i]['args'][0] . ' sub template - eval?)'; |
|
267 | - else |
|
268 | - $file = realpath($settings['current_include_filename']) . ' (eval?)'; |
|
281 | + if (isset($array[$i]) && !empty($array[$i]['args'])) { |
|
282 | + $file = realpath($settings['current_include_filename']) . ' (' . $array[$i]['args'][0] . ' sub template - eval?)'; |
|
283 | + } else { |
|
284 | + $file = realpath($settings['current_include_filename']) . ' (eval?)'; |
|
285 | + } |
|
269 | 286 | } |
270 | 287 | |
271 | 288 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -274,8 +291,9 @@ discard block |
||
274 | 291 | if ($error_level % 255 != E_ERROR) |
275 | 292 | { |
276 | 293 | $temporary = ob_get_contents(); |
277 | - if (substr($temporary, -2) == '="') |
|
278 | - echo '"'; |
|
294 | + if (substr($temporary, -2) == '="') { |
|
295 | + echo '"'; |
|
296 | + } |
|
279 | 297 | } |
280 | 298 | |
281 | 299 | // Debugging! This should look like a PHP error message. |
@@ -291,23 +309,27 @@ discard block |
||
291 | 309 | call_integration_hook('integrate_output_error', array($message, $error_type, $error_level, $file, $line)); |
292 | 310 | |
293 | 311 | // Dying on these errors only causes MORE problems (blank pages!) |
294 | - if ($file == 'Unknown') |
|
295 | - return; |
|
312 | + if ($file == 'Unknown') { |
|
313 | + return; |
|
314 | + } |
|
296 | 315 | |
297 | 316 | // If this is an E_ERROR or E_USER_ERROR.... die. Violently so. |
298 | - if ($error_level % 255 == E_ERROR) |
|
299 | - obExit(false); |
|
300 | - else |
|
301 | - return; |
|
317 | + if ($error_level % 255 == E_ERROR) { |
|
318 | + obExit(false); |
|
319 | + } else { |
|
320 | + return; |
|
321 | + } |
|
302 | 322 | |
303 | 323 | // If this is an E_ERROR, E_USER_ERROR, E_WARNING, or E_USER_WARNING.... die. Violently so. |
304 | - if ($error_level % 255 == E_ERROR || $error_level % 255 == E_WARNING) |
|
305 | - fatal_error(allowedTo('admin_forum') ? $message : $error_string, false); |
|
324 | + if ($error_level % 255 == E_ERROR || $error_level % 255 == E_WARNING) { |
|
325 | + fatal_error(allowedTo('admin_forum') ? $message : $error_string, false); |
|
326 | + } |
|
306 | 327 | |
307 | 328 | // We should NEVER get to this point. Any fatal error MUST quit, or very bad things can happen. |
308 | - if ($error_level % 255 == E_ERROR) |
|
309 | - die('No direct access...'); |
|
310 | -} |
|
329 | + if ($error_level % 255 == E_ERROR) { |
|
330 | + die('No direct access...'); |
|
331 | + } |
|
332 | + } |
|
311 | 333 | |
312 | 334 | /** |
313 | 335 | * It is called by {@link fatal_error()} and {@link fatal_lang_error()}. |
@@ -323,24 +345,28 @@ discard block |
||
323 | 345 | |
324 | 346 | // Attempt to prevent a recursive loop. |
325 | 347 | ++$level; |
326 | - if ($level > 1) |
|
327 | - return false; |
|
348 | + if ($level > 1) { |
|
349 | + return false; |
|
350 | + } |
|
328 | 351 | |
329 | 352 | // Maybe they came from dlattach or similar? |
330 | - if (SMF != 'SSI' && SMF != 'BACKGROUND' && empty($context['theme_loaded'])) |
|
331 | - loadTheme(); |
|
353 | + if (SMF != 'SSI' && SMF != 'BACKGROUND' && empty($context['theme_loaded'])) { |
|
354 | + loadTheme(); |
|
355 | + } |
|
332 | 356 | |
333 | 357 | // Don't bother indexing errors mate... |
334 | 358 | $context['robot_no_index'] = true; |
335 | 359 | |
336 | - if (!isset($context['error_title'])) |
|
337 | - $context['error_title'] = $txt['error_occured']; |
|
360 | + if (!isset($context['error_title'])) { |
|
361 | + $context['error_title'] = $txt['error_occured']; |
|
362 | + } |
|
338 | 363 | $context['error_message'] = isset($context['error_message']) ? $context['error_message'] : $error_message; |
339 | 364 | |
340 | 365 | $context['error_code'] = isset($error_code) ? 'id="' . $error_code . '" ' : ''; |
341 | 366 | |
342 | - if (empty($context['page_title'])) |
|
343 | - $context['page_title'] = $context['error_title']; |
|
367 | + if (empty($context['page_title'])) { |
|
368 | + $context['page_title'] = $context['error_title']; |
|
369 | + } |
|
344 | 370 | |
345 | 371 | loadTemplate('Errors'); |
346 | 372 | $context['sub_template'] = 'fatal_error'; |
@@ -348,23 +374,26 @@ discard block |
||
348 | 374 | // If this is SSI, what do they want us to do? |
349 | 375 | if (SMF == 'SSI') |
350 | 376 | { |
351 | - if (!empty($ssi_on_error_method) && $ssi_on_error_method !== true && is_callable($ssi_on_error_method)) |
|
352 | - $ssi_on_error_method(); |
|
353 | - elseif (empty($ssi_on_error_method) || $ssi_on_error_method !== true) |
|
354 | - loadSubTemplate('fatal_error'); |
|
377 | + if (!empty($ssi_on_error_method) && $ssi_on_error_method !== true && is_callable($ssi_on_error_method)) { |
|
378 | + $ssi_on_error_method(); |
|
379 | + } elseif (empty($ssi_on_error_method) || $ssi_on_error_method !== true) { |
|
380 | + loadSubTemplate('fatal_error'); |
|
381 | + } |
|
355 | 382 | |
356 | 383 | // No layers? |
357 | - if (empty($ssi_on_error_method) || $ssi_on_error_method !== true) |
|
358 | - exit; |
|
384 | + if (empty($ssi_on_error_method) || $ssi_on_error_method !== true) { |
|
385 | + exit; |
|
386 | + } |
|
359 | 387 | } |
360 | 388 | // Alternatively from the cron call? |
361 | 389 | elseif (SMF == 'BACKGROUND') |
362 | 390 | { |
363 | 391 | // We can't rely on even having language files available. |
364 | - if (defined('FROM_CLI') && FROM_CLI) |
|
365 | - echo 'cron error: ', $context['error_message']; |
|
366 | - else |
|
367 | - echo 'An error occurred. More information may be available in your logs.'; |
|
392 | + if (defined('FROM_CLI') && FROM_CLI) { |
|
393 | + echo 'cron error: ', $context['error_message']; |
|
394 | + } else { |
|
395 | + echo 'An error occurred. More information may be available in your logs.'; |
|
396 | + } |
|
368 | 397 | exit; |
369 | 398 | } |
370 | 399 | |
@@ -392,8 +421,8 @@ discard block |
||
392 | 421 | |
393 | 422 | set_fatal_error_headers(); |
394 | 423 | |
395 | - if (!empty($maintenance)) |
|
396 | - echo '<!DOCTYPE html> |
|
424 | + if (!empty($maintenance)) { |
|
425 | + echo '<!DOCTYPE html> |
|
397 | 426 | <html> |
398 | 427 | <head> |
399 | 428 | <meta name="robots" content="noindex"> |
@@ -404,6 +433,7 @@ discard block |
||
404 | 433 | ', $mmessage, ' |
405 | 434 | </body> |
406 | 435 | </html>'; |
436 | + } |
|
407 | 437 | |
408 | 438 | die(); |
409 | 439 | } |
@@ -425,15 +455,17 @@ discard block |
||
425 | 455 | // For our purposes, we're gonna want this on if at all possible. |
426 | 456 | $modSettings['cache_enable'] = '1'; |
427 | 457 | |
428 | - if (($temp = cache_get_data('db_last_error', 600)) !== null) |
|
429 | - $db_last_error = max($db_last_error, $temp); |
|
458 | + if (($temp = cache_get_data('db_last_error', 600)) !== null) { |
|
459 | + $db_last_error = max($db_last_error, $temp); |
|
460 | + } |
|
430 | 461 | |
431 | 462 | if ($db_last_error < time() - 3600 * 24 * 3 && empty($maintenance) && !empty($db_error_send)) |
432 | 463 | { |
433 | 464 | // Avoid writing to the Settings.php file if at all possible; use shared memory instead. |
434 | 465 | cache_put_data('db_last_error', time(), 600); |
435 | - if (($temp = cache_get_data('db_last_error', 600)) === null) |
|
436 | - logLastDatabaseError(); |
|
466 | + if (($temp = cache_get_data('db_last_error', 600)) === null) { |
|
467 | + logLastDatabaseError(); |
|
468 | + } |
|
437 | 469 | |
438 | 470 | // Language files aren't loaded yet :(. |
439 | 471 | $db_error = @$smcFunc['db_error']($db_connection); |
@@ -490,8 +522,9 @@ discard block |
||
490 | 522 | */ |
491 | 523 | function set_fatal_error_headers() |
492 | 524 | { |
493 | - if (headers_sent()) |
|
494 | - return; |
|
525 | + if (headers_sent()) { |
|
526 | + return; |
|
527 | + } |
|
495 | 528 | |
496 | 529 | // Don't cache this page! |
497 | 530 | header('expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
@@ -517,12 +550,14 @@ discard block |
||
517 | 550 | global $smcFunc, $user_info, $modSettings; |
518 | 551 | |
519 | 552 | // Don't bother if Who's Online is disabled. |
520 | - if (empty($modSettings['who_enabled'])) |
|
521 | - return; |
|
553 | + if (empty($modSettings['who_enabled'])) { |
|
554 | + return; |
|
555 | + } |
|
522 | 556 | |
523 | 557 | // Maybe they came from SSI or similar where sessions are not recorded? |
524 | - if (SMF == 'SSI' || SMF == 'BACKGROUND') |
|
525 | - return; |
|
558 | + if (SMF == 'SSI' || SMF == 'BACKGROUND') { |
|
559 | + return; |
|
560 | + } |
|
526 | 561 | |
527 | 562 | $session_id = !empty($user_info['is_guest']) ? 'ip' . $user_info['ip'] : session_id(); |
528 | 563 | |
@@ -548,11 +583,13 @@ discard block |
||
548 | 583 | $url = $smcFunc['json_decode']($url, true); |
549 | 584 | $url['error'] = $error; |
550 | 585 | // Url field got a max length of 1024 in db |
551 | - if (strlen($url['error']) > 500) |
|
552 | - $url['error'] = substr($url['error'],0,500); |
|
586 | + if (strlen($url['error']) > 500) { |
|
587 | + $url['error'] = substr($url['error'],0,500); |
|
588 | + } |
|
553 | 589 | |
554 | - if (!empty($sprintf)) |
|
555 | - $url['error_params'] = $sprintf; |
|
590 | + if (!empty($sprintf)) { |
|
591 | + $url['error_params'] = $sprintf; |
|
592 | + } |
|
556 | 593 | |
557 | 594 | $smcFunc['db_query']('', ' |
558 | 595 | UPDATE {db_prefix}log_online |
@@ -583,10 +620,11 @@ discard block |
||
583 | 620 | |
584 | 621 | $protocol = preg_match('~HTTP/1\.[01]~i', $_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0'; |
585 | 622 | |
586 | - if (!isset($statuses[$code])) |
|
587 | - header($protocol . ' 500 Internal Server Error'); |
|
588 | - else |
|
589 | - header($protocol . ' ' . $code . ' ' . $statuses[$code]); |
|
590 | -} |
|
623 | + if (!isset($statuses[$code])) { |
|
624 | + header($protocol . ' 500 Internal Server Error'); |
|
625 | + } else { |
|
626 | + header($protocol . ' ' . $code . ' ' . $statuses[$code]); |
|
627 | + } |
|
628 | + } |
|
591 | 629 | |
592 | 630 | ?> |
593 | 631 | \ No newline at end of file |
@@ -65,9 +65,10 @@ discard block |
||
65 | 65 | ', implode(', ', $context['administrators']); |
66 | 66 | |
67 | 67 | // If we have lots of admins... don't show them all. |
68 | - if (!empty($context['more_admins_link'])) |
|
69 | - echo ' |
|
68 | + if (!empty($context['more_admins_link'])) { |
|
69 | + echo ' |
|
70 | 70 | (', $context['more_admins_link'], ')'; |
71 | + } |
|
71 | 72 | |
72 | 73 | echo ' |
73 | 74 | </div><!-- #version_details --> |
@@ -84,17 +85,19 @@ discard block |
||
84 | 85 | foreach ($area['areas'] as $item_id => $item) |
85 | 86 | { |
86 | 87 | // No point showing the 'home' page here, we're already on it! |
87 | - if ($area_id == 'forum' && $item_id == 'index') |
|
88 | - continue; |
|
88 | + if ($area_id == 'forum' && $item_id == 'index') { |
|
89 | + continue; |
|
90 | + } |
|
89 | 91 | |
90 | 92 | $url = isset($item['url']) ? $item['url'] : $scripturl . '?action=admin;area=' . $item_id . (!empty($context[$context['admin_menu_name']]['extra_parameters']) ? $context[$context['admin_menu_name']]['extra_parameters'] : ''); |
91 | 93 | |
92 | - if (!empty($item['icon_file'])) |
|
93 | - echo ' |
|
94 | + if (!empty($item['icon_file'])) { |
|
95 | + echo ' |
|
94 | 96 | <a href="', $url, '" class="admin_group', !empty($item['inactive']) ? ' inactive' : '', '"><img class="large_admin_menu_icon_file" src="', $item['icon_file'], '" alt="">', $item['label'], '</a>'; |
95 | - else |
|
96 | - echo ' |
|
97 | + } else { |
|
98 | + echo ' |
|
97 | 99 | <a href="', $url, '"><span class="large_', $item['icon_class'], !empty($item['inactive']) ? ' inactive' : '', '"></span>', $item['label'], '</a>'; |
100 | + } |
|
98 | 101 | } |
99 | 102 | |
100 | 103 | echo ' |
@@ -105,10 +108,11 @@ discard block |
||
105 | 108 | </div><!-- #admincenter -->'; |
106 | 109 | |
107 | 110 | // The below functions include all the scripts needed from the simplemachines.org site. The language and format are passed for internationalization. |
108 | - if (empty($modSettings['disable_smf_js'])) |
|
109 | - echo ' |
|
111 | + if (empty($modSettings['disable_smf_js'])) { |
|
112 | + echo ' |
|
110 | 113 | <script src="', $scripturl, '?action=viewsmfile;filename=current-version.js"></script> |
111 | 114 | <script src="', $scripturl, '?action=viewsmfile;filename=latest-news.js"></script>'; |
115 | + } |
|
112 | 116 | |
113 | 117 | // This sets the announcements and current versions themselves ;). |
114 | 118 | echo ' |
@@ -186,9 +190,10 @@ discard block |
||
186 | 190 | <em>', $version['version'], '</em>'; |
187 | 191 | |
188 | 192 | // more details for this item, show them a link |
189 | - if ($context['can_admin'] && isset($version['more'])) |
|
190 | - echo |
|
193 | + if ($context['can_admin'] && isset($version['more'])) { |
|
194 | + echo |
|
191 | 195 | ' <a href="', $scripturl, $version['more'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['version_check_more'], '</a>'; |
196 | + } |
|
192 | 197 | echo ' |
193 | 198 | <br>'; |
194 | 199 | } |
@@ -219,21 +224,23 @@ discard block |
||
219 | 224 | |
220 | 225 | foreach ($context['credits'] as $section) |
221 | 226 | { |
222 | - if (isset($section['pretext'])) |
|
223 | - echo ' |
|
227 | + if (isset($section['pretext'])) { |
|
228 | + echo ' |
|
224 | 229 | <p>', $section['pretext'], '</p> |
225 | 230 | <hr>'; |
231 | + } |
|
226 | 232 | |
227 | 233 | echo ' |
228 | 234 | <dl>'; |
229 | 235 | |
230 | 236 | foreach ($section['groups'] as $group) |
231 | 237 | { |
232 | - if (isset($group['title'])) |
|
233 | - echo ' |
|
238 | + if (isset($group['title'])) { |
|
239 | + echo ' |
|
234 | 240 | <dt> |
235 | 241 | <strong>', $group['title'], ':</strong> |
236 | 242 | </dt>'; |
243 | + } |
|
237 | 244 | |
238 | 245 | echo ' |
239 | 246 | <dd>', implode(', ', $group['members']), '</dd>'; |
@@ -242,10 +249,11 @@ discard block |
||
242 | 249 | echo ' |
243 | 250 | </dl>'; |
244 | 251 | |
245 | - if (isset($section['posttext'])) |
|
246 | - echo ' |
|
252 | + if (isset($section['posttext'])) { |
|
253 | + echo ' |
|
247 | 254 | <hr> |
248 | 255 | <p>', $section['posttext'], '</p>'; |
256 | + } |
|
249 | 257 | } |
250 | 258 | |
251 | 259 | echo ' |
@@ -261,9 +269,10 @@ discard block |
||
261 | 269 | smfSupportVersions.forum = "', $context['forum_version'], '";'; |
262 | 270 | |
263 | 271 | // Don't worry, none of this is logged, it's just used to give information that might be of use. |
264 | - foreach ($context['current_versions'] as $variable => $version) |
|
265 | - echo ' |
|
272 | + foreach ($context['current_versions'] as $variable => $version) { |
|
273 | + echo ' |
|
266 | 274 | smfSupportVersions.', $variable, ' = "', $version['version'], '";'; |
275 | + } |
|
267 | 276 | |
268 | 277 | // Now we just have to include the script and wait ;). |
269 | 278 | echo ' |
@@ -360,8 +369,8 @@ discard block |
||
360 | 369 | <tbody>'; |
361 | 370 | |
362 | 371 | // Loop through every source file displaying its version - using javascript. |
363 | - foreach ($context['file_versions'] as $filename => $version) |
|
364 | - echo ' |
|
372 | + foreach ($context['file_versions'] as $filename => $version) { |
|
373 | + echo ' |
|
365 | 374 | <tr class="windowbg"> |
366 | 375 | <td class="half_table"> |
367 | 376 | ', $filename, ' |
@@ -373,6 +382,7 @@ discard block |
||
373 | 382 | <em id="currentSources', $filename, '">??</em> |
374 | 383 | </td> |
375 | 384 | </tr>'; |
385 | + } |
|
376 | 386 | |
377 | 387 | // Default template files. |
378 | 388 | echo ' |
@@ -398,8 +408,8 @@ discard block |
||
398 | 408 | <table id="Default" class="table_grid"> |
399 | 409 | <tbody>'; |
400 | 410 | |
401 | - foreach ($context['default_template_versions'] as $filename => $version) |
|
402 | - echo ' |
|
411 | + foreach ($context['default_template_versions'] as $filename => $version) { |
|
412 | + echo ' |
|
403 | 413 | <tr class="windowbg"> |
404 | 414 | <td class="half_table"> |
405 | 415 | ', $filename, ' |
@@ -411,6 +421,7 @@ discard block |
||
411 | 421 | <em id="currentDefault', $filename, '">??</em> |
412 | 422 | </td> |
413 | 423 | </tr>'; |
424 | + } |
|
414 | 425 | |
415 | 426 | // Now the language files... |
416 | 427 | echo ' |
@@ -438,8 +449,8 @@ discard block |
||
438 | 449 | |
439 | 450 | foreach ($context['default_language_versions'] as $language => $files) |
440 | 451 | { |
441 | - foreach ($files as $filename => $version) |
|
442 | - echo ' |
|
452 | + foreach ($files as $filename => $version) { |
|
453 | + echo ' |
|
443 | 454 | <tr class="windowbg"> |
444 | 455 | <td class="half_table"> |
445 | 456 | ', $filename, '.<em>', $language, '</em>.php |
@@ -451,6 +462,7 @@ discard block |
||
451 | 462 | <em id="current', $filename, '.', $language, '">??</em> |
452 | 463 | </td> |
453 | 464 | </tr>'; |
465 | + } |
|
454 | 466 | } |
455 | 467 | |
456 | 468 | echo ' |
@@ -480,8 +492,8 @@ discard block |
||
480 | 492 | <table id="Templates" class="table_grid"> |
481 | 493 | <tbody>'; |
482 | 494 | |
483 | - foreach ($context['template_versions'] as $filename => $version) |
|
484 | - echo ' |
|
495 | + foreach ($context['template_versions'] as $filename => $version) { |
|
496 | + echo ' |
|
485 | 497 | <tr class="windowbg"> |
486 | 498 | <td class="half_table"> |
487 | 499 | ', $filename, ' |
@@ -493,6 +505,7 @@ discard block |
||
493 | 505 | <em id="currentTemplates', $filename, '">??</em> |
494 | 506 | </td> |
495 | 507 | </tr>'; |
508 | + } |
|
496 | 509 | |
497 | 510 | echo ' |
498 | 511 | </tbody> |
@@ -522,8 +535,8 @@ discard block |
||
522 | 535 | <table id="Tasks" class="table_grid"> |
523 | 536 | <tbody>'; |
524 | 537 | |
525 | - foreach ($context['tasks_versions'] as $filename => $version) |
|
526 | - echo ' |
|
538 | + foreach ($context['tasks_versions'] as $filename => $version) { |
|
539 | + echo ' |
|
527 | 540 | <tr class="windowbg"> |
528 | 541 | <td class="half_table"> |
529 | 542 | ', $filename, ' |
@@ -535,6 +548,7 @@ discard block |
||
535 | 548 | <em id="currentTasks', $filename, '">??</em> |
536 | 549 | </td> |
537 | 550 | </tr>'; |
551 | + } |
|
538 | 552 | |
539 | 553 | echo ' |
540 | 554 | </tbody> |
@@ -576,9 +590,10 @@ discard block |
||
576 | 590 | { |
577 | 591 | global $context, $scripturl, $txt, $modSettings; |
578 | 592 | |
579 | - if (!empty($context['saved_successful'])) |
|
580 | - echo ' |
|
593 | + if (!empty($context['saved_successful'])) { |
|
594 | + echo ' |
|
581 | 595 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
596 | + } |
|
582 | 597 | |
583 | 598 | // First section is for adding/removing words from the censored list. |
584 | 599 | echo ' |
@@ -593,11 +608,12 @@ discard block |
||
593 | 608 | <p>', $txt['admin_censored_where'], '</p>'; |
594 | 609 | |
595 | 610 | // Show text boxes for censoring [bad ] => [good ]. |
596 | - foreach ($context['censored_words'] as $vulgar => $proper) |
|
597 | - echo ' |
|
611 | + foreach ($context['censored_words'] as $vulgar => $proper) { |
|
612 | + echo ' |
|
598 | 613 | <div class="block"> |
599 | 614 | <input type="text" name="censor_vulgar[]" value="', $vulgar, '" size="30"> => <input type="text" name="censor_proper[]" value="', $proper, '" size="30"> |
600 | 615 | </div>'; |
616 | + } |
|
601 | 617 | |
602 | 618 | // Now provide a way to censor more words. |
603 | 619 | echo ' |
@@ -672,19 +688,21 @@ discard block |
||
672 | 688 | <div class="windowbg noup"> |
673 | 689 | ', $txt['not_done_reason']; |
674 | 690 | |
675 | - if (!empty($context['continue_percent'])) |
|
676 | - echo ' |
|
691 | + if (!empty($context['continue_percent'])) { |
|
692 | + echo ' |
|
677 | 693 | <div class="progress_bar"> |
678 | 694 | <span>', $context['continue_percent'], '%</span> |
679 | 695 | <div class="bar" style="width: ', $context['continue_percent'], '%;"></div> |
680 | 696 | </div>'; |
697 | + } |
|
681 | 698 | |
682 | - if (!empty($context['substep_enabled'])) |
|
683 | - echo ' |
|
699 | + if (!empty($context['substep_enabled'])) { |
|
700 | + echo ' |
|
684 | 701 | <div class="progress_bar progress_blue"> |
685 | 702 | <span>', $context['substep_title'], ' (', $context['substep_continue_percent'], '%)</span> |
686 | 703 | <div class="bar" style="width: ', $context['substep_continue_percent'], '%;"></div> |
687 | 704 | </div>'; |
705 | + } |
|
688 | 706 | |
689 | 707 | echo ' |
690 | 708 | <form action="', $scripturl, $context['continue_get_data'], '" method="post" accept-charset="', $context['character_set'], '" name="autoSubmit" id="autoSubmit"> |
@@ -719,35 +737,40 @@ discard block |
||
719 | 737 | { |
720 | 738 | global $context, $txt, $scripturl; |
721 | 739 | |
722 | - if (!empty($context['saved_successful'])) |
|
723 | - echo ' |
|
740 | + if (!empty($context['saved_successful'])) { |
|
741 | + echo ' |
|
724 | 742 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
725 | - elseif (!empty($context['saved_failed'])) |
|
726 | - echo ' |
|
743 | + } elseif (!empty($context['saved_failed'])) { |
|
744 | + echo ' |
|
727 | 745 | <div class="errorbox">', sprintf($txt['settings_not_saved'], $context['saved_failed']), '</div>'; |
746 | + } |
|
728 | 747 | |
729 | - if (!empty($context['settings_pre_javascript'])) |
|
730 | - echo ' |
|
748 | + if (!empty($context['settings_pre_javascript'])) { |
|
749 | + echo ' |
|
731 | 750 | <script>', $context['settings_pre_javascript'], '</script>'; |
751 | + } |
|
732 | 752 | |
733 | - if (!empty($context['settings_insert_above'])) |
|
734 | - echo $context['settings_insert_above']; |
|
753 | + if (!empty($context['settings_insert_above'])) { |
|
754 | + echo $context['settings_insert_above']; |
|
755 | + } |
|
735 | 756 | |
736 | 757 | echo ' |
737 | 758 | <div id="admincenter"> |
738 | 759 | <form id="admin_form_wrapper" action="', $context['post_url'], '" method="post" accept-charset="', $context['character_set'], '"', !empty($context['force_form_onsubmit']) ? ' onsubmit="' . $context['force_form_onsubmit'] . '"' : '', '>'; |
739 | 760 | |
740 | 761 | // Is there a custom title? |
741 | - if (isset($context['settings_title'])) |
|
742 | - echo ' |
|
762 | + if (isset($context['settings_title'])) { |
|
763 | + echo ' |
|
743 | 764 | <div class="cat_bar"> |
744 | 765 | <h3 class="catbg">', $context['settings_title'], '</h3> |
745 | 766 | </div>'; |
767 | + } |
|
746 | 768 | |
747 | 769 | // Have we got a message to display? |
748 | - if (!empty($context['settings_message'])) |
|
749 | - echo ' |
|
770 | + if (!empty($context['settings_message'])) { |
|
771 | + echo ' |
|
750 | 772 | <div class="information">', $context['settings_message'], '</div>'; |
773 | + } |
|
751 | 774 | |
752 | 775 | // Now actually loop through all the variables. |
753 | 776 | $is_open = false; |
@@ -800,8 +823,9 @@ discard block |
||
800 | 823 | // Hang about? Are you pulling my leg - a callback?! |
801 | 824 | if (is_array($config_var) && $config_var['type'] == 'callback') |
802 | 825 | { |
803 | - if (function_exists('template_callback_' . $config_var['name'])) |
|
804 | - call_user_func('template_callback_' . $config_var['name']); |
|
826 | + if (function_exists('template_callback_' . $config_var['name'])) { |
|
827 | + call_user_func('template_callback_' . $config_var['name']); |
|
828 | + } |
|
805 | 829 | |
806 | 830 | continue; |
807 | 831 | } |
@@ -831,9 +855,10 @@ discard block |
||
831 | 855 | $text_types = array('color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time'); |
832 | 856 | |
833 | 857 | // Show the [?] button. |
834 | - if ($config_var['help']) |
|
835 | - echo ' |
|
858 | + if ($config_var['help']) { |
|
859 | + echo ' |
|
836 | 860 | <a id="setting_', $config_var['name'], '_help" href="', $scripturl, '?action=helpadmin;help=', $config_var['help'], '" onclick="return reqOverlayDiv(this.href);"><span class="generic_icons help" title="', $txt['help'], '"></span></a> '; |
861 | + } |
|
837 | 862 | |
838 | 863 | echo ' |
839 | 864 | <a id="setting_', $config_var['name'], '"></a> <span', ($config_var['disabled'] ? ' style="color: #777777;"' : ($config_var['invalid'] ? ' class="error"' : '')), '><label for="', $config_var['name'], '">', $config_var['label'], '</label>', $subtext, ($config_var['type'] == 'password' ? '<br><em>' . $txt['admin_confirm_password'] . '</em>' : ''), '</span> |
@@ -842,23 +867,26 @@ discard block |
||
842 | 867 | $config_var['preinput']; |
843 | 868 | |
844 | 869 | // Show a check box. |
845 | - if ($config_var['type'] == 'check') |
|
846 | - echo ' |
|
870 | + if ($config_var['type'] == 'check') { |
|
871 | + echo ' |
|
847 | 872 | <input type="checkbox"', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '"', ($config_var['value'] ? ' checked' : ''), ' value="1">'; |
873 | + } |
|
848 | 874 | // Escape (via htmlspecialchars.) the text box. |
849 | - elseif ($config_var['type'] == 'password') |
|
850 | - echo ' |
|
875 | + elseif ($config_var['type'] == 'password') { |
|
876 | + echo ' |
|
851 | 877 | <input type="password"', $disabled, $javascript, ' name="', $config_var['name'], '[0]"', ($config_var['size'] ? ' size="' . $config_var['size'] . '"' : ''), ' value="*#fakepass#*" onfocus="this.value = \'\'; this.form.', $config_var['name'], '.disabled = false;"><br> |
852 | 878 | <input type="password" disabled id="', $config_var['name'], '" name="', $config_var['name'], '[1]"', ($config_var['size'] ? ' size="' . $config_var['size'] . '"' : ''), '>'; |
879 | + } |
|
853 | 880 | // Show a selection box. |
854 | 881 | elseif ($config_var['type'] == 'select') |
855 | 882 | { |
856 | 883 | echo ' |
857 | 884 | <select name="', $config_var['name'], '" id="', $config_var['name'], '" ', $javascript, $disabled, (!empty($config_var['multiple']) ? ' multiple="multiple"' : ''), (!empty($config_var['multiple']) && !empty($config_var['size']) ? ' size="' . $config_var['size'] . '"' : ''), '>'; |
858 | 885 | |
859 | - foreach ($config_var['data'] as $option) |
|
860 | - echo ' |
|
886 | + foreach ($config_var['data'] as $option) { |
|
887 | + echo ' |
|
861 | 888 | <option value="', $option[0], '"', (!empty($config_var['value']) && ($option[0] == $config_var['value'] || (!empty($config_var['multiple']) && in_array($option[0], $config_var['value']))) ? ' selected' : ''), '>', $option[1], '</option>'; |
889 | + } |
|
862 | 890 | echo ' |
863 | 891 | </select>'; |
864 | 892 | } |
@@ -875,16 +903,18 @@ discard block |
||
875 | 903 | |
876 | 904 | foreach ($context['board_list'] as $id_cat => $cat) |
877 | 905 | { |
878 | - if (!$first) |
|
879 | - echo ' |
|
906 | + if (!$first) { |
|
907 | + echo ' |
|
880 | 908 | <hr>'; |
909 | + } |
|
881 | 910 | echo ' |
882 | 911 | <strong>', $cat['name'], '</strong> |
883 | 912 | <ul>'; |
884 | 913 | |
885 | - foreach ($cat['boards'] as $id_board => $brd) |
|
886 | - echo ' |
|
914 | + foreach ($cat['boards'] as $id_board => $brd) { |
|
915 | + echo ' |
|
887 | 916 | <li><label><input type="checkbox" name="', $config_var['name'], '[', $brd['id'], ']" value="1"', in_array($brd['id'], $config_var['value']) ? ' checked' : '', '> ', $brd['child_level'] > 0 ? str_repeat(' ', $brd['child_level']) : '', $brd['name'], '</label></li>'; |
917 | + } |
|
888 | 918 | |
889 | 919 | echo ' |
890 | 920 | </ul>'; |
@@ -894,12 +924,14 @@ discard block |
||
894 | 924 | </fieldset>'; |
895 | 925 | } |
896 | 926 | // Text area? |
897 | - elseif ($config_var['type'] == 'large_text') |
|
898 | - echo ' |
|
927 | + elseif ($config_var['type'] == 'large_text') { |
|
928 | + echo ' |
|
899 | 929 | <textarea rows="', (!empty($config_var['size']) ? $config_var['size'] : (!empty($config_var['rows']) ? $config_var['rows'] : 4)), '" cols="', (!empty($config_var['cols']) ? $config_var['cols'] : 30), '" ', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '">', $config_var['value'], '</textarea>'; |
930 | + } |
|
900 | 931 | // Permission group? |
901 | - elseif ($config_var['type'] == 'permissions') |
|
902 | - theme_inline_permissions($config_var['name']); |
|
932 | + elseif ($config_var['type'] == 'permissions') { |
|
933 | + theme_inline_permissions($config_var['name']); |
|
934 | + } |
|
903 | 935 | |
904 | 936 | // BBC selection? |
905 | 937 | elseif ($config_var['type'] == 'bbc') |
@@ -911,22 +943,24 @@ discard block |
||
911 | 943 | |
912 | 944 | foreach ($context['bbc_columns'] as $bbcColumn) |
913 | 945 | { |
914 | - foreach ($bbcColumn as $bbcTag) |
|
915 | - echo ' |
|
946 | + foreach ($bbcColumn as $bbcTag) { |
|
947 | + echo ' |
|
916 | 948 | <li class="list_bbc floatleft"> |
917 | 949 | <input type="checkbox" name="', $config_var['name'], '_enabledTags[]" id="tag_', $config_var['name'], '_', $bbcTag['tag'], '" value="', $bbcTag['tag'], '"', !in_array($bbcTag['tag'], $context['bbc_sections'][$config_var['name']]['disabled']) ? ' checked' : '', '> <label for="tag_', $config_var['name'], '_', $bbcTag['tag'], '">', $bbcTag['tag'], '</label>', $bbcTag['show_help'] ? ' (<a href="' . $scripturl . '?action=helpadmin;help=tag_' . $bbcTag['tag'] . '" onclick="return reqOverlayDiv(this.href);">?</a>)' : '', ' |
918 | 950 | </li>'; |
951 | + } |
|
919 | 952 | } |
920 | 953 | echo ' </ul> |
921 | 954 | <input type="checkbox" id="bbc_', $config_var['name'], '_select_all" onclick="invertAll(this, this.form, \'', $config_var['name'], '_enabledTags\');"', $context['bbc_sections'][$config_var['name']]['all_selected'] ? ' checked' : '', '> <label for="bbc_', $config_var['name'], '_select_all"><em>', $txt['bbcTagsToUse_select_all'], '</em></label> |
922 | 955 | </fieldset>'; |
923 | 956 | } |
924 | 957 | // A simple message? |
925 | - elseif ($config_var['type'] == 'var_message') |
|
926 | - echo ' |
|
958 | + elseif ($config_var['type'] == 'var_message') { |
|
959 | + echo ' |
|
927 | 960 | <div', !empty($config_var['name']) ? ' id="' . $config_var['name'] . '"' : '', '> |
928 | 961 | ', $config_var['var_message'], ' |
929 | 962 | </div>'; |
963 | + } |
|
930 | 964 | // Assume it must be a text box |
931 | 965 | else |
932 | 966 | { |
@@ -951,62 +985,70 @@ discard block |
||
951 | 985 | ' . $config_var['postinput'] : '',' |
952 | 986 | </dd>'; |
953 | 987 | } |
954 | - } |
|
955 | - else |
|
988 | + } else |
|
956 | 989 | { |
957 | 990 | // Just show a separator. |
958 | - if ($config_var == '') |
|
959 | - echo ' |
|
991 | + if ($config_var == '') { |
|
992 | + echo ' |
|
960 | 993 | </dl> |
961 | 994 | <hr> |
962 | 995 | <dl class="settings">'; |
963 | - else |
|
964 | - echo ' |
|
996 | + } else { |
|
997 | + echo ' |
|
965 | 998 | <dd> |
966 | 999 | <strong>' . $config_var . '</strong> |
967 | 1000 | </dd>'; |
1001 | + } |
|
968 | 1002 | } |
969 | 1003 | } |
970 | 1004 | |
971 | - if ($is_open) |
|
972 | - echo ' |
|
1005 | + if ($is_open) { |
|
1006 | + echo ' |
|
973 | 1007 | </dl>'; |
1008 | + } |
|
974 | 1009 | |
975 | - if (empty($context['settings_save_dont_show'])) |
|
976 | - echo ' |
|
1010 | + if (empty($context['settings_save_dont_show'])) { |
|
1011 | + echo ' |
|
977 | 1012 | <input type="submit" value="', $txt['save'], '"', (!empty($context['save_disabled']) ? ' disabled' : ''), (!empty($context['settings_save_onclick']) ? ' onclick="' . $context['settings_save_onclick'] . '"' : ''), ' class="button">'; |
1013 | + } |
|
978 | 1014 | |
979 | - if ($is_open) |
|
980 | - echo ' |
|
1015 | + if ($is_open) { |
|
1016 | + echo ' |
|
981 | 1017 | </div><!-- .windowbg -->'; |
1018 | + } |
|
982 | 1019 | |
983 | 1020 | |
984 | 1021 | // At least one token has to be used! |
985 | - if (isset($context['admin-ssc_token'])) |
|
986 | - echo ' |
|
1022 | + if (isset($context['admin-ssc_token'])) { |
|
1023 | + echo ' |
|
987 | 1024 | <input type="hidden" name="', $context['admin-ssc_token_var'], '" value="', $context['admin-ssc_token'], '">'; |
1025 | + } |
|
988 | 1026 | |
989 | - if (isset($context['admin-dbsc_token'])) |
|
990 | - echo ' |
|
1027 | + if (isset($context['admin-dbsc_token'])) { |
|
1028 | + echo ' |
|
991 | 1029 | <input type="hidden" name="', $context['admin-dbsc_token_var'], '" value="', $context['admin-dbsc_token'], '">'; |
1030 | + } |
|
992 | 1031 | |
993 | - if (isset($context['admin-mp_token'])) |
|
994 | - echo ' |
|
1032 | + if (isset($context['admin-mp_token'])) { |
|
1033 | + echo ' |
|
995 | 1034 | <input type="hidden" name="', $context['admin-mp_token_var'], '" value="', $context['admin-mp_token'], '">'; |
1035 | + } |
|
996 | 1036 | |
997 | 1037 | echo ' |
998 | 1038 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
999 | 1039 | </form> |
1000 | 1040 | </div><!-- #admincenter -->'; |
1001 | 1041 | |
1002 | - if (!empty($context['settings_post_javascript'])) |
|
1003 | - echo ' |
|
1042 | + if (!empty($context['settings_post_javascript'])) { |
|
1043 | + echo ' |
|
1004 | 1044 | <script> |
1005 | 1045 | ', $context['settings_post_javascript'], ' |
1006 | 1046 | </script>'; |
1047 | + } |
|
1007 | 1048 | |
1008 | - if (!empty($context['settings_insert_below'])) |
|
1009 | - echo $context['settings_insert_below']; |
|
1049 | + if (!empty($context['settings_insert_below'])) { |
|
1050 | + echo $context['settings_insert_below']; |
|
1051 | + } |
|
1010 | 1052 | |
1011 | 1053 | // We may have added a board listing. If we did, we need to make it work. |
1012 | 1054 | addInlineJavascript(' |
@@ -1029,9 +1071,10 @@ discard block |
||
1029 | 1071 | { |
1030 | 1072 | global $context, $txt; |
1031 | 1073 | |
1032 | - if (!empty($context['saved_successful'])) |
|
1033 | - echo ' |
|
1074 | + if (!empty($context['saved_successful'])) { |
|
1075 | + echo ' |
|
1034 | 1076 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
1077 | + } |
|
1035 | 1078 | |
1036 | 1079 | // Standard fields. |
1037 | 1080 | template_show_list('standard_profile_fields'); |
@@ -1065,11 +1108,12 @@ discard block |
||
1065 | 1108 | { |
1066 | 1109 | loadLanguage('Errors'); |
1067 | 1110 | |
1068 | - if (isset($txt['custom_option_' . $_GET['msg']])) |
|
1069 | - echo ' |
|
1111 | + if (isset($txt['custom_option_' . $_GET['msg']])) { |
|
1112 | + echo ' |
|
1070 | 1113 | <div class="errorbox">', |
1071 | 1114 | $txt['custom_option_' . $_GET['msg']], ' |
1072 | 1115 | </div>'; |
1116 | + } |
|
1073 | 1117 | } |
1074 | 1118 | |
1075 | 1119 | echo ' |
@@ -1136,9 +1180,10 @@ discard block |
||
1136 | 1180 | <dd> |
1137 | 1181 | <select name="placement" id="placement">'; |
1138 | 1182 | |
1139 | - foreach ($context['cust_profile_fields_placement'] as $order => $name) |
|
1140 | - echo ' |
|
1183 | + foreach ($context['cust_profile_fields_placement'] as $order => $name) { |
|
1184 | + echo ' |
|
1141 | 1185 | <option value="', $order, '"', $context['field']['placement'] == $order ? ' selected' : '', '>', $txt['custom_profile_placement_' . $name], '</option>'; |
1186 | + } |
|
1142 | 1187 | |
1143 | 1188 | echo ' |
1144 | 1189 | </select> |
@@ -1162,9 +1207,10 @@ discard block |
||
1162 | 1207 | <dd> |
1163 | 1208 | <select name="field_type" id="field_type" onchange="updateInputBoxes();">'; |
1164 | 1209 | |
1165 | - foreach (array('text', 'textarea', 'select', 'radio', 'check') as $field_type) |
|
1166 | - echo ' |
|
1210 | + foreach (array('text', 'textarea', 'select', 'radio', 'check') as $field_type) { |
|
1211 | + echo ' |
|
1167 | 1212 | <option value="', $field_type, '"', $context['field']['type'] == $field_type ? ' selected' : '', '>', $txt['custom_profile_type_' . $field_type], '</option>'; |
1213 | + } |
|
1168 | 1214 | |
1169 | 1215 | echo ' |
1170 | 1216 | </select> |
@@ -1196,9 +1242,10 @@ discard block |
||
1196 | 1242 | </dt> |
1197 | 1243 | <dd id="options_dd">'; |
1198 | 1244 | |
1199 | - foreach ($context['field']['options'] as $k => $option) |
|
1200 | - echo ' |
|
1245 | + foreach ($context['field']['options'] as $k => $option) { |
|
1246 | + echo ' |
|
1201 | 1247 | ', $k == 0 ? '' : '<br>', '<input type="radio" name="default_select" value="', $k, '"', $context['field']['default_select'] == $option ? ' checked' : '', '><input type="text" name="select_option[', $k, ']" value="', $option, '">'; |
1248 | + } |
|
1202 | 1249 | |
1203 | 1250 | echo ' |
1204 | 1251 | <span id="addopt"></span> |
@@ -1262,9 +1309,10 @@ discard block |
||
1262 | 1309 | </fieldset> |
1263 | 1310 | <input type="submit" name="save" value="', $txt['save'], '" class="button">'; |
1264 | 1311 | |
1265 | - if ($context['fid']) |
|
1266 | - echo ' |
|
1312 | + if ($context['fid']) { |
|
1313 | + echo ' |
|
1267 | 1314 | <input type="submit" name="delete" value="', $txt['delete'], '" data-confirm="', $txt['custom_edit_delete_sure'], '" class="button you_sure">'; |
1315 | + } |
|
1268 | 1316 | |
1269 | 1317 | echo ' |
1270 | 1318 | </div><!-- .windowbg --> |
@@ -1311,8 +1359,7 @@ discard block |
||
1311 | 1359 | <p class="centertext"> |
1312 | 1360 | <strong>', $txt['admin_search_results_none'], '</strong> |
1313 | 1361 | </p>'; |
1314 | - } |
|
1315 | - else |
|
1362 | + } else |
|
1316 | 1363 | { |
1317 | 1364 | echo ' |
1318 | 1365 | <ol class="search_results">'; |
@@ -1339,9 +1386,10 @@ discard block |
||
1339 | 1386 | <li> |
1340 | 1387 | <a href="', $result['url'], '"><strong>', $result['name'], '</strong></a> [', isset($txt['admin_search_section_' . $result['type']]) ? $txt['admin_search_section_' . $result['type']] : $result['type'], ']'; |
1341 | 1388 | |
1342 | - if ($result['help']) |
|
1343 | - echo ' |
|
1389 | + if ($result['help']) { |
|
1390 | + echo ' |
|
1344 | 1391 | <p class="double_height">', $result['help'], '</p>'; |
1392 | + } |
|
1345 | 1393 | |
1346 | 1394 | echo ' |
1347 | 1395 | </li>'; |
@@ -1381,10 +1429,11 @@ discard block |
||
1381 | 1429 | <strong>', $txt['setup_verification_answer'], '</strong> |
1382 | 1430 | </dd>'; |
1383 | 1431 | |
1384 | - if (!empty($context['qa_by_lang'][$lang_id])) |
|
1385 | - foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
1432 | + if (!empty($context['qa_by_lang'][$lang_id])) { |
|
1433 | + foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
1386 | 1434 | { |
1387 | 1435 | $question = $context['question_answers'][$q_id]; |
1436 | + } |
|
1388 | 1437 | |
1389 | 1438 | echo ' |
1390 | 1439 | <dt> |
@@ -1392,9 +1441,10 @@ discard block |
||
1392 | 1441 | </dt> |
1393 | 1442 | <dd>'; |
1394 | 1443 | |
1395 | - foreach ($question['answers'] as $answer) |
|
1396 | - echo ' |
|
1444 | + foreach ($question['answers'] as $answer) { |
|
1445 | + echo ' |
|
1397 | 1446 | <input type="text" name="answer[', $lang_id, '][', $q_id, '][]" value="', $answer, '" size="50" class="verification_answer">'; |
1447 | + } |
|
1398 | 1448 | |
1399 | 1449 | echo ' |
1400 | 1450 | <div class="qa_add_answer"><a href="javascript:void(0);" onclick="return addAnswer(this);">[ ', $txt['setup_verification_add_answer'], ' ]</a></div> |
@@ -1433,11 +1483,12 @@ discard block |
||
1433 | 1483 | ', $txt['errors_found'], ': |
1434 | 1484 | <ul>'; |
1435 | 1485 | |
1436 | - foreach ($context['repair_errors'] as $error) |
|
1437 | - echo ' |
|
1486 | + foreach ($context['repair_errors'] as $error) { |
|
1487 | + echo ' |
|
1438 | 1488 | <li> |
1439 | 1489 | ', $error, ' |
1440 | 1490 | </li>'; |
1491 | + } |
|
1441 | 1492 | |
1442 | 1493 | echo ' |
1443 | 1494 | </ul> |
@@ -1447,15 +1498,14 @@ discard block |
||
1447 | 1498 | <p class="padding"> |
1448 | 1499 | <strong><a href="', $scripturl, '?action=admin;area=repairboards;fixErrors;', $context['session_var'], '=', $context['session_id'], '">', $txt['yes'], '</a> - <a href="', $scripturl, '?action=admin;area=maintain">', $txt['no'], '</a></strong> |
1449 | 1500 | </p>'; |
1450 | - } |
|
1451 | - else |
|
1452 | - echo ' |
|
1501 | + } else { |
|
1502 | + echo ' |
|
1453 | 1503 | <p>', $txt['maintain_no_errors'], '</p> |
1454 | 1504 | <p class="padding"> |
1455 | 1505 | <a href="', $scripturl, '?action=admin;area=maintain;sa=routine">', $txt['maintain_return'], '</a> |
1456 | 1506 | </p>'; |
1457 | - } |
|
1458 | - else |
|
1507 | + } |
|
1508 | + } else |
|
1459 | 1509 | { |
1460 | 1510 | if (!empty($context['redirect_to_recount'])) |
1461 | 1511 | { |
@@ -1467,8 +1517,7 @@ discard block |
||
1467 | 1517 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
1468 | 1518 | <input type="submit" name="recount" id="recount_now" value="', $txt['errors_recount_now'], '"> |
1469 | 1519 | </form>'; |
1470 | - } |
|
1471 | - else |
|
1520 | + } else |
|
1472 | 1521 | { |
1473 | 1522 | echo ' |
1474 | 1523 | <p>', $txt['errors_fixed'], '</p> |
@@ -1559,9 +1608,10 @@ discard block |
||
1559 | 1608 | <tr class="windowbg"> |
1560 | 1609 | <td class="equal_table">', $key, '</td>'; |
1561 | 1610 | |
1562 | - foreach ($setting as $key_lm => $value) |
|
1563 | - echo ' |
|
1611 | + foreach ($setting as $key_lm => $value) { |
|
1612 | + echo ' |
|
1564 | 1613 | <td class="equal_table">', $value, '</td>'; |
1614 | + } |
|
1565 | 1615 | |
1566 | 1616 | echo ' |
1567 | 1617 | </tr>'; |
@@ -1621,8 +1671,8 @@ discard block |
||
1621 | 1671 | { |
1622 | 1672 | global $context, $txt; |
1623 | 1673 | |
1624 | - if ($context['user']['is_admin']) |
|
1625 | - echo ' |
|
1674 | + if ($context['user']['is_admin']) { |
|
1675 | + echo ' |
|
1626 | 1676 | <span class="floatright admin_search"> |
1627 | 1677 | <span class="generic_icons filter centericon"></span> |
1628 | 1678 | <input type="search" name="search_term" placeholder="', $txt['admin_search'], '"> |
@@ -1633,6 +1683,7 @@ discard block |
||
1633 | 1683 | </select> |
1634 | 1684 | <input type="submit" name="search_go" id="search_go" value="', $txt['admin_search_go'], '" class="button"> |
1635 | 1685 | </span>'; |
1636 | -} |
|
1686 | + } |
|
1687 | + } |
|
1637 | 1688 | |
1638 | 1689 | ?> |
1639 | 1690 | \ No newline at end of file |
@@ -28,14 +28,15 @@ discard block |
||
28 | 28 | <div id="confirm_buttons">'; |
29 | 29 | |
30 | 30 | // Age restriction in effect? |
31 | - if ($context['show_coppa']) |
|
32 | - echo ' |
|
31 | + if ($context['show_coppa']) { |
|
32 | + echo ' |
|
33 | 33 | <input type="submit" name="accept_agreement" value="', $context['coppa_agree_above'], '" class="button"><br> |
34 | 34 | <br> |
35 | 35 | <input type="submit" name="accept_agreement_coppa" value="', $context['coppa_agree_below'], '" class="button">'; |
36 | - else |
|
37 | - echo ' |
|
36 | + } else { |
|
37 | + echo ' |
|
38 | 38 | <input type="submit" name="accept_agreement" value="', $txt['agreement_agree'], '" class="button">'; |
39 | + } |
|
39 | 40 | |
40 | 41 | echo ' |
41 | 42 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -78,9 +79,10 @@ discard block |
||
78 | 79 | <ul>'; |
79 | 80 | |
80 | 81 | // Cycle through each error and display an error message. |
81 | - foreach ($context['registration_errors'] as $error) |
|
82 | - echo ' |
|
82 | + foreach ($context['registration_errors'] as $error) { |
|
83 | + echo ' |
|
83 | 84 | <li>', $error, '</li>'; |
85 | + } |
|
84 | 86 | |
85 | 87 | echo ' |
86 | 88 | </ul> |
@@ -149,14 +151,15 @@ discard block |
||
149 | 151 | echo ' |
150 | 152 | <dl class="register_form">'; |
151 | 153 | |
152 | - foreach ($context['custom_fields'] as $field) |
|
153 | - if ($field['show_reg'] > 1) |
|
154 | + foreach ($context['custom_fields'] as $field) { |
|
155 | + if ($field['show_reg'] > 1) |
|
154 | 156 | echo ' |
155 | 157 | <dt> |
156 | 158 | <strong', !empty($field['is_error']) ? ' class="red"' : '', '>', $field['name'], ':</strong> |
157 | 159 | <span class="smalltext">', $field['desc'], '</span> |
158 | 160 | </dt> |
159 | 161 | <dd>', str_replace('name="', 'tabindex="' . $context['tabindex']++ . '" name="', $field['input_html']), '</dd>'; |
162 | + } |
|
160 | 163 | |
161 | 164 | echo ' |
162 | 165 | </dl>'; |
@@ -167,14 +170,15 @@ discard block |
||
167 | 170 | </div><!-- .roundframe -->'; |
168 | 171 | |
169 | 172 | // If we have either of these, show the extra group. |
170 | - if (!empty($context['profile_fields']) || !empty($context['custom_fields'])) |
|
171 | - echo ' |
|
173 | + if (!empty($context['profile_fields']) || !empty($context['custom_fields'])) { |
|
174 | + echo ' |
|
172 | 175 | <div class="title_bar title_top"> |
173 | 176 | <h3 class="titlebg">', $txt['additional_information'], '</h3> |
174 | 177 | </div> |
175 | 178 | <div class="roundframe noup"> |
176 | 179 | <fieldset> |
177 | 180 | <dl class="register_form" id="custom_group">'; |
181 | + } |
|
178 | 182 | |
179 | 183 | if (!empty($context['profile_fields'])) |
180 | 184 | { |
@@ -188,41 +192,45 @@ discard block |
||
188 | 192 | $callback_func = 'template_profile_' . $field['callback_func']; |
189 | 193 | $callback_func(); |
190 | 194 | } |
191 | - } |
|
192 | - else |
|
195 | + } else |
|
193 | 196 | { |
194 | 197 | echo ' |
195 | 198 | <dt> |
196 | 199 | <strong', !empty($field['is_error']) ? ' class="red"' : '', '>', $field['label'], ':</strong>'; |
197 | 200 | |
198 | 201 | // Does it have any subtext to show? |
199 | - if (!empty($field['subtext'])) |
|
200 | - echo ' |
|
202 | + if (!empty($field['subtext'])) { |
|
203 | + echo ' |
|
201 | 204 | <span class="smalltext">', $field['subtext'], '</span>'; |
205 | + } |
|
202 | 206 | |
203 | 207 | echo ' |
204 | 208 | </dt> |
205 | 209 | <dd>'; |
206 | 210 | |
207 | 211 | // Want to put something infront of the box? |
208 | - if (!empty($field['preinput'])) |
|
209 | - echo ' |
|
212 | + if (!empty($field['preinput'])) { |
|
213 | + echo ' |
|
210 | 214 | ', $field['preinput']; |
215 | + } |
|
211 | 216 | |
212 | 217 | // What type of data are we showing? |
213 | - if ($field['type'] == 'label') |
|
214 | - echo ' |
|
218 | + if ($field['type'] == 'label') { |
|
219 | + echo ' |
|
215 | 220 | ', $field['value']; |
221 | + } |
|
216 | 222 | |
217 | 223 | // Maybe it's a text box - very likely! |
218 | - elseif (in_array($field['type'], array('int', 'float', 'text', 'password', 'url'))) |
|
219 | - echo ' |
|
224 | + elseif (in_array($field['type'], array('int', 'float', 'text', 'password', 'url'))) { |
|
225 | + echo ' |
|
220 | 226 | <input type="', $field['type'] == 'password' ? 'password' : 'text', '" name="', $key, '" id="', $key, '" size="', empty($field['size']) ? 30 : $field['size'], '" value="', $field['value'], '" tabindex="', $context['tabindex']++, '" ', $field['input_attr'], '>'; |
227 | + } |
|
221 | 228 | |
222 | 229 | // You "checking" me out? ;) |
223 | - elseif ($field['type'] == 'check') |
|
224 | - echo ' |
|
230 | + elseif ($field['type'] == 'check') { |
|
231 | + echo ' |
|
225 | 232 | <input type="hidden" name="', $key, '" value="0"><input type="checkbox" name="', $key, '" id="', $key, '"', !empty($field['value']) ? ' checked' : '', ' value="1" tabindex="', $context['tabindex']++, '" ', $field['input_attr'], '>'; |
233 | + } |
|
226 | 234 | |
227 | 235 | // Always fun - select boxes! |
228 | 236 | elseif ($field['type'] == 'select') |
@@ -233,14 +241,16 @@ discard block |
||
233 | 241 | if (isset($field['options'])) |
234 | 242 | { |
235 | 243 | // Is this some code to generate the options? |
236 | - if (!is_array($field['options'])) |
|
237 | - $field['options'] = eval($field['options']); |
|
244 | + if (!is_array($field['options'])) { |
|
245 | + $field['options'] = eval($field['options']); |
|
246 | + } |
|
238 | 247 | |
239 | 248 | // Assuming we now have some! |
240 | - if (is_array($field['options'])) |
|
241 | - foreach ($field['options'] as $value => $name) |
|
249 | + if (is_array($field['options'])) { |
|
250 | + foreach ($field['options'] as $value => $name) |
|
242 | 251 | echo ' |
243 | 252 | <option', is_numeric($value) ? ' value="" disabled' : ' value="' . $value . '"', $value === $field['value'] ? ' selected' : '', '>', $name, '</option>'; |
253 | + } |
|
244 | 254 | } |
245 | 255 | |
246 | 256 | echo ' |
@@ -248,9 +258,10 @@ discard block |
||
248 | 258 | } |
249 | 259 | |
250 | 260 | // Something to end with? |
251 | - if (!empty($field['postinput'])) |
|
252 | - echo ' |
|
261 | + if (!empty($field['postinput'])) { |
|
262 | + echo ' |
|
253 | 263 | ', $field['postinput']; |
264 | + } |
|
254 | 265 | |
255 | 266 | echo ' |
256 | 267 | </dd>'; |
@@ -261,25 +272,27 @@ discard block |
||
261 | 272 | // Are there any custom fields? |
262 | 273 | if (!empty($context['custom_fields'])) |
263 | 274 | { |
264 | - foreach ($context['custom_fields'] as $field) |
|
265 | - if ($field['show_reg'] < 2) |
|
275 | + foreach ($context['custom_fields'] as $field) { |
|
276 | + if ($field['show_reg'] < 2) |
|
266 | 277 | echo ' |
267 | 278 | <dt> |
268 | 279 | <strong', !empty($field['is_error']) ? ' class="red"' : '', '>', $field['name'], ':</strong> |
269 | 280 | <span class="smalltext">', $field['desc'], '</span> |
270 | 281 | </dt> |
271 | 282 | <dd>', $field['input_html'], '</dd>'; |
283 | + } |
|
272 | 284 | } |
273 | 285 | |
274 | 286 | // If we have either of these, close the list like a proper gent. |
275 | - if (!empty($context['profile_fields']) || !empty($context['custom_fields'])) |
|
276 | - echo ' |
|
287 | + if (!empty($context['profile_fields']) || !empty($context['custom_fields'])) { |
|
288 | + echo ' |
|
277 | 289 | </dl> |
278 | 290 | </fieldset> |
279 | 291 | </div><!-- .roundframe -->'; |
292 | + } |
|
280 | 293 | |
281 | - if ($context['visual_verification']) |
|
282 | - echo ' |
|
294 | + if ($context['visual_verification']) { |
|
295 | + echo ' |
|
283 | 296 | <div class="title_bar title_top"> |
284 | 297 | <h3 class="titlebg">', $txt['verification'], '</h3> |
285 | 298 | </div> |
@@ -288,19 +301,21 @@ discard block |
||
288 | 301 | ', template_control_verification($context['visual_verification_id'], 'all'), ' |
289 | 302 | </fieldset> |
290 | 303 | </div>'; |
304 | + } |
|
291 | 305 | |
292 | 306 | echo ' |
293 | 307 | <div id="confirm_buttons" class="flow_auto">'; |
294 | 308 | |
295 | 309 | // Age restriction in effect? |
296 | - if (!$context['require_agreement'] && $context['show_coppa']) |
|
297 | - echo ' |
|
310 | + if (!$context['require_agreement'] && $context['show_coppa']) { |
|
311 | + echo ' |
|
298 | 312 | <input type="submit" name="accept_agreement" value="', $context['coppa_agree_above'], '" class="button"><br> |
299 | 313 | <br> |
300 | 314 | <input type="submit" name="accept_agreement_coppa" value="', $context['coppa_agree_below'], '" class="button">'; |
301 | - else |
|
302 | - echo ' |
|
315 | + } else { |
|
316 | + echo ' |
|
303 | 317 | <input type="submit" name="regSubmit" value="', $txt['register'], '" tabindex="', $context['tabindex']++, '" class="button">'; |
318 | + } |
|
304 | 319 | |
305 | 320 | echo ' |
306 | 321 | </div> |
@@ -362,25 +377,28 @@ discard block |
||
362 | 377 | <p>', $context['coppa']['many_options'] ? $txt['coppa_send_to_two_options'] : $txt['coppa_send_to_one_option'], '</p>'; |
363 | 378 | |
364 | 379 | // Can they send by post? |
365 | - if (!empty($context['coppa']['post'])) |
|
366 | - echo ' |
|
380 | + if (!empty($context['coppa']['post'])) { |
|
381 | + echo ' |
|
367 | 382 | <h4>1) ', $txt['coppa_send_by_post'], '</h4> |
368 | 383 | <div class="coppa_contact"> |
369 | 384 | ', $context['coppa']['post'], ' |
370 | 385 | </div>'; |
386 | + } |
|
371 | 387 | |
372 | 388 | // Can they send by fax?? |
373 | - if (!empty($context['coppa']['fax'])) |
|
374 | - echo ' |
|
389 | + if (!empty($context['coppa']['fax'])) { |
|
390 | + echo ' |
|
375 | 391 | <h4>', !empty($context['coppa']['post']) ? '2' : '1', ') ', $txt['coppa_send_by_fax'], '</h4> |
376 | 392 | <div class="coppa_contact"> |
377 | 393 | ', $context['coppa']['fax'], ' |
378 | 394 | </div>'; |
395 | + } |
|
379 | 396 | |
380 | 397 | // Offer an alternative Phone Number? |
381 | - if ($context['coppa']['phone']) |
|
382 | - echo ' |
|
398 | + if ($context['coppa']['phone']) { |
|
399 | + echo ' |
|
383 | 400 | <p>', $context['coppa']['phone'], '</p>'; |
401 | + } |
|
384 | 402 | |
385 | 403 | echo ' |
386 | 404 | </div><!-- #coppa -->'; |
@@ -445,19 +463,20 @@ discard block |
||
445 | 463 | <body style="margin: 1ex;"> |
446 | 464 | <div class="windowbg description" style="text-align: center;">'; |
447 | 465 | |
448 | - if (isBrowser('is_ie') || isBrowser('is_ie11')) |
|
449 | - echo ' |
|
466 | + if (isBrowser('is_ie') || isBrowser('is_ie11')) { |
|
467 | + echo ' |
|
450 | 468 | <object classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" type="audio/x-wav"> |
451 | 469 | <param name="AutoStart" value="1"> |
452 | 470 | <param name="FileName" value="', $context['verification_sound_href'], '"> |
453 | 471 | </object>'; |
454 | - else |
|
455 | - echo ' |
|
472 | + } else { |
|
473 | + echo ' |
|
456 | 474 | <audio src="', $context['verification_sound_href'], '" controls> |
457 | 475 | <object type="audio/x-wav" data="', $context['verification_sound_href'], '"> |
458 | 476 | <a href="', $context['verification_sound_href'], '" rel="nofollow">', $context['verification_sound_href'], '</a> |
459 | 477 | </object> |
460 | 478 | </audio>'; |
479 | + } |
|
461 | 480 | |
462 | 481 | echo ' |
463 | 482 | <br> |
@@ -485,11 +504,12 @@ discard block |
||
485 | 504 | </div> |
486 | 505 | <div id="register_screen" class="windowbg noup">'; |
487 | 506 | |
488 | - if (!empty($context['registration_done'])) |
|
489 | - echo ' |
|
507 | + if (!empty($context['registration_done'])) { |
|
508 | + echo ' |
|
490 | 509 | <div class="infobox"> |
491 | 510 | ', $context['registration_done'], ' |
492 | 511 | </div>'; |
512 | + } |
|
493 | 513 | |
494 | 514 | echo ' |
495 | 515 | <dl class="register_form" id="admin_register_form"> |
@@ -525,9 +545,10 @@ discard block |
||
525 | 545 | <dd> |
526 | 546 | <select name="group" id="group_select" tabindex="', $context['tabindex']++, '">'; |
527 | 547 | |
528 | - foreach ($context['member_groups'] as $id => $name) |
|
529 | - echo ' |
|
548 | + foreach ($context['member_groups'] as $id => $name) { |
|
549 | + echo ' |
|
530 | 550 | <option value="', $id, '">', $name, '</option>'; |
551 | + } |
|
531 | 552 | |
532 | 553 | echo ' |
533 | 554 | </select> |
@@ -535,8 +556,8 @@ discard block |
||
535 | 556 | } |
536 | 557 | |
537 | 558 | // If there is any field marked as required, show it here! |
538 | - if (!empty($context['custom_fields_required']) && !empty($context['custom_fields'])) |
|
539 | - foreach ($context['custom_fields'] as $field) |
|
559 | + if (!empty($context['custom_fields_required']) && !empty($context['custom_fields'])) { |
|
560 | + foreach ($context['custom_fields'] as $field) |
|
540 | 561 | if ($field['show_reg'] > 1) |
541 | 562 | echo ' |
542 | 563 | <dt> |
@@ -546,6 +567,7 @@ discard block |
||
546 | 567 | <dd> |
547 | 568 | ', str_replace('name="', 'tabindex="' . $context['tabindex']++ . '" name="', $field['input_html']), ' |
548 | 569 | </dd>'; |
570 | + } |
|
549 | 571 | |
550 | 572 | echo ' |
551 | 573 | <dt> |
@@ -582,13 +604,13 @@ discard block |
||
582 | 604 | { |
583 | 605 | global $context, $scripturl, $txt; |
584 | 606 | |
585 | - if (!empty($context['saved_successful'])) |
|
586 | - echo ' |
|
607 | + if (!empty($context['saved_successful'])) { |
|
608 | + echo ' |
|
587 | 609 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
588 | - |
|
589 | - elseif (!empty($context['could_not_save'])) |
|
590 | - echo ' |
|
610 | + } elseif (!empty($context['could_not_save'])) { |
|
611 | + echo ' |
|
591 | 612 | <div class="errorbox">', $txt['admin_agreement_not_saved'], '</div>'; |
613 | + } |
|
592 | 614 | |
593 | 615 | // Just a big box to edit the text file ;) |
594 | 616 | echo ' |
@@ -598,9 +620,10 @@ discard block |
||
598 | 620 | </div>'; |
599 | 621 | |
600 | 622 | // Warning for if the file isn't writable. |
601 | - if (!empty($context['warning'])) |
|
602 | - echo ' |
|
623 | + if (!empty($context['warning'])) { |
|
624 | + echo ' |
|
603 | 625 | <p class="error">', $context['warning'], '</p>'; |
626 | + } |
|
604 | 627 | |
605 | 628 | echo ' |
606 | 629 | <div class="windowbg noup" id="registration_agreement">'; |
@@ -617,9 +640,10 @@ discard block |
||
617 | 640 | <strong>', $txt['admin_agreement_select_language'], ':</strong> |
618 | 641 | <select name="agree_lang" onchange="document.getElementById(\'change_reg\').submit();" tabindex="', $context['tabindex']++, '">'; |
619 | 642 | |
620 | - foreach ($context['editable_agreements'] as $file => $name) |
|
621 | - echo ' |
|
643 | + foreach ($context['editable_agreements'] as $file => $name) { |
|
644 | + echo ' |
|
622 | 645 | <option value="', $file, '"', $context['current_agreement'] == $file ? ' selected' : '', '>', $name, '</option>'; |
646 | + } |
|
623 | 647 | |
624 | 648 | echo ' |
625 | 649 | </select> |
@@ -659,9 +683,10 @@ discard block |
||
659 | 683 | { |
660 | 684 | global $context, $scripturl, $txt; |
661 | 685 | |
662 | - if (!empty($context['saved_successful'])) |
|
663 | - echo ' |
|
686 | + if (!empty($context['saved_successful'])) { |
|
687 | + echo ' |
|
664 | 688 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
689 | + } |
|
665 | 690 | |
666 | 691 | echo ' |
667 | 692 | <form id="admin_form_wrapper" action="', $scripturl, '?action=admin;area=regcenter" method="post" accept-charset="', $context['character_set'], '"> |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | <div id="personal_messages">'; |
22 | 22 | |
23 | 23 | // Show the capacity bar, if available. |
24 | - if (!empty($context['limit_bar'])) |
|
25 | - echo ' |
|
24 | + if (!empty($context['limit_bar'])) { |
|
25 | + echo ' |
|
26 | 26 | <div class="cat_bar"> |
27 | 27 | <h3 class="catbg"> |
28 | 28 | <span class="floatleft">', $txt['pm_capacity'], ':</span> |
@@ -32,14 +32,16 @@ discard block |
||
32 | 32 | <span class="floatright', $context['limit_bar']['percent'] > 90 ? ' alert' : '', '">', $context['limit_bar']['text'], '</span> |
33 | 33 | </h3> |
34 | 34 | </div>'; |
35 | + } |
|
35 | 36 | |
36 | 37 | // Message sent? Show a small indication. |
37 | - if (isset($context['pm_sent'])) |
|
38 | - echo ' |
|
38 | + if (isset($context['pm_sent'])) { |
|
39 | + echo ' |
|
39 | 40 | <div class="infobox"> |
40 | 41 | ', $txt['pm_sent'], ' |
41 | 42 | </div>'; |
42 | -} |
|
43 | + } |
|
44 | + } |
|
43 | 45 | |
44 | 46 | /** |
45 | 47 | * Just the end of the index bar, nothing special. |
@@ -68,13 +70,13 @@ discard block |
||
68 | 70 | </div> |
69 | 71 | <div class="pm_unread">'; |
70 | 72 | |
71 | - if (empty($context['unread_pms'])) |
|
72 | - echo ' |
|
73 | + if (empty($context['unread_pms'])) { |
|
74 | + echo ' |
|
73 | 75 | <div class="no_unread">', $txt['pm_no_unread'], '</div>'; |
74 | - else |
|
76 | + } else |
|
75 | 77 | { |
76 | - foreach ($context['unread_pms'] as $id_pm => $pm_details) |
|
77 | - echo ' |
|
78 | + foreach ($context['unread_pms'] as $id_pm => $pm_details) { |
|
79 | + echo ' |
|
78 | 80 | <div class="unread"> |
79 | 81 | ', !empty($pm_details['member']) ? $pm_details['member']['avatar']['image'] : '', ' |
80 | 82 | <div class="details"> |
@@ -85,6 +87,7 @@ discard block |
||
85 | 87 | </div> |
86 | 88 | </div> |
87 | 89 | </div>'; |
90 | + } |
|
88 | 91 | } |
89 | 92 | |
90 | 93 | echo ' |
@@ -193,14 +196,15 @@ discard block |
||
193 | 196 | if ($context['get_pmessage']('message', true)) |
194 | 197 | { |
195 | 198 | // Show the helpful titlebar - generally. |
196 | - if ($context['display_mode'] != 1) |
|
197 | - echo ' |
|
199 | + if ($context['display_mode'] != 1) { |
|
200 | + echo ' |
|
198 | 201 | <div class="cat_bar"> |
199 | 202 | <h3 class="catbg"> |
200 | 203 | <span id="author">', $txt['author'], '</span> |
201 | 204 | <span id="topic_title">', $txt[$context['display_mode'] == 0 ? 'messages' : 'conversation'], '</span> |
202 | 205 | </h3> |
203 | 206 | </div>'; |
207 | + } |
|
204 | 208 | |
205 | 209 | // Show a few buttons if we are in conversation mode and outputting the first message. |
206 | 210 | if ($context['display_mode'] == 2) |
@@ -228,9 +232,10 @@ discard block |
||
228 | 232 | <div class="custom_fields_above_member"> |
229 | 233 | <ul class="nolist">'; |
230 | 234 | |
231 | - foreach ($message['custom_fields']['above_member'] as $custom) |
|
232 | - echo ' |
|
235 | + foreach ($message['custom_fields']['above_member'] as $custom) { |
|
236 | + echo ' |
|
233 | 237 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
238 | + } |
|
234 | 239 | |
235 | 240 | echo ' |
236 | 241 | </ul> |
@@ -242,25 +247,28 @@ discard block |
||
242 | 247 | <a id="msg', $message['id'], '"></a>'; |
243 | 248 | |
244 | 249 | // Show online and offline buttons? |
245 | - if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest']) |
|
246 | - echo ' |
|
250 | + if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest']) { |
|
251 | + echo ' |
|
247 | 252 | <span class="' . ($message['member']['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $message['member']['online']['text'] . '"></span>'; |
253 | + } |
|
248 | 254 | |
249 | 255 | // Custom fields BEFORE the username? |
250 | - if (!empty($message['custom_fields']['before_member'])) |
|
251 | - foreach ($message['custom_fields']['before_member'] as $custom) |
|
256 | + if (!empty($message['custom_fields']['before_member'])) { |
|
257 | + foreach ($message['custom_fields']['before_member'] as $custom) |
|
252 | 258 | echo ' |
253 | 259 | <span class="custom ', $custom['col_name'], '">', $custom['value'], '</span>'; |
260 | + } |
|
254 | 261 | |
255 | 262 | // Show a link to the member's profile. |
256 | 263 | echo ' |
257 | 264 | ', $message['member']['link']; |
258 | 265 | |
259 | 266 | // Custom fields AFTER the username? |
260 | - if (!empty($message['custom_fields']['after_member'])) |
|
261 | - foreach ($message['custom_fields']['after_member'] as $custom) |
|
267 | + if (!empty($message['custom_fields']['after_member'])) { |
|
268 | + foreach ($message['custom_fields']['after_member'] as $custom) |
|
262 | 269 | echo ' |
263 | 270 | <span class="custom ', $custom['col_name'], '">', $custom['value'], '</span>'; |
271 | + } |
|
264 | 272 | |
265 | 273 | echo ' |
266 | 274 | </h4>'; |
@@ -269,48 +277,56 @@ discard block |
||
269 | 277 | <ul class="user_info">'; |
270 | 278 | |
271 | 279 | // Show the user's avatar. |
272 | - if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) |
|
273 | - echo ' |
|
280 | + if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) { |
|
281 | + echo ' |
|
274 | 282 | <li class="avatar"> |
275 | 283 | <a href="', $scripturl, '?action=profile;u=', $message['member']['id'], '">', $message['member']['avatar']['image'], '</a> |
276 | 284 | </li>'; |
285 | + } |
|
277 | 286 | |
278 | 287 | // Are there any custom fields below the avatar? |
279 | - if (!empty($message['custom_fields']['below_avatar'])) |
|
280 | - foreach ($message['custom_fields']['below_avatar'] as $custom) |
|
288 | + if (!empty($message['custom_fields']['below_avatar'])) { |
|
289 | + foreach ($message['custom_fields']['below_avatar'] as $custom) |
|
281 | 290 | echo ' |
282 | 291 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
292 | + } |
|
283 | 293 | |
284 | - if (!$message['member']['is_guest']) |
|
285 | - echo ' |
|
294 | + if (!$message['member']['is_guest']) { |
|
295 | + echo ' |
|
286 | 296 | <li class="icons">', $message['member']['group_icons'], '</li>'; |
297 | + } |
|
287 | 298 | // Show the member's primary group (like 'Administrator') if they have one. |
288 | - if (isset($message['member']['group']) && $message['member']['group'] != '') |
|
289 | - echo ' |
|
299 | + if (isset($message['member']['group']) && $message['member']['group'] != '') { |
|
300 | + echo ' |
|
290 | 301 | <li class="membergroup">', $message['member']['group'], '</li>'; |
302 | + } |
|
291 | 303 | |
292 | 304 | // Show the member's custom title, if they have one. |
293 | - if (isset($message['member']['title']) && $message['member']['title'] != '') |
|
294 | - echo ' |
|
305 | + if (isset($message['member']['title']) && $message['member']['title'] != '') { |
|
306 | + echo ' |
|
295 | 307 | <li class="title">', $message['member']['title'], '</li>'; |
308 | + } |
|
296 | 309 | |
297 | 310 | // Don't show these things for guests. |
298 | 311 | if (!$message['member']['is_guest']) |
299 | 312 | { |
300 | 313 | // Show the post group if and only if they have no other group or the option is on, and they are in a post group. |
301 | - if ((empty($modSettings['hide_post_group']) || $message['member']['group'] == '') && $message['member']['post_group'] != '') |
|
302 | - echo ' |
|
314 | + if ((empty($modSettings['hide_post_group']) || $message['member']['group'] == '') && $message['member']['post_group'] != '') { |
|
315 | + echo ' |
|
303 | 316 | <li class="postgroup">', $message['member']['post_group'], '</li>'; |
317 | + } |
|
304 | 318 | |
305 | 319 | // Show how many posts they have made. |
306 | - if (!isset($context['disabled_fields']['posts'])) |
|
307 | - echo ' |
|
320 | + if (!isset($context['disabled_fields']['posts'])) { |
|
321 | + echo ' |
|
308 | 322 | <li class="postcount">', $txt['member_postcount'], ': ', $message['member']['posts'], '</li>'; |
323 | + } |
|
309 | 324 | |
310 | 325 | // Show their personal text? |
311 | - if (!empty($modSettings['show_blurb']) && $message['member']['blurb'] != '') |
|
312 | - echo ' |
|
326 | + if (!empty($modSettings['show_blurb']) && $message['member']['blurb'] != '') { |
|
327 | + echo ' |
|
313 | 328 | <li class="blurb">', $message['member']['blurb'], '</li>'; |
329 | + } |
|
314 | 330 | |
315 | 331 | // Any custom fields to show as icons? |
316 | 332 | if (!empty($message['custom_fields']['icons'])) |
@@ -319,9 +335,10 @@ discard block |
||
319 | 335 | <li class="im_icons"> |
320 | 336 | <ol>'; |
321 | 337 | |
322 | - foreach ($message['custom_fields']['icons'] as $custom) |
|
323 | - echo ' |
|
338 | + foreach ($message['custom_fields']['icons'] as $custom) { |
|
339 | + echo ' |
|
324 | 340 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
341 | + } |
|
325 | 342 | |
326 | 343 | echo ' |
327 | 344 | </ol> |
@@ -329,25 +346,28 @@ discard block |
||
329 | 346 | } |
330 | 347 | |
331 | 348 | // Show the IP to this user for this post - because you can moderate? |
332 | - if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip'])) |
|
333 | - echo ' |
|
349 | + if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip'])) { |
|
350 | + echo ' |
|
334 | 351 | <li class="poster_ip"> |
335 | 352 | <a href="', $scripturl, '?action=', !empty($message['member']['is_guest']) ? 'trackip' : 'profile;area=tracking;sa=ip;u=' . $message['member']['id'], ';searchip=', $message['member']['ip'], '">', $message['member']['ip'], '</a> <a href="', $scripturl, '?action=helpadmin;help=see_admin_ip" onclick="return reqOverlayDiv(this.href);" class="help">(?)</a> |
336 | 353 | </li>'; |
354 | + } |
|
337 | 355 | |
338 | 356 | // Or, should we show it because this is you? |
339 | - elseif ($message['can_see_ip']) |
|
340 | - echo ' |
|
357 | + elseif ($message['can_see_ip']) { |
|
358 | + echo ' |
|
341 | 359 | <li class="poster_ip"> |
342 | 360 | <a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $message['member']['ip'], '</a> |
343 | 361 | </li>'; |
362 | + } |
|
344 | 363 | |
345 | 364 | // Okay, you are logged in, then we can show something about why IPs are logged... |
346 | - else |
|
347 | - echo ' |
|
365 | + else { |
|
366 | + echo ' |
|
348 | 367 | <li class="poster_ip"> |
349 | 368 | <a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $txt['logged'], '</a> |
350 | 369 | </li>'; |
370 | + } |
|
351 | 371 | |
352 | 372 | // Show the profile, website, email address, and personal message buttons. |
353 | 373 | if ($message['member']['show_profile_buttons']) |
@@ -357,24 +377,28 @@ discard block |
||
357 | 377 | <ol class="profile_icons">'; |
358 | 378 | |
359 | 379 | // Show the profile button |
360 | - if ($message['member']['can_view_profile']) |
|
361 | - echo ' |
|
380 | + if ($message['member']['can_view_profile']) { |
|
381 | + echo ' |
|
362 | 382 | <li><a href="', $message['member']['href'], '">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/icons/profile_sm.png" alt="' . $txt['view_profile'] . '" title="' . $txt['view_profile'] . '">' : $txt['view_profile']), '</a></li>'; |
383 | + } |
|
363 | 384 | |
364 | 385 | // Don't show an icon if they haven't specified a website. |
365 | - if ($message['member']['website']['url'] != '' && !isset($context['disabled_fields']['website'])) |
|
366 | - echo ' |
|
386 | + if ($message['member']['website']['url'] != '' && !isset($context['disabled_fields']['website'])) { |
|
387 | + echo ' |
|
367 | 388 | <li><a href="', $message['member']['website']['url'], '" title="' . $message['member']['website']['title'] . '" target="_blank" rel="noopener">', ($settings['use_image_buttons'] ? '<span class="generic_icons www centericon" title="' . $message['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>'; |
389 | + } |
|
368 | 390 | |
369 | 391 | // Don't show the email address if they want it hidden. |
370 | - if ($message['member']['show_email']) |
|
371 | - echo ' |
|
392 | + if ($message['member']['show_email']) { |
|
393 | + echo ' |
|
372 | 394 | <li><a href="mailto:', $message['member']['email'], '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a></li>'; |
395 | + } |
|
373 | 396 | |
374 | 397 | // Since we know this person isn't a guest, you *can* message them. |
375 | - if ($context['can_send_pm']) |
|
376 | - echo ' |
|
398 | + if ($context['can_send_pm']) { |
|
399 | + echo ' |
|
377 | 400 | <li><a href="', $scripturl, '?action=pm;sa=send;u=', $message['member']['id'], '" title="', $message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline'], '">', $settings['use_image_buttons'] ? '<span class="generic_icons im_' . ($message['member']['online']['is_online'] ? 'on' : 'off') . ' centericon" title="' . ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']) . '"></span> ' : ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']), '</a></li>'; |
401 | + } |
|
378 | 402 | |
379 | 403 | echo ' |
380 | 404 | </ol> |
@@ -382,21 +406,24 @@ discard block |
||
382 | 406 | } |
383 | 407 | |
384 | 408 | // Any custom fields for standard placement? |
385 | - if (!empty($message['custom_fields']['standard'])) |
|
386 | - foreach ($message['custom_fields']['standard'] as $custom) |
|
409 | + if (!empty($message['custom_fields']['standard'])) { |
|
410 | + foreach ($message['custom_fields']['standard'] as $custom) |
|
387 | 411 | echo ' |
388 | 412 | <li class="custom ', $custom['col_name'] ,'">', $custom['title'], ': ', $custom['value'], '</li>'; |
413 | + } |
|
389 | 414 | |
390 | 415 | // Are we showing the warning status? |
391 | - if ($message['member']['can_see_warning']) |
|
392 | - echo ' |
|
416 | + if ($message['member']['can_see_warning']) { |
|
417 | + echo ' |
|
393 | 418 | <li class="warning">', $context['can_issue_warning'] ? '<a href="' . $scripturl . '?action=profile;area=issuewarning;u=' . $message['member']['id'] . '">' : '', '<span class="generic_icons warning_', $message['member']['warning_status'], '"></span>', $context['can_issue_warning'] ? '</a>' : '', '<span class="warn_', $message['member']['warning_status'], '">', $txt['warn_' . $message['member']['warning_status']], '</span></li>'; |
419 | + } |
|
394 | 420 | |
395 | 421 | // Are there any custom fields to show at the bottom of the poster info? |
396 | - if (!empty($message['custom_fields']['bottom_poster'])) |
|
397 | - foreach ($message['custom_fields']['bottom_poster'] as $custom) |
|
422 | + if (!empty($message['custom_fields']['bottom_poster'])) { |
|
423 | + foreach ($message['custom_fields']['bottom_poster'] as $custom) |
|
398 | 424 | echo ' |
399 | 425 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
426 | + } |
|
400 | 427 | } |
401 | 428 | |
402 | 429 | // Done with the information about the poster... on to the post itself. |
@@ -415,25 +442,29 @@ discard block |
||
415 | 442 | <span class="smalltext">« <strong> ', $txt['sent_to'], ':</strong> '; |
416 | 443 | |
417 | 444 | // People it was sent directly to.... |
418 | - if (!empty($message['recipients']['to'])) |
|
419 | - echo implode(', ', $message['recipients']['to']); |
|
445 | + if (!empty($message['recipients']['to'])) { |
|
446 | + echo implode(', ', $message['recipients']['to']); |
|
447 | + } |
|
420 | 448 | |
421 | 449 | // Otherwise, we're just going to say "some people"... |
422 | - elseif ($context['folder'] != 'sent') |
|
423 | - echo '(', $txt['pm_undisclosed_recipients'], ')'; |
|
450 | + elseif ($context['folder'] != 'sent') { |
|
451 | + echo '(', $txt['pm_undisclosed_recipients'], ')'; |
|
452 | + } |
|
424 | 453 | |
425 | 454 | echo ' |
426 | 455 | <strong> ', $txt['on'], ':</strong> ', $message['time'], ' » |
427 | 456 | </span>'; |
428 | 457 | |
429 | 458 | // If we're in the sent items, show who it was sent to besides the "To:" people. |
430 | - if (!empty($message['recipients']['bcc'])) |
|
431 | - echo '<br> |
|
459 | + if (!empty($message['recipients']['bcc'])) { |
|
460 | + echo '<br> |
|
432 | 461 | <span class="smalltext">« <strong> ', $txt['pm_bcc'], ':</strong> ', implode(', ', $message['recipients']['bcc']), ' »</span>'; |
462 | + } |
|
433 | 463 | |
434 | - if (!empty($message['is_replied_to'])) |
|
435 | - echo '<br> |
|
464 | + if (!empty($message['is_replied_to'])) { |
|
465 | + echo '<br> |
|
436 | 466 | <span class="smalltext">« ', $context['folder'] == 'sent' ? $txt['pm_sent_is_replied_to'] : $txt['pm_is_replied_to'], ' »</span>'; |
467 | + } |
|
437 | 468 | |
438 | 469 | echo ' |
439 | 470 | </div><!-- .keyinfo --> |
@@ -443,13 +474,15 @@ discard block |
||
443 | 474 | ', $message['body'], ' |
444 | 475 | </div>'; |
445 | 476 | |
446 | - if ($message['can_report'] || $context['can_send_pm']) |
|
447 | - echo ' |
|
477 | + if ($message['can_report'] || $context['can_send_pm']) { |
|
478 | + echo ' |
|
448 | 479 | <div class="under_message">'; |
480 | + } |
|
449 | 481 | |
450 | - if ($message['can_report']) |
|
451 | - echo ' |
|
482 | + if ($message['can_report']) { |
|
483 | + echo ' |
|
452 | 484 | <a href="' . $scripturl . '?action=pm;sa=report;l=' . $context['current_label_id'] . ';pmsg=' . $message['id'] . '" class="floatright">' . $txt['pm_report_to_admin'] . '</a>'; |
485 | + } |
|
453 | 486 | |
454 | 487 | echo ' |
455 | 488 | <ul class="quickbuttons">'; |
@@ -461,32 +494,36 @@ discard block |
||
461 | 494 | if (!$message['member']['is_guest']) |
462 | 495 | { |
463 | 496 | // Is there than more than one recipient you can reply to? |
464 | - if ($message['number_recipients'] > 1) |
|
465 | - echo ' |
|
497 | + if ($message['number_recipients'] > 1) { |
|
498 | + echo ' |
|
466 | 499 | <li><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote;u=all"><span class="generic_icons reply_all_button"></span>', $txt['reply_to_all'], '</a></li>'; |
500 | + } |
|
467 | 501 | |
468 | 502 | echo ' |
469 | 503 | <li><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';u=', $message['member']['id'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li> |
470 | 504 | <li><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote', $context['folder'] == 'sent' ? '' : ';u=' . $message['member']['id'], '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>'; |
471 | 505 | } |
472 | 506 | // This is for "forwarding" - even if the member is gone. |
473 | - else |
|
474 | - echo ' |
|
507 | + else { |
|
508 | + echo ' |
|
475 | 509 | <li><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote"><span class="generic_icons quote"></span>', $txt['reply_quote'], '</a></li>'; |
510 | + } |
|
476 | 511 | } |
477 | 512 | echo ' |
478 | 513 | <li><a href="', $scripturl, '?action=pm;sa=pmactions;pm_actions%5b', $message['id'], '%5D=delete;f=', $context['folder'], ';start=', $context['start'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', addslashes($txt['remove_message_question']), '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['delete'], '</a></li>'; |
479 | 514 | |
480 | - if (empty($context['display_mode'])) |
|
481 | - echo ' |
|
515 | + if (empty($context['display_mode'])) { |
|
516 | + echo ' |
|
482 | 517 | <li><input type="checkbox" name="pms[]" id="deletedisplay', $message['id'], '" value="', $message['id'], '" onclick="document.getElementById(\'deletelisting', $message['id'], '\').checked = this.checked;"></li>'; |
518 | + } |
|
483 | 519 | |
484 | 520 | echo ' |
485 | 521 | </ul>'; |
486 | 522 | |
487 | - if ($message['can_report'] || $context['can_send_pm']) |
|
488 | - echo ' |
|
523 | + if ($message['can_report'] || $context['can_send_pm']) { |
|
524 | + echo ' |
|
489 | 525 | </div><!-- .under_message -->'; |
526 | + } |
|
490 | 527 | |
491 | 528 | // Are there any custom profile fields for above the signature? |
492 | 529 | if (!empty($message['custom_fields']['above_signature'])) |
@@ -495,9 +532,10 @@ discard block |
||
495 | 532 | <div class="custom_fields_above_signature"> |
496 | 533 | <ul class="nolist">'; |
497 | 534 | |
498 | - foreach ($message['custom_fields']['above_signature'] as $custom) |
|
499 | - echo ' |
|
535 | + foreach ($message['custom_fields']['above_signature'] as $custom) { |
|
536 | + echo ' |
|
500 | 537 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
538 | + } |
|
501 | 539 | |
502 | 540 | echo ' |
503 | 541 | </ul> |
@@ -505,11 +543,12 @@ discard block |
||
505 | 543 | } |
506 | 544 | |
507 | 545 | // Show the member's signature? |
508 | - if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) |
|
509 | - echo ' |
|
546 | + if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) { |
|
547 | + echo ' |
|
510 | 548 | <div class="signature"> |
511 | 549 | ', $message['member']['signature'], ' |
512 | 550 | </div>'; |
551 | + } |
|
513 | 552 | |
514 | 553 | // Are there any custom profile fields for below the signature? |
515 | 554 | if (!empty($message['custom_fields']['below_signature'])) |
@@ -518,9 +557,10 @@ discard block |
||
518 | 557 | <div class="custom_fields_below_signature"> |
519 | 558 | <ul class="nolist">'; |
520 | 559 | |
521 | - foreach ($message['custom_fields']['below_signature'] as $custom) |
|
522 | - echo ' |
|
560 | + foreach ($message['custom_fields']['below_signature'] as $custom) { |
|
561 | + echo ' |
|
523 | 562 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
563 | + } |
|
524 | 564 | |
525 | 565 | echo ' |
526 | 566 | </ul> |
@@ -547,10 +587,11 @@ discard block |
||
547 | 587 | echo ' |
548 | 588 | <option value="" disabled>', $txt['pm_msg_label_apply'], ':</option>'; |
549 | 589 | |
550 | - foreach ($context['labels'] as $label) |
|
551 | - if (!isset($message['labels'][$label['id']])) |
|
590 | + foreach ($context['labels'] as $label) { |
|
591 | + if (!isset($message['labels'][$label['id']])) |
|
552 | 592 | echo ' |
553 | 593 | <option value="', $label['id'], '">', $label['name'], '</option>'; |
594 | + } |
|
554 | 595 | } |
555 | 596 | |
556 | 597 | // ... and are there any that can be removed? |
@@ -559,9 +600,10 @@ discard block |
||
559 | 600 | echo ' |
560 | 601 | <option value="" disabled>', $txt['pm_msg_label_remove'], ':</option>'; |
561 | 602 | |
562 | - foreach ($message['labels'] as $label) |
|
563 | - echo ' |
|
603 | + foreach ($message['labels'] as $label) { |
|
604 | + echo ' |
|
564 | 605 | <option value="', $label['id'], '"> ', $label['name'], '</option>'; |
606 | + } |
|
565 | 607 | } |
566 | 608 | echo ' |
567 | 609 | </select> |
@@ -580,14 +622,15 @@ discard block |
||
580 | 622 | </div><!-- .windowbg -->'; |
581 | 623 | } |
582 | 624 | |
583 | - if (empty($context['display_mode'])) |
|
584 | - echo ' |
|
625 | + if (empty($context['display_mode'])) { |
|
626 | + echo ' |
|
585 | 627 | <div class="pagesection"> |
586 | 628 | <div class="floatleft">', $context['page_index'], '</div> |
587 | 629 | <div class="floatright"> |
588 | 630 | <input type="submit" name="del_selected" value="', $txt['quickmod_delete_selected'], '" onclick="if (!confirm(\'', $txt['delete_selected_confirm'], '\')) return false;" class="button"> |
589 | 631 | </div> |
590 | 632 | </div>'; |
633 | + } |
|
591 | 634 | |
592 | 635 | // Show a few buttons if we are in conversation mode and outputting the first message. |
593 | 636 | elseif ($context['display_mode'] == 2 && isset($context['conversation_buttons'])) |
@@ -647,11 +690,12 @@ discard block |
||
647 | 690 | </thead> |
648 | 691 | <tbody>'; |
649 | 692 | |
650 | - if (!$context['show_delete']) |
|
651 | - echo ' |
|
693 | + if (!$context['show_delete']) { |
|
694 | + echo ' |
|
652 | 695 | <tr class="windowbg"> |
653 | 696 | <td colspan="5">', $txt['pm_alert_none'], '</td> |
654 | 697 | </tr>'; |
698 | + } |
|
655 | 699 | |
656 | 700 | while ($message = $context['get_pmessage']('subject')) |
657 | 701 | { |
@@ -709,17 +753,19 @@ discard block |
||
709 | 753 | |
710 | 754 | foreach ($context['labels'] as $label) |
711 | 755 | { |
712 | - if ($label['id'] != $context['current_label_id']) |
|
713 | - echo ' |
|
756 | + if ($label['id'] != $context['current_label_id']) { |
|
757 | + echo ' |
|
714 | 758 | <option value="add_', $label['id'], '"> ', $label['name'], '</option>'; |
759 | + } |
|
715 | 760 | } |
716 | 761 | |
717 | 762 | echo ' |
718 | 763 | <option value="" disabled>', $txt['pm_msg_label_remove'], ':</option>'; |
719 | 764 | |
720 | - foreach ($context['labels'] as $label) |
|
721 | - echo ' |
|
765 | + foreach ($context['labels'] as $label) { |
|
766 | + echo ' |
|
722 | 767 | <option value="rem_', $label['id'], '"> ', $label['name'], '</option>'; |
768 | + } |
|
723 | 769 | |
724 | 770 | echo ' |
725 | 771 | </select> |
@@ -750,11 +796,12 @@ discard block |
||
750 | 796 | <h3 class="catbg">', $txt['pm_search_title'], '</h3> |
751 | 797 | </div>'; |
752 | 798 | |
753 | - if (!empty($context['search_errors'])) |
|
754 | - echo ' |
|
799 | + if (!empty($context['search_errors'])) { |
|
800 | + echo ' |
|
755 | 801 | <div class="errorbox"> |
756 | 802 | ', implode('<br>', $context['search_errors']['messages']), ' |
757 | 803 | </div>'; |
804 | + } |
|
758 | 805 | |
759 | 806 | |
760 | 807 | echo ' |
@@ -803,9 +850,10 @@ discard block |
||
803 | 850 | </dd> |
804 | 851 | </dl>'; |
805 | 852 | |
806 | - if (!$context['currently_using_labels']) |
|
807 | - echo ' |
|
853 | + if (!$context['currently_using_labels']) { |
|
854 | + echo ' |
|
808 | 855 | <input type="submit" name="pm_search" value="', $txt['pm_search_go'], '" class="button">'; |
856 | + } |
|
809 | 857 | |
810 | 858 | echo ' |
811 | 859 | <br class="clear_right"> |
@@ -826,12 +874,13 @@ discard block |
||
826 | 874 | <div id="advanced_panel_div"> |
827 | 875 | <ul id="searchLabelsExpand">'; |
828 | 876 | |
829 | - foreach ($context['search_labels'] as $label) |
|
830 | - echo ' |
|
877 | + foreach ($context['search_labels'] as $label) { |
|
878 | + echo ' |
|
831 | 879 | <li> |
832 | 880 | <label for="searchlabel_', $label['id'], '"><input type="checkbox" id="searchlabel_', $label['id'], '" name="searchlabel[', $label['id'], ']" value="', $label['id'], '"', $label['checked'] ? ' checked' : '', '> |
833 | 881 | ', $label['name'], '</label> |
834 | 882 | </li>'; |
883 | + } |
|
835 | 884 | |
836 | 885 | echo ' |
837 | 886 | </ul> |
@@ -893,8 +942,8 @@ discard block |
||
893 | 942 | </div>'; |
894 | 943 | |
895 | 944 | // Complete results? |
896 | - if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages'])) |
|
897 | - echo ' |
|
945 | + if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages'])) { |
|
946 | + echo ' |
|
898 | 947 | <table class="table_grid"> |
899 | 948 | <thead> |
900 | 949 | <tr class="title_bar"> |
@@ -904,6 +953,7 @@ discard block |
||
904 | 953 | </tr> |
905 | 954 | </thead> |
906 | 955 | <tbody>'; |
956 | + } |
|
907 | 957 | |
908 | 958 | // Print each message out... |
909 | 959 | foreach ($context['personal_messages'] as $message) |
@@ -923,12 +973,14 @@ discard block |
||
923 | 973 | |
924 | 974 | // Show the recipients. |
925 | 975 | // @todo This doesn't deal with the sent item searching quite right for bcc. |
926 | - if (!empty($message['recipients']['to'])) |
|
927 | - echo implode(', ', $message['recipients']['to']); |
|
976 | + if (!empty($message['recipients']['to'])) { |
|
977 | + echo implode(', ', $message['recipients']['to']); |
|
978 | + } |
|
928 | 979 | |
929 | 980 | // Otherwise, we're just going to say "some people"... |
930 | - elseif ($context['folder'] != 'sent') |
|
931 | - echo '(', $txt['pm_undisclosed_recipients'], ')'; |
|
981 | + elseif ($context['folder'] != 'sent') { |
|
982 | + echo '(', $txt['pm_undisclosed_recipients'], ')'; |
|
983 | + } |
|
932 | 984 | |
933 | 985 | echo ' |
934 | 986 | </h3> |
@@ -943,15 +995,17 @@ discard block |
||
943 | 995 | $reply_button = create_button('im_reply.png', 'reply', 'reply', 'class="centericon"'); |
944 | 996 | |
945 | 997 | // You can only reply if they are not a guest... |
946 | - if (!$message['member']['is_guest']) |
|
947 | - echo ' |
|
998 | + if (!$message['member']['is_guest']) { |
|
999 | + echo ' |
|
948 | 1000 | <a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote;u=', $context['folder'] == 'sent' ? '' : $message['member']['id'], '">', $quote_button , '</a>', $context['menu_separator'], ' |
949 | 1001 | <a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';u=', $message['member']['id'], '">', $reply_button , '</a> ', $context['menu_separator']; |
1002 | + } |
|
950 | 1003 | |
951 | 1004 | // This is for "forwarding" - even if the member is gone. |
952 | - else |
|
953 | - echo ' |
|
1005 | + else { |
|
1006 | + echo ' |
|
954 | 1007 | <a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote">', $quote_button , '</a>', $context['menu_separator']; |
1008 | + } |
|
955 | 1009 | } |
956 | 1010 | |
957 | 1011 | echo ' |
@@ -960,27 +1014,30 @@ discard block |
||
960 | 1014 | } |
961 | 1015 | // Otherwise just a simple list! |
962 | 1016 | // @todo No context at all of the search? |
963 | - else |
|
964 | - echo ' |
|
1017 | + else { |
|
1018 | + echo ' |
|
965 | 1019 | <tr class="windowbg"> |
966 | 1020 | <td>', $message['time'], '</td> |
967 | 1021 | <td>', $message['link'], '</td> |
968 | 1022 | <td>', $message['member']['link'], '</td> |
969 | 1023 | </tr>'; |
1024 | + } |
|
970 | 1025 | } |
971 | 1026 | |
972 | 1027 | // Finish off the page... |
973 | - if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages'])) |
|
974 | - echo ' |
|
1028 | + if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages'])) { |
|
1029 | + echo ' |
|
975 | 1030 | </tbody> |
976 | 1031 | </table>'; |
1032 | + } |
|
977 | 1033 | |
978 | 1034 | // No results? |
979 | - if (empty($context['personal_messages'])) |
|
980 | - echo ' |
|
1035 | + if (empty($context['personal_messages'])) { |
|
1036 | + echo ' |
|
981 | 1037 | <div class="windowbg"> |
982 | 1038 | <p class="centertext">', $txt['pm_search_none_found'], '</p> |
983 | 1039 | </div>'; |
1040 | + } |
|
984 | 1041 | |
985 | 1042 | echo ' |
986 | 1043 | <div class="pagesection"> |
@@ -1005,15 +1062,17 @@ discard block |
||
1005 | 1062 | </div> |
1006 | 1063 | <div class="windowbg">'; |
1007 | 1064 | |
1008 | - if (!empty($context['send_log']['sent'])) |
|
1009 | - foreach ($context['send_log']['sent'] as $log_entry) |
|
1065 | + if (!empty($context['send_log']['sent'])) { |
|
1066 | + foreach ($context['send_log']['sent'] as $log_entry) |
|
1010 | 1067 | echo ' |
1011 | 1068 | <span class="error">', $log_entry, '</span><br>'; |
1069 | + } |
|
1012 | 1070 | |
1013 | - if (!empty($context['send_log']['failed'])) |
|
1014 | - foreach ($context['send_log']['failed'] as $log_entry) |
|
1071 | + if (!empty($context['send_log']['failed'])) { |
|
1072 | + foreach ($context['send_log']['failed'] as $log_entry) |
|
1015 | 1073 | echo ' |
1016 | 1074 | <span class="error">', $log_entry, '</span><br>'; |
1075 | + } |
|
1017 | 1076 | |
1018 | 1077 | echo ' |
1019 | 1078 | </div> |
@@ -1061,12 +1120,13 @@ discard block |
||
1061 | 1120 | </dl> |
1062 | 1121 | </div>'; |
1063 | 1122 | |
1064 | - if (!empty($modSettings['drafts_pm_enabled'])) |
|
1065 | - echo ' |
|
1123 | + if (!empty($modSettings['drafts_pm_enabled'])) { |
|
1124 | + echo ' |
|
1066 | 1125 | <div id="draft_section" class="infobox"', isset($context['draft_saved']) ? '' : ' style="display: none;"', '>', |
1067 | 1126 | sprintf($txt['draft_pm_saved'], $scripturl . '?action=pm;sa=showpmdrafts'), ' |
1068 | 1127 | ', (!empty($modSettings['drafts_keep_days']) ? ' <strong>' . sprintf($txt['draft_save_warning'], $modSettings['drafts_keep_days']) . '</strong>' : ''), ' |
1069 | 1128 | </div>'; |
1129 | + } |
|
1070 | 1130 | |
1071 | 1131 | echo ' |
1072 | 1132 | <dl id="post_header">'; |
@@ -1132,22 +1192,24 @@ discard block |
||
1132 | 1192 | <dt><strong>', $txt['subject'], '</strong></dt> |
1133 | 1193 | <dd><strong>', $txt['draft_saved_on'], '</strong></dd>'; |
1134 | 1194 | |
1135 | - foreach ($context['drafts'] as $draft) |
|
1136 | - echo ' |
|
1195 | + foreach ($context['drafts'] as $draft) { |
|
1196 | + echo ' |
|
1137 | 1197 | <dt>', $draft['link'], '</dt> |
1138 | 1198 | <dd>', $draft['poster_time'], '</dd>'; |
1199 | + } |
|
1139 | 1200 | echo ' |
1140 | 1201 | </dl> |
1141 | 1202 | </div>'; |
1142 | 1203 | } |
1143 | 1204 | |
1144 | 1205 | // Require an image to be typed to save spamming? |
1145 | - if ($context['require_verification']) |
|
1146 | - echo ' |
|
1206 | + if ($context['require_verification']) { |
|
1207 | + echo ' |
|
1147 | 1208 | <div class="post_verification"> |
1148 | 1209 | <strong>', $txt['pm_visual_verification_label'], ':</strong> |
1149 | 1210 | ', template_control_verification($context['visual_verification_id'], 'all'), ' |
1150 | 1211 | </div>'; |
1212 | + } |
|
1151 | 1213 | |
1152 | 1214 | // Send, Preview, spellcheck buttons. |
1153 | 1215 | echo ' |
@@ -1265,8 +1327,8 @@ discard block |
||
1265 | 1327 | }'; |
1266 | 1328 | |
1267 | 1329 | // Code for showing and hiding drafts |
1268 | - if (!empty($context['drafts'])) |
|
1269 | - echo ' |
|
1330 | + if (!empty($context['drafts'])) { |
|
1331 | + echo ' |
|
1270 | 1332 | var oSwapDraftOptions = new smc_Toggle({ |
1271 | 1333 | bToggleEnabled: true, |
1272 | 1334 | bCurrentlyCollapsed: true, |
@@ -1288,13 +1350,14 @@ discard block |
||
1288 | 1350 | } |
1289 | 1351 | ] |
1290 | 1352 | });'; |
1353 | + } |
|
1291 | 1354 | |
1292 | 1355 | echo ' |
1293 | 1356 | </script>'; |
1294 | 1357 | |
1295 | 1358 | // Show the message you're replying to. |
1296 | - if ($context['reply']) |
|
1297 | - echo ' |
|
1359 | + if ($context['reply']) { |
|
1360 | + echo ' |
|
1298 | 1361 | <br><br> |
1299 | 1362 | <div class="cat_bar"> |
1300 | 1363 | <h3 class="catbg">', $txt['subject'], ': ', $context['quoted_message']['subject'], '</h3> |
@@ -1308,6 +1371,7 @@ discard block |
||
1308 | 1371 | ', $context['quoted_message']['body'], ' |
1309 | 1372 | </div> |
1310 | 1373 | <br class="clear">'; |
1374 | + } |
|
1311 | 1375 | |
1312 | 1376 | echo ' |
1313 | 1377 | <script> |
@@ -1319,23 +1383,25 @@ discard block |
||
1319 | 1383 | sToControlId: \'to_control\', |
1320 | 1384 | aToRecipients: ['; |
1321 | 1385 | |
1322 | - foreach ($context['recipients']['to'] as $i => $member) |
|
1323 | - echo ' |
|
1386 | + foreach ($context['recipients']['to'] as $i => $member) { |
|
1387 | + echo ' |
|
1324 | 1388 | { |
1325 | 1389 | sItemId: ', JavaScriptEscape($member['id']), ', |
1326 | 1390 | sItemName: ', JavaScriptEscape($member['name']), ' |
1327 | 1391 | }', $i == count($context['recipients']['to']) - 1 ? '' : ','; |
1392 | + } |
|
1328 | 1393 | |
1329 | 1394 | echo ' |
1330 | 1395 | ], |
1331 | 1396 | aBccRecipients: ['; |
1332 | 1397 | |
1333 | - foreach ($context['recipients']['bcc'] as $i => $member) |
|
1334 | - echo ' |
|
1398 | + foreach ($context['recipients']['bcc'] as $i => $member) { |
|
1399 | + echo ' |
|
1335 | 1400 | { |
1336 | 1401 | sItemId: ', JavaScriptEscape($member['id']), ', |
1337 | 1402 | sItemName: ', JavaScriptEscape($member['name']), ' |
1338 | 1403 | }', $i == count($context['recipients']['bcc']) - 1 ? '' : ','; |
1404 | + } |
|
1339 | 1405 | |
1340 | 1406 | echo ' |
1341 | 1407 | ], |
@@ -1424,26 +1490,28 @@ discard block |
||
1424 | 1490 | </th> |
1425 | 1491 | <th class="centertext table_icon">'; |
1426 | 1492 | |
1427 | - if (count($context['labels']) > 2) |
|
1428 | - echo ' |
|
1493 | + if (count($context['labels']) > 2) { |
|
1494 | + echo ' |
|
1429 | 1495 | <input type="checkbox" onclick="invertAll(this, this.form);">'; |
1496 | + } |
|
1430 | 1497 | |
1431 | 1498 | echo ' |
1432 | 1499 | </th> |
1433 | 1500 | </tr> |
1434 | 1501 | </thead> |
1435 | 1502 | <tbody>'; |
1436 | - if (count($context['labels']) < 2) |
|
1437 | - echo ' |
|
1503 | + if (count($context['labels']) < 2) { |
|
1504 | + echo ' |
|
1438 | 1505 | <tr class="windowbg"> |
1439 | 1506 | <td colspan="2">', $txt['pm_labels_no_exist'], '</td> |
1440 | 1507 | </tr>'; |
1441 | - else |
|
1508 | + } else |
|
1442 | 1509 | { |
1443 | 1510 | foreach ($context['labels'] as $label) |
1444 | 1511 | { |
1445 | - if ($label['id'] == -1) |
|
1446 | - continue; |
|
1512 | + if ($label['id'] == -1) { |
|
1513 | + continue; |
|
1514 | + } |
|
1447 | 1515 | |
1448 | 1516 | echo ' |
1449 | 1517 | <tr class="windowbg"> |
@@ -1458,12 +1526,13 @@ discard block |
||
1458 | 1526 | </tbody> |
1459 | 1527 | </table>'; |
1460 | 1528 | |
1461 | - if (!count($context['labels']) < 2) |
|
1462 | - echo ' |
|
1529 | + if (!count($context['labels']) < 2) { |
|
1530 | + echo ' |
|
1463 | 1531 | <div class="padding"> |
1464 | 1532 | <input type="submit" name="save" value="', $txt['save'], '" class="button"> |
1465 | 1533 | <input type="submit" name="delete" value="', $txt['quickmod_delete_selected'], '" data-confirm="', $txt['pm_labels_delete'] ,'" class="button you_sure"> |
1466 | 1534 | </div>'; |
1535 | + } |
|
1467 | 1536 | |
1468 | 1537 | echo ' |
1469 | 1538 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -1520,9 +1589,10 @@ discard block |
||
1520 | 1589 | <select name="id_admin"> |
1521 | 1590 | <option value="0">', $txt['pm_report_all_admins'], '</option>'; |
1522 | 1591 | |
1523 | - foreach ($context['admins'] as $id => $name) |
|
1524 | - echo ' |
|
1592 | + foreach ($context['admins'] as $id => $name) { |
|
1593 | + echo ' |
|
1525 | 1594 | <option value="', $id, '">', $name, '</option>'; |
1595 | + } |
|
1526 | 1596 | |
1527 | 1597 | echo ' |
1528 | 1598 | </select> |
@@ -1585,9 +1655,10 @@ discard block |
||
1585 | 1655 | </th> |
1586 | 1656 | <th class="centertext table_icon">'; |
1587 | 1657 | |
1588 | - if (!empty($context['rules'])) |
|
1589 | - echo ' |
|
1658 | + if (!empty($context['rules'])) { |
|
1659 | + echo ' |
|
1590 | 1660 | <input type="checkbox" onclick="invertAll(this, this.form);">'; |
1661 | + } |
|
1591 | 1662 | |
1592 | 1663 | echo ' |
1593 | 1664 | </th> |
@@ -1595,16 +1666,17 @@ discard block |
||
1595 | 1666 | </thead> |
1596 | 1667 | <tbody>'; |
1597 | 1668 | |
1598 | - if (empty($context['rules'])) |
|
1599 | - echo ' |
|
1669 | + if (empty($context['rules'])) { |
|
1670 | + echo ' |
|
1600 | 1671 | <tr class="windowbg"> |
1601 | 1672 | <td colspan="2"> |
1602 | 1673 | ', $txt['pm_rules_none'], ' |
1603 | 1674 | </td> |
1604 | 1675 | </tr>'; |
1676 | + } |
|
1605 | 1677 | |
1606 | - foreach ($context['rules'] as $rule) |
|
1607 | - echo ' |
|
1678 | + foreach ($context['rules'] as $rule) { |
|
1679 | + echo ' |
|
1608 | 1680 | <tr class="windowbg"> |
1609 | 1681 | <td> |
1610 | 1682 | <a href="', $scripturl, '?action=pm;sa=manrules;add;rid=', $rule['id'], '">', $rule['name'], '</a> |
@@ -1613,6 +1685,7 @@ discard block |
||
1613 | 1685 | <input type="checkbox" name="delrule[', $rule['id'], ']"> |
1614 | 1686 | </td> |
1615 | 1687 | </tr>'; |
1688 | + } |
|
1616 | 1689 | |
1617 | 1690 | echo ' |
1618 | 1691 | </tbody> |
@@ -1620,14 +1693,16 @@ discard block |
||
1620 | 1693 | <div class="righttext"> |
1621 | 1694 | <a class="button" href="', $scripturl, '?action=pm;sa=manrules;add;rid=0">', $txt['pm_add_rule'], '</a>'; |
1622 | 1695 | |
1623 | - if (!empty($context['rules'])) |
|
1624 | - echo ' |
|
1696 | + if (!empty($context['rules'])) { |
|
1697 | + echo ' |
|
1625 | 1698 | [<a href="', $scripturl, '?action=pm;sa=manrules;apply;', $context['session_var'], '=', $context['session_id'], '" onclick="return confirm(\'', $txt['pm_js_apply_rules_confirm'], '\');">', $txt['pm_apply_rules'], '</a>]'; |
1699 | + } |
|
1626 | 1700 | |
1627 | - if (!empty($context['rules'])) |
|
1628 | - echo ' |
|
1701 | + if (!empty($context['rules'])) { |
|
1702 | + echo ' |
|
1629 | 1703 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
1630 | 1704 | <input type="submit" name="delselected" value="', $txt['pm_delete_selected_rule'], '" data-confirm="', $txt['pm_js_delete_rule_confirm'] ,'" class="button smalltext you_sure">'; |
1705 | + } |
|
1631 | 1706 | |
1632 | 1707 | echo ' |
1633 | 1708 | </div> |
@@ -1649,14 +1724,16 @@ discard block |
||
1649 | 1724 | var groups = new Array() |
1650 | 1725 | var labels = new Array()'; |
1651 | 1726 | |
1652 | - foreach ($context['groups'] as $id => $title) |
|
1653 | - echo ' |
|
1727 | + foreach ($context['groups'] as $id => $title) { |
|
1728 | + echo ' |
|
1654 | 1729 | groups[', $id, '] = "', addslashes($title), '";'; |
1730 | + } |
|
1655 | 1731 | |
1656 | - foreach ($context['labels'] as $label) |
|
1657 | - if ($label['id'] != -1) |
|
1732 | + foreach ($context['labels'] as $label) { |
|
1733 | + if ($label['id'] != -1) |
|
1658 | 1734 | echo ' |
1659 | 1735 | labels[', ($label['id']), '] = "', addslashes($label['name']), '";'; |
1736 | + } |
|
1660 | 1737 | |
1661 | 1738 | echo ' |
1662 | 1739 | function addCriteriaOption() |
@@ -1671,8 +1748,9 @@ discard block |
||
1671 | 1748 | |
1672 | 1749 | setOuterHTML(document.getElementById("criteriaAddHere"), \'<br><select name="ruletype[\' + criteriaNum + \']" id="ruletype\' + criteriaNum + \'" onchange="updateRuleDef(\' + criteriaNum + \'); rebuildRuleDesc();"><option value="">', addslashes($txt['pm_rule_criteria_pick']), ':<\' + \'/option><option value="mid">', addslashes($txt['pm_rule_mid']), '<\' + \'/option><option value="gid">', addslashes($txt['pm_rule_gid']), '<\' + \'/option><option value="sub">', addslashes($txt['pm_rule_sub']), '<\' + \'/option><option value="msg">', addslashes($txt['pm_rule_msg']), '<\' + \'/option><option value="bud">', addslashes($txt['pm_rule_bud']), '<\' + \'/option><\' + \'/select> <span id="defdiv\' + criteriaNum + \'" style="display: none;"><input type="text" name="ruledef[\' + criteriaNum + \']" id="ruledef\' + criteriaNum + \'" onkeyup="rebuildRuleDesc();" value=""><\' + \'/span><span id="defseldiv\' + criteriaNum + \'" style="display: none;"><select name="ruledefgroup[\' + criteriaNum + \']" id="ruledefgroup\' + criteriaNum + \'" onchange="rebuildRuleDesc();"><option value="">', addslashes($txt['pm_rule_sel_group']), '<\' + \'/option>'; |
1673 | 1750 | |
1674 | - foreach ($context['groups'] as $id => $group) |
|
1675 | - echo '<option value="', $id, '">', strtr($group, array("'" => "\'")), '<\' + \'/option>'; |
|
1751 | + foreach ($context['groups'] as $id => $group) { |
|
1752 | + echo '<option value="', $id, '">', strtr($group, array("'" => "\'")), '<\' + \'/option>'; |
|
1753 | + } |
|
1676 | 1754 | |
1677 | 1755 | echo '<\' + \'/select><\' + \'/span><span id="criteriaAddHere"><\' + \'/span>\'); |
1678 | 1756 | } |
@@ -1689,9 +1767,10 @@ discard block |
||
1689 | 1767 | |
1690 | 1768 | setOuterHTML(document.getElementById("actionAddHere"), \'<br><select name="acttype[\' + actionNum + \']" id="acttype\' + actionNum + \'" onchange="updateActionDef(\' + actionNum + \'); rebuildRuleDesc();"><option value="">', addslashes($txt['pm_rule_sel_action']), ':<\' + \'/option><option value="lab">', addslashes($txt['pm_rule_label']), '<\' + \'/option><option value="del">', addslashes($txt['pm_rule_delete']), '<\' + \'/option><\' + \'/select> <span id="labdiv\' + actionNum + \'" style="display: none;"><select name="labdef[\' + actionNum + \']" id="labdef\' + actionNum + \'" onchange="rebuildRuleDesc();"><option value="">', addslashes($txt['pm_rule_sel_label']), '<\' + \'/option>'; |
1691 | 1769 | |
1692 | - foreach ($context['labels'] as $label) |
|
1693 | - if ($label['id'] != -1) |
|
1770 | + foreach ($context['labels'] as $label) { |
|
1771 | + if ($label['id'] != -1) |
|
1694 | 1772 | echo '<option value="', ($label['id']), '">', addslashes($label['name']), '<\' + \'/option>'; |
1773 | + } |
|
1695 | 1774 | |
1696 | 1775 | echo '<\' + \'/select><\' + \'/span><span id="actionAddHere"><\' + \'/span>\'); |
1697 | 1776 | } |
@@ -1805,19 +1884,20 @@ discard block |
||
1805 | 1884 | $isFirst = true; |
1806 | 1885 | foreach ($context['rule']['criteria'] as $k => $criteria) |
1807 | 1886 | { |
1808 | - if (!$isFirst && $criteria['t'] == '') |
|
1809 | - echo '<div id="removeonjs1">'; |
|
1810 | - |
|
1811 | - elseif (!$isFirst) |
|
1812 | - echo '<br>'; |
|
1887 | + if (!$isFirst && $criteria['t'] == '') { |
|
1888 | + echo '<div id="removeonjs1">'; |
|
1889 | + } elseif (!$isFirst) { |
|
1890 | + echo '<br>'; |
|
1891 | + } |
|
1813 | 1892 | |
1814 | 1893 | echo ' |
1815 | 1894 | <select name="ruletype[', $k, ']" id="ruletype', $k, '" onchange="updateRuleDef(', $k, '); rebuildRuleDesc();"> |
1816 | 1895 | <option value="">', $txt['pm_rule_criteria_pick'], ':</option>'; |
1817 | 1896 | |
1818 | - foreach (array('mid', 'gid', 'sub', 'msg', 'bud') as $cr) |
|
1819 | - echo ' |
|
1897 | + foreach (array('mid', 'gid', 'sub', 'msg', 'bud') as $cr) { |
|
1898 | + echo ' |
|
1820 | 1899 | <option value="', $cr, '"', $criteria['t'] == $cr ? ' selected' : '', '>', $txt['pm_rule_' . $cr], '</option>'; |
1900 | + } |
|
1821 | 1901 | |
1822 | 1902 | echo ' |
1823 | 1903 | </select> |
@@ -1828,19 +1908,20 @@ discard block |
||
1828 | 1908 | <select name="ruledefgroup[', $k, ']" id="ruledefgroup', $k, '" onchange="rebuildRuleDesc();"> |
1829 | 1909 | <option value="">', $txt['pm_rule_sel_group'], '</option>'; |
1830 | 1910 | |
1831 | - foreach ($context['groups'] as $id => $group) |
|
1832 | - echo ' |
|
1911 | + foreach ($context['groups'] as $id => $group) { |
|
1912 | + echo ' |
|
1833 | 1913 | <option value="', $id, '"', $criteria['t'] == 'gid' && $criteria['v'] == $id ? ' selected' : '', '>', $group, '</option>'; |
1914 | + } |
|
1834 | 1915 | echo ' |
1835 | 1916 | </select> |
1836 | 1917 | </span>'; |
1837 | 1918 | |
1838 | 1919 | // If this is the dummy we add a means to hide for non js users. |
1839 | - if ($isFirst) |
|
1840 | - $isFirst = false; |
|
1841 | - |
|
1842 | - elseif ($criteria['t'] == '') |
|
1843 | - echo '</div><!-- .removeonjs1 -->'; |
|
1920 | + if ($isFirst) { |
|
1921 | + $isFirst = false; |
|
1922 | + } elseif ($criteria['t'] == '') { |
|
1923 | + echo '</div><!-- .removeonjs1 -->'; |
|
1924 | + } |
|
1844 | 1925 | } |
1845 | 1926 | |
1846 | 1927 | echo ' |
@@ -1863,10 +1944,11 @@ discard block |
||
1863 | 1944 | $isFirst = true; |
1864 | 1945 | foreach ($context['rule']['actions'] as $k => $action) |
1865 | 1946 | { |
1866 | - if (!$isFirst && $action['t'] == '') |
|
1867 | - echo '<div id="removeonjs2">'; |
|
1868 | - elseif (!$isFirst) |
|
1869 | - echo '<br>'; |
|
1947 | + if (!$isFirst && $action['t'] == '') { |
|
1948 | + echo '<div id="removeonjs2">'; |
|
1949 | + } elseif (!$isFirst) { |
|
1950 | + echo '<br>'; |
|
1951 | + } |
|
1870 | 1952 | |
1871 | 1953 | echo ' |
1872 | 1954 | <select name="acttype[', $k, ']" id="acttype', $k, '" onchange="updateActionDef(', $k, '); rebuildRuleDesc();"> |
@@ -1878,20 +1960,21 @@ discard block |
||
1878 | 1960 | <select name="labdef[', $k, ']" id="labdef', $k, '" onchange="rebuildRuleDesc();"> |
1879 | 1961 | <option value="">', $txt['pm_rule_sel_label'], '</option>'; |
1880 | 1962 | |
1881 | - foreach ($context['labels'] as $label) |
|
1882 | - if ($label['id'] != -1) |
|
1963 | + foreach ($context['labels'] as $label) { |
|
1964 | + if ($label['id'] != -1) |
|
1883 | 1965 | echo ' |
1884 | 1966 | <option value="', ($label['id']), '"', $action['t'] == 'lab' && $action['v'] == $label['id'] ? ' selected' : '', '>', $label['name'], '</option>'; |
1967 | + } |
|
1885 | 1968 | |
1886 | 1969 | echo ' |
1887 | 1970 | </select> |
1888 | 1971 | </span>'; |
1889 | 1972 | |
1890 | - if ($isFirst) |
|
1891 | - $isFirst = false; |
|
1892 | - |
|
1893 | - elseif ($action['t'] == '') |
|
1894 | - echo '</div><!-- .removeonjs2 -->'; |
|
1973 | + if ($isFirst) { |
|
1974 | + $isFirst = false; |
|
1975 | + } elseif ($action['t'] == '') { |
|
1976 | + echo '</div><!-- .removeonjs2 -->'; |
|
1977 | + } |
|
1895 | 1978 | } |
1896 | 1979 | |
1897 | 1980 | echo ' |
@@ -1915,22 +1998,25 @@ discard block |
||
1915 | 1998 | echo ' |
1916 | 1999 | <script>'; |
1917 | 2000 | |
1918 | - foreach ($context['rule']['criteria'] as $k => $c) |
|
1919 | - echo ' |
|
2001 | + foreach ($context['rule']['criteria'] as $k => $c) { |
|
2002 | + echo ' |
|
1920 | 2003 | updateRuleDef(', $k, ');'; |
2004 | + } |
|
1921 | 2005 | |
1922 | - foreach ($context['rule']['actions'] as $k => $c) |
|
1923 | - echo ' |
|
2006 | + foreach ($context['rule']['actions'] as $k => $c) { |
|
2007 | + echo ' |
|
1924 | 2008 | updateActionDef(', $k, ');'; |
2009 | + } |
|
1925 | 2010 | |
1926 | 2011 | echo ' |
1927 | 2012 | rebuildRuleDesc();'; |
1928 | 2013 | |
1929 | 2014 | // If this isn't a new rule and we have JS enabled remove the JS compatibility stuff. |
1930 | - if ($context['rid']) |
|
1931 | - echo ' |
|
2015 | + if ($context['rid']) { |
|
2016 | + echo ' |
|
1932 | 2017 | document.getElementById("removeonjs1").style.display = "none"; |
1933 | 2018 | document.getElementById("removeonjs2").style.display = "none";'; |
2019 | + } |
|
1934 | 2020 | |
1935 | 2021 | echo ' |
1936 | 2022 | document.getElementById("addonjs1").style.display = ""; |
@@ -1958,12 +2044,12 @@ discard block |
||
1958 | 2044 | </div>'; |
1959 | 2045 | |
1960 | 2046 | // No drafts? Just show an informative message. |
1961 | - if (empty($context['drafts'])) |
|
1962 | - echo ' |
|
2047 | + if (empty($context['drafts'])) { |
|
2048 | + echo ' |
|
1963 | 2049 | <div class="windowbg centertext"> |
1964 | 2050 | ', $txt['draft_none'], ' |
1965 | 2051 | </div>'; |
1966 | - else |
|
2052 | + } else |
|
1967 | 2053 | { |
1968 | 2054 | // For every draft to be displayed, give it its own div, and show the important details of the draft. |
1969 | 2055 | foreach ($context['drafts'] as $draft) |
@@ -25,18 +25,20 @@ discard block |
||
25 | 25 | </div> |
26 | 26 | <div class="windowbg noup">'; |
27 | 27 | |
28 | - if (!empty($context['move_board'])) |
|
29 | - echo ' |
|
28 | + if (!empty($context['move_board'])) { |
|
29 | + echo ' |
|
30 | 30 | <div class="noticebox"> |
31 | 31 | ', $context['move_title'], ' [<a href="', $scripturl, '?action=admin;area=manageboards">', $txt['mboards_cancel_moving'], '</a>]', ' |
32 | 32 | </div>'; |
33 | + } |
|
33 | 34 | |
34 | 35 | // No categories so show a label. |
35 | - if (empty($context['categories'])) |
|
36 | - echo ' |
|
36 | + if (empty($context['categories'])) { |
|
37 | + echo ' |
|
37 | 38 | <div class="windowbg centertext"> |
38 | 39 | ', $txt['mboards_no_cats'], ' |
39 | 40 | </div>'; |
41 | + } |
|
40 | 42 | |
41 | 43 | // Loop through every category, listing the boards in each as we go. |
42 | 44 | foreach ($context['categories'] as $category) |
@@ -54,9 +56,10 @@ discard block |
||
54 | 56 | <form action="', $scripturl, '?action=admin;area=manageboards;sa=newboard;cat=', $category['id'], '" method="post" accept-charset="', $context['character_set'], '"> |
55 | 57 | <ul id="category_', $category['id'], '" class="nolist">'; |
56 | 58 | |
57 | - if (!empty($category['move_link'])) |
|
58 | - echo ' |
|
59 | + if (!empty($category['move_link'])) { |
|
60 | + echo ' |
|
59 | 61 | <li><a href="', $category['move_link']['href'], '" title="', $category['move_link']['label'], '"><span class="generic_icons select_above"></span></a></li>'; |
62 | + } |
|
60 | 63 | |
61 | 64 | $recycle_board = '<a href="' . $scripturl . '?action=admin;area=manageboards;sa=settings"> <img src="' . $settings['images_url'] . '/post/recycled.png" alt="' . $txt['recycle_board'] . '" title="' . $txt['recycle_board'] . '"></a>'; |
62 | 65 | $redirect_board = '<img src="' . $settings['images_url'] . '/new_redirect.png" alt="' . $txt['redirect_board_desc'] . '" title="' . $txt['redirect_board_desc'] . '">'; |
@@ -79,9 +82,10 @@ discard block |
||
79 | 82 | echo ' |
80 | 83 | <li class="windowbg" style="padding-', $context['right_to_left'] ? 'right' : 'left', ': ', 5 + 30 * $board['move_links'][0]['child_level'], 'px;">'; |
81 | 84 | |
82 | - foreach ($board['move_links'] as $link) |
|
83 | - echo ' |
|
85 | + foreach ($board['move_links'] as $link) { |
|
86 | + echo ' |
|
84 | 87 | <a href="', $link['href'], '" class="move_links" title="', $link['label'], '"><span class="generic_icons select_', $link['class'], '" title="', $link['label'], '"></span></a>'; |
88 | + } |
|
85 | 89 | |
86 | 90 | echo ' |
87 | 91 | </li>'; |
@@ -130,9 +134,10 @@ discard block |
||
130 | 134 | <select name="cat_order">'; |
131 | 135 | |
132 | 136 | // Print every existing category into a select box. |
133 | - foreach ($context['category_order'] as $order) |
|
134 | - echo ' |
|
137 | + foreach ($context['category_order'] as $order) { |
|
138 | + echo ' |
|
135 | 139 | <option', $order['selected'] ? ' selected' : '', ' value="', $order['id'], '">', $order['name'], '</option>'; |
140 | + } |
|
136 | 141 | echo ' |
137 | 142 | </select> |
138 | 143 | </dd>'; |
@@ -167,14 +172,15 @@ discard block |
||
167 | 172 | { |
168 | 173 | foreach ($context['custom_category_settings'] as $catset_id => $catset) |
169 | 174 | { |
170 | - if (!empty($catset['dt']) && !empty($catset['dd'])) |
|
171 | - echo ' |
|
175 | + if (!empty($catset['dt']) && !empty($catset['dd'])) { |
|
176 | + echo ' |
|
172 | 177 | <dt class="clear', !is_numeric($catset_id) ? ' catset_' . $catset_id : '', '"> |
173 | 178 | ', $catset['dt'], ' |
174 | 179 | </dt> |
175 | 180 | <dd', !is_numeric($catset_id) ? ' class="catset_' . $catset_id . '"' : '', '> |
176 | 181 | ', $catset['dd'], ' |
177 | 182 | </dd>'; |
183 | + } |
|
178 | 184 | } |
179 | 185 | } |
180 | 186 | |
@@ -182,21 +188,23 @@ discard block |
||
182 | 188 | echo ' |
183 | 189 | </dl>'; |
184 | 190 | |
185 | - if (isset($context['category']['is_new'])) |
|
186 | - echo ' |
|
191 | + if (isset($context['category']['is_new'])) { |
|
192 | + echo ' |
|
187 | 193 | <input type="submit" name="add" value="', $txt['mboards_add_cat_button'], '" onclick="return !isEmptyText(this.form.cat_name);" tabindex="', $context['tabindex']++, '" class="button">'; |
188 | - else |
|
189 | - echo ' |
|
194 | + } else { |
|
195 | + echo ' |
|
190 | 196 | <input type="submit" name="edit" value="', $txt['modify'], '" onclick="return !isEmptyText(this.form.cat_name);" tabindex="', $context['tabindex']++, '" class="button"> |
191 | 197 | <input type="submit" name="delete" value="', $txt['mboards_delete_cat'], '" data-confirm="', $txt['catConfirm'], '" class="button you_sure">'; |
198 | + } |
|
192 | 199 | echo ' |
193 | 200 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
194 | 201 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
195 | 202 | |
196 | 203 | // If this category is empty we don't bother with the next confirmation screen. |
197 | - if ($context['category']['is_empty']) |
|
198 | - echo ' |
|
204 | + if ($context['category']['is_empty']) { |
|
205 | + echo ' |
|
199 | 206 | <input type="hidden" name="empty" value="1">'; |
207 | + } |
|
200 | 208 | |
201 | 209 | echo ' |
202 | 210 | </div><!-- .windowbg --> |
@@ -223,9 +231,10 @@ discard block |
||
223 | 231 | <p>', $txt['mboards_delete_cat_contains'], ':</p> |
224 | 232 | <ul>'; |
225 | 233 | |
226 | - foreach ($context['category']['children'] as $child) |
|
227 | - echo ' |
|
234 | + foreach ($context['category']['children'] as $child) { |
|
235 | + echo ' |
|
228 | 236 | <li>', $child, '</li>'; |
237 | + } |
|
229 | 238 | |
230 | 239 | echo ' |
231 | 240 | </ul> |
@@ -239,10 +248,11 @@ discard block |
||
239 | 248 | <label for="delete_action1"><input type="radio" id="delete_action1" name="delete_action" value="1"', count($context['category_order']) == 1 ? ' disabled' : '', '>', $txt['mboards_delete_option2'], '</label>: |
240 | 249 | <select name="cat_to"', count($context['category_order']) == 1 ? ' disabled' : '', '>'; |
241 | 250 | |
242 | - foreach ($context['category_order'] as $cat) |
|
243 | - if ($cat['id'] != 0) |
|
251 | + foreach ($context['category_order'] as $cat) { |
|
252 | + if ($cat['id'] != 0) |
|
244 | 253 | echo ' |
245 | 254 | <option value="', $cat['id'], '">', $cat['true_name'], '</option>'; |
255 | + } |
|
246 | 256 | |
247 | 257 | echo ' |
248 | 258 | </select> |
@@ -285,9 +295,10 @@ discard block |
||
285 | 295 | <dd> |
286 | 296 | <select name="new_cat" onchange="if (this.form.order) {this.form.order.disabled = this.options[this.selectedIndex].value != 0; this.form.board_order.disabled = this.options[this.selectedIndex].value != 0 || this.form.order.options[this.form.order.selectedIndex].value == \'\';}">'; |
287 | 297 | |
288 | - foreach ($context['categories'] as $category) |
|
289 | - echo ' |
|
298 | + foreach ($context['categories'] as $category) { |
|
299 | + echo ' |
|
290 | 300 | <option', $category['selected'] ? ' selected' : '', ' value="', $category['id'], '">', $category['name'], '</option>'; |
301 | + } |
|
291 | 302 | echo ' |
292 | 303 | </select> |
293 | 304 | </dd>'; |
@@ -315,9 +326,10 @@ discard block |
||
315 | 326 | <select id="board_order" name="board_order"', !isset($context['board']['is_new']) ? ' disabled' : '', '> |
316 | 327 | ', !isset($context['board']['is_new']) ? '<option value="">(' . $txt['mboards_unchanged'] . ')</option>' : ''; |
317 | 328 | |
318 | - foreach ($context['board_order'] as $order) |
|
319 | - echo ' |
|
329 | + foreach ($context['board_order'] as $order) { |
|
330 | + echo ' |
|
320 | 331 | <option', $order['selected'] ? ' selected' : '', ' value="', $order['id'], '">', $order['name'], '</option>'; |
332 | + } |
|
321 | 333 | echo ' |
322 | 334 | </select> |
323 | 335 | </dd>'; |
@@ -346,13 +358,15 @@ discard block |
||
346 | 358 | <dd> |
347 | 359 | <select name="profile">'; |
348 | 360 | |
349 | - if (isset($context['board']['is_new'])) |
|
350 | - echo ' |
|
361 | + if (isset($context['board']['is_new'])) { |
|
362 | + echo ' |
|
351 | 363 | <option value="-1">[', $txt['permission_profile_inherit'], ']</option>'; |
364 | + } |
|
352 | 365 | |
353 | - foreach ($context['profiles'] as $id => $profile) |
|
354 | - echo ' |
|
366 | + foreach ($context['profiles'] as $id => $profile) { |
|
367 | + echo ' |
|
355 | 368 | <option value="', $id, '"', $id == $context['board']['profile'] ? ' selected' : '', '>', $profile['name'], '</option>'; |
369 | + } |
|
356 | 370 | |
357 | 371 | echo ' |
358 | 372 | </select> |
@@ -365,8 +379,8 @@ discard block |
||
365 | 379 | </dt> |
366 | 380 | <dd>'; |
367 | 381 | |
368 | - if (!empty($modSettings['deny_boards_access'])) |
|
369 | - echo ' |
|
382 | + if (!empty($modSettings['deny_boards_access'])) { |
|
383 | + echo ' |
|
370 | 384 | <table> |
371 | 385 | <tr> |
372 | 386 | <td></td> |
@@ -374,10 +388,11 @@ discard block |
||
374 | 388 | <th>', $txt['permissions_option_off'], '</th> |
375 | 389 | <th>', $txt['permissions_option_deny'], '</th> |
376 | 390 | </tr>'; |
391 | + } |
|
377 | 392 | |
378 | 393 | // List all the membergroups so the user can choose who may access this board. |
379 | - foreach ($context['groups'] as $group) |
|
380 | - if (empty($modSettings['deny_boards_access'])) |
|
394 | + foreach ($context['groups'] as $group) { |
|
395 | + if (empty($modSettings['deny_boards_access'])) |
|
381 | 396 | echo ' |
382 | 397 | <label for="groups_', $group['id'], '"> |
383 | 398 | <input type="checkbox" name="groups[', $group['id'], ']" value="allow" id="groups_', $group['id'], '"', in_array($group['id'], $context['board_managers']) ? ' checked disabled' : ($group['allow'] ? ' checked' : ''), '> |
@@ -385,8 +400,9 @@ discard block |
||
385 | 400 | ', $group['name'], ' |
386 | 401 | </span> |
387 | 402 | </label><br>'; |
388 | - else |
|
389 | - echo ' |
|
403 | + } |
|
404 | + else { |
|
405 | + echo ' |
|
390 | 406 | <tr> |
391 | 407 | <td> |
392 | 408 | <label for="groups_', $group['id'], '_a"> |
@@ -406,16 +422,17 @@ discard block |
||
406 | 422 | </td> |
407 | 423 | <td></td> |
408 | 424 | </tr>'; |
425 | + } |
|
409 | 426 | |
410 | - if (empty($modSettings['deny_boards_access'])) |
|
411 | - echo ' |
|
427 | + if (empty($modSettings['deny_boards_access'])) { |
|
428 | + echo ' |
|
412 | 429 | <span class="select_all_box"> |
413 | 430 | <em>', $txt['check_all'], '</em> <input type="checkbox" onclick="invertAll(this, this.form, \'groups[\');"> |
414 | 431 | </span> |
415 | 432 | <br><br> |
416 | 433 | </dd>'; |
417 | - else |
|
418 | - echo ' |
|
434 | + } else { |
|
435 | + echo ' |
|
419 | 436 | <tr class="select_all_box"> |
420 | 437 | <td> |
421 | 438 | </td> |
@@ -434,6 +451,7 @@ discard block |
||
434 | 451 | </tr> |
435 | 452 | </table> |
436 | 453 | </dd>'; |
454 | + } |
|
437 | 455 | |
438 | 456 | // Options to choose moderators, specify as announcement board and choose whether to count posts here. |
439 | 457 | echo ' |
@@ -488,8 +506,8 @@ discard block |
||
488 | 506 | </dl> |
489 | 507 | </div>'; |
490 | 508 | |
491 | - if ($context['board']['redirect']) |
|
492 | - echo ' |
|
509 | + if ($context['board']['redirect']) { |
|
510 | + echo ' |
|
493 | 511 | <div id="reset_redirect_div"> |
494 | 512 | <dl class="settings"> |
495 | 513 | <dt> |
@@ -502,6 +520,7 @@ discard block |
||
502 | 520 | </dd> |
503 | 521 | </dl> |
504 | 522 | </div>'; |
523 | + } |
|
505 | 524 | } |
506 | 525 | |
507 | 526 | echo ' |
@@ -529,9 +548,10 @@ discard block |
||
529 | 548 | <select name="boardtheme" id="boardtheme" onchange="refreshOptions();"> |
530 | 549 | <option value="0"', $context['board']['theme'] == 0 ? ' selected' : '', '>', $txt['mboards_theme_default'], '</option>'; |
531 | 550 | |
532 | - foreach ($context['themes'] as $theme) |
|
533 | - echo ' |
|
551 | + foreach ($context['themes'] as $theme) { |
|
552 | + echo ' |
|
534 | 553 | <option value="', $theme['id'], '"', $context['board']['theme'] == $theme['id'] ? ' selected' : '', '>', $theme['name'], '</option>'; |
554 | + } |
|
535 | 555 | |
536 | 556 | echo ' |
537 | 557 | </select> |
@@ -560,14 +580,15 @@ discard block |
||
560 | 580 | |
561 | 581 | foreach ($context['custom_board_settings'] as $cbs_id => $cbs) |
562 | 582 | { |
563 | - if (!empty($cbs['dt']) && !empty($cbs['dd'])) |
|
564 | - echo ' |
|
583 | + if (!empty($cbs['dt']) && !empty($cbs['dd'])) { |
|
584 | + echo ' |
|
565 | 585 | <dt class="clear', !is_numeric($cbs_id) ? ' cbs_' . $cbs_id : '', '"> |
566 | 586 | ', $cbs['dt'], ' |
567 | 587 | </dt> |
568 | 588 | <dd', !is_numeric($cbs_id) ? ' class="cbs_' . $cbs_id . '"' : '', '> |
569 | 589 | ', $cbs['dd'], ' |
570 | 590 | </dd>'; |
591 | + } |
|
571 | 592 | } |
572 | 593 | |
573 | 594 | echo ' |
@@ -575,9 +596,10 @@ discard block |
||
575 | 596 | </div>'; |
576 | 597 | } |
577 | 598 | |
578 | - if (!empty($context['board']['is_recycle'])) |
|
579 | - echo ' |
|
599 | + if (!empty($context['board']['is_recycle'])) { |
|
600 | + echo ' |
|
580 | 601 | <div class="noticebox">', $txt['mboards_recycle_disabled_delete'], '</div>'; |
602 | + } |
|
581 | 603 | |
582 | 604 | echo ' |
583 | 605 | <input type="hidden" name="rid" value="', $context['redirect_location'], '"> |
@@ -585,21 +607,24 @@ discard block |
||
585 | 607 | <input type="hidden" name="', $context['admin-be-' . $context['board']['id'] . '_token_var'], '" value="', $context['admin-be-' . $context['board']['id'] . '_token'], '">'; |
586 | 608 | |
587 | 609 | // If this board has no children don't bother with the next confirmation screen. |
588 | - if ($context['board']['no_children']) |
|
589 | - echo ' |
|
610 | + if ($context['board']['no_children']) { |
|
611 | + echo ' |
|
590 | 612 | <input type="hidden" name="no_children" value="1">'; |
613 | + } |
|
591 | 614 | |
592 | - if (isset($context['board']['is_new'])) |
|
593 | - echo ' |
|
615 | + if (isset($context['board']['is_new'])) { |
|
616 | + echo ' |
|
594 | 617 | <input type="hidden" name="cur_cat" value="', $context['board']['category'], '"> |
595 | 618 | <input type="submit" name="add" value="', $txt['mboards_new_board'], '" onclick="return !isEmptyText(this.form.board_name);" class="button">'; |
596 | - else |
|
597 | - echo ' |
|
619 | + } else { |
|
620 | + echo ' |
|
598 | 621 | <input type="submit" name="edit" value="', $txt['modify'], '" onclick="return !isEmptyText(this.form.board_name);" class="button">'; |
622 | + } |
|
599 | 623 | |
600 | - if (!isset($context['board']['is_new']) && empty($context['board']['is_recycle'])) |
|
601 | - echo ' |
|
624 | + if (!isset($context['board']['is_new']) && empty($context['board']['is_recycle'])) { |
|
625 | + echo ' |
|
602 | 626 | <input type="submit" name="delete" value="', $txt['mboards_delete_board'], '" data-confirm="', $txt['boardConfirm'], '" class="button you_sure">'; |
627 | + } |
|
603 | 628 | echo ' |
604 | 629 | </div><!-- .windowbg --> |
605 | 630 | </form> |
@@ -620,12 +645,13 @@ discard block |
||
620 | 645 | sItemListContainerId: \'moderator_container\', |
621 | 646 | aListItems: ['; |
622 | 647 | |
623 | - foreach ($context['board']['moderators'] as $id_member => $member_name) |
|
624 | - echo ' |
|
648 | + foreach ($context['board']['moderators'] as $id_member => $member_name) { |
|
649 | + echo ' |
|
625 | 650 | { |
626 | 651 | sItemId: ', JavaScriptEscape($id_member), ', |
627 | 652 | sItemName: ', JavaScriptEscape($member_name), ' |
628 | 653 | }', $id_member == $context['board']['last_moderator_id'] ? '' : ','; |
654 | + } |
|
629 | 655 | |
630 | 656 | echo ' |
631 | 657 | ] |
@@ -645,12 +671,13 @@ discard block |
||
645 | 671 | sItemListContainerId: \'moderator_group_container\', |
646 | 672 | aListItems: ['; |
647 | 673 | |
648 | - foreach ($context['board']['moderator_groups'] as $id_group => $group_name) |
|
649 | - echo ' |
|
674 | + foreach ($context['board']['moderator_groups'] as $id_group => $group_name) { |
|
675 | + echo ' |
|
650 | 676 | { |
651 | 677 | sItemId: ', JavaScriptEscape($id_group), ', |
652 | 678 | sItemName: ', JavaScriptEscape($group_name), ' |
653 | 679 | }', $id_group == $context['board']['last_moderator_group_id'] ? '' : ','; |
680 | + } |
|
654 | 681 | |
655 | 682 | echo ' |
656 | 683 | ] |
@@ -676,17 +703,19 @@ discard block |
||
676 | 703 | echo ' |
677 | 704 | document.getElementById("redirect_address_div").style.display = redirectEnabled ? "" : "none";'; |
678 | 705 | |
679 | - if ($context['board']['redirect']) |
|
680 | - echo ' |
|
706 | + if ($context['board']['redirect']) { |
|
707 | + echo ' |
|
681 | 708 | document.getElementById("reset_redirect_div").style.display = redirectEnabled ? "" : "none";'; |
709 | + } |
|
682 | 710 | } |
683 | 711 | |
684 | 712 | // Include any JavaScript added by mods using the 'integrate_edit_board' hook. |
685 | 713 | if (!empty($context['custom_refreshOptions']) && is_array($context['custom_refreshOptions'])) |
686 | 714 | { |
687 | - foreach ($context['custom_refreshOptions'] as $refreshOption) |
|
688 | - echo ' |
|
715 | + foreach ($context['custom_refreshOptions'] as $refreshOption) { |
|
716 | + echo ' |
|
689 | 717 | ', $refreshOption; |
718 | + } |
|
690 | 719 | } |
691 | 720 | |
692 | 721 | echo ' |
@@ -715,9 +744,10 @@ discard block |
||
715 | 744 | <p>', $txt['mboards_delete_board_contains'], '</p> |
716 | 745 | <ul>'; |
717 | 746 | |
718 | - foreach ($context['children'] as $child) |
|
719 | - echo ' |
|
747 | + foreach ($context['children'] as $child) { |
|
748 | + echo ' |
|
720 | 749 | <li>', $child['node']['name'], '</li>'; |
750 | + } |
|
721 | 751 | |
722 | 752 | echo ' |
723 | 753 | </ul> |
@@ -731,10 +761,11 @@ discard block |
||
731 | 761 | <label for="delete_action1"><input type="radio" id="delete_action1" name="delete_action" value="1"', empty($context['can_move_children']) ? ' disabled' : '', '>', $txt['mboards_delete_board_option2'], '</label>: |
732 | 762 | <select name="board_to"', empty($context['can_move_children']) ? ' disabled' : '', '>'; |
733 | 763 | |
734 | - foreach ($context['board_order'] as $board) |
|
735 | - if ($board['id'] != $context['board']['id'] && empty($board['is_child'])) |
|
764 | + foreach ($context['board_order'] as $board) { |
|
765 | + if ($board['id'] != $context['board']['id'] && empty($board['is_child'])) |
|
736 | 766 | echo ' |
737 | 767 | <option value="', $board['id'], '">', $board['name'], '</option>'; |
768 | + } |
|
738 | 769 | |
739 | 770 | echo ' |
740 | 771 | </select> |
@@ -121,9 +121,10 @@ discard block |
||
121 | 121 | <h3 class="catbg">', $txt['attachment_transfer'], '</h3> |
122 | 122 | </div>'; |
123 | 123 | |
124 | - if (!empty($context['results'])) |
|
125 | - echo ' |
|
124 | + if (!empty($context['results'])) { |
|
125 | + echo ' |
|
126 | 126 | <div class="noticebox">', $context['results'], '</div>'; |
127 | + } |
|
127 | 128 | |
128 | 129 | echo ' |
129 | 130 | <div class="windowbg noup"> |
@@ -135,9 +136,10 @@ discard block |
||
135 | 136 | <select name="from"> |
136 | 137 | <option value="0">', $txt['attachment_transfer_select'], '</option>'; |
137 | 138 | |
138 | - foreach ($context['attach_dirs'] as $id => $dir) |
|
139 | - echo ' |
|
139 | + foreach ($context['attach_dirs'] as $id => $dir) { |
|
140 | + echo ' |
|
140 | 141 | <option value="', $id, '">', $dir, '</option>'; |
142 | + } |
|
141 | 143 | |
142 | 144 | echo ' |
143 | 145 | </select> |
@@ -148,13 +150,14 @@ discard block |
||
148 | 150 | <option value="0">', $txt['attachment_transfer_auto_select'], '</option> |
149 | 151 | <option value="-1">', $txt['attachment_transfer_forum_root'], '</option>'; |
150 | 152 | |
151 | - if (!empty($context['base_dirs'])) |
|
152 | - foreach ($context['base_dirs'] as $id => $dir) |
|
153 | + if (!empty($context['base_dirs'])) { |
|
154 | + foreach ($context['base_dirs'] as $id => $dir) |
|
153 | 155 | echo ' |
154 | 156 | <option value="', $id, '">', $dir, '</option>'; |
155 | - else |
|
156 | - echo ' |
|
157 | + } else { |
|
158 | + echo ' |
|
157 | 159 | <option value="0" disabled>', $txt['attachment_transfer_no_base'], '</option>'; |
160 | + } |
|
158 | 161 | |
159 | 162 | echo ' |
160 | 163 | </select> |
@@ -164,18 +167,20 @@ discard block |
||
164 | 167 | <select name="to"> |
165 | 168 | <option value="0">', $txt['attachment_transfer_select'], '</option>'; |
166 | 169 | |
167 | - foreach ($context['attach_dirs'] as $id => $dir) |
|
168 | - echo ' |
|
170 | + foreach ($context['attach_dirs'] as $id => $dir) { |
|
171 | + echo ' |
|
169 | 172 | <option value="', $id, '">', $dir, '</option>'; |
173 | + } |
|
170 | 174 | |
171 | 175 | echo ' |
172 | 176 | </select> |
173 | 177 | </dd>'; |
174 | 178 | |
175 | - if (!empty($modSettings['attachmentDirFileLimit'])) |
|
176 | - echo ' |
|
179 | + if (!empty($modSettings['attachmentDirFileLimit'])) { |
|
180 | + echo ' |
|
177 | 181 | <dt>', $txt['attachment_transfer_empty'], '</dt> |
178 | 182 | <dd><input type="checkbox" name="empty_it"', $context['checked'] ? ' checked' : '', '></dd>'; |
183 | + } |
|
179 | 184 | |
180 | 185 | echo ' |
181 | 186 | </dl> |
@@ -211,8 +216,8 @@ discard block |
||
211 | 216 | global $context, $txt, $scripturl; |
212 | 217 | |
213 | 218 | // If we've completed just let them know! |
214 | - if ($context['completed']) |
|
215 | - echo ' |
|
219 | + if ($context['completed']) { |
|
220 | + echo ' |
|
216 | 221 | <div id="manage_attachments"> |
217 | 222 | <div class="cat_bar"> |
218 | 223 | <h3 class="catbg">', $txt['repair_attachments_complete'], '</h3> |
@@ -221,10 +226,11 @@ discard block |
||
221 | 226 | ', $txt['repair_attachments_complete_desc'], ' |
222 | 227 | </div> |
223 | 228 | </div>'; |
229 | + } |
|
224 | 230 | |
225 | 231 | // What about if no errors were even found? |
226 | - elseif (!$context['errors_found']) |
|
227 | - echo ' |
|
232 | + elseif (!$context['errors_found']) { |
|
233 | + echo ' |
|
228 | 234 | <div id="manage_attachments"> |
229 | 235 | <div class="cat_bar"> |
230 | 236 | <h3 class="catbg">', $txt['repair_attachments_complete'], '</h3> |
@@ -233,6 +239,7 @@ discard block |
||
233 | 239 | ', $txt['repair_attachments_no_errors'], ' |
234 | 240 | </div> |
235 | 241 | </div>'; |
242 | + } |
|
236 | 243 | |
237 | 244 | // Otherwise, I'm sad to say, we have a problem! |
238 | 245 | else |
@@ -247,11 +254,12 @@ discard block |
||
247 | 254 | <p>', $txt['repair_attachments_error_desc'], '</p>'; |
248 | 255 | |
249 | 256 | // Loop through each error reporting the status |
250 | - foreach ($context['repair_errors'] as $error => $number) |
|
251 | - if (!empty($number)) |
|
257 | + foreach ($context['repair_errors'] as $error => $number) { |
|
258 | + if (!empty($number)) |
|
252 | 259 | echo ' |
253 | 260 | <input type="checkbox" name="to_fix[]" id="', $error, '" value="', $error, '"> |
254 | 261 | <label for="', $error, '">', sprintf($txt['attach_repair_' . $error], $number), '</label><br>'; |
262 | + } |
|
255 | 263 | |
256 | 264 | echo ' |
257 | 265 | <br> |
@@ -270,8 +278,9 @@ discard block |
||
270 | 278 | { |
271 | 279 | global $modSettings; |
272 | 280 | |
273 | - if (!empty($modSettings['attachment_basedirectories'])) |
|
274 | - template_show_list('base_paths'); |
|
281 | + if (!empty($modSettings['attachment_basedirectories'])) { |
|
282 | + template_show_list('base_paths'); |
|
283 | + } |
|
275 | 284 | |
276 | 285 | template_show_list('attach_paths'); |
277 | 286 | } |