@@ -1622,8 +1622,7 @@ |
||
1622 | 1622 | updateStats('topic'); |
1623 | 1623 | |
1624 | 1624 | // This function is needed to do the updateStats('subject') call. |
1625 | - $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : |
|
1626 | - function($string){ |
|
1625 | + $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) { |
|
1627 | 1626 | global $sourcedir; |
1628 | 1627 | if (function_exists('mb_strtolower')) |
1629 | 1628 | return mb_strtolower($string, 'UTF-8'); |
@@ -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,12 +64,14 @@ discard block |
||
63 | 64 | $value = preg_replace('~[^A-Za-z0-9_\$]~', '', $value); |
64 | 65 | |
65 | 66 | // Is it reserved? |
66 | - if ($value == 'pg_') |
|
67 | - return $txt['error_db_prefix_reserved']; |
|
67 | + if ($value == 'pg_') { |
|
68 | + return $txt['error_db_prefix_reserved']; |
|
69 | + } |
|
68 | 70 | |
69 | 71 | // Is the prefix numeric? |
70 | - if (preg_match('~^\d~', $value)) |
|
71 | - return $txt['error_db_prefix_numeric']; |
|
72 | + if (preg_match('~^\d~', $value)) { |
|
73 | + return $txt['error_db_prefix_numeric']; |
|
74 | + } |
|
72 | 75 | |
73 | 76 | return true; |
74 | 77 | }, |
@@ -115,10 +118,11 @@ discard block |
||
115 | 118 | $incontext['skip'] = false; |
116 | 119 | |
117 | 120 | // Call the step and if it returns false that means pause! |
118 | - if (function_exists($step[2]) && $step[2]() === false) |
|
119 | - break; |
|
120 | - elseif (function_exists($step[2])) |
|
121 | - $incontext['current_step']++; |
|
121 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
122 | + break; |
|
123 | + } elseif (function_exists($step[2])) { |
|
124 | + $incontext['current_step']++; |
|
125 | + } |
|
122 | 126 | |
123 | 127 | // No warnings pass on. |
124 | 128 | $incontext['warning'] = ''; |
@@ -134,12 +138,14 @@ discard block |
||
134 | 138 | global $databases, $incontext; |
135 | 139 | |
136 | 140 | // Just so people using older versions of PHP aren't left in the cold. |
137 | - if (!isset($_SERVER['PHP_SELF'])) |
|
138 | - $_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php'; |
|
141 | + if (!isset($_SERVER['PHP_SELF'])) { |
|
142 | + $_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php'; |
|
143 | + } |
|
139 | 144 | |
140 | 145 | // Turn off magic quotes runtime and enable error reporting. |
141 | - if (function_exists('set_magic_quotes_runtime')) |
|
142 | - @set_magic_quotes_runtime(0); |
|
146 | + if (function_exists('set_magic_quotes_runtime')) { |
|
147 | + @set_magic_quotes_runtime(0); |
|
148 | + } |
|
143 | 149 | error_reporting(E_ALL); |
144 | 150 | |
145 | 151 | // Fun. Low PHP version... |
@@ -153,21 +159,23 @@ discard block |
||
153 | 159 | { |
154 | 160 | ob_start(); |
155 | 161 | |
156 | - if (ini_get('session.save_handler') == 'user') |
|
157 | - @ini_set('session.save_handler', 'files'); |
|
158 | - if (function_exists('session_start')) |
|
159 | - @session_start(); |
|
160 | - } |
|
161 | - else |
|
162 | + if (ini_get('session.save_handler') == 'user') { |
|
163 | + @ini_set('session.save_handler', 'files'); |
|
164 | + } |
|
165 | + if (function_exists('session_start')) { |
|
166 | + @session_start(); |
|
167 | + } |
|
168 | + } else |
|
162 | 169 | { |
163 | 170 | ob_start('ob_gzhandler'); |
164 | 171 | |
165 | - if (ini_get('session.save_handler') == 'user') |
|
166 | - @ini_set('session.save_handler', 'files'); |
|
172 | + if (ini_get('session.save_handler') == 'user') { |
|
173 | + @ini_set('session.save_handler', 'files'); |
|
174 | + } |
|
167 | 175 | session_start(); |
168 | 176 | |
169 | - if (!headers_sent()) |
|
170 | - echo '<!DOCTYPE html> |
|
177 | + if (!headers_sent()) { |
|
178 | + echo '<!DOCTYPE html> |
|
171 | 179 | <html> |
172 | 180 | <head> |
173 | 181 | <title>', htmlspecialchars($_GET['pass_string']), '</title> |
@@ -176,6 +184,7 @@ discard block |
||
176 | 184 | <strong>', htmlspecialchars($_GET['pass_string']), '</strong> |
177 | 185 | </body> |
178 | 186 | </html>'; |
187 | + } |
|
179 | 188 | exit; |
180 | 189 | } |
181 | 190 | |
@@ -184,16 +193,18 @@ discard block |
||
184 | 193 | { |
185 | 194 | $incontext['remote_files_available'] = false; |
186 | 195 | $test = @fsockopen('www.simplemachines.org', 80, $errno, $errstr, 1); |
187 | - if ($test) |
|
188 | - $incontext['remote_files_available'] = true; |
|
196 | + if ($test) { |
|
197 | + $incontext['remote_files_available'] = true; |
|
198 | + } |
|
189 | 199 | @fclose($test); |
190 | 200 | } |
191 | 201 | |
192 | 202 | // Add slashes, as long as they aren't already being added. |
193 | - if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) |
|
194 | - foreach ($_POST as $k => $v) |
|
203 | + if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) { |
|
204 | + foreach ($_POST as $k => $v) |
|
195 | 205 | if (strpos($k, 'password') === false && strpos($k, 'db_passwd') === false) |
196 | 206 | $_POST[$k] = addslashes($v); |
207 | + } |
|
197 | 208 | |
198 | 209 | // This is really quite simple; if ?delete is on the URL, delete the installer... |
199 | 210 | if (isset($_GET['delete'])) |
@@ -214,8 +225,7 @@ discard block |
||
214 | 225 | $ftp->close(); |
215 | 226 | |
216 | 227 | unset($_SESSION['installer_temp_ftp']); |
217 | - } |
|
218 | - else |
|
228 | + } else |
|
219 | 229 | { |
220 | 230 | @unlink(__FILE__); |
221 | 231 | |
@@ -236,10 +246,11 @@ discard block |
||
236 | 246 | { |
237 | 247 | // Get PHP's default timezone, if set |
238 | 248 | $ini_tz = ini_get('date.timezone'); |
239 | - if (!empty($ini_tz)) |
|
240 | - $timezone_id = $ini_tz; |
|
241 | - else |
|
242 | - $timezone_id = ''; |
|
249 | + if (!empty($ini_tz)) { |
|
250 | + $timezone_id = $ini_tz; |
|
251 | + } else { |
|
252 | + $timezone_id = ''; |
|
253 | + } |
|
243 | 254 | |
244 | 255 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
245 | 256 | if (!in_array($timezone_id, timezone_identifiers_list())) |
@@ -269,8 +280,9 @@ discard block |
||
269 | 280 | $dir = dir(dirname(__FILE__) . '/Themes/default/languages'); |
270 | 281 | while ($entry = $dir->read()) |
271 | 282 | { |
272 | - if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') |
|
273 | - $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 | + } |
|
274 | 286 | } |
275 | 287 | $dir->close(); |
276 | 288 | } |
@@ -305,10 +317,11 @@ discard block |
||
305 | 317 | } |
306 | 318 | |
307 | 319 | // Override the language file? |
308 | - if (isset($_GET['lang_file'])) |
|
309 | - $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
310 | - elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) |
|
311 | - $_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 | + } |
|
312 | 325 | |
313 | 326 | // Make sure it exists, if it doesn't reset it. |
314 | 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'])) |
@@ -317,8 +330,9 @@ discard block |
||
317 | 330 | list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
318 | 331 | |
319 | 332 | // If we have english and some other language, use the other language. We Americans hate english :P. |
320 | - if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) |
|
321 | - 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 | + } |
|
322 | 336 | } |
323 | 337 | |
324 | 338 | // And now include the actual language file itself. |
@@ -331,15 +345,18 @@ discard block |
||
331 | 345 | global $db_prefix, $db_connection, $sourcedir; |
332 | 346 | global $smcFunc, $modSettings, $db_type, $db_name, $db_user, $db_persist; |
333 | 347 | |
334 | - if (empty($sourcedir)) |
|
335 | - $sourcedir = dirname(__FILE__) . '/Sources'; |
|
348 | + if (empty($sourcedir)) { |
|
349 | + $sourcedir = dirname(__FILE__) . '/Sources'; |
|
350 | + } |
|
336 | 351 | |
337 | 352 | // Need this to check whether we need the database password. |
338 | 353 | require(dirname(__FILE__) . '/Settings.php'); |
339 | - if (!defined('SMF')) |
|
340 | - define('SMF', 1); |
|
341 | - if (empty($smcFunc)) |
|
342 | - $smcFunc = array(); |
|
354 | + if (!defined('SMF')) { |
|
355 | + define('SMF', 1); |
|
356 | + } |
|
357 | + if (empty($smcFunc)) { |
|
358 | + $smcFunc = array(); |
|
359 | + } |
|
343 | 360 | |
344 | 361 | $modSettings['disableQueryCheck'] = true; |
345 | 362 | |
@@ -347,8 +364,9 @@ discard block |
||
347 | 364 | if (!$db_connection) |
348 | 365 | { |
349 | 366 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
350 | - if (version_compare(PHP_VERSION, '5', '<')) |
|
351 | - require_once($sourcedir . '/Subs-Compat.php'); |
|
367 | + if (version_compare(PHP_VERSION, '5', '<')) { |
|
368 | + require_once($sourcedir . '/Subs-Compat.php'); |
|
369 | + } |
|
352 | 370 | |
353 | 371 | $db_options = array('persist' => $db_persist); |
354 | 372 | $port = ''; |
@@ -359,19 +377,20 @@ discard block |
||
359 | 377 | if ($db_type == 'mysql') |
360 | 378 | { |
361 | 379 | $port = ((int) $_POST['db_port'] == ini_get($db_type . 'default_port')) ? '' : (int) $_POST['db_port']; |
362 | - } |
|
363 | - elseif ($db_type == 'postgresql') |
|
380 | + } elseif ($db_type == 'postgresql') |
|
364 | 381 | { |
365 | 382 | // PostgreSQL doesn't have a default port setting in php.ini, so just check against the default |
366 | 383 | $port = ((int) $_POST['db_port'] == 5432) ? '' : (int) $_POST['db_port']; |
367 | 384 | } |
368 | 385 | } |
369 | 386 | |
370 | - if (!empty($port)) |
|
371 | - $db_options['port'] = $port; |
|
387 | + if (!empty($port)) { |
|
388 | + $db_options['port'] = $port; |
|
389 | + } |
|
372 | 390 | |
373 | - if (!$db_connection) |
|
374 | - $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 | + } |
|
375 | 394 | } |
376 | 395 | } |
377 | 396 | |
@@ -399,8 +418,9 @@ discard block |
||
399 | 418 | // @todo REMOVE THIS!! |
400 | 419 | else |
401 | 420 | { |
402 | - if (function_exists('doStep' . $_GET['step'])) |
|
403 | - call_user_func('doStep' . $_GET['step']); |
|
421 | + if (function_exists('doStep' . $_GET['step'])) { |
|
422 | + call_user_func('doStep' . $_GET['step']); |
|
423 | + } |
|
404 | 424 | } |
405 | 425 | // Show the footer. |
406 | 426 | template_install_below(); |
@@ -418,8 +438,9 @@ discard block |
||
418 | 438 | $incontext['sub_template'] = 'welcome_message'; |
419 | 439 | |
420 | 440 | // Done the submission? |
421 | - if (isset($_POST['contbutt'])) |
|
422 | - return true; |
|
441 | + if (isset($_POST['contbutt'])) { |
|
442 | + return true; |
|
443 | + } |
|
423 | 444 | |
424 | 445 | // See if we think they have already installed it? |
425 | 446 | if (is_readable(dirname(__FILE__) . '/Settings.php')) |
@@ -427,14 +448,17 @@ discard block |
||
427 | 448 | $probably_installed = 0; |
428 | 449 | foreach (file(dirname(__FILE__) . '/Settings.php') as $line) |
429 | 450 | { |
430 | - if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) |
|
431 | - $probably_installed++; |
|
432 | - if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) |
|
433 | - $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 | + } |
|
434 | 457 | } |
435 | 458 | |
436 | - if ($probably_installed == 2) |
|
437 | - $incontext['warning'] = $txt['error_already_installed']; |
|
459 | + if ($probably_installed == 2) { |
|
460 | + $incontext['warning'] = $txt['error_already_installed']; |
|
461 | + } |
|
438 | 462 | } |
439 | 463 | |
440 | 464 | // Is some database support even compiled in? |
@@ -449,36 +473,43 @@ discard block |
||
449 | 473 | $databases[$key]['supported'] = false; |
450 | 474 | $notFoundSQLFile = true; |
451 | 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; |
|
452 | 478 | } |
453 | - else |
|
454 | - $incontext['supported_databases'][] = $db; |
|
455 | 479 | } |
456 | 480 | } |
457 | 481 | |
458 | 482 | // Check the PHP version. |
459 | - if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>'))) |
|
460 | - $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 | + } |
|
461 | 486 | // Make sure we have a supported database |
462 | - elseif (empty($incontext['supported_databases'])) |
|
463 | - $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 | + } |
|
464 | 490 | // How about session support? Some crazy sysadmin remove it? |
465 | - elseif (!function_exists('session_start')) |
|
466 | - $error = 'error_session_missing'; |
|
491 | + elseif (!function_exists('session_start')) { |
|
492 | + $error = 'error_session_missing'; |
|
493 | + } |
|
467 | 494 | // Make sure they uploaded all the files. |
468 | - elseif (!file_exists(dirname(__FILE__) . '/index.php')) |
|
469 | - $error = 'error_missing_files'; |
|
495 | + elseif (!file_exists(dirname(__FILE__) . '/index.php')) { |
|
496 | + $error = 'error_missing_files'; |
|
497 | + } |
|
470 | 498 | // Very simple check on the session.save_path for Windows. |
471 | 499 | // @todo Move this down later if they don't use database-driven sessions? |
472 | - elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') |
|
473 | - $error = 'error_session_save_path'; |
|
500 | + elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') { |
|
501 | + $error = 'error_session_save_path'; |
|
502 | + } |
|
474 | 503 | |
475 | 504 | // Since each of the three messages would look the same, anyway... |
476 | - if (isset($error)) |
|
477 | - $incontext['error'] = $txt[$error]; |
|
505 | + if (isset($error)) { |
|
506 | + $incontext['error'] = $txt[$error]; |
|
507 | + } |
|
478 | 508 | |
479 | 509 | // Mod_security blocks everything that smells funny. Let SMF handle security. |
480 | - if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) |
|
481 | - $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 | + } |
|
482 | 513 | |
483 | 514 | return false; |
484 | 515 | } |
@@ -504,12 +535,14 @@ discard block |
||
504 | 535 | 'db_last_error.php', |
505 | 536 | ); |
506 | 537 | |
507 | - foreach ($incontext['detected_languages'] as $lang => $temp) |
|
508 | - $extra_files[] = 'Themes/default/languages/' . $lang; |
|
538 | + foreach ($incontext['detected_languages'] as $lang => $temp) { |
|
539 | + $extra_files[] = 'Themes/default/languages/' . $lang; |
|
540 | + } |
|
509 | 541 | |
510 | 542 | // With mod_security installed, we could attempt to fix it with .htaccess. |
511 | - if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) |
|
512 | - $writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.'; |
|
543 | + if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) { |
|
544 | + $writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.'; |
|
545 | + } |
|
513 | 546 | |
514 | 547 | $failed_files = array(); |
515 | 548 | |
@@ -525,12 +558,14 @@ discard block |
||
525 | 558 | @chmod(dirname(__FILE__) . '/' . $file, 0755); |
526 | 559 | |
527 | 560 | // Well, 755 hopefully worked... if not, try 777. |
528 | - if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) |
|
529 | - $failed_files[] = $file; |
|
561 | + if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) { |
|
562 | + $failed_files[] = $file; |
|
563 | + } |
|
530 | 564 | } |
531 | 565 | } |
532 | - foreach ($extra_files as $file) |
|
533 | - @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
566 | + foreach ($extra_files as $file) { |
|
567 | + @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
568 | + } |
|
534 | 569 | } |
535 | 570 | // Windows is trickier. Let's try opening for r+... |
536 | 571 | else |
@@ -540,30 +575,35 @@ discard block |
||
540 | 575 | foreach ($writable_files as $file) |
541 | 576 | { |
542 | 577 | // Folders can't be opened for write... but the index.php in them can ;) |
543 | - if (is_dir(dirname(__FILE__) . '/' . $file)) |
|
544 | - $file .= '/index.php'; |
|
578 | + if (is_dir(dirname(__FILE__) . '/' . $file)) { |
|
579 | + $file .= '/index.php'; |
|
580 | + } |
|
545 | 581 | |
546 | 582 | // Funny enough, chmod actually does do something on windows - it removes the read only attribute. |
547 | 583 | @chmod(dirname(__FILE__) . '/' . $file, 0777); |
548 | 584 | $fp = @fopen(dirname(__FILE__) . '/' . $file, 'r+'); |
549 | 585 | |
550 | 586 | // Hmm, okay, try just for write in that case... |
551 | - if (!is_resource($fp)) |
|
552 | - $fp = @fopen(dirname(__FILE__) . '/' . $file, 'w'); |
|
587 | + if (!is_resource($fp)) { |
|
588 | + $fp = @fopen(dirname(__FILE__) . '/' . $file, 'w'); |
|
589 | + } |
|
553 | 590 | |
554 | - if (!is_resource($fp)) |
|
555 | - $failed_files[] = $file; |
|
591 | + if (!is_resource($fp)) { |
|
592 | + $failed_files[] = $file; |
|
593 | + } |
|
556 | 594 | |
557 | 595 | @fclose($fp); |
558 | 596 | } |
559 | - foreach ($extra_files as $file) |
|
560 | - @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
597 | + foreach ($extra_files as $file) { |
|
598 | + @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
599 | + } |
|
561 | 600 | } |
562 | 601 | |
563 | 602 | $failure = count($failed_files) >= 1; |
564 | 603 | |
565 | - if (!isset($_SERVER)) |
|
566 | - return !$failure; |
|
604 | + if (!isset($_SERVER)) { |
|
605 | + return !$failure; |
|
606 | + } |
|
567 | 607 | |
568 | 608 | // Put the list into context. |
569 | 609 | $incontext['failed_files'] = $failed_files; |
@@ -611,19 +651,23 @@ discard block |
||
611 | 651 | |
612 | 652 | if (!isset($ftp) || $ftp->error !== false) |
613 | 653 | { |
614 | - if (!isset($ftp)) |
|
615 | - $ftp = new ftp_connection(null); |
|
654 | + if (!isset($ftp)) { |
|
655 | + $ftp = new ftp_connection(null); |
|
656 | + } |
|
616 | 657 | // Save the error so we can mess with listing... |
617 | - elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) |
|
618 | - $incontext['ftp_errors'][] = $ftp->last_message; |
|
658 | + elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) { |
|
659 | + $incontext['ftp_errors'][] = $ftp->last_message; |
|
660 | + } |
|
619 | 661 | |
620 | 662 | list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__)); |
621 | 663 | |
622 | - if (empty($_POST['ftp_path']) && $found_path) |
|
623 | - $_POST['ftp_path'] = $detect_path; |
|
664 | + if (empty($_POST['ftp_path']) && $found_path) { |
|
665 | + $_POST['ftp_path'] = $detect_path; |
|
666 | + } |
|
624 | 667 | |
625 | - if (!isset($_POST['ftp_username'])) |
|
626 | - $_POST['ftp_username'] = $username; |
|
668 | + if (!isset($_POST['ftp_username'])) { |
|
669 | + $_POST['ftp_username'] = $username; |
|
670 | + } |
|
627 | 671 | |
628 | 672 | // Set the username etc, into context. |
629 | 673 | $incontext['ftp'] = array( |
@@ -635,8 +679,7 @@ discard block |
||
635 | 679 | ); |
636 | 680 | |
637 | 681 | return false; |
638 | - } |
|
639 | - else |
|
682 | + } else |
|
640 | 683 | { |
641 | 684 | $_SESSION['installer_temp_ftp'] = array( |
642 | 685 | 'server' => $_POST['ftp_server'], |
@@ -650,10 +693,12 @@ discard block |
||
650 | 693 | |
651 | 694 | foreach ($failed_files as $file) |
652 | 695 | { |
653 | - if (!is_writable(dirname(__FILE__) . '/' . $file)) |
|
654 | - $ftp->chmod($file, 0755); |
|
655 | - if (!is_writable(dirname(__FILE__) . '/' . $file)) |
|
656 | - $ftp->chmod($file, 0777); |
|
696 | + if (!is_writable(dirname(__FILE__) . '/' . $file)) { |
|
697 | + $ftp->chmod($file, 0755); |
|
698 | + } |
|
699 | + if (!is_writable(dirname(__FILE__) . '/' . $file)) { |
|
700 | + $ftp->chmod($file, 0777); |
|
701 | + } |
|
657 | 702 | if (!is_writable(dirname(__FILE__) . '/' . $file)) |
658 | 703 | { |
659 | 704 | $failed_files_updated[] = $file; |
@@ -708,15 +753,17 @@ discard block |
||
708 | 753 | |
709 | 754 | if (!$foundOne) |
710 | 755 | { |
711 | - if (isset($db['default_host'])) |
|
712 | - $incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost'; |
|
756 | + if (isset($db['default_host'])) { |
|
757 | + $incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost'; |
|
758 | + } |
|
713 | 759 | if (isset($db['default_user'])) |
714 | 760 | { |
715 | 761 | $incontext['db']['user'] = ini_get($db['default_user']); |
716 | 762 | $incontext['db']['name'] = ini_get($db['default_user']); |
717 | 763 | } |
718 | - if (isset($db['default_password'])) |
|
719 | - $incontext['db']['pass'] = ini_get($db['default_password']); |
|
764 | + if (isset($db['default_password'])) { |
|
765 | + $incontext['db']['pass'] = ini_get($db['default_password']); |
|
766 | + } |
|
720 | 767 | |
721 | 768 | // For simplicity and less confusion, leave the port blank by default |
722 | 769 | $incontext['db']['port'] = ''; |
@@ -735,10 +782,10 @@ discard block |
||
735 | 782 | $incontext['db']['server'] = $_POST['db_server']; |
736 | 783 | $incontext['db']['prefix'] = $_POST['db_prefix']; |
737 | 784 | |
738 | - if (!empty($_POST['db_port'])) |
|
739 | - $incontext['db']['port'] = $_POST['db_port']; |
|
740 | - } |
|
741 | - else |
|
785 | + if (!empty($_POST['db_port'])) { |
|
786 | + $incontext['db']['port'] = $_POST['db_port']; |
|
787 | + } |
|
788 | + } else |
|
742 | 789 | { |
743 | 790 | $incontext['db']['prefix'] = 'smf_'; |
744 | 791 | } |
@@ -774,10 +821,11 @@ discard block |
||
774 | 821 | if (!empty($_POST['db_port'])) |
775 | 822 | { |
776 | 823 | // For MySQL, we can get the "default port" from PHP. PostgreSQL has no such option though. |
777 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) |
|
778 | - $vars['db_port'] = (int) $_POST['db_port']; |
|
779 | - elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) |
|
780 | - $vars['db_port'] = (int) $_POST['db_port']; |
|
824 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) { |
|
825 | + $vars['db_port'] = (int) $_POST['db_port']; |
|
826 | + } elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) { |
|
827 | + $vars['db_port'] = (int) $_POST['db_port']; |
|
828 | + } |
|
781 | 829 | } |
782 | 830 | |
783 | 831 | // God I hope it saved! |
@@ -790,8 +838,9 @@ discard block |
||
790 | 838 | // Make sure it works. |
791 | 839 | require(dirname(__FILE__) . '/Settings.php'); |
792 | 840 | |
793 | - if (empty($sourcedir)) |
|
794 | - $sourcedir = dirname(__FILE__) . '/Sources'; |
|
841 | + if (empty($sourcedir)) { |
|
842 | + $sourcedir = dirname(__FILE__) . '/Sources'; |
|
843 | + } |
|
795 | 844 | |
796 | 845 | // Better find the database file! |
797 | 846 | if (!file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
@@ -801,18 +850,21 @@ discard block |
||
801 | 850 | } |
802 | 851 | |
803 | 852 | // Now include it for database functions! |
804 | - if (!defined('SMF')) |
|
805 | - define('SMF', 1); |
|
853 | + if (!defined('SMF')) { |
|
854 | + define('SMF', 1); |
|
855 | + } |
|
806 | 856 | |
807 | 857 | $modSettings['disableQueryCheck'] = true; |
808 | - if (empty($smcFunc)) |
|
809 | - $smcFunc = array(); |
|
858 | + if (empty($smcFunc)) { |
|
859 | + $smcFunc = array(); |
|
860 | + } |
|
810 | 861 | |
811 | 862 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
812 | 863 | |
813 | 864 | // What - running PHP4? The shame! |
814 | - if (version_compare(PHP_VERSION, '5', '<')) |
|
815 | - require_once($sourcedir . '/Subs-Compat.php'); |
|
865 | + if (version_compare(PHP_VERSION, '5', '<')) { |
|
866 | + require_once($sourcedir . '/Subs-Compat.php'); |
|
867 | + } |
|
816 | 868 | |
817 | 869 | // Attempt a connection. |
818 | 870 | $needsDB = !empty($databases[$db_type]['always_has_db']); |
@@ -900,12 +952,14 @@ discard block |
||
900 | 952 | $incontext['page_title'] = $txt['install_settings']; |
901 | 953 | |
902 | 954 | // Let's see if we got the database type correct. |
903 | - if (isset($_POST['db_type'], $databases[$_POST['db_type']])) |
|
904 | - $db_type = $_POST['db_type']; |
|
955 | + if (isset($_POST['db_type'], $databases[$_POST['db_type']])) { |
|
956 | + $db_type = $_POST['db_type']; |
|
957 | + } |
|
905 | 958 | |
906 | 959 | // Else we'd better be able to get the connection. |
907 | - else |
|
908 | - load_database(); |
|
960 | + else { |
|
961 | + load_database(); |
|
962 | + } |
|
909 | 963 | |
910 | 964 | $db_type = isset($_POST['db_type']) ? $_POST['db_type'] : $db_type; |
911 | 965 | |
@@ -925,12 +979,14 @@ discard block |
||
925 | 979 | // Submitting? |
926 | 980 | if (isset($_POST['boardurl'])) |
927 | 981 | { |
928 | - if (substr($_POST['boardurl'], -10) == '/index.php') |
|
929 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
930 | - elseif (substr($_POST['boardurl'], -1) == '/') |
|
931 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
932 | - if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') |
|
933 | - $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
982 | + if (substr($_POST['boardurl'], -10) == '/index.php') { |
|
983 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
984 | + } elseif (substr($_POST['boardurl'], -1) == '/') { |
|
985 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
986 | + } |
|
987 | + if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') { |
|
988 | + $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
989 | + } |
|
934 | 990 | |
935 | 991 | // Save these variables. |
936 | 992 | $vars = array( |
@@ -961,10 +1017,10 @@ discard block |
||
961 | 1017 | { |
962 | 1018 | $incontext['error'] = sprintf($txt['error_utf8_version'], $databases[$db_type]['utf8_version']); |
963 | 1019 | return false; |
964 | - } |
|
965 | - else |
|
966 | - // Set the character set here. |
|
1020 | + } else { |
|
1021 | + // Set the character set here. |
|
967 | 1022 | updateSettingsFile(array('db_character_set' => 'utf8')); |
1023 | + } |
|
968 | 1024 | } |
969 | 1025 | |
970 | 1026 | // Good, skip on. |
@@ -984,8 +1040,9 @@ discard block |
||
984 | 1040 | $incontext['continue'] = 1; |
985 | 1041 | |
986 | 1042 | // Already done? |
987 | - if (isset($_POST['pop_done'])) |
|
988 | - return true; |
|
1043 | + if (isset($_POST['pop_done'])) { |
|
1044 | + return true; |
|
1045 | + } |
|
989 | 1046 | |
990 | 1047 | // Reload settings. |
991 | 1048 | require(dirname(__FILE__) . '/Settings.php'); |
@@ -1003,8 +1060,9 @@ discard block |
||
1003 | 1060 | $modSettings = array(); |
1004 | 1061 | if ($result !== false) |
1005 | 1062 | { |
1006 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
1007 | - $modSettings[$row['variable']] = $row['value']; |
|
1063 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
1064 | + $modSettings[$row['variable']] = $row['value']; |
|
1065 | + } |
|
1008 | 1066 | $smcFunc['db_free_result']($result); |
1009 | 1067 | |
1010 | 1068 | // Do they match? If so, this is just a refresh so charge on! |
@@ -1017,20 +1075,22 @@ discard block |
||
1017 | 1075 | $modSettings['disableQueryCheck'] = true; |
1018 | 1076 | |
1019 | 1077 | // If doing UTF8, select it. PostgreSQL requires passing it as a string... |
1020 | - if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) |
|
1021 | - $smcFunc['db_query']('', ' |
|
1078 | + if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) { |
|
1079 | + $smcFunc['db_query']('', ' |
|
1022 | 1080 | SET NAMES {string:utf8}', |
1023 | 1081 | array( |
1024 | 1082 | 'db_error_skip' => true, |
1025 | 1083 | 'utf8' => 'utf8', |
1026 | 1084 | ) |
1027 | 1085 | ); |
1086 | + } |
|
1028 | 1087 | |
1029 | 1088 | // Windows likes to leave the trailing slash, which yields to C:\path\to\SMF\/attachments... |
1030 | - if (substr(__DIR__, -1) == '\\') |
|
1031 | - $attachdir = __DIR__ . 'attachments'; |
|
1032 | - else |
|
1033 | - $attachdir = __DIR__ . '/attachments'; |
|
1089 | + if (substr(__DIR__, -1) == '\\') { |
|
1090 | + $attachdir = __DIR__ . 'attachments'; |
|
1091 | + } else { |
|
1092 | + $attachdir = __DIR__ . '/attachments'; |
|
1093 | + } |
|
1034 | 1094 | |
1035 | 1095 | $replaces = array( |
1036 | 1096 | '{$db_prefix}' => $db_prefix, |
@@ -1047,8 +1107,9 @@ discard block |
||
1047 | 1107 | |
1048 | 1108 | foreach ($txt as $key => $value) |
1049 | 1109 | { |
1050 | - if (substr($key, 0, 8) == 'default_') |
|
1051 | - $replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value); |
|
1110 | + if (substr($key, 0, 8) == 'default_') { |
|
1111 | + $replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value); |
|
1112 | + } |
|
1052 | 1113 | } |
1053 | 1114 | $replaces['{$default_reserved_names}'] = strtr($replaces['{$default_reserved_names}'], array('\\\\n' => '\\n')); |
1054 | 1115 | |
@@ -1063,8 +1124,9 @@ discard block |
||
1063 | 1124 | |
1064 | 1125 | while ($row = $smcFunc['db_fetch_assoc']($get_engines)) |
1065 | 1126 | { |
1066 | - if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') |
|
1067 | - $engines[] = $row['Engine']; |
|
1127 | + if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') { |
|
1128 | + $engines[] = $row['Engine']; |
|
1129 | + } |
|
1068 | 1130 | } |
1069 | 1131 | |
1070 | 1132 | // Done with this now |
@@ -1088,8 +1150,7 @@ discard block |
||
1088 | 1150 | $replaces['START TRANSACTION;'] = ''; |
1089 | 1151 | $replaces['COMMIT;'] = ''; |
1090 | 1152 | } |
1091 | - } |
|
1092 | - else |
|
1153 | + } else |
|
1093 | 1154 | { |
1094 | 1155 | $has_innodb = false; |
1095 | 1156 | } |
@@ -1111,21 +1172,24 @@ discard block |
||
1111 | 1172 | foreach ($sql_lines as $count => $line) |
1112 | 1173 | { |
1113 | 1174 | // No comments allowed! |
1114 | - if (substr(trim($line), 0, 1) != '#') |
|
1115 | - $current_statement .= "\n" . rtrim($line); |
|
1175 | + if (substr(trim($line), 0, 1) != '#') { |
|
1176 | + $current_statement .= "\n" . rtrim($line); |
|
1177 | + } |
|
1116 | 1178 | |
1117 | 1179 | // Is this the end of the query string? |
1118 | - if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) |
|
1119 | - continue; |
|
1180 | + if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) { |
|
1181 | + continue; |
|
1182 | + } |
|
1120 | 1183 | |
1121 | 1184 | // Does this table already exist? If so, don't insert more data into it! |
1122 | 1185 | if (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) != 0 && in_array($match[1], $exists)) |
1123 | 1186 | { |
1124 | 1187 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
1125 | - if (!empty($matches[0])) |
|
1126 | - $incontext['sql_results']['insert_dups'] += count($matches[0]); |
|
1127 | - else |
|
1128 | - $incontext['sql_results']['insert_dups']++; |
|
1188 | + if (!empty($matches[0])) { |
|
1189 | + $incontext['sql_results']['insert_dups'] += count($matches[0]); |
|
1190 | + } else { |
|
1191 | + $incontext['sql_results']['insert_dups']++; |
|
1192 | + } |
|
1129 | 1193 | |
1130 | 1194 | $current_statement = ''; |
1131 | 1195 | continue; |
@@ -1134,8 +1198,9 @@ discard block |
||
1134 | 1198 | if ($smcFunc['db_query']('', $current_statement, array('security_override' => true, 'db_error_skip' => true), $db_connection) === false) |
1135 | 1199 | { |
1136 | 1200 | // Use the appropriate function based on the DB type |
1137 | - if ($db_type == 'mysql' || $db_type == 'mysqli') |
|
1138 | - $db_errorno = $db_type . '_errno'; |
|
1201 | + if ($db_type == 'mysql' || $db_type == 'mysqli') { |
|
1202 | + $db_errorno = $db_type . '_errno'; |
|
1203 | + } |
|
1139 | 1204 | |
1140 | 1205 | // Error 1050: Table already exists! |
1141 | 1206 | // @todo Needs to be made better! |
@@ -1150,18 +1215,18 @@ discard block |
||
1150 | 1215 | // MySQLi requires a connection object. It's optional with MySQL and Postgres |
1151 | 1216 | $incontext['failures'][$count] = $smcFunc['db_error']($db_connection); |
1152 | 1217 | } |
1153 | - } |
|
1154 | - else |
|
1218 | + } else |
|
1155 | 1219 | { |
1156 | - if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
1157 | - $incontext['sql_results']['tables']++; |
|
1158 | - elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
1220 | + if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) { |
|
1221 | + $incontext['sql_results']['tables']++; |
|
1222 | + } elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
1159 | 1223 | { |
1160 | 1224 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
1161 | - if (!empty($matches[0])) |
|
1162 | - $incontext['sql_results']['inserts'] += count($matches[0]); |
|
1163 | - else |
|
1164 | - $incontext['sql_results']['inserts']++; |
|
1225 | + if (!empty($matches[0])) { |
|
1226 | + $incontext['sql_results']['inserts'] += count($matches[0]); |
|
1227 | + } else { |
|
1228 | + $incontext['sql_results']['inserts']++; |
|
1229 | + } |
|
1165 | 1230 | } |
1166 | 1231 | } |
1167 | 1232 | |
@@ -1174,15 +1239,17 @@ discard block |
||
1174 | 1239 | // Sort out the context for the SQL. |
1175 | 1240 | foreach ($incontext['sql_results'] as $key => $number) |
1176 | 1241 | { |
1177 | - if ($number == 0) |
|
1178 | - unset($incontext['sql_results'][$key]); |
|
1179 | - else |
|
1180 | - $incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number); |
|
1242 | + if ($number == 0) { |
|
1243 | + unset($incontext['sql_results'][$key]); |
|
1244 | + } else { |
|
1245 | + $incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number); |
|
1246 | + } |
|
1181 | 1247 | } |
1182 | 1248 | |
1183 | 1249 | // Make sure UTF will be used globally. |
1184 | - 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']))) |
|
1185 | - $newSettings[] = array('global_character_set', 'UTF-8'); |
|
1250 | + if ((!empty($databases[$db_type]['utf8_support']) && !empty($databases[$db_type]['utf8_required'])) || (empty($databases[$db_type]['utf8_required']) && !empty($databases[$db_type]['utf8_support']) && isset($_POST['utf8']))) { |
|
1251 | + $newSettings[] = array('global_character_set', 'UTF-8'); |
|
1252 | + } |
|
1186 | 1253 | |
1187 | 1254 | // Maybe we can auto-detect better cookie settings? |
1188 | 1255 | preg_match('~^http[s]?://([^\.]+?)([^/]*?)(/.*)?$~', $boardurl, $matches); |
@@ -1193,16 +1260,20 @@ discard block |
||
1193 | 1260 | $globalCookies = false; |
1194 | 1261 | |
1195 | 1262 | // Okay... let's see. Using a subdomain other than www.? (not a perfect check.) |
1196 | - if ($matches[2] != '' && (strpos(substr($matches[2], 1), '.') === false || in_array($matches[1], array('forum', 'board', 'community', 'forums', 'support', 'chat', 'help', 'talk', 'boards', 'www')))) |
|
1197 | - $globalCookies = true; |
|
1263 | + if ($matches[2] != '' && (strpos(substr($matches[2], 1), '.') === false || in_array($matches[1], array('forum', 'board', 'community', 'forums', 'support', 'chat', 'help', 'talk', 'boards', 'www')))) { |
|
1264 | + $globalCookies = true; |
|
1265 | + } |
|
1198 | 1266 | // If there's a / in the middle of the path, or it starts with ~... we want local. |
1199 | - if (isset($matches[3]) && strlen($matches[3]) > 3 && (substr($matches[3], 0, 2) == '/~' || strpos(substr($matches[3], 1), '/') !== false)) |
|
1200 | - $localCookies = true; |
|
1267 | + if (isset($matches[3]) && strlen($matches[3]) > 3 && (substr($matches[3], 0, 2) == '/~' || strpos(substr($matches[3], 1), '/') !== false)) { |
|
1268 | + $localCookies = true; |
|
1269 | + } |
|
1201 | 1270 | |
1202 | - if ($globalCookies) |
|
1203 | - $newSettings[] = array('globalCookies', '1'); |
|
1204 | - if ($localCookies) |
|
1205 | - $newSettings[] = array('localCookies', '1'); |
|
1271 | + if ($globalCookies) { |
|
1272 | + $newSettings[] = array('globalCookies', '1'); |
|
1273 | + } |
|
1274 | + if ($localCookies) { |
|
1275 | + $newSettings[] = array('localCookies', '1'); |
|
1276 | + } |
|
1206 | 1277 | } |
1207 | 1278 | |
1208 | 1279 | // Are we allowing stat collection? |
@@ -1218,32 +1289,36 @@ discard block |
||
1218 | 1289 | fwrite($fp, $out); |
1219 | 1290 | |
1220 | 1291 | $return_data = ''; |
1221 | - while (!feof($fp)) |
|
1222 | - $return_data .= fgets($fp, 128); |
|
1292 | + while (!feof($fp)) { |
|
1293 | + $return_data .= fgets($fp, 128); |
|
1294 | + } |
|
1223 | 1295 | |
1224 | 1296 | fclose($fp); |
1225 | 1297 | |
1226 | 1298 | // Get the unique site ID. |
1227 | 1299 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
1228 | 1300 | |
1229 | - if (!empty($ID[1])) |
|
1230 | - $newSettings[] = array('allow_sm_stats', $ID[1]); |
|
1301 | + if (!empty($ID[1])) { |
|
1302 | + $newSettings[] = array('allow_sm_stats', $ID[1]); |
|
1303 | + } |
|
1231 | 1304 | } |
1232 | 1305 | } |
1233 | 1306 | |
1234 | 1307 | // Are we enabling SSL? |
1235 | - if (!empty($_POST['force_ssl'])) |
|
1236 | - $newSettings[] = array('force_ssl', 2); |
|
1308 | + if (!empty($_POST['force_ssl'])) { |
|
1309 | + $newSettings[] = array('force_ssl', 2); |
|
1310 | + } |
|
1237 | 1311 | |
1238 | 1312 | // Setting a timezone is required. |
1239 | 1313 | if (!isset($modSettings['default_timezone']) && function_exists('date_default_timezone_set')) |
1240 | 1314 | { |
1241 | 1315 | // Get PHP's default timezone, if set |
1242 | 1316 | $ini_tz = ini_get('date.timezone'); |
1243 | - if (!empty($ini_tz)) |
|
1244 | - $timezone_id = $ini_tz; |
|
1245 | - else |
|
1246 | - $timezone_id = ''; |
|
1317 | + if (!empty($ini_tz)) { |
|
1318 | + $timezone_id = $ini_tz; |
|
1319 | + } else { |
|
1320 | + $timezone_id = ''; |
|
1321 | + } |
|
1247 | 1322 | |
1248 | 1323 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
1249 | 1324 | if (!in_array($timezone_id, timezone_identifiers_list())) |
@@ -1252,8 +1327,9 @@ discard block |
||
1252 | 1327 | $timezone_id = timezone_name_from_abbr('', $server_offset, 0); |
1253 | 1328 | } |
1254 | 1329 | |
1255 | - if (date_default_timezone_set($timezone_id)) |
|
1256 | - $newSettings[] = array('default_timezone', $timezone_id); |
|
1330 | + if (date_default_timezone_set($timezone_id)) { |
|
1331 | + $newSettings[] = array('default_timezone', $timezone_id); |
|
1332 | + } |
|
1257 | 1333 | } |
1258 | 1334 | |
1259 | 1335 | if (!empty($newSettings)) |
@@ -1284,16 +1360,18 @@ discard block |
||
1284 | 1360 | } |
1285 | 1361 | |
1286 | 1362 | // MySQL specific stuff |
1287 | - if (substr($db_type, 0, 5) != 'mysql') |
|
1288 | - return false; |
|
1363 | + if (substr($db_type, 0, 5) != 'mysql') { |
|
1364 | + return false; |
|
1365 | + } |
|
1289 | 1366 | |
1290 | 1367 | // Find database user privileges. |
1291 | 1368 | $privs = array(); |
1292 | 1369 | $get_privs = $smcFunc['db_query']('', 'SHOW PRIVILEGES', array()); |
1293 | 1370 | while ($row = $smcFunc['db_fetch_assoc']($get_privs)) |
1294 | 1371 | { |
1295 | - if ($row['Privilege'] == 'Alter') |
|
1296 | - $privs[] = $row['Privilege']; |
|
1372 | + if ($row['Privilege'] == 'Alter') { |
|
1373 | + $privs[] = $row['Privilege']; |
|
1374 | + } |
|
1297 | 1375 | } |
1298 | 1376 | $smcFunc['db_free_result']($get_privs); |
1299 | 1377 | |
@@ -1323,8 +1401,9 @@ discard block |
||
1323 | 1401 | $incontext['continue'] = 1; |
1324 | 1402 | |
1325 | 1403 | // Skipping? |
1326 | - if (!empty($_POST['skip'])) |
|
1327 | - return true; |
|
1404 | + if (!empty($_POST['skip'])) { |
|
1405 | + return true; |
|
1406 | + } |
|
1328 | 1407 | |
1329 | 1408 | // Need this to check whether we need the database password. |
1330 | 1409 | require(dirname(__FILE__) . '/Settings.php'); |
@@ -1337,18 +1416,22 @@ discard block |
||
1337 | 1416 | // We need this to properly hash the password for Admin |
1338 | 1417 | $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) { |
1339 | 1418 | global $sourcedir; |
1340 | - if (function_exists('mb_strtolower')) |
|
1341 | - return mb_strtolower($string, 'UTF-8'); |
|
1419 | + if (function_exists('mb_strtolower')) { |
|
1420 | + return mb_strtolower($string, 'UTF-8'); |
|
1421 | + } |
|
1342 | 1422 | require_once($sourcedir . '/Subs-Charset.php'); |
1343 | 1423 | return utf8_strtolower($string); |
1344 | 1424 | }; |
1345 | 1425 | |
1346 | - if (!isset($_POST['username'])) |
|
1347 | - $_POST['username'] = ''; |
|
1348 | - if (!isset($_POST['email'])) |
|
1349 | - $_POST['email'] = ''; |
|
1350 | - if (!isset($_POST['server_email'])) |
|
1351 | - $_POST['server_email'] = ''; |
|
1426 | + if (!isset($_POST['username'])) { |
|
1427 | + $_POST['username'] = ''; |
|
1428 | + } |
|
1429 | + if (!isset($_POST['email'])) { |
|
1430 | + $_POST['email'] = ''; |
|
1431 | + } |
|
1432 | + if (!isset($_POST['server_email'])) { |
|
1433 | + $_POST['server_email'] = ''; |
|
1434 | + } |
|
1352 | 1435 | |
1353 | 1436 | $incontext['username'] = htmlspecialchars(stripslashes($_POST['username'])); |
1354 | 1437 | $incontext['email'] = htmlspecialchars(stripslashes($_POST['email'])); |
@@ -1367,8 +1450,9 @@ discard block |
||
1367 | 1450 | 'admin_group' => 1, |
1368 | 1451 | ) |
1369 | 1452 | ); |
1370 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
1371 | - $incontext['skip'] = 1; |
|
1453 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
1454 | + $incontext['skip'] = 1; |
|
1455 | + } |
|
1372 | 1456 | $smcFunc['db_free_result']($request); |
1373 | 1457 | |
1374 | 1458 | // Trying to create an account? |
@@ -1399,8 +1483,9 @@ discard block |
||
1399 | 1483 | } |
1400 | 1484 | |
1401 | 1485 | // Update the webmaster's email? |
1402 | - if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) |
|
1403 | - updateSettingsFile(array('webmaster_email' => $_POST['server_email'])); |
|
1486 | + if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) { |
|
1487 | + updateSettingsFile(array('webmaster_email' => $_POST['server_email'])); |
|
1488 | + } |
|
1404 | 1489 | |
1405 | 1490 | // Work out whether we're going to have dodgy characters and remove them. |
1406 | 1491 | $invalid_characters = preg_match('~[<>&"\'=\\\]~', $_POST['username']) != 0; |
@@ -1423,32 +1508,27 @@ discard block |
||
1423 | 1508 | $smcFunc['db_free_result']($result); |
1424 | 1509 | |
1425 | 1510 | $incontext['account_existed'] = $txt['error_user_settings_taken']; |
1426 | - } |
|
1427 | - elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) |
|
1511 | + } elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) |
|
1428 | 1512 | { |
1429 | 1513 | // Try the previous step again. |
1430 | 1514 | $incontext['error'] = $_POST['username'] == '' ? $txt['error_username_left_empty'] : $txt['error_username_too_long']; |
1431 | 1515 | return false; |
1432 | - } |
|
1433 | - elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) |
|
1516 | + } elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) |
|
1434 | 1517 | { |
1435 | 1518 | // Try the previous step again. |
1436 | 1519 | $incontext['error'] = $txt['error_invalid_characters_username']; |
1437 | 1520 | return false; |
1438 | - } |
|
1439 | - elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255) |
|
1521 | + } elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255) |
|
1440 | 1522 | { |
1441 | 1523 | // One step back, this time fill out a proper admin email address. |
1442 | 1524 | $incontext['error'] = sprintf($txt['error_valid_admin_email_needed'], $_POST['username']); |
1443 | 1525 | return false; |
1444 | - } |
|
1445 | - elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255) |
|
1526 | + } elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255) |
|
1446 | 1527 | { |
1447 | 1528 | // One step back, this time fill out a proper admin email address. |
1448 | 1529 | $incontext['error'] = $txt['error_valid_server_email_needed']; |
1449 | 1530 | return false; |
1450 | - } |
|
1451 | - elseif ($_POST['username'] != '') |
|
1531 | + } elseif ($_POST['username'] != '') |
|
1452 | 1532 | { |
1453 | 1533 | $incontext['member_salt'] = substr(md5(mt_rand()), 0, 4); |
1454 | 1534 | |
@@ -1514,17 +1594,19 @@ discard block |
||
1514 | 1594 | require_once($sourcedir . '/Subs-Auth.php'); |
1515 | 1595 | |
1516 | 1596 | // Bring a warning over. |
1517 | - if (!empty($incontext['account_existed'])) |
|
1518 | - $incontext['warning'] = $incontext['account_existed']; |
|
1597 | + if (!empty($incontext['account_existed'])) { |
|
1598 | + $incontext['warning'] = $incontext['account_existed']; |
|
1599 | + } |
|
1519 | 1600 | |
1520 | - if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) |
|
1521 | - $smcFunc['db_query']('', ' |
|
1601 | + if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) { |
|
1602 | + $smcFunc['db_query']('', ' |
|
1522 | 1603 | SET NAMES {string:db_character_set}', |
1523 | 1604 | array( |
1524 | 1605 | 'db_character_set' => $db_character_set, |
1525 | 1606 | 'db_error_skip' => true, |
1526 | 1607 | ) |
1527 | 1608 | ); |
1609 | + } |
|
1528 | 1610 | |
1529 | 1611 | // As track stats is by default enabled let's add some activity. |
1530 | 1612 | $smcFunc['db_insert']('ignore', |
@@ -1545,14 +1627,16 @@ discard block |
||
1545 | 1627 | // Only proceed if we can load the data. |
1546 | 1628 | if ($request) |
1547 | 1629 | { |
1548 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
1549 | - $modSettings[$row[0]] = $row[1]; |
|
1630 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
1631 | + $modSettings[$row[0]] = $row[1]; |
|
1632 | + } |
|
1550 | 1633 | $smcFunc['db_free_result']($request); |
1551 | 1634 | } |
1552 | 1635 | |
1553 | 1636 | // Automatically log them in ;) |
1554 | - if (isset($incontext['member_id']) && isset($incontext['member_salt'])) |
|
1555 | - setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt'])); |
|
1637 | + if (isset($incontext['member_id']) && isset($incontext['member_salt'])) { |
|
1638 | + setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt'])); |
|
1639 | + } |
|
1556 | 1640 | |
1557 | 1641 | $result = $smcFunc['db_query']('', ' |
1558 | 1642 | SELECT value |
@@ -1563,13 +1647,14 @@ discard block |
||
1563 | 1647 | 'db_error_skip' => true, |
1564 | 1648 | ) |
1565 | 1649 | ); |
1566 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
1567 | - list ($db_sessions) = $smcFunc['db_fetch_row']($result); |
|
1650 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
1651 | + list ($db_sessions) = $smcFunc['db_fetch_row']($result); |
|
1652 | + } |
|
1568 | 1653 | $smcFunc['db_free_result']($result); |
1569 | 1654 | |
1570 | - if (empty($db_sessions)) |
|
1571 | - $_SESSION['admin_time'] = time(); |
|
1572 | - else |
|
1655 | + if (empty($db_sessions)) { |
|
1656 | + $_SESSION['admin_time'] = time(); |
|
1657 | + } else |
|
1573 | 1658 | { |
1574 | 1659 | $_SERVER['HTTP_USER_AGENT'] = substr($_SERVER['HTTP_USER_AGENT'], 0, 211); |
1575 | 1660 | |
@@ -1593,8 +1678,9 @@ discard block |
||
1593 | 1678 | $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : |
1594 | 1679 | function($string){ |
1595 | 1680 | global $sourcedir; |
1596 | - if (function_exists('mb_strtolower')) |
|
1597 | - return mb_strtolower($string, 'UTF-8'); |
|
1681 | + if (function_exists('mb_strtolower')) { |
|
1682 | + return mb_strtolower($string, 'UTF-8'); |
|
1683 | + } |
|
1598 | 1684 | require_once($sourcedir . '/Subs-Charset.php'); |
1599 | 1685 | return utf8_strtolower($string); |
1600 | 1686 | }; |
@@ -1610,8 +1696,9 @@ discard block |
||
1610 | 1696 | ) |
1611 | 1697 | ); |
1612 | 1698 | $context['utf8'] = $db_character_set === 'utf8' || $txt['lang_character_set'] === 'UTF-8'; |
1613 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
1614 | - updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject'])); |
|
1699 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
1700 | + updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject'])); |
|
1701 | + } |
|
1615 | 1702 | $smcFunc['db_free_result']($request); |
1616 | 1703 | |
1617 | 1704 | // Now is the perfect time to fetch the SM files. |
@@ -1630,8 +1717,9 @@ discard block |
||
1630 | 1717 | |
1631 | 1718 | // Check if we need some stupid MySQL fix. |
1632 | 1719 | $server_version = $smcFunc['db_server_info'](); |
1633 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
1634 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
1720 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
1721 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
1722 | + } |
|
1635 | 1723 | |
1636 | 1724 | // Some final context for the template. |
1637 | 1725 | $incontext['dir_still_writable'] = is_writable(dirname(__FILE__)) && substr(__FILE__, 1, 2) != ':\\'; |
@@ -1651,8 +1739,9 @@ discard block |
||
1651 | 1739 | $settingsArray = file(dirname(__FILE__) . '/Settings.php'); |
1652 | 1740 | |
1653 | 1741 | // @todo Do we just want to read the file in clean, and split it this way always? |
1654 | - if (count($settingsArray) == 1) |
|
1655 | - $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
1742 | + if (count($settingsArray) == 1) { |
|
1743 | + $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
1744 | + } |
|
1656 | 1745 | |
1657 | 1746 | for ($i = 0, $n = count($settingsArray); $i < $n; $i++) |
1658 | 1747 | { |
@@ -1667,19 +1756,22 @@ discard block |
||
1667 | 1756 | continue; |
1668 | 1757 | } |
1669 | 1758 | |
1670 | - if (trim($settingsArray[$i]) == '?' . '>') |
|
1671 | - $settingsArray[$i] = ''; |
|
1759 | + if (trim($settingsArray[$i]) == '?' . '>') { |
|
1760 | + $settingsArray[$i] = ''; |
|
1761 | + } |
|
1672 | 1762 | |
1673 | 1763 | // Don't trim or bother with it if it's not a variable. |
1674 | - if (substr($settingsArray[$i], 0, 1) != '$') |
|
1675 | - continue; |
|
1764 | + if (substr($settingsArray[$i], 0, 1) != '$') { |
|
1765 | + continue; |
|
1766 | + } |
|
1676 | 1767 | |
1677 | 1768 | $settingsArray[$i] = rtrim($settingsArray[$i]) . "\n"; |
1678 | 1769 | |
1679 | - foreach ($vars as $var => $val) |
|
1680 | - if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
1770 | + foreach ($vars as $var => $val) { |
|
1771 | + if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
1681 | 1772 | { |
1682 | 1773 | $comment = strstr($settingsArray[$i], '#'); |
1774 | + } |
|
1683 | 1775 | $settingsArray[$i] = '$' . $var . ' = \'' . $val . '\';' . ($comment != '' ? "\t\t" . $comment : "\n"); |
1684 | 1776 | unset($vars[$var]); |
1685 | 1777 | } |
@@ -1689,36 +1781,41 @@ discard block |
||
1689 | 1781 | if (!empty($vars)) |
1690 | 1782 | { |
1691 | 1783 | $settingsArray[$i++] = ''; |
1692 | - foreach ($vars as $var => $val) |
|
1693 | - $settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n"; |
|
1784 | + foreach ($vars as $var => $val) { |
|
1785 | + $settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n"; |
|
1786 | + } |
|
1694 | 1787 | } |
1695 | 1788 | |
1696 | 1789 | // Blank out the file - done to fix a oddity with some servers. |
1697 | 1790 | $fp = @fopen(dirname(__FILE__) . '/Settings.php', 'w'); |
1698 | - if (!$fp) |
|
1699 | - return false; |
|
1791 | + if (!$fp) { |
|
1792 | + return false; |
|
1793 | + } |
|
1700 | 1794 | fclose($fp); |
1701 | 1795 | |
1702 | 1796 | $fp = fopen(dirname(__FILE__) . '/Settings.php', 'r+'); |
1703 | 1797 | |
1704 | 1798 | // Gotta have one of these ;) |
1705 | - if (trim($settingsArray[0]) != '<?php') |
|
1706 | - fwrite($fp, "<?php\n"); |
|
1799 | + if (trim($settingsArray[0]) != '<?php') { |
|
1800 | + fwrite($fp, "<?php\n"); |
|
1801 | + } |
|
1707 | 1802 | |
1708 | 1803 | $lines = count($settingsArray); |
1709 | 1804 | for ($i = 0; $i < $lines - 1; $i++) |
1710 | 1805 | { |
1711 | 1806 | // Don't just write a bunch of blank lines. |
1712 | - if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') |
|
1713 | - fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
1807 | + if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') { |
|
1808 | + fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
1809 | + } |
|
1714 | 1810 | } |
1715 | 1811 | fwrite($fp, $settingsArray[$i] . '?' . '>'); |
1716 | 1812 | fclose($fp); |
1717 | 1813 | |
1718 | 1814 | // Even though on normal installations the filemtime should prevent this being used by the installer incorrectly |
1719 | 1815 | // it seems that there are times it might not. So let's MAKE it dump the cache. |
1720 | - if (function_exists('opcache_invalidate')) |
|
1721 | - opcache_invalidate(dirname(__FILE__) . '/Settings.php', true); |
|
1816 | + if (function_exists('opcache_invalidate')) { |
|
1817 | + opcache_invalidate(dirname(__FILE__) . '/Settings.php', true); |
|
1818 | + } |
|
1722 | 1819 | |
1723 | 1820 | return true; |
1724 | 1821 | } |
@@ -1743,9 +1840,9 @@ discard block |
||
1743 | 1840 | SecFilterScanPOST Off |
1744 | 1841 | </IfModule>'; |
1745 | 1842 | |
1746 | - if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) |
|
1747 | - return true; |
|
1748 | - elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess')) |
|
1843 | + if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) { |
|
1844 | + return true; |
|
1845 | + } elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess')) |
|
1749 | 1846 | { |
1750 | 1847 | $current_htaccess = implode('', file(dirname(__FILE__) . '/.htaccess')); |
1751 | 1848 | |
@@ -1757,29 +1854,28 @@ discard block |
||
1757 | 1854 | fwrite($ht_handle, $htaccess_addition); |
1758 | 1855 | fclose($ht_handle); |
1759 | 1856 | return true; |
1857 | + } else { |
|
1858 | + return false; |
|
1760 | 1859 | } |
1761 | - else |
|
1762 | - return false; |
|
1860 | + } else { |
|
1861 | + return true; |
|
1763 | 1862 | } |
1764 | - else |
|
1765 | - return true; |
|
1766 | - } |
|
1767 | - elseif (file_exists(dirname(__FILE__) . '/.htaccess')) |
|
1768 | - return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false; |
|
1769 | - elseif (is_writable(dirname(__FILE__))) |
|
1863 | + } elseif (file_exists(dirname(__FILE__) . '/.htaccess')) { |
|
1864 | + return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false; |
|
1865 | + } elseif (is_writable(dirname(__FILE__))) |
|
1770 | 1866 | { |
1771 | 1867 | if ($ht_handle = fopen(dirname(__FILE__) . '/.htaccess', 'w')) |
1772 | 1868 | { |
1773 | 1869 | fwrite($ht_handle, $htaccess_addition); |
1774 | 1870 | fclose($ht_handle); |
1775 | 1871 | return true; |
1872 | + } else { |
|
1873 | + return false; |
|
1776 | 1874 | } |
1777 | - else |
|
1875 | + } else { |
|
1778 | 1876 | return false; |
1779 | 1877 | } |
1780 | - else |
|
1781 | - return false; |
|
1782 | -} |
|
1878 | + } |
|
1783 | 1879 | |
1784 | 1880 | function template_install_above() |
1785 | 1881 | { |
@@ -1817,9 +1913,10 @@ discard block |
||
1817 | 1913 | <label for="installer_language">', $txt['installer_language'], ':</label> |
1818 | 1914 | <select id="installer_language" name="lang_file" onchange="location.href = \'', $installurl, '?lang_file=\' + this.options[this.selectedIndex].value;">'; |
1819 | 1915 | |
1820 | - foreach ($incontext['detected_languages'] as $lang => $name) |
|
1821 | - echo ' |
|
1916 | + foreach ($incontext['detected_languages'] as $lang => $name) { |
|
1917 | + echo ' |
|
1822 | 1918 | <option', isset($_SESSION['installer_temp_lang']) && $_SESSION['installer_temp_lang'] == $lang ? ' selected' : '', ' value="', $lang, '">', $name, '</option>'; |
1919 | + } |
|
1823 | 1920 | |
1824 | 1921 | echo ' |
1825 | 1922 | </select> |
@@ -1839,9 +1936,10 @@ discard block |
||
1839 | 1936 | <h2>', $txt['upgrade_progress'], '</h2> |
1840 | 1937 | <ul>'; |
1841 | 1938 | |
1842 | - foreach ($incontext['steps'] as $num => $step) |
|
1843 | - echo ' |
|
1939 | + foreach ($incontext['steps'] as $num => $step) { |
|
1940 | + echo ' |
|
1844 | 1941 | <li class="', $num < $incontext['current_step'] ? 'stepdone' : ($num == $incontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
1942 | + } |
|
1845 | 1943 | |
1846 | 1944 | echo ' |
1847 | 1945 | </ul> |
@@ -1866,20 +1964,23 @@ discard block |
||
1866 | 1964 | echo ' |
1867 | 1965 | <div>'; |
1868 | 1966 | |
1869 | - if (!empty($incontext['continue'])) |
|
1870 | - echo ' |
|
1967 | + if (!empty($incontext['continue'])) { |
|
1968 | + echo ' |
|
1871 | 1969 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '" onclick="return submitThisOnce(this);" class="button_submit" />'; |
1872 | - if (!empty($incontext['skip'])) |
|
1873 | - echo ' |
|
1970 | + } |
|
1971 | + if (!empty($incontext['skip'])) { |
|
1972 | + echo ' |
|
1874 | 1973 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="return submitThisOnce(this);" class="button_submit" />'; |
1974 | + } |
|
1875 | 1975 | echo ' |
1876 | 1976 | </div>'; |
1877 | 1977 | } |
1878 | 1978 | |
1879 | 1979 | // Show the closing form tag and other data only if not in the last step |
1880 | - if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) |
|
1881 | - echo ' |
|
1980 | + if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) { |
|
1981 | + echo ' |
|
1882 | 1982 | </form>'; |
1983 | + } |
|
1883 | 1984 | |
1884 | 1985 | echo ' |
1885 | 1986 | </div> |
@@ -1914,13 +2015,15 @@ discard block |
||
1914 | 2015 | </div>'; |
1915 | 2016 | |
1916 | 2017 | // Show the warnings, or not. |
1917 | - if (template_warning_divs()) |
|
1918 | - echo ' |
|
2018 | + if (template_warning_divs()) { |
|
2019 | + echo ' |
|
1919 | 2020 | <h3>', $txt['install_all_lovely'], '</h3>'; |
2021 | + } |
|
1920 | 2022 | |
1921 | 2023 | // Say we want the continue button! |
1922 | - if (empty($incontext['error'])) |
|
1923 | - $incontext['continue'] = 1; |
|
2024 | + if (empty($incontext['error'])) { |
|
2025 | + $incontext['continue'] = 1; |
|
2026 | + } |
|
1924 | 2027 | |
1925 | 2028 | // For the latest version stuff. |
1926 | 2029 | echo ' |
@@ -1954,8 +2057,8 @@ discard block |
||
1954 | 2057 | global $txt, $incontext; |
1955 | 2058 | |
1956 | 2059 | // Errors are very serious.. |
1957 | - if (!empty($incontext['error'])) |
|
1958 | - echo ' |
|
2060 | + if (!empty($incontext['error'])) { |
|
2061 | + echo ' |
|
1959 | 2062 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
1960 | 2063 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
1961 | 2064 | <strong style="text-decoration: underline;">', $txt['upgrade_critical_error'], '</strong><br> |
@@ -1963,9 +2066,10 @@ discard block |
||
1963 | 2066 | ', $incontext['error'], ' |
1964 | 2067 | </div> |
1965 | 2068 | </div>'; |
2069 | + } |
|
1966 | 2070 | // A warning message? |
1967 | - elseif (!empty($incontext['warning'])) |
|
1968 | - echo ' |
|
2071 | + elseif (!empty($incontext['warning'])) { |
|
2072 | + echo ' |
|
1969 | 2073 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
1970 | 2074 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
1971 | 2075 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -1973,6 +2077,7 @@ discard block |
||
1973 | 2077 | ', $incontext['warning'], ' |
1974 | 2078 | </div> |
1975 | 2079 | </div>'; |
2080 | + } |
|
1976 | 2081 | |
1977 | 2082 | return empty($incontext['error']) && empty($incontext['warning']); |
1978 | 2083 | } |
@@ -1988,27 +2093,30 @@ discard block |
||
1988 | 2093 | <li>', $incontext['failed_files']), '</li> |
1989 | 2094 | </ul>'; |
1990 | 2095 | |
1991 | - if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') |
|
1992 | - echo ' |
|
2096 | + if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') { |
|
2097 | + echo ' |
|
1993 | 2098 | <hr> |
1994 | 2099 | <p>', $txt['chmod_linux_info'], '</p> |
1995 | 2100 | <tt># chmod a+w ', implode(' ' . $incontext['detected_path'] . '/', $incontext['failed_files']), '</tt>'; |
2101 | + } |
|
1996 | 2102 | |
1997 | 2103 | // This is serious! |
1998 | - if (!template_warning_divs()) |
|
1999 | - return; |
|
2104 | + if (!template_warning_divs()) { |
|
2105 | + return; |
|
2106 | + } |
|
2000 | 2107 | |
2001 | 2108 | echo ' |
2002 | 2109 | <hr> |
2003 | 2110 | <p>', $txt['ftp_setup_info'], '</p>'; |
2004 | 2111 | |
2005 | - if (!empty($incontext['ftp_errors'])) |
|
2006 | - echo ' |
|
2112 | + if (!empty($incontext['ftp_errors'])) { |
|
2113 | + echo ' |
|
2007 | 2114 | <div class="error_message"> |
2008 | 2115 | ', $txt['error_ftp_no_connect'], '<br><br> |
2009 | 2116 | <code>', implode('<br>', $incontext['ftp_errors']), '</code> |
2010 | 2117 | </div> |
2011 | 2118 | <br>'; |
2119 | + } |
|
2012 | 2120 | |
2013 | 2121 | echo ' |
2014 | 2122 | <form action="', $incontext['form_url'], '" method="post"> |
@@ -2068,17 +2176,17 @@ discard block |
||
2068 | 2176 | <td> |
2069 | 2177 | <select name="db_type" id="db_type_input" onchange="toggleDBInput();">'; |
2070 | 2178 | |
2071 | - foreach ($incontext['supported_databases'] as $key => $db) |
|
2072 | - echo ' |
|
2179 | + foreach ($incontext['supported_databases'] as $key => $db) { |
|
2180 | + echo ' |
|
2073 | 2181 | <option value="', $key, '"', isset($_POST['db_type']) && $_POST['db_type'] == $key ? ' selected' : '', '>', $db['name'], '</option>'; |
2182 | + } |
|
2074 | 2183 | |
2075 | 2184 | echo ' |
2076 | 2185 | </select> |
2077 | 2186 | <div class="smalltext block">', $txt['db_settings_type_info'], '</div> |
2078 | 2187 | </td> |
2079 | 2188 | </tr>'; |
2080 | - } |
|
2081 | - else |
|
2189 | + } else |
|
2082 | 2190 | { |
2083 | 2191 | echo ' |
2084 | 2192 | <tr style="display: none;"> |
@@ -2270,9 +2378,10 @@ discard block |
||
2270 | 2378 | <div style="color: red;">', $txt['error_db_queries'], '</div> |
2271 | 2379 | <ul>'; |
2272 | 2380 | |
2273 | - foreach ($incontext['failures'] as $line => $fail) |
|
2274 | - echo ' |
|
2381 | + foreach ($incontext['failures'] as $line => $fail) { |
|
2382 | + echo ' |
|
2275 | 2383 | <li><strong>', $txt['error_db_queries_line'], $line + 1, ':</strong> ', nl2br(htmlspecialchars($fail)), '</li>'; |
2384 | + } |
|
2276 | 2385 | |
2277 | 2386 | echo ' |
2278 | 2387 | </ul>'; |
@@ -2333,15 +2442,16 @@ discard block |
||
2333 | 2442 | </tr> |
2334 | 2443 | </table>'; |
2335 | 2444 | |
2336 | - if ($incontext['require_db_confirm']) |
|
2337 | - echo ' |
|
2445 | + if ($incontext['require_db_confirm']) { |
|
2446 | + echo ' |
|
2338 | 2447 | <h2>', $txt['user_settings_database'], '</h2> |
2339 | 2448 | <p>', $txt['user_settings_database_info'], '</p> |
2340 | 2449 | |
2341 | 2450 | <div style="margin-bottom: 2ex; padding-', $txt['lang_rtl'] == false ? 'left' : 'right', ': 50px;"> |
2342 | 2451 | <input type="password" name="password3" size="30" class="input_password" /> |
2343 | 2452 | </div>'; |
2344 | -} |
|
2453 | + } |
|
2454 | + } |
|
2345 | 2455 | |
2346 | 2456 | // Tell them it's done, and to delete. |
2347 | 2457 | function template_delete_install() |
@@ -2354,14 +2464,15 @@ discard block |
||
2354 | 2464 | template_warning_divs(); |
2355 | 2465 | |
2356 | 2466 | // Install directory still writable? |
2357 | - if ($incontext['dir_still_writable']) |
|
2358 | - echo ' |
|
2467 | + if ($incontext['dir_still_writable']) { |
|
2468 | + echo ' |
|
2359 | 2469 | <em>', $txt['still_writable'], '</em><br> |
2360 | 2470 | <br>'; |
2471 | + } |
|
2361 | 2472 | |
2362 | 2473 | // Don't show the box if it's like 99% sure it won't work :P. |
2363 | - if ($incontext['probably_delete_install']) |
|
2364 | - echo ' |
|
2474 | + if ($incontext['probably_delete_install']) { |
|
2475 | + echo ' |
|
2365 | 2476 | <div style="margin: 1ex; font-weight: bold;"> |
2366 | 2477 | <label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete();" class="input_check" /> ', $txt['delete_installer'], !isset($_SESSION['installer_temp_ftp']) ? ' ' . $txt['delete_installer_maybe'] : '', '</label> |
2367 | 2478 | </div> |
@@ -2377,6 +2488,7 @@ discard block |
||
2377 | 2488 | } |
2378 | 2489 | </script> |
2379 | 2490 | <br>'; |
2491 | + } |
|
2380 | 2492 | |
2381 | 2493 | echo ' |
2382 | 2494 | ', sprintf($txt['go_to_your_forum'], $boardurl . '/index.php'), '<br> |
@@ -25,8 +25,9 @@ discard block |
||
25 | 25 | |
26 | 26 | // Get everything started up... |
27 | 27 | define('SMF', 1); |
28 | -if (function_exists('set_magic_quotes_runtime') && strnatcmp(phpversion(), '5.3.0') < 0) |
|
28 | +if (function_exists('set_magic_quotes_runtime') && strnatcmp(phpversion(), '5.3.0') < 0) { |
|
29 | 29 | @set_magic_quotes_runtime(0); |
30 | +} |
|
30 | 31 | error_reporting(defined('E_STRICT') ? E_ALL | E_STRICT : E_ALL); |
31 | 32 | $time_start = microtime(); |
32 | 33 | |
@@ -34,16 +35,18 @@ discard block |
||
34 | 35 | ob_start(); |
35 | 36 | |
36 | 37 | // Do some cleaning, just in case. |
37 | -foreach (array('db_character_set', 'cachedir') as $variable) |
|
38 | +foreach (array('db_character_set', 'cachedir') as $variable) { |
|
38 | 39 | if (isset($GLOBALS[$variable])) |
39 | 40 | unset($GLOBALS[$variable], $GLOBALS[$variable]); |
41 | +} |
|
40 | 42 | |
41 | 43 | // Load the settings... |
42 | 44 | require_once(dirname(__FILE__) . '/Settings.php'); |
43 | 45 | |
44 | 46 | // Make absolutely sure the cache directory is defined. |
45 | -if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) |
|
47 | +if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) { |
|
46 | 48 | $cachedir = $boarddir . '/cache'; |
49 | +} |
|
47 | 50 | |
48 | 51 | // Without those we can't go anywhere |
49 | 52 | require_once($sourcedir . '/QueryString.php'); |
@@ -53,8 +56,9 @@ discard block |
||
53 | 56 | require_once($sourcedir . '/Load.php'); |
54 | 57 | |
55 | 58 | // If $maintenance is set specifically to 2, then we're upgrading or something. |
56 | -if (!empty($maintenance) && $maintenance == 2) |
|
59 | +if (!empty($maintenance) && $maintenance == 2) { |
|
57 | 60 | display_maintenance_message(); |
61 | +} |
|
58 | 62 | |
59 | 63 | // Create a variable to store some SMF specific functions in. |
60 | 64 | $smcFunc = array(); |
@@ -69,8 +73,9 @@ discard block |
||
69 | 73 | cleanRequest(); |
70 | 74 | |
71 | 75 | // Seed the random generator. |
72 | -if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) |
|
76 | +if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) { |
|
73 | 77 | smf_seed_generator(); |
78 | +} |
|
74 | 79 | |
75 | 80 | // Before we get carried away, are we doing a scheduled task? If so save CPU cycles by jumping out! |
76 | 81 | if (isset($_GET['scheduled'])) |
@@ -90,9 +95,9 @@ discard block |
||
90 | 95 | if (!empty($modSettings['enableCompressedOutput']) && !headers_sent()) |
91 | 96 | { |
92 | 97 | // If zlib is being used, turn off output compression. |
93 | - if (ini_get('zlib.output_compression') >= 1 || ini_get('output_handler') == 'ob_gzhandler') |
|
94 | - $modSettings['enableCompressedOutput'] = '0'; |
|
95 | - else |
|
98 | + if (ini_get('zlib.output_compression') >= 1 || ini_get('output_handler') == 'ob_gzhandler') { |
|
99 | + $modSettings['enableCompressedOutput'] = '0'; |
|
100 | + } else |
|
96 | 101 | { |
97 | 102 | ob_end_clean(); |
98 | 103 | ob_start('ob_gzhandler'); |
@@ -141,18 +146,21 @@ discard block |
||
141 | 146 | loadPermissions(); |
142 | 147 | |
143 | 148 | // Attachments don't require the entire theme to be loaded. |
144 | - if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach') |
|
145 | - detectBrowser(); |
|
149 | + if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach') { |
|
150 | + detectBrowser(); |
|
151 | + } |
|
146 | 152 | // Load the current theme. (note that ?theme=1 will also work, may be used for guest theming.) |
147 | - else |
|
148 | - loadTheme(); |
|
153 | + else { |
|
154 | + loadTheme(); |
|
155 | + } |
|
149 | 156 | |
150 | 157 | // Check if the user should be disallowed access. |
151 | 158 | is_not_banned(); |
152 | 159 | |
153 | 160 | // If we are in a topic and don't have permission to approve it then duck out now. |
154 | - if (!empty($topic) && empty($board_info['cur_topic_approved']) && !allowedTo('approve_posts') && ($user_info['id'] != $board_info['cur_topic_starter'] || $user_info['is_guest'])) |
|
155 | - fatal_lang_error('not_a_topic', false); |
|
161 | + if (!empty($topic) && empty($board_info['cur_topic_approved']) && !allowedTo('approve_posts') && ($user_info['id'] != $board_info['cur_topic_starter'] || $user_info['is_guest'])) { |
|
162 | + fatal_lang_error('not_a_topic', false); |
|
163 | + } |
|
156 | 164 | |
157 | 165 | $no_stat_actions = array('clock', 'dlattach', 'findmember', 'jsoption', 'likes', 'loadeditorlocale', 'modifycat', 'requestmembers', 'smstats', 'suggest', 'about:unknown', '.xml', 'xmlhttp', 'verificationcode', 'viewquery', 'viewsmfile'); |
158 | 166 | call_integration_hook('integrate_pre_log_stats', array(&$no_stat_actions)); |
@@ -163,8 +171,9 @@ discard block |
||
163 | 171 | writeLog(); |
164 | 172 | |
165 | 173 | // Track forum statistics and hits...? |
166 | - if (!empty($modSettings['hitStats'])) |
|
167 | - trackStats(array('hits' => '+')); |
|
174 | + if (!empty($modSettings['hitStats'])) { |
|
175 | + trackStats(array('hits' => '+')); |
|
176 | + } |
|
168 | 177 | } |
169 | 178 | unset($no_stat_actions); |
170 | 179 | |
@@ -178,13 +187,14 @@ discard block |
||
178 | 187 | return ($_REQUEST['action'] == 'login2' ? 'Login2' : ($_REQUEST['action'] == 'logintfa' ? 'LoginTFA' : 'Logout')); |
179 | 188 | } |
180 | 189 | // Don't even try it, sonny. |
181 | - else |
|
182 | - return 'InMaintenance'; |
|
190 | + else { |
|
191 | + return 'InMaintenance'; |
|
192 | + } |
|
183 | 193 | } |
184 | 194 | // If guest access is off, a guest can only do one of the very few following actions. |
185 | - elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('coppa', 'login', 'login2', 'logintfa', 'reminder', 'activate', 'help', 'helpadmin', 'smstats', 'verificationcode', 'signup', 'signup2')))) |
|
186 | - return 'KickGuest'; |
|
187 | - elseif (empty($_REQUEST['action'])) |
|
195 | + elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('coppa', 'login', 'login2', 'logintfa', 'reminder', 'activate', 'help', 'helpadmin', 'smstats', 'verificationcode', 'signup', 'signup2')))) { |
|
196 | + return 'KickGuest'; |
|
197 | + } elseif (empty($_REQUEST['action'])) |
|
188 | 198 | { |
189 | 199 | // Action and board are both empty... BoardIndex! Unless someone else wants to do something different. |
190 | 200 | if (empty($board) && empty($topic)) |
@@ -200,8 +210,9 @@ discard block |
||
200 | 210 | |
201 | 211 | $call = call_helper($defaultAction, true); |
202 | 212 | |
203 | - if (!empty($call)) |
|
204 | - return $call; |
|
213 | + if (!empty($call)) { |
|
214 | + return $call; |
|
215 | + } |
|
205 | 216 | } |
206 | 217 | |
207 | 218 | // No default action huh? then go to our good old BoardIndex. |
@@ -331,8 +342,9 @@ discard block |
||
331 | 342 | |
332 | 343 | $call = call_helper($fallbackAction, true); |
333 | 344 | |
334 | - if (!empty($call)) |
|
335 | - return $call; |
|
345 | + if (!empty($call)) { |
|
346 | + return $call; |
|
347 | + } |
|
336 | 348 | } |
337 | 349 | |
338 | 350 | // No fallback action, huh? |
@@ -104,7 +104,7 @@ |
||
104 | 104 | * |
105 | 105 | * @param string $class The fully-qualified class name. |
106 | 106 | */ |
107 | -spl_autoload_register(function ($class) use ($sourcedir) |
|
107 | +spl_autoload_register(function($class) use ($sourcedir) |
|
108 | 108 | { |
109 | 109 | $classMap = array( |
110 | 110 | 'ReCaptcha\\' => 'ReCaptcha/', |
@@ -3031,8 +3031,7 @@ |
||
3031 | 3031 | <div class="roundframe"> |
3032 | 3032 | <div> |
3033 | 3033 | ', !empty($context['tfa_backup']) ? ' |
3034 | - <div class="smalltext error">' . $txt['tfa_backup_used_desc'] . '</div>' : |
|
3035 | - ($modSettings['tfa_mode'] == 2 ? ' |
|
3034 | + <div class="smalltext error">' . $txt['tfa_backup_used_desc'] . '</div>' : ($modSettings['tfa_mode'] == 2 ? ' |
|
3036 | 3035 | <div class="smalltext"><strong>' . $txt['tfa_forced_desc'] . '</strong></div>' : ''), ' |
3037 | 3036 | <div class="smalltext">', $txt['tfa_desc'], '</div> |
3038 | 3037 | <div id="basicinfo" style="width: 60%"> |
@@ -18,23 +18,25 @@ discard block |
||
18 | 18 | global $context; |
19 | 19 | |
20 | 20 | // Prevent Chrome from auto completing fields when viewing/editing other members profiles |
21 | - if (isBrowser('is_chrome') && !$context['user']['is_owner']) |
|
22 | - echo ' |
|
21 | + if (isBrowser('is_chrome') && !$context['user']['is_owner']) { |
|
22 | + echo ' |
|
23 | 23 | <script> |
24 | 24 | disableAutoComplete(); |
25 | 25 | </script>'; |
26 | + } |
|
26 | 27 | |
27 | 28 | // If an error occurred while trying to save previously, give the user a clue! |
28 | 29 | echo ' |
29 | 30 | ', template_error_message(); |
30 | 31 | |
31 | 32 | // If the profile was update successfully, let the user know this. |
32 | - if (!empty($context['profile_updated'])) |
|
33 | - echo ' |
|
33 | + if (!empty($context['profile_updated'])) { |
|
34 | + echo ' |
|
34 | 35 | <div class="infobox"> |
35 | 36 | ', $context['profile_updated'], ' |
36 | 37 | </div>'; |
37 | -} |
|
38 | + } |
|
39 | + } |
|
38 | 40 | |
39 | 41 | /** |
40 | 42 | * Template for any HTML needed below the profile (closing off divs/tables, etc.) |
@@ -102,8 +104,7 @@ discard block |
||
102 | 104 | if (empty($context['unread_alerts'])) |
103 | 105 | { |
104 | 106 | template_alerts_all_read(); |
105 | - } |
|
106 | - else |
|
107 | + } else |
|
107 | 108 | { |
108 | 109 | foreach ($context['unread_alerts'] as $id_alert => $details) |
109 | 110 | { |
@@ -164,10 +165,11 @@ discard block |
||
164 | 165 | <div class="custom_fields_above_name"> |
165 | 166 | <ul >'; |
166 | 167 | |
167 | - foreach ($context['print_custom_fields']['above_member'] as $field) |
|
168 | - if (!empty($field['output_html'])) |
|
168 | + foreach ($context['print_custom_fields']['above_member'] as $field) { |
|
169 | + if (!empty($field['output_html'])) |
|
169 | 170 | echo ' |
170 | 171 | <li>', $field['output_html'], '</li>'; |
172 | + } |
|
171 | 173 | |
172 | 174 | echo ' |
173 | 175 | </ul> |
@@ -188,10 +190,11 @@ discard block |
||
188 | 190 | <div class="custom_fields_below_avatar"> |
189 | 191 | <ul >'; |
190 | 192 | |
191 | - foreach ($context['print_custom_fields']['below_avatar'] as $field) |
|
192 | - if (!empty($field['output_html'])) |
|
193 | + foreach ($context['print_custom_fields']['below_avatar'] as $field) { |
|
194 | + if (!empty($field['output_html'])) |
|
193 | 195 | echo ' |
194 | 196 | <li>', $field['output_html'], '</li>'; |
197 | + } |
|
195 | 198 | |
196 | 199 | echo ' |
197 | 200 | </ul> |
@@ -202,22 +205,25 @@ discard block |
||
202 | 205 | echo ' |
203 | 206 | <ul class="clear">'; |
204 | 207 | // Email is only visible if it's your profile or you have the moderate_forum permission |
205 | - if ($context['member']['show_email']) |
|
206 | - echo ' |
|
208 | + if ($context['member']['show_email']) { |
|
209 | + echo ' |
|
207 | 210 | <li><a href="mailto:', $context['member']['email'], '" title="', $context['member']['email'], '" rel="nofollow"><span class="generic_icons mail" title="' . $txt['email'] . '"></span></a></li>'; |
211 | + } |
|
208 | 212 | |
209 | 213 | // Don't show an icon if they haven't specified a website. |
210 | - if ($context['member']['website']['url'] !== '' && !isset($context['disabled_fields']['website'])) |
|
211 | - echo ' |
|
214 | + if ($context['member']['website']['url'] !== '' && !isset($context['disabled_fields']['website'])) { |
|
215 | + echo ' |
|
212 | 216 | <li><a href="', $context['member']['website']['url'], '" title="' . $context['member']['website']['title'] . '" target="_blank" class="new_win">', ($settings['use_image_buttons'] ? '<span class="generic_icons www" title="' . $context['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>'; |
217 | + } |
|
213 | 218 | |
214 | 219 | // Are there any custom profile fields as icons? |
215 | 220 | if (!empty($context['print_custom_fields']['icons'])) |
216 | 221 | { |
217 | - foreach ($context['print_custom_fields']['icons'] as $field) |
|
218 | - if (!empty($field['output_html'])) |
|
222 | + foreach ($context['print_custom_fields']['icons'] as $field) { |
|
223 | + if (!empty($field['output_html'])) |
|
219 | 224 | echo ' |
220 | 225 | <li class="custom_field">', $field['output_html'], '</li>'; |
226 | + } |
|
221 | 227 | } |
222 | 228 | |
223 | 229 | echo ' |
@@ -225,23 +231,26 @@ discard block |
||
225 | 231 | <span id="userstatus">', $context['can_send_pm'] ? '<a href="' . $context['member']['online']['href'] . '" title="' . $context['member']['online']['text'] . '" rel="nofollow">' : '', $settings['use_image_buttons'] ? '<span class="' . ($context['member']['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $context['member']['online']['text'] . '"></span>' : $context['member']['online']['label'], $context['can_send_pm'] ? '</a>' : '', $settings['use_image_buttons'] ? '<span class="smalltext"> ' . $context['member']['online']['label'] . '</span>' : ''; |
226 | 232 | |
227 | 233 | // Can they add this member as a buddy? |
228 | - if (!empty($context['can_have_buddy']) && !$context['user']['is_owner']) |
|
229 | - echo ' |
|
234 | + if (!empty($context['can_have_buddy']) && !$context['user']['is_owner']) { |
|
235 | + echo ' |
|
230 | 236 | <br><a href="', $scripturl, '?action=buddy;u=', $context['id_member'], ';', $context['session_var'], '=', $context['session_id'], '">[', $txt['buddy_' . ($context['member']['is_buddy'] ? 'remove' : 'add')], ']</a>'; |
237 | + } |
|
231 | 238 | |
232 | 239 | echo ' |
233 | 240 | </span>'; |
234 | 241 | |
235 | - if (!$context['user']['is_owner'] && $context['can_send_pm']) |
|
236 | - echo ' |
|
242 | + if (!$context['user']['is_owner'] && $context['can_send_pm']) { |
|
243 | + echo ' |
|
237 | 244 | <a href="', $scripturl, '?action=pm;sa=send;u=', $context['id_member'], '" class="infolinks">', $txt['profile_sendpm_short'], '</a>'; |
245 | + } |
|
238 | 246 | |
239 | 247 | echo ' |
240 | 248 | <a href="', $scripturl, '?action=profile;area=showposts;u=', $context['id_member'], '" class="infolinks">', $txt['showPosts'], '</a>'; |
241 | 249 | |
242 | - if ($context['user']['is_owner'] && !empty($modSettings['drafts_post_enabled'])) |
|
243 | - echo ' |
|
250 | + if ($context['user']['is_owner'] && !empty($modSettings['drafts_post_enabled'])) { |
|
251 | + echo ' |
|
244 | 252 | <a href="', $scripturl, '?action=profile;area=showdrafts;u=', $context['id_member'], '" class="infolinks">', $txt['drafts_show'], '</a>'; |
253 | + } |
|
245 | 254 | |
246 | 255 | echo ' |
247 | 256 | <a href="', $scripturl, '?action=profile;area=statistics;u=', $context['id_member'], '" class="infolinks">', $txt['statPanel'], '</a>'; |
@@ -253,10 +262,11 @@ discard block |
||
253 | 262 | <div class="custom_fields_bottom"> |
254 | 263 | <ul class="nolist">'; |
255 | 264 | |
256 | - foreach ($context['print_custom_fields']['bottom_poster'] as $field) |
|
257 | - if (!empty($field['output_html'])) |
|
265 | + foreach ($context['print_custom_fields']['bottom_poster'] as $field) { |
|
266 | + if (!empty($field['output_html'])) |
|
258 | 267 | echo ' |
259 | 268 | <li>', $field['output_html'], '</li>'; |
269 | + } |
|
260 | 270 | |
261 | 271 | echo ' |
262 | 272 | </ul> |
@@ -270,15 +280,17 @@ discard block |
||
270 | 280 | <div id="detailedinfo"> |
271 | 281 | <dl class="settings">'; |
272 | 282 | |
273 | - if ($context['user']['is_owner'] || $context['user']['is_admin']) |
|
274 | - echo ' |
|
283 | + if ($context['user']['is_owner'] || $context['user']['is_admin']) { |
|
284 | + echo ' |
|
275 | 285 | <dt>', $txt['username'], ': </dt> |
276 | 286 | <dd>', $context['member']['username'], '</dd>'; |
287 | + } |
|
277 | 288 | |
278 | - if (!isset($context['disabled_fields']['posts'])) |
|
279 | - echo ' |
|
289 | + if (!isset($context['disabled_fields']['posts'])) { |
|
290 | + echo ' |
|
280 | 291 | <dt>', $txt['profile_posts'], ': </dt> |
281 | 292 | <dd>', $context['member']['posts'], ' (', $context['member']['posts_per_day'], ' ', $txt['posts_per_day'], ')</dd>'; |
293 | + } |
|
282 | 294 | |
283 | 295 | if ($context['member']['show_email']) |
284 | 296 | { |
@@ -287,15 +299,17 @@ discard block |
||
287 | 299 | <dd><a href="mailto:', $context['member']['email'], '">', $context['member']['email'], '</a></dd>'; |
288 | 300 | } |
289 | 301 | |
290 | - if (!empty($modSettings['titlesEnable']) && !empty($context['member']['title'])) |
|
291 | - echo ' |
|
302 | + if (!empty($modSettings['titlesEnable']) && !empty($context['member']['title'])) { |
|
303 | + echo ' |
|
292 | 304 | <dt>', $txt['custom_title'], ': </dt> |
293 | 305 | <dd>', $context['member']['title'], '</dd>'; |
306 | + } |
|
294 | 307 | |
295 | - if (!empty($context['member']['blurb'])) |
|
296 | - echo ' |
|
308 | + if (!empty($context['member']['blurb'])) { |
|
309 | + echo ' |
|
297 | 310 | <dt>', $txt['personal_text'], ': </dt> |
298 | 311 | <dd>', $context['member']['blurb'], '</dd>'; |
312 | + } |
|
299 | 313 | |
300 | 314 | echo ' |
301 | 315 | <dt>', $txt['age'], ':</dt> |
@@ -310,11 +324,12 @@ discard block |
||
310 | 324 | echo ' |
311 | 325 | <dl class="settings">'; |
312 | 326 | |
313 | - foreach ($context['print_custom_fields']['standard'] as $field) |
|
314 | - if (!empty($field['output_html'])) |
|
327 | + foreach ($context['print_custom_fields']['standard'] as $field) { |
|
328 | + if (!empty($field['output_html'])) |
|
315 | 329 | echo ' |
316 | 330 | <dt>', $field['name'], ':</dt> |
317 | 331 | <dd>', $field['output_html'], '</dd>'; |
332 | + } |
|
318 | 333 | |
319 | 334 | echo ' |
320 | 335 | </dl>'; |
@@ -332,9 +347,10 @@ discard block |
||
332 | 347 | <a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=', ($context['can_issue_warning'] && !$context['user']['is_owner'] ? 'issuewarning' : 'viewwarning'), '">', $context['member']['warning'], '%</a>'; |
333 | 348 | |
334 | 349 | // Can we provide information on what this means? |
335 | - if (!empty($context['warning_status'])) |
|
336 | - echo ' |
|
350 | + if (!empty($context['warning_status'])) { |
|
351 | + echo ' |
|
337 | 352 | <span class="smalltext">(', $context['warning_status'], ')</span>'; |
353 | + } |
|
338 | 354 | |
339 | 355 | echo ' |
340 | 356 | </dd>'; |
@@ -345,9 +361,10 @@ discard block |
||
345 | 361 | { |
346 | 362 | |
347 | 363 | // If the person looking at the summary has permission, and the account isn't activated, give the viewer the ability to do it themselves. |
348 | - if (!empty($context['activate_message'])) |
|
349 | - echo ' |
|
364 | + if (!empty($context['activate_message'])) { |
|
365 | + echo ' |
|
350 | 366 | <dt class="clear"><span class="alert">', $context['activate_message'], '</span> (<a href="', $context['activate_link'], '"', ($context['activate_type'] == 4 ? ' class="you_sure" data-confirm="' . $txt['profileConfirm'] . '"' : ''), '>', $context['activate_link_text'], '</a>)</dt>'; |
367 | + } |
|
351 | 368 | |
352 | 369 | // If the current member is banned, show a message and possibly a link to the ban. |
353 | 370 | if (!empty($context['member']['bans'])) |
@@ -357,9 +374,10 @@ discard block |
||
357 | 374 | <dt class="clear" id="ban_info" style="display: none;"> |
358 | 375 | <strong>', $txt['user_banned_by_following'], ':</strong>'; |
359 | 376 | |
360 | - foreach ($context['member']['bans'] as $ban) |
|
361 | - echo ' |
|
377 | + foreach ($context['member']['bans'] as $ban) { |
|
378 | + echo ' |
|
362 | 379 | <br><span class="smalltext">', $ban['explanation'], '</span>'; |
380 | + } |
|
363 | 381 | |
364 | 382 | echo ' |
365 | 383 | </dt>'; |
@@ -373,30 +391,34 @@ discard block |
||
373 | 391 | // If the person looking is allowed, they can check the members IP address and hostname. |
374 | 392 | if ($context['can_see_ip']) |
375 | 393 | { |
376 | - if (!empty($context['member']['ip'])) |
|
377 | - echo ' |
|
394 | + if (!empty($context['member']['ip'])) { |
|
395 | + echo ' |
|
378 | 396 | <dt>', $txt['ip'], ': </dt> |
379 | 397 | <dd><a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['member']['ip'], ';u=', $context['member']['id'], '">', $context['member']['ip'], '</a></dd>'; |
398 | + } |
|
380 | 399 | |
381 | - if (empty($modSettings['disableHostnameLookup']) && !empty($context['member']['ip'])) |
|
382 | - echo ' |
|
400 | + if (empty($modSettings['disableHostnameLookup']) && !empty($context['member']['ip'])) { |
|
401 | + echo ' |
|
383 | 402 | <dt>', $txt['hostname'], ': </dt> |
384 | 403 | <dd>', $context['member']['hostname'], '</dd>'; |
404 | + } |
|
385 | 405 | } |
386 | 406 | |
387 | 407 | echo ' |
388 | 408 | <dt>', $txt['local_time'], ':</dt> |
389 | 409 | <dd>', $context['member']['local_time'], '</dd>'; |
390 | 410 | |
391 | - if (!empty($modSettings['userLanguage']) && !empty($context['member']['language'])) |
|
392 | - echo ' |
|
411 | + if (!empty($modSettings['userLanguage']) && !empty($context['member']['language'])) { |
|
412 | + echo ' |
|
393 | 413 | <dt>', $txt['language'], ':</dt> |
394 | 414 | <dd>', $context['member']['language'], '</dd>'; |
415 | + } |
|
395 | 416 | |
396 | - if ($context['member']['show_last_login']) |
|
397 | - echo ' |
|
417 | + if ($context['member']['show_last_login']) { |
|
418 | + echo ' |
|
398 | 419 | <dt>', $txt['lastLoggedIn'], ': </dt> |
399 | 420 | <dd>', $context['member']['last_login'], (!empty($context['member']['is_hidden']) ? ' (' . $txt['hidden'] . ')' : ''), '</dd>'; |
421 | + } |
|
400 | 422 | |
401 | 423 | echo ' |
402 | 424 | </dl>'; |
@@ -408,10 +430,11 @@ discard block |
||
408 | 430 | <div class="custom_fields_above_signature"> |
409 | 431 | <ul class="nolist">'; |
410 | 432 | |
411 | - foreach ($context['print_custom_fields']['above_signature'] as $field) |
|
412 | - if (!empty($field['output_html'])) |
|
433 | + foreach ($context['print_custom_fields']['above_signature'] as $field) { |
|
434 | + if (!empty($field['output_html'])) |
|
413 | 435 | echo ' |
414 | 436 | <li>', $field['output_html'], '</li>'; |
437 | + } |
|
415 | 438 | |
416 | 439 | echo ' |
417 | 440 | </ul> |
@@ -419,12 +442,13 @@ discard block |
||
419 | 442 | } |
420 | 443 | |
421 | 444 | // Show the users signature. |
422 | - if ($context['signature_enabled'] && !empty($context['member']['signature'])) |
|
423 | - echo ' |
|
445 | + if ($context['signature_enabled'] && !empty($context['member']['signature'])) { |
|
446 | + echo ' |
|
424 | 447 | <div class="signature"> |
425 | 448 | <h5>', $txt['signature'], ':</h5> |
426 | 449 | ', $context['member']['signature'], ' |
427 | 450 | </div>'; |
451 | + } |
|
428 | 452 | |
429 | 453 | // Are there any custom profile fields for below the signature? |
430 | 454 | if (!empty($context['print_custom_fields']['below_signature'])) |
@@ -433,10 +457,11 @@ discard block |
||
433 | 457 | <div class="custom_fields_below_signature"> |
434 | 458 | <ul class="nolist">'; |
435 | 459 | |
436 | - foreach ($context['print_custom_fields']['below_signature'] as $field) |
|
437 | - if (!empty($field['output_html'])) |
|
460 | + foreach ($context['print_custom_fields']['below_signature'] as $field) { |
|
461 | + if (!empty($field['output_html'])) |
|
438 | 462 | echo ' |
439 | 463 | <li>', $field['output_html'], '</li>'; |
464 | + } |
|
440 | 465 | |
441 | 466 | echo ' |
442 | 467 | </ul> |
@@ -481,62 +506,70 @@ discard block |
||
481 | 506 | </div> |
482 | 507 | <div class="list_posts">'; |
483 | 508 | |
484 | - if (!$post['approved']) |
|
485 | - echo ' |
|
509 | + if (!$post['approved']) { |
|
510 | + echo ' |
|
486 | 511 | <div class="approve_post"> |
487 | 512 | <em>', $txt['post_awaiting_approval'], '</em> |
488 | 513 | </div>'; |
514 | + } |
|
489 | 515 | |
490 | 516 | echo ' |
491 | 517 | ', $post['body'], ' |
492 | 518 | </div>'; |
493 | 519 | |
494 | - if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) |
|
495 | - echo ' |
|
520 | + if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) { |
|
521 | + echo ' |
|
496 | 522 | <div class="floatright"> |
497 | 523 | <ul class="quickbuttons">'; |
524 | + } |
|
498 | 525 | |
499 | 526 | // If they *can* reply? |
500 | - if ($post['can_reply']) |
|
501 | - echo ' |
|
527 | + if ($post['can_reply']) { |
|
528 | + echo ' |
|
502 | 529 | <li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li>'; |
530 | + } |
|
503 | 531 | |
504 | 532 | // If they *can* quote? |
505 | - if ($post['can_quote']) |
|
506 | - echo ' |
|
533 | + if ($post['can_quote']) { |
|
534 | + echo ' |
|
507 | 535 | <li><a href="', $scripturl . '?action=post;topic=', $post['topic'], '.', $post['start'], ';quote=', $post['id'], '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>'; |
536 | + } |
|
508 | 537 | |
509 | 538 | // How about... even... remove it entirely?! |
510 | - if ($post['can_delete']) |
|
511 | - echo ' |
|
539 | + if ($post['can_delete']) { |
|
540 | + echo ' |
|
512 | 541 | <li><a href="', $scripturl, '?action=deletemsg;msg=', $post['id'], ';topic=', $post['topic'], ';profile;u=', $context['member']['id'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>'; |
542 | + } |
|
513 | 543 | |
514 | - if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) |
|
515 | - echo ' |
|
544 | + if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) { |
|
545 | + echo ' |
|
516 | 546 | </ul> |
517 | 547 | </div>'; |
548 | + } |
|
518 | 549 | |
519 | 550 | echo ' |
520 | 551 | </div>'; |
521 | 552 | } |
553 | + } else { |
|
554 | + template_show_list('attachments'); |
|
522 | 555 | } |
523 | - else |
|
524 | - template_show_list('attachments'); |
|
525 | 556 | |
526 | 557 | // No posts? Just end with a informative message. |
527 | - if ((isset($context['attachments']) && empty($context['attachments'])) || (!isset($context['attachments']) && empty($context['posts']))) |
|
528 | - echo ' |
|
558 | + if ((isset($context['attachments']) && empty($context['attachments'])) || (!isset($context['attachments']) && empty($context['posts']))) { |
|
559 | + echo ' |
|
529 | 560 | <div class="windowbg2"> |
530 | 561 | ', isset($context['attachments']) ? $txt['show_attachments_none'] : ($context['is_topics'] ? $txt['show_topics_none'] : $txt['show_posts_none']), ' |
531 | 562 | </div>'; |
563 | + } |
|
532 | 564 | |
533 | 565 | // Show more page numbers. |
534 | - if (!empty($context['page_index'])) |
|
535 | - echo ' |
|
566 | + if (!empty($context['page_index'])) { |
|
567 | + echo ' |
|
536 | 568 | <div class="pagesection"> |
537 | 569 | <div class="pagelinks">', $context['page_index'], '</div> |
538 | 570 | </div>'; |
539 | -} |
|
571 | + } |
|
572 | + } |
|
540 | 573 | |
541 | 574 | /** |
542 | 575 | * Template for showing alerts within the alerts popup |
@@ -546,11 +579,12 @@ discard block |
||
546 | 579 | global $context, $txt, $scripturl; |
547 | 580 | |
548 | 581 | // Do we have an update message? |
549 | - if (!empty($context['update_message'])) |
|
550 | - echo ' |
|
582 | + if (!empty($context['update_message'])) { |
|
583 | + echo ' |
|
551 | 584 | <div class="infobox"> |
552 | 585 | ', $context['update_message'], '. |
553 | 586 | </div>'; |
587 | + } |
|
554 | 588 | |
555 | 589 | echo ' |
556 | 590 | <div class="cat_bar"> |
@@ -559,13 +593,12 @@ discard block |
||
559 | 593 | </h3> |
560 | 594 | </div>'; |
561 | 595 | |
562 | - if (empty($context['alerts'])) |
|
563 | - echo ' |
|
596 | + if (empty($context['alerts'])) { |
|
597 | + echo ' |
|
564 | 598 | <div class="information"> |
565 | 599 | ', $txt['alerts_none'], ' |
566 | 600 | </div>'; |
567 | - |
|
568 | - else |
|
601 | + } else |
|
569 | 602 | { |
570 | 603 | // Start the form. |
571 | 604 | echo ' |
@@ -627,12 +660,12 @@ discard block |
||
627 | 660 | </div>' : ''; |
628 | 661 | |
629 | 662 | // No drafts? Just show an informative message. |
630 | - if (empty($context['drafts'])) |
|
631 | - echo ' |
|
663 | + if (empty($context['drafts'])) { |
|
664 | + echo ' |
|
632 | 665 | <div class="windowbg2 centertext"> |
633 | 666 | ', $txt['draft_none'], ' |
634 | 667 | </div>'; |
635 | - else |
|
668 | + } else |
|
636 | 669 | { |
637 | 670 | // For every draft to be displayed, give it its own div, and show the important details of the draft. |
638 | 671 | foreach ($context['drafts'] as $draft) |
@@ -643,11 +676,13 @@ discard block |
||
643 | 676 | <div class="topic_details"> |
644 | 677 | <h5><strong><a href="', $scripturl, '?board=', $draft['board']['id'], '.0">', $draft['board']['name'], '</a> / ', $draft['topic']['link'], '</strong> '; |
645 | 678 | |
646 | - if (!empty($draft['sticky'])) |
|
647 | - echo '<span class="generic_icons sticky" title="', $txt['sticky_topic'], '"></span>'; |
|
679 | + if (!empty($draft['sticky'])) { |
|
680 | + echo '<span class="generic_icons sticky" title="', $txt['sticky_topic'], '"></span>'; |
|
681 | + } |
|
648 | 682 | |
649 | - if (!empty($draft['locked'])) |
|
650 | - echo '<span class="generic_icons lock" title="', $txt['locked_topic'], '"></span>'; |
|
683 | + if (!empty($draft['locked'])) { |
|
684 | + echo '<span class="generic_icons lock" title="', $txt['locked_topic'], '"></span>'; |
|
685 | + } |
|
651 | 686 | |
652 | 687 | echo ' |
653 | 688 | </h5> |
@@ -680,12 +715,13 @@ discard block |
||
680 | 715 | { |
681 | 716 | global $context, $scripturl, $txt; |
682 | 717 | |
683 | - if (!empty($context['saved_successful'])) |
|
684 | - echo ' |
|
718 | + if (!empty($context['saved_successful'])) { |
|
719 | + echo ' |
|
685 | 720 | <div class="infobox">', $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $context['member']['name']), '</div>'; |
686 | - elseif (!empty($context['saved_failed'])) |
|
687 | - echo ' |
|
721 | + } elseif (!empty($context['saved_failed'])) { |
|
722 | + echo ' |
|
688 | 723 | <div class="errorbox">', $context['saved_failed'], '</div>'; |
724 | + } |
|
689 | 725 | |
690 | 726 | echo ' |
691 | 727 | <div id="edit_buddies"> |
@@ -699,24 +735,27 @@ discard block |
||
699 | 735 | <th scope="col" class="quarter_table">', $txt['name'], '</th> |
700 | 736 | <th scope="col">', $txt['status'], '</th>'; |
701 | 737 | |
702 | - if (allowedTo('moderate_forum')) |
|
703 | - echo ' |
|
738 | + if (allowedTo('moderate_forum')) { |
|
739 | + echo ' |
|
704 | 740 | <th scope="col">', $txt['email'], '</th>'; |
741 | + } |
|
705 | 742 | |
706 | - if (!empty($context['custom_pf'])) |
|
707 | - foreach ($context['custom_pf'] as $column) |
|
743 | + if (!empty($context['custom_pf'])) { |
|
744 | + foreach ($context['custom_pf'] as $column) |
|
708 | 745 | echo '<th scope="col">', $column['label'], '</th>'; |
746 | + } |
|
709 | 747 | |
710 | 748 | echo ' |
711 | 749 | <th scope="col">', $txt['remove'], '</th> |
712 | 750 | </tr>'; |
713 | 751 | |
714 | 752 | // If they don't have any buddies don't list them! |
715 | - if (empty($context['buddies'])) |
|
716 | - echo ' |
|
753 | + if (empty($context['buddies'])) { |
|
754 | + echo ' |
|
717 | 755 | <tr class="windowbg"> |
718 | 756 | <td colspan="', allowedTo('moderate_forum') ? '10' : '9', '"><strong>', $txt['no_buddies'], '</strong></td> |
719 | 757 | </tr>'; |
758 | + } |
|
720 | 759 | |
721 | 760 | // Now loop through each buddy showing info on each. |
722 | 761 | else |
@@ -728,15 +767,17 @@ discard block |
||
728 | 767 | <td>', $buddy['link'], '</td> |
729 | 768 | <td><a href="', $buddy['online']['href'], '"><span class="' . ($buddy['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $buddy['online']['text'] . '"></span></a></td>'; |
730 | 769 | |
731 | - if ($buddy['show_email']) |
|
732 | - echo ' |
|
770 | + if ($buddy['show_email']) { |
|
771 | + echo ' |
|
733 | 772 | <td><a href="mailto:' . $buddy['email'] . '" rel="nofollow"><span class="generic_icons mail icon" title="' . $txt['email'] . ' ' . $buddy['name'] . '"></span></a></td>'; |
773 | + } |
|
734 | 774 | |
735 | 775 | // Show the custom profile fields for this user. |
736 | - if (!empty($context['custom_pf'])) |
|
737 | - foreach ($context['custom_pf'] as $key => $column) |
|
776 | + if (!empty($context['custom_pf'])) { |
|
777 | + foreach ($context['custom_pf'] as $key => $column) |
|
738 | 778 | echo ' |
739 | 779 | <td class="lefttext">', $buddy['options'][$key], '</td>'; |
780 | + } |
|
740 | 781 | |
741 | 782 | echo ' |
742 | 783 | <td><a href="', $scripturl, '?action=profile;area=lists;sa=buddies;u=', $context['id_member'], ';remove=', $buddy['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons delete" title="', $txt['buddy_remove'], '"></span></a></td> |
@@ -766,9 +807,10 @@ discard block |
||
766 | 807 | </dl> |
767 | 808 | </div>'; |
768 | 809 | |
769 | - if (!empty($context['token_check'])) |
|
770 | - echo ' |
|
810 | + if (!empty($context['token_check'])) { |
|
811 | + echo ' |
|
771 | 812 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
813 | + } |
|
772 | 814 | |
773 | 815 | echo ' |
774 | 816 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -794,12 +836,13 @@ discard block |
||
794 | 836 | { |
795 | 837 | global $context, $scripturl, $txt; |
796 | 838 | |
797 | - if (!empty($context['saved_successful'])) |
|
798 | - echo ' |
|
839 | + if (!empty($context['saved_successful'])) { |
|
840 | + echo ' |
|
799 | 841 | <div class="infobox">', $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $context['member']['name']), '</div>'; |
800 | - elseif (!empty($context['saved_failed'])) |
|
801 | - echo ' |
|
842 | + } elseif (!empty($context['saved_failed'])) { |
|
843 | + echo ' |
|
802 | 844 | <div class="errorbox">', $context['saved_failed'], '</div>'; |
845 | + } |
|
803 | 846 | |
804 | 847 | echo ' |
805 | 848 | <div id="edit_buddies"> |
@@ -813,20 +856,22 @@ discard block |
||
813 | 856 | <th scope="col" class="quarter_table">', $txt['name'], '</th> |
814 | 857 | <th scope="col">', $txt['status'], '</th>'; |
815 | 858 | |
816 | - if (allowedTo('moderate_forum')) |
|
817 | - echo ' |
|
859 | + if (allowedTo('moderate_forum')) { |
|
860 | + echo ' |
|
818 | 861 | <th scope="col">', $txt['email'], '</th>'; |
862 | + } |
|
819 | 863 | |
820 | 864 | echo ' |
821 | 865 | <th scope="col">', $txt['ignore_remove'], '</th> |
822 | 866 | </tr>'; |
823 | 867 | |
824 | 868 | // If they don't have anyone on their ignore list, don't list it! |
825 | - if (empty($context['ignore_list'])) |
|
826 | - echo ' |
|
869 | + if (empty($context['ignore_list'])) { |
|
870 | + echo ' |
|
827 | 871 | <tr class="windowbg"> |
828 | 872 | <td colspan="', allowedTo('moderate_forum') ? '4' : '3', '"><strong>', $txt['no_ignore'], '</strong></td> |
829 | 873 | </tr>'; |
874 | + } |
|
830 | 875 | |
831 | 876 | // Now loop through each buddy showing info on each. |
832 | 877 | foreach ($context['ignore_list'] as $member) |
@@ -836,9 +881,10 @@ discard block |
||
836 | 881 | <td>', $member['link'], '</td> |
837 | 882 | <td><a href="', $member['online']['href'], '"><span class="' . ($member['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $member['online']['text'] . '"></span></a></td>'; |
838 | 883 | |
839 | - if ($member['show_email']) |
|
840 | - echo ' |
|
884 | + if ($member['show_email']) { |
|
885 | + echo ' |
|
841 | 886 | <td><a href="mailto:' . $member['email'] . '" rel="nofollow"><span class="generic_icons mail icon" title="' . $txt['email'] . ' ' . $member['name'] . '"></span></a></td>'; |
887 | + } |
|
842 | 888 | echo ' |
843 | 889 | <td><a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=lists;sa=ignore;remove=', $member['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons delete" title="', $txt['ignore_remove'], '"></span></a></td> |
844 | 890 | </tr>'; |
@@ -865,9 +911,10 @@ discard block |
||
865 | 911 | </dl> |
866 | 912 | </div>'; |
867 | 913 | |
868 | - if (!empty($context['token_check'])) |
|
869 | - echo ' |
|
914 | + if (!empty($context['token_check'])) { |
|
915 | + echo ' |
|
870 | 916 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
917 | + } |
|
871 | 918 | |
872 | 919 | echo ' |
873 | 920 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -912,9 +959,10 @@ discard block |
||
912 | 959 | <a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['last_ip'], ';u=', $context['member']['id'], '">', $context['last_ip'], '</a>'; |
913 | 960 | |
914 | 961 | // Second address detected? |
915 | - if (!empty($context['last_ip2'])) |
|
916 | - echo ' |
|
962 | + if (!empty($context['last_ip2'])) { |
|
963 | + echo ' |
|
917 | 964 | , <a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['last_ip2'], ';u=', $context['member']['id'], '">', $context['last_ip2'], '</a>'; |
965 | + } |
|
918 | 966 | |
919 | 967 | echo ' |
920 | 968 | </dd>'; |
@@ -979,9 +1027,10 @@ discard block |
||
979 | 1027 | <h3 class="catbg">', $txt['whois_title'], ' ', $context['ip'], '</h3> |
980 | 1028 | </div> |
981 | 1029 | <div class="windowbg2 noup">'; |
982 | - foreach ($context['whois_servers'] as $server) |
|
983 | - echo ' |
|
1030 | + foreach ($context['whois_servers'] as $server) { |
|
1031 | + echo ' |
|
984 | 1032 | <a href="', $server['url'], '" target="_blank" class="new_win"', isset($context['auto_whois_server']) && $context['auto_whois_server']['name'] == $server['name'] ? ' style="font-weight: bold;"' : '', '>', $server['name'], '</a><br>'; |
1033 | + } |
|
985 | 1034 | echo ' |
986 | 1035 | </div> |
987 | 1036 | <br>'; |
@@ -992,10 +1041,10 @@ discard block |
||
992 | 1041 | <div class="cat_bar"> |
993 | 1042 | <h3 class="catbg">', $txt['members_from_ip'], ' ', $context['ip'], '</h3> |
994 | 1043 | </div>'; |
995 | - if (empty($context['ips'])) |
|
996 | - echo ' |
|
1044 | + if (empty($context['ips'])) { |
|
1045 | + echo ' |
|
997 | 1046 | <p class="windowbg2 description"><em>', $txt['no_members_from_ip'], '</em></p>'; |
998 | - else |
|
1047 | + } else |
|
999 | 1048 | { |
1000 | 1049 | echo ' |
1001 | 1050 | <table class="table_grid"> |
@@ -1008,12 +1057,13 @@ discard block |
||
1008 | 1057 | <tbody>'; |
1009 | 1058 | |
1010 | 1059 | // Loop through each of the members and display them. |
1011 | - foreach ($context['ips'] as $ip => $memberlist) |
|
1012 | - echo ' |
|
1060 | + foreach ($context['ips'] as $ip => $memberlist) { |
|
1061 | + echo ' |
|
1013 | 1062 | <tr class="windowbg"> |
1014 | 1063 | <td><a href="', $context['base_url'], ';searchip=', $ip, '">', $ip, '</a></td> |
1015 | 1064 | <td>', implode(', ', $memberlist), '</td> |
1016 | 1065 | </tr>'; |
1066 | + } |
|
1017 | 1067 | |
1018 | 1068 | echo ' |
1019 | 1069 | </tbody> |
@@ -1059,8 +1109,7 @@ discard block |
||
1059 | 1109 | { |
1060 | 1110 | echo ' |
1061 | 1111 | <div class="information">', $txt['showPermissions_all'], '</div>'; |
1062 | - } |
|
1063 | - else |
|
1112 | + } else |
|
1064 | 1113 | { |
1065 | 1114 | echo ' |
1066 | 1115 | <div class="information">',$txt['showPermissions_help'], '</div> |
@@ -1074,9 +1123,10 @@ discard block |
||
1074 | 1123 | </div> |
1075 | 1124 | <div class="windowbg smalltext"> |
1076 | 1125 | ', $txt['showPermissions_restricted_boards_desc'], ':<br>'; |
1077 | - foreach ($context['no_access_boards'] as $no_access_board) |
|
1078 | - echo ' |
|
1126 | + foreach ($context['no_access_boards'] as $no_access_board) { |
|
1127 | + echo ' |
|
1079 | 1128 | <a href="', $scripturl, '?board=', $no_access_board['id'], '.0">', $no_access_board['name'], '</a>', $no_access_board['is_last'] ? '' : ', '; |
1129 | + } |
|
1080 | 1130 | echo ' |
1081 | 1131 | </div>'; |
1082 | 1132 | } |
@@ -1108,12 +1158,13 @@ discard block |
||
1108 | 1158 | </td> |
1109 | 1159 | <td class="smalltext">'; |
1110 | 1160 | |
1111 | - if ($permission['is_denied']) |
|
1112 | - echo ' |
|
1161 | + if ($permission['is_denied']) { |
|
1162 | + echo ' |
|
1113 | 1163 | <span class="alert">', $txt['showPermissions_denied'], ': ', implode(', ', $permission['groups']['denied']), '</span>'; |
1114 | - else |
|
1115 | - echo ' |
|
1164 | + } else { |
|
1165 | + echo ' |
|
1116 | 1166 | ', $txt['showPermissions_given'], ': ', implode(', ', $permission['groups']['allowed']); |
1167 | + } |
|
1117 | 1168 | |
1118 | 1169 | echo ' |
1119 | 1170 | </td> |
@@ -1123,10 +1174,10 @@ discard block |
||
1123 | 1174 | </tbody> |
1124 | 1175 | </table> |
1125 | 1176 | </div><br>'; |
1126 | - } |
|
1127 | - else |
|
1128 | - echo ' |
|
1177 | + } else { |
|
1178 | + echo ' |
|
1129 | 1179 | <p class="windowbg2">', $txt['showPermissions_none_general'], '</p>'; |
1180 | + } |
|
1130 | 1181 | |
1131 | 1182 | // Board permission section. |
1132 | 1183 | echo ' |
@@ -1136,14 +1187,16 @@ discard block |
||
1136 | 1187 | <a id="board_permissions"></a>', $txt['showPermissions_select'], ': |
1137 | 1188 | <select name="board" onchange="if (this.options[this.selectedIndex].value) this.form.submit();"> |
1138 | 1189 | <option value="0"', $context['board'] == 0 ? ' selected' : '', '>', $txt['showPermissions_global'], ' </option>'; |
1139 | - if (!empty($context['boards'])) |
|
1140 | - echo ' |
|
1190 | + if (!empty($context['boards'])) { |
|
1191 | + echo ' |
|
1141 | 1192 | <option value="" disabled>---------------------------</option>'; |
1193 | + } |
|
1142 | 1194 | |
1143 | 1195 | // Fill the box with any local permission boards. |
1144 | - foreach ($context['boards'] as $board) |
|
1145 | - echo ' |
|
1196 | + foreach ($context['boards'] as $board) { |
|
1197 | + echo ' |
|
1146 | 1198 | <option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['name'], ' (', $board['profile_name'], ')</option>'; |
1199 | + } |
|
1147 | 1200 | |
1148 | 1201 | echo ' |
1149 | 1202 | </select> |
@@ -1174,8 +1227,7 @@ discard block |
||
1174 | 1227 | { |
1175 | 1228 | echo ' |
1176 | 1229 | <span class="alert">', $txt['showPermissions_denied'], ': ', implode(', ', $permission['groups']['denied']), '</span>'; |
1177 | - } |
|
1178 | - else |
|
1230 | + } else |
|
1179 | 1231 | { |
1180 | 1232 | echo ' |
1181 | 1233 | ', $txt['showPermissions_given'], ': ', implode(', ', $permission['groups']['allowed']); |
@@ -1187,10 +1239,10 @@ discard block |
||
1187 | 1239 | echo ' |
1188 | 1240 | </tbody> |
1189 | 1241 | </table>'; |
1190 | - } |
|
1191 | - else |
|
1192 | - echo ' |
|
1242 | + } else { |
|
1243 | + echo ' |
|
1193 | 1244 | <p class="windowbg2">', $txt['showPermissions_none_board'], '</p>'; |
1245 | + } |
|
1194 | 1246 | echo ' |
1195 | 1247 | </div> |
1196 | 1248 | </div>'; |
@@ -1232,9 +1284,10 @@ discard block |
||
1232 | 1284 | </div>'; |
1233 | 1285 | |
1234 | 1286 | // If they haven't post at all, don't draw the graph. |
1235 | - if (empty($context['posts_by_time'])) |
|
1236 | - echo ' |
|
1287 | + if (empty($context['posts_by_time'])) { |
|
1288 | + echo ' |
|
1237 | 1289 | <p class="centertext padding">', $txt['statPanel_noPosts'], '</p>'; |
1290 | + } |
|
1238 | 1291 | // Otherwise do! |
1239 | 1292 | else |
1240 | 1293 | { |
@@ -1273,11 +1326,10 @@ discard block |
||
1273 | 1326 | </h3> |
1274 | 1327 | </div>'; |
1275 | 1328 | |
1276 | - if (empty($context['popular_boards'])) |
|
1277 | - echo ' |
|
1329 | + if (empty($context['popular_boards'])) { |
|
1330 | + echo ' |
|
1278 | 1331 | <p class="centertext padding">', $txt['statPanel_noPosts'], '</p>'; |
1279 | - |
|
1280 | - else |
|
1332 | + } else |
|
1281 | 1333 | { |
1282 | 1334 | echo ' |
1283 | 1335 | <dl class="stats">'; |
@@ -1308,10 +1360,10 @@ discard block |
||
1308 | 1360 | </h3> |
1309 | 1361 | </div>'; |
1310 | 1362 | |
1311 | - if (empty($context['board_activity'])) |
|
1312 | - echo ' |
|
1363 | + if (empty($context['board_activity'])) { |
|
1364 | + echo ' |
|
1313 | 1365 | <p class="centertext padding">', $txt['statPanel_noPosts'], '</p>'; |
1314 | - else |
|
1366 | + } else |
|
1315 | 1367 | { |
1316 | 1368 | echo ' |
1317 | 1369 | <dl class="stats">'; |
@@ -1359,41 +1411,46 @@ discard block |
||
1359 | 1411 | <h3 class="catbg profile_hd">'; |
1360 | 1412 | |
1361 | 1413 | // Don't say "Profile" if this isn't the profile... |
1362 | - if (!empty($context['profile_header_text'])) |
|
1363 | - echo ' |
|
1414 | + if (!empty($context['profile_header_text'])) { |
|
1415 | + echo ' |
|
1364 | 1416 | ', $context['profile_header_text']; |
1365 | - else |
|
1366 | - echo ' |
|
1417 | + } else { |
|
1418 | + echo ' |
|
1367 | 1419 | ', $txt['profile']; |
1420 | + } |
|
1368 | 1421 | |
1369 | 1422 | echo ' |
1370 | 1423 | </h3> |
1371 | 1424 | </div>'; |
1372 | 1425 | |
1373 | 1426 | // Have we some description? |
1374 | - if ($context['page_desc']) |
|
1375 | - echo ' |
|
1427 | + if ($context['page_desc']) { |
|
1428 | + echo ' |
|
1376 | 1429 | <p class="information">', $context['page_desc'], '</p>'; |
1430 | + } |
|
1377 | 1431 | |
1378 | 1432 | echo ' |
1379 | 1433 | <div class="roundframe">'; |
1380 | 1434 | |
1381 | 1435 | // Any bits at the start? |
1382 | - if (!empty($context['profile_prehtml'])) |
|
1383 | - echo ' |
|
1436 | + if (!empty($context['profile_prehtml'])) { |
|
1437 | + echo ' |
|
1384 | 1438 | <div>', $context['profile_prehtml'], '</div>'; |
1439 | + } |
|
1385 | 1440 | |
1386 | - if (!empty($context['profile_fields'])) |
|
1387 | - echo ' |
|
1441 | + if (!empty($context['profile_fields'])) { |
|
1442 | + echo ' |
|
1388 | 1443 | <dl class="settings">'; |
1444 | + } |
|
1389 | 1445 | |
1390 | 1446 | // Start the big old loop 'of love. |
1391 | 1447 | $lastItem = 'hr'; |
1392 | 1448 | foreach ($context['profile_fields'] as $key => $field) |
1393 | 1449 | { |
1394 | 1450 | // We add a little hack to be sure we never get more than one hr in a row! |
1395 | - if ($lastItem == 'hr' && $field['type'] == 'hr') |
|
1396 | - continue; |
|
1451 | + if ($lastItem == 'hr' && $field['type'] == 'hr') { |
|
1452 | + continue; |
|
1453 | + } |
|
1397 | 1454 | |
1398 | 1455 | $lastItem = $field['type']; |
1399 | 1456 | if ($field['type'] == 'hr') |
@@ -1402,48 +1459,50 @@ discard block |
||
1402 | 1459 | </dl> |
1403 | 1460 | <hr> |
1404 | 1461 | <dl class="settings">'; |
1405 | - } |
|
1406 | - elseif ($field['type'] == 'callback') |
|
1462 | + } elseif ($field['type'] == 'callback') |
|
1407 | 1463 | { |
1408 | 1464 | if (isset($field['callback_func']) && function_exists('template_profile_' . $field['callback_func'])) |
1409 | 1465 | { |
1410 | 1466 | $callback_func = 'template_profile_' . $field['callback_func']; |
1411 | 1467 | $callback_func(); |
1412 | 1468 | } |
1413 | - } |
|
1414 | - else |
|
1469 | + } else |
|
1415 | 1470 | { |
1416 | 1471 | echo ' |
1417 | 1472 | <dt> |
1418 | 1473 | <strong', !empty($field['is_error']) ? ' class="error"' : '', '>', $field['type'] !== 'label' ? '<label for="' . $key . '">' : '', $field['label'], $field['type'] !== 'label' ? '</label>' : '', '</strong>'; |
1419 | 1474 | |
1420 | 1475 | // Does it have any subtext to show? |
1421 | - if (!empty($field['subtext'])) |
|
1422 | - echo ' |
|
1476 | + if (!empty($field['subtext'])) { |
|
1477 | + echo ' |
|
1423 | 1478 | <br> |
1424 | 1479 | <span class="smalltext">', $field['subtext'], '</span>'; |
1480 | + } |
|
1425 | 1481 | |
1426 | 1482 | echo ' |
1427 | 1483 | </dt> |
1428 | 1484 | <dd>'; |
1429 | 1485 | |
1430 | 1486 | // Want to put something infront of the box? |
1431 | - if (!empty($field['preinput'])) |
|
1432 | - echo ' |
|
1487 | + if (!empty($field['preinput'])) { |
|
1488 | + echo ' |
|
1433 | 1489 | ', $field['preinput']; |
1490 | + } |
|
1434 | 1491 | |
1435 | 1492 | // What type of data are we showing? |
1436 | - if ($field['type'] == 'label') |
|
1437 | - echo ' |
|
1493 | + if ($field['type'] == 'label') { |
|
1494 | + echo ' |
|
1438 | 1495 | ', $field['value']; |
1496 | + } |
|
1439 | 1497 | |
1440 | 1498 | // Maybe it's a text box - very likely! |
1441 | 1499 | elseif (in_array($field['type'], array('int', 'float', 'text', 'password', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'number', 'time', 'url'))) |
1442 | 1500 | { |
1443 | - if ($field['type'] == 'int' || $field['type'] == 'float') |
|
1444 | - $type = 'number'; |
|
1445 | - else |
|
1446 | - $type = $field['type']; |
|
1501 | + if ($field['type'] == 'int' || $field['type'] == 'float') { |
|
1502 | + $type = 'number'; |
|
1503 | + } else { |
|
1504 | + $type = $field['type']; |
|
1505 | + } |
|
1447 | 1506 | $step = $field['type'] == 'float' ? ' step="0.1"' : ''; |
1448 | 1507 | |
1449 | 1508 | |
@@ -1451,9 +1510,10 @@ discard block |
||
1451 | 1510 | <input type="', $type, '" name="', $key, '" id="', $key, '" size="', empty($field['size']) ? 30 : $field['size'], '" value="', $field['value'], '" ', $field['input_attr'], ' class="input_', $field['type'] == 'password' ? 'password' : 'text', '"', $step, '>'; |
1452 | 1511 | } |
1453 | 1512 | // You "checking" me out? ;) |
1454 | - elseif ($field['type'] == 'check') |
|
1455 | - echo ' |
|
1513 | + elseif ($field['type'] == 'check') { |
|
1514 | + echo ' |
|
1456 | 1515 | <input type="hidden" name="', $key, '" value="0"><input type="checkbox" name="', $key, '" id="', $key, '"', !empty($field['value']) ? ' checked' : '', ' value="1" class="input_check" ', $field['input_attr'], '>'; |
1516 | + } |
|
1457 | 1517 | |
1458 | 1518 | // Always fun - select boxes! |
1459 | 1519 | elseif ($field['type'] == 'select') |
@@ -1464,13 +1524,15 @@ discard block |
||
1464 | 1524 | if (isset($field['options'])) |
1465 | 1525 | { |
1466 | 1526 | // Is this some code to generate the options? |
1467 | - if (!is_array($field['options'])) |
|
1468 | - $field['options'] = $field['options'](); |
|
1527 | + if (!is_array($field['options'])) { |
|
1528 | + $field['options'] = $field['options'](); |
|
1529 | + } |
|
1469 | 1530 | // Assuming we now have some! |
1470 | - if (is_array($field['options'])) |
|
1471 | - foreach ($field['options'] as $value => $name) |
|
1531 | + if (is_array($field['options'])) { |
|
1532 | + foreach ($field['options'] as $value => $name) |
|
1472 | 1533 | echo ' |
1473 | 1534 | <option value="', $value, '"', $value == $field['value'] ? ' selected' : '', '>', $name, '</option>'; |
1535 | + } |
|
1474 | 1536 | } |
1475 | 1537 | |
1476 | 1538 | echo ' |
@@ -1478,25 +1540,28 @@ discard block |
||
1478 | 1540 | } |
1479 | 1541 | |
1480 | 1542 | // Something to end with? |
1481 | - if (!empty($field['postinput'])) |
|
1482 | - echo ' |
|
1543 | + if (!empty($field['postinput'])) { |
|
1544 | + echo ' |
|
1483 | 1545 | ', $field['postinput']; |
1546 | + } |
|
1484 | 1547 | |
1485 | 1548 | echo ' |
1486 | 1549 | </dd>'; |
1487 | 1550 | } |
1488 | 1551 | } |
1489 | 1552 | |
1490 | - if (!empty($context['profile_fields'])) |
|
1491 | - echo ' |
|
1553 | + if (!empty($context['profile_fields'])) { |
|
1554 | + echo ' |
|
1492 | 1555 | </dl>'; |
1556 | + } |
|
1493 | 1557 | |
1494 | 1558 | // Are there any custom profile fields - if so print them! |
1495 | 1559 | if (!empty($context['custom_fields'])) |
1496 | 1560 | { |
1497 | - if ($lastItem != 'hr') |
|
1498 | - echo ' |
|
1561 | + if ($lastItem != 'hr') { |
|
1562 | + echo ' |
|
1499 | 1563 | <hr>'; |
1564 | + } |
|
1500 | 1565 | |
1501 | 1566 | echo ' |
1502 | 1567 | <dl class="settings">'; |
@@ -1519,13 +1584,14 @@ discard block |
||
1519 | 1584 | } |
1520 | 1585 | |
1521 | 1586 | // Any closing HTML? |
1522 | - if (!empty($context['profile_posthtml'])) |
|
1523 | - echo ' |
|
1587 | + if (!empty($context['profile_posthtml'])) { |
|
1588 | + echo ' |
|
1524 | 1589 | <div>', $context['profile_posthtml'], '</div>'; |
1590 | + } |
|
1525 | 1591 | |
1526 | 1592 | // Only show the password box if it's actually needed. |
1527 | - if ($context['require_password']) |
|
1528 | - echo ' |
|
1593 | + if ($context['require_password']) { |
|
1594 | + echo ' |
|
1529 | 1595 | <dl class="settings"> |
1530 | 1596 | <dt> |
1531 | 1597 | <strong', isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : '', '><label for="oldpasswrd">', $txt['current_password'], ': </label></strong><br> |
@@ -1535,18 +1601,21 @@ discard block |
||
1535 | 1601 | <input type="password" name="oldpasswrd" id="oldpasswrd" size="20" style="margin-right: 4ex;" class="input_password"> |
1536 | 1602 | </dd> |
1537 | 1603 | </dl>'; |
1604 | + } |
|
1538 | 1605 | |
1539 | 1606 | // The button shouldn't say "Change profile" unless we're changing the profile... |
1540 | - if (!empty($context['submit_button_text'])) |
|
1541 | - echo ' |
|
1607 | + if (!empty($context['submit_button_text'])) { |
|
1608 | + echo ' |
|
1542 | 1609 | <input type="submit" name="save" value="', $context['submit_button_text'], '" class="button_submit">'; |
1543 | - else |
|
1544 | - echo ' |
|
1610 | + } else { |
|
1611 | + echo ' |
|
1545 | 1612 | <input type="submit" name="save" value="', $txt['change_profile'], '" class="button_submit">'; |
1613 | + } |
|
1546 | 1614 | |
1547 | - if (!empty($context['token_check'])) |
|
1548 | - echo ' |
|
1615 | + if (!empty($context['token_check'])) { |
|
1616 | + echo ' |
|
1549 | 1617 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
1618 | + } |
|
1550 | 1619 | |
1551 | 1620 | echo ' |
1552 | 1621 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -1556,10 +1625,11 @@ discard block |
||
1556 | 1625 | </form>'; |
1557 | 1626 | |
1558 | 1627 | // Any final spellchecking stuff? |
1559 | - if (!empty($context['show_spellchecking'])) |
|
1560 | - echo ' |
|
1628 | + if (!empty($context['show_spellchecking'])) { |
|
1629 | + echo ' |
|
1561 | 1630 | <form name="spell_form" id="spell_form" method="post" accept-charset="', $context['character_set'], '" target="spellWindow" action="', $scripturl, '?action=spellcheck"><input type="hidden" name="spellstring" value=""></form>'; |
1562 | -} |
|
1631 | + } |
|
1632 | + } |
|
1563 | 1633 | |
1564 | 1634 | /** |
1565 | 1635 | * Personal Message settings. |
@@ -1596,10 +1666,11 @@ discard block |
||
1596 | 1666 | <select name="pm_receive_from" id="pm_receive_from"> |
1597 | 1667 | <option value="0"', empty($context['receive_from']) || (empty($modSettings['enable_buddylist']) && $context['receive_from'] < 3) ? ' selected' : '', '>', $txt['pm_receive_from_everyone'], '</option>'; |
1598 | 1668 | |
1599 | - if (!empty($modSettings['enable_buddylist'])) |
|
1600 | - echo ' |
|
1669 | + if (!empty($modSettings['enable_buddylist'])) { |
|
1670 | + echo ' |
|
1601 | 1671 | <option value="1"', !empty($context['receive_from']) && $context['receive_from'] == 1 ? ' selected' : '', '>', $txt['pm_receive_from_ignore'], '</option> |
1602 | 1672 | <option value="2"', !empty($context['receive_from']) && $context['receive_from'] == 2 ? ' selected' : '', '>', $txt['pm_receive_from_buddies'], '</option>'; |
1673 | + } |
|
1603 | 1674 | |
1604 | 1675 | echo ' |
1605 | 1676 | <option value="3"', !empty($context['receive_from']) && $context['receive_from'] > 2 ? ' selected' : '', '>', $txt['pm_receive_from_admins'], '</option> |
@@ -1641,11 +1712,12 @@ discard block |
||
1641 | 1712 | if (empty($setting) || !is_array($setting)) |
1642 | 1713 | { |
1643 | 1714 | // Insert a separator (unless this is the first item in the list) |
1644 | - if ($i !== $first_option_key) |
|
1645 | - echo ' |
|
1715 | + if ($i !== $first_option_key) { |
|
1716 | + echo ' |
|
1646 | 1717 | </dl> |
1647 | 1718 | <hr> |
1648 | 1719 | <dl class="settings">'; |
1720 | + } |
|
1649 | 1721 | |
1650 | 1722 | // Should we give a name to this section? |
1651 | 1723 | if (is_string($setting) && !empty($setting)) |
@@ -1653,48 +1725,52 @@ discard block |
||
1653 | 1725 | $titled_section = true; |
1654 | 1726 | echo ' |
1655 | 1727 | <dt><b>' . $setting . '</b></dt><dd></dd>'; |
1728 | + } else { |
|
1729 | + $titled_section = false; |
|
1656 | 1730 | } |
1657 | - else |
|
1658 | - $titled_section = false; |
|
1659 | 1731 | |
1660 | 1732 | continue; |
1661 | 1733 | } |
1662 | 1734 | |
1663 | 1735 | // Is this disabled? |
1664 | - if ($setting['id'] == 'calendar_start_day' && empty($modSettings['cal_enabled'])) |
|
1665 | - continue; |
|
1666 | - elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage'])) |
|
1667 | - continue; |
|
1668 | - elseif ($setting['id'] == 'show_no_censored' && empty($modSettings['allow_no_censored'])) |
|
1669 | - continue; |
|
1670 | - elseif ($setting['id'] == 'posts_apply_ignore_list' && empty($modSettings['enable_buddylist'])) |
|
1671 | - continue; |
|
1672 | - elseif ($setting['id'] == 'wysiwyg_default' && !empty($modSettings['disable_wysiwyg'])) |
|
1673 | - continue; |
|
1674 | - elseif ($setting['id'] == 'topics_per_page' && !empty($modSettings['disableCustomPerPage'])) |
|
1675 | - continue; |
|
1676 | - elseif ($setting['id'] == 'drafts_autosave_enabled' && (empty($modSettings['drafts_autosave_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) |
|
1677 | - continue; |
|
1678 | - elseif ($setting['id'] == 'drafts_show_saved_enabled' && (empty($modSettings['drafts_show_saved_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) |
|
1679 | - continue; |
|
1736 | + if ($setting['id'] == 'calendar_start_day' && empty($modSettings['cal_enabled'])) { |
|
1737 | + continue; |
|
1738 | + } elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage'])) { |
|
1739 | + continue; |
|
1740 | + } elseif ($setting['id'] == 'show_no_censored' && empty($modSettings['allow_no_censored'])) { |
|
1741 | + continue; |
|
1742 | + } elseif ($setting['id'] == 'posts_apply_ignore_list' && empty($modSettings['enable_buddylist'])) { |
|
1743 | + continue; |
|
1744 | + } elseif ($setting['id'] == 'wysiwyg_default' && !empty($modSettings['disable_wysiwyg'])) { |
|
1745 | + continue; |
|
1746 | + } elseif ($setting['id'] == 'topics_per_page' && !empty($modSettings['disableCustomPerPage'])) { |
|
1747 | + continue; |
|
1748 | + } elseif ($setting['id'] == 'drafts_autosave_enabled' && (empty($modSettings['drafts_autosave_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) { |
|
1749 | + continue; |
|
1750 | + } elseif ($setting['id'] == 'drafts_show_saved_enabled' && (empty($modSettings['drafts_show_saved_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) { |
|
1751 | + continue; |
|
1752 | + } |
|
1680 | 1753 | |
1681 | - if (!isset($setting['type']) || $setting['type'] == 'bool') |
|
1682 | - $setting['type'] = 'checkbox'; |
|
1683 | - elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') |
|
1684 | - $setting['type'] = 'number'; |
|
1685 | - elseif ($setting['type'] == 'string') |
|
1686 | - $setting['type'] = 'text'; |
|
1754 | + if (!isset($setting['type']) || $setting['type'] == 'bool') { |
|
1755 | + $setting['type'] = 'checkbox'; |
|
1756 | + } elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') { |
|
1757 | + $setting['type'] = 'number'; |
|
1758 | + } elseif ($setting['type'] == 'string') { |
|
1759 | + $setting['type'] = 'text'; |
|
1760 | + } |
|
1687 | 1761 | |
1688 | - if (isset($setting['options'])) |
|
1689 | - $setting['type'] = 'list'; |
|
1762 | + if (isset($setting['options'])) { |
|
1763 | + $setting['type'] = 'list'; |
|
1764 | + } |
|
1690 | 1765 | |
1691 | 1766 | echo ' |
1692 | 1767 | <dt> |
1693 | 1768 | <label for="', $setting['id'], '">', !$titled_section ? '<b>' : '', $setting['label'], !$titled_section ? '</b>' : '', '</label>'; |
1694 | 1769 | |
1695 | - if (isset($setting['description'])) |
|
1696 | - echo ' |
|
1770 | + if (isset($setting['description'])) { |
|
1771 | + echo ' |
|
1697 | 1772 | <br><span class="smalltext">', $setting['description'], '</span>'; |
1773 | + } |
|
1698 | 1774 | echo ' |
1699 | 1775 | </dt> |
1700 | 1776 | <dd>'; |
@@ -1732,13 +1808,11 @@ discard block |
||
1732 | 1808 | |
1733 | 1809 | echo ' |
1734 | 1810 | <input type="number"', $min . $max . $step; |
1735 | - } |
|
1736 | - else if (isset($setting['type']) && $setting['type'] == 'url') |
|
1811 | + } else if (isset($setting['type']) && $setting['type'] == 'url') |
|
1737 | 1812 | { |
1738 | 1813 | echo' |
1739 | 1814 | <input type="url"'; |
1740 | - } |
|
1741 | - else |
|
1815 | + } else |
|
1742 | 1816 | { |
1743 | 1817 | echo ' |
1744 | 1818 | <input type="text"'; |
@@ -1777,8 +1851,8 @@ discard block |
||
1777 | 1851 | <dl class="settings">'; |
1778 | 1852 | |
1779 | 1853 | // Allow notification on announcements to be disabled? |
1780 | - if (!empty($modSettings['allow_disableAnnounce'])) |
|
1781 | - echo ' |
|
1854 | + if (!empty($modSettings['allow_disableAnnounce'])) { |
|
1855 | + echo ' |
|
1782 | 1856 | <dt> |
1783 | 1857 | <label for="notify_announcements">', $txt['notify_important_email'], '</label> |
1784 | 1858 | </dt> |
@@ -1786,9 +1860,10 @@ discard block |
||
1786 | 1860 | <input type="hidden" name="notify_announcements" value="0"> |
1787 | 1861 | <input type="checkbox" id="notify_announcements" name="notify_announcements" value="1"', !empty($context['member']['notify_announcements']) ? ' checked' : '', ' class="input_check"> |
1788 | 1862 | </dd>'; |
1863 | + } |
|
1789 | 1864 | |
1790 | - if (!empty($modSettings['enable_ajax_alerts'])) |
|
1791 | - echo ' |
|
1865 | + if (!empty($modSettings['enable_ajax_alerts'])) { |
|
1866 | + echo ' |
|
1792 | 1867 | <dt> |
1793 | 1868 | <label for="notify_send_body">', $txt['notify_alert_timeout'], '</label> |
1794 | 1869 | </dt> |
@@ -1796,6 +1871,7 @@ discard block |
||
1796 | 1871 | <input type="number" size="4" id="notify_alert_timeout" name="opt_alert_timeout" min="0" value="', $context['member']['alert_timeout'], '" class="input_text"> |
1797 | 1872 | </dd> |
1798 | 1873 | '; |
1874 | + } |
|
1799 | 1875 | |
1800 | 1876 | echo ' |
1801 | 1877 | </dl> |
@@ -1825,9 +1901,10 @@ discard block |
||
1825 | 1901 | <td colspan="3">'; |
1826 | 1902 | $label = $txt['alert_opt_' . $opts[1]]; |
1827 | 1903 | $label_pos = isset($opts['label']) ? $opts['label'] : ''; |
1828 | - if ($label_pos == 'before') |
|
1829 | - echo ' |
|
1904 | + if ($label_pos == 'before') { |
|
1905 | + echo ' |
|
1830 | 1906 | <label for="opt_', $opts[1], '">', $label, '</label>'; |
1907 | + } |
|
1831 | 1908 | |
1832 | 1909 | $this_value = isset($context['alert_prefs'][$opts[1]]) ? $context['alert_prefs'][$opts[1]] : 0; |
1833 | 1910 | switch ($opts[0]) |
@@ -1839,17 +1916,19 @@ discard block |
||
1839 | 1916 | case 'select': |
1840 | 1917 | echo ' |
1841 | 1918 | <select name="opt_', $opts[1], '" id="opt_', $opts[1], '">'; |
1842 | - foreach ($opts['opts'] as $k => $v) |
|
1843 | - echo ' |
|
1919 | + foreach ($opts['opts'] as $k => $v) { |
|
1920 | + echo ' |
|
1844 | 1921 | <option value="', $k, '"', $this_value == $k ? ' selected' : '', '>', $v, '</option>'; |
1922 | + } |
|
1845 | 1923 | echo ' |
1846 | 1924 | </select>'; |
1847 | 1925 | break; |
1848 | 1926 | } |
1849 | 1927 | |
1850 | - if ($label_pos == 'after') |
|
1851 | - echo ' |
|
1928 | + if ($label_pos == 'after') { |
|
1929 | + echo ' |
|
1852 | 1930 | <label for="opt_', $opts[1], '">', $label, '</label>'; |
1931 | + } |
|
1853 | 1932 | |
1854 | 1933 | echo ' |
1855 | 1934 | </td> |
@@ -1963,11 +2042,12 @@ discard block |
||
1963 | 2042 | <p class="information">', $txt['groupMembership_info'], '</p>'; |
1964 | 2043 | |
1965 | 2044 | // Do we have an update message? |
1966 | - if (!empty($context['update_message'])) |
|
1967 | - echo ' |
|
2045 | + if (!empty($context['update_message'])) { |
|
2046 | + echo ' |
|
1968 | 2047 | <div class="infobox"> |
1969 | 2048 | ', $context['update_message'], '. |
1970 | 2049 | </div>'; |
2050 | + } |
|
1971 | 2051 | |
1972 | 2052 | echo ' |
1973 | 2053 | <div id="groups">'; |
@@ -1989,8 +2069,7 @@ discard block |
||
1989 | 2069 | </div> |
1990 | 2070 | </div> |
1991 | 2071 | </div>'; |
1992 | - } |
|
1993 | - else |
|
2072 | + } else |
|
1994 | 2073 | { |
1995 | 2074 | echo ' |
1996 | 2075 | <div class="title_bar"> |
@@ -2002,27 +2081,30 @@ discard block |
||
2002 | 2081 | echo ' |
2003 | 2082 | <div class="windowbg" id="primdiv_', $group['id'], '">'; |
2004 | 2083 | |
2005 | - if ($context['can_edit_primary']) |
|
2006 | - echo ' |
|
2084 | + if ($context['can_edit_primary']) { |
|
2085 | + echo ' |
|
2007 | 2086 | <input type="radio" name="primary" id="primary_', $group['id'], '" value="', $group['id'], '"', $group['is_primary'] ? ' checked' : '', ' onclick="highlightSelected(\'primdiv_' . $group['id'] . '\');"', $group['can_be_primary'] ? '' : ' disabled', ' class="input_radio">'; |
2087 | + } |
|
2008 | 2088 | |
2009 | 2089 | echo ' |
2010 | 2090 | <label for="primary_', $group['id'], '"><strong>', (empty($group['color']) ? $group['name'] : '<span style="color: ' . $group['color'] . '">' . $group['name'] . '</span>'), '</strong>', (!empty($group['desc']) ? '<br><span class="smalltext">' . $group['desc'] . '</span>' : ''), '</label>'; |
2011 | 2091 | |
2012 | 2092 | // Can they leave their group? |
2013 | - if ($group['can_leave']) |
|
2014 | - echo ' |
|
2093 | + if ($group['can_leave']) { |
|
2094 | + echo ' |
|
2015 | 2095 | <a href="' . $scripturl . '?action=profile;save;u=' . $context['id_member'] . ';area=groupmembership;' . $context['session_var'] . '=' . $context['session_id'] . ';gid=' . $group['id'] . ';', $context[$context['token_check'] . '_token_var'], '=', $context[$context['token_check'] . '_token'], '">' . $txt['leave_group'] . '</a>'; |
2096 | + } |
|
2016 | 2097 | |
2017 | 2098 | echo ' |
2018 | 2099 | </div>'; |
2019 | 2100 | } |
2020 | 2101 | |
2021 | - if ($context['can_edit_primary']) |
|
2022 | - echo ' |
|
2102 | + if ($context['can_edit_primary']) { |
|
2103 | + echo ' |
|
2023 | 2104 | <div class="padding righttext"> |
2024 | 2105 | <input type="submit" value="', $txt['make_primary'], '" class="button_submit"> |
2025 | 2106 | </div>'; |
2107 | + } |
|
2026 | 2108 | |
2027 | 2109 | // Any groups they can join? |
2028 | 2110 | if (!empty($context['groups']['available'])) |
@@ -2038,15 +2120,16 @@ discard block |
||
2038 | 2120 | <div class="windowbg"> |
2039 | 2121 | <strong>', (empty($group['color']) ? $group['name'] : '<span style="color: ' . $group['color'] . '">' . $group['name'] . '</span>'), '</strong>', (!empty($group['desc']) ? '<br><span class="smalltext">' . $group['desc'] . '</span>' : ''), ''; |
2040 | 2122 | |
2041 | - if ($group['type'] == 3) |
|
2042 | - echo ' |
|
2123 | + if ($group['type'] == 3) { |
|
2124 | + echo ' |
|
2043 | 2125 | <a href="', $scripturl, '?action=profile;save;u=', $context['id_member'], ';area=groupmembership;', $context['session_var'], '=', $context['session_id'], ';gid=', $group['id'], ';', $context[$context['token_check'] . '_token_var'], '=', $context[$context['token_check'] . '_token'], '" class="button floatright">', $txt['join_group'], '</a>'; |
2044 | - elseif ($group['type'] == 2 && $group['pending']) |
|
2045 | - echo ' |
|
2126 | + } elseif ($group['type'] == 2 && $group['pending']) { |
|
2127 | + echo ' |
|
2046 | 2128 | <span class="floatright">', $txt['approval_pending'], '</span>'; |
2047 | - elseif ($group['type'] == 2) |
|
2048 | - echo ' |
|
2129 | + } elseif ($group['type'] == 2) { |
|
2130 | + echo ' |
|
2049 | 2131 | <a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=groupmembership;request=', $group['id'], '" class="button floatright">', $txt['request_group'], '</a>'; |
2132 | + } |
|
2050 | 2133 | |
2051 | 2134 | echo ' |
2052 | 2135 | </div>'; |
@@ -2069,9 +2152,10 @@ discard block |
||
2069 | 2152 | |
2070 | 2153 | prevDiv.className = "windowbg"; |
2071 | 2154 | }'; |
2072 | - if (isset($context['groups']['member'][$context['primary_group']])) |
|
2073 | - echo ' |
|
2155 | + if (isset($context['groups']['member'][$context['primary_group']])) { |
|
2156 | + echo ' |
|
2074 | 2157 | highlightSelected("primdiv_' . $context['primary_group'] . '");'; |
2158 | + } |
|
2075 | 2159 | echo ' |
2076 | 2160 | </script>'; |
2077 | 2161 | } |
@@ -2079,9 +2163,10 @@ discard block |
||
2079 | 2163 | echo ' |
2080 | 2164 | </div>'; |
2081 | 2165 | |
2082 | - if (!empty($context['token_check'])) |
|
2083 | - echo ' |
|
2166 | + if (!empty($context['token_check'])) { |
|
2167 | + echo ' |
|
2084 | 2168 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
2169 | + } |
|
2085 | 2170 | |
2086 | 2171 | echo ' |
2087 | 2172 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -2128,14 +2213,15 @@ discard block |
||
2128 | 2213 | |
2129 | 2214 | foreach ($category['boards'] as $board) |
2130 | 2215 | { |
2131 | - if ($i == $limit) |
|
2132 | - echo ' |
|
2216 | + if ($i == $limit) { |
|
2217 | + echo ' |
|
2133 | 2218 | </ul> |
2134 | 2219 | </li> |
2135 | 2220 | </ul> |
2136 | 2221 | <ul class="ignoreboards floatright"> |
2137 | 2222 | <li class="category"> |
2138 | 2223 | <ul>'; |
2224 | + } |
|
2139 | 2225 | |
2140 | 2226 | echo ' |
2141 | 2227 | <li class="board" style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'], 'em;"> |
@@ -2181,10 +2267,11 @@ discard block |
||
2181 | 2267 | |
2182 | 2268 | // Work out the starting color. |
2183 | 2269 | $context['current_color'] = $context['colors'][0]; |
2184 | - foreach ($context['colors'] as $limit => $color) |
|
2185 | - if ($context['member']['warning'] >= $limit) |
|
2270 | + foreach ($context['colors'] as $limit => $color) { |
|
2271 | + if ($context['member']['warning'] >= $limit) |
|
2186 | 2272 | $context['current_color'] = $color; |
2187 | -} |
|
2273 | + } |
|
2274 | + } |
|
2188 | 2275 | |
2189 | 2276 | // Show all warnings of a user? |
2190 | 2277 | function template_viewWarning() |
@@ -2223,14 +2310,15 @@ discard block |
||
2223 | 2310 | </dd>'; |
2224 | 2311 | |
2225 | 2312 | // There's some impact of this? |
2226 | - if (!empty($context['level_effects'][$context['current_level']])) |
|
2227 | - echo ' |
|
2313 | + if (!empty($context['level_effects'][$context['current_level']])) { |
|
2314 | + echo ' |
|
2228 | 2315 | <dt> |
2229 | 2316 | <strong>', $txt['profile_viewwarning_impact'], ':</strong> |
2230 | 2317 | </dt> |
2231 | 2318 | <dd> |
2232 | 2319 | ', $context['level_effects'][$context['current_level']], ' |
2233 | 2320 | </dd>'; |
2321 | + } |
|
2234 | 2322 | |
2235 | 2323 | echo ' |
2236 | 2324 | </dl> |
@@ -2268,10 +2356,11 @@ discard block |
||
2268 | 2356 | |
2269 | 2357 | // Otherwise see what we can do...'; |
2270 | 2358 | |
2271 | - foreach ($context['notification_templates'] as $k => $type) |
|
2272 | - echo ' |
|
2359 | + foreach ($context['notification_templates'] as $k => $type) { |
|
2360 | + echo ' |
|
2273 | 2361 | if (index == ', $k, ') |
2274 | 2362 | document.getElementById(\'warn_body\').value = "', strtr($type['body'], array('"' => "'", "\n" => '\\n', "\r" => '')), '";'; |
2363 | + } |
|
2275 | 2364 | |
2276 | 2365 | echo ' |
2277 | 2366 | } |
@@ -2281,10 +2370,11 @@ discard block |
||
2281 | 2370 | // Also set the right effect. |
2282 | 2371 | effectText = "";'; |
2283 | 2372 | |
2284 | - foreach ($context['level_effects'] as $limit => $text) |
|
2285 | - echo ' |
|
2373 | + foreach ($context['level_effects'] as $limit => $text) { |
|
2374 | + echo ' |
|
2286 | 2375 | if (slideAmount >= ', $limit, ') |
2287 | 2376 | effectText = "', $text, '";'; |
2377 | + } |
|
2288 | 2378 | |
2289 | 2379 | echo ' |
2290 | 2380 | setInnerHTML(document.getElementById(\'cur_level_div\'), slideAmount + \'% (\' + effectText + \')\'); |
@@ -2299,31 +2389,34 @@ discard block |
||
2299 | 2389 | </h3> |
2300 | 2390 | </div>'; |
2301 | 2391 | |
2302 | - if (!$context['user']['is_owner']) |
|
2303 | - echo ' |
|
2392 | + if (!$context['user']['is_owner']) { |
|
2393 | + echo ' |
|
2304 | 2394 | <p class="information">', $txt['profile_warning_desc'], '</p>'; |
2395 | + } |
|
2305 | 2396 | |
2306 | 2397 | echo ' |
2307 | 2398 | <div class="windowbg"> |
2308 | 2399 | <dl class="settings">'; |
2309 | 2400 | |
2310 | - if (!$context['user']['is_owner']) |
|
2311 | - echo ' |
|
2401 | + if (!$context['user']['is_owner']) { |
|
2402 | + echo ' |
|
2312 | 2403 | <dt> |
2313 | 2404 | <strong>', $txt['profile_warning_name'], ':</strong> |
2314 | 2405 | </dt> |
2315 | 2406 | <dd> |
2316 | 2407 | <strong>', $context['member']['name'], '</strong> |
2317 | 2408 | </dd>'; |
2409 | + } |
|
2318 | 2410 | |
2319 | 2411 | echo ' |
2320 | 2412 | <dt> |
2321 | 2413 | <strong>', $txt['profile_warning_level'], ':</strong>'; |
2322 | 2414 | |
2323 | 2415 | // Is there only so much they can apply? |
2324 | - if ($context['warning_limit']) |
|
2325 | - echo ' |
|
2416 | + if ($context['warning_limit']) { |
|
2417 | + echo ' |
|
2326 | 2418 | <br><span class="smalltext">', sprintf($txt['profile_warning_limit_attribute'], $context['warning_limit']), '</span>'; |
2419 | + } |
|
2327 | 2420 | |
2328 | 2421 | echo ' |
2329 | 2422 | </dt> |
@@ -2376,9 +2469,10 @@ discard block |
||
2376 | 2469 | <option value="-1">', $txt['profile_warning_notify_template'], '</option> |
2377 | 2470 | <option value="-1" disabled>------------------------------</option>'; |
2378 | 2471 | |
2379 | - foreach ($context['notification_templates'] as $id_template => $template) |
|
2380 | - echo ' |
|
2472 | + foreach ($context['notification_templates'] as $id_template => $template) { |
|
2473 | + echo ' |
|
2381 | 2474 | <option value="', $id_template, '">', $template['title'], '</option>'; |
2475 | + } |
|
2382 | 2476 | |
2383 | 2477 | echo ' |
2384 | 2478 | </select> |
@@ -2390,9 +2484,10 @@ discard block |
||
2390 | 2484 | </dl> |
2391 | 2485 | <div class="righttext">'; |
2392 | 2486 | |
2393 | - if (!empty($context['token_check'])) |
|
2394 | - echo ' |
|
2487 | + if (!empty($context['token_check'])) { |
|
2488 | + echo ' |
|
2395 | 2489 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
2490 | + } |
|
2396 | 2491 | |
2397 | 2492 | echo ' |
2398 | 2493 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -2408,8 +2503,8 @@ discard block |
||
2408 | 2503 | echo ' |
2409 | 2504 | <script>'; |
2410 | 2505 | |
2411 | - if (!$context['user']['is_owner']) |
|
2412 | - echo ' |
|
2506 | + if (!$context['user']['is_owner']) { |
|
2507 | + echo ' |
|
2413 | 2508 | modifyWarnNotify(); |
2414 | 2509 | $(document).ready(function() { |
2415 | 2510 | $("#preview_button").click(function() { |
@@ -2448,6 +2543,7 @@ discard block |
||
2448 | 2543 | }); |
2449 | 2544 | return false; |
2450 | 2545 | }'; |
2546 | + } |
|
2451 | 2547 | |
2452 | 2548 | echo ' |
2453 | 2549 | </script>'; |
@@ -2470,16 +2566,18 @@ discard block |
||
2470 | 2566 | </div>'; |
2471 | 2567 | |
2472 | 2568 | // If deleting another account give them a lovely info box. |
2473 | - if (!$context['user']['is_owner']) |
|
2474 | - echo ' |
|
2569 | + if (!$context['user']['is_owner']) { |
|
2570 | + echo ' |
|
2475 | 2571 | <p class="information">', $txt['deleteAccount_desc'], '</p>'; |
2572 | + } |
|
2476 | 2573 | echo ' |
2477 | 2574 | <div class="windowbg2">'; |
2478 | 2575 | |
2479 | 2576 | // If they are deleting their account AND the admin needs to approve it - give them another piece of info ;) |
2480 | - if ($context['needs_approval']) |
|
2481 | - echo ' |
|
2577 | + if ($context['needs_approval']) { |
|
2578 | + echo ' |
|
2482 | 2579 | <div class="errorbox">', $txt['deleteAccount_approval'], '</div>'; |
2580 | + } |
|
2483 | 2581 | |
2484 | 2582 | // If the user is deleting their own account warn them first - and require a password! |
2485 | 2583 | if ($context['user']['is_owner']) |
@@ -2491,9 +2589,10 @@ discard block |
||
2491 | 2589 | <input type="password" name="oldpasswrd" size="20" class="input_password"> |
2492 | 2590 | <input type="submit" value="', $txt['yes'], '" class="button_submit">'; |
2493 | 2591 | |
2494 | - if (!empty($context['token_check'])) |
|
2495 | - echo ' |
|
2592 | + if (!empty($context['token_check'])) { |
|
2593 | + echo ' |
|
2496 | 2594 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
2595 | + } |
|
2497 | 2596 | |
2498 | 2597 | echo ' |
2499 | 2598 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -2519,9 +2618,10 @@ discard block |
||
2519 | 2618 | <option value="topics">', $txt['deleteAccount_topics'], '</option> |
2520 | 2619 | </select>'; |
2521 | 2620 | |
2522 | - if ($context['show_perma_delete']) |
|
2523 | - echo ' |
|
2621 | + if ($context['show_perma_delete']) { |
|
2622 | + echo ' |
|
2524 | 2623 | <br><label for="perma_delete"><input type="checkbox" name="perma_delete" id="perma_delete" value="1" class="input_check">', $txt['deleteAccount_permanent'], ':</label>'; |
2624 | + } |
|
2525 | 2625 | |
2526 | 2626 | echo ' |
2527 | 2627 | </div>'; |
@@ -2534,9 +2634,10 @@ discard block |
||
2534 | 2634 | <div> |
2535 | 2635 | <input type="submit" value="', $txt['delete'], '" class="button_submit">'; |
2536 | 2636 | |
2537 | - if (!empty($context['token_check'])) |
|
2538 | - echo ' |
|
2637 | + if (!empty($context['token_check'])) { |
|
2638 | + echo ' |
|
2539 | 2639 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
2640 | + } |
|
2540 | 2641 | |
2541 | 2642 | echo ' |
2542 | 2643 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -2562,8 +2663,8 @@ discard block |
||
2562 | 2663 | <hr>'; |
2563 | 2664 | |
2564 | 2665 | // Only show the password box if it's actually needed. |
2565 | - if ($context['require_password']) |
|
2566 | - echo ' |
|
2666 | + if ($context['require_password']) { |
|
2667 | + echo ' |
|
2567 | 2668 | <dl class="settings"> |
2568 | 2669 | <dt> |
2569 | 2670 | <strong', isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : '', '>', $txt['current_password'], ': </strong><br> |
@@ -2573,13 +2674,15 @@ discard block |
||
2573 | 2674 | <input type="password" name="oldpasswrd" size="20" style="margin-right: 4ex;" class="input_password"> |
2574 | 2675 | </dd> |
2575 | 2676 | </dl>'; |
2677 | + } |
|
2576 | 2678 | |
2577 | 2679 | echo ' |
2578 | 2680 | <div class="righttext">'; |
2579 | 2681 | |
2580 | - if (!empty($context['token_check'])) |
|
2581 | - echo ' |
|
2682 | + if (!empty($context['token_check'])) { |
|
2683 | + echo ' |
|
2582 | 2684 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
2685 | + } |
|
2583 | 2686 | |
2584 | 2687 | echo ' |
2585 | 2688 | <input type="submit" value="', $txt['change_profile'], '" class="button_submit"> |
@@ -2606,9 +2709,10 @@ discard block |
||
2606 | 2709 | <ul id="list_errors">'; |
2607 | 2710 | |
2608 | 2711 | // Cycle through each error and display an error message. |
2609 | - foreach ($context['post_errors'] as $error) |
|
2610 | - echo ' |
|
2712 | + foreach ($context['post_errors'] as $error) { |
|
2713 | + echo ' |
|
2611 | 2714 | <li>', isset($txt['profile_error_' . $error]) ? $txt['profile_error_' . $error] : $error, '</li>'; |
2715 | + } |
|
2612 | 2716 | |
2613 | 2717 | echo ' |
2614 | 2718 | </ul>'; |
@@ -2634,12 +2738,13 @@ discard block |
||
2634 | 2738 | <select name="id_group" ', ($context['user']['is_owner'] && $context['member']['group_id'] == 1 ? 'onchange="if (this.value != 1 && !confirm(\'' . $txt['deadmin_confirm'] . '\')) this.value = 1;"' : ''), '>'; |
2635 | 2739 | |
2636 | 2740 | // Fill the select box with all primary member groups that can be assigned to a member. |
2637 | - foreach ($context['member_groups'] as $member_group) |
|
2638 | - if (!empty($member_group['can_be_primary'])) |
|
2741 | + foreach ($context['member_groups'] as $member_group) { |
|
2742 | + if (!empty($member_group['can_be_primary'])) |
|
2639 | 2743 | echo ' |
2640 | 2744 | <option value="', $member_group['id'], '"', $member_group['is_primary'] ? ' selected' : '', '> |
2641 | 2745 | ', $member_group['name'], ' |
2642 | 2746 | </option>'; |
2747 | + } |
|
2643 | 2748 | echo ' |
2644 | 2749 | </select> |
2645 | 2750 | </dd> |
@@ -2651,10 +2756,11 @@ discard block |
||
2651 | 2756 | <input type="hidden" name="additional_groups[]" value="0">'; |
2652 | 2757 | |
2653 | 2758 | // For each membergroup show a checkbox so members can be assigned to more than one group. |
2654 | - foreach ($context['member_groups'] as $member_group) |
|
2655 | - if ($member_group['can_be_additional']) |
|
2759 | + foreach ($context['member_groups'] as $member_group) { |
|
2760 | + if ($member_group['can_be_additional']) |
|
2656 | 2761 | echo ' |
2657 | 2762 | <label for="additional_groups-', $member_group['id'], '"><input type="checkbox" name="additional_groups[]" value="', $member_group['id'], '" id="additional_groups-', $member_group['id'], '"', $member_group['is_additional'] ? ' checked' : '', ' class="input_check"> ', $member_group['name'], '</label><br>'; |
2763 | + } |
|
2658 | 2764 | echo ' |
2659 | 2765 | </span> |
2660 | 2766 | <a href="javascript:void(0);" onclick="document.getElementById(\'additional_groupsList\').style.display = \'block\'; document.getElementById(\'additional_groupsLink\').style.display = \'none\'; return false;" id="additional_groupsLink" style="display: none;" class="toggle_down">', $txt['additional_membergroups_show'], '</a> |
@@ -2714,9 +2820,10 @@ discard block |
||
2714 | 2820 | <span class="smalltext">', $txt['sig_info'], '</span><br> |
2715 | 2821 | <br>'; |
2716 | 2822 | |
2717 | - if ($context['show_spellchecking']) |
|
2718 | - echo ' |
|
2823 | + if ($context['show_spellchecking']) { |
|
2824 | + echo ' |
|
2719 | 2825 | <input type="button" value="', $txt['spell_check'], '" onclick="spellCheck(\'creator\', \'signature\');" class="button_submit">'; |
2826 | + } |
|
2720 | 2827 | |
2721 | 2828 | echo ' |
2722 | 2829 | </dt> |
@@ -2724,17 +2831,20 @@ discard block |
||
2724 | 2831 | <textarea class="editor" onkeyup="calcCharLeft();" id="signature" name="signature" rows="5" cols="50" style="min-width: 50%; max-width: 99%;">', $context['member']['signature'], '</textarea><br>'; |
2725 | 2832 | |
2726 | 2833 | // If there is a limit at all! |
2727 | - if (!empty($context['signature_limits']['max_length'])) |
|
2728 | - echo ' |
|
2834 | + if (!empty($context['signature_limits']['max_length'])) { |
|
2835 | + echo ' |
|
2729 | 2836 | <span class="smalltext">', sprintf($txt['max_sig_characters'], $context['signature_limits']['max_length']), ' <span id="signatureLeft">', $context['signature_limits']['max_length'], '</span></span><br>'; |
2837 | + } |
|
2730 | 2838 | |
2731 | - if (!empty($context['show_preview_button'])) |
|
2732 | - echo ' |
|
2839 | + if (!empty($context['show_preview_button'])) { |
|
2840 | + echo ' |
|
2733 | 2841 | <input type="button" name="preview_signature" id="preview_button" value="', $txt['preview_signature'], '" class="button_submit">'; |
2842 | + } |
|
2734 | 2843 | |
2735 | - if ($context['signature_warning']) |
|
2736 | - echo ' |
|
2844 | + if ($context['signature_warning']) { |
|
2845 | + echo ' |
|
2737 | 2846 | <span class="smalltext">', $context['signature_warning'], '</span>'; |
2847 | + } |
|
2738 | 2848 | |
2739 | 2849 | // Some javascript used to count how many characters have been used so far in the signature. |
2740 | 2850 | echo ' |
@@ -2778,9 +2888,10 @@ discard block |
||
2778 | 2888 | <div> |
2779 | 2889 | <select name="cat" id="cat" size="10" onchange="changeSel(\'\');" onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'server_stored\');">'; |
2780 | 2890 | // This lists all the file categories. |
2781 | - foreach ($context['avatars'] as $avatar) |
|
2782 | - echo ' |
|
2891 | + foreach ($context['avatars'] as $avatar) { |
|
2892 | + echo ' |
|
2783 | 2893 | <option value="', $avatar['filename'] . ($avatar['is_dir'] ? '/' : ''), '"', ($avatar['checked'] ? ' selected' : ''), '>', $avatar['name'], '</option>'; |
2894 | + } |
|
2784 | 2895 | echo ' |
2785 | 2896 | </select> |
2786 | 2897 | </div> |
@@ -2835,16 +2946,17 @@ discard block |
||
2835 | 2946 | <div id="avatar_gravatar"> |
2836 | 2947 | <img src="' . $context['member']['avatar']['href'] . '" alt="" />'; |
2837 | 2948 | |
2838 | - if (empty($modSettings['gravatarAllowExtraEmail'])) |
|
2839 | - echo ' |
|
2949 | + if (empty($modSettings['gravatarAllowExtraEmail'])) { |
|
2950 | + echo ' |
|
2840 | 2951 | <div class="smalltext">', $txt['gravatar_noAlternateEmail'], '</div>'; |
2841 | - else |
|
2952 | + } else |
|
2842 | 2953 | { |
2843 | 2954 | // Depending on other stuff, the stored value here might have some odd things in it from other areas. |
2844 | - if ($context['member']['avatar']['external'] == $context['member']['email']) |
|
2845 | - $textbox_value = ''; |
|
2846 | - else |
|
2847 | - $textbox_value = $context['member']['avatar']['external']; |
|
2955 | + if ($context['member']['avatar']['external'] == $context['member']['email']) { |
|
2956 | + $textbox_value = ''; |
|
2957 | + } else { |
|
2958 | + $textbox_value = $context['member']['avatar']['external']; |
|
2959 | + } |
|
2848 | 2960 | |
2849 | 2961 | echo ' |
2850 | 2962 | <div class="smalltext">', $txt['gravatar_alternateEmail'], '</div> |
@@ -2916,8 +3028,9 @@ discard block |
||
2916 | 3028 | $h = !empty($modSettings['avatar_max_height_' . $type]) ? comma_format($modSettings['avatar_max_height_' . $type]) : 0; |
2917 | 3029 | |
2918 | 3030 | $suffix = (!empty($w) ? 'w' : '') . (!empty($h) ? 'h' : ''); |
2919 | - if (empty($suffix)) |
|
2920 | - return; |
|
3031 | + if (empty($suffix)) { |
|
3032 | + return; |
|
3033 | + } |
|
2921 | 3034 | |
2922 | 3035 | echo ' |
2923 | 3036 | <div class="smalltext">', sprintf($txt['avatar_max_size_' . $suffix], $w, $h), '</div>'; |
@@ -2939,9 +3052,10 @@ discard block |
||
2939 | 3052 | <dd> |
2940 | 3053 | <select name="easyformat" id="easyformat" onchange="document.forms.creator.time_format.value = this.options[this.selectedIndex].value;" style="margin-bottom: 4px;">'; |
2941 | 3054 | // Help the user by showing a list of common time formats. |
2942 | - foreach ($context['easy_timeformats'] as $time_format) |
|
2943 | - echo ' |
|
3055 | + foreach ($context['easy_timeformats'] as $time_format) { |
|
3056 | + echo ' |
|
2944 | 3057 | <option value="', $time_format['format'], '"', $time_format['format'] == $context['member']['time_format'] ? ' selected' : '', '>', $time_format['title'], '</option>'; |
3058 | + } |
|
2945 | 3059 | echo ' |
2946 | 3060 | </select><br> |
2947 | 3061 | <input type="text" name="time_format" id="time_format" value="', $context['member']['time_format'], '" size="30" class="input_text"> |
@@ -2977,9 +3091,10 @@ discard block |
||
2977 | 3091 | </dt> |
2978 | 3092 | <dd> |
2979 | 3093 | <select name="smiley_set" id="smiley_set" onchange="document.getElementById(\'smileypr\').src = this.selectedIndex == 0 ? \'', $settings['images_url'], '/blank.png\' : \'', $modSettings['smileys_url'], '/\' + (this.selectedIndex != 1 ? this.options[this.selectedIndex].value : \'', !empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default'], '\') + \'/smiley.gif\';">'; |
2980 | - foreach ($context['smiley_sets'] as $set) |
|
2981 | - echo ' |
|
3094 | + foreach ($context['smiley_sets'] as $set) { |
|
3095 | + echo ' |
|
2982 | 3096 | <option value="', $set['id'], '"', $set['selected'] ? ' selected' : '', '>', $set['name'], '</option>'; |
3097 | + } |
|
2983 | 3098 | echo ' |
2984 | 3099 | </select> <img id="smileypr" class="centericon" src="', $context['member']['smiley_set']['id'] != 'none' ? $modSettings['smileys_url'] . '/' . ($context['member']['smiley_set']['id'] != '' ? $context['member']['smiley_set']['id'] : (!empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default'])) . '/smiley.gif' : $settings['images_url'] . '/blank.png', '" alt=":)" style="padding-left: 20px;"> |
2985 | 3100 | </dd>'; |
@@ -3030,10 +3145,11 @@ discard block |
||
3030 | 3145 | </div> |
3031 | 3146 | <div class="clear"></div>'; |
3032 | 3147 | |
3033 | - if (!empty($context['from_ajax'])) |
|
3034 | - echo ' |
|
3148 | + if (!empty($context['from_ajax'])) { |
|
3149 | + echo ' |
|
3035 | 3150 | <br> |
3036 | 3151 | <a href="javascript:self.close();"></a>'; |
3152 | + } |
|
3037 | 3153 | |
3038 | 3154 | echo ' |
3039 | 3155 | </div> |
@@ -3072,15 +3188,16 @@ discard block |
||
3072 | 3188 | <br /><div class="smalltext">', $txt['tfa_profile_desc'], '</div> |
3073 | 3189 | </dt> |
3074 | 3190 | <dd>'; |
3075 | - if (!$context['tfa_enabled'] && $context['user']['is_owner']) |
|
3076 | - echo ' |
|
3191 | + if (!$context['tfa_enabled'] && $context['user']['is_owner']) { |
|
3192 | + echo ' |
|
3077 | 3193 | <a href="', !empty($modSettings['force_ssl']) && $modSettings['force_ssl'] < 2 ? strtr($scripturl, array('http://' => 'https://')) : $scripturl, '?action=profile;area=tfasetup" id="enable_tfa">', $txt['tfa_profile_enable'], '</a>'; |
3078 | - elseif (!$context['tfa_enabled']) |
|
3079 | - echo ' |
|
3194 | + } elseif (!$context['tfa_enabled']) { |
|
3195 | + echo ' |
|
3080 | 3196 | ', $txt['tfa_profile_disabled']; |
3081 | - else |
|
3082 | - echo ' |
|
3197 | + } else { |
|
3198 | + echo ' |
|
3083 | 3199 | ', sprintf($txt['tfa_profile_enabled'], $scripturl . '?action=profile;u=' . $context['id_member'] . ';area=tfasetup;disable'); |
3200 | + } |
|
3084 | 3201 | echo ' |
3085 | 3202 | </dd>'; |
3086 | 3203 | } |
@@ -21,7 +21,7 @@ |
||
21 | 21 | <div id="recent" class="main_section"> |
22 | 22 | <div class="cat_bar"> |
23 | 23 | <h3 class="catbg"> |
24 | - <span class="xx"></span>',$txt['recent_posts'],' |
|
24 | + <span class="xx"></span>',$txt['recent_posts'], ' |
|
25 | 25 | </h3> |
26 | 26 | </div> |
27 | 27 | <div class="pagesection">', $context['page_index'], '</div>'; |
@@ -43,28 +43,33 @@ discard block |
||
43 | 43 | </div> |
44 | 44 | <div class="list_posts">', $post['message'], '</div>'; |
45 | 45 | |
46 | - if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) |
|
47 | - echo ' |
|
46 | + if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) { |
|
47 | + echo ' |
|
48 | 48 | <ul class="quickbuttons">'; |
49 | + } |
|
49 | 50 | |
50 | 51 | // If they *can* reply? |
51 | - if ($post['can_reply']) |
|
52 | - echo ' |
|
52 | + if ($post['can_reply']) { |
|
53 | + echo ' |
|
53 | 54 | <li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li>'; |
55 | + } |
|
54 | 56 | |
55 | 57 | // If they *can* quote? |
56 | - if ($post['can_quote']) |
|
57 | - echo ' |
|
58 | + if ($post['can_quote']) { |
|
59 | + echo ' |
|
58 | 60 | <li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], ';quote=', $post['id'], '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>'; |
61 | + } |
|
59 | 62 | |
60 | 63 | // How about... even... remove it entirely?! |
61 | - if ($post['can_delete']) |
|
62 | - echo ' |
|
64 | + if ($post['can_delete']) { |
|
65 | + echo ' |
|
63 | 66 | <li><a href="', $scripturl, '?action=deletemsg;msg=', $post['id'], ';topic=', $post['topic'], ';recent;', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>'; |
67 | + } |
|
64 | 68 | |
65 | - if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) |
|
66 | - echo ' |
|
69 | + if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) { |
|
70 | + echo ' |
|
67 | 71 | </ul>'; |
72 | + } |
|
68 | 73 | |
69 | 74 | echo ' |
70 | 75 | </div>'; |
@@ -86,12 +91,13 @@ discard block |
||
86 | 91 | echo ' |
87 | 92 | <div id="recent" class="main_content">'; |
88 | 93 | |
89 | - if ($context['showCheckboxes']) |
|
90 | - echo ' |
|
94 | + if ($context['showCheckboxes']) { |
|
95 | + echo ' |
|
91 | 96 | <form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="quickModForm" id="quickModForm" style="margin: 0;"> |
92 | 97 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
93 | 98 | <input type="hidden" name="qaction" value="markread"> |
94 | 99 | <input type="hidden" name="redirect_url" value="action=unread', (!empty($context['showing_all_topics']) ? ';all' : ''), $context['querystring_board_limits'], '">'; |
100 | + } |
|
95 | 101 | |
96 | 102 | if (!empty($context['topics'])) |
97 | 103 | { |
@@ -117,11 +123,12 @@ discard block |
||
117 | 123 | </div>'; |
118 | 124 | |
119 | 125 | // Show a "select all" box for quick moderation? |
120 | - if ($context['showCheckboxes']) |
|
121 | - echo ' |
|
126 | + if ($context['showCheckboxes']) { |
|
127 | + echo ' |
|
122 | 128 | <div class="moderation"> |
123 | 129 | <input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');" class="input_check"> |
124 | 130 | </div>'; |
131 | + } |
|
125 | 132 | |
126 | 133 | echo ' |
127 | 134 | </div> |
@@ -140,15 +147,18 @@ discard block |
||
140 | 147 | // Now we handle the icons |
141 | 148 | echo ' |
142 | 149 | <div class="icons floatright">'; |
143 | - if ($topic['is_locked']) |
|
144 | - echo ' |
|
150 | + if ($topic['is_locked']) { |
|
151 | + echo ' |
|
145 | 152 | <span class="generic_icons lock"></span>'; |
146 | - if ($topic['is_sticky']) |
|
147 | - echo ' |
|
153 | + } |
|
154 | + if ($topic['is_sticky']) { |
|
155 | + echo ' |
|
148 | 156 | <span class="generic_icons sticky"></span>'; |
149 | - if ($topic['is_poll']) |
|
150 | - echo ' |
|
157 | + } |
|
158 | + if ($topic['is_poll']) { |
|
159 | + echo ' |
|
151 | 160 | <span class="generic_icons poll"></span>'; |
161 | + } |
|
152 | 162 | echo ' |
153 | 163 | </div>'; |
154 | 164 | |
@@ -173,19 +183,21 @@ discard block |
||
173 | 183 | ', sprintf($txt['last_post_topic'], '<a href="' . $topic['last_post']['href'] . '">' . $topic['last_post']['time'] . '</a>', $topic['last_post']['member']['link']), ' |
174 | 184 | </div>'; |
175 | 185 | |
176 | - if ($context['showCheckboxes']) |
|
177 | - echo ' |
|
186 | + if ($context['showCheckboxes']) { |
|
187 | + echo ' |
|
178 | 188 | <div class="moderation"> |
179 | 189 | <input type="checkbox" name="topics[]" value="', $topic['id'], '" class="input_check"> |
180 | 190 | </div>'; |
191 | + } |
|
181 | 192 | |
182 | 193 | echo ' |
183 | 194 | </div>'; |
184 | 195 | } |
185 | 196 | |
186 | - if (empty($context['topics'])) |
|
187 | - echo ' |
|
197 | + if (empty($context['topics'])) { |
|
198 | + echo ' |
|
188 | 199 | <div style="display: none;"></div>'; |
200 | + } |
|
189 | 201 | |
190 | 202 | echo ' |
191 | 203 | </div> |
@@ -197,25 +209,27 @@ discard block |
||
197 | 209 | ', $context['menu_separator'], '<a href="#recent" class="topbottom floatleft">', $txt['go_up'], '</a> |
198 | 210 | <div class="pagelinks">', $context['page_index'], '</div> |
199 | 211 | </div>'; |
200 | - } |
|
201 | - else |
|
202 | - echo ' |
|
212 | + } else { |
|
213 | + echo ' |
|
203 | 214 | <div class="cat_bar"> |
204 | 215 | <h3 class="catbg centertext"> |
205 | 216 | ', $context['showing_all_topics'] ? $txt['topic_alert_none'] : $txt['unread_topics_visit_none'], ' |
206 | 217 | </h3> |
207 | 218 | </div>'; |
219 | + } |
|
208 | 220 | |
209 | - if ($context['showCheckboxes']) |
|
210 | - echo ' |
|
221 | + if ($context['showCheckboxes']) { |
|
222 | + echo ' |
|
211 | 223 | </form>'; |
224 | + } |
|
212 | 225 | |
213 | 226 | echo ' |
214 | 227 | </div>'; |
215 | 228 | |
216 | - if (empty($context['no_topic_listing'])) |
|
217 | - template_topic_legend(); |
|
218 | -} |
|
229 | + if (empty($context['no_topic_listing'])) { |
|
230 | + template_topic_legend(); |
|
231 | + } |
|
232 | + } |
|
219 | 233 | |
220 | 234 | /** |
221 | 235 | * Template for showing unread replies (eg new replies to topics you've posted in) |
@@ -227,12 +241,13 @@ discard block |
||
227 | 241 | echo ' |
228 | 242 | <div id="recent">'; |
229 | 243 | |
230 | - if ($context['showCheckboxes']) |
|
231 | - echo ' |
|
244 | + if ($context['showCheckboxes']) { |
|
245 | + echo ' |
|
232 | 246 | <form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="quickModForm" id="quickModForm" style="margin: 0;"> |
233 | 247 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
234 | 248 | <input type="hidden" name="qaction" value="markread"> |
235 | 249 | <input type="hidden" name="redirect_url" value="action=unreadreplies', (!empty($context['showing_all_topics']) ? ';all' : ''), $context['querystring_board_limits'], '">'; |
250 | + } |
|
236 | 251 | |
237 | 252 | if (!empty($context['topics'])) |
238 | 253 | { |
@@ -258,11 +273,12 @@ discard block |
||
258 | 273 | </div>'; |
259 | 274 | |
260 | 275 | // Show a "select all" box for quick moderation? |
261 | - if ($context['showCheckboxes']) |
|
262 | - echo ' |
|
276 | + if ($context['showCheckboxes']) { |
|
277 | + echo ' |
|
263 | 278 | <div class="moderation"> |
264 | 279 | <input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');" class="input_check"> |
265 | 280 | </div>'; |
281 | + } |
|
266 | 282 | |
267 | 283 | echo ' |
268 | 284 | </div> |
@@ -281,15 +297,18 @@ discard block |
||
281 | 297 | // Now we handle the icons |
282 | 298 | echo ' |
283 | 299 | <div class="icons floatright">'; |
284 | - if ($topic['is_locked']) |
|
285 | - echo ' |
|
300 | + if ($topic['is_locked']) { |
|
301 | + echo ' |
|
286 | 302 | <span class="generic_icons lock"></span>'; |
287 | - if ($topic['is_sticky']) |
|
288 | - echo ' |
|
303 | + } |
|
304 | + if ($topic['is_sticky']) { |
|
305 | + echo ' |
|
289 | 306 | <span class="generic_icons sticky"></span>'; |
290 | - if ($topic['is_poll']) |
|
291 | - echo ' |
|
307 | + } |
|
308 | + if ($topic['is_poll']) { |
|
309 | + echo ' |
|
292 | 310 | <span class="generic_icons poll"></span>'; |
311 | + } |
|
293 | 312 | echo ' |
294 | 313 | </div>'; |
295 | 314 | |
@@ -314,11 +333,12 @@ discard block |
||
314 | 333 | ', sprintf($txt['last_post_topic'], '<a href="' . $topic['last_post']['href'] . '">' . $topic['last_post']['time'] . '</a>', $topic['last_post']['member']['link']), ' |
315 | 334 | </div>'; |
316 | 335 | |
317 | - if ($context['showCheckboxes']) |
|
318 | - echo ' |
|
336 | + if ($context['showCheckboxes']) { |
|
337 | + echo ' |
|
319 | 338 | <div class="moderation"> |
320 | 339 | <input type="checkbox" name="topics[]" value="', $topic['id'], '" class="input_check"> |
321 | 340 | </div>'; |
341 | + } |
|
322 | 342 | echo ' |
323 | 343 | </div>'; |
324 | 344 | } |
@@ -331,24 +351,26 @@ discard block |
||
331 | 351 | ', $context['menu_separator'], '<a href="#recent" class="topbottom floatleft">', $txt['go_up'], '</a> |
332 | 352 | <div class="pagelinks">', $context['page_index'], '</div> |
333 | 353 | </div>'; |
334 | - } |
|
335 | - else |
|
336 | - echo ' |
|
354 | + } else { |
|
355 | + echo ' |
|
337 | 356 | <div class="cat_bar"> |
338 | 357 | <h3 class="catbg centertext"> |
339 | 358 | ', $context['showing_all_topics'] ? $txt['topic_alert_none'] : $txt['unread_topics_visit_none'], ' |
340 | 359 | </h3> |
341 | 360 | </div>'; |
361 | + } |
|
342 | 362 | |
343 | - if ($context['showCheckboxes']) |
|
344 | - echo ' |
|
363 | + if ($context['showCheckboxes']) { |
|
364 | + echo ' |
|
345 | 365 | </form>'; |
366 | + } |
|
346 | 367 | |
347 | 368 | echo ' |
348 | 369 | </div>'; |
349 | 370 | |
350 | - if (empty($context['no_topic_listing'])) |
|
351 | - template_topic_legend(); |
|
352 | -} |
|
371 | + if (empty($context['no_topic_listing'])) { |
|
372 | + template_topic_legend(); |
|
373 | + } |
|
374 | + } |
|
353 | 375 | |
354 | 376 | ?> |
355 | 377 | \ No newline at end of file |
@@ -89,8 +89,9 @@ discard block |
||
89 | 89 | foreach ($section['areas'] as $i => $area) |
90 | 90 | { |
91 | 91 | // Not supposed to be printed? |
92 | - if (empty($area['label'])) |
|
93 | - continue; |
|
92 | + if (empty($area['label'])) { |
|
93 | + continue; |
|
94 | + } |
|
94 | 95 | |
95 | 96 | echo ' |
96 | 97 | <li', !empty($area['subsections']) ? ' class="subsections"' : '', '>'; |
@@ -99,8 +100,9 @@ discard block |
||
99 | 100 | <a class="', $area['icon_class'], !empty($area['selected']) ? ' chosen ' : '', '" href="', (isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i), $menu_context['extra_parameters'], '">', $area['icon'], $area['label'], '</a>'; |
100 | 101 | |
101 | 102 | // Is this the current area, or just some area? |
102 | - if (!empty($area['selected']) && empty($context['tabs'])) |
|
103 | - $context['tabs'] = isset($area['subsections']) ? $area['subsections'] : array(); |
|
103 | + if (!empty($area['selected']) && empty($context['tabs'])) { |
|
104 | + $context['tabs'] = isset($area['subsections']) ? $area['subsections'] : array(); |
|
105 | + } |
|
104 | 106 | |
105 | 107 | // Are there any subsections? |
106 | 108 | if (!empty($area['subsections'])) |
@@ -110,8 +112,9 @@ discard block |
||
110 | 112 | |
111 | 113 | foreach ($area['subsections'] as $sa => $sub) |
112 | 114 | { |
113 | - if (!empty($sub['disabled'])) |
|
114 | - continue; |
|
115 | + if (!empty($sub['disabled'])) { |
|
116 | + continue; |
|
117 | + } |
|
115 | 118 | |
116 | 119 | $url = isset($sub['url']) ? $sub['url'] : (isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i) . ';sa=' . $sa; |
117 | 120 | |
@@ -158,8 +161,9 @@ discard block |
||
158 | 161 | <h3 class="catbg">'; |
159 | 162 | |
160 | 163 | // The function is in Admin.template.php, but since this template is used elsewhere too better check if the function is available |
161 | - if (function_exists('template_admin_quick_search')) |
|
162 | - template_admin_quick_search(); |
|
164 | + if (function_exists('template_admin_quick_search')) { |
|
165 | + template_admin_quick_search(); |
|
166 | + } |
|
163 | 167 | |
164 | 168 | // Exactly how many tabs do we have? |
165 | 169 | if (!empty($context['tabs'])) |
@@ -174,30 +178,36 @@ discard block |
||
174 | 178 | } |
175 | 179 | |
176 | 180 | // Did this not even exist - or do we not have a label? |
177 | - if (!isset($tab_context['tabs'][$id])) |
|
178 | - $tab_context['tabs'][$id] = array('label' => $tab['label']); |
|
179 | - elseif (!isset($tab_context['tabs'][$id]['label'])) |
|
180 | - $tab_context['tabs'][$id]['label'] = $tab['label']; |
|
181 | + if (!isset($tab_context['tabs'][$id])) { |
|
182 | + $tab_context['tabs'][$id] = array('label' => $tab['label']); |
|
183 | + } elseif (!isset($tab_context['tabs'][$id]['label'])) { |
|
184 | + $tab_context['tabs'][$id]['label'] = $tab['label']; |
|
185 | + } |
|
181 | 186 | |
182 | 187 | // Has a custom URL defined in the main admin structure? |
183 | - if (isset($tab['url']) && !isset($tab_context['tabs'][$id]['url'])) |
|
184 | - $tab_context['tabs'][$id]['url'] = $tab['url']; |
|
188 | + if (isset($tab['url']) && !isset($tab_context['tabs'][$id]['url'])) { |
|
189 | + $tab_context['tabs'][$id]['url'] = $tab['url']; |
|
190 | + } |
|
185 | 191 | |
186 | 192 | // Any additional paramaters for the url? |
187 | - if (isset($tab['add_params']) && !isset($tab_context['tabs'][$id]['add_params'])) |
|
188 | - $tab_context['tabs'][$id]['add_params'] = $tab['add_params']; |
|
193 | + if (isset($tab['add_params']) && !isset($tab_context['tabs'][$id]['add_params'])) { |
|
194 | + $tab_context['tabs'][$id]['add_params'] = $tab['add_params']; |
|
195 | + } |
|
189 | 196 | |
190 | 197 | // Has it been deemed selected? |
191 | - if (!empty($tab['is_selected'])) |
|
192 | - $tab_context['tabs'][$id]['is_selected'] = true; |
|
198 | + if (!empty($tab['is_selected'])) { |
|
199 | + $tab_context['tabs'][$id]['is_selected'] = true; |
|
200 | + } |
|
193 | 201 | |
194 | 202 | // Does it have its own help? |
195 | - if (!empty($tab['help'])) |
|
196 | - $tab_context['tabs'][$id]['help'] = $tab['help']; |
|
203 | + if (!empty($tab['help'])) { |
|
204 | + $tab_context['tabs'][$id]['help'] = $tab['help']; |
|
205 | + } |
|
197 | 206 | |
198 | 207 | // Is this the last one? |
199 | - if (!empty($tab['is_last']) && !isset($tab_context['override_last'])) |
|
200 | - $tab_context['tabs'][$id]['is_last'] = true; |
|
208 | + if (!empty($tab['is_last']) && !isset($tab_context['override_last'])) { |
|
209 | + $tab_context['tabs'][$id]['is_last'] = true; |
|
210 | + } |
|
201 | 211 | } |
202 | 212 | |
203 | 213 | // Find the selected tab |
@@ -214,17 +224,18 @@ discard block |
||
214 | 224 | // Show an icon and/or a help item? |
215 | 225 | if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class']) || !empty($selected_tab['icon']) || !empty($tab_context['icon']) || !empty($selected_tab['help']) || !empty($tab_context['help'])) |
216 | 226 | { |
217 | - if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class'])) |
|
218 | - echo '<span class="', !empty($selected_tab['icon_class']) ? $selected_tab['icon_class'] : $tab_context['icon_class'], ' icon"></span>'; |
|
219 | - elseif (!empty($selected_tab['icon']) || !empty($tab_context['icon'])) |
|
220 | - echo '<img src="', $settings['images_url'], '/icons/', !empty($selected_tab['icon']) ? $selected_tab['icon'] : $tab_context['icon'], '" alt="" class="icon">'; |
|
227 | + if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class'])) { |
|
228 | + echo '<span class="', !empty($selected_tab['icon_class']) ? $selected_tab['icon_class'] : $tab_context['icon_class'], ' icon"></span>'; |
|
229 | + } elseif (!empty($selected_tab['icon']) || !empty($tab_context['icon'])) { |
|
230 | + echo '<img src="', $settings['images_url'], '/icons/', !empty($selected_tab['icon']) ? $selected_tab['icon'] : $tab_context['icon'], '" alt="" class="icon">'; |
|
231 | + } |
|
221 | 232 | |
222 | - if (!empty($selected_tab['help']) || !empty($tab_context['help'])) |
|
223 | - echo '<a href="', $scripturl, '?action=helpadmin;help=', !empty($selected_tab['help']) ? $selected_tab['help'] : $tab_context['help'], '" onclick="return reqOverlayDiv(this.href);" class="help"><span class="generic_icons help" title="', $txt['help'], '"></span></a>'; |
|
233 | + if (!empty($selected_tab['help']) || !empty($tab_context['help'])) { |
|
234 | + echo '<a href="', $scripturl, '?action=helpadmin;help=', !empty($selected_tab['help']) ? $selected_tab['help'] : $tab_context['help'], '" onclick="return reqOverlayDiv(this.href);" class="help"><span class="generic_icons help" title="', $txt['help'], '"></span></a>'; |
|
235 | + } |
|
224 | 236 | |
225 | 237 | echo $tab_context['title']; |
226 | - } |
|
227 | - else |
|
238 | + } else |
|
228 | 239 | { |
229 | 240 | echo ' |
230 | 241 | ', $tab_context['title']; |
@@ -237,11 +248,12 @@ discard block |
||
237 | 248 | } |
238 | 249 | |
239 | 250 | // Shall we use the tabs? Yes, it's the only known way! |
240 | - if (!empty($selected_tab['description']) || !empty($tab_context['description'])) |
|
241 | - echo ' |
|
251 | + if (!empty($selected_tab['description']) || !empty($tab_context['description'])) { |
|
252 | + echo ' |
|
242 | 253 | <p class="information"> |
243 | 254 | ', !empty($selected_tab['description']) ? $selected_tab['description'] : $tab_context['description'], ' |
244 | 255 | </p>'; |
256 | + } |
|
245 | 257 | |
246 | 258 | // Print out all the items in this tab (if any). |
247 | 259 | if (!empty($context['tabs'])) |
@@ -253,8 +265,9 @@ discard block |
||
253 | 265 | |
254 | 266 | foreach ($tab_context['tabs'] as $sa => $tab) |
255 | 267 | { |
256 | - if (!empty($tab['disabled'])) |
|
257 | - continue; |
|
268 | + if (!empty($tab['disabled'])) { |
|
269 | + continue; |
|
270 | + } |
|
258 | 271 | |
259 | 272 | if (!empty($tab['is_selected'])) |
260 | 273 | { |
@@ -262,12 +275,12 @@ discard block |
||
262 | 275 | <li> |
263 | 276 | <a class="active" href="', isset($tab['url']) ? $tab['url'] : $menu_context['base_url'] . ';area=' . $menu_context['current_area'] . ';sa=' . $sa, $menu_context['extra_parameters'], isset($tab['add_params']) ? $tab['add_params'] : '', '">', $tab['label'], '</a> |
264 | 277 | </li>'; |
265 | - } |
|
266 | - else |
|
267 | - echo ' |
|
278 | + } else { |
|
279 | + echo ' |
|
268 | 280 | <li> |
269 | 281 | <a href="', isset($tab['url']) ? $tab['url'] : $menu_context['base_url'] . ';area=' . $menu_context['current_area'] . ';sa=' . $sa, $menu_context['extra_parameters'], isset($tab['add_params']) ? $tab['add_params'] : '', '">', $tab['label'], '</a> |
270 | 282 | </li>'; |
283 | + } |
|
271 | 284 | } |
272 | 285 | |
273 | 286 | // the end of tabs |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
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 | * Entry point function, permission checks, admin bars, etc. |
@@ -99,27 +100,27 @@ discard block |
||
99 | 100 | 'function' => function($rowData) use ($scripturl) |
100 | 101 | { |
101 | 102 | // Since the moderator group has no explicit members, no link is needed. |
102 | - if ($rowData['id_group'] == 3) |
|
103 | - $group_name = $rowData['group_name']; |
|
104 | - else |
|
103 | + if ($rowData['id_group'] == 3) { |
|
104 | + $group_name = $rowData['group_name']; |
|
105 | + } else |
|
105 | 106 | { |
106 | 107 | $color_style = empty($rowData['online_color']) ? '' : sprintf(' style="color: %1$s;"', $rowData['online_color']); |
107 | 108 | |
108 | 109 | if (allowedTo('manage_membergroups')) |
109 | 110 | { |
110 | 111 | $group_name = sprintf('<a href="%1$s?action=admin;area=membergroups;sa=members;group=%2$d"%3$s>%4$s</a>', $scripturl, $rowData['id_group'], $color_style, $rowData['group_name']); |
111 | - } |
|
112 | - else |
|
112 | + } else |
|
113 | 113 | { |
114 | 114 | $group_name = sprintf('<a href="%1$s?action=groups;sa=members;group=%2$d"%3$s>%4$s</a>', $scripturl, $rowData['id_group'], $color_style, $rowData['group_name']); |
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
118 | 118 | // Add a help option for moderator and administrator. |
119 | - if ($rowData['id_group'] == 1) |
|
120 | - $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_administrator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
121 | - elseif ($rowData['id_group'] == 3) |
|
122 | - $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_moderator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
119 | + if ($rowData['id_group'] == 1) { |
|
120 | + $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_administrator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
121 | + } elseif ($rowData['id_group'] == 3) { |
|
122 | + $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_moderator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
123 | + } |
|
123 | 124 | |
124 | 125 | return $group_name; |
125 | 126 | }, |
@@ -198,8 +199,9 @@ discard block |
||
198 | 199 | $_REQUEST['group'] = isset($_REQUEST['group']) ? (int) $_REQUEST['group'] : 0; |
199 | 200 | |
200 | 201 | // No browsing of guests, membergroup 0 or moderators. |
201 | - if (in_array($_REQUEST['group'], array(-1, 0, 3))) |
|
202 | - fatal_lang_error('membergroup_does_not_exist', false); |
|
202 | + if (in_array($_REQUEST['group'], array(-1, 0, 3))) { |
|
203 | + fatal_lang_error('membergroup_does_not_exist', false); |
|
204 | + } |
|
203 | 205 | |
204 | 206 | // Load up the group details. |
205 | 207 | $request = $smcFunc['db_query']('', ' |
@@ -214,8 +216,9 @@ discard block |
||
214 | 216 | ) |
215 | 217 | ); |
216 | 218 | // Doesn't exist? |
217 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
218 | - fatal_lang_error('membergroup_does_not_exist', false); |
|
219 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
220 | + fatal_lang_error('membergroup_does_not_exist', false); |
|
221 | + } |
|
219 | 222 | $context['group'] = $smcFunc['db_fetch_assoc']($request); |
220 | 223 | $smcFunc['db_free_result']($request); |
221 | 224 | |
@@ -248,21 +251,25 @@ discard block |
||
248 | 251 | 'name' => $row['real_name'] |
249 | 252 | ); |
250 | 253 | |
251 | - if ($user_info['id'] == $row['id_member'] && $context['group']['group_type'] != 1) |
|
252 | - $context['group']['can_moderate'] = true; |
|
254 | + if ($user_info['id'] == $row['id_member'] && $context['group']['group_type'] != 1) { |
|
255 | + $context['group']['can_moderate'] = true; |
|
256 | + } |
|
253 | 257 | } |
254 | 258 | $smcFunc['db_free_result']($request); |
255 | 259 | |
256 | 260 | // If this group is hidden then it can only "exists" if the user can moderate it! |
257 | - if ($context['group']['hidden'] && !$context['group']['can_moderate']) |
|
258 | - fatal_lang_error('membergroup_does_not_exist', false); |
|
261 | + if ($context['group']['hidden'] && !$context['group']['can_moderate']) { |
|
262 | + fatal_lang_error('membergroup_does_not_exist', false); |
|
263 | + } |
|
259 | 264 | |
260 | 265 | // You can only assign membership if you are the moderator and/or can manage groups! |
261 | - if (!$context['group']['can_moderate']) |
|
262 | - $context['group']['assignable'] = 0; |
|
266 | + if (!$context['group']['can_moderate']) { |
|
267 | + $context['group']['assignable'] = 0; |
|
268 | + } |
|
263 | 269 | // Non-admins cannot assign admins. |
264 | - elseif ($context['group']['id'] == 1 && !allowedTo('admin_forum')) |
|
265 | - $context['group']['assignable'] = 0; |
|
270 | + elseif ($context['group']['id'] == 1 && !allowedTo('admin_forum')) { |
|
271 | + $context['group']['assignable'] = 0; |
|
272 | + } |
|
266 | 273 | |
267 | 274 | // Removing member from group? |
268 | 275 | if (isset($_POST['remove']) && !empty($_REQUEST['rem']) && is_array($_REQUEST['rem']) && $context['group']['assignable']) |
@@ -271,8 +278,9 @@ discard block |
||
271 | 278 | validateToken('mod-mgm'); |
272 | 279 | |
273 | 280 | // Make sure we're dealing with integers only. |
274 | - foreach ($_REQUEST['rem'] as $key => $group) |
|
275 | - $_REQUEST['rem'][$key] = (int) $group; |
|
281 | + foreach ($_REQUEST['rem'] as $key => $group) { |
|
282 | + $_REQUEST['rem'][$key] = (int) $group; |
|
283 | + } |
|
276 | 284 | |
277 | 285 | require_once($sourcedir . '/Subs-Membergroups.php'); |
278 | 286 | removeMembersFromGroups($_REQUEST['rem'], $_REQUEST['group'], true); |
@@ -295,16 +303,18 @@ discard block |
||
295 | 303 | { |
296 | 304 | $member_names[$index] = trim($smcFunc['strtolower']($member_names[$index])); |
297 | 305 | |
298 | - if (strlen($member_names[$index]) == 0) |
|
299 | - unset($member_names[$index]); |
|
306 | + if (strlen($member_names[$index]) == 0) { |
|
307 | + unset($member_names[$index]); |
|
308 | + } |
|
300 | 309 | } |
301 | 310 | |
302 | 311 | // Any passed by ID? |
303 | 312 | $member_ids = array(); |
304 | - if (!empty($_REQUEST['member_add'])) |
|
305 | - foreach ($_REQUEST['member_add'] as $id) |
|
313 | + if (!empty($_REQUEST['member_add'])) { |
|
314 | + foreach ($_REQUEST['member_add'] as $id) |
|
306 | 315 | if ($id > 0) |
307 | 316 | $member_ids[] = (int) $id; |
317 | + } |
|
308 | 318 | |
309 | 319 | // Construct the query pelements. |
310 | 320 | if (!empty($member_ids)) |
@@ -332,8 +342,9 @@ discard block |
||
332 | 342 | 'id_group' => $_REQUEST['group'], |
333 | 343 | )) |
334 | 344 | ); |
335 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
336 | - $members[] = $row['id_member']; |
|
345 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
346 | + $members[] = $row['id_member']; |
|
347 | + } |
|
337 | 348 | $smcFunc['db_free_result']($request); |
338 | 349 | } |
339 | 350 | |
@@ -372,10 +383,11 @@ discard block |
||
372 | 383 | $context['sort_direction'] = isset($_REQUEST['desc']) ? 'down' : 'up'; |
373 | 384 | |
374 | 385 | // The where on the query is interesting. Non-moderators should only see people who are in this group as primary. |
375 | - if ($context['group']['can_moderate']) |
|
376 | - $where = $context['group']['is_post_group'] ? 'id_post_group = {int:group}' : 'id_group = {int:group} OR FIND_IN_SET({int:group}, additional_groups) != 0'; |
|
377 | - else |
|
378 | - $where = $context['group']['is_post_group'] ? 'id_post_group = {int:group}' : 'id_group = {int:group}'; |
|
386 | + if ($context['group']['can_moderate']) { |
|
387 | + $where = $context['group']['is_post_group'] ? 'id_post_group = {int:group}' : 'id_group = {int:group} OR FIND_IN_SET({int:group}, additional_groups) != 0'; |
|
388 | + } else { |
|
389 | + $where = $context['group']['is_post_group'] ? 'id_post_group = {int:group}' : 'id_group = {int:group}'; |
|
390 | + } |
|
379 | 391 | |
380 | 392 | // Count members of the group. |
381 | 393 | $request = $smcFunc['db_query']('', ' |
@@ -416,8 +428,9 @@ discard block |
||
416 | 428 | $last_online = empty($row['last_login']) ? $txt['never'] : timeformat($row['last_login']); |
417 | 429 | |
418 | 430 | // Italicize the online note if they aren't activated. |
419 | - if ($row['is_activated'] % 10 != 1) |
|
420 | - $last_online = '<em title="' . $txt['not_activated'] . '">' . $last_online . '</em>'; |
|
431 | + if ($row['is_activated'] % 10 != 1) { |
|
432 | + $last_online = '<em title="' . $txt['not_activated'] . '">' . $last_online . '</em>'; |
|
433 | + } |
|
421 | 434 | |
422 | 435 | $context['members'][] = array( |
423 | 436 | 'id' => $row['id_member'], |
@@ -437,9 +450,10 @@ discard block |
||
437 | 450 | $context['page_title'] = $txt['membergroups_members_title'] . ': ' . $context['group']['name']; |
438 | 451 | createToken('mod-mgm'); |
439 | 452 | |
440 | - if ($context['group']['assignable']) |
|
441 | - loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest'); |
|
442 | -} |
|
453 | + if ($context['group']['assignable']) { |
|
454 | + loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest'); |
|
455 | + } |
|
456 | + } |
|
443 | 457 | |
444 | 458 | /** |
445 | 459 | * Show and manage all group requests. |
@@ -453,16 +467,18 @@ discard block |
||
453 | 467 | $context['sub_template'] = 'show_list'; |
454 | 468 | |
455 | 469 | // Verify we can be here. |
456 | - if ($user_info['mod_cache']['gq'] == '0=1') |
|
457 | - isAllowedTo('manage_membergroups'); |
|
470 | + if ($user_info['mod_cache']['gq'] == '0=1') { |
|
471 | + isAllowedTo('manage_membergroups'); |
|
472 | + } |
|
458 | 473 | |
459 | 474 | // Normally, we act normally... |
460 | 475 | $where = ($user_info['mod_cache']['gq'] == '1=1' || $user_info['mod_cache']['gq'] == '0=1' ? $user_info['mod_cache']['gq'] : 'lgr.' . $user_info['mod_cache']['gq']); |
461 | 476 | |
462 | - if (isset($_GET['closed'])) |
|
463 | - $where .= ' AND lgr.status != {int:status_open}'; |
|
464 | - else |
|
465 | - $where .= ' AND lgr.status = {int:status_open}'; |
|
477 | + if (isset($_GET['closed'])) { |
|
478 | + $where .= ' AND lgr.status != {int:status_open}'; |
|
479 | + } else { |
|
480 | + $where .= ' AND lgr.status = {int:status_open}'; |
|
481 | + } |
|
466 | 482 | |
467 | 483 | $where_parameters = array( |
468 | 484 | 'status_open' => 0, |
@@ -475,8 +491,9 @@ discard block |
||
475 | 491 | validateToken('mod-gr'); |
476 | 492 | |
477 | 493 | // Clean the values. |
478 | - foreach ($_POST['groupr'] as $k => $request) |
|
479 | - $_POST['groupr'][$k] = (int) $request; |
|
494 | + foreach ($_POST['groupr'] as $k => $request) { |
|
495 | + $_POST['groupr'][$k] = (int) $request; |
|
496 | + } |
|
480 | 497 | |
481 | 498 | $log_changes = array(); |
482 | 499 | |
@@ -513,8 +530,8 @@ discard block |
||
513 | 530 | $request_list = array(); |
514 | 531 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
515 | 532 | { |
516 | - if (!isset($log_changes[$row['id_request']])) |
|
517 | - $log_changes[$row['id_request']] = array( |
|
533 | + if (!isset($log_changes[$row['id_request']])) { |
|
534 | + $log_changes[$row['id_request']] = array( |
|
518 | 535 | 'id_request' => $row['id_request'], |
519 | 536 | 'status' => $_POST['req_action'] == 'approve' ? 1 : 2, // 1 = approved, 2 = rejected |
520 | 537 | 'id_member_acted' => $user_info['id'], |
@@ -522,6 +539,7 @@ discard block |
||
522 | 539 | 'time_acted' => time(), |
523 | 540 | 'act_reason' => $_POST['req_action'] != 'approve' && !empty($_POST['groupreason']) && !empty($_POST['groupreason'][$row['id_request']]) ? $smcFunc['htmlspecialchars']($_POST['groupreason'][$row['id_request']], ENT_QUOTES) : '', |
524 | 541 | ); |
542 | + } |
|
525 | 543 | $request_list[] = $row['id_request']; |
526 | 544 | } |
527 | 545 | $smcFunc['db_free_result']($request); |
@@ -744,21 +762,24 @@ discard block |
||
744 | 762 | $group_requests = array(); |
745 | 763 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
746 | 764 | { |
747 | - if (empty($row['reason'])) |
|
748 | - $reason = '<em>(' . $txt['mc_groupr_no_reason'] . ')</em>'; |
|
749 | - else |
|
750 | - $reason = censorText($row['reason']); |
|
765 | + if (empty($row['reason'])) { |
|
766 | + $reason = '<em>(' . $txt['mc_groupr_no_reason'] . ')</em>'; |
|
767 | + } else { |
|
768 | + $reason = censorText($row['reason']); |
|
769 | + } |
|
751 | 770 | |
752 | 771 | if (isset($_GET['closed'])) |
753 | 772 | { |
754 | - if ($row['status'] == 1) |
|
755 | - $reason .= '<br><br><strong>' . $txt['mc_groupr_approved'] . '</strong>'; |
|
756 | - elseif ($row['status'] == 2) |
|
757 | - $reason .= '<br><br><strong>' . $txt['mc_groupr_rejected'] . '</strong>'; |
|
773 | + if ($row['status'] == 1) { |
|
774 | + $reason .= '<br><br><strong>' . $txt['mc_groupr_approved'] . '</strong>'; |
|
775 | + } elseif ($row['status'] == 2) { |
|
776 | + $reason .= '<br><br><strong>' . $txt['mc_groupr_rejected'] . '</strong>'; |
|
777 | + } |
|
758 | 778 | |
759 | 779 | $reason .= ' (' . timeformat($row['time_acted']) . ')'; |
760 | - if (!empty($row['act_reason'])) |
|
761 | - $reason .= '<br><br>' . censorText($row['act_reason']); |
|
780 | + if (!empty($row['act_reason'])) { |
|
781 | + $reason .= '<br><br>' . censorText($row['act_reason']); |
|
782 | + } |
|
762 | 783 | } |
763 | 784 | |
764 | 785 | $group_requests[] = array( |
@@ -259,8 +259,8 @@ |
||
259 | 259 | $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
260 | 260 | |
261 | 261 | $js_time_string = str_replace( |
262 | - array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
|
263 | - array('H', 'G', 'h', 'g', 'i', 'A', 'a', 'h:i:s A', 'H:i', 's', 'H:i:s', 'H:i:s'), |
|
262 | + array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
|
263 | + array('H', 'G', 'h', 'g', 'i', 'A', 'a', 'h:i:s A', 'H:i', 's', 'H:i:s', 'H:i:s'), |
|
264 | 264 | $time_string |
265 | 265 | ); |
266 | 266 |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 3 |
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 | * Handles showing the post screen, loading the post to be modified, and loading any post quoted. |
@@ -35,12 +36,14 @@ discard block |
||
35 | 36 | global $sourcedir, $smcFunc, $language; |
36 | 37 | |
37 | 38 | loadLanguage('Post'); |
38 | - if (!empty($modSettings['drafts_post_enabled'])) |
|
39 | - loadLanguage('Drafts'); |
|
39 | + if (!empty($modSettings['drafts_post_enabled'])) { |
|
40 | + loadLanguage('Drafts'); |
|
41 | + } |
|
40 | 42 | |
41 | 43 | // You can't reply with a poll... hacker. |
42 | - if (isset($_REQUEST['poll']) && !empty($topic) && !isset($_REQUEST['msg'])) |
|
43 | - unset($_REQUEST['poll']); |
|
44 | + if (isset($_REQUEST['poll']) && !empty($topic) && !isset($_REQUEST['msg'])) { |
|
45 | + unset($_REQUEST['poll']); |
|
46 | + } |
|
44 | 47 | |
45 | 48 | // Posting an event? |
46 | 49 | $context['make_event'] = isset($_REQUEST['calendar']); |
@@ -55,8 +58,9 @@ discard block |
||
55 | 58 | $context['auto_notify'] = !empty($context['notify_prefs']['msg_auto_notify']); |
56 | 59 | |
57 | 60 | // You must be posting to *some* board. |
58 | - if (empty($board) && !$context['make_event']) |
|
59 | - fatal_lang_error('no_board', false); |
|
61 | + if (empty($board) && !$context['make_event']) { |
|
62 | + fatal_lang_error('no_board', false); |
|
63 | + } |
|
60 | 64 | |
61 | 65 | require_once($sourcedir . '/Subs-Post.php'); |
62 | 66 | |
@@ -79,10 +83,11 @@ discard block |
||
79 | 83 | array( |
80 | 84 | 'msg' => (int) $_REQUEST['msg'], |
81 | 85 | )); |
82 | - if ($smcFunc['db_num_rows']($request) != 1) |
|
83 | - unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']); |
|
84 | - else |
|
85 | - list ($topic) = $smcFunc['db_fetch_row']($request); |
|
86 | + if ($smcFunc['db_num_rows']($request) != 1) { |
|
87 | + unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']); |
|
88 | + } else { |
|
89 | + list ($topic) = $smcFunc['db_fetch_row']($request); |
|
90 | + } |
|
86 | 91 | $smcFunc['db_free_result']($request); |
87 | 92 | } |
88 | 93 | |
@@ -109,33 +114,36 @@ discard block |
||
109 | 114 | $smcFunc['db_free_result']($request); |
110 | 115 | |
111 | 116 | // If this topic already has a poll, they sure can't add another. |
112 | - if (isset($_REQUEST['poll']) && $pollID > 0) |
|
113 | - unset($_REQUEST['poll']); |
|
117 | + if (isset($_REQUEST['poll']) && $pollID > 0) { |
|
118 | + unset($_REQUEST['poll']); |
|
119 | + } |
|
114 | 120 | |
115 | 121 | if (empty($_REQUEST['msg'])) |
116 | 122 | { |
117 | - if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any'))) |
|
118 | - is_not_guest(); |
|
123 | + if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any'))) { |
|
124 | + is_not_guest(); |
|
125 | + } |
|
119 | 126 | |
120 | 127 | // By default the reply will be approved... |
121 | 128 | $context['becomes_approved'] = true; |
122 | 129 | if ($id_member_poster != $user_info['id'] || $user_info['is_guest']) |
123 | 130 | { |
124 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) |
|
125 | - $context['becomes_approved'] = false; |
|
126 | - else |
|
127 | - isAllowedTo('post_reply_any'); |
|
128 | - } |
|
129 | - elseif (!allowedTo('post_reply_any')) |
|
131 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) { |
|
132 | + $context['becomes_approved'] = false; |
|
133 | + } else { |
|
134 | + isAllowedTo('post_reply_any'); |
|
135 | + } |
|
136 | + } elseif (!allowedTo('post_reply_any')) |
|
130 | 137 | { |
131 | - if ($modSettings['postmod_active'] && ((allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) || allowedTo('post_unapproved_replies_any'))) |
|
132 | - $context['becomes_approved'] = false; |
|
133 | - else |
|
134 | - isAllowedTo('post_reply_own'); |
|
138 | + if ($modSettings['postmod_active'] && ((allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) || allowedTo('post_unapproved_replies_any'))) { |
|
139 | + $context['becomes_approved'] = false; |
|
140 | + } else { |
|
141 | + isAllowedTo('post_reply_own'); |
|
142 | + } |
|
135 | 143 | } |
144 | + } else { |
|
145 | + $context['becomes_approved'] = true; |
|
136 | 146 | } |
137 | - else |
|
138 | - $context['becomes_approved'] = true; |
|
139 | 147 | |
140 | 148 | $context['can_lock'] = allowedTo('lock_any') || ($user_info['id'] == $id_member_poster && allowedTo('lock_own')); |
141 | 149 | $context['can_sticky'] = allowedTo('make_sticky'); |
@@ -147,18 +155,19 @@ discard block |
||
147 | 155 | $context['sticky'] = isset($_REQUEST['sticky']) ? !empty($_REQUEST['sticky']) : $sticky; |
148 | 156 | |
149 | 157 | // Check whether this is a really old post being bumped... |
150 | - if (!empty($modSettings['oldTopicDays']) && $lastPostTime + $modSettings['oldTopicDays'] * 86400 < time() && empty($sticky) && !isset($_REQUEST['subject'])) |
|
151 | - $post_errors[] = array('old_topic', array($modSettings['oldTopicDays'])); |
|
152 | - } |
|
153 | - else |
|
158 | + if (!empty($modSettings['oldTopicDays']) && $lastPostTime + $modSettings['oldTopicDays'] * 86400 < time() && empty($sticky) && !isset($_REQUEST['subject'])) { |
|
159 | + $post_errors[] = array('old_topic', array($modSettings['oldTopicDays'])); |
|
160 | + } |
|
161 | + } else |
|
154 | 162 | { |
155 | 163 | $context['becomes_approved'] = true; |
156 | 164 | if ((!$context['make_event'] || !empty($board))) |
157 | 165 | { |
158 | - if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) |
|
159 | - $context['becomes_approved'] = false; |
|
160 | - else |
|
161 | - isAllowedTo('post_new'); |
|
166 | + if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) { |
|
167 | + $context['becomes_approved'] = false; |
|
168 | + } else { |
|
169 | + isAllowedTo('post_new'); |
|
170 | + } |
|
162 | 171 | } |
163 | 172 | |
164 | 173 | $locked = 0; |
@@ -190,20 +199,24 @@ discard block |
||
190 | 199 | unset($_SESSION['already_attached']); |
191 | 200 | |
192 | 201 | // Don't allow a post if it's locked and you aren't all powerful. |
193 | - if ($locked && !allowedTo('moderate_board')) |
|
194 | - fatal_lang_error('topic_locked', false); |
|
202 | + if ($locked && !allowedTo('moderate_board')) { |
|
203 | + fatal_lang_error('topic_locked', false); |
|
204 | + } |
|
195 | 205 | // Check the users permissions - is the user allowed to add or post a poll? |
196 | 206 | if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1') |
197 | 207 | { |
198 | 208 | // New topic, new poll. |
199 | - if (empty($topic)) |
|
200 | - isAllowedTo('poll_post'); |
|
209 | + if (empty($topic)) { |
|
210 | + isAllowedTo('poll_post'); |
|
211 | + } |
|
201 | 212 | // This is an old topic - but it is yours! Can you add to it? |
202 | - elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any')) |
|
203 | - isAllowedTo('poll_add_own'); |
|
213 | + elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any')) { |
|
214 | + isAllowedTo('poll_add_own'); |
|
215 | + } |
|
204 | 216 | // If you're not the owner, can you add to any poll? |
205 | - else |
|
206 | - isAllowedTo('poll_add_any'); |
|
217 | + else { |
|
218 | + isAllowedTo('poll_add_any'); |
|
219 | + } |
|
207 | 220 | |
208 | 221 | require_once($sourcedir . '/Subs-Members.php'); |
209 | 222 | $allowedVoteGroups = groupsAllowedTo('poll_vote', $board); |
@@ -232,8 +245,9 @@ discard block |
||
232 | 245 | if ($context['make_event']) |
233 | 246 | { |
234 | 247 | // They might want to pick a board. |
235 | - if (!isset($context['current_board'])) |
|
236 | - $context['current_board'] = 0; |
|
248 | + if (!isset($context['current_board'])) { |
|
249 | + $context['current_board'] = 0; |
|
250 | + } |
|
237 | 251 | |
238 | 252 | // Start loading up the event info. |
239 | 253 | $context['event'] = array(); |
@@ -247,10 +261,11 @@ discard block |
||
247 | 261 | isAllowedTo('calendar_post'); |
248 | 262 | |
249 | 263 | // We want a fairly compact version of the time, but as close as possible to the user's settings. |
250 | - if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
251 | - $time_string = '%k:%M'; |
|
252 | - else |
|
253 | - $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
264 | + if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
265 | + $time_string = '%k:%M'; |
|
266 | + } else { |
|
267 | + $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
268 | + } |
|
254 | 269 | |
255 | 270 | $js_time_string = str_replace( |
256 | 271 | array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
@@ -272,8 +287,7 @@ discard block |
||
272 | 287 | require_once($sourcedir . '/Subs-Calendar.php'); |
273 | 288 | $eventProperties = getEventProperties($context['event']['id']); |
274 | 289 | $context['event'] = array_merge($context['event'], $eventProperties); |
275 | - } |
|
276 | - else |
|
290 | + } else |
|
277 | 291 | { |
278 | 292 | // Get the current event information. |
279 | 293 | require_once($sourcedir . '/Subs-Calendar.php'); |
@@ -281,15 +295,18 @@ discard block |
||
281 | 295 | $context['event'] = array_merge($context['event'], $eventProperties); |
282 | 296 | |
283 | 297 | // Make sure the year and month are in the valid range. |
284 | - if ($context['event']['month'] < 1 || $context['event']['month'] > 12) |
|
285 | - fatal_lang_error('invalid_month', false); |
|
286 | - if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > $modSettings['cal_maxyear']) |
|
287 | - fatal_lang_error('invalid_year', false); |
|
298 | + if ($context['event']['month'] < 1 || $context['event']['month'] > 12) { |
|
299 | + fatal_lang_error('invalid_month', false); |
|
300 | + } |
|
301 | + if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > $modSettings['cal_maxyear']) { |
|
302 | + fatal_lang_error('invalid_year', false); |
|
303 | + } |
|
288 | 304 | |
289 | 305 | // Get a list of boards they can post in. |
290 | 306 | $boards = boardsAllowedTo('post_new'); |
291 | - if (empty($boards)) |
|
292 | - fatal_lang_error('cannot_post_new', 'user'); |
|
307 | + if (empty($boards)) { |
|
308 | + fatal_lang_error('cannot_post_new', 'user'); |
|
309 | + } |
|
293 | 310 | |
294 | 311 | // Load a list of boards for this event in the context. |
295 | 312 | require_once($sourcedir . '/Subs-MessageIndex.php'); |
@@ -408,10 +425,11 @@ discard block |
||
408 | 425 | |
409 | 426 | if (!empty($context['new_replies'])) |
410 | 427 | { |
411 | - if ($context['new_replies'] == 1) |
|
412 | - $txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply']; |
|
413 | - else |
|
414 | - $txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']); |
|
428 | + if ($context['new_replies'] == 1) { |
|
429 | + $txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply']; |
|
430 | + } else { |
|
431 | + $txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']); |
|
432 | + } |
|
415 | 433 | |
416 | 434 | $post_errors[] = 'new_replies'; |
417 | 435 | |
@@ -423,9 +441,9 @@ discard block |
||
423 | 441 | // Get a response prefix (like 'Re:') in the default forum language. |
424 | 442 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
425 | 443 | { |
426 | - if ($language === $user_info['language']) |
|
427 | - $context['response_prefix'] = $txt['response_prefix']; |
|
428 | - else |
|
444 | + if ($language === $user_info['language']) { |
|
445 | + $context['response_prefix'] = $txt['response_prefix']; |
|
446 | + } else |
|
429 | 447 | { |
430 | 448 | loadLanguage('index', $language, false); |
431 | 449 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -438,8 +456,9 @@ discard block |
||
438 | 456 | // Do we have a body, but an error happened. |
439 | 457 | if (isset($_REQUEST['message']) || isset($_REQUEST['quickReply']) || !empty($context['post_error'])) |
440 | 458 | { |
441 | - if (isset($_REQUEST['quickReply'])) |
|
442 | - $_REQUEST['message'] = $_REQUEST['quickReply']; |
|
459 | + if (isset($_REQUEST['quickReply'])) { |
|
460 | + $_REQUEST['message'] = $_REQUEST['quickReply']; |
|
461 | + } |
|
443 | 462 | |
444 | 463 | // Validate inputs. |
445 | 464 | if (empty($context['post_error'])) |
@@ -447,15 +466,17 @@ discard block |
||
447 | 466 | // This means they didn't click Post and get an error. |
448 | 467 | $really_previewing = true; |
449 | 468 | |
450 | - } |
|
451 | - else |
|
469 | + } else |
|
452 | 470 | { |
453 | - if (!isset($_REQUEST['subject'])) |
|
454 | - $_REQUEST['subject'] = ''; |
|
455 | - if (!isset($_REQUEST['message'])) |
|
456 | - $_REQUEST['message'] = ''; |
|
457 | - if (!isset($_REQUEST['icon'])) |
|
458 | - $_REQUEST['icon'] = 'xx'; |
|
471 | + if (!isset($_REQUEST['subject'])) { |
|
472 | + $_REQUEST['subject'] = ''; |
|
473 | + } |
|
474 | + if (!isset($_REQUEST['message'])) { |
|
475 | + $_REQUEST['message'] = ''; |
|
476 | + } |
|
477 | + if (!isset($_REQUEST['icon'])) { |
|
478 | + $_REQUEST['icon'] = 'xx'; |
|
479 | + } |
|
459 | 480 | |
460 | 481 | // They are previewing if they asked to preview (i.e. came from quick reply). |
461 | 482 | $really_previewing = !empty($_POST['preview']); |
@@ -471,8 +492,9 @@ discard block |
||
471 | 492 | $form_message = $smcFunc['htmlspecialchars']($_REQUEST['message'], ENT_QUOTES); |
472 | 493 | |
473 | 494 | // Make sure the subject isn't too long - taking into account special characters. |
474 | - if ($smcFunc['strlen']($form_subject) > 100) |
|
475 | - $form_subject = $smcFunc['substr']($form_subject, 0, 100); |
|
495 | + if ($smcFunc['strlen']($form_subject) > 100) { |
|
496 | + $form_subject = $smcFunc['substr']($form_subject, 0, 100); |
|
497 | + } |
|
476 | 498 | |
477 | 499 | if (isset($_REQUEST['poll'])) |
478 | 500 | { |
@@ -484,8 +506,9 @@ discard block |
||
484 | 506 | $_POST['options'] = empty($_POST['options']) ? array() : htmlspecialchars__recursive($_POST['options']); |
485 | 507 | foreach ($_POST['options'] as $option) |
486 | 508 | { |
487 | - if (trim($option) == '') |
|
488 | - continue; |
|
509 | + if (trim($option) == '') { |
|
510 | + continue; |
|
511 | + } |
|
489 | 512 | |
490 | 513 | $context['choices'][] = array( |
491 | 514 | 'id' => $choice_id++, |
@@ -547,13 +570,14 @@ discard block |
||
547 | 570 | $context['preview_subject'] = $form_subject; |
548 | 571 | |
549 | 572 | censorText($context['preview_subject']); |
573 | + } else { |
|
574 | + $context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>'; |
|
550 | 575 | } |
551 | - else |
|
552 | - $context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>'; |
|
553 | 576 | |
554 | 577 | // Protect any CDATA blocks. |
555 | - if (isset($_REQUEST['xml'])) |
|
556 | - $context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]><![CDATA[>')); |
|
578 | + if (isset($_REQUEST['xml'])) { |
|
579 | + $context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]>< == 0) |
|
596 | - fatal_lang_error('no_board', false); |
|
619 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
620 | + fatal_lang_error('no_board', false); |
|
621 | + } |
|
597 | 622 | $row = $smcFunc['db_fetch_assoc']($request); |
598 | 623 | |
599 | 624 | $attachment_stuff = array($row); |
600 | - while ($row2 = $smcFunc['db_fetch_assoc']($request)) |
|
601 | - $attachment_stuff[] = $row2; |
|
625 | + while ($row2 = $smcFunc['db_fetch_assoc']($request)) { |
|
626 | + $attachment_stuff[] = $row2; |
|
627 | + } |
|
602 | 628 | $smcFunc['db_free_result']($request); |
603 | 629 | |
604 | 630 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
605 | 631 | { |
606 | 632 | // Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public. |
607 | - if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
608 | - fatal_lang_error('modify_post_time_passed', false); |
|
609 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) |
|
610 | - isAllowedTo('modify_replies'); |
|
611 | - else |
|
612 | - isAllowedTo('modify_own'); |
|
633 | + if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
634 | + fatal_lang_error('modify_post_time_passed', false); |
|
635 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
636 | + isAllowedTo('modify_replies'); |
|
637 | + } else { |
|
638 | + isAllowedTo('modify_own'); |
|
639 | + } |
|
640 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
641 | + isAllowedTo('modify_replies'); |
|
642 | + } else { |
|
643 | + isAllowedTo('modify_any'); |
|
613 | 644 | } |
614 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) |
|
615 | - isAllowedTo('modify_replies'); |
|
616 | - else |
|
617 | - isAllowedTo('modify_any'); |
|
618 | 645 | |
619 | 646 | if ($context['can_announce'] && !empty($row['id_action'])) |
620 | 647 | { |
@@ -638,8 +665,9 @@ discard block |
||
638 | 665 | |
639 | 666 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
640 | 667 | { |
641 | - if ($row['filesize'] <= 0) |
|
642 | - continue; |
|
668 | + if ($row['filesize'] <= 0) { |
|
669 | + continue; |
|
670 | + } |
|
643 | 671 | $context['current_attachments'][$row['id_attach']] = array( |
644 | 672 | 'name' => $smcFunc['htmlspecialchars']($row['filename']), |
645 | 673 | 'size' => $row['filesize'], |
@@ -709,29 +737,32 @@ discard block |
||
709 | 737 | ) |
710 | 738 | ); |
711 | 739 | // The message they were trying to edit was most likely deleted. |
712 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
713 | - fatal_lang_error('no_message', false); |
|
740 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
741 | + fatal_lang_error('no_message', false); |
|
742 | + } |
|
714 | 743 | $row = $smcFunc['db_fetch_assoc']($request); |
715 | 744 | |
716 | 745 | $attachment_stuff = array($row); |
717 | - while ($row2 = $smcFunc['db_fetch_assoc']($request)) |
|
718 | - $attachment_stuff[] = $row2; |
|
746 | + while ($row2 = $smcFunc['db_fetch_assoc']($request)) { |
|
747 | + $attachment_stuff[] = $row2; |
|
748 | + } |
|
719 | 749 | $smcFunc['db_free_result']($request); |
720 | 750 | |
721 | 751 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
722 | 752 | { |
723 | 753 | // Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public. |
724 | - if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
725 | - fatal_lang_error('modify_post_time_passed', false); |
|
726 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) |
|
727 | - isAllowedTo('modify_replies'); |
|
728 | - else |
|
729 | - isAllowedTo('modify_own'); |
|
754 | + if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
755 | + fatal_lang_error('modify_post_time_passed', false); |
|
756 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
757 | + isAllowedTo('modify_replies'); |
|
758 | + } else { |
|
759 | + isAllowedTo('modify_own'); |
|
760 | + } |
|
761 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
762 | + isAllowedTo('modify_replies'); |
|
763 | + } else { |
|
764 | + isAllowedTo('modify_any'); |
|
730 | 765 | } |
731 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) |
|
732 | - isAllowedTo('modify_replies'); |
|
733 | - else |
|
734 | - isAllowedTo('modify_any'); |
|
735 | 766 | |
736 | 767 | if ($context['can_announce'] && !empty($row['id_action'])) |
737 | 768 | { |
@@ -758,15 +789,17 @@ discard block |
||
758 | 789 | $context['icon'] = $row['icon']; |
759 | 790 | |
760 | 791 | // Show an "approve" box if the user can approve it, and the message isn't approved. |
761 | - if (!$row['approved'] && !$context['show_approval']) |
|
762 | - $context['show_approval'] = allowedTo('approve_posts'); |
|
792 | + if (!$row['approved'] && !$context['show_approval']) { |
|
793 | + $context['show_approval'] = allowedTo('approve_posts'); |
|
794 | + } |
|
763 | 795 | |
764 | 796 | // Sort the attachments so they are in the order saved |
765 | 797 | $temp = array(); |
766 | 798 | foreach ($attachment_stuff as $attachment) |
767 | 799 | { |
768 | - if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable'])) |
|
769 | - $temp[$attachment['id_attach']] = $attachment; |
|
800 | + if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable'])) { |
|
801 | + $temp[$attachment['id_attach']] = $attachment; |
|
802 | + } |
|
770 | 803 | |
771 | 804 | } |
772 | 805 | ksort($temp); |
@@ -828,14 +861,16 @@ discard block |
||
828 | 861 | 'is_approved' => 1, |
829 | 862 | ) |
830 | 863 | ); |
831 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
832 | - fatal_lang_error('quoted_post_deleted', false); |
|
864 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
865 | + fatal_lang_error('quoted_post_deleted', false); |
|
866 | + } |
|
833 | 867 | list ($form_subject, $mname, $mdate, $form_message) = $smcFunc['db_fetch_row']($request); |
834 | 868 | $smcFunc['db_free_result']($request); |
835 | 869 | |
836 | 870 | // Add 'Re: ' to the front of the quoted subject. |
837 | - if (trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) |
|
838 | - $form_subject = $context['response_prefix'] . $form_subject; |
|
871 | + if (trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
872 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
873 | + } |
|
839 | 874 | |
840 | 875 | // Censor the message and subject. |
841 | 876 | censorText($form_message); |
@@ -848,10 +883,11 @@ discard block |
||
848 | 883 | for ($i = 0, $n = count($parts); $i < $n; $i++) |
849 | 884 | { |
850 | 885 | // It goes 0 = outside, 1 = begin tag, 2 = inside, 3 = close tag, repeat. |
851 | - if ($i % 4 == 0) |
|
852 | - $parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) |
|
886 | + if ($i % 4 == 0) { |
|
887 | + $parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) |
|
853 | 888 | { |
854 | 889 | return '[html]' . preg_replace('~<br\s?/?' . '>~i', '<br /><br>', "$m[1]") . '[/html]'; |
890 | + } |
|
855 | 891 | }, $parts[$i]); |
856 | 892 | } |
857 | 893 | $form_message = implode('', $parts); |
@@ -860,8 +896,9 @@ discard block |
||
860 | 896 | $form_message = preg_replace('~<br ?/?' . '>~i', "\n", $form_message); |
861 | 897 | |
862 | 898 | // Remove any nested quotes, if necessary. |
863 | - if (!empty($modSettings['removeNestedQuotes'])) |
|
864 | - $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
899 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
900 | + $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
901 | + } |
|
865 | 902 | |
866 | 903 | // Add a quote string on the front and end. |
867 | 904 | $form_message = '[quote author=' . $mname . ' link=msg=' . (int) $_REQUEST['quote'] . ' date=' . $mdate . ']' . "\n" . rtrim($form_message) . "\n" . '[/quote]'; |
@@ -873,15 +910,15 @@ discard block |
||
873 | 910 | $form_subject = $first_subject; |
874 | 911 | |
875 | 912 | // Add 'Re: ' to the front of the subject. |
876 | - if (trim($context['response_prefix']) != '' && $form_subject != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) |
|
877 | - $form_subject = $context['response_prefix'] . $form_subject; |
|
913 | + if (trim($context['response_prefix']) != '' && $form_subject != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
914 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
915 | + } |
|
878 | 916 | |
879 | 917 | // Censor the subject. |
880 | 918 | censorText($form_subject); |
881 | 919 | |
882 | 920 | $form_message = ''; |
883 | - } |
|
884 | - else |
|
921 | + } else |
|
885 | 922 | { |
886 | 923 | $form_subject = isset($_GET['subject']) ? $_GET['subject'] : ''; |
887 | 924 | $form_message = ''; |
@@ -899,13 +936,15 @@ discard block |
||
899 | 936 | if (isset($_REQUEST['msg'])) |
900 | 937 | { |
901 | 938 | $context['attachments']['quantity'] = count($context['current_attachments']); |
902 | - foreach ($context['current_attachments'] as $attachment) |
|
903 | - $context['attachments']['total_size'] += $attachment['size']; |
|
939 | + foreach ($context['current_attachments'] as $attachment) { |
|
940 | + $context['attachments']['total_size'] += $attachment['size']; |
|
941 | + } |
|
904 | 942 | } |
905 | 943 | |
906 | 944 | // A bit of house keeping first. |
907 | - if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) |
|
908 | - unset($_SESSION['temp_attachments']); |
|
945 | + if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) { |
|
946 | + unset($_SESSION['temp_attachments']); |
|
947 | + } |
|
909 | 948 | |
910 | 949 | if (!empty($_SESSION['temp_attachments'])) |
911 | 950 | { |
@@ -914,9 +953,10 @@ discard block |
||
914 | 953 | { |
915 | 954 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
916 | 955 | { |
917 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
918 | - if (file_exists($attachment['tmp_name'])) |
|
956 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) { |
|
957 | + if (file_exists($attachment['tmp_name'])) |
|
919 | 958 | unlink($attachment['tmp_name']); |
959 | + } |
|
920 | 960 | } |
921 | 961 | $post_errors[] = 'temp_attachments_gone'; |
922 | 962 | $_SESSION['temp_attachments'] = array(); |
@@ -930,8 +970,9 @@ discard block |
||
930 | 970 | // See if any files still exist before showing the warning message and the files attached. |
931 | 971 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
932 | 972 | { |
933 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
934 | - continue; |
|
973 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
974 | + continue; |
|
975 | + } |
|
935 | 976 | |
936 | 977 | if (file_exists($attachment['tmp_name'])) |
937 | 978 | { |
@@ -941,20 +982,21 @@ discard block |
||
941 | 982 | break; |
942 | 983 | } |
943 | 984 | } |
944 | - } |
|
945 | - else |
|
985 | + } else |
|
946 | 986 | { |
947 | 987 | // Since, they don't belong here. Let's inform the user that they exist.. |
948 | - if (!empty($topic)) |
|
949 | - $delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp'; |
|
950 | - else |
|
951 | - $delete_url = $scripturl . '?action=post;board=' . $board . ';delete_temp'; |
|
988 | + if (!empty($topic)) { |
|
989 | + $delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp'; |
|
990 | + } else { |
|
991 | + $delete_url = $scripturl . '?action=post;board=' . $board . ';delete_temp'; |
|
992 | + } |
|
952 | 993 | |
953 | 994 | // Compile a list of the files to show the user. |
954 | 995 | $file_list = array(); |
955 | - foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
956 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
996 | + foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) { |
|
997 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
957 | 998 | $file_list[] = $attachment['name']; |
999 | + } |
|
958 | 1000 | |
959 | 1001 | $_SESSION['temp_attachments']['post']['files'] = $file_list; |
960 | 1002 | $file_list = '<div class="attachments">' . implode('<br>', $file_list) . '</div>'; |
@@ -966,8 +1008,7 @@ discard block |
||
966 | 1008 | |
967 | 1009 | $post_errors[] = array('temp_attachments_found', array($delete_url, $goback_url, $file_list)); |
968 | 1010 | $context['ignore_temp_attachments'] = true; |
969 | - } |
|
970 | - else |
|
1011 | + } else |
|
971 | 1012 | { |
972 | 1013 | $post_errors[] = array('temp_attachments_lost', array($delete_url, $file_list)); |
973 | 1014 | $context['ignore_temp_attachments'] = true; |
@@ -975,16 +1016,19 @@ discard block |
||
975 | 1016 | } |
976 | 1017 | } |
977 | 1018 | |
978 | - if (!empty($context['we_are_history'])) |
|
979 | - $post_errors[] = $context['we_are_history']; |
|
1019 | + if (!empty($context['we_are_history'])) { |
|
1020 | + $post_errors[] = $context['we_are_history']; |
|
1021 | + } |
|
980 | 1022 | |
981 | 1023 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
982 | 1024 | { |
983 | - if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files'])) |
|
984 | - break; |
|
1025 | + if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files'])) { |
|
1026 | + break; |
|
1027 | + } |
|
985 | 1028 | |
986 | - if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
987 | - continue; |
|
1029 | + if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
1030 | + continue; |
|
1031 | + } |
|
988 | 1032 | |
989 | 1033 | if ($attachID == 'initial_error') |
990 | 1034 | { |
@@ -999,15 +1043,17 @@ discard block |
||
999 | 1043 | { |
1000 | 1044 | $txt['error_attach_errors'] = empty($txt['error_attach_errors']) ? '<br>' : ''; |
1001 | 1045 | $txt['error_attach_errors'] .= vsprintf($txt['attach_warning'], $attachment['name']) . '<div style="padding: 0 1em;">'; |
1002 | - foreach ($attachment['errors'] as $error) |
|
1003 | - $txt['error_attach_errors'] .= (is_array($error) ? vsprintf($txt[$error[0]], $error[1]) : $txt[$error]) . '<br >'; |
|
1046 | + foreach ($attachment['errors'] as $error) { |
|
1047 | + $txt['error_attach_errors'] .= (is_array($error) ? vsprintf($txt[$error[0]], $error[1]) : $txt[$error]) . '<br >'; |
|
1048 | + } |
|
1004 | 1049 | $txt['error_attach_errors'] .= '</div>'; |
1005 | 1050 | $post_errors[] = 'attach_errors'; |
1006 | 1051 | |
1007 | 1052 | // Take out the trash. |
1008 | 1053 | unset($_SESSION['temp_attachments'][$attachID]); |
1009 | - if (file_exists($attachment['tmp_name'])) |
|
1010 | - unlink($attachment['tmp_name']); |
|
1054 | + if (file_exists($attachment['tmp_name'])) { |
|
1055 | + unlink($attachment['tmp_name']); |
|
1056 | + } |
|
1011 | 1057 | continue; |
1012 | 1058 | } |
1013 | 1059 | |
@@ -1020,8 +1066,9 @@ discard block |
||
1020 | 1066 | |
1021 | 1067 | $context['attachments']['quantity']++; |
1022 | 1068 | $context['attachments']['total_size'] += $attachment['size']; |
1023 | - if (!isset($context['files_in_session_warning'])) |
|
1024 | - $context['files_in_session_warning'] = $txt['attached_files_in_session']; |
|
1069 | + if (!isset($context['files_in_session_warning'])) { |
|
1070 | + $context['files_in_session_warning'] = $txt['attached_files_in_session']; |
|
1071 | + } |
|
1025 | 1072 | |
1026 | 1073 | $context['current_attachments'][$attachID] = array( |
1027 | 1074 | 'name' => '<u>' . $smcFunc['htmlspecialchars']($attachment['name']) . '</u>', |
@@ -1049,8 +1096,9 @@ discard block |
||
1049 | 1096 | } |
1050 | 1097 | |
1051 | 1098 | // If they came from quick reply, and have to enter verification details, give them some notice. |
1052 | - if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification'])) |
|
1053 | - $post_errors[] = 'need_qr_verification'; |
|
1099 | + if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification'])) { |
|
1100 | + $post_errors[] = 'need_qr_verification'; |
|
1101 | + } |
|
1054 | 1102 | |
1055 | 1103 | /* |
1056 | 1104 | * There are two error types: serious and minor. Serious errors |
@@ -1067,52 +1115,56 @@ discard block |
||
1067 | 1115 | { |
1068 | 1116 | loadLanguage('Errors'); |
1069 | 1117 | $context['error_type'] = 'minor'; |
1070 | - foreach ($post_errors as $post_error) |
|
1071 | - if (is_array($post_error)) |
|
1118 | + foreach ($post_errors as $post_error) { |
|
1119 | + if (is_array($post_error)) |
|
1072 | 1120 | { |
1073 | 1121 | $post_error_id = $post_error[0]; |
1122 | + } |
|
1074 | 1123 | $context['post_error'][$post_error_id] = vsprintf($txt['error_' . $post_error_id], $post_error[1]); |
1075 | 1124 | |
1076 | 1125 | // If it's not a minor error flag it as such. |
1077 | - if (!in_array($post_error_id, $minor_errors)) |
|
1078 | - $context['error_type'] = 'serious'; |
|
1079 | - } |
|
1080 | - else |
|
1126 | + if (!in_array($post_error_id, $minor_errors)) { |
|
1127 | + $context['error_type'] = 'serious'; |
|
1128 | + } |
|
1129 | + } else |
|
1081 | 1130 | { |
1082 | 1131 | $context['post_error'][$post_error] = $txt['error_' . $post_error]; |
1083 | 1132 | |
1084 | 1133 | // If it's not a minor error flag it as such. |
1085 | - if (!in_array($post_error, $minor_errors)) |
|
1086 | - $context['error_type'] = 'serious'; |
|
1134 | + if (!in_array($post_error, $minor_errors)) { |
|
1135 | + $context['error_type'] = 'serious'; |
|
1136 | + } |
|
1087 | 1137 | } |
1088 | 1138 | } |
1089 | 1139 | |
1090 | 1140 | // What are you doing? Posting a poll, modifying, previewing, new post, or reply... |
1091 | - if (isset($_REQUEST['poll'])) |
|
1092 | - $context['page_title'] = $txt['new_poll']; |
|
1093 | - elseif ($context['make_event']) |
|
1094 | - $context['page_title'] = $context['event']['id'] == -1 ? $txt['calendar_post_event'] : $txt['calendar_edit']; |
|
1095 | - elseif (isset($_REQUEST['msg'])) |
|
1096 | - $context['page_title'] = $txt['modify_msg']; |
|
1097 | - elseif (isset($_REQUEST['subject'], $context['preview_subject'])) |
|
1098 | - $context['page_title'] = $txt['preview'] . ' - ' . strip_tags($context['preview_subject']); |
|
1099 | - elseif (empty($topic)) |
|
1100 | - $context['page_title'] = $txt['start_new_topic']; |
|
1101 | - else |
|
1102 | - $context['page_title'] = $txt['post_reply']; |
|
1141 | + if (isset($_REQUEST['poll'])) { |
|
1142 | + $context['page_title'] = $txt['new_poll']; |
|
1143 | + } elseif ($context['make_event']) { |
|
1144 | + $context['page_title'] = $context['event']['id'] == -1 ? $txt['calendar_post_event'] : $txt['calendar_edit']; |
|
1145 | + } elseif (isset($_REQUEST['msg'])) { |
|
1146 | + $context['page_title'] = $txt['modify_msg']; |
|
1147 | + } elseif (isset($_REQUEST['subject'], $context['preview_subject'])) { |
|
1148 | + $context['page_title'] = $txt['preview'] . ' - ' . strip_tags($context['preview_subject']); |
|
1149 | + } elseif (empty($topic)) { |
|
1150 | + $context['page_title'] = $txt['start_new_topic']; |
|
1151 | + } else { |
|
1152 | + $context['page_title'] = $txt['post_reply']; |
|
1153 | + } |
|
1103 | 1154 | |
1104 | 1155 | // Build the link tree. |
1105 | - if (empty($topic)) |
|
1106 | - $context['linktree'][] = array( |
|
1156 | + if (empty($topic)) { |
|
1157 | + $context['linktree'][] = array( |
|
1107 | 1158 | 'name' => '<em>' . $txt['start_new_topic'] . '</em>' |
1108 | 1159 | ); |
1109 | - else |
|
1110 | - $context['linktree'][] = array( |
|
1160 | + } else { |
|
1161 | + $context['linktree'][] = array( |
|
1111 | 1162 | 'url' => $scripturl . '?topic=' . $topic . '.' . $_REQUEST['start'], |
1112 | 1163 | 'name' => $form_subject, |
1113 | 1164 | 'extra_before' => '<span><strong class="nav">' . $context['page_title'] . ' (</strong></span>', |
1114 | 1165 | 'extra_after' => '<span><strong class="nav">)</strong></span>' |
1115 | 1166 | ); |
1167 | + } |
|
1116 | 1168 | |
1117 | 1169 | $context['subject'] = addcslashes($form_subject, '"'); |
1118 | 1170 | $context['message'] = str_replace(array('"', '<', '>', ' '), array('"', '<', '>', ' '), $form_message); |
@@ -1156,8 +1208,9 @@ discard block |
||
1156 | 1208 | // Message icons - customized icons are off? |
1157 | 1209 | $context['icons'] = getMessageIcons($board); |
1158 | 1210 | |
1159 | - if (!empty($context['icons'])) |
|
1160 | - $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
1211 | + if (!empty($context['icons'])) { |
|
1212 | + $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
1213 | + } |
|
1161 | 1214 | |
1162 | 1215 | // Are we starting a poll? if set the poll icon as selected if its available |
1163 | 1216 | if (isset($_REQUEST['poll'])) |
@@ -1177,8 +1230,9 @@ discard block |
||
1177 | 1230 | for ($i = 0, $n = count($context['icons']); $i < $n; $i++) |
1178 | 1231 | { |
1179 | 1232 | $context['icons'][$i]['selected'] = $context['icon'] == $context['icons'][$i]['value']; |
1180 | - if ($context['icons'][$i]['selected']) |
|
1181 | - $context['icon_url'] = $context['icons'][$i]['url']; |
|
1233 | + if ($context['icons'][$i]['selected']) { |
|
1234 | + $context['icon_url'] = $context['icons'][$i]['url']; |
|
1235 | + } |
|
1182 | 1236 | } |
1183 | 1237 | if (empty($context['icon_url'])) |
1184 | 1238 | { |
@@ -1192,8 +1246,9 @@ discard block |
||
1192 | 1246 | )); |
1193 | 1247 | } |
1194 | 1248 | |
1195 | - if (!empty($topic) && !empty($modSettings['topicSummaryPosts'])) |
|
1196 | - getTopic(); |
|
1249 | + if (!empty($topic) && !empty($modSettings['topicSummaryPosts'])) { |
|
1250 | + getTopic(); |
|
1251 | + } |
|
1197 | 1252 | |
1198 | 1253 | // If the user can post attachments prepare the warning labels. |
1199 | 1254 | if ($context['can_post_attachment']) |
@@ -1204,15 +1259,17 @@ discard block |
||
1204 | 1259 | $context['attachment_restrictions'] = array(); |
1205 | 1260 | $context['allowed_extensions'] = strtr(strtolower($modSettings['attachmentExtensions']), array(',' => ', ')); |
1206 | 1261 | $attachmentRestrictionTypes = array('attachmentNumPerPostLimit', 'attachmentPostLimit', 'attachmentSizeLimit'); |
1207 | - foreach ($attachmentRestrictionTypes as $type) |
|
1208 | - if (!empty($modSettings[$type])) |
|
1262 | + foreach ($attachmentRestrictionTypes as $type) { |
|
1263 | + if (!empty($modSettings[$type])) |
|
1209 | 1264 | { |
1210 | 1265 | $context['attachment_restrictions'][] = sprintf($txt['attach_restrict_' . $type . ($modSettings[$type] >= 1024 ? '_MB' : '')], comma_format($modSettings[$type], 0)); |
1266 | + } |
|
1211 | 1267 | // Show some numbers. If they exist. |
1212 | - if ($type == 'attachmentNumPerPostLimit' && $context['attachments']['quantity'] > 0) |
|
1213 | - $context['attachment_restrictions'][] = sprintf($txt['attach_remaining'], $modSettings['attachmentNumPerPostLimit'] - $context['attachments']['quantity']); |
|
1214 | - elseif ($type == 'attachmentPostLimit' && $context['attachments']['total_size'] > 0) |
|
1215 | - $context['attachment_restrictions'][] = sprintf($txt['attach_available'], comma_format(round(max($modSettings['attachmentPostLimit'] - ($context['attachments']['total_size'] / 1024), 0)), 0)); |
|
1268 | + if ($type == 'attachmentNumPerPostLimit' && $context['attachments']['quantity'] > 0) { |
|
1269 | + $context['attachment_restrictions'][] = sprintf($txt['attach_remaining'], $modSettings['attachmentNumPerPostLimit'] - $context['attachments']['quantity']); |
|
1270 | + } elseif ($type == 'attachmentPostLimit' && $context['attachments']['total_size'] > 0) { |
|
1271 | + $context['attachment_restrictions'][] = sprintf($txt['attach_available'], comma_format(round(max($modSettings['attachmentPostLimit'] - ($context['attachments']['total_size'] / 1024), 0)), 0)); |
|
1272 | + } |
|
1216 | 1273 | } |
1217 | 1274 | } |
1218 | 1275 | |
@@ -1246,8 +1303,8 @@ discard block |
||
1246 | 1303 | |
1247 | 1304 | if (!empty($context['current_attachments'])) |
1248 | 1305 | { |
1249 | - foreach ($context['current_attachments'] as $key => $mock) |
|
1250 | - addInlineJavaScript(' |
|
1306 | + foreach ($context['current_attachments'] as $key => $mock) { |
|
1307 | + addInlineJavaScript(' |
|
1251 | 1308 | current_attachments.push({ |
1252 | 1309 | name: '. JavaScriptEscape($mock['name']) . ', |
1253 | 1310 | size: '. $mock['size'] . ', |
@@ -1256,6 +1313,7 @@ discard block |
||
1256 | 1313 | type: '. JavaScriptEscape(!empty($mock['mime_type']) ? $mock['mime_type'] : '') . ', |
1257 | 1314 | thumbID: '. (!empty($mock['thumb']) ? $mock['thumb'] : 0) . ' |
1258 | 1315 | });', true); |
1316 | + } |
|
1259 | 1317 | } |
1260 | 1318 | |
1261 | 1319 | // File Upload. |
@@ -1300,8 +1358,9 @@ discard block |
||
1300 | 1358 | var current_board = '. (empty($context['current_board']) ? 'null' : $context['current_board']) . ';', false); |
1301 | 1359 | |
1302 | 1360 | // Finally, load the template. |
1303 | - if (!isset($_REQUEST['xml'])) |
|
1304 | - loadTemplate('Post'); |
|
1361 | + if (!isset($_REQUEST['xml'])) { |
|
1362 | + loadTemplate('Post'); |
|
1363 | + } |
|
1305 | 1364 | |
1306 | 1365 | call_integration_hook('integrate_post_end'); |
1307 | 1366 | } |
@@ -1322,13 +1381,14 @@ discard block |
||
1322 | 1381 | // Sneaking off, are we? |
1323 | 1382 | if (empty($_POST) && empty($topic)) |
1324 | 1383 | { |
1325 | - if (empty($_SERVER['CONTENT_LENGTH'])) |
|
1326 | - redirectexit('action=post;board=' . $board . '.0'); |
|
1327 | - else |
|
1328 | - fatal_lang_error('post_upload_error', false); |
|
1384 | + if (empty($_SERVER['CONTENT_LENGTH'])) { |
|
1385 | + redirectexit('action=post;board=' . $board . '.0'); |
|
1386 | + } else { |
|
1387 | + fatal_lang_error('post_upload_error', false); |
|
1388 | + } |
|
1389 | + } elseif (empty($_POST) && !empty($topic)) { |
|
1390 | + redirectexit('action=post;topic=' . $topic . '.0'); |
|
1329 | 1391 | } |
1330 | - elseif (empty($_POST) && !empty($topic)) |
|
1331 | - redirectexit('action=post;topic=' . $topic . '.0'); |
|
1332 | 1392 | |
1333 | 1393 | // No need! |
1334 | 1394 | $context['robot_no_index'] = true; |
@@ -1340,8 +1400,9 @@ discard block |
||
1340 | 1400 | $post_errors = array(); |
1341 | 1401 | |
1342 | 1402 | // If the session has timed out, let the user re-submit their form. |
1343 | - if (checkSession('post', '', false) != '') |
|
1344 | - $post_errors[] = 'session_timeout'; |
|
1403 | + if (checkSession('post', '', false) != '') { |
|
1404 | + $post_errors[] = 'session_timeout'; |
|
1405 | + } |
|
1345 | 1406 | |
1346 | 1407 | // Wrong verification code? |
1347 | 1408 | if (!$user_info['is_admin'] && !$user_info['is_mod'] && !empty($modSettings['posts_require_captcha']) && ($user_info['posts'] < $modSettings['posts_require_captcha'] || ($user_info['is_guest'] && $modSettings['posts_require_captcha'] == -1))) |
@@ -1351,33 +1412,38 @@ discard block |
||
1351 | 1412 | 'id' => 'post', |
1352 | 1413 | ); |
1353 | 1414 | $context['require_verification'] = create_control_verification($verificationOptions, true); |
1354 | - if (is_array($context['require_verification'])) |
|
1355 | - $post_errors = array_merge($post_errors, $context['require_verification']); |
|
1415 | + if (is_array($context['require_verification'])) { |
|
1416 | + $post_errors = array_merge($post_errors, $context['require_verification']); |
|
1417 | + } |
|
1356 | 1418 | } |
1357 | 1419 | |
1358 | 1420 | require_once($sourcedir . '/Subs-Post.php'); |
1359 | 1421 | loadLanguage('Post'); |
1360 | 1422 | |
1361 | 1423 | // Drafts enabled and needed? |
1362 | - if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft']))) |
|
1363 | - require_once($sourcedir . '/Drafts.php'); |
|
1424 | + if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft']))) { |
|
1425 | + require_once($sourcedir . '/Drafts.php'); |
|
1426 | + } |
|
1364 | 1427 | |
1365 | 1428 | // First check to see if they are trying to delete any current attachments. |
1366 | 1429 | if (isset($_POST['attach_del'])) |
1367 | 1430 | { |
1368 | 1431 | $keep_temp = array(); |
1369 | 1432 | $keep_ids = array(); |
1370 | - foreach ($_POST['attach_del'] as $dummy) |
|
1371 | - if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false) |
|
1433 | + foreach ($_POST['attach_del'] as $dummy) { |
|
1434 | + if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false) |
|
1372 | 1435 | $keep_temp[] = $dummy; |
1373 | - else |
|
1374 | - $keep_ids[] = (int) $dummy; |
|
1436 | + } |
|
1437 | + else { |
|
1438 | + $keep_ids[] = (int) $dummy; |
|
1439 | + } |
|
1375 | 1440 | |
1376 | - if (isset($_SESSION['temp_attachments'])) |
|
1377 | - foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
1441 | + if (isset($_SESSION['temp_attachments'])) { |
|
1442 | + foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
1378 | 1443 | { |
1379 | 1444 | if ((isset($_SESSION['temp_attachments']['post']['files'], $attachment['name']) && in_array($attachment['name'], $_SESSION['temp_attachments']['post']['files'])) || in_array($attachID, $keep_temp) || strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
1380 | 1445 | continue; |
1446 | + } |
|
1381 | 1447 | |
1382 | 1448 | unset($_SESSION['temp_attachments'][$attachID]); |
1383 | 1449 | unlink($attachment['tmp_name']); |
@@ -1419,24 +1485,28 @@ discard block |
||
1419 | 1485 | $smcFunc['db_free_result']($request); |
1420 | 1486 | |
1421 | 1487 | // Though the topic should be there, it might have vanished. |
1422 | - if (!is_array($topic_info)) |
|
1423 | - fatal_lang_error('topic_doesnt_exist', 404); |
|
1488 | + if (!is_array($topic_info)) { |
|
1489 | + fatal_lang_error('topic_doesnt_exist', 404); |
|
1490 | + } |
|
1424 | 1491 | |
1425 | 1492 | // Did this topic suddenly move? Just checking... |
1426 | - if ($topic_info['id_board'] != $board) |
|
1427 | - fatal_lang_error('not_a_topic'); |
|
1493 | + if ($topic_info['id_board'] != $board) { |
|
1494 | + fatal_lang_error('not_a_topic'); |
|
1495 | + } |
|
1428 | 1496 | } |
1429 | 1497 | |
1430 | 1498 | // Replying to a topic? |
1431 | 1499 | if (!empty($topic) && !isset($_REQUEST['msg'])) |
1432 | 1500 | { |
1433 | 1501 | // Don't allow a post if it's locked. |
1434 | - if ($topic_info['locked'] != 0 && !allowedTo('moderate_board')) |
|
1435 | - fatal_lang_error('topic_locked', false); |
|
1502 | + if ($topic_info['locked'] != 0 && !allowedTo('moderate_board')) { |
|
1503 | + fatal_lang_error('topic_locked', false); |
|
1504 | + } |
|
1436 | 1505 | |
1437 | 1506 | // Sorry, multiple polls aren't allowed... yet. You should stop giving me ideas :P. |
1438 | - if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0) |
|
1439 | - unset($_REQUEST['poll']); |
|
1507 | + if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0) { |
|
1508 | + unset($_REQUEST['poll']); |
|
1509 | + } |
|
1440 | 1510 | |
1441 | 1511 | // Do the permissions and approval stuff... |
1442 | 1512 | $becomesApproved = true; |
@@ -1452,44 +1522,43 @@ discard block |
||
1452 | 1522 | |
1453 | 1523 | // Set a nice session var... |
1454 | 1524 | $_SESSION['becomesUnapproved'] = true; |
1455 | - } |
|
1456 | - |
|
1457 | - elseif ($topic_info['id_member_started'] != $user_info['id']) |
|
1525 | + } elseif ($topic_info['id_member_started'] != $user_info['id']) |
|
1458 | 1526 | { |
1459 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) |
|
1460 | - $becomesApproved = false; |
|
1461 | - |
|
1462 | - else |
|
1463 | - isAllowedTo('post_reply_any'); |
|
1464 | - } |
|
1465 | - elseif (!allowedTo('post_reply_any')) |
|
1527 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) { |
|
1528 | + $becomesApproved = false; |
|
1529 | + } else { |
|
1530 | + isAllowedTo('post_reply_any'); |
|
1531 | + } |
|
1532 | + } elseif (!allowedTo('post_reply_any')) |
|
1466 | 1533 | { |
1467 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) |
|
1468 | - $becomesApproved = false; |
|
1469 | - |
|
1470 | - else |
|
1471 | - isAllowedTo('post_reply_own'); |
|
1534 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) { |
|
1535 | + $becomesApproved = false; |
|
1536 | + } else { |
|
1537 | + isAllowedTo('post_reply_own'); |
|
1538 | + } |
|
1472 | 1539 | } |
1473 | 1540 | |
1474 | 1541 | if (isset($_POST['lock'])) |
1475 | 1542 | { |
1476 | 1543 | // Nothing is changed to the lock. |
1477 | - if ((empty($topic_info['locked']) && empty($_POST['lock'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) |
|
1478 | - unset($_POST['lock']); |
|
1544 | + if ((empty($topic_info['locked']) && empty($_POST['lock'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) { |
|
1545 | + unset($_POST['lock']); |
|
1546 | + } |
|
1479 | 1547 | |
1480 | 1548 | // You're have no permission to lock this topic. |
1481 | - elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) |
|
1482 | - unset($_POST['lock']); |
|
1549 | + elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) { |
|
1550 | + unset($_POST['lock']); |
|
1551 | + } |
|
1483 | 1552 | |
1484 | 1553 | // You are allowed to (un)lock your own topic only. |
1485 | 1554 | elseif (!allowedTo('lock_any')) |
1486 | 1555 | { |
1487 | 1556 | // You cannot override a moderator lock. |
1488 | - if ($topic_info['locked'] == 1) |
|
1489 | - unset($_POST['lock']); |
|
1490 | - |
|
1491 | - else |
|
1492 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
1557 | + if ($topic_info['locked'] == 1) { |
|
1558 | + unset($_POST['lock']); |
|
1559 | + } else { |
|
1560 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
1561 | + } |
|
1493 | 1562 | } |
1494 | 1563 | // Hail mighty moderator, (un)lock this topic immediately. |
1495 | 1564 | else |
@@ -1497,19 +1566,21 @@ discard block |
||
1497 | 1566 | $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
1498 | 1567 | |
1499 | 1568 | // Did someone (un)lock this while you were posting? |
1500 | - if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) |
|
1501 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
1569 | + if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) { |
|
1570 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
1571 | + } |
|
1502 | 1572 | } |
1503 | 1573 | } |
1504 | 1574 | |
1505 | 1575 | // So you wanna (un)sticky this...let's see. |
1506 | - if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky'))) |
|
1507 | - unset($_POST['sticky']); |
|
1508 | - elseif (isset($_POST['sticky'])) |
|
1576 | + if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky'))) { |
|
1577 | + unset($_POST['sticky']); |
|
1578 | + } elseif (isset($_POST['sticky'])) |
|
1509 | 1579 | { |
1510 | 1580 | // Did someone (un)sticky this while you were posting? |
1511 | - if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) |
|
1512 | - $post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky'; |
|
1581 | + if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) { |
|
1582 | + $post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky'; |
|
1583 | + } |
|
1513 | 1584 | } |
1514 | 1585 | |
1515 | 1586 | // If drafts are enabled, then pass this off |
@@ -1536,26 +1607,31 @@ discard block |
||
1536 | 1607 | |
1537 | 1608 | // Do like, the permissions, for safety and stuff... |
1538 | 1609 | $becomesApproved = true; |
1539 | - if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) |
|
1540 | - $becomesApproved = false; |
|
1541 | - else |
|
1542 | - isAllowedTo('post_new'); |
|
1610 | + if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) { |
|
1611 | + $becomesApproved = false; |
|
1612 | + } else { |
|
1613 | + isAllowedTo('post_new'); |
|
1614 | + } |
|
1543 | 1615 | |
1544 | 1616 | if (isset($_POST['lock'])) |
1545 | 1617 | { |
1546 | 1618 | // New topics are by default not locked. |
1547 | - if (empty($_POST['lock'])) |
|
1548 | - unset($_POST['lock']); |
|
1619 | + if (empty($_POST['lock'])) { |
|
1620 | + unset($_POST['lock']); |
|
1621 | + } |
|
1549 | 1622 | // Besides, you need permission. |
1550 | - elseif (!allowedTo(array('lock_any', 'lock_own'))) |
|
1551 | - unset($_POST['lock']); |
|
1623 | + elseif (!allowedTo(array('lock_any', 'lock_own'))) { |
|
1624 | + unset($_POST['lock']); |
|
1625 | + } |
|
1552 | 1626 | // A moderator-lock (1) can override a user-lock (2). |
1553 | - else |
|
1554 | - $_POST['lock'] = allowedTo('lock_any') ? 1 : 2; |
|
1627 | + else { |
|
1628 | + $_POST['lock'] = allowedTo('lock_any') ? 1 : 2; |
|
1629 | + } |
|
1555 | 1630 | } |
1556 | 1631 | |
1557 | - if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky'))) |
|
1558 | - unset($_POST['sticky']); |
|
1632 | + if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky'))) { |
|
1633 | + unset($_POST['sticky']); |
|
1634 | + } |
|
1559 | 1635 | |
1560 | 1636 | // Saving your new topic as a draft first? |
1561 | 1637 | if (!empty($modSettings['drafts_post_enabled']) && isset($_POST['save_draft'])) |
@@ -1580,31 +1656,37 @@ discard block |
||
1580 | 1656 | 'id_msg' => $_REQUEST['msg'], |
1581 | 1657 | ) |
1582 | 1658 | ); |
1583 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1584 | - fatal_lang_error('cant_find_messages', false); |
|
1659 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1660 | + fatal_lang_error('cant_find_messages', false); |
|
1661 | + } |
|
1585 | 1662 | $row = $smcFunc['db_fetch_assoc']($request); |
1586 | 1663 | $smcFunc['db_free_result']($request); |
1587 | 1664 | |
1588 | - if (!empty($topic_info['locked']) && !allowedTo('moderate_board')) |
|
1589 | - fatal_lang_error('topic_locked', false); |
|
1665 | + if (!empty($topic_info['locked']) && !allowedTo('moderate_board')) { |
|
1666 | + fatal_lang_error('topic_locked', false); |
|
1667 | + } |
|
1590 | 1668 | |
1591 | 1669 | if (isset($_POST['lock'])) |
1592 | 1670 | { |
1593 | 1671 | // Nothing changes to the lock status. |
1594 | - if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) |
|
1595 | - unset($_POST['lock']); |
|
1672 | + if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) { |
|
1673 | + unset($_POST['lock']); |
|
1674 | + } |
|
1596 | 1675 | // You're simply not allowed to (un)lock this. |
1597 | - elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) |
|
1598 | - unset($_POST['lock']); |
|
1676 | + elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) { |
|
1677 | + unset($_POST['lock']); |
|
1678 | + } |
|
1599 | 1679 | // You're only allowed to lock your own topics. |
1600 | 1680 | elseif (!allowedTo('lock_any')) |
1601 | 1681 | { |
1602 | 1682 | // You're not allowed to break a moderator's lock. |
1603 | - if ($topic_info['locked'] == 1) |
|
1604 | - unset($_POST['lock']); |
|
1683 | + if ($topic_info['locked'] == 1) { |
|
1684 | + unset($_POST['lock']); |
|
1685 | + } |
|
1605 | 1686 | // Lock it with a soft lock or unlock it. |
1606 | - else |
|
1607 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
1687 | + else { |
|
1688 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
1689 | + } |
|
1608 | 1690 | } |
1609 | 1691 | // You must be the moderator. |
1610 | 1692 | else |
@@ -1612,44 +1694,46 @@ discard block |
||
1612 | 1694 | $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
1613 | 1695 | |
1614 | 1696 | // Did someone (un)lock this while you were posting? |
1615 | - if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) |
|
1616 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
1697 | + if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) { |
|
1698 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
1699 | + } |
|
1617 | 1700 | } |
1618 | 1701 | } |
1619 | 1702 | |
1620 | 1703 | // Change the sticky status of this topic? |
1621 | - if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky'])) |
|
1622 | - unset($_POST['sticky']); |
|
1623 | - elseif (isset($_POST['sticky'])) |
|
1704 | + if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky'])) { |
|
1705 | + unset($_POST['sticky']); |
|
1706 | + } elseif (isset($_POST['sticky'])) |
|
1624 | 1707 | { |
1625 | 1708 | // Did someone (un)sticky this while you were posting? |
1626 | - if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) |
|
1627 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied'; |
|
1709 | + if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) { |
|
1710 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied'; |
|
1711 | + } |
|
1628 | 1712 | } |
1629 | 1713 | |
1630 | 1714 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
1631 | 1715 | { |
1632 | - if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
1633 | - fatal_lang_error('modify_post_time_passed', false); |
|
1634 | - elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) |
|
1635 | - isAllowedTo('modify_replies'); |
|
1636 | - else |
|
1637 | - isAllowedTo('modify_own'); |
|
1638 | - } |
|
1639 | - elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
1716 | + if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
1717 | + fatal_lang_error('modify_post_time_passed', false); |
|
1718 | + } elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
1719 | + isAllowedTo('modify_replies'); |
|
1720 | + } else { |
|
1721 | + isAllowedTo('modify_own'); |
|
1722 | + } |
|
1723 | + } elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
1640 | 1724 | { |
1641 | 1725 | isAllowedTo('modify_replies'); |
1642 | 1726 | |
1643 | 1727 | // If you're modifying a reply, I say it better be logged... |
1644 | 1728 | $moderationAction = true; |
1645 | - } |
|
1646 | - else |
|
1729 | + } else |
|
1647 | 1730 | { |
1648 | 1731 | isAllowedTo('modify_any'); |
1649 | 1732 | |
1650 | 1733 | // Log it, assuming you're not modifying your own post. |
1651 | - if ($row['id_member'] != $user_info['id']) |
|
1652 | - $moderationAction = true; |
|
1734 | + if ($row['id_member'] != $user_info['id']) { |
|
1735 | + $moderationAction = true; |
|
1736 | + } |
|
1653 | 1737 | } |
1654 | 1738 | |
1655 | 1739 | // If drafts are enabled, then lets send this off to save |
@@ -1686,20 +1770,24 @@ discard block |
||
1686 | 1770 | $_POST['guestname'] = !isset($_POST['guestname']) ? '' : trim($_POST['guestname']); |
1687 | 1771 | $_POST['email'] = !isset($_POST['email']) ? '' : trim($_POST['email']); |
1688 | 1772 | |
1689 | - if ($_POST['guestname'] == '' || $_POST['guestname'] == '_') |
|
1690 | - $post_errors[] = 'no_name'; |
|
1691 | - if ($smcFunc['strlen']($_POST['guestname']) > 25) |
|
1692 | - $post_errors[] = 'long_name'; |
|
1773 | + if ($_POST['guestname'] == '' || $_POST['guestname'] == '_') { |
|
1774 | + $post_errors[] = 'no_name'; |
|
1775 | + } |
|
1776 | + if ($smcFunc['strlen']($_POST['guestname']) > 25) { |
|
1777 | + $post_errors[] = 'long_name'; |
|
1778 | + } |
|
1693 | 1779 | |
1694 | 1780 | if (empty($modSettings['guest_post_no_email'])) |
1695 | 1781 | { |
1696 | 1782 | // Only check if they changed it! |
1697 | 1783 | if (!isset($row) || $row['poster_email'] != $_POST['email']) |
1698 | 1784 | { |
1699 | - if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == '')) |
|
1700 | - $post_errors[] = 'no_email'; |
|
1701 | - if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) |
|
1702 | - $post_errors[] = 'bad_email'; |
|
1785 | + if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == '')) { |
|
1786 | + $post_errors[] = 'no_email'; |
|
1787 | + } |
|
1788 | + if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { |
|
1789 | + $post_errors[] = 'bad_email'; |
|
1790 | + } |
|
1703 | 1791 | } |
1704 | 1792 | |
1705 | 1793 | // Now make sure this email address is not banned from posting. |
@@ -1715,75 +1803,89 @@ discard block |
||
1715 | 1803 | } |
1716 | 1804 | |
1717 | 1805 | // Coming from the quickReply? |
1718 | - if (isset($_POST['quickReply'])) |
|
1719 | - $_POST['message'] = $_POST['quickReply']; |
|
1806 | + if (isset($_POST['quickReply'])) { |
|
1807 | + $_POST['message'] = $_POST['quickReply']; |
|
1808 | + } |
|
1720 | 1809 | |
1721 | 1810 | // Check the subject and message. |
1722 | - if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '') |
|
1723 | - $post_errors[] = 'no_subject'; |
|
1724 | - if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '') |
|
1725 | - $post_errors[] = 'no_message'; |
|
1726 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
1727 | - $post_errors[] = array('long_message', array($modSettings['max_messageLength'])); |
|
1728 | - else |
|
1811 | + if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '') { |
|
1812 | + $post_errors[] = 'no_subject'; |
|
1813 | + } |
|
1814 | + if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '') { |
|
1815 | + $post_errors[] = 'no_message'; |
|
1816 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) { |
|
1817 | + $post_errors[] = array('long_message', array($modSettings['max_messageLength'])); |
|
1818 | + } else |
|
1729 | 1819 | { |
1730 | 1820 | // Prepare the message a bit for some additional testing. |
1731 | 1821 | $_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES); |
1732 | 1822 | |
1733 | 1823 | // Preparse code. (Zef) |
1734 | - if ($user_info['is_guest']) |
|
1735 | - $user_info['name'] = $_POST['guestname']; |
|
1824 | + if ($user_info['is_guest']) { |
|
1825 | + $user_info['name'] = $_POST['guestname']; |
|
1826 | + } |
|
1736 | 1827 | preparsecode($_POST['message']); |
1737 | 1828 | |
1738 | 1829 | // Let's see if there's still some content left without the tags. |
1739 | - if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false)) |
|
1740 | - $post_errors[] = 'no_message'; |
|
1830 | + if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false)) { |
|
1831 | + $post_errors[] = 'no_message'; |
|
1832 | + } |
|
1833 | + } |
|
1834 | + if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '') { |
|
1835 | + $post_errors[] = 'no_event'; |
|
1741 | 1836 | } |
1742 | - if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '') |
|
1743 | - $post_errors[] = 'no_event'; |
|
1744 | 1837 | // You are not! |
1745 | - if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin']) |
|
1746 | - fatal_error('Knave! Masquerader! Charlatan!', false); |
|
1838 | + if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin']) { |
|
1839 | + fatal_error('Knave! Masquerader! Charlatan!', false); |
|
1840 | + } |
|
1747 | 1841 | |
1748 | 1842 | // Validate the poll... |
1749 | 1843 | if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1') |
1750 | 1844 | { |
1751 | - if (!empty($topic) && !isset($_REQUEST['msg'])) |
|
1752 | - fatal_lang_error('no_access', false); |
|
1845 | + if (!empty($topic) && !isset($_REQUEST['msg'])) { |
|
1846 | + fatal_lang_error('no_access', false); |
|
1847 | + } |
|
1753 | 1848 | |
1754 | 1849 | // This is a new topic... so it's a new poll. |
1755 | - if (empty($topic)) |
|
1756 | - isAllowedTo('poll_post'); |
|
1850 | + if (empty($topic)) { |
|
1851 | + isAllowedTo('poll_post'); |
|
1852 | + } |
|
1757 | 1853 | // Can you add to your own topics? |
1758 | - elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any')) |
|
1759 | - isAllowedTo('poll_add_own'); |
|
1854 | + elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any')) { |
|
1855 | + isAllowedTo('poll_add_own'); |
|
1856 | + } |
|
1760 | 1857 | // Can you add polls to any topic, then? |
1761 | - else |
|
1762 | - isAllowedTo('poll_add_any'); |
|
1858 | + else { |
|
1859 | + isAllowedTo('poll_add_any'); |
|
1860 | + } |
|
1763 | 1861 | |
1764 | - if (!isset($_POST['question']) || trim($_POST['question']) == '') |
|
1765 | - $post_errors[] = 'no_question'; |
|
1862 | + if (!isset($_POST['question']) || trim($_POST['question']) == '') { |
|
1863 | + $post_errors[] = 'no_question'; |
|
1864 | + } |
|
1766 | 1865 | |
1767 | 1866 | $_POST['options'] = empty($_POST['options']) ? array() : htmltrim__recursive($_POST['options']); |
1768 | 1867 | |
1769 | 1868 | // Get rid of empty ones. |
1770 | - foreach ($_POST['options'] as $k => $option) |
|
1771 | - if ($option == '') |
|
1869 | + foreach ($_POST['options'] as $k => $option) { |
|
1870 | + if ($option == '') |
|
1772 | 1871 | unset($_POST['options'][$k], $_POST['options'][$k]); |
1872 | + } |
|
1773 | 1873 | |
1774 | 1874 | // What are you going to vote between with one choice?!? |
1775 | - if (count($_POST['options']) < 2) |
|
1776 | - $post_errors[] = 'poll_few'; |
|
1777 | - elseif (count($_POST['options']) > 256) |
|
1778 | - $post_errors[] = 'poll_many'; |
|
1875 | + if (count($_POST['options']) < 2) { |
|
1876 | + $post_errors[] = 'poll_few'; |
|
1877 | + } elseif (count($_POST['options']) > 256) { |
|
1878 | + $post_errors[] = 'poll_many'; |
|
1879 | + } |
|
1779 | 1880 | } |
1780 | 1881 | |
1781 | 1882 | if ($posterIsGuest) |
1782 | 1883 | { |
1783 | 1884 | // If user is a guest, make sure the chosen name isn't taken. |
1784 | 1885 | require_once($sourcedir . '/Subs-Members.php'); |
1785 | - if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name'])) |
|
1786 | - $post_errors[] = 'bad_name'; |
|
1886 | + if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name'])) { |
|
1887 | + $post_errors[] = 'bad_name'; |
|
1888 | + } |
|
1787 | 1889 | } |
1788 | 1890 | // If the user isn't a guest, get his or her name and email. |
1789 | 1891 | elseif (!isset($_REQUEST['msg'])) |
@@ -1814,8 +1916,9 @@ discard block |
||
1814 | 1916 | } |
1815 | 1917 | |
1816 | 1918 | // Make sure the user isn't spamming the board. |
1817 | - if (!isset($_REQUEST['msg'])) |
|
1818 | - spamProtection('post'); |
|
1919 | + if (!isset($_REQUEST['msg'])) { |
|
1920 | + spamProtection('post'); |
|
1921 | + } |
|
1819 | 1922 | |
1820 | 1923 | // At about this point, we're posting and that's that. |
1821 | 1924 | ignore_user_abort(true); |
@@ -1828,32 +1931,36 @@ discard block |
||
1828 | 1931 | $_POST['modify_reason'] = empty($_POST['modify_reason']) ? '' : strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => '')); |
1829 | 1932 | |
1830 | 1933 | // At this point, we want to make sure the subject isn't too long. |
1831 | - if ($smcFunc['strlen']($_POST['subject']) > 100) |
|
1832 | - $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
1934 | + if ($smcFunc['strlen']($_POST['subject']) > 100) { |
|
1935 | + $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
1936 | + } |
|
1833 | 1937 | |
1834 | 1938 | // Same with the "why did you edit this" text. |
1835 | - if ($smcFunc['strlen']($_POST['modify_reason']) > 100) |
|
1836 | - $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
1939 | + if ($smcFunc['strlen']($_POST['modify_reason']) > 100) { |
|
1940 | + $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
1941 | + } |
|
1837 | 1942 | |
1838 | 1943 | // Make the poll... |
1839 | 1944 | if (isset($_REQUEST['poll'])) |
1840 | 1945 | { |
1841 | 1946 | // Make sure that the user has not entered a ridiculous number of options.. |
1842 | - if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) |
|
1843 | - $_POST['poll_max_votes'] = 1; |
|
1844 | - elseif ($_POST['poll_max_votes'] > count($_POST['options'])) |
|
1845 | - $_POST['poll_max_votes'] = count($_POST['options']); |
|
1846 | - else |
|
1847 | - $_POST['poll_max_votes'] = (int) $_POST['poll_max_votes']; |
|
1947 | + if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) { |
|
1948 | + $_POST['poll_max_votes'] = 1; |
|
1949 | + } elseif ($_POST['poll_max_votes'] > count($_POST['options'])) { |
|
1950 | + $_POST['poll_max_votes'] = count($_POST['options']); |
|
1951 | + } else { |
|
1952 | + $_POST['poll_max_votes'] = (int) $_POST['poll_max_votes']; |
|
1953 | + } |
|
1848 | 1954 | |
1849 | 1955 | $_POST['poll_expire'] = (int) $_POST['poll_expire']; |
1850 | 1956 | $_POST['poll_expire'] = $_POST['poll_expire'] > 9999 ? 9999 : ($_POST['poll_expire'] < 0 ? 0 : $_POST['poll_expire']); |
1851 | 1957 | |
1852 | 1958 | // Just set it to zero if it's not there.. |
1853 | - if (!isset($_POST['poll_hide'])) |
|
1854 | - $_POST['poll_hide'] = 0; |
|
1855 | - else |
|
1856 | - $_POST['poll_hide'] = (int) $_POST['poll_hide']; |
|
1959 | + if (!isset($_POST['poll_hide'])) { |
|
1960 | + $_POST['poll_hide'] = 0; |
|
1961 | + } else { |
|
1962 | + $_POST['poll_hide'] = (int) $_POST['poll_hide']; |
|
1963 | + } |
|
1857 | 1964 | $_POST['poll_change_vote'] = isset($_POST['poll_change_vote']) ? 1 : 0; |
1858 | 1965 | |
1859 | 1966 | $_POST['poll_guest_vote'] = isset($_POST['poll_guest_vote']) ? 1 : 0; |
@@ -1862,16 +1969,19 @@ discard block |
||
1862 | 1969 | { |
1863 | 1970 | require_once($sourcedir . '/Subs-Members.php'); |
1864 | 1971 | $allowedVoteGroups = groupsAllowedTo('poll_vote', $board); |
1865 | - if (!in_array(-1, $allowedVoteGroups['allowed'])) |
|
1866 | - $_POST['poll_guest_vote'] = 0; |
|
1972 | + if (!in_array(-1, $allowedVoteGroups['allowed'])) { |
|
1973 | + $_POST['poll_guest_vote'] = 0; |
|
1974 | + } |
|
1867 | 1975 | } |
1868 | 1976 | |
1869 | 1977 | // If the user tries to set the poll too far in advance, don't let them. |
1870 | - if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1) |
|
1871 | - fatal_lang_error('poll_range_error', false); |
|
1978 | + if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1) { |
|
1979 | + fatal_lang_error('poll_range_error', false); |
|
1980 | + } |
|
1872 | 1981 | // Don't allow them to select option 2 for hidden results if it's not time limited. |
1873 | - elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) |
|
1874 | - $_POST['poll_hide'] = 1; |
|
1982 | + elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) { |
|
1983 | + $_POST['poll_hide'] = 1; |
|
1984 | + } |
|
1875 | 1985 | |
1876 | 1986 | // Clean up the question and answers. |
1877 | 1987 | $_POST['question'] = $smcFunc['htmlspecialchars']($_POST['question']); |
@@ -1885,13 +1995,15 @@ discard block |
||
1885 | 1995 | { |
1886 | 1996 | $attachIDs = array(); |
1887 | 1997 | $attach_errors = array(); |
1888 | - if (!empty($context['we_are_history'])) |
|
1889 | - $attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>'; |
|
1998 | + if (!empty($context['we_are_history'])) { |
|
1999 | + $attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>'; |
|
2000 | + } |
|
1890 | 2001 | |
1891 | 2002 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
1892 | 2003 | { |
1893 | - if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
1894 | - continue; |
|
2004 | + if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
2005 | + continue; |
|
2006 | + } |
|
1895 | 2007 | |
1896 | 2008 | // If there was an initial error just show that message. |
1897 | 2009 | if ($attachID == 'initial_error') |
@@ -1920,12 +2032,13 @@ discard block |
||
1920 | 2032 | if (createAttachment($attachmentOptions)) |
1921 | 2033 | { |
1922 | 2034 | $attachIDs[] = $attachmentOptions['id']; |
1923 | - if (!empty($attachmentOptions['thumb'])) |
|
1924 | - $attachIDs[] = $attachmentOptions['thumb']; |
|
2035 | + if (!empty($attachmentOptions['thumb'])) { |
|
2036 | + $attachIDs[] = $attachmentOptions['thumb']; |
|
2037 | + } |
|
1925 | 2038 | } |
2039 | + } else { |
|
2040 | + $attach_errors[] = '<dt> </dt>'; |
|
1926 | 2041 | } |
1927 | - else |
|
1928 | - $attach_errors[] = '<dt> </dt>'; |
|
1929 | 2042 | |
1930 | 2043 | if (!empty($attachmentOptions['errors'])) |
1931 | 2044 | { |
@@ -1937,14 +2050,16 @@ discard block |
||
1937 | 2050 | if (!is_array($error)) |
1938 | 2051 | { |
1939 | 2052 | $attach_errors[] = '<dd>' . $txt[$error] . '</dd>'; |
1940 | - if (in_array($error, $log_these)) |
|
1941 | - log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
2053 | + if (in_array($error, $log_these)) { |
|
2054 | + log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
2055 | + } |
|
2056 | + } else { |
|
2057 | + $attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>'; |
|
1942 | 2058 | } |
1943 | - else |
|
1944 | - $attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>'; |
|
1945 | 2059 | } |
1946 | - if (file_exists($attachment['tmp_name'])) |
|
1947 | - unlink($attachment['tmp_name']); |
|
2060 | + if (file_exists($attachment['tmp_name'])) { |
|
2061 | + unlink($attachment['tmp_name']); |
|
2062 | + } |
|
1948 | 2063 | } |
1949 | 2064 | } |
1950 | 2065 | unset($_SESSION['temp_attachments']); |
@@ -1985,24 +2100,24 @@ discard block |
||
1985 | 2100 | ); |
1986 | 2101 | |
1987 | 2102 | call_integration_hook('integrate_poll_add_edit', array($id_poll, false)); |
2103 | + } else { |
|
2104 | + $id_poll = 0; |
|
1988 | 2105 | } |
1989 | - else |
|
1990 | - $id_poll = 0; |
|
1991 | 2106 | |
1992 | 2107 | // Creating a new topic? |
1993 | 2108 | $newTopic = empty($_REQUEST['msg']) && empty($topic); |
1994 | 2109 | |
1995 | 2110 | // Check the icon. |
1996 | - if (!isset($_POST['icon'])) |
|
1997 | - $_POST['icon'] = 'xx'; |
|
1998 | - |
|
1999 | - else |
|
2111 | + if (!isset($_POST['icon'])) { |
|
2112 | + $_POST['icon'] = 'xx'; |
|
2113 | + } else |
|
2000 | 2114 | { |
2001 | 2115 | $_POST['icon'] = $smcFunc['htmlspecialchars']($_POST['icon']); |
2002 | 2116 | |
2003 | 2117 | // Need to figure it out if this is a valid icon name. |
2004 | - if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png'))) |
|
2005 | - $_POST['icon'] = 'xx'; |
|
2118 | + if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png'))) { |
|
2119 | + $_POST['icon'] = 'xx'; |
|
2120 | + } |
|
2006 | 2121 | } |
2007 | 2122 | |
2008 | 2123 | // Collect all parameters for the creation or modification of a post. |
@@ -2043,8 +2158,9 @@ discard block |
||
2043 | 2158 | } |
2044 | 2159 | |
2045 | 2160 | // This will save some time... |
2046 | - if (empty($approve_has_changed)) |
|
2047 | - unset($msgOptions['approved']); |
|
2161 | + if (empty($approve_has_changed)) { |
|
2162 | + unset($msgOptions['approved']); |
|
2163 | + } |
|
2048 | 2164 | |
2049 | 2165 | modifyPost($msgOptions, $topicOptions, $posterOptions); |
2050 | 2166 | } |
@@ -2053,8 +2169,9 @@ discard block |
||
2053 | 2169 | { |
2054 | 2170 | createPost($msgOptions, $topicOptions, $posterOptions); |
2055 | 2171 | |
2056 | - if (isset($topicOptions['id'])) |
|
2057 | - $topic = $topicOptions['id']; |
|
2172 | + if (isset($topicOptions['id'])) { |
|
2173 | + $topic = $topicOptions['id']; |
|
2174 | + } |
|
2058 | 2175 | } |
2059 | 2176 | |
2060 | 2177 | // Assign the previously uploaded attachments to the brand new message. |
@@ -2066,8 +2183,9 @@ discard block |
||
2066 | 2183 | } |
2067 | 2184 | |
2068 | 2185 | // If we had a draft for this, its time to remove it since it was just posted |
2069 | - if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft'])) |
|
2070 | - DeleteDraft($_POST['id_draft']); |
|
2186 | + if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft'])) { |
|
2187 | + DeleteDraft($_POST['id_draft']); |
|
2188 | + } |
|
2071 | 2189 | |
2072 | 2190 | // Editing or posting an event? |
2073 | 2191 | if (isset($_POST['calendar']) && (!isset($_REQUEST['eventid']) || $_REQUEST['eventid'] == -1)) |
@@ -2086,8 +2204,7 @@ discard block |
||
2086 | 2204 | 'member' => $user_info['id'], |
2087 | 2205 | ); |
2088 | 2206 | insertEvent($eventOptions); |
2089 | - } |
|
2090 | - elseif (isset($_POST['calendar'])) |
|
2207 | + } elseif (isset($_POST['calendar'])) |
|
2091 | 2208 | { |
2092 | 2209 | $_REQUEST['eventid'] = (int) $_REQUEST['eventid']; |
2093 | 2210 | |
@@ -2115,14 +2232,15 @@ discard block |
||
2115 | 2232 | } |
2116 | 2233 | |
2117 | 2234 | // Delete it? |
2118 | - if (isset($_REQUEST['deleteevent'])) |
|
2119 | - $smcFunc['db_query']('', ' |
|
2235 | + if (isset($_REQUEST['deleteevent'])) { |
|
2236 | + $smcFunc['db_query']('', ' |
|
2120 | 2237 | DELETE FROM {db_prefix}calendar |
2121 | 2238 | WHERE id_event = {int:id_event}', |
2122 | 2239 | array( |
2123 | 2240 | 'id_event' => $_REQUEST['eventid'], |
2124 | 2241 | ) |
2125 | 2242 | ); |
2243 | + } |
|
2126 | 2244 | // ... or just update it? |
2127 | 2245 | else |
2128 | 2246 | { |
@@ -2164,9 +2282,8 @@ discard block |
||
2164 | 2282 | array($user_info['id'], $topic, 0), |
2165 | 2283 | array('id_member', 'id_topic', 'id_board') |
2166 | 2284 | ); |
2167 | - } |
|
2168 | - elseif (!$newTopic) |
|
2169 | - $smcFunc['db_query']('', ' |
|
2285 | + } elseif (!$newTopic) { |
|
2286 | + $smcFunc['db_query']('', ' |
|
2170 | 2287 | DELETE FROM {db_prefix}log_notify |
2171 | 2288 | WHERE id_member = {int:current_member} |
2172 | 2289 | AND id_topic = {int:current_topic}', |
@@ -2175,16 +2292,20 @@ discard block |
||
2175 | 2292 | 'current_topic' => $topic, |
2176 | 2293 | ) |
2177 | 2294 | ); |
2295 | + } |
|
2178 | 2296 | |
2179 | 2297 | // Log an act of moderation - modifying. |
2180 | - if (!empty($moderationAction)) |
|
2181 | - logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
2298 | + if (!empty($moderationAction)) { |
|
2299 | + logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
2300 | + } |
|
2182 | 2301 | |
2183 | - if (isset($_POST['lock']) && $_POST['lock'] != 2) |
|
2184 | - logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
2302 | + if (isset($_POST['lock']) && $_POST['lock'] != 2) { |
|
2303 | + logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
2304 | + } |
|
2185 | 2305 | |
2186 | - if (isset($_POST['sticky'])) |
|
2187 | - logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
2306 | + if (isset($_POST['sticky'])) { |
|
2307 | + logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
2308 | + } |
|
2188 | 2309 | |
2189 | 2310 | // Returning to the topic? |
2190 | 2311 | if (!empty($_REQUEST['goback'])) |
@@ -2203,26 +2324,31 @@ discard block |
||
2203 | 2324 | ); |
2204 | 2325 | } |
2205 | 2326 | |
2206 | - if ($board_info['num_topics'] == 0) |
|
2207 | - cache_put_data('board-' . $board, null, 120); |
|
2327 | + if ($board_info['num_topics'] == 0) { |
|
2328 | + cache_put_data('board-' . $board, null, 120); |
|
2329 | + } |
|
2208 | 2330 | |
2209 | 2331 | call_integration_hook('integrate_post2_end'); |
2210 | 2332 | |
2211 | - if (!empty($_POST['announce_topic'])) |
|
2212 | - redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2333 | + if (!empty($_POST['announce_topic'])) { |
|
2334 | + redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2335 | + } |
|
2213 | 2336 | |
2214 | - if (!empty($_POST['move']) && allowedTo('move_any')) |
|
2215 | - redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2337 | + if (!empty($_POST['move']) && allowedTo('move_any')) { |
|
2338 | + redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2339 | + } |
|
2216 | 2340 | |
2217 | 2341 | // Return to post if the mod is on. |
2218 | - if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback'])) |
|
2219 | - redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie')); |
|
2220 | - elseif (!empty($_REQUEST['goback'])) |
|
2221 | - redirectexit('topic=' . $topic . '.new#new', isBrowser('ie')); |
|
2342 | + if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback'])) { |
|
2343 | + redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie')); |
|
2344 | + } elseif (!empty($_REQUEST['goback'])) { |
|
2345 | + redirectexit('topic=' . $topic . '.new#new', isBrowser('ie')); |
|
2346 | + } |
|
2222 | 2347 | // Dut-dut-duh-duh-DUH-duh-dut-duh-duh! *dances to the Final Fantasy Fanfare...* |
2223 | - else |
|
2224 | - redirectexit('board=' . $board . '.0'); |
|
2225 | -} |
|
2348 | + else { |
|
2349 | + redirectexit('board=' . $board . '.0'); |
|
2350 | + } |
|
2351 | + } |
|
2226 | 2352 | |
2227 | 2353 | /** |
2228 | 2354 | * Handle the announce topic function (action=announce). |
@@ -2240,8 +2366,9 @@ discard block |
||
2240 | 2366 | |
2241 | 2367 | validateSession(); |
2242 | 2368 | |
2243 | - if (empty($topic)) |
|
2244 | - fatal_lang_error('topic_gone', false); |
|
2369 | + if (empty($topic)) { |
|
2370 | + fatal_lang_error('topic_gone', false); |
|
2371 | + } |
|
2245 | 2372 | |
2246 | 2373 | loadLanguage('Post'); |
2247 | 2374 | loadTemplate('Post'); |
@@ -2268,8 +2395,9 @@ discard block |
||
2268 | 2395 | global $txt, $context, $topic, $board, $board_info, $smcFunc; |
2269 | 2396 | |
2270 | 2397 | $groups = array_merge($board_info['groups'], array(1)); |
2271 | - foreach ($groups as $id => $group) |
|
2272 | - $groups[$id] = (int) $group; |
|
2398 | + foreach ($groups as $id => $group) { |
|
2399 | + $groups[$id] = (int) $group; |
|
2400 | + } |
|
2273 | 2401 | |
2274 | 2402 | $context['groups'] = array(); |
2275 | 2403 | if (in_array(0, $groups)) |
@@ -2312,8 +2440,9 @@ discard block |
||
2312 | 2440 | 'group_list' => $groups, |
2313 | 2441 | ) |
2314 | 2442 | ); |
2315 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2316 | - $context['groups'][$row['id_group']]['name'] = $row['group_name']; |
|
2443 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2444 | + $context['groups'][$row['id_group']]['name'] = $row['group_name']; |
|
2445 | + } |
|
2317 | 2446 | $smcFunc['db_free_result']($request); |
2318 | 2447 | |
2319 | 2448 | // Get the subject of the topic we're about to announce. |
@@ -2355,16 +2484,19 @@ discard block |
||
2355 | 2484 | $context['start'] = empty($_REQUEST['start']) ? 0 : (int) $_REQUEST['start']; |
2356 | 2485 | $groups = array_merge($board_info['groups'], array(1)); |
2357 | 2486 | |
2358 | - if (isset($_POST['membergroups'])) |
|
2359 | - $_POST['who'] = explode(',', $_POST['membergroups']); |
|
2487 | + if (isset($_POST['membergroups'])) { |
|
2488 | + $_POST['who'] = explode(',', $_POST['membergroups']); |
|
2489 | + } |
|
2360 | 2490 | |
2361 | 2491 | // Check whether at least one membergroup was selected. |
2362 | - if (empty($_POST['who'])) |
|
2363 | - fatal_lang_error('no_membergroup_selected'); |
|
2492 | + if (empty($_POST['who'])) { |
|
2493 | + fatal_lang_error('no_membergroup_selected'); |
|
2494 | + } |
|
2364 | 2495 | |
2365 | 2496 | // Make sure all membergroups are integers and can access the board of the announcement. |
2366 | - foreach ($_POST['who'] as $id => $mg) |
|
2367 | - $_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0; |
|
2497 | + foreach ($_POST['who'] as $id => $mg) { |
|
2498 | + $_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0; |
|
2499 | + } |
|
2368 | 2500 | |
2369 | 2501 | // Get the topic subject and censor it. |
2370 | 2502 | $request = $smcFunc['db_query']('', ' |
@@ -2410,12 +2542,13 @@ discard block |
||
2410 | 2542 | if ($smcFunc['db_num_rows']($request) == 0) |
2411 | 2543 | { |
2412 | 2544 | logAction('announce_topic', array('topic' => $topic), 'user'); |
2413 | - if (!empty($_REQUEST['move']) && allowedTo('move_any')) |
|
2414 | - redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2415 | - elseif (!empty($_REQUEST['goback'])) |
|
2416 | - redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie')); |
|
2417 | - else |
|
2418 | - redirectexit('board=' . $board . '.0'); |
|
2545 | + if (!empty($_REQUEST['move']) && allowedTo('move_any')) { |
|
2546 | + redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2547 | + } elseif (!empty($_REQUEST['goback'])) { |
|
2548 | + redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie')); |
|
2549 | + } else { |
|
2550 | + redirectexit('board=' . $board . '.0'); |
|
2551 | + } |
|
2419 | 2552 | } |
2420 | 2553 | |
2421 | 2554 | $announcements = array(); |
@@ -2434,8 +2567,9 @@ discard block |
||
2434 | 2567 | foreach ($rows as $row) |
2435 | 2568 | { |
2436 | 2569 | // Force them to have it? |
2437 | - if (empty($prefs[$row['id_member']]['announcements'])) |
|
2438 | - continue; |
|
2570 | + if (empty($prefs[$row['id_member']]['announcements'])) { |
|
2571 | + continue; |
|
2572 | + } |
|
2439 | 2573 | |
2440 | 2574 | $cur_language = empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile']; |
2441 | 2575 | |
@@ -2463,8 +2597,9 @@ discard block |
||
2463 | 2597 | } |
2464 | 2598 | |
2465 | 2599 | // For each language send a different mail - low priority... |
2466 | - foreach ($announcements as $lang => $mail) |
|
2467 | - sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5); |
|
2600 | + foreach ($announcements as $lang => $mail) { |
|
2601 | + sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5); |
|
2602 | + } |
|
2468 | 2603 | |
2469 | 2604 | $context['percentage_done'] = round(100 * $context['start'] / $modSettings['latestMember'], 1); |
2470 | 2605 | |
@@ -2474,9 +2609,10 @@ discard block |
||
2474 | 2609 | $context['sub_template'] = 'announcement_send'; |
2475 | 2610 | |
2476 | 2611 | // Go back to the correct language for the user ;). |
2477 | - if (!empty($modSettings['userLanguage'])) |
|
2478 | - loadLanguage('Post'); |
|
2479 | -} |
|
2612 | + if (!empty($modSettings['userLanguage'])) { |
|
2613 | + loadLanguage('Post'); |
|
2614 | + } |
|
2615 | + } |
|
2480 | 2616 | |
2481 | 2617 | /** |
2482 | 2618 | * Get the topic for display purposes. |
@@ -2489,12 +2625,13 @@ discard block |
||
2489 | 2625 | { |
2490 | 2626 | global $topic, $modSettings, $context, $smcFunc, $counter, $options; |
2491 | 2627 | |
2492 | - if (isset($_REQUEST['xml'])) |
|
2493 | - $limit = ' |
|
2628 | + if (isset($_REQUEST['xml'])) { |
|
2629 | + $limit = ' |
|
2494 | 2630 | LIMIT ' . (empty($context['new_replies']) ? '0' : $context['new_replies']); |
2495 | - else |
|
2496 | - $limit = empty($modSettings['topicSummaryPosts']) ? '' : ' |
|
2631 | + } else { |
|
2632 | + $limit = empty($modSettings['topicSummaryPosts']) ? '' : ' |
|
2497 | 2633 | LIMIT ' . (int) $modSettings['topicSummaryPosts']; |
2634 | + } |
|
2498 | 2635 | |
2499 | 2636 | // If you're modifying, get only those posts before the current one. (otherwise get all.) |
2500 | 2637 | $request = $smcFunc['db_query']('', ' |
@@ -2532,8 +2669,9 @@ discard block |
||
2532 | 2669 | 'is_ignored' => !empty($modSettings['enable_buddylist']) && !empty($options['posts_apply_ignore_list']) && in_array($row['id_member'], $context['user']['ignoreusers']), |
2533 | 2670 | ); |
2534 | 2671 | |
2535 | - if (!empty($context['new_replies'])) |
|
2536 | - $context['new_replies']--; |
|
2672 | + if (!empty($context['new_replies'])) { |
|
2673 | + $context['new_replies']--; |
|
2674 | + } |
|
2537 | 2675 | } |
2538 | 2676 | $smcFunc['db_free_result']($request); |
2539 | 2677 | } |
@@ -2550,8 +2688,9 @@ discard block |
||
2550 | 2688 | global $sourcedir, $smcFunc; |
2551 | 2689 | |
2552 | 2690 | loadLanguage('Post'); |
2553 | - if (!isset($_REQUEST['xml'])) |
|
2554 | - loadTemplate('Post'); |
|
2691 | + if (!isset($_REQUEST['xml'])) { |
|
2692 | + loadTemplate('Post'); |
|
2693 | + } |
|
2555 | 2694 | |
2556 | 2695 | include_once($sourcedir . '/Subs-Post.php'); |
2557 | 2696 | |
@@ -2582,8 +2721,9 @@ discard block |
||
2582 | 2721 | $smcFunc['db_free_result']($request); |
2583 | 2722 | |
2584 | 2723 | $context['sub_template'] = 'quotefast'; |
2585 | - if (!empty($row)) |
|
2586 | - $can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']); |
|
2724 | + if (!empty($row)) { |
|
2725 | + $can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']); |
|
2726 | + } |
|
2587 | 2727 | |
2588 | 2728 | if (!empty($can_view_post)) |
2589 | 2729 | { |
@@ -2616,8 +2756,9 @@ discard block |
||
2616 | 2756 | } |
2617 | 2757 | |
2618 | 2758 | // Remove any nested quotes. |
2619 | - if (!empty($modSettings['removeNestedQuotes'])) |
|
2620 | - $row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']); |
|
2759 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
2760 | + $row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']); |
|
2761 | + } |
|
2621 | 2762 | |
2622 | 2763 | $lb = "\n"; |
2623 | 2764 | |
@@ -2643,14 +2784,14 @@ discard block |
||
2643 | 2784 | 'time' => '', |
2644 | 2785 | ), |
2645 | 2786 | ); |
2646 | - } |
|
2647 | - else |
|
2648 | - $context['quote'] = array( |
|
2787 | + } else { |
|
2788 | + $context['quote'] = array( |
|
2649 | 2789 | 'xml' => '', |
2650 | 2790 | 'mozilla' => '', |
2651 | 2791 | 'text' => '', |
2652 | 2792 | ); |
2653 | -} |
|
2793 | + } |
|
2794 | + } |
|
2654 | 2795 | |
2655 | 2796 | /** |
2656 | 2797 | * Used to edit the body or subject of a message inline |
@@ -2662,8 +2803,9 @@ discard block |
||
2662 | 2803 | global $user_info, $context, $smcFunc, $language, $board_info; |
2663 | 2804 | |
2664 | 2805 | // We have to have a topic! |
2665 | - if (empty($topic)) |
|
2666 | - obExit(false); |
|
2806 | + if (empty($topic)) { |
|
2807 | + obExit(false); |
|
2808 | + } |
|
2667 | 2809 | |
2668 | 2810 | checkSession('get'); |
2669 | 2811 | require_once($sourcedir . '/Subs-Post.php'); |
@@ -2689,31 +2831,35 @@ discard block |
||
2689 | 2831 | 'guest_id' => 0, |
2690 | 2832 | ) |
2691 | 2833 | ); |
2692 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
2693 | - fatal_lang_error('no_board', false); |
|
2834 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
2835 | + fatal_lang_error('no_board', false); |
|
2836 | + } |
|
2694 | 2837 | $row = $smcFunc['db_fetch_assoc']($request); |
2695 | 2838 | $smcFunc['db_free_result']($request); |
2696 | 2839 | |
2697 | 2840 | // Change either body or subject requires permissions to modify messages. |
2698 | 2841 | if (isset($_POST['message']) || isset($_POST['subject']) || isset($_REQUEST['icon'])) |
2699 | 2842 | { |
2700 | - if (!empty($row['locked'])) |
|
2701 | - isAllowedTo('moderate_board'); |
|
2843 | + if (!empty($row['locked'])) { |
|
2844 | + isAllowedTo('moderate_board'); |
|
2845 | + } |
|
2702 | 2846 | |
2703 | 2847 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
2704 | 2848 | { |
2705 | - if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
2706 | - fatal_lang_error('modify_post_time_passed', false); |
|
2707 | - elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) |
|
2708 | - isAllowedTo('modify_replies'); |
|
2709 | - else |
|
2710 | - isAllowedTo('modify_own'); |
|
2849 | + if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
2850 | + fatal_lang_error('modify_post_time_passed', false); |
|
2851 | + } elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
2852 | + isAllowedTo('modify_replies'); |
|
2853 | + } else { |
|
2854 | + isAllowedTo('modify_own'); |
|
2855 | + } |
|
2711 | 2856 | } |
2712 | 2857 | // Otherwise, they're locked out; someone who can modify the replies is needed. |
2713 | - elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
2714 | - isAllowedTo('modify_replies'); |
|
2715 | - else |
|
2716 | - isAllowedTo('modify_any'); |
|
2858 | + elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
2859 | + isAllowedTo('modify_replies'); |
|
2860 | + } else { |
|
2861 | + isAllowedTo('modify_any'); |
|
2862 | + } |
|
2717 | 2863 | |
2718 | 2864 | // Only log this action if it wasn't your message. |
2719 | 2865 | $moderationAction = $row['id_member'] != $user_info['id']; |
@@ -2725,10 +2871,10 @@ discard block |
||
2725 | 2871 | $_POST['subject'] = strtr($smcFunc['htmlspecialchars']($_POST['subject']), array("\r" => '', "\n" => '', "\t" => '')); |
2726 | 2872 | |
2727 | 2873 | // Maximum number of characters. |
2728 | - if ($smcFunc['strlen']($_POST['subject']) > 100) |
|
2729 | - $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
2730 | - } |
|
2731 | - elseif (isset($_POST['subject'])) |
|
2874 | + if ($smcFunc['strlen']($_POST['subject']) > 100) { |
|
2875 | + $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
2876 | + } |
|
2877 | + } elseif (isset($_POST['subject'])) |
|
2732 | 2878 | { |
2733 | 2879 | $post_errors[] = 'no_subject'; |
2734 | 2880 | unset($_POST['subject']); |
@@ -2740,13 +2886,11 @@ discard block |
||
2740 | 2886 | { |
2741 | 2887 | $post_errors[] = 'no_message'; |
2742 | 2888 | unset($_POST['message']); |
2743 | - } |
|
2744 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
2889 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
2745 | 2890 | { |
2746 | 2891 | $post_errors[] = 'long_message'; |
2747 | 2892 | unset($_POST['message']); |
2748 | - } |
|
2749 | - else |
|
2893 | + } else |
|
2750 | 2894 | { |
2751 | 2895 | $_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES); |
2752 | 2896 | |
@@ -2762,31 +2906,34 @@ discard block |
||
2762 | 2906 | |
2763 | 2907 | if (isset($_POST['lock'])) |
2764 | 2908 | { |
2765 | - if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member'])) |
|
2766 | - unset($_POST['lock']); |
|
2767 | - elseif (!allowedTo('lock_any')) |
|
2909 | + if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member'])) { |
|
2910 | + unset($_POST['lock']); |
|
2911 | + } elseif (!allowedTo('lock_any')) |
|
2768 | 2912 | { |
2769 | - if ($row['locked'] == 1) |
|
2770 | - unset($_POST['lock']); |
|
2771 | - else |
|
2772 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
2913 | + if ($row['locked'] == 1) { |
|
2914 | + unset($_POST['lock']); |
|
2915 | + } else { |
|
2916 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
2917 | + } |
|
2918 | + } elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked']) { |
|
2919 | + unset($_POST['lock']); |
|
2920 | + } else { |
|
2921 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
|
2773 | 2922 | } |
2774 | - elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked']) |
|
2775 | - unset($_POST['lock']); |
|
2776 | - else |
|
2777 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
|
2778 | 2923 | } |
2779 | 2924 | |
2780 | - if (isset($_POST['sticky']) && !allowedTo('make_sticky')) |
|
2781 | - unset($_POST['sticky']); |
|
2925 | + if (isset($_POST['sticky']) && !allowedTo('make_sticky')) { |
|
2926 | + unset($_POST['sticky']); |
|
2927 | + } |
|
2782 | 2928 | |
2783 | 2929 | if (isset($_POST['modify_reason'])) |
2784 | 2930 | { |
2785 | 2931 | $_POST['modify_reason'] = strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => '')); |
2786 | 2932 | |
2787 | 2933 | // Maximum number of characters. |
2788 | - if ($smcFunc['strlen']($_POST['modify_reason']) > 100) |
|
2789 | - $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
2934 | + if ($smcFunc['strlen']($_POST['modify_reason']) > 100) { |
|
2935 | + $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
2936 | + } |
|
2790 | 2937 | } |
2791 | 2938 | |
2792 | 2939 | if (empty($post_errors)) |
@@ -2823,8 +2970,9 @@ discard block |
||
2823 | 2970 | } |
2824 | 2971 | } |
2825 | 2972 | // If nothing was changed there's no need to add an entry to the moderation log. |
2826 | - else |
|
2827 | - $moderationAction = false; |
|
2973 | + else { |
|
2974 | + $moderationAction = false; |
|
2975 | + } |
|
2828 | 2976 | |
2829 | 2977 | modifyPost($msgOptions, $topicOptions, $posterOptions); |
2830 | 2978 | |
@@ -2842,9 +2990,9 @@ discard block |
||
2842 | 2990 | // Get the proper (default language) response prefix first. |
2843 | 2991 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
2844 | 2992 | { |
2845 | - if ($language === $user_info['language']) |
|
2846 | - $context['response_prefix'] = $txt['response_prefix']; |
|
2847 | - else |
|
2993 | + if ($language === $user_info['language']) { |
|
2994 | + $context['response_prefix'] = $txt['response_prefix']; |
|
2995 | + } else |
|
2848 | 2996 | { |
2849 | 2997 | loadLanguage('index', $language, false); |
2850 | 2998 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -2866,8 +3014,9 @@ discard block |
||
2866 | 3014 | ); |
2867 | 3015 | } |
2868 | 3016 | |
2869 | - if (!empty($moderationAction)) |
|
2870 | - logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
3017 | + if (!empty($moderationAction)) { |
|
3018 | + logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
3019 | + } |
|
2871 | 3020 | } |
2872 | 3021 | |
2873 | 3022 | if (isset($_REQUEST['xml'])) |
@@ -2908,8 +3057,7 @@ discard block |
||
2908 | 3057 | ); |
2909 | 3058 | |
2910 | 3059 | censorText($context['message']['subject']); |
2911 | - } |
|
2912 | - else |
|
3060 | + } else |
|
2913 | 3061 | { |
2914 | 3062 | $context['message'] = array( |
2915 | 3063 | 'id' => $row['id_msg'], |
@@ -2921,15 +3069,16 @@ discard block |
||
2921 | 3069 | loadLanguage('Errors'); |
2922 | 3070 | foreach ($post_errors as $post_error) |
2923 | 3071 | { |
2924 | - if ($post_error == 'long_message') |
|
2925 | - $context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']); |
|
2926 | - else |
|
2927 | - $context['message']['errors'][] = $txt['error_' . $post_error]; |
|
3072 | + if ($post_error == 'long_message') { |
|
3073 | + $context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']); |
|
3074 | + } else { |
|
3075 | + $context['message']['errors'][] = $txt['error_' . $post_error]; |
|
3076 | + } |
|
2928 | 3077 | } |
2929 | 3078 | } |
3079 | + } else { |
|
3080 | + obExit(false); |
|
3081 | + } |
|
2930 | 3082 | } |
2931 | - else |
|
2932 | - obExit(false); |
|
2933 | -} |
|
2934 | 3083 | |
2935 | 3084 | ?> |
2936 | 3085 | \ No newline at end of file |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 3 |
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 | * Ask them for their login information. (shows a page for the user to type |
@@ -29,8 +30,9 @@ discard block |
||
29 | 30 | global $txt, $context, $scripturl, $user_info; |
30 | 31 | |
31 | 32 | // You are already logged in, go take a tour of the boards |
32 | - if (!empty($user_info['id'])) |
|
33 | - redirectexit(); |
|
33 | + if (!empty($user_info['id'])) { |
|
34 | + redirectexit(); |
|
35 | + } |
|
34 | 36 | |
35 | 37 | // We need to load the Login template/language file. |
36 | 38 | loadLanguage('Login'); |
@@ -57,10 +59,11 @@ discard block |
||
57 | 59 | ); |
58 | 60 | |
59 | 61 | // Set the login URL - will be used when the login process is done (but careful not to send us to an attachment). |
60 | - if (isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) |
|
61 | - $_SESSION['login_url'] = $_SESSION['old_url']; |
|
62 | - elseif (isset($_SESSION['login_url']) && strpos($_SESSION['login_url'], 'dlattach') !== false) |
|
63 | - unset($_SESSION['login_url']); |
|
62 | + if (isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) { |
|
63 | + $_SESSION['login_url'] = $_SESSION['old_url']; |
|
64 | + } elseif (isset($_SESSION['login_url']) && strpos($_SESSION['login_url'], 'dlattach') !== false) { |
|
65 | + unset($_SESSION['login_url']); |
|
66 | + } |
|
64 | 67 | |
65 | 68 | // Create a one time token. |
66 | 69 | createToken('login'); |
@@ -83,8 +86,9 @@ discard block |
||
83 | 86 | global $cookiename, $modSettings, $context, $sourcedir, $maintenance; |
84 | 87 | |
85 | 88 | // Check to ensure we're forcing SSL for authentication |
86 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
87 | - fatal_lang_error('login_ssl_required'); |
|
89 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
90 | + fatal_lang_error('login_ssl_required'); |
|
91 | + } |
|
88 | 92 | |
89 | 93 | // Load cookie authentication stuff. |
90 | 94 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -102,19 +106,20 @@ discard block |
||
102 | 106 | list (,, $timeout) = smf_json_decode($_COOKIE[$cookiename], true); |
103 | 107 | |
104 | 108 | // That didn't work... Maybe it's using serialize? |
105 | - if (is_null($timeout)) |
|
106 | - list (,, $timeout) = safe_unserialize($_COOKIE[$cookiename]); |
|
107 | - } |
|
108 | - elseif (isset($_SESSION['login_' . $cookiename])) |
|
109 | + if (is_null($timeout)) { |
|
110 | + list (,, $timeout) = safe_unserialize($_COOKIE[$cookiename]); |
|
111 | + } |
|
112 | + } elseif (isset($_SESSION['login_' . $cookiename])) |
|
109 | 113 | { |
110 | 114 | list (,, $timeout) = smf_json_decode($_SESSION['login_' . $cookiename]); |
111 | 115 | |
112 | 116 | // Try for old format |
113 | - if (is_null($timeout)) |
|
114 | - list (,, $timeout) = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
117 | + if (is_null($timeout)) { |
|
118 | + list (,, $timeout) = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
119 | + } |
|
120 | + } else { |
|
121 | + trigger_error('Login2(): Cannot be logged in without a session or cookie', E_USER_ERROR); |
|
115 | 122 | } |
116 | - else |
|
117 | - trigger_error('Login2(): Cannot be logged in without a session or cookie', E_USER_ERROR); |
|
118 | 123 | |
119 | 124 | $user_settings['password_salt'] = substr(md5(mt_rand()), 0, 4); |
120 | 125 | updateMemberData($user_info['id'], array('password_salt' => $user_settings['password_salt'])); |
@@ -125,16 +130,18 @@ discard block |
||
125 | 130 | $tfadata = smf_json_decode($_COOKIE[$cookiename . '_tfa'], true); |
126 | 131 | |
127 | 132 | // If that didn't work, try unserialize instead... |
128 | - if (is_null($tfadata)) |
|
129 | - $tfadata = safe_unserialize($_COOKIE[$cookiename . '_tfa']); |
|
133 | + if (is_null($tfadata)) { |
|
134 | + $tfadata = safe_unserialize($_COOKIE[$cookiename . '_tfa']); |
|
135 | + } |
|
130 | 136 | |
131 | 137 | list ($tfamember, $tfasecret, $exp, $state, $preserve) = $tfadata; |
132 | 138 | |
133 | 139 | // If we're preserving the cookie, reset it with updated salt |
134 | - if ($preserve && time() < $exp) |
|
135 | - setTFACookie(3153600, $user_info['password_salt'], hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']), true); |
|
136 | - else |
|
137 | - setTFACookie(-3600, 0, ''); |
|
140 | + if ($preserve && time() < $exp) { |
|
141 | + setTFACookie(3153600, $user_info['password_salt'], hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']), true); |
|
142 | + } else { |
|
143 | + setTFACookie(-3600, 0, ''); |
|
144 | + } |
|
138 | 145 | } |
139 | 146 | |
140 | 147 | setLoginCookie($timeout - time(), $user_info['id'], hash_salt($user_settings['passwd'], $user_settings['password_salt'])); |
@@ -145,20 +152,20 @@ discard block |
||
145 | 152 | elseif (isset($_GET['sa']) && $_GET['sa'] == 'check') |
146 | 153 | { |
147 | 154 | // Strike! You're outta there! |
148 | - if ($_GET['member'] != $user_info['id']) |
|
149 | - fatal_lang_error('login_cookie_error', false); |
|
155 | + if ($_GET['member'] != $user_info['id']) { |
|
156 | + fatal_lang_error('login_cookie_error', false); |
|
157 | + } |
|
150 | 158 | |
151 | 159 | $user_info['can_mod'] = allowedTo('access_mod_center') || (!$user_info['is_guest'] && ($user_info['mod_cache']['gq'] != '0=1' || $user_info['mod_cache']['bq'] != '0=1' || ($modSettings['postmod_active'] && !empty($user_info['mod_cache']['ap'])))); |
152 | 160 | |
153 | 161 | // Some whitelisting for login_url... |
154 | - if (empty($_SESSION['login_url'])) |
|
155 | - redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa'); |
|
156 | - elseif (!empty($_SESSION['login_url']) && (strpos($_SESSION['login_url'], 'http://') === false && strpos($_SESSION['login_url'], 'https://') === false)) |
|
162 | + if (empty($_SESSION['login_url'])) { |
|
163 | + redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa'); |
|
164 | + } elseif (!empty($_SESSION['login_url']) && (strpos($_SESSION['login_url'], 'http://') === false && strpos($_SESSION['login_url'], 'https://') === false)) |
|
157 | 165 | { |
158 | 166 | unset ($_SESSION['login_url']); |
159 | 167 | redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa'); |
160 | - } |
|
161 | - else |
|
168 | + } else |
|
162 | 169 | { |
163 | 170 | // Best not to clutter the session data too much... |
164 | 171 | $temp = $_SESSION['login_url']; |
@@ -169,8 +176,9 @@ discard block |
||
169 | 176 | } |
170 | 177 | |
171 | 178 | // Beyond this point you are assumed to be a guest trying to login. |
172 | - if (!$user_info['is_guest']) |
|
173 | - redirectexit(); |
|
179 | + if (!$user_info['is_guest']) { |
|
180 | + redirectexit(); |
|
181 | + } |
|
174 | 182 | |
175 | 183 | // Are you guessing with a script? |
176 | 184 | checkSession(); |
@@ -178,18 +186,21 @@ discard block |
||
178 | 186 | spamProtection('login'); |
179 | 187 | |
180 | 188 | // Set the login_url if it's not already set (but careful not to send us to an attachment). |
181 | - if ((empty($_SESSION['login_url']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) || (isset($_GET['quicklogin']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'login') === false)) |
|
182 | - $_SESSION['login_url'] = $_SESSION['old_url']; |
|
189 | + if ((empty($_SESSION['login_url']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) || (isset($_GET['quicklogin']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'login') === false)) { |
|
190 | + $_SESSION['login_url'] = $_SESSION['old_url']; |
|
191 | + } |
|
183 | 192 | |
184 | 193 | // Been guessing a lot, haven't we? |
185 | - if (isset($_SESSION['failed_login']) && $_SESSION['failed_login'] >= $modSettings['failed_login_threshold'] * 3) |
|
186 | - fatal_lang_error('login_threshold_fail', 'critical'); |
|
194 | + if (isset($_SESSION['failed_login']) && $_SESSION['failed_login'] >= $modSettings['failed_login_threshold'] * 3) { |
|
195 | + fatal_lang_error('login_threshold_fail', 'critical'); |
|
196 | + } |
|
187 | 197 | |
188 | 198 | // Set up the cookie length. (if it's invalid, just fall through and use the default.) |
189 | - if (isset($_POST['cookieneverexp']) || (!empty($_POST['cookielength']) && $_POST['cookielength'] == -1)) |
|
190 | - $modSettings['cookieTime'] = 3153600; |
|
191 | - elseif (!empty($_POST['cookielength']) && ($_POST['cookielength'] >= 1 && $_POST['cookielength'] <= 525600)) |
|
192 | - $modSettings['cookieTime'] = (int) $_POST['cookielength']; |
|
199 | + if (isset($_POST['cookieneverexp']) || (!empty($_POST['cookielength']) && $_POST['cookielength'] == -1)) { |
|
200 | + $modSettings['cookieTime'] = 3153600; |
|
201 | + } elseif (!empty($_POST['cookielength']) && ($_POST['cookielength'] >= 1 && $_POST['cookielength'] <= 525600)) { |
|
202 | + $modSettings['cookieTime'] = (int) $_POST['cookielength']; |
|
203 | + } |
|
193 | 204 | |
194 | 205 | loadLanguage('Login'); |
195 | 206 | // Load the template stuff. |
@@ -309,8 +320,9 @@ discard block |
||
309 | 320 | $other_passwords[] = crypt(md5($_POST['passwrd']), md5($_POST['passwrd'])); |
310 | 321 | |
311 | 322 | // Snitz style - SHA-256. Technically, this is a downgrade, but most PHP configurations don't support sha256 anyway. |
312 | - if (strlen($user_settings['passwd']) == 64 && function_exists('mhash') && defined('MHASH_SHA256')) |
|
313 | - $other_passwords[] = bin2hex(mhash(MHASH_SHA256, $_POST['passwrd'])); |
|
323 | + if (strlen($user_settings['passwd']) == 64 && function_exists('mhash') && defined('MHASH_SHA256')) { |
|
324 | + $other_passwords[] = bin2hex(mhash(MHASH_SHA256, $_POST['passwrd'])); |
|
325 | + } |
|
314 | 326 | |
315 | 327 | // phpBB3 users new hashing. We now support it as well ;). |
316 | 328 | $other_passwords[] = phpBB3_password_check($_POST['passwrd'], $user_settings['passwd']); |
@@ -330,27 +342,29 @@ discard block |
||
330 | 342 | // Some common md5 ones. |
331 | 343 | $other_passwords[] = md5($user_settings['password_salt'] . $_POST['passwrd']); |
332 | 344 | $other_passwords[] = md5($_POST['passwrd'] . $user_settings['password_salt']); |
333 | - } |
|
334 | - elseif (strlen($user_settings['passwd']) == 40) |
|
345 | + } elseif (strlen($user_settings['passwd']) == 40) |
|
335 | 346 | { |
336 | 347 | // Maybe they are using a hash from before the password fix. |
337 | 348 | // This is also valid for SMF 1.1 to 2.0 style of hashing, changed to bcrypt in SMF 2.1 |
338 | 349 | $other_passwords[] = sha1(strtolower($user_settings['member_name']) . un_htmlspecialchars($_POST['passwrd'])); |
339 | 350 | |
340 | 351 | // BurningBoard3 style of hashing. |
341 | - if (!empty($modSettings['enable_password_conversion'])) |
|
342 | - $other_passwords[] = sha1($user_settings['password_salt'] . sha1($user_settings['password_salt'] . sha1($_POST['passwrd']))); |
|
352 | + if (!empty($modSettings['enable_password_conversion'])) { |
|
353 | + $other_passwords[] = sha1($user_settings['password_salt'] . sha1($user_settings['password_salt'] . sha1($_POST['passwrd']))); |
|
354 | + } |
|
343 | 355 | |
344 | 356 | // Perhaps we converted to UTF-8 and have a valid password being hashed differently. |
345 | 357 | if ($context['character_set'] == 'UTF-8' && !empty($modSettings['previousCharacterSet']) && $modSettings['previousCharacterSet'] != 'utf8') |
346 | 358 | { |
347 | 359 | // Try iconv first, for no particular reason. |
348 | - if (function_exists('iconv')) |
|
349 | - $other_passwords['iconv'] = sha1(strtolower(iconv('UTF-8', $modSettings['previousCharacterSet'], $user_settings['member_name'])) . un_htmlspecialchars(iconv('UTF-8', $modSettings['previousCharacterSet'], $_POST['passwrd']))); |
|
360 | + if (function_exists('iconv')) { |
|
361 | + $other_passwords['iconv'] = sha1(strtolower(iconv('UTF-8', $modSettings['previousCharacterSet'], $user_settings['member_name'])) . un_htmlspecialchars(iconv('UTF-8', $modSettings['previousCharacterSet'], $_POST['passwrd']))); |
|
362 | + } |
|
350 | 363 | |
351 | 364 | // Say it aint so, iconv failed! |
352 | - if (empty($other_passwords['iconv']) && function_exists('mb_convert_encoding')) |
|
353 | - $other_passwords[] = sha1(strtolower(mb_convert_encoding($user_settings['member_name'], 'UTF-8', $modSettings['previousCharacterSet'])) . un_htmlspecialchars(mb_convert_encoding($_POST['passwrd'], 'UTF-8', $modSettings['previousCharacterSet']))); |
|
365 | + if (empty($other_passwords['iconv']) && function_exists('mb_convert_encoding')) { |
|
366 | + $other_passwords[] = sha1(strtolower(mb_convert_encoding($user_settings['member_name'], 'UTF-8', $modSettings['previousCharacterSet'])) . un_htmlspecialchars(mb_convert_encoding($_POST['passwrd'], 'UTF-8', $modSettings['previousCharacterSet']))); |
|
367 | + } |
|
354 | 368 | } |
355 | 369 | } |
356 | 370 | |
@@ -380,8 +394,9 @@ discard block |
||
380 | 394 | $_SESSION['failed_login'] = isset($_SESSION['failed_login']) ? ($_SESSION['failed_login'] + 1) : 1; |
381 | 395 | |
382 | 396 | // Hmm... don't remember it, do you? Here, try the password reminder ;). |
383 | - if ($_SESSION['failed_login'] >= $modSettings['failed_login_threshold']) |
|
384 | - redirectexit('action=reminder'); |
|
397 | + if ($_SESSION['failed_login'] >= $modSettings['failed_login_threshold']) { |
|
398 | + redirectexit('action=reminder'); |
|
399 | + } |
|
385 | 400 | // We'll give you another chance... |
386 | 401 | else |
387 | 402 | { |
@@ -392,8 +407,7 @@ discard block |
||
392 | 407 | return; |
393 | 408 | } |
394 | 409 | } |
395 | - } |
|
396 | - elseif (!empty($user_settings['passwd_flood'])) |
|
410 | + } elseif (!empty($user_settings['passwd_flood'])) |
|
397 | 411 | { |
398 | 412 | // Let's be sure they weren't a little hacker. |
399 | 413 | validatePasswordFlood($user_settings['id_member'], $user_settings['passwd_flood'], true); |
@@ -410,8 +424,9 @@ discard block |
||
410 | 424 | } |
411 | 425 | |
412 | 426 | // Check their activation status. |
413 | - if (!checkActivation()) |
|
414 | - return; |
|
427 | + if (!checkActivation()) { |
|
428 | + return; |
|
429 | + } |
|
415 | 430 | |
416 | 431 | DoLogin(); |
417 | 432 | } |
@@ -423,8 +438,9 @@ discard block |
||
423 | 438 | { |
424 | 439 | global $sourcedir, $txt, $context, $user_info, $modSettings, $scripturl; |
425 | 440 | |
426 | - if (!$user_info['is_guest'] || empty($context['tfa_member']) || empty($modSettings['tfa_mode'])) |
|
427 | - fatal_lang_error('no_access', false); |
|
441 | + if (!$user_info['is_guest'] || empty($context['tfa_member']) || empty($modSettings['tfa_mode'])) { |
|
442 | + fatal_lang_error('no_access', false); |
|
443 | + } |
|
428 | 444 | |
429 | 445 | loadLanguage('Profile'); |
430 | 446 | require_once($sourcedir . '/Class-TOTP.php'); |
@@ -432,8 +448,9 @@ discard block |
||
432 | 448 | $member = $context['tfa_member']; |
433 | 449 | |
434 | 450 | // Prevent replay attacks by limiting at least 2 minutes before they can log in again via 2FA |
435 | - if (time() - $member['last_login'] < 120) |
|
436 | - fatal_lang_error('tfa_wait', false); |
|
451 | + if (time() - $member['last_login'] < 120) { |
|
452 | + fatal_lang_error('tfa_wait', false); |
|
453 | + } |
|
437 | 454 | |
438 | 455 | $totp = new \TOTP\Auth($member['tfa_secret']); |
439 | 456 | $totp->setRange(1); |
@@ -447,8 +464,9 @@ discard block |
||
447 | 464 | if (!empty($_POST['tfa_code']) && empty($_POST['tfa_backup'])) |
448 | 465 | { |
449 | 466 | // Check to ensure we're forcing SSL for authentication |
450 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
451 | - fatal_lang_error('login_ssl_required'); |
|
467 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
468 | + fatal_lang_error('login_ssl_required'); |
|
469 | + } |
|
452 | 470 | |
453 | 471 | $code = $_POST['tfa_code']; |
454 | 472 | |
@@ -458,20 +476,19 @@ discard block |
||
458 | 476 | |
459 | 477 | setTFACookie(3153600, $member['id_member'], hash_salt($member['tfa_backup'], $member['password_salt']), !empty($_POST['tfa_preserve'])); |
460 | 478 | redirectexit(); |
461 | - } |
|
462 | - else |
|
479 | + } else |
|
463 | 480 | { |
464 | 481 | validatePasswordFlood($member['id_member'], $member['passwd_flood'], false, true); |
465 | 482 | |
466 | 483 | $context['tfa_error'] = true; |
467 | 484 | $context['tfa_value'] = $_POST['tfa_code']; |
468 | 485 | } |
469 | - } |
|
470 | - elseif (!empty($_POST['tfa_backup'])) |
|
486 | + } elseif (!empty($_POST['tfa_backup'])) |
|
471 | 487 | { |
472 | 488 | // Check to ensure we're forcing SSL for authentication |
473 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
474 | - fatal_lang_error('login_ssl_required'); |
|
489 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
490 | + fatal_lang_error('login_ssl_required'); |
|
491 | + } |
|
475 | 492 | |
476 | 493 | $backup = $_POST['tfa_backup']; |
477 | 494 | |
@@ -485,8 +502,7 @@ discard block |
||
485 | 502 | )); |
486 | 503 | setTFACookie(3153600, $member['id_member'], hash_salt($member['tfa_backup'], $member['password_salt'])); |
487 | 504 | redirectexit('action=profile;area=tfasetup;backup'); |
488 | - } |
|
489 | - else |
|
505 | + } else |
|
490 | 506 | { |
491 | 507 | validatePasswordFlood($member['id_member'], $member['passwd_flood'], false, true); |
492 | 508 | |
@@ -509,8 +525,9 @@ discard block |
||
509 | 525 | { |
510 | 526 | global $context, $txt, $scripturl, $user_settings, $modSettings; |
511 | 527 | |
512 | - if (!isset($context['login_errors'])) |
|
513 | - $context['login_errors'] = array(); |
|
528 | + if (!isset($context['login_errors'])) { |
|
529 | + $context['login_errors'] = array(); |
|
530 | + } |
|
514 | 531 | |
515 | 532 | // What is the true activation status of this account? |
516 | 533 | $activation_status = $user_settings['is_activated'] > 10 ? $user_settings['is_activated'] - 10 : $user_settings['is_activated']; |
@@ -522,8 +539,9 @@ discard block |
||
522 | 539 | return false; |
523 | 540 | } |
524 | 541 | // Awaiting approval still? |
525 | - elseif ($activation_status == 3) |
|
526 | - fatal_lang_error('still_awaiting_approval', 'user'); |
|
542 | + elseif ($activation_status == 3) { |
|
543 | + fatal_lang_error('still_awaiting_approval', 'user'); |
|
544 | + } |
|
527 | 545 | // Awaiting deletion, changed their mind? |
528 | 546 | elseif ($activation_status == 4) |
529 | 547 | { |
@@ -531,8 +549,7 @@ discard block |
||
531 | 549 | { |
532 | 550 | updateMemberData($user_settings['id_member'], array('is_activated' => 1)); |
533 | 551 | updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 0 ? $modSettings['unapprovedMembers'] - 1 : 0))); |
534 | - } |
|
535 | - else |
|
552 | + } else |
|
536 | 553 | { |
537 | 554 | $context['disable_login_hashing'] = true; |
538 | 555 | $context['login_errors'][] = $txt['awaiting_delete_account']; |
@@ -573,8 +590,9 @@ discard block |
||
573 | 590 | setLoginCookie(60 * $modSettings['cookieTime'], $user_settings['id_member'], hash_salt($user_settings['passwd'], $user_settings['password_salt'])); |
574 | 591 | |
575 | 592 | // Reset the login threshold. |
576 | - if (isset($_SESSION['failed_login'])) |
|
577 | - unset($_SESSION['failed_login']); |
|
593 | + if (isset($_SESSION['failed_login'])) { |
|
594 | + unset($_SESSION['failed_login']); |
|
595 | + } |
|
578 | 596 | |
579 | 597 | $user_info['is_guest'] = false; |
580 | 598 | $user_settings['additional_groups'] = explode(',', $user_settings['additional_groups']); |
@@ -596,16 +614,18 @@ discard block |
||
596 | 614 | 'id_member' => $user_info['id'], |
597 | 615 | ) |
598 | 616 | ); |
599 | - if ($smcFunc['db_num_rows']($request) == 1) |
|
600 | - $_SESSION['first_login'] = true; |
|
601 | - else |
|
602 | - unset($_SESSION['first_login']); |
|
617 | + if ($smcFunc['db_num_rows']($request) == 1) { |
|
618 | + $_SESSION['first_login'] = true; |
|
619 | + } else { |
|
620 | + unset($_SESSION['first_login']); |
|
621 | + } |
|
603 | 622 | $smcFunc['db_free_result']($request); |
604 | 623 | |
605 | 624 | // You've logged in, haven't you? |
606 | 625 | $update = array('member_ip' => $user_info['ip'], 'member_ip2' => $_SERVER['BAN_CHECK_IP']); |
607 | - if (empty($user_settings['tfa_secret'])) |
|
608 | - $update['last_login'] = time(); |
|
626 | + if (empty($user_settings['tfa_secret'])) { |
|
627 | + $update['last_login'] = time(); |
|
628 | + } |
|
609 | 629 | updateMemberData($user_info['id'], $update); |
610 | 630 | |
611 | 631 | // Get rid of the online entry for that old guest.... |
@@ -619,8 +639,8 @@ discard block |
||
619 | 639 | $_SESSION['log_time'] = 0; |
620 | 640 | |
621 | 641 | // Log this entry, only if we have it enabled. |
622 | - if (!empty($modSettings['loginHistoryDays'])) |
|
623 | - $smcFunc['db_insert']('insert', |
|
642 | + if (!empty($modSettings['loginHistoryDays'])) { |
|
643 | + $smcFunc['db_insert']('insert', |
|
624 | 644 | '{db_prefix}member_logins', |
625 | 645 | array( |
626 | 646 | 'id_member' => 'int', 'time' => 'int', 'ip' => 'inet', 'ip2' => 'inet', |
@@ -632,13 +652,15 @@ discard block |
||
632 | 652 | 'id_member', 'time' |
633 | 653 | ) |
634 | 654 | ); |
655 | + } |
|
635 | 656 | |
636 | 657 | // Just log you back out if it's in maintenance mode and you AREN'T an admin. |
637 | - if (empty($maintenance) || allowedTo('admin_forum')) |
|
638 | - redirectexit('action=login2;sa=check;member=' . $user_info['id'], $context['server']['needs_login_fix']); |
|
639 | - else |
|
640 | - redirectexit('action=logout;' . $context['session_var'] . '=' . $context['session_id'], $context['server']['needs_login_fix']); |
|
641 | -} |
|
658 | + if (empty($maintenance) || allowedTo('admin_forum')) { |
|
659 | + redirectexit('action=login2;sa=check;member=' . $user_info['id'], $context['server']['needs_login_fix']); |
|
660 | + } else { |
|
661 | + redirectexit('action=logout;' . $context['session_var'] . '=' . $context['session_id'], $context['server']['needs_login_fix']); |
|
662 | + } |
|
663 | + } |
|
642 | 664 | |
643 | 665 | /** |
644 | 666 | * Logs the current user out of their account. |
@@ -654,13 +676,15 @@ discard block |
||
654 | 676 | global $sourcedir, $user_info, $user_settings, $context, $smcFunc, $cookiename, $modSettings; |
655 | 677 | |
656 | 678 | // Make sure they aren't being auto-logged out. |
657 | - if (!$internal) |
|
658 | - checkSession('get'); |
|
679 | + if (!$internal) { |
|
680 | + checkSession('get'); |
|
681 | + } |
|
659 | 682 | |
660 | 683 | require_once($sourcedir . '/Subs-Auth.php'); |
661 | 684 | |
662 | - if (isset($_SESSION['pack_ftp'])) |
|
663 | - $_SESSION['pack_ftp'] = null; |
|
685 | + if (isset($_SESSION['pack_ftp'])) { |
|
686 | + $_SESSION['pack_ftp'] = null; |
|
687 | + } |
|
664 | 688 | |
665 | 689 | // It won't be first login anymore. |
666 | 690 | unset($_SESSION['first_login']); |
@@ -688,24 +712,27 @@ discard block |
||
688 | 712 | |
689 | 713 | // And some other housekeeping while we're at it. |
690 | 714 | $salt = substr(md5(mt_rand()), 0, 4); |
691 | - if (!empty($user_info['id'])) |
|
692 | - updateMemberData($user_info['id'], array('password_salt' => $salt)); |
|
715 | + if (!empty($user_info['id'])) { |
|
716 | + updateMemberData($user_info['id'], array('password_salt' => $salt)); |
|
717 | + } |
|
693 | 718 | |
694 | 719 | if (!empty($modSettings['tfa_mode']) && !empty($user_info['id']) && !empty($_COOKIE[$cookiename . '_tfa'])) |
695 | 720 | { |
696 | 721 | $tfadata = smf_json_decode($_COOKIE[$cookiename . '_tfa'], true); |
697 | 722 | |
698 | 723 | // If that failed, try the old method |
699 | - if (is_null($tfadata)) |
|
700 | - $tfadata = safe_unserialize($_COOKIE[$cookiename . '_tfa']); |
|
724 | + if (is_null($tfadata)) { |
|
725 | + $tfadata = safe_unserialize($_COOKIE[$cookiename . '_tfa']); |
|
726 | + } |
|
701 | 727 | |
702 | 728 | list ($tfamember, $tfasecret, $exp, $state, $preserve) = $tfadata; |
703 | 729 | |
704 | 730 | // If we're preserving the cookie, reset it with updated salt |
705 | - if ($preserve && time() < $exp) |
|
706 | - setTFACookie(3153600, $user_info['id'], hash_salt($user_settings['tfa_backup'], $salt), true); |
|
707 | - else |
|
708 | - setTFACookie(-3600, 0, ''); |
|
731 | + if ($preserve && time() < $exp) { |
|
732 | + setTFACookie(3153600, $user_info['id'], hash_salt($user_settings['tfa_backup'], $salt), true); |
|
733 | + } else { |
|
734 | + setTFACookie(-3600, 0, ''); |
|
735 | + } |
|
709 | 736 | } |
710 | 737 | |
711 | 738 | session_destroy(); |
@@ -713,14 +740,13 @@ discard block |
||
713 | 740 | // Off to the merry board index we go! |
714 | 741 | if ($redirect) |
715 | 742 | { |
716 | - if (empty($_SESSION['logout_url'])) |
|
717 | - redirectexit('', $context['server']['needs_login_fix']); |
|
718 | - elseif (!empty($_SESSION['logout_url']) && (strpos($_SESSION['logout_url'], 'http://') === false && strpos($_SESSION['logout_url'], 'https://') === false)) |
|
743 | + if (empty($_SESSION['logout_url'])) { |
|
744 | + redirectexit('', $context['server']['needs_login_fix']); |
|
745 | + } elseif (!empty($_SESSION['logout_url']) && (strpos($_SESSION['logout_url'], 'http://') === false && strpos($_SESSION['logout_url'], 'https://') === false)) |
|
719 | 746 | { |
720 | 747 | unset ($_SESSION['logout_url']); |
721 | 748 | redirectexit(); |
722 | - } |
|
723 | - else |
|
749 | + } else |
|
724 | 750 | { |
725 | 751 | $temp = $_SESSION['logout_url']; |
726 | 752 | unset($_SESSION['logout_url']); |
@@ -753,8 +779,9 @@ discard block |
||
753 | 779 | function phpBB3_password_check($passwd, $passwd_hash) |
754 | 780 | { |
755 | 781 | // Too long or too short? |
756 | - if (strlen($passwd_hash) != 34) |
|
757 | - return; |
|
782 | + if (strlen($passwd_hash) != 34) { |
|
783 | + return; |
|
784 | + } |
|
758 | 785 | |
759 | 786 | // Range of characters allowed. |
760 | 787 | $range = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; |
@@ -766,8 +793,9 @@ discard block |
||
766 | 793 | $salt = substr($passwd_hash, 4, 8); |
767 | 794 | |
768 | 795 | $hash = md5($salt . $passwd, true); |
769 | - for (; $count != 0; --$count) |
|
770 | - $hash = md5($hash . $passwd, true); |
|
796 | + for (; $count != 0; --$count) { |
|
797 | + $hash = md5($hash . $passwd, true); |
|
798 | + } |
|
771 | 799 | |
772 | 800 | $output = substr($passwd_hash, 0, 12); |
773 | 801 | $i = 0; |
@@ -776,21 +804,25 @@ discard block |
||
776 | 804 | $value = ord($hash[$i++]); |
777 | 805 | $output .= $range[$value & 0x3f]; |
778 | 806 | |
779 | - if ($i < 16) |
|
780 | - $value |= ord($hash[$i]) << 8; |
|
807 | + if ($i < 16) { |
|
808 | + $value |= ord($hash[$i]) << 8; |
|
809 | + } |
|
781 | 810 | |
782 | 811 | $output .= $range[($value >> 6) & 0x3f]; |
783 | 812 | |
784 | - if ($i++ >= 16) |
|
785 | - break; |
|
813 | + if ($i++ >= 16) { |
|
814 | + break; |
|
815 | + } |
|
786 | 816 | |
787 | - if ($i < 16) |
|
788 | - $value |= ord($hash[$i]) << 16; |
|
817 | + if ($i < 16) { |
|
818 | + $value |= ord($hash[$i]) << 16; |
|
819 | + } |
|
789 | 820 | |
790 | 821 | $output .= $range[($value >> 12) & 0x3f]; |
791 | 822 | |
792 | - if ($i++ >= 16) |
|
793 | - break; |
|
823 | + if ($i++ >= 16) { |
|
824 | + break; |
|
825 | + } |
|
794 | 826 | |
795 | 827 | $output .= $range[($value >> 18) & 0x3f]; |
796 | 828 | } |
@@ -821,8 +853,9 @@ discard block |
||
821 | 853 | require_once($sourcedir . '/Subs-Auth.php'); |
822 | 854 | setLoginCookie(-3600, 0); |
823 | 855 | |
824 | - if (isset($_SESSION['login_' . $cookiename])) |
|
825 | - unset($_SESSION['login_' . $cookiename]); |
|
856 | + if (isset($_SESSION['login_' . $cookiename])) { |
|
857 | + unset($_SESSION['login_' . $cookiename]); |
|
858 | + } |
|
826 | 859 | } |
827 | 860 | |
828 | 861 | // We need a member! |
@@ -836,8 +869,9 @@ discard block |
||
836 | 869 | } |
837 | 870 | |
838 | 871 | // Right, have we got a flood value? |
839 | - if ($password_flood_value !== false) |
|
840 | - @list ($time_stamp, $number_tries) = explode('|', $password_flood_value); |
|
872 | + if ($password_flood_value !== false) { |
|
873 | + @list ($time_stamp, $number_tries) = explode('|', $password_flood_value); |
|
874 | + } |
|
841 | 875 | |
842 | 876 | // Timestamp or number of tries invalid? |
843 | 877 | if (empty($number_tries) || empty($time_stamp)) |
@@ -853,15 +887,17 @@ discard block |
||
853 | 887 | $number_tries = $time_stamp < time() - 20 ? 2 : $number_tries; |
854 | 888 | |
855 | 889 | // They are trying too fast, make them wait longer |
856 | - if ($time_stamp < time() - 10) |
|
857 | - $time_stamp = time(); |
|
890 | + if ($time_stamp < time() - 10) { |
|
891 | + $time_stamp = time(); |
|
892 | + } |
|
858 | 893 | } |
859 | 894 | |
860 | 895 | $number_tries++; |
861 | 896 | |
862 | 897 | // Broken the law? |
863 | - if ($number_tries > 5) |
|
864 | - fatal_lang_error('login_threshold_brute_fail', 'critical'); |
|
898 | + if ($number_tries > 5) { |
|
899 | + fatal_lang_error('login_threshold_brute_fail', 'critical'); |
|
900 | + } |
|
865 | 901 | |
866 | 902 | // Otherwise set the members data. If they correct on their first attempt then we actually clear it, otherwise we set it! |
867 | 903 | updateMemberData($id_member, array('passwd_flood' => $was_correct && $number_tries == 1 ? '' : $time_stamp . '|' . $number_tries)); |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
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 | * Add the functions implemented in this file to the $smcFunc array. |
@@ -23,8 +24,8 @@ discard block |
||
23 | 24 | { |
24 | 25 | global $smcFunc; |
25 | 26 | |
26 | - if (!isset($smcFunc['db_backup_table']) || $smcFunc['db_backup_table'] != 'smf_db_backup_table') |
|
27 | - $smcFunc += array( |
|
27 | + if (!isset($smcFunc['db_backup_table']) || $smcFunc['db_backup_table'] != 'smf_db_backup_table') { |
|
28 | + $smcFunc += array( |
|
28 | 29 | 'db_backup_table' => 'smf_db_backup_table', |
29 | 30 | 'db_optimize_table' => 'smf_db_optimize_table', |
30 | 31 | 'db_table_sql' => 'smf_db_table_sql', |
@@ -32,7 +33,8 @@ discard block |
||
32 | 33 | 'db_get_version' => 'smf_db_get_version', |
33 | 34 | 'db_get_engine' => 'smf_db_get_engine', |
34 | 35 | ); |
35 | -} |
|
36 | + } |
|
37 | + } |
|
36 | 38 | |
37 | 39 | /** |
38 | 40 | * Backup $table to $backup_table. |
@@ -74,8 +76,9 @@ discard block |
||
74 | 76 | )); |
75 | 77 | |
76 | 78 | // Old school or no school? |
77 | - if ($request) |
|
78 | - return $request; |
|
79 | + if ($request) { |
|
80 | + return $request; |
|
81 | + } |
|
79 | 82 | } |
80 | 83 | |
81 | 84 | // At this point, the quick method failed. |
@@ -99,8 +102,9 @@ discard block |
||
99 | 102 | foreach ($create as $k => $l) |
100 | 103 | { |
101 | 104 | // Get the name of the auto_increment column. |
102 | - if (strpos($l, 'auto_increment')) |
|
103 | - $auto_inc = trim($l); |
|
105 | + if (strpos($l, 'auto_increment')) { |
|
106 | + $auto_inc = trim($l); |
|
107 | + } |
|
104 | 108 | |
105 | 109 | // For the engine type, see if we can work out what it is. |
106 | 110 | if (strpos($l, 'ENGINE') !== false || strpos($l, 'TYPE') !== false) |
@@ -108,30 +112,36 @@ discard block |
||
108 | 112 | // Extract the engine type. |
109 | 113 | preg_match('~(ENGINE|TYPE)=(\w+)(\sDEFAULT)?(\sCHARSET=(\w+))?(\sCOLLATE=(\w+))?~', $l, $match); |
110 | 114 | |
111 | - if (!empty($match[1])) |
|
112 | - $engine = $match[1]; |
|
115 | + if (!empty($match[1])) { |
|
116 | + $engine = $match[1]; |
|
117 | + } |
|
113 | 118 | |
114 | - if (!empty($match[2])) |
|
115 | - $engine = $match[2]; |
|
119 | + if (!empty($match[2])) { |
|
120 | + $engine = $match[2]; |
|
121 | + } |
|
116 | 122 | |
117 | - if (!empty($match[5])) |
|
118 | - $charset = $match[5]; |
|
123 | + if (!empty($match[5])) { |
|
124 | + $charset = $match[5]; |
|
125 | + } |
|
119 | 126 | |
120 | - if (!empty($match[7])) |
|
121 | - $collate = $match[7]; |
|
127 | + if (!empty($match[7])) { |
|
128 | + $collate = $match[7]; |
|
129 | + } |
|
122 | 130 | } |
123 | 131 | |
124 | 132 | // Skip everything but keys... |
125 | - if (strpos($l, 'KEY') === false) |
|
126 | - unset($create[$k]); |
|
133 | + if (strpos($l, 'KEY') === false) { |
|
134 | + unset($create[$k]); |
|
135 | + } |
|
127 | 136 | } |
128 | 137 | |
129 | - if (!empty($create)) |
|
130 | - $create = '( |
|
138 | + if (!empty($create)) { |
|
139 | + $create = '( |
|
131 | 140 | ' . implode(' |
132 | 141 | ', $create) . ')'; |
133 | - else |
|
134 | - $create = ''; |
|
142 | + } else { |
|
143 | + $create = ''; |
|
144 | + } |
|
135 | 145 | |
136 | 146 | $request = $smcFunc['db_query']('', ' |
137 | 147 | CREATE TABLE {raw:backup_table} {raw:create} |
@@ -150,8 +160,9 @@ discard block |
||
150 | 160 | |
151 | 161 | if ($auto_inc != '') |
152 | 162 | { |
153 | - if (preg_match('~\`(.+?)\`\s~', $auto_inc, $match) != 0 && substr($auto_inc, -1, 1) == ',') |
|
154 | - $auto_inc = substr($auto_inc, 0, -1); |
|
163 | + if (preg_match('~\`(.+?)\`\s~', $auto_inc, $match) != 0 && substr($auto_inc, -1, 1) == ',') { |
|
164 | + $auto_inc = substr($auto_inc, 0, -1); |
|
165 | + } |
|
155 | 166 | |
156 | 167 | $smcFunc['db_query']('', ' |
157 | 168 | ALTER TABLE {raw:backup_table} |
@@ -195,8 +206,9 @@ discard block |
||
195 | 206 | 'table' => $table, |
196 | 207 | ) |
197 | 208 | ); |
198 | - if (!$request) |
|
199 | - return -1; |
|
209 | + if (!$request) { |
|
210 | + return -1; |
|
211 | + } |
|
200 | 212 | |
201 | 213 | // How much left? |
202 | 214 | $request = $smcFunc['db_query']('', ' |
@@ -239,8 +251,9 @@ discard block |
||
239 | 251 | ) |
240 | 252 | ); |
241 | 253 | $tables = array(); |
242 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
243 | - $tables[] = $row[0]; |
|
254 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
255 | + $tables[] = $row[0]; |
|
256 | + } |
|
244 | 257 | $smcFunc['db_free_result']($request); |
245 | 258 | |
246 | 259 | return $tables; |
@@ -284,8 +297,9 @@ discard block |
||
284 | 297 | if (!empty($row['Default']) || $row['Null'] !== 'YES') |
285 | 298 | { |
286 | 299 | // Make a special case of auto-timestamp. |
287 | - if ($row['Default'] == 'CURRENT_TIMESTAMP') |
|
288 | - $schema_create .= ' /*!40102 NOT NULL default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP */'; |
|
300 | + if ($row['Default'] == 'CURRENT_TIMESTAMP') { |
|
301 | + $schema_create .= ' /*!40102 NOT NULL default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP */'; |
|
302 | + } |
|
289 | 303 | // Text shouldn't have a default. |
290 | 304 | elseif ($row['Default'] !== null) |
291 | 305 | { |
@@ -320,14 +334,16 @@ discard block |
||
320 | 334 | $row['Key_name'] = $row['Key_name'] == 'PRIMARY' ? 'PRIMARY KEY' : (empty($row['Non_unique']) ? 'UNIQUE ' : ($row['Comment'] == 'FULLTEXT' || (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT') ? 'FULLTEXT ' : 'KEY ')) . '`' . $row['Key_name'] . '`'; |
321 | 335 | |
322 | 336 | // Is this the first column in the index? |
323 | - if (empty($indexes[$row['Key_name']])) |
|
324 | - $indexes[$row['Key_name']] = array(); |
|
337 | + if (empty($indexes[$row['Key_name']])) { |
|
338 | + $indexes[$row['Key_name']] = array(); |
|
339 | + } |
|
325 | 340 | |
326 | 341 | // A sub part, like only indexing 15 characters of a varchar. |
327 | - if (!empty($row['Sub_part'])) |
|
328 | - $indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`(' . $row['Sub_part'] . ')'; |
|
329 | - else |
|
330 | - $indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`'; |
|
342 | + if (!empty($row['Sub_part'])) { |
|
343 | + $indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`(' . $row['Sub_part'] . ')'; |
|
344 | + } else { |
|
345 | + $indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`'; |
|
346 | + } |
|
331 | 347 | } |
332 | 348 | $smcFunc['db_free_result']($result); |
333 | 349 | |
@@ -365,8 +381,9 @@ discard block |
||
365 | 381 | { |
366 | 382 | static $ver; |
367 | 383 | |
368 | - if (!empty($ver)) |
|
369 | - return $ver; |
|
384 | + if (!empty($ver)) { |
|
385 | + return $ver; |
|
386 | + } |
|
370 | 387 | |
371 | 388 | global $smcFunc; |
372 | 389 | |
@@ -391,8 +408,9 @@ discard block |
||
391 | 408 | global $smcFunc; |
392 | 409 | static $db_type; |
393 | 410 | |
394 | - if (!empty($db_type)) |
|
395 | - return $db_type; |
|
411 | + if (!empty($db_type)) { |
|
412 | + return $db_type; |
|
413 | + } |
|
396 | 414 | |
397 | 415 | $request = $smcFunc['db_query']('', 'SELECT @@version_comment'); |
398 | 416 | list ($comment) = $smcFunc['db_fetch_row']($request); |
@@ -401,13 +419,15 @@ discard block |
||
401 | 419 | // Skip these if we don't have a comment. |
402 | 420 | if (!empty($comment)) |
403 | 421 | { |
404 | - if (stripos($comment, 'percona') !== false) |
|
405 | - return 'Percona'; |
|
406 | - if (stripos($comment, 'mariadb') !== false) |
|
407 | - return 'MariaDB'; |
|
422 | + if (stripos($comment, 'percona') !== false) { |
|
423 | + return 'Percona'; |
|
424 | + } |
|
425 | + if (stripos($comment, 'mariadb') !== false) { |
|
426 | + return 'MariaDB'; |
|
427 | + } |
|
428 | + } else { |
|
429 | + return 'fail'; |
|
408 | 430 | } |
409 | - else |
|
410 | - return 'fail'; |
|
411 | 431 | |
412 | 432 | return 'MySQL'; |
413 | 433 | } |