@@ -75,8 +75,9 @@ discard block |
||
75 | 75 | $upcontext['inactive_timeout'] = 10; |
76 | 76 | |
77 | 77 | // The helper is crucial. Include it first thing. |
78 | -if (!file_exists($upgrade_path . '/upgrade-helper.php')) |
|
78 | +if (!file_exists($upgrade_path . '/upgrade-helper.php')) { |
|
79 | 79 | die('upgrade-helper.php not found where it was expected: ' . $upgrade_path . '/upgrade-helper.php! Make sure you have uploaded ALL files from the upgrade package. The upgrader cannot continue.'); |
80 | +} |
|
80 | 81 | |
81 | 82 | require_once($upgrade_path . '/upgrade-helper.php'); |
82 | 83 | |
@@ -100,11 +101,14 @@ discard block |
||
100 | 101 | ini_set('default_socket_timeout', 900); |
101 | 102 | } |
102 | 103 | // Clean the upgrade path if this is from the client. |
103 | -if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) |
|
104 | - for ($i = 1; $i < $_SERVER['argc']; $i++) |
|
104 | +if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) { |
|
105 | + for ($i = 1; |
|
106 | +} |
|
107 | +$i < $_SERVER['argc']; $i++) |
|
105 | 108 | { |
106 | - if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) |
|
107 | - $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
109 | + if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) { |
|
110 | + $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
111 | + } |
|
108 | 112 | } |
109 | 113 | |
110 | 114 | // Are we from the client? |
@@ -112,16 +116,17 @@ discard block |
||
112 | 116 | { |
113 | 117 | $command_line = true; |
114 | 118 | $disable_security = true; |
115 | -} |
|
116 | -else |
|
119 | +} else { |
|
117 | 120 | $command_line = false; |
121 | +} |
|
118 | 122 | |
119 | 123 | // Load this now just because we can. |
120 | 124 | require_once($upgrade_path . '/Settings.php'); |
121 | 125 | |
122 | 126 | // We don't use "-utf8" anymore... Tweak the entry that may have been loaded by Settings.php |
123 | -if (isset($language)) |
|
127 | +if (isset($language)) { |
|
124 | 128 | $language = str_ireplace('-utf8', '', $language); |
129 | +} |
|
125 | 130 | |
126 | 131 | // Are we logged in? |
127 | 132 | if (isset($upgradeData)) |
@@ -129,10 +134,12 @@ discard block |
||
129 | 134 | $upcontext['user'] = json_decode(base64_decode($upgradeData), true); |
130 | 135 | |
131 | 136 | // Check for sensible values. |
132 | - if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) |
|
133 | - $upcontext['user']['started'] = time(); |
|
134 | - if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) |
|
135 | - $upcontext['user']['updated'] = 0; |
|
137 | + if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) { |
|
138 | + $upcontext['user']['started'] = time(); |
|
139 | + } |
|
140 | + if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) { |
|
141 | + $upcontext['user']['updated'] = 0; |
|
142 | + } |
|
136 | 143 | |
137 | 144 | $upcontext['started'] = $upcontext['user']['started']; |
138 | 145 | $upcontext['updated'] = $upcontext['user']['updated']; |
@@ -197,8 +204,9 @@ discard block |
||
197 | 204 | 'db_error_skip' => true, |
198 | 205 | ) |
199 | 206 | ); |
200 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
201 | - $modSettings[$row['variable']] = $row['value']; |
|
207 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
208 | + $modSettings[$row['variable']] = $row['value']; |
|
209 | + } |
|
202 | 210 | $smcFunc['db_free_result']($request); |
203 | 211 | } |
204 | 212 | |
@@ -208,10 +216,12 @@ discard block |
||
208 | 216 | $modSettings['theme_url'] = 'Themes/default'; |
209 | 217 | $modSettings['images_url'] = 'Themes/default/images'; |
210 | 218 | } |
211 | -if (!isset($settings['default_theme_url'])) |
|
219 | +if (!isset($settings['default_theme_url'])) { |
|
212 | 220 | $settings['default_theme_url'] = $modSettings['theme_url']; |
213 | -if (!isset($settings['default_theme_dir'])) |
|
221 | +} |
|
222 | +if (!isset($settings['default_theme_dir'])) { |
|
214 | 223 | $settings['default_theme_dir'] = $modSettings['theme_dir']; |
224 | +} |
|
215 | 225 | |
216 | 226 | $upcontext['is_large_forum'] = (empty($modSettings['smfVersion']) || $modSettings['smfVersion'] <= '1.1 RC1') && !empty($modSettings['totalMessages']) && $modSettings['totalMessages'] > 75000; |
217 | 227 | // Default title... |
@@ -229,13 +239,15 @@ discard block |
||
229 | 239 | $support_js = $upcontext['upgrade_status']['js']; |
230 | 240 | |
231 | 241 | // Only set this if the upgrader status says so. |
232 | - if (empty($is_debug)) |
|
233 | - $is_debug = $upcontext['upgrade_status']['debug']; |
|
242 | + if (empty($is_debug)) { |
|
243 | + $is_debug = $upcontext['upgrade_status']['debug']; |
|
244 | + } |
|
234 | 245 | |
235 | 246 | // Load the language. |
236 | - if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
237 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
238 | -} |
|
247 | + if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
248 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
249 | + } |
|
250 | + } |
|
239 | 251 | // Set the defaults. |
240 | 252 | else |
241 | 253 | { |
@@ -253,15 +265,18 @@ discard block |
||
253 | 265 | } |
254 | 266 | |
255 | 267 | // If this isn't the first stage see whether they are logging in and resuming. |
256 | -if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) |
|
268 | +if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) { |
|
257 | 269 | checkLogin(); |
270 | +} |
|
258 | 271 | |
259 | -if ($command_line) |
|
272 | +if ($command_line) { |
|
260 | 273 | cmdStep0(); |
274 | +} |
|
261 | 275 | |
262 | 276 | // Don't error if we're using xml. |
263 | -if (isset($_GET['xml'])) |
|
277 | +if (isset($_GET['xml'])) { |
|
264 | 278 | $upcontext['return_error'] = true; |
279 | +} |
|
265 | 280 | |
266 | 281 | // Loop through all the steps doing each one as required. |
267 | 282 | $upcontext['overall_percent'] = 0; |
@@ -282,9 +297,9 @@ discard block |
||
282 | 297 | } |
283 | 298 | |
284 | 299 | // Call the step and if it returns false that means pause! |
285 | - if (function_exists($step[2]) && $step[2]() === false) |
|
286 | - break; |
|
287 | - elseif (function_exists($step[2])) { |
|
300 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
301 | + break; |
|
302 | + } elseif (function_exists($step[2])) { |
|
288 | 303 | //Start each new step with this unset, so the 'normal' template is called first |
289 | 304 | unset($_GET['xml']); |
290 | 305 | //Clear out warnings at the start of each step |
@@ -330,17 +345,18 @@ discard block |
||
330 | 345 | // This should not happen my dear... HELP ME DEVELOPERS!! |
331 | 346 | if (!empty($command_line)) |
332 | 347 | { |
333 | - if (function_exists('debug_print_backtrace')) |
|
334 | - debug_print_backtrace(); |
|
348 | + if (function_exists('debug_print_backtrace')) { |
|
349 | + debug_print_backtrace(); |
|
350 | + } |
|
335 | 351 | |
336 | 352 | 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.'; |
337 | 353 | flush(); |
338 | 354 | die(); |
339 | 355 | } |
340 | 356 | |
341 | - if (!isset($_GET['xml'])) |
|
342 | - template_upgrade_above(); |
|
343 | - else |
|
357 | + if (!isset($_GET['xml'])) { |
|
358 | + template_upgrade_above(); |
|
359 | + } else |
|
344 | 360 | { |
345 | 361 | header('Content-Type: text/xml; charset=UTF-8'); |
346 | 362 | // Sadly we need to retain the $_GET data thanks to the old upgrade scripts. |
@@ -362,25 +378,29 @@ discard block |
||
362 | 378 | $upcontext['form_url'] = $upgradeurl . '?step=' . $upcontext['current_step'] . '&substep=' . $_GET['substep'] . '&data=' . base64_encode(json_encode($upcontext['upgrade_status'])); |
363 | 379 | |
364 | 380 | // Custom stuff to pass back? |
365 | - if (!empty($upcontext['query_string'])) |
|
366 | - $upcontext['form_url'] .= $upcontext['query_string']; |
|
381 | + if (!empty($upcontext['query_string'])) { |
|
382 | + $upcontext['form_url'] .= $upcontext['query_string']; |
|
383 | + } |
|
367 | 384 | |
368 | 385 | // Call the appropriate subtemplate |
369 | - if (is_callable('template_' . $upcontext['sub_template'])) |
|
370 | - call_user_func('template_' . $upcontext['sub_template']); |
|
371 | - else |
|
372 | - die('Upgrade aborted! Invalid template: template_' . $upcontext['sub_template']); |
|
386 | + if (is_callable('template_' . $upcontext['sub_template'])) { |
|
387 | + call_user_func('template_' . $upcontext['sub_template']); |
|
388 | + } else { |
|
389 | + die('Upgrade aborted! Invalid template: template_' . $upcontext['sub_template']); |
|
390 | + } |
|
373 | 391 | } |
374 | 392 | |
375 | 393 | // Was there an error? |
376 | - if (!empty($upcontext['forced_error_message'])) |
|
377 | - echo $upcontext['forced_error_message']; |
|
394 | + if (!empty($upcontext['forced_error_message'])) { |
|
395 | + echo $upcontext['forced_error_message']; |
|
396 | + } |
|
378 | 397 | |
379 | 398 | // Show the footer. |
380 | - if (!isset($_GET['xml'])) |
|
381 | - template_upgrade_below(); |
|
382 | - else |
|
383 | - template_xml_below(); |
|
399 | + if (!isset($_GET['xml'])) { |
|
400 | + template_upgrade_below(); |
|
401 | + } else { |
|
402 | + template_xml_below(); |
|
403 | + } |
|
384 | 404 | } |
385 | 405 | |
386 | 406 | |
@@ -392,15 +412,19 @@ discard block |
||
392 | 412 | $seconds = intval($active % 60); |
393 | 413 | |
394 | 414 | $totalTime = ''; |
395 | - if ($hours > 0) |
|
396 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
397 | - if ($minutes > 0) |
|
398 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
399 | - if ($seconds > 0) |
|
400 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
415 | + if ($hours > 0) { |
|
416 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
417 | + } |
|
418 | + if ($minutes > 0) { |
|
419 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
420 | + } |
|
421 | + if ($seconds > 0) { |
|
422 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
423 | + } |
|
401 | 424 | |
402 | - if (!empty($totalTime)) |
|
403 | - echo "\n" . 'Upgrade completed in ' . $totalTime . "\n"; |
|
425 | + if (!empty($totalTime)) { |
|
426 | + echo "\n" . 'Upgrade completed in ' . $totalTime . "\n"; |
|
427 | + } |
|
404 | 428 | } |
405 | 429 | |
406 | 430 | // Bang - gone! |
@@ -413,8 +437,9 @@ discard block |
||
413 | 437 | global $upgradeurl, $upcontext, $command_line; |
414 | 438 | |
415 | 439 | // Command line users can't be redirected. |
416 | - if ($command_line) |
|
417 | - upgradeExit(true); |
|
440 | + if ($command_line) { |
|
441 | + upgradeExit(true); |
|
442 | + } |
|
418 | 443 | |
419 | 444 | // Are we providing the core info? |
420 | 445 | if ($addForm) |
@@ -440,12 +465,14 @@ discard block |
||
440 | 465 | define('SMF', 1); |
441 | 466 | |
442 | 467 | // Start the session. |
443 | - if (@ini_get('session.save_handler') == 'user') |
|
444 | - @ini_set('session.save_handler', 'files'); |
|
468 | + if (@ini_get('session.save_handler') == 'user') { |
|
469 | + @ini_set('session.save_handler', 'files'); |
|
470 | + } |
|
445 | 471 | @session_start(); |
446 | 472 | |
447 | - if (empty($smcFunc)) |
|
448 | - $smcFunc = array(); |
|
473 | + if (empty($smcFunc)) { |
|
474 | + $smcFunc = array(); |
|
475 | + } |
|
449 | 476 | |
450 | 477 | // We need this for authentication and some upgrade code |
451 | 478 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -472,24 +499,27 @@ discard block |
||
472 | 499 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
473 | 500 | |
474 | 501 | // Make the connection... |
475 | - if (empty($db_connection)) |
|
476 | - $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true)); |
|
477 | - else |
|
478 | - // If we've returned here, ping/reconnect to be safe |
|
502 | + if (empty($db_connection)) { |
|
503 | + $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true)); |
|
504 | + } else { |
|
505 | + // If we've returned here, ping/reconnect to be safe |
|
479 | 506 | $smcFunc['db_ping']($db_connection); |
507 | + } |
|
480 | 508 | |
481 | 509 | // Oh dear god!! |
482 | - if ($db_connection === null) |
|
483 | - die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
510 | + if ($db_connection === null) { |
|
511 | + die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
512 | + } |
|
484 | 513 | |
485 | - if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) |
|
486 | - $smcFunc['db_query']('', ' |
|
514 | + if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) { |
|
515 | + $smcFunc['db_query']('', ' |
|
487 | 516 | SET NAMES {string:db_character_set}', |
488 | 517 | array( |
489 | 518 | 'db_error_skip' => true, |
490 | 519 | 'db_character_set' => $db_character_set, |
491 | 520 | ) |
492 | 521 | ); |
522 | + } |
|
493 | 523 | |
494 | 524 | // Load the modSettings data... |
495 | 525 | $request = $smcFunc['db_query']('', ' |
@@ -500,11 +530,11 @@ discard block |
||
500 | 530 | ) |
501 | 531 | ); |
502 | 532 | $modSettings = array(); |
503 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
504 | - $modSettings[$row['variable']] = $row['value']; |
|
533 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
534 | + $modSettings[$row['variable']] = $row['value']; |
|
535 | + } |
|
505 | 536 | $smcFunc['db_free_result']($request); |
506 | - } |
|
507 | - else |
|
537 | + } else |
|
508 | 538 | { |
509 | 539 | 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.'); |
510 | 540 | } |
@@ -518,9 +548,10 @@ discard block |
||
518 | 548 | cleanRequest(); |
519 | 549 | } |
520 | 550 | |
521 | - if (!isset($_GET['substep'])) |
|
522 | - $_GET['substep'] = 0; |
|
523 | -} |
|
551 | + if (!isset($_GET['substep'])) { |
|
552 | + $_GET['substep'] = 0; |
|
553 | + } |
|
554 | + } |
|
524 | 555 | |
525 | 556 | function initialize_inputs() |
526 | 557 | { |
@@ -550,8 +581,9 @@ discard block |
||
550 | 581 | $dh = opendir(dirname(__FILE__)); |
551 | 582 | while ($file = readdir($dh)) |
552 | 583 | { |
553 | - if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) |
|
554 | - @unlink(dirname(__FILE__) . '/' . $file); |
|
584 | + if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) { |
|
585 | + @unlink(dirname(__FILE__) . '/' . $file); |
|
586 | + } |
|
555 | 587 | } |
556 | 588 | closedir($dh); |
557 | 589 | |
@@ -580,8 +612,9 @@ discard block |
||
580 | 612 | $temp = 'upgrade_php?step'; |
581 | 613 | while (strlen($temp) > 4) |
582 | 614 | { |
583 | - if (isset($_GET[$temp])) |
|
584 | - unset($_GET[$temp]); |
|
615 | + if (isset($_GET[$temp])) { |
|
616 | + unset($_GET[$temp]); |
|
617 | + } |
|
585 | 618 | $temp = substr($temp, 1); |
586 | 619 | } |
587 | 620 | |
@@ -608,32 +641,39 @@ discard block |
||
608 | 641 | && @file_exists(dirname(__FILE__) . '/upgrade_2-1_' . $db_type . '.sql'); |
609 | 642 | |
610 | 643 | // Need legacy scripts? |
611 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) |
|
612 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
613 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) |
|
614 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
615 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) |
|
616 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
644 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) { |
|
645 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
646 | + } |
|
647 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) { |
|
648 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
649 | + } |
|
650 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) { |
|
651 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
652 | + } |
|
617 | 653 | |
618 | 654 | // We don't need "-utf8" files anymore... |
619 | 655 | $upcontext['language'] = str_ireplace('-utf8', '', $upcontext['language']); |
620 | 656 | |
621 | 657 | // This needs to exist! |
622 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
623 | - 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>]'); |
|
624 | - else |
|
625 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
658 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
659 | + 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>]'); |
|
660 | + } else { |
|
661 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
662 | + } |
|
626 | 663 | |
627 | - if (!$check) |
|
628 | - // 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. |
|
664 | + if (!$check) { |
|
665 | + // 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. |
|
629 | 666 | 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.'); |
667 | + } |
|
630 | 668 | |
631 | 669 | // Do they meet the install requirements? |
632 | - if (!php_version_check()) |
|
633 | - 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.'); |
|
670 | + if (!php_version_check()) { |
|
671 | + 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.'); |
|
672 | + } |
|
634 | 673 | |
635 | - if (!db_version_check()) |
|
636 | - 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.'); |
|
674 | + if (!db_version_check()) { |
|
675 | + 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.'); |
|
676 | + } |
|
637 | 677 | |
638 | 678 | // Do some checks to make sure they have proper privileges |
639 | 679 | db_extend('packages'); |
@@ -648,14 +688,16 @@ discard block |
||
648 | 688 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
649 | 689 | |
650 | 690 | // Sorry... we need CREATE, ALTER and DROP |
651 | - if (!$create || !$alter || !$drop) |
|
652 | - 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.'); |
|
691 | + if (!$create || !$alter || !$drop) { |
|
692 | + 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.'); |
|
693 | + } |
|
653 | 694 | |
654 | 695 | // Do a quick version spot check. |
655 | 696 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
656 | 697 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
657 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
658 | - 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.'); |
|
698 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
699 | + 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.'); |
|
700 | + } |
|
659 | 701 | |
660 | 702 | // What absolutely needs to be writable? |
661 | 703 | $writable_files = array( |
@@ -677,12 +719,13 @@ discard block |
||
677 | 719 | quickFileWritable($custom_av_dir); |
678 | 720 | |
679 | 721 | // Are we good now? |
680 | - if (!is_writable($custom_av_dir)) |
|
681 | - 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)); |
|
682 | - elseif ($need_settings_update) |
|
722 | + if (!is_writable($custom_av_dir)) { |
|
723 | + 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)); |
|
724 | + } elseif ($need_settings_update) |
|
683 | 725 | { |
684 | - if (!function_exists('cache_put_data')) |
|
685 | - require_once($sourcedir . '/Load.php'); |
|
726 | + if (!function_exists('cache_put_data')) { |
|
727 | + require_once($sourcedir . '/Load.php'); |
|
728 | + } |
|
686 | 729 | updateSettings(array('custom_avatar_dir' => $custom_av_dir)); |
687 | 730 | updateSettings(array('custom_avatar_url' => $custom_av_url)); |
688 | 731 | } |
@@ -691,28 +734,33 @@ discard block |
||
691 | 734 | |
692 | 735 | // Check the cache directory. |
693 | 736 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
694 | - if (!file_exists($cachedir_temp)) |
|
695 | - @mkdir($cachedir_temp); |
|
696 | - if (!file_exists($cachedir_temp)) |
|
697 | - 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.'); |
|
698 | - |
|
699 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
700 | - 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>.'); |
|
701 | - elseif (!isset($_GET['skiplang'])) |
|
737 | + if (!file_exists($cachedir_temp)) { |
|
738 | + @mkdir($cachedir_temp); |
|
739 | + } |
|
740 | + if (!file_exists($cachedir_temp)) { |
|
741 | + 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.'); |
|
742 | + } |
|
743 | + |
|
744 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
745 | + 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>.'); |
|
746 | + } elseif (!isset($_GET['skiplang'])) |
|
702 | 747 | { |
703 | 748 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
704 | 749 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
705 | 750 | |
706 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
707 | - 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>]'); |
|
751 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
752 | + 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>]'); |
|
753 | + } |
|
708 | 754 | } |
709 | 755 | |
710 | - if (!makeFilesWritable($writable_files)) |
|
711 | - return false; |
|
756 | + if (!makeFilesWritable($writable_files)) { |
|
757 | + return false; |
|
758 | + } |
|
712 | 759 | |
713 | 760 | // Check agreement.txt. (it may not exist, in which case $boarddir must be writable.) |
714 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
715 | - 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.'); |
|
761 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
762 | + 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.'); |
|
763 | + } |
|
716 | 764 | |
717 | 765 | // Upgrade the agreement. |
718 | 766 | elseif (isset($modSettings['agreement'])) |
@@ -723,8 +771,8 @@ discard block |
||
723 | 771 | } |
724 | 772 | |
725 | 773 | // We're going to check that their board dir setting is right in case they've been moving stuff around. |
726 | - if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) |
|
727 | - $upcontext['warning'] = ' |
|
774 | + if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) { |
|
775 | + $upcontext['warning'] = ' |
|
728 | 776 | 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> |
729 | 777 | <ul> |
730 | 778 | <li>Board Directory: ' . $boarddir . '</li> |
@@ -732,19 +780,23 @@ discard block |
||
732 | 780 | <li>Cache Directory: ' . $cachedir_temp . '</li> |
733 | 781 | </ul> |
734 | 782 | 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.'; |
783 | + } |
|
735 | 784 | |
736 | 785 | // Confirm mbstring is loaded... |
737 | - if (!extension_loaded('mbstring')) |
|
738 | - return throw_error($txt['install_no_mbstring']); |
|
786 | + if (!extension_loaded('mbstring')) { |
|
787 | + return throw_error($txt['install_no_mbstring']); |
|
788 | + } |
|
739 | 789 | |
740 | 790 | // Check for https stream support. |
741 | 791 | $supported_streams = stream_get_wrappers(); |
742 | - if (!in_array('https', $supported_streams)) |
|
743 | - $upcontext['custom_warning'] = $txt['install_no_https']; |
|
792 | + if (!in_array('https', $supported_streams)) { |
|
793 | + $upcontext['custom_warning'] = $txt['install_no_https']; |
|
794 | + } |
|
744 | 795 | |
745 | 796 | // Either we're logged in or we're going to present the login. |
746 | - if (checkLogin()) |
|
747 | - return true; |
|
797 | + if (checkLogin()) { |
|
798 | + return true; |
|
799 | + } |
|
748 | 800 | |
749 | 801 | $upcontext += createToken('login'); |
750 | 802 | |
@@ -758,15 +810,17 @@ discard block |
||
758 | 810 | global $smcFunc, $db_type, $support_js; |
759 | 811 | |
760 | 812 | // Don't bother if the security is disabled. |
761 | - if ($disable_security) |
|
762 | - return true; |
|
813 | + if ($disable_security) { |
|
814 | + return true; |
|
815 | + } |
|
763 | 816 | |
764 | 817 | // Are we trying to login? |
765 | 818 | if (isset($_POST['contbutt']) && (!empty($_POST['user']))) |
766 | 819 | { |
767 | 820 | // If we've disabled security pick a suitable name! |
768 | - if (empty($_POST['user'])) |
|
769 | - $_POST['user'] = 'Administrator'; |
|
821 | + if (empty($_POST['user'])) { |
|
822 | + $_POST['user'] = 'Administrator'; |
|
823 | + } |
|
770 | 824 | |
771 | 825 | // Before 2.0 these column names were different! |
772 | 826 | $oldDB = false; |
@@ -781,16 +835,17 @@ discard block |
||
781 | 835 | 'db_error_skip' => true, |
782 | 836 | ) |
783 | 837 | ); |
784 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
785 | - $oldDB = true; |
|
838 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
839 | + $oldDB = true; |
|
840 | + } |
|
786 | 841 | $smcFunc['db_free_result']($request); |
787 | 842 | } |
788 | 843 | |
789 | 844 | // Get what we believe to be their details. |
790 | 845 | if (!$disable_security) |
791 | 846 | { |
792 | - if ($oldDB) |
|
793 | - $request = $smcFunc['db_query']('', ' |
|
847 | + if ($oldDB) { |
|
848 | + $request = $smcFunc['db_query']('', ' |
|
794 | 849 | SELECT id_member, memberName AS member_name, passwd, id_group, |
795 | 850 | additionalGroups AS additional_groups, lngfile |
796 | 851 | FROM {db_prefix}members |
@@ -800,8 +855,8 @@ discard block |
||
800 | 855 | 'db_error_skip' => true, |
801 | 856 | ) |
802 | 857 | ); |
803 | - else |
|
804 | - $request = $smcFunc['db_query']('', ' |
|
858 | + } else { |
|
859 | + $request = $smcFunc['db_query']('', ' |
|
805 | 860 | SELECT id_member, member_name, passwd, id_group, additional_groups, lngfile |
806 | 861 | FROM {db_prefix}members |
807 | 862 | WHERE member_name = {string:member_name}', |
@@ -810,6 +865,7 @@ discard block |
||
810 | 865 | 'db_error_skip' => true, |
811 | 866 | ) |
812 | 867 | ); |
868 | + } |
|
813 | 869 | if ($smcFunc['db_num_rows']($request) != 0) |
814 | 870 | { |
815 | 871 | list ($id_member, $name, $password, $id_group, $addGroups, $user_language) = $smcFunc['db_fetch_row']($request); |
@@ -817,16 +873,17 @@ discard block |
||
817 | 873 | $groups = explode(',', $addGroups); |
818 | 874 | $groups[] = $id_group; |
819 | 875 | |
820 | - foreach ($groups as $k => $v) |
|
821 | - $groups[$k] = (int) $v; |
|
876 | + foreach ($groups as $k => $v) { |
|
877 | + $groups[$k] = (int) $v; |
|
878 | + } |
|
822 | 879 | |
823 | 880 | $sha_passwd = sha1(strtolower($name) . un_htmlspecialchars($_REQUEST['passwrd'])); |
824 | 881 | |
825 | 882 | // We don't use "-utf8" anymore... |
826 | 883 | $user_language = str_ireplace('-utf8', '', $user_language); |
884 | + } else { |
|
885 | + $upcontext['username_incorrect'] = true; |
|
827 | 886 | } |
828 | - else |
|
829 | - $upcontext['username_incorrect'] = true; |
|
830 | 887 | $smcFunc['db_free_result']($request); |
831 | 888 | } |
832 | 889 | $upcontext['username'] = $_POST['user']; |
@@ -836,13 +893,14 @@ discard block |
||
836 | 893 | { |
837 | 894 | $upcontext['upgrade_status']['js'] = 1; |
838 | 895 | $support_js = 1; |
896 | + } else { |
|
897 | + $support_js = 0; |
|
839 | 898 | } |
840 | - else |
|
841 | - $support_js = 0; |
|
842 | 899 | |
843 | 900 | // Note down the version we are coming from. |
844 | - if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) |
|
845 | - $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
901 | + if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) { |
|
902 | + $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
903 | + } |
|
846 | 904 | |
847 | 905 | // Didn't get anywhere? |
848 | 906 | 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'])) |
@@ -876,15 +934,15 @@ discard block |
||
876 | 934 | 'db_error_skip' => true, |
877 | 935 | ) |
878 | 936 | ); |
879 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
880 | - return throw_error('You need to be an admin to perform an upgrade!'); |
|
937 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
938 | + return throw_error('You need to be an admin to perform an upgrade!'); |
|
939 | + } |
|
881 | 940 | $smcFunc['db_free_result']($request); |
882 | 941 | } |
883 | 942 | |
884 | 943 | $upcontext['user']['id'] = $id_member; |
885 | 944 | $upcontext['user']['name'] = $name; |
886 | - } |
|
887 | - else |
|
945 | + } else |
|
888 | 946 | { |
889 | 947 | $upcontext['user']['id'] = 1; |
890 | 948 | $upcontext['user']['name'] = 'Administrator'; |
@@ -900,11 +958,11 @@ discard block |
||
900 | 958 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $user_language . '.php')), 0, 4096); |
901 | 959 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
902 | 960 | |
903 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
904 | - $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'] . '.'; |
|
905 | - elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) |
|
906 | - $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'] . '.'; |
|
907 | - else |
|
961 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
962 | + $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'] . '.'; |
|
963 | + } elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) { |
|
964 | + $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'] . '.'; |
|
965 | + } else |
|
908 | 966 | { |
909 | 967 | // Set this as the new language. |
910 | 968 | $upcontext['language'] = $user_language; |
@@ -948,8 +1006,9 @@ discard block |
||
948 | 1006 | unset($member_columns); |
949 | 1007 | |
950 | 1008 | // If we've not submitted then we're done. |
951 | - if (empty($_POST['upcont'])) |
|
952 | - return false; |
|
1009 | + if (empty($_POST['upcont'])) { |
|
1010 | + return false; |
|
1011 | + } |
|
953 | 1012 | |
954 | 1013 | // Firstly, if they're enabling SM stat collection just do it. |
955 | 1014 | if (!empty($_POST['stats']) && substr($boardurl, 0, 16) != 'http://localhost' && empty($modSettings['allow_sm_stats']) && empty($modSettings['enable_sm_stats'])) |
@@ -969,16 +1028,17 @@ discard block |
||
969 | 1028 | fwrite($fp, $out); |
970 | 1029 | |
971 | 1030 | $return_data = ''; |
972 | - while (!feof($fp)) |
|
973 | - $return_data .= fgets($fp, 128); |
|
1031 | + while (!feof($fp)) { |
|
1032 | + $return_data .= fgets($fp, 128); |
|
1033 | + } |
|
974 | 1034 | |
975 | 1035 | fclose($fp); |
976 | 1036 | |
977 | 1037 | // Get the unique site ID. |
978 | 1038 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
979 | 1039 | |
980 | - if (!empty($ID[1])) |
|
981 | - $smcFunc['db_insert']('replace', |
|
1040 | + if (!empty($ID[1])) { |
|
1041 | + $smcFunc['db_insert']('replace', |
|
982 | 1042 | $db_prefix . 'settings', |
983 | 1043 | array('variable' => 'string', 'value' => 'string'), |
984 | 1044 | array( |
@@ -987,9 +1047,9 @@ discard block |
||
987 | 1047 | ), |
988 | 1048 | array('variable') |
989 | 1049 | ); |
1050 | + } |
|
990 | 1051 | } |
991 | - } |
|
992 | - else |
|
1052 | + } else |
|
993 | 1053 | { |
994 | 1054 | $smcFunc['db_insert']('replace', |
995 | 1055 | $db_prefix . 'settings', |
@@ -1000,8 +1060,8 @@ discard block |
||
1000 | 1060 | } |
1001 | 1061 | } |
1002 | 1062 | // Don't remove stat collection unless we unchecked the box for real, not from the loop. |
1003 | - elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) |
|
1004 | - $smcFunc['db_query']('', ' |
|
1063 | + elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) { |
|
1064 | + $smcFunc['db_query']('', ' |
|
1005 | 1065 | DELETE FROM {db_prefix}settings |
1006 | 1066 | WHERE variable = {string:enable_sm_stats}', |
1007 | 1067 | array( |
@@ -1009,6 +1069,7 @@ discard block |
||
1009 | 1069 | 'db_error_skip' => true, |
1010 | 1070 | ) |
1011 | 1071 | ); |
1072 | + } |
|
1012 | 1073 | |
1013 | 1074 | // Deleting old karma stuff? |
1014 | 1075 | if (!empty($_POST['delete_karma'])) |
@@ -1023,20 +1084,22 @@ discard block |
||
1023 | 1084 | ); |
1024 | 1085 | |
1025 | 1086 | // Cleaning up old karma member settings. |
1026 | - if ($upcontext['karma_installed']['good']) |
|
1027 | - $smcFunc['db_query']('', ' |
|
1087 | + if ($upcontext['karma_installed']['good']) { |
|
1088 | + $smcFunc['db_query']('', ' |
|
1028 | 1089 | ALTER TABLE {db_prefix}members |
1029 | 1090 | DROP karma_good', |
1030 | 1091 | array() |
1031 | 1092 | ); |
1093 | + } |
|
1032 | 1094 | |
1033 | 1095 | // Does karma bad was enable? |
1034 | - if ($upcontext['karma_installed']['bad']) |
|
1035 | - $smcFunc['db_query']('', ' |
|
1096 | + if ($upcontext['karma_installed']['bad']) { |
|
1097 | + $smcFunc['db_query']('', ' |
|
1036 | 1098 | ALTER TABLE {db_prefix}members |
1037 | 1099 | DROP karma_bad', |
1038 | 1100 | array() |
1039 | 1101 | ); |
1102 | + } |
|
1040 | 1103 | |
1041 | 1104 | // Cleaning up old karma permissions. |
1042 | 1105 | $smcFunc['db_query']('', ' |
@@ -1049,32 +1112,37 @@ discard block |
||
1049 | 1112 | } |
1050 | 1113 | |
1051 | 1114 | // Emptying the error log? |
1052 | - if (!empty($_POST['empty_error'])) |
|
1053 | - $smcFunc['db_query']('truncate_table', ' |
|
1115 | + if (!empty($_POST['empty_error'])) { |
|
1116 | + $smcFunc['db_query']('truncate_table', ' |
|
1054 | 1117 | TRUNCATE {db_prefix}log_errors', |
1055 | 1118 | array( |
1056 | 1119 | ) |
1057 | 1120 | ); |
1121 | + } |
|
1058 | 1122 | |
1059 | 1123 | $changes = array(); |
1060 | 1124 | |
1061 | 1125 | // Add proxy settings. |
1062 | - if (!isset($GLOBALS['image_proxy_maxsize'])) |
|
1063 | - $changes += array( |
|
1126 | + if (!isset($GLOBALS['image_proxy_maxsize'])) { |
|
1127 | + $changes += array( |
|
1064 | 1128 | 'image_proxy_secret' => '\'' . substr(sha1(mt_rand()), 0, 20) . '\'', |
1065 | 1129 | 'image_proxy_maxsize' => 5190, |
1066 | 1130 | 'image_proxy_enabled' => 0, |
1067 | 1131 | ); |
1132 | + } |
|
1068 | 1133 | |
1069 | 1134 | // If $boardurl reflects https, set force_ssl |
1070 | - if (!function_exists('cache_put_data')) |
|
1071 | - require_once($sourcedir . '/Load.php'); |
|
1072 | - if (stripos($boardurl, 'https://') !== false) |
|
1073 | - updateSettings(array('force_ssl' => '2')); |
|
1135 | + if (!function_exists('cache_put_data')) { |
|
1136 | + require_once($sourcedir . '/Load.php'); |
|
1137 | + } |
|
1138 | + if (stripos($boardurl, 'https://') !== false) { |
|
1139 | + updateSettings(array('force_ssl' => '2')); |
|
1140 | + } |
|
1074 | 1141 | |
1075 | 1142 | // If we're overriding the language follow it through. |
1076 | - if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) |
|
1077 | - $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
1143 | + if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) { |
|
1144 | + $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
1145 | + } |
|
1078 | 1146 | |
1079 | 1147 | if (!empty($_POST['maint'])) |
1080 | 1148 | { |
@@ -1086,26 +1154,29 @@ discard block |
||
1086 | 1154 | { |
1087 | 1155 | $changes['mtitle'] = '\'' . addslashes($_POST['maintitle']) . '\''; |
1088 | 1156 | $changes['mmessage'] = '\'' . addslashes($_POST['mainmessage']) . '\''; |
1089 | - } |
|
1090 | - else |
|
1157 | + } else |
|
1091 | 1158 | { |
1092 | 1159 | $changes['mtitle'] = '\'Upgrading the forum...\''; |
1093 | 1160 | $changes['mmessage'] = '\'Don\\\'t worry, we will be back shortly with an updated forum. It will only be a minute ;).\''; |
1094 | 1161 | } |
1095 | 1162 | } |
1096 | 1163 | |
1097 | - if ($command_line) |
|
1098 | - echo ' * Updating Settings.php...'; |
|
1164 | + if ($command_line) { |
|
1165 | + echo ' * Updating Settings.php...'; |
|
1166 | + } |
|
1099 | 1167 | |
1100 | 1168 | // Fix some old paths. |
1101 | - if (substr($boarddir, 0, 1) == '.') |
|
1102 | - $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
1169 | + if (substr($boarddir, 0, 1) == '.') { |
|
1170 | + $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
1171 | + } |
|
1103 | 1172 | |
1104 | - if (substr($sourcedir, 0, 1) == '.') |
|
1105 | - $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
1173 | + if (substr($sourcedir, 0, 1) == '.') { |
|
1174 | + $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
1175 | + } |
|
1106 | 1176 | |
1107 | - if (empty($cachedir) || substr($cachedir, 0, 1) == '.') |
|
1108 | - $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
1177 | + if (empty($cachedir) || substr($cachedir, 0, 1) == '.') { |
|
1178 | + $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
1179 | + } |
|
1109 | 1180 | |
1110 | 1181 | // If they have a "host:port" setup for the host, split that into separate values |
1111 | 1182 | // You should never have a : in the hostname if you're not on MySQL, but better safe than sorry |
@@ -1116,32 +1187,36 @@ discard block |
||
1116 | 1187 | $changes['db_server'] = '\'' . $db_server . '\''; |
1117 | 1188 | |
1118 | 1189 | // Only set this if we're not using the default port |
1119 | - if ($db_port != ini_get('mysqli.default_port')) |
|
1120 | - $changes['db_port'] = (int) $db_port; |
|
1121 | - } |
|
1122 | - elseif (!empty($db_port)) |
|
1190 | + if ($db_port != ini_get('mysqli.default_port')) { |
|
1191 | + $changes['db_port'] = (int) $db_port; |
|
1192 | + } |
|
1193 | + } elseif (!empty($db_port)) |
|
1123 | 1194 | { |
1124 | 1195 | // If db_port is set and is the same as the default, set it to '' |
1125 | 1196 | if ($db_type == 'mysql') |
1126 | 1197 | { |
1127 | - if ($db_port == ini_get('mysqli.default_port')) |
|
1128 | - $changes['db_port'] = '\'\''; |
|
1129 | - elseif ($db_type == 'postgresql' && $db_port == 5432) |
|
1130 | - $changes['db_port'] = '\'\''; |
|
1198 | + if ($db_port == ini_get('mysqli.default_port')) { |
|
1199 | + $changes['db_port'] = '\'\''; |
|
1200 | + } elseif ($db_type == 'postgresql' && $db_port == 5432) { |
|
1201 | + $changes['db_port'] = '\'\''; |
|
1202 | + } |
|
1131 | 1203 | } |
1132 | 1204 | } |
1133 | 1205 | |
1134 | 1206 | // Maybe we haven't had this option yet? |
1135 | - if (empty($packagesdir)) |
|
1136 | - $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
1207 | + if (empty($packagesdir)) { |
|
1208 | + $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
1209 | + } |
|
1137 | 1210 | |
1138 | 1211 | // Add support for $tasksdir var. |
1139 | - if (empty($tasksdir)) |
|
1140 | - $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
1212 | + if (empty($tasksdir)) { |
|
1213 | + $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
1214 | + } |
|
1141 | 1215 | |
1142 | 1216 | // Make sure we fix the language as well. |
1143 | - if (stristr($language, '-utf8')) |
|
1144 | - $changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\''; |
|
1217 | + if (stristr($language, '-utf8')) { |
|
1218 | + $changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\''; |
|
1219 | + } |
|
1145 | 1220 | |
1146 | 1221 | // @todo Maybe change the cookie name if going to 1.1, too? |
1147 | 1222 | |
@@ -1149,8 +1224,9 @@ discard block |
||
1149 | 1224 | require_once($sourcedir . '/Subs-Admin.php'); |
1150 | 1225 | updateSettingsFile($changes); |
1151 | 1226 | |
1152 | - if ($command_line) |
|
1153 | - echo ' Successful.' . "\n"; |
|
1227 | + if ($command_line) { |
|
1228 | + echo ' Successful.' . "\n"; |
|
1229 | + } |
|
1154 | 1230 | |
1155 | 1231 | // Are we doing debug? |
1156 | 1232 | if (isset($_POST['debug'])) |
@@ -1160,8 +1236,9 @@ discard block |
||
1160 | 1236 | } |
1161 | 1237 | |
1162 | 1238 | // If we're not backing up then jump one. |
1163 | - if (empty($_POST['backup'])) |
|
1164 | - $upcontext['current_step']++; |
|
1239 | + if (empty($_POST['backup'])) { |
|
1240 | + $upcontext['current_step']++; |
|
1241 | + } |
|
1165 | 1242 | |
1166 | 1243 | // If we've got here then let's proceed to the next step! |
1167 | 1244 | return true; |
@@ -1176,8 +1253,9 @@ discard block |
||
1176 | 1253 | $upcontext['page_title'] = 'Backup Database'; |
1177 | 1254 | |
1178 | 1255 | // Done it already - js wise? |
1179 | - if (!empty($_POST['backup_done'])) |
|
1180 | - return true; |
|
1256 | + if (!empty($_POST['backup_done'])) { |
|
1257 | + return true; |
|
1258 | + } |
|
1181 | 1259 | |
1182 | 1260 | // Some useful stuff here. |
1183 | 1261 | db_extend(); |
@@ -1191,9 +1269,10 @@ discard block |
||
1191 | 1269 | $tables = $smcFunc['db_list_tables']($db, $filter); |
1192 | 1270 | |
1193 | 1271 | $table_names = array(); |
1194 | - foreach ($tables as $table) |
|
1195 | - if (substr($table, 0, 7) !== 'backup_') |
|
1272 | + foreach ($tables as $table) { |
|
1273 | + if (substr($table, 0, 7) !== 'backup_') |
|
1196 | 1274 | $table_names[] = $table; |
1275 | + } |
|
1197 | 1276 | |
1198 | 1277 | $upcontext['table_count'] = count($table_names); |
1199 | 1278 | $upcontext['cur_table_num'] = $_GET['substep']; |
@@ -1203,12 +1282,14 @@ discard block |
||
1203 | 1282 | $file_steps = $upcontext['table_count']; |
1204 | 1283 | |
1205 | 1284 | // What ones have we already done? |
1206 | - foreach ($table_names as $id => $table) |
|
1207 | - if ($id < $_GET['substep']) |
|
1285 | + foreach ($table_names as $id => $table) { |
|
1286 | + if ($id < $_GET['substep']) |
|
1208 | 1287 | $upcontext['previous_tables'][] = $table; |
1288 | + } |
|
1209 | 1289 | |
1210 | - if ($command_line) |
|
1211 | - echo 'Backing Up Tables.'; |
|
1290 | + if ($command_line) { |
|
1291 | + echo 'Backing Up Tables.'; |
|
1292 | + } |
|
1212 | 1293 | |
1213 | 1294 | // If we don't support javascript we backup here. |
1214 | 1295 | if (!$support_js || isset($_GET['xml'])) |
@@ -1227,8 +1308,9 @@ discard block |
||
1227 | 1308 | backupTable($table_names[$substep]); |
1228 | 1309 | |
1229 | 1310 | // If this is XML to keep it nice for the user do one table at a time anyway! |
1230 | - if (isset($_GET['xml'])) |
|
1231 | - return upgradeExit(); |
|
1311 | + if (isset($_GET['xml'])) { |
|
1312 | + return upgradeExit(); |
|
1313 | + } |
|
1232 | 1314 | } |
1233 | 1315 | |
1234 | 1316 | if ($command_line) |
@@ -1261,9 +1343,10 @@ discard block |
||
1261 | 1343 | |
1262 | 1344 | $smcFunc['db_backup_table']($table, 'backup_' . $table); |
1263 | 1345 | |
1264 | - if ($command_line) |
|
1265 | - echo ' done.'; |
|
1266 | -} |
|
1346 | + if ($command_line) { |
|
1347 | + echo ' done.'; |
|
1348 | + } |
|
1349 | + } |
|
1267 | 1350 | |
1268 | 1351 | // Step 2: Everything. |
1269 | 1352 | function DatabaseChanges() |
@@ -1272,8 +1355,9 @@ discard block |
||
1272 | 1355 | global $upcontext, $support_js, $db_type; |
1273 | 1356 | |
1274 | 1357 | // Have we just completed this? |
1275 | - if (!empty($_POST['database_done'])) |
|
1276 | - return true; |
|
1358 | + if (!empty($_POST['database_done'])) { |
|
1359 | + return true; |
|
1360 | + } |
|
1277 | 1361 | |
1278 | 1362 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'database_xml' : 'database_changes'; |
1279 | 1363 | $upcontext['page_title'] = 'Database Changes'; |
@@ -1288,15 +1372,16 @@ discard block |
||
1288 | 1372 | ); |
1289 | 1373 | |
1290 | 1374 | // How many files are there in total? |
1291 | - if (isset($_GET['filecount'])) |
|
1292 | - $upcontext['file_count'] = (int) $_GET['filecount']; |
|
1293 | - else |
|
1375 | + if (isset($_GET['filecount'])) { |
|
1376 | + $upcontext['file_count'] = (int) $_GET['filecount']; |
|
1377 | + } else |
|
1294 | 1378 | { |
1295 | 1379 | $upcontext['file_count'] = 0; |
1296 | 1380 | foreach ($files as $file) |
1297 | 1381 | { |
1298 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) |
|
1299 | - $upcontext['file_count']++; |
|
1382 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) { |
|
1383 | + $upcontext['file_count']++; |
|
1384 | + } |
|
1300 | 1385 | } |
1301 | 1386 | } |
1302 | 1387 | |
@@ -1306,9 +1391,9 @@ discard block |
||
1306 | 1391 | $upcontext['cur_file_num'] = 0; |
1307 | 1392 | foreach ($files as $file) |
1308 | 1393 | { |
1309 | - if ($did_not_do) |
|
1310 | - $did_not_do--; |
|
1311 | - else |
|
1394 | + if ($did_not_do) { |
|
1395 | + $did_not_do--; |
|
1396 | + } else |
|
1312 | 1397 | { |
1313 | 1398 | $upcontext['cur_file_num']++; |
1314 | 1399 | $upcontext['cur_file_name'] = $file[0]; |
@@ -1335,12 +1420,13 @@ discard block |
||
1335 | 1420 | // Flag to move on to the next. |
1336 | 1421 | $upcontext['completed_step'] = true; |
1337 | 1422 | // Did we complete the whole file? |
1338 | - if ($nextFile) |
|
1339 | - $upcontext['current_debug_item_num'] = -1; |
|
1423 | + if ($nextFile) { |
|
1424 | + $upcontext['current_debug_item_num'] = -1; |
|
1425 | + } |
|
1340 | 1426 | return upgradeExit(); |
1427 | + } elseif ($support_js) { |
|
1428 | + break; |
|
1341 | 1429 | } |
1342 | - elseif ($support_js) |
|
1343 | - break; |
|
1344 | 1430 | } |
1345 | 1431 | // Set the progress bar to be right as if we had - even if we hadn't... |
1346 | 1432 | $upcontext['step_progress'] = ($upcontext['cur_file_num'] / $upcontext['file_count']) * 100; |
@@ -1365,8 +1451,9 @@ discard block |
||
1365 | 1451 | global $command_line, $language, $upcontext, $sourcedir, $forum_version, $user_info, $maintenance, $smcFunc, $db_type; |
1366 | 1452 | |
1367 | 1453 | // Now it's nice to have some of the basic SMF source files. |
1368 | - if (!isset($_GET['ssi']) && !$command_line) |
|
1369 | - redirectLocation('&ssi=1'); |
|
1454 | + if (!isset($_GET['ssi']) && !$command_line) { |
|
1455 | + redirectLocation('&ssi=1'); |
|
1456 | + } |
|
1370 | 1457 | |
1371 | 1458 | $upcontext['sub_template'] = 'upgrade_complete'; |
1372 | 1459 | $upcontext['page_title'] = 'Upgrade Complete'; |
@@ -1382,14 +1469,16 @@ discard block |
||
1382 | 1469 | // Are we in maintenance mode? |
1383 | 1470 | if (isset($upcontext['user']['main'])) |
1384 | 1471 | { |
1385 | - if ($command_line) |
|
1386 | - echo ' * '; |
|
1472 | + if ($command_line) { |
|
1473 | + echo ' * '; |
|
1474 | + } |
|
1387 | 1475 | $upcontext['removed_maintenance'] = true; |
1388 | 1476 | $changes['maintenance'] = $upcontext['user']['main']; |
1389 | 1477 | } |
1390 | 1478 | // Otherwise if somehow we are in 2 let's go to 1. |
1391 | - elseif (!empty($maintenance) && $maintenance == 2) |
|
1392 | - $changes['maintenance'] = 1; |
|
1479 | + elseif (!empty($maintenance) && $maintenance == 2) { |
|
1480 | + $changes['maintenance'] = 1; |
|
1481 | + } |
|
1393 | 1482 | |
1394 | 1483 | // Wipe this out... |
1395 | 1484 | $upcontext['user'] = array(); |
@@ -1404,9 +1493,9 @@ discard block |
||
1404 | 1493 | $upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__); |
1405 | 1494 | |
1406 | 1495 | // Now is the perfect time to fetch the SM files. |
1407 | - if ($command_line) |
|
1408 | - cli_scheduled_fetchSMfiles(); |
|
1409 | - else |
|
1496 | + if ($command_line) { |
|
1497 | + cli_scheduled_fetchSMfiles(); |
|
1498 | + } else |
|
1410 | 1499 | { |
1411 | 1500 | require_once($sourcedir . '/ScheduledTasks.php'); |
1412 | 1501 | $forum_version = SMF_VERSION; // The variable is usually defined in index.php so lets just use the constant to do it for us. |
@@ -1414,8 +1503,9 @@ discard block |
||
1414 | 1503 | } |
1415 | 1504 | |
1416 | 1505 | // Log what we've done. |
1417 | - if (empty($user_info['id'])) |
|
1418 | - $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
1506 | + if (empty($user_info['id'])) { |
|
1507 | + $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
1508 | + } |
|
1419 | 1509 | |
1420 | 1510 | // Log the action manually, so CLI still works. |
1421 | 1511 | $smcFunc['db_insert']('', |
@@ -1434,8 +1524,9 @@ discard block |
||
1434 | 1524 | |
1435 | 1525 | // Save the current database version. |
1436 | 1526 | $server_version = $smcFunc['db_server_info'](); |
1437 | - if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
1438 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
1527 | + if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
1528 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
1529 | + } |
|
1439 | 1530 | |
1440 | 1531 | if ($command_line) |
1441 | 1532 | { |
@@ -1447,8 +1538,9 @@ discard block |
||
1447 | 1538 | |
1448 | 1539 | // Make sure it says we're done. |
1449 | 1540 | $upcontext['overall_percent'] = 100; |
1450 | - if (isset($upcontext['step_progress'])) |
|
1451 | - unset($upcontext['step_progress']); |
|
1541 | + if (isset($upcontext['step_progress'])) { |
|
1542 | + unset($upcontext['step_progress']); |
|
1543 | + } |
|
1452 | 1544 | |
1453 | 1545 | $_GET['substep'] = 0; |
1454 | 1546 | return false; |
@@ -1459,8 +1551,9 @@ discard block |
||
1459 | 1551 | { |
1460 | 1552 | global $sourcedir, $language, $forum_version, $modSettings, $smcFunc; |
1461 | 1553 | |
1462 | - if (empty($modSettings['time_format'])) |
|
1463 | - $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
1554 | + if (empty($modSettings['time_format'])) { |
|
1555 | + $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
1556 | + } |
|
1464 | 1557 | |
1465 | 1558 | // What files do we want to get |
1466 | 1559 | $request = $smcFunc['db_query']('', ' |
@@ -1494,8 +1587,9 @@ discard block |
||
1494 | 1587 | $file_data = fetch_web_data($url); |
1495 | 1588 | |
1496 | 1589 | // If we got an error - give up - the site might be down. |
1497 | - if ($file_data === false) |
|
1498 | - return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
1590 | + if ($file_data === false) { |
|
1591 | + return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
1592 | + } |
|
1499 | 1593 | |
1500 | 1594 | // Save the file to the database. |
1501 | 1595 | $smcFunc['db_query']('substring', ' |
@@ -1537,8 +1631,9 @@ discard block |
||
1537 | 1631 | $themeData = array(); |
1538 | 1632 | foreach ($values as $variable => $value) |
1539 | 1633 | { |
1540 | - if (!isset($value) || $value === null) |
|
1541 | - $value = 0; |
|
1634 | + if (!isset($value) || $value === null) { |
|
1635 | + $value = 0; |
|
1636 | + } |
|
1542 | 1637 | |
1543 | 1638 | $themeData[] = array(0, 1, $variable, $value); |
1544 | 1639 | } |
@@ -1567,8 +1662,9 @@ discard block |
||
1567 | 1662 | |
1568 | 1663 | foreach ($values as $variable => $value) |
1569 | 1664 | { |
1570 | - if (empty($modSettings[$value[0]])) |
|
1571 | - continue; |
|
1665 | + if (empty($modSettings[$value[0]])) { |
|
1666 | + continue; |
|
1667 | + } |
|
1572 | 1668 | |
1573 | 1669 | $smcFunc['db_query']('', ' |
1574 | 1670 | INSERT IGNORE INTO {db_prefix}themes |
@@ -1654,19 +1750,21 @@ discard block |
||
1654 | 1750 | set_error_handler( |
1655 | 1751 | function ($errno, $errstr, $errfile, $errline) use ($support_js) |
1656 | 1752 | { |
1657 | - if ($support_js) |
|
1658 | - return true; |
|
1659 | - else |
|
1660 | - echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
1753 | + if ($support_js) { |
|
1754 | + return true; |
|
1755 | + } else { |
|
1756 | + echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
1757 | + } |
|
1661 | 1758 | } |
1662 | 1759 | ); |
1663 | 1760 | |
1664 | 1761 | // If we're on MySQL, set {db_collation}; this approach is used throughout upgrade_2-0_mysql.php to set new tables to utf8 |
1665 | 1762 | // Note it is expected to be in the format: ENGINE=MyISAM{$db_collation}; |
1666 | - if ($db_type == 'mysql') |
|
1667 | - $db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
1668 | - else |
|
1669 | - $db_collation = ''; |
|
1763 | + if ($db_type == 'mysql') { |
|
1764 | + $db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
1765 | + } else { |
|
1766 | + $db_collation = ''; |
|
1767 | + } |
|
1670 | 1768 | |
1671 | 1769 | $endl = $command_line ? "\n" : '<br>' . "\n"; |
1672 | 1770 | |
@@ -1678,8 +1776,9 @@ discard block |
||
1678 | 1776 | $last_step = ''; |
1679 | 1777 | |
1680 | 1778 | // Make sure all newly created tables will have the proper characters set; this approach is used throughout upgrade_2-1_mysql.php |
1681 | - if (isset($db_character_set) && $db_character_set === 'utf8') |
|
1682 | - $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
1779 | + if (isset($db_character_set) && $db_character_set === 'utf8') { |
|
1780 | + $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
1781 | + } |
|
1683 | 1782 | |
1684 | 1783 | // Count the total number of steps within this file - for progress. |
1685 | 1784 | $file_steps = substr_count(implode('', $lines), '---#'); |
@@ -1699,15 +1798,18 @@ discard block |
||
1699 | 1798 | $do_current = $substep >= $_GET['substep']; |
1700 | 1799 | |
1701 | 1800 | // Get rid of any comments in the beginning of the line... |
1702 | - if (substr(trim($line), 0, 2) === '/*') |
|
1703 | - $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
1801 | + if (substr(trim($line), 0, 2) === '/*') { |
|
1802 | + $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
1803 | + } |
|
1704 | 1804 | |
1705 | 1805 | // Always flush. Flush, flush, flush. Flush, flush, flush, flush! FLUSH! |
1706 | - if ($is_debug && !$support_js && $command_line) |
|
1707 | - flush(); |
|
1806 | + if ($is_debug && !$support_js && $command_line) { |
|
1807 | + flush(); |
|
1808 | + } |
|
1708 | 1809 | |
1709 | - if (trim($line) === '') |
|
1710 | - continue; |
|
1810 | + if (trim($line) === '') { |
|
1811 | + continue; |
|
1812 | + } |
|
1711 | 1813 | |
1712 | 1814 | if (trim(substr($line, 0, 3)) === '---') |
1713 | 1815 | { |
@@ -1717,8 +1819,9 @@ discard block |
||
1717 | 1819 | if (trim($current_data) != '' && $type !== '}') |
1718 | 1820 | { |
1719 | 1821 | $upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl; |
1720 | - if ($command_line) |
|
1721 | - echo $upcontext['error_message']; |
|
1822 | + if ($command_line) { |
|
1823 | + echo $upcontext['error_message']; |
|
1824 | + } |
|
1722 | 1825 | } |
1723 | 1826 | |
1724 | 1827 | if ($type == ' ') |
@@ -1736,17 +1839,18 @@ discard block |
||
1736 | 1839 | if ($do_current) |
1737 | 1840 | { |
1738 | 1841 | $upcontext['actioned_items'][] = $last_step; |
1739 | - if ($command_line) |
|
1740 | - echo ' * '; |
|
1842 | + if ($command_line) { |
|
1843 | + echo ' * '; |
|
1844 | + } |
|
1741 | 1845 | } |
1742 | - } |
|
1743 | - elseif ($type == '#') |
|
1846 | + } elseif ($type == '#') |
|
1744 | 1847 | { |
1745 | 1848 | $upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps; |
1746 | 1849 | |
1747 | 1850 | $upcontext['current_debug_item_num']++; |
1748 | - if (trim($line) != '---#') |
|
1749 | - $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
1851 | + if (trim($line) != '---#') { |
|
1852 | + $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
1853 | + } |
|
1750 | 1854 | |
1751 | 1855 | // Have we already done something? |
1752 | 1856 | if (isset($_GET['xml']) && $done_something) |
@@ -1757,34 +1861,36 @@ discard block |
||
1757 | 1861 | |
1758 | 1862 | if ($do_current) |
1759 | 1863 | { |
1760 | - if (trim($line) == '---#' && $command_line) |
|
1761 | - echo ' done.', $endl; |
|
1762 | - elseif ($command_line) |
|
1763 | - echo ' +++ ', rtrim(substr($line, 4)); |
|
1764 | - elseif (trim($line) != '---#') |
|
1864 | + if (trim($line) == '---#' && $command_line) { |
|
1865 | + echo ' done.', $endl; |
|
1866 | + } elseif ($command_line) { |
|
1867 | + echo ' +++ ', rtrim(substr($line, 4)); |
|
1868 | + } elseif (trim($line) != '---#') |
|
1765 | 1869 | { |
1766 | - if ($is_debug) |
|
1767 | - $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
1870 | + if ($is_debug) { |
|
1871 | + $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
1872 | + } |
|
1768 | 1873 | } |
1769 | 1874 | } |
1770 | 1875 | |
1771 | 1876 | if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep']) |
1772 | 1877 | { |
1773 | - if ($command_line) |
|
1774 | - echo ' * '; |
|
1775 | - else |
|
1776 | - $upcontext['actioned_items'][] = $last_step; |
|
1878 | + if ($command_line) { |
|
1879 | + echo ' * '; |
|
1880 | + } else { |
|
1881 | + $upcontext['actioned_items'][] = $last_step; |
|
1882 | + } |
|
1777 | 1883 | } |
1778 | 1884 | |
1779 | 1885 | // Small step - only if we're actually doing stuff. |
1780 | - if ($do_current) |
|
1781 | - nextSubstep(++$substep); |
|
1782 | - else |
|
1783 | - $substep++; |
|
1784 | - } |
|
1785 | - elseif ($type == '{') |
|
1786 | - $current_type = 'code'; |
|
1787 | - elseif ($type == '}') |
|
1886 | + if ($do_current) { |
|
1887 | + nextSubstep(++$substep); |
|
1888 | + } else { |
|
1889 | + $substep++; |
|
1890 | + } |
|
1891 | + } elseif ($type == '{') { |
|
1892 | + $current_type = 'code'; |
|
1893 | + } elseif ($type == '}') |
|
1788 | 1894 | { |
1789 | 1895 | $current_type = 'sql'; |
1790 | 1896 | |
@@ -1797,8 +1903,9 @@ discard block |
||
1797 | 1903 | if (eval('global $db_prefix, $modSettings, $smcFunc; ' . $current_data) === false) |
1798 | 1904 | { |
1799 | 1905 | $upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl; |
1800 | - if ($command_line) |
|
1801 | - echo $upcontext['error_message']; |
|
1906 | + if ($command_line) { |
|
1907 | + echo $upcontext['error_message']; |
|
1908 | + } |
|
1802 | 1909 | } |
1803 | 1910 | |
1804 | 1911 | // Done with code! |
@@ -1878,8 +1985,9 @@ discard block |
||
1878 | 1985 | $db_unbuffered = false; |
1879 | 1986 | |
1880 | 1987 | // Failure?! |
1881 | - if ($result !== false) |
|
1882 | - return $result; |
|
1988 | + if ($result !== false) { |
|
1989 | + return $result; |
|
1990 | + } |
|
1883 | 1991 | |
1884 | 1992 | $db_error_message = $smcFunc['db_error']($db_connection); |
1885 | 1993 | // If MySQL we do something more clever. |
@@ -1907,54 +2015,61 @@ discard block |
||
1907 | 2015 | { |
1908 | 2016 | mysqli_query($db_connection, 'REPAIR TABLE `' . $match[1] . '`'); |
1909 | 2017 | $result = mysqli_query($db_connection, $string); |
1910 | - if ($result !== false) |
|
1911 | - return $result; |
|
2018 | + if ($result !== false) { |
|
2019 | + return $result; |
|
2020 | + } |
|
1912 | 2021 | } |
1913 | - } |
|
1914 | - elseif ($mysqli_errno == 2013) |
|
2022 | + } elseif ($mysqli_errno == 2013) |
|
1915 | 2023 | { |
1916 | 2024 | $db_connection = mysqli_connect($db_server, $db_user, $db_passwd); |
1917 | 2025 | mysqli_select_db($db_connection, $db_name); |
1918 | 2026 | if ($db_connection) |
1919 | 2027 | { |
1920 | 2028 | $result = mysqli_query($db_connection, $string); |
1921 | - if ($result !== false) |
|
1922 | - return $result; |
|
2029 | + if ($result !== false) { |
|
2030 | + return $result; |
|
2031 | + } |
|
1923 | 2032 | } |
1924 | 2033 | } |
1925 | 2034 | // Duplicate column name... should be okay ;). |
1926 | - elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) |
|
1927 | - return false; |
|
2035 | + elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) { |
|
2036 | + return false; |
|
2037 | + } |
|
1928 | 2038 | // Duplicate insert... make sure it's the proper type of query ;). |
1929 | - elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) |
|
1930 | - return false; |
|
2039 | + elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) { |
|
2040 | + return false; |
|
2041 | + } |
|
1931 | 2042 | // Creating an index on a non-existent column. |
1932 | - elseif ($mysqli_errno == 1072) |
|
1933 | - return false; |
|
1934 | - elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') |
|
1935 | - return false; |
|
2043 | + elseif ($mysqli_errno == 1072) { |
|
2044 | + return false; |
|
2045 | + } elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') { |
|
2046 | + return false; |
|
2047 | + } |
|
1936 | 2048 | } |
1937 | 2049 | // If a table already exists don't go potty. |
1938 | 2050 | else |
1939 | 2051 | { |
1940 | 2052 | if (in_array(substr(trim($string), 0, 8), array('CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U'))) |
1941 | 2053 | { |
1942 | - if (strpos($db_error_message, 'exist') !== false) |
|
1943 | - return true; |
|
1944 | - } |
|
1945 | - elseif (strpos(trim($string), 'INSERT ') !== false) |
|
2054 | + if (strpos($db_error_message, 'exist') !== false) { |
|
2055 | + return true; |
|
2056 | + } |
|
2057 | + } elseif (strpos(trim($string), 'INSERT ') !== false) |
|
1946 | 2058 | { |
1947 | - if (strpos($db_error_message, 'duplicate') !== false) |
|
1948 | - return true; |
|
2059 | + if (strpos($db_error_message, 'duplicate') !== false) { |
|
2060 | + return true; |
|
2061 | + } |
|
1949 | 2062 | } |
1950 | 2063 | } |
1951 | 2064 | |
1952 | 2065 | // Get the query string so we pass everything. |
1953 | 2066 | $query_string = ''; |
1954 | - foreach ($_GET as $k => $v) |
|
1955 | - $query_string .= ';' . $k . '=' . $v; |
|
1956 | - if (strlen($query_string) != 0) |
|
1957 | - $query_string = '?' . substr($query_string, 1); |
|
2067 | + foreach ($_GET as $k => $v) { |
|
2068 | + $query_string .= ';' . $k . '=' . $v; |
|
2069 | + } |
|
2070 | + if (strlen($query_string) != 0) { |
|
2071 | + $query_string = '?' . substr($query_string, 1); |
|
2072 | + } |
|
1958 | 2073 | |
1959 | 2074 | if ($command_line) |
1960 | 2075 | { |
@@ -2009,16 +2124,18 @@ discard block |
||
2009 | 2124 | { |
2010 | 2125 | $found |= 1; |
2011 | 2126 | // Do some checks on the data if we have it set. |
2012 | - if (isset($change['col_type'])) |
|
2013 | - $found &= $change['col_type'] === $column['type']; |
|
2014 | - if (isset($change['null_allowed'])) |
|
2015 | - $found &= $column['null'] == $change['null_allowed']; |
|
2016 | - if (isset($change['default'])) |
|
2017 | - $found &= $change['default'] === $column['default']; |
|
2127 | + if (isset($change['col_type'])) { |
|
2128 | + $found &= $change['col_type'] === $column['type']; |
|
2129 | + } |
|
2130 | + if (isset($change['null_allowed'])) { |
|
2131 | + $found &= $column['null'] == $change['null_allowed']; |
|
2132 | + } |
|
2133 | + if (isset($change['default'])) { |
|
2134 | + $found &= $change['default'] === $column['default']; |
|
2135 | + } |
|
2018 | 2136 | } |
2019 | 2137 | } |
2020 | - } |
|
2021 | - elseif ($change['type'] === 'index') |
|
2138 | + } elseif ($change['type'] === 'index') |
|
2022 | 2139 | { |
2023 | 2140 | $request = upgrade_query(' |
2024 | 2141 | SHOW INDEX |
@@ -2027,9 +2144,10 @@ discard block |
||
2027 | 2144 | { |
2028 | 2145 | $cur_index = array(); |
2029 | 2146 | |
2030 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2031 | - if ($row['Key_name'] === $change['name']) |
|
2147 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2148 | + if ($row['Key_name'] === $change['name']) |
|
2032 | 2149 | $cur_index[(int) $row['Seq_in_index']] = $row['Column_name']; |
2150 | + } |
|
2033 | 2151 | |
2034 | 2152 | ksort($cur_index, SORT_NUMERIC); |
2035 | 2153 | $found = array_values($cur_index) === $change['target_columns']; |
@@ -2039,14 +2157,17 @@ discard block |
||
2039 | 2157 | } |
2040 | 2158 | |
2041 | 2159 | // If we're trying to add and it's added, we're done. |
2042 | - if ($found && in_array($change['method'], array('add', 'change'))) |
|
2043 | - return true; |
|
2160 | + if ($found && in_array($change['method'], array('add', 'change'))) { |
|
2161 | + return true; |
|
2162 | + } |
|
2044 | 2163 | // Otherwise if we're removing and it wasn't found we're also done. |
2045 | - elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) |
|
2046 | - return true; |
|
2164 | + elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) { |
|
2165 | + return true; |
|
2166 | + } |
|
2047 | 2167 | // Otherwise is it just a test? |
2048 | - elseif ($is_test) |
|
2049 | - return false; |
|
2168 | + elseif ($is_test) { |
|
2169 | + return false; |
|
2170 | + } |
|
2050 | 2171 | |
2051 | 2172 | // Not found it yet? Bummer! How about we see if we're currently doing it? |
2052 | 2173 | $running = false; |
@@ -2057,8 +2178,9 @@ discard block |
||
2057 | 2178 | SHOW FULL PROCESSLIST'); |
2058 | 2179 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2059 | 2180 | { |
2060 | - if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) |
|
2061 | - $found = true; |
|
2181 | + if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) { |
|
2182 | + $found = true; |
|
2183 | + } |
|
2062 | 2184 | } |
2063 | 2185 | |
2064 | 2186 | // Can't find it? Then we need to run it fools! |
@@ -2070,8 +2192,9 @@ discard block |
||
2070 | 2192 | ALTER TABLE ' . $db_prefix . $change['table'] . ' |
2071 | 2193 | ' . $change['text'], true) !== false; |
2072 | 2194 | |
2073 | - if (!$success) |
|
2074 | - return false; |
|
2195 | + if (!$success) { |
|
2196 | + return false; |
|
2197 | + } |
|
2075 | 2198 | |
2076 | 2199 | // Return |
2077 | 2200 | $running = true; |
@@ -2113,8 +2236,9 @@ discard block |
||
2113 | 2236 | 'db_error_skip' => true, |
2114 | 2237 | ) |
2115 | 2238 | ); |
2116 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
2117 | - die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
2239 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
2240 | + die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
2241 | + } |
|
2118 | 2242 | $table_row = $smcFunc['db_fetch_assoc']($request); |
2119 | 2243 | $smcFunc['db_free_result']($request); |
2120 | 2244 | |
@@ -2136,18 +2260,19 @@ discard block |
||
2136 | 2260 | ) |
2137 | 2261 | ); |
2138 | 2262 | // No results? Just forget it all together. |
2139 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
2140 | - unset($table_row['Collation']); |
|
2141 | - else |
|
2142 | - $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
2263 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
2264 | + unset($table_row['Collation']); |
|
2265 | + } else { |
|
2266 | + $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
2267 | + } |
|
2143 | 2268 | $smcFunc['db_free_result']($request); |
2144 | 2269 | } |
2145 | 2270 | |
2146 | 2271 | if ($column_fix) |
2147 | 2272 | { |
2148 | 2273 | // Make sure there are no NULL's left. |
2149 | - if ($null_fix) |
|
2150 | - $smcFunc['db_query']('', ' |
|
2274 | + if ($null_fix) { |
|
2275 | + $smcFunc['db_query']('', ' |
|
2151 | 2276 | UPDATE {db_prefix}' . $change['table'] . ' |
2152 | 2277 | SET ' . $change['column'] . ' = {string:default} |
2153 | 2278 | WHERE ' . $change['column'] . ' IS NULL', |
@@ -2156,6 +2281,7 @@ discard block |
||
2156 | 2281 | 'db_error_skip' => true, |
2157 | 2282 | ) |
2158 | 2283 | ); |
2284 | + } |
|
2159 | 2285 | |
2160 | 2286 | // Do the actual alteration. |
2161 | 2287 | $smcFunc['db_query']('', ' |
@@ -2184,8 +2310,9 @@ discard block |
||
2184 | 2310 | } |
2185 | 2311 | |
2186 | 2312 | // Not a column we need to check on? |
2187 | - if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) |
|
2188 | - return; |
|
2313 | + if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) { |
|
2314 | + return; |
|
2315 | + } |
|
2189 | 2316 | |
2190 | 2317 | // Break it up you (six|seven). |
2191 | 2318 | $temp = explode(' ', str_replace('NOT NULL', 'NOT_NULL', $change['text'])); |
@@ -2204,13 +2331,13 @@ discard block |
||
2204 | 2331 | 'new_name' => $temp[2], |
2205 | 2332 | )); |
2206 | 2333 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
2207 | - if ($smcFunc['db_num_rows'] != 1) |
|
2208 | - return; |
|
2334 | + if ($smcFunc['db_num_rows'] != 1) { |
|
2335 | + return; |
|
2336 | + } |
|
2209 | 2337 | |
2210 | 2338 | list (, $current_type) = $smcFunc['db_fetch_assoc']($request); |
2211 | 2339 | $smcFunc['db_free_result']($request); |
2212 | - } |
|
2213 | - else |
|
2340 | + } else |
|
2214 | 2341 | { |
2215 | 2342 | // Do this the old fashion, sure method way. |
2216 | 2343 | $request = $smcFunc['db_query']('', ' |
@@ -2221,21 +2348,24 @@ discard block |
||
2221 | 2348 | )); |
2222 | 2349 | // Mayday! |
2223 | 2350 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
2224 | - if ($smcFunc['db_num_rows'] == 0) |
|
2225 | - return; |
|
2351 | + if ($smcFunc['db_num_rows'] == 0) { |
|
2352 | + return; |
|
2353 | + } |
|
2226 | 2354 | |
2227 | 2355 | // Oh where, oh where has my little field gone. Oh where can it be... |
2228 | - while ($row = $smcFunc['db_query']($request)) |
|
2229 | - if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
2356 | + while ($row = $smcFunc['db_query']($request)) { |
|
2357 | + if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
2230 | 2358 | { |
2231 | 2359 | $current_type = $row['Type']; |
2360 | + } |
|
2232 | 2361 | break; |
2233 | 2362 | } |
2234 | 2363 | } |
2235 | 2364 | |
2236 | 2365 | // If this doesn't match, the column may of been altered for a reason. |
2237 | - if (trim($current_type) != trim($temp[3])) |
|
2238 | - $temp[3] = $current_type; |
|
2366 | + if (trim($current_type) != trim($temp[3])) { |
|
2367 | + $temp[3] = $current_type; |
|
2368 | + } |
|
2239 | 2369 | |
2240 | 2370 | // Piece this back together. |
2241 | 2371 | $change['text'] = str_replace('NOT_NULL', 'NOT NULL', implode(' ', $temp)); |
@@ -2247,8 +2377,9 @@ discard block |
||
2247 | 2377 | global $start_time, $timeLimitThreshold, $command_line, $custom_warning; |
2248 | 2378 | global $step_progress, $is_debug, $upcontext; |
2249 | 2379 | |
2250 | - if ($_GET['substep'] < $substep) |
|
2251 | - $_GET['substep'] = $substep; |
|
2380 | + if ($_GET['substep'] < $substep) { |
|
2381 | + $_GET['substep'] = $substep; |
|
2382 | + } |
|
2252 | 2383 | |
2253 | 2384 | if ($command_line) |
2254 | 2385 | { |
@@ -2261,29 +2392,33 @@ discard block |
||
2261 | 2392 | } |
2262 | 2393 | |
2263 | 2394 | @set_time_limit(300); |
2264 | - if (function_exists('apache_reset_timeout')) |
|
2265 | - @apache_reset_timeout(); |
|
2395 | + if (function_exists('apache_reset_timeout')) { |
|
2396 | + @apache_reset_timeout(); |
|
2397 | + } |
|
2266 | 2398 | |
2267 | - if (time() - $start_time <= $timeLimitThreshold) |
|
2268 | - return; |
|
2399 | + if (time() - $start_time <= $timeLimitThreshold) { |
|
2400 | + return; |
|
2401 | + } |
|
2269 | 2402 | |
2270 | 2403 | // Do we have some custom step progress stuff? |
2271 | 2404 | if (!empty($step_progress)) |
2272 | 2405 | { |
2273 | 2406 | $upcontext['substep_progress'] = 0; |
2274 | 2407 | $upcontext['substep_progress_name'] = $step_progress['name']; |
2275 | - if ($step_progress['current'] > $step_progress['total']) |
|
2276 | - $upcontext['substep_progress'] = 99.9; |
|
2277 | - else |
|
2278 | - $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
2408 | + if ($step_progress['current'] > $step_progress['total']) { |
|
2409 | + $upcontext['substep_progress'] = 99.9; |
|
2410 | + } else { |
|
2411 | + $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
2412 | + } |
|
2279 | 2413 | |
2280 | 2414 | // Make it nicely rounded. |
2281 | 2415 | $upcontext['substep_progress'] = round($upcontext['substep_progress'], 1); |
2282 | 2416 | } |
2283 | 2417 | |
2284 | 2418 | // If this is XML we just exit right away! |
2285 | - if (isset($_GET['xml'])) |
|
2286 | - return upgradeExit(); |
|
2419 | + if (isset($_GET['xml'])) { |
|
2420 | + return upgradeExit(); |
|
2421 | + } |
|
2287 | 2422 | |
2288 | 2423 | // We're going to pause after this! |
2289 | 2424 | $upcontext['pause'] = true; |
@@ -2291,13 +2426,15 @@ discard block |
||
2291 | 2426 | $upcontext['query_string'] = ''; |
2292 | 2427 | foreach ($_GET as $k => $v) |
2293 | 2428 | { |
2294 | - if ($k != 'data' && $k != 'substep' && $k != 'step') |
|
2295 | - $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
2429 | + if ($k != 'data' && $k != 'substep' && $k != 'step') { |
|
2430 | + $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
2431 | + } |
|
2296 | 2432 | } |
2297 | 2433 | |
2298 | 2434 | // Custom warning? |
2299 | - if (!empty($custom_warning)) |
|
2300 | - $upcontext['custom_warning'] = $custom_warning; |
|
2435 | + if (!empty($custom_warning)) { |
|
2436 | + $upcontext['custom_warning'] = $custom_warning; |
|
2437 | + } |
|
2301 | 2438 | |
2302 | 2439 | upgradeExit(); |
2303 | 2440 | } |
@@ -2312,25 +2449,26 @@ discard block |
||
2312 | 2449 | ob_implicit_flush(true); |
2313 | 2450 | @set_time_limit(600); |
2314 | 2451 | |
2315 | - if (!isset($_SERVER['argv'])) |
|
2316 | - $_SERVER['argv'] = array(); |
|
2452 | + if (!isset($_SERVER['argv'])) { |
|
2453 | + $_SERVER['argv'] = array(); |
|
2454 | + } |
|
2317 | 2455 | $_GET['maint'] = 1; |
2318 | 2456 | |
2319 | 2457 | foreach ($_SERVER['argv'] as $i => $arg) |
2320 | 2458 | { |
2321 | - if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) |
|
2322 | - $_GET['lang'] = $match[1]; |
|
2323 | - elseif (preg_match('~^--path=(.+)$~', $arg) != 0) |
|
2324 | - continue; |
|
2325 | - elseif ($arg == '--no-maintenance') |
|
2326 | - $_GET['maint'] = 0; |
|
2327 | - elseif ($arg == '--debug') |
|
2328 | - $is_debug = true; |
|
2329 | - elseif ($arg == '--backup') |
|
2330 | - $_POST['backup'] = 1; |
|
2331 | - elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) |
|
2332 | - $_GET['conv'] = 1; |
|
2333 | - elseif ($i != 0) |
|
2459 | + if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) { |
|
2460 | + $_GET['lang'] = $match[1]; |
|
2461 | + } elseif (preg_match('~^--path=(.+)$~', $arg) != 0) { |
|
2462 | + continue; |
|
2463 | + } elseif ($arg == '--no-maintenance') { |
|
2464 | + $_GET['maint'] = 0; |
|
2465 | + } elseif ($arg == '--debug') { |
|
2466 | + $is_debug = true; |
|
2467 | + } elseif ($arg == '--backup') { |
|
2468 | + $_POST['backup'] = 1; |
|
2469 | + } elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) { |
|
2470 | + $_GET['conv'] = 1; |
|
2471 | + } elseif ($i != 0) |
|
2334 | 2472 | { |
2335 | 2473 | echo 'SMF Command-line Upgrader |
2336 | 2474 | Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]... |
@@ -2344,10 +2482,12 @@ discard block |
||
2344 | 2482 | } |
2345 | 2483 | } |
2346 | 2484 | |
2347 | - if (!php_version_check()) |
|
2348 | - print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
2349 | - if (!db_version_check()) |
|
2350 | - print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
2485 | + if (!php_version_check()) { |
|
2486 | + print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
2487 | + } |
|
2488 | + if (!db_version_check()) { |
|
2489 | + print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
2490 | + } |
|
2351 | 2491 | |
2352 | 2492 | // Do some checks to make sure they have proper privileges |
2353 | 2493 | db_extend('packages'); |
@@ -2362,39 +2502,45 @@ discard block |
||
2362 | 2502 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
2363 | 2503 | |
2364 | 2504 | // Sorry... we need CREATE, ALTER and DROP |
2365 | - if (!$create || !$alter || !$drop) |
|
2366 | - 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); |
|
2505 | + if (!$create || !$alter || !$drop) { |
|
2506 | + 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); |
|
2507 | + } |
|
2367 | 2508 | |
2368 | 2509 | $check = @file_exists($modSettings['theme_dir'] . '/index.template.php') |
2369 | 2510 | && @file_exists($sourcedir . '/QueryString.php') |
2370 | 2511 | && @file_exists($sourcedir . '/ManageBoards.php'); |
2371 | - if (!$check && !isset($modSettings['smfVersion'])) |
|
2372 | - print_error('Error: Some files are missing or out-of-date.', true); |
|
2512 | + if (!$check && !isset($modSettings['smfVersion'])) { |
|
2513 | + print_error('Error: Some files are missing or out-of-date.', true); |
|
2514 | + } |
|
2373 | 2515 | |
2374 | 2516 | // Do a quick version spot check. |
2375 | 2517 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
2376 | 2518 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
2377 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
2378 | - print_error('Error: Some files have not yet been updated properly.'); |
|
2519 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
2520 | + print_error('Error: Some files have not yet been updated properly.'); |
|
2521 | + } |
|
2379 | 2522 | |
2380 | 2523 | // Make sure Settings.php is writable. |
2381 | 2524 | quickFileWritable($boarddir . '/Settings.php'); |
2382 | - if (!is_writable($boarddir . '/Settings.php')) |
|
2383 | - print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
2525 | + if (!is_writable($boarddir . '/Settings.php')) { |
|
2526 | + print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
2527 | + } |
|
2384 | 2528 | |
2385 | 2529 | // Make sure Settings_bak.php is writable. |
2386 | 2530 | quickFileWritable($boarddir . '/Settings_bak.php'); |
2387 | - if (!is_writable($boarddir . '/Settings_bak.php')) |
|
2388 | - print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
2531 | + if (!is_writable($boarddir . '/Settings_bak.php')) { |
|
2532 | + print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
2533 | + } |
|
2389 | 2534 | |
2390 | 2535 | // Make sure db_last_error.php is writable. |
2391 | 2536 | quickFileWritable($boarddir . '/db_last_error.php'); |
2392 | - if (!is_writable($boarddir . '/db_last_error.php')) |
|
2393 | - print_error('Error: Unable to obtain write access to "db_last_error.php".'); |
|
2537 | + if (!is_writable($boarddir . '/db_last_error.php')) { |
|
2538 | + print_error('Error: Unable to obtain write access to "db_last_error.php".'); |
|
2539 | + } |
|
2394 | 2540 | |
2395 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
2396 | - print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
2397 | - elseif (isset($modSettings['agreement'])) |
|
2541 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
2542 | + print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
2543 | + } elseif (isset($modSettings['agreement'])) |
|
2398 | 2544 | { |
2399 | 2545 | $fp = fopen($boarddir . '/agreement.txt', 'w'); |
2400 | 2546 | fwrite($fp, $modSettings['agreement']); |
@@ -2404,31 +2550,36 @@ discard block |
||
2404 | 2550 | // Make sure Themes is writable. |
2405 | 2551 | quickFileWritable($modSettings['theme_dir']); |
2406 | 2552 | |
2407 | - if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) |
|
2408 | - print_error('Error: Unable to obtain write access to "Themes".'); |
|
2553 | + if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) { |
|
2554 | + print_error('Error: Unable to obtain write access to "Themes".'); |
|
2555 | + } |
|
2409 | 2556 | |
2410 | 2557 | // Make sure cache directory exists and is writable! |
2411 | 2558 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
2412 | - if (!file_exists($cachedir_temp)) |
|
2413 | - @mkdir($cachedir_temp); |
|
2559 | + if (!file_exists($cachedir_temp)) { |
|
2560 | + @mkdir($cachedir_temp); |
|
2561 | + } |
|
2414 | 2562 | |
2415 | 2563 | // Make sure the cache temp dir is writable. |
2416 | 2564 | quickFileWritable($cachedir_temp); |
2417 | 2565 | |
2418 | - if (!is_writable($cachedir_temp)) |
|
2419 | - print_error('Error: Unable to obtain write access to "cache".', true); |
|
2566 | + if (!is_writable($cachedir_temp)) { |
|
2567 | + print_error('Error: Unable to obtain write access to "cache".', true); |
|
2568 | + } |
|
2420 | 2569 | |
2421 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
2422 | - print_error('Error: Unable to find language files!', true); |
|
2423 | - else |
|
2570 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
2571 | + print_error('Error: Unable to find language files!', true); |
|
2572 | + } else |
|
2424 | 2573 | { |
2425 | 2574 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
2426 | 2575 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
2427 | 2576 | |
2428 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
2429 | - print_error('Error: Language files out of date.', true); |
|
2430 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
2431 | - print_error('Error: Install language is missing for selected language.', true); |
|
2577 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
2578 | + print_error('Error: Language files out of date.', true); |
|
2579 | + } |
|
2580 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
2581 | + print_error('Error: Install language is missing for selected language.', true); |
|
2582 | + } |
|
2432 | 2583 | |
2433 | 2584 | // Otherwise include it! |
2434 | 2585 | require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
@@ -2447,8 +2598,9 @@ discard block |
||
2447 | 2598 | global $upcontext, $db_character_set, $sourcedir, $smcFunc, $modSettings, $language, $db_prefix, $db_type, $command_line, $support_js; |
2448 | 2599 | |
2449 | 2600 | // Done it already? |
2450 | - if (!empty($_POST['utf8_done'])) |
|
2451 | - return true; |
|
2601 | + if (!empty($_POST['utf8_done'])) { |
|
2602 | + return true; |
|
2603 | + } |
|
2452 | 2604 | |
2453 | 2605 | // First make sure they aren't already on UTF-8 before we go anywhere... |
2454 | 2606 | if ($db_type == 'postgresql' || ($db_character_set === 'utf8' && !empty($modSettings['global_character_set']) && $modSettings['global_character_set'] === 'UTF-8')) |
@@ -2461,8 +2613,7 @@ discard block |
||
2461 | 2613 | ); |
2462 | 2614 | |
2463 | 2615 | return true; |
2464 | - } |
|
2465 | - else |
|
2616 | + } else |
|
2466 | 2617 | { |
2467 | 2618 | $upcontext['page_title'] = 'Converting to UTF8'; |
2468 | 2619 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'convert_xml' : 'convert_utf8'; |
@@ -2506,8 +2657,9 @@ discard block |
||
2506 | 2657 | ) |
2507 | 2658 | ); |
2508 | 2659 | $db_charsets = array(); |
2509 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2510 | - $db_charsets[] = $row['Charset']; |
|
2660 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2661 | + $db_charsets[] = $row['Charset']; |
|
2662 | + } |
|
2511 | 2663 | |
2512 | 2664 | $smcFunc['db_free_result']($request); |
2513 | 2665 | |
@@ -2543,13 +2695,15 @@ discard block |
||
2543 | 2695 | // If there's a fulltext index, we need to drop it first... |
2544 | 2696 | if ($request !== false || $smcFunc['db_num_rows']($request) != 0) |
2545 | 2697 | { |
2546 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2547 | - if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
2698 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2699 | + if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
2548 | 2700 | $upcontext['fulltext_index'][] = $row['Key_name']; |
2701 | + } |
|
2549 | 2702 | $smcFunc['db_free_result']($request); |
2550 | 2703 | |
2551 | - if (isset($upcontext['fulltext_index'])) |
|
2552 | - $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
2704 | + if (isset($upcontext['fulltext_index'])) { |
|
2705 | + $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
2706 | + } |
|
2553 | 2707 | } |
2554 | 2708 | |
2555 | 2709 | // Drop it and make a note... |
@@ -2739,8 +2893,9 @@ discard block |
||
2739 | 2893 | $replace = '%field%'; |
2740 | 2894 | |
2741 | 2895 | // Build a huge REPLACE statement... |
2742 | - foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) |
|
2743 | - $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
2896 | + foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) { |
|
2897 | + $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
2898 | + } |
|
2744 | 2899 | } |
2745 | 2900 | |
2746 | 2901 | // Get a list of table names ahead of time... This makes it easier to set our substep and such |
@@ -2750,9 +2905,10 @@ discard block |
||
2750 | 2905 | $upcontext['table_count'] = count($queryTables); |
2751 | 2906 | |
2752 | 2907 | // What ones have we already done? |
2753 | - foreach ($queryTables as $id => $table) |
|
2754 | - if ($id < $_GET['substep']) |
|
2908 | + foreach ($queryTables as $id => $table) { |
|
2909 | + if ($id < $_GET['substep']) |
|
2755 | 2910 | $upcontext['previous_tables'][] = $table; |
2911 | + } |
|
2756 | 2912 | |
2757 | 2913 | $upcontext['cur_table_num'] = $_GET['substep']; |
2758 | 2914 | $upcontext['cur_table_name'] = str_replace($db_prefix, '', $queryTables[$_GET['substep']]); |
@@ -2789,8 +2945,9 @@ discard block |
||
2789 | 2945 | nextSubstep($substep); |
2790 | 2946 | |
2791 | 2947 | // Just to make sure it doesn't time out. |
2792 | - if (function_exists('apache_reset_timeout')) |
|
2793 | - @apache_reset_timeout(); |
|
2948 | + if (function_exists('apache_reset_timeout')) { |
|
2949 | + @apache_reset_timeout(); |
|
2950 | + } |
|
2794 | 2951 | |
2795 | 2952 | $table_charsets = array(); |
2796 | 2953 | |
@@ -2813,8 +2970,9 @@ discard block |
||
2813 | 2970 | |
2814 | 2971 | // Build structure of columns to operate on organized by charset; only operate on columns not yet utf8 |
2815 | 2972 | if ($charset != 'utf8') { |
2816 | - if (!isset($table_charsets[$charset])) |
|
2817 | - $table_charsets[$charset] = array(); |
|
2973 | + if (!isset($table_charsets[$charset])) { |
|
2974 | + $table_charsets[$charset] = array(); |
|
2975 | + } |
|
2818 | 2976 | |
2819 | 2977 | $table_charsets[$charset][] = $column_info; |
2820 | 2978 | } |
@@ -2855,10 +3013,11 @@ discard block |
||
2855 | 3013 | if (isset($translation_tables[$upcontext['charset_detected']])) |
2856 | 3014 | { |
2857 | 3015 | $update = ''; |
2858 | - foreach ($table_charsets as $charset => $columns) |
|
2859 | - foreach ($columns as $column) |
|
3016 | + foreach ($table_charsets as $charset => $columns) { |
|
3017 | + foreach ($columns as $column) |
|
2860 | 3018 | $update .= ' |
2861 | 3019 | ' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ','; |
3020 | + } |
|
2862 | 3021 | |
2863 | 3022 | $smcFunc['db_query']('', ' |
2864 | 3023 | UPDATE {raw:table_name} |
@@ -2883,8 +3042,9 @@ discard block |
||
2883 | 3042 | // Now do the actual conversion (if still needed). |
2884 | 3043 | if ($charsets[$upcontext['charset_detected']] !== 'utf8') |
2885 | 3044 | { |
2886 | - if ($command_line) |
|
2887 | - echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
3045 | + if ($command_line) { |
|
3046 | + echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
3047 | + } |
|
2888 | 3048 | |
2889 | 3049 | $smcFunc['db_query']('', ' |
2890 | 3050 | ALTER TABLE {raw:table_name} |
@@ -2894,12 +3054,14 @@ discard block |
||
2894 | 3054 | ) |
2895 | 3055 | ); |
2896 | 3056 | |
2897 | - if ($command_line) |
|
2898 | - echo " done.\n"; |
|
3057 | + if ($command_line) { |
|
3058 | + echo " done.\n"; |
|
3059 | + } |
|
2899 | 3060 | } |
2900 | 3061 | // If this is XML to keep it nice for the user do one table at a time anyway! |
2901 | - if (isset($_GET['xml']) && $upcontext['cur_table_num'] < $upcontext['table_count']) |
|
2902 | - return upgradeExit(); |
|
3062 | + if (isset($_GET['xml']) && $upcontext['cur_table_num'] < $upcontext['table_count']) { |
|
3063 | + return upgradeExit(); |
|
3064 | + } |
|
2903 | 3065 | } |
2904 | 3066 | |
2905 | 3067 | $prev_charset = empty($translation_tables[$upcontext['charset_detected']]) ? $charsets[$upcontext['charset_detected']] : $translation_tables[$upcontext['charset_detected']]; |
@@ -2928,8 +3090,8 @@ discard block |
||
2928 | 3090 | ); |
2929 | 3091 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2930 | 3092 | { |
2931 | - 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) |
|
2932 | - $smcFunc['db_query']('', ' |
|
3093 | + 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) { |
|
3094 | + $smcFunc['db_query']('', ' |
|
2933 | 3095 | UPDATE {db_prefix}log_actions |
2934 | 3096 | SET extra = {string:extra} |
2935 | 3097 | WHERE id_action = {int:current_action}', |
@@ -2938,6 +3100,7 @@ discard block |
||
2938 | 3100 | 'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4], |
2939 | 3101 | ) |
2940 | 3102 | ); |
3103 | + } |
|
2941 | 3104 | } |
2942 | 3105 | $smcFunc['db_free_result']($request); |
2943 | 3106 | |
@@ -2959,15 +3122,17 @@ discard block |
||
2959 | 3122 | // First thing's first - did we already do this? |
2960 | 3123 | if (!empty($modSettings['json_done'])) |
2961 | 3124 | { |
2962 | - if ($command_line) |
|
2963 | - return DeleteUpgrade(); |
|
2964 | - else |
|
2965 | - return true; |
|
3125 | + if ($command_line) { |
|
3126 | + return DeleteUpgrade(); |
|
3127 | + } else { |
|
3128 | + return true; |
|
3129 | + } |
|
2966 | 3130 | } |
2967 | 3131 | |
2968 | 3132 | // Done it already - js wise? |
2969 | - if (!empty($_POST['json_done'])) |
|
2970 | - return true; |
|
3133 | + if (!empty($_POST['json_done'])) { |
|
3134 | + return true; |
|
3135 | + } |
|
2971 | 3136 | |
2972 | 3137 | // List of tables affected by this function |
2973 | 3138 | // name => array('key', col1[,col2|true[,col3]]) |
@@ -2999,12 +3164,14 @@ discard block |
||
2999 | 3164 | $upcontext['cur_table_name'] = isset($keys[$_GET['substep']]) ? $keys[$_GET['substep']] : $keys[0]; |
3000 | 3165 | $upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100); |
3001 | 3166 | |
3002 | - foreach ($keys as $id => $table) |
|
3003 | - if ($id < $_GET['substep']) |
|
3167 | + foreach ($keys as $id => $table) { |
|
3168 | + if ($id < $_GET['substep']) |
|
3004 | 3169 | $upcontext['previous_tables'][] = $table; |
3170 | + } |
|
3005 | 3171 | |
3006 | - if ($command_line) |
|
3007 | - echo 'Converting data from serialize() to json_encode().'; |
|
3172 | + if ($command_line) { |
|
3173 | + echo 'Converting data from serialize() to json_encode().'; |
|
3174 | + } |
|
3008 | 3175 | |
3009 | 3176 | if (!$support_js || isset($_GET['xml'])) |
3010 | 3177 | { |
@@ -3044,8 +3211,9 @@ discard block |
||
3044 | 3211 | |
3045 | 3212 | // Loop through and fix these... |
3046 | 3213 | $new_settings = array(); |
3047 | - if ($command_line) |
|
3048 | - echo "\n" . 'Fixing some settings...'; |
|
3214 | + if ($command_line) { |
|
3215 | + echo "\n" . 'Fixing some settings...'; |
|
3216 | + } |
|
3049 | 3217 | |
3050 | 3218 | foreach ($serialized_settings as $var) |
3051 | 3219 | { |
@@ -3053,22 +3221,24 @@ discard block |
||
3053 | 3221 | { |
3054 | 3222 | // Attempt to unserialize the setting |
3055 | 3223 | $temp = @safe_unserialize($modSettings[$var]); |
3056 | - if (!$temp && $command_line) |
|
3057 | - echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
3058 | - elseif ($temp !== false) |
|
3059 | - $new_settings[$var] = json_encode($temp); |
|
3224 | + if (!$temp && $command_line) { |
|
3225 | + echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
3226 | + } elseif ($temp !== false) { |
|
3227 | + $new_settings[$var] = json_encode($temp); |
|
3228 | + } |
|
3060 | 3229 | } |
3061 | 3230 | } |
3062 | 3231 | |
3063 | 3232 | // Update everything at once |
3064 | - if (!function_exists('cache_put_data')) |
|
3065 | - require_once($sourcedir . '/Load.php'); |
|
3233 | + if (!function_exists('cache_put_data')) { |
|
3234 | + require_once($sourcedir . '/Load.php'); |
|
3235 | + } |
|
3066 | 3236 | updateSettings($new_settings, true); |
3067 | 3237 | |
3068 | - if ($command_line) |
|
3069 | - echo ' done.'; |
|
3070 | - } |
|
3071 | - elseif ($table == 'themes') |
|
3238 | + if ($command_line) { |
|
3239 | + echo ' done.'; |
|
3240 | + } |
|
3241 | + } elseif ($table == 'themes') |
|
3072 | 3242 | { |
3073 | 3243 | // Finally, fix the admin prefs. Unfortunately this is stored per theme, but hopefully they only have one theme installed at this point... |
3074 | 3244 | $query = $smcFunc['db_query']('', ' |
@@ -3087,10 +3257,11 @@ discard block |
||
3087 | 3257 | |
3088 | 3258 | if ($command_line) |
3089 | 3259 | { |
3090 | - if ($temp === false) |
|
3091 | - echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
3092 | - else |
|
3093 | - echo "\n" . 'Fixing admin preferences...'; |
|
3260 | + if ($temp === false) { |
|
3261 | + echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
3262 | + } else { |
|
3263 | + echo "\n" . 'Fixing admin preferences...'; |
|
3264 | + } |
|
3094 | 3265 | } |
3095 | 3266 | |
3096 | 3267 | if ($temp !== false) |
@@ -3112,15 +3283,15 @@ discard block |
||
3112 | 3283 | ) |
3113 | 3284 | ); |
3114 | 3285 | |
3115 | - if ($command_line) |
|
3116 | - echo ' done.'; |
|
3286 | + if ($command_line) { |
|
3287 | + echo ' done.'; |
|
3288 | + } |
|
3117 | 3289 | } |
3118 | 3290 | } |
3119 | 3291 | |
3120 | 3292 | $smcFunc['db_free_result']($query); |
3121 | 3293 | } |
3122 | - } |
|
3123 | - else |
|
3294 | + } else |
|
3124 | 3295 | { |
3125 | 3296 | // First item is always the key... |
3126 | 3297 | $key = $info[0]; |
@@ -3131,8 +3302,7 @@ discard block |
||
3131 | 3302 | { |
3132 | 3303 | $col_select = $info[1]; |
3133 | 3304 | $where = ' WHERE ' . $info[1] . ' != {empty}'; |
3134 | - } |
|
3135 | - else |
|
3305 | + } else |
|
3136 | 3306 | { |
3137 | 3307 | $col_select = implode(', ', $info); |
3138 | 3308 | } |
@@ -3165,8 +3335,7 @@ discard block |
||
3165 | 3335 | if ($temp === false && $command_line) |
3166 | 3336 | { |
3167 | 3337 | echo "\nFailed to unserialize " . $row[$col] . "... Skipping\n"; |
3168 | - } |
|
3169 | - else |
|
3338 | + } else |
|
3170 | 3339 | { |
3171 | 3340 | $row[$col] = json_encode($temp); |
3172 | 3341 | |
@@ -3191,16 +3360,18 @@ discard block |
||
3191 | 3360 | } |
3192 | 3361 | } |
3193 | 3362 | |
3194 | - if ($command_line) |
|
3195 | - echo ' done.'; |
|
3363 | + if ($command_line) { |
|
3364 | + echo ' done.'; |
|
3365 | + } |
|
3196 | 3366 | |
3197 | 3367 | // Free up some memory... |
3198 | 3368 | $smcFunc['db_free_result']($query); |
3199 | 3369 | } |
3200 | 3370 | } |
3201 | 3371 | // If this is XML to keep it nice for the user do one table at a time anyway! |
3202 | - if (isset($_GET['xml'])) |
|
3203 | - return upgradeExit(); |
|
3372 | + if (isset($_GET['xml'])) { |
|
3373 | + return upgradeExit(); |
|
3374 | + } |
|
3204 | 3375 | } |
3205 | 3376 | |
3206 | 3377 | if ($command_line) |
@@ -3215,8 +3386,9 @@ discard block |
||
3215 | 3386 | |
3216 | 3387 | $_GET['substep'] = 0; |
3217 | 3388 | // Make sure we move on! |
3218 | - if ($command_line) |
|
3219 | - return DeleteUpgrade(); |
|
3389 | + if ($command_line) { |
|
3390 | + return DeleteUpgrade(); |
|
3391 | + } |
|
3220 | 3392 | |
3221 | 3393 | return true; |
3222 | 3394 | } |
@@ -3236,14 +3408,16 @@ discard block |
||
3236 | 3408 | global $upcontext, $txt, $settings; |
3237 | 3409 | |
3238 | 3410 | // Don't call me twice! |
3239 | - if (!empty($upcontext['chmod_called'])) |
|
3240 | - return; |
|
3411 | + if (!empty($upcontext['chmod_called'])) { |
|
3412 | + return; |
|
3413 | + } |
|
3241 | 3414 | |
3242 | 3415 | $upcontext['chmod_called'] = true; |
3243 | 3416 | |
3244 | 3417 | // Nothing? |
3245 | - if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) |
|
3246 | - return; |
|
3418 | + if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) { |
|
3419 | + return; |
|
3420 | + } |
|
3247 | 3421 | |
3248 | 3422 | // Was it a problem with Windows? |
3249 | 3423 | if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess') |
@@ -3275,11 +3449,12 @@ discard block |
||
3275 | 3449 | content.write(\'<div class="windowbg description">\n\t\t\t<h4>The following files needs to be made writable to continue:</h4>\n\t\t\t\'); |
3276 | 3450 | content.write(\'<p>', implode('<br>\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');'; |
3277 | 3451 | |
3278 | - if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') |
|
3279 | - echo ' |
|
3452 | + if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') { |
|
3453 | + echo ' |
|
3280 | 3454 | content.write(\'<hr>\n\t\t\t\'); |
3281 | 3455 | content.write(\'<p>If you have a shell account, the convenient below command can automatically correct permissions on these files</p>\n\t\t\t\'); |
3282 | 3456 | content.write(\'<tt># chmod a+w ', implode(' ', $upcontext['chmod']['files']), '</tt>\n\t\t\t\');'; |
3457 | + } |
|
3283 | 3458 | |
3284 | 3459 | echo ' |
3285 | 3460 | content.write(\'<a href="javascript:self.close();">close</a>\n\t\t</div>\n\t</body>\n</html>\'); |
@@ -3287,17 +3462,19 @@ discard block |
||
3287 | 3462 | } |
3288 | 3463 | </script>'; |
3289 | 3464 | |
3290 | - if (!empty($upcontext['chmod']['ftp_error'])) |
|
3291 | - echo ' |
|
3465 | + if (!empty($upcontext['chmod']['ftp_error'])) { |
|
3466 | + echo ' |
|
3292 | 3467 | <div class="error_message red"> |
3293 | 3468 | The following error was encountered when trying to connect:<br><br> |
3294 | 3469 | <code>', $upcontext['chmod']['ftp_error'], '</code> |
3295 | 3470 | </div> |
3296 | 3471 | <br>'; |
3472 | + } |
|
3297 | 3473 | |
3298 | - if (empty($upcontext['chmod_in_form'])) |
|
3299 | - echo ' |
|
3474 | + if (empty($upcontext['chmod_in_form'])) { |
|
3475 | + echo ' |
|
3300 | 3476 | <form action="', $upcontext['form_url'], '" method="post">'; |
3477 | + } |
|
3301 | 3478 | |
3302 | 3479 | echo ' |
3303 | 3480 | <table width="520" border="0" align="center" style="margin-bottom: 1ex;"> |
@@ -3332,10 +3509,11 @@ discard block |
||
3332 | 3509 | <div class="righttext" style="margin: 1ex;"><input type="submit" value="', $txt['ftp_connect'], '" class="button"></div> |
3333 | 3510 | </div>'; |
3334 | 3511 | |
3335 | - if (empty($upcontext['chmod_in_form'])) |
|
3336 | - echo ' |
|
3512 | + if (empty($upcontext['chmod_in_form'])) { |
|
3513 | + echo ' |
|
3337 | 3514 | </form>'; |
3338 | -} |
|
3515 | + } |
|
3516 | + } |
|
3339 | 3517 | |
3340 | 3518 | function template_upgrade_above() |
3341 | 3519 | { |
@@ -3395,9 +3573,10 @@ discard block |
||
3395 | 3573 | <h2>', $txt['upgrade_progress'], '</h2> |
3396 | 3574 | <ul>'; |
3397 | 3575 | |
3398 | - foreach ($upcontext['steps'] as $num => $step) |
|
3399 | - echo ' |
|
3576 | + foreach ($upcontext['steps'] as $num => $step) { |
|
3577 | + echo ' |
|
3400 | 3578 | <li class="', $num < $upcontext['current_step'] ? 'stepdone' : ($num == $upcontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
3579 | + } |
|
3401 | 3580 | |
3402 | 3581 | echo ' |
3403 | 3582 | </ul> |
@@ -3410,8 +3589,8 @@ discard block |
||
3410 | 3589 | </div> |
3411 | 3590 | </div>'; |
3412 | 3591 | |
3413 | - if (isset($upcontext['step_progress'])) |
|
3414 | - echo ' |
|
3592 | + if (isset($upcontext['step_progress'])) { |
|
3593 | + echo ' |
|
3415 | 3594 | <br> |
3416 | 3595 | <br> |
3417 | 3596 | <div id="progress_bar_step"> |
@@ -3420,6 +3599,7 @@ discard block |
||
3420 | 3599 | <span>', $txt['upgrade_step_progress'], '</span> |
3421 | 3600 | </div> |
3422 | 3601 | </div>'; |
3602 | + } |
|
3423 | 3603 | |
3424 | 3604 | echo ' |
3425 | 3605 | <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> |
@@ -3450,32 +3630,36 @@ discard block |
||
3450 | 3630 | { |
3451 | 3631 | global $upcontext, $txt; |
3452 | 3632 | |
3453 | - if (!empty($upcontext['pause'])) |
|
3454 | - echo ' |
|
3633 | + if (!empty($upcontext['pause'])) { |
|
3634 | + echo ' |
|
3455 | 3635 | <em>', $txt['upgrade_incomplete'], '.</em><br> |
3456 | 3636 | |
3457 | 3637 | <h2 style="margin-top: 2ex;">', $txt['upgrade_not_quite_done'], '</h2> |
3458 | 3638 | <h3> |
3459 | 3639 | ', $txt['upgrade_paused_overload'], ' |
3460 | 3640 | </h3>'; |
3641 | + } |
|
3461 | 3642 | |
3462 | - if (!empty($upcontext['custom_warning'])) |
|
3463 | - echo ' |
|
3643 | + if (!empty($upcontext['custom_warning'])) { |
|
3644 | + echo ' |
|
3464 | 3645 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
3465 | 3646 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
3466 | 3647 | <strong style="text-decoration: underline;">', $txt['upgrade_note'], '</strong><br> |
3467 | 3648 | <div style="padding-left: 6ex;">', $upcontext['custom_warning'], '</div> |
3468 | 3649 | </div>'; |
3650 | + } |
|
3469 | 3651 | |
3470 | 3652 | echo ' |
3471 | 3653 | <div class="righttext" style="margin: 1ex;">'; |
3472 | 3654 | |
3473 | - if (!empty($upcontext['continue'])) |
|
3474 | - echo ' |
|
3655 | + if (!empty($upcontext['continue'])) { |
|
3656 | + echo ' |
|
3475 | 3657 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled' : '', ' class="button">'; |
3476 | - if (!empty($upcontext['skip'])) |
|
3477 | - echo ' |
|
3658 | + } |
|
3659 | + if (!empty($upcontext['skip'])) { |
|
3660 | + echo ' |
|
3478 | 3661 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button">'; |
3662 | + } |
|
3479 | 3663 | |
3480 | 3664 | echo ' |
3481 | 3665 | </div> |
@@ -3525,11 +3709,12 @@ discard block |
||
3525 | 3709 | echo '<', '?xml version="1.0" encoding="UTF-8"?', '> |
3526 | 3710 | <smf>'; |
3527 | 3711 | |
3528 | - if (!empty($upcontext['get_data'])) |
|
3529 | - foreach ($upcontext['get_data'] as $k => $v) |
|
3712 | + if (!empty($upcontext['get_data'])) { |
|
3713 | + foreach ($upcontext['get_data'] as $k => $v) |
|
3530 | 3714 | echo ' |
3531 | 3715 | <get key="', $k, '">', $v, '</get>'; |
3532 | -} |
|
3716 | + } |
|
3717 | + } |
|
3533 | 3718 | |
3534 | 3719 | function template_xml_below() |
3535 | 3720 | { |
@@ -3570,8 +3755,8 @@ discard block |
||
3570 | 3755 | template_chmod(); |
3571 | 3756 | |
3572 | 3757 | // For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade! |
3573 | - if ($upcontext['is_large_forum']) |
|
3574 | - echo ' |
|
3758 | + if ($upcontext['is_large_forum']) { |
|
3759 | + echo ' |
|
3575 | 3760 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
3576 | 3761 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
3577 | 3762 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -3579,10 +3764,11 @@ discard block |
||
3579 | 3764 | ', $txt['upgrade_warning_lots_data'], ' |
3580 | 3765 | </div> |
3581 | 3766 | </div>'; |
3767 | + } |
|
3582 | 3768 | |
3583 | 3769 | // A warning message? |
3584 | - if (!empty($upcontext['warning'])) |
|
3585 | - echo ' |
|
3770 | + if (!empty($upcontext['warning'])) { |
|
3771 | + echo ' |
|
3586 | 3772 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
3587 | 3773 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
3588 | 3774 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -3590,6 +3776,7 @@ discard block |
||
3590 | 3776 | ', $upcontext['warning'], ' |
3591 | 3777 | </div> |
3592 | 3778 | </div>'; |
3779 | + } |
|
3593 | 3780 | |
3594 | 3781 | // Paths are incorrect? |
3595 | 3782 | echo ' |
@@ -3605,20 +3792,22 @@ discard block |
||
3605 | 3792 | if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600)) |
3606 | 3793 | { |
3607 | 3794 | $ago = time() - $upcontext['started']; |
3608 | - if ($ago < 60) |
|
3609 | - $ago = $ago . ' seconds'; |
|
3610 | - elseif ($ago < 3600) |
|
3611 | - $ago = (int) ($ago / 60) . ' minutes'; |
|
3612 | - else |
|
3613 | - $ago = (int) ($ago / 3600) . ' hours'; |
|
3795 | + if ($ago < 60) { |
|
3796 | + $ago = $ago . ' seconds'; |
|
3797 | + } elseif ($ago < 3600) { |
|
3798 | + $ago = (int) ($ago / 60) . ' minutes'; |
|
3799 | + } else { |
|
3800 | + $ago = (int) ($ago / 3600) . ' hours'; |
|
3801 | + } |
|
3614 | 3802 | |
3615 | 3803 | $active = time() - $upcontext['updated']; |
3616 | - if ($active < 60) |
|
3617 | - $updated = $active . ' seconds'; |
|
3618 | - elseif ($active < 3600) |
|
3619 | - $updated = (int) ($active / 60) . ' minutes'; |
|
3620 | - else |
|
3621 | - $updated = (int) ($active / 3600) . ' hours'; |
|
3804 | + if ($active < 60) { |
|
3805 | + $updated = $active . ' seconds'; |
|
3806 | + } elseif ($active < 3600) { |
|
3807 | + $updated = (int) ($active / 60) . ' minutes'; |
|
3808 | + } else { |
|
3809 | + $updated = (int) ($active / 3600) . ' hours'; |
|
3810 | + } |
|
3622 | 3811 | |
3623 | 3812 | echo ' |
3624 | 3813 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
@@ -3627,16 +3816,18 @@ discard block |
||
3627 | 3816 | <div style="padding-left: 6ex;"> |
3628 | 3817 | "', $upcontext['user']['name'], '" has been running the upgrade script for the last ', $ago, ' - and was last active ', $updated, ' ago.'; |
3629 | 3818 | |
3630 | - if ($active < 600) |
|
3631 | - echo ' |
|
3819 | + if ($active < 600) { |
|
3820 | + echo ' |
|
3632 | 3821 | We recommend that you do not run this script unless you are sure that ', $upcontext['user']['name'], ' has completed their upgrade.'; |
3822 | + } |
|
3633 | 3823 | |
3634 | - if ($active > $upcontext['inactive_timeout']) |
|
3635 | - echo ' |
|
3824 | + if ($active > $upcontext['inactive_timeout']) { |
|
3825 | + echo ' |
|
3636 | 3826 | <br><br>You can choose to either run the upgrade again from the beginning - or alternatively continue from the last step reached during the last upgrade.'; |
3637 | - else |
|
3638 | - echo ' |
|
3827 | + } else { |
|
3828 | + echo ' |
|
3639 | 3829 | <br><br>This upgrade script cannot be run until ', $upcontext['user']['name'], ' has been inactive for at least ', ($upcontext['inactive_timeout'] > 120 ? round($upcontext['inactive_timeout'] / 60, 1) . ' minutes!' : $upcontext['inactive_timeout'] . ' seconds!'); |
3830 | + } |
|
3640 | 3831 | |
3641 | 3832 | echo ' |
3642 | 3833 | </div> |
@@ -3652,9 +3843,10 @@ discard block |
||
3652 | 3843 | <td> |
3653 | 3844 | <input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '"', $disable_security ? ' disabled' : '', '>'; |
3654 | 3845 | |
3655 | - if (!empty($upcontext['username_incorrect'])) |
|
3656 | - echo ' |
|
3846 | + if (!empty($upcontext['username_incorrect'])) { |
|
3847 | + echo ' |
|
3657 | 3848 | <div class="smalltext" style="color: red;">Username Incorrect</div>'; |
3849 | + } |
|
3658 | 3850 | |
3659 | 3851 | echo ' |
3660 | 3852 | </td> |
@@ -3665,9 +3857,10 @@ discard block |
||
3665 | 3857 | <input type="password" name="passwrd" value=""', $disable_security ? ' disabled' : '', '> |
3666 | 3858 | <input type="hidden" name="hash_passwrd" value="">'; |
3667 | 3859 | |
3668 | - if (!empty($upcontext['password_failed'])) |
|
3669 | - echo ' |
|
3860 | + if (!empty($upcontext['password_failed'])) { |
|
3861 | + echo ' |
|
3670 | 3862 | <div class="smalltext" style="color: red;">Password Incorrect</div>'; |
3863 | + } |
|
3671 | 3864 | |
3672 | 3865 | echo ' |
3673 | 3866 | </td> |
@@ -3738,8 +3931,8 @@ discard block |
||
3738 | 3931 | <form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">'; |
3739 | 3932 | |
3740 | 3933 | // Warning message? |
3741 | - if (!empty($upcontext['upgrade_options_warning'])) |
|
3742 | - echo ' |
|
3934 | + if (!empty($upcontext['upgrade_options_warning'])) { |
|
3935 | + echo ' |
|
3743 | 3936 | <div style="margin: 1ex; padding: 1ex; border: 1px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
3744 | 3937 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
3745 | 3938 | <strong style="text-decoration: underline;">Warning!</strong><br> |
@@ -3747,6 +3940,7 @@ discard block |
||
3747 | 3940 | ', $upcontext['upgrade_options_warning'], ' |
3748 | 3941 | </div> |
3749 | 3942 | </div>'; |
3943 | + } |
|
3750 | 3944 | |
3751 | 3945 | echo ' |
3752 | 3946 | <table> |
@@ -3789,8 +3983,8 @@ discard block |
||
3789 | 3983 | </td> |
3790 | 3984 | </tr>'; |
3791 | 3985 | |
3792 | - if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) |
|
3793 | - echo ' |
|
3986 | + if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) { |
|
3987 | + echo ' |
|
3794 | 3988 | <tr valign="top"> |
3795 | 3989 | <td width="2%"> |
3796 | 3990 | <input type="checkbox" name="delete_karma" id="delete_karma" value="1"> |
@@ -3799,6 +3993,7 @@ discard block |
||
3799 | 3993 | <label for="delete_karma">Delete all karma settings and info from the DB</label> |
3800 | 3994 | </td> |
3801 | 3995 | </tr>'; |
3996 | + } |
|
3802 | 3997 | |
3803 | 3998 | echo ' |
3804 | 3999 | <tr valign="top"> |
@@ -3836,10 +4031,11 @@ discard block |
||
3836 | 4031 | </div>'; |
3837 | 4032 | |
3838 | 4033 | // Dont any tables so far? |
3839 | - if (!empty($upcontext['previous_tables'])) |
|
3840 | - foreach ($upcontext['previous_tables'] as $table) |
|
4034 | + if (!empty($upcontext['previous_tables'])) { |
|
4035 | + foreach ($upcontext['previous_tables'] as $table) |
|
3841 | 4036 | echo ' |
3842 | 4037 | <br>Completed Table: "', $table, '".'; |
4038 | + } |
|
3843 | 4039 | |
3844 | 4040 | echo ' |
3845 | 4041 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
@@ -3876,12 +4072,13 @@ discard block |
||
3876 | 4072 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
3877 | 4073 | |
3878 | 4074 | // If debug flood the screen. |
3879 | - if ($is_debug) |
|
3880 | - echo ' |
|
4075 | + if ($is_debug) { |
|
4076 | + echo ' |
|
3881 | 4077 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
3882 | 4078 | |
3883 | 4079 | if (document.getElementById(\'debug_section\').scrollHeight) |
3884 | 4080 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
4081 | + } |
|
3885 | 4082 | |
3886 | 4083 | echo ' |
3887 | 4084 | // Get the next update... |
@@ -3914,8 +4111,9 @@ discard block |
||
3914 | 4111 | { |
3915 | 4112 | global $upcontext, $support_js, $is_debug, $timeLimitThreshold; |
3916 | 4113 | |
3917 | - if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) |
|
3918 | - $is_debug = true; |
|
4114 | + if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) { |
|
4115 | + $is_debug = true; |
|
4116 | + } |
|
3919 | 4117 | |
3920 | 4118 | echo ' |
3921 | 4119 | <h3>Executing database changes</h3> |
@@ -3930,8 +4128,9 @@ discard block |
||
3930 | 4128 | { |
3931 | 4129 | foreach ($upcontext['actioned_items'] as $num => $item) |
3932 | 4130 | { |
3933 | - if ($num != 0) |
|
3934 | - echo ' Successful!'; |
|
4131 | + if ($num != 0) { |
|
4132 | + echo ' Successful!'; |
|
4133 | + } |
|
3935 | 4134 | echo '<br>' . $item; |
3936 | 4135 | } |
3937 | 4136 | if (!empty($upcontext['changes_complete'])) |
@@ -3944,28 +4143,32 @@ discard block |
||
3944 | 4143 | $seconds = intval($active % 60); |
3945 | 4144 | |
3946 | 4145 | $totalTime = ''; |
3947 | - if ($hours > 0) |
|
3948 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
3949 | - if ($minutes > 0) |
|
3950 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
3951 | - if ($seconds > 0) |
|
3952 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4146 | + if ($hours > 0) { |
|
4147 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
4148 | + } |
|
4149 | + if ($minutes > 0) { |
|
4150 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
4151 | + } |
|
4152 | + if ($seconds > 0) { |
|
4153 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4154 | + } |
|
3953 | 4155 | } |
3954 | 4156 | |
3955 | - if ($is_debug && !empty($totalTime)) |
|
3956 | - echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
3957 | - else |
|
3958 | - echo ' Successful!<br><br>'; |
|
4157 | + if ($is_debug && !empty($totalTime)) { |
|
4158 | + echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
4159 | + } else { |
|
4160 | + echo ' Successful!<br><br>'; |
|
4161 | + } |
|
3959 | 4162 | |
3960 | 4163 | echo '<span id="commess" style="font-weight: bold;">1 Database Updates Complete! Click Continue to Proceed.</span><br>'; |
3961 | 4164 | } |
3962 | - } |
|
3963 | - else |
|
4165 | + } else |
|
3964 | 4166 | { |
3965 | 4167 | // Tell them how many files we have in total. |
3966 | - if ($upcontext['file_count'] > 1) |
|
3967 | - echo ' |
|
4168 | + if ($upcontext['file_count'] > 1) { |
|
4169 | + echo ' |
|
3968 | 4170 | <strong id="info1">Executing upgrade script <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>'; |
4171 | + } |
|
3969 | 4172 | |
3970 | 4173 | echo ' |
3971 | 4174 | <h3 id="info2"><strong>Executing:</strong> "<span id="cur_item_name">', $upcontext['current_item_name'], '</span>" (<span id="item_num">', $upcontext['current_item_num'], '</span> of <span id="total_items"><span id="item_count">', $upcontext['total_items'], '</span>', $upcontext['file_count'] > 1 ? ' - of this script' : '', ')</span></h3> |
@@ -3981,19 +4184,23 @@ discard block |
||
3981 | 4184 | $seconds = intval($active % 60); |
3982 | 4185 | |
3983 | 4186 | $totalTime = ''; |
3984 | - if ($hours > 0) |
|
3985 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
3986 | - if ($minutes > 0) |
|
3987 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
3988 | - if ($seconds > 0) |
|
3989 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4187 | + if ($hours > 0) { |
|
4188 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
4189 | + } |
|
4190 | + if ($minutes > 0) { |
|
4191 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
4192 | + } |
|
4193 | + if ($seconds > 0) { |
|
4194 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4195 | + } |
|
3990 | 4196 | } |
3991 | 4197 | |
3992 | 4198 | echo ' |
3993 | 4199 | <br><span id="upgradeCompleted">'; |
3994 | 4200 | |
3995 | - if (!empty($totalTime)) |
|
3996 | - echo 'Completed in ', $totalTime, '<br>'; |
|
4201 | + if (!empty($totalTime)) { |
|
4202 | + echo 'Completed in ', $totalTime, '<br>'; |
|
4203 | + } |
|
3997 | 4204 | |
3998 | 4205 | echo '</span> |
3999 | 4206 | <div id="debug_section" style="height: 59px; overflow: auto;"> |
@@ -4030,9 +4237,10 @@ discard block |
||
4030 | 4237 | var getData = ""; |
4031 | 4238 | var debugItems = ', $upcontext['debug_items'], ';'; |
4032 | 4239 | |
4033 | - if ($is_debug) |
|
4034 | - echo ' |
|
4240 | + if ($is_debug) { |
|
4241 | + echo ' |
|
4035 | 4242 | var upgradeStartTime = ' . $upcontext['started'] . ';'; |
4243 | + } |
|
4036 | 4244 | |
4037 | 4245 | echo ' |
4038 | 4246 | function getNextItem() |
@@ -4072,9 +4280,10 @@ discard block |
||
4072 | 4280 | document.getElementById("error_block").style.display = ""; |
4073 | 4281 | setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));'; |
4074 | 4282 | |
4075 | - if ($is_debug) |
|
4076 | - echo ' |
|
4283 | + if ($is_debug) { |
|
4284 | + echo ' |
|
4077 | 4285 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
4286 | + } |
|
4078 | 4287 | |
4079 | 4288 | echo ' |
4080 | 4289 | } |
@@ -4095,9 +4304,10 @@ discard block |
||
4095 | 4304 | document.getElementById("error_block").style.display = ""; |
4096 | 4305 | setInnerHTML(document.getElementById("error_message"), "Upgrade script appears to be going into a loop - step: " + sDebugName);'; |
4097 | 4306 | |
4098 | - if ($is_debug) |
|
4099 | - echo ' |
|
4307 | + if ($is_debug) { |
|
4308 | + echo ' |
|
4100 | 4309 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
4310 | + } |
|
4101 | 4311 | |
4102 | 4312 | echo ' |
4103 | 4313 | } |
@@ -4156,8 +4366,8 @@ discard block |
||
4156 | 4366 | if (bIsComplete && iDebugNum == -1 && curFile >= ', $upcontext['file_count'], ') |
4157 | 4367 | {'; |
4158 | 4368 | |
4159 | - if ($is_debug) |
|
4160 | - echo ' |
|
4369 | + if ($is_debug) { |
|
4370 | + echo ' |
|
4161 | 4371 | document.getElementById(\'debug_section\').style.display = "none"; |
4162 | 4372 | |
4163 | 4373 | var upgradeFinishedTime = parseInt(oXMLDoc.getElementsByTagName("curtime")[0].childNodes[0].nodeValue); |
@@ -4175,6 +4385,7 @@ discard block |
||
4175 | 4385 | totalTime = totalTime + diffSeconds + " second" + (diffSeconds > 1 ? "s" : ""); |
4176 | 4386 | |
4177 | 4387 | setInnerHTML(document.getElementById("upgradeCompleted"), "Completed in " + totalTime);'; |
4388 | + } |
|
4178 | 4389 | |
4179 | 4390 | echo ' |
4180 | 4391 | |
@@ -4182,9 +4393,10 @@ discard block |
||
4182 | 4393 | document.getElementById(\'contbutt\').disabled = 0; |
4183 | 4394 | document.getElementById(\'database_done\').value = 1;'; |
4184 | 4395 | |
4185 | - if ($upcontext['file_count'] > 1) |
|
4186 | - echo ' |
|
4396 | + if ($upcontext['file_count'] > 1) { |
|
4397 | + echo ' |
|
4187 | 4398 | document.getElementById(\'info1\').style.display = "none";'; |
4399 | + } |
|
4188 | 4400 | |
4189 | 4401 | echo ' |
4190 | 4402 | document.getElementById(\'info2\').style.display = "none"; |
@@ -4197,9 +4409,10 @@ discard block |
||
4197 | 4409 | lastItem = 0; |
4198 | 4410 | prevFile = curFile;'; |
4199 | 4411 | |
4200 | - if ($is_debug) |
|
4201 | - echo ' |
|
4412 | + if ($is_debug) { |
|
4413 | + echo ' |
|
4202 | 4414 | setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br><span id="debuginfo"><\' + \'/span>\');'; |
4415 | + } |
|
4203 | 4416 | |
4204 | 4417 | echo ' |
4205 | 4418 | getNextItem(); |
@@ -4207,8 +4420,8 @@ discard block |
||
4207 | 4420 | }'; |
4208 | 4421 | |
4209 | 4422 | // If debug scroll the screen. |
4210 | - if ($is_debug) |
|
4211 | - echo ' |
|
4423 | + if ($is_debug) { |
|
4424 | + echo ' |
|
4212 | 4425 | if (iLastSubStepProgress == -1) |
4213 | 4426 | { |
4214 | 4427 | // Give it consistent dots. |
@@ -4227,6 +4440,7 @@ discard block |
||
4227 | 4440 | |
4228 | 4441 | if (document.getElementById(\'debug_section\').scrollHeight) |
4229 | 4442 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
4443 | + } |
|
4230 | 4444 | |
4231 | 4445 | echo ' |
4232 | 4446 | // Update the page. |
@@ -4287,9 +4501,10 @@ discard block |
||
4287 | 4501 | }'; |
4288 | 4502 | |
4289 | 4503 | // Start things off assuming we've not errored. |
4290 | - if (empty($upcontext['error_message'])) |
|
4291 | - echo ' |
|
4504 | + if (empty($upcontext['error_message'])) { |
|
4505 | + echo ' |
|
4292 | 4506 | getNextItem();'; |
4507 | + } |
|
4293 | 4508 | |
4294 | 4509 | echo ' |
4295 | 4510 | //# sourceURL=dynamicScript-dbch.js |
@@ -4307,18 +4522,21 @@ discard block |
||
4307 | 4522 | <item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item> |
4308 | 4523 | <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>'; |
4309 | 4524 | |
4310 | - if (!empty($upcontext['error_message'])) |
|
4311 | - echo ' |
|
4525 | + if (!empty($upcontext['error_message'])) { |
|
4526 | + echo ' |
|
4312 | 4527 | <error>', $upcontext['error_message'], '</error>'; |
4528 | + } |
|
4313 | 4529 | |
4314 | - if (!empty($upcontext['error_string'])) |
|
4315 | - echo ' |
|
4530 | + if (!empty($upcontext['error_string'])) { |
|
4531 | + echo ' |
|
4316 | 4532 | <sql>', $upcontext['error_string'], '</sql>'; |
4533 | + } |
|
4317 | 4534 | |
4318 | - if ($is_debug) |
|
4319 | - echo ' |
|
4535 | + if ($is_debug) { |
|
4536 | + echo ' |
|
4320 | 4537 | <curtime>', time(), '</curtime>'; |
4321 | -} |
|
4538 | + } |
|
4539 | + } |
|
4322 | 4540 | |
4323 | 4541 | // Template for the UTF-8 conversion step. Basically a copy of the backup stuff with slight modifications.... |
4324 | 4542 | function template_convert_utf8() |
@@ -4337,18 +4555,20 @@ discard block |
||
4337 | 4555 | </div>'; |
4338 | 4556 | |
4339 | 4557 | // Done any tables so far? |
4340 | - if (!empty($upcontext['previous_tables'])) |
|
4341 | - foreach ($upcontext['previous_tables'] as $table) |
|
4558 | + if (!empty($upcontext['previous_tables'])) { |
|
4559 | + foreach ($upcontext['previous_tables'] as $table) |
|
4342 | 4560 | echo ' |
4343 | 4561 | <br>Completed Table: "', $table, '".'; |
4562 | + } |
|
4344 | 4563 | |
4345 | 4564 | echo ' |
4346 | 4565 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3>'; |
4347 | 4566 | |
4348 | 4567 | // If we dropped their index, let's let them know |
4349 | - if ($upcontext['dropping_index']) |
|
4350 | - echo ' |
|
4568 | + if ($upcontext['dropping_index']) { |
|
4569 | + echo ' |
|
4351 | 4570 | <br><span id="indexmsg" style="font-weight: bold; font-style: italic; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">Please note that your fulltext index was dropped to facilitate the conversion and will need to be recreated in the admin area after the upgrade is complete.</span>'; |
4571 | + } |
|
4352 | 4572 | |
4353 | 4573 | // Completion notification |
4354 | 4574 | echo ' |
@@ -4385,12 +4605,13 @@ discard block |
||
4385 | 4605 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
4386 | 4606 | |
4387 | 4607 | // If debug flood the screen. |
4388 | - if ($is_debug) |
|
4389 | - echo ' |
|
4608 | + if ($is_debug) { |
|
4609 | + echo ' |
|
4390 | 4610 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
4391 | 4611 | |
4392 | 4612 | if (document.getElementById(\'debug_section\').scrollHeight) |
4393 | 4613 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
4614 | + } |
|
4394 | 4615 | |
4395 | 4616 | echo ' |
4396 | 4617 | // Get the next update... |
@@ -4438,19 +4659,21 @@ discard block |
||
4438 | 4659 | </div>'; |
4439 | 4660 | |
4440 | 4661 | // Dont any tables so far? |
4441 | - if (!empty($upcontext['previous_tables'])) |
|
4442 | - foreach ($upcontext['previous_tables'] as $table) |
|
4662 | + if (!empty($upcontext['previous_tables'])) { |
|
4663 | + foreach ($upcontext['previous_tables'] as $table) |
|
4443 | 4664 | echo ' |
4444 | 4665 | <br>Completed Table: "', $table, '".'; |
4666 | + } |
|
4445 | 4667 | |
4446 | 4668 | echo ' |
4447 | 4669 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
4448 | 4670 | <br><span id="commess" style="font-weight: bold; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">Convert to JSON Complete! Click Continue to Proceed.</span>'; |
4449 | 4671 | |
4450 | 4672 | // Try to make sure substep was reset. |
4451 | - if ($upcontext['cur_table_num'] == $upcontext['table_count']) |
|
4452 | - echo ' |
|
4673 | + if ($upcontext['cur_table_num'] == $upcontext['table_count']) { |
|
4674 | + echo ' |
|
4453 | 4675 | <input type="hidden" name="substep" id="substep" value="0">'; |
4676 | + } |
|
4454 | 4677 | |
4455 | 4678 | // Continue please! |
4456 | 4679 | $upcontext['continue'] = $support_js ? 2 : 1; |
@@ -4483,12 +4706,13 @@ discard block |
||
4483 | 4706 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
4484 | 4707 | |
4485 | 4708 | // If debug flood the screen. |
4486 | - if ($is_debug) |
|
4487 | - echo ' |
|
4709 | + if ($is_debug) { |
|
4710 | + echo ' |
|
4488 | 4711 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
4489 | 4712 | |
4490 | 4713 | if (document.getElementById(\'debug_section\').scrollHeight) |
4491 | 4714 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
4715 | + } |
|
4492 | 4716 | |
4493 | 4717 | echo ' |
4494 | 4718 | // Get the next update... |
@@ -4524,8 +4748,8 @@ discard block |
||
4524 | 4748 | <h3>That wasn\'t so hard, was it? Now you are ready to use <a href="', $boardurl, '/index.php">your installation of SMF</a>. Hope you like it!</h3> |
4525 | 4749 | <form action="', $boardurl, '/index.php">'; |
4526 | 4750 | |
4527 | - if (!empty($upcontext['can_delete_script'])) |
|
4528 | - echo ' |
|
4751 | + if (!empty($upcontext['can_delete_script'])) { |
|
4752 | + echo ' |
|
4529 | 4753 | <label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete(this);"> Delete upgrade.php and its data files now</label> <em>(doesn\'t work on all servers).</em> |
4530 | 4754 | <script> |
4531 | 4755 | function doTheDelete(theCheck) |
@@ -4537,6 +4761,7 @@ discard block |
||
4537 | 4761 | } |
4538 | 4762 | </script> |
4539 | 4763 | <img src="', $settings['default_theme_url'], '/images/blank.png" alt="" id="delete_upgrader"><br>'; |
4764 | + } |
|
4540 | 4765 | |
4541 | 4766 | $active = time() - $upcontext['started']; |
4542 | 4767 | $hours = floor($active / 3600); |
@@ -4546,16 +4771,20 @@ discard block |
||
4546 | 4771 | if ($is_debug) |
4547 | 4772 | { |
4548 | 4773 | $totalTime = ''; |
4549 | - if ($hours > 0) |
|
4550 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
4551 | - if ($minutes > 0) |
|
4552 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
4553 | - if ($seconds > 0) |
|
4554 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4774 | + if ($hours > 0) { |
|
4775 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
4776 | + } |
|
4777 | + if ($minutes > 0) { |
|
4778 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
4779 | + } |
|
4780 | + if ($seconds > 0) { |
|
4781 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4782 | + } |
|
4555 | 4783 | } |
4556 | 4784 | |
4557 | - if ($is_debug && !empty($totalTime)) |
|
4558 | - echo '<br> Upgrade completed in ', $totalTime, '<br><br>'; |
|
4785 | + if ($is_debug && !empty($totalTime)) { |
|
4786 | + echo '<br> Upgrade completed in ', $totalTime, '<br><br>'; |
|
4787 | + } |
|
4559 | 4788 | |
4560 | 4789 | echo '<br> |
4561 | 4790 | If you had any problems with this upgrade, or have any problems using SMF, please don\'t hesitate to <a href="https://www.simplemachines.org/community/index.php">look to us for assistance</a>.<br> |
@@ -4582,8 +4811,9 @@ discard block |
||
4582 | 4811 | |
4583 | 4812 | $current_substep = $_GET['substep']; |
4584 | 4813 | |
4585 | - if (empty($_GET['a'])) |
|
4586 | - $_GET['a'] = 0; |
|
4814 | + if (empty($_GET['a'])) { |
|
4815 | + $_GET['a'] = 0; |
|
4816 | + } |
|
4587 | 4817 | $step_progress['name'] = 'Converting ips'; |
4588 | 4818 | $step_progress['current'] = $_GET['a']; |
4589 | 4819 | |
@@ -4626,16 +4856,19 @@ discard block |
||
4626 | 4856 | 'empty' => '', |
4627 | 4857 | 'limit' => $limit, |
4628 | 4858 | )); |
4629 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
4630 | - $arIp[] = $row[$oldCol]; |
|
4859 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
4860 | + $arIp[] = $row[$oldCol]; |
|
4861 | + } |
|
4631 | 4862 | $smcFunc['db_free_result']($request); |
4632 | 4863 | |
4633 | 4864 | // Special case, null ip could keep us in a loop. |
4634 | - if (is_null($arIp[0])) |
|
4635 | - unset($arIp[0]); |
|
4865 | + if (is_null($arIp[0])) { |
|
4866 | + unset($arIp[0]); |
|
4867 | + } |
|
4636 | 4868 | |
4637 | - if (empty($arIp)) |
|
4638 | - $is_done = true; |
|
4869 | + if (empty($arIp)) { |
|
4870 | + $is_done = true; |
|
4871 | + } |
|
4639 | 4872 | |
4640 | 4873 | $updates = array(); |
4641 | 4874 | $cases = array(); |
@@ -4644,16 +4877,18 @@ discard block |
||
4644 | 4877 | { |
4645 | 4878 | $arIp[$i] = trim($arIp[$i]); |
4646 | 4879 | |
4647 | - if (empty($arIp[$i])) |
|
4648 | - continue; |
|
4880 | + if (empty($arIp[$i])) { |
|
4881 | + continue; |
|
4882 | + } |
|
4649 | 4883 | |
4650 | 4884 | $updates['ip' . $i] = $arIp[$i]; |
4651 | 4885 | $cases[$arIp[$i]] = 'WHEN ' . $oldCol . ' = {string:ip' . $i . '} THEN {inet:ip' . $i . '}'; |
4652 | 4886 | |
4653 | 4887 | if ($setSize > 0 && $i % $setSize === 0) |
4654 | 4888 | { |
4655 | - if (count($updates) == 1) |
|
4656 | - continue; |
|
4889 | + if (count($updates) == 1) { |
|
4890 | + continue; |
|
4891 | + } |
|
4657 | 4892 | |
4658 | 4893 | $updates['whereSet'] = array_values($updates); |
4659 | 4894 | $smcFunc['db_query']('', ' |
@@ -4687,8 +4922,7 @@ discard block |
||
4687 | 4922 | 'ip' => $ip |
4688 | 4923 | )); |
4689 | 4924 | } |
4690 | - } |
|
4691 | - else |
|
4925 | + } else |
|
4692 | 4926 | { |
4693 | 4927 | $updates['whereSet'] = array_values($updates); |
4694 | 4928 | $smcFunc['db_query']('', ' |
@@ -4702,9 +4936,9 @@ discard block |
||
4702 | 4936 | $updates |
4703 | 4937 | ); |
4704 | 4938 | } |
4939 | + } else { |
|
4940 | + $is_done = true; |
|
4705 | 4941 | } |
4706 | - else |
|
4707 | - $is_done = true; |
|
4708 | 4942 | |
4709 | 4943 | $_GET['a'] += $limit; |
4710 | 4944 | $step_progress['current'] = $_GET['a']; |
@@ -4730,10 +4964,11 @@ discard block |
||
4730 | 4964 | |
4731 | 4965 | $columns = $smcFunc['db_list_columns']($targetTable, true); |
4732 | 4966 | |
4733 | - if (isset($columns[$column])) |
|
4734 | - return $columns[$column]; |
|
4735 | - else |
|
4736 | - return null; |
|
4737 | -} |
|
4967 | + if (isset($columns[$column])) { |
|
4968 | + return $columns[$column]; |
|
4969 | + } else { |
|
4970 | + return null; |
|
4971 | + } |
|
4972 | + } |
|
4738 | 4973 | |
4739 | 4974 | ?> |
4740 | 4975 | \ No newline at end of file |
@@ -59,8 +59,9 @@ discard block |
||
59 | 59 | * @version 2.1 Beta 4 |
60 | 60 | */ |
61 | 61 | |
62 | -if (!defined('SMF')) |
|
62 | +if (!defined('SMF')) { |
|
63 | 63 | die('No direct access...'); |
64 | +} |
|
64 | 65 | |
65 | 66 | /** |
66 | 67 | * This is the main dispatcher. Sets up all the available sub-actions, all the tabs and selects |
@@ -111,10 +112,11 @@ discard block |
||
111 | 112 | $settings_not_writable = !is_writable($boarddir . '/Settings.php'); |
112 | 113 | $settings_backup_fail = !@is_writable($boarddir . '/Settings_bak.php') || !@copy($boarddir . '/Settings.php', $boarddir . '/Settings_bak.php'); |
113 | 114 | |
114 | - if ($settings_not_writable) |
|
115 | - $context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>'; |
|
116 | - elseif ($settings_backup_fail) |
|
117 | - $context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>'; |
|
115 | + if ($settings_not_writable) { |
|
116 | + $context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>'; |
|
117 | + } elseif ($settings_backup_fail) { |
|
118 | + $context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>'; |
|
119 | + } |
|
118 | 120 | |
119 | 121 | $context['settings_not_writable'] = $settings_not_writable; |
120 | 122 | |
@@ -142,10 +144,11 @@ discard block |
||
142 | 144 | |
143 | 145 | // If no cert, force_ssl must remain 0 |
144 | 146 | require_once($sourcedir . '/Subs.php'); |
145 | - if (!ssl_cert_found($boardurl) && empty($modSettings['force_ssl'])) |
|
146 | - $disable_force_ssl = true; |
|
147 | - else |
|
148 | - $disable_force_ssl = false; |
|
147 | + if (!ssl_cert_found($boardurl) && empty($modSettings['force_ssl'])) { |
|
148 | + $disable_force_ssl = true; |
|
149 | + } else { |
|
150 | + $disable_force_ssl = false; |
|
151 | + } |
|
149 | 152 | |
150 | 153 | /* If you're writing a mod, it's a bad idea to add things here.... |
151 | 154 | For each option: |
@@ -175,8 +178,9 @@ discard block |
||
175 | 178 | |
176 | 179 | call_integration_hook('integrate_general_settings', array(&$config_vars)); |
177 | 180 | |
178 | - if ($return_config) |
|
179 | - return $config_vars; |
|
181 | + if ($return_config) { |
|
182 | + return $config_vars; |
|
183 | + } |
|
180 | 184 | |
181 | 185 | // Setup the template stuff. |
182 | 186 | $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=general;save'; |
@@ -193,16 +197,18 @@ discard block |
||
193 | 197 | $registerSMStats = registerSMStats(); |
194 | 198 | |
195 | 199 | // Failed to register, disable it again. |
196 | - if (empty($registerSMStats)) |
|
197 | - $_POST['enable_sm_stats'] = 0; |
|
200 | + if (empty($registerSMStats)) { |
|
201 | + $_POST['enable_sm_stats'] = 0; |
|
202 | + } |
|
198 | 203 | } |
199 | 204 | |
200 | 205 | // Ensure all URLs are aligned with the new force_ssl setting |
201 | 206 | // Treat unset like 0 |
202 | - if (isset($_POST['force_ssl'])) |
|
203 | - AlignURLsWithSSLSetting($_POST['force_ssl']); |
|
204 | - else |
|
205 | - AlignURLsWithSSLSetting(0); |
|
207 | + if (isset($_POST['force_ssl'])) { |
|
208 | + AlignURLsWithSSLSetting($_POST['force_ssl']); |
|
209 | + } else { |
|
210 | + AlignURLsWithSSLSetting(0); |
|
211 | + } |
|
206 | 212 | |
207 | 213 | saveSettings($config_vars); |
208 | 214 | $_SESSION['adm-save'] = true; |
@@ -255,10 +261,11 @@ discard block |
||
255 | 261 | require_once($sourcedir . '/Subs-Admin.php'); |
256 | 262 | |
257 | 263 | // Check $boardurl |
258 | - if ($new_force_ssl == 2) |
|
259 | - $newval = strtr($boardurl, array('http://' => 'https://')); |
|
260 | - else |
|
261 | - $newval = strtr($boardurl, array('https://' => 'http://')); |
|
264 | + if ($new_force_ssl == 2) { |
|
265 | + $newval = strtr($boardurl, array('http://' => 'https://')); |
|
266 | + } else { |
|
267 | + $newval = strtr($boardurl, array('https://' => 'http://')); |
|
268 | + } |
|
262 | 269 | updateSettingsFile(array('boardurl' => '\'' . addslashes($newval) . '\'')); |
263 | 270 | |
264 | 271 | $new_settings = array(); |
@@ -266,20 +273,22 @@ discard block |
||
266 | 273 | // Check $smileys_url, but only if it points to a subfolder of $boardurl |
267 | 274 | if (BoardurlMatch($modSettings['smileys_url'])) |
268 | 275 | { |
269 | - if ($new_force_ssl == 2) |
|
270 | - $newval = strtr($modSettings['smileys_url'], array('http://' => 'https://')); |
|
271 | - else |
|
272 | - $newval = strtr($modSettings['smileys_url'], array('https://' => 'http://')); |
|
276 | + if ($new_force_ssl == 2) { |
|
277 | + $newval = strtr($modSettings['smileys_url'], array('http://' => 'https://')); |
|
278 | + } else { |
|
279 | + $newval = strtr($modSettings['smileys_url'], array('https://' => 'http://')); |
|
280 | + } |
|
273 | 281 | $new_settings['smileys_url'] = $newval; |
274 | 282 | } |
275 | 283 | |
276 | 284 | // Check $avatar_url, but only if it points to a subfolder of $boardurl |
277 | 285 | if (BoardurlMatch($modSettings['avatar_url'])) |
278 | 286 | { |
279 | - if ($new_force_ssl == 2) |
|
280 | - $newval = strtr($modSettings['avatar_url'], array('http://' => 'https://')); |
|
281 | - else |
|
282 | - $newval = strtr($modSettings['avatar_url'], array('https://' => 'http://')); |
|
287 | + if ($new_force_ssl == 2) { |
|
288 | + $newval = strtr($modSettings['avatar_url'], array('http://' => 'https://')); |
|
289 | + } else { |
|
290 | + $newval = strtr($modSettings['avatar_url'], array('https://' => 'http://')); |
|
291 | + } |
|
283 | 292 | $new_settings['avatar_url'] = $newval; |
284 | 293 | } |
285 | 294 | |
@@ -287,16 +296,18 @@ discard block |
||
287 | 296 | // This one had been optional in the past, make sure it is set first |
288 | 297 | if (isset($modSettings['custom_avatar_url']) && BoardurlMatch($modSettings['custom_avatar_url'])) |
289 | 298 | { |
290 | - if ($new_force_ssl == 2) |
|
291 | - $newval = strtr($modSettings['custom_avatar_url'], array('http://' => 'https://')); |
|
292 | - else |
|
293 | - $newval = strtr($modSettings['custom_avatar_url'], array('https://' => 'http://')); |
|
299 | + if ($new_force_ssl == 2) { |
|
300 | + $newval = strtr($modSettings['custom_avatar_url'], array('http://' => 'https://')); |
|
301 | + } else { |
|
302 | + $newval = strtr($modSettings['custom_avatar_url'], array('https://' => 'http://')); |
|
303 | + } |
|
294 | 304 | $new_settings['custom_avatar_url'] = $newval; |
295 | 305 | } |
296 | 306 | |
297 | 307 | // Save updates to the settings table |
298 | - if (!empty($new_settings)) |
|
299 | - updateSettings($new_settings, true); |
|
308 | + if (!empty($new_settings)) { |
|
309 | + updateSettings($new_settings, true); |
|
310 | + } |
|
300 | 311 | |
301 | 312 | // Now we move onto the themes. |
302 | 313 | // First, get a list of theme URLs... |
@@ -317,10 +328,11 @@ discard block |
||
317 | 328 | // First check to see if it points to a subfolder of $boardurl |
318 | 329 | if (BoardurlMatch($row['value'])) |
319 | 330 | { |
320 | - if ($new_force_ssl == 2) |
|
321 | - $newval = strtr($row['value'], array('http://' => 'https://')); |
|
322 | - else |
|
323 | - $newval = strtr($row['value'], array('https://' => 'http://')); |
|
331 | + if ($new_force_ssl == 2) { |
|
332 | + $newval = strtr($row['value'], array('http://' => 'https://')); |
|
333 | + } else { |
|
334 | + $newval = strtr($row['value'], array('https://' => 'http://')); |
|
335 | + } |
|
324 | 336 | $smcFunc['db_query']('', ' |
325 | 337 | UPDATE {db_prefix}themes |
326 | 338 | SET value = {string:theme_val} |
@@ -360,11 +372,12 @@ discard block |
||
360 | 372 | |
361 | 373 | // If leftmost portion of path matches boardurl, return true |
362 | 374 | $result = strpos($urlpath, $boardurlpath); |
363 | - if ($result === false || $result != 0) |
|
364 | - return false; |
|
365 | - else |
|
366 | - return true; |
|
367 | -} |
|
375 | + if ($result === false || $result != 0) { |
|
376 | + return false; |
|
377 | + } else { |
|
378 | + return true; |
|
379 | + } |
|
380 | + } |
|
368 | 381 | |
369 | 382 | /** |
370 | 383 | * Basic database and paths settings - database name, host, etc. |
@@ -402,8 +415,9 @@ discard block |
||
402 | 415 | $request = $smcFunc['db_query']('', 'SELECT cfgname FROM pg_ts_config', array()); |
403 | 416 | $fts_language = array(); |
404 | 417 | |
405 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
406 | - $fts_language[$row['cfgname']] = $row['cfgname']; |
|
418 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
419 | + $fts_language[$row['cfgname']] = $row['cfgname']; |
|
420 | + } |
|
407 | 421 | |
408 | 422 | $config_vars = array_merge ($config_vars, array( |
409 | 423 | '', |
@@ -415,8 +429,9 @@ discard block |
||
415 | 429 | |
416 | 430 | call_integration_hook('integrate_database_settings', array(&$config_vars)); |
417 | 431 | |
418 | - if ($return_config) |
|
419 | - return $config_vars; |
|
432 | + if ($return_config) { |
|
433 | + return $config_vars; |
|
434 | + } |
|
420 | 435 | |
421 | 436 | // Setup the template stuff. |
422 | 437 | $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=database;save'; |
@@ -491,13 +506,15 @@ discard block |
||
491 | 506 | hideGlobalCookies(); |
492 | 507 | });', true); |
493 | 508 | |
494 | - if (empty($user_settings['tfa_secret'])) |
|
495 | - addInlineJavaScript(''); |
|
509 | + if (empty($user_settings['tfa_secret'])) { |
|
510 | + addInlineJavaScript(''); |
|
511 | + } |
|
496 | 512 | |
497 | 513 | call_integration_hook('integrate_cookie_settings', array(&$config_vars)); |
498 | 514 | |
499 | - if ($return_config) |
|
500 | - return $config_vars; |
|
515 | + if ($return_config) { |
|
516 | + return $config_vars; |
|
517 | + } |
|
501 | 518 | |
502 | 519 | $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=cookie;save'; |
503 | 520 | $context['settings_title'] = $txt['cookies_sessions_settings']; |
@@ -508,11 +525,13 @@ discard block |
||
508 | 525 | call_integration_hook('integrate_save_cookie_settings'); |
509 | 526 | |
510 | 527 | // Local and global do not play nicely together. |
511 | - if (!empty($_POST['localCookies']) && empty($_POST['globalCookies'])) |
|
512 | - unset ($_POST['globalCookies']); |
|
528 | + if (!empty($_POST['localCookies']) && empty($_POST['globalCookies'])) { |
|
529 | + unset ($_POST['globalCookies']); |
|
530 | + } |
|
513 | 531 | |
514 | - if (!empty($_POST['globalCookiesDomain']) && strpos($boardurl, $_POST['globalCookiesDomain']) === false) |
|
515 | - fatal_lang_error('invalid_cookie_domain', false); |
|
532 | + if (!empty($_POST['globalCookiesDomain']) && strpos($boardurl, $_POST['globalCookiesDomain']) === false) { |
|
533 | + fatal_lang_error('invalid_cookie_domain', false); |
|
534 | + } |
|
516 | 535 | |
517 | 536 | saveSettings($config_vars); |
518 | 537 | |
@@ -595,8 +614,9 @@ discard block |
||
595 | 614 | |
596 | 615 | call_integration_hook('integrate_general_security_settings', array(&$config_vars)); |
597 | 616 | |
598 | - if ($return_config) |
|
599 | - return $config_vars; |
|
617 | + if ($return_config) { |
|
618 | + return $config_vars; |
|
619 | + } |
|
600 | 620 | |
601 | 621 | // Saving? |
602 | 622 | if (isset($_GET['save'])) |
@@ -635,8 +655,7 @@ discard block |
||
635 | 655 | $txt['cache_settings_message'] = $txt['detected_no_caching']; |
636 | 656 | $cache_level = array($txt['cache_off']); |
637 | 657 | $detected['none'] = $txt['cache_off']; |
638 | - } |
|
639 | - else |
|
658 | + } else |
|
640 | 659 | { |
641 | 660 | $txt['cache_settings_message'] = sprintf($txt['detected_accelerators'], implode(', ', $detected)); |
642 | 661 | $cache_level = array($txt['cache_off'], $txt['cache_level1'], $txt['cache_level2'], $txt['cache_level3']); |
@@ -673,8 +692,9 @@ discard block |
||
673 | 692 | } |
674 | 693 | } |
675 | 694 | } |
676 | - if ($return_config) |
|
677 | - return $config_vars; |
|
695 | + if ($return_config) { |
|
696 | + return $config_vars; |
|
697 | + } |
|
678 | 698 | |
679 | 699 | // Saving again? |
680 | 700 | if (isset($_GET['save'])) |
@@ -702,8 +722,9 @@ discard block |
||
702 | 722 | $context['save_disabled'] = $context['settings_not_writable']; |
703 | 723 | |
704 | 724 | // Decide what message to show. |
705 | - if (!$context['save_disabled']) |
|
706 | - $context['settings_message'] = $txt['caching_information']; |
|
725 | + if (!$context['save_disabled']) { |
|
726 | + $context['settings_message'] = $txt['caching_information']; |
|
727 | + } |
|
707 | 728 | |
708 | 729 | // Prepare the template. |
709 | 730 | prepareServerSettingsContext($config_vars); |
@@ -726,24 +747,25 @@ discard block |
||
726 | 747 | if (stripos(PHP_OS, 'win') === 0) |
727 | 748 | { |
728 | 749 | $context['settings_message'] = $txt['loadavg_disabled_windows']; |
729 | - if (isset($_GET['save'])) |
|
730 | - $_SESSION['adm-save'] = $txt['loadavg_disabled_windows']; |
|
731 | - } |
|
732 | - elseif (stripos(PHP_OS, 'darwin') === 0) |
|
750 | + if (isset($_GET['save'])) { |
|
751 | + $_SESSION['adm-save'] = $txt['loadavg_disabled_windows']; |
|
752 | + } |
|
753 | + } elseif (stripos(PHP_OS, 'darwin') === 0) |
|
733 | 754 | { |
734 | 755 | $context['settings_message'] = $txt['loadavg_disabled_osx']; |
735 | - if (isset($_GET['save'])) |
|
736 | - $_SESSION['adm-save'] = $txt['loadavg_disabled_osx']; |
|
737 | - } |
|
738 | - else |
|
756 | + if (isset($_GET['save'])) { |
|
757 | + $_SESSION['adm-save'] = $txt['loadavg_disabled_osx']; |
|
758 | + } |
|
759 | + } else |
|
739 | 760 | { |
740 | 761 | $modSettings['load_average'] = @file_get_contents('/proc/loadavg'); |
741 | - if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) !== 0) |
|
742 | - $modSettings['load_average'] = (float) $matches[1]; |
|
743 | - elseif (($modSettings['load_average'] = @`uptime`) !== null && preg_match('~load averages?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) !== 0) |
|
744 | - $modSettings['load_average'] = (float) $matches[1]; |
|
745 | - else |
|
746 | - unset($modSettings['load_average']); |
|
762 | + if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) !== 0) { |
|
763 | + $modSettings['load_average'] = (float) $matches[1]; |
|
764 | + } elseif (($modSettings['load_average'] = @`uptime`) !== null && preg_match('~load averages?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) !== 0) { |
|
765 | + $modSettings['load_average'] = (float) $matches[1]; |
|
766 | + } else { |
|
767 | + unset($modSettings['load_average']); |
|
768 | + } |
|
747 | 769 | |
748 | 770 | if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
749 | 771 | { |
@@ -779,8 +801,9 @@ discard block |
||
779 | 801 | |
780 | 802 | call_integration_hook('integrate_loadavg_settings', array(&$config_vars)); |
781 | 803 | |
782 | - if ($return_config) |
|
783 | - return $config_vars; |
|
804 | + if ($return_config) { |
|
805 | + return $config_vars; |
|
806 | + } |
|
784 | 807 | |
785 | 808 | $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=loads;save'; |
786 | 809 | $context['settings_title'] = $txt['load_balancing_settings']; |
@@ -791,24 +814,27 @@ discard block |
||
791 | 814 | // Stupidity is not allowed. |
792 | 815 | foreach ($_POST as $key => $value) |
793 | 816 | { |
794 | - if (strpos($key, 'loadavg') === 0 || $key === 'loadavg_enable' || !in_array($key, array_keys($default_values))) |
|
795 | - continue; |
|
796 | - else |
|
797 | - $_POST[$key] = (float) $value; |
|
798 | - |
|
799 | - if ($key == 'loadavg_auto_opt' && $value <= 1) |
|
800 | - $_POST['loadavg_auto_opt'] = 1.0; |
|
801 | - elseif ($key == 'loadavg_forum' && $value < 10) |
|
802 | - $_POST['loadavg_forum'] = 10.0; |
|
803 | - elseif ($value < 2) |
|
804 | - $_POST[$key] = 2.0; |
|
817 | + if (strpos($key, 'loadavg') === 0 || $key === 'loadavg_enable' || !in_array($key, array_keys($default_values))) { |
|
818 | + continue; |
|
819 | + } else { |
|
820 | + $_POST[$key] = (float) $value; |
|
821 | + } |
|
822 | + |
|
823 | + if ($key == 'loadavg_auto_opt' && $value <= 1) { |
|
824 | + $_POST['loadavg_auto_opt'] = 1.0; |
|
825 | + } elseif ($key == 'loadavg_forum' && $value < 10) { |
|
826 | + $_POST['loadavg_forum'] = 10.0; |
|
827 | + } elseif ($value < 2) { |
|
828 | + $_POST[$key] = 2.0; |
|
829 | + } |
|
805 | 830 | } |
806 | 831 | |
807 | 832 | call_integration_hook('integrate_save_loadavg_settings'); |
808 | 833 | |
809 | 834 | saveDBSettings($config_vars); |
810 | - if (!isset($_SESSION['adm-save'])) |
|
811 | - $_SESSION['adm-save'] = true; |
|
835 | + if (!isset($_SESSION['adm-save'])) { |
|
836 | + $_SESSION['adm-save'] = true; |
|
837 | + } |
|
812 | 838 | redirectexit('action=admin;area=serversettings;sa=loads;' . $context['session_var'] . '=' . $context['session_id']); |
813 | 839 | } |
814 | 840 | |
@@ -844,10 +870,11 @@ discard block |
||
844 | 870 | |
845 | 871 | if (isset($_SESSION['adm-save'])) |
846 | 872 | { |
847 | - if ($_SESSION['adm-save'] === true) |
|
848 | - $context['saved_successful'] = true; |
|
849 | - else |
|
850 | - $context['saved_failed'] = $_SESSION['adm-save']; |
|
873 | + if ($_SESSION['adm-save'] === true) { |
|
874 | + $context['saved_successful'] = true; |
|
875 | + } else { |
|
876 | + $context['saved_failed'] = $_SESSION['adm-save']; |
|
877 | + } |
|
851 | 878 | |
852 | 879 | unset($_SESSION['adm-save']); |
853 | 880 | } |
@@ -855,9 +882,9 @@ discard block |
||
855 | 882 | $context['config_vars'] = array(); |
856 | 883 | foreach ($config_vars as $identifier => $config_var) |
857 | 884 | { |
858 | - if (!is_array($config_var) || !isset($config_var[1])) |
|
859 | - $context['config_vars'][] = $config_var; |
|
860 | - else |
|
885 | + if (!is_array($config_var) || !isset($config_var[1])) { |
|
886 | + $context['config_vars'][] = $config_var; |
|
887 | + } else |
|
861 | 888 | { |
862 | 889 | $varname = $config_var[0]; |
863 | 890 | global $$varname; |
@@ -892,16 +919,19 @@ discard block |
||
892 | 919 | if ($config_var[3] == 'int' || $config_var[3] == 'float') |
893 | 920 | { |
894 | 921 | // Default to a min of 0 if one isn't set |
895 | - if (isset($config_var['min'])) |
|
896 | - $context['config_vars'][$config_var[0]]['min'] = $config_var['min']; |
|
897 | - else |
|
898 | - $context['config_vars'][$config_var[0]]['min'] = 0; |
|
922 | + if (isset($config_var['min'])) { |
|
923 | + $context['config_vars'][$config_var[0]]['min'] = $config_var['min']; |
|
924 | + } else { |
|
925 | + $context['config_vars'][$config_var[0]]['min'] = 0; |
|
926 | + } |
|
899 | 927 | |
900 | - if (isset($config_var['max'])) |
|
901 | - $context['config_vars'][$config_var[0]]['max'] = $config_var['max']; |
|
928 | + if (isset($config_var['max'])) { |
|
929 | + $context['config_vars'][$config_var[0]]['max'] = $config_var['max']; |
|
930 | + } |
|
902 | 931 | |
903 | - if (isset($config_var['step'])) |
|
904 | - $context['config_vars'][$config_var[0]]['step'] = $config_var['step']; |
|
932 | + if (isset($config_var['step'])) { |
|
933 | + $context['config_vars'][$config_var[0]]['step'] = $config_var['step']; |
|
934 | + } |
|
905 | 935 | } |
906 | 936 | |
907 | 937 | // If this is a select box handle any data. |
@@ -909,12 +939,13 @@ discard block |
||
909 | 939 | { |
910 | 940 | // If it's associative |
911 | 941 | $config_values = array_values($config_var[4]); |
912 | - if (isset($config_values[0]) && is_array($config_values[0])) |
|
913 | - $context['config_vars'][$config_var[0]]['data'] = $config_var[4]; |
|
914 | - else |
|
942 | + if (isset($config_values[0]) && is_array($config_values[0])) { |
|
943 | + $context['config_vars'][$config_var[0]]['data'] = $config_var[4]; |
|
944 | + } else |
|
915 | 945 | { |
916 | - foreach ($config_var[4] as $key => $item) |
|
917 | - $context['config_vars'][$config_var[0]]['data'][] = array($key, $item); |
|
946 | + foreach ($config_var[4] as $key => $item) { |
|
947 | + $context['config_vars'][$config_var[0]]['data'][] = array($key, $item); |
|
948 | + } |
|
918 | 949 | } |
919 | 950 | } |
920 | 951 | } |
@@ -939,10 +970,11 @@ discard block |
||
939 | 970 | |
940 | 971 | if (isset($_SESSION['adm-save'])) |
941 | 972 | { |
942 | - if ($_SESSION['adm-save'] === true) |
|
943 | - $context['saved_successful'] = true; |
|
944 | - else |
|
945 | - $context['saved_failed'] = $_SESSION['adm-save']; |
|
973 | + if ($_SESSION['adm-save'] === true) { |
|
974 | + $context['saved_successful'] = true; |
|
975 | + } else { |
|
976 | + $context['saved_failed'] = $_SESSION['adm-save']; |
|
977 | + } |
|
946 | 978 | |
947 | 979 | unset($_SESSION['adm-save']); |
948 | 980 | } |
@@ -954,26 +986,30 @@ discard block |
||
954 | 986 | foreach ($config_vars as $config_var) |
955 | 987 | { |
956 | 988 | // HR? |
957 | - if (!is_array($config_var)) |
|
958 | - $context['config_vars'][] = $config_var; |
|
959 | - else |
|
989 | + if (!is_array($config_var)) { |
|
990 | + $context['config_vars'][] = $config_var; |
|
991 | + } else |
|
960 | 992 | { |
961 | 993 | // If it has no name it doesn't have any purpose! |
962 | - if (empty($config_var[1])) |
|
963 | - continue; |
|
994 | + if (empty($config_var[1])) { |
|
995 | + continue; |
|
996 | + } |
|
964 | 997 | |
965 | 998 | // Special case for inline permissions |
966 | - if ($config_var[0] == 'permissions' && allowedTo('manage_permissions')) |
|
967 | - $inlinePermissions[] = $config_var[1]; |
|
968 | - elseif ($config_var[0] == 'permissions') |
|
969 | - continue; |
|
999 | + if ($config_var[0] == 'permissions' && allowedTo('manage_permissions')) { |
|
1000 | + $inlinePermissions[] = $config_var[1]; |
|
1001 | + } elseif ($config_var[0] == 'permissions') { |
|
1002 | + continue; |
|
1003 | + } |
|
970 | 1004 | |
971 | - if ($config_var[0] == 'boards') |
|
972 | - $board_list = true; |
|
1005 | + if ($config_var[0] == 'boards') { |
|
1006 | + $board_list = true; |
|
1007 | + } |
|
973 | 1008 | |
974 | 1009 | // Are we showing the BBC selection box? |
975 | - if ($config_var[0] == 'bbc') |
|
976 | - $bbcChoice[] = $config_var[1]; |
|
1010 | + if ($config_var[0] == 'bbc') { |
|
1011 | + $bbcChoice[] = $config_var[1]; |
|
1012 | + } |
|
977 | 1013 | |
978 | 1014 | // We need to do some parsing of the value before we pass it in. |
979 | 1015 | if (isset($modSettings[$config_var[1]])) |
@@ -992,8 +1028,7 @@ discard block |
||
992 | 1028 | default: |
993 | 1029 | $value = $smcFunc['htmlspecialchars']($modSettings[$config_var[1]]); |
994 | 1030 | } |
995 | - } |
|
996 | - else |
|
1031 | + } else |
|
997 | 1032 | { |
998 | 1033 | // Darn, it's empty. What type is expected? |
999 | 1034 | switch ($config_var[0]) |
@@ -1033,16 +1068,19 @@ discard block |
||
1033 | 1068 | if ($config_var[0] == 'int' || $config_var[0] == 'float') |
1034 | 1069 | { |
1035 | 1070 | // Default to a min of 0 if one isn't set |
1036 | - if (isset($config_var['min'])) |
|
1037 | - $context['config_vars'][$config_var[1]]['min'] = $config_var['min']; |
|
1038 | - else |
|
1039 | - $context['config_vars'][$config_var[1]]['min'] = 0; |
|
1071 | + if (isset($config_var['min'])) { |
|
1072 | + $context['config_vars'][$config_var[1]]['min'] = $config_var['min']; |
|
1073 | + } else { |
|
1074 | + $context['config_vars'][$config_var[1]]['min'] = 0; |
|
1075 | + } |
|
1040 | 1076 | |
1041 | - if (isset($config_var['max'])) |
|
1042 | - $context['config_vars'][$config_var[1]]['max'] = $config_var['max']; |
|
1077 | + if (isset($config_var['max'])) { |
|
1078 | + $context['config_vars'][$config_var[1]]['max'] = $config_var['max']; |
|
1079 | + } |
|
1043 | 1080 | |
1044 | - if (isset($config_var['step'])) |
|
1045 | - $context['config_vars'][$config_var[1]]['step'] = $config_var['step']; |
|
1081 | + if (isset($config_var['step'])) { |
|
1082 | + $context['config_vars'][$config_var[1]]['step'] = $config_var['step']; |
|
1083 | + } |
|
1046 | 1084 | } |
1047 | 1085 | |
1048 | 1086 | // If this is a select box handle any data. |
@@ -1056,12 +1094,13 @@ discard block |
||
1056 | 1094 | } |
1057 | 1095 | |
1058 | 1096 | // If it's associative |
1059 | - if (isset($config_var[2][0]) && is_array($config_var[2][0])) |
|
1060 | - $context['config_vars'][$config_var[1]]['data'] = $config_var[2]; |
|
1061 | - else |
|
1097 | + if (isset($config_var[2][0]) && is_array($config_var[2][0])) { |
|
1098 | + $context['config_vars'][$config_var[1]]['data'] = $config_var[2]; |
|
1099 | + } else |
|
1062 | 1100 | { |
1063 | - foreach ($config_var[2] as $key => $item) |
|
1064 | - $context['config_vars'][$config_var[1]]['data'][] = array($key, $item); |
|
1101 | + foreach ($config_var[2] as $key => $item) { |
|
1102 | + $context['config_vars'][$config_var[1]]['data'][] = array($key, $item); |
|
1103 | + } |
|
1065 | 1104 | } |
1066 | 1105 | } |
1067 | 1106 | |
@@ -1070,17 +1109,19 @@ discard block |
||
1070 | 1109 | { |
1071 | 1110 | if (!is_numeric($k)) |
1072 | 1111 | { |
1073 | - if (substr($k, 0, 2) == 'on') |
|
1074 | - $context['config_vars'][$config_var[1]]['javascript'] .= ' ' . $k . '="' . $v . '"'; |
|
1075 | - else |
|
1076 | - $context['config_vars'][$config_var[1]][$k] = $v; |
|
1112 | + if (substr($k, 0, 2) == 'on') { |
|
1113 | + $context['config_vars'][$config_var[1]]['javascript'] .= ' ' . $k . '="' . $v . '"'; |
|
1114 | + } else { |
|
1115 | + $context['config_vars'][$config_var[1]][$k] = $v; |
|
1116 | + } |
|
1077 | 1117 | } |
1078 | 1118 | |
1079 | 1119 | // See if there are any other labels that might fit? |
1080 | - if (isset($txt['setting_' . $config_var[1]])) |
|
1081 | - $context['config_vars'][$config_var[1]]['label'] = $txt['setting_' . $config_var[1]]; |
|
1082 | - elseif (isset($txt['groups_' . $config_var[1]])) |
|
1083 | - $context['config_vars'][$config_var[1]]['label'] = $txt['groups_' . $config_var[1]]; |
|
1120 | + if (isset($txt['setting_' . $config_var[1]])) { |
|
1121 | + $context['config_vars'][$config_var[1]]['label'] = $txt['setting_' . $config_var[1]]; |
|
1122 | + } elseif (isset($txt['groups_' . $config_var[1]])) { |
|
1123 | + $context['config_vars'][$config_var[1]]['label'] = $txt['groups_' . $config_var[1]]; |
|
1124 | + } |
|
1084 | 1125 | } |
1085 | 1126 | |
1086 | 1127 | // Set the subtext in case it's part of the label. |
@@ -1113,8 +1154,9 @@ discard block |
||
1113 | 1154 | // What are the options, eh? |
1114 | 1155 | $temp = parse_bbc(false); |
1115 | 1156 | $bbcTags = array(); |
1116 | - foreach ($temp as $tag) |
|
1117 | - $bbcTags[] = $tag['tag']; |
|
1157 | + foreach ($temp as $tag) { |
|
1158 | + $bbcTags[] = $tag['tag']; |
|
1159 | + } |
|
1118 | 1160 | |
1119 | 1161 | $bbcTags = array_unique($bbcTags); |
1120 | 1162 | $totalTags = count($bbcTags); |
@@ -1129,8 +1171,9 @@ discard block |
||
1129 | 1171 | $col = 0; $i = 0; |
1130 | 1172 | foreach ($bbcTags as $tag) |
1131 | 1173 | { |
1132 | - if ($i % $tagsPerColumn == 0 && $i != 0) |
|
1133 | - $col++; |
|
1174 | + if ($i % $tagsPerColumn == 0 && $i != 0) { |
|
1175 | + $col++; |
|
1176 | + } |
|
1134 | 1177 | |
1135 | 1178 | $context['bbc_columns'][$col][] = array( |
1136 | 1179 | 'tag' => $tag, |
@@ -1173,18 +1216,21 @@ discard block |
||
1173 | 1216 | validateToken('admin-ssc'); |
1174 | 1217 | |
1175 | 1218 | // Fix the darn stupid cookiename! (more may not be allowed, but these for sure!) |
1176 | - if (isset($_POST['cookiename'])) |
|
1177 | - $_POST['cookiename'] = preg_replace('~[,;\s\.$]+~' . ($context['utf8'] ? 'u' : ''), '', $_POST['cookiename']); |
|
1219 | + if (isset($_POST['cookiename'])) { |
|
1220 | + $_POST['cookiename'] = preg_replace('~[,;\s\.$]+~' . ($context['utf8'] ? 'u' : ''), '', $_POST['cookiename']); |
|
1221 | + } |
|
1178 | 1222 | |
1179 | 1223 | // Fix the forum's URL if necessary. |
1180 | 1224 | if (isset($_POST['boardurl'])) |
1181 | 1225 | { |
1182 | - if (substr($_POST['boardurl'], -10) == '/index.php') |
|
1183 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
1184 | - elseif (substr($_POST['boardurl'], -1) == '/') |
|
1185 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
1186 | - if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') |
|
1187 | - $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
1226 | + if (substr($_POST['boardurl'], -10) == '/index.php') { |
|
1227 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
1228 | + } elseif (substr($_POST['boardurl'], -1) == '/') { |
|
1229 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
1230 | + } |
|
1231 | + if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') { |
|
1232 | + $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
1233 | + } |
|
1188 | 1234 | } |
1189 | 1235 | |
1190 | 1236 | // Any passwords? |
@@ -1219,21 +1265,21 @@ discard block |
||
1219 | 1265 | // Figure out which config vars we're saving here... |
1220 | 1266 | foreach ($config_vars as $var) |
1221 | 1267 | { |
1222 | - if (!is_array($var) || $var[2] != 'file' || (!in_array($var[0], $config_bools) && !isset($_POST[$var[0]]))) |
|
1223 | - continue; |
|
1268 | + if (!is_array($var) || $var[2] != 'file' || (!in_array($var[0], $config_bools) && !isset($_POST[$var[0]]))) { |
|
1269 | + continue; |
|
1270 | + } |
|
1224 | 1271 | |
1225 | 1272 | $config_var = $var[0]; |
1226 | 1273 | |
1227 | 1274 | if (in_array($config_var, $config_passwords)) |
1228 | 1275 | { |
1229 | - if (isset($_POST[$config_var][1]) && $_POST[$config_var][0] == $_POST[$config_var][1]) |
|
1230 | - $new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var][0], '\'\\') . '\''; |
|
1231 | - } |
|
1232 | - elseif (in_array($config_var, $config_strs)) |
|
1276 | + if (isset($_POST[$config_var][1]) && $_POST[$config_var][0] == $_POST[$config_var][1]) { |
|
1277 | + $new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var][0], '\'\\') . '\''; |
|
1278 | + } |
|
1279 | + } elseif (in_array($config_var, $config_strs)) |
|
1233 | 1280 | { |
1234 | 1281 | $new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var], '\'\\') . '\''; |
1235 | - } |
|
1236 | - elseif (in_array($config_var, $config_ints)) |
|
1282 | + } elseif (in_array($config_var, $config_ints)) |
|
1237 | 1283 | { |
1238 | 1284 | $new_settings[$config_var] = (int) $_POST[$config_var]; |
1239 | 1285 | |
@@ -1242,17 +1288,17 @@ discard block |
||
1242 | 1288 | $new_settings[$config_var] = max($min, $new_settings[$config_var]); |
1243 | 1289 | |
1244 | 1290 | // Is there a max value for this as well? |
1245 | - if (isset($var['max'])) |
|
1246 | - $new_settings[$config_var] = min($var['max'], $new_settings[$config_var]); |
|
1247 | - } |
|
1248 | - elseif (in_array($config_var, $config_bools)) |
|
1291 | + if (isset($var['max'])) { |
|
1292 | + $new_settings[$config_var] = min($var['max'], $new_settings[$config_var]); |
|
1293 | + } |
|
1294 | + } elseif (in_array($config_var, $config_bools)) |
|
1249 | 1295 | { |
1250 | - if (!empty($_POST[$config_var])) |
|
1251 | - $new_settings[$config_var] = '1'; |
|
1252 | - else |
|
1253 | - $new_settings[$config_var] = '0'; |
|
1254 | - } |
|
1255 | - else |
|
1296 | + if (!empty($_POST[$config_var])) { |
|
1297 | + $new_settings[$config_var] = '1'; |
|
1298 | + } else { |
|
1299 | + $new_settings[$config_var] = '0'; |
|
1300 | + } |
|
1301 | + } else |
|
1256 | 1302 | { |
1257 | 1303 | // This shouldn't happen, but it might... |
1258 | 1304 | fatal_error('Unknown config_var \'' . $config_var . '\''); |
@@ -1268,30 +1314,35 @@ discard block |
||
1268 | 1314 | foreach ($config_vars as $config_var) |
1269 | 1315 | { |
1270 | 1316 | // We just saved the file-based settings, so skip their definitions. |
1271 | - if (!is_array($config_var) || $config_var[2] == 'file') |
|
1272 | - continue; |
|
1317 | + if (!is_array($config_var) || $config_var[2] == 'file') { |
|
1318 | + continue; |
|
1319 | + } |
|
1273 | 1320 | |
1274 | 1321 | $new_setting = array($config_var[3], $config_var[0]); |
1275 | 1322 | |
1276 | 1323 | // Select options need carried over, too. |
1277 | - if (isset($config_var[4])) |
|
1278 | - $new_setting[] = $config_var[4]; |
|
1324 | + if (isset($config_var[4])) { |
|
1325 | + $new_setting[] = $config_var[4]; |
|
1326 | + } |
|
1279 | 1327 | |
1280 | 1328 | // Include min and max if necessary |
1281 | - if (isset($config_var['min'])) |
|
1282 | - $new_setting['min'] = $config_var['min']; |
|
1329 | + if (isset($config_var['min'])) { |
|
1330 | + $new_setting['min'] = $config_var['min']; |
|
1331 | + } |
|
1283 | 1332 | |
1284 | - if (isset($config_var['max'])) |
|
1285 | - $new_setting['max'] = $config_var['max']; |
|
1333 | + if (isset($config_var['max'])) { |
|
1334 | + $new_setting['max'] = $config_var['max']; |
|
1335 | + } |
|
1286 | 1336 | |
1287 | 1337 | // Rewrite the definition a bit. |
1288 | 1338 | $new_settings[] = $new_setting; |
1289 | 1339 | } |
1290 | 1340 | |
1291 | 1341 | // Save the new database-based settings, if any. |
1292 | - if (!empty($new_settings)) |
|
1293 | - saveDBSettings($new_settings); |
|
1294 | -} |
|
1342 | + if (!empty($new_settings)) { |
|
1343 | + saveDBSettings($new_settings); |
|
1344 | + } |
|
1345 | + } |
|
1295 | 1346 | |
1296 | 1347 | /** |
1297 | 1348 | * Helper function for saving database settings. |
@@ -1309,22 +1360,25 @@ discard block |
||
1309 | 1360 | $inlinePermissions = array(); |
1310 | 1361 | foreach ($config_vars as $var) |
1311 | 1362 | { |
1312 | - if (!isset($var[1]) || (!isset($_POST[$var[1]]) && $var[0] != 'check' && $var[0] != 'permissions' && $var[0] != 'boards' && ($var[0] != 'bbc' || !isset($_POST[$var[1] . '_enabledTags'])))) |
|
1313 | - continue; |
|
1363 | + if (!isset($var[1]) || (!isset($_POST[$var[1]]) && $var[0] != 'check' && $var[0] != 'permissions' && $var[0] != 'boards' && ($var[0] != 'bbc' || !isset($_POST[$var[1] . '_enabledTags'])))) { |
|
1364 | + continue; |
|
1365 | + } |
|
1314 | 1366 | |
1315 | 1367 | // Checkboxes! |
1316 | - elseif ($var[0] == 'check') |
|
1317 | - $setArray[$var[1]] = !empty($_POST[$var[1]]) ? '1' : '0'; |
|
1368 | + elseif ($var[0] == 'check') { |
|
1369 | + $setArray[$var[1]] = !empty($_POST[$var[1]]) ? '1' : '0'; |
|
1370 | + } |
|
1318 | 1371 | // Select boxes! |
1319 | - elseif ($var[0] == 'select' && in_array($_POST[$var[1]], array_keys($var[2]))) |
|
1320 | - $setArray[$var[1]] = $_POST[$var[1]]; |
|
1321 | - elseif ($var[0] == 'select' && !empty($var['multiple']) && array_intersect($_POST[$var[1]], array_keys($var[2])) != array()) |
|
1372 | + elseif ($var[0] == 'select' && in_array($_POST[$var[1]], array_keys($var[2]))) { |
|
1373 | + $setArray[$var[1]] = $_POST[$var[1]]; |
|
1374 | + } elseif ($var[0] == 'select' && !empty($var['multiple']) && array_intersect($_POST[$var[1]], array_keys($var[2])) != array()) |
|
1322 | 1375 | { |
1323 | 1376 | // For security purposes we validate this line by line. |
1324 | 1377 | $lOptions = array(); |
1325 | - foreach ($_POST[$var[1]] as $invar) |
|
1326 | - if (in_array($invar, array_keys($var[2]))) |
|
1378 | + foreach ($_POST[$var[1]] as $invar) { |
|
1379 | + if (in_array($invar, array_keys($var[2]))) |
|
1327 | 1380 | $lOptions[] = $invar; |
1381 | + } |
|
1328 | 1382 | |
1329 | 1383 | $setArray[$var[1]] = $smcFunc['json_encode']($lOptions); |
1330 | 1384 | } |
@@ -1338,18 +1392,20 @@ discard block |
||
1338 | 1392 | $request = $smcFunc['db_query']('', ' |
1339 | 1393 | SELECT id_board |
1340 | 1394 | FROM {db_prefix}boards'); |
1341 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
1342 | - $board_list[$row[0]] = true; |
|
1395 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
1396 | + $board_list[$row[0]] = true; |
|
1397 | + } |
|
1343 | 1398 | |
1344 | 1399 | $smcFunc['db_free_result']($request); |
1345 | 1400 | } |
1346 | 1401 | |
1347 | 1402 | $lOptions = array(); |
1348 | 1403 | |
1349 | - if (!empty($_POST[$var[1]])) |
|
1350 | - foreach ($_POST[$var[1]] as $invar => $dummy) |
|
1404 | + if (!empty($_POST[$var[1]])) { |
|
1405 | + foreach ($_POST[$var[1]] as $invar => $dummy) |
|
1351 | 1406 | if (isset($board_list[$invar])) |
1352 | 1407 | $lOptions[] = $invar; |
1408 | + } |
|
1353 | 1409 | |
1354 | 1410 | $setArray[$var[1]] = !empty($lOptions) ? implode(',', $lOptions) : ''; |
1355 | 1411 | } |
@@ -1363,8 +1419,9 @@ discard block |
||
1363 | 1419 | $setArray[$var[1]] = max($min, $setArray[$var[1]]); |
1364 | 1420 | |
1365 | 1421 | // Do we have a max value for this as well? |
1366 | - if (isset($var['max'])) |
|
1367 | - $setArray[$var[1]] = min($var['max'], $setArray[$var[1]]); |
|
1422 | + if (isset($var['max'])) { |
|
1423 | + $setArray[$var[1]] = min($var['max'], $setArray[$var[1]]); |
|
1424 | + } |
|
1368 | 1425 | } |
1369 | 1426 | // Floating point! |
1370 | 1427 | elseif ($var[0] == 'float') |
@@ -1376,40 +1433,47 @@ discard block |
||
1376 | 1433 | $setArray[$var[1]] = max($min, $setArray[$var[1]]); |
1377 | 1434 | |
1378 | 1435 | // Do we have a max value for this as well? |
1379 | - if (isset($var['max'])) |
|
1380 | - $setArray[$var[1]] = min($var['max'], $setArray[$var[1]]); |
|
1436 | + if (isset($var['max'])) { |
|
1437 | + $setArray[$var[1]] = min($var['max'], $setArray[$var[1]]); |
|
1438 | + } |
|
1381 | 1439 | } |
1382 | 1440 | // Text! |
1383 | - elseif (in_array($var[0], array('text', 'large_text', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time'))) |
|
1384 | - $setArray[$var[1]] = $_POST[$var[1]]; |
|
1441 | + elseif (in_array($var[0], array('text', 'large_text', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time'))) { |
|
1442 | + $setArray[$var[1]] = $_POST[$var[1]]; |
|
1443 | + } |
|
1385 | 1444 | // Passwords! |
1386 | 1445 | elseif ($var[0] == 'password') |
1387 | 1446 | { |
1388 | - if (isset($_POST[$var[1]][1]) && $_POST[$var[1]][0] == $_POST[$var[1]][1]) |
|
1389 | - $setArray[$var[1]] = $_POST[$var[1]][0]; |
|
1447 | + if (isset($_POST[$var[1]][1]) && $_POST[$var[1]][0] == $_POST[$var[1]][1]) { |
|
1448 | + $setArray[$var[1]] = $_POST[$var[1]][0]; |
|
1449 | + } |
|
1390 | 1450 | } |
1391 | 1451 | // BBC. |
1392 | 1452 | elseif ($var[0] == 'bbc') |
1393 | 1453 | { |
1394 | 1454 | |
1395 | 1455 | $bbcTags = array(); |
1396 | - foreach (parse_bbc(false) as $tag) |
|
1397 | - $bbcTags[] = $tag['tag']; |
|
1456 | + foreach (parse_bbc(false) as $tag) { |
|
1457 | + $bbcTags[] = $tag['tag']; |
|
1458 | + } |
|
1398 | 1459 | |
1399 | - if (!isset($_POST[$var[1] . '_enabledTags'])) |
|
1400 | - $_POST[$var[1] . '_enabledTags'] = array(); |
|
1401 | - elseif (!is_array($_POST[$var[1] . '_enabledTags'])) |
|
1402 | - $_POST[$var[1] . '_enabledTags'] = array($_POST[$var[1] . '_enabledTags']); |
|
1460 | + if (!isset($_POST[$var[1] . '_enabledTags'])) { |
|
1461 | + $_POST[$var[1] . '_enabledTags'] = array(); |
|
1462 | + } elseif (!is_array($_POST[$var[1] . '_enabledTags'])) { |
|
1463 | + $_POST[$var[1] . '_enabledTags'] = array($_POST[$var[1] . '_enabledTags']); |
|
1464 | + } |
|
1403 | 1465 | |
1404 | 1466 | $setArray[$var[1]] = implode(',', array_diff($bbcTags, $_POST[$var[1] . '_enabledTags'])); |
1405 | 1467 | } |
1406 | 1468 | // Permissions? |
1407 | - elseif ($var[0] == 'permissions') |
|
1408 | - $inlinePermissions[] = $var[1]; |
|
1469 | + elseif ($var[0] == 'permissions') { |
|
1470 | + $inlinePermissions[] = $var[1]; |
|
1471 | + } |
|
1409 | 1472 | } |
1410 | 1473 | |
1411 | - if (!empty($setArray)) |
|
1412 | - updateSettings($setArray); |
|
1474 | + if (!empty($setArray)) { |
|
1475 | + updateSettings($setArray); |
|
1476 | + } |
|
1413 | 1477 | |
1414 | 1478 | // If we have inline permissions we need to save them. |
1415 | 1479 | if (!empty($inlinePermissions) && allowedTo('manage_permissions')) |
@@ -1446,18 +1510,21 @@ discard block |
||
1446 | 1510 | // put all of it into an array |
1447 | 1511 | foreach ($info_lines as $line) |
1448 | 1512 | { |
1449 | - if (preg_match('~(' . $remove . ')~', $line)) |
|
1450 | - continue; |
|
1513 | + if (preg_match('~(' . $remove . ')~', $line)) { |
|
1514 | + continue; |
|
1515 | + } |
|
1451 | 1516 | |
1452 | 1517 | // new category? |
1453 | - if (strpos($line, '<h2>') !== false) |
|
1454 | - $category = preg_match('~<h2>(.*)</h2>~', $line, $title) ? $category = $title[1] : $category; |
|
1518 | + if (strpos($line, '<h2>') !== false) { |
|
1519 | + $category = preg_match('~<h2>(.*)</h2>~', $line, $title) ? $category = $title[1] : $category; |
|
1520 | + } |
|
1455 | 1521 | |
1456 | 1522 | // load it as setting => value or the old setting local master |
1457 | - if (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) |
|
1458 | - $pinfo[$category][$val[1]] = $val[2]; |
|
1459 | - elseif (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) |
|
1460 | - $pinfo[$category][$val[1]] = array($txt['phpinfo_localsettings'] => $val[2], $txt['phpinfo_defaultsettings'] => $val[3]); |
|
1523 | + if (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) { |
|
1524 | + $pinfo[$category][$val[1]] = $val[2]; |
|
1525 | + } elseif (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) { |
|
1526 | + $pinfo[$category][$val[1]] = array($txt['phpinfo_localsettings'] => $val[2], $txt['phpinfo_defaultsettings'] => $val[3]); |
|
1527 | + } |
|
1461 | 1528 | } |
1462 | 1529 | |
1463 | 1530 | // load it in to context and display it |
@@ -1492,8 +1559,9 @@ discard block |
||
1492 | 1559 | $testAPI = new $cache_class_name(); |
1493 | 1560 | |
1494 | 1561 | // No Support? NEXT! |
1495 | - if (!$testAPI->isSupported(true)) |
|
1496 | - continue; |
|
1562 | + if (!$testAPI->isSupported(true)) { |
|
1563 | + continue; |
|
1564 | + } |
|
1497 | 1565 | |
1498 | 1566 | $apis[$tryCache] = isset($txt[$tryCache . '_cache']) ? $txt[$tryCache . '_cache'] : $tryCache; |
1499 | 1567 | } |
@@ -1518,8 +1586,9 @@ discard block |
||
1518 | 1586 | global $modSettings, $boardurl, $smcFunc; |
1519 | 1587 | |
1520 | 1588 | // Already have a key? Can't register again. |
1521 | - if (!empty($modSettings['sm_stats_key'])) |
|
1522 | - return true; |
|
1589 | + if (!empty($modSettings['sm_stats_key'])) { |
|
1590 | + return true; |
|
1591 | + } |
|
1523 | 1592 | |
1524 | 1593 | $fp = @fsockopen('www.simplemachines.org', 80, $errno, $errstr); |
1525 | 1594 | if ($fp) |
@@ -1530,8 +1599,9 @@ discard block |
||
1530 | 1599 | fwrite($fp, $out); |
1531 | 1600 | |
1532 | 1601 | $return_data = ''; |
1533 | - while (!feof($fp)) |
|
1534 | - $return_data .= fgets($fp, 128); |
|
1602 | + while (!feof($fp)) { |
|
1603 | + $return_data .= fgets($fp, 128); |
|
1604 | + } |
|
1535 | 1605 | |
1536 | 1606 | fclose($fp); |
1537 | 1607 |
@@ -20,8 +20,9 @@ discard block |
||
20 | 20 | // ><html dir="ltr"><head><title>Error!</title></head><body>Sorry, this installer requires PHP!<div style="display: none;"> |
21 | 21 | |
22 | 22 | // Let's pull in useful classes |
23 | -if (!defined('SMF')) |
|
23 | +if (!defined('SMF')) { |
|
24 | 24 | define('SMF', 1); |
25 | +} |
|
25 | 26 | |
26 | 27 | require_once('Sources/Class-Package.php'); |
27 | 28 | |
@@ -63,10 +64,11 @@ discard block |
||
63 | 64 | |
64 | 65 | list ($charcode) = pg_fetch_row($request); |
65 | 66 | |
66 | - if ($charcode == 'UTF8') |
|
67 | - return true; |
|
68 | - else |
|
69 | - return false; |
|
67 | + if ($charcode == 'UTF8') { |
|
68 | + return true; |
|
69 | + } else { |
|
70 | + return false; |
|
71 | + } |
|
70 | 72 | }, |
71 | 73 | 'utf8_version' => '8.0', |
72 | 74 | 'utf8_version_check' => '$request = pg_query(\'SELECT version()\'); list ($version) = pg_fetch_row($request); list($pgl, $version) = explode(" ", $version); return $version;', |
@@ -76,12 +78,14 @@ discard block |
||
76 | 78 | $value = preg_replace('~[^A-Za-z0-9_\$]~', '', $value); |
77 | 79 | |
78 | 80 | // Is it reserved? |
79 | - if ($value == 'pg_') |
|
80 | - return $txt['error_db_prefix_reserved']; |
|
81 | + if ($value == 'pg_') { |
|
82 | + return $txt['error_db_prefix_reserved']; |
|
83 | + } |
|
81 | 84 | |
82 | 85 | // Is the prefix numeric? |
83 | - if (preg_match('~^\d~', $value)) |
|
84 | - return $txt['error_db_prefix_numeric']; |
|
86 | + if (preg_match('~^\d~', $value)) { |
|
87 | + return $txt['error_db_prefix_numeric']; |
|
88 | + } |
|
85 | 89 | |
86 | 90 | return true; |
87 | 91 | }, |
@@ -128,10 +132,11 @@ discard block |
||
128 | 132 | $incontext['skip'] = false; |
129 | 133 | |
130 | 134 | // Call the step and if it returns false that means pause! |
131 | - if (function_exists($step[2]) && $step[2]() === false) |
|
132 | - break; |
|
133 | - elseif (function_exists($step[2])) |
|
134 | - $incontext['current_step']++; |
|
135 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
136 | + break; |
|
137 | + } elseif (function_exists($step[2])) { |
|
138 | + $incontext['current_step']++; |
|
139 | + } |
|
135 | 140 | |
136 | 141 | // No warnings pass on. |
137 | 142 | $incontext['warning'] = ''; |
@@ -147,8 +152,9 @@ discard block |
||
147 | 152 | global $databases; |
148 | 153 | |
149 | 154 | // Just so people using older versions of PHP aren't left in the cold. |
150 | - if (!isset($_SERVER['PHP_SELF'])) |
|
151 | - $_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php'; |
|
155 | + if (!isset($_SERVER['PHP_SELF'])) { |
|
156 | + $_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php'; |
|
157 | + } |
|
152 | 158 | |
153 | 159 | // Enable error reporting for fatal errors. |
154 | 160 | error_reporting(E_ERROR | E_PARSE); |
@@ -164,21 +170,23 @@ discard block |
||
164 | 170 | { |
165 | 171 | ob_start(); |
166 | 172 | |
167 | - if (ini_get('session.save_handler') == 'user') |
|
168 | - @ini_set('session.save_handler', 'files'); |
|
169 | - if (function_exists('session_start')) |
|
170 | - @session_start(); |
|
171 | - } |
|
172 | - else |
|
173 | + if (ini_get('session.save_handler') == 'user') { |
|
174 | + @ini_set('session.save_handler', 'files'); |
|
175 | + } |
|
176 | + if (function_exists('session_start')) { |
|
177 | + @session_start(); |
|
178 | + } |
|
179 | + } else |
|
173 | 180 | { |
174 | 181 | ob_start('ob_gzhandler'); |
175 | 182 | |
176 | - if (ini_get('session.save_handler') == 'user') |
|
177 | - @ini_set('session.save_handler', 'files'); |
|
183 | + if (ini_get('session.save_handler') == 'user') { |
|
184 | + @ini_set('session.save_handler', 'files'); |
|
185 | + } |
|
178 | 186 | session_start(); |
179 | 187 | |
180 | - if (!headers_sent()) |
|
181 | - echo '<!DOCTYPE html> |
|
188 | + if (!headers_sent()) { |
|
189 | + echo '<!DOCTYPE html> |
|
182 | 190 | <html> |
183 | 191 | <head> |
184 | 192 | <title>', htmlspecialchars($_GET['pass_string']), '</title> |
@@ -187,14 +195,16 @@ discard block |
||
187 | 195 | <strong>', htmlspecialchars($_GET['pass_string']), '</strong> |
188 | 196 | </body> |
189 | 197 | </html>'; |
198 | + } |
|
190 | 199 | exit; |
191 | 200 | } |
192 | 201 | |
193 | 202 | // Add slashes, as long as they aren't already being added. |
194 | - if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) |
|
195 | - foreach ($_POST as $k => $v) |
|
203 | + if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) { |
|
204 | + foreach ($_POST as $k => $v) |
|
196 | 205 | if (strpos($k, 'password') === false && strpos($k, 'db_passwd') === false) |
197 | 206 | $_POST[$k] = addslashes($v); |
207 | + } |
|
198 | 208 | |
199 | 209 | // This is really quite simple; if ?delete is on the URL, delete the installer... |
200 | 210 | if (isset($_GET['delete'])) |
@@ -215,8 +225,7 @@ discard block |
||
215 | 225 | $ftp->close(); |
216 | 226 | |
217 | 227 | unset($_SESSION['installer_temp_ftp']); |
218 | - } |
|
219 | - else |
|
228 | + } else |
|
220 | 229 | { |
221 | 230 | @unlink(__FILE__); |
222 | 231 | |
@@ -237,10 +246,11 @@ discard block |
||
237 | 246 | { |
238 | 247 | // Get PHP's default timezone, if set |
239 | 248 | $ini_tz = ini_get('date.timezone'); |
240 | - if (!empty($ini_tz)) |
|
241 | - $timezone_id = $ini_tz; |
|
242 | - else |
|
243 | - $timezone_id = ''; |
|
249 | + if (!empty($ini_tz)) { |
|
250 | + $timezone_id = $ini_tz; |
|
251 | + } else { |
|
252 | + $timezone_id = ''; |
|
253 | + } |
|
244 | 254 | |
245 | 255 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
246 | 256 | if (!in_array($timezone_id, timezone_identifiers_list())) |
@@ -270,8 +280,9 @@ discard block |
||
270 | 280 | $dir = dir(dirname(__FILE__) . '/Themes/default/languages'); |
271 | 281 | while ($entry = $dir->read()) |
272 | 282 | { |
273 | - if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') |
|
274 | - $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
283 | + if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') { |
|
284 | + $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
285 | + } |
|
275 | 286 | } |
276 | 287 | $dir->close(); |
277 | 288 | } |
@@ -306,10 +317,11 @@ discard block |
||
306 | 317 | } |
307 | 318 | |
308 | 319 | // Override the language file? |
309 | - if (isset($_GET['lang_file'])) |
|
310 | - $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
311 | - elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) |
|
312 | - $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
320 | + if (isset($_GET['lang_file'])) { |
|
321 | + $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
322 | + } elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) { |
|
323 | + $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
324 | + } |
|
313 | 325 | |
314 | 326 | // Make sure it exists, if it doesn't reset it. |
315 | 327 | if (!isset($_SESSION['installer_temp_lang']) || preg_match('~[^\\w_\\-.]~', $_SESSION['installer_temp_lang']) === 1 || !file_exists(dirname(__FILE__) . '/Themes/default/languages/' . $_SESSION['installer_temp_lang'])) |
@@ -318,8 +330,9 @@ discard block |
||
318 | 330 | list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
319 | 331 | |
320 | 332 | // If we have english and some other language, use the other language. We Americans hate english :P. |
321 | - if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) |
|
322 | - list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
333 | + if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) { |
|
334 | + list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
335 | + } |
|
323 | 336 | } |
324 | 337 | |
325 | 338 | // And now include the actual language file itself. |
@@ -332,15 +345,18 @@ discard block |
||
332 | 345 | global $db_prefix, $db_connection, $sourcedir, $smcFunc, $modSettings; |
333 | 346 | global $db_server, $db_passwd, $db_type, $db_name, $db_user, $db_persist; |
334 | 347 | |
335 | - if (empty($sourcedir)) |
|
336 | - $sourcedir = dirname(__FILE__) . '/Sources'; |
|
348 | + if (empty($sourcedir)) { |
|
349 | + $sourcedir = dirname(__FILE__) . '/Sources'; |
|
350 | + } |
|
337 | 351 | |
338 | 352 | // Need this to check whether we need the database password. |
339 | 353 | require(dirname(__FILE__) . '/Settings.php'); |
340 | - if (!defined('SMF')) |
|
341 | - define('SMF', 1); |
|
342 | - if (empty($smcFunc)) |
|
343 | - $smcFunc = array(); |
|
354 | + if (!defined('SMF')) { |
|
355 | + define('SMF', 1); |
|
356 | + } |
|
357 | + if (empty($smcFunc)) { |
|
358 | + $smcFunc = array(); |
|
359 | + } |
|
344 | 360 | |
345 | 361 | $modSettings['disableQueryCheck'] = true; |
346 | 362 | |
@@ -348,8 +364,9 @@ discard block |
||
348 | 364 | if (!$db_connection) |
349 | 365 | { |
350 | 366 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
351 | - if (version_compare(PHP_VERSION, '5', '<')) |
|
352 | - require_once($sourcedir . '/Subs-Compat.php'); |
|
367 | + if (version_compare(PHP_VERSION, '5', '<')) { |
|
368 | + require_once($sourcedir . '/Subs-Compat.php'); |
|
369 | + } |
|
353 | 370 | |
354 | 371 | $db_options = array('persist' => $db_persist); |
355 | 372 | $port = ''; |
@@ -360,19 +377,20 @@ discard block |
||
360 | 377 | if ($db_type == 'mysql') |
361 | 378 | { |
362 | 379 | $port = ((int) $_POST['db_port'] == ini_get($db_type . 'default_port')) ? '' : (int) $_POST['db_port']; |
363 | - } |
|
364 | - elseif ($db_type == 'postgresql') |
|
380 | + } elseif ($db_type == 'postgresql') |
|
365 | 381 | { |
366 | 382 | // PostgreSQL doesn't have a default port setting in php.ini, so just check against the default |
367 | 383 | $port = ((int) $_POST['db_port'] == 5432) ? '' : (int) $_POST['db_port']; |
368 | 384 | } |
369 | 385 | } |
370 | 386 | |
371 | - if (!empty($port)) |
|
372 | - $db_options['port'] = $port; |
|
387 | + if (!empty($port)) { |
|
388 | + $db_options['port'] = $port; |
|
389 | + } |
|
373 | 390 | |
374 | - if (!$db_connection) |
|
375 | - $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options); |
|
391 | + if (!$db_connection) { |
|
392 | + $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options); |
|
393 | + } |
|
376 | 394 | } |
377 | 395 | } |
378 | 396 | |
@@ -400,8 +418,9 @@ discard block |
||
400 | 418 | // @todo REMOVE THIS!! |
401 | 419 | else |
402 | 420 | { |
403 | - if (function_exists('doStep' . $_GET['step'])) |
|
404 | - call_user_func('doStep' . $_GET['step']); |
|
421 | + if (function_exists('doStep' . $_GET['step'])) { |
|
422 | + call_user_func('doStep' . $_GET['step']); |
|
423 | + } |
|
405 | 424 | } |
406 | 425 | // Show the footer. |
407 | 426 | template_install_below(); |
@@ -419,8 +438,9 @@ discard block |
||
419 | 438 | $incontext['sub_template'] = 'welcome_message'; |
420 | 439 | |
421 | 440 | // Done the submission? |
422 | - if (isset($_POST['contbutt'])) |
|
423 | - return true; |
|
441 | + if (isset($_POST['contbutt'])) { |
|
442 | + return true; |
|
443 | + } |
|
424 | 444 | |
425 | 445 | // See if we think they have already installed it? |
426 | 446 | if (is_readable(dirname(__FILE__) . '/Settings.php')) |
@@ -428,14 +448,17 @@ discard block |
||
428 | 448 | $probably_installed = 0; |
429 | 449 | foreach (file(dirname(__FILE__) . '/Settings.php') as $line) |
430 | 450 | { |
431 | - if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) |
|
432 | - $probably_installed++; |
|
433 | - if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) |
|
434 | - $probably_installed++; |
|
451 | + if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) { |
|
452 | + $probably_installed++; |
|
453 | + } |
|
454 | + if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) { |
|
455 | + $probably_installed++; |
|
456 | + } |
|
435 | 457 | } |
436 | 458 | |
437 | - if ($probably_installed == 2) |
|
438 | - $incontext['warning'] = $txt['error_already_installed']; |
|
459 | + if ($probably_installed == 2) { |
|
460 | + $incontext['warning'] = $txt['error_already_installed']; |
|
461 | + } |
|
439 | 462 | } |
440 | 463 | |
441 | 464 | // Is some database support even compiled in? |
@@ -450,45 +473,54 @@ discard block |
||
450 | 473 | $databases[$key]['supported'] = false; |
451 | 474 | $notFoundSQLFile = true; |
452 | 475 | $txt['error_db_script_missing'] = sprintf($txt['error_db_script_missing'], 'install_' . $GLOBALS['db_script_version'] . '_' . $type . '.sql'); |
476 | + } else { |
|
477 | + $incontext['supported_databases'][] = $db; |
|
453 | 478 | } |
454 | - else |
|
455 | - $incontext['supported_databases'][] = $db; |
|
456 | 479 | } |
457 | 480 | } |
458 | 481 | |
459 | 482 | // Check the PHP version. |
460 | - if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>='))) |
|
461 | - $error = 'error_php_too_low'; |
|
483 | + if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>='))) { |
|
484 | + $error = 'error_php_too_low'; |
|
485 | + } |
|
462 | 486 | // Make sure we have a supported database |
463 | - elseif (empty($incontext['supported_databases'])) |
|
464 | - $error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing'; |
|
487 | + elseif (empty($incontext['supported_databases'])) { |
|
488 | + $error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing'; |
|
489 | + } |
|
465 | 490 | // How about session support? Some crazy sysadmin remove it? |
466 | - elseif (!function_exists('session_start')) |
|
467 | - $error = 'error_session_missing'; |
|
491 | + elseif (!function_exists('session_start')) { |
|
492 | + $error = 'error_session_missing'; |
|
493 | + } |
|
468 | 494 | // Make sure they uploaded all the files. |
469 | - elseif (!file_exists(dirname(__FILE__) . '/index.php')) |
|
470 | - $error = 'error_missing_files'; |
|
495 | + elseif (!file_exists(dirname(__FILE__) . '/index.php')) { |
|
496 | + $error = 'error_missing_files'; |
|
497 | + } |
|
471 | 498 | // Very simple check on the session.save_path for Windows. |
472 | 499 | // @todo Move this down later if they don't use database-driven sessions? |
473 | - elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') |
|
474 | - $error = 'error_session_save_path'; |
|
500 | + elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') { |
|
501 | + $error = 'error_session_save_path'; |
|
502 | + } |
|
475 | 503 | |
476 | 504 | // Since each of the three messages would look the same, anyway... |
477 | - if (isset($error)) |
|
478 | - $incontext['error'] = $txt[$error]; |
|
505 | + if (isset($error)) { |
|
506 | + $incontext['error'] = $txt[$error]; |
|
507 | + } |
|
479 | 508 | |
480 | 509 | // Mod_security blocks everything that smells funny. Let SMF handle security. |
481 | - if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) |
|
482 | - $incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again']; |
|
510 | + if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) { |
|
511 | + $incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again']; |
|
512 | + } |
|
483 | 513 | |
484 | 514 | // Confirm mbstring is loaded... |
485 | - if (!extension_loaded('mbstring')) |
|
486 | - $incontext['error'] = $txt['install_no_mbstring']; |
|
515 | + if (!extension_loaded('mbstring')) { |
|
516 | + $incontext['error'] = $txt['install_no_mbstring']; |
|
517 | + } |
|
487 | 518 | |
488 | 519 | // Check for https stream support. |
489 | 520 | $supported_streams = stream_get_wrappers(); |
490 | - if (!in_array('https', $supported_streams)) |
|
491 | - $incontext['warning'] = $txt['install_no_https']; |
|
521 | + if (!in_array('https', $supported_streams)) { |
|
522 | + $incontext['warning'] = $txt['install_no_https']; |
|
523 | + } |
|
492 | 524 | |
493 | 525 | return false; |
494 | 526 | } |
@@ -514,12 +546,14 @@ discard block |
||
514 | 546 | 'db_last_error.php', |
515 | 547 | ); |
516 | 548 | |
517 | - foreach ($incontext['detected_languages'] as $lang => $temp) |
|
518 | - $extra_files[] = 'Themes/default/languages/' . $lang; |
|
549 | + foreach ($incontext['detected_languages'] as $lang => $temp) { |
|
550 | + $extra_files[] = 'Themes/default/languages/' . $lang; |
|
551 | + } |
|
519 | 552 | |
520 | 553 | // With mod_security installed, we could attempt to fix it with .htaccess. |
521 | - if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) |
|
522 | - $writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.'; |
|
554 | + if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) { |
|
555 | + $writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.'; |
|
556 | + } |
|
523 | 557 | |
524 | 558 | $failed_files = array(); |
525 | 559 | |
@@ -531,20 +565,23 @@ discard block |
||
531 | 565 | foreach ($writable_files as $file) |
532 | 566 | { |
533 | 567 | // Some files won't exist, try to address up front |
534 | - if (!file_exists(dirname(__FILE__) . '/' . $file)) |
|
535 | - @touch(dirname(__FILE__) . '/' . $file); |
|
568 | + if (!file_exists(dirname(__FILE__) . '/' . $file)) { |
|
569 | + @touch(dirname(__FILE__) . '/' . $file); |
|
570 | + } |
|
536 | 571 | // NOW do the writable check... |
537 | 572 | if (!is_writable(dirname(__FILE__) . '/' . $file)) |
538 | 573 | { |
539 | 574 | @chmod(dirname(__FILE__) . '/' . $file, 0755); |
540 | 575 | |
541 | 576 | // Well, 755 hopefully worked... if not, try 777. |
542 | - if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) |
|
543 | - $failed_files[] = $file; |
|
577 | + if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) { |
|
578 | + $failed_files[] = $file; |
|
579 | + } |
|
544 | 580 | } |
545 | 581 | } |
546 | - foreach ($extra_files as $file) |
|
547 | - @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
582 | + foreach ($extra_files as $file) { |
|
583 | + @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
584 | + } |
|
548 | 585 | } |
549 | 586 | // Windows is trickier. Let's try opening for r+... |
550 | 587 | else |
@@ -554,30 +591,35 @@ discard block |
||
554 | 591 | foreach ($writable_files as $file) |
555 | 592 | { |
556 | 593 | // Folders can't be opened for write... but the index.php in them can ;) |
557 | - if (is_dir(dirname(__FILE__) . '/' . $file)) |
|
558 | - $file .= '/index.php'; |
|
594 | + if (is_dir(dirname(__FILE__) . '/' . $file)) { |
|
595 | + $file .= '/index.php'; |
|
596 | + } |
|
559 | 597 | |
560 | 598 | // Funny enough, chmod actually does do something on windows - it removes the read only attribute. |
561 | 599 | @chmod(dirname(__FILE__) . '/' . $file, 0777); |
562 | 600 | $fp = @fopen(dirname(__FILE__) . '/' . $file, 'r+'); |
563 | 601 | |
564 | 602 | // Hmm, okay, try just for write in that case... |
565 | - if (!is_resource($fp)) |
|
566 | - $fp = @fopen(dirname(__FILE__) . '/' . $file, 'w'); |
|
603 | + if (!is_resource($fp)) { |
|
604 | + $fp = @fopen(dirname(__FILE__) . '/' . $file, 'w'); |
|
605 | + } |
|
567 | 606 | |
568 | - if (!is_resource($fp)) |
|
569 | - $failed_files[] = $file; |
|
607 | + if (!is_resource($fp)) { |
|
608 | + $failed_files[] = $file; |
|
609 | + } |
|
570 | 610 | |
571 | 611 | @fclose($fp); |
572 | 612 | } |
573 | - foreach ($extra_files as $file) |
|
574 | - @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
613 | + foreach ($extra_files as $file) { |
|
614 | + @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
615 | + } |
|
575 | 616 | } |
576 | 617 | |
577 | 618 | $failure = count($failed_files) >= 1; |
578 | 619 | |
579 | - if (!isset($_SERVER)) |
|
580 | - return !$failure; |
|
620 | + if (!isset($_SERVER)) { |
|
621 | + return !$failure; |
|
622 | + } |
|
581 | 623 | |
582 | 624 | // Put the list into context. |
583 | 625 | $incontext['failed_files'] = $failed_files; |
@@ -625,19 +667,23 @@ discard block |
||
625 | 667 | |
626 | 668 | if (!isset($ftp) || $ftp->error !== false) |
627 | 669 | { |
628 | - if (!isset($ftp)) |
|
629 | - $ftp = new ftp_connection(null); |
|
670 | + if (!isset($ftp)) { |
|
671 | + $ftp = new ftp_connection(null); |
|
672 | + } |
|
630 | 673 | // Save the error so we can mess with listing... |
631 | - elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) |
|
632 | - $incontext['ftp_errors'][] = $ftp->last_message; |
|
674 | + elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) { |
|
675 | + $incontext['ftp_errors'][] = $ftp->last_message; |
|
676 | + } |
|
633 | 677 | |
634 | 678 | list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__)); |
635 | 679 | |
636 | - if (empty($_POST['ftp_path']) && $found_path) |
|
637 | - $_POST['ftp_path'] = $detect_path; |
|
680 | + if (empty($_POST['ftp_path']) && $found_path) { |
|
681 | + $_POST['ftp_path'] = $detect_path; |
|
682 | + } |
|
638 | 683 | |
639 | - if (!isset($_POST['ftp_username'])) |
|
640 | - $_POST['ftp_username'] = $username; |
|
684 | + if (!isset($_POST['ftp_username'])) { |
|
685 | + $_POST['ftp_username'] = $username; |
|
686 | + } |
|
641 | 687 | |
642 | 688 | // Set the username etc, into context. |
643 | 689 | $incontext['ftp'] = array( |
@@ -649,8 +695,7 @@ discard block |
||
649 | 695 | ); |
650 | 696 | |
651 | 697 | return false; |
652 | - } |
|
653 | - else |
|
698 | + } else |
|
654 | 699 | { |
655 | 700 | $_SESSION['installer_temp_ftp'] = array( |
656 | 701 | 'server' => $_POST['ftp_server'], |
@@ -664,10 +709,12 @@ discard block |
||
664 | 709 | |
665 | 710 | foreach ($failed_files as $file) |
666 | 711 | { |
667 | - if (!is_writable(dirname(__FILE__) . '/' . $file)) |
|
668 | - $ftp->chmod($file, 0755); |
|
669 | - if (!is_writable(dirname(__FILE__) . '/' . $file)) |
|
670 | - $ftp->chmod($file, 0777); |
|
712 | + if (!is_writable(dirname(__FILE__) . '/' . $file)) { |
|
713 | + $ftp->chmod($file, 0755); |
|
714 | + } |
|
715 | + if (!is_writable(dirname(__FILE__) . '/' . $file)) { |
|
716 | + $ftp->chmod($file, 0777); |
|
717 | + } |
|
671 | 718 | if (!is_writable(dirname(__FILE__) . '/' . $file)) |
672 | 719 | { |
673 | 720 | $failed_files_updated[] = $file; |
@@ -723,15 +770,17 @@ discard block |
||
723 | 770 | |
724 | 771 | if (!$foundOne) |
725 | 772 | { |
726 | - if (isset($db['default_host'])) |
|
727 | - $incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost'; |
|
773 | + if (isset($db['default_host'])) { |
|
774 | + $incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost'; |
|
775 | + } |
|
728 | 776 | if (isset($db['default_user'])) |
729 | 777 | { |
730 | 778 | $incontext['db']['user'] = ini_get($db['default_user']); |
731 | 779 | $incontext['db']['name'] = ini_get($db['default_user']); |
732 | 780 | } |
733 | - if (isset($db['default_password'])) |
|
734 | - $incontext['db']['pass'] = ini_get($db['default_password']); |
|
781 | + if (isset($db['default_password'])) { |
|
782 | + $incontext['db']['pass'] = ini_get($db['default_password']); |
|
783 | + } |
|
735 | 784 | |
736 | 785 | // For simplicity and less confusion, leave the port blank by default |
737 | 786 | $incontext['db']['port'] = ''; |
@@ -750,10 +799,10 @@ discard block |
||
750 | 799 | $incontext['db']['server'] = $_POST['db_server']; |
751 | 800 | $incontext['db']['prefix'] = $_POST['db_prefix']; |
752 | 801 | |
753 | - if (!empty($_POST['db_port'])) |
|
754 | - $incontext['db']['port'] = $_POST['db_port']; |
|
755 | - } |
|
756 | - else |
|
802 | + if (!empty($_POST['db_port'])) { |
|
803 | + $incontext['db']['port'] = $_POST['db_port']; |
|
804 | + } |
|
805 | + } else |
|
757 | 806 | { |
758 | 807 | $incontext['db']['prefix'] = 'smf_'; |
759 | 808 | } |
@@ -789,10 +838,11 @@ discard block |
||
789 | 838 | if (!empty($_POST['db_port'])) |
790 | 839 | { |
791 | 840 | // For MySQL, we can get the "default port" from PHP. PostgreSQL has no such option though. |
792 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) |
|
793 | - $vars['db_port'] = (int) $_POST['db_port']; |
|
794 | - elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) |
|
795 | - $vars['db_port'] = (int) $_POST['db_port']; |
|
841 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) { |
|
842 | + $vars['db_port'] = (int) $_POST['db_port']; |
|
843 | + } elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) { |
|
844 | + $vars['db_port'] = (int) $_POST['db_port']; |
|
845 | + } |
|
796 | 846 | } |
797 | 847 | |
798 | 848 | // God I hope it saved! |
@@ -805,8 +855,9 @@ discard block |
||
805 | 855 | // Make sure it works. |
806 | 856 | require(dirname(__FILE__) . '/Settings.php'); |
807 | 857 | |
808 | - if (empty($sourcedir)) |
|
809 | - $sourcedir = dirname(__FILE__) . '/Sources'; |
|
858 | + if (empty($sourcedir)) { |
|
859 | + $sourcedir = dirname(__FILE__) . '/Sources'; |
|
860 | + } |
|
810 | 861 | |
811 | 862 | // Better find the database file! |
812 | 863 | if (!file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
@@ -816,18 +867,21 @@ discard block |
||
816 | 867 | } |
817 | 868 | |
818 | 869 | // Now include it for database functions! |
819 | - if (!defined('SMF')) |
|
820 | - define('SMF', 1); |
|
870 | + if (!defined('SMF')) { |
|
871 | + define('SMF', 1); |
|
872 | + } |
|
821 | 873 | |
822 | 874 | $modSettings['disableQueryCheck'] = true; |
823 | - if (empty($smcFunc)) |
|
824 | - $smcFunc = array(); |
|
875 | + if (empty($smcFunc)) { |
|
876 | + $smcFunc = array(); |
|
877 | + } |
|
825 | 878 | |
826 | 879 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
827 | 880 | |
828 | 881 | // What - running PHP4? The shame! |
829 | - if (version_compare(PHP_VERSION, '5', '<')) |
|
830 | - require_once($sourcedir . '/Subs-Compat.php'); |
|
882 | + if (version_compare(PHP_VERSION, '5', '<')) { |
|
883 | + require_once($sourcedir . '/Subs-Compat.php'); |
|
884 | + } |
|
831 | 885 | |
832 | 886 | // Attempt a connection. |
833 | 887 | $needsDB = !empty($databases[$db_type]['always_has_db']); |
@@ -915,12 +969,14 @@ discard block |
||
915 | 969 | $incontext['page_title'] = $txt['install_settings']; |
916 | 970 | |
917 | 971 | // Let's see if we got the database type correct. |
918 | - if (isset($_POST['db_type'], $databases[$_POST['db_type']])) |
|
919 | - $db_type = $_POST['db_type']; |
|
972 | + if (isset($_POST['db_type'], $databases[$_POST['db_type']])) { |
|
973 | + $db_type = $_POST['db_type']; |
|
974 | + } |
|
920 | 975 | |
921 | 976 | // Else we'd better be able to get the connection. |
922 | - else |
|
923 | - load_database(); |
|
977 | + else { |
|
978 | + load_database(); |
|
979 | + } |
|
924 | 980 | |
925 | 981 | $db_type = isset($_POST['db_type']) ? $_POST['db_type'] : $db_type; |
926 | 982 | |
@@ -957,18 +1013,21 @@ discard block |
||
957 | 1013 | // Submitting? |
958 | 1014 | if (isset($_POST['boardurl'])) |
959 | 1015 | { |
960 | - if (substr($_POST['boardurl'], -10) == '/index.php') |
|
961 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
962 | - elseif (substr($_POST['boardurl'], -1) == '/') |
|
963 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
964 | - if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') |
|
965 | - $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
1016 | + if (substr($_POST['boardurl'], -10) == '/index.php') { |
|
1017 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
1018 | + } elseif (substr($_POST['boardurl'], -1) == '/') { |
|
1019 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
1020 | + } |
|
1021 | + if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') { |
|
1022 | + $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
1023 | + } |
|
966 | 1024 | |
967 | 1025 | //Make sure boardurl is aligned with ssl setting |
968 | - if (empty($_POST['force_ssl'])) |
|
969 | - $_POST['boardurl'] = strtr($_POST['boardurl'], array('https://' => 'http://')); |
|
970 | - else |
|
971 | - $_POST['boardurl'] = strtr($_POST['boardurl'], array('http://' => 'https://')); |
|
1026 | + if (empty($_POST['force_ssl'])) { |
|
1027 | + $_POST['boardurl'] = strtr($_POST['boardurl'], array('https://' => 'http://')); |
|
1028 | + } else { |
|
1029 | + $_POST['boardurl'] = strtr($_POST['boardurl'], array('http://' => 'https://')); |
|
1030 | + } |
|
972 | 1031 | |
973 | 1032 | // Save these variables. |
974 | 1033 | $vars = array( |
@@ -1007,10 +1066,10 @@ discard block |
||
1007 | 1066 | { |
1008 | 1067 | $incontext['error'] = sprintf($txt['error_utf8_version'], $databases[$db_type]['utf8_version']); |
1009 | 1068 | return false; |
1010 | - } |
|
1011 | - else |
|
1012 | - // Set the character set here. |
|
1069 | + } else { |
|
1070 | + // Set the character set here. |
|
1013 | 1071 | updateSettingsFile(array('db_character_set' => 'utf8')); |
1072 | + } |
|
1014 | 1073 | } |
1015 | 1074 | |
1016 | 1075 | // Good, skip on. |
@@ -1030,8 +1089,9 @@ discard block |
||
1030 | 1089 | $incontext['continue'] = 1; |
1031 | 1090 | |
1032 | 1091 | // Already done? |
1033 | - if (isset($_POST['pop_done'])) |
|
1034 | - return true; |
|
1092 | + if (isset($_POST['pop_done'])) { |
|
1093 | + return true; |
|
1094 | + } |
|
1035 | 1095 | |
1036 | 1096 | // Reload settings. |
1037 | 1097 | require(dirname(__FILE__) . '/Settings.php'); |
@@ -1049,8 +1109,9 @@ discard block |
||
1049 | 1109 | $modSettings = array(); |
1050 | 1110 | if ($result !== false) |
1051 | 1111 | { |
1052 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
1053 | - $modSettings[$row['variable']] = $row['value']; |
|
1112 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
1113 | + $modSettings[$row['variable']] = $row['value']; |
|
1114 | + } |
|
1054 | 1115 | $smcFunc['db_free_result']($result); |
1055 | 1116 | |
1056 | 1117 | // Do they match? If so, this is just a refresh so charge on! |
@@ -1063,20 +1124,22 @@ discard block |
||
1063 | 1124 | $modSettings['disableQueryCheck'] = true; |
1064 | 1125 | |
1065 | 1126 | // If doing UTF8, select it. PostgreSQL requires passing it as a string... |
1066 | - if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) |
|
1067 | - $smcFunc['db_query']('', ' |
|
1127 | + if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) { |
|
1128 | + $smcFunc['db_query']('', ' |
|
1068 | 1129 | SET NAMES {string:utf8}', |
1069 | 1130 | array( |
1070 | 1131 | 'db_error_skip' => true, |
1071 | 1132 | 'utf8' => 'utf8', |
1072 | 1133 | ) |
1073 | 1134 | ); |
1135 | + } |
|
1074 | 1136 | |
1075 | 1137 | // Windows likes to leave the trailing slash, which yields to C:\path\to\SMF\/attachments... |
1076 | - if (substr(__DIR__, -1) == '\\') |
|
1077 | - $attachdir = __DIR__ . 'attachments'; |
|
1078 | - else |
|
1079 | - $attachdir = __DIR__ . '/attachments'; |
|
1138 | + if (substr(__DIR__, -1) == '\\') { |
|
1139 | + $attachdir = __DIR__ . 'attachments'; |
|
1140 | + } else { |
|
1141 | + $attachdir = __DIR__ . '/attachments'; |
|
1142 | + } |
|
1080 | 1143 | |
1081 | 1144 | $replaces = array( |
1082 | 1145 | '{$db_prefix}' => $db_prefix, |
@@ -1093,8 +1156,9 @@ discard block |
||
1093 | 1156 | |
1094 | 1157 | foreach ($txt as $key => $value) |
1095 | 1158 | { |
1096 | - if (substr($key, 0, 8) == 'default_') |
|
1097 | - $replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value); |
|
1159 | + if (substr($key, 0, 8) == 'default_') { |
|
1160 | + $replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value); |
|
1161 | + } |
|
1098 | 1162 | } |
1099 | 1163 | $replaces['{$default_reserved_names}'] = strtr($replaces['{$default_reserved_names}'], array('\\\\n' => '\\n')); |
1100 | 1164 | |
@@ -1109,8 +1173,9 @@ discard block |
||
1109 | 1173 | |
1110 | 1174 | while ($row = $smcFunc['db_fetch_assoc']($get_engines)) |
1111 | 1175 | { |
1112 | - if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') |
|
1113 | - $engines[] = $row['Engine']; |
|
1176 | + if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') { |
|
1177 | + $engines[] = $row['Engine']; |
|
1178 | + } |
|
1114 | 1179 | } |
1115 | 1180 | |
1116 | 1181 | // Done with this now |
@@ -1134,8 +1199,7 @@ discard block |
||
1134 | 1199 | $replaces['START TRANSACTION;'] = ''; |
1135 | 1200 | $replaces['COMMIT;'] = ''; |
1136 | 1201 | } |
1137 | - } |
|
1138 | - else |
|
1202 | + } else |
|
1139 | 1203 | { |
1140 | 1204 | $has_innodb = false; |
1141 | 1205 | } |
@@ -1157,21 +1221,24 @@ discard block |
||
1157 | 1221 | foreach ($sql_lines as $count => $line) |
1158 | 1222 | { |
1159 | 1223 | // No comments allowed! |
1160 | - if (substr(trim($line), 0, 1) != '#') |
|
1161 | - $current_statement .= "\n" . rtrim($line); |
|
1224 | + if (substr(trim($line), 0, 1) != '#') { |
|
1225 | + $current_statement .= "\n" . rtrim($line); |
|
1226 | + } |
|
1162 | 1227 | |
1163 | 1228 | // Is this the end of the query string? |
1164 | - if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) |
|
1165 | - continue; |
|
1229 | + if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) { |
|
1230 | + continue; |
|
1231 | + } |
|
1166 | 1232 | |
1167 | 1233 | // Does this table already exist? If so, don't insert more data into it! |
1168 | 1234 | if (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) != 0 && in_array($match[1], $exists)) |
1169 | 1235 | { |
1170 | 1236 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
1171 | - if (!empty($matches[0])) |
|
1172 | - $incontext['sql_results']['insert_dups'] += count($matches[0]); |
|
1173 | - else |
|
1174 | - $incontext['sql_results']['insert_dups']++; |
|
1237 | + if (!empty($matches[0])) { |
|
1238 | + $incontext['sql_results']['insert_dups'] += count($matches[0]); |
|
1239 | + } else { |
|
1240 | + $incontext['sql_results']['insert_dups']++; |
|
1241 | + } |
|
1175 | 1242 | |
1176 | 1243 | $current_statement = ''; |
1177 | 1244 | continue; |
@@ -1180,8 +1247,9 @@ discard block |
||
1180 | 1247 | if ($smcFunc['db_query']('', $current_statement, array('security_override' => true, 'db_error_skip' => true), $db_connection) === false) |
1181 | 1248 | { |
1182 | 1249 | // Use the appropriate function based on the DB type |
1183 | - if ($db_type == 'mysql' || $db_type == 'mysqli') |
|
1184 | - $db_errorno = $db_type . '_errno'; |
|
1250 | + if ($db_type == 'mysql' || $db_type == 'mysqli') { |
|
1251 | + $db_errorno = $db_type . '_errno'; |
|
1252 | + } |
|
1185 | 1253 | |
1186 | 1254 | // Error 1050: Table already exists! |
1187 | 1255 | // @todo Needs to be made better! |
@@ -1196,18 +1264,18 @@ discard block |
||
1196 | 1264 | // MySQLi requires a connection object. It's optional with MySQL and Postgres |
1197 | 1265 | $incontext['failures'][$count] = $smcFunc['db_error']($db_connection); |
1198 | 1266 | } |
1199 | - } |
|
1200 | - else |
|
1267 | + } else |
|
1201 | 1268 | { |
1202 | - if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
1203 | - $incontext['sql_results']['tables']++; |
|
1204 | - elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
1269 | + if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) { |
|
1270 | + $incontext['sql_results']['tables']++; |
|
1271 | + } elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
1205 | 1272 | { |
1206 | 1273 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
1207 | - if (!empty($matches[0])) |
|
1208 | - $incontext['sql_results']['inserts'] += count($matches[0]); |
|
1209 | - else |
|
1210 | - $incontext['sql_results']['inserts']++; |
|
1274 | + if (!empty($matches[0])) { |
|
1275 | + $incontext['sql_results']['inserts'] += count($matches[0]); |
|
1276 | + } else { |
|
1277 | + $incontext['sql_results']['inserts']++; |
|
1278 | + } |
|
1211 | 1279 | } |
1212 | 1280 | } |
1213 | 1281 | |
@@ -1220,15 +1288,17 @@ discard block |
||
1220 | 1288 | // Sort out the context for the SQL. |
1221 | 1289 | foreach ($incontext['sql_results'] as $key => $number) |
1222 | 1290 | { |
1223 | - if ($number == 0) |
|
1224 | - unset($incontext['sql_results'][$key]); |
|
1225 | - else |
|
1226 | - $incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number); |
|
1291 | + if ($number == 0) { |
|
1292 | + unset($incontext['sql_results'][$key]); |
|
1293 | + } else { |
|
1294 | + $incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number); |
|
1295 | + } |
|
1227 | 1296 | } |
1228 | 1297 | |
1229 | 1298 | // Make sure UTF will be used globally. |
1230 | - if ((!empty($databases[$db_type]['utf8_support']) && !empty($databases[$db_type]['utf8_required'])) || (empty($databases[$db_type]['utf8_required']) && !empty($databases[$db_type]['utf8_support']) && isset($_POST['utf8']))) |
|
1231 | - $newSettings[] = array('global_character_set', 'UTF-8'); |
|
1299 | + if ((!empty($databases[$db_type]['utf8_support']) && !empty($databases[$db_type]['utf8_required'])) || (empty($databases[$db_type]['utf8_required']) && !empty($databases[$db_type]['utf8_support']) && isset($_POST['utf8']))) { |
|
1300 | + $newSettings[] = array('global_character_set', 'UTF-8'); |
|
1301 | + } |
|
1232 | 1302 | |
1233 | 1303 | // Maybe we can auto-detect better cookie settings? |
1234 | 1304 | preg_match('~^http[s]?://([^\.]+?)([^/]*?)(/.*)?$~', $boardurl, $matches); |
@@ -1239,16 +1309,20 @@ discard block |
||
1239 | 1309 | $globalCookies = false; |
1240 | 1310 | |
1241 | 1311 | // Okay... let's see. Using a subdomain other than www.? (not a perfect check.) |
1242 | - if ($matches[2] != '' && (strpos(substr($matches[2], 1), '.') === false || in_array($matches[1], array('forum', 'board', 'community', 'forums', 'support', 'chat', 'help', 'talk', 'boards', 'www')))) |
|
1243 | - $globalCookies = true; |
|
1312 | + if ($matches[2] != '' && (strpos(substr($matches[2], 1), '.') === false || in_array($matches[1], array('forum', 'board', 'community', 'forums', 'support', 'chat', 'help', 'talk', 'boards', 'www')))) { |
|
1313 | + $globalCookies = true; |
|
1314 | + } |
|
1244 | 1315 | // If there's a / in the middle of the path, or it starts with ~... we want local. |
1245 | - if (isset($matches[3]) && strlen($matches[3]) > 3 && (substr($matches[3], 0, 2) == '/~' || strpos(substr($matches[3], 1), '/') !== false)) |
|
1246 | - $localCookies = true; |
|
1316 | + if (isset($matches[3]) && strlen($matches[3]) > 3 && (substr($matches[3], 0, 2) == '/~' || strpos(substr($matches[3], 1), '/') !== false)) { |
|
1317 | + $localCookies = true; |
|
1318 | + } |
|
1247 | 1319 | |
1248 | - if ($globalCookies) |
|
1249 | - $newSettings[] = array('globalCookies', '1'); |
|
1250 | - if ($localCookies) |
|
1251 | - $newSettings[] = array('localCookies', '1'); |
|
1320 | + if ($globalCookies) { |
|
1321 | + $newSettings[] = array('globalCookies', '1'); |
|
1322 | + } |
|
1323 | + if ($localCookies) { |
|
1324 | + $newSettings[] = array('localCookies', '1'); |
|
1325 | + } |
|
1252 | 1326 | } |
1253 | 1327 | |
1254 | 1328 | // Are we allowing stat collection? |
@@ -1266,16 +1340,17 @@ discard block |
||
1266 | 1340 | fwrite($fp, $out); |
1267 | 1341 | |
1268 | 1342 | $return_data = ''; |
1269 | - while (!feof($fp)) |
|
1270 | - $return_data .= fgets($fp, 128); |
|
1343 | + while (!feof($fp)) { |
|
1344 | + $return_data .= fgets($fp, 128); |
|
1345 | + } |
|
1271 | 1346 | |
1272 | 1347 | fclose($fp); |
1273 | 1348 | |
1274 | 1349 | // Get the unique site ID. |
1275 | 1350 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
1276 | 1351 | |
1277 | - if (!empty($ID[1])) |
|
1278 | - $smcFunc['db_insert']('replace', |
|
1352 | + if (!empty($ID[1])) { |
|
1353 | + $smcFunc['db_insert']('replace', |
|
1279 | 1354 | $db_prefix . 'settings', |
1280 | 1355 | array('variable' => 'string', 'value' => 'string'), |
1281 | 1356 | array( |
@@ -1284,11 +1359,12 @@ discard block |
||
1284 | 1359 | ), |
1285 | 1360 | array('variable') |
1286 | 1361 | ); |
1362 | + } |
|
1287 | 1363 | } |
1288 | 1364 | } |
1289 | 1365 | // Don't remove stat collection unless we unchecked the box for real, not from the loop. |
1290 | - elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) |
|
1291 | - $smcFunc['db_query']('', ' |
|
1366 | + elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) { |
|
1367 | + $smcFunc['db_query']('', ' |
|
1292 | 1368 | DELETE FROM {db_prefix}settings |
1293 | 1369 | WHERE variable = {string:enable_sm_stats}', |
1294 | 1370 | array( |
@@ -1296,20 +1372,23 @@ discard block |
||
1296 | 1372 | 'db_error_skip' => true, |
1297 | 1373 | ) |
1298 | 1374 | ); |
1375 | + } |
|
1299 | 1376 | |
1300 | 1377 | // Are we enabling SSL? |
1301 | - if (!empty($_POST['force_ssl'])) |
|
1302 | - $newSettings[] = array('force_ssl', 2); |
|
1378 | + if (!empty($_POST['force_ssl'])) { |
|
1379 | + $newSettings[] = array('force_ssl', 2); |
|
1380 | + } |
|
1303 | 1381 | |
1304 | 1382 | // Setting a timezone is required. |
1305 | 1383 | if (!isset($modSettings['default_timezone']) && function_exists('date_default_timezone_set')) |
1306 | 1384 | { |
1307 | 1385 | // Get PHP's default timezone, if set |
1308 | 1386 | $ini_tz = ini_get('date.timezone'); |
1309 | - if (!empty($ini_tz)) |
|
1310 | - $timezone_id = $ini_tz; |
|
1311 | - else |
|
1312 | - $timezone_id = ''; |
|
1387 | + if (!empty($ini_tz)) { |
|
1388 | + $timezone_id = $ini_tz; |
|
1389 | + } else { |
|
1390 | + $timezone_id = ''; |
|
1391 | + } |
|
1313 | 1392 | |
1314 | 1393 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
1315 | 1394 | if (!in_array($timezone_id, timezone_identifiers_list())) |
@@ -1318,8 +1397,9 @@ discard block |
||
1318 | 1397 | $timezone_id = timezone_name_from_abbr('', $server_offset, 0); |
1319 | 1398 | } |
1320 | 1399 | |
1321 | - if (date_default_timezone_set($timezone_id)) |
|
1322 | - $newSettings[] = array('default_timezone', $timezone_id); |
|
1400 | + if (date_default_timezone_set($timezone_id)) { |
|
1401 | + $newSettings[] = array('default_timezone', $timezone_id); |
|
1402 | + } |
|
1323 | 1403 | } |
1324 | 1404 | |
1325 | 1405 | if (!empty($newSettings)) |
@@ -1350,16 +1430,18 @@ discard block |
||
1350 | 1430 | } |
1351 | 1431 | |
1352 | 1432 | // MySQL specific stuff |
1353 | - if (substr($db_type, 0, 5) != 'mysql') |
|
1354 | - return false; |
|
1433 | + if (substr($db_type, 0, 5) != 'mysql') { |
|
1434 | + return false; |
|
1435 | + } |
|
1355 | 1436 | |
1356 | 1437 | // Find database user privileges. |
1357 | 1438 | $privs = array(); |
1358 | 1439 | $get_privs = $smcFunc['db_query']('', 'SHOW PRIVILEGES', array()); |
1359 | 1440 | while ($row = $smcFunc['db_fetch_assoc']($get_privs)) |
1360 | 1441 | { |
1361 | - if ($row['Privilege'] == 'Alter') |
|
1362 | - $privs[] = $row['Privilege']; |
|
1442 | + if ($row['Privilege'] == 'Alter') { |
|
1443 | + $privs[] = $row['Privilege']; |
|
1444 | + } |
|
1363 | 1445 | } |
1364 | 1446 | $smcFunc['db_free_result']($get_privs); |
1365 | 1447 | |
@@ -1389,8 +1471,9 @@ discard block |
||
1389 | 1471 | $incontext['continue'] = 1; |
1390 | 1472 | |
1391 | 1473 | // Skipping? |
1392 | - if (!empty($_POST['skip'])) |
|
1393 | - return true; |
|
1474 | + if (!empty($_POST['skip'])) { |
|
1475 | + return true; |
|
1476 | + } |
|
1394 | 1477 | |
1395 | 1478 | // Need this to check whether we need the database password. |
1396 | 1479 | require(dirname(__FILE__) . '/Settings.php'); |
@@ -1407,18 +1490,22 @@ discard block |
||
1407 | 1490 | // We need this to properly hash the password for Admin |
1408 | 1491 | $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) { |
1409 | 1492 | global $sourcedir; |
1410 | - if (function_exists('mb_strtolower')) |
|
1411 | - return mb_strtolower($string, 'UTF-8'); |
|
1493 | + if (function_exists('mb_strtolower')) { |
|
1494 | + return mb_strtolower($string, 'UTF-8'); |
|
1495 | + } |
|
1412 | 1496 | require_once($sourcedir . '/Subs-Charset.php'); |
1413 | 1497 | return utf8_strtolower($string); |
1414 | 1498 | }; |
1415 | 1499 | |
1416 | - if (!isset($_POST['username'])) |
|
1417 | - $_POST['username'] = ''; |
|
1418 | - if (!isset($_POST['email'])) |
|
1419 | - $_POST['email'] = ''; |
|
1420 | - if (!isset($_POST['server_email'])) |
|
1421 | - $_POST['server_email'] = ''; |
|
1500 | + if (!isset($_POST['username'])) { |
|
1501 | + $_POST['username'] = ''; |
|
1502 | + } |
|
1503 | + if (!isset($_POST['email'])) { |
|
1504 | + $_POST['email'] = ''; |
|
1505 | + } |
|
1506 | + if (!isset($_POST['server_email'])) { |
|
1507 | + $_POST['server_email'] = ''; |
|
1508 | + } |
|
1422 | 1509 | |
1423 | 1510 | $incontext['username'] = htmlspecialchars(stripslashes($_POST['username'])); |
1424 | 1511 | $incontext['email'] = htmlspecialchars(stripslashes($_POST['email'])); |
@@ -1437,8 +1524,9 @@ discard block |
||
1437 | 1524 | 'admin_group' => 1, |
1438 | 1525 | ) |
1439 | 1526 | ); |
1440 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
1441 | - $incontext['skip'] = 1; |
|
1527 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
1528 | + $incontext['skip'] = 1; |
|
1529 | + } |
|
1442 | 1530 | $smcFunc['db_free_result']($request); |
1443 | 1531 | |
1444 | 1532 | // Trying to create an account? |
@@ -1469,8 +1557,9 @@ discard block |
||
1469 | 1557 | } |
1470 | 1558 | |
1471 | 1559 | // Update the webmaster's email? |
1472 | - if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) |
|
1473 | - updateSettingsFile(array('webmaster_email' => $_POST['server_email'])); |
|
1560 | + if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) { |
|
1561 | + updateSettingsFile(array('webmaster_email' => $_POST['server_email'])); |
|
1562 | + } |
|
1474 | 1563 | |
1475 | 1564 | // Work out whether we're going to have dodgy characters and remove them. |
1476 | 1565 | $invalid_characters = preg_match('~[<>&"\'=\\\]~', $_POST['username']) != 0; |
@@ -1493,32 +1582,27 @@ discard block |
||
1493 | 1582 | $smcFunc['db_free_result']($result); |
1494 | 1583 | |
1495 | 1584 | $incontext['account_existed'] = $txt['error_user_settings_taken']; |
1496 | - } |
|
1497 | - elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) |
|
1585 | + } elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) |
|
1498 | 1586 | { |
1499 | 1587 | // Try the previous step again. |
1500 | 1588 | $incontext['error'] = $_POST['username'] == '' ? $txt['error_username_left_empty'] : $txt['error_username_too_long']; |
1501 | 1589 | return false; |
1502 | - } |
|
1503 | - elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) |
|
1590 | + } elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) |
|
1504 | 1591 | { |
1505 | 1592 | // Try the previous step again. |
1506 | 1593 | $incontext['error'] = $txt['error_invalid_characters_username']; |
1507 | 1594 | return false; |
1508 | - } |
|
1509 | - elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255) |
|
1595 | + } elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255) |
|
1510 | 1596 | { |
1511 | 1597 | // One step back, this time fill out a proper admin email address. |
1512 | 1598 | $incontext['error'] = sprintf($txt['error_valid_admin_email_needed'], $_POST['username']); |
1513 | 1599 | return false; |
1514 | - } |
|
1515 | - elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255) |
|
1600 | + } elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255) |
|
1516 | 1601 | { |
1517 | 1602 | // One step back, this time fill out a proper admin email address. |
1518 | 1603 | $incontext['error'] = $txt['error_valid_server_email_needed']; |
1519 | 1604 | return false; |
1520 | - } |
|
1521 | - elseif ($_POST['username'] != '') |
|
1605 | + } elseif ($_POST['username'] != '') |
|
1522 | 1606 | { |
1523 | 1607 | $incontext['member_salt'] = substr(md5(mt_rand()), 0, 4); |
1524 | 1608 | |
@@ -1586,17 +1670,19 @@ discard block |
||
1586 | 1670 | reloadSettings(); |
1587 | 1671 | |
1588 | 1672 | // Bring a warning over. |
1589 | - if (!empty($incontext['account_existed'])) |
|
1590 | - $incontext['warning'] = $incontext['account_existed']; |
|
1673 | + if (!empty($incontext['account_existed'])) { |
|
1674 | + $incontext['warning'] = $incontext['account_existed']; |
|
1675 | + } |
|
1591 | 1676 | |
1592 | - if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) |
|
1593 | - $smcFunc['db_query']('', ' |
|
1677 | + if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) { |
|
1678 | + $smcFunc['db_query']('', ' |
|
1594 | 1679 | SET NAMES {string:db_character_set}', |
1595 | 1680 | array( |
1596 | 1681 | 'db_character_set' => $db_character_set, |
1597 | 1682 | 'db_error_skip' => true, |
1598 | 1683 | ) |
1599 | 1684 | ); |
1685 | + } |
|
1600 | 1686 | |
1601 | 1687 | // As track stats is by default enabled let's add some activity. |
1602 | 1688 | $smcFunc['db_insert']('ignore', |
@@ -1617,14 +1703,16 @@ discard block |
||
1617 | 1703 | // Only proceed if we can load the data. |
1618 | 1704 | if ($request) |
1619 | 1705 | { |
1620 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
1621 | - $modSettings[$row[0]] = $row[1]; |
|
1706 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
1707 | + $modSettings[$row[0]] = $row[1]; |
|
1708 | + } |
|
1622 | 1709 | $smcFunc['db_free_result']($request); |
1623 | 1710 | } |
1624 | 1711 | |
1625 | 1712 | // Automatically log them in ;) |
1626 | - if (isset($incontext['member_id']) && isset($incontext['member_salt'])) |
|
1627 | - setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt'])); |
|
1713 | + if (isset($incontext['member_id']) && isset($incontext['member_salt'])) { |
|
1714 | + setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt'])); |
|
1715 | + } |
|
1628 | 1716 | |
1629 | 1717 | $result = $smcFunc['db_query']('', ' |
1630 | 1718 | SELECT value |
@@ -1635,13 +1723,14 @@ discard block |
||
1635 | 1723 | 'db_error_skip' => true, |
1636 | 1724 | ) |
1637 | 1725 | ); |
1638 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
1639 | - list ($db_sessions) = $smcFunc['db_fetch_row']($result); |
|
1726 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
1727 | + list ($db_sessions) = $smcFunc['db_fetch_row']($result); |
|
1728 | + } |
|
1640 | 1729 | $smcFunc['db_free_result']($result); |
1641 | 1730 | |
1642 | - if (empty($db_sessions)) |
|
1643 | - $_SESSION['admin_time'] = time(); |
|
1644 | - else |
|
1731 | + if (empty($db_sessions)) { |
|
1732 | + $_SESSION['admin_time'] = time(); |
|
1733 | + } else |
|
1645 | 1734 | { |
1646 | 1735 | $_SERVER['HTTP_USER_AGENT'] = substr($_SERVER['HTTP_USER_AGENT'], 0, 211); |
1647 | 1736 | |
@@ -1665,8 +1754,9 @@ discard block |
||
1665 | 1754 | $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : |
1666 | 1755 | function($string){ |
1667 | 1756 | global $sourcedir; |
1668 | - if (function_exists('mb_strtolower')) |
|
1669 | - return mb_strtolower($string, 'UTF-8'); |
|
1757 | + if (function_exists('mb_strtolower')) { |
|
1758 | + return mb_strtolower($string, 'UTF-8'); |
|
1759 | + } |
|
1670 | 1760 | require_once($sourcedir . '/Subs-Charset.php'); |
1671 | 1761 | return utf8_strtolower($string); |
1672 | 1762 | }; |
@@ -1682,8 +1772,9 @@ discard block |
||
1682 | 1772 | ) |
1683 | 1773 | ); |
1684 | 1774 | $context['utf8'] = $db_character_set === 'utf8' || $txt['lang_character_set'] === 'UTF-8'; |
1685 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
1686 | - updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject'])); |
|
1775 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
1776 | + updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject'])); |
|
1777 | + } |
|
1687 | 1778 | $smcFunc['db_free_result']($request); |
1688 | 1779 | |
1689 | 1780 | // Now is the perfect time to fetch the SM files. |
@@ -1702,8 +1793,9 @@ discard block |
||
1702 | 1793 | |
1703 | 1794 | // Check if we need some stupid MySQL fix. |
1704 | 1795 | $server_version = $smcFunc['db_server_info'](); |
1705 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
1706 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
1796 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
1797 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
1798 | + } |
|
1707 | 1799 | |
1708 | 1800 | // Some final context for the template. |
1709 | 1801 | $incontext['dir_still_writable'] = is_writable(dirname(__FILE__)) && substr(__FILE__, 1, 2) != ':\\'; |
@@ -1723,8 +1815,9 @@ discard block |
||
1723 | 1815 | $settingsArray = file(dirname(__FILE__) . '/Settings.php'); |
1724 | 1816 | |
1725 | 1817 | // @todo Do we just want to read the file in clean, and split it this way always? |
1726 | - if (count($settingsArray) == 1) |
|
1727 | - $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
1818 | + if (count($settingsArray) == 1) { |
|
1819 | + $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
1820 | + } |
|
1728 | 1821 | |
1729 | 1822 | for ($i = 0, $n = count($settingsArray); $i < $n; $i++) |
1730 | 1823 | { |
@@ -1739,19 +1832,22 @@ discard block |
||
1739 | 1832 | continue; |
1740 | 1833 | } |
1741 | 1834 | |
1742 | - if (trim($settingsArray[$i]) == '?' . '>') |
|
1743 | - $settingsArray[$i] = ''; |
|
1835 | + if (trim($settingsArray[$i]) == '?' . '>') { |
|
1836 | + $settingsArray[$i] = ''; |
|
1837 | + } |
|
1744 | 1838 | |
1745 | 1839 | // Don't trim or bother with it if it's not a variable. |
1746 | - if (substr($settingsArray[$i], 0, 1) != '$') |
|
1747 | - continue; |
|
1840 | + if (substr($settingsArray[$i], 0, 1) != '$') { |
|
1841 | + continue; |
|
1842 | + } |
|
1748 | 1843 | |
1749 | 1844 | $settingsArray[$i] = rtrim($settingsArray[$i]) . "\n"; |
1750 | 1845 | |
1751 | - foreach ($vars as $var => $val) |
|
1752 | - if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
1846 | + foreach ($vars as $var => $val) { |
|
1847 | + if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
1753 | 1848 | { |
1754 | 1849 | $comment = strstr($settingsArray[$i], '#'); |
1850 | + } |
|
1755 | 1851 | $settingsArray[$i] = '$' . $var . ' = \'' . $val . '\';' . ($comment != '' ? "\t\t" . $comment : "\n"); |
1756 | 1852 | unset($vars[$var]); |
1757 | 1853 | } |
@@ -1761,36 +1857,41 @@ discard block |
||
1761 | 1857 | if (!empty($vars)) |
1762 | 1858 | { |
1763 | 1859 | $settingsArray[$i++] = ''; |
1764 | - foreach ($vars as $var => $val) |
|
1765 | - $settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n"; |
|
1860 | + foreach ($vars as $var => $val) { |
|
1861 | + $settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n"; |
|
1862 | + } |
|
1766 | 1863 | } |
1767 | 1864 | |
1768 | 1865 | // Blank out the file - done to fix a oddity with some servers. |
1769 | 1866 | $fp = @fopen(dirname(__FILE__) . '/Settings.php', 'w'); |
1770 | - if (!$fp) |
|
1771 | - return false; |
|
1867 | + if (!$fp) { |
|
1868 | + return false; |
|
1869 | + } |
|
1772 | 1870 | fclose($fp); |
1773 | 1871 | |
1774 | 1872 | $fp = fopen(dirname(__FILE__) . '/Settings.php', 'r+'); |
1775 | 1873 | |
1776 | 1874 | // Gotta have one of these ;) |
1777 | - if (trim($settingsArray[0]) != '<?php') |
|
1778 | - fwrite($fp, "<?php\n"); |
|
1875 | + if (trim($settingsArray[0]) != '<?php') { |
|
1876 | + fwrite($fp, "<?php\n"); |
|
1877 | + } |
|
1779 | 1878 | |
1780 | 1879 | $lines = count($settingsArray); |
1781 | 1880 | for ($i = 0; $i < $lines - 1; $i++) |
1782 | 1881 | { |
1783 | 1882 | // Don't just write a bunch of blank lines. |
1784 | - if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') |
|
1785 | - fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
1883 | + if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') { |
|
1884 | + fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
1885 | + } |
|
1786 | 1886 | } |
1787 | 1887 | fwrite($fp, $settingsArray[$i] . '?' . '>'); |
1788 | 1888 | fclose($fp); |
1789 | 1889 | |
1790 | 1890 | // Even though on normal installations the filemtime should prevent this being used by the installer incorrectly |
1791 | 1891 | // it seems that there are times it might not. So let's MAKE it dump the cache. |
1792 | - if (function_exists('opcache_invalidate')) |
|
1793 | - opcache_invalidate(dirname(__FILE__) . '/Settings.php', true); |
|
1892 | + if (function_exists('opcache_invalidate')) { |
|
1893 | + opcache_invalidate(dirname(__FILE__) . '/Settings.php', true); |
|
1894 | + } |
|
1794 | 1895 | |
1795 | 1896 | return true; |
1796 | 1897 | } |
@@ -1815,9 +1916,9 @@ discard block |
||
1815 | 1916 | SecFilterScanPOST Off |
1816 | 1917 | </IfModule>'; |
1817 | 1918 | |
1818 | - if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) |
|
1819 | - return true; |
|
1820 | - elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess')) |
|
1919 | + if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) { |
|
1920 | + return true; |
|
1921 | + } elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess')) |
|
1821 | 1922 | { |
1822 | 1923 | $current_htaccess = implode('', file(dirname(__FILE__) . '/.htaccess')); |
1823 | 1924 | |
@@ -1829,29 +1930,28 @@ discard block |
||
1829 | 1930 | fwrite($ht_handle, $htaccess_addition); |
1830 | 1931 | fclose($ht_handle); |
1831 | 1932 | return true; |
1933 | + } else { |
|
1934 | + return false; |
|
1832 | 1935 | } |
1833 | - else |
|
1834 | - return false; |
|
1936 | + } else { |
|
1937 | + return true; |
|
1835 | 1938 | } |
1836 | - else |
|
1837 | - return true; |
|
1838 | - } |
|
1839 | - elseif (file_exists(dirname(__FILE__) . '/.htaccess')) |
|
1840 | - return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false; |
|
1841 | - elseif (is_writable(dirname(__FILE__))) |
|
1939 | + } elseif (file_exists(dirname(__FILE__) . '/.htaccess')) { |
|
1940 | + return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false; |
|
1941 | + } elseif (is_writable(dirname(__FILE__))) |
|
1842 | 1942 | { |
1843 | 1943 | if ($ht_handle = fopen(dirname(__FILE__) . '/.htaccess', 'w')) |
1844 | 1944 | { |
1845 | 1945 | fwrite($ht_handle, $htaccess_addition); |
1846 | 1946 | fclose($ht_handle); |
1847 | 1947 | return true; |
1948 | + } else { |
|
1949 | + return false; |
|
1848 | 1950 | } |
1849 | - else |
|
1951 | + } else { |
|
1850 | 1952 | return false; |
1851 | 1953 | } |
1852 | - else |
|
1853 | - return false; |
|
1854 | -} |
|
1954 | + } |
|
1855 | 1955 | |
1856 | 1956 | function template_install_above() |
1857 | 1957 | { |
@@ -1889,9 +1989,10 @@ discard block |
||
1889 | 1989 | <label for="installer_language">', $txt['installer_language'], ':</label> |
1890 | 1990 | <select id="installer_language" name="lang_file" onchange="location.href = \'', $installurl, '?lang_file=\' + this.options[this.selectedIndex].value;">'; |
1891 | 1991 | |
1892 | - foreach ($incontext['detected_languages'] as $lang => $name) |
|
1893 | - echo ' |
|
1992 | + foreach ($incontext['detected_languages'] as $lang => $name) { |
|
1993 | + echo ' |
|
1894 | 1994 | <option', isset($_SESSION['installer_temp_lang']) && $_SESSION['installer_temp_lang'] == $lang ? ' selected' : '', ' value="', $lang, '">', $name, '</option>'; |
1995 | + } |
|
1895 | 1996 | |
1896 | 1997 | echo ' |
1897 | 1998 | </select> |
@@ -1911,9 +2012,10 @@ discard block |
||
1911 | 2012 | <h2>', $txt['upgrade_progress'], '</h2> |
1912 | 2013 | <ul>'; |
1913 | 2014 | |
1914 | - foreach ($incontext['steps'] as $num => $step) |
|
1915 | - echo ' |
|
2015 | + foreach ($incontext['steps'] as $num => $step) { |
|
2016 | + echo ' |
|
1916 | 2017 | <li class="', $num < $incontext['current_step'] ? 'stepdone' : ($num == $incontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
2018 | + } |
|
1917 | 2019 | |
1918 | 2020 | echo ' |
1919 | 2021 | </ul> |
@@ -1938,20 +2040,23 @@ discard block |
||
1938 | 2040 | echo ' |
1939 | 2041 | <div class="floatright">'; |
1940 | 2042 | |
1941 | - if (!empty($incontext['continue'])) |
|
1942 | - echo ' |
|
2043 | + if (!empty($incontext['continue'])) { |
|
2044 | + echo ' |
|
1943 | 2045 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '" onclick="return submitThisOnce(this);" class="button" />'; |
1944 | - if (!empty($incontext['skip'])) |
|
1945 | - echo ' |
|
2046 | + } |
|
2047 | + if (!empty($incontext['skip'])) { |
|
2048 | + echo ' |
|
1946 | 2049 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="return submitThisOnce(this);" class="button" />'; |
2050 | + } |
|
1947 | 2051 | echo ' |
1948 | 2052 | </div>'; |
1949 | 2053 | } |
1950 | 2054 | |
1951 | 2055 | // Show the closing form tag and other data only if not in the last step |
1952 | - if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) |
|
1953 | - echo ' |
|
2056 | + if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) { |
|
2057 | + echo ' |
|
1954 | 2058 | </form>'; |
2059 | + } |
|
1955 | 2060 | |
1956 | 2061 | echo ' |
1957 | 2062 | </div> |
@@ -1986,13 +2091,15 @@ discard block |
||
1986 | 2091 | </div>'; |
1987 | 2092 | |
1988 | 2093 | // Show the warnings, or not. |
1989 | - if (template_warning_divs()) |
|
1990 | - echo ' |
|
2094 | + if (template_warning_divs()) { |
|
2095 | + echo ' |
|
1991 | 2096 | <h3>', $txt['install_all_lovely'], '</h3>'; |
2097 | + } |
|
1992 | 2098 | |
1993 | 2099 | // Say we want the continue button! |
1994 | - if (empty($incontext['error'])) |
|
1995 | - $incontext['continue'] = 1; |
|
2100 | + if (empty($incontext['error'])) { |
|
2101 | + $incontext['continue'] = 1; |
|
2102 | + } |
|
1996 | 2103 | |
1997 | 2104 | // For the latest version stuff. |
1998 | 2105 | echo ' |
@@ -2026,8 +2133,8 @@ discard block |
||
2026 | 2133 | global $txt, $incontext; |
2027 | 2134 | |
2028 | 2135 | // Errors are very serious.. |
2029 | - if (!empty($incontext['error'])) |
|
2030 | - echo ' |
|
2136 | + if (!empty($incontext['error'])) { |
|
2137 | + echo ' |
|
2031 | 2138 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
2032 | 2139 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
2033 | 2140 | <strong style="text-decoration: underline;">', $txt['upgrade_critical_error'], '</strong><br> |
@@ -2035,9 +2142,10 @@ discard block |
||
2035 | 2142 | ', $incontext['error'], ' |
2036 | 2143 | </div> |
2037 | 2144 | </div>'; |
2145 | + } |
|
2038 | 2146 | // A warning message? |
2039 | - elseif (!empty($incontext['warning'])) |
|
2040 | - echo ' |
|
2147 | + elseif (!empty($incontext['warning'])) { |
|
2148 | + echo ' |
|
2041 | 2149 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
2042 | 2150 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
2043 | 2151 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -2045,6 +2153,7 @@ discard block |
||
2045 | 2153 | ', $incontext['warning'], ' |
2046 | 2154 | </div> |
2047 | 2155 | </div>'; |
2156 | + } |
|
2048 | 2157 | |
2049 | 2158 | return empty($incontext['error']) && empty($incontext['warning']); |
2050 | 2159 | } |
@@ -2060,27 +2169,30 @@ discard block |
||
2060 | 2169 | <li>', $incontext['failed_files']), '</li> |
2061 | 2170 | </ul>'; |
2062 | 2171 | |
2063 | - if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') |
|
2064 | - echo ' |
|
2172 | + if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') { |
|
2173 | + echo ' |
|
2065 | 2174 | <hr> |
2066 | 2175 | <p>', $txt['chmod_linux_info'], '</p> |
2067 | 2176 | <tt># chmod a+w ', implode(' ' . $incontext['detected_path'] . '/', $incontext['failed_files']), '</tt>'; |
2177 | + } |
|
2068 | 2178 | |
2069 | 2179 | // This is serious! |
2070 | - if (!template_warning_divs()) |
|
2071 | - return; |
|
2180 | + if (!template_warning_divs()) { |
|
2181 | + return; |
|
2182 | + } |
|
2072 | 2183 | |
2073 | 2184 | echo ' |
2074 | 2185 | <hr> |
2075 | 2186 | <p>', $txt['ftp_setup_info'], '</p>'; |
2076 | 2187 | |
2077 | - if (!empty($incontext['ftp_errors'])) |
|
2078 | - echo ' |
|
2188 | + if (!empty($incontext['ftp_errors'])) { |
|
2189 | + echo ' |
|
2079 | 2190 | <div class="error_message"> |
2080 | 2191 | ', $txt['error_ftp_no_connect'], '<br><br> |
2081 | 2192 | <code>', implode('<br>', $incontext['ftp_errors']), '</code> |
2082 | 2193 | </div> |
2083 | 2194 | <br>'; |
2195 | + } |
|
2084 | 2196 | |
2085 | 2197 | echo ' |
2086 | 2198 | <form action="', $incontext['form_url'], '" method="post"> |
@@ -2140,17 +2252,17 @@ discard block |
||
2140 | 2252 | <td> |
2141 | 2253 | <select name="db_type" id="db_type_input" onchange="toggleDBInput();">'; |
2142 | 2254 | |
2143 | - foreach ($incontext['supported_databases'] as $key => $db) |
|
2144 | - echo ' |
|
2255 | + foreach ($incontext['supported_databases'] as $key => $db) { |
|
2256 | + echo ' |
|
2145 | 2257 | <option value="', $key, '"', isset($_POST['db_type']) && $_POST['db_type'] == $key ? ' selected' : '', '>', $db['name'], '</option>'; |
2258 | + } |
|
2146 | 2259 | |
2147 | 2260 | echo ' |
2148 | 2261 | </select> |
2149 | 2262 | <div class="smalltext block">', $txt['db_settings_type_info'], '</div> |
2150 | 2263 | </td> |
2151 | 2264 | </tr>'; |
2152 | - } |
|
2153 | - else |
|
2265 | + } else |
|
2154 | 2266 | { |
2155 | 2267 | echo ' |
2156 | 2268 | <tr style="display: none;"> |
@@ -2343,9 +2455,10 @@ discard block |
||
2343 | 2455 | <div style="color: red;">', $txt['error_db_queries'], '</div> |
2344 | 2456 | <ul>'; |
2345 | 2457 | |
2346 | - foreach ($incontext['failures'] as $line => $fail) |
|
2347 | - echo ' |
|
2458 | + foreach ($incontext['failures'] as $line => $fail) { |
|
2459 | + echo ' |
|
2348 | 2460 | <li><strong>', $txt['error_db_queries_line'], $line + 1, ':</strong> ', nl2br(htmlspecialchars($fail)), '</li>'; |
2461 | + } |
|
2349 | 2462 | |
2350 | 2463 | echo ' |
2351 | 2464 | </ul>'; |
@@ -2406,15 +2519,16 @@ discard block |
||
2406 | 2519 | </tr> |
2407 | 2520 | </table>'; |
2408 | 2521 | |
2409 | - if ($incontext['require_db_confirm']) |
|
2410 | - echo ' |
|
2522 | + if ($incontext['require_db_confirm']) { |
|
2523 | + echo ' |
|
2411 | 2524 | <h2>', $txt['user_settings_database'], '</h2> |
2412 | 2525 | <p>', $txt['user_settings_database_info'], '</p> |
2413 | 2526 | |
2414 | 2527 | <div style="margin-bottom: 2ex; padding-', $txt['lang_rtl'] == false ? 'left' : 'right', ': 50px;"> |
2415 | 2528 | <input type="password" name="password3" size="30" /> |
2416 | 2529 | </div>'; |
2417 | -} |
|
2530 | + } |
|
2531 | + } |
|
2418 | 2532 | |
2419 | 2533 | // Tell them it's done, and to delete. |
2420 | 2534 | function template_delete_install() |
@@ -2427,14 +2541,15 @@ discard block |
||
2427 | 2541 | template_warning_divs(); |
2428 | 2542 | |
2429 | 2543 | // Install directory still writable? |
2430 | - if ($incontext['dir_still_writable']) |
|
2431 | - echo ' |
|
2544 | + if ($incontext['dir_still_writable']) { |
|
2545 | + echo ' |
|
2432 | 2546 | <em>', $txt['still_writable'], '</em><br> |
2433 | 2547 | <br>'; |
2548 | + } |
|
2434 | 2549 | |
2435 | 2550 | // Don't show the box if it's like 99% sure it won't work :P. |
2436 | - if ($incontext['probably_delete_install']) |
|
2437 | - echo ' |
|
2551 | + if ($incontext['probably_delete_install']) { |
|
2552 | + echo ' |
|
2438 | 2553 | <div style="margin: 1ex; font-weight: bold;"> |
2439 | 2554 | <label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete();" /> ', $txt['delete_installer'], !isset($_SESSION['installer_temp_ftp']) ? ' ' . $txt['delete_installer_maybe'] : '', '</label> |
2440 | 2555 | </div> |
@@ -2450,6 +2565,7 @@ discard block |
||
2450 | 2565 | } |
2451 | 2566 | </script> |
2452 | 2567 | <br>'; |
2568 | + } |
|
2453 | 2569 | |
2454 | 2570 | echo ' |
2455 | 2571 | ', sprintf($txt['go_to_your_forum'], $boardurl . '/index.php'), '<br> |
@@ -31,9 +31,10 @@ discard block |
||
31 | 31 | <div class="selectbox floatright" id="upper_show">', $txt['who_show1'], ' |
32 | 32 | <select name="show_top" onchange="document.forms.whoFilter.show.value = this.value; document.forms.whoFilter.submit();">'; |
33 | 33 | |
34 | - foreach ($context['show_methods'] as $value => $label) |
|
35 | - echo ' |
|
34 | + foreach ($context['show_methods'] as $value => $label) { |
|
35 | + echo ' |
|
36 | 36 | <option value="', $value, '" ', $value == $context['show_by'] ? ' selected' : '', '>', $label, '</option>'; |
37 | + } |
|
37 | 38 | echo ' |
38 | 39 | </select> |
39 | 40 | <noscript> |
@@ -71,9 +72,10 @@ discard block |
||
71 | 72 | ', $member['is_guest'] ? $member['name'] : '<a href="' . $member['href'] . '" title="' . $txt['profile_of'] . ' ' . $member['name'] . '"' . (empty($member['color']) ? '' : ' style="color: ' . $member['color'] . '"') . '>' . $member['name'] . '</a>', ' |
72 | 73 | </span>'; |
73 | 74 | |
74 | - if (!empty($member['ip'])) |
|
75 | - echo ' |
|
75 | + if (!empty($member['ip'])) { |
|
76 | + echo ' |
|
76 | 77 | (<a href="' . $scripturl . '?action=', ($member['is_guest'] ? 'trackip' : 'profile;area=tracking;sa=ip;u=' . $member['id']), ';searchip=' . $member['ip'] . '">' . $member['ip'] . '</a>)'; |
78 | + } |
|
77 | 79 | |
78 | 80 | echo ' |
79 | 81 | </td> |
@@ -103,9 +105,10 @@ discard block |
||
103 | 105 | <div class="selectbox floatright">', $txt['who_show1'], ' |
104 | 106 | <select name="show" onchange="document.forms.whoFilter.submit();">'; |
105 | 107 | |
106 | - foreach ($context['show_methods'] as $value => $label) |
|
107 | - echo ' |
|
108 | + foreach ($context['show_methods'] as $value => $label) { |
|
109 | + echo ' |
|
108 | 110 | <option value="', $value, '" ', $value == $context['show_by'] ? ' selected' : '', '>', $label, '</option>'; |
111 | + } |
|
109 | 112 | echo ' |
110 | 113 | </select> |
111 | 114 | <noscript> |
@@ -134,17 +137,19 @@ discard block |
||
134 | 137 | |
135 | 138 | foreach ($context['credits'] as $section) |
136 | 139 | { |
137 | - if (isset($section['pretext'])) |
|
138 | - echo ' |
|
140 | + if (isset($section['pretext'])) { |
|
141 | + echo ' |
|
139 | 142 | <div class="windowbg noup"> |
140 | 143 | <p>', $section['pretext'], '</p> |
141 | 144 | </div>'; |
145 | + } |
|
142 | 146 | |
143 | - if (isset($section['title'])) |
|
144 | - echo ' |
|
147 | + if (isset($section['title'])) { |
|
148 | + echo ' |
|
145 | 149 | <div class="cat_bar"> |
146 | 150 | <h3 class="catbg">', $section['title'], '</h3> |
147 | 151 | </div>'; |
152 | + } |
|
148 | 153 | |
149 | 154 | echo ' |
150 | 155 | <div class="windowbg2 noup"> |
@@ -152,17 +157,18 @@ discard block |
||
152 | 157 | |
153 | 158 | foreach ($section['groups'] as $group) |
154 | 159 | { |
155 | - if (isset($group['title'])) |
|
156 | - echo ' |
|
160 | + if (isset($group['title'])) { |
|
161 | + echo ' |
|
157 | 162 | <dt> |
158 | 163 | <strong>', $group['title'], '</strong> |
159 | 164 | </dt> |
160 | 165 | <dd>'; |
166 | + } |
|
161 | 167 | |
162 | 168 | // Try to make this read nicely. |
163 | - if (count($group['members']) <= 2) |
|
164 | - echo implode(' ' . $txt['credits_and'] . ' ', $group['members']); |
|
165 | - else |
|
169 | + if (count($group['members']) <= 2) { |
|
170 | + echo implode(' ' . $txt['credits_and'] . ' ', $group['members']); |
|
171 | + } else |
|
166 | 172 | { |
167 | 173 | $last_peep = array_pop($group['members']); |
168 | 174 | echo implode(', ', $group['members']), ' ', $txt['credits_and'], ' ', $last_peep; |
@@ -175,9 +181,10 @@ discard block |
||
175 | 181 | echo ' |
176 | 182 | </dl>'; |
177 | 183 | |
178 | - if (isset($section['posttext'])) |
|
179 | - echo ' |
|
184 | + if (isset($section['posttext'])) { |
|
185 | + echo ' |
|
180 | 186 | <p class="posttext">', $section['posttext'], '</p>'; |
187 | + } |
|
181 | 188 | |
182 | 189 | echo ' |
183 | 190 | </div>'; |
@@ -192,26 +199,29 @@ discard block |
||
192 | 199 | </div> |
193 | 200 | <div class="windowbg noup">'; |
194 | 201 | |
195 | - if (!empty($context['credits_software_graphics']['graphics'])) |
|
196 | - echo ' |
|
202 | + if (!empty($context['credits_software_graphics']['graphics'])) { |
|
203 | + echo ' |
|
197 | 204 | <dl> |
198 | 205 | <dt><strong>', $txt['credits_graphics'], '</strong></dt> |
199 | 206 | <dd>', implode('</dd><dd>', $context['credits_software_graphics']['graphics']), '</dd> |
200 | 207 | </dl>'; |
208 | + } |
|
201 | 209 | |
202 | - if (!empty($context['credits_software_graphics']['software'])) |
|
203 | - echo ' |
|
210 | + if (!empty($context['credits_software_graphics']['software'])) { |
|
211 | + echo ' |
|
204 | 212 | <dl> |
205 | 213 | <dt><strong>', $txt['credits_software'], '</strong></dt> |
206 | 214 | <dd>', implode('</dd><dd>', $context['credits_software_graphics']['software']), '</dd> |
207 | 215 | </dl>'; |
216 | + } |
|
208 | 217 | |
209 | - if (!empty($context['credits_software_graphics']['fonts'])) |
|
210 | - echo ' |
|
218 | + if (!empty($context['credits_software_graphics']['fonts'])) { |
|
219 | + echo ' |
|
211 | 220 | <dl> |
212 | 221 | <dt><strong>', $txt['credits_fonts'], '</strong></dt> |
213 | 222 | <dd>', implode('</dd><dd>', $context['credits_software_graphics']['fonts']), '</dd> |
214 | 223 | </dl>'; |
224 | + } |
|
215 | 225 | echo ' |
216 | 226 | </div>'; |
217 | 227 | } |
@@ -227,14 +237,16 @@ discard block |
||
227 | 237 | <ul>'; |
228 | 238 | |
229 | 239 | // Display the credits. |
230 | - if (!empty($context['credits_modifications'])) |
|
231 | - echo ' |
|
240 | + if (!empty($context['credits_modifications'])) { |
|
241 | + echo ' |
|
232 | 242 | <li>', implode('</li><li>', $context['credits_modifications']), '</li>'; |
243 | + } |
|
233 | 244 | |
234 | 245 | // Legacy. |
235 | - if (!empty($context['copyrights']['mods'])) |
|
236 | - echo ' |
|
246 | + if (!empty($context['copyrights']['mods'])) { |
|
247 | + echo ' |
|
237 | 248 | <li>', implode('</li><li>', $context['copyrights']['mods']), '</li>'; |
249 | + } |
|
238 | 250 | |
239 | 251 | echo ' |
240 | 252 | </ul> |
@@ -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 | * The central part of the board - topic display. |
@@ -34,8 +35,9 @@ discard block |
||
34 | 35 | global $messages_request, $language, $smcFunc; |
35 | 36 | |
36 | 37 | // What are you gonna display if these are empty?! |
37 | - if (empty($topic)) |
|
38 | - fatal_lang_error('no_board', false); |
|
38 | + if (empty($topic)) { |
|
39 | + fatal_lang_error('no_board', false); |
|
40 | + } |
|
39 | 41 | |
40 | 42 | // Load the proper template. |
41 | 43 | loadTemplate('Display'); |
@@ -52,15 +54,17 @@ discard block |
||
52 | 54 | $context['messages_per_page'] = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
53 | 55 | |
54 | 56 | // Let's do some work on what to search index. |
55 | - if (count($_GET) > 2) |
|
56 | - foreach ($_GET as $k => $v) |
|
57 | + if (count($_GET) > 2) { |
|
58 | + foreach ($_GET as $k => $v) |
|
57 | 59 | { |
58 | 60 | if (!in_array($k, array('topic', 'board', 'start', session_name()))) |
59 | 61 | $context['robot_no_index'] = true; |
62 | + } |
|
60 | 63 | } |
61 | 64 | |
62 | - if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) |
|
63 | - $context['robot_no_index'] = true; |
|
65 | + if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) { |
|
66 | + $context['robot_no_index'] = true; |
|
67 | + } |
|
64 | 68 | |
65 | 69 | // Find the previous or next topic. Make a fuss if there are no more. |
66 | 70 | if (isset($_REQUEST['prev_next']) && ($_REQUEST['prev_next'] == 'prev' || $_REQUEST['prev_next'] == 'next')) |
@@ -172,8 +176,9 @@ discard block |
||
172 | 176 | $topic_parameters |
173 | 177 | ); |
174 | 178 | |
175 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
176 | - fatal_lang_error('not_a_topic', false, 404); |
|
179 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
180 | + fatal_lang_error('not_a_topic', false, 404); |
|
181 | + } |
|
177 | 182 | $context['topicinfo'] = $smcFunc['db_fetch_assoc']($request); |
178 | 183 | $smcFunc['db_free_result']($request); |
179 | 184 | |
@@ -210,8 +215,9 @@ discard block |
||
210 | 215 | $context['topic_unwatched'] = isset($context['topicinfo']['unwatched']) ? $context['topicinfo']['unwatched'] : 0; |
211 | 216 | |
212 | 217 | // Add up unapproved replies to get real number of replies... |
213 | - if ($modSettings['postmod_active'] && $approve_posts) |
|
214 | - $context['real_num_replies'] += $context['topicinfo']['unapproved_posts'] - ($context['topicinfo']['approved'] ? 0 : 1); |
|
218 | + if ($modSettings['postmod_active'] && $approve_posts) { |
|
219 | + $context['real_num_replies'] += $context['topicinfo']['unapproved_posts'] - ($context['topicinfo']['approved'] ? 0 : 1); |
|
220 | + } |
|
215 | 221 | |
216 | 222 | // If this topic has unapproved posts, we need to work out how many posts the user can see, for page indexing. |
217 | 223 | if ($modSettings['postmod_active'] && $context['topicinfo']['unapproved_posts'] && !$user_info['is_guest'] && !$approve_posts) |
@@ -231,11 +237,11 @@ discard block |
||
231 | 237 | $smcFunc['db_free_result']($request); |
232 | 238 | |
233 | 239 | $context['total_visible_posts'] = $context['num_replies'] + $myUnapprovedPosts + ($context['topicinfo']['approved'] ? 1 : 0); |
240 | + } elseif ($user_info['is_guest']) { |
|
241 | + $context['total_visible_posts'] = $context['num_replies'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
242 | + } else { |
|
243 | + $context['total_visible_posts'] = $context['num_replies'] + $context['topicinfo']['unapproved_posts'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
234 | 244 | } |
235 | - elseif ($user_info['is_guest']) |
|
236 | - $context['total_visible_posts'] = $context['num_replies'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
237 | - else |
|
238 | - $context['total_visible_posts'] = $context['num_replies'] + $context['topicinfo']['unapproved_posts'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
239 | 245 | |
240 | 246 | // The start isn't a number; it's information about what to do, where to go. |
241 | 247 | if (!is_numeric($_REQUEST['start'])) |
@@ -248,8 +254,7 @@ discard block |
||
248 | 254 | { |
249 | 255 | $context['start_from'] = $context['total_visible_posts'] - 1; |
250 | 256 | $_REQUEST['start'] = empty($options['view_newest_first']) ? $context['start_from'] : 0; |
251 | - } |
|
252 | - else |
|
257 | + } else |
|
253 | 258 | { |
254 | 259 | // Find the earliest unread message in the topic. (the use of topics here is just for both tables.) |
255 | 260 | $request = $smcFunc['db_query']('', ' |
@@ -277,9 +282,9 @@ discard block |
||
277 | 282 | if (substr($_REQUEST['start'], 0, 4) == 'from') |
278 | 283 | { |
279 | 284 | $timestamp = (int) substr($_REQUEST['start'], 4); |
280 | - if ($timestamp === 0) |
|
281 | - $_REQUEST['start'] = 0; |
|
282 | - else |
|
285 | + if ($timestamp === 0) { |
|
286 | + $_REQUEST['start'] = 0; |
|
287 | + } else |
|
283 | 288 | { |
284 | 289 | // Find the number of messages posted before said time... |
285 | 290 | $request = $smcFunc['db_query']('', ' |
@@ -307,11 +312,11 @@ discard block |
||
307 | 312 | elseif (substr($_REQUEST['start'], 0, 3) == 'msg') |
308 | 313 | { |
309 | 314 | $virtual_msg = (int) substr($_REQUEST['start'], 3); |
310 | - if (!$context['topicinfo']['unapproved_posts'] && $virtual_msg >= $context['topicinfo']['id_last_msg']) |
|
311 | - $context['start_from'] = $context['total_visible_posts'] - 1; |
|
312 | - elseif (!$context['topicinfo']['unapproved_posts'] && $virtual_msg <= $context['topicinfo']['id_first_msg']) |
|
313 | - $context['start_from'] = 0; |
|
314 | - else |
|
315 | + if (!$context['topicinfo']['unapproved_posts'] && $virtual_msg >= $context['topicinfo']['id_last_msg']) { |
|
316 | + $context['start_from'] = $context['total_visible_posts'] - 1; |
|
317 | + } elseif (!$context['topicinfo']['unapproved_posts'] && $virtual_msg <= $context['topicinfo']['id_first_msg']) { |
|
318 | + $context['start_from'] = 0; |
|
319 | + } else |
|
315 | 320 | { |
316 | 321 | // Find the start value for that message...... |
317 | 322 | $request = $smcFunc['db_query']('', ' |
@@ -394,21 +399,25 @@ discard block |
||
394 | 399 | ); |
395 | 400 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
396 | 401 | { |
397 | - if (empty($row['id_member'])) |
|
398 | - continue; |
|
402 | + if (empty($row['id_member'])) { |
|
403 | + continue; |
|
404 | + } |
|
399 | 405 | |
400 | - if (!empty($row['online_color'])) |
|
401 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
402 | - else |
|
403 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
406 | + if (!empty($row['online_color'])) { |
|
407 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
408 | + } else { |
|
409 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
410 | + } |
|
404 | 411 | |
405 | 412 | $is_buddy = in_array($row['id_member'], $user_info['buddies']); |
406 | - if ($is_buddy) |
|
407 | - $link = '<strong>' . $link . '</strong>'; |
|
413 | + if ($is_buddy) { |
|
414 | + $link = '<strong>' . $link . '</strong>'; |
|
415 | + } |
|
408 | 416 | |
409 | 417 | // Add them both to the list and to the more detailed list. |
410 | - if (!empty($row['show_online']) || allowedTo('moderate_forum')) |
|
411 | - $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
418 | + if (!empty($row['show_online']) || allowedTo('moderate_forum')) { |
|
419 | + $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
420 | + } |
|
412 | 421 | $context['view_members'][$row['log_time'] . $row['member_name']] = array( |
413 | 422 | 'id' => $row['id_member'], |
414 | 423 | 'username' => $row['member_name'], |
@@ -420,8 +429,9 @@ discard block |
||
420 | 429 | 'hidden' => empty($row['show_online']), |
421 | 430 | ); |
422 | 431 | |
423 | - if (empty($row['show_online'])) |
|
424 | - $context['view_num_hidden']++; |
|
432 | + if (empty($row['show_online'])) { |
|
433 | + $context['view_num_hidden']++; |
|
434 | + } |
|
425 | 435 | } |
426 | 436 | |
427 | 437 | // The number of guests is equal to the rows minus the ones we actually used ;). |
@@ -435,11 +445,13 @@ discard block |
||
435 | 445 | |
436 | 446 | // If all is set, but not allowed... just unset it. |
437 | 447 | $can_show_all = !empty($modSettings['enableAllMessages']) && $context['total_visible_posts'] > $context['messages_per_page'] && $context['total_visible_posts'] < $modSettings['enableAllMessages']; |
438 | - if (isset($_REQUEST['all']) && !$can_show_all) |
|
439 | - unset($_REQUEST['all']); |
|
448 | + if (isset($_REQUEST['all']) && !$can_show_all) { |
|
449 | + unset($_REQUEST['all']); |
|
450 | + } |
|
440 | 451 | // Otherwise, it must be allowed... so pretend start was -1. |
441 | - elseif (isset($_REQUEST['all'])) |
|
442 | - $_REQUEST['start'] = -1; |
|
452 | + elseif (isset($_REQUEST['all'])) { |
|
453 | + $_REQUEST['start'] = -1; |
|
454 | + } |
|
443 | 455 | |
444 | 456 | // Construct the page index, allowing for the .START method... |
445 | 457 | $context['page_index'] = constructPageIndex($scripturl . '?topic=' . $topic . '.%1$d', $_REQUEST['start'], $context['total_visible_posts'], $context['messages_per_page'], true); |
@@ -476,8 +488,9 @@ discard block |
||
476 | 488 | $_REQUEST['start'] = 0; |
477 | 489 | } |
478 | 490 | // They aren't using it, but the *option* is there, at least. |
479 | - else |
|
480 | - $context['page_index'] .= ' <a href="' . $scripturl . '?topic=' . $topic . '.0;all">' . $txt['all'] . '</a> '; |
|
491 | + else { |
|
492 | + $context['page_index'] .= ' <a href="' . $scripturl . '?topic=' . $topic . '.0;all">' . $txt['all'] . '</a> '; |
|
493 | + } |
|
481 | 494 | } |
482 | 495 | |
483 | 496 | // Build the link tree. |
@@ -493,14 +506,16 @@ discard block |
||
493 | 506 | if (!empty($board_info['moderators'])) |
494 | 507 | { |
495 | 508 | // Add a link for each moderator... |
496 | - foreach ($board_info['moderators'] as $mod) |
|
497 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
509 | + foreach ($board_info['moderators'] as $mod) { |
|
510 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
511 | + } |
|
498 | 512 | } |
499 | 513 | if (!empty($board_info['moderator_groups'])) |
500 | 514 | { |
501 | 515 | // Add a link for each moderator group as well... |
502 | - foreach ($board_info['moderator_groups'] as $mod_group) |
|
503 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=viewmemberes;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
516 | + foreach ($board_info['moderator_groups'] as $mod_group) { |
|
517 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=viewmemberes;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
518 | + } |
|
504 | 519 | } |
505 | 520 | |
506 | 521 | if (!empty($context['link_moderators'])) |
@@ -531,9 +546,9 @@ discard block |
||
531 | 546 | // For quick reply we need a response prefix in the default forum language. |
532 | 547 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix', 600))) |
533 | 548 | { |
534 | - if ($language === $user_info['language']) |
|
535 | - $context['response_prefix'] = $txt['response_prefix']; |
|
536 | - else |
|
549 | + if ($language === $user_info['language']) { |
|
550 | + $context['response_prefix'] = $txt['response_prefix']; |
|
551 | + } else |
|
537 | 552 | { |
538 | 553 | loadLanguage('index', $language, false); |
539 | 554 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -565,8 +580,9 @@ discard block |
||
565 | 580 | list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row); |
566 | 581 | |
567 | 582 | // Sanity check |
568 | - if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) |
|
569 | - continue; |
|
583 | + if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) { |
|
584 | + continue; |
|
585 | + } |
|
570 | 586 | |
571 | 587 | $linked_calendar_event = array( |
572 | 588 | 'id' => $row['id_event'], |
@@ -615,8 +631,9 @@ discard block |
||
615 | 631 | } |
616 | 632 | $smcFunc['db_free_result']($request); |
617 | 633 | |
618 | - if (!empty($context['linked_calendar_events'])) |
|
619 | - $context['linked_calendar_events'][count($context['linked_calendar_events']) - 1]['is_last'] = true; |
|
634 | + if (!empty($context['linked_calendar_events'])) { |
|
635 | + $context['linked_calendar_events'][count($context['linked_calendar_events']) - 1]['is_last'] = true; |
|
636 | + } |
|
620 | 637 | } |
621 | 638 | |
622 | 639 | // Create the poll info if it exists. |
@@ -679,8 +696,9 @@ discard block |
||
679 | 696 | $smcFunc['db_free_result']($request); |
680 | 697 | |
681 | 698 | // Got we multi choice? |
682 | - if ($pollinfo['max_votes'] > 1) |
|
683 | - $realtotal = $pollinfo['total']; |
|
699 | + if ($pollinfo['max_votes'] > 1) { |
|
700 | + $realtotal = $pollinfo['total']; |
|
701 | + } |
|
684 | 702 | |
685 | 703 | // If this is a guest we need to do our best to work out if they have voted, and what they voted for. |
686 | 704 | if ($user_info['is_guest'] && $pollinfo['guest_vote'] && allowedTo('poll_vote')) |
@@ -693,20 +711,21 @@ discard block |
||
693 | 711 | foreach ($guestinfo as $i => $guestvoted) |
694 | 712 | { |
695 | 713 | $guestvoted = explode(',', $guestvoted); |
696 | - if ($guestvoted[0] == $context['topicinfo']['id_poll']) |
|
697 | - break; |
|
714 | + if ($guestvoted[0] == $context['topicinfo']['id_poll']) { |
|
715 | + break; |
|
716 | + } |
|
698 | 717 | } |
699 | 718 | // Has the poll been reset since guest voted? |
700 | 719 | if ($pollinfo['reset_poll'] > $guestvoted[1]) |
701 | 720 | { |
702 | 721 | // Remove the poll info from the cookie to allow guest to vote again |
703 | 722 | unset($guestinfo[$i]); |
704 | - if (!empty($guestinfo)) |
|
705 | - $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
706 | - else |
|
707 | - unset($_COOKIE['guest_poll_vote']); |
|
708 | - } |
|
709 | - else |
|
723 | + if (!empty($guestinfo)) { |
|
724 | + $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
725 | + } else { |
|
726 | + unset($_COOKIE['guest_poll_vote']); |
|
727 | + } |
|
728 | + } else |
|
710 | 729 | { |
711 | 730 | // What did they vote for? |
712 | 731 | unset($guestvoted[0], $guestvoted[1]); |
@@ -820,23 +839,29 @@ discard block |
||
820 | 839 | // Build the poll moderation button array. |
821 | 840 | $context['poll_buttons'] = array(); |
822 | 841 | |
823 | - if ($context['allow_return_vote']) |
|
824 | - $context['poll_buttons']['vote'] = array('text' => 'poll_return_vote', 'image' => 'poll_options.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start']); |
|
842 | + if ($context['allow_return_vote']) { |
|
843 | + $context['poll_buttons']['vote'] = array('text' => 'poll_return_vote', 'image' => 'poll_options.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start']); |
|
844 | + } |
|
825 | 845 | |
826 | - if ($context['show_view_results_button']) |
|
827 | - $context['poll_buttons']['results'] = array('text' => 'poll_results', 'image' => 'poll_results.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start'] . ';viewresults'); |
|
846 | + if ($context['show_view_results_button']) { |
|
847 | + $context['poll_buttons']['results'] = array('text' => 'poll_results', 'image' => 'poll_results.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start'] . ';viewresults'); |
|
848 | + } |
|
828 | 849 | |
829 | - if ($context['allow_change_vote']) |
|
830 | - $context['poll_buttons']['change_vote'] = array('text' => 'poll_change_vote', 'image' => 'poll_change_vote.png', 'url' => $scripturl . '?action=vote;topic=' . $context['current_topic'] . '.' . $context['start'] . ';poll=' . $context['poll']['id'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
850 | + if ($context['allow_change_vote']) { |
|
851 | + $context['poll_buttons']['change_vote'] = array('text' => 'poll_change_vote', 'image' => 'poll_change_vote.png', 'url' => $scripturl . '?action=vote;topic=' . $context['current_topic'] . '.' . $context['start'] . ';poll=' . $context['poll']['id'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
852 | + } |
|
831 | 853 | |
832 | - if ($context['allow_lock_poll']) |
|
833 | - $context['poll_buttons']['lock'] = array('text' => (!$context['poll']['is_locked'] ? 'poll_lock' : 'poll_unlock'), 'image' => 'poll_lock.png', 'url' => $scripturl . '?action=lockvoting;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
854 | + if ($context['allow_lock_poll']) { |
|
855 | + $context['poll_buttons']['lock'] = array('text' => (!$context['poll']['is_locked'] ? 'poll_lock' : 'poll_unlock'), 'image' => 'poll_lock.png', 'url' => $scripturl . '?action=lockvoting;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
856 | + } |
|
834 | 857 | |
835 | - if ($context['allow_edit_poll']) |
|
836 | - $context['poll_buttons']['edit'] = array('text' => 'poll_edit', 'image' => 'poll_edit.png', 'url' => $scripturl . '?action=editpoll;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
858 | + if ($context['allow_edit_poll']) { |
|
859 | + $context['poll_buttons']['edit'] = array('text' => 'poll_edit', 'image' => 'poll_edit.png', 'url' => $scripturl . '?action=editpoll;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
860 | + } |
|
837 | 861 | |
838 | - if ($context['can_remove_poll']) |
|
839 | - $context['poll_buttons']['remove_poll'] = array('text' => 'poll_remove', 'image' => 'admin_remove_poll.png', 'custom' => 'data-confirm="' . $txt['poll_remove_warn'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removepoll;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
862 | + if ($context['can_remove_poll']) { |
|
863 | + $context['poll_buttons']['remove_poll'] = array('text' => 'poll_remove', 'image' => 'admin_remove_poll.png', 'custom' => 'data-confirm="' . $txt['poll_remove_warn'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removepoll;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
864 | + } |
|
840 | 865 | |
841 | 866 | // Allow mods to add additional buttons here |
842 | 867 | call_integration_hook('integrate_poll_buttons'); |
@@ -871,9 +896,9 @@ discard block |
||
871 | 896 | { |
872 | 897 | $start_char = 'C'; |
873 | 898 | $page_id = $context['topicinfo']['id_first_msg']; |
899 | + } else { |
|
900 | + $start_char = null; |
|
874 | 901 | } |
875 | - else |
|
876 | - $start_char = null; |
|
877 | 902 | |
878 | 903 | $limit = $context['messages_per_page']; |
879 | 904 | |
@@ -888,17 +913,17 @@ discard block |
||
888 | 913 | { |
889 | 914 | $ascending = true; |
890 | 915 | $page_operator = '>='; |
891 | - } |
|
892 | - else |
|
916 | + } else |
|
893 | 917 | { |
894 | 918 | $ascending = false; |
895 | 919 | $page_operator = '<='; |
896 | 920 | } |
897 | 921 | |
898 | - if ($start_char === 'C') |
|
899 | - $limit_seek = $limit; |
|
900 | - else |
|
901 | - $limit_seek = $limit + 1; |
|
922 | + if ($start_char === 'C') { |
|
923 | + $limit_seek = $limit; |
|
924 | + } else { |
|
925 | + $limit_seek = $limit + 1; |
|
926 | + } |
|
902 | 927 | |
903 | 928 | $request = $smcFunc['db_query']('', ' |
904 | 929 | SELECT id_msg, id_member, approved |
@@ -921,21 +946,23 @@ discard block |
||
921 | 946 | $found_msg = false; |
922 | 947 | |
923 | 948 | // Fallback |
924 | - if ($smcFunc['db_num_rows']($request) < 1) |
|
925 | - unset($start_char); |
|
926 | - else |
|
949 | + if ($smcFunc['db_num_rows']($request) < 1) { |
|
950 | + unset($start_char); |
|
951 | + } else |
|
927 | 952 | { |
928 | 953 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
929 | 954 | { |
930 | 955 | // Check if the start msg is in our result |
931 | - if ($row['id_msg'] == $page_id) |
|
932 | - $found_msg = true; |
|
956 | + if ($row['id_msg'] == $page_id) { |
|
957 | + $found_msg = true; |
|
958 | + } |
|
933 | 959 | |
934 | 960 | // Skip the the start msg if we not in mode C |
935 | 961 | if ($start_char === 'C' || $row['id_msg'] != $page_id) |
936 | 962 | { |
937 | - if (!empty($row['id_member'])) |
|
938 | - $all_posters[$row['id_msg']] = $row['id_member']; |
|
963 | + if (!empty($row['id_member'])) { |
|
964 | + $all_posters[$row['id_msg']] = $row['id_member']; |
|
965 | + } |
|
939 | 966 | |
940 | 967 | $messages[] = $row['id_msg']; |
941 | 968 | } |
@@ -951,8 +978,9 @@ discard block |
||
951 | 978 | } |
952 | 979 | |
953 | 980 | // Before Page bring in the right order |
954 | - if (!empty($start_char) && $start_char === 'L') |
|
955 | - krsort($messages); |
|
981 | + if (!empty($start_char) && $start_char === 'L') { |
|
982 | + krsort($messages); |
|
983 | + } |
|
956 | 984 | } |
957 | 985 | |
958 | 986 | // Jump to page |
@@ -989,14 +1017,16 @@ discard block |
||
989 | 1017 | |
990 | 1018 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
991 | 1019 | { |
992 | - if (!empty($row['id_member'])) |
|
993 | - $all_posters[$row['id_msg']] = $row['id_member']; |
|
1020 | + if (!empty($row['id_member'])) { |
|
1021 | + $all_posters[$row['id_msg']] = $row['id_member']; |
|
1022 | + } |
|
994 | 1023 | $messages[] = $row['id_msg']; |
995 | 1024 | } |
996 | 1025 | |
997 | 1026 | // Sort the messages into the correct display order |
998 | - if (!$ascending) |
|
999 | - sort($messages); |
|
1027 | + if (!$ascending) { |
|
1028 | + sort($messages); |
|
1029 | + } |
|
1000 | 1030 | } |
1001 | 1031 | |
1002 | 1032 | // Remember the paging data for next time |
@@ -1016,8 +1046,9 @@ discard block |
||
1016 | 1046 | if (!$user_info['is_guest'] && !empty($messages)) |
1017 | 1047 | { |
1018 | 1048 | $mark_at_msg = max($messages); |
1019 | - if ($mark_at_msg >= $context['topicinfo']['id_last_msg']) |
|
1020 | - $mark_at_msg = $modSettings['maxMsgID']; |
|
1049 | + if ($mark_at_msg >= $context['topicinfo']['id_last_msg']) { |
|
1050 | + $mark_at_msg = $modSettings['maxMsgID']; |
|
1051 | + } |
|
1021 | 1052 | if ($mark_at_msg >= $context['topicinfo']['new_from']) |
1022 | 1053 | { |
1023 | 1054 | $smcFunc['db_insert']($context['topicinfo']['new_from'] == 0 ? 'ignore' : 'replace', |
@@ -1049,8 +1080,9 @@ discard block |
||
1049 | 1080 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1050 | 1081 | { |
1051 | 1082 | // Find if this topic is marked for notification... |
1052 | - if (!empty($row['id_topic'])) |
|
1053 | - $context['is_marked_notify'] = true; |
|
1083 | + if (!empty($row['id_topic'])) { |
|
1084 | + $context['is_marked_notify'] = true; |
|
1085 | + } |
|
1054 | 1086 | |
1055 | 1087 | // Only do this once, but mark the notifications as "not sent yet" for next time. |
1056 | 1088 | if (!empty($row['sent']) && $do_once) |
@@ -1072,8 +1104,9 @@ discard block |
||
1072 | 1104 | } |
1073 | 1105 | |
1074 | 1106 | // Have we recently cached the number of new topics in this board, and it's still a lot? |
1075 | - if (isset($_REQUEST['topicseen']) && isset($_SESSION['topicseen_cache'][$board]) && $_SESSION['topicseen_cache'][$board] > 5) |
|
1076 | - $_SESSION['topicseen_cache'][$board]--; |
|
1107 | + if (isset($_REQUEST['topicseen']) && isset($_SESSION['topicseen_cache'][$board]) && $_SESSION['topicseen_cache'][$board] > 5) { |
|
1108 | + $_SESSION['topicseen_cache'][$board]--; |
|
1109 | + } |
|
1077 | 1110 | // Mark board as seen if this is the only new topic. |
1078 | 1111 | elseif (isset($_REQUEST['topicseen'])) |
1079 | 1112 | { |
@@ -1097,14 +1130,16 @@ discard block |
||
1097 | 1130 | $smcFunc['db_free_result']($request); |
1098 | 1131 | |
1099 | 1132 | // If there're no real new topics in this board, mark the board as seen. |
1100 | - if (empty($numNewTopics)) |
|
1101 | - $_REQUEST['boardseen'] = true; |
|
1102 | - else |
|
1103 | - $_SESSION['topicseen_cache'][$board] = $numNewTopics; |
|
1133 | + if (empty($numNewTopics)) { |
|
1134 | + $_REQUEST['boardseen'] = true; |
|
1135 | + } else { |
|
1136 | + $_SESSION['topicseen_cache'][$board] = $numNewTopics; |
|
1137 | + } |
|
1104 | 1138 | } |
1105 | 1139 | // Probably one less topic - maybe not, but even if we decrease this too fast it will only make us look more often. |
1106 | - elseif (isset($_SESSION['topicseen_cache'][$board])) |
|
1107 | - $_SESSION['topicseen_cache'][$board]--; |
|
1140 | + elseif (isset($_SESSION['topicseen_cache'][$board])) { |
|
1141 | + $_SESSION['topicseen_cache'][$board]--; |
|
1142 | + } |
|
1108 | 1143 | |
1109 | 1144 | // Mark board as seen if we came using last post link from BoardIndex. (or other places...) |
1110 | 1145 | if (isset($_REQUEST['boardseen'])) |
@@ -1161,23 +1196,26 @@ discard block |
||
1161 | 1196 | $temp = array(); |
1162 | 1197 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1163 | 1198 | { |
1164 | - if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id'])) |
|
1165 | - continue; |
|
1199 | + if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id'])) { |
|
1200 | + continue; |
|
1201 | + } |
|
1166 | 1202 | |
1167 | 1203 | $temp[$row['id_attach']] = $row; |
1168 | 1204 | $temp[$row['id_attach']]['topic'] = $topic; |
1169 | 1205 | $temp[$row['id_attach']]['board'] = $board; |
1170 | 1206 | |
1171 | - if (!isset($context['loaded_attachments'][$row['id_msg']])) |
|
1172 | - $context['loaded_attachments'][$row['id_msg']] = array(); |
|
1207 | + if (!isset($context['loaded_attachments'][$row['id_msg']])) { |
|
1208 | + $context['loaded_attachments'][$row['id_msg']] = array(); |
|
1209 | + } |
|
1173 | 1210 | } |
1174 | 1211 | $smcFunc['db_free_result']($request); |
1175 | 1212 | |
1176 | 1213 | // This is better than sorting it with the query... |
1177 | 1214 | ksort($temp); |
1178 | 1215 | |
1179 | - foreach ($temp as $row) |
|
1180 | - $context['loaded_attachments'][$row['id_msg']][] = $row; |
|
1216 | + foreach ($temp as $row) { |
|
1217 | + $context['loaded_attachments'][$row['id_msg']][] = $row; |
|
1218 | + } |
|
1181 | 1219 | } |
1182 | 1220 | |
1183 | 1221 | $msg_parameters = array( |
@@ -1204,21 +1242,23 @@ discard block |
||
1204 | 1242 | ); |
1205 | 1243 | |
1206 | 1244 | // And the likes |
1207 | - if (!empty($modSettings['enable_likes'])) |
|
1208 | - $context['my_likes'] = $context['user']['is_guest'] ? array() : prepareLikesContext($topic); |
|
1245 | + if (!empty($modSettings['enable_likes'])) { |
|
1246 | + $context['my_likes'] = $context['user']['is_guest'] ? array() : prepareLikesContext($topic); |
|
1247 | + } |
|
1209 | 1248 | |
1210 | 1249 | // Go to the last message if the given time is beyond the time of the last message. |
1211 | - if (isset($context['start_from']) && $context['start_from'] >= $context['topicinfo']['num_replies']) |
|
1212 | - $context['start_from'] = $context['topicinfo']['num_replies']; |
|
1250 | + if (isset($context['start_from']) && $context['start_from'] >= $context['topicinfo']['num_replies']) { |
|
1251 | + $context['start_from'] = $context['topicinfo']['num_replies']; |
|
1252 | + } |
|
1213 | 1253 | |
1214 | 1254 | // Since the anchor information is needed on the top of the page we load these variables beforehand. |
1215 | 1255 | $context['first_message'] = isset($messages[$firstIndex]) ? $messages[$firstIndex] : $messages[0]; |
1216 | - if (empty($options['view_newest_first'])) |
|
1217 | - $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['start_from']; |
|
1218 | - else |
|
1219 | - $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['topicinfo']['num_replies'] - $context['start_from']; |
|
1220 | - } |
|
1221 | - else |
|
1256 | + if (empty($options['view_newest_first'])) { |
|
1257 | + $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['start_from']; |
|
1258 | + } else { |
|
1259 | + $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['topicinfo']['num_replies'] - $context['start_from']; |
|
1260 | + } |
|
1261 | + } else |
|
1222 | 1262 | { |
1223 | 1263 | $messages_request = false; |
1224 | 1264 | $context['first_message'] = 0; |
@@ -1253,8 +1293,9 @@ discard block |
||
1253 | 1293 | 'can_restore_msg' => 'move_any', |
1254 | 1294 | 'can_like' => 'likes_like', |
1255 | 1295 | ); |
1256 | - foreach ($common_permissions as $contextual => $perm) |
|
1257 | - $context[$contextual] = allowedTo($perm); |
|
1296 | + foreach ($common_permissions as $contextual => $perm) { |
|
1297 | + $context[$contextual] = allowedTo($perm); |
|
1298 | + } |
|
1258 | 1299 | |
1259 | 1300 | // Permissions with _any/_own versions. $context[YYY] => ZZZ_any/_own. |
1260 | 1301 | $anyown_permissions = array( |
@@ -1267,8 +1308,9 @@ discard block |
||
1267 | 1308 | 'can_reply_unapproved' => 'post_unapproved_replies', |
1268 | 1309 | 'can_view_warning' => 'profile_warning', |
1269 | 1310 | ); |
1270 | - foreach ($anyown_permissions as $contextual => $perm) |
|
1271 | - $context[$contextual] = allowedTo($perm . '_any') || ($context['user']['started'] && allowedTo($perm . '_own')); |
|
1311 | + foreach ($anyown_permissions as $contextual => $perm) { |
|
1312 | + $context[$contextual] = allowedTo($perm . '_any') || ($context['user']['started'] && allowedTo($perm . '_own')); |
|
1313 | + } |
|
1272 | 1314 | |
1273 | 1315 | if (!$user_info['is_admin'] && !$modSettings['topic_move_any']) |
1274 | 1316 | { |
@@ -1314,8 +1356,9 @@ discard block |
||
1314 | 1356 | // Check if the draft functions are enabled and that they have permission to use them (for quick reply.) |
1315 | 1357 | $context['drafts_save'] = !empty($modSettings['drafts_post_enabled']) && allowedTo('post_draft') && $context['can_reply']; |
1316 | 1358 | $context['drafts_autosave'] = !empty($context['drafts_save']) && !empty($modSettings['drafts_autosave_enabled']); |
1317 | - if (!empty($context['drafts_save'])) |
|
1318 | - loadLanguage('Drafts'); |
|
1359 | + if (!empty($context['drafts_save'])) { |
|
1360 | + loadLanguage('Drafts'); |
|
1361 | + } |
|
1319 | 1362 | |
1320 | 1363 | // When was the last time this topic was replied to? Should we warn them about it? |
1321 | 1364 | if (!empty($modSettings['oldTopicDays']) && ($context['can_reply'] || $context['can_reply_unapproved']) && empty($context['topicinfo']['is_sticky'])) |
@@ -1376,26 +1419,31 @@ discard block |
||
1376 | 1419 | // Message icons - customized icons are off? |
1377 | 1420 | $context['icons'] = getMessageIcons($board); |
1378 | 1421 | |
1379 | - if (!empty($context['icons'])) |
|
1380 | - $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
1422 | + if (!empty($context['icons'])) { |
|
1423 | + $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
1424 | + } |
|
1381 | 1425 | |
1382 | 1426 | // Build the normal button array. |
1383 | 1427 | $context['normal_buttons'] = array(); |
1384 | 1428 | |
1385 | - if ($context['can_reply']) |
|
1386 | - $context['normal_buttons']['reply'] = array('text' => 'reply', 'image' => 'reply.png', 'url' => $scripturl . '?action=post;topic=' . $context['current_topic'] . '.' . $context['start'] . ';last_msg=' . $context['topic_last_message'], 'active' => true); |
|
1429 | + if ($context['can_reply']) { |
|
1430 | + $context['normal_buttons']['reply'] = array('text' => 'reply', 'image' => 'reply.png', 'url' => $scripturl . '?action=post;topic=' . $context['current_topic'] . '.' . $context['start'] . ';last_msg=' . $context['topic_last_message'], 'active' => true); |
|
1431 | + } |
|
1387 | 1432 | |
1388 | - if ($context['can_add_poll']) |
|
1389 | - $context['normal_buttons']['add_poll'] = array('text' => 'add_poll', 'image' => 'add_poll.png', 'url' => $scripturl . '?action=editpoll;add;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
1433 | + if ($context['can_add_poll']) { |
|
1434 | + $context['normal_buttons']['add_poll'] = array('text' => 'add_poll', 'image' => 'add_poll.png', 'url' => $scripturl . '?action=editpoll;add;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
1435 | + } |
|
1390 | 1436 | |
1391 | - if ($context['can_mark_unread']) |
|
1392 | - $context['normal_buttons']['mark_unread'] = array('text' => 'mark_unread', 'image' => 'markunread.png', 'url' => $scripturl . '?action=markasread;sa=topic;t=' . $context['mark_unread_time'] . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1437 | + if ($context['can_mark_unread']) { |
|
1438 | + $context['normal_buttons']['mark_unread'] = array('text' => 'mark_unread', 'image' => 'markunread.png', 'url' => $scripturl . '?action=markasread;sa=topic;t=' . $context['mark_unread_time'] . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1439 | + } |
|
1393 | 1440 | |
1394 | - if ($context['can_print']) |
|
1395 | - $context['normal_buttons']['print'] = array('text' => 'print', 'image' => 'print.png', 'custom' => 'rel="nofollow"', 'url' => $scripturl . '?action=printpage;topic=' . $context['current_topic'] . '.0'); |
|
1441 | + if ($context['can_print']) { |
|
1442 | + $context['normal_buttons']['print'] = array('text' => 'print', 'image' => 'print.png', 'custom' => 'rel="nofollow"', 'url' => $scripturl . '?action=printpage;topic=' . $context['current_topic'] . '.0'); |
|
1443 | + } |
|
1396 | 1444 | |
1397 | - if ($context['can_set_notify']) |
|
1398 | - $context['normal_buttons']['notify'] = array( |
|
1445 | + if ($context['can_set_notify']) { |
|
1446 | + $context['normal_buttons']['notify'] = array( |
|
1399 | 1447 | 'text' => 'notify_topic_' . $context['topic_notification_mode'], |
1400 | 1448 | 'sub_buttons' => array( |
1401 | 1449 | array( |
@@ -1417,38 +1465,47 @@ discard block |
||
1417 | 1465 | ), |
1418 | 1466 | ), |
1419 | 1467 | ); |
1468 | + } |
|
1420 | 1469 | |
1421 | 1470 | // Build the mod button array |
1422 | 1471 | $context['mod_buttons'] = array(); |
1423 | 1472 | |
1424 | - if ($context['can_move']) |
|
1425 | - $context['mod_buttons']['move'] = array('text' => 'move_topic', 'image' => 'admin_move.png', 'url' => $scripturl . '?action=movetopic;current_board=' . $context['current_board'] . ';topic=' . $context['current_topic'] . '.0'); |
|
1473 | + if ($context['can_move']) { |
|
1474 | + $context['mod_buttons']['move'] = array('text' => 'move_topic', 'image' => 'admin_move.png', 'url' => $scripturl . '?action=movetopic;current_board=' . $context['current_board'] . ';topic=' . $context['current_topic'] . '.0'); |
|
1475 | + } |
|
1426 | 1476 | |
1427 | - if ($context['can_delete']) |
|
1428 | - $context['mod_buttons']['delete'] = array('text' => 'remove_topic', 'image' => 'admin_rem.png', 'custom' => 'data-confirm="' . $txt['are_sure_remove_topic'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removetopic2;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
1477 | + if ($context['can_delete']) { |
|
1478 | + $context['mod_buttons']['delete'] = array('text' => 'remove_topic', 'image' => 'admin_rem.png', 'custom' => 'data-confirm="' . $txt['are_sure_remove_topic'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removetopic2;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
1479 | + } |
|
1429 | 1480 | |
1430 | - if ($context['can_lock']) |
|
1431 | - $context['mod_buttons']['lock'] = array('text' => empty($context['is_locked']) ? 'set_lock' : 'set_unlock', 'image' => 'admin_lock.png', 'url' => $scripturl . '?action=lock;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1481 | + if ($context['can_lock']) { |
|
1482 | + $context['mod_buttons']['lock'] = array('text' => empty($context['is_locked']) ? 'set_lock' : 'set_unlock', 'image' => 'admin_lock.png', 'url' => $scripturl . '?action=lock;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1483 | + } |
|
1432 | 1484 | |
1433 | - if ($context['can_sticky']) |
|
1434 | - $context['mod_buttons']['sticky'] = array('text' => empty($context['is_sticky']) ? 'set_sticky' : 'set_nonsticky', 'image' => 'admin_sticky.png', 'url' => $scripturl . '?action=sticky;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1485 | + if ($context['can_sticky']) { |
|
1486 | + $context['mod_buttons']['sticky'] = array('text' => empty($context['is_sticky']) ? 'set_sticky' : 'set_nonsticky', 'image' => 'admin_sticky.png', 'url' => $scripturl . '?action=sticky;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1487 | + } |
|
1435 | 1488 | |
1436 | - if ($context['can_merge']) |
|
1437 | - $context['mod_buttons']['merge'] = array('text' => 'merge', 'image' => 'merge.png', 'url' => $scripturl . '?action=mergetopics;board=' . $context['current_board'] . '.0;from=' . $context['current_topic']); |
|
1489 | + if ($context['can_merge']) { |
|
1490 | + $context['mod_buttons']['merge'] = array('text' => 'merge', 'image' => 'merge.png', 'url' => $scripturl . '?action=mergetopics;board=' . $context['current_board'] . '.0;from=' . $context['current_topic']); |
|
1491 | + } |
|
1438 | 1492 | |
1439 | - if ($context['calendar_post']) |
|
1440 | - $context['mod_buttons']['calendar'] = array('text' => 'calendar_link', 'image' => 'linktocal.png', 'url' => $scripturl . '?action=post;calendar;msg=' . $context['topic_first_message'] . ';topic=' . $context['current_topic'] . '.0'); |
|
1493 | + if ($context['calendar_post']) { |
|
1494 | + $context['mod_buttons']['calendar'] = array('text' => 'calendar_link', 'image' => 'linktocal.png', 'url' => $scripturl . '?action=post;calendar;msg=' . $context['topic_first_message'] . ';topic=' . $context['current_topic'] . '.0'); |
|
1495 | + } |
|
1441 | 1496 | |
1442 | 1497 | // Restore topic. eh? No monkey business. |
1443 | - if ($context['can_restore_topic']) |
|
1444 | - $context['mod_buttons']['restore_topic'] = array('text' => 'restore_topic', 'image' => '', 'url' => $scripturl . '?action=restoretopic;topics=' . $context['current_topic'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1498 | + if ($context['can_restore_topic']) { |
|
1499 | + $context['mod_buttons']['restore_topic'] = array('text' => 'restore_topic', 'image' => '', 'url' => $scripturl . '?action=restoretopic;topics=' . $context['current_topic'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1500 | + } |
|
1445 | 1501 | |
1446 | 1502 | // Show a message in case a recently posted message became unapproved. |
1447 | 1503 | $context['becomesUnapproved'] = !empty($_SESSION['becomesUnapproved']) ? true : false; |
1448 | 1504 | |
1449 | 1505 | // Don't want to show this forever... |
1450 | - if ($context['becomesUnapproved']) |
|
1451 | - unset($_SESSION['becomesUnapproved']); |
|
1506 | + if ($context['becomesUnapproved']) { |
|
1507 | + unset($_SESSION['becomesUnapproved']); |
|
1508 | + } |
|
1452 | 1509 | |
1453 | 1510 | // Allow adding new mod buttons easily. |
1454 | 1511 | // Note: $context['normal_buttons'] and $context['mod_buttons'] are added for backward compatibility with 2.0, but are deprecated and should not be used |
@@ -1457,12 +1514,14 @@ discard block |
||
1457 | 1514 | call_integration_hook('integrate_mod_buttons', array(&$context['mod_buttons'])); |
1458 | 1515 | |
1459 | 1516 | // Load the drafts js file |
1460 | - if ($context['drafts_autosave']) |
|
1461 | - loadJavaScriptFile('drafts.js', array('defer' => false), 'smf_drafts'); |
|
1517 | + if ($context['drafts_autosave']) { |
|
1518 | + loadJavaScriptFile('drafts.js', array('defer' => false), 'smf_drafts'); |
|
1519 | + } |
|
1462 | 1520 | |
1463 | 1521 | // Spellcheck |
1464 | - if ($context['show_spellchecking']) |
|
1465 | - loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
1522 | + if ($context['show_spellchecking']) { |
|
1523 | + loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
1524 | + } |
|
1466 | 1525 | |
1467 | 1526 | // topic.js |
1468 | 1527 | loadJavaScriptFile('topic.js', array('defer' => false), 'smf_topic'); |
@@ -1496,16 +1555,19 @@ discard block |
||
1496 | 1555 | static $counter = null; |
1497 | 1556 | |
1498 | 1557 | // If the query returned false, bail. |
1499 | - if ($messages_request == false) |
|
1500 | - return false; |
|
1558 | + if ($messages_request == false) { |
|
1559 | + return false; |
|
1560 | + } |
|
1501 | 1561 | |
1502 | 1562 | // Remember which message this is. (ie. reply #83) |
1503 | - if ($counter === null || $reset) |
|
1504 | - $counter = empty($options['view_newest_first']) ? $context['start'] : $context['total_visible_posts'] - $context['start']; |
|
1563 | + if ($counter === null || $reset) { |
|
1564 | + $counter = empty($options['view_newest_first']) ? $context['start'] : $context['total_visible_posts'] - $context['start']; |
|
1565 | + } |
|
1505 | 1566 | |
1506 | 1567 | // Start from the beginning... |
1507 | - if ($reset) |
|
1508 | - return @$smcFunc['db_data_seek']($messages_request, 0); |
|
1568 | + if ($reset) { |
|
1569 | + return @$smcFunc['db_data_seek']($messages_request, 0); |
|
1570 | + } |
|
1509 | 1571 | |
1510 | 1572 | // Attempt to get the next message. |
1511 | 1573 | $message = $smcFunc['db_fetch_assoc']($messages_request); |
@@ -1519,19 +1581,21 @@ discard block |
||
1519 | 1581 | if (empty($context['icon_sources'])) |
1520 | 1582 | { |
1521 | 1583 | $context['icon_sources'] = array(); |
1522 | - foreach ($context['stable_icons'] as $icon) |
|
1523 | - $context['icon_sources'][$icon] = 'images_url'; |
|
1584 | + foreach ($context['stable_icons'] as $icon) { |
|
1585 | + $context['icon_sources'][$icon] = 'images_url'; |
|
1586 | + } |
|
1524 | 1587 | } |
1525 | 1588 | |
1526 | 1589 | // Message Icon Management... check the images exist. |
1527 | 1590 | if (empty($modSettings['messageIconChecks_disable'])) |
1528 | 1591 | { |
1529 | 1592 | // If the current icon isn't known, then we need to do something... |
1530 | - if (!isset($context['icon_sources'][$message['icon']])) |
|
1531 | - $context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1593 | + if (!isset($context['icon_sources'][$message['icon']])) { |
|
1594 | + $context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1595 | + } |
|
1596 | + } elseif (!isset($context['icon_sources'][$message['icon']])) { |
|
1597 | + $context['icon_sources'][$message['icon']] = 'images_url'; |
|
1532 | 1598 | } |
1533 | - elseif (!isset($context['icon_sources'][$message['icon']])) |
|
1534 | - $context['icon_sources'][$message['icon']] = 'images_url'; |
|
1535 | 1599 | |
1536 | 1600 | // If you're a lazy bum, you probably didn't give a subject... |
1537 | 1601 | $message['subject'] = $message['subject'] != '' ? $message['subject'] : $txt['no_subject']; |
@@ -1556,8 +1620,7 @@ discard block |
||
1556 | 1620 | $memberContext[$message['id_member']]['email'] = $message['poster_email']; |
1557 | 1621 | $memberContext[$message['id_member']]['show_email'] = allowedTo('moderate_forum'); |
1558 | 1622 | $memberContext[$message['id_member']]['is_guest'] = true; |
1559 | - } |
|
1560 | - else |
|
1623 | + } else |
|
1561 | 1624 | { |
1562 | 1625 | // Define this here to make things a bit more readable |
1563 | 1626 | $can_view_warning = $context['user']['can_mod'] || allowedTo('view_warning_any') || ($message['id_member'] == $user_info['id'] && allowedTo('view_warning_own')); |
@@ -1580,8 +1643,9 @@ discard block |
||
1580 | 1643 | $message['body'] = parse_bbc($message['body'], $message['smileys_enabled'], $message['id_msg']); |
1581 | 1644 | |
1582 | 1645 | // If it's in the recycle bin we need to override whatever icon we did have. |
1583 | - if (!empty($board_info['recycle'])) |
|
1584 | - $message['icon'] = 'recycled'; |
|
1646 | + if (!empty($board_info['recycle'])) { |
|
1647 | + $message['icon'] = 'recycled'; |
|
1648 | + } |
|
1585 | 1649 | |
1586 | 1650 | require_once($sourcedir . '/Subs-Attachments.php'); |
1587 | 1651 | |
@@ -1625,32 +1689,36 @@ discard block |
||
1625 | 1689 | } |
1626 | 1690 | |
1627 | 1691 | // Are likes enable? |
1628 | - if (!empty($modSettings['enable_likes'])) |
|
1629 | - $output['likes'] = array( |
|
1692 | + if (!empty($modSettings['enable_likes'])) { |
|
1693 | + $output['likes'] = array( |
|
1630 | 1694 | 'count' => $message['likes'], |
1631 | 1695 | 'you' => in_array($message['id_msg'], $context['my_likes']), |
1632 | 1696 | 'can_like' => !$context['user']['is_guest'] && $message['id_member'] != $context['user']['id'] && !empty($context['can_like']), |
1633 | 1697 | ); |
1698 | + } |
|
1634 | 1699 | |
1635 | 1700 | // Is this user the message author? |
1636 | 1701 | $output['is_message_author'] = $message['id_member'] == $user_info['id']; |
1637 | - if (!empty($output['modified']['name'])) |
|
1638 | - $output['modified']['last_edit_text'] = sprintf($txt['last_edit_by'], $output['modified']['time'], $output['modified']['name']); |
|
1702 | + if (!empty($output['modified']['name'])) { |
|
1703 | + $output['modified']['last_edit_text'] = sprintf($txt['last_edit_by'], $output['modified']['time'], $output['modified']['name']); |
|
1704 | + } |
|
1639 | 1705 | |
1640 | 1706 | // Did they give a reason for editing? |
1641 | - if (!empty($output['modified']['name']) && !empty($output['modified']['reason'])) |
|
1642 | - $output['modified']['last_edit_text'] .= ' ' . sprintf($txt['last_edit_reason'], $output['modified']['reason']); |
|
1707 | + if (!empty($output['modified']['name']) && !empty($output['modified']['reason'])) { |
|
1708 | + $output['modified']['last_edit_text'] .= ' ' . sprintf($txt['last_edit_reason'], $output['modified']['reason']); |
|
1709 | + } |
|
1643 | 1710 | |
1644 | 1711 | // Any custom profile fields? |
1645 | - if (!empty($memberContext[$message['id_member']]['custom_fields'])) |
|
1646 | - foreach ($memberContext[$message['id_member']]['custom_fields'] as $custom) |
|
1712 | + if (!empty($memberContext[$message['id_member']]['custom_fields'])) { |
|
1713 | + foreach ($memberContext[$message['id_member']]['custom_fields'] as $custom) |
|
1647 | 1714 | $output['custom_fields'][$context['cust_profile_fields_placement'][$custom['placement']]][] = $custom; |
1715 | + } |
|
1648 | 1716 | |
1649 | - if (empty($options['view_newest_first'])) |
|
1650 | - $counter++; |
|
1651 | - |
|
1652 | - else |
|
1653 | - $counter--; |
|
1717 | + if (empty($options['view_newest_first'])) { |
|
1718 | + $counter++; |
|
1719 | + } else { |
|
1720 | + $counter--; |
|
1721 | + } |
|
1654 | 1722 | |
1655 | 1723 | call_integration_hook('integrate_prepare_display_context', array(&$output, &$message, $counter)); |
1656 | 1724 | |
@@ -1676,21 +1744,23 @@ discard block |
||
1676 | 1744 | $context['no_last_modified'] = true; |
1677 | 1745 | |
1678 | 1746 | // Prevent a preview image from being displayed twice. |
1679 | - if (isset($_GET['action']) && $_GET['action'] == 'dlattach' && isset($_GET['type']) && ($_GET['type'] == 'avatar' || $_GET['type'] == 'preview')) |
|
1680 | - return; |
|
1747 | + if (isset($_GET['action']) && $_GET['action'] == 'dlattach' && isset($_GET['type']) && ($_GET['type'] == 'avatar' || $_GET['type'] == 'preview')) { |
|
1748 | + return; |
|
1749 | + } |
|
1681 | 1750 | |
1682 | 1751 | // Make sure some attachment was requested! |
1683 | - if (!isset($_REQUEST['attach']) && !isset($_REQUEST['id'])) |
|
1684 | - fatal_lang_error('no_access', false); |
|
1752 | + if (!isset($_REQUEST['attach']) && !isset($_REQUEST['id'])) { |
|
1753 | + fatal_lang_error('no_access', false); |
|
1754 | + } |
|
1685 | 1755 | |
1686 | 1756 | $_REQUEST['attach'] = isset($_REQUEST['attach']) ? (int) $_REQUEST['attach'] : (int) $_REQUEST['id']; |
1687 | 1757 | |
1688 | 1758 | // Do we have a hook wanting to use our attachment system? We use $attachRequest to prevent accidental usage of $request. |
1689 | 1759 | $attachRequest = null; |
1690 | 1760 | call_integration_hook('integrate_download_request', array(&$attachRequest)); |
1691 | - if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest)) |
|
1692 | - $request = $attachRequest; |
|
1693 | - else |
|
1761 | + if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest)) { |
|
1762 | + $request = $attachRequest; |
|
1763 | + } else |
|
1694 | 1764 | { |
1695 | 1765 | // This checks only the current board for $board/$topic's permissions. |
1696 | 1766 | isAllowedTo('view_attachments'); |
@@ -1711,19 +1781,21 @@ discard block |
||
1711 | 1781 | ); |
1712 | 1782 | } |
1713 | 1783 | |
1714 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1715 | - fatal_lang_error('no_access', false); |
|
1784 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1785 | + fatal_lang_error('no_access', false); |
|
1786 | + } |
|
1716 | 1787 | |
1717 | 1788 | list ($id_folder, $real_filename, $file_hash, $file_ext, $id_attach, $attachment_type, $mime_type, $is_approved, $id_member) = $smcFunc['db_fetch_row']($request); |
1718 | 1789 | $smcFunc['db_free_result']($request); |
1719 | 1790 | |
1720 | 1791 | // If it isn't yet approved, do they have permission to view it? |
1721 | - if (!$is_approved && ($id_member == 0 || $user_info['id'] != $id_member) && ($attachment_type == 0 || $attachment_type == 3)) |
|
1722 | - isAllowedTo('approve_posts'); |
|
1792 | + if (!$is_approved && ($id_member == 0 || $user_info['id'] != $id_member) && ($attachment_type == 0 || $attachment_type == 3)) { |
|
1793 | + isAllowedTo('approve_posts'); |
|
1794 | + } |
|
1723 | 1795 | |
1724 | 1796 | // Update the download counter (unless it's a thumbnail). |
1725 | - if ($attachment_type != 3) |
|
1726 | - $smcFunc['db_query']('attach_download_increase', ' |
|
1797 | + if ($attachment_type != 3) { |
|
1798 | + $smcFunc['db_query']('attach_download_increase', ' |
|
1727 | 1799 | UPDATE LOW_PRIORITY {db_prefix}attachments |
1728 | 1800 | SET downloads = downloads + 1 |
1729 | 1801 | WHERE id_attach = {int:id_attach}', |
@@ -1731,15 +1803,15 @@ discard block |
||
1731 | 1803 | 'id_attach' => $id_attach, |
1732 | 1804 | ) |
1733 | 1805 | ); |
1806 | + } |
|
1734 | 1807 | |
1735 | 1808 | $filename = getAttachmentFilename($real_filename, $_REQUEST['attach'], $id_folder, false, $file_hash); |
1736 | 1809 | |
1737 | 1810 | // This is done to clear any output that was made before now. |
1738 | 1811 | ob_end_clean(); |
1739 | - if (!empty($modSettings['enableCompressedOutput']) && @filesize($filename) <= 4194304 && in_array($file_ext, array('txt', 'html', 'htm', 'js', 'doc', 'docx', 'rtf', 'css', 'php', 'log', 'xml', 'sql', 'c', 'java'))) |
|
1740 | - @ob_start('ob_gzhandler'); |
|
1741 | - |
|
1742 | - else |
|
1812 | + if (!empty($modSettings['enableCompressedOutput']) && @filesize($filename) <= 4194304 && in_array($file_ext, array('txt', 'html', 'htm', 'js', 'doc', 'docx', 'rtf', 'css', 'php', 'log', 'xml', 'sql', 'c', 'java'))) { |
|
1813 | + @ob_start('ob_gzhandler'); |
|
1814 | + } else |
|
1743 | 1815 | { |
1744 | 1816 | ob_start(); |
1745 | 1817 | header('Content-Encoding: none'); |
@@ -1782,8 +1854,9 @@ discard block |
||
1782 | 1854 | // Send the attachment headers. |
1783 | 1855 | header('Pragma: '); |
1784 | 1856 | |
1785 | - if (!isBrowser('gecko')) |
|
1786 | - header('Content-Transfer-Encoding: binary'); |
|
1857 | + if (!isBrowser('gecko')) { |
|
1858 | + header('Content-Transfer-Encoding: binary'); |
|
1859 | + } |
|
1787 | 1860 | |
1788 | 1861 | header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT'); |
1789 | 1862 | header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($filename)) . ' GMT'); |
@@ -1792,18 +1865,19 @@ discard block |
||
1792 | 1865 | header('ETag: ' . $eTag); |
1793 | 1866 | |
1794 | 1867 | // Make sure the mime type warrants an inline display. |
1795 | - if (isset($_REQUEST['image']) && !empty($mime_type) && strpos($mime_type, 'image/') !== 0) |
|
1796 | - unset($_REQUEST['image']); |
|
1868 | + if (isset($_REQUEST['image']) && !empty($mime_type) && strpos($mime_type, 'image/') !== 0) { |
|
1869 | + unset($_REQUEST['image']); |
|
1870 | + } |
|
1797 | 1871 | |
1798 | 1872 | // Does this have a mime type? |
1799 | - elseif (!empty($mime_type) && (isset($_REQUEST['image']) || !in_array($file_ext, array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff')))) |
|
1800 | - header('Content-Type: ' . strtr($mime_type, array('image/bmp' => 'image/x-ms-bmp'))); |
|
1801 | - |
|
1802 | - else |
|
1873 | + elseif (!empty($mime_type) && (isset($_REQUEST['image']) || !in_array($file_ext, array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff')))) { |
|
1874 | + header('Content-Type: ' . strtr($mime_type, array('image/bmp' => 'image/x-ms-bmp'))); |
|
1875 | + } else |
|
1803 | 1876 | { |
1804 | 1877 | header('Content-Type: ' . (isBrowser('ie') || isBrowser('opera') ? 'application/octetstream' : 'application/octet-stream')); |
1805 | - if (isset($_REQUEST['image'])) |
|
1806 | - unset($_REQUEST['image']); |
|
1878 | + if (isset($_REQUEST['image'])) { |
|
1879 | + unset($_REQUEST['image']); |
|
1880 | + } |
|
1807 | 1881 | } |
1808 | 1882 | |
1809 | 1883 | // Convert the file to UTF-8, cuz most browsers dig that. |
@@ -1811,23 +1885,22 @@ discard block |
||
1811 | 1885 | $disposition = !isset($_REQUEST['image']) ? 'attachment' : 'inline'; |
1812 | 1886 | |
1813 | 1887 | // Different browsers like different standards... |
1814 | - if (isBrowser('firefox')) |
|
1815 | - header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name))); |
|
1816 | - |
|
1817 | - elseif (isBrowser('opera')) |
|
1818 | - header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"'); |
|
1819 | - |
|
1820 | - elseif (isBrowser('ie')) |
|
1821 | - header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"'); |
|
1822 | - |
|
1823 | - else |
|
1824 | - header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"'); |
|
1888 | + if (isBrowser('firefox')) { |
|
1889 | + header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name))); |
|
1890 | + } elseif (isBrowser('opera')) { |
|
1891 | + header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"'); |
|
1892 | + } elseif (isBrowser('ie')) { |
|
1893 | + header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"'); |
|
1894 | + } else { |
|
1895 | + header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"'); |
|
1896 | + } |
|
1825 | 1897 | |
1826 | 1898 | // If this has an "image extension" - but isn't actually an image - then ensure it isn't cached cause of silly IE. |
1827 | - if (!isset($_REQUEST['image']) && in_array($file_ext, array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff'))) |
|
1828 | - header('Cache-Control: no-cache'); |
|
1829 | - else |
|
1830 | - header('Cache-Control: max-age=' . (525600 * 60) . ', private'); |
|
1899 | + if (!isset($_REQUEST['image']) && in_array($file_ext, array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff'))) { |
|
1900 | + header('Cache-Control: no-cache'); |
|
1901 | + } else { |
|
1902 | + header('Cache-Control: max-age=' . (525600 * 60) . ', private'); |
|
1903 | + } |
|
1831 | 1904 | |
1832 | 1905 | header('Content-Length: ' . filesize($filename)); |
1833 | 1906 | |
@@ -1837,20 +1910,23 @@ discard block |
||
1837 | 1910 | // Recode line endings for text files, if enabled. |
1838 | 1911 | if (!empty($modSettings['attachmentRecodeLineEndings']) && !isset($_REQUEST['image']) && in_array($file_ext, array('txt', 'css', 'htm', 'html', 'php', 'xml'))) |
1839 | 1912 | { |
1840 | - if (strpos($_SERVER['HTTP_USER_AGENT'], 'Windows') !== false) |
|
1841 | - $callback = function($buffer) |
|
1913 | + if (strpos($_SERVER['HTTP_USER_AGENT'], 'Windows') !== false) { |
|
1914 | + $callback = function($buffer) |
|
1842 | 1915 | { |
1843 | 1916 | return preg_replace('~[\r]?\n~', "\r\n", $buffer); |
1917 | + } |
|
1844 | 1918 | }; |
1845 | - elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) |
|
1846 | - $callback = function($buffer) |
|
1919 | + elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) { |
|
1920 | + $callback = function($buffer) |
|
1847 | 1921 | { |
1848 | 1922 | return preg_replace('~[\r]?\n~', "\r", $buffer); |
1923 | + } |
|
1849 | 1924 | }; |
1850 | - else |
|
1851 | - $callback = function($buffer) |
|
1925 | + else { |
|
1926 | + $callback = function($buffer) |
|
1852 | 1927 | { |
1853 | 1928 | return preg_replace('~[\r]?\n~', "\n", $buffer); |
1929 | + } |
|
1854 | 1930 | }; |
1855 | 1931 | } |
1856 | 1932 | |
@@ -1858,23 +1934,26 @@ discard block |
||
1858 | 1934 | if (filesize($filename) > 4194304) |
1859 | 1935 | { |
1860 | 1936 | // Forcibly end any output buffering going on. |
1861 | - while (@ob_get_level() > 0) |
|
1862 | - @ob_end_clean(); |
|
1937 | + while (@ob_get_level() > 0) { |
|
1938 | + @ob_end_clean(); |
|
1939 | + } |
|
1863 | 1940 | |
1864 | 1941 | $fp = fopen($filename, 'rb'); |
1865 | 1942 | while (!feof($fp)) |
1866 | 1943 | { |
1867 | - if (isset($callback)) |
|
1868 | - echo $callback(fread($fp, 8192)); |
|
1869 | - else |
|
1870 | - echo fread($fp, 8192); |
|
1944 | + if (isset($callback)) { |
|
1945 | + echo $callback(fread($fp, 8192)); |
|
1946 | + } else { |
|
1947 | + echo fread($fp, 8192); |
|
1948 | + } |
|
1871 | 1949 | flush(); |
1872 | 1950 | } |
1873 | 1951 | fclose($fp); |
1874 | 1952 | } |
1875 | 1953 | // On some of the less-bright hosts, readfile() is disabled. It's just a faster, more byte safe, version of what's in the if. |
1876 | - elseif (isset($callback) || @readfile($filename) === null) |
|
1877 | - echo isset($callback) ? $callback(file_get_contents($filename)) : file_get_contents($filename); |
|
1954 | + elseif (isset($callback) || @readfile($filename) === null) { |
|
1955 | + echo isset($callback) ? $callback(file_get_contents($filename)) : file_get_contents($filename); |
|
1956 | + } |
|
1878 | 1957 | |
1879 | 1958 | obExit(false); |
1880 | 1959 | } |
@@ -1887,8 +1966,9 @@ discard block |
||
1887 | 1966 | */ |
1888 | 1967 | function approved_attach_sort($a, $b) |
1889 | 1968 | { |
1890 | - if ($a['is_approved'] == $b['is_approved']) |
|
1891 | - return 0; |
|
1969 | + if ($a['is_approved'] == $b['is_approved']) { |
|
1970 | + return 0; |
|
1971 | + } |
|
1892 | 1972 | |
1893 | 1973 | return $a['is_approved'] > $b['is_approved'] ? -1 : 1; |
1894 | 1974 | } |
@@ -1905,16 +1985,19 @@ discard block |
||
1905 | 1985 | |
1906 | 1986 | require_once($sourcedir . '/RemoveTopic.php'); |
1907 | 1987 | |
1908 | - if (empty($_REQUEST['msgs'])) |
|
1909 | - redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
1988 | + if (empty($_REQUEST['msgs'])) { |
|
1989 | + redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
1990 | + } |
|
1910 | 1991 | |
1911 | 1992 | $messages = array(); |
1912 | - foreach ($_REQUEST['msgs'] as $dummy) |
|
1913 | - $messages[] = (int) $dummy; |
|
1993 | + foreach ($_REQUEST['msgs'] as $dummy) { |
|
1994 | + $messages[] = (int) $dummy; |
|
1995 | + } |
|
1914 | 1996 | |
1915 | 1997 | // We are restoring messages. We handle this in another place. |
1916 | - if (isset($_REQUEST['restore_selected'])) |
|
1917 | - redirectexit('action=restoretopic;msgs=' . implode(',', $messages) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1998 | + if (isset($_REQUEST['restore_selected'])) { |
|
1999 | + redirectexit('action=restoretopic;msgs=' . implode(',', $messages) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
2000 | + } |
|
1918 | 2001 | if (isset($_REQUEST['split_selection'])) |
1919 | 2002 | { |
1920 | 2003 | $request = $smcFunc['db_query']('', ' |
@@ -1933,8 +2016,9 @@ discard block |
||
1933 | 2016 | } |
1934 | 2017 | |
1935 | 2018 | // Allowed to delete any message? |
1936 | - if (allowedTo('delete_any')) |
|
1937 | - $allowed_all = true; |
|
2019 | + if (allowedTo('delete_any')) { |
|
2020 | + $allowed_all = true; |
|
2021 | + } |
|
1938 | 2022 | // Allowed to delete replies to their messages? |
1939 | 2023 | elseif (allowedTo('delete_replies')) |
1940 | 2024 | { |
@@ -1951,13 +2035,14 @@ discard block |
||
1951 | 2035 | $smcFunc['db_free_result']($request); |
1952 | 2036 | |
1953 | 2037 | $allowed_all = $starter == $user_info['id']; |
2038 | + } else { |
|
2039 | + $allowed_all = false; |
|
1954 | 2040 | } |
1955 | - else |
|
1956 | - $allowed_all = false; |
|
1957 | 2041 | |
1958 | 2042 | // Make sure they're allowed to delete their own messages, if not any. |
1959 | - if (!$allowed_all) |
|
1960 | - isAllowedTo('delete_own'); |
|
2043 | + if (!$allowed_all) { |
|
2044 | + isAllowedTo('delete_own'); |
|
2045 | + } |
|
1961 | 2046 | |
1962 | 2047 | // Allowed to remove which messages? |
1963 | 2048 | $request = $smcFunc['db_query']('', ' |
@@ -1977,8 +2062,9 @@ discard block |
||
1977 | 2062 | $messages = array(); |
1978 | 2063 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1979 | 2064 | { |
1980 | - if (!$allowed_all && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time()) |
|
1981 | - continue; |
|
2065 | + if (!$allowed_all && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time()) { |
|
2066 | + continue; |
|
2067 | + } |
|
1982 | 2068 | |
1983 | 2069 | $messages[$row['id_msg']] = array($row['subject'], $row['id_member']); |
1984 | 2070 | } |
@@ -2001,17 +2087,20 @@ discard block |
||
2001 | 2087 | foreach ($messages as $message => $info) |
2002 | 2088 | { |
2003 | 2089 | // Just skip the first message - if it's not the last. |
2004 | - if ($message == $first_message && $message != $last_message) |
|
2005 | - continue; |
|
2090 | + if ($message == $first_message && $message != $last_message) { |
|
2091 | + continue; |
|
2092 | + } |
|
2006 | 2093 | // If the first message is going then don't bother going back to the topic as we're effectively deleting it. |
2007 | - elseif ($message == $first_message) |
|
2008 | - $topicGone = true; |
|
2094 | + elseif ($message == $first_message) { |
|
2095 | + $topicGone = true; |
|
2096 | + } |
|
2009 | 2097 | |
2010 | 2098 | removeMessage($message); |
2011 | 2099 | |
2012 | 2100 | // Log this moderation action ;). |
2013 | - if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) |
|
2014 | - logAction('delete', array('topic' => $topic, 'subject' => $info[0], 'member' => $info[1], 'board' => $board)); |
|
2101 | + if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) { |
|
2102 | + logAction('delete', array('topic' => $topic, 'subject' => $info[0], 'member' => $info[1], 'board' => $board)); |
|
2103 | + } |
|
2015 | 2104 | } |
2016 | 2105 | |
2017 | 2106 | redirectexit(!empty($topicGone) ? 'board=' . $board : 'topic=' . $topic . '.' . $_REQUEST['start']); |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Class Likes |
@@ -106,8 +107,9 @@ discard block |
||
106 | 107 | $this->_extra = isset($_GET['extra']) ? $_GET['extra'] : false; |
107 | 108 | |
108 | 109 | // We do not want to output debug information here. |
109 | - if ($this->_js) |
|
110 | - $db_show_debug = false; |
|
110 | + if ($this->_js) { |
|
111 | + $db_show_debug = false; |
|
112 | + } |
|
111 | 113 | } |
112 | 114 | |
113 | 115 | /** |
@@ -141,8 +143,9 @@ discard block |
||
141 | 143 | $call = $this->_sa; |
142 | 144 | |
143 | 145 | // Guest can only view likes. |
144 | - if ($call != 'view') |
|
145 | - is_not_guest(); |
|
146 | + if ($call != 'view') { |
|
147 | + is_not_guest(); |
|
148 | + } |
|
146 | 149 | |
147 | 150 | checkSession('get'); |
148 | 151 | |
@@ -180,15 +183,17 @@ discard block |
||
180 | 183 | global $smcFunc, $modSettings; |
181 | 184 | |
182 | 185 | // This feature is currently disable. |
183 | - if (empty($modSettings['enable_likes'])) |
|
184 | - return $this->_error = 'like_disable'; |
|
186 | + if (empty($modSettings['enable_likes'])) { |
|
187 | + return $this->_error = 'like_disable'; |
|
188 | + } |
|
185 | 189 | |
186 | 190 | // Zerothly, they did indicate some kind of content to like, right? |
187 | 191 | preg_match('~^([a-z0-9\-\_]{1,6})~i', $this->_type, $matches); |
188 | 192 | $this->_type = isset($matches[1]) ? $matches[1] : ''; |
189 | 193 | |
190 | - if ($this->_type == '' || $this->_content <= 0) |
|
191 | - return $this->_error = 'cannot_'; |
|
194 | + if ($this->_type == '' || $this->_content <= 0) { |
|
195 | + return $this->_error = 'cannot_'; |
|
196 | + } |
|
192 | 197 | |
193 | 198 | // First we need to verify if the user can see the type of content or not. This is set up to be extensible, |
194 | 199 | // so we'll check for the one type we do know about, and if it's not that, we'll defer to any hooks. |
@@ -207,12 +212,14 @@ discard block |
||
207 | 212 | 'msg' => $this->_content, |
208 | 213 | ) |
209 | 214 | ); |
210 | - if ($smcFunc['db_num_rows']($request) == 1) |
|
211 | - list ($this->_idTopic, $topicOwner) = $smcFunc['db_fetch_row']($request); |
|
215 | + if ($smcFunc['db_num_rows']($request) == 1) { |
|
216 | + list ($this->_idTopic, $topicOwner) = $smcFunc['db_fetch_row']($request); |
|
217 | + } |
|
212 | 218 | |
213 | 219 | $smcFunc['db_free_result']($request); |
214 | - if (empty($this->_idTopic)) |
|
215 | - return $this->_error = 'cannot_'; |
|
220 | + if (empty($this->_idTopic)) { |
|
221 | + return $this->_error = 'cannot_'; |
|
222 | + } |
|
216 | 223 | |
217 | 224 | // So we know what topic it's in and more importantly we know the user can see it. |
218 | 225 | // If we're not viewing, we need some info set up. |
@@ -221,9 +228,7 @@ discard block |
||
221 | 228 | $this->_validLikes['redirect'] = 'topic=' . $this->_idTopic . '.msg' . $this->_content . '#msg' . $this->_content; |
222 | 229 | |
223 | 230 | $this->_validLikes['can_like'] = ($this->_user['id'] == $topicOwner ? 'cannot_like_content' : (allowedTo('likes_like') ? true : 'cannot_like_content')); |
224 | - } |
|
225 | - |
|
226 | - else |
|
231 | + } else |
|
227 | 232 | { |
228 | 233 | // Modders: This will give you whatever the user offers up in terms of liking, e.g. $this->_type=msg, $this->_content=1 |
229 | 234 | // When you hook this, check $this->_type first. If it is not something your mod worries about, return false. |
@@ -241,8 +246,9 @@ discard block |
||
241 | 246 | if ($result !== false) |
242 | 247 | { |
243 | 248 | // Match the type with what we already have. |
244 | - if (!isset($result['type']) || $result['type'] != $this->_type) |
|
245 | - return $this->_error = 'not_valid_like_type'; |
|
249 | + if (!isset($result['type']) || $result['type'] != $this->_type) { |
|
250 | + return $this->_error = 'not_valid_like_type'; |
|
251 | + } |
|
246 | 252 | |
247 | 253 | // Fill out the rest. |
248 | 254 | $this->_type = $result['type']; |
@@ -253,13 +259,15 @@ discard block |
||
253 | 259 | } |
254 | 260 | } |
255 | 261 | |
256 | - if (!$found) |
|
257 | - return $this->_error = 'cannot_'; |
|
262 | + if (!$found) { |
|
263 | + return $this->_error = 'cannot_'; |
|
264 | + } |
|
258 | 265 | } |
259 | 266 | |
260 | 267 | // Does the user can like this? Viewing a list of likes doesn't require this permission. |
261 | - if ($this->_sa != 'view' && isset($this->_validLikes['can_like']) && is_string($this->_validLikes['can_like'])) |
|
262 | - return $this->_error = $this->_validLikes['can_like']; |
|
268 | + if ($this->_sa != 'view' && isset($this->_validLikes['can_like']) && is_string($this->_validLikes['can_like'])) { |
|
269 | + return $this->_error = $this->_validLikes['can_like']; |
|
270 | + } |
|
263 | 271 | } |
264 | 272 | |
265 | 273 | /** |
@@ -284,8 +292,9 @@ discard block |
||
284 | 292 | ); |
285 | 293 | |
286 | 294 | // Are we calling this directly? if so, set a proper data for the response. Do note that __METHOD__ returns both the class name and the function name. |
287 | - if ($this->_sa == __FUNCTION__) |
|
288 | - $this->_data = __FUNCTION__; |
|
295 | + if ($this->_sa == __FUNCTION__) { |
|
296 | + $this->_data = __FUNCTION__; |
|
297 | + } |
|
289 | 298 | } |
290 | 299 | |
291 | 300 | /** |
@@ -315,8 +324,8 @@ discard block |
||
315 | 324 | |
316 | 325 | // Add a background task to process sending alerts. |
317 | 326 | // Mod author, you can add your own background task for your own custom like event using the "integrate_issue_like" hook or your callback, both are immediately called after this. |
318 | - if ($this->_type == 'msg') |
|
319 | - $smcFunc['db_insert']('insert', |
|
327 | + if ($this->_type == 'msg') { |
|
328 | + $smcFunc['db_insert']('insert', |
|
320 | 329 | '{db_prefix}background_tasks', |
321 | 330 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
322 | 331 | array('$sourcedir/tasks/Likes-Notify.php', 'Likes_Notify_Background', $smcFunc['json_encode'](array( |
@@ -328,10 +337,12 @@ discard block |
||
328 | 337 | )), 0), |
329 | 338 | array('id_task') |
330 | 339 | ); |
340 | + } |
|
331 | 341 | |
332 | 342 | // Are we calling this directly? if so, set a proper data for the response. Do note that __METHOD__ returns both the class name and the function name. |
333 | - if ($this->_sa == __FUNCTION__) |
|
334 | - $this->_data = __FUNCTION__; |
|
343 | + if ($this->_sa == __FUNCTION__) { |
|
344 | + $this->_data = __FUNCTION__; |
|
345 | + } |
|
335 | 346 | } |
336 | 347 | |
337 | 348 | /** |
@@ -357,8 +368,9 @@ discard block |
||
357 | 368 | $smcFunc['db_free_result']($request); |
358 | 369 | |
359 | 370 | // If you want to call this directly, fill out _data property too. |
360 | - if ($this->_sa == __FUNCTION__) |
|
361 | - $this->_data = $this->_numLikes; |
|
371 | + if ($this->_sa == __FUNCTION__) { |
|
372 | + $this->_data = $this->_numLikes; |
|
373 | + } |
|
362 | 374 | } |
363 | 375 | |
364 | 376 | /** |
@@ -371,8 +383,9 @@ discard block |
||
371 | 383 | global $smcFunc; |
372 | 384 | |
373 | 385 | // Safety first! |
374 | - if (empty($this->_type) || empty($this->_content)) |
|
375 | - return $this->_error = 'cannot_'; |
|
386 | + if (empty($this->_type) || empty($this->_content)) { |
|
387 | + return $this->_error = 'cannot_'; |
|
388 | + } |
|
376 | 389 | |
377 | 390 | // Do we already like this? |
378 | 391 | $request = $smcFunc['db_query']('', ' |
@@ -390,26 +403,28 @@ discard block |
||
390 | 403 | $this->_alreadyLiked = (bool) $smcFunc['db_num_rows']($request) != 0; |
391 | 404 | $smcFunc['db_free_result']($request); |
392 | 405 | |
393 | - if ($this->_alreadyLiked) |
|
394 | - $this->delete(); |
|
395 | - |
|
396 | - else |
|
397 | - $this->insert(); |
|
406 | + if ($this->_alreadyLiked) { |
|
407 | + $this->delete(); |
|
408 | + } else { |
|
409 | + $this->insert(); |
|
410 | + } |
|
398 | 411 | |
399 | 412 | // Now, how many people like this content now? We *could* just +1 / -1 the relevant container but that has proven to become unstable. |
400 | 413 | $this->_count(); |
401 | 414 | |
402 | 415 | // Update the likes count for messages. |
403 | - if ($this->_type == 'msg') |
|
404 | - $this->msgIssueLike(); |
|
416 | + if ($this->_type == 'msg') { |
|
417 | + $this->msgIssueLike(); |
|
418 | + } |
|
405 | 419 | |
406 | 420 | // Any callbacks? |
407 | 421 | elseif (!empty($this->_validLikes['callback'])) |
408 | 422 | { |
409 | 423 | $call = call_helper($this->_validLikes['callback'], true); |
410 | 424 | |
411 | - if (!empty($call)) |
|
412 | - call_user_func_array($call, array($this)); |
|
425 | + if (!empty($call)) { |
|
426 | + call_user_func_array($call, array($this)); |
|
427 | + } |
|
413 | 428 | } |
414 | 429 | |
415 | 430 | // Sometimes there might be other things that need updating after we do this like. |
@@ -418,8 +433,9 @@ discard block |
||
418 | 433 | // Now some clean up. This is provided here for any like handlers that want to do any cache flushing. |
419 | 434 | // This way a like handler doesn't need to explicitly declare anything in integrate_issue_like, but do so |
420 | 435 | // in integrate_valid_likes where it absolutely has to exist. |
421 | - if (!empty($this->_validLikes['flush_cache'])) |
|
422 | - cache_put_data($this->_validLikes['flush_cache'], null); |
|
436 | + if (!empty($this->_validLikes['flush_cache'])) { |
|
437 | + cache_put_data($this->_validLikes['flush_cache'], null); |
|
438 | + } |
|
423 | 439 | |
424 | 440 | // All done, start building the data to pass as response. |
425 | 441 | $this->_data = array( |
@@ -442,8 +458,9 @@ discard block |
||
442 | 458 | { |
443 | 459 | global $smcFunc; |
444 | 460 | |
445 | - if ($this->_type !== 'msg') |
|
446 | - return; |
|
461 | + if ($this->_type !== 'msg') { |
|
462 | + return; |
|
463 | + } |
|
447 | 464 | |
448 | 465 | $smcFunc['db_query']('', ' |
449 | 466 | UPDATE {db_prefix}messages |
@@ -484,8 +501,9 @@ discard block |
||
484 | 501 | 'like_type' => $this->_type, |
485 | 502 | ) |
486 | 503 | ); |
487 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
488 | - $context['likers'][$row['id_member']] = array('timestamp' => $row['like_time']); |
|
504 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
505 | + $context['likers'][$row['id_member']] = array('timestamp' => $row['like_time']); |
|
506 | + } |
|
489 | 507 | |
490 | 508 | // Now to get member data, including avatars and so on. |
491 | 509 | $members = array_keys($context['likers']); |
@@ -493,8 +511,9 @@ discard block |
||
493 | 511 | if (count($loaded) != count($members)) |
494 | 512 | { |
495 | 513 | $members = array_diff($members, $loaded); |
496 | - foreach ($members as $not_loaded) |
|
497 | - unset ($context['likers'][$not_loaded]); |
|
514 | + foreach ($members as $not_loaded) { |
|
515 | + unset ($context['likers'][$not_loaded]); |
|
516 | + } |
|
498 | 517 | } |
499 | 518 | |
500 | 519 | foreach ($context['likers'] as $liker => $dummy) |
@@ -536,12 +555,14 @@ discard block |
||
536 | 555 | global $context, $txt; |
537 | 556 | |
538 | 557 | // Don't do anything if someone else has already take care of the response. |
539 | - if (!$this->_setResponse) |
|
540 | - return; |
|
558 | + if (!$this->_setResponse) { |
|
559 | + return; |
|
560 | + } |
|
541 | 561 | |
542 | 562 | // Want a json response huh? |
543 | - if ($this->_validLikes['json']) |
|
544 | - return $this->jsonResponse(); |
|
563 | + if ($this->_validLikes['json']) { |
|
564 | + return $this->jsonResponse(); |
|
565 | + } |
|
545 | 566 | |
546 | 567 | // Set everything up for display. |
547 | 568 | loadTemplate('Likes'); |
@@ -551,8 +572,9 @@ discard block |
||
551 | 572 | if ($this->_error) |
552 | 573 | { |
553 | 574 | // If this is a generic error, set it up good. |
554 | - if ($this->_error == 'cannot_') |
|
555 | - $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
575 | + if ($this->_error == 'cannot_') { |
|
576 | + $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
577 | + } |
|
556 | 578 | |
557 | 579 | // Is this request coming from an ajax call? |
558 | 580 | if ($this->_js) |
@@ -562,8 +584,9 @@ discard block |
||
562 | 584 | } |
563 | 585 | |
564 | 586 | // Nope? then just do a redirect to whatever URL was provided. |
565 | - else |
|
566 | - redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] . ';error=' . $this->_error : ''); |
|
587 | + else { |
|
588 | + redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] . ';error=' . $this->_error : ''); |
|
589 | + } |
|
567 | 590 | |
568 | 591 | return; |
569 | 592 | } |
@@ -572,8 +595,9 @@ discard block |
||
572 | 595 | else |
573 | 596 | { |
574 | 597 | // Not an ajax request so send the user back to the previous location or the main page. |
575 | - if (!$this->_js) |
|
576 | - redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] : ''); |
|
598 | + if (!$this->_js) { |
|
599 | + redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] : ''); |
|
600 | + } |
|
577 | 601 | |
578 | 602 | // These fine gentlemen all share the same template. |
579 | 603 | $generic = array('delete', 'insert', '_count'); |
@@ -606,8 +630,9 @@ discard block |
||
606 | 630 | // If there is an error, send it. |
607 | 631 | if ($this->_error) |
608 | 632 | { |
609 | - if ($this->_error == 'cannot_') |
|
610 | - $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
633 | + if ($this->_error == 'cannot_') { |
|
634 | + $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
635 | + } |
|
611 | 636 | |
612 | 637 | $print['error'] = $this->_error; |
613 | 638 | } |
@@ -643,33 +668,36 @@ discard block |
||
643 | 668 | <body style="background-color: #444455; color: white; font-style: italic; font-family: serif;"> |
644 | 669 | <div style="margin-top: 12%; font-size: 1.1em; line-height: 1.4; text-align: center;">'; |
645 | 670 | |
646 | - if (!isset($_GET['verse']) || ($_GET['verse'] != '2:18' && $_GET['verse'] != '22:1-2')) |
|
647 | - $_GET['verse'] = '4:16'; |
|
671 | + if (!isset($_GET['verse']) || ($_GET['verse'] != '2:18' && $_GET['verse'] != '22:1-2')) { |
|
672 | + $_GET['verse'] = '4:16'; |
|
673 | + } |
|
648 | 674 | |
649 | - if ($_GET['verse'] == '2:18') |
|
650 | - echo ' |
|
675 | + if ($_GET['verse'] == '2:18') { |
|
676 | + echo ' |
|
651 | 677 | Woe, it was that his name wasn\'t <em>known</em>, that he came in mystery, and was recognized by none. And it became to be in those days <em>something</em>. Something not yet <em id="unknown" name="[Unknown]">unknown</em> to mankind. And thus what was to be known the <em>secret project</em> began into its existence. Henceforth the opposition was only <em>weary</em> and <em>fearful</em>, for now their match was at arms against them.'; |
652 | - elseif ($_GET['verse'] == '4:16') |
|
653 | - echo ' |
|
678 | + } elseif ($_GET['verse'] == '4:16') { |
|
679 | + echo ' |
|
654 | 680 | And it came to pass that the <em>unbelievers</em> dwindled in number and saw rise of many <em>proselytizers</em>, and the opposition found fear in the face of the <em>x</em> and the <em>j</em> while those who stood with the <em>something</em> grew stronger and came together. Still, this was only the <em>beginning</em>, and what lay in the future was <em id="unknown" name="[Unknown]">unknown</em> to all, even those on the right side.'; |
655 | - elseif ($_GET['verse'] == '22:1-2') |
|
656 | - echo ' |
|
681 | + } elseif ($_GET['verse'] == '22:1-2') { |
|
682 | + echo ' |
|
657 | 683 | <p>Now <em>behold</em>, that which was once the secret project was <em id="unknown" name="[Unknown]">unknown</em> no longer. Alas, it needed more than <em>only one</em>, but yet even thought otherwise. It became that the opposition <em>rumored</em> and lied, but still to no avail. Their match, though not <em>perfect</em>, had them outdone.</p> |
658 | 684 | <p style="margin: 2ex 1ex 0 1ex; font-size: 1.05em; line-height: 1.5; text-align: center;">Let it continue. <em>The end</em>.</p>'; |
685 | + } |
|
659 | 686 | |
660 | 687 | echo ' |
661 | 688 | </div> |
662 | 689 | <div style="margin-top: 2ex; font-size: 2em; text-align: right;">'; |
663 | 690 | |
664 | - if ($_GET['verse'] == '2:18') |
|
665 | - echo ' |
|
691 | + if ($_GET['verse'] == '2:18') { |
|
692 | + echo ' |
|
666 | 693 | from <span style="font-family: Georgia, serif;"><strong><a href="', $scripturl, '?action=about:unknown;verse=4:16" style="color: white; text-decoration: none; cursor: text;">The Book of Unknown</a></strong>, 2:18</span>'; |
667 | - elseif ($_GET['verse'] == '4:16') |
|
668 | - echo ' |
|
694 | + } elseif ($_GET['verse'] == '4:16') { |
|
695 | + echo ' |
|
669 | 696 | from <span style="font-family: Georgia, serif;"><strong><a href="', $scripturl, '?action=about:unknown;verse=22:1-2" style="color: white; text-decoration: none; cursor: text;">The Book of Unknown</a></strong>, 4:16</span>'; |
670 | - elseif ($_GET['verse'] == '22:1-2') |
|
671 | - echo ' |
|
697 | + } elseif ($_GET['verse'] == '22:1-2') { |
|
698 | + echo ' |
|
672 | 699 | from <span style="font-family: Georgia, serif;"><strong>The Book of Unknown</strong>, 22:1-2</span>'; |
700 | + } |
|
673 | 701 | |
674 | 702 | echo ' |
675 | 703 | </div> |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Get all birthdays within the given time range. |
@@ -60,8 +61,7 @@ discard block |
||
60 | 61 | 'max_year' => $year_high, |
61 | 62 | ) |
62 | 63 | ); |
63 | - } |
|
64 | - else |
|
64 | + } else |
|
65 | 65 | { |
66 | 66 | $result = $smcFunc['db_query']('birthday_array', ' |
67 | 67 | SELECT id_member, real_name, YEAR(birthdate) AS birth_year, birthdate |
@@ -91,10 +91,11 @@ discard block |
||
91 | 91 | $bday = array(); |
92 | 92 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
93 | 93 | { |
94 | - if ($year_low != $year_high) |
|
95 | - $age_year = substr($row['birthdate'], 5) < substr($high_date, 5) ? $year_high : $year_low; |
|
96 | - else |
|
97 | - $age_year = $year_low; |
|
94 | + if ($year_low != $year_high) { |
|
95 | + $age_year = substr($row['birthdate'], 5) < substr($high_date, 5) ? $year_high : $year_low; |
|
96 | + } else { |
|
97 | + $age_year = $year_low; |
|
98 | + } |
|
98 | 99 | |
99 | 100 | $bday[$age_year . substr($row['birthdate'], 4)][] = array( |
100 | 101 | 'id' => $row['id_member'], |
@@ -108,8 +109,9 @@ discard block |
||
108 | 109 | ksort($bday); |
109 | 110 | |
110 | 111 | // Set is_last, so the themes know when to stop placing separators. |
111 | - foreach ($bday as $mday => $array) |
|
112 | - $bday[$mday][count($array) - 1]['is_last'] = true; |
|
112 | + foreach ($bday as $mday => $array) { |
|
113 | + $bday[$mday][count($array) - 1]['is_last'] = true; |
|
114 | + } |
|
113 | 115 | |
114 | 116 | return $bday; |
115 | 117 | } |
@@ -133,8 +135,9 @@ discard block |
||
133 | 135 | static $timezone_array = array(); |
134 | 136 | require_once($sourcedir . '/Subs.php'); |
135 | 137 | |
136 | - if (empty($timezone_array['default'])) |
|
137 | - $timezone_array['default'] = timezone_open(date_default_timezone_get()); |
|
138 | + if (empty($timezone_array['default'])) { |
|
139 | + $timezone_array['default'] = timezone_open(date_default_timezone_get()); |
|
140 | + } |
|
138 | 141 | |
139 | 142 | $low_object = date_create($low_date); |
140 | 143 | $high_object = date_create($high_date); |
@@ -161,8 +164,9 @@ discard block |
||
161 | 164 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
162 | 165 | { |
163 | 166 | // If the attached topic is not approved then for the moment pretend it doesn't exist |
164 | - if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved']) |
|
165 | - continue; |
|
167 | + if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved']) { |
|
168 | + continue; |
|
169 | + } |
|
166 | 170 | |
167 | 171 | // Force a censor of the title - as often these are used by others. |
168 | 172 | censorText($row['title'], $use_permissions ? false : true); |
@@ -170,12 +174,14 @@ discard block |
||
170 | 174 | // Get the various time and date properties for this event |
171 | 175 | list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row); |
172 | 176 | |
173 | - if (empty($timezone_array[$tz])) |
|
174 | - $timezone_array[$tz] = timezone_open($tz); |
|
177 | + if (empty($timezone_array[$tz])) { |
|
178 | + $timezone_array[$tz] = timezone_open($tz); |
|
179 | + } |
|
175 | 180 | |
176 | 181 | // Sanity check |
177 | - if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) |
|
178 | - continue; |
|
182 | + if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) { |
|
183 | + continue; |
|
184 | + } |
|
179 | 185 | |
180 | 186 | // Get set up for the loop |
181 | 187 | $start_object = date_create($row['start_date'] . (!$allday ? ' ' . $row['start_time'] : ''), $timezone_array[$tz]); |
@@ -239,8 +245,8 @@ discard block |
||
239 | 245 | ); |
240 | 246 | |
241 | 247 | // If we're using permissions (calendar pages?) then just ouput normal contextual style information. |
242 | - if ($use_permissions) |
|
243 | - $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
248 | + if ($use_permissions) { |
|
249 | + $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
244 | 250 | 'href' => $row['id_board'] == 0 ? '' : $scripturl . '?topic=' . $row['id_topic'] . '.0', |
245 | 251 | 'link' => $row['id_board'] == 0 ? $row['title'] : '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['title'] . '</a>', |
246 | 252 | 'can_edit' => allowedTo('calendar_edit_any') || ($row['id_member'] == $user_info['id'] && allowedTo('calendar_edit_own')), |
@@ -248,9 +254,10 @@ discard block |
||
248 | 254 | 'can_export' => !empty($modSettings['cal_export']) ? true : false, |
249 | 255 | 'export_href' => $scripturl . '?action=calendar;sa=ical;eventid=' . $row['id_event'] . ';' . $context['session_var'] . '=' . $context['session_id'], |
250 | 256 | )); |
257 | + } |
|
251 | 258 | // Otherwise, this is going to be cached and the VIEWER'S permissions should apply... just put together some info. |
252 | - else |
|
253 | - $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
259 | + else { |
|
260 | + $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
254 | 261 | 'href' => $row['id_topic'] == 0 ? '' : $scripturl . '?topic=' . $row['id_topic'] . '.0', |
255 | 262 | 'link' => $row['id_topic'] == 0 ? $row['title'] : '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['title'] . '</a>', |
256 | 263 | 'can_edit' => false, |
@@ -260,6 +267,7 @@ discard block |
||
260 | 267 | 'poster' => $row['id_member'], |
261 | 268 | 'allowed_groups' => explode(',', $row['member_groups']), |
262 | 269 | )); |
270 | + } |
|
263 | 271 | |
264 | 272 | date_add($cal_date, date_interval_create_from_date_string('1 day')); |
265 | 273 | } |
@@ -269,8 +277,9 @@ discard block |
||
269 | 277 | // If we're doing normal contextual data, go through and make things clear to the templates ;). |
270 | 278 | if ($use_permissions) |
271 | 279 | { |
272 | - foreach ($events as $mday => $array) |
|
273 | - $events[$mday][count($array) - 1]['is_last'] = true; |
|
280 | + foreach ($events as $mday => $array) { |
|
281 | + $events[$mday][count($array) - 1]['is_last'] = true; |
|
282 | + } |
|
274 | 283 | } |
275 | 284 | |
276 | 285 | ksort($events); |
@@ -290,11 +299,12 @@ discard block |
||
290 | 299 | global $smcFunc; |
291 | 300 | |
292 | 301 | // Get the lowest and highest dates for "all years". |
293 | - if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) |
|
294 | - $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec} |
|
302 | + if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) { |
|
303 | + $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec} |
|
295 | 304 | OR event_date BETWEEN {date:all_year_jan} AND {date:all_year_high}'; |
296 | - else |
|
297 | - $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}'; |
|
305 | + } else { |
|
306 | + $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}'; |
|
307 | + } |
|
298 | 308 | |
299 | 309 | // Find some holidays... ;). |
300 | 310 | $result = $smcFunc['db_query']('', ' |
@@ -314,10 +324,11 @@ discard block |
||
314 | 324 | $holidays = array(); |
315 | 325 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
316 | 326 | { |
317 | - if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) |
|
318 | - $event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4); |
|
319 | - else |
|
320 | - $event_year = substr($low_date, 0, 4); |
|
327 | + if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) { |
|
328 | + $event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4); |
|
329 | + } else { |
|
330 | + $event_year = substr($low_date, 0, 4); |
|
331 | + } |
|
321 | 332 | |
322 | 333 | $holidays[$event_year . substr($row['event_date'], 4)][] = $row['title']; |
323 | 334 | } |
@@ -343,10 +354,12 @@ discard block |
||
343 | 354 | isAllowedTo('calendar_post'); |
344 | 355 | |
345 | 356 | // No board? No topic?!? |
346 | - if (empty($board)) |
|
347 | - fatal_lang_error('missing_board_id', false); |
|
348 | - if (empty($topic)) |
|
349 | - fatal_lang_error('missing_topic_id', false); |
|
357 | + if (empty($board)) { |
|
358 | + fatal_lang_error('missing_board_id', false); |
|
359 | + } |
|
360 | + if (empty($topic)) { |
|
361 | + fatal_lang_error('missing_topic_id', false); |
|
362 | + } |
|
350 | 363 | |
351 | 364 | // Administrator, Moderator, or owner. Period. |
352 | 365 | if (!allowedTo('admin_forum') && !allowedTo('moderate_board')) |
@@ -364,12 +377,14 @@ discard block |
||
364 | 377 | if ($row = $smcFunc['db_fetch_assoc']($result)) |
365 | 378 | { |
366 | 379 | // Not the owner of the topic. |
367 | - if ($row['id_member_started'] != $user_info['id']) |
|
368 | - fatal_lang_error('not_your_topic', 'user'); |
|
380 | + if ($row['id_member_started'] != $user_info['id']) { |
|
381 | + fatal_lang_error('not_your_topic', 'user'); |
|
382 | + } |
|
369 | 383 | } |
370 | 384 | // Topic/Board doesn't exist..... |
371 | - else |
|
372 | - fatal_lang_error('calendar_no_topic', 'general'); |
|
385 | + else { |
|
386 | + fatal_lang_error('calendar_no_topic', 'general'); |
|
387 | + } |
|
373 | 388 | $smcFunc['db_free_result']($result); |
374 | 389 | } |
375 | 390 | } |
@@ -457,14 +472,16 @@ discard block |
||
457 | 472 | if (!empty($calendarOptions['start_day'])) |
458 | 473 | { |
459 | 474 | $nShift -= $calendarOptions['start_day']; |
460 | - if ($nShift < 0) |
|
461 | - $nShift = 7 + $nShift; |
|
475 | + if ($nShift < 0) { |
|
476 | + $nShift = 7 + $nShift; |
|
477 | + } |
|
462 | 478 | } |
463 | 479 | |
464 | 480 | // Number of rows required to fit the month. |
465 | 481 | $nRows = floor(($month_info['last_day']['day_of_month'] + $nShift) / 7); |
466 | - if (($month_info['last_day']['day_of_month'] + $nShift) % 7) |
|
467 | - $nRows++; |
|
482 | + if (($month_info['last_day']['day_of_month'] + $nShift) % 7) { |
|
483 | + $nRows++; |
|
484 | + } |
|
468 | 485 | |
469 | 486 | // Fetch the arrays for birthdays, posted events, and holidays. |
470 | 487 | $bday = $calendarOptions['show_birthdays'] ? getBirthdayRange($month_info['first_day']['date'], $month_info['last_day']['date']) : array(); |
@@ -477,8 +494,9 @@ discard block |
||
477 | 494 | { |
478 | 495 | $calendarGrid['week_days'][] = $count; |
479 | 496 | $count++; |
480 | - if ($count == 7) |
|
481 | - $count = 0; |
|
497 | + if ($count == 7) { |
|
498 | + $count = 0; |
|
499 | + } |
|
482 | 500 | } |
483 | 501 | |
484 | 502 | // Iterate through each week. |
@@ -495,8 +513,9 @@ discard block |
||
495 | 513 | { |
496 | 514 | $nDay = ($nRow * 7) + $nCol - $nShift + 1; |
497 | 515 | |
498 | - if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month']) |
|
499 | - $nDay = 0; |
|
516 | + if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month']) { |
|
517 | + $nDay = 0; |
|
518 | + } |
|
500 | 519 | |
501 | 520 | $date = sprintf('%04d-%02d-%02d', $year, $month, $nDay); |
502 | 521 | |
@@ -514,8 +533,9 @@ discard block |
||
514 | 533 | } |
515 | 534 | |
516 | 535 | // What is the last day of the month? |
517 | - if ($is_previous === true) |
|
518 | - $calendarGrid['last_of_month'] = $month_info['last_day']['day_of_month']; |
|
536 | + if ($is_previous === true) { |
|
537 | + $calendarGrid['last_of_month'] = $month_info['last_day']['day_of_month']; |
|
538 | + } |
|
519 | 539 | |
520 | 540 | // We'll use the shift in the template. |
521 | 541 | $calendarGrid['shift'] = $nShift; |
@@ -549,8 +569,9 @@ discard block |
||
549 | 569 | { |
550 | 570 | // Here we offset accordingly to get things to the real start of a week. |
551 | 571 | $date_diff = $day_of_week - $calendarOptions['start_day']; |
552 | - if ($date_diff < 0) |
|
553 | - $date_diff += 7; |
|
572 | + if ($date_diff < 0) { |
|
573 | + $date_diff += 7; |
|
574 | + } |
|
554 | 575 | $new_timestamp = mktime(0, 0, 0, $month, $day, $year) - $date_diff * 86400; |
555 | 576 | $day = (int) strftime('%d', $new_timestamp); |
556 | 577 | $month = (int) strftime('%m', $new_timestamp); |
@@ -680,18 +701,20 @@ discard block |
||
680 | 701 | { |
681 | 702 | foreach ($date_events as $event_key => $event_val) |
682 | 703 | { |
683 | - if (in_array($event_val['id'], $temp)) |
|
684 | - unset($calendarGrid['events'][$date][$event_key]); |
|
685 | - else |
|
686 | - $temp[] = $event_val['id']; |
|
704 | + if (in_array($event_val['id'], $temp)) { |
|
705 | + unset($calendarGrid['events'][$date][$event_key]); |
|
706 | + } else { |
|
707 | + $temp[] = $event_val['id']; |
|
708 | + } |
|
687 | 709 | } |
688 | 710 | } |
689 | 711 | |
690 | 712 | // Give birthdays and holidays a friendly format, without the year |
691 | - if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
692 | - $date_format = '%b %d'; |
|
693 | - else |
|
694 | - $date_format = str_replace(array('%Y', '%y', '%G', '%g', '%C', '%c', '%D'), array('', '', '', '', '', '%b %d', '%m/%d'), $matches[0]); |
|
713 | + if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
714 | + $date_format = '%b %d'; |
|
715 | + } else { |
|
716 | + $date_format = str_replace(array('%Y', '%y', '%G', '%g', '%C', '%c', '%D'), array('', '', '', '', '', '%b %d', '%m/%d'), $matches[0]); |
|
717 | + } |
|
695 | 718 | |
696 | 719 | foreach (array('birthdays', 'holidays') as $type) |
697 | 720 | { |
@@ -790,8 +813,9 @@ discard block |
||
790 | 813 | // Holidays between now and now + days. |
791 | 814 | for ($i = $now; $i < $now + $days_for_index; $i += 86400) |
792 | 815 | { |
793 | - if (isset($cached_data['holidays'][strftime('%Y-%m-%d', $i)])) |
|
794 | - $return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][strftime('%Y-%m-%d', $i)]); |
|
816 | + if (isset($cached_data['holidays'][strftime('%Y-%m-%d', $i)])) { |
|
817 | + $return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][strftime('%Y-%m-%d', $i)]); |
|
818 | + } |
|
795 | 819 | } |
796 | 820 | } |
797 | 821 | |
@@ -803,8 +827,9 @@ discard block |
||
803 | 827 | $loop_date = strftime('%Y-%m-%d', $i); |
804 | 828 | if (isset($cached_data['birthdays'][$loop_date])) |
805 | 829 | { |
806 | - foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy) |
|
807 | - $cached_data['birthdays'][strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date']; |
|
830 | + foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy) { |
|
831 | + $cached_data['birthdays'][strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date']; |
|
832 | + } |
|
808 | 833 | $return_data['calendar_birthdays'] = array_merge($return_data['calendar_birthdays'], $cached_data['birthdays'][$loop_date]); |
809 | 834 | } |
810 | 835 | } |
@@ -819,8 +844,9 @@ discard block |
||
819 | 844 | $loop_date = strftime('%Y-%m-%d', $i); |
820 | 845 | |
821 | 846 | // No events today? Check the next day. |
822 | - if (empty($cached_data['events'][$loop_date])) |
|
823 | - continue; |
|
847 | + if (empty($cached_data['events'][$loop_date])) { |
|
848 | + continue; |
|
849 | + } |
|
824 | 850 | |
825 | 851 | // Loop through all events to add a few last-minute values. |
826 | 852 | foreach ($cached_data['events'][$loop_date] as $ev => $event) |
@@ -833,9 +859,9 @@ discard block |
||
833 | 859 | { |
834 | 860 | unset($cached_data['events'][$loop_date][$ev]); |
835 | 861 | continue; |
862 | + } else { |
|
863 | + $duplicates[$this_event['topic'] . $this_event['title']] = true; |
|
836 | 864 | } |
837 | - else |
|
838 | - $duplicates[$this_event['topic'] . $this_event['title']] = true; |
|
839 | 865 | |
840 | 866 | // Might be set to true afterwards, depending on the permissions. |
841 | 867 | $this_event['can_edit'] = false; |
@@ -843,16 +869,19 @@ discard block |
||
843 | 869 | $this_event['date'] = $loop_date; |
844 | 870 | } |
845 | 871 | |
846 | - if (!empty($cached_data['events'][$loop_date])) |
|
847 | - $return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]); |
|
872 | + if (!empty($cached_data['events'][$loop_date])) { |
|
873 | + $return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]); |
|
874 | + } |
|
848 | 875 | } |
849 | 876 | } |
850 | 877 | |
851 | 878 | // Mark the last item so that a list separator can be used in the template. |
852 | - for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++) |
|
853 | - $return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]); |
|
854 | - for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++) |
|
855 | - $return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]); |
|
879 | + for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++) { |
|
880 | + $return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]); |
|
881 | + } |
|
882 | + for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++) { |
|
883 | + $return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]); |
|
884 | + } |
|
856 | 885 | |
857 | 886 | return array( |
858 | 887 | 'data' => $return_data, |
@@ -900,37 +929,46 @@ discard block |
||
900 | 929 | if (isset($_POST['start_date'])) |
901 | 930 | { |
902 | 931 | $d = date_parse($_POST['start_date']); |
903 | - if (!empty($d['error_count']) || !empty($d['warning_count'])) |
|
904 | - fatal_lang_error('invalid_date', false); |
|
905 | - if (empty($d['year'])) |
|
906 | - fatal_lang_error('event_year_missing', false); |
|
907 | - if (empty($d['month'])) |
|
908 | - fatal_lang_error('event_month_missing', false); |
|
909 | - } |
|
910 | - elseif (isset($_POST['start_datetime'])) |
|
932 | + if (!empty($d['error_count']) || !empty($d['warning_count'])) { |
|
933 | + fatal_lang_error('invalid_date', false); |
|
934 | + } |
|
935 | + if (empty($d['year'])) { |
|
936 | + fatal_lang_error('event_year_missing', false); |
|
937 | + } |
|
938 | + if (empty($d['month'])) { |
|
939 | + fatal_lang_error('event_month_missing', false); |
|
940 | + } |
|
941 | + } elseif (isset($_POST['start_datetime'])) |
|
911 | 942 | { |
912 | 943 | $d = date_parse($_POST['start_datetime']); |
913 | - if (!empty($d['error_count']) || !empty($d['warning_count'])) |
|
914 | - fatal_lang_error('invalid_date', false); |
|
915 | - if (empty($d['year'])) |
|
916 | - fatal_lang_error('event_year_missing', false); |
|
917 | - if (empty($d['month'])) |
|
918 | - fatal_lang_error('event_month_missing', false); |
|
944 | + if (!empty($d['error_count']) || !empty($d['warning_count'])) { |
|
945 | + fatal_lang_error('invalid_date', false); |
|
946 | + } |
|
947 | + if (empty($d['year'])) { |
|
948 | + fatal_lang_error('event_year_missing', false); |
|
949 | + } |
|
950 | + if (empty($d['month'])) { |
|
951 | + fatal_lang_error('event_month_missing', false); |
|
952 | + } |
|
919 | 953 | } |
920 | 954 | // The 2.0 way |
921 | 955 | else |
922 | 956 | { |
923 | 957 | // No month? No year? |
924 | - if (!isset($_POST['month'])) |
|
925 | - fatal_lang_error('event_month_missing', false); |
|
926 | - if (!isset($_POST['year'])) |
|
927 | - fatal_lang_error('event_year_missing', false); |
|
958 | + if (!isset($_POST['month'])) { |
|
959 | + fatal_lang_error('event_month_missing', false); |
|
960 | + } |
|
961 | + if (!isset($_POST['year'])) { |
|
962 | + fatal_lang_error('event_year_missing', false); |
|
963 | + } |
|
928 | 964 | |
929 | 965 | // Check the month and year... |
930 | - if ($_POST['month'] < 1 || $_POST['month'] > 12) |
|
931 | - fatal_lang_error('invalid_month', false); |
|
932 | - if ($_POST['year'] < $modSettings['cal_minyear'] || $_POST['year'] > $modSettings['cal_maxyear']) |
|
933 | - fatal_lang_error('invalid_year', false); |
|
966 | + if ($_POST['month'] < 1 || $_POST['month'] > 12) { |
|
967 | + fatal_lang_error('invalid_month', false); |
|
968 | + } |
|
969 | + if ($_POST['year'] < $modSettings['cal_minyear'] || $_POST['year'] > $modSettings['cal_maxyear']) { |
|
970 | + fatal_lang_error('invalid_year', false); |
|
971 | + } |
|
934 | 972 | } |
935 | 973 | } |
936 | 974 | |
@@ -940,8 +978,9 @@ discard block |
||
940 | 978 | // If they want to us to calculate an end date, make sure it will fit in an acceptable range. |
941 | 979 | if (isset($_POST['span'])) |
942 | 980 | { |
943 | - if (($_POST['span'] < 1) || (!empty($modSettings['cal_maxspan']) && $_POST['span'] > $modSettings['cal_maxspan'])) |
|
944 | - fatal_lang_error('invalid_days_numb', false); |
|
981 | + if (($_POST['span'] < 1) || (!empty($modSettings['cal_maxspan']) && $_POST['span'] > $modSettings['cal_maxspan'])) { |
|
982 | + fatal_lang_error('invalid_days_numb', false); |
|
983 | + } |
|
945 | 984 | } |
946 | 985 | |
947 | 986 | // There is no need to validate the following values if we are just deleting the event. |
@@ -951,24 +990,29 @@ discard block |
||
951 | 990 | if (empty($_POST['start_date']) && empty($_POST['start_datetime'])) |
952 | 991 | { |
953 | 992 | // No day? |
954 | - if (!isset($_POST['day'])) |
|
955 | - fatal_lang_error('event_day_missing', false); |
|
993 | + if (!isset($_POST['day'])) { |
|
994 | + fatal_lang_error('event_day_missing', false); |
|
995 | + } |
|
956 | 996 | |
957 | 997 | // Bad day? |
958 | - if (!checkdate($_POST['month'], $_POST['day'], $_POST['year'])) |
|
959 | - fatal_lang_error('invalid_date', false); |
|
998 | + if (!checkdate($_POST['month'], $_POST['day'], $_POST['year'])) { |
|
999 | + fatal_lang_error('invalid_date', false); |
|
1000 | + } |
|
960 | 1001 | } |
961 | 1002 | |
962 | - if (!isset($_POST['evtitle']) && !isset($_POST['subject'])) |
|
963 | - fatal_lang_error('event_title_missing', false); |
|
964 | - elseif (!isset($_POST['evtitle'])) |
|
965 | - $_POST['evtitle'] = $_POST['subject']; |
|
1003 | + if (!isset($_POST['evtitle']) && !isset($_POST['subject'])) { |
|
1004 | + fatal_lang_error('event_title_missing', false); |
|
1005 | + } elseif (!isset($_POST['evtitle'])) { |
|
1006 | + $_POST['evtitle'] = $_POST['subject']; |
|
1007 | + } |
|
966 | 1008 | |
967 | 1009 | // No title? |
968 | - if ($smcFunc['htmltrim']($_POST['evtitle']) === '') |
|
969 | - fatal_lang_error('no_event_title', false); |
|
970 | - if ($smcFunc['strlen']($_POST['evtitle']) > 100) |
|
971 | - $_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100); |
|
1010 | + if ($smcFunc['htmltrim']($_POST['evtitle']) === '') { |
|
1011 | + fatal_lang_error('no_event_title', false); |
|
1012 | + } |
|
1013 | + if ($smcFunc['strlen']($_POST['evtitle']) > 100) { |
|
1014 | + $_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100); |
|
1015 | + } |
|
972 | 1016 | $_POST['evtitle'] = str_replace(';', '', $_POST['evtitle']); |
973 | 1017 | } |
974 | 1018 | } |
@@ -995,8 +1039,9 @@ discard block |
||
995 | 1039 | ); |
996 | 1040 | |
997 | 1041 | // No results, return false. |
998 | - if ($smcFunc['db_num_rows'] === 0) |
|
999 | - return false; |
|
1042 | + if ($smcFunc['db_num_rows'] === 0) { |
|
1043 | + return false; |
|
1044 | + } |
|
1000 | 1045 | |
1001 | 1046 | // Grab the results and return. |
1002 | 1047 | list ($poster) = $smcFunc['db_fetch_row']($request); |
@@ -1130,8 +1175,9 @@ discard block |
||
1130 | 1175 | call_integration_hook('integrate_modify_event', array($event_id, &$eventOptions, &$event_columns, &$event_parameters)); |
1131 | 1176 | |
1132 | 1177 | $column_clauses = array(); |
1133 | - foreach ($event_columns as $col => $crit) |
|
1134 | - $column_clauses[] = $col . ' = ' . $crit; |
|
1178 | + foreach ($event_columns as $col => $crit) { |
|
1179 | + $column_clauses[] = $col . ' = ' . $crit; |
|
1180 | + } |
|
1135 | 1181 | |
1136 | 1182 | $smcFunc['db_query']('', ' |
1137 | 1183 | UPDATE {db_prefix}calendar |
@@ -1216,8 +1262,9 @@ discard block |
||
1216 | 1262 | ); |
1217 | 1263 | |
1218 | 1264 | // If nothing returned, we are in poo, poo. |
1219 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
1220 | - return false; |
|
1265 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
1266 | + return false; |
|
1267 | + } |
|
1221 | 1268 | |
1222 | 1269 | $row = $smcFunc['db_fetch_assoc']($request); |
1223 | 1270 | $smcFunc['db_free_result']($request); |
@@ -1225,8 +1272,9 @@ discard block |
||
1225 | 1272 | list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row); |
1226 | 1273 | |
1227 | 1274 | // Sanity check |
1228 | - if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) |
|
1229 | - return false; |
|
1275 | + if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) { |
|
1276 | + return false; |
|
1277 | + } |
|
1230 | 1278 | |
1231 | 1279 | $return_value = array( |
1232 | 1280 | 'boards' => array(), |
@@ -1363,24 +1411,27 @@ discard block |
||
1363 | 1411 | |
1364 | 1412 | // Set $span, in case we need it |
1365 | 1413 | $span = isset($eventOptions['span']) ? $eventOptions['span'] : (isset($_POST['span']) ? $_POST['span'] : 0); |
1366 | - if ($span > 0) |
|
1367 | - $span = !empty($modSettings['cal_maxspan']) ? min($modSettings['cal_maxspan'], $span - 1) : $span - 1; |
|
1414 | + if ($span > 0) { |
|
1415 | + $span = !empty($modSettings['cal_maxspan']) ? min($modSettings['cal_maxspan'], $span - 1) : $span - 1; |
|
1416 | + } |
|
1368 | 1417 | |
1369 | 1418 | // Define the timezone for this event, falling back to the default if not provided |
1370 | - if (!empty($eventOptions['tz']) && in_array($eventOptions['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
1371 | - $tz = $eventOptions['tz']; |
|
1372 | - elseif (!empty($_POST['tz']) && in_array($_POST['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
1373 | - $tz = $_POST['tz']; |
|
1374 | - else |
|
1375 | - $tz = getUserTimezone(); |
|
1419 | + if (!empty($eventOptions['tz']) && in_array($eventOptions['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
1420 | + $tz = $eventOptions['tz']; |
|
1421 | + } elseif (!empty($_POST['tz']) && in_array($_POST['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
1422 | + $tz = $_POST['tz']; |
|
1423 | + } else { |
|
1424 | + $tz = getUserTimezone(); |
|
1425 | + } |
|
1376 | 1426 | |
1377 | 1427 | // Is this supposed to be an all day event, or should it have specific start and end times? |
1378 | - if (isset($eventOptions['allday'])) |
|
1379 | - $allday = $eventOptions['allday']; |
|
1380 | - elseif (empty($_POST['allday'])) |
|
1381 | - $allday = false; |
|
1382 | - else |
|
1383 | - $allday = true; |
|
1428 | + if (isset($eventOptions['allday'])) { |
|
1429 | + $allday = $eventOptions['allday']; |
|
1430 | + } elseif (empty($_POST['allday'])) { |
|
1431 | + $allday = false; |
|
1432 | + } else { |
|
1433 | + $allday = true; |
|
1434 | + } |
|
1384 | 1435 | |
1385 | 1436 | // Input might come as individual parameters... |
1386 | 1437 | $start_year = isset($eventOptions['year']) ? $eventOptions['year'] : (isset($_POST['year']) ? $_POST['year'] : null); |
@@ -1407,10 +1458,12 @@ discard block |
||
1407 | 1458 | $end_time_string = isset($eventOptions['end_time']) ? $eventOptions['end_time'] : (isset($_POST['end_time']) ? $_POST['end_time'] : null); |
1408 | 1459 | |
1409 | 1460 | // If the date and time were given in separate strings, combine them |
1410 | - if (empty($start_string) && isset($start_date_string)) |
|
1411 | - $start_string = $start_date_string . (isset($start_time_string) ? ' ' . $start_time_string : ''); |
|
1412 | - if (empty($end_string) && isset($end_date_string)) |
|
1413 | - $end_string = $end_date_string . (isset($end_time_string) ? ' ' . $end_time_string : ''); |
|
1461 | + if (empty($start_string) && isset($start_date_string)) { |
|
1462 | + $start_string = $start_date_string . (isset($start_time_string) ? ' ' . $start_time_string : ''); |
|
1463 | + } |
|
1464 | + if (empty($end_string) && isset($end_date_string)) { |
|
1465 | + $end_string = $end_date_string . (isset($end_time_string) ? ' ' . $end_time_string : ''); |
|
1466 | + } |
|
1414 | 1467 | |
1415 | 1468 | // If some form of string input was given, override individually defined options with it |
1416 | 1469 | if (isset($start_string)) |
@@ -1501,10 +1554,11 @@ discard block |
||
1501 | 1554 | if ($start_object >= $end_object) |
1502 | 1555 | { |
1503 | 1556 | $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, $start_hour, $start_minute, $start_second) . ' ' . $tz); |
1504 | - if ($span > 0) |
|
1505 | - date_add($end_object, date_interval_create_from_date_string($span . ' days')); |
|
1506 | - else |
|
1507 | - date_add($end_object, date_interval_create_from_date_string('1 hour')); |
|
1557 | + if ($span > 0) { |
|
1558 | + date_add($end_object, date_interval_create_from_date_string($span . ' days')); |
|
1559 | + } else { |
|
1560 | + date_add($end_object, date_interval_create_from_date_string('1 hour')); |
|
1561 | + } |
|
1508 | 1562 | } |
1509 | 1563 | |
1510 | 1564 | // Is $end_object too late? |
@@ -1517,9 +1571,9 @@ discard block |
||
1517 | 1571 | { |
1518 | 1572 | $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, $start_hour, $start_minute, $start_second) . ' ' . $tz); |
1519 | 1573 | date_add($end_object, date_interval_create_from_date_string($modSettings['cal_maxspan'] . ' days')); |
1574 | + } else { |
|
1575 | + $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, '11', '59', '59') . ' ' . $tz); |
|
1520 | 1576 | } |
1521 | - else |
|
1522 | - $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, '11', '59', '59') . ' ' . $tz); |
|
1523 | 1577 | } |
1524 | 1578 | } |
1525 | 1579 | |
@@ -1532,8 +1586,7 @@ discard block |
||
1532 | 1586 | $start_time = null; |
1533 | 1587 | $end_time = null; |
1534 | 1588 | $tz = null; |
1535 | - } |
|
1536 | - else |
|
1589 | + } else |
|
1537 | 1590 | { |
1538 | 1591 | $start_time = date_format($start_object, 'H:i:s'); |
1539 | 1592 | $end_time = date_format($end_object, 'H:i:s'); |
@@ -1559,19 +1612,21 @@ discard block |
||
1559 | 1612 | // First, try to create a better date format, ignoring the "time" elements. |
1560 | 1613 | if (empty($date_format)) |
1561 | 1614 | { |
1562 | - if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
1563 | - $date_format = '%F'; |
|
1564 | - else |
|
1565 | - $date_format = $matches[0]; |
|
1615 | + if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
1616 | + $date_format = '%F'; |
|
1617 | + } else { |
|
1618 | + $date_format = $matches[0]; |
|
1619 | + } |
|
1566 | 1620 | } |
1567 | 1621 | |
1568 | 1622 | // We want a fairly compact version of the time, but as close as possible to the user's settings. |
1569 | 1623 | if (empty($time_format)) |
1570 | 1624 | { |
1571 | - if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
1572 | - $time_format = '%k:%M'; |
|
1573 | - else |
|
1574 | - $time_format = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
1625 | + if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
1626 | + $time_format = '%k:%M'; |
|
1627 | + } else { |
|
1628 | + $time_format = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
1629 | + } |
|
1575 | 1630 | } |
1576 | 1631 | |
1577 | 1632 | // Should this be an all day event? |
@@ -1581,11 +1636,13 @@ discard block |
||
1581 | 1636 | $span = 1 + date_interval_format(date_diff(date_create($row['start_date']), date_create($row['end_date'])), '%d'); |
1582 | 1637 | |
1583 | 1638 | // We need to have a defined timezone in the steps below |
1584 | - if (empty($row['timezone'])) |
|
1585 | - $row['timezone'] = getUserTimezone(); |
|
1639 | + if (empty($row['timezone'])) { |
|
1640 | + $row['timezone'] = getUserTimezone(); |
|
1641 | + } |
|
1586 | 1642 | |
1587 | - if (empty($timezone_array[$row['timezone']])) |
|
1588 | - $timezone_array[$row['timezone']] = timezone_open($row['timezone']); |
|
1643 | + if (empty($timezone_array[$row['timezone']])) { |
|
1644 | + $timezone_array[$row['timezone']] = timezone_open($row['timezone']); |
|
1645 | + } |
|
1589 | 1646 | |
1590 | 1647 | // Get most of the standard date information for the start and end datetimes |
1591 | 1648 | $start = date_parse($row['start_date'] . (!$allday ? ' ' . $row['start_time'] : '')); |
@@ -1633,8 +1690,9 @@ discard block |
||
1633 | 1690 | global $smcFunc, $context, $user_info, $modSettings, $user_settings; |
1634 | 1691 | static $member_cache = array(); |
1635 | 1692 | |
1636 | - if (is_null($id_member) && $user_info['is_guest'] == false) |
|
1637 | - $id_member = $context['user']['id']; |
|
1693 | + if (is_null($id_member) && $user_info['is_guest'] == false) { |
|
1694 | + $id_member = $context['user']['id']; |
|
1695 | + } |
|
1638 | 1696 | |
1639 | 1697 | //check if the cache got the data |
1640 | 1698 | if (isset($id_member) && isset($member_cache[$id_member])) |
@@ -1663,11 +1721,13 @@ discard block |
||
1663 | 1721 | $smcFunc['db_free_result']($request); |
1664 | 1722 | } |
1665 | 1723 | |
1666 | - if (empty($timezone) || !in_array($timezone, timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
1667 | - $timezone = isset($modSettings['default_timezone']) ? $modSettings['default_timezone'] : date_default_timezone_get(); |
|
1724 | + if (empty($timezone) || !in_array($timezone, timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
1725 | + $timezone = isset($modSettings['default_timezone']) ? $modSettings['default_timezone'] : date_default_timezone_get(); |
|
1726 | + } |
|
1668 | 1727 | |
1669 | - if (isset($id_member)) |
|
1670 | - $member_cache[$id_member] = $timezone; |
|
1728 | + if (isset($id_member)) { |
|
1729 | + $member_cache[$id_member] = $timezone; |
|
1730 | + } |
|
1671 | 1731 | |
1672 | 1732 | return $timezone; |
1673 | 1733 | } |
@@ -1696,8 +1756,9 @@ discard block |
||
1696 | 1756 | ) |
1697 | 1757 | ); |
1698 | 1758 | $holidays = array(); |
1699 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1700 | - $holidays[] = $row; |
|
1759 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1760 | + $holidays[] = $row; |
|
1761 | + } |
|
1701 | 1762 | $smcFunc['db_free_result']($request); |
1702 | 1763 | |
1703 | 1764 | return $holidays; |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 4 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('No direct access...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * View a summary. |
@@ -23,8 +24,9 @@ discard block |
||
23 | 24 | global $context, $memberContext, $txt, $modSettings, $user_profile, $sourcedir, $scripturl, $smcFunc; |
24 | 25 | |
25 | 26 | // Attempt to load the member's profile data. |
26 | - if (!loadMemberContext($memID) || !isset($memberContext[$memID])) |
|
27 | - fatal_lang_error('not_a_user', false, 404); |
|
27 | + if (!loadMemberContext($memID) || !isset($memberContext[$memID])) { |
|
28 | + fatal_lang_error('not_a_user', false, 404); |
|
29 | + } |
|
28 | 30 | |
29 | 31 | // Set up the stuff and load the user. |
30 | 32 | $context += array( |
@@ -49,19 +51,21 @@ discard block |
||
49 | 51 | |
50 | 52 | // See if they have broken any warning levels... |
51 | 53 | list ($modSettings['warning_enable'], $modSettings['user_limit']) = explode(',', $modSettings['warning_settings']); |
52 | - if (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $context['member']['warning']) |
|
53 | - $context['warning_status'] = $txt['profile_warning_is_muted']; |
|
54 | - elseif (!empty($modSettings['warning_moderate']) && $modSettings['warning_moderate'] <= $context['member']['warning']) |
|
55 | - $context['warning_status'] = $txt['profile_warning_is_moderation']; |
|
56 | - elseif (!empty($modSettings['warning_watch']) && $modSettings['warning_watch'] <= $context['member']['warning']) |
|
57 | - $context['warning_status'] = $txt['profile_warning_is_watch']; |
|
54 | + if (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $context['member']['warning']) { |
|
55 | + $context['warning_status'] = $txt['profile_warning_is_muted']; |
|
56 | + } elseif (!empty($modSettings['warning_moderate']) && $modSettings['warning_moderate'] <= $context['member']['warning']) { |
|
57 | + $context['warning_status'] = $txt['profile_warning_is_moderation']; |
|
58 | + } elseif (!empty($modSettings['warning_watch']) && $modSettings['warning_watch'] <= $context['member']['warning']) { |
|
59 | + $context['warning_status'] = $txt['profile_warning_is_watch']; |
|
60 | + } |
|
58 | 61 | |
59 | 62 | // They haven't even been registered for a full day!? |
60 | 63 | $days_registered = (int) ((time() - $user_profile[$memID]['date_registered']) / (3600 * 24)); |
61 | - if (empty($user_profile[$memID]['date_registered']) || $days_registered < 1) |
|
62 | - $context['member']['posts_per_day'] = $txt['not_applicable']; |
|
63 | - else |
|
64 | - $context['member']['posts_per_day'] = comma_format($context['member']['real_posts'] / $days_registered, 3); |
|
64 | + if (empty($user_profile[$memID]['date_registered']) || $days_registered < 1) { |
|
65 | + $context['member']['posts_per_day'] = $txt['not_applicable']; |
|
66 | + } else { |
|
67 | + $context['member']['posts_per_day'] = comma_format($context['member']['real_posts'] / $days_registered, 3); |
|
68 | + } |
|
65 | 69 | |
66 | 70 | // Set the age... |
67 | 71 | if (empty($context['member']['birth_date']) || substr($context['member']['birth_date'], 0, 4) < 1002) |
@@ -70,8 +74,7 @@ discard block |
||
70 | 74 | 'age' => $txt['not_applicable'], |
71 | 75 | 'today_is_birthday' => false |
72 | 76 | ); |
73 | - } |
|
74 | - else |
|
77 | + } else |
|
75 | 78 | { |
76 | 79 | list ($birth_year, $birth_month, $birth_day) = sscanf($context['member']['birth_date'], '%d-%d-%d'); |
77 | 80 | $datearray = getdate(forum_time()); |
@@ -84,15 +87,16 @@ discard block |
||
84 | 87 | if (allowedTo('moderate_forum')) |
85 | 88 | { |
86 | 89 | // Make sure it's a valid ip address; otherwise, don't bother... |
87 | - if (preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $memberContext[$memID]['ip']) == 1 && empty($modSettings['disableHostnameLookup'])) |
|
88 | - $context['member']['hostname'] = host_from_ip($memberContext[$memID]['ip']); |
|
89 | - else |
|
90 | - $context['member']['hostname'] = ''; |
|
90 | + if (preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $memberContext[$memID]['ip']) == 1 && empty($modSettings['disableHostnameLookup'])) { |
|
91 | + $context['member']['hostname'] = host_from_ip($memberContext[$memID]['ip']); |
|
92 | + } else { |
|
93 | + $context['member']['hostname'] = ''; |
|
94 | + } |
|
91 | 95 | |
92 | 96 | $context['can_see_ip'] = true; |
97 | + } else { |
|
98 | + $context['can_see_ip'] = false; |
|
93 | 99 | } |
94 | - else |
|
95 | - $context['can_see_ip'] = false; |
|
96 | 100 | |
97 | 101 | // Are they hidden? |
98 | 102 | $context['member']['is_hidden'] = empty($user_profile[$memID]['show_online']); |
@@ -103,8 +107,9 @@ discard block |
||
103 | 107 | include_once($sourcedir . '/Who.php'); |
104 | 108 | $action = determineActions($user_profile[$memID]['url']); |
105 | 109 | |
106 | - if ($action !== false) |
|
107 | - $context['member']['action'] = $action; |
|
110 | + if ($action !== false) { |
|
111 | + $context['member']['action'] = $action; |
|
112 | + } |
|
108 | 113 | } |
109 | 114 | |
110 | 115 | // If the user is awaiting activation, and the viewer has permission - setup some activation context messages. |
@@ -167,13 +172,15 @@ discard block |
||
167 | 172 | { |
168 | 173 | // Work out what restrictions we actually have. |
169 | 174 | $ban_restrictions = array(); |
170 | - foreach (array('access', 'login', 'post') as $type) |
|
171 | - if ($row['cannot_' . $type]) |
|
175 | + foreach (array('access', 'login', 'post') as $type) { |
|
176 | + if ($row['cannot_' . $type]) |
|
172 | 177 | $ban_restrictions[] = $txt['ban_type_' . $type]; |
178 | + } |
|
173 | 179 | |
174 | 180 | // No actual ban in place? |
175 | - if (empty($ban_restrictions)) |
|
176 | - continue; |
|
181 | + if (empty($ban_restrictions)) { |
|
182 | + continue; |
|
183 | + } |
|
177 | 184 | |
178 | 185 | // Prepare the link for context. |
179 | 186 | $ban_explanation = sprintf($txt['user_cannot_due_to'], implode(', ', $ban_restrictions), '<a href="' . $scripturl . '?action=admin;area=ban;sa=edit;bg=' . $row['id_ban_group'] . '">' . $row['name'] . '</a>'); |
@@ -195,9 +202,10 @@ discard block |
||
195 | 202 | $context['print_custom_fields'] = array(); |
196 | 203 | |
197 | 204 | // Any custom profile fields? |
198 | - if (!empty($context['custom_fields'])) |
|
199 | - foreach ($context['custom_fields'] as $custom) |
|
205 | + if (!empty($context['custom_fields'])) { |
|
206 | + foreach ($context['custom_fields'] as $custom) |
|
200 | 207 | $context['print_custom_fields'][$context['cust_profile_fields_placement'][$custom['placement']]][] = $custom; |
208 | + } |
|
201 | 209 | |
202 | 210 | } |
203 | 211 | |
@@ -242,16 +250,18 @@ discard block |
||
242 | 250 | $row['extra'] = !empty($row['extra']) ? $smcFunc['json_decode']($row['extra'], true) : array(); |
243 | 251 | $alerts[$id_alert] = $row; |
244 | 252 | |
245 | - if (!empty($row['sender_id'])) |
|
246 | - $senders[] = $row['sender_id']; |
|
253 | + if (!empty($row['sender_id'])) { |
|
254 | + $senders[] = $row['sender_id']; |
|
255 | + } |
|
247 | 256 | } |
248 | 257 | $smcFunc['db_free_result']($request); |
249 | 258 | |
250 | 259 | if($withSender) |
251 | 260 | { |
252 | 261 | $senders = loadMemberData($senders); |
253 | - foreach ($senders as $member) |
|
254 | - loadMemberContext($member); |
|
262 | + foreach ($senders as $member) { |
|
263 | + loadMemberContext($member); |
|
264 | + } |
|
255 | 265 | } |
256 | 266 | |
257 | 267 | // Now go through and actually make with the text. |
@@ -266,12 +276,15 @@ discard block |
||
266 | 276 | $msgs = array(); |
267 | 277 | foreach ($alerts as $id_alert => $alert) |
268 | 278 | { |
269 | - if (isset($alert['extra']['board'])) |
|
270 | - $boards[$alert['extra']['board']] = $txt['board_na']; |
|
271 | - if (isset($alert['extra']['topic'])) |
|
272 | - $topics[$alert['extra']['topic']] = $txt['topic_na']; |
|
273 | - if ($alert['content_type'] == 'msg') |
|
274 | - $msgs[$alert['content_id']] = $txt['topic_na']; |
|
279 | + if (isset($alert['extra']['board'])) { |
|
280 | + $boards[$alert['extra']['board']] = $txt['board_na']; |
|
281 | + } |
|
282 | + if (isset($alert['extra']['topic'])) { |
|
283 | + $topics[$alert['extra']['topic']] = $txt['topic_na']; |
|
284 | + } |
|
285 | + if ($alert['content_type'] == 'msg') { |
|
286 | + $msgs[$alert['content_id']] = $txt['topic_na']; |
|
287 | + } |
|
275 | 288 | } |
276 | 289 | |
277 | 290 | // Having figured out what boards etc. there are, let's now get the names of them if we can see them. If not, there's already a fallback set up. |
@@ -286,8 +299,9 @@ discard block |
||
286 | 299 | 'boards' => array_keys($boards), |
287 | 300 | ) |
288 | 301 | ); |
289 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
290 | - $boards[$row['id_board']] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
302 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
303 | + $boards[$row['id_board']] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
304 | + } |
|
291 | 305 | } |
292 | 306 | if (!empty($topics)) |
293 | 307 | { |
@@ -302,8 +316,9 @@ discard block |
||
302 | 316 | 'topics' => array_keys($topics), |
303 | 317 | ) |
304 | 318 | ); |
305 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
306 | - $topics[$row['id_topic']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>'; |
|
319 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
320 | + $topics[$row['id_topic']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>'; |
|
321 | + } |
|
307 | 322 | } |
308 | 323 | if (!empty($msgs)) |
309 | 324 | { |
@@ -318,44 +333,51 @@ discard block |
||
318 | 333 | 'msgs' => array_keys($msgs), |
319 | 334 | ) |
320 | 335 | ); |
321 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
322 | - $msgs[$row['id_msg']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
336 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
337 | + $msgs[$row['id_msg']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
338 | + } |
|
323 | 339 | } |
324 | 340 | |
325 | 341 | // Now to go back through the alerts, reattach this extra information and then try to build the string out of it (if a hook didn't already) |
326 | 342 | foreach ($alerts as $id_alert => $alert) |
327 | 343 | { |
328 | - if (!empty($alert['text'])) |
|
329 | - continue; |
|
330 | - if (isset($alert['extra']['board'])) |
|
331 | - if ($boards[$alert['extra']['board']] == $txt['board_na']) |
|
344 | + if (!empty($alert['text'])) { |
|
345 | + continue; |
|
346 | + } |
|
347 | + if (isset($alert['extra']['board'])) { |
|
348 | + if ($boards[$alert['extra']['board']] == $txt['board_na']) |
|
332 | 349 | { |
333 | 350 | unset($alerts[$id_alert]); |
351 | + } |
|
334 | 352 | continue; |
353 | + } else { |
|
354 | + $alerts[$id_alert]['extra']['board_msg'] = $boards[$alert['extra']['board']]; |
|
335 | 355 | } |
336 | - else |
|
337 | - $alerts[$id_alert]['extra']['board_msg'] = $boards[$alert['extra']['board']]; |
|
338 | - if (isset($alert['extra']['topic'])) |
|
339 | - if ($alert['extra']['topic'] == $txt['topic_na']) |
|
356 | + if (isset($alert['extra']['topic'])) { |
|
357 | + if ($alert['extra']['topic'] == $txt['topic_na']) |
|
340 | 358 | { |
341 | 359 | unset($alerts[$id_alert]); |
360 | + } |
|
342 | 361 | continue; |
362 | + } else { |
|
363 | + $alerts[$id_alert]['extra']['topic_msg'] = $topics[$alert['extra']['topic']]; |
|
343 | 364 | } |
344 | - else |
|
345 | - $alerts[$id_alert]['extra']['topic_msg'] = $topics[$alert['extra']['topic']]; |
|
346 | - if ($alert['content_type'] == 'msg') |
|
347 | - if ($msgs[$alert['content_id']] == $txt['topic_na']) |
|
365 | + if ($alert['content_type'] == 'msg') { |
|
366 | + if ($msgs[$alert['content_id']] == $txt['topic_na']) |
|
348 | 367 | { |
349 | 368 | unset($alerts[$id_alert]); |
369 | + } |
|
350 | 370 | continue; |
351 | - } |
|
352 | - else |
|
353 | - $alerts[$id_alert]['extra']['msg_msg'] = $msgs[$alert['content_id']]; |
|
354 | - if ($alert['content_type'] == 'profile') |
|
355 | - $alerts[$id_alert]['extra']['profile_msg'] = '<a href="' . $scripturl . '?action=profile;u=' . $alerts[$id_alert]['content_id'] . '">' . $alerts[$id_alert]['extra']['user_name'] . '</a>'; |
|
371 | + } else { |
|
372 | + $alerts[$id_alert]['extra']['msg_msg'] = $msgs[$alert['content_id']]; |
|
373 | + } |
|
374 | + if ($alert['content_type'] == 'profile') { |
|
375 | + $alerts[$id_alert]['extra']['profile_msg'] = '<a href="' . $scripturl . '?action=profile;u=' . $alerts[$id_alert]['content_id'] . '">' . $alerts[$id_alert]['extra']['user_name'] . '</a>'; |
|
376 | + } |
|
356 | 377 | |
357 | - if (!empty($memberContext[$alert['sender_id']])) |
|
358 | - $alerts[$id_alert]['sender'] = &$memberContext[$alert['sender_id']]; |
|
378 | + if (!empty($memberContext[$alert['sender_id']])) { |
|
379 | + $alerts[$id_alert]['sender'] = &$memberContext[$alert['sender_id']]; |
|
380 | + } |
|
359 | 381 | |
360 | 382 | $string = 'alert_' . $alert['content_type'] . '_' . $alert['content_action']; |
361 | 383 | if (isset($txt[$string])) |
@@ -443,11 +465,11 @@ discard block |
||
443 | 465 | checkSession('request'); |
444 | 466 | |
445 | 467 | // Call it! |
446 | - if ($action == 'remove') |
|
447 | - alert_delete($toMark, $memID); |
|
448 | - |
|
449 | - else |
|
450 | - alert_mark($memID, $toMark, $action == 'read' ? 1 : 0); |
|
468 | + if ($action == 'remove') { |
|
469 | + alert_delete($toMark, $memID); |
|
470 | + } else { |
|
471 | + alert_mark($memID, $toMark, $action == 'read' ? 1 : 0); |
|
472 | + } |
|
451 | 473 | |
452 | 474 | // Set a nice update message. |
453 | 475 | $_SESSION['update_message'] = true; |
@@ -497,23 +519,27 @@ discard block |
||
497 | 519 | ); |
498 | 520 | |
499 | 521 | // Set the page title |
500 | - if (isset($_GET['sa']) && array_key_exists($_GET['sa'], $title)) |
|
501 | - $context['page_title'] = $txt['show' . $title[$_GET['sa']]]; |
|
502 | - else |
|
503 | - $context['page_title'] = $txt['showPosts']; |
|
522 | + if (isset($_GET['sa']) && array_key_exists($_GET['sa'], $title)) { |
|
523 | + $context['page_title'] = $txt['show' . $title[$_GET['sa']]]; |
|
524 | + } else { |
|
525 | + $context['page_title'] = $txt['showPosts']; |
|
526 | + } |
|
504 | 527 | |
505 | 528 | $context['page_title'] .= ' - ' . $user_profile[$memID]['real_name']; |
506 | 529 | |
507 | 530 | // Is the load average too high to allow searching just now? |
508 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_show_posts']) && $context['load_average'] >= $modSettings['loadavg_show_posts']) |
|
509 | - fatal_lang_error('loadavg_show_posts_disabled', false); |
|
531 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_show_posts']) && $context['load_average'] >= $modSettings['loadavg_show_posts']) { |
|
532 | + fatal_lang_error('loadavg_show_posts_disabled', false); |
|
533 | + } |
|
510 | 534 | |
511 | 535 | // If we're specifically dealing with attachments use that function! |
512 | - if (isset($_GET['sa']) && $_GET['sa'] == 'attach') |
|
513 | - return showAttachments($memID); |
|
536 | + if (isset($_GET['sa']) && $_GET['sa'] == 'attach') { |
|
537 | + return showAttachments($memID); |
|
538 | + } |
|
514 | 539 | // Instead, if we're dealing with unwatched topics (and the feature is enabled) use that other function. |
515 | - elseif (isset($_GET['sa']) && $_GET['sa'] == 'unwatchedtopics') |
|
516 | - return showUnwatched($memID); |
|
540 | + elseif (isset($_GET['sa']) && $_GET['sa'] == 'unwatchedtopics') { |
|
541 | + return showUnwatched($memID); |
|
542 | + } |
|
517 | 543 | |
518 | 544 | // Are we just viewing topics? |
519 | 545 | $context['is_topics'] = isset($_GET['sa']) && $_GET['sa'] == 'topics' ? true : false; |
@@ -536,27 +562,30 @@ discard block |
||
536 | 562 | $smcFunc['db_free_result']($request); |
537 | 563 | |
538 | 564 | // Trying to remove a message that doesn't exist. |
539 | - if (empty($info)) |
|
540 | - redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
|
565 | + if (empty($info)) { |
|
566 | + redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
|
567 | + } |
|
541 | 568 | |
542 | 569 | // We can be lazy, since removeMessage() will check the permissions for us. |
543 | 570 | require_once($sourcedir . '/RemoveTopic.php'); |
544 | 571 | removeMessage((int) $_GET['delete']); |
545 | 572 | |
546 | 573 | // Add it to the mod log. |
547 | - if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) |
|
548 | - logAction('delete', array('topic' => $info[2], 'subject' => $info[0], 'member' => $info[1], 'board' => $info[3])); |
|
574 | + if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) { |
|
575 | + logAction('delete', array('topic' => $info[2], 'subject' => $info[0], 'member' => $info[1], 'board' => $info[3])); |
|
576 | + } |
|
549 | 577 | |
550 | 578 | // Back to... where we are now ;). |
551 | 579 | redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
552 | 580 | } |
553 | 581 | |
554 | 582 | // Default to 10. |
555 | - if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) |
|
556 | - $_REQUEST['viewscount'] = '10'; |
|
583 | + if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) { |
|
584 | + $_REQUEST['viewscount'] = '10'; |
|
585 | + } |
|
557 | 586 | |
558 | - if ($context['is_topics']) |
|
559 | - $request = $smcFunc['db_query']('', ' |
|
587 | + if ($context['is_topics']) { |
|
588 | + $request = $smcFunc['db_query']('', ' |
|
560 | 589 | SELECT COUNT(*) |
561 | 590 | FROM {db_prefix}topics AS t' . ($user_info['query_see_board'] == '1=1' ? '' : ' |
562 | 591 | INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board AND {query_see_board})') . ' |
@@ -569,8 +598,8 @@ discard block |
||
569 | 598 | 'board' => $board, |
570 | 599 | ) |
571 | 600 | ); |
572 | - else |
|
573 | - $request = $smcFunc['db_query']('', ' |
|
601 | + } else { |
|
602 | + $request = $smcFunc['db_query']('', ' |
|
574 | 603 | SELECT COUNT(*) |
575 | 604 | FROM {db_prefix}messages AS m' . ($user_info['query_see_board'] == '1=1' ? '' : ' |
576 | 605 | INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board AND {query_see_board})') . ' |
@@ -583,6 +612,7 @@ discard block |
||
583 | 612 | 'board' => $board, |
584 | 613 | ) |
585 | 614 | ); |
615 | + } |
|
586 | 616 | list ($msgCount) = $smcFunc['db_fetch_row']($request); |
587 | 617 | $smcFunc['db_free_result']($request); |
588 | 618 | |
@@ -603,10 +633,11 @@ discard block |
||
603 | 633 | |
604 | 634 | $range_limit = ''; |
605 | 635 | |
606 | - if ($context['is_topics']) |
|
607 | - $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics']; |
|
608 | - else |
|
609 | - $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
|
636 | + if ($context['is_topics']) { |
|
637 | + $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics']; |
|
638 | + } else { |
|
639 | + $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
|
640 | + } |
|
610 | 641 | |
611 | 642 | $maxIndex = $maxPerPage; |
612 | 643 | |
@@ -632,9 +663,9 @@ discard block |
||
632 | 663 | { |
633 | 664 | $margin *= 5; |
634 | 665 | $range_limit = $reverse ? 't.id_first_msg < ' . ($min_msg_member + $margin) : 't.id_first_msg > ' . ($max_msg_member - $margin); |
666 | + } else { |
|
667 | + $range_limit = $reverse ? 'm.id_msg < ' . ($min_msg_member + $margin) : 'm.id_msg > ' . ($max_msg_member - $margin); |
|
635 | 668 | } |
636 | - else |
|
637 | - $range_limit = $reverse ? 'm.id_msg < ' . ($min_msg_member + $margin) : 'm.id_msg > ' . ($max_msg_member - $margin); |
|
638 | 669 | } |
639 | 670 | |
640 | 671 | // Find this user's posts. The left join on categories somehow makes this faster, weird as it looks. |
@@ -666,8 +697,7 @@ discard block |
||
666 | 697 | 'max' => $maxIndex, |
667 | 698 | ) |
668 | 699 | ); |
669 | - } |
|
670 | - else |
|
700 | + } else |
|
671 | 701 | { |
672 | 702 | $request = $smcFunc['db_query']('', ' |
673 | 703 | SELECT |
@@ -696,8 +726,9 @@ discard block |
||
696 | 726 | } |
697 | 727 | |
698 | 728 | // Make sure we quit this loop. |
699 | - if ($smcFunc['db_num_rows']($request) === $maxIndex || $looped) |
|
700 | - break; |
|
729 | + if ($smcFunc['db_num_rows']($request) === $maxIndex || $looped) { |
|
730 | + break; |
|
731 | + } |
|
701 | 732 | $looped = true; |
702 | 733 | $range_limit = ''; |
703 | 734 | } |
@@ -741,19 +772,21 @@ discard block |
||
741 | 772 | 'css_class' => $row['approved'] ? 'windowbg' : 'approvebg', |
742 | 773 | ); |
743 | 774 | |
744 | - if ($user_info['id'] == $row['id_member_started']) |
|
745 | - $board_ids['own'][$row['id_board']][] = $counter; |
|
775 | + if ($user_info['id'] == $row['id_member_started']) { |
|
776 | + $board_ids['own'][$row['id_board']][] = $counter; |
|
777 | + } |
|
746 | 778 | $board_ids['any'][$row['id_board']][] = $counter; |
747 | 779 | } |
748 | 780 | $smcFunc['db_free_result']($request); |
749 | 781 | |
750 | 782 | // All posts were retrieved in reverse order, get them right again. |
751 | - if ($reverse) |
|
752 | - $context['posts'] = array_reverse($context['posts'], true); |
|
783 | + if ($reverse) { |
|
784 | + $context['posts'] = array_reverse($context['posts'], true); |
|
785 | + } |
|
753 | 786 | |
754 | 787 | // These are all the permissions that are different from board to board.. |
755 | - if ($context['is_topics']) |
|
756 | - $permissions = array( |
|
788 | + if ($context['is_topics']) { |
|
789 | + $permissions = array( |
|
757 | 790 | 'own' => array( |
758 | 791 | 'post_reply_own' => 'can_reply', |
759 | 792 | ), |
@@ -761,8 +794,8 @@ discard block |
||
761 | 794 | 'post_reply_any' => 'can_reply', |
762 | 795 | ) |
763 | 796 | ); |
764 | - else |
|
765 | - $permissions = array( |
|
797 | + } else { |
|
798 | + $permissions = array( |
|
766 | 799 | 'own' => array( |
767 | 800 | 'post_reply_own' => 'can_reply', |
768 | 801 | 'delete_own' => 'can_delete', |
@@ -772,6 +805,7 @@ discard block |
||
772 | 805 | 'delete_any' => 'can_delete', |
773 | 806 | ) |
774 | 807 | ); |
808 | + } |
|
775 | 809 | |
776 | 810 | // For every permission in the own/any lists... |
777 | 811 | foreach ($permissions as $type => $list) |
@@ -782,19 +816,22 @@ discard block |
||
782 | 816 | $boards = boardsAllowedTo($permission); |
783 | 817 | |
784 | 818 | // Hmm, they can do it on all boards, can they? |
785 | - if (!empty($boards) && $boards[0] == 0) |
|
786 | - $boards = array_keys($board_ids[$type]); |
|
819 | + if (!empty($boards) && $boards[0] == 0) { |
|
820 | + $boards = array_keys($board_ids[$type]); |
|
821 | + } |
|
787 | 822 | |
788 | 823 | // Now go through each board they can do the permission on. |
789 | 824 | foreach ($boards as $board_id) |
790 | 825 | { |
791 | 826 | // There aren't any posts displayed from this board. |
792 | - if (!isset($board_ids[$type][$board_id])) |
|
793 | - continue; |
|
827 | + if (!isset($board_ids[$type][$board_id])) { |
|
828 | + continue; |
|
829 | + } |
|
794 | 830 | |
795 | 831 | // Set the permission to true ;). |
796 | - foreach ($board_ids[$type][$board_id] as $counter) |
|
797 | - $context['posts'][$counter][$allowed] = true; |
|
832 | + foreach ($board_ids[$type][$board_id] as $counter) { |
|
833 | + $context['posts'][$counter][$allowed] = true; |
|
834 | + } |
|
798 | 835 | } |
799 | 836 | } |
800 | 837 | } |
@@ -825,8 +862,9 @@ discard block |
||
825 | 862 | $boardsAllowed = boardsAllowedTo('view_attachments'); |
826 | 863 | |
827 | 864 | // Make sure we can't actually see anything... |
828 | - if (empty($boardsAllowed)) |
|
829 | - $boardsAllowed = array(-1); |
|
865 | + if (empty($boardsAllowed)) { |
|
866 | + $boardsAllowed = array(-1); |
|
867 | + } |
|
830 | 868 | |
831 | 869 | require_once($sourcedir . '/Subs-List.php'); |
832 | 870 | |
@@ -977,8 +1015,8 @@ discard block |
||
977 | 1015 | ) |
978 | 1016 | ); |
979 | 1017 | $attachments = array(); |
980 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
981 | - $attachments[] = array( |
|
1018 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1019 | + $attachments[] = array( |
|
982 | 1020 | 'id' => $row['id_attach'], |
983 | 1021 | 'filename' => $row['filename'], |
984 | 1022 | 'downloads' => $row['downloads'], |
@@ -990,6 +1028,7 @@ discard block |
||
990 | 1028 | 'board_name' => $row['name'], |
991 | 1029 | 'approved' => $row['approved'], |
992 | 1030 | ); |
1031 | + } |
|
993 | 1032 | |
994 | 1033 | $smcFunc['db_free_result']($request); |
995 | 1034 | |
@@ -1044,8 +1083,9 @@ discard block |
||
1044 | 1083 | global $txt, $user_info, $scripturl, $modSettings, $context, $sourcedir; |
1045 | 1084 | |
1046 | 1085 | // Only the owner can see the list (if the function is enabled of course) |
1047 | - if ($user_info['id'] != $memID) |
|
1048 | - return; |
|
1086 | + if ($user_info['id'] != $memID) { |
|
1087 | + return; |
|
1088 | + } |
|
1049 | 1089 | |
1050 | 1090 | require_once($sourcedir . '/Subs-List.php'); |
1051 | 1091 | |
@@ -1191,8 +1231,9 @@ discard block |
||
1191 | 1231 | ); |
1192 | 1232 | |
1193 | 1233 | $topics = array(); |
1194 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1195 | - $topics[] = $row['id_topic']; |
|
1234 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1235 | + $topics[] = $row['id_topic']; |
|
1236 | + } |
|
1196 | 1237 | |
1197 | 1238 | $smcFunc['db_free_result']($request); |
1198 | 1239 | |
@@ -1212,8 +1253,9 @@ discard block |
||
1212 | 1253 | 'topics' => $topics, |
1213 | 1254 | ) |
1214 | 1255 | ); |
1215 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1216 | - $topicsInfo[] = $row; |
|
1256 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1257 | + $topicsInfo[] = $row; |
|
1258 | + } |
|
1217 | 1259 | $smcFunc['db_free_result']($request); |
1218 | 1260 | } |
1219 | 1261 | |
@@ -1261,8 +1303,9 @@ discard block |
||
1261 | 1303 | $context['page_title'] = $txt['statPanel_showStats'] . ' ' . $user_profile[$memID]['real_name']; |
1262 | 1304 | |
1263 | 1305 | // Is the load average too high to allow searching just now? |
1264 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_userstats']) && $context['load_average'] >= $modSettings['loadavg_userstats']) |
|
1265 | - fatal_lang_error('loadavg_userstats_disabled', false); |
|
1306 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_userstats']) && $context['load_average'] >= $modSettings['loadavg_userstats']) { |
|
1307 | + fatal_lang_error('loadavg_userstats_disabled', false); |
|
1308 | + } |
|
1266 | 1309 | |
1267 | 1310 | // General user statistics. |
1268 | 1311 | $timeDays = floor($user_profile[$memID]['total_time_logged_in'] / 86400); |
@@ -1405,11 +1448,13 @@ discard block |
||
1405 | 1448 | } |
1406 | 1449 | $smcFunc['db_free_result']($result); |
1407 | 1450 | |
1408 | - if ($maxPosts > 0) |
|
1409 | - for ($hour = 0; $hour < 24; $hour++) |
|
1451 | + if ($maxPosts > 0) { |
|
1452 | + for ($hour = 0; |
|
1453 | + } |
|
1454 | + $hour < 24; $hour++) |
|
1410 | 1455 | { |
1411 | - if (!isset($context['posts_by_time'][$hour])) |
|
1412 | - $context['posts_by_time'][$hour] = array( |
|
1456 | + if (!isset($context['posts_by_time'][$hour])) { |
|
1457 | + $context['posts_by_time'][$hour] = array( |
|
1413 | 1458 | 'hour' => $hour, |
1414 | 1459 | 'hour_format' => stripos($user_info['time_format'], '%p') === false ? $hour : date('g a', mktime($hour)), |
1415 | 1460 | 'posts' => 0, |
@@ -1417,7 +1462,7 @@ discard block |
||
1417 | 1462 | 'relative_percent' => 0, |
1418 | 1463 | 'is_last' => $hour == 23, |
1419 | 1464 | ); |
1420 | - else |
|
1465 | + } else |
|
1421 | 1466 | { |
1422 | 1467 | $context['posts_by_time'][$hour]['posts_percent'] = round(($context['posts_by_time'][$hour]['posts'] * 100) / $realPosts); |
1423 | 1468 | $context['posts_by_time'][$hour]['relative_percent'] = round(($context['posts_by_time'][$hour]['posts'] * 100) / $maxPosts); |
@@ -1450,8 +1495,9 @@ discard block |
||
1450 | 1495 | |
1451 | 1496 | foreach ($subActions as $sa => $action) |
1452 | 1497 | { |
1453 | - if (!allowedTo($action[2])) |
|
1454 | - unset($subActions[$sa]); |
|
1498 | + if (!allowedTo($action[2])) { |
|
1499 | + unset($subActions[$sa]); |
|
1500 | + } |
|
1455 | 1501 | } |
1456 | 1502 | |
1457 | 1503 | // Create the tabs for the template. |
@@ -1469,15 +1515,18 @@ discard block |
||
1469 | 1515 | ); |
1470 | 1516 | |
1471 | 1517 | // Moderation must be on to track edits. |
1472 | - if (empty($modSettings['userlog_enabled'])) |
|
1473 | - unset($context[$context['profile_menu_name']]['tab_data']['edits'], $subActions['edits']); |
|
1518 | + if (empty($modSettings['userlog_enabled'])) { |
|
1519 | + unset($context[$context['profile_menu_name']]['tab_data']['edits'], $subActions['edits']); |
|
1520 | + } |
|
1474 | 1521 | |
1475 | 1522 | // Group requests must be active to show it... |
1476 | - if (empty($modSettings['show_group_membership'])) |
|
1477 | - unset($context[$context['profile_menu_name']]['tab_data']['groupreq'], $subActions['groupreq']); |
|
1523 | + if (empty($modSettings['show_group_membership'])) { |
|
1524 | + unset($context[$context['profile_menu_name']]['tab_data']['groupreq'], $subActions['groupreq']); |
|
1525 | + } |
|
1478 | 1526 | |
1479 | - if (empty($subActions)) |
|
1480 | - fatal_lang_error('no_access', false); |
|
1527 | + if (empty($subActions)) { |
|
1528 | + fatal_lang_error('no_access', false); |
|
1529 | + } |
|
1481 | 1530 | |
1482 | 1531 | $keys = array_keys($subActions); |
1483 | 1532 | $default = array_shift($keys); |
@@ -1490,9 +1539,10 @@ discard block |
||
1490 | 1539 | $context['sub_template'] = $subActions[$context['tracking_area']][0]; |
1491 | 1540 | $call = call_helper($subActions[$context['tracking_area']][0], true); |
1492 | 1541 | |
1493 | - if (!empty($call)) |
|
1494 | - call_user_func($call, $memID); |
|
1495 | -} |
|
1542 | + if (!empty($call)) { |
|
1543 | + call_user_func($call, $memID); |
|
1544 | + } |
|
1545 | + } |
|
1496 | 1546 | |
1497 | 1547 | /** |
1498 | 1548 | * Handles tracking a user's activity |
@@ -1508,8 +1558,9 @@ discard block |
||
1508 | 1558 | isAllowedTo('moderate_forum'); |
1509 | 1559 | |
1510 | 1560 | $context['last_ip'] = $user_profile[$memID]['member_ip']; |
1511 | - if ($context['last_ip'] != $user_profile[$memID]['member_ip2']) |
|
1512 | - $context['last_ip2'] = $user_profile[$memID]['member_ip2']; |
|
1561 | + if ($context['last_ip'] != $user_profile[$memID]['member_ip2']) { |
|
1562 | + $context['last_ip2'] = $user_profile[$memID]['member_ip2']; |
|
1563 | + } |
|
1513 | 1564 | $context['member']['name'] = $user_profile[$memID]['real_name']; |
1514 | 1565 | |
1515 | 1566 | // Set the options for the list component. |
@@ -1675,8 +1726,9 @@ discard block |
||
1675 | 1726 | ) |
1676 | 1727 | ); |
1677 | 1728 | $message_members = array(); |
1678 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1679 | - $message_members[] = $row['id_member']; |
|
1729 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1730 | + $message_members[] = $row['id_member']; |
|
1731 | + } |
|
1680 | 1732 | $smcFunc['db_free_result']($request); |
1681 | 1733 | |
1682 | 1734 | // Fetch their names, cause of the GROUP BY doesn't like giving us that normally. |
@@ -1691,8 +1743,9 @@ discard block |
||
1691 | 1743 | 'ip_list' => $ips, |
1692 | 1744 | ) |
1693 | 1745 | ); |
1694 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1695 | - $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
1746 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1747 | + $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
1748 | + } |
|
1696 | 1749 | $smcFunc['db_free_result']($request); |
1697 | 1750 | } |
1698 | 1751 | |
@@ -1706,8 +1759,9 @@ discard block |
||
1706 | 1759 | 'ip_list' => $ips, |
1707 | 1760 | ) |
1708 | 1761 | ); |
1709 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1710 | - $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
1762 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1763 | + $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
1764 | + } |
|
1711 | 1765 | $smcFunc['db_free_result']($request); |
1712 | 1766 | } |
1713 | 1767 | } |
@@ -1767,8 +1821,8 @@ discard block |
||
1767 | 1821 | )) |
1768 | 1822 | ); |
1769 | 1823 | $error_messages = array(); |
1770 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1771 | - $error_messages[] = array( |
|
1824 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1825 | + $error_messages[] = array( |
|
1772 | 1826 | 'ip' => inet_dtop($row['ip']), |
1773 | 1827 | 'member_link' => $row['id_member'] > 0 ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>' : $row['display_name'], |
1774 | 1828 | 'message' => strtr($row['message'], array('<span class="remove">' => '', '</span>' => '')), |
@@ -1776,6 +1830,7 @@ discard block |
||
1776 | 1830 | 'time' => timeformat($row['log_time']), |
1777 | 1831 | 'timestamp' => forum_time(true, $row['log_time']), |
1778 | 1832 | ); |
1833 | + } |
|
1779 | 1834 | $smcFunc['db_free_result']($request); |
1780 | 1835 | |
1781 | 1836 | return $error_messages; |
@@ -1838,8 +1893,8 @@ discard block |
||
1838 | 1893 | )) |
1839 | 1894 | ); |
1840 | 1895 | $messages = array(); |
1841 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1842 | - $messages[] = array( |
|
1896 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1897 | + $messages[] = array( |
|
1843 | 1898 | 'ip' => inet_dtop($row['poster_ip']), |
1844 | 1899 | 'member_link' => empty($row['id_member']) ? $row['display_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>', |
1845 | 1900 | 'board' => array( |
@@ -1852,6 +1907,7 @@ discard block |
||
1852 | 1907 | 'time' => timeformat($row['poster_time']), |
1853 | 1908 | 'timestamp' => forum_time(true, $row['poster_time']) |
1854 | 1909 | ); |
1910 | + } |
|
1855 | 1911 | $smcFunc['db_free_result']($request); |
1856 | 1912 | |
1857 | 1913 | return $messages; |
@@ -1878,19 +1934,20 @@ discard block |
||
1878 | 1934 | $context['sub_template'] = 'trackIP'; |
1879 | 1935 | $context['page_title'] = $txt['profile']; |
1880 | 1936 | $context['base_url'] = $scripturl . '?action=trackip'; |
1881 | - } |
|
1882 | - else |
|
1937 | + } else |
|
1883 | 1938 | { |
1884 | 1939 | $context['ip'] = $user_profile[$memID]['member_ip']; |
1885 | 1940 | $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
1886 | 1941 | } |
1887 | 1942 | |
1888 | 1943 | // Searching? |
1889 | - if (isset($_REQUEST['searchip'])) |
|
1890 | - $context['ip'] = trim($_REQUEST['searchip']); |
|
1944 | + if (isset($_REQUEST['searchip'])) { |
|
1945 | + $context['ip'] = trim($_REQUEST['searchip']); |
|
1946 | + } |
|
1891 | 1947 | |
1892 | - if (isValidIP($context['ip']) === false) |
|
1893 | - fatal_lang_error('invalid_tracking_ip', false); |
|
1948 | + if (isValidIP($context['ip']) === false) { |
|
1949 | + fatal_lang_error('invalid_tracking_ip', false); |
|
1950 | + } |
|
1894 | 1951 | |
1895 | 1952 | //mysql didn't support like search with varbinary |
1896 | 1953 | //$ip_var = str_replace('*', '%', $context['ip']); |
@@ -1898,8 +1955,9 @@ discard block |
||
1898 | 1955 | $ip_var = $context['ip']; |
1899 | 1956 | $ip_string = '= {inet:ip_address}'; |
1900 | 1957 | |
1901 | - if (empty($context['tracking_area'])) |
|
1902 | - $context['page_title'] = $txt['trackIP'] . ' - ' . $context['ip']; |
|
1958 | + if (empty($context['tracking_area'])) { |
|
1959 | + $context['page_title'] = $txt['trackIP'] . ' - ' . $context['ip']; |
|
1960 | + } |
|
1903 | 1961 | |
1904 | 1962 | $request = $smcFunc['db_query']('', ' |
1905 | 1963 | SELECT id_member, real_name AS display_name, member_ip |
@@ -1910,8 +1968,9 @@ discard block |
||
1910 | 1968 | ) |
1911 | 1969 | ); |
1912 | 1970 | $context['ips'] = array(); |
1913 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1914 | - $context['ips'][inet_dtop($row['member_ip'])][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>'; |
|
1971 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1972 | + $context['ips'][inet_dtop($row['member_ip'])][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>'; |
|
1973 | + } |
|
1915 | 1974 | $smcFunc['db_free_result']($request); |
1916 | 1975 | |
1917 | 1976 | ksort($context['ips']); |
@@ -2140,8 +2199,9 @@ discard block |
||
2140 | 2199 | foreach ($context['whois_servers'] as $whois) |
2141 | 2200 | { |
2142 | 2201 | // Strip off the "decimal point" and anything following... |
2143 | - if (in_array((int) $context['ip'], $whois['range'])) |
|
2144 | - $context['auto_whois_server'] = $whois; |
|
2202 | + if (in_array((int) $context['ip'], $whois['range'])) { |
|
2203 | + $context['auto_whois_server'] = $whois; |
|
2204 | + } |
|
2145 | 2205 | } |
2146 | 2206 | } |
2147 | 2207 | } |
@@ -2158,10 +2218,11 @@ discard block |
||
2158 | 2218 | // Gonna want this for the list. |
2159 | 2219 | require_once($sourcedir . '/Subs-List.php'); |
2160 | 2220 | |
2161 | - if ($memID == 0) |
|
2162 | - $context['base_url'] = $scripturl . '?action=trackip'; |
|
2163 | - else |
|
2164 | - $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
|
2221 | + if ($memID == 0) { |
|
2222 | + $context['base_url'] = $scripturl . '?action=trackip'; |
|
2223 | + } else { |
|
2224 | + $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
|
2225 | + } |
|
2165 | 2226 | |
2166 | 2227 | // Start with the user messages. |
2167 | 2228 | $listOptions = array( |
@@ -2271,12 +2332,13 @@ discard block |
||
2271 | 2332 | ) |
2272 | 2333 | ); |
2273 | 2334 | $logins = array(); |
2274 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2275 | - $logins[] = array( |
|
2335 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2336 | + $logins[] = array( |
|
2276 | 2337 | 'time' => timeformat($row['time']), |
2277 | 2338 | 'ip' => inet_dtop($row['ip']), |
2278 | 2339 | 'ip2' => inet_dtop($row['ip2']), |
2279 | 2340 | ); |
2341 | + } |
|
2280 | 2342 | $smcFunc['db_free_result']($request); |
2281 | 2343 | |
2282 | 2344 | return $logins; |
@@ -2301,11 +2363,12 @@ discard block |
||
2301 | 2363 | ) |
2302 | 2364 | ); |
2303 | 2365 | $context['custom_field_titles'] = array(); |
2304 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2305 | - $context['custom_field_titles']['customfield_' . $row['col_name']] = array( |
|
2366 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2367 | + $context['custom_field_titles']['customfield_' . $row['col_name']] = array( |
|
2306 | 2368 | 'title' => $row['field_name'], |
2307 | 2369 | 'parse_bbc' => $row['bbc'], |
2308 | 2370 | ); |
2371 | + } |
|
2309 | 2372 | $smcFunc['db_free_result']($request); |
2310 | 2373 | |
2311 | 2374 | // Set the options for the error lists. |
@@ -2444,19 +2507,22 @@ discard block |
||
2444 | 2507 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2445 | 2508 | { |
2446 | 2509 | $extra = $smcFunc['json_decode']($row['extra'], true); |
2447 | - if (!empty($extra['applicator'])) |
|
2448 | - $members[] = $extra['applicator']; |
|
2510 | + if (!empty($extra['applicator'])) { |
|
2511 | + $members[] = $extra['applicator']; |
|
2512 | + } |
|
2449 | 2513 | |
2450 | 2514 | // Work out what the name of the action is. |
2451 | - if (isset($txt['trackEdit_action_' . $row['action']])) |
|
2452 | - $action_text = $txt['trackEdit_action_' . $row['action']]; |
|
2453 | - elseif (isset($txt[$row['action']])) |
|
2454 | - $action_text = $txt[$row['action']]; |
|
2515 | + if (isset($txt['trackEdit_action_' . $row['action']])) { |
|
2516 | + $action_text = $txt['trackEdit_action_' . $row['action']]; |
|
2517 | + } elseif (isset($txt[$row['action']])) { |
|
2518 | + $action_text = $txt[$row['action']]; |
|
2519 | + } |
|
2455 | 2520 | // Custom field? |
2456 | - elseif (isset($context['custom_field_titles'][$row['action']])) |
|
2457 | - $action_text = $context['custom_field_titles'][$row['action']]['title']; |
|
2458 | - else |
|
2459 | - $action_text = $row['action']; |
|
2521 | + elseif (isset($context['custom_field_titles'][$row['action']])) { |
|
2522 | + $action_text = $context['custom_field_titles'][$row['action']]['title']; |
|
2523 | + } else { |
|
2524 | + $action_text = $row['action']; |
|
2525 | + } |
|
2460 | 2526 | |
2461 | 2527 | // Parse BBC? |
2462 | 2528 | $parse_bbc = isset($context['custom_field_titles'][$row['action']]) && $context['custom_field_titles'][$row['action']]['parse_bbc'] ? true : false; |
@@ -2488,13 +2554,15 @@ discard block |
||
2488 | 2554 | ) |
2489 | 2555 | ); |
2490 | 2556 | $members = array(); |
2491 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2492 | - $members[$row['id_member']] = $row['real_name']; |
|
2557 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2558 | + $members[$row['id_member']] = $row['real_name']; |
|
2559 | + } |
|
2493 | 2560 | $smcFunc['db_free_result']($request); |
2494 | 2561 | |
2495 | - foreach ($edits as $key => $value) |
|
2496 | - if (isset($members[$value['id_member']])) |
|
2562 | + foreach ($edits as $key => $value) { |
|
2563 | + if (isset($members[$value['id_member']])) |
|
2497 | 2564 | $edits[$key]['member_link'] = '<a href="' . $scripturl . '?action=profile;u=' . $value['id_member'] . '">' . $members[$value['id_member']] . '</a>'; |
2565 | + } |
|
2498 | 2566 | } |
2499 | 2567 | |
2500 | 2568 | return $edits; |
@@ -2695,10 +2763,11 @@ discard block |
||
2695 | 2763 | $context['board'] = $board; |
2696 | 2764 | |
2697 | 2765 | // Determine which groups this user is in. |
2698 | - if (empty($user_profile[$memID]['additional_groups'])) |
|
2699 | - $curGroups = array(); |
|
2700 | - else |
|
2701 | - $curGroups = explode(',', $user_profile[$memID]['additional_groups']); |
|
2766 | + if (empty($user_profile[$memID]['additional_groups'])) { |
|
2767 | + $curGroups = array(); |
|
2768 | + } else { |
|
2769 | + $curGroups = explode(',', $user_profile[$memID]['additional_groups']); |
|
2770 | + } |
|
2702 | 2771 | $curGroups[] = $user_profile[$memID]['id_group']; |
2703 | 2772 | $curGroups[] = $user_profile[$memID]['id_post_group']; |
2704 | 2773 | |
@@ -2718,28 +2787,30 @@ discard block |
||
2718 | 2787 | $context['no_access_boards'] = array(); |
2719 | 2788 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2720 | 2789 | { |
2721 | - if (count(array_intersect($curGroups, explode(',', $row['member_groups']))) === 0 && !$row['is_mod']) |
|
2722 | - $context['no_access_boards'][] = array( |
|
2790 | + if (count(array_intersect($curGroups, explode(',', $row['member_groups']))) === 0 && !$row['is_mod']) { |
|
2791 | + $context['no_access_boards'][] = array( |
|
2723 | 2792 | 'id' => $row['id_board'], |
2724 | 2793 | 'name' => $row['name'], |
2725 | 2794 | 'is_last' => false, |
2726 | 2795 | ); |
2727 | - elseif ($row['id_profile'] != 1 || $row['is_mod']) |
|
2728 | - $context['boards'][$row['id_board']] = array( |
|
2796 | + } elseif ($row['id_profile'] != 1 || $row['is_mod']) { |
|
2797 | + $context['boards'][$row['id_board']] = array( |
|
2729 | 2798 | 'id' => $row['id_board'], |
2730 | 2799 | 'name' => $row['name'], |
2731 | 2800 | 'selected' => $board == $row['id_board'], |
2732 | 2801 | 'profile' => $row['id_profile'], |
2733 | 2802 | 'profile_name' => $context['profiles'][$row['id_profile']]['name'], |
2734 | 2803 | ); |
2804 | + } |
|
2735 | 2805 | } |
2736 | 2806 | $smcFunc['db_free_result']($request); |
2737 | 2807 | |
2738 | 2808 | require_once($sourcedir . '/Subs-Boards.php'); |
2739 | 2809 | sortBoards($context['boards']); |
2740 | 2810 | |
2741 | - if (!empty($context['no_access_boards'])) |
|
2742 | - $context['no_access_boards'][count($context['no_access_boards']) - 1]['is_last'] = true; |
|
2811 | + if (!empty($context['no_access_boards'])) { |
|
2812 | + $context['no_access_boards'][count($context['no_access_boards']) - 1]['is_last'] = true; |
|
2813 | + } |
|
2743 | 2814 | |
2744 | 2815 | $context['member']['permissions'] = array( |
2745 | 2816 | 'general' => array(), |
@@ -2748,8 +2819,9 @@ discard block |
||
2748 | 2819 | |
2749 | 2820 | // If you're an admin we know you can do everything, we might as well leave. |
2750 | 2821 | $context['member']['has_all_permissions'] = in_array(1, $curGroups); |
2751 | - if ($context['member']['has_all_permissions']) |
|
2752 | - return; |
|
2822 | + if ($context['member']['has_all_permissions']) { |
|
2823 | + return; |
|
2824 | + } |
|
2753 | 2825 | |
2754 | 2826 | $denied = array(); |
2755 | 2827 | |
@@ -2768,21 +2840,24 @@ discard block |
||
2768 | 2840 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
2769 | 2841 | { |
2770 | 2842 | // We don't know about this permission, it doesn't exist :P. |
2771 | - if (!isset($txt['permissionname_' . $row['permission']])) |
|
2772 | - continue; |
|
2843 | + if (!isset($txt['permissionname_' . $row['permission']])) { |
|
2844 | + continue; |
|
2845 | + } |
|
2773 | 2846 | |
2774 | - if (empty($row['add_deny'])) |
|
2775 | - $denied[] = $row['permission']; |
|
2847 | + if (empty($row['add_deny'])) { |
|
2848 | + $denied[] = $row['permission']; |
|
2849 | + } |
|
2776 | 2850 | |
2777 | 2851 | // Permissions that end with _own or _any consist of two parts. |
2778 | - if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) |
|
2779 | - $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
2780 | - else |
|
2781 | - $name = $txt['permissionname_' . $row['permission']]; |
|
2852 | + if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) { |
|
2853 | + $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
2854 | + } else { |
|
2855 | + $name = $txt['permissionname_' . $row['permission']]; |
|
2856 | + } |
|
2782 | 2857 | |
2783 | 2858 | // Add this permission if it doesn't exist yet. |
2784 | - if (!isset($context['member']['permissions']['general'][$row['permission']])) |
|
2785 | - $context['member']['permissions']['general'][$row['permission']] = array( |
|
2859 | + if (!isset($context['member']['permissions']['general'][$row['permission']])) { |
|
2860 | + $context['member']['permissions']['general'][$row['permission']] = array( |
|
2786 | 2861 | 'id' => $row['permission'], |
2787 | 2862 | 'groups' => array( |
2788 | 2863 | 'allowed' => array(), |
@@ -2792,6 +2867,7 @@ discard block |
||
2792 | 2867 | 'is_denied' => false, |
2793 | 2868 | 'is_global' => true, |
2794 | 2869 | ); |
2870 | + } |
|
2795 | 2871 | |
2796 | 2872 | // Add the membergroup to either the denied or the allowed groups. |
2797 | 2873 | $context['member']['permissions']['general'][$row['permission']]['groups'][empty($row['add_deny']) ? 'denied' : 'allowed'][] = $row['id_group'] == 0 ? $txt['membergroups_members'] : $row['group_name']; |
@@ -2825,18 +2901,20 @@ discard block |
||
2825 | 2901 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2826 | 2902 | { |
2827 | 2903 | // We don't know about this permission, it doesn't exist :P. |
2828 | - if (!isset($txt['permissionname_' . $row['permission']])) |
|
2829 | - continue; |
|
2904 | + if (!isset($txt['permissionname_' . $row['permission']])) { |
|
2905 | + continue; |
|
2906 | + } |
|
2830 | 2907 | |
2831 | 2908 | // The name of the permission using the format 'permission name' - 'own/any topic/event/etc.'. |
2832 | - if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) |
|
2833 | - $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
2834 | - else |
|
2835 | - $name = $txt['permissionname_' . $row['permission']]; |
|
2909 | + if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) { |
|
2910 | + $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
2911 | + } else { |
|
2912 | + $name = $txt['permissionname_' . $row['permission']]; |
|
2913 | + } |
|
2836 | 2914 | |
2837 | 2915 | // Create the structure for this permission. |
2838 | - if (!isset($context['member']['permissions']['board'][$row['permission']])) |
|
2839 | - $context['member']['permissions']['board'][$row['permission']] = array( |
|
2916 | + if (!isset($context['member']['permissions']['board'][$row['permission']])) { |
|
2917 | + $context['member']['permissions']['board'][$row['permission']] = array( |
|
2840 | 2918 | 'id' => $row['permission'], |
2841 | 2919 | 'groups' => array( |
2842 | 2920 | 'allowed' => array(), |
@@ -2846,6 +2924,7 @@ discard block |
||
2846 | 2924 | 'is_denied' => false, |
2847 | 2925 | 'is_global' => empty($board), |
2848 | 2926 | ); |
2927 | + } |
|
2849 | 2928 | |
2850 | 2929 | $context['member']['permissions']['board'][$row['permission']]['groups'][empty($row['add_deny']) ? 'denied' : 'allowed'][$row['id_group']] = $row['id_group'] == 0 ? $txt['membergroups_members'] : $row['group_name']; |
2851 | 2930 | |
@@ -2864,8 +2943,9 @@ discard block |
||
2864 | 2943 | global $modSettings, $context, $sourcedir, $txt, $scripturl; |
2865 | 2944 | |
2866 | 2945 | // Firstly, can we actually even be here? |
2867 | - if (!($context['user']['is_owner'] && allowedTo('view_warning_own')) && !allowedTo('view_warning_any') && !allowedTo('issue_warning') && !allowedTo('moderate_forum')) |
|
2868 | - fatal_lang_error('no_access', false); |
|
2946 | + if (!($context['user']['is_owner'] && allowedTo('view_warning_own')) && !allowedTo('view_warning_any') && !allowedTo('issue_warning') && !allowedTo('moderate_forum')) { |
|
2947 | + fatal_lang_error('no_access', false); |
|
2948 | + } |
|
2869 | 2949 | |
2870 | 2950 | // Make sure things which are disabled stay disabled. |
2871 | 2951 | $modSettings['warning_watch'] = !empty($modSettings['warning_watch']) ? $modSettings['warning_watch'] : 110; |
@@ -2952,9 +3032,10 @@ discard block |
||
2952 | 3032 | $modSettings['warning_mute'] => $txt['profile_warning_effect_own_muted'], |
2953 | 3033 | ); |
2954 | 3034 | $context['current_level'] = 0; |
2955 | - foreach ($context['level_effects'] as $limit => $dummy) |
|
2956 | - if ($context['member']['warning'] >= $limit) |
|
3035 | + foreach ($context['level_effects'] as $limit => $dummy) { |
|
3036 | + if ($context['member']['warning'] >= $limit) |
|
2957 | 3037 | $context['current_level'] = $limit; |
2958 | -} |
|
3038 | + } |
|
3039 | + } |
|
2959 | 3040 | |
2960 | 3041 | ?> |
2961 | 3042 | \ No newline at end of file |
@@ -22,22 +22,24 @@ discard block |
||
22 | 22 | <script>'; |
23 | 23 | |
24 | 24 | // When using Go Back due to fatal_error, allow the form to be re-submitted with changes. |
25 | - if (isBrowser('is_firefox')) |
|
26 | - echo ' |
|
25 | + if (isBrowser('is_firefox')) { |
|
26 | + echo ' |
|
27 | 27 | window.addEventListener("pageshow", reActivate, false);'; |
28 | + } |
|
28 | 29 | |
29 | 30 | // Start with message icons - and any missing from this theme. |
30 | 31 | echo ' |
31 | 32 | var icon_urls = {'; |
32 | - foreach ($context['icons'] as $icon) |
|
33 | - echo ' |
|
33 | + foreach ($context['icons'] as $icon) { |
|
34 | + echo ' |
|
34 | 35 | \'', $icon['value'], '\': \'', $icon['url'], '\'', $icon['is_last'] ? '' : ','; |
36 | + } |
|
35 | 37 | echo ' |
36 | 38 | };'; |
37 | 39 | |
38 | 40 | // If this is a poll - use some javascript to ensure the user doesn't create a poll with illegal option combinations. |
39 | - if ($context['make_poll']) |
|
40 | - echo ' |
|
41 | + if ($context['make_poll']) { |
|
42 | + echo ' |
|
41 | 43 | var pollOptionNum = 0, pollTabIndex; |
42 | 44 | var pollOptionId = ', $context['last_choice_id'], '; |
43 | 45 | function addPollOption() |
@@ -56,11 +58,13 @@ discard block |
||
56 | 58 | |
57 | 59 | setOuterHTML(document.getElementById(\'pollMoreOptions\'), ', JavaScriptEscape('<dt><label for="options-'), ' + pollOptionId + ', JavaScriptEscape('">' . $txt['option'] . ' '), ' + pollOptionNum + ', JavaScriptEscape('</label>:</dt><dd><input type="text" name="options['), ' + pollOptionId + ', JavaScriptEscape(']" id="options-'), ' + pollOptionId + ', JavaScriptEscape('" value="" size="80" maxlength="255" tabindex="'), ' + pollTabIndex + ', JavaScriptEscape('"></dd><p id="pollMoreOptions"></p>'), '); |
58 | 60 | }'; |
61 | + } |
|
59 | 62 | |
60 | 63 | // If we are making a calendar event we want to ensure we show the current days in a month etc... this is done here. |
61 | - if ($context['make_event']) |
|
62 | - echo ' |
|
64 | + if ($context['make_event']) { |
|
65 | + echo ' |
|
63 | 66 | var monthLength = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];'; |
67 | + } |
|
64 | 68 | |
65 | 69 | // End of the javascript, start the form and display the link tree. |
66 | 70 | echo ' |
@@ -80,9 +84,10 @@ discard block |
||
80 | 84 | </div> |
81 | 85 | </div><br>'; |
82 | 86 | |
83 | - if ($context['make_event'] && (!$context['event']['new'] || !empty($context['current_board']))) |
|
84 | - echo ' |
|
87 | + if ($context['make_event'] && (!$context['event']['new'] || !empty($context['current_board']))) { |
|
88 | + echo ' |
|
85 | 89 | <input type="hidden" name="eventid" value="', $context['event']['id'], '">'; |
90 | + } |
|
86 | 91 | |
87 | 92 | // Start the main table. |
88 | 93 | echo ' |
@@ -117,18 +122,20 @@ discard block |
||
117 | 122 | } |
118 | 123 | |
119 | 124 | // If it's locked, show a message to warn the replier. |
120 | - if (!empty($context['locked'])) |
|
121 | - echo ' |
|
125 | + if (!empty($context['locked'])) { |
|
126 | + echo ' |
|
122 | 127 | <div class="errorbox"> |
123 | 128 | ', $txt['topic_locked_no_reply'], ' |
124 | 129 | </div>'; |
130 | + } |
|
125 | 131 | |
126 | - if (!empty($modSettings['drafts_post_enabled'])) |
|
127 | - echo ' |
|
132 | + if (!empty($modSettings['drafts_post_enabled'])) { |
|
133 | + echo ' |
|
128 | 134 | <div id="draft_section" class="infobox"', isset($context['draft_saved']) ? '' : ' style="display: none;"', '>', |
129 | 135 | sprintf($txt['draft_saved'], $scripturl . '?action=profile;u=' . $context['user']['id'] . ';area=showdrafts'), ' |
130 | 136 | ', (!empty($modSettings['drafts_keep_days']) ? ' <strong>' . sprintf($txt['draft_save_warning'], $modSettings['drafts_keep_days']) . '</strong>' : ''), ' |
131 | 137 | </div>'; |
138 | + } |
|
132 | 139 | |
133 | 140 | // The post header... important stuff |
134 | 141 | echo ' |
@@ -180,9 +187,10 @@ discard block |
||
180 | 187 | { |
181 | 188 | echo ' |
182 | 189 | <optgroup label="', $category['name'], '">'; |
183 | - foreach ($category['boards'] as $board) |
|
184 | - echo ' |
|
190 | + foreach ($category['boards'] as $board) { |
|
191 | + echo ' |
|
185 | 192 | <option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=>' : '', ' ', $board['name'], ' </option>'; |
193 | + } |
|
186 | 194 | echo ' |
187 | 195 | </optgroup>'; |
188 | 196 | } |
@@ -218,9 +226,10 @@ discard block |
||
218 | 226 | <span class="label">', $txt['calendar_timezone'], '</span> |
219 | 227 | <select name="tz" id="tz"', !empty($context['event']['allday']) ? ' disabled' : '', '>'; |
220 | 228 | |
221 | - foreach ($context['all_timezones'] as $tz => $tzname) |
|
222 | - echo ' |
|
229 | + foreach ($context['all_timezones'] as $tz => $tzname) { |
|
230 | + echo ' |
|
223 | 231 | <option value="', $tz, '"', $tz == $context['event']['tz'] ? ' selected' : '', '>', $tzname, '</option>'; |
232 | + } |
|
224 | 233 | |
225 | 234 | echo ' |
226 | 235 | </select> |
@@ -286,14 +295,15 @@ discard block |
||
286 | 295 | <input type="checkbox" id="poll_change_vote" name="poll_change_vote"', !empty($context['poll']['change_vote']) ? ' checked' : '', '> |
287 | 296 | </dd>'; |
288 | 297 | |
289 | - if ($context['poll_options']['guest_vote_enabled']) |
|
290 | - echo ' |
|
298 | + if ($context['poll_options']['guest_vote_enabled']) { |
|
299 | + echo ' |
|
291 | 300 | <dt> |
292 | 301 | <label for="poll_guest_vote">', $txt['poll_guest_vote'], ':</label> |
293 | 302 | </dt> |
294 | 303 | <dd> |
295 | 304 | <input type="checkbox" id="poll_guest_vote" name="poll_guest_vote"', !empty($context['poll_options']['guest_vote']) ? ' checked' : '', '> |
296 | 305 | </dd>'; |
306 | + } |
|
297 | 307 | |
298 | 308 | echo ' |
299 | 309 | <dt> |
@@ -314,8 +324,8 @@ discard block |
||
314 | 324 | ', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message'); |
315 | 325 | |
316 | 326 | // If we're editing and displaying edit details, show a box where they can say why |
317 | - if (isset($context['editing']) && $modSettings['show_modify']) |
|
318 | - echo ' |
|
327 | + if (isset($context['editing']) && $modSettings['show_modify']) { |
|
328 | + echo ' |
|
319 | 329 | <dl> |
320 | 330 | <dt class="clear"> |
321 | 331 | <span id="caption_edit_reason">', $txt['reason_for_edit'], ':</span> |
@@ -324,20 +334,23 @@ discard block |
||
324 | 334 | <input type="text" name="modify_reason"', isset($context['last_modified_reason']) ? ' value="' . $context['last_modified_reason'] . '"' : '', ' tabindex="', $context['tabindex']++, '" size="80" maxlength="80"> |
325 | 335 | </dd> |
326 | 336 | </dl>'; |
337 | + } |
|
327 | 338 | |
328 | 339 | // If this message has been edited in the past - display when it was. |
329 | - if (isset($context['last_modified'])) |
|
330 | - echo ' |
|
340 | + if (isset($context['last_modified'])) { |
|
341 | + echo ' |
|
331 | 342 | <div class="padding smalltext"> |
332 | 343 | ', $context['last_modified_text'], ' |
333 | 344 | </div>'; |
345 | + } |
|
334 | 346 | |
335 | 347 | // If the admin has enabled the hiding of the additional options - show a link and image for it. |
336 | - if (!empty($modSettings['additional_options_collapsable'])) |
|
337 | - echo ' |
|
348 | + if (!empty($modSettings['additional_options_collapsable'])) { |
|
349 | + echo ' |
|
338 | 350 | <div id="postAdditionalOptionsHeader"> |
339 | 351 | <strong><a href="#" id="postMoreExpandLink"> ', $context['can_post_attachment'] ? $txt['post_additionalopt_attach'] : $txt['post_additionalopt'], '</a></strong> |
340 | 352 | </div>'; |
353 | + } |
|
341 | 354 | |
342 | 355 | echo ' |
343 | 356 | <div id="postAdditionalOptions">'; |
@@ -369,19 +382,21 @@ discard block |
||
369 | 382 | <input type="hidden" name="attach_del[]" value="0"> |
370 | 383 | ', $txt['uncheck_unwatchd_attach'], ': |
371 | 384 | </dd>'; |
372 | - foreach ($context['current_attachments'] as $attachment) |
|
373 | - echo ' |
|
385 | + foreach ($context['current_attachments'] as $attachment) { |
|
386 | + echo ' |
|
374 | 387 | <dd class="smalltext"> |
375 | 388 | <label for="attachment_', $attachment['attachID'], '"><input type="checkbox" id="attachment_', $attachment['attachID'], '" name="attach_del[]" value="', $attachment['attachID'], '"', empty($attachment['unchecked']) ? ' checked' : '', '> ', $attachment['name'], (empty($attachment['approved']) ? ' (' . $txt['awaiting_approval'] . ')' : ''), |
376 | 389 | !empty($modSettings['attachmentPostLimit']) || !empty($modSettings['attachmentSizeLimit']) ? sprintf($txt['attach_kb'], comma_format(round(max($attachment['size'], 1024) / 1024), 0)) : '', '</label> |
377 | 390 | </dd>'; |
391 | + } |
|
378 | 392 | |
379 | 393 | echo ' |
380 | 394 | </dl>'; |
381 | 395 | |
382 | - if (!empty($context['files_in_session_warning'])) |
|
383 | - echo ' |
|
396 | + if (!empty($context['files_in_session_warning'])) { |
|
397 | + echo ' |
|
384 | 398 | <div class="smalltext">', $context['files_in_session_warning'], '</div>'; |
399 | + } |
|
385 | 400 | } |
386 | 401 | |
387 | 402 | // Is the user allowed to post any additional ones? If so give them the boxes to do it! |
@@ -445,8 +460,8 @@ discard block |
||
445 | 460 | ', empty($modSettings['attachmentSizeLimit']) ? '' : ('<input type="hidden" name="MAX_FILE_SIZE" value="' . $modSettings['attachmentSizeLimit'] * 1024 . '">'); |
446 | 461 | |
447 | 462 | // Show more boxes if they aren't approaching that limit. |
448 | - if ($context['num_allowed_attachments'] > 1) |
|
449 | - echo ' |
|
463 | + if ($context['num_allowed_attachments'] > 1) { |
|
464 | + echo ' |
|
450 | 465 | <script> |
451 | 466 | var allowed_attachments = ', $context['num_allowed_attachments'], '; |
452 | 467 | var current_attachment = 1; |
@@ -467,9 +482,10 @@ discard block |
||
467 | 482 | </div> |
468 | 483 | </div> |
469 | 484 | </dd>'; |
470 | - else |
|
471 | - echo ' |
|
485 | + } else { |
|
486 | + echo ' |
|
472 | 487 | </dd>'; |
488 | + } |
|
473 | 489 | |
474 | 490 | // Add any template changes for an alternative upload system here. |
475 | 491 | call_integration_hook('integrate_upload_template'); |
@@ -478,21 +494,25 @@ discard block |
||
478 | 494 | <dd class="smalltext">'; |
479 | 495 | |
480 | 496 | // Show some useful information such as allowed extensions, maximum size and amount of attachments allowed. |
481 | - if (!empty($modSettings['attachmentCheckExtensions'])) |
|
482 | - echo ' |
|
497 | + if (!empty($modSettings['attachmentCheckExtensions'])) { |
|
498 | + echo ' |
|
483 | 499 | ', $txt['allowed_types'], ': ', $context['allowed_extensions'], '<br>'; |
500 | + } |
|
484 | 501 | |
485 | - if (!empty($context['attachment_restrictions'])) |
|
486 | - echo ' |
|
502 | + if (!empty($context['attachment_restrictions'])) { |
|
503 | + echo ' |
|
487 | 504 | ', $txt['attach_restrictions'], ' ', implode(', ', $context['attachment_restrictions']), '<br>'; |
505 | + } |
|
488 | 506 | |
489 | - if ($context['num_allowed_attachments'] == 0) |
|
490 | - echo ' |
|
507 | + if ($context['num_allowed_attachments'] == 0) { |
|
508 | + echo ' |
|
491 | 509 | ', $txt['attach_limit_nag'], '<br>'; |
510 | + } |
|
492 | 511 | |
493 | - if (!$context['can_post_attachment_unapproved']) |
|
494 | - echo ' |
|
512 | + if (!$context['can_post_attachment_unapproved']) { |
|
513 | + echo ' |
|
495 | 514 | <span class="alert">', $txt['attachment_requires_approval'], '</span>', '<br>'; |
515 | + } |
|
496 | 516 | |
497 | 517 | echo ' |
498 | 518 | </dd> |
@@ -515,10 +535,11 @@ discard block |
||
515 | 535 | <dt><strong>', $txt['subject'], '</strong></dt> |
516 | 536 | <dd><strong>', $txt['draft_saved_on'], '</strong></dd>'; |
517 | 537 | |
518 | - foreach ($context['drafts'] as $draft) |
|
519 | - echo ' |
|
538 | + foreach ($context['drafts'] as $draft) { |
|
539 | + echo ' |
|
520 | 540 | <dt>', $draft['link'], '</dt> |
521 | 541 | <dd>', $draft['poster_time'], '</dd>'; |
542 | + } |
|
522 | 543 | echo ' |
523 | 544 | </dl> |
524 | 545 | </div>'; |
@@ -543,9 +564,10 @@ discard block |
||
543 | 564 | ', template_control_richedit_buttons($context['post_box_name']); |
544 | 565 | |
545 | 566 | // Option to delete an event if user is editing one. |
546 | - if ($context['make_event'] && !$context['event']['new']) |
|
547 | - echo ' |
|
567 | + if ($context['make_event'] && !$context['event']['new']) { |
|
568 | + echo ' |
|
548 | 569 | <input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['event_delete_confirm'] ,'" class="button you_sure">'; |
570 | + } |
|
549 | 571 | |
550 | 572 | echo ' |
551 | 573 | </span> |
@@ -554,9 +576,10 @@ discard block |
||
554 | 576 | <br class="clear">'; |
555 | 577 | |
556 | 578 | // Assuming this isn't a new topic pass across the last message id. |
557 | - if (isset($context['topic_last_message'])) |
|
558 | - echo ' |
|
579 | + if (isset($context['topic_last_message'])) { |
|
580 | + echo ' |
|
559 | 581 | <input type="hidden" name="last_msg" value="', $context['topic_last_message'], '">'; |
582 | + } |
|
560 | 583 | |
561 | 584 | echo ' |
562 | 585 | <input type="hidden" name="additional_options" id="additional_options" value="', $context['show_additional_options'] ? '1' : '0', '"> |
@@ -698,9 +721,10 @@ discard block |
||
698 | 721 | |
699 | 722 | newPostsHTML += \'<div class="windowbg\' + (++reply_counter % 2 == 0 ? \'2\' : \'\') + \'"><div id="msg\' + newPosts[i].getAttribute("id") + \'"><div class="floatleft"><h5>', $txt['posted_by'], ': \' + newPosts[i].getElementsByTagName("poster")[0].firstChild.nodeValue + \'</h5><span class="smalltext">« <strong>', $txt['on'], ':</strong> \' + newPosts[i].getElementsByTagName("time")[0].firstChild.nodeValue + \' »</span> <span class="new_posts" id="image_new_\' + newPosts[i].getAttribute("id") + \'">', $txt['new'], '</span></div>\';'; |
700 | 723 | |
701 | - if ($context['can_quote']) |
|
702 | - echo ' |
|
724 | + if ($context['can_quote']) { |
|
725 | + echo ' |
|
703 | 726 | newPostsHTML += \'<ul class="quickbuttons" id="msg_\' + newPosts[i].getAttribute("id") + \'_quote"><li><a href="#postmodify" onclick="return insertQuoteFast(\\\'\' + newPosts[i].getAttribute("id") + \'\\\');" class="quote_button"><span>', $txt['quote'], '</span><\' + \'/a></li></ul>\';'; |
727 | + } |
|
704 | 728 | |
705 | 729 | echo ' |
706 | 730 | newPostsHTML += \'<br class="clear">\'; |
@@ -743,8 +767,8 @@ discard block |
||
743 | 767 | }'; |
744 | 768 | |
745 | 769 | // Code for showing and hiding additional options. |
746 | - if (!empty($modSettings['additional_options_collapsable'])) |
|
747 | - echo ' |
|
770 | + if (!empty($modSettings['additional_options_collapsable'])) { |
|
771 | + echo ' |
|
748 | 772 | var oSwapAdditionalOptions = new smc_Toggle({ |
749 | 773 | bToggleEnabled: true, |
750 | 774 | bCurrentlyCollapsed: ', $context['show_additional_options'] ? 'false' : 'true', ', |
@@ -772,10 +796,11 @@ discard block |
||
772 | 796 | } |
773 | 797 | ] |
774 | 798 | });'; |
799 | + } |
|
775 | 800 | |
776 | 801 | // Code for showing and hiding drafts |
777 | - if (!empty($context['drafts'])) |
|
778 | - echo ' |
|
802 | + if (!empty($context['drafts'])) { |
|
803 | + echo ' |
|
779 | 804 | var oSwapDraftOptions = new smc_Toggle({ |
780 | 805 | bToggleEnabled: true, |
781 | 806 | bCurrentlyCollapsed: true, |
@@ -797,6 +822,7 @@ discard block |
||
797 | 822 | } |
798 | 823 | ] |
799 | 824 | });'; |
825 | + } |
|
800 | 826 | |
801 | 827 | echo ' |
802 | 828 | var oEditorID = "', $context['post_box_name'] ,'"; |
@@ -817,8 +843,9 @@ discard block |
||
817 | 843 | foreach ($context['previous_posts'] as $post) |
818 | 844 | { |
819 | 845 | $ignoring = false; |
820 | - if (!empty($post['is_ignored'])) |
|
821 | - $ignored_posts[] = $ignoring = $post['id']; |
|
846 | + if (!empty($post['is_ignored'])) { |
|
847 | + $ignored_posts[] = $ignoring = $post['id']; |
|
848 | + } |
|
822 | 849 | |
823 | 850 | echo ' |
824 | 851 | <div class="windowbg"> |
@@ -1001,10 +1028,10 @@ discard block |
||
1001 | 1028 | <div id="temporary_posting_area" style="display: none;"></div> |
1002 | 1029 | <script>'; |
1003 | 1030 | |
1004 | - if ($context['close_window']) |
|
1005 | - echo ' |
|
1031 | + if ($context['close_window']) { |
|
1032 | + echo ' |
|
1006 | 1033 | window.close();'; |
1007 | - else |
|
1034 | + } else |
|
1008 | 1035 | { |
1009 | 1036 | // Lucky for us, Internet Explorer has an "innerText" feature which basically converts entities <--> text. Use it if possible ;). |
1010 | 1037 | echo ' |
@@ -1058,11 +1085,12 @@ discard block |
||
1058 | 1085 | </p> |
1059 | 1086 | <ul>'; |
1060 | 1087 | |
1061 | - foreach ($context['groups'] as $group) |
|
1062 | - echo ' |
|
1088 | + foreach ($context['groups'] as $group) { |
|
1089 | + echo ' |
|
1063 | 1090 | <li> |
1064 | 1091 | <label for="who_', $group['id'], '"><input type="checkbox" name="who[', $group['id'], ']" id="who_', $group['id'], '" value="', $group['id'], '" checked> ', $group['name'], '</label> <em>(', $group['member_count'], ')</em> |
1065 | 1092 | </li>'; |
1093 | + } |
|
1066 | 1094 | |
1067 | 1095 | echo ' |
1068 | 1096 | <li> |