@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Scheduled tasks management dispatcher. This function checks permissions and delegates |
@@ -41,10 +42,11 @@ discard block |
||
| 41 | 42 | ); |
| 42 | 43 | |
| 43 | 44 | // We need to find what's the action. |
| 44 | - if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) |
|
| 45 | - $context['sub_action'] = $_REQUEST['sa']; |
|
| 46 | - else |
|
| 47 | - $context['sub_action'] = 'tasks'; |
|
| 45 | + if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) { |
|
| 46 | + $context['sub_action'] = $_REQUEST['sa']; |
|
| 47 | + } else { |
|
| 48 | + $context['sub_action'] = 'tasks'; |
|
| 49 | + } |
|
| 48 | 50 | |
| 49 | 51 | // Now for the lovely tabs. That we all love. |
| 50 | 52 | $context[$context['admin_menu_name']]['tab_data'] = array( |
@@ -94,9 +96,10 @@ discard block |
||
| 94 | 96 | |
| 95 | 97 | // Enable and disable as required. |
| 96 | 98 | $enablers = array(0); |
| 97 | - foreach ($_POST['enable_task'] as $id => $enabled) |
|
| 98 | - if ($enabled) |
|
| 99 | + foreach ($_POST['enable_task'] as $id => $enabled) { |
|
| 100 | + if ($enabled) |
|
| 99 | 101 | $enablers[] = (int) $id; |
| 102 | + } |
|
| 100 | 103 | |
| 101 | 104 | // Do the update! |
| 102 | 105 | $smcFunc['db_query']('', ' |
@@ -134,8 +137,9 @@ discard block |
||
| 134 | 137 | |
| 135 | 138 | // Lets figure out which ones they want to run. |
| 136 | 139 | $tasks = array(); |
| 137 | - foreach ($_POST['run_task'] as $task => $dummy) |
|
| 138 | - $tasks[] = (int) $task; |
|
| 140 | + foreach ($_POST['run_task'] as $task => $dummy) { |
|
| 141 | + $tasks[] = (int) $task; |
|
| 142 | + } |
|
| 139 | 143 | |
| 140 | 144 | // Load up the tasks. |
| 141 | 145 | $request = $smcFunc['db_query']('', ' |
@@ -155,36 +159,41 @@ discard block |
||
| 155 | 159 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 156 | 160 | { |
| 157 | 161 | // What kind of task are we handling? |
| 158 | - if (!empty($row['callable'])) |
|
| 159 | - $task_string = $row['callable']; |
|
| 162 | + if (!empty($row['callable'])) { |
|
| 163 | + $task_string = $row['callable']; |
|
| 164 | + } |
|
| 160 | 165 | |
| 161 | 166 | // Default SMF task or old mods? |
| 162 | - elseif (function_exists('scheduled_' . $row['task'])) |
|
| 163 | - $task_string = 'scheduled_' . $row['task']; |
|
| 167 | + elseif (function_exists('scheduled_' . $row['task'])) { |
|
| 168 | + $task_string = 'scheduled_' . $row['task']; |
|
| 169 | + } |
|
| 164 | 170 | |
| 165 | 171 | // One last resource, the task name. |
| 166 | - elseif (!empty($row['task'])) |
|
| 167 | - $task_string = $row['task']; |
|
| 172 | + elseif (!empty($row['task'])) { |
|
| 173 | + $task_string = $row['task']; |
|
| 174 | + } |
|
| 168 | 175 | |
| 169 | 176 | $start_time = microtime(); |
| 170 | 177 | // The functions got to exist for us to use it. |
| 171 | - if (empty($task_string)) |
|
| 172 | - continue; |
|
| 178 | + if (empty($task_string)) { |
|
| 179 | + continue; |
|
| 180 | + } |
|
| 173 | 181 | |
| 174 | 182 | // Try to stop a timeout, this would be bad... |
| 175 | 183 | @set_time_limit(300); |
| 176 | - if (function_exists('apache_reset_timeout')) |
|
| 177 | - @apache_reset_timeout(); |
|
| 184 | + if (function_exists('apache_reset_timeout')) { |
|
| 185 | + @apache_reset_timeout(); |
|
| 186 | + } |
|
| 178 | 187 | |
| 179 | 188 | // Get the callable. |
| 180 | 189 | $callable_task = call_helper($task_string, true); |
| 181 | 190 | |
| 182 | 191 | // Perform the task. |
| 183 | - if (!empty($callable_task)) |
|
| 184 | - $completed = call_user_func($callable_task); |
|
| 185 | - |
|
| 186 | - else |
|
| 187 | - $completed = false; |
|
| 192 | + if (!empty($callable_task)) { |
|
| 193 | + $completed = call_user_func($callable_task); |
|
| 194 | + } else { |
|
| 195 | + $completed = false; |
|
| 196 | + } |
|
| 188 | 197 | |
| 189 | 198 | // Log that we did it ;) |
| 190 | 199 | if ($completed) |
@@ -201,8 +210,9 @@ discard block |
||
| 201 | 210 | $smcFunc['db_free_result']($request); |
| 202 | 211 | |
| 203 | 212 | // If we had any errors, push them to session so we can pick them up next time to tell the user. |
| 204 | - if (!empty($context['scheduled_errors'])) |
|
| 205 | - $_SESSION['st_error'] = $context['scheduled_errors']; |
|
| 213 | + if (!empty($context['scheduled_errors'])) { |
|
| 214 | + $_SESSION['st_error'] = $context['scheduled_errors']; |
|
| 215 | + } |
|
| 206 | 216 | |
| 207 | 217 | redirectexit('action=admin;area=scheduledtasks;done'); |
| 208 | 218 | } |
@@ -374,8 +384,9 @@ discard block |
||
| 374 | 384 | $context['server_time'] = timeformat(time(), false, 'server'); |
| 375 | 385 | |
| 376 | 386 | // Cleaning... |
| 377 | - if (!isset($_GET['tid'])) |
|
| 378 | - fatal_lang_error('no_access', false); |
|
| 387 | + if (!isset($_GET['tid'])) { |
|
| 388 | + fatal_lang_error('no_access', false); |
|
| 389 | + } |
|
| 379 | 390 | $_GET['tid'] = (int) $_GET['tid']; |
| 380 | 391 | |
| 381 | 392 | // Saving? |
@@ -391,10 +402,12 @@ discard block |
||
| 391 | 402 | preg_match('~(\d{1,2}):(\d{1,2})~', $_POST['offset'], $matches); |
| 392 | 403 | |
| 393 | 404 | // If a half is empty then assume zero offset! |
| 394 | - if (!isset($matches[2]) || $matches[2] > 59) |
|
| 395 | - $matches[2] = 0; |
|
| 396 | - if (!isset($matches[1]) || $matches[1] > 23) |
|
| 397 | - $matches[1] = 0; |
|
| 405 | + if (!isset($matches[2]) || $matches[2] > 59) { |
|
| 406 | + $matches[2] = 0; |
|
| 407 | + } |
|
| 408 | + if (!isset($matches[1]) || $matches[1] > 23) { |
|
| 409 | + $matches[1] = 0; |
|
| 410 | + } |
|
| 398 | 411 | |
| 399 | 412 | // Now the offset is easy; easy peasy - except we need to offset by a few hours... |
| 400 | 413 | $offset = $matches[1] * 3600 + $matches[2] * 60 - date('Z'); |
@@ -404,8 +417,9 @@ discard block |
||
| 404 | 417 | $unit = in_array(substr($_POST['unit'], 0, 1), array('m', 'h', 'd', 'w')) ? substr($_POST['unit'], 0, 1) : 'd'; |
| 405 | 418 | |
| 406 | 419 | // Don't allow one minute intervals. |
| 407 | - if ($interval == 1 && $unit == 'm') |
|
| 408 | - $interval = 2; |
|
| 420 | + if ($interval == 1 && $unit == 'm') { |
|
| 421 | + $interval = 2; |
|
| 422 | + } |
|
| 409 | 423 | |
| 410 | 424 | // Is it disabled? |
| 411 | 425 | $disabled = !isset($_POST['enabled']) ? 1 : 0; |
@@ -443,8 +457,9 @@ discard block |
||
| 443 | 457 | ); |
| 444 | 458 | |
| 445 | 459 | // Should never, ever, happen! |
| 446 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 447 | - fatal_lang_error('no_access', false); |
|
| 460 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 461 | + fatal_lang_error('no_access', false); |
|
| 462 | + } |
|
| 448 | 463 | |
| 449 | 464 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 450 | 465 | { |
@@ -602,13 +617,14 @@ discard block |
||
| 602 | 617 | ) |
| 603 | 618 | ); |
| 604 | 619 | $log_entries = array(); |
| 605 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 606 | - $log_entries[] = array( |
|
| 620 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 621 | + $log_entries[] = array( |
|
| 607 | 622 | 'id' => $row['id_log'], |
| 608 | 623 | 'name' => isset($txt['scheduled_task_' . $row['task']]) ? $txt['scheduled_task_' . $row['task']] : $row['task'], |
| 609 | 624 | 'time_run' => $row['time_run'], |
| 610 | 625 | 'time_taken' => $row['time_taken'], |
| 611 | 626 | ); |
| 627 | + } |
|
| 612 | 628 | $smcFunc['db_free_result']($request); |
| 613 | 629 | |
| 614 | 630 | return $log_entries; |
@@ -649,8 +665,9 @@ discard block |
||
| 649 | 665 | |
| 650 | 666 | call_integration_hook('integrate_scheduled_tasks_settings', array(&$config_vars)); |
| 651 | 667 | |
| 652 | - if ($return_config) |
|
| 653 | - return $config_vars; |
|
| 668 | + if ($return_config) { |
|
| 669 | + return $config_vars; |
|
| 670 | + } |
|
| 654 | 671 | |
| 655 | 672 | // Set up the template. |
| 656 | 673 | $context['page_title'] = $txt['scheduled_tasks_settings']; |
@@ -15,8 +15,9 @@ discard block |
||
| 15 | 15 | * @version 2.1 Beta 4 |
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | -if (!defined('SMF')) |
|
| 18 | +if (!defined('SMF')) { |
|
| 19 | 19 | die('No direct access...'); |
| 20 | +} |
|
| 20 | 21 | |
| 21 | 22 | /** |
| 22 | 23 | * Begin the registration process. |
@@ -29,19 +30,23 @@ discard block |
||
| 29 | 30 | global $language, $scripturl, $smcFunc, $sourcedir, $cur_profile; |
| 30 | 31 | |
| 31 | 32 | // Is this an incoming AJAX check? |
| 32 | - if (isset($_GET['sa']) && $_GET['sa'] == 'usernamecheck') |
|
| 33 | - return RegisterCheckUsername(); |
|
| 33 | + if (isset($_GET['sa']) && $_GET['sa'] == 'usernamecheck') { |
|
| 34 | + return RegisterCheckUsername(); |
|
| 35 | + } |
|
| 34 | 36 | |
| 35 | 37 | // Check if the administrator has it disabled. |
| 36 | - if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == '3') |
|
| 37 | - fatal_lang_error('registration_disabled', false); |
|
| 38 | + if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == '3') { |
|
| 39 | + fatal_lang_error('registration_disabled', false); |
|
| 40 | + } |
|
| 38 | 41 | |
| 39 | 42 | // If this user is an admin - redirect them to the admin registration page. |
| 40 | - if (allowedTo('moderate_forum') && !$user_info['is_guest']) |
|
| 41 | - redirectexit('action=admin;area=regcenter;sa=register'); |
|
| 43 | + if (allowedTo('moderate_forum') && !$user_info['is_guest']) { |
|
| 44 | + redirectexit('action=admin;area=regcenter;sa=register'); |
|
| 45 | + } |
|
| 42 | 46 | // You are not a guest, so you are a member - and members don't get to register twice! |
| 43 | - elseif (empty($user_info['is_guest'])) |
|
| 44 | - redirectexit(); |
|
| 47 | + elseif (empty($user_info['is_guest'])) { |
|
| 48 | + redirectexit(); |
|
| 49 | + } |
|
| 45 | 50 | |
| 46 | 51 | loadLanguage('Login'); |
| 47 | 52 | loadTemplate('Register'); |
@@ -82,16 +87,18 @@ discard block |
||
| 82 | 87 | } |
| 83 | 88 | } |
| 84 | 89 | // Make sure they don't squeeze through without agreeing. |
| 85 | - elseif ($current_step > 1 && $context['require_agreement'] && !$context['registration_passed_agreement']) |
|
| 86 | - $current_step = 1; |
|
| 90 | + elseif ($current_step > 1 && $context['require_agreement'] && !$context['registration_passed_agreement']) { |
|
| 91 | + $current_step = 1; |
|
| 92 | + } |
|
| 87 | 93 | |
| 88 | 94 | // Show the user the right form. |
| 89 | 95 | $context['sub_template'] = $current_step == 1 ? 'registration_agreement' : 'registration_form'; |
| 90 | 96 | $context['page_title'] = $current_step == 1 ? $txt['registration_agreement'] : $txt['registration_form']; |
| 91 | 97 | |
| 92 | 98 | // Kinda need this. |
| 93 | - if ($context['sub_template'] == 'registration_form') |
|
| 94 | - loadJavaScriptFile('register.js', array('defer' => false, 'minimize' => true), 'smf_register'); |
|
| 99 | + if ($context['sub_template'] == 'registration_form') { |
|
| 100 | + loadJavaScriptFile('register.js', array('defer' => false, 'minimize' => true), 'smf_register'); |
|
| 101 | + } |
|
| 95 | 102 | |
| 96 | 103 | // Add the register chain to the link tree. |
| 97 | 104 | $context['linktree'][] = array( |
@@ -100,24 +107,26 @@ discard block |
||
| 100 | 107 | ); |
| 101 | 108 | |
| 102 | 109 | // Prepare the time gate! Do it like so, in case later steps want to reset the limit for any reason, but make sure the time is the current one. |
| 103 | - if (!isset($_SESSION['register'])) |
|
| 104 | - $_SESSION['register'] = array( |
|
| 110 | + if (!isset($_SESSION['register'])) { |
|
| 111 | + $_SESSION['register'] = array( |
|
| 105 | 112 | 'timenow' => time(), |
| 106 | 113 | 'limit' => 10, // minimum number of seconds required on this page for registration |
| 107 | 114 | ); |
| 108 | - else |
|
| 109 | - $_SESSION['register']['timenow'] = time(); |
|
| 115 | + } else { |
|
| 116 | + $_SESSION['register']['timenow'] = time(); |
|
| 117 | + } |
|
| 110 | 118 | |
| 111 | 119 | // If you have to agree to the agreement, it needs to be fetched from the file. |
| 112 | 120 | if ($context['require_agreement']) |
| 113 | 121 | { |
| 114 | 122 | // Have we got a localized one? |
| 115 | - if (file_exists($boarddir . '/agreement.' . $user_info['language'] . '.txt')) |
|
| 116 | - $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.' . $user_info['language'] . '.txt'), true, 'agreement_' . $user_info['language']); |
|
| 117 | - elseif (file_exists($boarddir . '/agreement.txt')) |
|
| 118 | - $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.txt'), true, 'agreement'); |
|
| 119 | - else |
|
| 120 | - $context['agreement'] = ''; |
|
| 123 | + if (file_exists($boarddir . '/agreement.' . $user_info['language'] . '.txt')) { |
|
| 124 | + $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.' . $user_info['language'] . '.txt'), true, 'agreement_' . $user_info['language']); |
|
| 125 | + } elseif (file_exists($boarddir . '/agreement.txt')) { |
|
| 126 | + $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.txt'), true, 'agreement'); |
|
| 127 | + } else { |
|
| 128 | + $context['agreement'] = ''; |
|
| 129 | + } |
|
| 121 | 130 | |
| 122 | 131 | // Nothing to show, lets disable registration and inform the admin of this error |
| 123 | 132 | if (empty($context['agreement'])) |
@@ -133,8 +142,9 @@ discard block |
||
| 133 | 142 | $selectedLanguage = empty($_SESSION['language']) ? $language : $_SESSION['language']; |
| 134 | 143 | |
| 135 | 144 | // Do we have any languages? |
| 136 | - if (empty($context['languages'])) |
|
| 137 | - getLanguages(); |
|
| 145 | + if (empty($context['languages'])) { |
|
| 146 | + getLanguages(); |
|
| 147 | + } |
|
| 138 | 148 | |
| 139 | 149 | // Try to find our selected language. |
| 140 | 150 | foreach ($context['languages'] as $key => $lang) |
@@ -142,8 +152,9 @@ discard block |
||
| 142 | 152 | $context['languages'][$key]['name'] = strtr($lang['name'], array('-utf8' => '')); |
| 143 | 153 | |
| 144 | 154 | // Found it! |
| 145 | - if ($selectedLanguage == $lang['filename']) |
|
| 146 | - $context['languages'][$key]['selected'] = true; |
|
| 155 | + if ($selectedLanguage == $lang['filename']) { |
|
| 156 | + $context['languages'][$key]['selected'] = true; |
|
| 157 | + } |
|
| 147 | 158 | } |
| 148 | 159 | } |
| 149 | 160 | |
@@ -170,16 +181,19 @@ discard block |
||
| 170 | 181 | if (in_array('website', $reg_fields)) |
| 171 | 182 | { |
| 172 | 183 | unset($reg_fields['website']); |
| 173 | - if (isset($_POST['website_title'])) |
|
| 174 | - $cur_profile['website_title'] = $smcFunc['htmlspecialchars']($_POST['website_title']); |
|
| 175 | - if (isset($_POST['website_url'])) |
|
| 176 | - $cur_profile['website_url'] = $smcFunc['htmlspecialchars']($_POST['website_url']); |
|
| 184 | + if (isset($_POST['website_title'])) { |
|
| 185 | + $cur_profile['website_title'] = $smcFunc['htmlspecialchars']($_POST['website_title']); |
|
| 186 | + } |
|
| 187 | + if (isset($_POST['website_url'])) { |
|
| 188 | + $cur_profile['website_url'] = $smcFunc['htmlspecialchars']($_POST['website_url']); |
|
| 189 | + } |
|
| 177 | 190 | } |
| 178 | 191 | |
| 179 | 192 | // We might have had some submissions on this front - go check. |
| 180 | - foreach ($reg_fields as $field) |
|
| 181 | - if (isset($_POST[$field])) |
|
| 193 | + foreach ($reg_fields as $field) { |
|
| 194 | + if (isset($_POST[$field])) |
|
| 182 | 195 | $cur_profile[$field] = $smcFunc['htmlspecialchars']($_POST[$field]); |
| 196 | + } |
|
| 183 | 197 | |
| 184 | 198 | // Load all the fields in question. |
| 185 | 199 | setupProfileContext($reg_fields); |
@@ -196,8 +210,9 @@ discard block |
||
| 196 | 210 | $context['visual_verification_id'] = $verificationOptions['id']; |
| 197 | 211 | } |
| 198 | 212 | // Otherwise we have nothing to show. |
| 199 | - else |
|
| 200 | - $context['visual_verification'] = false; |
|
| 213 | + else { |
|
| 214 | + $context['visual_verification'] = false; |
|
| 215 | + } |
|
| 201 | 216 | |
| 202 | 217 | |
| 203 | 218 | $context += array( |
@@ -208,8 +223,9 @@ discard block |
||
| 208 | 223 | |
| 209 | 224 | // Were there any errors? |
| 210 | 225 | $context['registration_errors'] = array(); |
| 211 | - if (!empty($reg_errors)) |
|
| 212 | - $context['registration_errors'] = $reg_errors; |
|
| 226 | + if (!empty($reg_errors)) { |
|
| 227 | + $context['registration_errors'] = $reg_errors; |
|
| 228 | + } |
|
| 213 | 229 | |
| 214 | 230 | createToken('register'); |
| 215 | 231 | } |
@@ -226,27 +242,32 @@ discard block |
||
| 226 | 242 | validateToken('register'); |
| 227 | 243 | |
| 228 | 244 | // Check to ensure we're forcing SSL for authentication |
| 229 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) |
|
| 230 | - fatal_lang_error('register_ssl_required'); |
|
| 245 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) { |
|
| 246 | + fatal_lang_error('register_ssl_required'); |
|
| 247 | + } |
|
| 231 | 248 | |
| 232 | 249 | // Start collecting together any errors. |
| 233 | 250 | $reg_errors = array(); |
| 234 | 251 | |
| 235 | 252 | // You can't register if it's disabled. |
| 236 | - if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 3) |
|
| 237 | - fatal_lang_error('registration_disabled', false); |
|
| 253 | + if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 3) { |
|
| 254 | + fatal_lang_error('registration_disabled', false); |
|
| 255 | + } |
|
| 238 | 256 | |
| 239 | 257 | // Well, if you don't agree, you can't register. |
| 240 | - if (!empty($modSettings['requireAgreement']) && empty($_SESSION['registration_agreed'])) |
|
| 241 | - redirectexit(); |
|
| 258 | + if (!empty($modSettings['requireAgreement']) && empty($_SESSION['registration_agreed'])) { |
|
| 259 | + redirectexit(); |
|
| 260 | + } |
|
| 242 | 261 | |
| 243 | 262 | // Make sure they came from *somewhere*, have a session. |
| 244 | - if (!isset($_SESSION['old_url'])) |
|
| 245 | - redirectexit('action=signup'); |
|
| 263 | + if (!isset($_SESSION['old_url'])) { |
|
| 264 | + redirectexit('action=signup'); |
|
| 265 | + } |
|
| 246 | 266 | |
| 247 | 267 | // If we don't require an agreement, we need a extra check for coppa. |
| 248 | - if (empty($modSettings['requireAgreement']) && !empty($modSettings['coppaAge'])) |
|
| 249 | - $_SESSION['skip_coppa'] = !empty($_POST['accept_agreement']); |
|
| 268 | + if (empty($modSettings['requireAgreement']) && !empty($modSettings['coppaAge'])) { |
|
| 269 | + $_SESSION['skip_coppa'] = !empty($_POST['accept_agreement']); |
|
| 270 | + } |
|
| 250 | 271 | // Are they under age, and under age users are banned? |
| 251 | 272 | if (!empty($modSettings['coppaAge']) && empty($modSettings['coppaType']) && empty($_SESSION['skip_coppa'])) |
| 252 | 273 | { |
@@ -255,8 +276,9 @@ discard block |
||
| 255 | 276 | } |
| 256 | 277 | |
| 257 | 278 | // Check the time gate for miscreants. First make sure they came from somewhere that actually set it up. |
| 258 | - if (empty($_SESSION['register']['timenow']) || empty($_SESSION['register']['limit'])) |
|
| 259 | - redirectexit('action=signup'); |
|
| 279 | + if (empty($_SESSION['register']['timenow']) || empty($_SESSION['register']['limit'])) { |
|
| 280 | + redirectexit('action=signup'); |
|
| 281 | + } |
|
| 260 | 282 | // Failing that, check the time on it. |
| 261 | 283 | if (time() - $_SESSION['register']['timenow'] < $_SESSION['register']['limit']) |
| 262 | 284 | { |
@@ -276,8 +298,9 @@ discard block |
||
| 276 | 298 | if (is_array($context['visual_verification'])) |
| 277 | 299 | { |
| 278 | 300 | loadLanguage('Errors'); |
| 279 | - foreach ($context['visual_verification'] as $error) |
|
| 280 | - $reg_errors[] = $txt['error_' . $error]; |
|
| 301 | + foreach ($context['visual_verification'] as $error) { |
|
| 302 | + $reg_errors[] = $txt['error_' . $error]; |
|
| 303 | + } |
|
| 281 | 304 | } |
| 282 | 305 | } |
| 283 | 306 | |
@@ -286,14 +309,16 @@ discard block |
||
| 286 | 309 | if (!is_array($_POST[$key])) |
| 287 | 310 | { |
| 288 | 311 | // For UTF-8, replace any kind of space with a normal space, and remove any kind of control character (incl. "\n" and "\r"), then trim. |
| 289 | - if ($context['utf8']) |
|
| 290 | - $_POST[$key] = $smcFunc['htmltrim'](preg_replace(array('~\p{Z}+~u', '~\p{C}+~u'), array(' ', ''), $_POST[$key])); |
|
| 312 | + if ($context['utf8']) { |
|
| 313 | + $_POST[$key] = $smcFunc['htmltrim'](preg_replace(array('~\p{Z}+~u', '~\p{C}+~u'), array(' ', ''), $_POST[$key])); |
|
| 314 | + } |
|
| 291 | 315 | // Otherwise, just remove "\n" and "\r", then trim. |
| 292 | - else |
|
| 293 | - $_POST[$key] = $smcFunc['htmltrim'](str_replace(array("\n", "\r"), '', $_POST[$key])); |
|
| 316 | + else { |
|
| 317 | + $_POST[$key] = $smcFunc['htmltrim'](str_replace(array("\n", "\r"), '', $_POST[$key])); |
|
| 318 | + } |
|
| 319 | + } else { |
|
| 320 | + $_POST[$key] = htmltrim__recursive($_POST[$key]); |
|
| 294 | 321 | } |
| 295 | - else |
|
| 296 | - $_POST[$key] = htmltrim__recursive($_POST[$key]); |
|
| 297 | 322 | } |
| 298 | 323 | |
| 299 | 324 | // Collect all extra registration fields someone might have filled in. |
@@ -328,13 +353,15 @@ discard block |
||
| 328 | 353 | $possible_strings = array_merge(array('website_url', 'website_title'), $possible_strings); |
| 329 | 354 | |
| 330 | 355 | // Make sure their website URL is squeaky clean |
| 331 | - if (isset($_POST['website_url'])) |
|
| 332 | - $_POST['website_url'] = (string) validate_iri(sanitize_iri($_POST['website_url'])); |
|
| 356 | + if (isset($_POST['website_url'])) { |
|
| 357 | + $_POST['website_url'] = (string) validate_iri(sanitize_iri($_POST['website_url'])); |
|
| 358 | + } |
|
| 333 | 359 | } |
| 334 | 360 | } |
| 335 | 361 | |
| 336 | - if (isset($_POST['secret_answer']) && $_POST['secret_answer'] != '') |
|
| 337 | - $_POST['secret_answer'] = md5($_POST['secret_answer']); |
|
| 362 | + if (isset($_POST['secret_answer']) && $_POST['secret_answer'] != '') { |
|
| 363 | + $_POST['secret_answer'] = md5($_POST['secret_answer']); |
|
| 364 | + } |
|
| 338 | 365 | |
| 339 | 366 | // Needed for isReservedName() and registerMember(). |
| 340 | 367 | require_once($sourcedir . '/Subs-Members.php'); |
@@ -343,8 +370,9 @@ discard block |
||
| 343 | 370 | if (isset($_POST['real_name'])) |
| 344 | 371 | { |
| 345 | 372 | // Are you already allowed to edit the displayed name? |
| 346 | - if (allowedTo('profile_displayed_name') || allowedTo('moderate_forum')) |
|
| 347 | - $canEditDisplayName = true; |
|
| 373 | + if (allowedTo('profile_displayed_name') || allowedTo('moderate_forum')) { |
|
| 374 | + $canEditDisplayName = true; |
|
| 375 | + } |
|
| 348 | 376 | |
| 349 | 377 | // If you are a guest, will you be allowed to once you register? |
| 350 | 378 | else |
@@ -363,32 +391,37 @@ discard block |
||
| 363 | 391 | } |
| 364 | 392 | |
| 365 | 393 | // Only set it if you can and if we are sure it is good |
| 366 | - if ($canEditDisplayName && $smcFunc['htmltrim']($_POST['real_name']) != '' && !isReservedName($_POST['real_name']) && $smcFunc['strlen']($_POST['real_name']) < 60) |
|
| 367 | - $possible_strings[] = 'real_name'; |
|
| 394 | + if ($canEditDisplayName && $smcFunc['htmltrim']($_POST['real_name']) != '' && !isReservedName($_POST['real_name']) && $smcFunc['strlen']($_POST['real_name']) < 60) { |
|
| 395 | + $possible_strings[] = 'real_name'; |
|
| 396 | + } |
|
| 368 | 397 | } |
| 369 | 398 | |
| 370 | 399 | // Handle a string as a birthdate... |
| 371 | - if (isset($_POST['birthdate']) && $_POST['birthdate'] != '') |
|
| 372 | - $_POST['birthdate'] = strftime('%Y-%m-%d', strtotime($_POST['birthdate'])); |
|
| 400 | + if (isset($_POST['birthdate']) && $_POST['birthdate'] != '') { |
|
| 401 | + $_POST['birthdate'] = strftime('%Y-%m-%d', strtotime($_POST['birthdate'])); |
|
| 402 | + } |
|
| 373 | 403 | // Or birthdate parts... |
| 374 | - elseif (!empty($_POST['bday1']) && !empty($_POST['bday2'])) |
|
| 375 | - $_POST['birthdate'] = sprintf('%04d-%02d-%02d', empty($_POST['bday3']) ? 0 : (int) $_POST['bday3'], (int) $_POST['bday1'], (int) $_POST['bday2']); |
|
| 404 | + elseif (!empty($_POST['bday1']) && !empty($_POST['bday2'])) { |
|
| 405 | + $_POST['birthdate'] = sprintf('%04d-%02d-%02d', empty($_POST['bday3']) ? 0 : (int) $_POST['bday3'], (int) $_POST['bday1'], (int) $_POST['bday2']); |
|
| 406 | + } |
|
| 376 | 407 | |
| 377 | 408 | // Validate the passed language file. |
| 378 | 409 | if (isset($_POST['lngfile']) && !empty($modSettings['userLanguage'])) |
| 379 | 410 | { |
| 380 | 411 | // Do we have any languages? |
| 381 | - if (empty($context['languages'])) |
|
| 382 | - getLanguages(); |
|
| 412 | + if (empty($context['languages'])) { |
|
| 413 | + getLanguages(); |
|
| 414 | + } |
|
| 383 | 415 | |
| 384 | 416 | // Did we find it? |
| 385 | - if (isset($context['languages'][$_POST['lngfile']])) |
|
| 386 | - $_SESSION['language'] = $_POST['lngfile']; |
|
| 387 | - else |
|
| 417 | + if (isset($context['languages'][$_POST['lngfile']])) { |
|
| 418 | + $_SESSION['language'] = $_POST['lngfile']; |
|
| 419 | + } else { |
|
| 420 | + unset($_POST['lngfile']); |
|
| 421 | + } |
|
| 422 | + } else { |
|
| 388 | 423 | unset($_POST['lngfile']); |
| 389 | 424 | } |
| 390 | - else |
|
| 391 | - unset($_POST['lngfile']); |
|
| 392 | 425 | |
| 393 | 426 | // Set the options needed for registration. |
| 394 | 427 | $regOptions = array( |
@@ -408,22 +441,27 @@ discard block |
||
| 408 | 441 | ); |
| 409 | 442 | |
| 410 | 443 | // Include the additional options that might have been filled in. |
| 411 | - foreach ($possible_strings as $var) |
|
| 412 | - if (isset($_POST[$var])) |
|
| 444 | + foreach ($possible_strings as $var) { |
|
| 445 | + if (isset($_POST[$var])) |
|
| 413 | 446 | $regOptions['extra_register_vars'][$var] = $smcFunc['htmlspecialchars']($_POST[$var], ENT_QUOTES); |
| 414 | - foreach ($possible_ints as $var) |
|
| 415 | - if (isset($_POST[$var])) |
|
| 447 | + } |
|
| 448 | + foreach ($possible_ints as $var) { |
|
| 449 | + if (isset($_POST[$var])) |
|
| 416 | 450 | $regOptions['extra_register_vars'][$var] = (int) $_POST[$var]; |
| 417 | - foreach ($possible_floats as $var) |
|
| 418 | - if (isset($_POST[$var])) |
|
| 451 | + } |
|
| 452 | + foreach ($possible_floats as $var) { |
|
| 453 | + if (isset($_POST[$var])) |
|
| 419 | 454 | $regOptions['extra_register_vars'][$var] = (float) $_POST[$var]; |
| 420 | - foreach ($possible_bools as $var) |
|
| 421 | - if (isset($_POST[$var])) |
|
| 455 | + } |
|
| 456 | + foreach ($possible_bools as $var) { |
|
| 457 | + if (isset($_POST[$var])) |
|
| 422 | 458 | $regOptions['extra_register_vars'][$var] = empty($_POST[$var]) ? 0 : 1; |
| 459 | + } |
|
| 423 | 460 | |
| 424 | 461 | // Registration options are always default options... |
| 425 | - if (isset($_POST['default_options'])) |
|
| 426 | - $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; |
|
| 462 | + if (isset($_POST['default_options'])) { |
|
| 463 | + $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; |
|
| 464 | + } |
|
| 427 | 465 | $regOptions['theme_vars'] = isset($_POST['options']) && is_array($_POST['options']) ? $_POST['options'] : array(); |
| 428 | 466 | |
| 429 | 467 | // Make sure they are clean, dammit! |
@@ -443,12 +481,14 @@ discard block |
||
| 443 | 481 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 444 | 482 | { |
| 445 | 483 | // Don't allow overriding of the theme variables. |
| 446 | - if (isset($regOptions['theme_vars'][$row['col_name']])) |
|
| 447 | - unset($regOptions['theme_vars'][$row['col_name']]); |
|
| 484 | + if (isset($regOptions['theme_vars'][$row['col_name']])) { |
|
| 485 | + unset($regOptions['theme_vars'][$row['col_name']]); |
|
| 486 | + } |
|
| 448 | 487 | |
| 449 | 488 | // Not actually showing it then? |
| 450 | - if (!$row['show_reg']) |
|
| 451 | - continue; |
|
| 489 | + if (!$row['show_reg']) { |
|
| 490 | + continue; |
|
| 491 | + } |
|
| 452 | 492 | |
| 453 | 493 | // Prepare the value! |
| 454 | 494 | $value = isset($_POST['customfield'][$row['col_name']]) ? trim($_POST['customfield'][$row['col_name']]) : ''; |
@@ -457,24 +497,27 @@ discard block |
||
| 457 | 497 | if (!in_array($row['field_type'], array('check', 'select', 'radio'))) |
| 458 | 498 | { |
| 459 | 499 | // Is it too long? |
| 460 | - if ($row['field_length'] && $row['field_length'] < $smcFunc['strlen']($value)) |
|
| 461 | - $custom_field_errors[] = array('custom_field_too_long', array($row['field_name'], $row['field_length'])); |
|
| 500 | + if ($row['field_length'] && $row['field_length'] < $smcFunc['strlen']($value)) { |
|
| 501 | + $custom_field_errors[] = array('custom_field_too_long', array($row['field_name'], $row['field_length'])); |
|
| 502 | + } |
|
| 462 | 503 | |
| 463 | 504 | // Any masks to apply? |
| 464 | 505 | if ($row['field_type'] == 'text' && !empty($row['mask']) && $row['mask'] != 'none') |
| 465 | 506 | { |
| 466 | - if ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255)) |
|
| 467 | - $custom_field_errors[] = array('custom_field_invalid_email', array($row['field_name'])); |
|
| 468 | - elseif ($row['mask'] == 'number' && preg_match('~[^\d]~', $value)) |
|
| 469 | - $custom_field_errors[] = array('custom_field_not_number', array($row['field_name'])); |
|
| 470 | - elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) |
|
| 471 | - $custom_field_errors[] = array('custom_field_inproper_format', array($row['field_name'])); |
|
| 507 | + if ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255)) { |
|
| 508 | + $custom_field_errors[] = array('custom_field_invalid_email', array($row['field_name'])); |
|
| 509 | + } elseif ($row['mask'] == 'number' && preg_match('~[^\d]~', $value)) { |
|
| 510 | + $custom_field_errors[] = array('custom_field_not_number', array($row['field_name'])); |
|
| 511 | + } elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) { |
|
| 512 | + $custom_field_errors[] = array('custom_field_inproper_format', array($row['field_name'])); |
|
| 513 | + } |
|
| 472 | 514 | } |
| 473 | 515 | } |
| 474 | 516 | |
| 475 | 517 | // Is this required but not there? |
| 476 | - if (trim($value) == '' && $row['show_reg'] > 1) |
|
| 477 | - $custom_field_errors[] = array('custom_field_empty', array($row['field_name'])); |
|
| 518 | + if (trim($value) == '' && $row['show_reg'] > 1) { |
|
| 519 | + $custom_field_errors[] = array('custom_field_empty', array($row['field_name'])); |
|
| 520 | + } |
|
| 478 | 521 | } |
| 479 | 522 | $smcFunc['db_free_result']($request); |
| 480 | 523 | |
@@ -482,8 +525,9 @@ discard block |
||
| 482 | 525 | if (!empty($custom_field_errors)) |
| 483 | 526 | { |
| 484 | 527 | loadLanguage('Errors'); |
| 485 | - foreach ($custom_field_errors as $error) |
|
| 486 | - $reg_errors[] = vsprintf($txt['error_' . $error[0]], $error[1]); |
|
| 528 | + foreach ($custom_field_errors as $error) { |
|
| 529 | + $reg_errors[] = vsprintf($txt['error_' . $error[0]], $error[1]); |
|
| 530 | + } |
|
| 487 | 531 | } |
| 488 | 532 | |
| 489 | 533 | // Lets check for other errors before trying to register the member. |
@@ -528,8 +572,9 @@ discard block |
||
| 528 | 572 | } |
| 529 | 573 | |
| 530 | 574 | // If COPPA has been selected then things get complicated, setup the template. |
| 531 | - if (!empty($modSettings['coppaAge']) && empty($_SESSION['skip_coppa'])) |
|
| 532 | - redirectexit('action=coppa;member=' . $memberID); |
|
| 575 | + if (!empty($modSettings['coppaAge']) && empty($_SESSION['skip_coppa'])) { |
|
| 576 | + redirectexit('action=coppa;member=' . $memberID); |
|
| 577 | + } |
|
| 533 | 578 | // Basic template variable setup. |
| 534 | 579 | elseif (!empty($modSettings['registration_method'])) |
| 535 | 580 | { |
@@ -541,8 +586,7 @@ discard block |
||
| 541 | 586 | 'sub_template' => 'after', |
| 542 | 587 | 'description' => $modSettings['registration_method'] == 2 ? $txt['approval_after_registration'] : $txt['activate_after_registration'] |
| 543 | 588 | ); |
| 544 | - } |
|
| 545 | - else |
|
| 589 | + } else |
|
| 546 | 590 | { |
| 547 | 591 | call_integration_hook('integrate_activate', array($regOptions['username'])); |
| 548 | 592 | |
@@ -562,16 +606,18 @@ discard block |
||
| 562 | 606 | global $context, $txt, $modSettings, $scripturl, $sourcedir, $smcFunc, $language, $user_info; |
| 563 | 607 | |
| 564 | 608 | // Logged in users should not bother to activate their accounts |
| 565 | - if (!empty($user_info['id'])) |
|
| 566 | - redirectexit(); |
|
| 609 | + if (!empty($user_info['id'])) { |
|
| 610 | + redirectexit(); |
|
| 611 | + } |
|
| 567 | 612 | |
| 568 | 613 | loadLanguage('Login'); |
| 569 | 614 | loadTemplate('Login'); |
| 570 | 615 | |
| 571 | 616 | if (empty($_REQUEST['u']) && empty($_POST['user'])) |
| 572 | 617 | { |
| 573 | - if (empty($modSettings['registration_method']) || $modSettings['registration_method'] == '3') |
|
| 574 | - fatal_lang_error('no_access', false); |
|
| 618 | + if (empty($modSettings['registration_method']) || $modSettings['registration_method'] == '3') { |
|
| 619 | + fatal_lang_error('no_access', false); |
|
| 620 | + } |
|
| 575 | 621 | |
| 576 | 622 | $context['member_id'] = 0; |
| 577 | 623 | $context['sub_template'] = 'resend'; |
@@ -611,11 +657,13 @@ discard block |
||
| 611 | 657 | // Change their email address? (they probably tried a fake one first :P.) |
| 612 | 658 | if (isset($_POST['new_email'], $_REQUEST['passwd']) && hash_password($row['member_name'], $_REQUEST['passwd']) == $row['passwd'] && ($row['is_activated'] == 0 || $row['is_activated'] == 2)) |
| 613 | 659 | { |
| 614 | - if (empty($modSettings['registration_method']) || $modSettings['registration_method'] == 3) |
|
| 615 | - fatal_lang_error('no_access', false); |
|
| 660 | + if (empty($modSettings['registration_method']) || $modSettings['registration_method'] == 3) { |
|
| 661 | + fatal_lang_error('no_access', false); |
|
| 662 | + } |
|
| 616 | 663 | |
| 617 | - if (!filter_var($_POST['new_email'], FILTER_VALIDATE_EMAIL)) |
|
| 618 | - fatal_error(sprintf($txt['valid_email_needed'], $smcFunc['htmlspecialchars']($_POST['new_email'])), false); |
|
| 664 | + if (!filter_var($_POST['new_email'], FILTER_VALIDATE_EMAIL)) { |
|
| 665 | + fatal_error(sprintf($txt['valid_email_needed'], $smcFunc['htmlspecialchars']($_POST['new_email'])), false); |
|
| 666 | + } |
|
| 619 | 667 | |
| 620 | 668 | // Make sure their email isn't banned. |
| 621 | 669 | isBannedEmail($_POST['new_email'], 'cannot_register', $txt['ban_register_prohibited']); |
@@ -631,8 +679,9 @@ discard block |
||
| 631 | 679 | ) |
| 632 | 680 | ); |
| 633 | 681 | |
| 634 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 635 | - fatal_lang_error('email_in_use', false, array($smcFunc['htmlspecialchars']($_POST['new_email']))); |
|
| 682 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 683 | + fatal_lang_error('email_in_use', false, array($smcFunc['htmlspecialchars']($_POST['new_email']))); |
|
| 684 | + } |
|
| 636 | 685 | $smcFunc['db_free_result']($request); |
| 637 | 686 | |
| 638 | 687 | updateMemberData($row['id_member'], array('email_address' => $_POST['new_email'])); |
@@ -670,9 +719,9 @@ discard block |
||
| 670 | 719 | // Quit if this code is not right. |
| 671 | 720 | if (empty($_REQUEST['code']) || $row['validation_code'] != $_REQUEST['code']) |
| 672 | 721 | { |
| 673 | - if (!empty($row['is_activated'])) |
|
| 674 | - fatal_lang_error('already_activated', false); |
|
| 675 | - elseif ($row['validation_code'] == '') |
|
| 722 | + if (!empty($row['is_activated'])) { |
|
| 723 | + fatal_lang_error('already_activated', false); |
|
| 724 | + } elseif ($row['validation_code'] == '') |
|
| 676 | 725 | { |
| 677 | 726 | loadLanguage('Profile'); |
| 678 | 727 | fatal_error(sprintf($txt['registration_not_approved'], $scripturl . '?action=activate;user=' . $row['member_name']), false); |
@@ -722,8 +771,9 @@ discard block |
||
| 722 | 771 | loadTemplate('Register'); |
| 723 | 772 | |
| 724 | 773 | // No User ID?? |
| 725 | - if (!isset($_GET['member'])) |
|
| 726 | - fatal_lang_error('no_access', false); |
|
| 774 | + if (!isset($_GET['member'])) { |
|
| 775 | + fatal_lang_error('no_access', false); |
|
| 776 | + } |
|
| 727 | 777 | |
| 728 | 778 | // Get the user details... |
| 729 | 779 | $request = $smcFunc['db_query']('', ' |
@@ -736,8 +786,9 @@ discard block |
||
| 736 | 786 | 'is_coppa' => 5, |
| 737 | 787 | ) |
| 738 | 788 | ); |
| 739 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 740 | - fatal_lang_error('no_access', false); |
|
| 789 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 790 | + fatal_lang_error('no_access', false); |
|
| 791 | + } |
|
| 741 | 792 | list ($username) = $smcFunc['db_fetch_row']($request); |
| 742 | 793 | $smcFunc['db_free_result']($request); |
| 743 | 794 | |
@@ -775,8 +826,7 @@ discard block |
||
| 775 | 826 | echo $data; |
| 776 | 827 | obExit(false); |
| 777 | 828 | } |
| 778 | - } |
|
| 779 | - else |
|
| 829 | + } else |
|
| 780 | 830 | { |
| 781 | 831 | $context += array( |
| 782 | 832 | 'page_title' => $txt['coppa_title'], |
@@ -829,8 +879,9 @@ discard block |
||
| 829 | 879 | { |
| 830 | 880 | require_once($sourcedir . '/Subs-Graphics.php'); |
| 831 | 881 | |
| 832 | - if (in_array('gd', get_loaded_extensions()) && !showCodeImage($code)) |
|
| 833 | - header('HTTP/1.1 400 Bad Request'); |
|
| 882 | + if (in_array('gd', get_loaded_extensions()) && !showCodeImage($code)) { |
|
| 883 | + header('HTTP/1.1 400 Bad Request'); |
|
| 884 | + } |
|
| 834 | 885 | |
| 835 | 886 | // Otherwise just show a pre-defined letter. |
| 836 | 887 | elseif (isset($_REQUEST['letter'])) |
@@ -848,14 +899,13 @@ discard block |
||
| 848 | 899 | header('content-type: image/gif'); |
| 849 | 900 | die("\x47\x49\x46\x38\x39\x61\x01\x00\x01\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x21\xF9\x04\x01\x00\x00\x00\x00\x2C\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02\x44\x01\x00\x3B"); |
| 850 | 901 | } |
| 851 | - } |
|
| 852 | - |
|
| 853 | - elseif ($_REQUEST['format'] === '.wav') |
|
| 902 | + } elseif ($_REQUEST['format'] === '.wav') |
|
| 854 | 903 | { |
| 855 | 904 | require_once($sourcedir . '/Subs-Sound.php'); |
| 856 | 905 | |
| 857 | - if (!createWaveFile($code)) |
|
| 858 | - header('HTTP/1.1 400 Bad Request'); |
|
| 906 | + if (!createWaveFile($code)) { |
|
| 907 | + header('HTTP/1.1 400 Bad Request'); |
|
| 908 | + } |
|
| 859 | 909 | } |
| 860 | 910 | |
| 861 | 911 | // We all die one day... |
@@ -75,8 +75,9 @@ discard block |
||
| 75 | 75 | $upcontext['inactive_timeout'] = 10; |
| 76 | 76 | |
| 77 | 77 | // The helper is crucial. Include it first thing. |
| 78 | -if (!file_exists($upgrade_path . '/upgrade-helper.php')) |
|
| 78 | +if (!file_exists($upgrade_path . '/upgrade-helper.php')) { |
|
| 79 | 79 | die('upgrade-helper.php not found where it was expected: ' . $upgrade_path . '/upgrade-helper.php! Make sure you have uploaded ALL files from the upgrade package. The upgrader cannot continue.'); |
| 80 | +} |
|
| 80 | 81 | |
| 81 | 82 | require_once($upgrade_path . '/upgrade-helper.php'); |
| 82 | 83 | |
@@ -107,11 +108,14 @@ discard block |
||
| 107 | 108 | ini_set('default_socket_timeout', 900); |
| 108 | 109 | } |
| 109 | 110 | // Clean the upgrade path if this is from the client. |
| 110 | -if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) |
|
| 111 | - for ($i = 1; $i < $_SERVER['argc']; $i++) |
|
| 111 | +if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) { |
|
| 112 | + for ($i = 1; |
|
| 113 | +} |
|
| 114 | +$i < $_SERVER['argc']; $i++) |
|
| 112 | 115 | { |
| 113 | - if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) |
|
| 114 | - $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
| 116 | + if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) { |
|
| 117 | + $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
| 118 | + } |
|
| 115 | 119 | } |
| 116 | 120 | |
| 117 | 121 | // Are we from the client? |
@@ -119,16 +123,17 @@ discard block |
||
| 119 | 123 | { |
| 120 | 124 | $command_line = true; |
| 121 | 125 | $disable_security = true; |
| 122 | -} |
|
| 123 | -else |
|
| 126 | +} else { |
|
| 124 | 127 | $command_line = false; |
| 128 | +} |
|
| 125 | 129 | |
| 126 | 130 | // Load this now just because we can. |
| 127 | 131 | require_once($upgrade_path . '/Settings.php'); |
| 128 | 132 | |
| 129 | 133 | // We don't use "-utf8" anymore... Tweak the entry that may have been loaded by Settings.php |
| 130 | -if (isset($language)) |
|
| 134 | +if (isset($language)) { |
|
| 131 | 135 | $language = str_ireplace('-utf8', '', $language); |
| 136 | +} |
|
| 132 | 137 | |
| 133 | 138 | // Are we logged in? |
| 134 | 139 | if (isset($upgradeData)) |
@@ -136,10 +141,12 @@ discard block |
||
| 136 | 141 | $upcontext['user'] = json_decode(base64_decode($upgradeData), true); |
| 137 | 142 | |
| 138 | 143 | // Check for sensible values. |
| 139 | - if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) |
|
| 140 | - $upcontext['user']['started'] = time(); |
|
| 141 | - if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) |
|
| 142 | - $upcontext['user']['updated'] = 0; |
|
| 144 | + if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) { |
|
| 145 | + $upcontext['user']['started'] = time(); |
|
| 146 | + } |
|
| 147 | + if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) { |
|
| 148 | + $upcontext['user']['updated'] = 0; |
|
| 149 | + } |
|
| 143 | 150 | |
| 144 | 151 | $upcontext['started'] = $upcontext['user']['started']; |
| 145 | 152 | $upcontext['updated'] = $upcontext['user']['updated']; |
@@ -204,8 +211,9 @@ discard block |
||
| 204 | 211 | 'db_error_skip' => true, |
| 205 | 212 | ) |
| 206 | 213 | ); |
| 207 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 208 | - $modSettings[$row['variable']] = $row['value']; |
|
| 214 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 215 | + $modSettings[$row['variable']] = $row['value']; |
|
| 216 | + } |
|
| 209 | 217 | $smcFunc['db_free_result']($request); |
| 210 | 218 | } |
| 211 | 219 | |
@@ -215,10 +223,12 @@ discard block |
||
| 215 | 223 | $modSettings['theme_url'] = 'Themes/default'; |
| 216 | 224 | $modSettings['images_url'] = 'Themes/default/images'; |
| 217 | 225 | } |
| 218 | -if (!isset($settings['default_theme_url'])) |
|
| 226 | +if (!isset($settings['default_theme_url'])) { |
|
| 219 | 227 | $settings['default_theme_url'] = $modSettings['theme_url']; |
| 220 | -if (!isset($settings['default_theme_dir'])) |
|
| 228 | +} |
|
| 229 | +if (!isset($settings['default_theme_dir'])) { |
|
| 221 | 230 | $settings['default_theme_dir'] = $modSettings['theme_dir']; |
| 231 | +} |
|
| 222 | 232 | |
| 223 | 233 | $upcontext['is_large_forum'] = (empty($modSettings['smfVersion']) || $modSettings['smfVersion'] <= '1.1 RC1') && !empty($modSettings['totalMessages']) && $modSettings['totalMessages'] > 75000; |
| 224 | 234 | // Default title... |
@@ -236,13 +246,15 @@ discard block |
||
| 236 | 246 | $support_js = $upcontext['upgrade_status']['js']; |
| 237 | 247 | |
| 238 | 248 | // Only set this if the upgrader status says so. |
| 239 | - if (empty($is_debug)) |
|
| 240 | - $is_debug = $upcontext['upgrade_status']['debug']; |
|
| 249 | + if (empty($is_debug)) { |
|
| 250 | + $is_debug = $upcontext['upgrade_status']['debug']; |
|
| 251 | + } |
|
| 241 | 252 | |
| 242 | 253 | // Load the language. |
| 243 | - if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 244 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 245 | -} |
|
| 254 | + if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 255 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 256 | + } |
|
| 257 | + } |
|
| 246 | 258 | // Set the defaults. |
| 247 | 259 | else |
| 248 | 260 | { |
@@ -260,15 +272,18 @@ discard block |
||
| 260 | 272 | } |
| 261 | 273 | |
| 262 | 274 | // If this isn't the first stage see whether they are logging in and resuming. |
| 263 | -if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) |
|
| 275 | +if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) { |
|
| 264 | 276 | checkLogin(); |
| 277 | +} |
|
| 265 | 278 | |
| 266 | -if ($command_line) |
|
| 279 | +if ($command_line) { |
|
| 267 | 280 | cmdStep0(); |
| 281 | +} |
|
| 268 | 282 | |
| 269 | 283 | // Don't error if we're using xml. |
| 270 | -if (isset($_GET['xml'])) |
|
| 284 | +if (isset($_GET['xml'])) { |
|
| 271 | 285 | $upcontext['return_error'] = true; |
| 286 | +} |
|
| 272 | 287 | |
| 273 | 288 | // Loop through all the steps doing each one as required. |
| 274 | 289 | $upcontext['overall_percent'] = 0; |
@@ -289,9 +304,9 @@ discard block |
||
| 289 | 304 | } |
| 290 | 305 | |
| 291 | 306 | // Call the step and if it returns false that means pause! |
| 292 | - if (function_exists($step[2]) && $step[2]() === false) |
|
| 293 | - break; |
|
| 294 | - elseif (function_exists($step[2])) { |
|
| 307 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
| 308 | + break; |
|
| 309 | + } elseif (function_exists($step[2])) { |
|
| 295 | 310 | //Start each new step with this unset, so the 'normal' template is called first |
| 296 | 311 | unset($_GET['xml']); |
| 297 | 312 | //Clear out warnings at the start of each step |
@@ -337,17 +352,18 @@ discard block |
||
| 337 | 352 | // This should not happen my dear... HELP ME DEVELOPERS!! |
| 338 | 353 | if (!empty($command_line)) |
| 339 | 354 | { |
| 340 | - if (function_exists('debug_print_backtrace')) |
|
| 341 | - debug_print_backtrace(); |
|
| 355 | + if (function_exists('debug_print_backtrace')) { |
|
| 356 | + debug_print_backtrace(); |
|
| 357 | + } |
|
| 342 | 358 | |
| 343 | 359 | echo "\n" . 'Error: Unexpected call to use the ' . (isset($upcontext['sub_template']) ? $upcontext['sub_template'] : '') . ' template. Please copy and paste all the text above and visit the SMF support forum to tell the Developers that they\'ve made a boo boo; they\'ll get you up and running again.'; |
| 344 | 360 | flush(); |
| 345 | 361 | die(); |
| 346 | 362 | } |
| 347 | 363 | |
| 348 | - if (!isset($_GET['xml'])) |
|
| 349 | - template_upgrade_above(); |
|
| 350 | - else |
|
| 364 | + if (!isset($_GET['xml'])) { |
|
| 365 | + template_upgrade_above(); |
|
| 366 | + } else |
|
| 351 | 367 | { |
| 352 | 368 | header('content-type: text/xml; charset=UTF-8'); |
| 353 | 369 | // Sadly we need to retain the $_GET data thanks to the old upgrade scripts. |
@@ -369,25 +385,29 @@ discard block |
||
| 369 | 385 | $upcontext['form_url'] = $upgradeurl . '?step=' . $upcontext['current_step'] . '&substep=' . $_GET['substep'] . '&data=' . base64_encode(json_encode($upcontext['upgrade_status'])); |
| 370 | 386 | |
| 371 | 387 | // Custom stuff to pass back? |
| 372 | - if (!empty($upcontext['query_string'])) |
|
| 373 | - $upcontext['form_url'] .= $upcontext['query_string']; |
|
| 388 | + if (!empty($upcontext['query_string'])) { |
|
| 389 | + $upcontext['form_url'] .= $upcontext['query_string']; |
|
| 390 | + } |
|
| 374 | 391 | |
| 375 | 392 | // Call the appropriate subtemplate |
| 376 | - if (is_callable('template_' . $upcontext['sub_template'])) |
|
| 377 | - call_user_func('template_' . $upcontext['sub_template']); |
|
| 378 | - else |
|
| 379 | - die('Upgrade aborted! Invalid template: template_' . $upcontext['sub_template']); |
|
| 393 | + if (is_callable('template_' . $upcontext['sub_template'])) { |
|
| 394 | + call_user_func('template_' . $upcontext['sub_template']); |
|
| 395 | + } else { |
|
| 396 | + die('Upgrade aborted! Invalid template: template_' . $upcontext['sub_template']); |
|
| 397 | + } |
|
| 380 | 398 | } |
| 381 | 399 | |
| 382 | 400 | // Was there an error? |
| 383 | - if (!empty($upcontext['forced_error_message'])) |
|
| 384 | - echo $upcontext['forced_error_message']; |
|
| 401 | + if (!empty($upcontext['forced_error_message'])) { |
|
| 402 | + echo $upcontext['forced_error_message']; |
|
| 403 | + } |
|
| 385 | 404 | |
| 386 | 405 | // Show the footer. |
| 387 | - if (!isset($_GET['xml'])) |
|
| 388 | - template_upgrade_below(); |
|
| 389 | - else |
|
| 390 | - template_xml_below(); |
|
| 406 | + if (!isset($_GET['xml'])) { |
|
| 407 | + template_upgrade_below(); |
|
| 408 | + } else { |
|
| 409 | + template_xml_below(); |
|
| 410 | + } |
|
| 391 | 411 | } |
| 392 | 412 | |
| 393 | 413 | |
@@ -399,15 +419,19 @@ discard block |
||
| 399 | 419 | $seconds = intval($active % 60); |
| 400 | 420 | |
| 401 | 421 | $totalTime = ''; |
| 402 | - if ($hours > 0) |
|
| 403 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 404 | - if ($minutes > 0) |
|
| 405 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 406 | - if ($seconds > 0) |
|
| 407 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 422 | + if ($hours > 0) { |
|
| 423 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 424 | + } |
|
| 425 | + if ($minutes > 0) { |
|
| 426 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 427 | + } |
|
| 428 | + if ($seconds > 0) { |
|
| 429 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 430 | + } |
|
| 408 | 431 | |
| 409 | - if (!empty($totalTime)) |
|
| 410 | - echo "\n" . '', $txt['upgrade_completed_time'], ' ' . $totalTime . "\n"; |
|
| 432 | + if (!empty($totalTime)) { |
|
| 433 | + echo "\n" . '', $txt['upgrade_completed_time'], ' ' . $totalTime . "\n"; |
|
| 434 | + } |
|
| 411 | 435 | } |
| 412 | 436 | |
| 413 | 437 | // Bang - gone! |
@@ -428,8 +452,9 @@ discard block |
||
| 428 | 452 | $dir = dir(dirname(__FILE__) . '/Themes/default/languages'); |
| 429 | 453 | while ($entry = $dir->read()) |
| 430 | 454 | { |
| 431 | - if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') |
|
| 432 | - $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
| 455 | + if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') { |
|
| 456 | + $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
| 457 | + } |
|
| 433 | 458 | } |
| 434 | 459 | $dir->close(); |
| 435 | 460 | } |
@@ -464,10 +489,11 @@ discard block |
||
| 464 | 489 | } |
| 465 | 490 | |
| 466 | 491 | // Override the language file? |
| 467 | - if (isset($_GET['lang_file'])) |
|
| 468 | - $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
| 469 | - elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) |
|
| 470 | - $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
| 492 | + if (isset($_GET['lang_file'])) { |
|
| 493 | + $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
| 494 | + } elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) { |
|
| 495 | + $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
| 496 | + } |
|
| 471 | 497 | |
| 472 | 498 | // Make sure it exists, if it doesn't reset it. |
| 473 | 499 | 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'])) |
@@ -476,12 +502,14 @@ discard block |
||
| 476 | 502 | list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
| 477 | 503 | |
| 478 | 504 | // If we have english and some other language, use the other language. We Americans hate english :P. |
| 479 | - if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) |
|
| 480 | - list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
| 505 | + if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) { |
|
| 506 | + list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
| 507 | + } |
|
| 481 | 508 | |
| 482 | 509 | // For backup we load the english at first -> second language overwrite the english one |
| 483 | - if (count($incontext['detected_languages']) > 1) |
|
| 484 | - require_once(dirname(__FILE__) . '/Themes/default/languages/Install.english.php'); |
|
| 510 | + if (count($incontext['detected_languages']) > 1) { |
|
| 511 | + require_once(dirname(__FILE__) . '/Themes/default/languages/Install.english.php'); |
|
| 512 | + } |
|
| 485 | 513 | } |
| 486 | 514 | |
| 487 | 515 | // And now include the actual language file itself. |
@@ -489,11 +517,12 @@ discard block |
||
| 489 | 517 | |
| 490 | 518 | // Which language did we load? Assume that he likes his language. |
| 491 | 519 | preg_match('~^Install\.(.+[^-utf8])\.php$~', $_SESSION['installer_temp_lang'], $matches); |
| 492 | - if (empty($matches[1])) |
|
| 493 | - $matches = [ |
|
| 520 | + if (empty($matches[1])) { |
|
| 521 | + $matches = [ |
|
| 494 | 522 | 0 => 'nothing', |
| 495 | 523 | 1 => 'english', |
| 496 | 524 | ]; |
| 525 | + } |
|
| 497 | 526 | $user_info['language'] = $matches[1]; |
| 498 | 527 | } |
| 499 | 528 | |
@@ -503,8 +532,9 @@ discard block |
||
| 503 | 532 | global $upgradeurl, $upcontext, $command_line; |
| 504 | 533 | |
| 505 | 534 | // Command line users can't be redirected. |
| 506 | - if ($command_line) |
|
| 507 | - upgradeExit(true); |
|
| 535 | + if ($command_line) { |
|
| 536 | + upgradeExit(true); |
|
| 537 | + } |
|
| 508 | 538 | |
| 509 | 539 | // Are we providing the core info? |
| 510 | 540 | if ($addForm) |
@@ -530,12 +560,14 @@ discard block |
||
| 530 | 560 | define('SMF', 1); |
| 531 | 561 | |
| 532 | 562 | // Start the session. |
| 533 | - if (@ini_get('session.save_handler') == 'user') |
|
| 534 | - @ini_set('session.save_handler', 'files'); |
|
| 563 | + if (@ini_get('session.save_handler') == 'user') { |
|
| 564 | + @ini_set('session.save_handler', 'files'); |
|
| 565 | + } |
|
| 535 | 566 | @session_start(); |
| 536 | 567 | |
| 537 | - if (empty($smcFunc)) |
|
| 538 | - $smcFunc = array(); |
|
| 568 | + if (empty($smcFunc)) { |
|
| 569 | + $smcFunc = array(); |
|
| 570 | + } |
|
| 539 | 571 | |
| 540 | 572 | // We need this for authentication and some upgrade code |
| 541 | 573 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -562,24 +594,27 @@ discard block |
||
| 562 | 594 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
| 563 | 595 | |
| 564 | 596 | // Make the connection... |
| 565 | - if (empty($db_connection)) |
|
| 566 | - $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true)); |
|
| 567 | - else |
|
| 568 | - // If we've returned here, ping/reconnect to be safe |
|
| 597 | + if (empty($db_connection)) { |
|
| 598 | + $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true)); |
|
| 599 | + } else { |
|
| 600 | + // If we've returned here, ping/reconnect to be safe |
|
| 569 | 601 | $smcFunc['db_ping']($db_connection); |
| 602 | + } |
|
| 570 | 603 | |
| 571 | 604 | // Oh dear god!! |
| 572 | - if ($db_connection === null) |
|
| 573 | - die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
| 605 | + if ($db_connection === null) { |
|
| 606 | + die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
| 607 | + } |
|
| 574 | 608 | |
| 575 | - if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) |
|
| 576 | - $smcFunc['db_query']('', ' |
|
| 609 | + if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) { |
|
| 610 | + $smcFunc['db_query']('', ' |
|
| 577 | 611 | SET NAMES {string:db_character_set}', |
| 578 | 612 | array( |
| 579 | 613 | 'db_error_skip' => true, |
| 580 | 614 | 'db_character_set' => $db_character_set, |
| 581 | 615 | ) |
| 582 | 616 | ); |
| 617 | + } |
|
| 583 | 618 | |
| 584 | 619 | // Load the modSettings data... |
| 585 | 620 | $request = $smcFunc['db_query']('', ' |
@@ -590,11 +625,11 @@ discard block |
||
| 590 | 625 | ) |
| 591 | 626 | ); |
| 592 | 627 | $modSettings = array(); |
| 593 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 594 | - $modSettings[$row['variable']] = $row['value']; |
|
| 628 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 629 | + $modSettings[$row['variable']] = $row['value']; |
|
| 630 | + } |
|
| 595 | 631 | $smcFunc['db_free_result']($request); |
| 596 | - } |
|
| 597 | - else |
|
| 632 | + } else |
|
| 598 | 633 | { |
| 599 | 634 | return throw_error('Cannot find ' . $sourcedir . '/Subs-Db-' . $db_type . '.php' . '. Please check you have uploaded all source files and have the correct paths set.'); |
| 600 | 635 | } |
@@ -608,9 +643,10 @@ discard block |
||
| 608 | 643 | cleanRequest(); |
| 609 | 644 | } |
| 610 | 645 | |
| 611 | - if (!isset($_GET['substep'])) |
|
| 612 | - $_GET['substep'] = 0; |
|
| 613 | -} |
|
| 646 | + if (!isset($_GET['substep'])) { |
|
| 647 | + $_GET['substep'] = 0; |
|
| 648 | + } |
|
| 649 | + } |
|
| 614 | 650 | |
| 615 | 651 | function initialize_inputs() |
| 616 | 652 | { |
@@ -640,8 +676,9 @@ discard block |
||
| 640 | 676 | $dh = opendir(dirname(__FILE__)); |
| 641 | 677 | while ($file = readdir($dh)) |
| 642 | 678 | { |
| 643 | - if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) |
|
| 644 | - @unlink(dirname(__FILE__) . '/' . $file); |
|
| 679 | + if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) { |
|
| 680 | + @unlink(dirname(__FILE__) . '/' . $file); |
|
| 681 | + } |
|
| 645 | 682 | } |
| 646 | 683 | closedir($dh); |
| 647 | 684 | |
@@ -670,8 +707,9 @@ discard block |
||
| 670 | 707 | $temp = 'upgrade_php?step'; |
| 671 | 708 | while (strlen($temp) > 4) |
| 672 | 709 | { |
| 673 | - if (isset($_GET[$temp])) |
|
| 674 | - unset($_GET[$temp]); |
|
| 710 | + if (isset($_GET[$temp])) { |
|
| 711 | + unset($_GET[$temp]); |
|
| 712 | + } |
|
| 675 | 713 | $temp = substr($temp, 1); |
| 676 | 714 | } |
| 677 | 715 | |
@@ -698,32 +736,39 @@ discard block |
||
| 698 | 736 | && @file_exists(dirname(__FILE__) . '/upgrade_2-1_' . $db_type . '.sql'); |
| 699 | 737 | |
| 700 | 738 | // Need legacy scripts? |
| 701 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) |
|
| 702 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
| 703 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) |
|
| 704 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
| 705 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) |
|
| 706 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
| 739 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) { |
|
| 740 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
| 741 | + } |
|
| 742 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) { |
|
| 743 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
| 744 | + } |
|
| 745 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) { |
|
| 746 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
| 747 | + } |
|
| 707 | 748 | |
| 708 | 749 | // We don't need "-utf8" files anymore... |
| 709 | 750 | $upcontext['language'] = str_ireplace('-utf8', '', $upcontext['language']); |
| 710 | 751 | |
| 711 | 752 | // This needs to exist! |
| 712 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 713 | - return throw_error('The upgrader could not find the "Install" language file for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
| 714 | - else |
|
| 715 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 753 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 754 | + return throw_error('The upgrader could not find the "Install" language file for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
| 755 | + } else { |
|
| 756 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 757 | + } |
|
| 716 | 758 | |
| 717 | - if (!$check) |
|
| 718 | - // Don't tell them what files exactly because it's a spot check - just like teachers don't tell which problems they are spot checking, that's dumb. |
|
| 759 | + if (!$check) { |
|
| 760 | + // Don't tell them what files exactly because it's a spot check - just like teachers don't tell which problems they are spot checking, that's dumb. |
|
| 719 | 761 | return throw_error('The upgrader was unable to find some crucial files.<br><br>Please make sure you uploaded all of the files included in the package, including the Themes, Sources, and other directories.'); |
| 762 | + } |
|
| 720 | 763 | |
| 721 | 764 | // Do they meet the install requirements? |
| 722 | - if (!php_version_check()) |
|
| 723 | - return throw_error('Warning! You do not appear to have a version of PHP installed on your webserver that meets SMF\'s minimum installations requirements.<br><br>Please ask your host to upgrade.'); |
|
| 765 | + if (!php_version_check()) { |
|
| 766 | + return throw_error('Warning! You do not appear to have a version of PHP installed on your webserver that meets SMF\'s minimum installations requirements.<br><br>Please ask your host to upgrade.'); |
|
| 767 | + } |
|
| 724 | 768 | |
| 725 | - if (!db_version_check()) |
|
| 726 | - return throw_error('Your ' . $databases[$db_type]['name'] . ' version does not meet the minimum requirements of SMF.<br><br>Please ask your host to upgrade.'); |
|
| 769 | + if (!db_version_check()) { |
|
| 770 | + return throw_error('Your ' . $databases[$db_type]['name'] . ' version does not meet the minimum requirements of SMF.<br><br>Please ask your host to upgrade.'); |
|
| 771 | + } |
|
| 727 | 772 | |
| 728 | 773 | // Do some checks to make sure they have proper privileges |
| 729 | 774 | db_extend('packages'); |
@@ -738,14 +783,16 @@ discard block |
||
| 738 | 783 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
| 739 | 784 | |
| 740 | 785 | // Sorry... we need CREATE, ALTER and DROP |
| 741 | - if (!$create || !$alter || !$drop) |
|
| 742 | - return throw_error('The ' . $databases[$db_type]['name'] . ' user you have set in Settings.php does not have proper privileges.<br><br>Please ask your host to give this user the ALTER, CREATE, and DROP privileges.'); |
|
| 786 | + if (!$create || !$alter || !$drop) { |
|
| 787 | + return throw_error('The ' . $databases[$db_type]['name'] . ' user you have set in Settings.php does not have proper privileges.<br><br>Please ask your host to give this user the ALTER, CREATE, and DROP privileges.'); |
|
| 788 | + } |
|
| 743 | 789 | |
| 744 | 790 | // Do a quick version spot check. |
| 745 | 791 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
| 746 | 792 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
| 747 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
| 748 | - return throw_error('The upgrader found some old or outdated files.<br><br>Please make certain you uploaded the new versions of all the files included in the package.'); |
|
| 793 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
| 794 | + return throw_error('The upgrader found some old or outdated files.<br><br>Please make certain you uploaded the new versions of all the files included in the package.'); |
|
| 795 | + } |
|
| 749 | 796 | |
| 750 | 797 | // What absolutely needs to be writable? |
| 751 | 798 | $writable_files = array( |
@@ -754,12 +801,13 @@ discard block |
||
| 754 | 801 | ); |
| 755 | 802 | |
| 756 | 803 | // Only check for minified writable files if we have it enabled or not set. |
| 757 | - if (!empty($modSettings['minimize_files']) || !isset($modSettings['minimize_files'])) |
|
| 758 | - $writable_files += array( |
|
| 804 | + if (!empty($modSettings['minimize_files']) || !isset($modSettings['minimize_files'])) { |
|
| 805 | + $writable_files += array( |
|
| 759 | 806 | $modSettings['theme_dir'] . '/css/minified.css', |
| 760 | 807 | $modSettings['theme_dir'] . '/scripts/minified.js', |
| 761 | 808 | $modSettings['theme_dir'] . '/scripts/minified_deferred.js', |
| 762 | 809 | ); |
| 810 | + } |
|
| 763 | 811 | |
| 764 | 812 | // Do we need to add this setting? |
| 765 | 813 | $need_settings_update = empty($modSettings['custom_avatar_dir']); |
@@ -771,12 +819,13 @@ discard block |
||
| 771 | 819 | quickFileWritable($custom_av_dir); |
| 772 | 820 | |
| 773 | 821 | // Are we good now? |
| 774 | - if (!is_writable($custom_av_dir)) |
|
| 775 | - return throw_error(sprintf('The directory: %1$s has to be writable to continue the upgrade. Please make sure permissions are correctly set to allow this.', $custom_av_dir)); |
|
| 776 | - elseif ($need_settings_update) |
|
| 822 | + if (!is_writable($custom_av_dir)) { |
|
| 823 | + return throw_error(sprintf('The directory: %1$s has to be writable to continue the upgrade. Please make sure permissions are correctly set to allow this.', $custom_av_dir)); |
|
| 824 | + } elseif ($need_settings_update) |
|
| 777 | 825 | { |
| 778 | - if (!function_exists('cache_put_data')) |
|
| 779 | - require_once($sourcedir . '/Load.php'); |
|
| 826 | + if (!function_exists('cache_put_data')) { |
|
| 827 | + require_once($sourcedir . '/Load.php'); |
|
| 828 | + } |
|
| 780 | 829 | updateSettings(array('custom_avatar_dir' => $custom_av_dir)); |
| 781 | 830 | updateSettings(array('custom_avatar_url' => $custom_av_url)); |
| 782 | 831 | } |
@@ -785,28 +834,33 @@ discard block |
||
| 785 | 834 | |
| 786 | 835 | // Check the cache directory. |
| 787 | 836 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
| 788 | - if (!file_exists($cachedir_temp)) |
|
| 789 | - @mkdir($cachedir_temp); |
|
| 790 | - if (!file_exists($cachedir_temp)) |
|
| 791 | - return throw_error('The cache directory could not be found.<br><br>Please make sure you have a directory called "cache" in your forum directory before continuing.'); |
|
| 792 | - |
|
| 793 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
| 794 | - return throw_error('The upgrader was unable to find language files for the language specified in Settings.php.<br>SMF will not work without the primary language files installed.<br><br>Please either install them, or <a href="' . $upgradeurl . '?step=0;lang=english">use english instead</a>.'); |
|
| 795 | - elseif (!isset($_GET['skiplang'])) |
|
| 837 | + if (!file_exists($cachedir_temp)) { |
|
| 838 | + @mkdir($cachedir_temp); |
|
| 839 | + } |
|
| 840 | + if (!file_exists($cachedir_temp)) { |
|
| 841 | + return throw_error('The cache directory could not be found.<br><br>Please make sure you have a directory called "cache" in your forum directory before continuing.'); |
|
| 842 | + } |
|
| 843 | + |
|
| 844 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
| 845 | + return throw_error('The upgrader was unable to find language files for the language specified in Settings.php.<br>SMF will not work without the primary language files installed.<br><br>Please either install them, or <a href="' . $upgradeurl . '?step=0;lang=english">use english instead</a>.'); |
|
| 846 | + } elseif (!isset($_GET['skiplang'])) |
|
| 796 | 847 | { |
| 797 | 848 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
| 798 | 849 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 799 | 850 | |
| 800 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 801 | - return throw_error('The upgrader found some old or outdated language files, for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded the new versions of all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?skiplang">SKIP</a>] [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
| 851 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 852 | + return throw_error('The upgrader found some old or outdated language files, for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded the new versions of all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?skiplang">SKIP</a>] [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
| 853 | + } |
|
| 802 | 854 | } |
| 803 | 855 | |
| 804 | - if (!makeFilesWritable($writable_files)) |
|
| 805 | - return false; |
|
| 856 | + if (!makeFilesWritable($writable_files)) { |
|
| 857 | + return false; |
|
| 858 | + } |
|
| 806 | 859 | |
| 807 | 860 | // Check agreement.txt. (it may not exist, in which case $boarddir must be writable.) |
| 808 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
| 809 | - return throw_error('The upgrader was unable to obtain write access to agreement.txt.<br><br>If you are using a linux or unix based server, please ensure that the file is chmod\'d to 777, or if it does not exist that the directory this upgrader is in is 777.<br>If your server is running Windows, please ensure that the internet guest account has the proper permissions on it or its folder.'); |
|
| 861 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
| 862 | + return throw_error('The upgrader was unable to obtain write access to agreement.txt.<br><br>If you are using a linux or unix based server, please ensure that the file is chmod\'d to 777, or if it does not exist that the directory this upgrader is in is 777.<br>If your server is running Windows, please ensure that the internet guest account has the proper permissions on it or its folder.'); |
|
| 863 | + } |
|
| 810 | 864 | |
| 811 | 865 | // Upgrade the agreement. |
| 812 | 866 | elseif (isset($modSettings['agreement'])) |
@@ -817,8 +871,8 @@ discard block |
||
| 817 | 871 | } |
| 818 | 872 | |
| 819 | 873 | // We're going to check that their board dir setting is right in case they've been moving stuff around. |
| 820 | - if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) |
|
| 821 | - $upcontext['warning'] = ' |
|
| 874 | + if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) { |
|
| 875 | + $upcontext['warning'] = ' |
|
| 822 | 876 | It looks as if your board directory settings <em>might</em> be incorrect. Your board directory is currently set to "' . $boarddir . '" but should probably be "' . dirname(__FILE__) . '". Settings.php currently lists your paths as:<br> |
| 823 | 877 | <ul> |
| 824 | 878 | <li>Board Directory: ' . $boarddir . '</li> |
@@ -826,19 +880,23 @@ discard block |
||
| 826 | 880 | <li>Cache Directory: ' . $cachedir_temp . '</li> |
| 827 | 881 | </ul> |
| 828 | 882 | If these seem incorrect please open Settings.php in a text editor before proceeding with this upgrade. If they are incorrect due to you moving your forum to a new location please download and execute the <a href="https://download.simplemachines.org/?tools">Repair Settings</a> tool from the Simple Machines website before continuing.'; |
| 883 | + } |
|
| 829 | 884 | |
| 830 | 885 | // Confirm mbstring is loaded... |
| 831 | - if (!extension_loaded('mbstring')) |
|
| 832 | - return throw_error($txt['install_no_mbstring']); |
|
| 886 | + if (!extension_loaded('mbstring')) { |
|
| 887 | + return throw_error($txt['install_no_mbstring']); |
|
| 888 | + } |
|
| 833 | 889 | |
| 834 | 890 | // Check for https stream support. |
| 835 | 891 | $supported_streams = stream_get_wrappers(); |
| 836 | - if (!in_array('https', $supported_streams)) |
|
| 837 | - $upcontext['custom_warning'] = $txt['install_no_https']; |
|
| 892 | + if (!in_array('https', $supported_streams)) { |
|
| 893 | + $upcontext['custom_warning'] = $txt['install_no_https']; |
|
| 894 | + } |
|
| 838 | 895 | |
| 839 | 896 | // Either we're logged in or we're going to present the login. |
| 840 | - if (checkLogin()) |
|
| 841 | - return true; |
|
| 897 | + if (checkLogin()) { |
|
| 898 | + return true; |
|
| 899 | + } |
|
| 842 | 900 | |
| 843 | 901 | $upcontext += createToken('login'); |
| 844 | 902 | |
@@ -852,15 +910,17 @@ discard block |
||
| 852 | 910 | global $smcFunc, $db_type, $support_js; |
| 853 | 911 | |
| 854 | 912 | // Don't bother if the security is disabled. |
| 855 | - if ($disable_security) |
|
| 856 | - return true; |
|
| 913 | + if ($disable_security) { |
|
| 914 | + return true; |
|
| 915 | + } |
|
| 857 | 916 | |
| 858 | 917 | // Are we trying to login? |
| 859 | 918 | if (isset($_POST['contbutt']) && (!empty($_POST['user']))) |
| 860 | 919 | { |
| 861 | 920 | // If we've disabled security pick a suitable name! |
| 862 | - if (empty($_POST['user'])) |
|
| 863 | - $_POST['user'] = 'Administrator'; |
|
| 921 | + if (empty($_POST['user'])) { |
|
| 922 | + $_POST['user'] = 'Administrator'; |
|
| 923 | + } |
|
| 864 | 924 | |
| 865 | 925 | // Before 2.0 these column names were different! |
| 866 | 926 | $oldDB = false; |
@@ -875,16 +935,17 @@ discard block |
||
| 875 | 935 | 'db_error_skip' => true, |
| 876 | 936 | ) |
| 877 | 937 | ); |
| 878 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 879 | - $oldDB = true; |
|
| 938 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 939 | + $oldDB = true; |
|
| 940 | + } |
|
| 880 | 941 | $smcFunc['db_free_result']($request); |
| 881 | 942 | } |
| 882 | 943 | |
| 883 | 944 | // Get what we believe to be their details. |
| 884 | 945 | if (!$disable_security) |
| 885 | 946 | { |
| 886 | - if ($oldDB) |
|
| 887 | - $request = $smcFunc['db_query']('', ' |
|
| 947 | + if ($oldDB) { |
|
| 948 | + $request = $smcFunc['db_query']('', ' |
|
| 888 | 949 | SELECT id_member, memberName AS member_name, passwd, id_group, |
| 889 | 950 | additionalGroups AS additional_groups, lngfile |
| 890 | 951 | FROM {db_prefix}members |
@@ -894,8 +955,8 @@ discard block |
||
| 894 | 955 | 'db_error_skip' => true, |
| 895 | 956 | ) |
| 896 | 957 | ); |
| 897 | - else |
|
| 898 | - $request = $smcFunc['db_query']('', ' |
|
| 958 | + } else { |
|
| 959 | + $request = $smcFunc['db_query']('', ' |
|
| 899 | 960 | SELECT id_member, member_name, passwd, id_group, additional_groups, lngfile |
| 900 | 961 | FROM {db_prefix}members |
| 901 | 962 | WHERE member_name = {string:member_name}', |
@@ -904,6 +965,7 @@ discard block |
||
| 904 | 965 | 'db_error_skip' => true, |
| 905 | 966 | ) |
| 906 | 967 | ); |
| 968 | + } |
|
| 907 | 969 | if ($smcFunc['db_num_rows']($request) != 0) |
| 908 | 970 | { |
| 909 | 971 | list ($id_member, $name, $password, $id_group, $addGroups, $user_language) = $smcFunc['db_fetch_row']($request); |
@@ -911,16 +973,17 @@ discard block |
||
| 911 | 973 | $groups = explode(',', $addGroups); |
| 912 | 974 | $groups[] = $id_group; |
| 913 | 975 | |
| 914 | - foreach ($groups as $k => $v) |
|
| 915 | - $groups[$k] = (int) $v; |
|
| 976 | + foreach ($groups as $k => $v) { |
|
| 977 | + $groups[$k] = (int) $v; |
|
| 978 | + } |
|
| 916 | 979 | |
| 917 | 980 | $sha_passwd = sha1(strtolower($name) . un_htmlspecialchars($_REQUEST['passwrd'])); |
| 918 | 981 | |
| 919 | 982 | // We don't use "-utf8" anymore... |
| 920 | 983 | $user_language = str_ireplace('-utf8', '', $user_language); |
| 984 | + } else { |
|
| 985 | + $upcontext['username_incorrect'] = true; |
|
| 921 | 986 | } |
| 922 | - else |
|
| 923 | - $upcontext['username_incorrect'] = true; |
|
| 924 | 987 | $smcFunc['db_free_result']($request); |
| 925 | 988 | } |
| 926 | 989 | $upcontext['username'] = $_POST['user']; |
@@ -930,13 +993,14 @@ discard block |
||
| 930 | 993 | { |
| 931 | 994 | $upcontext['upgrade_status']['js'] = 1; |
| 932 | 995 | $support_js = 1; |
| 996 | + } else { |
|
| 997 | + $support_js = 0; |
|
| 933 | 998 | } |
| 934 | - else |
|
| 935 | - $support_js = 0; |
|
| 936 | 999 | |
| 937 | 1000 | // Note down the version we are coming from. |
| 938 | - if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) |
|
| 939 | - $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
| 1001 | + if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) { |
|
| 1002 | + $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
| 1003 | + } |
|
| 940 | 1004 | |
| 941 | 1005 | // Didn't get anywhere? |
| 942 | 1006 | if (!$disable_security && (empty($sha_passwd) || (!empty($password) ? $password : '') != $sha_passwd) && !hash_verify_password((!empty($name) ? $name : ''), $_REQUEST['passwrd'], (!empty($password) ? $password : '')) && empty($upcontext['username_incorrect'])) |
@@ -970,15 +1034,15 @@ discard block |
||
| 970 | 1034 | 'db_error_skip' => true, |
| 971 | 1035 | ) |
| 972 | 1036 | ); |
| 973 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 974 | - return throw_error('You need to be an admin to perform an upgrade!'); |
|
| 1037 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1038 | + return throw_error('You need to be an admin to perform an upgrade!'); |
|
| 1039 | + } |
|
| 975 | 1040 | $smcFunc['db_free_result']($request); |
| 976 | 1041 | } |
| 977 | 1042 | |
| 978 | 1043 | $upcontext['user']['id'] = $id_member; |
| 979 | 1044 | $upcontext['user']['name'] = $name; |
| 980 | - } |
|
| 981 | - else |
|
| 1045 | + } else |
|
| 982 | 1046 | { |
| 983 | 1047 | $upcontext['user']['id'] = 1; |
| 984 | 1048 | $upcontext['user']['name'] = 'Administrator'; |
@@ -994,11 +1058,11 @@ discard block |
||
| 994 | 1058 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $user_language . '.php')), 0, 4096); |
| 995 | 1059 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 996 | 1060 | |
| 997 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 998 | - $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been updated to the latest version. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
| 999 | - elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) |
|
| 1000 | - $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been uploaded/updated as the "Install" language file is missing. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
| 1001 | - else |
|
| 1061 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 1062 | + $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been updated to the latest version. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
| 1063 | + } elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) { |
|
| 1064 | + $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been uploaded/updated as the "Install" language file is missing. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
| 1065 | + } else |
|
| 1002 | 1066 | { |
| 1003 | 1067 | // Set this as the new language. |
| 1004 | 1068 | $upcontext['language'] = $user_language; |
@@ -1042,8 +1106,9 @@ discard block |
||
| 1042 | 1106 | unset($member_columns); |
| 1043 | 1107 | |
| 1044 | 1108 | // If we've not submitted then we're done. |
| 1045 | - if (empty($_POST['upcont'])) |
|
| 1046 | - return false; |
|
| 1109 | + if (empty($_POST['upcont'])) { |
|
| 1110 | + return false; |
|
| 1111 | + } |
|
| 1047 | 1112 | |
| 1048 | 1113 | // Firstly, if they're enabling SM stat collection just do it. |
| 1049 | 1114 | if (!empty($_POST['stats']) && substr($boardurl, 0, 16) != 'http://localhost' && empty($modSettings['allow_sm_stats']) && empty($modSettings['enable_sm_stats'])) |
@@ -1063,16 +1128,17 @@ discard block |
||
| 1063 | 1128 | fwrite($fp, $out); |
| 1064 | 1129 | |
| 1065 | 1130 | $return_data = ''; |
| 1066 | - while (!feof($fp)) |
|
| 1067 | - $return_data .= fgets($fp, 128); |
|
| 1131 | + while (!feof($fp)) { |
|
| 1132 | + $return_data .= fgets($fp, 128); |
|
| 1133 | + } |
|
| 1068 | 1134 | |
| 1069 | 1135 | fclose($fp); |
| 1070 | 1136 | |
| 1071 | 1137 | // Get the unique site ID. |
| 1072 | 1138 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
| 1073 | 1139 | |
| 1074 | - if (!empty($ID[1])) |
|
| 1075 | - $smcFunc['db_insert']('replace', |
|
| 1140 | + if (!empty($ID[1])) { |
|
| 1141 | + $smcFunc['db_insert']('replace', |
|
| 1076 | 1142 | $db_prefix . 'settings', |
| 1077 | 1143 | array('variable' => 'string', 'value' => 'string'), |
| 1078 | 1144 | array( |
@@ -1081,9 +1147,9 @@ discard block |
||
| 1081 | 1147 | ), |
| 1082 | 1148 | array('variable') |
| 1083 | 1149 | ); |
| 1150 | + } |
|
| 1084 | 1151 | } |
| 1085 | - } |
|
| 1086 | - else |
|
| 1152 | + } else |
|
| 1087 | 1153 | { |
| 1088 | 1154 | $smcFunc['db_insert']('replace', |
| 1089 | 1155 | $db_prefix . 'settings', |
@@ -1094,8 +1160,8 @@ discard block |
||
| 1094 | 1160 | } |
| 1095 | 1161 | } |
| 1096 | 1162 | // Don't remove stat collection unless we unchecked the box for real, not from the loop. |
| 1097 | - elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) |
|
| 1098 | - $smcFunc['db_query']('', ' |
|
| 1163 | + elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) { |
|
| 1164 | + $smcFunc['db_query']('', ' |
|
| 1099 | 1165 | DELETE FROM {db_prefix}settings |
| 1100 | 1166 | WHERE variable = {string:enable_sm_stats}', |
| 1101 | 1167 | array( |
@@ -1103,6 +1169,7 @@ discard block |
||
| 1103 | 1169 | 'db_error_skip' => true, |
| 1104 | 1170 | ) |
| 1105 | 1171 | ); |
| 1172 | + } |
|
| 1106 | 1173 | |
| 1107 | 1174 | // Deleting old karma stuff? |
| 1108 | 1175 | if (!empty($_POST['delete_karma'])) |
@@ -1117,20 +1184,22 @@ discard block |
||
| 1117 | 1184 | ); |
| 1118 | 1185 | |
| 1119 | 1186 | // Cleaning up old karma member settings. |
| 1120 | - if ($upcontext['karma_installed']['good']) |
|
| 1121 | - $smcFunc['db_query']('', ' |
|
| 1187 | + if ($upcontext['karma_installed']['good']) { |
|
| 1188 | + $smcFunc['db_query']('', ' |
|
| 1122 | 1189 | ALTER TABLE {db_prefix}members |
| 1123 | 1190 | DROP karma_good', |
| 1124 | 1191 | array() |
| 1125 | 1192 | ); |
| 1193 | + } |
|
| 1126 | 1194 | |
| 1127 | 1195 | // Does karma bad was enable? |
| 1128 | - if ($upcontext['karma_installed']['bad']) |
|
| 1129 | - $smcFunc['db_query']('', ' |
|
| 1196 | + if ($upcontext['karma_installed']['bad']) { |
|
| 1197 | + $smcFunc['db_query']('', ' |
|
| 1130 | 1198 | ALTER TABLE {db_prefix}members |
| 1131 | 1199 | DROP karma_bad', |
| 1132 | 1200 | array() |
| 1133 | 1201 | ); |
| 1202 | + } |
|
| 1134 | 1203 | |
| 1135 | 1204 | // Cleaning up old karma permissions. |
| 1136 | 1205 | $smcFunc['db_query']('', ' |
@@ -1148,32 +1217,37 @@ discard block |
||
| 1148 | 1217 | } |
| 1149 | 1218 | |
| 1150 | 1219 | // Emptying the error log? |
| 1151 | - if (!empty($_POST['empty_error'])) |
|
| 1152 | - $smcFunc['db_query']('truncate_table', ' |
|
| 1220 | + if (!empty($_POST['empty_error'])) { |
|
| 1221 | + $smcFunc['db_query']('truncate_table', ' |
|
| 1153 | 1222 | TRUNCATE {db_prefix}log_errors', |
| 1154 | 1223 | array( |
| 1155 | 1224 | ) |
| 1156 | 1225 | ); |
| 1226 | + } |
|
| 1157 | 1227 | |
| 1158 | 1228 | $changes = array(); |
| 1159 | 1229 | |
| 1160 | 1230 | // Add proxy settings. |
| 1161 | - if (!isset($GLOBALS['image_proxy_maxsize'])) |
|
| 1162 | - $changes += array( |
|
| 1231 | + if (!isset($GLOBALS['image_proxy_maxsize'])) { |
|
| 1232 | + $changes += array( |
|
| 1163 | 1233 | 'image_proxy_secret' => '\'' . substr(sha1(mt_rand()), 0, 20) . '\'', |
| 1164 | 1234 | 'image_proxy_maxsize' => 5190, |
| 1165 | 1235 | 'image_proxy_enabled' => 0, |
| 1166 | 1236 | ); |
| 1237 | + } |
|
| 1167 | 1238 | |
| 1168 | 1239 | // If $boardurl reflects https, set force_ssl |
| 1169 | - if (!function_exists('cache_put_data')) |
|
| 1170 | - require_once($sourcedir . '/Load.php'); |
|
| 1171 | - if (stripos($boardurl, 'https://') !== false) |
|
| 1172 | - updateSettings(array('force_ssl' => '1')); |
|
| 1240 | + if (!function_exists('cache_put_data')) { |
|
| 1241 | + require_once($sourcedir . '/Load.php'); |
|
| 1242 | + } |
|
| 1243 | + if (stripos($boardurl, 'https://') !== false) { |
|
| 1244 | + updateSettings(array('force_ssl' => '1')); |
|
| 1245 | + } |
|
| 1173 | 1246 | |
| 1174 | 1247 | // If we're overriding the language follow it through. |
| 1175 | - if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) |
|
| 1176 | - $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
| 1248 | + if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) { |
|
| 1249 | + $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
| 1250 | + } |
|
| 1177 | 1251 | |
| 1178 | 1252 | if (!empty($_POST['maint'])) |
| 1179 | 1253 | { |
@@ -1185,26 +1259,29 @@ discard block |
||
| 1185 | 1259 | { |
| 1186 | 1260 | $changes['mtitle'] = '\'' . addslashes($_POST['maintitle']) . '\''; |
| 1187 | 1261 | $changes['mmessage'] = '\'' . addslashes($_POST['mainmessage']) . '\''; |
| 1188 | - } |
|
| 1189 | - else |
|
| 1262 | + } else |
|
| 1190 | 1263 | { |
| 1191 | 1264 | $changes['mtitle'] = '\'Upgrading the forum...\''; |
| 1192 | 1265 | $changes['mmessage'] = '\'Don\\\'t worry, we will be back shortly with an updated forum. It will only be a minute ;).\''; |
| 1193 | 1266 | } |
| 1194 | 1267 | } |
| 1195 | 1268 | |
| 1196 | - if ($command_line) |
|
| 1197 | - echo ' * Updating Settings.php...'; |
|
| 1269 | + if ($command_line) { |
|
| 1270 | + echo ' * Updating Settings.php...'; |
|
| 1271 | + } |
|
| 1198 | 1272 | |
| 1199 | 1273 | // Fix some old paths. |
| 1200 | - if (substr($boarddir, 0, 1) == '.') |
|
| 1201 | - $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
| 1274 | + if (substr($boarddir, 0, 1) == '.') { |
|
| 1275 | + $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
| 1276 | + } |
|
| 1202 | 1277 | |
| 1203 | - if (substr($sourcedir, 0, 1) == '.') |
|
| 1204 | - $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
| 1278 | + if (substr($sourcedir, 0, 1) == '.') { |
|
| 1279 | + $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
| 1280 | + } |
|
| 1205 | 1281 | |
| 1206 | - if (empty($cachedir) || substr($cachedir, 0, 1) == '.') |
|
| 1207 | - $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
| 1282 | + if (empty($cachedir) || substr($cachedir, 0, 1) == '.') { |
|
| 1283 | + $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
| 1284 | + } |
|
| 1208 | 1285 | |
| 1209 | 1286 | // If they have a "host:port" setup for the host, split that into separate values |
| 1210 | 1287 | // You should never have a : in the hostname if you're not on MySQL, but better safe than sorry |
@@ -1215,32 +1292,36 @@ discard block |
||
| 1215 | 1292 | $changes['db_server'] = '\'' . $db_server . '\''; |
| 1216 | 1293 | |
| 1217 | 1294 | // Only set this if we're not using the default port |
| 1218 | - if ($db_port != ini_get('mysqli.default_port')) |
|
| 1219 | - $changes['db_port'] = (int) $db_port; |
|
| 1220 | - } |
|
| 1221 | - elseif (!empty($db_port)) |
|
| 1295 | + if ($db_port != ini_get('mysqli.default_port')) { |
|
| 1296 | + $changes['db_port'] = (int) $db_port; |
|
| 1297 | + } |
|
| 1298 | + } elseif (!empty($db_port)) |
|
| 1222 | 1299 | { |
| 1223 | 1300 | // If db_port is set and is the same as the default, set it to '' |
| 1224 | 1301 | if ($db_type == 'mysql') |
| 1225 | 1302 | { |
| 1226 | - if ($db_port == ini_get('mysqli.default_port')) |
|
| 1227 | - $changes['db_port'] = '\'\''; |
|
| 1228 | - elseif ($db_type == 'postgresql' && $db_port == 5432) |
|
| 1229 | - $changes['db_port'] = '\'\''; |
|
| 1303 | + if ($db_port == ini_get('mysqli.default_port')) { |
|
| 1304 | + $changes['db_port'] = '\'\''; |
|
| 1305 | + } elseif ($db_type == 'postgresql' && $db_port == 5432) { |
|
| 1306 | + $changes['db_port'] = '\'\''; |
|
| 1307 | + } |
|
| 1230 | 1308 | } |
| 1231 | 1309 | } |
| 1232 | 1310 | |
| 1233 | 1311 | // Maybe we haven't had this option yet? |
| 1234 | - if (empty($packagesdir)) |
|
| 1235 | - $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
| 1312 | + if (empty($packagesdir)) { |
|
| 1313 | + $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
| 1314 | + } |
|
| 1236 | 1315 | |
| 1237 | 1316 | // Add support for $tasksdir var. |
| 1238 | - if (empty($tasksdir)) |
|
| 1239 | - $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
| 1317 | + if (empty($tasksdir)) { |
|
| 1318 | + $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
| 1319 | + } |
|
| 1240 | 1320 | |
| 1241 | 1321 | // Make sure we fix the language as well. |
| 1242 | - if (stristr($language, '-utf8')) |
|
| 1243 | - $changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\''; |
|
| 1322 | + if (stristr($language, '-utf8')) { |
|
| 1323 | + $changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\''; |
|
| 1324 | + } |
|
| 1244 | 1325 | |
| 1245 | 1326 | // @todo Maybe change the cookie name if going to 1.1, too? |
| 1246 | 1327 | |
@@ -1251,8 +1332,9 @@ discard block |
||
| 1251 | 1332 | // Tell Settings.php to store db_last_error.php in the cache |
| 1252 | 1333 | move_db_last_error_to_cachedir(); |
| 1253 | 1334 | |
| 1254 | - if ($command_line) |
|
| 1255 | - echo ' Successful.' . "\n"; |
|
| 1335 | + if ($command_line) { |
|
| 1336 | + echo ' Successful.' . "\n"; |
|
| 1337 | + } |
|
| 1256 | 1338 | |
| 1257 | 1339 | // Are we doing debug? |
| 1258 | 1340 | if (isset($_POST['debug'])) |
@@ -1262,8 +1344,9 @@ discard block |
||
| 1262 | 1344 | } |
| 1263 | 1345 | |
| 1264 | 1346 | // If we're not backing up then jump one. |
| 1265 | - if (empty($_POST['backup'])) |
|
| 1266 | - $upcontext['current_step']++; |
|
| 1347 | + if (empty($_POST['backup'])) { |
|
| 1348 | + $upcontext['current_step']++; |
|
| 1349 | + } |
|
| 1267 | 1350 | |
| 1268 | 1351 | // If we've got here then let's proceed to the next step! |
| 1269 | 1352 | return true; |
@@ -1278,8 +1361,9 @@ discard block |
||
| 1278 | 1361 | $upcontext['page_title'] = $txt['backup_database']; |
| 1279 | 1362 | |
| 1280 | 1363 | // Done it already - js wise? |
| 1281 | - if (!empty($_POST['backup_done'])) |
|
| 1282 | - return true; |
|
| 1364 | + if (!empty($_POST['backup_done'])) { |
|
| 1365 | + return true; |
|
| 1366 | + } |
|
| 1283 | 1367 | |
| 1284 | 1368 | // Some useful stuff here. |
| 1285 | 1369 | db_extend(); |
@@ -1293,9 +1377,10 @@ discard block |
||
| 1293 | 1377 | $tables = $smcFunc['db_list_tables']($db, $filter); |
| 1294 | 1378 | |
| 1295 | 1379 | $table_names = array(); |
| 1296 | - foreach ($tables as $table) |
|
| 1297 | - if (substr($table, 0, 7) !== 'backup_') |
|
| 1380 | + foreach ($tables as $table) { |
|
| 1381 | + if (substr($table, 0, 7) !== 'backup_') |
|
| 1298 | 1382 | $table_names[] = $table; |
| 1383 | + } |
|
| 1299 | 1384 | |
| 1300 | 1385 | $upcontext['table_count'] = count($table_names); |
| 1301 | 1386 | $upcontext['cur_table_num'] = $_GET['substep']; |
@@ -1305,12 +1390,14 @@ discard block |
||
| 1305 | 1390 | $file_steps = $upcontext['table_count']; |
| 1306 | 1391 | |
| 1307 | 1392 | // What ones have we already done? |
| 1308 | - foreach ($table_names as $id => $table) |
|
| 1309 | - if ($id < $_GET['substep']) |
|
| 1393 | + foreach ($table_names as $id => $table) { |
|
| 1394 | + if ($id < $_GET['substep']) |
|
| 1310 | 1395 | $upcontext['previous_tables'][] = $table; |
| 1396 | + } |
|
| 1311 | 1397 | |
| 1312 | - if ($command_line) |
|
| 1313 | - echo 'Backing Up Tables.'; |
|
| 1398 | + if ($command_line) { |
|
| 1399 | + echo 'Backing Up Tables.'; |
|
| 1400 | + } |
|
| 1314 | 1401 | |
| 1315 | 1402 | // If we don't support javascript we backup here. |
| 1316 | 1403 | if (!$support_js || isset($_GET['xml'])) |
@@ -1329,8 +1416,9 @@ discard block |
||
| 1329 | 1416 | backupTable($table_names[$substep]); |
| 1330 | 1417 | |
| 1331 | 1418 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 1332 | - if (isset($_GET['xml'])) |
|
| 1333 | - return upgradeExit(); |
|
| 1419 | + if (isset($_GET['xml'])) { |
|
| 1420 | + return upgradeExit(); |
|
| 1421 | + } |
|
| 1334 | 1422 | } |
| 1335 | 1423 | |
| 1336 | 1424 | if ($command_line) |
@@ -1363,9 +1451,10 @@ discard block |
||
| 1363 | 1451 | |
| 1364 | 1452 | $smcFunc['db_backup_table']($table, 'backup_' . $table); |
| 1365 | 1453 | |
| 1366 | - if ($command_line) |
|
| 1367 | - echo ' done.'; |
|
| 1368 | -} |
|
| 1454 | + if ($command_line) { |
|
| 1455 | + echo ' done.'; |
|
| 1456 | + } |
|
| 1457 | + } |
|
| 1369 | 1458 | |
| 1370 | 1459 | // Step 2: Everything. |
| 1371 | 1460 | function DatabaseChanges() |
@@ -1374,8 +1463,9 @@ discard block |
||
| 1374 | 1463 | global $upcontext, $support_js, $db_type; |
| 1375 | 1464 | |
| 1376 | 1465 | // Have we just completed this? |
| 1377 | - if (!empty($_POST['database_done'])) |
|
| 1378 | - return true; |
|
| 1466 | + if (!empty($_POST['database_done'])) { |
|
| 1467 | + return true; |
|
| 1468 | + } |
|
| 1379 | 1469 | |
| 1380 | 1470 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'database_xml' : 'database_changes'; |
| 1381 | 1471 | $upcontext['page_title'] = $txt['database_changes']; |
@@ -1390,15 +1480,16 @@ discard block |
||
| 1390 | 1480 | ); |
| 1391 | 1481 | |
| 1392 | 1482 | // How many files are there in total? |
| 1393 | - if (isset($_GET['filecount'])) |
|
| 1394 | - $upcontext['file_count'] = (int) $_GET['filecount']; |
|
| 1395 | - else |
|
| 1483 | + if (isset($_GET['filecount'])) { |
|
| 1484 | + $upcontext['file_count'] = (int) $_GET['filecount']; |
|
| 1485 | + } else |
|
| 1396 | 1486 | { |
| 1397 | 1487 | $upcontext['file_count'] = 0; |
| 1398 | 1488 | foreach ($files as $file) |
| 1399 | 1489 | { |
| 1400 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) |
|
| 1401 | - $upcontext['file_count']++; |
|
| 1490 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) { |
|
| 1491 | + $upcontext['file_count']++; |
|
| 1492 | + } |
|
| 1402 | 1493 | } |
| 1403 | 1494 | } |
| 1404 | 1495 | |
@@ -1408,9 +1499,9 @@ discard block |
||
| 1408 | 1499 | $upcontext['cur_file_num'] = 0; |
| 1409 | 1500 | foreach ($files as $file) |
| 1410 | 1501 | { |
| 1411 | - if ($did_not_do) |
|
| 1412 | - $did_not_do--; |
|
| 1413 | - else |
|
| 1502 | + if ($did_not_do) { |
|
| 1503 | + $did_not_do--; |
|
| 1504 | + } else |
|
| 1414 | 1505 | { |
| 1415 | 1506 | $upcontext['cur_file_num']++; |
| 1416 | 1507 | $upcontext['cur_file_name'] = $file[0]; |
@@ -1437,12 +1528,13 @@ discard block |
||
| 1437 | 1528 | // Flag to move on to the next. |
| 1438 | 1529 | $upcontext['completed_step'] = true; |
| 1439 | 1530 | // Did we complete the whole file? |
| 1440 | - if ($nextFile) |
|
| 1441 | - $upcontext['current_debug_item_num'] = -1; |
|
| 1531 | + if ($nextFile) { |
|
| 1532 | + $upcontext['current_debug_item_num'] = -1; |
|
| 1533 | + } |
|
| 1442 | 1534 | return upgradeExit(); |
| 1535 | + } elseif ($support_js) { |
|
| 1536 | + break; |
|
| 1443 | 1537 | } |
| 1444 | - elseif ($support_js) |
|
| 1445 | - break; |
|
| 1446 | 1538 | } |
| 1447 | 1539 | // Set the progress bar to be right as if we had - even if we hadn't... |
| 1448 | 1540 | $upcontext['step_progress'] = ($upcontext['cur_file_num'] / $upcontext['file_count']) * 100; |
@@ -1468,8 +1560,9 @@ discard block |
||
| 1468 | 1560 | global $user_info, $maintenance, $smcFunc, $db_type, $txt; |
| 1469 | 1561 | |
| 1470 | 1562 | // Now it's nice to have some of the basic SMF source files. |
| 1471 | - if (!isset($_GET['ssi']) && !$command_line) |
|
| 1472 | - redirectLocation('&ssi=1'); |
|
| 1563 | + if (!isset($_GET['ssi']) && !$command_line) { |
|
| 1564 | + redirectLocation('&ssi=1'); |
|
| 1565 | + } |
|
| 1473 | 1566 | |
| 1474 | 1567 | $upcontext['sub_template'] = 'upgrade_complete'; |
| 1475 | 1568 | $upcontext['page_title'] = $txt['upgrade_complete']; |
@@ -1485,14 +1578,16 @@ discard block |
||
| 1485 | 1578 | // Are we in maintenance mode? |
| 1486 | 1579 | if (isset($upcontext['user']['main'])) |
| 1487 | 1580 | { |
| 1488 | - if ($command_line) |
|
| 1489 | - echo ' * '; |
|
| 1581 | + if ($command_line) { |
|
| 1582 | + echo ' * '; |
|
| 1583 | + } |
|
| 1490 | 1584 | $upcontext['removed_maintenance'] = true; |
| 1491 | 1585 | $changes['maintenance'] = $upcontext['user']['main']; |
| 1492 | 1586 | } |
| 1493 | 1587 | // Otherwise if somehow we are in 2 let's go to 1. |
| 1494 | - elseif (!empty($maintenance) && $maintenance == 2) |
|
| 1495 | - $changes['maintenance'] = 1; |
|
| 1588 | + elseif (!empty($maintenance) && $maintenance == 2) { |
|
| 1589 | + $changes['maintenance'] = 1; |
|
| 1590 | + } |
|
| 1496 | 1591 | |
| 1497 | 1592 | // Wipe this out... |
| 1498 | 1593 | $upcontext['user'] = array(); |
@@ -1507,9 +1602,9 @@ discard block |
||
| 1507 | 1602 | $upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__); |
| 1508 | 1603 | |
| 1509 | 1604 | // Now is the perfect time to fetch the SM files. |
| 1510 | - if ($command_line) |
|
| 1511 | - cli_scheduled_fetchSMfiles(); |
|
| 1512 | - else |
|
| 1605 | + if ($command_line) { |
|
| 1606 | + cli_scheduled_fetchSMfiles(); |
|
| 1607 | + } else |
|
| 1513 | 1608 | { |
| 1514 | 1609 | require_once($sourcedir . '/ScheduledTasks.php'); |
| 1515 | 1610 | $forum_version = SMF_VERSION; // The variable is usually defined in index.php so lets just use the constant to do it for us. |
@@ -1517,8 +1612,9 @@ discard block |
||
| 1517 | 1612 | } |
| 1518 | 1613 | |
| 1519 | 1614 | // Log what we've done. |
| 1520 | - if (empty($user_info['id'])) |
|
| 1521 | - $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
| 1615 | + if (empty($user_info['id'])) { |
|
| 1616 | + $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
| 1617 | + } |
|
| 1522 | 1618 | |
| 1523 | 1619 | // Log the action manually, so CLI still works. |
| 1524 | 1620 | $smcFunc['db_insert']('', |
@@ -1537,8 +1633,9 @@ discard block |
||
| 1537 | 1633 | |
| 1538 | 1634 | // Save the current database version. |
| 1539 | 1635 | $server_version = $smcFunc['db_server_info'](); |
| 1540 | - if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
| 1541 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1636 | + if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
| 1637 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1638 | + } |
|
| 1542 | 1639 | |
| 1543 | 1640 | if ($command_line) |
| 1544 | 1641 | { |
@@ -1550,8 +1647,9 @@ discard block |
||
| 1550 | 1647 | |
| 1551 | 1648 | // Make sure it says we're done. |
| 1552 | 1649 | $upcontext['overall_percent'] = 100; |
| 1553 | - if (isset($upcontext['step_progress'])) |
|
| 1554 | - unset($upcontext['step_progress']); |
|
| 1650 | + if (isset($upcontext['step_progress'])) { |
|
| 1651 | + unset($upcontext['step_progress']); |
|
| 1652 | + } |
|
| 1555 | 1653 | |
| 1556 | 1654 | $_GET['substep'] = 0; |
| 1557 | 1655 | return false; |
@@ -1562,8 +1660,9 @@ discard block |
||
| 1562 | 1660 | { |
| 1563 | 1661 | global $sourcedir, $language, $forum_version, $modSettings, $smcFunc; |
| 1564 | 1662 | |
| 1565 | - if (empty($modSettings['time_format'])) |
|
| 1566 | - $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
| 1663 | + if (empty($modSettings['time_format'])) { |
|
| 1664 | + $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
| 1665 | + } |
|
| 1567 | 1666 | |
| 1568 | 1667 | // What files do we want to get |
| 1569 | 1668 | $request = $smcFunc['db_query']('', ' |
@@ -1597,8 +1696,9 @@ discard block |
||
| 1597 | 1696 | $file_data = fetch_web_data($url); |
| 1598 | 1697 | |
| 1599 | 1698 | // If we got an error - give up - the site might be down. |
| 1600 | - if ($file_data === false) |
|
| 1601 | - return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
| 1699 | + if ($file_data === false) { |
|
| 1700 | + return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
| 1701 | + } |
|
| 1602 | 1702 | |
| 1603 | 1703 | // Save the file to the database. |
| 1604 | 1704 | $smcFunc['db_query']('substring', ' |
@@ -1640,8 +1740,9 @@ discard block |
||
| 1640 | 1740 | $themeData = array(); |
| 1641 | 1741 | foreach ($values as $variable => $value) |
| 1642 | 1742 | { |
| 1643 | - if (!isset($value) || $value === null) |
|
| 1644 | - $value = 0; |
|
| 1743 | + if (!isset($value) || $value === null) { |
|
| 1744 | + $value = 0; |
|
| 1745 | + } |
|
| 1645 | 1746 | |
| 1646 | 1747 | $themeData[] = array(0, 1, $variable, $value); |
| 1647 | 1748 | } |
@@ -1670,8 +1771,9 @@ discard block |
||
| 1670 | 1771 | |
| 1671 | 1772 | foreach ($values as $variable => $value) |
| 1672 | 1773 | { |
| 1673 | - if (empty($modSettings[$value[0]])) |
|
| 1674 | - continue; |
|
| 1774 | + if (empty($modSettings[$value[0]])) { |
|
| 1775 | + continue; |
|
| 1776 | + } |
|
| 1675 | 1777 | |
| 1676 | 1778 | $smcFunc['db_query']('', ' |
| 1677 | 1779 | INSERT IGNORE INTO {db_prefix}themes |
@@ -1757,19 +1859,21 @@ discard block |
||
| 1757 | 1859 | set_error_handler( |
| 1758 | 1860 | function ($errno, $errstr, $errfile, $errline) use ($support_js) |
| 1759 | 1861 | { |
| 1760 | - if ($support_js) |
|
| 1761 | - return true; |
|
| 1762 | - else |
|
| 1763 | - echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
| 1862 | + if ($support_js) { |
|
| 1863 | + return true; |
|
| 1864 | + } else { |
|
| 1865 | + echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
| 1866 | + } |
|
| 1764 | 1867 | } |
| 1765 | 1868 | ); |
| 1766 | 1869 | |
| 1767 | 1870 | // If we're on MySQL, set {db_collation}; this approach is used throughout upgrade_2-0_mysql.php to set new tables to utf8 |
| 1768 | 1871 | // Note it is expected to be in the format: ENGINE=MyISAM{$db_collation}; |
| 1769 | - if ($db_type == 'mysql') |
|
| 1770 | - $db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
| 1771 | - else |
|
| 1772 | - $db_collation = ''; |
|
| 1872 | + if ($db_type == 'mysql') { |
|
| 1873 | + $db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
| 1874 | + } else { |
|
| 1875 | + $db_collation = ''; |
|
| 1876 | + } |
|
| 1773 | 1877 | |
| 1774 | 1878 | $endl = $command_line ? "\n" : '<br>' . "\n"; |
| 1775 | 1879 | |
@@ -1781,8 +1885,9 @@ discard block |
||
| 1781 | 1885 | $last_step = ''; |
| 1782 | 1886 | |
| 1783 | 1887 | // Make sure all newly created tables will have the proper characters set; this approach is used throughout upgrade_2-1_mysql.php |
| 1784 | - if (isset($db_character_set) && $db_character_set === 'utf8') |
|
| 1785 | - $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
| 1888 | + if (isset($db_character_set) && $db_character_set === 'utf8') { |
|
| 1889 | + $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
| 1890 | + } |
|
| 1786 | 1891 | |
| 1787 | 1892 | // Count the total number of steps within this file - for progress. |
| 1788 | 1893 | $file_steps = substr_count(implode('', $lines), '---#'); |
@@ -1802,15 +1907,18 @@ discard block |
||
| 1802 | 1907 | $do_current = $substep >= $_GET['substep']; |
| 1803 | 1908 | |
| 1804 | 1909 | // Get rid of any comments in the beginning of the line... |
| 1805 | - if (substr(trim($line), 0, 2) === '/*') |
|
| 1806 | - $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
| 1910 | + if (substr(trim($line), 0, 2) === '/*') { |
|
| 1911 | + $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
| 1912 | + } |
|
| 1807 | 1913 | |
| 1808 | 1914 | // Always flush. Flush, flush, flush. Flush, flush, flush, flush! FLUSH! |
| 1809 | - if ($is_debug && !$support_js && $command_line) |
|
| 1810 | - flush(); |
|
| 1915 | + if ($is_debug && !$support_js && $command_line) { |
|
| 1916 | + flush(); |
|
| 1917 | + } |
|
| 1811 | 1918 | |
| 1812 | - if (trim($line) === '') |
|
| 1813 | - continue; |
|
| 1919 | + if (trim($line) === '') { |
|
| 1920 | + continue; |
|
| 1921 | + } |
|
| 1814 | 1922 | |
| 1815 | 1923 | if (trim(substr($line, 0, 3)) === '---') |
| 1816 | 1924 | { |
@@ -1820,8 +1928,9 @@ discard block |
||
| 1820 | 1928 | if (trim($current_data) != '' && $type !== '}') |
| 1821 | 1929 | { |
| 1822 | 1930 | $upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl; |
| 1823 | - if ($command_line) |
|
| 1824 | - echo $upcontext['error_message']; |
|
| 1931 | + if ($command_line) { |
|
| 1932 | + echo $upcontext['error_message']; |
|
| 1933 | + } |
|
| 1825 | 1934 | } |
| 1826 | 1935 | |
| 1827 | 1936 | if ($type == ' ') |
@@ -1839,17 +1948,18 @@ discard block |
||
| 1839 | 1948 | if ($do_current) |
| 1840 | 1949 | { |
| 1841 | 1950 | $upcontext['actioned_items'][] = $last_step; |
| 1842 | - if ($command_line) |
|
| 1843 | - echo ' * '; |
|
| 1951 | + if ($command_line) { |
|
| 1952 | + echo ' * '; |
|
| 1953 | + } |
|
| 1844 | 1954 | } |
| 1845 | - } |
|
| 1846 | - elseif ($type == '#') |
|
| 1955 | + } elseif ($type == '#') |
|
| 1847 | 1956 | { |
| 1848 | 1957 | $upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps; |
| 1849 | 1958 | |
| 1850 | 1959 | $upcontext['current_debug_item_num']++; |
| 1851 | - if (trim($line) != '---#') |
|
| 1852 | - $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1960 | + if (trim($line) != '---#') { |
|
| 1961 | + $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1962 | + } |
|
| 1853 | 1963 | |
| 1854 | 1964 | // Have we already done something? |
| 1855 | 1965 | if (isset($_GET['xml']) && $done_something) |
@@ -1860,34 +1970,36 @@ discard block |
||
| 1860 | 1970 | |
| 1861 | 1971 | if ($do_current) |
| 1862 | 1972 | { |
| 1863 | - if (trim($line) == '---#' && $command_line) |
|
| 1864 | - echo ' done.', $endl; |
|
| 1865 | - elseif ($command_line) |
|
| 1866 | - echo ' +++ ', rtrim(substr($line, 4)); |
|
| 1867 | - elseif (trim($line) != '---#') |
|
| 1973 | + if (trim($line) == '---#' && $command_line) { |
|
| 1974 | + echo ' done.', $endl; |
|
| 1975 | + } elseif ($command_line) { |
|
| 1976 | + echo ' +++ ', rtrim(substr($line, 4)); |
|
| 1977 | + } elseif (trim($line) != '---#') |
|
| 1868 | 1978 | { |
| 1869 | - if ($is_debug) |
|
| 1870 | - $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1979 | + if ($is_debug) { |
|
| 1980 | + $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1981 | + } |
|
| 1871 | 1982 | } |
| 1872 | 1983 | } |
| 1873 | 1984 | |
| 1874 | 1985 | if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep']) |
| 1875 | 1986 | { |
| 1876 | - if ($command_line) |
|
| 1877 | - echo ' * '; |
|
| 1878 | - else |
|
| 1879 | - $upcontext['actioned_items'][] = $last_step; |
|
| 1987 | + if ($command_line) { |
|
| 1988 | + echo ' * '; |
|
| 1989 | + } else { |
|
| 1990 | + $upcontext['actioned_items'][] = $last_step; |
|
| 1991 | + } |
|
| 1880 | 1992 | } |
| 1881 | 1993 | |
| 1882 | 1994 | // Small step - only if we're actually doing stuff. |
| 1883 | - if ($do_current) |
|
| 1884 | - nextSubstep(++$substep); |
|
| 1885 | - else |
|
| 1886 | - $substep++; |
|
| 1887 | - } |
|
| 1888 | - elseif ($type == '{') |
|
| 1889 | - $current_type = 'code'; |
|
| 1890 | - elseif ($type == '}') |
|
| 1995 | + if ($do_current) { |
|
| 1996 | + nextSubstep(++$substep); |
|
| 1997 | + } else { |
|
| 1998 | + $substep++; |
|
| 1999 | + } |
|
| 2000 | + } elseif ($type == '{') { |
|
| 2001 | + $current_type = 'code'; |
|
| 2002 | + } elseif ($type == '}') |
|
| 1891 | 2003 | { |
| 1892 | 2004 | $current_type = 'sql'; |
| 1893 | 2005 | |
@@ -1900,8 +2012,9 @@ discard block |
||
| 1900 | 2012 | if (eval('global $db_prefix, $modSettings, $smcFunc; ' . $current_data) === false) |
| 1901 | 2013 | { |
| 1902 | 2014 | $upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl; |
| 1903 | - if ($command_line) |
|
| 1904 | - echo $upcontext['error_message']; |
|
| 2015 | + if ($command_line) { |
|
| 2016 | + echo $upcontext['error_message']; |
|
| 2017 | + } |
|
| 1905 | 2018 | } |
| 1906 | 2019 | |
| 1907 | 2020 | // Done with code! |
@@ -1988,8 +2101,9 @@ discard block |
||
| 1988 | 2101 | $db_unbuffered = false; |
| 1989 | 2102 | |
| 1990 | 2103 | // Failure?! |
| 1991 | - if ($result !== false) |
|
| 1992 | - return $result; |
|
| 2104 | + if ($result !== false) { |
|
| 2105 | + return $result; |
|
| 2106 | + } |
|
| 1993 | 2107 | |
| 1994 | 2108 | $db_error_message = $smcFunc['db_error']($db_connection); |
| 1995 | 2109 | // If MySQL we do something more clever. |
@@ -2017,54 +2131,61 @@ discard block |
||
| 2017 | 2131 | { |
| 2018 | 2132 | mysqli_query($db_connection, 'REPAIR TABLE `' . $match[1] . '`'); |
| 2019 | 2133 | $result = mysqli_query($db_connection, $string); |
| 2020 | - if ($result !== false) |
|
| 2021 | - return $result; |
|
| 2134 | + if ($result !== false) { |
|
| 2135 | + return $result; |
|
| 2136 | + } |
|
| 2022 | 2137 | } |
| 2023 | - } |
|
| 2024 | - elseif ($mysqli_errno == 2013) |
|
| 2138 | + } elseif ($mysqli_errno == 2013) |
|
| 2025 | 2139 | { |
| 2026 | 2140 | $db_connection = mysqli_connect($db_server, $db_user, $db_passwd); |
| 2027 | 2141 | mysqli_select_db($db_connection, $db_name); |
| 2028 | 2142 | if ($db_connection) |
| 2029 | 2143 | { |
| 2030 | 2144 | $result = mysqli_query($db_connection, $string); |
| 2031 | - if ($result !== false) |
|
| 2032 | - return $result; |
|
| 2145 | + if ($result !== false) { |
|
| 2146 | + return $result; |
|
| 2147 | + } |
|
| 2033 | 2148 | } |
| 2034 | 2149 | } |
| 2035 | 2150 | // Duplicate column name... should be okay ;). |
| 2036 | - elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) |
|
| 2037 | - return false; |
|
| 2151 | + elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) { |
|
| 2152 | + return false; |
|
| 2153 | + } |
|
| 2038 | 2154 | // Duplicate insert... make sure it's the proper type of query ;). |
| 2039 | - elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) |
|
| 2040 | - return false; |
|
| 2155 | + elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) { |
|
| 2156 | + return false; |
|
| 2157 | + } |
|
| 2041 | 2158 | // Creating an index on a non-existent column. |
| 2042 | - elseif ($mysqli_errno == 1072) |
|
| 2043 | - return false; |
|
| 2044 | - elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') |
|
| 2045 | - return false; |
|
| 2159 | + elseif ($mysqli_errno == 1072) { |
|
| 2160 | + return false; |
|
| 2161 | + } elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') { |
|
| 2162 | + return false; |
|
| 2163 | + } |
|
| 2046 | 2164 | } |
| 2047 | 2165 | // If a table already exists don't go potty. |
| 2048 | 2166 | else |
| 2049 | 2167 | { |
| 2050 | 2168 | if (in_array(substr(trim($string), 0, 8), array('CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U'))) |
| 2051 | 2169 | { |
| 2052 | - if (strpos($db_error_message, 'exist') !== false) |
|
| 2053 | - return true; |
|
| 2054 | - } |
|
| 2055 | - elseif (strpos(trim($string), 'INSERT ') !== false) |
|
| 2170 | + if (strpos($db_error_message, 'exist') !== false) { |
|
| 2171 | + return true; |
|
| 2172 | + } |
|
| 2173 | + } elseif (strpos(trim($string), 'INSERT ') !== false) |
|
| 2056 | 2174 | { |
| 2057 | - if (strpos($db_error_message, 'duplicate') !== false || $ignore_insert_error) |
|
| 2058 | - return true; |
|
| 2175 | + if (strpos($db_error_message, 'duplicate') !== false || $ignore_insert_error) { |
|
| 2176 | + return true; |
|
| 2177 | + } |
|
| 2059 | 2178 | } |
| 2060 | 2179 | } |
| 2061 | 2180 | |
| 2062 | 2181 | // Get the query string so we pass everything. |
| 2063 | 2182 | $query_string = ''; |
| 2064 | - foreach ($_GET as $k => $v) |
|
| 2065 | - $query_string .= ';' . $k . '=' . $v; |
|
| 2066 | - if (strlen($query_string) != 0) |
|
| 2067 | - $query_string = '?' . substr($query_string, 1); |
|
| 2183 | + foreach ($_GET as $k => $v) { |
|
| 2184 | + $query_string .= ';' . $k . '=' . $v; |
|
| 2185 | + } |
|
| 2186 | + if (strlen($query_string) != 0) { |
|
| 2187 | + $query_string = '?' . substr($query_string, 1); |
|
| 2188 | + } |
|
| 2068 | 2189 | |
| 2069 | 2190 | if ($command_line) |
| 2070 | 2191 | { |
@@ -2119,16 +2240,18 @@ discard block |
||
| 2119 | 2240 | { |
| 2120 | 2241 | $found |= 1; |
| 2121 | 2242 | // Do some checks on the data if we have it set. |
| 2122 | - if (isset($change['col_type'])) |
|
| 2123 | - $found &= $change['col_type'] === $column['type']; |
|
| 2124 | - if (isset($change['null_allowed'])) |
|
| 2125 | - $found &= $column['null'] == $change['null_allowed']; |
|
| 2126 | - if (isset($change['default'])) |
|
| 2127 | - $found &= $change['default'] === $column['default']; |
|
| 2243 | + if (isset($change['col_type'])) { |
|
| 2244 | + $found &= $change['col_type'] === $column['type']; |
|
| 2245 | + } |
|
| 2246 | + if (isset($change['null_allowed'])) { |
|
| 2247 | + $found &= $column['null'] == $change['null_allowed']; |
|
| 2248 | + } |
|
| 2249 | + if (isset($change['default'])) { |
|
| 2250 | + $found &= $change['default'] === $column['default']; |
|
| 2251 | + } |
|
| 2128 | 2252 | } |
| 2129 | 2253 | } |
| 2130 | - } |
|
| 2131 | - elseif ($change['type'] === 'index') |
|
| 2254 | + } elseif ($change['type'] === 'index') |
|
| 2132 | 2255 | { |
| 2133 | 2256 | $request = upgrade_query(' |
| 2134 | 2257 | SHOW INDEX |
@@ -2137,9 +2260,10 @@ discard block |
||
| 2137 | 2260 | { |
| 2138 | 2261 | $cur_index = array(); |
| 2139 | 2262 | |
| 2140 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2141 | - if ($row['Key_name'] === $change['name']) |
|
| 2263 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2264 | + if ($row['Key_name'] === $change['name']) |
|
| 2142 | 2265 | $cur_index[(int) $row['Seq_in_index']] = $row['Column_name']; |
| 2266 | + } |
|
| 2143 | 2267 | |
| 2144 | 2268 | ksort($cur_index, SORT_NUMERIC); |
| 2145 | 2269 | $found = array_values($cur_index) === $change['target_columns']; |
@@ -2149,14 +2273,17 @@ discard block |
||
| 2149 | 2273 | } |
| 2150 | 2274 | |
| 2151 | 2275 | // If we're trying to add and it's added, we're done. |
| 2152 | - if ($found && in_array($change['method'], array('add', 'change'))) |
|
| 2153 | - return true; |
|
| 2276 | + if ($found && in_array($change['method'], array('add', 'change'))) { |
|
| 2277 | + return true; |
|
| 2278 | + } |
|
| 2154 | 2279 | // Otherwise if we're removing and it wasn't found we're also done. |
| 2155 | - elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) |
|
| 2156 | - return true; |
|
| 2280 | + elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) { |
|
| 2281 | + return true; |
|
| 2282 | + } |
|
| 2157 | 2283 | // Otherwise is it just a test? |
| 2158 | - elseif ($is_test) |
|
| 2159 | - return false; |
|
| 2284 | + elseif ($is_test) { |
|
| 2285 | + return false; |
|
| 2286 | + } |
|
| 2160 | 2287 | |
| 2161 | 2288 | // Not found it yet? Bummer! How about we see if we're currently doing it? |
| 2162 | 2289 | $running = false; |
@@ -2167,8 +2294,9 @@ discard block |
||
| 2167 | 2294 | SHOW FULL PROCESSLIST'); |
| 2168 | 2295 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2169 | 2296 | { |
| 2170 | - if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) |
|
| 2171 | - $found = true; |
|
| 2297 | + if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) { |
|
| 2298 | + $found = true; |
|
| 2299 | + } |
|
| 2172 | 2300 | } |
| 2173 | 2301 | |
| 2174 | 2302 | // Can't find it? Then we need to run it fools! |
@@ -2180,8 +2308,9 @@ discard block |
||
| 2180 | 2308 | ALTER TABLE ' . $db_prefix . $change['table'] . ' |
| 2181 | 2309 | ' . $change['text'], true) !== false; |
| 2182 | 2310 | |
| 2183 | - if (!$success) |
|
| 2184 | - return false; |
|
| 2311 | + if (!$success) { |
|
| 2312 | + return false; |
|
| 2313 | + } |
|
| 2185 | 2314 | |
| 2186 | 2315 | // Return |
| 2187 | 2316 | $running = true; |
@@ -2223,8 +2352,9 @@ discard block |
||
| 2223 | 2352 | 'db_error_skip' => true, |
| 2224 | 2353 | ) |
| 2225 | 2354 | ); |
| 2226 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 2227 | - die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
| 2355 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 2356 | + die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
| 2357 | + } |
|
| 2228 | 2358 | $table_row = $smcFunc['db_fetch_assoc']($request); |
| 2229 | 2359 | $smcFunc['db_free_result']($request); |
| 2230 | 2360 | |
@@ -2246,18 +2376,19 @@ discard block |
||
| 2246 | 2376 | ) |
| 2247 | 2377 | ); |
| 2248 | 2378 | // No results? Just forget it all together. |
| 2249 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 2250 | - unset($table_row['Collation']); |
|
| 2251 | - else |
|
| 2252 | - $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 2379 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 2380 | + unset($table_row['Collation']); |
|
| 2381 | + } else { |
|
| 2382 | + $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 2383 | + } |
|
| 2253 | 2384 | $smcFunc['db_free_result']($request); |
| 2254 | 2385 | } |
| 2255 | 2386 | |
| 2256 | 2387 | if ($column_fix) |
| 2257 | 2388 | { |
| 2258 | 2389 | // Make sure there are no NULL's left. |
| 2259 | - if ($null_fix) |
|
| 2260 | - $smcFunc['db_query']('', ' |
|
| 2390 | + if ($null_fix) { |
|
| 2391 | + $smcFunc['db_query']('', ' |
|
| 2261 | 2392 | UPDATE {db_prefix}' . $change['table'] . ' |
| 2262 | 2393 | SET ' . $change['column'] . ' = {string:default} |
| 2263 | 2394 | WHERE ' . $change['column'] . ' IS NULL', |
@@ -2266,6 +2397,7 @@ discard block |
||
| 2266 | 2397 | 'db_error_skip' => true, |
| 2267 | 2398 | ) |
| 2268 | 2399 | ); |
| 2400 | + } |
|
| 2269 | 2401 | |
| 2270 | 2402 | // Do the actual alteration. |
| 2271 | 2403 | $smcFunc['db_query']('', ' |
@@ -2294,8 +2426,9 @@ discard block |
||
| 2294 | 2426 | } |
| 2295 | 2427 | |
| 2296 | 2428 | // Not a column we need to check on? |
| 2297 | - if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) |
|
| 2298 | - return; |
|
| 2429 | + if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) { |
|
| 2430 | + return; |
|
| 2431 | + } |
|
| 2299 | 2432 | |
| 2300 | 2433 | // Break it up you (six|seven). |
| 2301 | 2434 | $temp = explode(' ', str_replace('NOT NULL', 'NOT_NULL', $change['text'])); |
@@ -2314,13 +2447,13 @@ discard block |
||
| 2314 | 2447 | 'new_name' => $temp[2], |
| 2315 | 2448 | )); |
| 2316 | 2449 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
| 2317 | - if ($smcFunc['db_num_rows'] != 1) |
|
| 2318 | - return; |
|
| 2450 | + if ($smcFunc['db_num_rows'] != 1) { |
|
| 2451 | + return; |
|
| 2452 | + } |
|
| 2319 | 2453 | |
| 2320 | 2454 | list (, $current_type) = $smcFunc['db_fetch_assoc']($request); |
| 2321 | 2455 | $smcFunc['db_free_result']($request); |
| 2322 | - } |
|
| 2323 | - else |
|
| 2456 | + } else |
|
| 2324 | 2457 | { |
| 2325 | 2458 | // Do this the old fashion, sure method way. |
| 2326 | 2459 | $request = $smcFunc['db_query']('', ' |
@@ -2331,21 +2464,24 @@ discard block |
||
| 2331 | 2464 | )); |
| 2332 | 2465 | // Mayday! |
| 2333 | 2466 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
| 2334 | - if ($smcFunc['db_num_rows'] == 0) |
|
| 2335 | - return; |
|
| 2467 | + if ($smcFunc['db_num_rows'] == 0) { |
|
| 2468 | + return; |
|
| 2469 | + } |
|
| 2336 | 2470 | |
| 2337 | 2471 | // Oh where, oh where has my little field gone. Oh where can it be... |
| 2338 | - while ($row = $smcFunc['db_query']($request)) |
|
| 2339 | - if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
| 2472 | + while ($row = $smcFunc['db_query']($request)) { |
|
| 2473 | + if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
| 2340 | 2474 | { |
| 2341 | 2475 | $current_type = $row['Type']; |
| 2476 | + } |
|
| 2342 | 2477 | break; |
| 2343 | 2478 | } |
| 2344 | 2479 | } |
| 2345 | 2480 | |
| 2346 | 2481 | // If this doesn't match, the column may of been altered for a reason. |
| 2347 | - if (trim($current_type) != trim($temp[3])) |
|
| 2348 | - $temp[3] = $current_type; |
|
| 2482 | + if (trim($current_type) != trim($temp[3])) { |
|
| 2483 | + $temp[3] = $current_type; |
|
| 2484 | + } |
|
| 2349 | 2485 | |
| 2350 | 2486 | // Piece this back together. |
| 2351 | 2487 | $change['text'] = str_replace('NOT_NULL', 'NOT NULL', implode(' ', $temp)); |
@@ -2357,8 +2493,9 @@ discard block |
||
| 2357 | 2493 | global $start_time, $timeLimitThreshold, $command_line, $custom_warning; |
| 2358 | 2494 | global $step_progress, $is_debug, $upcontext; |
| 2359 | 2495 | |
| 2360 | - if ($_GET['substep'] < $substep) |
|
| 2361 | - $_GET['substep'] = $substep; |
|
| 2496 | + if ($_GET['substep'] < $substep) { |
|
| 2497 | + $_GET['substep'] = $substep; |
|
| 2498 | + } |
|
| 2362 | 2499 | |
| 2363 | 2500 | if ($command_line) |
| 2364 | 2501 | { |
@@ -2371,29 +2508,33 @@ discard block |
||
| 2371 | 2508 | } |
| 2372 | 2509 | |
| 2373 | 2510 | @set_time_limit(300); |
| 2374 | - if (function_exists('apache_reset_timeout')) |
|
| 2375 | - @apache_reset_timeout(); |
|
| 2511 | + if (function_exists('apache_reset_timeout')) { |
|
| 2512 | + @apache_reset_timeout(); |
|
| 2513 | + } |
|
| 2376 | 2514 | |
| 2377 | - if (time() - $start_time <= $timeLimitThreshold) |
|
| 2378 | - return; |
|
| 2515 | + if (time() - $start_time <= $timeLimitThreshold) { |
|
| 2516 | + return; |
|
| 2517 | + } |
|
| 2379 | 2518 | |
| 2380 | 2519 | // Do we have some custom step progress stuff? |
| 2381 | 2520 | if (!empty($step_progress)) |
| 2382 | 2521 | { |
| 2383 | 2522 | $upcontext['substep_progress'] = 0; |
| 2384 | 2523 | $upcontext['substep_progress_name'] = $step_progress['name']; |
| 2385 | - if ($step_progress['current'] > $step_progress['total']) |
|
| 2386 | - $upcontext['substep_progress'] = 99.9; |
|
| 2387 | - else |
|
| 2388 | - $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
| 2524 | + if ($step_progress['current'] > $step_progress['total']) { |
|
| 2525 | + $upcontext['substep_progress'] = 99.9; |
|
| 2526 | + } else { |
|
| 2527 | + $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
| 2528 | + } |
|
| 2389 | 2529 | |
| 2390 | 2530 | // Make it nicely rounded. |
| 2391 | 2531 | $upcontext['substep_progress'] = round($upcontext['substep_progress'], 1); |
| 2392 | 2532 | } |
| 2393 | 2533 | |
| 2394 | 2534 | // If this is XML we just exit right away! |
| 2395 | - if (isset($_GET['xml'])) |
|
| 2396 | - return upgradeExit(); |
|
| 2535 | + if (isset($_GET['xml'])) { |
|
| 2536 | + return upgradeExit(); |
|
| 2537 | + } |
|
| 2397 | 2538 | |
| 2398 | 2539 | // We're going to pause after this! |
| 2399 | 2540 | $upcontext['pause'] = true; |
@@ -2401,13 +2542,15 @@ discard block |
||
| 2401 | 2542 | $upcontext['query_string'] = ''; |
| 2402 | 2543 | foreach ($_GET as $k => $v) |
| 2403 | 2544 | { |
| 2404 | - if ($k != 'data' && $k != 'substep' && $k != 'step') |
|
| 2405 | - $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
| 2545 | + if ($k != 'data' && $k != 'substep' && $k != 'step') { |
|
| 2546 | + $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
| 2547 | + } |
|
| 2406 | 2548 | } |
| 2407 | 2549 | |
| 2408 | 2550 | // Custom warning? |
| 2409 | - if (!empty($custom_warning)) |
|
| 2410 | - $upcontext['custom_warning'] = $custom_warning; |
|
| 2551 | + if (!empty($custom_warning)) { |
|
| 2552 | + $upcontext['custom_warning'] = $custom_warning; |
|
| 2553 | + } |
|
| 2411 | 2554 | |
| 2412 | 2555 | upgradeExit(); |
| 2413 | 2556 | } |
@@ -2422,25 +2565,26 @@ discard block |
||
| 2422 | 2565 | ob_implicit_flush(true); |
| 2423 | 2566 | @set_time_limit(600); |
| 2424 | 2567 | |
| 2425 | - if (!isset($_SERVER['argv'])) |
|
| 2426 | - $_SERVER['argv'] = array(); |
|
| 2568 | + if (!isset($_SERVER['argv'])) { |
|
| 2569 | + $_SERVER['argv'] = array(); |
|
| 2570 | + } |
|
| 2427 | 2571 | $_GET['maint'] = 1; |
| 2428 | 2572 | |
| 2429 | 2573 | foreach ($_SERVER['argv'] as $i => $arg) |
| 2430 | 2574 | { |
| 2431 | - if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) |
|
| 2432 | - $_GET['lang'] = $match[1]; |
|
| 2433 | - elseif (preg_match('~^--path=(.+)$~', $arg) != 0) |
|
| 2434 | - continue; |
|
| 2435 | - elseif ($arg == '--no-maintenance') |
|
| 2436 | - $_GET['maint'] = 0; |
|
| 2437 | - elseif ($arg == '--debug') |
|
| 2438 | - $is_debug = true; |
|
| 2439 | - elseif ($arg == '--backup') |
|
| 2440 | - $_POST['backup'] = 1; |
|
| 2441 | - elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) |
|
| 2442 | - $_GET['conv'] = 1; |
|
| 2443 | - elseif ($i != 0) |
|
| 2575 | + if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) { |
|
| 2576 | + $_GET['lang'] = $match[1]; |
|
| 2577 | + } elseif (preg_match('~^--path=(.+)$~', $arg) != 0) { |
|
| 2578 | + continue; |
|
| 2579 | + } elseif ($arg == '--no-maintenance') { |
|
| 2580 | + $_GET['maint'] = 0; |
|
| 2581 | + } elseif ($arg == '--debug') { |
|
| 2582 | + $is_debug = true; |
|
| 2583 | + } elseif ($arg == '--backup') { |
|
| 2584 | + $_POST['backup'] = 1; |
|
| 2585 | + } elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) { |
|
| 2586 | + $_GET['conv'] = 1; |
|
| 2587 | + } elseif ($i != 0) |
|
| 2444 | 2588 | { |
| 2445 | 2589 | echo 'SMF Command-line Upgrader |
| 2446 | 2590 | Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]... |
@@ -2454,10 +2598,12 @@ discard block |
||
| 2454 | 2598 | } |
| 2455 | 2599 | } |
| 2456 | 2600 | |
| 2457 | - if (!php_version_check()) |
|
| 2458 | - print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
| 2459 | - if (!db_version_check()) |
|
| 2460 | - print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
| 2601 | + if (!php_version_check()) { |
|
| 2602 | + print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
| 2603 | + } |
|
| 2604 | + if (!db_version_check()) { |
|
| 2605 | + print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
| 2606 | + } |
|
| 2461 | 2607 | |
| 2462 | 2608 | // Do some checks to make sure they have proper privileges |
| 2463 | 2609 | db_extend('packages'); |
@@ -2472,34 +2618,39 @@ discard block |
||
| 2472 | 2618 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
| 2473 | 2619 | |
| 2474 | 2620 | // Sorry... we need CREATE, ALTER and DROP |
| 2475 | - if (!$create || !$alter || !$drop) |
|
| 2476 | - print_error("The " . $databases[$db_type]['name'] . " user you have set in Settings.php does not have proper privileges.\n\nPlease ask your host to give this user the ALTER, CREATE, and DROP privileges.", true); |
|
| 2621 | + if (!$create || !$alter || !$drop) { |
|
| 2622 | + print_error("The " . $databases[$db_type]['name'] . " user you have set in Settings.php does not have proper privileges.\n\nPlease ask your host to give this user the ALTER, CREATE, and DROP privileges.", true); |
|
| 2623 | + } |
|
| 2477 | 2624 | |
| 2478 | 2625 | $check = @file_exists($modSettings['theme_dir'] . '/index.template.php') |
| 2479 | 2626 | && @file_exists($sourcedir . '/QueryString.php') |
| 2480 | 2627 | && @file_exists($sourcedir . '/ManageBoards.php'); |
| 2481 | - if (!$check && !isset($modSettings['smfVersion'])) |
|
| 2482 | - print_error('Error: Some files are missing or out-of-date.', true); |
|
| 2628 | + if (!$check && !isset($modSettings['smfVersion'])) { |
|
| 2629 | + print_error('Error: Some files are missing or out-of-date.', true); |
|
| 2630 | + } |
|
| 2483 | 2631 | |
| 2484 | 2632 | // Do a quick version spot check. |
| 2485 | 2633 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
| 2486 | 2634 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
| 2487 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
| 2488 | - print_error('Error: Some files have not yet been updated properly.'); |
|
| 2635 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
| 2636 | + print_error('Error: Some files have not yet been updated properly.'); |
|
| 2637 | + } |
|
| 2489 | 2638 | |
| 2490 | 2639 | // Make sure Settings.php is writable. |
| 2491 | 2640 | quickFileWritable($boarddir . '/Settings.php'); |
| 2492 | - if (!is_writable($boarddir . '/Settings.php')) |
|
| 2493 | - print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
| 2641 | + if (!is_writable($boarddir . '/Settings.php')) { |
|
| 2642 | + print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
| 2643 | + } |
|
| 2494 | 2644 | |
| 2495 | 2645 | // Make sure Settings_bak.php is writable. |
| 2496 | 2646 | quickFileWritable($boarddir . '/Settings_bak.php'); |
| 2497 | - if (!is_writable($boarddir . '/Settings_bak.php')) |
|
| 2498 | - print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
| 2647 | + if (!is_writable($boarddir . '/Settings_bak.php')) { |
|
| 2648 | + print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
| 2649 | + } |
|
| 2499 | 2650 | |
| 2500 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
| 2501 | - print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
| 2502 | - elseif (isset($modSettings['agreement'])) |
|
| 2651 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
| 2652 | + print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
| 2653 | + } elseif (isset($modSettings['agreement'])) |
|
| 2503 | 2654 | { |
| 2504 | 2655 | $fp = fopen($boarddir . '/agreement.txt', 'w'); |
| 2505 | 2656 | fwrite($fp, $modSettings['agreement']); |
@@ -2509,36 +2660,42 @@ discard block |
||
| 2509 | 2660 | // Make sure Themes is writable. |
| 2510 | 2661 | quickFileWritable($modSettings['theme_dir']); |
| 2511 | 2662 | |
| 2512 | - if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) |
|
| 2513 | - print_error('Error: Unable to obtain write access to "Themes".'); |
|
| 2663 | + if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) { |
|
| 2664 | + print_error('Error: Unable to obtain write access to "Themes".'); |
|
| 2665 | + } |
|
| 2514 | 2666 | |
| 2515 | 2667 | // Make sure cache directory exists and is writable! |
| 2516 | 2668 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
| 2517 | - if (!file_exists($cachedir_temp)) |
|
| 2518 | - @mkdir($cachedir_temp); |
|
| 2669 | + if (!file_exists($cachedir_temp)) { |
|
| 2670 | + @mkdir($cachedir_temp); |
|
| 2671 | + } |
|
| 2519 | 2672 | |
| 2520 | 2673 | // Make sure the cache temp dir is writable. |
| 2521 | 2674 | quickFileWritable($cachedir_temp); |
| 2522 | 2675 | |
| 2523 | - if (!is_writable($cachedir_temp)) |
|
| 2524 | - print_error('Error: Unable to obtain write access to "cache".', true); |
|
| 2676 | + if (!is_writable($cachedir_temp)) { |
|
| 2677 | + print_error('Error: Unable to obtain write access to "cache".', true); |
|
| 2678 | + } |
|
| 2525 | 2679 | |
| 2526 | 2680 | // Make sure db_last_error.php is writable. |
| 2527 | 2681 | quickFileWritable($cachedir_temp . '/db_last_error.php'); |
| 2528 | - if (!is_writable($cachedir_temp . '/db_last_error.php')) |
|
| 2529 | - print_error('Error: Unable to obtain write access to "db_last_error.php".'); |
|
| 2682 | + if (!is_writable($cachedir_temp . '/db_last_error.php')) { |
|
| 2683 | + print_error('Error: Unable to obtain write access to "db_last_error.php".'); |
|
| 2684 | + } |
|
| 2530 | 2685 | |
| 2531 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
| 2532 | - print_error('Error: Unable to find language files!', true); |
|
| 2533 | - else |
|
| 2686 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
| 2687 | + print_error('Error: Unable to find language files!', true); |
|
| 2688 | + } else |
|
| 2534 | 2689 | { |
| 2535 | 2690 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
| 2536 | 2691 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 2537 | 2692 | |
| 2538 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 2539 | - print_error('Error: Language files out of date.', true); |
|
| 2540 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 2541 | - print_error('Error: Install language is missing for selected language.', true); |
|
| 2693 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 2694 | + print_error('Error: Language files out of date.', true); |
|
| 2695 | + } |
|
| 2696 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 2697 | + print_error('Error: Install language is missing for selected language.', true); |
|
| 2698 | + } |
|
| 2542 | 2699 | |
| 2543 | 2700 | // Otherwise include it! |
| 2544 | 2701 | require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
@@ -2558,8 +2715,9 @@ discard block |
||
| 2558 | 2715 | global $db_prefix, $db_type, $command_line, $support_js, $txt; |
| 2559 | 2716 | |
| 2560 | 2717 | // Done it already? |
| 2561 | - if (!empty($_POST['utf8_done'])) |
|
| 2562 | - return true; |
|
| 2718 | + if (!empty($_POST['utf8_done'])) { |
|
| 2719 | + return true; |
|
| 2720 | + } |
|
| 2563 | 2721 | |
| 2564 | 2722 | // First make sure they aren't already on UTF-8 before we go anywhere... |
| 2565 | 2723 | if ($db_type == 'postgresql' || ($db_character_set === 'utf8' && !empty($modSettings['global_character_set']) && $modSettings['global_character_set'] === 'UTF-8')) |
@@ -2572,8 +2730,7 @@ discard block |
||
| 2572 | 2730 | ); |
| 2573 | 2731 | |
| 2574 | 2732 | return true; |
| 2575 | - } |
|
| 2576 | - else |
|
| 2733 | + } else |
|
| 2577 | 2734 | { |
| 2578 | 2735 | $upcontext['page_title'] = $txt['converting_utf8']; |
| 2579 | 2736 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'convert_xml' : 'convert_utf8'; |
@@ -2617,8 +2774,9 @@ discard block |
||
| 2617 | 2774 | ) |
| 2618 | 2775 | ); |
| 2619 | 2776 | $db_charsets = array(); |
| 2620 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2621 | - $db_charsets[] = $row['Charset']; |
|
| 2777 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2778 | + $db_charsets[] = $row['Charset']; |
|
| 2779 | + } |
|
| 2622 | 2780 | |
| 2623 | 2781 | $smcFunc['db_free_result']($request); |
| 2624 | 2782 | |
@@ -2654,13 +2812,15 @@ discard block |
||
| 2654 | 2812 | // If there's a fulltext index, we need to drop it first... |
| 2655 | 2813 | if ($request !== false || $smcFunc['db_num_rows']($request) != 0) |
| 2656 | 2814 | { |
| 2657 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2658 | - if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 2815 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2816 | + if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 2659 | 2817 | $upcontext['fulltext_index'][] = $row['Key_name']; |
| 2818 | + } |
|
| 2660 | 2819 | $smcFunc['db_free_result']($request); |
| 2661 | 2820 | |
| 2662 | - if (isset($upcontext['fulltext_index'])) |
|
| 2663 | - $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
| 2821 | + if (isset($upcontext['fulltext_index'])) { |
|
| 2822 | + $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
| 2823 | + } |
|
| 2664 | 2824 | } |
| 2665 | 2825 | |
| 2666 | 2826 | // Drop it and make a note... |
@@ -2850,8 +3010,9 @@ discard block |
||
| 2850 | 3010 | $replace = '%field%'; |
| 2851 | 3011 | |
| 2852 | 3012 | // Build a huge REPLACE statement... |
| 2853 | - foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) |
|
| 2854 | - $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
| 3013 | + foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) { |
|
| 3014 | + $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
| 3015 | + } |
|
| 2855 | 3016 | } |
| 2856 | 3017 | |
| 2857 | 3018 | // Get a list of table names ahead of time... This makes it easier to set our substep and such |
@@ -2861,9 +3022,10 @@ discard block |
||
| 2861 | 3022 | $upcontext['table_count'] = count($queryTables); |
| 2862 | 3023 | |
| 2863 | 3024 | // What ones have we already done? |
| 2864 | - foreach ($queryTables as $id => $table) |
|
| 2865 | - if ($id < $_GET['substep']) |
|
| 3025 | + foreach ($queryTables as $id => $table) { |
|
| 3026 | + if ($id < $_GET['substep']) |
|
| 2866 | 3027 | $upcontext['previous_tables'][] = $table; |
| 3028 | + } |
|
| 2867 | 3029 | |
| 2868 | 3030 | $upcontext['cur_table_num'] = $_GET['substep']; |
| 2869 | 3031 | $upcontext['cur_table_name'] = str_replace($db_prefix, '', $queryTables[$_GET['substep']]); |
@@ -2900,8 +3062,9 @@ discard block |
||
| 2900 | 3062 | nextSubstep($substep); |
| 2901 | 3063 | |
| 2902 | 3064 | // Just to make sure it doesn't time out. |
| 2903 | - if (function_exists('apache_reset_timeout')) |
|
| 2904 | - @apache_reset_timeout(); |
|
| 3065 | + if (function_exists('apache_reset_timeout')) { |
|
| 3066 | + @apache_reset_timeout(); |
|
| 3067 | + } |
|
| 2905 | 3068 | |
| 2906 | 3069 | $table_charsets = array(); |
| 2907 | 3070 | |
@@ -2924,8 +3087,9 @@ discard block |
||
| 2924 | 3087 | |
| 2925 | 3088 | // Build structure of columns to operate on organized by charset; only operate on columns not yet utf8 |
| 2926 | 3089 | if ($charset != 'utf8') { |
| 2927 | - if (!isset($table_charsets[$charset])) |
|
| 2928 | - $table_charsets[$charset] = array(); |
|
| 3090 | + if (!isset($table_charsets[$charset])) { |
|
| 3091 | + $table_charsets[$charset] = array(); |
|
| 3092 | + } |
|
| 2929 | 3093 | |
| 2930 | 3094 | $table_charsets[$charset][] = $column_info; |
| 2931 | 3095 | } |
@@ -2966,10 +3130,11 @@ discard block |
||
| 2966 | 3130 | if (isset($translation_tables[$upcontext['charset_detected']])) |
| 2967 | 3131 | { |
| 2968 | 3132 | $update = ''; |
| 2969 | - foreach ($table_charsets as $charset => $columns) |
|
| 2970 | - foreach ($columns as $column) |
|
| 3133 | + foreach ($table_charsets as $charset => $columns) { |
|
| 3134 | + foreach ($columns as $column) |
|
| 2971 | 3135 | $update .= ' |
| 2972 | 3136 | ' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ','; |
| 3137 | + } |
|
| 2973 | 3138 | |
| 2974 | 3139 | $smcFunc['db_query']('', ' |
| 2975 | 3140 | UPDATE {raw:table_name} |
@@ -2994,8 +3159,9 @@ discard block |
||
| 2994 | 3159 | // Now do the actual conversion (if still needed). |
| 2995 | 3160 | if ($charsets[$upcontext['charset_detected']] !== 'utf8') |
| 2996 | 3161 | { |
| 2997 | - if ($command_line) |
|
| 2998 | - echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
| 3162 | + if ($command_line) { |
|
| 3163 | + echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
| 3164 | + } |
|
| 2999 | 3165 | |
| 3000 | 3166 | $smcFunc['db_query']('', ' |
| 3001 | 3167 | ALTER TABLE {raw:table_name} |
@@ -3005,12 +3171,14 @@ discard block |
||
| 3005 | 3171 | ) |
| 3006 | 3172 | ); |
| 3007 | 3173 | |
| 3008 | - if ($command_line) |
|
| 3009 | - echo " done.\n"; |
|
| 3174 | + if ($command_line) { |
|
| 3175 | + echo " done.\n"; |
|
| 3176 | + } |
|
| 3010 | 3177 | } |
| 3011 | 3178 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 3012 | - if (isset($_GET['xml']) && $upcontext['cur_table_num'] < $upcontext['table_count']) |
|
| 3013 | - return upgradeExit(); |
|
| 3179 | + if (isset($_GET['xml']) && $upcontext['cur_table_num'] < $upcontext['table_count']) { |
|
| 3180 | + return upgradeExit(); |
|
| 3181 | + } |
|
| 3014 | 3182 | } |
| 3015 | 3183 | |
| 3016 | 3184 | $prev_charset = empty($translation_tables[$upcontext['charset_detected']]) ? $charsets[$upcontext['charset_detected']] : $translation_tables[$upcontext['charset_detected']]; |
@@ -3039,8 +3207,8 @@ discard block |
||
| 3039 | 3207 | ); |
| 3040 | 3208 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 3041 | 3209 | { |
| 3042 | - if (@safe_unserialize($row['extra']) === false && preg_match('~^(a:3:{s:5:"topic";i:\d+;s:7:"subject";s:)(\d+):"(.+)"(;s:6:"member";s:5:"\d+";})$~', $row['extra'], $matches) === 1) |
|
| 3043 | - $smcFunc['db_query']('', ' |
|
| 3210 | + if (@safe_unserialize($row['extra']) === false && preg_match('~^(a:3:{s:5:"topic";i:\d+;s:7:"subject";s:)(\d+):"(.+)"(;s:6:"member";s:5:"\d+";})$~', $row['extra'], $matches) === 1) { |
|
| 3211 | + $smcFunc['db_query']('', ' |
|
| 3044 | 3212 | UPDATE {db_prefix}log_actions |
| 3045 | 3213 | SET extra = {string:extra} |
| 3046 | 3214 | WHERE id_action = {int:current_action}', |
@@ -3049,6 +3217,7 @@ discard block |
||
| 3049 | 3217 | 'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4], |
| 3050 | 3218 | ) |
| 3051 | 3219 | ); |
| 3220 | + } |
|
| 3052 | 3221 | } |
| 3053 | 3222 | $smcFunc['db_free_result']($request); |
| 3054 | 3223 | |
@@ -3070,15 +3239,17 @@ discard block |
||
| 3070 | 3239 | // First thing's first - did we already do this? |
| 3071 | 3240 | if (!empty($modSettings['json_done'])) |
| 3072 | 3241 | { |
| 3073 | - if ($command_line) |
|
| 3074 | - return DeleteUpgrade(); |
|
| 3075 | - else |
|
| 3076 | - return true; |
|
| 3242 | + if ($command_line) { |
|
| 3243 | + return DeleteUpgrade(); |
|
| 3244 | + } else { |
|
| 3245 | + return true; |
|
| 3246 | + } |
|
| 3077 | 3247 | } |
| 3078 | 3248 | |
| 3079 | 3249 | // Done it already - js wise? |
| 3080 | - if (!empty($_POST['json_done'])) |
|
| 3081 | - return true; |
|
| 3250 | + if (!empty($_POST['json_done'])) { |
|
| 3251 | + return true; |
|
| 3252 | + } |
|
| 3082 | 3253 | |
| 3083 | 3254 | // List of tables affected by this function |
| 3084 | 3255 | // name => array('key', col1[,col2|true[,col3]]) |
@@ -3110,12 +3281,14 @@ discard block |
||
| 3110 | 3281 | $upcontext['cur_table_name'] = isset($keys[$_GET['substep']]) ? $keys[$_GET['substep']] : $keys[0]; |
| 3111 | 3282 | $upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100); |
| 3112 | 3283 | |
| 3113 | - foreach ($keys as $id => $table) |
|
| 3114 | - if ($id < $_GET['substep']) |
|
| 3284 | + foreach ($keys as $id => $table) { |
|
| 3285 | + if ($id < $_GET['substep']) |
|
| 3115 | 3286 | $upcontext['previous_tables'][] = $table; |
| 3287 | + } |
|
| 3116 | 3288 | |
| 3117 | - if ($command_line) |
|
| 3118 | - echo 'Converting data from serialize() to json_encode().'; |
|
| 3289 | + if ($command_line) { |
|
| 3290 | + echo 'Converting data from serialize() to json_encode().'; |
|
| 3291 | + } |
|
| 3119 | 3292 | |
| 3120 | 3293 | if (!$support_js || isset($_GET['xml'])) |
| 3121 | 3294 | { |
@@ -3155,8 +3328,9 @@ discard block |
||
| 3155 | 3328 | |
| 3156 | 3329 | // Loop through and fix these... |
| 3157 | 3330 | $new_settings = array(); |
| 3158 | - if ($command_line) |
|
| 3159 | - echo "\n" . 'Fixing some settings...'; |
|
| 3331 | + if ($command_line) { |
|
| 3332 | + echo "\n" . 'Fixing some settings...'; |
|
| 3333 | + } |
|
| 3160 | 3334 | |
| 3161 | 3335 | foreach ($serialized_settings as $var) |
| 3162 | 3336 | { |
@@ -3164,22 +3338,24 @@ discard block |
||
| 3164 | 3338 | { |
| 3165 | 3339 | // Attempt to unserialize the setting |
| 3166 | 3340 | $temp = @safe_unserialize($modSettings[$var]); |
| 3167 | - if (!$temp && $command_line) |
|
| 3168 | - echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
| 3169 | - elseif ($temp !== false) |
|
| 3170 | - $new_settings[$var] = json_encode($temp); |
|
| 3341 | + if (!$temp && $command_line) { |
|
| 3342 | + echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
| 3343 | + } elseif ($temp !== false) { |
|
| 3344 | + $new_settings[$var] = json_encode($temp); |
|
| 3345 | + } |
|
| 3171 | 3346 | } |
| 3172 | 3347 | } |
| 3173 | 3348 | |
| 3174 | 3349 | // Update everything at once |
| 3175 | - if (!function_exists('cache_put_data')) |
|
| 3176 | - require_once($sourcedir . '/Load.php'); |
|
| 3350 | + if (!function_exists('cache_put_data')) { |
|
| 3351 | + require_once($sourcedir . '/Load.php'); |
|
| 3352 | + } |
|
| 3177 | 3353 | updateSettings($new_settings, true); |
| 3178 | 3354 | |
| 3179 | - if ($command_line) |
|
| 3180 | - echo ' done.'; |
|
| 3181 | - } |
|
| 3182 | - elseif ($table == 'themes') |
|
| 3355 | + if ($command_line) { |
|
| 3356 | + echo ' done.'; |
|
| 3357 | + } |
|
| 3358 | + } elseif ($table == 'themes') |
|
| 3183 | 3359 | { |
| 3184 | 3360 | // Finally, fix the admin prefs. Unfortunately this is stored per theme, but hopefully they only have one theme installed at this point... |
| 3185 | 3361 | $query = $smcFunc['db_query']('', ' |
@@ -3198,10 +3374,11 @@ discard block |
||
| 3198 | 3374 | |
| 3199 | 3375 | if ($command_line) |
| 3200 | 3376 | { |
| 3201 | - if ($temp === false) |
|
| 3202 | - echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
| 3203 | - else |
|
| 3204 | - echo "\n" . 'Fixing admin preferences...'; |
|
| 3377 | + if ($temp === false) { |
|
| 3378 | + echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
| 3379 | + } else { |
|
| 3380 | + echo "\n" . 'Fixing admin preferences...'; |
|
| 3381 | + } |
|
| 3205 | 3382 | } |
| 3206 | 3383 | |
| 3207 | 3384 | if ($temp !== false) |
@@ -3223,15 +3400,15 @@ discard block |
||
| 3223 | 3400 | ) |
| 3224 | 3401 | ); |
| 3225 | 3402 | |
| 3226 | - if ($command_line) |
|
| 3227 | - echo ' done.'; |
|
| 3403 | + if ($command_line) { |
|
| 3404 | + echo ' done.'; |
|
| 3405 | + } |
|
| 3228 | 3406 | } |
| 3229 | 3407 | } |
| 3230 | 3408 | |
| 3231 | 3409 | $smcFunc['db_free_result']($query); |
| 3232 | 3410 | } |
| 3233 | - } |
|
| 3234 | - else |
|
| 3411 | + } else |
|
| 3235 | 3412 | { |
| 3236 | 3413 | // First item is always the key... |
| 3237 | 3414 | $key = $info[0]; |
@@ -3242,8 +3419,7 @@ discard block |
||
| 3242 | 3419 | { |
| 3243 | 3420 | $col_select = $info[1]; |
| 3244 | 3421 | $where = ' WHERE ' . $info[1] . ' != {empty}'; |
| 3245 | - } |
|
| 3246 | - else |
|
| 3422 | + } else |
|
| 3247 | 3423 | { |
| 3248 | 3424 | $col_select = implode(', ', $info); |
| 3249 | 3425 | } |
@@ -3276,8 +3452,7 @@ discard block |
||
| 3276 | 3452 | if ($temp === false && $command_line) |
| 3277 | 3453 | { |
| 3278 | 3454 | echo "\nFailed to unserialize " . $row[$col] . "... Skipping\n"; |
| 3279 | - } |
|
| 3280 | - else |
|
| 3455 | + } else |
|
| 3281 | 3456 | { |
| 3282 | 3457 | $row[$col] = json_encode($temp); |
| 3283 | 3458 | |
@@ -3302,16 +3477,18 @@ discard block |
||
| 3302 | 3477 | } |
| 3303 | 3478 | } |
| 3304 | 3479 | |
| 3305 | - if ($command_line) |
|
| 3306 | - echo ' done.'; |
|
| 3480 | + if ($command_line) { |
|
| 3481 | + echo ' done.'; |
|
| 3482 | + } |
|
| 3307 | 3483 | |
| 3308 | 3484 | // Free up some memory... |
| 3309 | 3485 | $smcFunc['db_free_result']($query); |
| 3310 | 3486 | } |
| 3311 | 3487 | } |
| 3312 | 3488 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 3313 | - if (isset($_GET['xml'])) |
|
| 3314 | - return upgradeExit(); |
|
| 3489 | + if (isset($_GET['xml'])) { |
|
| 3490 | + return upgradeExit(); |
|
| 3491 | + } |
|
| 3315 | 3492 | } |
| 3316 | 3493 | |
| 3317 | 3494 | if ($command_line) |
@@ -3326,8 +3503,9 @@ discard block |
||
| 3326 | 3503 | |
| 3327 | 3504 | $_GET['substep'] = 0; |
| 3328 | 3505 | // Make sure we move on! |
| 3329 | - if ($command_line) |
|
| 3330 | - return DeleteUpgrade(); |
|
| 3506 | + if ($command_line) { |
|
| 3507 | + return DeleteUpgrade(); |
|
| 3508 | + } |
|
| 3331 | 3509 | |
| 3332 | 3510 | return true; |
| 3333 | 3511 | } |
@@ -3384,14 +3562,16 @@ discard block |
||
| 3384 | 3562 | global $upcontext, $txt, $settings; |
| 3385 | 3563 | |
| 3386 | 3564 | // Don't call me twice! |
| 3387 | - if (!empty($upcontext['chmod_called'])) |
|
| 3388 | - return; |
|
| 3565 | + if (!empty($upcontext['chmod_called'])) { |
|
| 3566 | + return; |
|
| 3567 | + } |
|
| 3389 | 3568 | |
| 3390 | 3569 | $upcontext['chmod_called'] = true; |
| 3391 | 3570 | |
| 3392 | 3571 | // Nothing? |
| 3393 | - if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) |
|
| 3394 | - return; |
|
| 3572 | + if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) { |
|
| 3573 | + return; |
|
| 3574 | + } |
|
| 3395 | 3575 | |
| 3396 | 3576 | // Was it a problem with Windows? |
| 3397 | 3577 | if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess') |
@@ -3423,11 +3603,12 @@ discard block |
||
| 3423 | 3603 | content.write(\'<div class="windowbg description">\n\t\t\t<h4>', $txt['upgrade_ftp_files'], '</h4>\n\t\t\t\'); |
| 3424 | 3604 | content.write(\'<p>', implode('<br>\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');'; |
| 3425 | 3605 | |
| 3426 | - if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') |
|
| 3427 | - echo ' |
|
| 3606 | + if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') { |
|
| 3607 | + echo ' |
|
| 3428 | 3608 | content.write(\'<hr>\n\t\t\t\'); |
| 3429 | 3609 | content.write(\'<p>', $txt['upgrade_ftp_shell'], '</p>\n\t\t\t\'); |
| 3430 | 3610 | content.write(\'<tt># chmod a+w ', implode(' ', $upcontext['chmod']['files']), '</tt>\n\t\t\t\');'; |
| 3611 | + } |
|
| 3431 | 3612 | |
| 3432 | 3613 | echo ' |
| 3433 | 3614 | content.write(\'<a href="javascript:self.close();">close</a>\n\t\t</div>\n\t</body>\n</html>\'); |
@@ -3435,17 +3616,19 @@ discard block |
||
| 3435 | 3616 | } |
| 3436 | 3617 | </script>'; |
| 3437 | 3618 | |
| 3438 | - if (!empty($upcontext['chmod']['ftp_error'])) |
|
| 3439 | - echo ' |
|
| 3619 | + if (!empty($upcontext['chmod']['ftp_error'])) { |
|
| 3620 | + echo ' |
|
| 3440 | 3621 | <div class="error_message red"> |
| 3441 | 3622 | ', $txt['upgrade_ftp_error'], '<br><br> |
| 3442 | 3623 | <code>', $upcontext['chmod']['ftp_error'], '</code> |
| 3443 | 3624 | </div> |
| 3444 | 3625 | <br>'; |
| 3626 | + } |
|
| 3445 | 3627 | |
| 3446 | - if (empty($upcontext['chmod_in_form'])) |
|
| 3447 | - echo ' |
|
| 3628 | + if (empty($upcontext['chmod_in_form'])) { |
|
| 3629 | + echo ' |
|
| 3448 | 3630 | <form action="', $upcontext['form_url'], '" method="post">'; |
| 3631 | + } |
|
| 3449 | 3632 | |
| 3450 | 3633 | echo ' |
| 3451 | 3634 | <table width="520" border="0" align="center" style="margin-bottom: 1ex;"> |
@@ -3480,10 +3663,11 @@ discard block |
||
| 3480 | 3663 | <div class="righttext" style="margin: 1ex;"><input type="submit" value="', $txt['ftp_connect'], '" class="button"></div> |
| 3481 | 3664 | </div>'; |
| 3482 | 3665 | |
| 3483 | - if (empty($upcontext['chmod_in_form'])) |
|
| 3484 | - echo ' |
|
| 3666 | + if (empty($upcontext['chmod_in_form'])) { |
|
| 3667 | + echo ' |
|
| 3485 | 3668 | </form>'; |
| 3486 | -} |
|
| 3669 | + } |
|
| 3670 | + } |
|
| 3487 | 3671 | |
| 3488 | 3672 | function template_upgrade_above() |
| 3489 | 3673 | { |
@@ -3543,9 +3727,10 @@ discard block |
||
| 3543 | 3727 | <h2>', $txt['upgrade_progress'], '</h2> |
| 3544 | 3728 | <ul>'; |
| 3545 | 3729 | |
| 3546 | - foreach ($upcontext['steps'] as $num => $step) |
|
| 3547 | - echo ' |
|
| 3730 | + foreach ($upcontext['steps'] as $num => $step) { |
|
| 3731 | + echo ' |
|
| 3548 | 3732 | <li class="', $num < $upcontext['current_step'] ? 'stepdone' : ($num == $upcontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
| 3733 | + } |
|
| 3549 | 3734 | |
| 3550 | 3735 | echo ' |
| 3551 | 3736 | </ul> |
@@ -3558,8 +3743,8 @@ discard block |
||
| 3558 | 3743 | </div> |
| 3559 | 3744 | </div>'; |
| 3560 | 3745 | |
| 3561 | - if (isset($upcontext['step_progress'])) |
|
| 3562 | - echo ' |
|
| 3746 | + if (isset($upcontext['step_progress'])) { |
|
| 3747 | + echo ' |
|
| 3563 | 3748 | <br> |
| 3564 | 3749 | <br> |
| 3565 | 3750 | <div id="progress_bar_step"> |
@@ -3568,6 +3753,7 @@ discard block |
||
| 3568 | 3753 | <span>', $txt['upgrade_step_progress'], '</span> |
| 3569 | 3754 | </div> |
| 3570 | 3755 | </div>'; |
| 3756 | + } |
|
| 3571 | 3757 | |
| 3572 | 3758 | echo ' |
| 3573 | 3759 | <div id="substep_bar_div" class="smalltext" style="float: left;width: 50%;margin-top: 0.6em;display: ', isset($upcontext['substep_progress']) ? '' : 'none', ';">', isset($upcontext['substep_progress_name']) ? trim(strtr($upcontext['substep_progress_name'], array('.' => ''))) : '', ':</div> |
@@ -3598,32 +3784,36 @@ discard block |
||
| 3598 | 3784 | { |
| 3599 | 3785 | global $upcontext, $txt; |
| 3600 | 3786 | |
| 3601 | - if (!empty($upcontext['pause'])) |
|
| 3602 | - echo ' |
|
| 3787 | + if (!empty($upcontext['pause'])) { |
|
| 3788 | + echo ' |
|
| 3603 | 3789 | <em>', $txt['upgrade_incomplete'], '.</em><br> |
| 3604 | 3790 | |
| 3605 | 3791 | <h2 style="margin-top: 2ex;">', $txt['upgrade_not_quite_done'], '</h2> |
| 3606 | 3792 | <h3> |
| 3607 | 3793 | ', $txt['upgrade_paused_overload'], ' |
| 3608 | 3794 | </h3>'; |
| 3795 | + } |
|
| 3609 | 3796 | |
| 3610 | - if (!empty($upcontext['custom_warning'])) |
|
| 3611 | - echo ' |
|
| 3797 | + if (!empty($upcontext['custom_warning'])) { |
|
| 3798 | + echo ' |
|
| 3612 | 3799 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3613 | 3800 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3614 | 3801 | <strong style="text-decoration: underline;">', $txt['upgrade_note'], '</strong><br> |
| 3615 | 3802 | <div style="padding-left: 6ex;">', $upcontext['custom_warning'], '</div> |
| 3616 | 3803 | </div>'; |
| 3804 | + } |
|
| 3617 | 3805 | |
| 3618 | 3806 | echo ' |
| 3619 | 3807 | <div class="righttext" style="margin: 1ex;">'; |
| 3620 | 3808 | |
| 3621 | - if (!empty($upcontext['continue'])) |
|
| 3622 | - echo ' |
|
| 3809 | + if (!empty($upcontext['continue'])) { |
|
| 3810 | + echo ' |
|
| 3623 | 3811 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled' : '', ' class="button">'; |
| 3624 | - if (!empty($upcontext['skip'])) |
|
| 3625 | - echo ' |
|
| 3812 | + } |
|
| 3813 | + if (!empty($upcontext['skip'])) { |
|
| 3814 | + echo ' |
|
| 3626 | 3815 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button">'; |
| 3816 | + } |
|
| 3627 | 3817 | |
| 3628 | 3818 | echo ' |
| 3629 | 3819 | </div> |
@@ -3673,11 +3863,12 @@ discard block |
||
| 3673 | 3863 | echo '<', '?xml version="1.0" encoding="UTF-8"?', '> |
| 3674 | 3864 | <smf>'; |
| 3675 | 3865 | |
| 3676 | - if (!empty($upcontext['get_data'])) |
|
| 3677 | - foreach ($upcontext['get_data'] as $k => $v) |
|
| 3866 | + if (!empty($upcontext['get_data'])) { |
|
| 3867 | + foreach ($upcontext['get_data'] as $k => $v) |
|
| 3678 | 3868 | echo ' |
| 3679 | 3869 | <get key="', $k, '">', $v, '</get>'; |
| 3680 | -} |
|
| 3870 | + } |
|
| 3871 | + } |
|
| 3681 | 3872 | |
| 3682 | 3873 | function template_xml_below() |
| 3683 | 3874 | { |
@@ -3718,8 +3909,8 @@ discard block |
||
| 3718 | 3909 | template_chmod(); |
| 3719 | 3910 | |
| 3720 | 3911 | // For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade! |
| 3721 | - if ($upcontext['is_large_forum']) |
|
| 3722 | - echo ' |
|
| 3912 | + if ($upcontext['is_large_forum']) { |
|
| 3913 | + echo ' |
|
| 3723 | 3914 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3724 | 3915 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3725 | 3916 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -3727,10 +3918,11 @@ discard block |
||
| 3727 | 3918 | ', $txt['upgrade_warning_lots_data'], ' |
| 3728 | 3919 | </div> |
| 3729 | 3920 | </div>'; |
| 3921 | + } |
|
| 3730 | 3922 | |
| 3731 | 3923 | // A warning message? |
| 3732 | - if (!empty($upcontext['warning'])) |
|
| 3733 | - echo ' |
|
| 3924 | + if (!empty($upcontext['warning'])) { |
|
| 3925 | + echo ' |
|
| 3734 | 3926 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3735 | 3927 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3736 | 3928 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -3738,6 +3930,7 @@ discard block |
||
| 3738 | 3930 | ', $upcontext['warning'], ' |
| 3739 | 3931 | </div> |
| 3740 | 3932 | </div>'; |
| 3933 | + } |
|
| 3741 | 3934 | |
| 3742 | 3935 | // Paths are incorrect? |
| 3743 | 3936 | echo ' |
@@ -3753,20 +3946,22 @@ discard block |
||
| 3753 | 3946 | if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600)) |
| 3754 | 3947 | { |
| 3755 | 3948 | $ago = time() - $upcontext['started']; |
| 3756 | - if ($ago < 60) |
|
| 3757 | - $ago = $ago . ' seconds'; |
|
| 3758 | - elseif ($ago < 3600) |
|
| 3759 | - $ago = (int) ($ago / 60) . ' minutes'; |
|
| 3760 | - else |
|
| 3761 | - $ago = (int) ($ago / 3600) . ' hours'; |
|
| 3949 | + if ($ago < 60) { |
|
| 3950 | + $ago = $ago . ' seconds'; |
|
| 3951 | + } elseif ($ago < 3600) { |
|
| 3952 | + $ago = (int) ($ago / 60) . ' minutes'; |
|
| 3953 | + } else { |
|
| 3954 | + $ago = (int) ($ago / 3600) . ' hours'; |
|
| 3955 | + } |
|
| 3762 | 3956 | |
| 3763 | 3957 | $active = time() - $upcontext['updated']; |
| 3764 | - if ($active < 60) |
|
| 3765 | - $updated = $active . ' seconds'; |
|
| 3766 | - elseif ($active < 3600) |
|
| 3767 | - $updated = (int) ($active / 60) . ' minutes'; |
|
| 3768 | - else |
|
| 3769 | - $updated = (int) ($active / 3600) . ' hours'; |
|
| 3958 | + if ($active < 60) { |
|
| 3959 | + $updated = $active . ' seconds'; |
|
| 3960 | + } elseif ($active < 3600) { |
|
| 3961 | + $updated = (int) ($active / 60) . ' minutes'; |
|
| 3962 | + } else { |
|
| 3963 | + $updated = (int) ($active / 3600) . ' hours'; |
|
| 3964 | + } |
|
| 3770 | 3965 | |
| 3771 | 3966 | echo ' |
| 3772 | 3967 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
@@ -3775,16 +3970,18 @@ discard block |
||
| 3775 | 3970 | <div style="padding-left: 6ex;"> |
| 3776 | 3971 | "', $upcontext['user']['name'], '" has been running the upgrade script for the last ', $ago, ' - and was last active ', $updated, ' ago.'; |
| 3777 | 3972 | |
| 3778 | - if ($active < 600) |
|
| 3779 | - echo ' |
|
| 3973 | + if ($active < 600) { |
|
| 3974 | + echo ' |
|
| 3780 | 3975 | ', $txt['upgrade_run_script'], ' ', $upcontext['user']['name'],' ', $txt['upgrade_run_script2'], ''; |
| 3976 | + } |
|
| 3781 | 3977 | |
| 3782 | - if ($active > $upcontext['inactive_timeout']) |
|
| 3783 | - echo ' |
|
| 3978 | + if ($active > $upcontext['inactive_timeout']) { |
|
| 3979 | + echo ' |
|
| 3784 | 3980 | <br><br>',$txt['upgrade_run'], ''; |
| 3785 | - else |
|
| 3786 | - echo ' |
|
| 3981 | + } else { |
|
| 3982 | + echo ' |
|
| 3787 | 3983 | <br><br>', $txt['upgrade_script_timeout'], ' ', $upcontext['user']['name'], ' ', $txt['upgrade_script_timeout2'], ' ', ($upcontext['inactive_timeout'] > 120 ? round($upcontext['inactive_timeout'] / 60, 1) . ' minutes!' : $upcontext['inactive_timeout'] . ' seconds!'); |
| 3984 | + } |
|
| 3788 | 3985 | |
| 3789 | 3986 | echo ' |
| 3790 | 3987 | </div> |
@@ -3800,9 +3997,10 @@ discard block |
||
| 3800 | 3997 | <td> |
| 3801 | 3998 | <input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '"', $disable_security ? ' disabled' : '', '>'; |
| 3802 | 3999 | |
| 3803 | - if (!empty($upcontext['username_incorrect'])) |
|
| 3804 | - echo ' |
|
| 4000 | + if (!empty($upcontext['username_incorrect'])) { |
|
| 4001 | + echo ' |
|
| 3805 | 4002 | <div class="smalltext" style="color: red;">', $txt['upgrade_wrong_username'], '</div>'; |
| 4003 | + } |
|
| 3806 | 4004 | |
| 3807 | 4005 | echo ' |
| 3808 | 4006 | </td> |
@@ -3813,9 +4011,10 @@ discard block |
||
| 3813 | 4011 | <input type="password" name="passwrd" value=""', $disable_security ? ' disabled' : '', '> |
| 3814 | 4012 | <input type="hidden" name="hash_passwrd" value="">'; |
| 3815 | 4013 | |
| 3816 | - if (!empty($upcontext['password_failed'])) |
|
| 3817 | - echo ' |
|
| 4014 | + if (!empty($upcontext['password_failed'])) { |
|
| 4015 | + echo ' |
|
| 3818 | 4016 | <div class="smalltext" style="color: red;">', $txt['upgrade_wrong_password'], '</div>'; |
| 4017 | + } |
|
| 3819 | 4018 | |
| 3820 | 4019 | echo ' |
| 3821 | 4020 | </td> |
@@ -3886,8 +4085,8 @@ discard block |
||
| 3886 | 4085 | <form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">'; |
| 3887 | 4086 | |
| 3888 | 4087 | // Warning message? |
| 3889 | - if (!empty($upcontext['upgrade_options_warning'])) |
|
| 3890 | - echo ' |
|
| 4088 | + if (!empty($upcontext['upgrade_options_warning'])) { |
|
| 4089 | + echo ' |
|
| 3891 | 4090 | <div style="margin: 1ex; padding: 1ex; border: 1px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3892 | 4091 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3893 | 4092 | <strong style="text-decoration: underline;">Warning!</strong><br> |
@@ -3895,6 +4094,7 @@ discard block |
||
| 3895 | 4094 | ', $upcontext['upgrade_options_warning'], ' |
| 3896 | 4095 | </div> |
| 3897 | 4096 | </div>'; |
| 4097 | + } |
|
| 3898 | 4098 | |
| 3899 | 4099 | echo ' |
| 3900 | 4100 | <table> |
@@ -3937,8 +4137,8 @@ discard block |
||
| 3937 | 4137 | </td> |
| 3938 | 4138 | </tr>'; |
| 3939 | 4139 | |
| 3940 | - if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) |
|
| 3941 | - echo ' |
|
| 4140 | + if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) { |
|
| 4141 | + echo ' |
|
| 3942 | 4142 | <tr valign="top"> |
| 3943 | 4143 | <td width="2%"> |
| 3944 | 4144 | <input type="checkbox" name="delete_karma" id="delete_karma" value="1"> |
@@ -3947,6 +4147,7 @@ discard block |
||
| 3947 | 4147 | <label for="delete_karma">', $txt['upgrade_delete_karma'], '</label> |
| 3948 | 4148 | </td> |
| 3949 | 4149 | </tr>'; |
| 4150 | + } |
|
| 3950 | 4151 | |
| 3951 | 4152 | echo ' |
| 3952 | 4153 | <tr valign="top"> |
@@ -3984,10 +4185,11 @@ discard block |
||
| 3984 | 4185 | </div>'; |
| 3985 | 4186 | |
| 3986 | 4187 | // Dont any tables so far? |
| 3987 | - if (!empty($upcontext['previous_tables'])) |
|
| 3988 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4188 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4189 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 3989 | 4190 | echo ' |
| 3990 | 4191 | <br>', $txt['upgrade_completed_table'], ' "', $table, '".'; |
| 4192 | + } |
|
| 3991 | 4193 | |
| 3992 | 4194 | echo ' |
| 3993 | 4195 | <h3 id="current_tab_div">', $txt['upgrade_current_table'], ' "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
@@ -4024,12 +4226,13 @@ discard block |
||
| 4024 | 4226 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 4025 | 4227 | |
| 4026 | 4228 | // If debug flood the screen. |
| 4027 | - if ($is_debug) |
|
| 4028 | - echo ' |
|
| 4229 | + if ($is_debug) { |
|
| 4230 | + echo ' |
|
| 4029 | 4231 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 4030 | 4232 | |
| 4031 | 4233 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4032 | 4234 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4235 | + } |
|
| 4033 | 4236 | |
| 4034 | 4237 | echo ' |
| 4035 | 4238 | // Get the next update... |
@@ -4062,8 +4265,9 @@ discard block |
||
| 4062 | 4265 | { |
| 4063 | 4266 | global $upcontext, $support_js, $is_debug, $timeLimitThreshold, $txt; |
| 4064 | 4267 | |
| 4065 | - if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) |
|
| 4066 | - $is_debug = true; |
|
| 4268 | + if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) { |
|
| 4269 | + $is_debug = true; |
|
| 4270 | + } |
|
| 4067 | 4271 | |
| 4068 | 4272 | echo ' |
| 4069 | 4273 | <h3>', $txt['upgrade_db_changes'], '</h3> |
@@ -4078,8 +4282,9 @@ discard block |
||
| 4078 | 4282 | { |
| 4079 | 4283 | foreach ($upcontext['actioned_items'] as $num => $item) |
| 4080 | 4284 | { |
| 4081 | - if ($num != 0) |
|
| 4082 | - echo ' Successful!'; |
|
| 4285 | + if ($num != 0) { |
|
| 4286 | + echo ' Successful!'; |
|
| 4287 | + } |
|
| 4083 | 4288 | echo '<br>' . $item; |
| 4084 | 4289 | } |
| 4085 | 4290 | if (!empty($upcontext['changes_complete'])) |
@@ -4092,28 +4297,32 @@ discard block |
||
| 4092 | 4297 | $seconds = intval($active % 60); |
| 4093 | 4298 | |
| 4094 | 4299 | $totalTime = ''; |
| 4095 | - if ($hours > 0) |
|
| 4096 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4097 | - if ($minutes > 0) |
|
| 4098 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4099 | - if ($seconds > 0) |
|
| 4100 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4300 | + if ($hours > 0) { |
|
| 4301 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4302 | + } |
|
| 4303 | + if ($minutes > 0) { |
|
| 4304 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4305 | + } |
|
| 4306 | + if ($seconds > 0) { |
|
| 4307 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4308 | + } |
|
| 4101 | 4309 | } |
| 4102 | 4310 | |
| 4103 | - if ($is_debug && !empty($totalTime)) |
|
| 4104 | - echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
| 4105 | - else |
|
| 4106 | - echo ' Successful!<br><br>'; |
|
| 4311 | + if ($is_debug && !empty($totalTime)) { |
|
| 4312 | + echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
| 4313 | + } else { |
|
| 4314 | + echo ' Successful!<br><br>'; |
|
| 4315 | + } |
|
| 4107 | 4316 | |
| 4108 | 4317 | echo '<span id="commess" style="font-weight: bold;">', $txt['upgrade_db_complete'], '</span><br>'; |
| 4109 | 4318 | } |
| 4110 | - } |
|
| 4111 | - else |
|
| 4319 | + } else |
|
| 4112 | 4320 | { |
| 4113 | 4321 | // Tell them how many files we have in total. |
| 4114 | - if ($upcontext['file_count'] > 1) |
|
| 4115 | - echo ' |
|
| 4322 | + if ($upcontext['file_count'] > 1) { |
|
| 4323 | + echo ' |
|
| 4116 | 4324 | <strong id="info1">', $txt['upgrade_script'], ' <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>'; |
| 4325 | + } |
|
| 4117 | 4326 | |
| 4118 | 4327 | echo ' |
| 4119 | 4328 | <h3 id="info2"><strong>', $txt['upgrade_executing'], '</strong> "<span id="cur_item_name">', $upcontext['current_item_name'], '</span>" (<span id="item_num">', $upcontext['current_item_num'], '</span> ', $txt['upgrade_of'], ' <span id="total_items"><span id="item_count">', $upcontext['total_items'], '</span>', $upcontext['file_count'] > 1 ? ' - of this script' : '', ')</span></h3> |
@@ -4129,19 +4338,23 @@ discard block |
||
| 4129 | 4338 | $seconds = intval($active % 60); |
| 4130 | 4339 | |
| 4131 | 4340 | $totalTime = ''; |
| 4132 | - if ($hours > 0) |
|
| 4133 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4134 | - if ($minutes > 0) |
|
| 4135 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4136 | - if ($seconds > 0) |
|
| 4137 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4341 | + if ($hours > 0) { |
|
| 4342 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4343 | + } |
|
| 4344 | + if ($minutes > 0) { |
|
| 4345 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4346 | + } |
|
| 4347 | + if ($seconds > 0) { |
|
| 4348 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4349 | + } |
|
| 4138 | 4350 | } |
| 4139 | 4351 | |
| 4140 | 4352 | echo ' |
| 4141 | 4353 | <br><span id="upgradeCompleted">'; |
| 4142 | 4354 | |
| 4143 | - if (!empty($totalTime)) |
|
| 4144 | - echo 'Completed in ', $totalTime, '<br>'; |
|
| 4355 | + if (!empty($totalTime)) { |
|
| 4356 | + echo 'Completed in ', $totalTime, '<br>'; |
|
| 4357 | + } |
|
| 4145 | 4358 | |
| 4146 | 4359 | echo '</span> |
| 4147 | 4360 | <div id="debug_section" style="height: 59px; overflow: auto;"> |
@@ -4178,9 +4391,10 @@ discard block |
||
| 4178 | 4391 | var getData = ""; |
| 4179 | 4392 | var debugItems = ', $upcontext['debug_items'], ';'; |
| 4180 | 4393 | |
| 4181 | - if ($is_debug) |
|
| 4182 | - echo ' |
|
| 4394 | + if ($is_debug) { |
|
| 4395 | + echo ' |
|
| 4183 | 4396 | var upgradeStartTime = ' . $upcontext['started'] . ';'; |
| 4397 | + } |
|
| 4184 | 4398 | |
| 4185 | 4399 | echo ' |
| 4186 | 4400 | function getNextItem() |
@@ -4220,9 +4434,10 @@ discard block |
||
| 4220 | 4434 | document.getElementById("error_block").style.display = ""; |
| 4221 | 4435 | setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));'; |
| 4222 | 4436 | |
| 4223 | - if ($is_debug) |
|
| 4224 | - echo ' |
|
| 4437 | + if ($is_debug) { |
|
| 4438 | + echo ' |
|
| 4225 | 4439 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
| 4440 | + } |
|
| 4226 | 4441 | |
| 4227 | 4442 | echo ' |
| 4228 | 4443 | } |
@@ -4243,9 +4458,10 @@ discard block |
||
| 4243 | 4458 | document.getElementById("error_block").style.display = ""; |
| 4244 | 4459 | setInnerHTML(document.getElementById("error_message"), "Upgrade script appears to be going into a loop - step: " + sDebugName);'; |
| 4245 | 4460 | |
| 4246 | - if ($is_debug) |
|
| 4247 | - echo ' |
|
| 4461 | + if ($is_debug) { |
|
| 4462 | + echo ' |
|
| 4248 | 4463 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
| 4464 | + } |
|
| 4249 | 4465 | |
| 4250 | 4466 | echo ' |
| 4251 | 4467 | } |
@@ -4304,8 +4520,8 @@ discard block |
||
| 4304 | 4520 | if (bIsComplete && iDebugNum == -1 && curFile >= ', $upcontext['file_count'], ') |
| 4305 | 4521 | {'; |
| 4306 | 4522 | |
| 4307 | - if ($is_debug) |
|
| 4308 | - echo ' |
|
| 4523 | + if ($is_debug) { |
|
| 4524 | + echo ' |
|
| 4309 | 4525 | document.getElementById(\'debug_section\').style.display = "none"; |
| 4310 | 4526 | |
| 4311 | 4527 | var upgradeFinishedTime = parseInt(oXMLDoc.getElementsByTagName("curtime")[0].childNodes[0].nodeValue); |
@@ -4323,6 +4539,7 @@ discard block |
||
| 4323 | 4539 | totalTime = totalTime + diffSeconds + " second" + (diffSeconds > 1 ? "s" : ""); |
| 4324 | 4540 | |
| 4325 | 4541 | setInnerHTML(document.getElementById("upgradeCompleted"), "Completed in " + totalTime);'; |
| 4542 | + } |
|
| 4326 | 4543 | |
| 4327 | 4544 | echo ' |
| 4328 | 4545 | |
@@ -4330,9 +4547,10 @@ discard block |
||
| 4330 | 4547 | document.getElementById(\'contbutt\').disabled = 0; |
| 4331 | 4548 | document.getElementById(\'database_done\').value = 1;'; |
| 4332 | 4549 | |
| 4333 | - if ($upcontext['file_count'] > 1) |
|
| 4334 | - echo ' |
|
| 4550 | + if ($upcontext['file_count'] > 1) { |
|
| 4551 | + echo ' |
|
| 4335 | 4552 | document.getElementById(\'info1\').style.display = "none";'; |
| 4553 | + } |
|
| 4336 | 4554 | |
| 4337 | 4555 | echo ' |
| 4338 | 4556 | document.getElementById(\'info2\').style.display = "none"; |
@@ -4345,9 +4563,10 @@ discard block |
||
| 4345 | 4563 | lastItem = 0; |
| 4346 | 4564 | prevFile = curFile;'; |
| 4347 | 4565 | |
| 4348 | - if ($is_debug) |
|
| 4349 | - echo ' |
|
| 4566 | + if ($is_debug) { |
|
| 4567 | + echo ' |
|
| 4350 | 4568 | setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br><span id="debuginfo"><\' + \'/span>\');'; |
| 4569 | + } |
|
| 4351 | 4570 | |
| 4352 | 4571 | echo ' |
| 4353 | 4572 | getNextItem(); |
@@ -4355,8 +4574,8 @@ discard block |
||
| 4355 | 4574 | }'; |
| 4356 | 4575 | |
| 4357 | 4576 | // If debug scroll the screen. |
| 4358 | - if ($is_debug) |
|
| 4359 | - echo ' |
|
| 4577 | + if ($is_debug) { |
|
| 4578 | + echo ' |
|
| 4360 | 4579 | if (iLastSubStepProgress == -1) |
| 4361 | 4580 | { |
| 4362 | 4581 | // Give it consistent dots. |
@@ -4375,6 +4594,7 @@ discard block |
||
| 4375 | 4594 | |
| 4376 | 4595 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4377 | 4596 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4597 | + } |
|
| 4378 | 4598 | |
| 4379 | 4599 | echo ' |
| 4380 | 4600 | // Update the page. |
@@ -4435,9 +4655,10 @@ discard block |
||
| 4435 | 4655 | }'; |
| 4436 | 4656 | |
| 4437 | 4657 | // Start things off assuming we've not errored. |
| 4438 | - if (empty($upcontext['error_message'])) |
|
| 4439 | - echo ' |
|
| 4658 | + if (empty($upcontext['error_message'])) { |
|
| 4659 | + echo ' |
|
| 4440 | 4660 | getNextItem();'; |
| 4661 | + } |
|
| 4441 | 4662 | |
| 4442 | 4663 | echo ' |
| 4443 | 4664 | //# sourceURL=dynamicScript-dbch.js |
@@ -4455,18 +4676,21 @@ discard block |
||
| 4455 | 4676 | <item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item> |
| 4456 | 4677 | <debug num="', $upcontext['current_debug_item_num'], '" percent="', isset($upcontext['substep_progress']) ? $upcontext['substep_progress'] : '-1', '" complete="', empty($upcontext['completed_step']) ? 0 : 1, '">', $upcontext['current_debug_item_name'], '</debug>'; |
| 4457 | 4678 | |
| 4458 | - if (!empty($upcontext['error_message'])) |
|
| 4459 | - echo ' |
|
| 4679 | + if (!empty($upcontext['error_message'])) { |
|
| 4680 | + echo ' |
|
| 4460 | 4681 | <error>', $upcontext['error_message'], '</error>'; |
| 4682 | + } |
|
| 4461 | 4683 | |
| 4462 | - if (!empty($upcontext['error_string'])) |
|
| 4463 | - echo ' |
|
| 4684 | + if (!empty($upcontext['error_string'])) { |
|
| 4685 | + echo ' |
|
| 4464 | 4686 | <sql>', $upcontext['error_string'], '</sql>'; |
| 4687 | + } |
|
| 4465 | 4688 | |
| 4466 | - if ($is_debug) |
|
| 4467 | - echo ' |
|
| 4689 | + if ($is_debug) { |
|
| 4690 | + echo ' |
|
| 4468 | 4691 | <curtime>', time(), '</curtime>'; |
| 4469 | -} |
|
| 4692 | + } |
|
| 4693 | + } |
|
| 4470 | 4694 | |
| 4471 | 4695 | // Template for the UTF-8 conversion step. Basically a copy of the backup stuff with slight modifications.... |
| 4472 | 4696 | function template_convert_utf8() |
@@ -4485,18 +4709,20 @@ discard block |
||
| 4485 | 4709 | </div>'; |
| 4486 | 4710 | |
| 4487 | 4711 | // Done any tables so far? |
| 4488 | - if (!empty($upcontext['previous_tables'])) |
|
| 4489 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4712 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4713 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 4490 | 4714 | echo ' |
| 4491 | 4715 | <br>', $txt['upgrade_completed_table'], ' "', $table, '".'; |
| 4716 | + } |
|
| 4492 | 4717 | |
| 4493 | 4718 | echo ' |
| 4494 | 4719 | <h3 id="current_tab_div">', $txt['upgrade_current_table'], ' "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3>'; |
| 4495 | 4720 | |
| 4496 | 4721 | // If we dropped their index, let's let them know |
| 4497 | - if ($upcontext['dropping_index']) |
|
| 4498 | - echo ' |
|
| 4722 | + if ($upcontext['dropping_index']) { |
|
| 4723 | + echo ' |
|
| 4499 | 4724 | <br><span id="indexmsg" style="font-weight: bold; font-style: italic; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">', $txt['upgrade_fulltext'], '</span>'; |
| 4725 | + } |
|
| 4500 | 4726 | |
| 4501 | 4727 | // Completion notification |
| 4502 | 4728 | echo ' |
@@ -4533,12 +4759,13 @@ discard block |
||
| 4533 | 4759 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 4534 | 4760 | |
| 4535 | 4761 | // If debug flood the screen. |
| 4536 | - if ($is_debug) |
|
| 4537 | - echo ' |
|
| 4762 | + if ($is_debug) { |
|
| 4763 | + echo ' |
|
| 4538 | 4764 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 4539 | 4765 | |
| 4540 | 4766 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4541 | 4767 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4768 | + } |
|
| 4542 | 4769 | |
| 4543 | 4770 | echo ' |
| 4544 | 4771 | // Get the next update... |
@@ -4586,19 +4813,21 @@ discard block |
||
| 4586 | 4813 | </div>'; |
| 4587 | 4814 | |
| 4588 | 4815 | // Dont any tables so far? |
| 4589 | - if (!empty($upcontext['previous_tables'])) |
|
| 4590 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4816 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4817 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 4591 | 4818 | echo ' |
| 4592 | 4819 | <br>', $txt['upgrade_completed_table'], ' "', $table, '".'; |
| 4820 | + } |
|
| 4593 | 4821 | |
| 4594 | 4822 | echo ' |
| 4595 | 4823 | <h3 id="current_tab_div">', $txt['upgrade_current_table'], ' "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
| 4596 | 4824 | <br><span id="commess" style="font-weight: bold; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">', $txt['upgrade_json_completed'], '</span>'; |
| 4597 | 4825 | |
| 4598 | 4826 | // Try to make sure substep was reset. |
| 4599 | - if ($upcontext['cur_table_num'] == $upcontext['table_count']) |
|
| 4600 | - echo ' |
|
| 4827 | + if ($upcontext['cur_table_num'] == $upcontext['table_count']) { |
|
| 4828 | + echo ' |
|
| 4601 | 4829 | <input type="hidden" name="substep" id="substep" value="0">'; |
| 4830 | + } |
|
| 4602 | 4831 | |
| 4603 | 4832 | // Continue please! |
| 4604 | 4833 | $upcontext['continue'] = $support_js ? 2 : 1; |
@@ -4631,12 +4860,13 @@ discard block |
||
| 4631 | 4860 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 4632 | 4861 | |
| 4633 | 4862 | // If debug flood the screen. |
| 4634 | - if ($is_debug) |
|
| 4635 | - echo ' |
|
| 4863 | + if ($is_debug) { |
|
| 4864 | + echo ' |
|
| 4636 | 4865 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>', $txt['upgrade_completed_table'], ' "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 4637 | 4866 | |
| 4638 | 4867 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4639 | 4868 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4869 | + } |
|
| 4640 | 4870 | |
| 4641 | 4871 | echo ' |
| 4642 | 4872 | // Get the next update... |
@@ -4672,8 +4902,8 @@ discard block |
||
| 4672 | 4902 | <h3>', $txt['upgrade_done'], ' <a href="', $boardurl, '/index.php">', $txt['upgrade_done2'], '</a>. ', $txt['upgrade_done3'], '</h3> |
| 4673 | 4903 | <form action="', $boardurl, '/index.php">'; |
| 4674 | 4904 | |
| 4675 | - if (!empty($upcontext['can_delete_script'])) |
|
| 4676 | - echo ' |
|
| 4905 | + if (!empty($upcontext['can_delete_script'])) { |
|
| 4906 | + echo ' |
|
| 4677 | 4907 | <label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete(this);"> ', $txt['upgrade_delete_now'], '</label> <em>', $txt['upgrade_delete_server'], '</em> |
| 4678 | 4908 | <script> |
| 4679 | 4909 | function doTheDelete(theCheck) |
@@ -4685,6 +4915,7 @@ discard block |
||
| 4685 | 4915 | } |
| 4686 | 4916 | </script> |
| 4687 | 4917 | <img src="', $settings['default_theme_url'], '/images/blank.png" alt="" id="delete_upgrader"><br>'; |
| 4918 | + } |
|
| 4688 | 4919 | |
| 4689 | 4920 | $active = time() - $upcontext['started']; |
| 4690 | 4921 | $hours = floor($active / 3600); |
@@ -4694,16 +4925,20 @@ discard block |
||
| 4694 | 4925 | if ($is_debug) |
| 4695 | 4926 | { |
| 4696 | 4927 | $totalTime = ''; |
| 4697 | - if ($hours > 0) |
|
| 4698 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4699 | - if ($minutes > 0) |
|
| 4700 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4701 | - if ($seconds > 0) |
|
| 4702 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4928 | + if ($hours > 0) { |
|
| 4929 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4930 | + } |
|
| 4931 | + if ($minutes > 0) { |
|
| 4932 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4933 | + } |
|
| 4934 | + if ($seconds > 0) { |
|
| 4935 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4936 | + } |
|
| 4703 | 4937 | } |
| 4704 | 4938 | |
| 4705 | - if ($is_debug && !empty($totalTime)) |
|
| 4706 | - echo '<br> ', $txt['upgrade_completed_time'], ' ', $totalTime, '<br><br>'; |
|
| 4939 | + if ($is_debug && !empty($totalTime)) { |
|
| 4940 | + echo '<br> ', $txt['upgrade_completed_time'], ' ', $totalTime, '<br><br>'; |
|
| 4941 | + } |
|
| 4707 | 4942 | |
| 4708 | 4943 | echo '<br> |
| 4709 | 4944 | ', sprintf($txt['upgrade_problems'], 'http://simplemachines.org'), '<br> |
@@ -4730,8 +4965,9 @@ discard block |
||
| 4730 | 4965 | |
| 4731 | 4966 | $current_substep = $_GET['substep']; |
| 4732 | 4967 | |
| 4733 | - if (empty($_GET['a'])) |
|
| 4734 | - $_GET['a'] = 0; |
|
| 4968 | + if (empty($_GET['a'])) { |
|
| 4969 | + $_GET['a'] = 0; |
|
| 4970 | + } |
|
| 4735 | 4971 | $step_progress['name'] = 'Converting ips'; |
| 4736 | 4972 | $step_progress['current'] = $_GET['a']; |
| 4737 | 4973 | |
@@ -4774,16 +5010,19 @@ discard block |
||
| 4774 | 5010 | 'empty' => '', |
| 4775 | 5011 | 'limit' => $limit, |
| 4776 | 5012 | )); |
| 4777 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 4778 | - $arIp[] = $row[$oldCol]; |
|
| 5013 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 5014 | + $arIp[] = $row[$oldCol]; |
|
| 5015 | + } |
|
| 4779 | 5016 | $smcFunc['db_free_result']($request); |
| 4780 | 5017 | |
| 4781 | 5018 | // Special case, null ip could keep us in a loop. |
| 4782 | - if (is_null($arIp[0])) |
|
| 4783 | - unset($arIp[0]); |
|
| 5019 | + if (is_null($arIp[0])) { |
|
| 5020 | + unset($arIp[0]); |
|
| 5021 | + } |
|
| 4784 | 5022 | |
| 4785 | - if (empty($arIp)) |
|
| 4786 | - $is_done = true; |
|
| 5023 | + if (empty($arIp)) { |
|
| 5024 | + $is_done = true; |
|
| 5025 | + } |
|
| 4787 | 5026 | |
| 4788 | 5027 | $updates = array(); |
| 4789 | 5028 | $cases = array(); |
@@ -4792,16 +5031,18 @@ discard block |
||
| 4792 | 5031 | { |
| 4793 | 5032 | $arIp[$i] = trim($arIp[$i]); |
| 4794 | 5033 | |
| 4795 | - if (empty($arIp[$i])) |
|
| 4796 | - continue; |
|
| 5034 | + if (empty($arIp[$i])) { |
|
| 5035 | + continue; |
|
| 5036 | + } |
|
| 4797 | 5037 | |
| 4798 | 5038 | $updates['ip' . $i] = $arIp[$i]; |
| 4799 | 5039 | $cases[$arIp[$i]] = 'WHEN ' . $oldCol . ' = {string:ip' . $i . '} THEN {inet:ip' . $i . '}'; |
| 4800 | 5040 | |
| 4801 | 5041 | if ($setSize > 0 && $i % $setSize === 0) |
| 4802 | 5042 | { |
| 4803 | - if (count($updates) == 1) |
|
| 4804 | - continue; |
|
| 5043 | + if (count($updates) == 1) { |
|
| 5044 | + continue; |
|
| 5045 | + } |
|
| 4805 | 5046 | |
| 4806 | 5047 | $updates['whereSet'] = array_values($updates); |
| 4807 | 5048 | $smcFunc['db_query']('', ' |
@@ -4835,8 +5076,7 @@ discard block |
||
| 4835 | 5076 | 'ip' => $ip |
| 4836 | 5077 | )); |
| 4837 | 5078 | } |
| 4838 | - } |
|
| 4839 | - else |
|
| 5079 | + } else |
|
| 4840 | 5080 | { |
| 4841 | 5081 | $updates['whereSet'] = array_values($updates); |
| 4842 | 5082 | $smcFunc['db_query']('', ' |
@@ -4850,9 +5090,9 @@ discard block |
||
| 4850 | 5090 | $updates |
| 4851 | 5091 | ); |
| 4852 | 5092 | } |
| 5093 | + } else { |
|
| 5094 | + $is_done = true; |
|
| 4853 | 5095 | } |
| 4854 | - else |
|
| 4855 | - $is_done = true; |
|
| 4856 | 5096 | |
| 4857 | 5097 | $_GET['a'] += $limit; |
| 4858 | 5098 | $step_progress['current'] = $_GET['a']; |
@@ -4878,10 +5118,11 @@ discard block |
||
| 4878 | 5118 | |
| 4879 | 5119 | $columns = $smcFunc['db_list_columns']($targetTable, true); |
| 4880 | 5120 | |
| 4881 | - if (isset($columns[$column])) |
|
| 4882 | - return $columns[$column]; |
|
| 4883 | - else |
|
| 4884 | - return null; |
|
| 4885 | -} |
|
| 5121 | + if (isset($columns[$column])) { |
|
| 5122 | + return $columns[$column]; |
|
| 5123 | + } else { |
|
| 5124 | + return null; |
|
| 5125 | + } |
|
| 5126 | + } |
|
| 4886 | 5127 | |
| 4887 | 5128 | ?> |
| 4888 | 5129 | \ No newline at end of file |
@@ -28,14 +28,15 @@ discard block |
||
| 28 | 28 | <div id="confirm_buttons">'; |
| 29 | 29 | |
| 30 | 30 | // Age restriction in effect? |
| 31 | - if ($context['show_coppa']) |
|
| 32 | - echo ' |
|
| 31 | + if ($context['show_coppa']) { |
|
| 32 | + echo ' |
|
| 33 | 33 | <input type="submit" name="accept_agreement" value="', $context['coppa_agree_above'], '" class="button"><br> |
| 34 | 34 | <br> |
| 35 | 35 | <input type="submit" name="accept_agreement_coppa" value="', $context['coppa_agree_below'], '" class="button">'; |
| 36 | - else |
|
| 37 | - echo ' |
|
| 36 | + } else { |
|
| 37 | + echo ' |
|
| 38 | 38 | <input type="submit" name="accept_agreement" value="', $txt['agreement_agree'], '" class="button">'; |
| 39 | + } |
|
| 39 | 40 | |
| 40 | 41 | echo ' |
| 41 | 42 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -78,9 +79,10 @@ discard block |
||
| 78 | 79 | <ul>'; |
| 79 | 80 | |
| 80 | 81 | // Cycle through each error and display an error message. |
| 81 | - foreach ($context['registration_errors'] as $error) |
|
| 82 | - echo ' |
|
| 82 | + foreach ($context['registration_errors'] as $error) { |
|
| 83 | + echo ' |
|
| 83 | 84 | <li>', $error, '</li>'; |
| 85 | + } |
|
| 84 | 86 | |
| 85 | 87 | echo ' |
| 86 | 88 | </ul> |
@@ -149,14 +151,15 @@ discard block |
||
| 149 | 151 | echo ' |
| 150 | 152 | <dl class="register_form">'; |
| 151 | 153 | |
| 152 | - foreach ($context['custom_fields'] as $field) |
|
| 153 | - if ($field['show_reg'] > 1) |
|
| 154 | + foreach ($context['custom_fields'] as $field) { |
|
| 155 | + if ($field['show_reg'] > 1) |
|
| 154 | 156 | echo ' |
| 155 | 157 | <dt> |
| 156 | 158 | <strong', !empty($field['is_error']) ? ' class="red"' : '', '>', $field['name'], ':</strong> |
| 157 | 159 | <span class="smalltext">', $field['desc'], '</span> |
| 158 | 160 | </dt> |
| 159 | 161 | <dd>', str_replace('name="', 'tabindex="' . $context['tabindex']++ . '" name="', $field['input_html']), '</dd>'; |
| 162 | + } |
|
| 160 | 163 | |
| 161 | 164 | echo ' |
| 162 | 165 | </dl>'; |
@@ -167,14 +170,15 @@ discard block |
||
| 167 | 170 | </div><!-- .roundframe -->'; |
| 168 | 171 | |
| 169 | 172 | // If we have either of these, show the extra group. |
| 170 | - if (!empty($context['profile_fields']) || !empty($context['custom_fields'])) |
|
| 171 | - echo ' |
|
| 173 | + if (!empty($context['profile_fields']) || !empty($context['custom_fields'])) { |
|
| 174 | + echo ' |
|
| 172 | 175 | <div class="title_bar title_top"> |
| 173 | 176 | <h3 class="titlebg">', $txt['additional_information'], '</h3> |
| 174 | 177 | </div> |
| 175 | 178 | <div class="roundframe noup"> |
| 176 | 179 | <fieldset> |
| 177 | 180 | <dl class="register_form" id="custom_group">'; |
| 181 | + } |
|
| 178 | 182 | |
| 179 | 183 | if (!empty($context['profile_fields'])) |
| 180 | 184 | { |
@@ -188,41 +192,45 @@ discard block |
||
| 188 | 192 | $callback_func = 'template_profile_' . $field['callback_func']; |
| 189 | 193 | $callback_func(); |
| 190 | 194 | } |
| 191 | - } |
|
| 192 | - else |
|
| 195 | + } else |
|
| 193 | 196 | { |
| 194 | 197 | echo ' |
| 195 | 198 | <dt> |
| 196 | 199 | <strong', !empty($field['is_error']) ? ' class="red"' : '', '>', $field['label'], ':</strong>'; |
| 197 | 200 | |
| 198 | 201 | // Does it have any subtext to show? |
| 199 | - if (!empty($field['subtext'])) |
|
| 200 | - echo ' |
|
| 202 | + if (!empty($field['subtext'])) { |
|
| 203 | + echo ' |
|
| 201 | 204 | <span class="smalltext">', $field['subtext'], '</span>'; |
| 205 | + } |
|
| 202 | 206 | |
| 203 | 207 | echo ' |
| 204 | 208 | </dt> |
| 205 | 209 | <dd>'; |
| 206 | 210 | |
| 207 | 211 | // Want to put something infront of the box? |
| 208 | - if (!empty($field['preinput'])) |
|
| 209 | - echo ' |
|
| 212 | + if (!empty($field['preinput'])) { |
|
| 213 | + echo ' |
|
| 210 | 214 | ', $field['preinput']; |
| 215 | + } |
|
| 211 | 216 | |
| 212 | 217 | // What type of data are we showing? |
| 213 | - if ($field['type'] == 'label') |
|
| 214 | - echo ' |
|
| 218 | + if ($field['type'] == 'label') { |
|
| 219 | + echo ' |
|
| 215 | 220 | ', $field['value']; |
| 221 | + } |
|
| 216 | 222 | |
| 217 | 223 | // Maybe it's a text box - very likely! |
| 218 | - elseif (in_array($field['type'], array('int', 'float', 'text', 'password', 'url'))) |
|
| 219 | - echo ' |
|
| 224 | + elseif (in_array($field['type'], array('int', 'float', 'text', 'password', 'url'))) { |
|
| 225 | + echo ' |
|
| 220 | 226 | <input type="', $field['type'] == 'password' ? 'password' : 'text', '" name="', $key, '" id="', $key, '" size="', empty($field['size']) ? 30 : $field['size'], '" value="', $field['value'], '" tabindex="', $context['tabindex']++, '" ', $field['input_attr'], '>'; |
| 227 | + } |
|
| 221 | 228 | |
| 222 | 229 | // You "checking" me out? ;) |
| 223 | - elseif ($field['type'] == 'check') |
|
| 224 | - echo ' |
|
| 230 | + elseif ($field['type'] == 'check') { |
|
| 231 | + echo ' |
|
| 225 | 232 | <input type="hidden" name="', $key, '" value="0"><input type="checkbox" name="', $key, '" id="', $key, '"', !empty($field['value']) ? ' checked' : '', ' value="1" tabindex="', $context['tabindex']++, '" ', $field['input_attr'], '>'; |
| 233 | + } |
|
| 226 | 234 | |
| 227 | 235 | // Always fun - select boxes! |
| 228 | 236 | elseif ($field['type'] == 'select') |
@@ -233,14 +241,16 @@ discard block |
||
| 233 | 241 | if (isset($field['options'])) |
| 234 | 242 | { |
| 235 | 243 | // Is this some code to generate the options? |
| 236 | - if (!is_array($field['options'])) |
|
| 237 | - $field['options'] = eval($field['options']); |
|
| 244 | + if (!is_array($field['options'])) { |
|
| 245 | + $field['options'] = eval($field['options']); |
|
| 246 | + } |
|
| 238 | 247 | |
| 239 | 248 | // Assuming we now have some! |
| 240 | - if (is_array($field['options'])) |
|
| 241 | - foreach ($field['options'] as $value => $name) |
|
| 249 | + if (is_array($field['options'])) { |
|
| 250 | + foreach ($field['options'] as $value => $name) |
|
| 242 | 251 | echo ' |
| 243 | 252 | <option', is_numeric($value) ? ' value="" disabled' : ' value="' . $value . '"', $value === $field['value'] ? ' selected' : '', '>', $name, '</option>'; |
| 253 | + } |
|
| 244 | 254 | } |
| 245 | 255 | |
| 246 | 256 | echo ' |
@@ -248,9 +258,10 @@ discard block |
||
| 248 | 258 | } |
| 249 | 259 | |
| 250 | 260 | // Something to end with? |
| 251 | - if (!empty($field['postinput'])) |
|
| 252 | - echo ' |
|
| 261 | + if (!empty($field['postinput'])) { |
|
| 262 | + echo ' |
|
| 253 | 263 | ', $field['postinput']; |
| 264 | + } |
|
| 254 | 265 | |
| 255 | 266 | echo ' |
| 256 | 267 | </dd>'; |
@@ -261,25 +272,27 @@ discard block |
||
| 261 | 272 | // Are there any custom fields? |
| 262 | 273 | if (!empty($context['custom_fields'])) |
| 263 | 274 | { |
| 264 | - foreach ($context['custom_fields'] as $field) |
|
| 265 | - if ($field['show_reg'] < 2) |
|
| 275 | + foreach ($context['custom_fields'] as $field) { |
|
| 276 | + if ($field['show_reg'] < 2) |
|
| 266 | 277 | echo ' |
| 267 | 278 | <dt> |
| 268 | 279 | <strong', !empty($field['is_error']) ? ' class="red"' : '', '>', $field['name'], ':</strong> |
| 269 | 280 | <span class="smalltext">', $field['desc'], '</span> |
| 270 | 281 | </dt> |
| 271 | 282 | <dd>', $field['input_html'], '</dd>'; |
| 283 | + } |
|
| 272 | 284 | } |
| 273 | 285 | |
| 274 | 286 | // If we have either of these, close the list like a proper gent. |
| 275 | - if (!empty($context['profile_fields']) || !empty($context['custom_fields'])) |
|
| 276 | - echo ' |
|
| 287 | + if (!empty($context['profile_fields']) || !empty($context['custom_fields'])) { |
|
| 288 | + echo ' |
|
| 277 | 289 | </dl> |
| 278 | 290 | </fieldset> |
| 279 | 291 | </div><!-- .roundframe -->'; |
| 292 | + } |
|
| 280 | 293 | |
| 281 | - if ($context['visual_verification']) |
|
| 282 | - echo ' |
|
| 294 | + if ($context['visual_verification']) { |
|
| 295 | + echo ' |
|
| 283 | 296 | <div class="title_bar title_top"> |
| 284 | 297 | <h3 class="titlebg">', $txt['verification'], '</h3> |
| 285 | 298 | </div> |
@@ -288,19 +301,21 @@ discard block |
||
| 288 | 301 | ', template_control_verification($context['visual_verification_id'], 'all'), ' |
| 289 | 302 | </fieldset> |
| 290 | 303 | </div>'; |
| 304 | + } |
|
| 291 | 305 | |
| 292 | 306 | echo ' |
| 293 | 307 | <div id="confirm_buttons" class="flow_auto">'; |
| 294 | 308 | |
| 295 | 309 | // Age restriction in effect? |
| 296 | - if (!$context['require_agreement'] && $context['show_coppa']) |
|
| 297 | - echo ' |
|
| 310 | + if (!$context['require_agreement'] && $context['show_coppa']) { |
|
| 311 | + echo ' |
|
| 298 | 312 | <input type="submit" name="accept_agreement" value="', $context['coppa_agree_above'], '" class="button"><br> |
| 299 | 313 | <br> |
| 300 | 314 | <input type="submit" name="accept_agreement_coppa" value="', $context['coppa_agree_below'], '" class="button">'; |
| 301 | - else |
|
| 302 | - echo ' |
|
| 315 | + } else { |
|
| 316 | + echo ' |
|
| 303 | 317 | <input type="submit" name="regSubmit" value="', $txt['register'], '" tabindex="', $context['tabindex']++, '" class="button">'; |
| 318 | + } |
|
| 304 | 319 | |
| 305 | 320 | echo ' |
| 306 | 321 | </div> |
@@ -362,25 +377,28 @@ discard block |
||
| 362 | 377 | <p>', $context['coppa']['many_options'] ? $txt['coppa_send_to_two_options'] : $txt['coppa_send_to_one_option'], '</p>'; |
| 363 | 378 | |
| 364 | 379 | // Can they send by post? |
| 365 | - if (!empty($context['coppa']['post'])) |
|
| 366 | - echo ' |
|
| 380 | + if (!empty($context['coppa']['post'])) { |
|
| 381 | + echo ' |
|
| 367 | 382 | <h4>1) ', $txt['coppa_send_by_post'], '</h4> |
| 368 | 383 | <div class="coppa_contact"> |
| 369 | 384 | ', $context['coppa']['post'], ' |
| 370 | 385 | </div>'; |
| 386 | + } |
|
| 371 | 387 | |
| 372 | 388 | // Can they send by fax?? |
| 373 | - if (!empty($context['coppa']['fax'])) |
|
| 374 | - echo ' |
|
| 389 | + if (!empty($context['coppa']['fax'])) { |
|
| 390 | + echo ' |
|
| 375 | 391 | <h4>', !empty($context['coppa']['post']) ? '2' : '1', ') ', $txt['coppa_send_by_fax'], '</h4> |
| 376 | 392 | <div class="coppa_contact"> |
| 377 | 393 | ', $context['coppa']['fax'], ' |
| 378 | 394 | </div>'; |
| 395 | + } |
|
| 379 | 396 | |
| 380 | 397 | // Offer an alternative Phone Number? |
| 381 | - if ($context['coppa']['phone']) |
|
| 382 | - echo ' |
|
| 398 | + if ($context['coppa']['phone']) { |
|
| 399 | + echo ' |
|
| 383 | 400 | <p>', $context['coppa']['phone'], '</p>'; |
| 401 | + } |
|
| 384 | 402 | |
| 385 | 403 | echo ' |
| 386 | 404 | </div><!-- #coppa -->'; |
@@ -445,19 +463,20 @@ discard block |
||
| 445 | 463 | <body style="margin: 1ex;"> |
| 446 | 464 | <div class="windowbg description" style="text-align: center;">'; |
| 447 | 465 | |
| 448 | - if (isBrowser('is_ie') || isBrowser('is_ie11')) |
|
| 449 | - echo ' |
|
| 466 | + if (isBrowser('is_ie') || isBrowser('is_ie11')) { |
|
| 467 | + echo ' |
|
| 450 | 468 | <object classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" type="audio/x-wav"> |
| 451 | 469 | <param name="AutoStart" value="1"> |
| 452 | 470 | <param name="FileName" value="', $context['verification_sound_href'], '"> |
| 453 | 471 | </object>'; |
| 454 | - else |
|
| 455 | - echo ' |
|
| 472 | + } else { |
|
| 473 | + echo ' |
|
| 456 | 474 | <audio src="', $context['verification_sound_href'], '" controls> |
| 457 | 475 | <object type="audio/x-wav" data="', $context['verification_sound_href'], '"> |
| 458 | 476 | <a href="', $context['verification_sound_href'], '" rel="nofollow">', $context['verification_sound_href'], '</a> |
| 459 | 477 | </object> |
| 460 | 478 | </audio>'; |
| 479 | + } |
|
| 461 | 480 | |
| 462 | 481 | echo ' |
| 463 | 482 | <br> |
@@ -485,11 +504,12 @@ discard block |
||
| 485 | 504 | </div> |
| 486 | 505 | <div id="register_screen" class="windowbg2 noup">'; |
| 487 | 506 | |
| 488 | - if (!empty($context['registration_done'])) |
|
| 489 | - echo ' |
|
| 507 | + if (!empty($context['registration_done'])) { |
|
| 508 | + echo ' |
|
| 490 | 509 | <div class="infobox"> |
| 491 | 510 | ', $context['registration_done'], ' |
| 492 | 511 | </div>'; |
| 512 | + } |
|
| 493 | 513 | |
| 494 | 514 | echo ' |
| 495 | 515 | <dl class="register_form" id="admin_register_form"> |
@@ -525,9 +545,10 @@ discard block |
||
| 525 | 545 | <dd> |
| 526 | 546 | <select name="group" id="group_select" tabindex="', $context['tabindex']++, '">'; |
| 527 | 547 | |
| 528 | - foreach ($context['member_groups'] as $id => $name) |
|
| 529 | - echo ' |
|
| 548 | + foreach ($context['member_groups'] as $id => $name) { |
|
| 549 | + echo ' |
|
| 530 | 550 | <option value="', $id, '">', $name, '</option>'; |
| 551 | + } |
|
| 531 | 552 | |
| 532 | 553 | echo ' |
| 533 | 554 | </select> |
@@ -535,8 +556,8 @@ discard block |
||
| 535 | 556 | } |
| 536 | 557 | |
| 537 | 558 | // If there is any field marked as required, show it here! |
| 538 | - if (!empty($context['custom_fields_required']) && !empty($context['custom_fields'])) |
|
| 539 | - foreach ($context['custom_fields'] as $field) |
|
| 559 | + if (!empty($context['custom_fields_required']) && !empty($context['custom_fields'])) { |
|
| 560 | + foreach ($context['custom_fields'] as $field) |
|
| 540 | 561 | if ($field['show_reg'] > 1) |
| 541 | 562 | echo ' |
| 542 | 563 | <dt> |
@@ -546,6 +567,7 @@ discard block |
||
| 546 | 567 | <dd> |
| 547 | 568 | ', str_replace('name="', 'tabindex="' . $context['tabindex']++ . '" name="', $field['input_html']), ' |
| 548 | 569 | </dd>'; |
| 570 | + } |
|
| 549 | 571 | |
| 550 | 572 | echo ' |
| 551 | 573 | <dt> |
@@ -582,13 +604,13 @@ discard block |
||
| 582 | 604 | { |
| 583 | 605 | global $context, $scripturl, $txt; |
| 584 | 606 | |
| 585 | - if (!empty($context['saved_successful'])) |
|
| 586 | - echo ' |
|
| 607 | + if (!empty($context['saved_successful'])) { |
|
| 608 | + echo ' |
|
| 587 | 609 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
| 588 | - |
|
| 589 | - elseif (!empty($context['could_not_save'])) |
|
| 590 | - echo ' |
|
| 610 | + } elseif (!empty($context['could_not_save'])) { |
|
| 611 | + echo ' |
|
| 591 | 612 | <div class="errorbox">', $txt['admin_agreement_not_saved'], '</div>'; |
| 613 | + } |
|
| 592 | 614 | |
| 593 | 615 | // Just a big box to edit the text file ;) |
| 594 | 616 | echo ' |
@@ -598,9 +620,10 @@ discard block |
||
| 598 | 620 | </div>'; |
| 599 | 621 | |
| 600 | 622 | // Warning for if the file isn't writable. |
| 601 | - if (!empty($context['warning'])) |
|
| 602 | - echo ' |
|
| 623 | + if (!empty($context['warning'])) { |
|
| 624 | + echo ' |
|
| 603 | 625 | <p class="error">', $context['warning'], '</p>'; |
| 626 | + } |
|
| 604 | 627 | |
| 605 | 628 | echo ' |
| 606 | 629 | <div class="windowbg2 noup" id="registration_agreement">'; |
@@ -617,9 +640,10 @@ discard block |
||
| 617 | 640 | <strong>', $txt['admin_agreement_select_language'], ':</strong> |
| 618 | 641 | <select name="agree_lang" onchange="document.getElementById(\'change_reg\').submit();" tabindex="', $context['tabindex']++, '">'; |
| 619 | 642 | |
| 620 | - foreach ($context['editable_agreements'] as $file => $name) |
|
| 621 | - echo ' |
|
| 643 | + foreach ($context['editable_agreements'] as $file => $name) { |
|
| 644 | + echo ' |
|
| 622 | 645 | <option value="', $file, '"', $context['current_agreement'] == $file ? ' selected' : '', '>', $name, '</option>'; |
| 646 | + } |
|
| 623 | 647 | |
| 624 | 648 | echo ' |
| 625 | 649 | </select> |
@@ -659,9 +683,10 @@ discard block |
||
| 659 | 683 | { |
| 660 | 684 | global $context, $scripturl, $txt; |
| 661 | 685 | |
| 662 | - if (!empty($context['saved_successful'])) |
|
| 663 | - echo ' |
|
| 686 | + if (!empty($context['saved_successful'])) { |
|
| 687 | + echo ' |
|
| 664 | 688 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
| 689 | + } |
|
| 665 | 690 | |
| 666 | 691 | echo ' |
| 667 | 692 | <form id="admin_form_wrapper" action="', $scripturl, '?action=admin;area=regcenter" method="post" accept-charset="', $context['character_set'], '"> |
@@ -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.) |
@@ -99,19 +101,19 @@ discard block |
||
| 99 | 101 | </div> |
| 100 | 102 | <div class="alerts_unread">'; |
| 101 | 103 | |
| 102 | - if (empty($context['unread_alerts'])) |
|
| 103 | - template_alerts_all_read(); |
|
| 104 | - |
|
| 105 | - else |
|
| 104 | + if (empty($context['unread_alerts'])) { |
|
| 105 | + template_alerts_all_read(); |
|
| 106 | + } else |
|
| 106 | 107 | { |
| 107 | - foreach ($context['unread_alerts'] as $id_alert => $details) |
|
| 108 | - echo ' |
|
| 108 | + foreach ($context['unread_alerts'] as $id_alert => $details) { |
|
| 109 | + echo ' |
|
| 109 | 110 | <div class="unread"> |
| 110 | 111 | ', !empty($details['sender']) ? $details['sender']['avatar']['image'] : '', ' |
| 111 | 112 | <div class="details"> |
| 112 | 113 | ', !empty($details['icon']) ? $details['icon'] : '', '<span>', $details['text'], '</span> - ', $details['time'], ' |
| 113 | 114 | </div> |
| 114 | 115 | </div>'; |
| 116 | + } |
|
| 115 | 117 | } |
| 116 | 118 | |
| 117 | 119 | echo ' |
@@ -158,37 +160,41 @@ discard block |
||
| 158 | 160 | if (!empty($context['print_custom_fields']['above_member'])) |
| 159 | 161 | { |
| 160 | 162 | $fields = ''; |
| 161 | - foreach ($context['print_custom_fields']['above_member'] as $field) |
|
| 162 | - if (!empty($field['output_html'])) |
|
| 163 | + foreach ($context['print_custom_fields']['above_member'] as $field) { |
|
| 164 | + if (!empty($field['output_html'])) |
|
| 163 | 165 | $fields .= ' |
| 164 | 166 | <li>' . $field['output_html'] . '</li>'; |
| 167 | + } |
|
| 165 | 168 | |
| 166 | - if (!empty($fields)) |
|
| 167 | - echo ' |
|
| 169 | + if (!empty($fields)) { |
|
| 170 | + echo ' |
|
| 168 | 171 | <div class="custom_fields_above_name"> |
| 169 | 172 | <ul>', $fields, ' |
| 170 | 173 | </ul> |
| 171 | 174 | </div>'; |
| 175 | + } |
|
| 172 | 176 | } |
| 173 | 177 | |
| 174 | 178 | echo ' |
| 175 | 179 | <div class="username clear"> |
| 176 | 180 | <h4>'; |
| 177 | 181 | |
| 178 | - if (!empty($context['print_custom_fields']['before_member'])) |
|
| 179 | - foreach ($context['print_custom_fields']['before_member'] as $field) |
|
| 182 | + if (!empty($context['print_custom_fields']['before_member'])) { |
|
| 183 | + foreach ($context['print_custom_fields']['before_member'] as $field) |
|
| 180 | 184 | if (!empty($field['output_html'])) |
| 181 | 185 | echo ' |
| 182 | 186 | <span>', $field['output_html'], '</span>'; |
| 187 | + } |
|
| 183 | 188 | |
| 184 | 189 | echo ' |
| 185 | 190 | ', $context['member']['name']; |
| 186 | 191 | |
| 187 | - if (!empty($context['print_custom_fields']['after_member'])) |
|
| 188 | - foreach ($context['print_custom_fields']['after_member'] as $field) |
|
| 192 | + if (!empty($context['print_custom_fields']['after_member'])) { |
|
| 193 | + foreach ($context['print_custom_fields']['after_member'] as $field) |
|
| 189 | 194 | if (!empty($field['output_html'])) |
| 190 | 195 | echo ' |
| 191 | 196 | <span>', $field['output_html'], '</span>'; |
| 197 | + } |
|
| 192 | 198 | |
| 193 | 199 | |
| 194 | 200 | echo ' |
@@ -201,39 +207,44 @@ discard block |
||
| 201 | 207 | if (!empty($context['print_custom_fields']['below_avatar'])) |
| 202 | 208 | { |
| 203 | 209 | $fields = ''; |
| 204 | - foreach ($context['print_custom_fields']['below_avatar'] as $field) |
|
| 205 | - if (!empty($field['output_html'])) |
|
| 210 | + foreach ($context['print_custom_fields']['below_avatar'] as $field) { |
|
| 211 | + if (!empty($field['output_html'])) |
|
| 206 | 212 | $fields .= ' |
| 207 | 213 | <li>' . $field['output_html'] . '</li>'; |
| 214 | + } |
|
| 208 | 215 | |
| 209 | - if (!empty($fields)) |
|
| 210 | - echo ' |
|
| 216 | + if (!empty($fields)) { |
|
| 217 | + echo ' |
|
| 211 | 218 | <div class="custom_fields_below_avatar"> |
| 212 | 219 | <ul>', $fields, ' |
| 213 | 220 | </ul> |
| 214 | 221 | </div>'; |
| 222 | + } |
|
| 215 | 223 | } |
| 216 | 224 | |
| 217 | 225 | echo ' |
| 218 | 226 | <ul class="icon_fields clear">'; |
| 219 | 227 | |
| 220 | 228 | // Email is only visible if it's your profile or you have the moderate_forum permission |
| 221 | - if ($context['member']['show_email']) |
|
| 222 | - echo ' |
|
| 229 | + if ($context['member']['show_email']) { |
|
| 230 | + echo ' |
|
| 223 | 231 | <li><a href="mailto:', $context['member']['email'], '" title="', $context['member']['email'], '" rel="nofollow"><span class="generic_icons mail" title="' . $txt['email'] . '"></span></a></li>'; |
| 232 | + } |
|
| 224 | 233 | |
| 225 | 234 | // Don't show an icon if they haven't specified a website. |
| 226 | - if ($context['member']['website']['url'] !== '' && !isset($context['disabled_fields']['website'])) |
|
| 227 | - echo ' |
|
| 235 | + if ($context['member']['website']['url'] !== '' && !isset($context['disabled_fields']['website'])) { |
|
| 236 | + echo ' |
|
| 228 | 237 | <li><a href="', $context['member']['website']['url'], '" title="' . $context['member']['website']['title'] . '" target="_blank" rel="noopener">', ($settings['use_image_buttons'] ? '<span class="generic_icons www" title="' . $context['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>'; |
| 238 | + } |
|
| 229 | 239 | |
| 230 | 240 | // Are there any custom profile fields as icons? |
| 231 | 241 | if (!empty($context['print_custom_fields']['icons'])) |
| 232 | 242 | { |
| 233 | - foreach ($context['print_custom_fields']['icons'] as $field) |
|
| 234 | - if (!empty($field['output_html'])) |
|
| 243 | + foreach ($context['print_custom_fields']['icons'] as $field) { |
|
| 244 | + if (!empty($field['output_html'])) |
|
| 235 | 245 | echo ' |
| 236 | 246 | <li class="custom_field">', $field['output_html'], '</li>'; |
| 247 | + } |
|
| 237 | 248 | } |
| 238 | 249 | |
| 239 | 250 | echo ' |
@@ -242,24 +253,27 @@ discard block |
||
| 242 | 253 | ', $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>' : ''; |
| 243 | 254 | |
| 244 | 255 | // Can they add this member as a buddy? |
| 245 | - if (!empty($context['can_have_buddy']) && !$context['user']['is_owner']) |
|
| 246 | - echo ' |
|
| 256 | + if (!empty($context['can_have_buddy']) && !$context['user']['is_owner']) { |
|
| 257 | + echo ' |
|
| 247 | 258 | <br> |
| 248 | 259 | <a href="', $scripturl, '?action=buddy;u=', $context['id_member'], ';', $context['session_var'], '=', $context['session_id'], '">[', $txt['buddy_' . ($context['member']['is_buddy'] ? 'remove' : 'add')], ']</a>'; |
| 260 | + } |
|
| 249 | 261 | |
| 250 | 262 | echo ' |
| 251 | 263 | </span>'; |
| 252 | 264 | |
| 253 | - if (!$context['user']['is_owner'] && $context['can_send_pm']) |
|
| 254 | - echo ' |
|
| 265 | + if (!$context['user']['is_owner'] && $context['can_send_pm']) { |
|
| 266 | + echo ' |
|
| 255 | 267 | <a href="', $scripturl, '?action=pm;sa=send;u=', $context['id_member'], '" class="infolinks">', $txt['profile_sendpm_short'], '</a>'; |
| 268 | + } |
|
| 256 | 269 | |
| 257 | 270 | echo ' |
| 258 | 271 | <a href="', $scripturl, '?action=profile;area=showposts;u=', $context['id_member'], '" class="infolinks">', $txt['showPosts'], '</a>'; |
| 259 | 272 | |
| 260 | - if ($context['user']['is_owner'] && !empty($modSettings['drafts_post_enabled'])) |
|
| 261 | - echo ' |
|
| 273 | + if ($context['user']['is_owner'] && !empty($modSettings['drafts_post_enabled'])) { |
|
| 274 | + echo ' |
|
| 262 | 275 | <a href="', $scripturl, '?action=profile;area=showdrafts;u=', $context['id_member'], '" class="infolinks">', $txt['drafts_show'], '</a>'; |
| 276 | + } |
|
| 263 | 277 | |
| 264 | 278 | echo ' |
| 265 | 279 | <a href="', $scripturl, '?action=profile;area=statistics;u=', $context['id_member'], '" class="infolinks">', $txt['statPanel'], '</a>'; |
@@ -268,17 +282,19 @@ discard block |
||
| 268 | 282 | if (!empty($context['print_custom_fields']['bottom_poster'])) |
| 269 | 283 | { |
| 270 | 284 | $fields = ''; |
| 271 | - foreach ($context['print_custom_fields']['bottom_poster'] as $field) |
|
| 272 | - if (!empty($field['output_html'])) |
|
| 285 | + foreach ($context['print_custom_fields']['bottom_poster'] as $field) { |
|
| 286 | + if (!empty($field['output_html'])) |
|
| 273 | 287 | $fields .= ' |
| 274 | 288 | <li>' . $field['output_html'] . '</li>'; |
| 289 | + } |
|
| 275 | 290 | |
| 276 | - if (!empty($fields)) |
|
| 277 | - echo ' |
|
| 291 | + if (!empty($fields)) { |
|
| 292 | + echo ' |
|
| 278 | 293 | <div class="custom_fields_bottom"> |
| 279 | 294 | <ul class="nolist">', $fields, ' |
| 280 | 295 | </ul> |
| 281 | 296 | </div>'; |
| 297 | + } |
|
| 282 | 298 | } |
| 283 | 299 | |
| 284 | 300 | echo ' |
@@ -287,30 +303,35 @@ discard block |
||
| 287 | 303 | <div id="detailedinfo"> |
| 288 | 304 | <dl class="settings">'; |
| 289 | 305 | |
| 290 | - if ($context['user']['is_owner'] || $context['user']['is_admin']) |
|
| 291 | - echo ' |
|
| 306 | + if ($context['user']['is_owner'] || $context['user']['is_admin']) { |
|
| 307 | + echo ' |
|
| 292 | 308 | <dt>', $txt['username'], ': </dt> |
| 293 | 309 | <dd>', $context['member']['username'], '</dd>'; |
| 310 | + } |
|
| 294 | 311 | |
| 295 | - if (!isset($context['disabled_fields']['posts'])) |
|
| 296 | - echo ' |
|
| 312 | + if (!isset($context['disabled_fields']['posts'])) { |
|
| 313 | + echo ' |
|
| 297 | 314 | <dt>', $txt['profile_posts'], ': </dt> |
| 298 | 315 | <dd>', $context['member']['posts'], ' (', $context['member']['posts_per_day'], ' ', $txt['posts_per_day'], ')</dd>'; |
| 316 | + } |
|
| 299 | 317 | |
| 300 | - if ($context['member']['show_email']) |
|
| 301 | - echo ' |
|
| 318 | + if ($context['member']['show_email']) { |
|
| 319 | + echo ' |
|
| 302 | 320 | <dt>', $txt['email'], ': </dt> |
| 303 | 321 | <dd><a href="mailto:', $context['member']['email'], '">', $context['member']['email'], '</a></dd>'; |
| 322 | + } |
|
| 304 | 323 | |
| 305 | - if (!empty($modSettings['titlesEnable']) && !empty($context['member']['title'])) |
|
| 306 | - echo ' |
|
| 324 | + if (!empty($modSettings['titlesEnable']) && !empty($context['member']['title'])) { |
|
| 325 | + echo ' |
|
| 307 | 326 | <dt>', $txt['custom_title'], ': </dt> |
| 308 | 327 | <dd>', $context['member']['title'], '</dd>'; |
| 328 | + } |
|
| 309 | 329 | |
| 310 | - if (!empty($context['member']['blurb'])) |
|
| 311 | - echo ' |
|
| 330 | + if (!empty($context['member']['blurb'])) { |
|
| 331 | + echo ' |
|
| 312 | 332 | <dt>', $txt['personal_text'], ': </dt> |
| 313 | 333 | <dd>', $context['member']['blurb'], '</dd>'; |
| 334 | + } |
|
| 314 | 335 | |
| 315 | 336 | echo ' |
| 316 | 337 | <dt>', $txt['age'], ':</dt> |
@@ -324,19 +345,21 @@ discard block |
||
| 324 | 345 | { |
| 325 | 346 | $fields = array(); |
| 326 | 347 | |
| 327 | - foreach ($context['print_custom_fields']['standard'] as $field) |
|
| 328 | - if (!empty($field['output_html'])) |
|
| 348 | + foreach ($context['print_custom_fields']['standard'] as $field) { |
|
| 349 | + if (!empty($field['output_html'])) |
|
| 329 | 350 | $fields[] = $field; |
| 351 | + } |
|
| 330 | 352 | |
| 331 | 353 | if (count($fields) > 0) |
| 332 | 354 | { |
| 333 | 355 | echo ' |
| 334 | 356 | <dl class="settings">'; |
| 335 | 357 | |
| 336 | - foreach ($fields as $field) |
|
| 337 | - echo ' |
|
| 358 | + foreach ($fields as $field) { |
|
| 359 | + echo ' |
|
| 338 | 360 | <dt>', $field['name'], ':</dt> |
| 339 | 361 | <dd>', $field['output_html'], '</dd>'; |
| 362 | + } |
|
| 340 | 363 | |
| 341 | 364 | echo ' |
| 342 | 365 | </dl>'; |
@@ -355,9 +378,10 @@ discard block |
||
| 355 | 378 | <a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=', ($context['can_issue_warning'] && !$context['user']['is_owner'] ? 'issuewarning' : 'viewwarning'), '">', $context['member']['warning'], '%</a>'; |
| 356 | 379 | |
| 357 | 380 | // Can we provide information on what this means? |
| 358 | - if (!empty($context['warning_status'])) |
|
| 359 | - echo ' |
|
| 381 | + if (!empty($context['warning_status'])) { |
|
| 382 | + echo ' |
|
| 360 | 383 | <span class="smalltext">(', $context['warning_status'], ')</span>'; |
| 384 | + } |
|
| 361 | 385 | |
| 362 | 386 | echo ' |
| 363 | 387 | </dd>'; |
@@ -367,11 +391,12 @@ discard block |
||
| 367 | 391 | if (!empty($context['activate_message']) || !empty($context['member']['bans'])) |
| 368 | 392 | { |
| 369 | 393 | // If the person looking at the summary has permission, and the account isn't activated, give the viewer the ability to do it themselves. |
| 370 | - if (!empty($context['activate_message'])) |
|
| 371 | - echo ' |
|
| 394 | + if (!empty($context['activate_message'])) { |
|
| 395 | + echo ' |
|
| 372 | 396 | <dt class="clear"> |
| 373 | 397 | <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>) |
| 374 | 398 | </dt>'; |
| 399 | + } |
|
| 375 | 400 | |
| 376 | 401 | // If the current member is banned, show a message and possibly a link to the ban. |
| 377 | 402 | if (!empty($context['member']['bans'])) |
@@ -383,10 +408,11 @@ discard block |
||
| 383 | 408 | <dt class="clear" id="ban_info" style="display: none;"> |
| 384 | 409 | <strong>', $txt['user_banned_by_following'], ':</strong>'; |
| 385 | 410 | |
| 386 | - foreach ($context['member']['bans'] as $ban) |
|
| 387 | - echo ' |
|
| 411 | + foreach ($context['member']['bans'] as $ban) { |
|
| 412 | + echo ' |
|
| 388 | 413 | <br> |
| 389 | 414 | <span class="smalltext">', $ban['explanation'], '</span>'; |
| 415 | + } |
|
| 390 | 416 | |
| 391 | 417 | echo ' |
| 392 | 418 | </dt>'; |
@@ -400,30 +426,34 @@ discard block |
||
| 400 | 426 | // If the person looking is allowed, they can check the members IP address and hostname. |
| 401 | 427 | if ($context['can_see_ip']) |
| 402 | 428 | { |
| 403 | - if (!empty($context['member']['ip'])) |
|
| 404 | - echo ' |
|
| 429 | + if (!empty($context['member']['ip'])) { |
|
| 430 | + echo ' |
|
| 405 | 431 | <dt>', $txt['ip'], ': </dt> |
| 406 | 432 | <dd><a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['member']['ip'], ';u=', $context['member']['id'], '">', $context['member']['ip'], '</a></dd>'; |
| 433 | + } |
|
| 407 | 434 | |
| 408 | - if (empty($modSettings['disableHostnameLookup']) && !empty($context['member']['ip'])) |
|
| 409 | - echo ' |
|
| 435 | + if (empty($modSettings['disableHostnameLookup']) && !empty($context['member']['ip'])) { |
|
| 436 | + echo ' |
|
| 410 | 437 | <dt>', $txt['hostname'], ': </dt> |
| 411 | 438 | <dd>', $context['member']['hostname'], '</dd>'; |
| 439 | + } |
|
| 412 | 440 | } |
| 413 | 441 | |
| 414 | 442 | echo ' |
| 415 | 443 | <dt>', $txt['local_time'], ':</dt> |
| 416 | 444 | <dd>', $context['member']['local_time'], '</dd>'; |
| 417 | 445 | |
| 418 | - if (!empty($modSettings['userLanguage']) && !empty($context['member']['language'])) |
|
| 419 | - echo ' |
|
| 446 | + if (!empty($modSettings['userLanguage']) && !empty($context['member']['language'])) { |
|
| 447 | + echo ' |
|
| 420 | 448 | <dt>', $txt['language'], ':</dt> |
| 421 | 449 | <dd>', $context['member']['language'], '</dd>'; |
| 450 | + } |
|
| 422 | 451 | |
| 423 | - if ($context['member']['show_last_login']) |
|
| 424 | - echo ' |
|
| 452 | + if ($context['member']['show_last_login']) { |
|
| 453 | + echo ' |
|
| 425 | 454 | <dt>', $txt['lastLoggedIn'], ': </dt> |
| 426 | 455 | <dd>', $context['member']['last_login'], (!empty($context['member']['is_hidden']) ? ' (' . $txt['hidden'] . ')' : ''), '</dd>'; |
| 456 | + } |
|
| 427 | 457 | |
| 428 | 458 | echo ' |
| 429 | 459 | </dl>'; |
@@ -432,42 +462,47 @@ discard block |
||
| 432 | 462 | if (!empty($context['print_custom_fields']['above_signature'])) |
| 433 | 463 | { |
| 434 | 464 | $fields = ''; |
| 435 | - foreach ($context['print_custom_fields']['above_signature'] as $field) |
|
| 436 | - if (!empty($field['output_html'])) |
|
| 465 | + foreach ($context['print_custom_fields']['above_signature'] as $field) { |
|
| 466 | + if (!empty($field['output_html'])) |
|
| 437 | 467 | $fields .= ' |
| 438 | 468 | <li>' . $field['output_html'] . '</li>'; |
| 469 | + } |
|
| 439 | 470 | |
| 440 | - if (!empty($fields)) |
|
| 441 | - echo ' |
|
| 471 | + if (!empty($fields)) { |
|
| 472 | + echo ' |
|
| 442 | 473 | <div class="custom_fields_above_signature"> |
| 443 | 474 | <ul class="nolist">', $fields, ' |
| 444 | 475 | </ul> |
| 445 | 476 | </div>'; |
| 477 | + } |
|
| 446 | 478 | } |
| 447 | 479 | |
| 448 | 480 | // Show the users signature. |
| 449 | - if ($context['signature_enabled'] && !empty($context['member']['signature'])) |
|
| 450 | - echo ' |
|
| 481 | + if ($context['signature_enabled'] && !empty($context['member']['signature'])) { |
|
| 482 | + echo ' |
|
| 451 | 483 | <div class="signature"> |
| 452 | 484 | <h5>', $txt['signature'], ':</h5> |
| 453 | 485 | ', $context['member']['signature'], ' |
| 454 | 486 | </div>'; |
| 487 | + } |
|
| 455 | 488 | |
| 456 | 489 | // Are there any custom profile fields for below the signature? |
| 457 | 490 | if (!empty($context['print_custom_fields']['below_signature'])) |
| 458 | 491 | { |
| 459 | 492 | $fields = ''; |
| 460 | - foreach ($context['print_custom_fields']['below_signature'] as $field) |
|
| 461 | - if (!empty($field['output_html'])) |
|
| 493 | + foreach ($context['print_custom_fields']['below_signature'] as $field) { |
|
| 494 | + if (!empty($field['output_html'])) |
|
| 462 | 495 | $fields .= ' |
| 463 | 496 | <li>' . $field['output_html'] . '</li>'; |
| 497 | + } |
|
| 464 | 498 | |
| 465 | - if (!empty($fields)) |
|
| 466 | - echo ' |
|
| 499 | + if (!empty($fields)) { |
|
| 500 | + echo ' |
|
| 467 | 501 | <div class="custom_fields_below_signature"> |
| 468 | 502 | <ul class="nolist">', $fields, ' |
| 469 | 503 | </ul> |
| 470 | 504 | </div>'; |
| 505 | + } |
|
| 471 | 506 | } |
| 472 | 507 | |
| 473 | 508 | echo ' |
@@ -509,62 +544,70 @@ discard block |
||
| 509 | 544 | </div> |
| 510 | 545 | <div class="list_posts">'; |
| 511 | 546 | |
| 512 | - if (!$post['approved']) |
|
| 513 | - echo ' |
|
| 547 | + if (!$post['approved']) { |
|
| 548 | + echo ' |
|
| 514 | 549 | <div class="approve_post"> |
| 515 | 550 | <em>', $txt['post_awaiting_approval'], '</em> |
| 516 | 551 | </div>'; |
| 552 | + } |
|
| 517 | 553 | |
| 518 | 554 | echo ' |
| 519 | 555 | ', $post['body'], ' |
| 520 | 556 | </div>'; |
| 521 | 557 | |
| 522 | - if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) |
|
| 523 | - echo ' |
|
| 558 | + if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) { |
|
| 559 | + echo ' |
|
| 524 | 560 | <div class="floatright"> |
| 525 | 561 | <ul class="quickbuttons">'; |
| 562 | + } |
|
| 526 | 563 | |
| 527 | 564 | // If they *can* reply? |
| 528 | - if ($post['can_reply']) |
|
| 529 | - echo ' |
|
| 565 | + if ($post['can_reply']) { |
|
| 566 | + echo ' |
|
| 530 | 567 | <li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li>'; |
| 568 | + } |
|
| 531 | 569 | |
| 532 | 570 | // If they *can* quote? |
| 533 | - if ($post['can_quote']) |
|
| 534 | - echo ' |
|
| 571 | + if ($post['can_quote']) { |
|
| 572 | + echo ' |
|
| 535 | 573 | <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>'; |
| 574 | + } |
|
| 536 | 575 | |
| 537 | 576 | // How about... even... remove it entirely?! |
| 538 | - if ($post['can_delete']) |
|
| 539 | - echo ' |
|
| 577 | + if ($post['can_delete']) { |
|
| 578 | + echo ' |
|
| 540 | 579 | <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>'; |
| 580 | + } |
|
| 541 | 581 | |
| 542 | - if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) |
|
| 543 | - echo ' |
|
| 582 | + if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) { |
|
| 583 | + echo ' |
|
| 544 | 584 | </ul> |
| 545 | 585 | </div><!-- .floatright -->'; |
| 586 | + } |
|
| 546 | 587 | |
| 547 | 588 | echo ' |
| 548 | 589 | </div><!-- $post[css_class] -->'; |
| 549 | 590 | } |
| 591 | + } else { |
|
| 592 | + template_show_list('attachments'); |
|
| 550 | 593 | } |
| 551 | - else |
|
| 552 | - template_show_list('attachments'); |
|
| 553 | 594 | |
| 554 | 595 | // No posts? Just end with a informative message. |
| 555 | - if ((isset($context['attachments']) && empty($context['attachments'])) || (!isset($context['attachments']) && empty($context['posts']))) |
|
| 556 | - echo ' |
|
| 596 | + if ((isset($context['attachments']) && empty($context['attachments'])) || (!isset($context['attachments']) && empty($context['posts']))) { |
|
| 597 | + echo ' |
|
| 557 | 598 | <div class="windowbg2"> |
| 558 | 599 | ', isset($context['attachments']) ? $txt['show_attachments_none'] : ($context['is_topics'] ? $txt['show_topics_none'] : $txt['show_posts_none']), ' |
| 559 | 600 | </div>'; |
| 601 | + } |
|
| 560 | 602 | |
| 561 | 603 | // Show more page numbers. |
| 562 | - if (!empty($context['page_index'])) |
|
| 563 | - echo ' |
|
| 604 | + if (!empty($context['page_index'])) { |
|
| 605 | + echo ' |
|
| 564 | 606 | <div class="pagesection"> |
| 565 | 607 | <div class="pagelinks">', $context['page_index'], '</div> |
| 566 | 608 | </div>'; |
| 567 | -} |
|
| 609 | + } |
|
| 610 | + } |
|
| 568 | 611 | |
| 569 | 612 | /** |
| 570 | 613 | * Template for showing alerts within the alerts popup |
@@ -574,11 +617,12 @@ discard block |
||
| 574 | 617 | global $context, $txt, $scripturl; |
| 575 | 618 | |
| 576 | 619 | // Do we have an update message? |
| 577 | - if (!empty($context['update_message'])) |
|
| 578 | - echo ' |
|
| 620 | + if (!empty($context['update_message'])) { |
|
| 621 | + echo ' |
|
| 579 | 622 | <div class="infobox"> |
| 580 | 623 | ', $context['update_message'], ' |
| 581 | 624 | </div>'; |
| 625 | + } |
|
| 582 | 626 | |
| 583 | 627 | echo ' |
| 584 | 628 | <div class="cat_bar"> |
@@ -587,18 +631,18 @@ discard block |
||
| 587 | 631 | </h3> |
| 588 | 632 | </div>'; |
| 589 | 633 | |
| 590 | - if (empty($context['alerts'])) |
|
| 591 | - echo ' |
|
| 634 | + if (empty($context['alerts'])) { |
|
| 635 | + echo ' |
|
| 592 | 636 | <div class="information"> |
| 593 | 637 | ', $txt['alerts_none'], ' |
| 594 | 638 | </div>'; |
| 595 | - |
|
| 596 | - else |
|
| 639 | + } else |
|
| 597 | 640 | { |
| 598 | 641 | // Start the form if checkboxes are in use |
| 599 | - if ($context['showCheckboxes']) |
|
| 600 | - echo ' |
|
| 642 | + if ($context['showCheckboxes']) { |
|
| 643 | + echo ' |
|
| 601 | 644 | <form action="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=showalerts;save" method="post" accept-charset="', $context['character_set'], '" id="mark_all">'; |
| 645 | + } |
|
| 602 | 646 | |
| 603 | 647 | echo ' |
| 604 | 648 | <table id="alerts" class="table_grid">'; |
@@ -614,9 +658,10 @@ discard block |
||
| 614 | 658 | <li><a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=showalerts;do=remove;aid=', $id, ';', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['delete'], '</a></li> |
| 615 | 659 | <li><a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=showalerts;do=', ($alert['is_read'] != 0 ? 'unread' : 'read'), ';aid=', $id, ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons ', $alert['is_read'] != 0 ? 'unread_button' : 'read_button', '"></span>', ($alert['is_read'] != 0 ? $txt['mark_unread'] : $txt['mark_read_short']), '</a></li>'; |
| 616 | 660 | |
| 617 | - if ($context['showCheckboxes']) |
|
| 618 | - echo ' |
|
| 661 | + if ($context['showCheckboxes']) { |
|
| 662 | + echo ' |
|
| 619 | 663 | <li><input type="checkbox" name="mark[', $id, ']" value="', $id, '"></li>'; |
| 664 | + } |
|
| 620 | 665 | |
| 621 | 666 | echo ' |
| 622 | 667 | </ul> |
@@ -631,8 +676,8 @@ discard block |
||
| 631 | 676 | ', $context['pagination'], ' |
| 632 | 677 | </div>'; |
| 633 | 678 | |
| 634 | - if ($context['showCheckboxes']) |
|
| 635 | - echo ' |
|
| 679 | + if ($context['showCheckboxes']) { |
|
| 680 | + echo ' |
|
| 636 | 681 | <div class="floatright"> |
| 637 | 682 | ', $txt['check_all'], ': <input type="checkbox" name="select_all" id="select_all"> |
| 638 | 683 | <select name="mark_as"> |
@@ -643,14 +688,16 @@ discard block |
||
| 643 | 688 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
| 644 | 689 | <input type="submit" name="req" value="', $txt['quick_mod_go'], '" class="button you_sure"> |
| 645 | 690 | </div>'; |
| 691 | + } |
|
| 646 | 692 | |
| 647 | 693 | echo ' |
| 648 | 694 | </div>'; |
| 649 | 695 | |
| 650 | - if ($context['showCheckboxes']) |
|
| 651 | - echo ' |
|
| 696 | + if ($context['showCheckboxes']) { |
|
| 697 | + echo ' |
|
| 652 | 698 | </form>'; |
| 653 | 699 | } |
| 700 | + } |
|
| 654 | 701 | } |
| 655 | 702 | |
| 656 | 703 | /** |
@@ -671,12 +718,12 @@ discard block |
||
| 671 | 718 | </div>' : ''; |
| 672 | 719 | |
| 673 | 720 | // No drafts? Just show an informative message. |
| 674 | - if (empty($context['drafts'])) |
|
| 675 | - echo ' |
|
| 721 | + if (empty($context['drafts'])) { |
|
| 722 | + echo ' |
|
| 676 | 723 | <div class="windowbg2 centertext"> |
| 677 | 724 | ', $txt['draft_none'], ' |
| 678 | 725 | </div>'; |
| 679 | - else |
|
| 726 | + } else |
|
| 680 | 727 | { |
| 681 | 728 | // For every draft to be displayed, give it its own div, and show the important details of the draft. |
| 682 | 729 | foreach ($context['drafts'] as $draft) |
@@ -688,13 +735,15 @@ discard block |
||
| 688 | 735 | <h5> |
| 689 | 736 | <strong><a href="', $scripturl, '?board=', $draft['board']['id'], '.0">', $draft['board']['name'], '</a> / ', $draft['topic']['link'], '</strong> '; |
| 690 | 737 | |
| 691 | - if (!empty($draft['sticky'])) |
|
| 692 | - echo ' |
|
| 738 | + if (!empty($draft['sticky'])) { |
|
| 739 | + echo ' |
|
| 693 | 740 | <span class="generic_icons sticky" title="', $txt['sticky_topic'], '"></span>'; |
| 741 | + } |
|
| 694 | 742 | |
| 695 | - if (!empty($draft['locked'])) |
|
| 696 | - echo ' |
|
| 743 | + if (!empty($draft['locked'])) { |
|
| 744 | + echo ' |
|
| 697 | 745 | <span class="generic_icons lock" title="', $txt['locked_topic'], '"></span>'; |
| 746 | + } |
|
| 698 | 747 | |
| 699 | 748 | echo ' |
| 700 | 749 | </h5> |
@@ -727,13 +776,13 @@ discard block |
||
| 727 | 776 | { |
| 728 | 777 | global $context, $scripturl, $txt; |
| 729 | 778 | |
| 730 | - if (!empty($context['saved_successful'])) |
|
| 731 | - echo ' |
|
| 779 | + if (!empty($context['saved_successful'])) { |
|
| 780 | + echo ' |
|
| 732 | 781 | <div class="infobox">', $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $context['member']['name']), '</div>'; |
| 733 | - |
|
| 734 | - elseif (!empty($context['saved_failed'])) |
|
| 735 | - echo ' |
|
| 782 | + } elseif (!empty($context['saved_failed'])) { |
|
| 783 | + echo ' |
|
| 736 | 784 | <div class="errorbox">', $context['saved_failed'], '</div>'; |
| 785 | + } |
|
| 737 | 786 | |
| 738 | 787 | echo ' |
| 739 | 788 | <div id="edit_buddies"> |
@@ -748,14 +797,16 @@ discard block |
||
| 748 | 797 | <th scope="col" class="quarter_table">', $txt['name'], '</th> |
| 749 | 798 | <th scope="col">', $txt['status'], '</th>'; |
| 750 | 799 | |
| 751 | - if (allowedTo('moderate_forum')) |
|
| 752 | - echo ' |
|
| 800 | + if (allowedTo('moderate_forum')) { |
|
| 801 | + echo ' |
|
| 753 | 802 | <th scope="col">', $txt['email'], '</th>'; |
| 803 | + } |
|
| 754 | 804 | |
| 755 | - if (!empty($context['custom_pf'])) |
|
| 756 | - foreach ($context['custom_pf'] as $column) |
|
| 805 | + if (!empty($context['custom_pf'])) { |
|
| 806 | + foreach ($context['custom_pf'] as $column) |
|
| 757 | 807 | echo ' |
| 758 | 808 | <th scope="col">', $column['label'], '</th>'; |
| 809 | + } |
|
| 759 | 810 | |
| 760 | 811 | echo ' |
| 761 | 812 | <th scope="col">', $txt['remove'], '</th> |
@@ -764,13 +815,14 @@ discard block |
||
| 764 | 815 | <tbody>'; |
| 765 | 816 | |
| 766 | 817 | // If they don't have any buddies don't list them! |
| 767 | - if (empty($context['buddies'])) |
|
| 768 | - echo ' |
|
| 818 | + if (empty($context['buddies'])) { |
|
| 819 | + echo ' |
|
| 769 | 820 | <tr class="windowbg"> |
| 770 | 821 | <td colspan="', allowedTo('moderate_forum') ? '10' : '9', '"> |
| 771 | 822 | <strong>', $txt['no_buddies'], '</strong> |
| 772 | 823 | </td> |
| 773 | 824 | </tr>'; |
| 825 | + } |
|
| 774 | 826 | |
| 775 | 827 | // Now loop through each buddy showing info on each. |
| 776 | 828 | else |
@@ -784,17 +836,19 @@ discard block |
||
| 784 | 836 | <a href="', $buddy['online']['href'], '"><span class="' . ($buddy['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $buddy['online']['text'] . '"></span></a> |
| 785 | 837 | </td>'; |
| 786 | 838 | |
| 787 | - if ($buddy['show_email']) |
|
| 788 | - echo ' |
|
| 839 | + if ($buddy['show_email']) { |
|
| 840 | + echo ' |
|
| 789 | 841 | <td> |
| 790 | 842 | <a href="mailto:' . $buddy['email'] . '" rel="nofollow"><span class="generic_icons mail icon" title="' . $txt['email'] . ' ' . $buddy['name'] . '"></span></a> |
| 791 | 843 | </td>'; |
| 844 | + } |
|
| 792 | 845 | |
| 793 | 846 | // Show the custom profile fields for this user. |
| 794 | - if (!empty($context['custom_pf'])) |
|
| 795 | - foreach ($context['custom_pf'] as $key => $column) |
|
| 847 | + if (!empty($context['custom_pf'])) { |
|
| 848 | + foreach ($context['custom_pf'] as $key => $column) |
|
| 796 | 849 | echo ' |
| 797 | 850 | <td class="lefttext">', $buddy['options'][$key], '</td>'; |
| 851 | + } |
|
| 798 | 852 | |
| 799 | 853 | echo ' |
| 800 | 854 | <td> |
@@ -827,9 +881,10 @@ discard block |
||
| 827 | 881 | </dl> |
| 828 | 882 | </div>'; |
| 829 | 883 | |
| 830 | - if (!empty($context['token_check'])) |
|
| 831 | - echo ' |
|
| 884 | + if (!empty($context['token_check'])) { |
|
| 885 | + echo ' |
|
| 832 | 886 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
| 887 | + } |
|
| 833 | 888 | |
| 834 | 889 | echo ' |
| 835 | 890 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -855,13 +910,13 @@ discard block |
||
| 855 | 910 | { |
| 856 | 911 | global $context, $scripturl, $txt; |
| 857 | 912 | |
| 858 | - if (!empty($context['saved_successful'])) |
|
| 859 | - echo ' |
|
| 913 | + if (!empty($context['saved_successful'])) { |
|
| 914 | + echo ' |
|
| 860 | 915 | <div class="infobox">', $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $context['member']['name']), '</div>'; |
| 861 | - |
|
| 862 | - elseif (!empty($context['saved_failed'])) |
|
| 863 | - echo ' |
|
| 916 | + } elseif (!empty($context['saved_failed'])) { |
|
| 917 | + echo ' |
|
| 864 | 918 | <div class="errorbox">', $context['saved_failed'], '</div>'; |
| 919 | + } |
|
| 865 | 920 | |
| 866 | 921 | echo ' |
| 867 | 922 | <div id="edit_buddies"> |
@@ -876,9 +931,10 @@ discard block |
||
| 876 | 931 | <th scope="col" class="quarter_table">', $txt['name'], '</th> |
| 877 | 932 | <th scope="col">', $txt['status'], '</th>'; |
| 878 | 933 | |
| 879 | - if (allowedTo('moderate_forum')) |
|
| 880 | - echo ' |
|
| 934 | + if (allowedTo('moderate_forum')) { |
|
| 935 | + echo ' |
|
| 881 | 936 | <th scope="col">', $txt['email'], '</th>'; |
| 937 | + } |
|
| 882 | 938 | |
| 883 | 939 | echo ' |
| 884 | 940 | <th scope="col">', $txt['ignore_remove'], '</th> |
@@ -887,13 +943,14 @@ discard block |
||
| 887 | 943 | <tbody>'; |
| 888 | 944 | |
| 889 | 945 | // If they don't have anyone on their ignore list, don't list it! |
| 890 | - if (empty($context['ignore_list'])) |
|
| 891 | - echo ' |
|
| 946 | + if (empty($context['ignore_list'])) { |
|
| 947 | + echo ' |
|
| 892 | 948 | <tr class="windowbg"> |
| 893 | 949 | <td colspan="', allowedTo('moderate_forum') ? '4' : '3', '"> |
| 894 | 950 | <strong>', $txt['no_ignore'], '</strong> |
| 895 | 951 | </td> |
| 896 | 952 | </tr>'; |
| 953 | + } |
|
| 897 | 954 | |
| 898 | 955 | // Now loop through each buddy showing info on each. |
| 899 | 956 | foreach ($context['ignore_list'] as $member) |
@@ -905,11 +962,12 @@ discard block |
||
| 905 | 962 | <a href="', $member['online']['href'], '"><span class="' . ($member['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $member['online']['text'] . '"></span></a> |
| 906 | 963 | </td>'; |
| 907 | 964 | |
| 908 | - if ($member['show_email']) |
|
| 909 | - echo ' |
|
| 965 | + if ($member['show_email']) { |
|
| 966 | + echo ' |
|
| 910 | 967 | <td> |
| 911 | 968 | <a href="mailto:' . $member['email'] . '" rel="nofollow"><span class="generic_icons mail icon" title="' . $txt['email'] . ' ' . $member['name'] . '"></span></a> |
| 912 | 969 | </td>'; |
| 970 | + } |
|
| 913 | 971 | echo ' |
| 914 | 972 | <td> |
| 915 | 973 | <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> |
@@ -939,9 +997,10 @@ discard block |
||
| 939 | 997 | </dl> |
| 940 | 998 | </div>'; |
| 941 | 999 | |
| 942 | - if (!empty($context['token_check'])) |
|
| 943 | - echo ' |
|
| 1000 | + if (!empty($context['token_check'])) { |
|
| 1001 | + echo ' |
|
| 944 | 1002 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
| 1003 | + } |
|
| 945 | 1004 | |
| 946 | 1005 | echo ' |
| 947 | 1006 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -987,9 +1046,10 @@ discard block |
||
| 987 | 1046 | <a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['last_ip'], ';u=', $context['member']['id'], '">', $context['last_ip'], '</a>'; |
| 988 | 1047 | |
| 989 | 1048 | // Second address detected? |
| 990 | - if (!empty($context['last_ip2'])) |
|
| 991 | - echo ' |
|
| 1049 | + if (!empty($context['last_ip2'])) { |
|
| 1050 | + echo ' |
|
| 992 | 1051 | , <a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['last_ip2'], ';u=', $context['member']['id'], '">', $context['last_ip2'], '</a>'; |
| 1052 | + } |
|
| 993 | 1053 | |
| 994 | 1054 | echo ' |
| 995 | 1055 | </dd>'; |
@@ -1055,9 +1115,10 @@ discard block |
||
| 1055 | 1115 | </div> |
| 1056 | 1116 | <div class="windowbg2 noup">'; |
| 1057 | 1117 | |
| 1058 | - foreach ($context['whois_servers'] as $server) |
|
| 1059 | - echo ' |
|
| 1118 | + foreach ($context['whois_servers'] as $server) { |
|
| 1119 | + echo ' |
|
| 1060 | 1120 | <a href="', $server['url'], '" target="_blank" rel="noopener"', '>', $server['name'], '</a><br>'; |
| 1121 | + } |
|
| 1061 | 1122 | echo ' |
| 1062 | 1123 | </div> |
| 1063 | 1124 | <br>'; |
@@ -1069,13 +1130,12 @@ discard block |
||
| 1069 | 1130 | <h3 class="catbg">', $txt['members_from_ip'], ' ', $context['ip'], '</h3> |
| 1070 | 1131 | </div>'; |
| 1071 | 1132 | |
| 1072 | - if (empty($context['ips'])) |
|
| 1073 | - echo ' |
|
| 1133 | + if (empty($context['ips'])) { |
|
| 1134 | + echo ' |
|
| 1074 | 1135 | <p class="windowbg2 description"> |
| 1075 | 1136 | <em>', $txt['no_members_from_ip'], '</em> |
| 1076 | 1137 | </p>'; |
| 1077 | - |
|
| 1078 | - else |
|
| 1138 | + } else |
|
| 1079 | 1139 | { |
| 1080 | 1140 | echo ' |
| 1081 | 1141 | <table class="table_grid"> |
@@ -1088,12 +1148,13 @@ discard block |
||
| 1088 | 1148 | <tbody>'; |
| 1089 | 1149 | |
| 1090 | 1150 | // Loop through each of the members and display them. |
| 1091 | - foreach ($context['ips'] as $ip => $memberlist) |
|
| 1092 | - echo ' |
|
| 1151 | + foreach ($context['ips'] as $ip => $memberlist) { |
|
| 1152 | + echo ' |
|
| 1093 | 1153 | <tr class="windowbg"> |
| 1094 | 1154 | <td><a href="', $context['base_url'], ';searchip=', $ip, '">', $ip, '</a></td> |
| 1095 | 1155 | <td>', implode(', ', $memberlist), '</td> |
| 1096 | 1156 | </tr>'; |
| 1157 | + } |
|
| 1097 | 1158 | |
| 1098 | 1159 | echo ' |
| 1099 | 1160 | </tbody> |
@@ -1135,11 +1196,10 @@ discard block |
||
| 1135 | 1196 | </h3> |
| 1136 | 1197 | </div>'; |
| 1137 | 1198 | |
| 1138 | - if ($context['member']['has_all_permissions']) |
|
| 1139 | - echo ' |
|
| 1199 | + if ($context['member']['has_all_permissions']) { |
|
| 1200 | + echo ' |
|
| 1140 | 1201 | <div class="information">', $txt['showPermissions_all'], '</div>'; |
| 1141 | - |
|
| 1142 | - else |
|
| 1202 | + } else |
|
| 1143 | 1203 | { |
| 1144 | 1204 | echo ' |
| 1145 | 1205 | <div class="information">',$txt['showPermissions_help'], '</div> |
@@ -1154,9 +1214,10 @@ discard block |
||
| 1154 | 1214 | <div class="windowbg smalltext"> |
| 1155 | 1215 | ', $txt['showPermissions_restricted_boards_desc'], ':<br>'; |
| 1156 | 1216 | |
| 1157 | - foreach ($context['no_access_boards'] as $no_access_board) |
|
| 1158 | - echo ' |
|
| 1217 | + foreach ($context['no_access_boards'] as $no_access_board) { |
|
| 1218 | + echo ' |
|
| 1159 | 1219 | <a href="', $scripturl, '?board=', $no_access_board['id'], '.0">', $no_access_board['name'], '</a>', $no_access_board['is_last'] ? '' : ', '; |
| 1220 | + } |
|
| 1160 | 1221 | echo ' |
| 1161 | 1222 | </div>'; |
| 1162 | 1223 | } |
@@ -1188,12 +1249,13 @@ discard block |
||
| 1188 | 1249 | </td> |
| 1189 | 1250 | <td class="smalltext">'; |
| 1190 | 1251 | |
| 1191 | - if ($permission['is_denied']) |
|
| 1192 | - echo ' |
|
| 1252 | + if ($permission['is_denied']) { |
|
| 1253 | + echo ' |
|
| 1193 | 1254 | <span class="alert">', $txt['showPermissions_denied'], ': ', implode(', ', $permission['groups']['denied']), '</span>'; |
| 1194 | - else |
|
| 1195 | - echo ' |
|
| 1255 | + } else { |
|
| 1256 | + echo ' |
|
| 1196 | 1257 | ', $txt['showPermissions_given'], ': ', implode(', ', $permission['groups']['allowed']); |
| 1258 | + } |
|
| 1197 | 1259 | |
| 1198 | 1260 | echo ' |
| 1199 | 1261 | </td> |
@@ -1204,10 +1266,10 @@ discard block |
||
| 1204 | 1266 | </table> |
| 1205 | 1267 | </div><!-- .tborder --> |
| 1206 | 1268 | <br>'; |
| 1207 | - } |
|
| 1208 | - else |
|
| 1209 | - echo ' |
|
| 1269 | + } else { |
|
| 1270 | + echo ' |
|
| 1210 | 1271 | <p class="windowbg2">', $txt['showPermissions_none_general'], '</p>'; |
| 1272 | + } |
|
| 1211 | 1273 | |
| 1212 | 1274 | // Board permission section. |
| 1213 | 1275 | echo ' |
@@ -1218,14 +1280,16 @@ discard block |
||
| 1218 | 1280 | <select name="board" onchange="if (this.options[this.selectedIndex].value) this.form.submit();"> |
| 1219 | 1281 | <option value="0"', $context['board'] == 0 ? ' selected' : '', '>', $txt['showPermissions_global'], '</option>'; |
| 1220 | 1282 | |
| 1221 | - if (!empty($context['boards'])) |
|
| 1222 | - echo ' |
|
| 1283 | + if (!empty($context['boards'])) { |
|
| 1284 | + echo ' |
|
| 1223 | 1285 | <option value="" disabled>---------------------------</option>'; |
| 1286 | + } |
|
| 1224 | 1287 | |
| 1225 | 1288 | // Fill the box with any local permission boards. |
| 1226 | - foreach ($context['boards'] as $board) |
|
| 1227 | - echo ' |
|
| 1289 | + foreach ($context['boards'] as $board) { |
|
| 1290 | + echo ' |
|
| 1228 | 1291 | <option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['name'], ' (', $board['profile_name'], ')</option>'; |
| 1292 | + } |
|
| 1229 | 1293 | |
| 1230 | 1294 | echo ' |
| 1231 | 1295 | </select> |
@@ -1254,13 +1318,13 @@ discard block |
||
| 1254 | 1318 | </td> |
| 1255 | 1319 | <td class="smalltext">'; |
| 1256 | 1320 | |
| 1257 | - if ($permission['is_denied']) |
|
| 1258 | - echo ' |
|
| 1321 | + if ($permission['is_denied']) { |
|
| 1322 | + echo ' |
|
| 1259 | 1323 | <span class="alert">', $txt['showPermissions_denied'], ': ', implode(', ', $permission['groups']['denied']), '</span>'; |
| 1260 | - |
|
| 1261 | - else |
|
| 1262 | - echo ' |
|
| 1324 | + } else { |
|
| 1325 | + echo ' |
|
| 1263 | 1326 | ', $txt['showPermissions_given'], ': ', implode(', ', $permission['groups']['allowed']); |
| 1327 | + } |
|
| 1264 | 1328 | |
| 1265 | 1329 | echo ' |
| 1266 | 1330 | </td> |
@@ -1269,10 +1333,10 @@ discard block |
||
| 1269 | 1333 | echo ' |
| 1270 | 1334 | </tbody> |
| 1271 | 1335 | </table>'; |
| 1272 | - } |
|
| 1273 | - else |
|
| 1274 | - echo ' |
|
| 1336 | + } else { |
|
| 1337 | + echo ' |
|
| 1275 | 1338 | <p class="windowbg2">', $txt['showPermissions_none_board'], '</p>'; |
| 1339 | + } |
|
| 1276 | 1340 | echo ' |
| 1277 | 1341 | </div><!-- #permissions -->'; |
| 1278 | 1342 | } |
@@ -1313,9 +1377,10 @@ discard block |
||
| 1313 | 1377 | </div>'; |
| 1314 | 1378 | |
| 1315 | 1379 | // If they haven't post at all, don't draw the graph. |
| 1316 | - if (empty($context['posts_by_time'])) |
|
| 1317 | - echo ' |
|
| 1380 | + if (empty($context['posts_by_time'])) { |
|
| 1381 | + echo ' |
|
| 1318 | 1382 | <p class="centertext padding">', $txt['statPanel_noPosts'], '</p>'; |
| 1383 | + } |
|
| 1319 | 1384 | |
| 1320 | 1385 | // Otherwise do! |
| 1321 | 1386 | else |
@@ -1324,8 +1389,8 @@ discard block |
||
| 1324 | 1389 | <ul class="activity_stats flow_hidden">'; |
| 1325 | 1390 | |
| 1326 | 1391 | // The labels. |
| 1327 | - foreach ($context['posts_by_time'] as $time_of_day) |
|
| 1328 | - echo ' |
|
| 1392 | + foreach ($context['posts_by_time'] as $time_of_day) { |
|
| 1393 | + echo ' |
|
| 1329 | 1394 | <li', $time_of_day['is_last'] ? ' class="last"' : '', '> |
| 1330 | 1395 | <div class="bar" style="padding-top: ', ((int) (100 - $time_of_day['relative_percent'])), 'px;" title="', sprintf($txt['statPanel_activityTime_posts'], $time_of_day['posts'], $time_of_day['posts_percent']), '"> |
| 1331 | 1396 | <div style="height: ', (int) $time_of_day['relative_percent'], 'px;"> |
@@ -1334,6 +1399,7 @@ discard block |
||
| 1334 | 1399 | </div> |
| 1335 | 1400 | <span class="stats_hour">', $time_of_day['hour_format'], '</span> |
| 1336 | 1401 | </li>'; |
| 1402 | + } |
|
| 1337 | 1403 | |
| 1338 | 1404 | echo ' |
| 1339 | 1405 | </ul>'; |
@@ -1352,11 +1418,10 @@ discard block |
||
| 1352 | 1418 | </h3> |
| 1353 | 1419 | </div>'; |
| 1354 | 1420 | |
| 1355 | - if (empty($context['popular_boards'])) |
|
| 1356 | - echo ' |
|
| 1421 | + if (empty($context['popular_boards'])) { |
|
| 1422 | + echo ' |
|
| 1357 | 1423 | <p class="centertext padding">', $txt['statPanel_noPosts'], '</p>'; |
| 1358 | - |
|
| 1359 | - else |
|
| 1424 | + } else |
|
| 1360 | 1425 | { |
| 1361 | 1426 | echo ' |
| 1362 | 1427 | <dl class="stats">'; |
@@ -1386,10 +1451,10 @@ discard block |
||
| 1386 | 1451 | </h3> |
| 1387 | 1452 | </div>'; |
| 1388 | 1453 | |
| 1389 | - if (empty($context['board_activity'])) |
|
| 1390 | - echo ' |
|
| 1454 | + if (empty($context['board_activity'])) { |
|
| 1455 | + echo ' |
|
| 1391 | 1456 | <p class="centertext padding">', $txt['statPanel_noPosts'], '</p>'; |
| 1392 | - else |
|
| 1457 | + } else |
|
| 1393 | 1458 | { |
| 1394 | 1459 | echo ' |
| 1395 | 1460 | <dl class="stats">'; |
@@ -1440,90 +1505,97 @@ discard block |
||
| 1440 | 1505 | <h3 class="catbg profile_hd">'; |
| 1441 | 1506 | |
| 1442 | 1507 | // Don't say "Profile" if this isn't the profile... |
| 1443 | - if (!empty($context['profile_header_text'])) |
|
| 1444 | - echo ' |
|
| 1508 | + if (!empty($context['profile_header_text'])) { |
|
| 1509 | + echo ' |
|
| 1445 | 1510 | ', $context['profile_header_text']; |
| 1446 | - else |
|
| 1447 | - echo ' |
|
| 1511 | + } else { |
|
| 1512 | + echo ' |
|
| 1448 | 1513 | ', $txt['profile']; |
| 1514 | + } |
|
| 1449 | 1515 | |
| 1450 | 1516 | echo ' |
| 1451 | 1517 | </h3> |
| 1452 | 1518 | </div>'; |
| 1453 | 1519 | |
| 1454 | 1520 | // Have we some description? |
| 1455 | - if ($context['page_desc']) |
|
| 1456 | - echo ' |
|
| 1521 | + if ($context['page_desc']) { |
|
| 1522 | + echo ' |
|
| 1457 | 1523 | <p class="information">', $context['page_desc'], '</p>'; |
| 1524 | + } |
|
| 1458 | 1525 | |
| 1459 | 1526 | echo ' |
| 1460 | 1527 | <div class="roundframe">'; |
| 1461 | 1528 | |
| 1462 | 1529 | // Any bits at the start? |
| 1463 | - if (!empty($context['profile_prehtml'])) |
|
| 1464 | - echo ' |
|
| 1530 | + if (!empty($context['profile_prehtml'])) { |
|
| 1531 | + echo ' |
|
| 1465 | 1532 | <div>', $context['profile_prehtml'], '</div>'; |
| 1533 | + } |
|
| 1466 | 1534 | |
| 1467 | - if (!empty($context['profile_fields'])) |
|
| 1468 | - echo ' |
|
| 1535 | + if (!empty($context['profile_fields'])) { |
|
| 1536 | + echo ' |
|
| 1469 | 1537 | <dl class="settings">'; |
| 1538 | + } |
|
| 1470 | 1539 | |
| 1471 | 1540 | // Start the big old loop 'of love. |
| 1472 | 1541 | $lastItem = 'hr'; |
| 1473 | 1542 | foreach ($context['profile_fields'] as $key => $field) |
| 1474 | 1543 | { |
| 1475 | 1544 | // We add a little hack to be sure we never get more than one hr in a row! |
| 1476 | - if ($lastItem == 'hr' && $field['type'] == 'hr') |
|
| 1477 | - continue; |
|
| 1545 | + if ($lastItem == 'hr' && $field['type'] == 'hr') { |
|
| 1546 | + continue; |
|
| 1547 | + } |
|
| 1478 | 1548 | |
| 1479 | 1549 | $lastItem = $field['type']; |
| 1480 | - if ($field['type'] == 'hr') |
|
| 1481 | - echo ' |
|
| 1550 | + if ($field['type'] == 'hr') { |
|
| 1551 | + echo ' |
|
| 1482 | 1552 | </dl> |
| 1483 | 1553 | <hr> |
| 1484 | 1554 | <dl class="settings">'; |
| 1485 | - |
|
| 1486 | - elseif ($field['type'] == 'callback') |
|
| 1555 | + } elseif ($field['type'] == 'callback') |
|
| 1487 | 1556 | { |
| 1488 | 1557 | if (isset($field['callback_func']) && function_exists('template_profile_' . $field['callback_func'])) |
| 1489 | 1558 | { |
| 1490 | 1559 | $callback_func = 'template_profile_' . $field['callback_func']; |
| 1491 | 1560 | $callback_func(); |
| 1492 | 1561 | } |
| 1493 | - } |
|
| 1494 | - else |
|
| 1562 | + } else |
|
| 1495 | 1563 | { |
| 1496 | 1564 | echo ' |
| 1497 | 1565 | <dt> |
| 1498 | 1566 | <strong', !empty($field['is_error']) ? ' class="error"' : '', '>', $field['type'] !== 'label' ? '<label for="' . $key . '">' : '', $field['label'], $field['type'] !== 'label' ? '</label>' : '', '</strong>'; |
| 1499 | 1567 | |
| 1500 | 1568 | // Does it have any subtext to show? |
| 1501 | - if (!empty($field['subtext'])) |
|
| 1502 | - echo ' |
|
| 1569 | + if (!empty($field['subtext'])) { |
|
| 1570 | + echo ' |
|
| 1503 | 1571 | <br> |
| 1504 | 1572 | <span class="smalltext">', $field['subtext'], '</span>'; |
| 1573 | + } |
|
| 1505 | 1574 | |
| 1506 | 1575 | echo ' |
| 1507 | 1576 | </dt> |
| 1508 | 1577 | <dd>'; |
| 1509 | 1578 | |
| 1510 | 1579 | // Want to put something infront of the box? |
| 1511 | - if (!empty($field['preinput'])) |
|
| 1512 | - echo ' |
|
| 1580 | + if (!empty($field['preinput'])) { |
|
| 1581 | + echo ' |
|
| 1513 | 1582 | ', $field['preinput']; |
| 1583 | + } |
|
| 1514 | 1584 | |
| 1515 | 1585 | // What type of data are we showing? |
| 1516 | - if ($field['type'] == 'label') |
|
| 1517 | - echo ' |
|
| 1586 | + if ($field['type'] == 'label') { |
|
| 1587 | + echo ' |
|
| 1518 | 1588 | ', $field['value']; |
| 1589 | + } |
|
| 1519 | 1590 | |
| 1520 | 1591 | // Maybe it's a text box - very likely! |
| 1521 | 1592 | elseif (in_array($field['type'], array('int', 'float', 'text', 'password', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'number', 'time', 'url'))) |
| 1522 | 1593 | { |
| 1523 | - if ($field['type'] == 'int' || $field['type'] == 'float') |
|
| 1524 | - $type = 'number'; |
|
| 1525 | - else |
|
| 1526 | - $type = $field['type']; |
|
| 1594 | + if ($field['type'] == 'int' || $field['type'] == 'float') { |
|
| 1595 | + $type = 'number'; |
|
| 1596 | + } else { |
|
| 1597 | + $type = $field['type']; |
|
| 1598 | + } |
|
| 1527 | 1599 | $step = $field['type'] == 'float' ? ' step="0.1"' : ''; |
| 1528 | 1600 | |
| 1529 | 1601 | |
@@ -1531,10 +1603,11 @@ discard block |
||
| 1531 | 1603 | <input type="', $type, '" name="', $key, '" id="', $key, '" size="', empty($field['size']) ? 30 : $field['size'], '" value="', $field['value'], '" ', $field['input_attr'], ' ', $step, '>'; |
| 1532 | 1604 | } |
| 1533 | 1605 | // You "checking" me out? ;) |
| 1534 | - elseif ($field['type'] == 'check') |
|
| 1535 | - echo ' |
|
| 1606 | + elseif ($field['type'] == 'check') { |
|
| 1607 | + echo ' |
|
| 1536 | 1608 | <input type="hidden" name="', $key, '" value="0"> |
| 1537 | 1609 | <input type="checkbox" name="', $key, '" id="', $key, '"', !empty($field['value']) ? ' checked' : '', ' value="1" ', $field['input_attr'], '>'; |
| 1610 | + } |
|
| 1538 | 1611 | |
| 1539 | 1612 | // Always fun - select boxes! |
| 1540 | 1613 | elseif ($field['type'] == 'select') |
@@ -1545,14 +1618,16 @@ discard block |
||
| 1545 | 1618 | if (isset($field['options'])) |
| 1546 | 1619 | { |
| 1547 | 1620 | // Is this some code to generate the options? |
| 1548 | - if (!is_array($field['options'])) |
|
| 1549 | - $field['options'] = $field['options'](); |
|
| 1621 | + if (!is_array($field['options'])) { |
|
| 1622 | + $field['options'] = $field['options'](); |
|
| 1623 | + } |
|
| 1550 | 1624 | |
| 1551 | 1625 | // Assuming we now have some! |
| 1552 | - if (is_array($field['options'])) |
|
| 1553 | - foreach ($field['options'] as $value => $name) |
|
| 1626 | + if (is_array($field['options'])) { |
|
| 1627 | + foreach ($field['options'] as $value => $name) |
|
| 1554 | 1628 | echo ' |
| 1555 | 1629 | <option', is_numeric($value) ? ' value="" disabled' : ' value="' . $value . '"', $value === $field['value'] ? ' selected' : '', '>', $name, '</option>'; |
| 1630 | + } |
|
| 1556 | 1631 | } |
| 1557 | 1632 | |
| 1558 | 1633 | echo ' |
@@ -1560,31 +1635,34 @@ discard block |
||
| 1560 | 1635 | } |
| 1561 | 1636 | |
| 1562 | 1637 | // Something to end with? |
| 1563 | - if (!empty($field['postinput'])) |
|
| 1564 | - echo ' |
|
| 1638 | + if (!empty($field['postinput'])) { |
|
| 1639 | + echo ' |
|
| 1565 | 1640 | ', $field['postinput']; |
| 1641 | + } |
|
| 1566 | 1642 | |
| 1567 | 1643 | echo ' |
| 1568 | 1644 | </dd>'; |
| 1569 | 1645 | } |
| 1570 | 1646 | } |
| 1571 | 1647 | |
| 1572 | - if (!empty($context['profile_fields'])) |
|
| 1573 | - echo ' |
|
| 1648 | + if (!empty($context['profile_fields'])) { |
|
| 1649 | + echo ' |
|
| 1574 | 1650 | </dl>'; |
| 1651 | + } |
|
| 1575 | 1652 | |
| 1576 | 1653 | // Are there any custom profile fields - if so print them! |
| 1577 | 1654 | if (!empty($context['custom_fields'])) |
| 1578 | 1655 | { |
| 1579 | - if ($lastItem != 'hr') |
|
| 1580 | - echo ' |
|
| 1656 | + if ($lastItem != 'hr') { |
|
| 1657 | + echo ' |
|
| 1581 | 1658 | <hr>'; |
| 1659 | + } |
|
| 1582 | 1660 | |
| 1583 | 1661 | echo ' |
| 1584 | 1662 | <dl class="settings">'; |
| 1585 | 1663 | |
| 1586 | - foreach ($context['custom_fields'] as $field) |
|
| 1587 | - echo ' |
|
| 1664 | + foreach ($context['custom_fields'] as $field) { |
|
| 1665 | + echo ' |
|
| 1588 | 1666 | <dt> |
| 1589 | 1667 | <strong>', $field['name'], ': </strong><br> |
| 1590 | 1668 | <span class="smalltext">', $field['desc'], '</span> |
@@ -1592,19 +1670,21 @@ discard block |
||
| 1592 | 1670 | <dd> |
| 1593 | 1671 | ', $field['input_html'], ' |
| 1594 | 1672 | </dd>'; |
| 1673 | + } |
|
| 1595 | 1674 | |
| 1596 | 1675 | echo ' |
| 1597 | 1676 | </dl>'; |
| 1598 | 1677 | } |
| 1599 | 1678 | |
| 1600 | 1679 | // Any closing HTML? |
| 1601 | - if (!empty($context['profile_posthtml'])) |
|
| 1602 | - echo ' |
|
| 1680 | + if (!empty($context['profile_posthtml'])) { |
|
| 1681 | + echo ' |
|
| 1603 | 1682 | <div>', $context['profile_posthtml'], '</div>'; |
| 1683 | + } |
|
| 1604 | 1684 | |
| 1605 | 1685 | // Only show the password box if it's actually needed. |
| 1606 | - if ($context['require_password']) |
|
| 1607 | - echo ' |
|
| 1686 | + if ($context['require_password']) { |
|
| 1687 | + echo ' |
|
| 1608 | 1688 | <dl class="settings"> |
| 1609 | 1689 | <dt> |
| 1610 | 1690 | <strong', isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : '', '><label for="oldpasswrd">', $txt['current_password'], ': </label></strong><br> |
@@ -1614,18 +1694,21 @@ discard block |
||
| 1614 | 1694 | <input type="password" name="oldpasswrd" id="oldpasswrd" size="20"> |
| 1615 | 1695 | </dd> |
| 1616 | 1696 | </dl>'; |
| 1697 | + } |
|
| 1617 | 1698 | |
| 1618 | 1699 | // The button shouldn't say "Change profile" unless we're changing the profile... |
| 1619 | - if (!empty($context['submit_button_text'])) |
|
| 1620 | - echo ' |
|
| 1700 | + if (!empty($context['submit_button_text'])) { |
|
| 1701 | + echo ' |
|
| 1621 | 1702 | <input type="submit" name="save" value="', $context['submit_button_text'], '" class="button floatright">'; |
| 1622 | - else |
|
| 1623 | - echo ' |
|
| 1703 | + } else { |
|
| 1704 | + echo ' |
|
| 1624 | 1705 | <input type="submit" name="save" value="', $txt['change_profile'], '" class="button floatright">'; |
| 1706 | + } |
|
| 1625 | 1707 | |
| 1626 | - if (!empty($context['token_check'])) |
|
| 1627 | - echo ' |
|
| 1708 | + if (!empty($context['token_check'])) { |
|
| 1709 | + echo ' |
|
| 1628 | 1710 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
| 1711 | + } |
|
| 1629 | 1712 | |
| 1630 | 1713 | echo ' |
| 1631 | 1714 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -1635,10 +1718,11 @@ discard block |
||
| 1635 | 1718 | </form>'; |
| 1636 | 1719 | |
| 1637 | 1720 | // Any final spellchecking stuff? |
| 1638 | - if (!empty($context['show_spellchecking'])) |
|
| 1639 | - echo ' |
|
| 1721 | + if (!empty($context['show_spellchecking'])) { |
|
| 1722 | + echo ' |
|
| 1640 | 1723 | <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>'; |
| 1641 | -} |
|
| 1724 | + } |
|
| 1725 | + } |
|
| 1642 | 1726 | |
| 1643 | 1727 | /** |
| 1644 | 1728 | * Personal Message settings. |
@@ -1675,10 +1759,11 @@ discard block |
||
| 1675 | 1759 | <select name="pm_receive_from" id="pm_receive_from"> |
| 1676 | 1760 | <option value="0"', empty($context['receive_from']) || (empty($modSettings['enable_buddylist']) && $context['receive_from'] < 3) ? ' selected' : '', '>', $txt['pm_receive_from_everyone'], '</option>'; |
| 1677 | 1761 | |
| 1678 | - if (!empty($modSettings['enable_buddylist'])) |
|
| 1679 | - echo ' |
|
| 1762 | + if (!empty($modSettings['enable_buddylist'])) { |
|
| 1763 | + echo ' |
|
| 1680 | 1764 | <option value="1"', !empty($context['receive_from']) && $context['receive_from'] == 1 ? ' selected' : '', '>', $txt['pm_receive_from_ignore'], '</option> |
| 1681 | 1765 | <option value="2"', !empty($context['receive_from']) && $context['receive_from'] == 2 ? ' selected' : '', '>', $txt['pm_receive_from_buddies'], '</option>'; |
| 1766 | + } |
|
| 1682 | 1767 | |
| 1683 | 1768 | echo ' |
| 1684 | 1769 | <option value="3"', !empty($context['receive_from']) && $context['receive_from'] > 2 ? ' selected' : '', '>', $txt['pm_receive_from_admins'], '</option> |
@@ -1721,11 +1806,12 @@ discard block |
||
| 1721 | 1806 | if (empty($setting) || !is_array($setting)) |
| 1722 | 1807 | { |
| 1723 | 1808 | // Insert a separator (unless this is the first item in the list) |
| 1724 | - if ($i !== $first_option_key) |
|
| 1725 | - echo ' |
|
| 1809 | + if ($i !== $first_option_key) { |
|
| 1810 | + echo ' |
|
| 1726 | 1811 | </dl> |
| 1727 | 1812 | <hr> |
| 1728 | 1813 | <dl class="settings">'; |
| 1814 | + } |
|
| 1729 | 1815 | |
| 1730 | 1816 | // Should we give a name to this section? |
| 1731 | 1817 | if (is_string($setting) && !empty($setting)) |
@@ -1734,69 +1820,67 @@ discard block |
||
| 1734 | 1820 | echo ' |
| 1735 | 1821 | <dt><strong>' . $setting . '</strong></dt> |
| 1736 | 1822 | <dd></dd>'; |
| 1823 | + } else { |
|
| 1824 | + $titled_section = false; |
|
| 1737 | 1825 | } |
| 1738 | - else |
|
| 1739 | - $titled_section = false; |
|
| 1740 | 1826 | |
| 1741 | 1827 | continue; |
| 1742 | 1828 | } |
| 1743 | 1829 | |
| 1744 | 1830 | // Is this disabled? |
| 1745 | - if ($setting['id'] == 'calendar_start_day' && empty($modSettings['cal_enabled'])) |
|
| 1746 | - continue; |
|
| 1747 | - |
|
| 1748 | - elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage'])) |
|
| 1749 | - continue; |
|
| 1750 | - |
|
| 1751 | - elseif ($setting['id'] == 'show_no_censored' && empty($modSettings['allow_no_censored'])) |
|
| 1752 | - continue; |
|
| 1753 | - |
|
| 1754 | - elseif ($setting['id'] == 'posts_apply_ignore_list' && empty($modSettings['enable_buddylist'])) |
|
| 1755 | - continue; |
|
| 1756 | - |
|
| 1757 | - elseif ($setting['id'] == 'wysiwyg_default' && !empty($modSettings['disable_wysiwyg'])) |
|
| 1758 | - continue; |
|
| 1759 | - |
|
| 1760 | - elseif ($setting['id'] == 'drafts_autosave_enabled' && (empty($modSettings['drafts_autosave_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) |
|
| 1761 | - continue; |
|
| 1762 | - |
|
| 1763 | - elseif ($setting['id'] == 'drafts_show_saved_enabled' && (empty($modSettings['drafts_show_saved_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) |
|
| 1764 | - continue; |
|
| 1831 | + if ($setting['id'] == 'calendar_start_day' && empty($modSettings['cal_enabled'])) { |
|
| 1832 | + continue; |
|
| 1833 | + } elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage'])) { |
|
| 1834 | + continue; |
|
| 1835 | + } elseif ($setting['id'] == 'show_no_censored' && empty($modSettings['allow_no_censored'])) { |
|
| 1836 | + continue; |
|
| 1837 | + } elseif ($setting['id'] == 'posts_apply_ignore_list' && empty($modSettings['enable_buddylist'])) { |
|
| 1838 | + continue; |
|
| 1839 | + } elseif ($setting['id'] == 'wysiwyg_default' && !empty($modSettings['disable_wysiwyg'])) { |
|
| 1840 | + continue; |
|
| 1841 | + } elseif ($setting['id'] == 'drafts_autosave_enabled' && (empty($modSettings['drafts_autosave_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) { |
|
| 1842 | + continue; |
|
| 1843 | + } elseif ($setting['id'] == 'drafts_show_saved_enabled' && (empty($modSettings['drafts_show_saved_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) { |
|
| 1844 | + continue; |
|
| 1845 | + } |
|
| 1765 | 1846 | |
| 1766 | 1847 | // Some of these may not be set... Set to defaults here |
| 1767 | 1848 | $opts = array('topics_per_page', 'messages_per_page', 'display_quick_mod'); |
| 1768 | - if (in_array($setting['id'], $opts) && !isset($context['member']['options'][$setting['id']])) |
|
| 1769 | - $context['member']['options'][$setting['id']] = 0; |
|
| 1770 | - |
|
| 1771 | - if (!isset($setting['type']) || $setting['type'] == 'bool') |
|
| 1772 | - $setting['type'] = 'checkbox'; |
|
| 1773 | - |
|
| 1774 | - elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') |
|
| 1775 | - $setting['type'] = 'number'; |
|
| 1849 | + if (in_array($setting['id'], $opts) && !isset($context['member']['options'][$setting['id']])) { |
|
| 1850 | + $context['member']['options'][$setting['id']] = 0; |
|
| 1851 | + } |
|
| 1776 | 1852 | |
| 1777 | - elseif ($setting['type'] == 'string') |
|
| 1778 | - $setting['type'] = 'text'; |
|
| 1853 | + if (!isset($setting['type']) || $setting['type'] == 'bool') { |
|
| 1854 | + $setting['type'] = 'checkbox'; |
|
| 1855 | + } elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') { |
|
| 1856 | + $setting['type'] = 'number'; |
|
| 1857 | + } elseif ($setting['type'] == 'string') { |
|
| 1858 | + $setting['type'] = 'text'; |
|
| 1859 | + } |
|
| 1779 | 1860 | |
| 1780 | - if (isset($setting['options'])) |
|
| 1781 | - $setting['type'] = 'list'; |
|
| 1861 | + if (isset($setting['options'])) { |
|
| 1862 | + $setting['type'] = 'list'; |
|
| 1863 | + } |
|
| 1782 | 1864 | |
| 1783 | 1865 | echo ' |
| 1784 | 1866 | <dt> |
| 1785 | 1867 | <label for="', $setting['id'], '">', !$titled_section ? '<strong>' : '', $setting['label'], !$titled_section ? '</strong>' : '', '</label>'; |
| 1786 | 1868 | |
| 1787 | - if (isset($setting['description'])) |
|
| 1788 | - echo ' |
|
| 1869 | + if (isset($setting['description'])) { |
|
| 1870 | + echo ' |
|
| 1789 | 1871 | <br> |
| 1790 | 1872 | <span class="smalltext">', $setting['description'], '</span>'; |
| 1873 | + } |
|
| 1791 | 1874 | echo ' |
| 1792 | 1875 | </dt> |
| 1793 | 1876 | <dd>'; |
| 1794 | 1877 | |
| 1795 | 1878 | // Display checkbox options |
| 1796 | - if ($setting['type'] == 'checkbox') |
|
| 1797 | - echo ' |
|
| 1879 | + if ($setting['type'] == 'checkbox') { |
|
| 1880 | + echo ' |
|
| 1798 | 1881 | <input type="hidden" name="default_options[' . $setting['id'] . ']" value="0"> |
| 1799 | 1882 | <input type="checkbox" name="default_options[', $setting['id'], ']" id="', $setting['id'], '"', !empty($context['member']['options'][$setting['id']]) ? ' checked' : '', ' value="1">'; |
| 1883 | + } |
|
| 1800 | 1884 | |
| 1801 | 1885 | // How about selection lists, we all love them |
| 1802 | 1886 | elseif ($setting['type'] == 'list') |
@@ -1804,9 +1888,10 @@ discard block |
||
| 1804 | 1888 | echo ' |
| 1805 | 1889 | <select name="default_options[', $setting['id'], ']" id="', $setting['id'], '"', '>'; |
| 1806 | 1890 | |
| 1807 | - foreach ($setting['options'] as $value => $label) |
|
| 1808 | - echo ' |
|
| 1891 | + foreach ($setting['options'] as $value => $label) { |
|
| 1892 | + echo ' |
|
| 1809 | 1893 | <option value="', $value, '"', $value == $context['member']['options'][$setting['id']] ? ' selected' : '', '>', $label, '</option>'; |
| 1894 | + } |
|
| 1810 | 1895 | |
| 1811 | 1896 | echo ' |
| 1812 | 1897 | </select>'; |
@@ -1822,14 +1907,13 @@ discard block |
||
| 1822 | 1907 | |
| 1823 | 1908 | echo ' |
| 1824 | 1909 | <input type="number"', $min . $max . $step; |
| 1825 | - } |
|
| 1826 | - elseif (isset($setting['type']) && $setting['type'] == 'url') |
|
| 1827 | - echo' |
|
| 1910 | + } elseif (isset($setting['type']) && $setting['type'] == 'url') { |
|
| 1911 | + echo' |
|
| 1828 | 1912 | <input type="url"'; |
| 1829 | - |
|
| 1830 | - else |
|
| 1831 | - echo ' |
|
| 1913 | + } else { |
|
| 1914 | + echo ' |
|
| 1832 | 1915 | <input type="text"'; |
| 1916 | + } |
|
| 1833 | 1917 | |
| 1834 | 1918 | echo ' name="default_options[', $setting['id'], ']" id="', $setting['id'], '" value="', isset($context['member']['options'][$setting['id']]) ? $context['member']['options'][$setting['id']] : $setting['value'], '"', $setting['type'] == 'number' ? ' size="5"' : '', '>'; |
| 1835 | 1919 | } |
@@ -1866,8 +1950,8 @@ discard block |
||
| 1866 | 1950 | <dl class="settings">'; |
| 1867 | 1951 | |
| 1868 | 1952 | // Allow notification on announcements to be disabled? |
| 1869 | - if (!empty($modSettings['allow_disableAnnounce'])) |
|
| 1870 | - echo ' |
|
| 1953 | + if (!empty($modSettings['allow_disableAnnounce'])) { |
|
| 1954 | + echo ' |
|
| 1871 | 1955 | <dt> |
| 1872 | 1956 | <label for="notify_announcements">', $txt['notify_important_email'], '</label> |
| 1873 | 1957 | </dt> |
@@ -1875,15 +1959,17 @@ discard block |
||
| 1875 | 1959 | <input type="hidden" name="notify_announcements" value="0"> |
| 1876 | 1960 | <input type="checkbox" id="notify_announcements" name="notify_announcements" value="1"', !empty($context['member']['notify_announcements']) ? ' checked' : '', '> |
| 1877 | 1961 | </dd>'; |
| 1962 | + } |
|
| 1878 | 1963 | |
| 1879 | - if (!empty($modSettings['enable_ajax_alerts'])) |
|
| 1880 | - echo ' |
|
| 1964 | + if (!empty($modSettings['enable_ajax_alerts'])) { |
|
| 1965 | + echo ' |
|
| 1881 | 1966 | <dt> |
| 1882 | 1967 | <label for="notify_send_body">', $txt['notify_alert_timeout'], '</label> |
| 1883 | 1968 | </dt> |
| 1884 | 1969 | <dd> |
| 1885 | 1970 | <input type="number" size="4" id="notify_alert_timeout" name="opt_alert_timeout" min="0" value="', $context['member']['alert_timeout'], '"> |
| 1886 | 1971 | </dd>'; |
| 1972 | + } |
|
| 1887 | 1973 | |
| 1888 | 1974 | echo ' |
| 1889 | 1975 | </dl> |
@@ -1915,9 +2001,10 @@ discard block |
||
| 1915 | 2001 | |
| 1916 | 2002 | $label = $txt['alert_opt_' . $opts[1]]; |
| 1917 | 2003 | $label_pos = isset($opts['label']) ? $opts['label'] : ''; |
| 1918 | - if ($label_pos == 'before') |
|
| 1919 | - echo ' |
|
| 2004 | + if ($label_pos == 'before') { |
|
| 2005 | + echo ' |
|
| 1920 | 2006 | <label for="opt_', $opts[1], '">', $label, '</label>'; |
| 2007 | + } |
|
| 1921 | 2008 | |
| 1922 | 2009 | $this_value = isset($context['alert_prefs'][$opts[1]]) ? $context['alert_prefs'][$opts[1]] : 0; |
| 1923 | 2010 | switch ($opts[0]) |
@@ -1931,17 +2018,19 @@ discard block |
||
| 1931 | 2018 | echo ' |
| 1932 | 2019 | <select name="opt_', $opts[1], '" id="opt_', $opts[1], '">'; |
| 1933 | 2020 | |
| 1934 | - foreach ($opts['opts'] as $k => $v) |
|
| 1935 | - echo ' |
|
| 2021 | + foreach ($opts['opts'] as $k => $v) { |
|
| 2022 | + echo ' |
|
| 1936 | 2023 | <option value="', $k, '"', $this_value == $k ? ' selected' : '', '>', $v, '</option>'; |
| 2024 | + } |
|
| 1937 | 2025 | echo ' |
| 1938 | 2026 | </select>'; |
| 1939 | 2027 | break; |
| 1940 | 2028 | } |
| 1941 | 2029 | |
| 1942 | - if ($label_pos == 'after') |
|
| 1943 | - echo ' |
|
| 2030 | + if ($label_pos == 'after') { |
|
| 2031 | + echo ' |
|
| 1944 | 2032 | <label for="opt_', $opts[1], '">', $label, '</label>'; |
| 2033 | + } |
|
| 1945 | 2034 | |
| 1946 | 2035 | echo ' |
| 1947 | 2036 | </td> |
@@ -2058,11 +2147,12 @@ discard block |
||
| 2058 | 2147 | <p class="information">', $txt['groupMembership_info'], '</p>'; |
| 2059 | 2148 | |
| 2060 | 2149 | // Do we have an update message? |
| 2061 | - if (!empty($context['update_message'])) |
|
| 2062 | - echo ' |
|
| 2150 | + if (!empty($context['update_message'])) { |
|
| 2151 | + echo ' |
|
| 2063 | 2152 | <div class="infobox"> |
| 2064 | 2153 | ', $context['update_message'], '. |
| 2065 | 2154 | </div>'; |
| 2155 | + } |
|
| 2066 | 2156 | |
| 2067 | 2157 | echo ' |
| 2068 | 2158 | <div id="groups">'; |
@@ -2084,8 +2174,7 @@ discard block |
||
| 2084 | 2174 | </div> |
| 2085 | 2175 | </div> |
| 2086 | 2176 | </div><!-- .groupmembership -->'; |
| 2087 | - } |
|
| 2088 | - else |
|
| 2177 | + } else |
|
| 2089 | 2178 | { |
| 2090 | 2179 | echo ' |
| 2091 | 2180 | <div class="title_bar"> |
@@ -2097,27 +2186,30 @@ discard block |
||
| 2097 | 2186 | echo ' |
| 2098 | 2187 | <div class="windowbg" id="primdiv_', $group['id'], '">'; |
| 2099 | 2188 | |
| 2100 | - if ($context['can_edit_primary']) |
|
| 2101 | - echo ' |
|
| 2189 | + if ($context['can_edit_primary']) { |
|
| 2190 | + echo ' |
|
| 2102 | 2191 | <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', '>'; |
| 2192 | + } |
|
| 2103 | 2193 | |
| 2104 | 2194 | echo ' |
| 2105 | 2195 | <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>'; |
| 2106 | 2196 | |
| 2107 | 2197 | // Can they leave their group? |
| 2108 | - if ($group['can_leave']) |
|
| 2109 | - echo ' |
|
| 2198 | + if ($group['can_leave']) { |
|
| 2199 | + echo ' |
|
| 2110 | 2200 | <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>'; |
| 2201 | + } |
|
| 2111 | 2202 | |
| 2112 | 2203 | echo ' |
| 2113 | 2204 | </div><!-- .windowbg -->'; |
| 2114 | 2205 | } |
| 2115 | 2206 | |
| 2116 | - if ($context['can_edit_primary']) |
|
| 2117 | - echo ' |
|
| 2207 | + if ($context['can_edit_primary']) { |
|
| 2208 | + echo ' |
|
| 2118 | 2209 | <div class="padding righttext"> |
| 2119 | 2210 | <input type="submit" value="', $txt['make_primary'], '" class="button"> |
| 2120 | 2211 | </div>'; |
| 2212 | + } |
|
| 2121 | 2213 | |
| 2122 | 2214 | // Any groups they can join? |
| 2123 | 2215 | if (!empty($context['groups']['available'])) |
@@ -2133,17 +2225,16 @@ discard block |
||
| 2133 | 2225 | <div class="windowbg"> |
| 2134 | 2226 | <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>' : ''), ''; |
| 2135 | 2227 | |
| 2136 | - if ($group['type'] == 3) |
|
| 2137 | - echo ' |
|
| 2228 | + if ($group['type'] == 3) { |
|
| 2229 | + echo ' |
|
| 2138 | 2230 | <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>'; |
| 2139 | - |
|
| 2140 | - elseif ($group['type'] == 2 && $group['pending']) |
|
| 2141 | - echo ' |
|
| 2231 | + } elseif ($group['type'] == 2 && $group['pending']) { |
|
| 2232 | + echo ' |
|
| 2142 | 2233 | <span class="floatright">', $txt['approval_pending'], '</span>'; |
| 2143 | - |
|
| 2144 | - elseif ($group['type'] == 2) |
|
| 2145 | - echo ' |
|
| 2234 | + } elseif ($group['type'] == 2) { |
|
| 2235 | + echo ' |
|
| 2146 | 2236 | <a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=groupmembership;request=', $group['id'], '" class="button floatright">', $txt['request_group'], '</a>'; |
| 2237 | + } |
|
| 2147 | 2238 | |
| 2148 | 2239 | echo ' |
| 2149 | 2240 | </div><!-- .windowbg -->'; |
@@ -2166,9 +2257,10 @@ discard block |
||
| 2166 | 2257 | |
| 2167 | 2258 | prevDiv.className = "windowbg"; |
| 2168 | 2259 | }'; |
| 2169 | - if (isset($context['groups']['member'][$context['primary_group']])) |
|
| 2170 | - echo ' |
|
| 2260 | + if (isset($context['groups']['member'][$context['primary_group']])) { |
|
| 2261 | + echo ' |
|
| 2171 | 2262 | highlightSelected("primdiv_' . $context['primary_group'] . '");'; |
| 2263 | + } |
|
| 2172 | 2264 | |
| 2173 | 2265 | echo ' |
| 2174 | 2266 | </script>'; |
@@ -2177,9 +2269,10 @@ discard block |
||
| 2177 | 2269 | echo ' |
| 2178 | 2270 | </div><!-- #groups -->'; |
| 2179 | 2271 | |
| 2180 | - if (!empty($context['token_check'])) |
|
| 2181 | - echo ' |
|
| 2272 | + if (!empty($context['token_check'])) { |
|
| 2273 | + echo ' |
|
| 2182 | 2274 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
| 2275 | + } |
|
| 2183 | 2276 | |
| 2184 | 2277 | echo ' |
| 2185 | 2278 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -2227,14 +2320,15 @@ discard block |
||
| 2227 | 2320 | |
| 2228 | 2321 | foreach ($category['boards'] as $board) |
| 2229 | 2322 | { |
| 2230 | - if ($i == $limit) |
|
| 2231 | - echo ' |
|
| 2323 | + if ($i == $limit) { |
|
| 2324 | + echo ' |
|
| 2232 | 2325 | </ul> |
| 2233 | 2326 | </li> |
| 2234 | 2327 | </ul> |
| 2235 | 2328 | <ul class="ignoreboards floatright"> |
| 2236 | 2329 | <li class="category"> |
| 2237 | 2330 | <ul>'; |
| 2331 | + } |
|
| 2238 | 2332 | |
| 2239 | 2333 | echo ' |
| 2240 | 2334 | <li class="board" style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'], 'em;"> |
@@ -2280,10 +2374,11 @@ discard block |
||
| 2280 | 2374 | |
| 2281 | 2375 | // Work out the starting color. |
| 2282 | 2376 | $context['current_color'] = $context['colors'][0]; |
| 2283 | - foreach ($context['colors'] as $limit => $color) |
|
| 2284 | - if ($context['member']['warning'] >= $limit) |
|
| 2377 | + foreach ($context['colors'] as $limit => $color) { |
|
| 2378 | + if ($context['member']['warning'] >= $limit) |
|
| 2285 | 2379 | $context['current_color'] = $color; |
| 2286 | -} |
|
| 2380 | + } |
|
| 2381 | + } |
|
| 2287 | 2382 | |
| 2288 | 2383 | // Show all warnings of a user? |
| 2289 | 2384 | function template_viewWarning() |
@@ -2322,14 +2417,15 @@ discard block |
||
| 2322 | 2417 | </dd>'; |
| 2323 | 2418 | |
| 2324 | 2419 | // There's some impact of this? |
| 2325 | - if (!empty($context['level_effects'][$context['current_level']])) |
|
| 2326 | - echo ' |
|
| 2420 | + if (!empty($context['level_effects'][$context['current_level']])) { |
|
| 2421 | + echo ' |
|
| 2327 | 2422 | <dt> |
| 2328 | 2423 | <strong>', $txt['profile_viewwarning_impact'], ':</strong> |
| 2329 | 2424 | </dt> |
| 2330 | 2425 | <dd> |
| 2331 | 2426 | ', $context['level_effects'][$context['current_level']], ' |
| 2332 | 2427 | </dd>'; |
| 2428 | + } |
|
| 2333 | 2429 | |
| 2334 | 2430 | echo ' |
| 2335 | 2431 | </dl> |
@@ -2367,10 +2463,11 @@ discard block |
||
| 2367 | 2463 | |
| 2368 | 2464 | // Otherwise see what we can do...'; |
| 2369 | 2465 | |
| 2370 | - foreach ($context['notification_templates'] as $k => $type) |
|
| 2371 | - echo ' |
|
| 2466 | + foreach ($context['notification_templates'] as $k => $type) { |
|
| 2467 | + echo ' |
|
| 2372 | 2468 | if (index == ', $k, ') |
| 2373 | 2469 | document.getElementById(\'warn_body\').value = "', strtr($type['body'], array('"' => "'", "\n" => '\\n', "\r" => '')), '";'; |
| 2470 | + } |
|
| 2374 | 2471 | |
| 2375 | 2472 | echo ' |
| 2376 | 2473 | } |
@@ -2380,10 +2477,11 @@ discard block |
||
| 2380 | 2477 | // Also set the right effect. |
| 2381 | 2478 | effectText = "";'; |
| 2382 | 2479 | |
| 2383 | - foreach ($context['level_effects'] as $limit => $text) |
|
| 2384 | - echo ' |
|
| 2480 | + foreach ($context['level_effects'] as $limit => $text) { |
|
| 2481 | + echo ' |
|
| 2385 | 2482 | if (slideAmount >= ', $limit, ') |
| 2386 | 2483 | effectText = "', $text, '";'; |
| 2484 | + } |
|
| 2387 | 2485 | |
| 2388 | 2486 | echo ' |
| 2389 | 2487 | setInnerHTML(document.getElementById(\'cur_level_div\'), slideAmount + \'% (\' + effectText + \')\'); |
@@ -2398,32 +2496,35 @@ discard block |
||
| 2398 | 2496 | </h3> |
| 2399 | 2497 | </div>'; |
| 2400 | 2498 | |
| 2401 | - if (!$context['user']['is_owner']) |
|
| 2402 | - echo ' |
|
| 2499 | + if (!$context['user']['is_owner']) { |
|
| 2500 | + echo ' |
|
| 2403 | 2501 | <p class="information">', $txt['profile_warning_desc'], '</p>'; |
| 2502 | + } |
|
| 2404 | 2503 | |
| 2405 | 2504 | echo ' |
| 2406 | 2505 | <div class="windowbg"> |
| 2407 | 2506 | <dl class="settings">'; |
| 2408 | 2507 | |
| 2409 | - if (!$context['user']['is_owner']) |
|
| 2410 | - echo ' |
|
| 2508 | + if (!$context['user']['is_owner']) { |
|
| 2509 | + echo ' |
|
| 2411 | 2510 | <dt> |
| 2412 | 2511 | <strong>', $txt['profile_warning_name'], ':</strong> |
| 2413 | 2512 | </dt> |
| 2414 | 2513 | <dd> |
| 2415 | 2514 | <strong>', $context['member']['name'], '</strong> |
| 2416 | 2515 | </dd>'; |
| 2516 | + } |
|
| 2417 | 2517 | |
| 2418 | 2518 | echo ' |
| 2419 | 2519 | <dt> |
| 2420 | 2520 | <strong>', $txt['profile_warning_level'], ':</strong>'; |
| 2421 | 2521 | |
| 2422 | 2522 | // Is there only so much they can apply? |
| 2423 | - if ($context['warning_limit']) |
|
| 2424 | - echo ' |
|
| 2523 | + if ($context['warning_limit']) { |
|
| 2524 | + echo ' |
|
| 2425 | 2525 | <br> |
| 2426 | 2526 | <span class="smalltext">', sprintf($txt['profile_warning_limit_attribute'], $context['warning_limit']), '</span>'; |
| 2527 | + } |
|
| 2427 | 2528 | |
| 2428 | 2529 | echo ' |
| 2429 | 2530 | </dt> |
@@ -2478,9 +2579,10 @@ discard block |
||
| 2478 | 2579 | <option value="-1">', $txt['profile_warning_notify_template'], '</option> |
| 2479 | 2580 | <option value="-1" disabled>------------------------------</option>'; |
| 2480 | 2581 | |
| 2481 | - foreach ($context['notification_templates'] as $id_template => $template) |
|
| 2482 | - echo ' |
|
| 2582 | + foreach ($context['notification_templates'] as $id_template => $template) { |
|
| 2583 | + echo ' |
|
| 2483 | 2584 | <option value="', $id_template, '">', $template['title'], '</option>'; |
| 2585 | + } |
|
| 2484 | 2586 | |
| 2485 | 2587 | echo ' |
| 2486 | 2588 | </select> |
@@ -2493,9 +2595,10 @@ discard block |
||
| 2493 | 2595 | </dl> |
| 2494 | 2596 | <div class="righttext">'; |
| 2495 | 2597 | |
| 2496 | - if (!empty($context['token_check'])) |
|
| 2497 | - echo ' |
|
| 2598 | + if (!empty($context['token_check'])) { |
|
| 2599 | + echo ' |
|
| 2498 | 2600 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
| 2601 | + } |
|
| 2499 | 2602 | |
| 2500 | 2603 | echo ' |
| 2501 | 2604 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -2511,8 +2614,8 @@ discard block |
||
| 2511 | 2614 | echo ' |
| 2512 | 2615 | <script>'; |
| 2513 | 2616 | |
| 2514 | - if (!$context['user']['is_owner']) |
|
| 2515 | - echo ' |
|
| 2617 | + if (!$context['user']['is_owner']) { |
|
| 2618 | + echo ' |
|
| 2516 | 2619 | modifyWarnNotify(); |
| 2517 | 2620 | $(document).ready(function() { |
| 2518 | 2621 | $("#preview_button").click(function() { |
@@ -2551,6 +2654,7 @@ discard block |
||
| 2551 | 2654 | }); |
| 2552 | 2655 | return false; |
| 2553 | 2656 | }'; |
| 2657 | + } |
|
| 2554 | 2658 | |
| 2555 | 2659 | echo ' |
| 2556 | 2660 | </script>'; |
@@ -2573,17 +2677,19 @@ discard block |
||
| 2573 | 2677 | </div>'; |
| 2574 | 2678 | |
| 2575 | 2679 | // If deleting another account give them a lovely info box. |
| 2576 | - if (!$context['user']['is_owner']) |
|
| 2577 | - echo ' |
|
| 2680 | + if (!$context['user']['is_owner']) { |
|
| 2681 | + echo ' |
|
| 2578 | 2682 | <p class="information">', $txt['deleteAccount_desc'], '</p>'; |
| 2683 | + } |
|
| 2579 | 2684 | |
| 2580 | 2685 | echo ' |
| 2581 | 2686 | <div class="windowbg2">'; |
| 2582 | 2687 | |
| 2583 | 2688 | // If they are deleting their account AND the admin needs to approve it - give them another piece of info ;) |
| 2584 | - if ($context['needs_approval']) |
|
| 2585 | - echo ' |
|
| 2689 | + if ($context['needs_approval']) { |
|
| 2690 | + echo ' |
|
| 2586 | 2691 | <div class="errorbox">', $txt['deleteAccount_approval'], '</div>'; |
| 2692 | + } |
|
| 2587 | 2693 | |
| 2588 | 2694 | // If the user is deleting their own account warn them first - and require a password! |
| 2589 | 2695 | if ($context['user']['is_owner']) |
@@ -2595,9 +2701,10 @@ discard block |
||
| 2595 | 2701 | <input type="password" name="oldpasswrd" size="20"> |
| 2596 | 2702 | <input type="submit" value="', $txt['yes'], '" class="button">'; |
| 2597 | 2703 | |
| 2598 | - if (!empty($context['token_check'])) |
|
| 2599 | - echo ' |
|
| 2704 | + if (!empty($context['token_check'])) { |
|
| 2705 | + echo ' |
|
| 2600 | 2706 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
| 2707 | + } |
|
| 2601 | 2708 | |
| 2602 | 2709 | echo ' |
| 2603 | 2710 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -2627,10 +2734,11 @@ discard block |
||
| 2627 | 2734 | <option value="topics">', $txt['deleteAccount_topics'], '</option> |
| 2628 | 2735 | </select>'; |
| 2629 | 2736 | |
| 2630 | - if ($context['show_perma_delete']) |
|
| 2631 | - echo ' |
|
| 2737 | + if ($context['show_perma_delete']) { |
|
| 2738 | + echo ' |
|
| 2632 | 2739 | <br> |
| 2633 | 2740 | <label for="perma_delete"><input type="checkbox" name="perma_delete" id="perma_delete" value="1">', $txt['deleteAccount_permanent'], ':</label>'; |
| 2741 | + } |
|
| 2634 | 2742 | |
| 2635 | 2743 | echo ' |
| 2636 | 2744 | </div>'; |
@@ -2643,9 +2751,10 @@ discard block |
||
| 2643 | 2751 | <div> |
| 2644 | 2752 | <input type="submit" value="', $txt['delete'], '" class="button">'; |
| 2645 | 2753 | |
| 2646 | - if (!empty($context['token_check'])) |
|
| 2647 | - echo ' |
|
| 2754 | + if (!empty($context['token_check'])) { |
|
| 2755 | + echo ' |
|
| 2648 | 2756 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
| 2757 | + } |
|
| 2649 | 2758 | |
| 2650 | 2759 | echo ' |
| 2651 | 2760 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -2671,8 +2780,8 @@ discard block |
||
| 2671 | 2780 | <hr>'; |
| 2672 | 2781 | |
| 2673 | 2782 | // Only show the password box if it's actually needed. |
| 2674 | - if ($context['require_password']) |
|
| 2675 | - echo ' |
|
| 2783 | + if ($context['require_password']) { |
|
| 2784 | + echo ' |
|
| 2676 | 2785 | <dl class="settings"> |
| 2677 | 2786 | <dt> |
| 2678 | 2787 | <strong', isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : '', '>', $txt['current_password'], ': </strong><br> |
@@ -2682,13 +2791,15 @@ discard block |
||
| 2682 | 2791 | <input type="password" name="oldpasswrd" size="20"> |
| 2683 | 2792 | </dd> |
| 2684 | 2793 | </dl>'; |
| 2794 | + } |
|
| 2685 | 2795 | |
| 2686 | 2796 | echo ' |
| 2687 | 2797 | <div class="righttext">'; |
| 2688 | 2798 | |
| 2689 | - if (!empty($context['token_check'])) |
|
| 2690 | - echo ' |
|
| 2799 | + if (!empty($context['token_check'])) { |
|
| 2800 | + echo ' |
|
| 2691 | 2801 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
| 2802 | + } |
|
| 2692 | 2803 | |
| 2693 | 2804 | echo ' |
| 2694 | 2805 | <input type="submit" value="', $txt['change_profile'], '" class="button"> |
@@ -2715,9 +2826,10 @@ discard block |
||
| 2715 | 2826 | <ul id="list_errors">'; |
| 2716 | 2827 | |
| 2717 | 2828 | // Cycle through each error and display an error message. |
| 2718 | - foreach ($context['post_errors'] as $error) |
|
| 2719 | - echo ' |
|
| 2829 | + foreach ($context['post_errors'] as $error) { |
|
| 2830 | + echo ' |
|
| 2720 | 2831 | <li>', isset($txt['profile_error_' . $error]) ? $txt['profile_error_' . $error] : $error, '</li>'; |
| 2832 | + } |
|
| 2721 | 2833 | |
| 2722 | 2834 | echo ' |
| 2723 | 2835 | </ul>'; |
@@ -2743,12 +2855,13 @@ discard block |
||
| 2743 | 2855 | <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;"' : ''), '>'; |
| 2744 | 2856 | |
| 2745 | 2857 | // Fill the select box with all primary member groups that can be assigned to a member. |
| 2746 | - foreach ($context['member_groups'] as $member_group) |
|
| 2747 | - if (!empty($member_group['can_be_primary'])) |
|
| 2858 | + foreach ($context['member_groups'] as $member_group) { |
|
| 2859 | + if (!empty($member_group['can_be_primary'])) |
|
| 2748 | 2860 | echo ' |
| 2749 | 2861 | <option value="', $member_group['id'], '"', $member_group['is_primary'] ? ' selected' : '', '> |
| 2750 | 2862 | ', $member_group['name'], ' |
| 2751 | 2863 | </option>'; |
| 2864 | + } |
|
| 2752 | 2865 | |
| 2753 | 2866 | echo ' |
| 2754 | 2867 | </select> |
@@ -2761,10 +2874,11 @@ discard block |
||
| 2761 | 2874 | <input type="hidden" name="additional_groups[]" value="0">'; |
| 2762 | 2875 | |
| 2763 | 2876 | // For each membergroup show a checkbox so members can be assigned to more than one group. |
| 2764 | - foreach ($context['member_groups'] as $member_group) |
|
| 2765 | - if ($member_group['can_be_additional']) |
|
| 2877 | + foreach ($context['member_groups'] as $member_group) { |
|
| 2878 | + if ($member_group['can_be_additional']) |
|
| 2766 | 2879 | echo ' |
| 2767 | 2880 | <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' : '', '> ', $member_group['name'], '</label><br>'; |
| 2881 | + } |
|
| 2768 | 2882 | |
| 2769 | 2883 | echo ' |
| 2770 | 2884 | </span> |
@@ -2824,9 +2938,10 @@ discard block |
||
| 2824 | 2938 | <span class="smalltext">', $txt['sig_info'], '</span><br> |
| 2825 | 2939 | <br>'; |
| 2826 | 2940 | |
| 2827 | - if ($context['show_spellchecking']) |
|
| 2828 | - echo ' |
|
| 2941 | + if ($context['show_spellchecking']) { |
|
| 2942 | + echo ' |
|
| 2829 | 2943 | <input type="button" value="', $txt['spell_check'], '" onclick="spellCheck(\'creator\', \'signature\');" class="button">'; |
| 2944 | + } |
|
| 2830 | 2945 | |
| 2831 | 2946 | echo ' |
| 2832 | 2947 | </dt> |
@@ -2834,17 +2949,20 @@ discard block |
||
| 2834 | 2949 | <textarea class="editor" onkeyup="calcCharLeft();" id="signature" name="signature" rows="5" cols="50">', $context['member']['signature'], '</textarea><br>'; |
| 2835 | 2950 | |
| 2836 | 2951 | // If there is a limit at all! |
| 2837 | - if (!empty($context['signature_limits']['max_length'])) |
|
| 2838 | - echo ' |
|
| 2952 | + if (!empty($context['signature_limits']['max_length'])) { |
|
| 2953 | + echo ' |
|
| 2839 | 2954 | <span class="smalltext">', sprintf($txt['max_sig_characters'], $context['signature_limits']['max_length']), ' <span id="signatureLeft">', $context['signature_limits']['max_length'], '</span></span><br>'; |
| 2955 | + } |
|
| 2840 | 2956 | |
| 2841 | - if (!empty($context['show_preview_button'])) |
|
| 2842 | - echo ' |
|
| 2957 | + if (!empty($context['show_preview_button'])) { |
|
| 2958 | + echo ' |
|
| 2843 | 2959 | <input type="button" name="preview_signature" id="preview_button" value="', $txt['preview_signature'], '" class="button floatright">'; |
| 2960 | + } |
|
| 2844 | 2961 | |
| 2845 | - if ($context['signature_warning']) |
|
| 2846 | - echo ' |
|
| 2962 | + if ($context['signature_warning']) { |
|
| 2963 | + echo ' |
|
| 2847 | 2964 | <span class="smalltext">', $context['signature_warning'], '</span>'; |
| 2965 | + } |
|
| 2848 | 2966 | |
| 2849 | 2967 | // Some javascript used to count how many characters have been used so far in the signature. |
| 2850 | 2968 | echo ' |
@@ -2889,9 +3007,10 @@ discard block |
||
| 2889 | 3007 | <select name="cat" id="cat" size="10" onchange="changeSel(\'\');" onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'server_stored\');">'; |
| 2890 | 3008 | |
| 2891 | 3009 | // This lists all the file categories. |
| 2892 | - foreach ($context['avatars'] as $avatar) |
|
| 2893 | - echo ' |
|
| 3010 | + foreach ($context['avatars'] as $avatar) { |
|
| 3011 | + echo ' |
|
| 2894 | 3012 | <option value="', $avatar['filename'] . ($avatar['is_dir'] ? '/' : ''), '"', ($avatar['checked'] ? ' selected' : ''), '>', $avatar['name'], '</option>'; |
| 3013 | + } |
|
| 2895 | 3014 | |
| 2896 | 3015 | echo ' |
| 2897 | 3016 | </select> |
@@ -2923,20 +3042,22 @@ discard block |
||
| 2923 | 3042 | } |
| 2924 | 3043 | |
| 2925 | 3044 | // If the user can link to an off server avatar, show them a box to input the address. |
| 2926 | - if (!empty($context['member']['avatar']['allow_external'])) |
|
| 2927 | - echo ' |
|
| 3045 | + if (!empty($context['member']['avatar']['allow_external'])) { |
|
| 3046 | + echo ' |
|
| 2928 | 3047 | <div id="avatar_external"> |
| 2929 | 3048 | <div class="smalltext">', $txt['avatar_by_url'], '</div>', !empty($modSettings['avatar_action_too_large']) && $modSettings['avatar_action_too_large'] == 'option_download_and_resize' ? template_max_size('external') : '', ' |
| 2930 | 3049 | <input type="text" name="userpicpersonal" size="45" value="', ((stristr($context['member']['avatar']['external'], 'http://') || stristr($context['member']['avatar']['external'], 'https://')) ? $context['member']['avatar']['external'] : 'http://'), '" onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'external\');" onchange="if (typeof(previewExternalAvatar) != \'undefined\') previewExternalAvatar(this.value);"> |
| 2931 | 3050 | </div>'; |
| 3051 | + } |
|
| 2932 | 3052 | |
| 2933 | 3053 | // If the user is able to upload avatars to the server show them an upload box. |
| 2934 | - if (!empty($context['member']['avatar']['allow_upload'])) |
|
| 2935 | - echo ' |
|
| 3054 | + if (!empty($context['member']['avatar']['allow_upload'])) { |
|
| 3055 | + echo ' |
|
| 2936 | 3056 | <div id="avatar_upload"> |
| 2937 | 3057 | <input type="file" size="44" name="attachment" id="avatar_upload_box" value="" onchange="readfromUpload(this)" onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'upload\');" accept="image/gif, image/jpeg, image/jpg, image/png">', template_max_size('upload'), ' |
| 2938 | 3058 | ', (!empty($context['member']['avatar']['id_attach']) ? '<br><img src="' . $context['member']['avatar']['href'] . (strpos($context['member']['avatar']['href'], '?') === false ? '?' : '&') . 'time=' . time() . '" alt="" id="attached_image"><input type="hidden" name="id_attach" value="' . $context['member']['avatar']['id_attach'] . '">' : ''), ' |
| 2939 | 3059 | </div>'; |
| 3060 | + } |
|
| 2940 | 3061 | |
| 2941 | 3062 | // if the user is able to use Gravatar avatars show then the image preview |
| 2942 | 3063 | if (!empty($context['member']['avatar']['allow_gravatar'])) |
@@ -2945,16 +3066,17 @@ discard block |
||
| 2945 | 3066 | <div id="avatar_gravatar"> |
| 2946 | 3067 | <img src="' . $context['member']['avatar']['href'] . '" alt="">'; |
| 2947 | 3068 | |
| 2948 | - if (empty($modSettings['gravatarAllowExtraEmail'])) |
|
| 2949 | - echo ' |
|
| 3069 | + if (empty($modSettings['gravatarAllowExtraEmail'])) { |
|
| 3070 | + echo ' |
|
| 2950 | 3071 | <div class="smalltext">', $txt['gravatar_noAlternateEmail'], '</div>'; |
| 2951 | - else |
|
| 3072 | + } else |
|
| 2952 | 3073 | { |
| 2953 | 3074 | // Depending on other stuff, the stored value here might have some odd things in it from other areas. |
| 2954 | - if ($context['member']['avatar']['external'] == $context['member']['email']) |
|
| 2955 | - $textbox_value = ''; |
|
| 2956 | - else |
|
| 2957 | - $textbox_value = $context['member']['avatar']['external']; |
|
| 3075 | + if ($context['member']['avatar']['external'] == $context['member']['email']) { |
|
| 3076 | + $textbox_value = ''; |
|
| 3077 | + } else { |
|
| 3078 | + $textbox_value = $context['member']['avatar']['external']; |
|
| 3079 | + } |
|
| 2958 | 3080 | |
| 2959 | 3081 | echo ' |
| 2960 | 3082 | <div class="smalltext">', $txt['gravatar_alternateEmail'], '</div> |
@@ -3026,8 +3148,9 @@ discard block |
||
| 3026 | 3148 | $h = !empty($modSettings['avatar_max_height_' . $type]) ? comma_format($modSettings['avatar_max_height_' . $type]) : 0; |
| 3027 | 3149 | |
| 3028 | 3150 | $suffix = (!empty($w) ? 'w' : '') . (!empty($h) ? 'h' : ''); |
| 3029 | - if (empty($suffix)) |
|
| 3030 | - return; |
|
| 3151 | + if (empty($suffix)) { |
|
| 3152 | + return; |
|
| 3153 | + } |
|
| 3031 | 3154 | |
| 3032 | 3155 | echo ' |
| 3033 | 3156 | <div class="smalltext">', sprintf($txt['avatar_max_size_' . $suffix], $w, $h), '</div>'; |
@@ -3052,9 +3175,10 @@ discard block |
||
| 3052 | 3175 | <select name="easyformat" id="easyformat" onchange="document.forms.creator.time_format.value = this.options[this.selectedIndex].value;">'; |
| 3053 | 3176 | |
| 3054 | 3177 | // Help the user by showing a list of common time formats. |
| 3055 | - foreach ($context['easy_timeformats'] as $time_format) |
|
| 3056 | - echo ' |
|
| 3178 | + foreach ($context['easy_timeformats'] as $time_format) { |
|
| 3179 | + echo ' |
|
| 3057 | 3180 | <option value="', $time_format['format'], '"', $time_format['format'] == $context['member']['time_format'] ? ' selected' : '', '>', $time_format['title'], '</option>'; |
| 3181 | + } |
|
| 3058 | 3182 | |
| 3059 | 3183 | echo ' |
| 3060 | 3184 | </select> |
@@ -3092,9 +3216,10 @@ discard block |
||
| 3092 | 3216 | <dd> |
| 3093 | 3217 | <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.png\';">'; |
| 3094 | 3218 | |
| 3095 | - foreach ($context['smiley_sets'] as $set) |
|
| 3096 | - echo ' |
|
| 3219 | + foreach ($context['smiley_sets'] as $set) { |
|
| 3220 | + echo ' |
|
| 3097 | 3221 | <option value="', $set['id'], '"', $set['selected'] ? ' selected' : '', '>', $set['name'], '</option>'; |
| 3222 | + } |
|
| 3098 | 3223 | |
| 3099 | 3224 | echo ' |
| 3100 | 3225 | </select> |
@@ -3146,10 +3271,11 @@ discard block |
||
| 3146 | 3271 | <img src="', $context['tfa_qr_url'], '" alt=""> |
| 3147 | 3272 | </div>'; |
| 3148 | 3273 | |
| 3149 | - if (!empty($context['from_ajax'])) |
|
| 3150 | - echo ' |
|
| 3274 | + if (!empty($context['from_ajax'])) { |
|
| 3275 | + echo ' |
|
| 3151 | 3276 | <br> |
| 3152 | 3277 | <a href="javascript:self.close();"></a>'; |
| 3278 | + } |
|
| 3153 | 3279 | |
| 3154 | 3280 | echo ' |
| 3155 | 3281 | </div> |
@@ -3189,17 +3315,16 @@ discard block |
||
| 3189 | 3315 | </dt> |
| 3190 | 3316 | <dd>'; |
| 3191 | 3317 | |
| 3192 | - if (!$context['tfa_enabled'] && $context['user']['is_owner']) |
|
| 3193 | - echo ' |
|
| 3318 | + if (!$context['tfa_enabled'] && $context['user']['is_owner']) { |
|
| 3319 | + echo ' |
|
| 3194 | 3320 | <a href="', !empty($modSettings['force_ssl']) ? strtr($scripturl, array('http://' => 'https://')) : $scripturl, '?action=profile;area=tfasetup" id="enable_tfa">', $txt['tfa_profile_enable'], '</a>'; |
| 3195 | - |
|
| 3196 | - elseif (!$context['tfa_enabled']) |
|
| 3197 | - echo ' |
|
| 3321 | + } elseif (!$context['tfa_enabled']) { |
|
| 3322 | + echo ' |
|
| 3198 | 3323 | ', $txt['tfa_profile_disabled']; |
| 3199 | - |
|
| 3200 | - else |
|
| 3201 | - echo ' |
|
| 3324 | + } else { |
|
| 3325 | + echo ' |
|
| 3202 | 3326 | ', sprintf($txt['tfa_profile_enabled'], $scripturl . '?action=profile;u=' . $context['id_member'] . ';area=tfasetup;disable'); |
| 3327 | + } |
|
| 3203 | 3328 | |
| 3204 | 3329 | echo ' |
| 3205 | 3330 | </dd>'; |
@@ -22,30 +22,32 @@ discard block |
||
| 22 | 22 | <div id="calendar">'; |
| 23 | 23 | |
| 24 | 24 | // Show the mini-blocks if they're enabled. |
| 25 | - if (empty($context['blocks_disabled'])) |
|
| 26 | - echo ' |
|
| 25 | + if (empty($context['blocks_disabled'])) { |
|
| 26 | + echo ' |
|
| 27 | 27 | <div id="month_grid"> |
| 28 | 28 | ', template_show_month_grid('prev', true), ' |
| 29 | 29 | ', template_show_month_grid('current', true), ' |
| 30 | 30 | ', template_show_month_grid('next', true), ' |
| 31 | 31 | </div>'; |
| 32 | + } |
|
| 32 | 33 | |
| 33 | 34 | // What view are we showing? |
| 34 | - if ($context['calendar_view'] == 'viewlist') |
|
| 35 | - echo ' |
|
| 35 | + if ($context['calendar_view'] == 'viewlist') { |
|
| 36 | + echo ' |
|
| 36 | 37 | <div id="main_grid"> |
| 37 | 38 | ', template_show_upcoming_list('main'), ' |
| 38 | 39 | </div>'; |
| 39 | - elseif ($context['calendar_view'] == 'viewweek') |
|
| 40 | - echo ' |
|
| 40 | + } elseif ($context['calendar_view'] == 'viewweek') { |
|
| 41 | + echo ' |
|
| 41 | 42 | <div id="main_grid"> |
| 42 | 43 | ', template_show_week_grid('main'), ' |
| 43 | 44 | </div>'; |
| 44 | - else |
|
| 45 | - echo ' |
|
| 45 | + } else { |
|
| 46 | + echo ' |
|
| 46 | 47 | <div id="main_grid"> |
| 47 | 48 | ', template_show_month_grid('main'), ' |
| 48 | 49 | </div>'; |
| 50 | + } |
|
| 49 | 51 | |
| 50 | 52 | // Close our wrapper. |
| 51 | 53 | echo ' |
@@ -64,20 +66,22 @@ discard block |
||
| 64 | 66 | global $context, $scripturl, $txt; |
| 65 | 67 | |
| 66 | 68 | // Bail out if we have nothing to work with |
| 67 | - if (!isset($context['calendar_grid_' . $grid_name])) |
|
| 68 | - return false; |
|
| 69 | + if (!isset($context['calendar_grid_' . $grid_name])) { |
|
| 70 | + return false; |
|
| 71 | + } |
|
| 69 | 72 | |
| 70 | 73 | // Protect programmer sanity |
| 71 | 74 | $calendar_data = &$context['calendar_grid_' . $grid_name]; |
| 72 | 75 | |
| 73 | 76 | // Do we want a title? |
| 74 | - if (empty($calendar_data['disable_title'])) |
|
| 75 | - echo ' |
|
| 77 | + if (empty($calendar_data['disable_title'])) { |
|
| 78 | + echo ' |
|
| 76 | 79 | <div class="cat_bar"> |
| 77 | 80 | <h3 class="catbg centertext largetext"> |
| 78 | 81 | <a href="', $scripturl, '?action=calendar;viewlist;year=', $calendar_data['start_year'], ';month=', $calendar_data['start_month'], ';day=', $calendar_data['start_day'], '">', $txt['calendar_upcoming'], '</a> |
| 79 | 82 | </h3> |
| 80 | 83 | </div>'; |
| 84 | + } |
|
| 81 | 85 | |
| 82 | 86 | // Give the user some controls to work with |
| 83 | 87 | template_calendar_top($calendar_data); |
@@ -100,11 +104,13 @@ discard block |
||
| 100 | 104 | <li class="windowbg"> |
| 101 | 105 | <strong class="event_title">', $event['link'], '</strong>'; |
| 102 | 106 | |
| 103 | - if ($event['can_edit']) |
|
| 104 | - echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>'; |
|
| 107 | + if ($event['can_edit']) { |
|
| 108 | + echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>'; |
|
| 109 | + } |
|
| 105 | 110 | |
| 106 | - if ($event['can_export']) |
|
| 107 | - echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>'; |
|
| 111 | + if ($event['can_export']) { |
|
| 112 | + echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>'; |
|
| 113 | + } |
|
| 108 | 114 | |
| 109 | 115 | echo ' |
| 110 | 116 | <br>'; |
@@ -112,14 +118,14 @@ discard block |
||
| 112 | 118 | if (!empty($event['allday'])) |
| 113 | 119 | { |
| 114 | 120 | echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), '</time>', ($event['start_date'] != $event['end_date']) ? ' – <time datetime="' . $event['end_iso_gmdate'] . '">' . trim($event['end_date_local']) . '</time>' : ''; |
| 115 | - } |
|
| 116 | - else |
|
| 121 | + } else |
|
| 117 | 122 | { |
| 118 | 123 | // Display event info relative to user's local timezone |
| 119 | 124 | echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), ', ', trim($event['start_time_local']), '</time> – <time datetime="' . $event['end_iso_gmdate'] . '">'; |
| 120 | 125 | |
| 121 | - if ($event['start_date_local'] != $event['end_date_local']) |
|
| 122 | - echo trim($event['end_date_local']) . ', '; |
|
| 126 | + if ($event['start_date_local'] != $event['end_date_local']) { |
|
| 127 | + echo trim($event['end_date_local']) . ', '; |
|
| 128 | + } |
|
| 123 | 129 | |
| 124 | 130 | echo trim($event['end_time_local']); |
| 125 | 131 | |
@@ -128,23 +134,27 @@ discard block |
||
| 128 | 134 | { |
| 129 | 135 | echo '</time> (<time datetime="' . $event['start_iso_gmdate'] . '">'; |
| 130 | 136 | |
| 131 | - if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig']) |
|
| 132 | - echo trim($event['start_date_orig']), ', '; |
|
| 137 | + if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig']) { |
|
| 138 | + echo trim($event['start_date_orig']), ', '; |
|
| 139 | + } |
|
| 133 | 140 | |
| 134 | 141 | echo trim($event['start_time_orig']), '</time> – <time datetime="' . $event['end_iso_gmdate'] . '">'; |
| 135 | 142 | |
| 136 | - if ($event['start_date_orig'] != $event['end_date_orig']) |
|
| 137 | - echo trim($event['end_date_orig']) . ', '; |
|
| 143 | + if ($event['start_date_orig'] != $event['end_date_orig']) { |
|
| 144 | + echo trim($event['end_date_orig']) . ', '; |
|
| 145 | + } |
|
| 138 | 146 | |
| 139 | 147 | echo trim($event['end_time_orig']), ' ', $event['tz_abbrev'], '</time>)'; |
| 140 | 148 | } |
| 141 | 149 | // Event is scheduled in the user's own timezone? Let 'em know, just to avoid confusion |
| 142 | - else |
|
| 143 | - echo ' ', $event['tz_abbrev'], '</time>'; |
|
| 150 | + else { |
|
| 151 | + echo ' ', $event['tz_abbrev'], '</time>'; |
|
| 152 | + } |
|
| 144 | 153 | } |
| 145 | 154 | |
| 146 | - if (!empty($event['location'])) |
|
| 147 | - echo '<br>', $event['location']; |
|
| 155 | + if (!empty($event['location'])) { |
|
| 156 | + echo '<br>', $event['location']; |
|
| 157 | + } |
|
| 148 | 158 | |
| 149 | 159 | echo ' |
| 150 | 160 | </li>'; |
@@ -176,8 +186,9 @@ discard block |
||
| 176 | 186 | |
| 177 | 187 | $birthdays = array(); |
| 178 | 188 | |
| 179 | - foreach ($date as $member) |
|
| 180 | - $birthdays[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '">' . $member['name'] . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>'; |
|
| 189 | + foreach ($date as $member) { |
|
| 190 | + $birthdays[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '">' . $member['name'] . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>'; |
|
| 191 | + } |
|
| 181 | 192 | |
| 182 | 193 | echo implode(', ', $birthdays); |
| 183 | 194 | |
@@ -208,8 +219,9 @@ discard block |
||
| 208 | 219 | $date_local = $date['date_local']; |
| 209 | 220 | unset($date['date_local']); |
| 210 | 221 | |
| 211 | - foreach ($date as $holiday) |
|
| 212 | - $holidays[] = $holiday . ' (' . $date_local . ')'; |
|
| 222 | + foreach ($date as $holiday) { |
|
| 223 | + $holidays[] = $holiday . ' (' . $date_local . ')'; |
|
| 224 | + } |
|
| 213 | 225 | } |
| 214 | 226 | |
| 215 | 227 | echo implode(', ', $holidays); |
@@ -233,17 +245,19 @@ discard block |
||
| 233 | 245 | global $context, $txt, $scripturl, $modSettings; |
| 234 | 246 | |
| 235 | 247 | // If the grid doesn't exist, no point in proceeding. |
| 236 | - if (!isset($context['calendar_grid_' . $grid_name])) |
|
| 237 | - return false; |
|
| 248 | + if (!isset($context['calendar_grid_' . $grid_name])) { |
|
| 249 | + return false; |
|
| 250 | + } |
|
| 238 | 251 | |
| 239 | 252 | // A handy little pointer variable. |
| 240 | 253 | $calendar_data = &$context['calendar_grid_' . $grid_name]; |
| 241 | 254 | |
| 242 | 255 | // Some conditions for whether or not we should show the week links *here*. |
| 243 | - if (isset($calendar_data['show_week_links']) && ($calendar_data['show_week_links'] == 3 || (($calendar_data['show_week_links'] == 1 && $is_mini === true) || $calendar_data['show_week_links'] == 2 && $is_mini === false))) |
|
| 244 | - $show_week_links = true; |
|
| 245 | - else |
|
| 246 | - $show_week_links = false; |
|
| 256 | + if (isset($calendar_data['show_week_links']) && ($calendar_data['show_week_links'] == 3 || (($calendar_data['show_week_links'] == 1 && $is_mini === true) || $calendar_data['show_week_links'] == 2 && $is_mini === false))) { |
|
| 257 | + $show_week_links = true; |
|
| 258 | + } else { |
|
| 259 | + $show_week_links = false; |
|
| 260 | + } |
|
| 247 | 261 | |
| 248 | 262 | // Assuming that we've not disabled it, show the title block! |
| 249 | 263 | if (empty($calendar_data['disable_title'])) |
@@ -253,18 +267,20 @@ discard block |
||
| 253 | 267 | <h3 class="catbg centertext largetext">'; |
| 254 | 268 | |
| 255 | 269 | // Previous Link: If we're showing prev / next and it's not a mini-calendar. |
| 256 | - if (empty($calendar_data['previous_calendar']['disabled']) && $calendar_data['show_next_prev'] && $is_mini === false) |
|
| 257 | - echo ' |
|
| 270 | + if (empty($calendar_data['previous_calendar']['disabled']) && $calendar_data['show_next_prev'] && $is_mini === false) { |
|
| 271 | + echo ' |
|
| 258 | 272 | <span class="floatleft"> |
| 259 | 273 | <a href="', $calendar_data['previous_calendar']['href'], '">«</a> |
| 260 | 274 | </span>'; |
| 275 | + } |
|
| 261 | 276 | |
| 262 | 277 | // Next Link: if we're showing prev / next and it's not a mini-calendar. |
| 263 | - if (empty($calendar_data['next_calendar']['disabled']) && $calendar_data['show_next_prev'] && $is_mini === false) |
|
| 264 | - echo ' |
|
| 278 | + if (empty($calendar_data['next_calendar']['disabled']) && $calendar_data['show_next_prev'] && $is_mini === false) { |
|
| 279 | + echo ' |
|
| 265 | 280 | <span class="floatright"> |
| 266 | 281 | <a href="', $calendar_data['next_calendar']['href'], '">»</a> |
| 267 | 282 | </span>'; |
| 283 | + } |
|
| 268 | 284 | |
| 269 | 285 | // Arguably the most exciting part, the title! |
| 270 | 286 | echo ' |
@@ -274,8 +290,9 @@ discard block |
||
| 274 | 290 | } |
| 275 | 291 | |
| 276 | 292 | // Show the controls on main grids |
| 277 | - if ($is_mini === false) |
|
| 278 | - template_calendar_top($calendar_data); |
|
| 293 | + if ($is_mini === false) { |
|
| 294 | + template_calendar_top($calendar_data); |
|
| 295 | + } |
|
| 279 | 296 | |
| 280 | 297 | // Finally, the main calendar table. |
| 281 | 298 | echo ' |
@@ -288,14 +305,16 @@ discard block |
||
| 288 | 305 | <tr>'; |
| 289 | 306 | |
| 290 | 307 | // If we're showing week links, there's an extra column ahead of the week links, so let's think ahead and be prepared! |
| 291 | - if ($show_week_links === true) |
|
| 292 | - echo ' |
|
| 308 | + if ($show_week_links === true) { |
|
| 309 | + echo ' |
|
| 293 | 310 | <th></th>'; |
| 311 | + } |
|
| 294 | 312 | |
| 295 | 313 | // Now, loop through each actual day of the week. |
| 296 | - foreach ($calendar_data['week_days'] as $day) |
|
| 297 | - echo ' |
|
| 314 | + foreach ($calendar_data['week_days'] as $day) { |
|
| 315 | + echo ' |
|
| 298 | 316 | <th class="days" scope="col">', !empty($calendar_data['short_day_titles']) || $is_mini === true ? $txt['days_short'][$day] : $txt['days'][$day], '</th>'; |
| 317 | + } |
|
| 299 | 318 | |
| 300 | 319 | echo ' |
| 301 | 320 | </tr>'; |
@@ -313,11 +332,12 @@ discard block |
||
| 313 | 332 | <tr class="days_wrapper">'; |
| 314 | 333 | |
| 315 | 334 | // This is where we add the actual week link, if enabled on this location. |
| 316 | - if ($show_week_links === true) |
|
| 317 | - echo ' |
|
| 335 | + if ($show_week_links === true) { |
|
| 336 | + echo ' |
|
| 318 | 337 | <td class="windowbg2 weeks"> |
| 319 | 338 | <a href="', $scripturl, '?action=calendar;viewweek;year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $week['days'][0]['day'], '" title="', $txt['calendar_view_week'], '">»</a> |
| 320 | 339 | </td>'; |
| 340 | + } |
|
| 321 | 341 | |
| 322 | 342 | // Now loop through each day in the week we're on. |
| 323 | 343 | foreach ($week['days'] as $day) |
@@ -333,27 +353,29 @@ discard block |
||
| 333 | 353 | // Additional classes are given for events, holidays, and birthdays. |
| 334 | 354 | if (!empty($day['events']) && !empty($calendar_data['highlight']['events'])) |
| 335 | 355 | { |
| 336 | - if ($is_mini === true && in_array($calendar_data['highlight']['events'], array(1, 3))) |
|
| 337 | - $classes[] = 'events'; |
|
| 338 | - elseif ($is_mini === false && in_array($calendar_data['highlight']['events'], array(2, 3))) |
|
| 339 | - $classes[] = 'events'; |
|
| 356 | + if ($is_mini === true && in_array($calendar_data['highlight']['events'], array(1, 3))) { |
|
| 357 | + $classes[] = 'events'; |
|
| 358 | + } elseif ($is_mini === false && in_array($calendar_data['highlight']['events'], array(2, 3))) { |
|
| 359 | + $classes[] = 'events'; |
|
| 360 | + } |
|
| 340 | 361 | } |
| 341 | 362 | if (!empty($day['holidays']) && !empty($calendar_data['highlight']['holidays'])) |
| 342 | 363 | { |
| 343 | - if ($is_mini === true && in_array($calendar_data['highlight']['holidays'], array(1, 3))) |
|
| 344 | - $classes[] = 'holidays'; |
|
| 345 | - elseif ($is_mini === false && in_array($calendar_data['highlight']['holidays'], array(2, 3))) |
|
| 346 | - $classes[] = 'holidays'; |
|
| 364 | + if ($is_mini === true && in_array($calendar_data['highlight']['holidays'], array(1, 3))) { |
|
| 365 | + $classes[] = 'holidays'; |
|
| 366 | + } elseif ($is_mini === false && in_array($calendar_data['highlight']['holidays'], array(2, 3))) { |
|
| 367 | + $classes[] = 'holidays'; |
|
| 368 | + } |
|
| 347 | 369 | } |
| 348 | 370 | if (!empty($day['birthdays']) && !empty($calendar_data['highlight']['birthdays'])) |
| 349 | 371 | { |
| 350 | - if ($is_mini === true && in_array($calendar_data['highlight']['birthdays'], array(1, 3))) |
|
| 351 | - $classes[] = 'birthdays'; |
|
| 352 | - elseif ($is_mini === false && in_array($calendar_data['highlight']['birthdays'], array(2, 3))) |
|
| 353 | - $classes[] = 'birthdays'; |
|
| 372 | + if ($is_mini === true && in_array($calendar_data['highlight']['birthdays'], array(1, 3))) { |
|
| 373 | + $classes[] = 'birthdays'; |
|
| 374 | + } elseif ($is_mini === false && in_array($calendar_data['highlight']['birthdays'], array(2, 3))) { |
|
| 375 | + $classes[] = 'birthdays'; |
|
| 376 | + } |
|
| 354 | 377 | } |
| 355 | - } |
|
| 356 | - else |
|
| 378 | + } else |
|
| 357 | 379 | { |
| 358 | 380 | // Default Classes (either compact or comfortable and disabled). |
| 359 | 381 | $classes[] = !empty($calendar_data['size']) && $calendar_data['size'] == 'small' ? 'compact' : 'comfortable'; |
@@ -371,25 +393,27 @@ discard block |
||
| 371 | 393 | $title_prefix = !empty($day['is_first_of_month']) && $context['current_month'] == $calendar_data['current_month'] && $is_mini === false ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$calendar_data['current_month']] . ' ' : $txt['months_titles'][$calendar_data['current_month']] . ' ') : ''; |
| 372 | 394 | |
| 373 | 395 | // The actual day number - be it a link, or just plain old text! |
| 374 | - if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) |
|
| 375 | - echo ' |
|
| 396 | + if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) { |
|
| 397 | + echo ' |
|
| 376 | 398 | <a href="', $scripturl, '?action=calendar;sa=post;year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="day_text">', $title_prefix, $day['day'], '</span></a>'; |
| 377 | - elseif ($is_mini) |
|
| 378 | - echo ' |
|
| 399 | + } elseif ($is_mini) { |
|
| 400 | + echo ' |
|
| 379 | 401 | <a href="', $scripturl, '?action=calendar;', $context['calendar_view'], ';year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $day['day'], '"><span class="day_text">', $title_prefix, $day['day'], '</span></a>'; |
| 380 | - else |
|
| 381 | - echo ' |
|
| 402 | + } else { |
|
| 403 | + echo ' |
|
| 382 | 404 | <span class="day_text">', $title_prefix, $day['day'], '</span>'; |
| 405 | + } |
|
| 383 | 406 | |
| 384 | 407 | // A lot of stuff, we're not showing on mini-calendars to conserve space. |
| 385 | 408 | if ($is_mini === false) |
| 386 | 409 | { |
| 387 | 410 | // Holidays are always fun, let's show them! |
| 388 | - if (!empty($day['holidays'])) |
|
| 389 | - echo ' |
|
| 411 | + if (!empty($day['holidays'])) { |
|
| 412 | + echo ' |
|
| 390 | 413 | <div class="smalltext holiday"> |
| 391 | 414 | <span>', $txt['calendar_prompt'], '</span> ', implode(', ', $day['holidays']), ' |
| 392 | 415 | </div>'; |
| 416 | + } |
|
| 393 | 417 | |
| 394 | 418 | // Happy Birthday Dear Member! |
| 395 | 419 | if (!empty($day['birthdays'])) |
@@ -407,15 +431,17 @@ discard block |
||
| 407 | 431 | echo '<a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">', $member['name'], '</span>', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', $member['is_last'] || ($count == 10 && $use_js_hide) ? '' : ', '; |
| 408 | 432 | |
| 409 | 433 | // 9...10! Let's stop there. |
| 410 | - if ($birthday_count == 10 && $use_js_hide) |
|
| 411 | - // !!TODO - Inline CSS and JavaScript should be moved. |
|
| 434 | + if ($birthday_count == 10 && $use_js_hide) { |
|
| 435 | + // !!TODO - Inline CSS and JavaScript should be moved. |
|
| 412 | 436 | echo '<span class="hidelink" id="bdhidelink_', $day['day'], '">...<br><a href="', $scripturl, '?action=calendar;month=', $calendar_data['current_month'], ';year=', $calendar_data['current_year'], ';showbd" onclick="document.getElementById(\'bdhide_', $day['day'], '\').style.display = \'\'; document.getElementById(\'bdhidelink_', $day['day'], '\').style.display = \'none\'; return false;">(', sprintf($txt['calendar_click_all'], count($day['birthdays'])), ')</a></span><span id="bdhide_', $day['day'], '" style="display: none;">, '; |
| 437 | + } |
|
| 413 | 438 | |
| 414 | 439 | ++$birthday_count; |
| 415 | 440 | } |
| 416 | - if ($use_js_hide) |
|
| 417 | - echo ' |
|
| 441 | + if ($use_js_hide) { |
|
| 442 | + echo ' |
|
| 418 | 443 | </span>'; |
| 444 | + } |
|
| 419 | 445 | |
| 420 | 446 | echo ' |
| 421 | 447 | </div><!-- .smalltext -->'; |
@@ -426,8 +452,9 @@ discard block |
||
| 426 | 452 | { |
| 427 | 453 | // Sort events by start time (all day events will be listed first) |
| 428 | 454 | uasort($day['events'], function($a, $b) { |
| 429 | - if ($a['start_timestamp'] == $b['start_timestamp']) |
|
| 430 | - return 0; |
|
| 455 | + if ($a['start_timestamp'] == $b['start_timestamp']) { |
|
| 456 | + return 0; |
|
| 457 | + } |
|
| 431 | 458 | |
| 432 | 459 | return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1; |
| 433 | 460 | }); |
@@ -447,20 +474,22 @@ discard block |
||
| 447 | 474 | ', $event['link'], '<br> |
| 448 | 475 | <span class="event_time', empty($event_icons_needed) ? ' floatright' : '', '">'; |
| 449 | 476 | |
| 450 | - if (!empty($event['start_time_local']) && $event['starts_today'] == true) |
|
| 451 | - echo trim(str_replace(':00 ', ' ', $event['start_time_local'])); |
|
| 452 | - elseif (!empty($event['end_time_local']) && $event['ends_today'] == true) |
|
| 453 | - echo strtolower($txt['ends']), ' ', trim(str_replace(':00 ', ' ', $event['end_time_local'])); |
|
| 454 | - elseif (!empty($event['allday'])) |
|
| 455 | - echo $txt['calendar_allday']; |
|
| 477 | + if (!empty($event['start_time_local']) && $event['starts_today'] == true) { |
|
| 478 | + echo trim(str_replace(':00 ', ' ', $event['start_time_local'])); |
|
| 479 | + } elseif (!empty($event['end_time_local']) && $event['ends_today'] == true) { |
|
| 480 | + echo strtolower($txt['ends']), ' ', trim(str_replace(':00 ', ' ', $event['end_time_local'])); |
|
| 481 | + } elseif (!empty($event['allday'])) { |
|
| 482 | + echo $txt['calendar_allday']; |
|
| 483 | + } |
|
| 456 | 484 | |
| 457 | 485 | echo ' |
| 458 | 486 | </span>'; |
| 459 | 487 | |
| 460 | - if (!empty($event['location'])) |
|
| 461 | - echo ' |
|
| 488 | + if (!empty($event['location'])) { |
|
| 489 | + echo ' |
|
| 462 | 490 | <br> |
| 463 | 491 | <span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>'; |
| 492 | + } |
|
| 464 | 493 | |
| 465 | 494 | if ($event['can_edit'] || $event['can_export']) |
| 466 | 495 | { |
@@ -468,18 +497,20 @@ discard block |
||
| 468 | 497 | <span class="modify_event_links">'; |
| 469 | 498 | |
| 470 | 499 | // If they can edit the event, show an icon they can click on.... |
| 471 | - if ($event['can_edit']) |
|
| 472 | - echo ' |
|
| 500 | + if ($event['can_edit']) { |
|
| 501 | + echo ' |
|
| 473 | 502 | <a class="modify_event" href="', $event['modify_href'], '"> |
| 474 | 503 | <span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span> |
| 475 | 504 | </a>'; |
| 505 | + } |
|
| 476 | 506 | |
| 477 | 507 | // Exporting! |
| 478 | - if ($event['can_export']) |
|
| 479 | - echo ' |
|
| 508 | + if ($event['can_export']) { |
|
| 509 | + echo ' |
|
| 480 | 510 | <a class="modify_event" href="', $event['export_href'], '"> |
| 481 | 511 | <span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span> |
| 482 | 512 | </a>'; |
| 513 | + } |
|
| 483 | 514 | |
| 484 | 515 | echo ' |
| 485 | 516 | </span><br class="clear">'; |
@@ -498,10 +529,11 @@ discard block |
||
| 498 | 529 | // Otherwise, assuming it's not a mini-calendar, we can show previous / next month days! |
| 499 | 530 | elseif ($is_mini === false) |
| 500 | 531 | { |
| 501 | - if (empty($current_month_started) && !empty($context['calendar_grid_prev'])) |
|
| 502 | - echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_prev']['current_year'], ';month=', $context['calendar_grid_prev']['current_month'], '">', $context['calendar_grid_prev']['last_of_month'] - $calendar_data['shift']-- +1, '</a>'; |
|
| 503 | - elseif (!empty($current_month_started) && !empty($context['calendar_grid_next'])) |
|
| 504 | - echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_next']['current_year'], ';month=', $context['calendar_grid_next']['current_month'], '">', $current_month_started + 1 == $count ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$context['calendar_grid_next']['current_month']] . ' ' : $txt['months_titles'][$context['calendar_grid_next']['current_month']] . ' ') : '', $final_count++, '</a>'; |
|
| 532 | + if (empty($current_month_started) && !empty($context['calendar_grid_prev'])) { |
|
| 533 | + echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_prev']['current_year'], ';month=', $context['calendar_grid_prev']['current_month'], '">', $context['calendar_grid_prev']['last_of_month'] - $calendar_data['shift']-- +1, '</a>'; |
|
| 534 | + } elseif (!empty($current_month_started) && !empty($context['calendar_grid_next'])) { |
|
| 535 | + echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_next']['current_year'], ';month=', $context['calendar_grid_next']['current_month'], '">', $current_month_started + 1 == $count ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$context['calendar_grid_next']['current_month']] . ' ' : $txt['months_titles'][$context['calendar_grid_next']['current_month']] . ' ') : '', $final_count++, '</a>'; |
|
| 536 | + } |
|
| 505 | 537 | } |
| 506 | 538 | |
| 507 | 539 | // Close this day and increase var count. |
@@ -531,8 +563,9 @@ discard block |
||
| 531 | 563 | global $context, $txt, $scripturl, $modSettings; |
| 532 | 564 | |
| 533 | 565 | // We might have no reason to proceed, if the variable isn't there. |
| 534 | - if (!isset($context['calendar_grid_' . $grid_name])) |
|
| 535 | - return false; |
|
| 566 | + if (!isset($context['calendar_grid_' . $grid_name])) { |
|
| 567 | + return false; |
|
| 568 | + } |
|
| 536 | 569 | |
| 537 | 570 | // Handy pointer. |
| 538 | 571 | $calendar_data = &$context['calendar_grid_' . $grid_name]; |
@@ -549,22 +582,25 @@ discard block |
||
| 549 | 582 | <h3 class="catbg centertext largetext">'; |
| 550 | 583 | |
| 551 | 584 | // Previous Week Link... |
| 552 | - if (empty($calendar_data['previous_calendar']['disabled']) && !empty($calendar_data['show_next_prev'])) |
|
| 553 | - echo ' |
|
| 585 | + if (empty($calendar_data['previous_calendar']['disabled']) && !empty($calendar_data['show_next_prev'])) { |
|
| 586 | + echo ' |
|
| 554 | 587 | <span class="floatleft"> |
| 555 | 588 | <a href="', $calendar_data['previous_week']['href'], '">«</a> |
| 556 | 589 | </span>'; |
| 590 | + } |
|
| 557 | 591 | |
| 558 | 592 | // Next Week Link... |
| 559 | - if (empty($calendar_data['next_calendar']['disabled']) && !empty($calendar_data['show_next_prev'])) |
|
| 560 | - echo ' |
|
| 593 | + if (empty($calendar_data['next_calendar']['disabled']) && !empty($calendar_data['show_next_prev'])) { |
|
| 594 | + echo ' |
|
| 561 | 595 | <span class="floatright"> |
| 562 | 596 | <a href="', $calendar_data['next_week']['href'], '">»</a> |
| 563 | 597 | </span>'; |
| 598 | + } |
|
| 564 | 599 | |
| 565 | 600 | // The Month Title + Week Number... |
| 566 | - if (!empty($calendar_data['week_title'])) |
|
| 567 | - echo $calendar_data['week_title']; |
|
| 601 | + if (!empty($calendar_data['week_title'])) { |
|
| 602 | + echo $calendar_data['week_title']; |
|
| 603 | + } |
|
| 568 | 604 | |
| 569 | 605 | echo ' |
| 570 | 606 | </h3> |
@@ -605,11 +641,12 @@ discard block |
||
| 605 | 641 | <td class="', implode(' ', $classes), ' act_day">'; |
| 606 | 642 | |
| 607 | 643 | // Should the day number be a link? |
| 608 | - if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) |
|
| 609 | - echo ' |
|
| 644 | + if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) { |
|
| 645 | + echo ' |
|
| 610 | 646 | <a href="', $scripturl, '?action=calendar;sa=post;month=', $month_data['current_month'], ';year=', $month_data['current_year'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['days'][$day['day_of_week']], ' - ', $day['day'], '</a>'; |
| 611 | - else |
|
| 612 | - echo $txt['days'][$day['day_of_week']], ' - ', $day['day']; |
|
| 647 | + } else { |
|
| 648 | + echo $txt['days'][$day['day_of_week']], ' - ', $day['day']; |
|
| 649 | + } |
|
| 613 | 650 | |
| 614 | 651 | echo ' |
| 615 | 652 | </td> |
@@ -620,8 +657,9 @@ discard block |
||
| 620 | 657 | { |
| 621 | 658 | // Sort events by start time (all day events will be listed first) |
| 622 | 659 | uasort($day['events'], function($a, $b) { |
| 623 | - if ($a['start_timestamp'] == $b['start_timestamp']) |
|
| 624 | - return 0; |
|
| 660 | + if ($a['start_timestamp'] == $b['start_timestamp']) { |
|
| 661 | + return 0; |
|
| 662 | + } |
|
| 625 | 663 | return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1; |
| 626 | 664 | }); |
| 627 | 665 | |
@@ -635,35 +673,39 @@ discard block |
||
| 635 | 673 | echo $event['link'], '<br> |
| 636 | 674 | <span class="event_time', empty($event_icons_needed) ? ' floatright' : '', '">'; |
| 637 | 675 | |
| 638 | - if (!empty($event['start_time_local'])) |
|
| 639 | - echo trim($event['start_time_local']), !empty($event['end_time_local']) ? ' – ' . trim($event['end_time_local']) : ''; |
|
| 640 | - else |
|
| 641 | - echo $txt['calendar_allday']; |
|
| 676 | + if (!empty($event['start_time_local'])) { |
|
| 677 | + echo trim($event['start_time_local']), !empty($event['end_time_local']) ? ' – ' . trim($event['end_time_local']) : ''; |
|
| 678 | + } else { |
|
| 679 | + echo $txt['calendar_allday']; |
|
| 680 | + } |
|
| 642 | 681 | |
| 643 | 682 | echo ' |
| 644 | 683 | </span>'; |
| 645 | 684 | |
| 646 | - if (!empty($event['location'])) |
|
| 647 | - echo '<br> |
|
| 685 | + if (!empty($event['location'])) { |
|
| 686 | + echo '<br> |
|
| 648 | 687 | <span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>'; |
| 688 | + } |
|
| 649 | 689 | |
| 650 | 690 | if (!empty($event_icons_needed)) |
| 651 | 691 | { |
| 652 | 692 | echo ' <span class="modify_event_links">'; |
| 653 | 693 | |
| 654 | 694 | // If they can edit the event, show a star they can click on.... |
| 655 | - if (!empty($event['can_edit'])) |
|
| 656 | - echo ' |
|
| 695 | + if (!empty($event['can_edit'])) { |
|
| 696 | + echo ' |
|
| 657 | 697 | <a class="modify_event" href="', $event['modify_href'], '"> |
| 658 | 698 | <span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span> |
| 659 | 699 | </a>'; |
| 700 | + } |
|
| 660 | 701 | |
| 661 | 702 | // Can we export? Sweet. |
| 662 | - if (!empty($event['can_export'])) |
|
| 663 | - echo ' |
|
| 703 | + if (!empty($event['can_export'])) { |
|
| 704 | + echo ' |
|
| 664 | 705 | <a class="modify_event" href="', $event['export_href'], '"> |
| 665 | 706 | <span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span> |
| 666 | 707 | </a>'; |
| 708 | + } |
|
| 667 | 709 | |
| 668 | 710 | echo ' |
| 669 | 711 | </span><br class="clear">'; |
@@ -681,22 +723,23 @@ discard block |
||
| 681 | 723 | </div> |
| 682 | 724 | <br class="clear">'; |
| 683 | 725 | } |
| 684 | - } |
|
| 685 | - else |
|
| 726 | + } else |
|
| 686 | 727 | { |
| 687 | - if (!empty($context['can_post'])) |
|
| 688 | - echo ' |
|
| 728 | + if (!empty($context['can_post'])) { |
|
| 729 | + echo ' |
|
| 689 | 730 | <div class="week_add_event"> |
| 690 | 731 | <a href="', $scripturl, '?action=calendar;sa=post;month=', $month_data['current_month'], ';year=', $month_data['current_year'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['calendar_post_event'], '</a> |
| 691 | 732 | </div>'; |
| 733 | + } |
|
| 692 | 734 | } |
| 693 | 735 | echo ' |
| 694 | 736 | </td> |
| 695 | 737 | <td class="', implode(' ', $classes), !empty($day['holidays']) ? ' holidays' : ' disabled', ' holiday_col" data-css-prefix="' . $txt['calendar_prompt'] . ' ">'; |
| 696 | 738 | |
| 697 | 739 | // Show any holidays! |
| 698 | - if (!empty($day['holidays'])) |
|
| 699 | - echo implode('<br>', $day['holidays']); |
|
| 740 | + if (!empty($day['holidays'])) { |
|
| 741 | + echo implode('<br>', $day['holidays']); |
|
| 742 | + } |
|
| 700 | 743 | |
| 701 | 744 | echo ' |
| 702 | 745 | </td> |
@@ -705,11 +748,12 @@ discard block |
||
| 705 | 748 | // Show any birthdays... |
| 706 | 749 | if (!empty($day['birthdays'])) |
| 707 | 750 | { |
| 708 | - foreach ($day['birthdays'] as $member) |
|
| 709 | - echo ' |
|
| 751 | + foreach ($day['birthdays'] as $member) { |
|
| 752 | + echo ' |
|
| 710 | 753 | <a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['name'], '</a> |
| 711 | 754 | ', isset($member['age']) ? ' (' . $member['age'] . ')' : '', ' |
| 712 | 755 | ', $member['is_last'] ? '' : '<br>'; |
| 756 | + } |
|
| 713 | 757 | } |
| 714 | 758 | echo ' |
| 715 | 759 | </td> |
@@ -755,26 +799,27 @@ discard block |
||
| 755 | 799 | <input type="text" name="end_date" id="end_date" maxlength="10" value="', $calendar_data['end_date'], '" tabindex="', $context['tabindex']++, '" class="date_input end" data-type="date"> |
| 756 | 800 | <input type="submit" class="button" style="float:none" id="view_button" value="', $txt['view'], '"> |
| 757 | 801 | </form>'; |
| 758 | - } |
|
| 759 | - else |
|
| 802 | + } else |
|
| 760 | 803 | { |
| 761 | 804 | echo' |
| 762 | 805 | <form action="', $scripturl, '?action=calendar" id="calendar_navigation" method="post" accept-charset="', $context['character_set'], '"> |
| 763 | 806 | <select name="month" id="input_month">'; |
| 764 | 807 | |
| 765 | 808 | // Show a select box with all the months. |
| 766 | - foreach ($txt['months_short'] as $number => $month) |
|
| 767 | - echo ' |
|
| 809 | + foreach ($txt['months_short'] as $number => $month) { |
|
| 810 | + echo ' |
|
| 768 | 811 | <option value="', $number, '"', $number == $context['current_month'] ? ' selected' : '', '>', $month, '</option>'; |
| 812 | + } |
|
| 769 | 813 | |
| 770 | 814 | echo ' |
| 771 | 815 | </select> |
| 772 | 816 | <select name="year">'; |
| 773 | 817 | |
| 774 | 818 | // Show a link for every year... |
| 775 | - for ($year = $context['calendar_resources']['min_year']; $year <= $context['calendar_resources']['max_year']; $year++) |
|
| 776 | - echo ' |
|
| 819 | + for ($year = $context['calendar_resources']['min_year']; $year <= $context['calendar_resources']['max_year']; $year++) { |
|
| 820 | + echo ' |
|
| 777 | 821 | <option value="', $year, '"', $year == $context['current_year'] ? ' selected' : '', '>', $year, '</option>'; |
| 822 | + } |
|
| 778 | 823 | |
| 779 | 824 | echo ' |
| 780 | 825 | </select> |
@@ -796,9 +841,10 @@ discard block |
||
| 796 | 841 | echo ' |
| 797 | 842 | <form action="', $scripturl, '?action=calendar;sa=post" method="post" name="postevent" accept-charset="', $context['character_set'], '" onsubmit="submitonce(this);">'; |
| 798 | 843 | |
| 799 | - if (!empty($context['event']['new'])) |
|
| 800 | - echo ' |
|
| 844 | + if (!empty($context['event']['new'])) { |
|
| 845 | + echo ' |
|
| 801 | 846 | <input type="hidden" name="eventid" value="', $context['event']['eventid'], '">'; |
| 847 | + } |
|
| 802 | 848 | |
| 803 | 849 | // Start the main table. |
| 804 | 850 | echo ' |
@@ -809,8 +855,8 @@ discard block |
||
| 809 | 855 | </h3> |
| 810 | 856 | </div>'; |
| 811 | 857 | |
| 812 | - if (!empty($context['post_error']['messages'])) |
|
| 813 | - echo ' |
|
| 858 | + if (!empty($context['post_error']['messages'])) { |
|
| 859 | + echo ' |
|
| 814 | 860 | <div class="errorbox"> |
| 815 | 861 | <dl class="event_error"> |
| 816 | 862 | <dt> |
@@ -821,6 +867,7 @@ discard block |
||
| 821 | 867 | </dt> |
| 822 | 868 | </dl> |
| 823 | 869 | </div>'; |
| 870 | + } |
|
| 824 | 871 | |
| 825 | 872 | echo ' |
| 826 | 873 | <div class="roundframe noup"> |
@@ -848,9 +895,10 @@ discard block |
||
| 848 | 895 | echo ' |
| 849 | 896 | <optgroup label="', $category['name'], '">'; |
| 850 | 897 | |
| 851 | - foreach ($category['boards'] as $board) |
|
| 852 | - echo ' |
|
| 898 | + foreach ($category['boards'] as $board) { |
|
| 899 | + echo ' |
|
| 853 | 900 | <option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=>' : '', ' ', $board['name'], '</option>'; |
| 901 | + } |
|
| 854 | 902 | echo ' |
| 855 | 903 | </optgroup>'; |
| 856 | 904 | } |
@@ -886,9 +934,10 @@ discard block |
||
| 886 | 934 | <span class="label">', $txt['calendar_timezone'], '</span> |
| 887 | 935 | <select name="tz" id="tz"', !empty($context['event']['allday']) ? ' disabled' : '', '>'; |
| 888 | 936 | |
| 889 | - foreach ($context['all_timezones'] as $tz => $tzname) |
|
| 890 | - echo ' |
|
| 937 | + foreach ($context['all_timezones'] as $tz => $tzname) { |
|
| 938 | + echo ' |
|
| 891 | 939 | <option', is_numeric($tz) ? ' value="" disabled' : ' value="' . $tz . '"', $tz === $context['event']['tz'] ? ' selected' : '', '>', $tzname, '</option>'; |
| 940 | + } |
|
| 892 | 941 | |
| 893 | 942 | echo ' |
| 894 | 943 | </select> |
@@ -904,9 +953,10 @@ discard block |
||
| 904 | 953 | <input type="submit" value="', empty($context['event']['new']) ? $txt['save'] : $txt['post'], '" class="button">'; |
| 905 | 954 | |
| 906 | 955 | // Delete button? |
| 907 | - if (empty($context['event']['new'])) |
|
| 908 | - echo ' |
|
| 956 | + if (empty($context['event']['new'])) { |
|
| 957 | + echo ' |
|
| 909 | 958 | <input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['calendar_confirm_delete'], '" class="button you_sure">'; |
| 959 | + } |
|
| 910 | 960 | |
| 911 | 961 | echo ' |
| 912 | 962 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -934,9 +984,10 @@ discard block |
||
| 934 | 984 | echo ' |
| 935 | 985 | <td style="padding-', $alt ? 'right' : 'left', ': 1.5em;">'; |
| 936 | 986 | |
| 937 | - foreach ($v as $i) |
|
| 938 | - echo ' |
|
| 987 | + foreach ($v as $i) { |
|
| 988 | + echo ' |
|
| 939 | 989 | <img src="', $context['offimg'], '" alt="" id="', $t, '_', $i, '"><br>'; |
| 990 | + } |
|
| 940 | 991 | |
| 941 | 992 | echo ' |
| 942 | 993 | </td>'; |
@@ -957,9 +1008,10 @@ discard block |
||
| 957 | 1008 | |
| 958 | 1009 | foreach ($context['clockicons'] as $t => $v) |
| 959 | 1010 | { |
| 960 | - foreach ($v as $i) |
|
| 961 | - echo ' |
|
| 1011 | + foreach ($v as $i) { |
|
| 1012 | + echo ' |
|
| 962 | 1013 | icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');'; |
| 1014 | + } |
|
| 963 | 1015 | } |
| 964 | 1016 | |
| 965 | 1017 | echo ' |
@@ -984,13 +1036,14 @@ discard block |
||
| 984 | 1036 | |
| 985 | 1037 | foreach ($context['clockicons'] as $t => $v) |
| 986 | 1038 | { |
| 987 | - foreach ($v as $i) |
|
| 988 | - echo ' |
|
| 1039 | + foreach ($v as $i) { |
|
| 1040 | + echo ' |
|
| 989 | 1041 | if (', $t, ' >= ', $i, ') |
| 990 | 1042 | { |
| 991 | 1043 | turnon.push("', $t, '_', $i, '"); |
| 992 | 1044 | ', $t, ' -= ', $i, '; |
| 993 | 1045 | }'; |
| 1046 | + } |
|
| 994 | 1047 | } |
| 995 | 1048 | |
| 996 | 1049 | echo ' |
@@ -1034,9 +1087,10 @@ discard block |
||
| 1034 | 1087 | <tr class="', $alt ? 'windowbg2' : 'windowbg', '"> |
| 1035 | 1088 | <td>'; |
| 1036 | 1089 | |
| 1037 | - foreach ($v as $i) |
|
| 1038 | - echo ' |
|
| 1090 | + foreach ($v as $i) { |
|
| 1091 | + echo ' |
|
| 1039 | 1092 | <img src="', $context['offimg'], '" alt="" id="', $t, '_', $i, '" style="padding: 2px;">'; |
| 1093 | + } |
|
| 1040 | 1094 | |
| 1041 | 1095 | echo ' |
| 1042 | 1096 | </td> |
@@ -1058,9 +1112,10 @@ discard block |
||
| 1058 | 1112 | |
| 1059 | 1113 | foreach ($context['clockicons'] as $t => $v) |
| 1060 | 1114 | { |
| 1061 | - foreach ($v as $i) |
|
| 1062 | - echo ' |
|
| 1115 | + foreach ($v as $i) { |
|
| 1116 | + echo ' |
|
| 1063 | 1117 | icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');'; |
| 1118 | + } |
|
| 1064 | 1119 | } |
| 1065 | 1120 | |
| 1066 | 1121 | echo ' |
@@ -1077,13 +1132,14 @@ discard block |
||
| 1077 | 1132 | |
| 1078 | 1133 | foreach ($context['clockicons'] as $t => $v) |
| 1079 | 1134 | { |
| 1080 | - foreach ($v as $i) |
|
| 1081 | - echo ' |
|
| 1135 | + foreach ($v as $i) { |
|
| 1136 | + echo ' |
|
| 1082 | 1137 | if (', $t, ' >= ', $i, ') |
| 1083 | 1138 | { |
| 1084 | 1139 | turnon.push("', $t, '_', $i, '"); |
| 1085 | 1140 | ', $t, ' -= ', $i, '; |
| 1086 | 1141 | }'; |
| 1142 | + } |
|
| 1087 | 1143 | } |
| 1088 | 1144 | |
| 1089 | 1145 | echo ' |
@@ -1127,9 +1183,10 @@ discard block |
||
| 1127 | 1183 | <tr class="', $alt ? 'windowbg2' : 'windowbg', '"> |
| 1128 | 1184 | <td>'; |
| 1129 | 1185 | |
| 1130 | - foreach ($v as $i) |
|
| 1131 | - echo ' |
|
| 1186 | + foreach ($v as $i) { |
|
| 1187 | + echo ' |
|
| 1132 | 1188 | <img src="', $context['offimg'], '" alt="" id="', $t, '_', $i, '" style="padding: 2px;">'; |
| 1189 | + } |
|
| 1133 | 1190 | |
| 1134 | 1191 | echo ' |
| 1135 | 1192 | </td> |
@@ -1145,9 +1202,10 @@ discard block |
||
| 1145 | 1202 | |
| 1146 | 1203 | foreach ($context['clockicons'] as $t => $v) |
| 1147 | 1204 | { |
| 1148 | - foreach ($v as $i) |
|
| 1149 | - echo ' |
|
| 1205 | + foreach ($v as $i) { |
|
| 1206 | + echo ' |
|
| 1150 | 1207 | icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');'; |
| 1208 | + } |
|
| 1151 | 1209 | } |
| 1152 | 1210 | |
| 1153 | 1211 | echo ' |
@@ -1168,13 +1226,14 @@ discard block |
||
| 1168 | 1226 | |
| 1169 | 1227 | foreach ($context['clockicons'] as $t => $v) |
| 1170 | 1228 | { |
| 1171 | - foreach ($v as $i) |
|
| 1172 | - echo ' |
|
| 1229 | + foreach ($v as $i) { |
|
| 1230 | + echo ' |
|
| 1173 | 1231 | if (', $t, ' >= ', $i, ') |
| 1174 | 1232 | { |
| 1175 | 1233 | turnon.push("', $t, '_', $i, '"); |
| 1176 | 1234 | ', $t, ' -= ', $i, '; |
| 1177 | 1235 | }'; |
| 1236 | + } |
|
| 1178 | 1237 | } |
| 1179 | 1238 | |
| 1180 | 1239 | echo ' |
@@ -1218,9 +1277,10 @@ discard block |
||
| 1218 | 1277 | <tr class="', $alt ? 'windowbg2' : 'windowbg', '"> |
| 1219 | 1278 | <td>'; |
| 1220 | 1279 | |
| 1221 | - foreach ($v as $i) |
|
| 1222 | - echo ' |
|
| 1280 | + foreach ($v as $i) { |
|
| 1281 | + echo ' |
|
| 1223 | 1282 | <img src="', $i ? $context['onimg'] : $context['offimg'], '" alt="" style="padding: 2px;">'; |
| 1283 | + } |
|
| 1224 | 1284 | |
| 1225 | 1285 | echo ' |
| 1226 | 1286 | </td> |
@@ -22,24 +22,26 @@ discard block |
||
| 22 | 22 | <script>'; |
| 23 | 23 | |
| 24 | 24 | // When using Go Back due to fatal_error, allow the form to be re-submitted with changes. |
| 25 | - if (isBrowser('is_firefox')) |
|
| 26 | - echo ' |
|
| 25 | + if (isBrowser('is_firefox')) { |
|
| 26 | + echo ' |
|
| 27 | 27 | window.addEventListener("pageshow", reActivate, false);'; |
| 28 | + } |
|
| 28 | 29 | |
| 29 | 30 | // Start with message icons - and any missing from this theme. |
| 30 | 31 | echo ' |
| 31 | 32 | var icon_urls = {'; |
| 32 | 33 | |
| 33 | - foreach ($context['icons'] as $icon) |
|
| 34 | - echo ' |
|
| 34 | + foreach ($context['icons'] as $icon) { |
|
| 35 | + echo ' |
|
| 35 | 36 | \'', $icon['value'], '\': \'', $icon['url'], '\'', $icon['is_last'] ? '' : ','; |
| 37 | + } |
|
| 36 | 38 | |
| 37 | 39 | echo ' |
| 38 | 40 | };'; |
| 39 | 41 | |
| 40 | 42 | // If this is a poll - use some javascript to ensure the user doesn't create a poll with illegal option combinations. |
| 41 | - if ($context['make_poll']) |
|
| 42 | - echo ' |
|
| 43 | + if ($context['make_poll']) { |
|
| 44 | + echo ' |
|
| 43 | 45 | var pollOptionNum = 0, pollTabIndex; |
| 44 | 46 | var pollOptionId = ', $context['last_choice_id'], '; |
| 45 | 47 | function addPollOption() |
@@ -58,11 +60,13 @@ discard block |
||
| 58 | 60 | |
| 59 | 61 | setOuterHTML(document.getElementById(\'pollMoreOptions\'), ', JavaScriptEscape('<dt><label for="options-'), ' + pollOptionId + ', JavaScriptEscape('">' . $txt['option'] . ' '), ' + pollOptionNum + ', JavaScriptEscape('</label>:</dt><dd><input type="text" name="options['), ' + pollOptionId + ', JavaScriptEscape(']" id="options-'), ' + pollOptionId + ', JavaScriptEscape('" value="" size="80" maxlength="255" tabindex="'), ' + pollTabIndex + ', JavaScriptEscape('"></dd><p id="pollMoreOptions"></p>'), '); |
| 60 | 62 | }'; |
| 63 | + } |
|
| 61 | 64 | |
| 62 | 65 | // If we are making a calendar event we want to ensure we show the current days in a month etc... this is done here. |
| 63 | - if ($context['make_event']) |
|
| 64 | - echo ' |
|
| 66 | + if ($context['make_event']) { |
|
| 67 | + echo ' |
|
| 65 | 68 | var monthLength = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];'; |
| 69 | + } |
|
| 66 | 70 | |
| 67 | 71 | // End of the javascript, start the form and display the link tree. |
| 68 | 72 | echo ' |
@@ -83,9 +87,10 @@ discard block |
||
| 83 | 87 | </div> |
| 84 | 88 | <br>'; |
| 85 | 89 | |
| 86 | - if ($context['make_event'] && (!$context['event']['new'] || !empty($context['current_board']))) |
|
| 87 | - echo ' |
|
| 90 | + if ($context['make_event'] && (!$context['event']['new'] || !empty($context['current_board']))) { |
|
| 91 | + echo ' |
|
| 88 | 92 | <input type="hidden" name="eventid" value="', $context['event']['id'], '">'; |
| 93 | + } |
|
| 89 | 94 | |
| 90 | 95 | // Start the main table. |
| 91 | 96 | echo ' |
@@ -110,26 +115,29 @@ discard block |
||
| 110 | 115 | </div>'; |
| 111 | 116 | |
| 112 | 117 | // If this won't be approved let them know! |
| 113 | - if (!$context['becomes_approved']) |
|
| 114 | - echo ' |
|
| 118 | + if (!$context['becomes_approved']) { |
|
| 119 | + echo ' |
|
| 115 | 120 | <div class="noticebox"> |
| 116 | 121 | <em>', $txt['wait_for_approval'], '</em> |
| 117 | 122 | <input type="hidden" name="not_approved" value="1"> |
| 118 | 123 | </div>'; |
| 124 | + } |
|
| 119 | 125 | |
| 120 | 126 | // If it's locked, show a message to warn the replier. |
| 121 | - if (!empty($context['locked'])) |
|
| 122 | - echo ' |
|
| 127 | + if (!empty($context['locked'])) { |
|
| 128 | + echo ' |
|
| 123 | 129 | <div class="errorbox"> |
| 124 | 130 | ', $txt['topic_locked_no_reply'], ' |
| 125 | 131 | </div>'; |
| 132 | + } |
|
| 126 | 133 | |
| 127 | - if (!empty($modSettings['drafts_post_enabled'])) |
|
| 128 | - echo ' |
|
| 134 | + if (!empty($modSettings['drafts_post_enabled'])) { |
|
| 135 | + echo ' |
|
| 129 | 136 | <div id="draft_section" class="infobox"', isset($context['draft_saved']) ? '' : ' style="display: none;"', '>', |
| 130 | 137 | sprintf($txt['draft_saved'], $scripturl . '?action=profile;u=' . $context['user']['id'] . ';area=showdrafts'), ' |
| 131 | 138 | ', (!empty($modSettings['drafts_keep_days']) ? ' <strong>' . sprintf($txt['draft_save_warning'], $modSettings['drafts_keep_days']) . '</strong>' : ''), ' |
| 132 | 139 | </div>'; |
| 140 | + } |
|
| 133 | 141 | |
| 134 | 142 | // The post header... important stuff |
| 135 | 143 | echo ' |
@@ -139,14 +147,15 @@ discard block |
||
| 139 | 147 | // Mod & theme authors can use the 'integrate_post_end' hook to modify or add to these (see Post.php) |
| 140 | 148 | if (!empty($context['posting_fields']) && is_array($context['posting_fields'])) |
| 141 | 149 | { |
| 142 | - foreach ($context['posting_fields'] as $pfid => $pf) |
|
| 143 | - echo ' |
|
| 150 | + foreach ($context['posting_fields'] as $pfid => $pf) { |
|
| 151 | + echo ' |
|
| 144 | 152 | <dt class="clear', !is_numeric($pfid) ? ' pf_' . $pfid : '', '"> |
| 145 | 153 | ', $pf['dt'], ' |
| 146 | 154 | </dt> |
| 147 | 155 | <dd', !is_numeric($pfid) ? ' class="pf_' . $pfid . '"' : '', '> |
| 148 | 156 | ', preg_replace('~<(input|select|textarea|button|area|a|object)\b~', '<$1 tabindex="' . $context['tabindex']++ . '"', $pf['dd']), ' |
| 149 | 157 | </dd>'; |
| 158 | + } |
|
| 150 | 159 | } |
| 151 | 160 | |
| 152 | 161 | echo ' |
@@ -180,9 +189,10 @@ discard block |
||
| 180 | 189 | echo ' |
| 181 | 190 | <optgroup label="', $category['name'], '">'; |
| 182 | 191 | |
| 183 | - foreach ($category['boards'] as $board) |
|
| 184 | - echo ' |
|
| 192 | + foreach ($category['boards'] as $board) { |
|
| 193 | + echo ' |
|
| 185 | 194 | <option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=>' : '', ' ', $board['name'], '</option>'; |
| 195 | + } |
|
| 186 | 196 | echo ' |
| 187 | 197 | </optgroup>'; |
| 188 | 198 | } |
@@ -218,9 +228,10 @@ discard block |
||
| 218 | 228 | <span class="label">', $txt['calendar_timezone'], '</span> |
| 219 | 229 | <select name="tz" id="tz"', !empty($context['event']['allday']) ? ' disabled' : '', '>'; |
| 220 | 230 | |
| 221 | - foreach ($context['all_timezones'] as $tz => $tzname) |
|
| 222 | - echo ' |
|
| 231 | + foreach ($context['all_timezones'] as $tz => $tzname) { |
|
| 232 | + echo ' |
|
| 223 | 233 | <option', is_numeric($tz) ? ' value="" disabled' : ' value="' . $tz . '"', $tz === $context['event']['tz'] ? ' selected' : '', '>', $tzname, '</option>'; |
| 234 | + } |
|
| 224 | 235 | |
| 225 | 236 | echo ' |
| 226 | 237 | </select> |
@@ -249,14 +260,15 @@ discard block |
||
| 249 | 260 | </dd>'; |
| 250 | 261 | |
| 251 | 262 | // Loop through all the choices and print them out. |
| 252 | - foreach ($context['choices'] as $choice) |
|
| 253 | - echo ' |
|
| 263 | + foreach ($context['choices'] as $choice) { |
|
| 264 | + echo ' |
|
| 254 | 265 | <dt> |
| 255 | 266 | <label for="options-', $choice['id'], '">', $txt['option'], ' ', $choice['number'], '</label>: |
| 256 | 267 | </dt> |
| 257 | 268 | <dd> |
| 258 | 269 | <input type="text" name="options[', $choice['id'], ']" id="options-', $choice['id'], '" value="', $choice['label'], '" tabindex="', $context['tabindex']++, '" size="80" maxlength="255"> |
| 259 | 270 | </dd>'; |
| 271 | + } |
|
| 260 | 272 | |
| 261 | 273 | echo ' |
| 262 | 274 | <p id="pollMoreOptions"></p> |
@@ -286,14 +298,15 @@ discard block |
||
| 286 | 298 | <input type="checkbox" id="poll_change_vote" name="poll_change_vote"', !empty($context['poll']['change_vote']) ? ' checked' : '', '> |
| 287 | 299 | </dd>'; |
| 288 | 300 | |
| 289 | - if ($context['poll_options']['guest_vote_enabled']) |
|
| 290 | - echo ' |
|
| 301 | + if ($context['poll_options']['guest_vote_enabled']) { |
|
| 302 | + echo ' |
|
| 291 | 303 | <dt> |
| 292 | 304 | <label for="poll_guest_vote">', $txt['poll_guest_vote'], ':</label> |
| 293 | 305 | </dt> |
| 294 | 306 | <dd> |
| 295 | 307 | <input type="checkbox" id="poll_guest_vote" name="poll_guest_vote"', !empty($context['poll_options']['guest_vote']) ? ' checked' : '', '> |
| 296 | 308 | </dd>'; |
| 309 | + } |
|
| 297 | 310 | |
| 298 | 311 | echo ' |
| 299 | 312 | <dt> |
@@ -314,8 +327,8 @@ discard block |
||
| 314 | 327 | ', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message'); |
| 315 | 328 | |
| 316 | 329 | // If we're editing and displaying edit details, show a box where they can say why |
| 317 | - if (isset($context['editing']) && $modSettings['show_modify']) |
|
| 318 | - echo ' |
|
| 330 | + if (isset($context['editing']) && $modSettings['show_modify']) { |
|
| 331 | + echo ' |
|
| 319 | 332 | <dl> |
| 320 | 333 | <dt class="clear"> |
| 321 | 334 | <span id="caption_edit_reason">', $txt['reason_for_edit'], ':</span> |
@@ -324,20 +337,23 @@ discard block |
||
| 324 | 337 | <input type="text" name="modify_reason"', isset($context['last_modified_reason']) ? ' value="' . $context['last_modified_reason'] . '"' : '', ' tabindex="', $context['tabindex']++, '" size="80" maxlength="80"> |
| 325 | 338 | </dd> |
| 326 | 339 | </dl>'; |
| 340 | + } |
|
| 327 | 341 | |
| 328 | 342 | // If this message has been edited in the past - display when it was. |
| 329 | - if (isset($context['last_modified'])) |
|
| 330 | - echo ' |
|
| 343 | + if (isset($context['last_modified'])) { |
|
| 344 | + echo ' |
|
| 331 | 345 | <div class="padding smalltext"> |
| 332 | 346 | ', $context['last_modified_text'], ' |
| 333 | 347 | </div>'; |
| 348 | + } |
|
| 334 | 349 | |
| 335 | 350 | // If the admin has enabled the hiding of the additional options - show a link and image for it. |
| 336 | - if (!empty($modSettings['additional_options_collapsable'])) |
|
| 337 | - echo ' |
|
| 351 | + if (!empty($modSettings['additional_options_collapsable'])) { |
|
| 352 | + echo ' |
|
| 338 | 353 | <div id="postAdditionalOptionsHeader"> |
| 339 | 354 | <strong><a href="#" id="postMoreExpandLink"> ', $context['can_post_attachment'] ? $txt['post_additionalopt_attach'] : $txt['post_additionalopt'], '</a></strong> |
| 340 | 355 | </div>'; |
| 356 | + } |
|
| 341 | 357 | |
| 342 | 358 | echo ' |
| 343 | 359 | <div id="postAdditionalOptions">'; |
@@ -370,19 +386,21 @@ discard block |
||
| 370 | 386 | ', $txt['uncheck_unwatchd_attach'], ': |
| 371 | 387 | </dd>'; |
| 372 | 388 | |
| 373 | - foreach ($context['current_attachments'] as $attachment) |
|
| 374 | - echo ' |
|
| 389 | + foreach ($context['current_attachments'] as $attachment) { |
|
| 390 | + echo ' |
|
| 375 | 391 | <dd class="smalltext"> |
| 376 | 392 | <label for="attachment_', $attachment['attachID'], '"><input type="checkbox" id="attachment_', $attachment['attachID'], '" name="attach_del[]" value="', $attachment['attachID'], '"', empty($attachment['unchecked']) ? ' checked' : '', '> ', $attachment['name'], (empty($attachment['approved']) ? ' (' . $txt['awaiting_approval'] . ')' : ''), |
| 377 | 393 | !empty($modSettings['attachmentPostLimit']) || !empty($modSettings['attachmentSizeLimit']) ? sprintf($txt['attach_kb'], comma_format(round(max($attachment['size'], 1024) / 1024), 0)) : '', '</label> |
| 378 | 394 | </dd>'; |
| 395 | + } |
|
| 379 | 396 | |
| 380 | 397 | echo ' |
| 381 | 398 | </dl>'; |
| 382 | 399 | |
| 383 | - if (!empty($context['files_in_session_warning'])) |
|
| 384 | - echo ' |
|
| 400 | + if (!empty($context['files_in_session_warning'])) { |
|
| 401 | + echo ' |
|
| 385 | 402 | <div class="smalltext">', $context['files_in_session_warning'], '</div>'; |
| 403 | + } |
|
| 386 | 404 | } |
| 387 | 405 | |
| 388 | 406 | // Is the user allowed to post any additional ones? If so give them the boxes to do it! |
@@ -443,8 +461,8 @@ discard block |
||
| 443 | 461 | ', empty($modSettings['attachmentSizeLimit']) ? '' : ('<input type="hidden" name="MAX_FILE_SIZE" value="' . $modSettings['attachmentSizeLimit'] * 1024 . '">'); |
| 444 | 462 | |
| 445 | 463 | // Show more boxes if they aren't approaching that limit. |
| 446 | - if ($context['num_allowed_attachments'] > 1) |
|
| 447 | - echo ' |
|
| 464 | + if ($context['num_allowed_attachments'] > 1) { |
|
| 465 | + echo ' |
|
| 448 | 466 | <script> |
| 449 | 467 | var allowed_attachments = ', $context['num_allowed_attachments'], '; |
| 450 | 468 | var current_attachment = 1; |
@@ -464,6 +482,7 @@ discard block |
||
| 464 | 482 | <a href="#" onclick="addAttachment(); return false;">(', $txt['more_attachments'], ')</a> |
| 465 | 483 | </div><!-- .fallback --> |
| 466 | 484 | </div><!-- #attachUpload -->'; |
| 485 | + } |
|
| 467 | 486 | |
| 468 | 487 | echo ' |
| 469 | 488 | </dd>'; |
@@ -475,21 +494,25 @@ discard block |
||
| 475 | 494 | <dd class="smalltext">'; |
| 476 | 495 | |
| 477 | 496 | // Show some useful information such as allowed extensions, maximum size and amount of attachments allowed. |
| 478 | - if (!empty($modSettings['attachmentCheckExtensions'])) |
|
| 479 | - echo ' |
|
| 497 | + if (!empty($modSettings['attachmentCheckExtensions'])) { |
|
| 498 | + echo ' |
|
| 480 | 499 | ', $txt['allowed_types'], ': ', $context['allowed_extensions'], '<br>'; |
| 500 | + } |
|
| 481 | 501 | |
| 482 | - if (!empty($context['attachment_restrictions'])) |
|
| 483 | - echo ' |
|
| 502 | + if (!empty($context['attachment_restrictions'])) { |
|
| 503 | + echo ' |
|
| 484 | 504 | ', $txt['attach_restrictions'], ' ', implode(', ', $context['attachment_restrictions']), '<br>'; |
| 505 | + } |
|
| 485 | 506 | |
| 486 | - if ($context['num_allowed_attachments'] == 0) |
|
| 487 | - echo ' |
|
| 507 | + if ($context['num_allowed_attachments'] == 0) { |
|
| 508 | + echo ' |
|
| 488 | 509 | ', $txt['attach_limit_nag'], '<br>'; |
| 510 | + } |
|
| 489 | 511 | |
| 490 | - if (!$context['can_post_attachment_unapproved']) |
|
| 491 | - echo ' |
|
| 512 | + if (!$context['can_post_attachment_unapproved']) { |
|
| 513 | + echo ' |
|
| 492 | 514 | <span class="alert">', $txt['attachment_requires_approval'], '</span>', '<br>'; |
| 515 | + } |
|
| 493 | 516 | |
| 494 | 517 | echo ' |
| 495 | 518 | </dd> |
@@ -513,24 +536,26 @@ discard block |
||
| 513 | 536 | <dt><strong>', $txt['subject'], '</strong></dt> |
| 514 | 537 | <dd><strong>', $txt['draft_saved_on'], '</strong></dd>'; |
| 515 | 538 | |
| 516 | - foreach ($context['drafts'] as $draft) |
|
| 517 | - echo ' |
|
| 539 | + foreach ($context['drafts'] as $draft) { |
|
| 540 | + echo ' |
|
| 518 | 541 | <dt>', $draft['link'], '</dt> |
| 519 | 542 | <dd>', $draft['poster_time'], '</dd>'; |
| 543 | + } |
|
| 520 | 544 | echo ' |
| 521 | 545 | </dl> |
| 522 | 546 | </div>'; |
| 523 | 547 | } |
| 524 | 548 | |
| 525 | 549 | // Is visual verification enabled? |
| 526 | - if ($context['require_verification']) |
|
| 527 | - echo ' |
|
| 550 | + if ($context['require_verification']) { |
|
| 551 | + echo ' |
|
| 528 | 552 | <div class="post_verification"> |
| 529 | 553 | <span', !empty($context['post_error']['need_qr_verification']) ? ' class="error"' : '', '> |
| 530 | 554 | <strong>', $txt['verification'], ':</strong> |
| 531 | 555 | </span> |
| 532 | 556 | ', template_control_verification($context['visual_verification_id'], 'all'), ' |
| 533 | 557 | </div>'; |
| 558 | + } |
|
| 534 | 559 | |
| 535 | 560 | // Finally, the submit buttons. |
| 536 | 561 | echo ' |
@@ -539,9 +564,10 @@ discard block |
||
| 539 | 564 | ', template_control_richedit_buttons($context['post_box_name']); |
| 540 | 565 | |
| 541 | 566 | // Option to delete an event if user is editing one. |
| 542 | - if ($context['make_event'] && !$context['event']['new']) |
|
| 543 | - echo ' |
|
| 567 | + if ($context['make_event'] && !$context['event']['new']) { |
|
| 568 | + echo ' |
|
| 544 | 569 | <input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['event_delete_confirm'] ,'" class="button you_sure">'; |
| 570 | + } |
|
| 545 | 571 | |
| 546 | 572 | echo ' |
| 547 | 573 | </span> |
@@ -550,9 +576,10 @@ discard block |
||
| 550 | 576 | <br class="clear">'; |
| 551 | 577 | |
| 552 | 578 | // Assuming this isn't a new topic pass across the last message id. |
| 553 | - if (isset($context['topic_last_message'])) |
|
| 554 | - echo ' |
|
| 579 | + if (isset($context['topic_last_message'])) { |
|
| 580 | + echo ' |
|
| 555 | 581 | <input type="hidden" name="last_msg" value="', $context['topic_last_message'], '">'; |
| 582 | + } |
|
| 556 | 583 | |
| 557 | 584 | echo ' |
| 558 | 585 | <input type="hidden" name="additional_options" id="additional_options" value="', $context['show_additional_options'] ? '1' : '0', '"> |
@@ -695,9 +722,10 @@ discard block |
||
| 695 | 722 | |
| 696 | 723 | newPostsHTML += \'<div class="windowbg\' + (++reply_counter % 2 == 0 ? \'2\' : \'\') + \'"><div id="msg\' + newPosts[i].getAttribute("id") + \'"><div class="floatleft"><h5>', $txt['posted_by'], ': \' + newPosts[i].getElementsByTagName("poster")[0].firstChild.nodeValue + \'</h5><span class="smalltext">« <strong>', $txt['on'], ':</strong> \' + newPosts[i].getElementsByTagName("time")[0].firstChild.nodeValue + \' »</span> <span class="new_posts" id="image_new_\' + newPosts[i].getAttribute("id") + \'">', $txt['new'], '</span></div>\';'; |
| 697 | 724 | |
| 698 | - if ($context['can_quote']) |
|
| 699 | - echo ' |
|
| 725 | + if ($context['can_quote']) { |
|
| 726 | + echo ' |
|
| 700 | 727 | newPostsHTML += \'<ul class="quickbuttons" id="msg_\' + newPosts[i].getAttribute("id") + \'_quote"><li><a href="#postmodify" onclick="return insertQuoteFast(\\\'\' + newPosts[i].getAttribute("id") + \'\\\');" class="quote_button"><span>', $txt['quote'], '</span><\' + \'/a></li></ul>\';'; |
| 728 | + } |
|
| 701 | 729 | |
| 702 | 730 | echo ' |
| 703 | 731 | newPostsHTML += \'<br class="clear">\'; |
@@ -740,8 +768,8 @@ discard block |
||
| 740 | 768 | }'; |
| 741 | 769 | |
| 742 | 770 | // Code for showing and hiding additional options. |
| 743 | - if (!empty($modSettings['additional_options_collapsable'])) |
|
| 744 | - echo ' |
|
| 771 | + if (!empty($modSettings['additional_options_collapsable'])) { |
|
| 772 | + echo ' |
|
| 745 | 773 | var oSwapAdditionalOptions = new smc_Toggle({ |
| 746 | 774 | bToggleEnabled: true, |
| 747 | 775 | bCurrentlyCollapsed: ', $context['show_additional_options'] ? 'false' : 'true', ', |
@@ -769,10 +797,11 @@ discard block |
||
| 769 | 797 | } |
| 770 | 798 | ] |
| 771 | 799 | });'; |
| 800 | + } |
|
| 772 | 801 | |
| 773 | 802 | // Code for showing and hiding drafts |
| 774 | - if (!empty($context['drafts'])) |
|
| 775 | - echo ' |
|
| 803 | + if (!empty($context['drafts'])) { |
|
| 804 | + echo ' |
|
| 776 | 805 | var oSwapDraftOptions = new smc_Toggle({ |
| 777 | 806 | bToggleEnabled: true, |
| 778 | 807 | bCurrentlyCollapsed: true, |
@@ -794,6 +823,7 @@ discard block |
||
| 794 | 823 | } |
| 795 | 824 | ] |
| 796 | 825 | });'; |
| 826 | + } |
|
| 797 | 827 | |
| 798 | 828 | echo ' |
| 799 | 829 | var oEditorID = "', $context['post_box_name'] ,'"; |
@@ -814,8 +844,9 @@ discard block |
||
| 814 | 844 | foreach ($context['previous_posts'] as $post) |
| 815 | 845 | { |
| 816 | 846 | $ignoring = false; |
| 817 | - if (!empty($post['is_ignored'])) |
|
| 818 | - $ignored_posts[] = $ignoring = $post['id']; |
|
| 847 | + if (!empty($post['is_ignored'])) { |
|
| 848 | + $ignored_posts[] = $ignoring = $post['id']; |
|
| 849 | + } |
|
| 819 | 850 | |
| 820 | 851 | echo ' |
| 821 | 852 | <div class="windowbg"> |
@@ -825,22 +856,24 @@ discard block |
||
| 825 | 856 | </h5> |
| 826 | 857 | - ', $post['time']; |
| 827 | 858 | |
| 828 | - if ($context['can_quote']) |
|
| 829 | - echo ' |
|
| 859 | + if ($context['can_quote']) { |
|
| 860 | + echo ' |
|
| 830 | 861 | <ul class="quickbuttons" id="msg_', $post['id'], '_quote"> |
| 831 | 862 | <li style="display:none;" id="quoteSelected_', $post['id'], '" data-msgid="', $post['id'], '"><a href="javascript:void(0)"><span class="generic_icons quote_selected"></span>', $txt['quote_selected_action'] ,'</a></li> |
| 832 | 863 | <li id="post_modify"><a href="#postmodify" onclick="return insertQuoteFast(', $post['id'], ');"><span class="generic_icons quote"></span>', $txt['quote'], '</a></li> |
| 833 | 864 | </ul>'; |
| 865 | + } |
|
| 834 | 866 | |
| 835 | 867 | echo ' |
| 836 | 868 | <br class="clear">'; |
| 837 | 869 | |
| 838 | - if ($ignoring) |
|
| 839 | - echo ' |
|
| 870 | + if ($ignoring) { |
|
| 871 | + echo ' |
|
| 840 | 872 | <div id="msg_', $post['id'], '_ignored_prompt" class="smalltext"> |
| 841 | 873 | ', $txt['ignoring_user'], ' |
| 842 | 874 | <a href="#" id="msg_', $post['id'], '_ignored_link" style="display: none;">', $txt['show_ignore_user_post'], '</a> |
| 843 | 875 | </div>'; |
| 876 | + } |
|
| 844 | 877 | |
| 845 | 878 | echo ' |
| 846 | 879 | <div class="list_posts smalltext" id="msg_', $post['id'], '_body" data-msgid="', $post['id'], '">', $post['message'], '</div> |
@@ -995,10 +1028,10 @@ discard block |
||
| 995 | 1028 | <div id="temporary_posting_area" style="display: none;"></div> |
| 996 | 1029 | <script>'; |
| 997 | 1030 | |
| 998 | - if ($context['close_window']) |
|
| 999 | - echo ' |
|
| 1031 | + if ($context['close_window']) { |
|
| 1032 | + echo ' |
|
| 1000 | 1033 | window.close();'; |
| 1001 | - else |
|
| 1034 | + } else |
|
| 1002 | 1035 | { |
| 1003 | 1036 | // Lucky for us, Internet Explorer has an "innerText" feature which basically converts entities <--> text. Use it if possible ;) |
| 1004 | 1037 | echo ' |
@@ -1052,11 +1085,12 @@ discard block |
||
| 1052 | 1085 | </p> |
| 1053 | 1086 | <ul>'; |
| 1054 | 1087 | |
| 1055 | - foreach ($context['groups'] as $group) |
|
| 1056 | - echo ' |
|
| 1088 | + foreach ($context['groups'] as $group) { |
|
| 1089 | + echo ' |
|
| 1057 | 1090 | <li> |
| 1058 | 1091 | <label for="who_', $group['id'], '"><input type="checkbox" name="who[', $group['id'], ']" id="who_', $group['id'], '" value="', $group['id'], '" checked> ', $group['name'], '</label> <em>(', $group['member_count'], ')</em> |
| 1059 | 1092 | </li>'; |
| 1093 | + } |
|
| 1060 | 1094 | |
| 1061 | 1095 | echo ' |
| 1062 | 1096 | <li> |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Get all birthdays within the given time range. |
@@ -60,8 +61,7 @@ discard block |
||
| 60 | 61 | 'max_year' => $year_high, |
| 61 | 62 | ) |
| 62 | 63 | ); |
| 63 | - } |
|
| 64 | - else |
|
| 64 | + } else |
|
| 65 | 65 | { |
| 66 | 66 | $result = $smcFunc['db_query']('birthday_array', ' |
| 67 | 67 | SELECT id_member, real_name, YEAR(birthdate) AS birth_year, birthdate |
@@ -91,10 +91,11 @@ discard block |
||
| 91 | 91 | $bday = array(); |
| 92 | 92 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 93 | 93 | { |
| 94 | - if ($year_low != $year_high) |
|
| 95 | - $age_year = substr($row['birthdate'], 5) < substr($high_date, 5) ? $year_high : $year_low; |
|
| 96 | - else |
|
| 97 | - $age_year = $year_low; |
|
| 94 | + if ($year_low != $year_high) { |
|
| 95 | + $age_year = substr($row['birthdate'], 5) < substr($high_date, 5) ? $year_high : $year_low; |
|
| 96 | + } else { |
|
| 97 | + $age_year = $year_low; |
|
| 98 | + } |
|
| 98 | 99 | |
| 99 | 100 | $bday[$age_year . substr($row['birthdate'], 4)][] = array( |
| 100 | 101 | 'id' => $row['id_member'], |
@@ -108,8 +109,9 @@ discard block |
||
| 108 | 109 | ksort($bday); |
| 109 | 110 | |
| 110 | 111 | // Set is_last, so the themes know when to stop placing separators. |
| 111 | - foreach ($bday as $mday => $array) |
|
| 112 | - $bday[$mday][count($array) - 1]['is_last'] = true; |
|
| 112 | + foreach ($bday as $mday => $array) { |
|
| 113 | + $bday[$mday][count($array) - 1]['is_last'] = true; |
|
| 114 | + } |
|
| 113 | 115 | |
| 114 | 116 | return $bday; |
| 115 | 117 | } |
@@ -133,8 +135,9 @@ discard block |
||
| 133 | 135 | static $timezone_array = array(); |
| 134 | 136 | require_once($sourcedir . '/Subs.php'); |
| 135 | 137 | |
| 136 | - if (empty($timezone_array['default'])) |
|
| 137 | - $timezone_array['default'] = timezone_open(date_default_timezone_get()); |
|
| 138 | + if (empty($timezone_array['default'])) { |
|
| 139 | + $timezone_array['default'] = timezone_open(date_default_timezone_get()); |
|
| 140 | + } |
|
| 138 | 141 | |
| 139 | 142 | $low_object = date_create($low_date); |
| 140 | 143 | $high_object = date_create($high_date); |
@@ -161,8 +164,9 @@ discard block |
||
| 161 | 164 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 162 | 165 | { |
| 163 | 166 | // If the attached topic is not approved then for the moment pretend it doesn't exist |
| 164 | - if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved']) |
|
| 165 | - continue; |
|
| 167 | + if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved']) { |
|
| 168 | + continue; |
|
| 169 | + } |
|
| 166 | 170 | |
| 167 | 171 | // Force a censor of the title - as often these are used by others. |
| 168 | 172 | censorText($row['title'], $use_permissions ? false : true); |
@@ -170,12 +174,14 @@ discard block |
||
| 170 | 174 | // Get the various time and date properties for this event |
| 171 | 175 | list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row); |
| 172 | 176 | |
| 173 | - if (empty($timezone_array[$tz])) |
|
| 174 | - $timezone_array[$tz] = timezone_open($tz); |
|
| 177 | + if (empty($timezone_array[$tz])) { |
|
| 178 | + $timezone_array[$tz] = timezone_open($tz); |
|
| 179 | + } |
|
| 175 | 180 | |
| 176 | 181 | // Sanity check |
| 177 | - if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) |
|
| 178 | - continue; |
|
| 182 | + if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) { |
|
| 183 | + continue; |
|
| 184 | + } |
|
| 179 | 185 | |
| 180 | 186 | // Get set up for the loop |
| 181 | 187 | $start_object = date_create($row['start_date'] . (!$allday ? ' ' . $row['start_time'] : ''), $timezone_array[$tz]); |
@@ -239,8 +245,8 @@ discard block |
||
| 239 | 245 | ); |
| 240 | 246 | |
| 241 | 247 | // If we're using permissions (calendar pages?) then just ouput normal contextual style information. |
| 242 | - if ($use_permissions) |
|
| 243 | - $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
| 248 | + if ($use_permissions) { |
|
| 249 | + $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
| 244 | 250 | 'href' => $row['id_board'] == 0 ? '' : $scripturl . '?topic=' . $row['id_topic'] . '.0', |
| 245 | 251 | 'link' => $row['id_board'] == 0 ? $row['title'] : '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['title'] . '</a>', |
| 246 | 252 | 'can_edit' => allowedTo('calendar_edit_any') || ($row['id_member'] == $user_info['id'] && allowedTo('calendar_edit_own')), |
@@ -248,9 +254,10 @@ discard block |
||
| 248 | 254 | 'can_export' => !empty($modSettings['cal_export']) ? true : false, |
| 249 | 255 | 'export_href' => $scripturl . '?action=calendar;sa=ical;eventid=' . $row['id_event'] . ';' . $context['session_var'] . '=' . $context['session_id'], |
| 250 | 256 | )); |
| 257 | + } |
|
| 251 | 258 | // Otherwise, this is going to be cached and the VIEWER'S permissions should apply... just put together some info. |
| 252 | - else |
|
| 253 | - $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
| 259 | + else { |
|
| 260 | + $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
| 254 | 261 | 'href' => $row['id_topic'] == 0 ? '' : $scripturl . '?topic=' . $row['id_topic'] . '.0', |
| 255 | 262 | 'link' => $row['id_topic'] == 0 ? $row['title'] : '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['title'] . '</a>', |
| 256 | 263 | 'can_edit' => false, |
@@ -260,6 +267,7 @@ discard block |
||
| 260 | 267 | 'poster' => $row['id_member'], |
| 261 | 268 | 'allowed_groups' => explode(',', $row['member_groups']), |
| 262 | 269 | )); |
| 270 | + } |
|
| 263 | 271 | |
| 264 | 272 | date_add($cal_date, date_interval_create_from_date_string('1 day')); |
| 265 | 273 | } |
@@ -269,8 +277,9 @@ discard block |
||
| 269 | 277 | // If we're doing normal contextual data, go through and make things clear to the templates ;). |
| 270 | 278 | if ($use_permissions) |
| 271 | 279 | { |
| 272 | - foreach ($events as $mday => $array) |
|
| 273 | - $events[$mday][count($array) - 1]['is_last'] = true; |
|
| 280 | + foreach ($events as $mday => $array) { |
|
| 281 | + $events[$mday][count($array) - 1]['is_last'] = true; |
|
| 282 | + } |
|
| 274 | 283 | } |
| 275 | 284 | |
| 276 | 285 | ksort($events); |
@@ -290,11 +299,12 @@ discard block |
||
| 290 | 299 | global $smcFunc; |
| 291 | 300 | |
| 292 | 301 | // Get the lowest and highest dates for "all years". |
| 293 | - if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) |
|
| 294 | - $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec} |
|
| 302 | + if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) { |
|
| 303 | + $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec} |
|
| 295 | 304 | OR event_date BETWEEN {date:all_year_jan} AND {date:all_year_high}'; |
| 296 | - else |
|
| 297 | - $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}'; |
|
| 305 | + } else { |
|
| 306 | + $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}'; |
|
| 307 | + } |
|
| 298 | 308 | |
| 299 | 309 | // Find some holidays... ;). |
| 300 | 310 | $result = $smcFunc['db_query']('', ' |
@@ -314,10 +324,11 @@ discard block |
||
| 314 | 324 | $holidays = array(); |
| 315 | 325 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 316 | 326 | { |
| 317 | - if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) |
|
| 318 | - $event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4); |
|
| 319 | - else |
|
| 320 | - $event_year = substr($low_date, 0, 4); |
|
| 327 | + if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) { |
|
| 328 | + $event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4); |
|
| 329 | + } else { |
|
| 330 | + $event_year = substr($low_date, 0, 4); |
|
| 331 | + } |
|
| 321 | 332 | |
| 322 | 333 | $holidays[$event_year . substr($row['event_date'], 4)][] = $row['title']; |
| 323 | 334 | } |
@@ -343,10 +354,12 @@ discard block |
||
| 343 | 354 | isAllowedTo('calendar_post'); |
| 344 | 355 | |
| 345 | 356 | // No board? No topic?!? |
| 346 | - if (empty($board)) |
|
| 347 | - fatal_lang_error('missing_board_id', false); |
|
| 348 | - if (empty($topic)) |
|
| 349 | - fatal_lang_error('missing_topic_id', false); |
|
| 357 | + if (empty($board)) { |
|
| 358 | + fatal_lang_error('missing_board_id', false); |
|
| 359 | + } |
|
| 360 | + if (empty($topic)) { |
|
| 361 | + fatal_lang_error('missing_topic_id', false); |
|
| 362 | + } |
|
| 350 | 363 | |
| 351 | 364 | // Administrator, Moderator, or owner. Period. |
| 352 | 365 | if (!allowedTo('admin_forum') && !allowedTo('moderate_board')) |
@@ -364,12 +377,14 @@ discard block |
||
| 364 | 377 | if ($row = $smcFunc['db_fetch_assoc']($result)) |
| 365 | 378 | { |
| 366 | 379 | // Not the owner of the topic. |
| 367 | - if ($row['id_member_started'] != $user_info['id']) |
|
| 368 | - fatal_lang_error('not_your_topic', 'user'); |
|
| 380 | + if ($row['id_member_started'] != $user_info['id']) { |
|
| 381 | + fatal_lang_error('not_your_topic', 'user'); |
|
| 382 | + } |
|
| 369 | 383 | } |
| 370 | 384 | // Topic/Board doesn't exist..... |
| 371 | - else |
|
| 372 | - fatal_lang_error('calendar_no_topic', 'general'); |
|
| 385 | + else { |
|
| 386 | + fatal_lang_error('calendar_no_topic', 'general'); |
|
| 387 | + } |
|
| 373 | 388 | $smcFunc['db_free_result']($result); |
| 374 | 389 | } |
| 375 | 390 | } |
@@ -457,14 +472,16 @@ discard block |
||
| 457 | 472 | if (!empty($calendarOptions['start_day'])) |
| 458 | 473 | { |
| 459 | 474 | $nShift -= $calendarOptions['start_day']; |
| 460 | - if ($nShift < 0) |
|
| 461 | - $nShift = 7 + $nShift; |
|
| 475 | + if ($nShift < 0) { |
|
| 476 | + $nShift = 7 + $nShift; |
|
| 477 | + } |
|
| 462 | 478 | } |
| 463 | 479 | |
| 464 | 480 | // Number of rows required to fit the month. |
| 465 | 481 | $nRows = floor(($month_info['last_day']['day_of_month'] + $nShift) / 7); |
| 466 | - if (($month_info['last_day']['day_of_month'] + $nShift) % 7) |
|
| 467 | - $nRows++; |
|
| 482 | + if (($month_info['last_day']['day_of_month'] + $nShift) % 7) { |
|
| 483 | + $nRows++; |
|
| 484 | + } |
|
| 468 | 485 | |
| 469 | 486 | // Fetch the arrays for birthdays, posted events, and holidays. |
| 470 | 487 | $bday = $calendarOptions['show_birthdays'] ? getBirthdayRange($month_info['first_day']['date'], $month_info['last_day']['date']) : array(); |
@@ -477,8 +494,9 @@ discard block |
||
| 477 | 494 | { |
| 478 | 495 | $calendarGrid['week_days'][] = $count; |
| 479 | 496 | $count++; |
| 480 | - if ($count == 7) |
|
| 481 | - $count = 0; |
|
| 497 | + if ($count == 7) { |
|
| 498 | + $count = 0; |
|
| 499 | + } |
|
| 482 | 500 | } |
| 483 | 501 | |
| 484 | 502 | // Iterate through each week. |
@@ -495,8 +513,9 @@ discard block |
||
| 495 | 513 | { |
| 496 | 514 | $nDay = ($nRow * 7) + $nCol - $nShift + 1; |
| 497 | 515 | |
| 498 | - if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month']) |
|
| 499 | - $nDay = 0; |
|
| 516 | + if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month']) { |
|
| 517 | + $nDay = 0; |
|
| 518 | + } |
|
| 500 | 519 | |
| 501 | 520 | $date = sprintf('%04d-%02d-%02d', $year, $month, $nDay); |
| 502 | 521 | |
@@ -514,8 +533,9 @@ discard block |
||
| 514 | 533 | } |
| 515 | 534 | |
| 516 | 535 | // What is the last day of the month? |
| 517 | - if ($is_previous === true) |
|
| 518 | - $calendarGrid['last_of_month'] = $month_info['last_day']['day_of_month']; |
|
| 536 | + if ($is_previous === true) { |
|
| 537 | + $calendarGrid['last_of_month'] = $month_info['last_day']['day_of_month']; |
|
| 538 | + } |
|
| 519 | 539 | |
| 520 | 540 | // We'll use the shift in the template. |
| 521 | 541 | $calendarGrid['shift'] = $nShift; |
@@ -549,8 +569,9 @@ discard block |
||
| 549 | 569 | { |
| 550 | 570 | // Here we offset accordingly to get things to the real start of a week. |
| 551 | 571 | $date_diff = $day_of_week - $calendarOptions['start_day']; |
| 552 | - if ($date_diff < 0) |
|
| 553 | - $date_diff += 7; |
|
| 572 | + if ($date_diff < 0) { |
|
| 573 | + $date_diff += 7; |
|
| 574 | + } |
|
| 554 | 575 | $new_timestamp = mktime(0, 0, 0, $month, $day, $year) - $date_diff * 86400; |
| 555 | 576 | $day = (int) strftime('%d', $new_timestamp); |
| 556 | 577 | $month = (int) strftime('%m', $new_timestamp); |
@@ -680,18 +701,20 @@ discard block |
||
| 680 | 701 | { |
| 681 | 702 | foreach ($date_events as $event_key => $event_val) |
| 682 | 703 | { |
| 683 | - if (in_array($event_val['id'], $temp)) |
|
| 684 | - unset($calendarGrid['events'][$date][$event_key]); |
|
| 685 | - else |
|
| 686 | - $temp[] = $event_val['id']; |
|
| 704 | + if (in_array($event_val['id'], $temp)) { |
|
| 705 | + unset($calendarGrid['events'][$date][$event_key]); |
|
| 706 | + } else { |
|
| 707 | + $temp[] = $event_val['id']; |
|
| 708 | + } |
|
| 687 | 709 | } |
| 688 | 710 | } |
| 689 | 711 | |
| 690 | 712 | // Give birthdays and holidays a friendly format, without the year |
| 691 | - if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
| 692 | - $date_format = '%b %d'; |
|
| 693 | - else |
|
| 694 | - $date_format = str_replace(array('%Y', '%y', '%G', '%g', '%C', '%c', '%D'), array('', '', '', '', '', '%b %d', '%m/%d'), $matches[0]); |
|
| 713 | + if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
| 714 | + $date_format = '%b %d'; |
|
| 715 | + } else { |
|
| 716 | + $date_format = str_replace(array('%Y', '%y', '%G', '%g', '%C', '%c', '%D'), array('', '', '', '', '', '%b %d', '%m/%d'), $matches[0]); |
|
| 717 | + } |
|
| 695 | 718 | |
| 696 | 719 | foreach (array('birthdays', 'holidays') as $type) |
| 697 | 720 | { |
@@ -790,8 +813,9 @@ discard block |
||
| 790 | 813 | // Holidays between now and now + days. |
| 791 | 814 | for ($i = $now; $i < $now + $days_for_index; $i += 86400) |
| 792 | 815 | { |
| 793 | - if (isset($cached_data['holidays'][strftime('%Y-%m-%d', $i)])) |
|
| 794 | - $return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][strftime('%Y-%m-%d', $i)]); |
|
| 816 | + if (isset($cached_data['holidays'][strftime('%Y-%m-%d', $i)])) { |
|
| 817 | + $return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][strftime('%Y-%m-%d', $i)]); |
|
| 818 | + } |
|
| 795 | 819 | } |
| 796 | 820 | } |
| 797 | 821 | |
@@ -803,8 +827,9 @@ discard block |
||
| 803 | 827 | $loop_date = strftime('%Y-%m-%d', $i); |
| 804 | 828 | if (isset($cached_data['birthdays'][$loop_date])) |
| 805 | 829 | { |
| 806 | - foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy) |
|
| 807 | - $cached_data['birthdays'][strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date']; |
|
| 830 | + foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy) { |
|
| 831 | + $cached_data['birthdays'][strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date']; |
|
| 832 | + } |
|
| 808 | 833 | $return_data['calendar_birthdays'] = array_merge($return_data['calendar_birthdays'], $cached_data['birthdays'][$loop_date]); |
| 809 | 834 | } |
| 810 | 835 | } |
@@ -819,8 +844,9 @@ discard block |
||
| 819 | 844 | $loop_date = strftime('%Y-%m-%d', $i); |
| 820 | 845 | |
| 821 | 846 | // No events today? Check the next day. |
| 822 | - if (empty($cached_data['events'][$loop_date])) |
|
| 823 | - continue; |
|
| 847 | + if (empty($cached_data['events'][$loop_date])) { |
|
| 848 | + continue; |
|
| 849 | + } |
|
| 824 | 850 | |
| 825 | 851 | // Loop through all events to add a few last-minute values. |
| 826 | 852 | foreach ($cached_data['events'][$loop_date] as $ev => $event) |
@@ -833,9 +859,9 @@ discard block |
||
| 833 | 859 | { |
| 834 | 860 | unset($cached_data['events'][$loop_date][$ev]); |
| 835 | 861 | continue; |
| 862 | + } else { |
|
| 863 | + $duplicates[$this_event['topic'] . $this_event['title']] = true; |
|
| 836 | 864 | } |
| 837 | - else |
|
| 838 | - $duplicates[$this_event['topic'] . $this_event['title']] = true; |
|
| 839 | 865 | |
| 840 | 866 | // Might be set to true afterwards, depending on the permissions. |
| 841 | 867 | $this_event['can_edit'] = false; |
@@ -843,16 +869,19 @@ discard block |
||
| 843 | 869 | $this_event['date'] = $loop_date; |
| 844 | 870 | } |
| 845 | 871 | |
| 846 | - if (!empty($cached_data['events'][$loop_date])) |
|
| 847 | - $return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]); |
|
| 872 | + if (!empty($cached_data['events'][$loop_date])) { |
|
| 873 | + $return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]); |
|
| 874 | + } |
|
| 848 | 875 | } |
| 849 | 876 | } |
| 850 | 877 | |
| 851 | 878 | // Mark the last item so that a list separator can be used in the template. |
| 852 | - for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++) |
|
| 853 | - $return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]); |
|
| 854 | - for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++) |
|
| 855 | - $return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]); |
|
| 879 | + for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++) { |
|
| 880 | + $return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]); |
|
| 881 | + } |
|
| 882 | + for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++) { |
|
| 883 | + $return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]); |
|
| 884 | + } |
|
| 856 | 885 | |
| 857 | 886 | return array( |
| 858 | 887 | 'data' => $return_data, |
@@ -900,37 +929,46 @@ discard block |
||
| 900 | 929 | if (isset($_POST['start_date'])) |
| 901 | 930 | { |
| 902 | 931 | $d = date_parse($_POST['start_date']); |
| 903 | - if (!empty($d['error_count']) || !empty($d['warning_count'])) |
|
| 904 | - fatal_lang_error('invalid_date', false); |
|
| 905 | - if (empty($d['year'])) |
|
| 906 | - fatal_lang_error('event_year_missing', false); |
|
| 907 | - if (empty($d['month'])) |
|
| 908 | - fatal_lang_error('event_month_missing', false); |
|
| 909 | - } |
|
| 910 | - elseif (isset($_POST['start_datetime'])) |
|
| 932 | + if (!empty($d['error_count']) || !empty($d['warning_count'])) { |
|
| 933 | + fatal_lang_error('invalid_date', false); |
|
| 934 | + } |
|
| 935 | + if (empty($d['year'])) { |
|
| 936 | + fatal_lang_error('event_year_missing', false); |
|
| 937 | + } |
|
| 938 | + if (empty($d['month'])) { |
|
| 939 | + fatal_lang_error('event_month_missing', false); |
|
| 940 | + } |
|
| 941 | + } elseif (isset($_POST['start_datetime'])) |
|
| 911 | 942 | { |
| 912 | 943 | $d = date_parse($_POST['start_datetime']); |
| 913 | - if (!empty($d['error_count']) || !empty($d['warning_count'])) |
|
| 914 | - fatal_lang_error('invalid_date', false); |
|
| 915 | - if (empty($d['year'])) |
|
| 916 | - fatal_lang_error('event_year_missing', false); |
|
| 917 | - if (empty($d['month'])) |
|
| 918 | - fatal_lang_error('event_month_missing', false); |
|
| 944 | + if (!empty($d['error_count']) || !empty($d['warning_count'])) { |
|
| 945 | + fatal_lang_error('invalid_date', false); |
|
| 946 | + } |
|
| 947 | + if (empty($d['year'])) { |
|
| 948 | + fatal_lang_error('event_year_missing', false); |
|
| 949 | + } |
|
| 950 | + if (empty($d['month'])) { |
|
| 951 | + fatal_lang_error('event_month_missing', false); |
|
| 952 | + } |
|
| 919 | 953 | } |
| 920 | 954 | // The 2.0 way |
| 921 | 955 | else |
| 922 | 956 | { |
| 923 | 957 | // No month? No year? |
| 924 | - if (!isset($_POST['month'])) |
|
| 925 | - fatal_lang_error('event_month_missing', false); |
|
| 926 | - if (!isset($_POST['year'])) |
|
| 927 | - fatal_lang_error('event_year_missing', false); |
|
| 958 | + if (!isset($_POST['month'])) { |
|
| 959 | + fatal_lang_error('event_month_missing', false); |
|
| 960 | + } |
|
| 961 | + if (!isset($_POST['year'])) { |
|
| 962 | + fatal_lang_error('event_year_missing', false); |
|
| 963 | + } |
|
| 928 | 964 | |
| 929 | 965 | // Check the month and year... |
| 930 | - if ($_POST['month'] < 1 || $_POST['month'] > 12) |
|
| 931 | - fatal_lang_error('invalid_month', false); |
|
| 932 | - if ($_POST['year'] < $modSettings['cal_minyear'] || $_POST['year'] > $modSettings['cal_maxyear']) |
|
| 933 | - fatal_lang_error('invalid_year', false); |
|
| 966 | + if ($_POST['month'] < 1 || $_POST['month'] > 12) { |
|
| 967 | + fatal_lang_error('invalid_month', false); |
|
| 968 | + } |
|
| 969 | + if ($_POST['year'] < $modSettings['cal_minyear'] || $_POST['year'] > $modSettings['cal_maxyear']) { |
|
| 970 | + fatal_lang_error('invalid_year', false); |
|
| 971 | + } |
|
| 934 | 972 | } |
| 935 | 973 | } |
| 936 | 974 | |
@@ -940,8 +978,9 @@ discard block |
||
| 940 | 978 | // If they want to us to calculate an end date, make sure it will fit in an acceptable range. |
| 941 | 979 | if (isset($_POST['span'])) |
| 942 | 980 | { |
| 943 | - if (($_POST['span'] < 1) || (!empty($modSettings['cal_maxspan']) && $_POST['span'] > $modSettings['cal_maxspan'])) |
|
| 944 | - fatal_lang_error('invalid_days_numb', false); |
|
| 981 | + if (($_POST['span'] < 1) || (!empty($modSettings['cal_maxspan']) && $_POST['span'] > $modSettings['cal_maxspan'])) { |
|
| 982 | + fatal_lang_error('invalid_days_numb', false); |
|
| 983 | + } |
|
| 945 | 984 | } |
| 946 | 985 | |
| 947 | 986 | // There is no need to validate the following values if we are just deleting the event. |
@@ -951,24 +990,29 @@ discard block |
||
| 951 | 990 | if (empty($_POST['start_date']) && empty($_POST['start_datetime'])) |
| 952 | 991 | { |
| 953 | 992 | // No day? |
| 954 | - if (!isset($_POST['day'])) |
|
| 955 | - fatal_lang_error('event_day_missing', false); |
|
| 993 | + if (!isset($_POST['day'])) { |
|
| 994 | + fatal_lang_error('event_day_missing', false); |
|
| 995 | + } |
|
| 956 | 996 | |
| 957 | 997 | // Bad day? |
| 958 | - if (!checkdate($_POST['month'], $_POST['day'], $_POST['year'])) |
|
| 959 | - fatal_lang_error('invalid_date', false); |
|
| 998 | + if (!checkdate($_POST['month'], $_POST['day'], $_POST['year'])) { |
|
| 999 | + fatal_lang_error('invalid_date', false); |
|
| 1000 | + } |
|
| 960 | 1001 | } |
| 961 | 1002 | |
| 962 | - if (!isset($_POST['evtitle']) && !isset($_POST['subject'])) |
|
| 963 | - fatal_lang_error('event_title_missing', false); |
|
| 964 | - elseif (!isset($_POST['evtitle'])) |
|
| 965 | - $_POST['evtitle'] = $_POST['subject']; |
|
| 1003 | + if (!isset($_POST['evtitle']) && !isset($_POST['subject'])) { |
|
| 1004 | + fatal_lang_error('event_title_missing', false); |
|
| 1005 | + } elseif (!isset($_POST['evtitle'])) { |
|
| 1006 | + $_POST['evtitle'] = $_POST['subject']; |
|
| 1007 | + } |
|
| 966 | 1008 | |
| 967 | 1009 | // No title? |
| 968 | - if ($smcFunc['htmltrim']($_POST['evtitle']) === '') |
|
| 969 | - fatal_lang_error('no_event_title', false); |
|
| 970 | - if ($smcFunc['strlen']($_POST['evtitle']) > 100) |
|
| 971 | - $_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100); |
|
| 1010 | + if ($smcFunc['htmltrim']($_POST['evtitle']) === '') { |
|
| 1011 | + fatal_lang_error('no_event_title', false); |
|
| 1012 | + } |
|
| 1013 | + if ($smcFunc['strlen']($_POST['evtitle']) > 100) { |
|
| 1014 | + $_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100); |
|
| 1015 | + } |
|
| 972 | 1016 | $_POST['evtitle'] = str_replace(';', '', $_POST['evtitle']); |
| 973 | 1017 | } |
| 974 | 1018 | } |
@@ -995,8 +1039,9 @@ discard block |
||
| 995 | 1039 | ); |
| 996 | 1040 | |
| 997 | 1041 | // No results, return false. |
| 998 | - if ($smcFunc['db_num_rows'] === 0) |
|
| 999 | - return false; |
|
| 1042 | + if ($smcFunc['db_num_rows'] === 0) { |
|
| 1043 | + return false; |
|
| 1044 | + } |
|
| 1000 | 1045 | |
| 1001 | 1046 | // Grab the results and return. |
| 1002 | 1047 | list ($poster) = $smcFunc['db_fetch_row']($request); |
@@ -1130,8 +1175,9 @@ discard block |
||
| 1130 | 1175 | call_integration_hook('integrate_modify_event', array($event_id, &$eventOptions, &$event_columns, &$event_parameters)); |
| 1131 | 1176 | |
| 1132 | 1177 | $column_clauses = array(); |
| 1133 | - foreach ($event_columns as $col => $crit) |
|
| 1134 | - $column_clauses[] = $col . ' = ' . $crit; |
|
| 1178 | + foreach ($event_columns as $col => $crit) { |
|
| 1179 | + $column_clauses[] = $col . ' = ' . $crit; |
|
| 1180 | + } |
|
| 1135 | 1181 | |
| 1136 | 1182 | $smcFunc['db_query']('', ' |
| 1137 | 1183 | UPDATE {db_prefix}calendar |
@@ -1216,8 +1262,9 @@ discard block |
||
| 1216 | 1262 | ); |
| 1217 | 1263 | |
| 1218 | 1264 | // If nothing returned, we are in poo, poo. |
| 1219 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 1220 | - return false; |
|
| 1265 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 1266 | + return false; |
|
| 1267 | + } |
|
| 1221 | 1268 | |
| 1222 | 1269 | $row = $smcFunc['db_fetch_assoc']($request); |
| 1223 | 1270 | $smcFunc['db_free_result']($request); |
@@ -1225,8 +1272,9 @@ discard block |
||
| 1225 | 1272 | list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row); |
| 1226 | 1273 | |
| 1227 | 1274 | // Sanity check |
| 1228 | - if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) |
|
| 1229 | - return false; |
|
| 1275 | + if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) { |
|
| 1276 | + return false; |
|
| 1277 | + } |
|
| 1230 | 1278 | |
| 1231 | 1279 | $return_value = array( |
| 1232 | 1280 | 'boards' => array(), |
@@ -1363,24 +1411,27 @@ discard block |
||
| 1363 | 1411 | |
| 1364 | 1412 | // Set $span, in case we need it |
| 1365 | 1413 | $span = isset($eventOptions['span']) ? $eventOptions['span'] : (isset($_POST['span']) ? $_POST['span'] : 0); |
| 1366 | - if ($span > 0) |
|
| 1367 | - $span = !empty($modSettings['cal_maxspan']) ? min($modSettings['cal_maxspan'], $span - 1) : $span - 1; |
|
| 1414 | + if ($span > 0) { |
|
| 1415 | + $span = !empty($modSettings['cal_maxspan']) ? min($modSettings['cal_maxspan'], $span - 1) : $span - 1; |
|
| 1416 | + } |
|
| 1368 | 1417 | |
| 1369 | 1418 | // Define the timezone for this event, falling back to the default if not provided |
| 1370 | - if (!empty($eventOptions['tz']) && in_array($eventOptions['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
| 1371 | - $tz = $eventOptions['tz']; |
|
| 1372 | - elseif (!empty($_POST['tz']) && in_array($_POST['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
| 1373 | - $tz = $_POST['tz']; |
|
| 1374 | - else |
|
| 1375 | - $tz = getUserTimezone(); |
|
| 1419 | + if (!empty($eventOptions['tz']) && in_array($eventOptions['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
| 1420 | + $tz = $eventOptions['tz']; |
|
| 1421 | + } elseif (!empty($_POST['tz']) && in_array($_POST['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
| 1422 | + $tz = $_POST['tz']; |
|
| 1423 | + } else { |
|
| 1424 | + $tz = getUserTimezone(); |
|
| 1425 | + } |
|
| 1376 | 1426 | |
| 1377 | 1427 | // Is this supposed to be an all day event, or should it have specific start and end times? |
| 1378 | - if (isset($eventOptions['allday'])) |
|
| 1379 | - $allday = $eventOptions['allday']; |
|
| 1380 | - elseif (empty($_POST['allday'])) |
|
| 1381 | - $allday = false; |
|
| 1382 | - else |
|
| 1383 | - $allday = true; |
|
| 1428 | + if (isset($eventOptions['allday'])) { |
|
| 1429 | + $allday = $eventOptions['allday']; |
|
| 1430 | + } elseif (empty($_POST['allday'])) { |
|
| 1431 | + $allday = false; |
|
| 1432 | + } else { |
|
| 1433 | + $allday = true; |
|
| 1434 | + } |
|
| 1384 | 1435 | |
| 1385 | 1436 | // Input might come as individual parameters... |
| 1386 | 1437 | $start_year = isset($eventOptions['year']) ? $eventOptions['year'] : (isset($_POST['year']) ? $_POST['year'] : null); |
@@ -1407,10 +1458,12 @@ discard block |
||
| 1407 | 1458 | $end_time_string = isset($eventOptions['end_time']) ? $eventOptions['end_time'] : (isset($_POST['end_time']) ? $_POST['end_time'] : null); |
| 1408 | 1459 | |
| 1409 | 1460 | // If the date and time were given in separate strings, combine them |
| 1410 | - if (empty($start_string) && isset($start_date_string)) |
|
| 1411 | - $start_string = $start_date_string . (isset($start_time_string) ? ' ' . $start_time_string : ''); |
|
| 1412 | - if (empty($end_string) && isset($end_date_string)) |
|
| 1413 | - $end_string = $end_date_string . (isset($end_time_string) ? ' ' . $end_time_string : ''); |
|
| 1461 | + if (empty($start_string) && isset($start_date_string)) { |
|
| 1462 | + $start_string = $start_date_string . (isset($start_time_string) ? ' ' . $start_time_string : ''); |
|
| 1463 | + } |
|
| 1464 | + if (empty($end_string) && isset($end_date_string)) { |
|
| 1465 | + $end_string = $end_date_string . (isset($end_time_string) ? ' ' . $end_time_string : ''); |
|
| 1466 | + } |
|
| 1414 | 1467 | |
| 1415 | 1468 | // If some form of string input was given, override individually defined options with it |
| 1416 | 1469 | if (isset($start_string)) |
@@ -1501,10 +1554,11 @@ discard block |
||
| 1501 | 1554 | if ($start_object >= $end_object) |
| 1502 | 1555 | { |
| 1503 | 1556 | $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, $start_hour, $start_minute, $start_second) . ' ' . $tz); |
| 1504 | - if ($span > 0) |
|
| 1505 | - date_add($end_object, date_interval_create_from_date_string($span . ' days')); |
|
| 1506 | - else |
|
| 1507 | - date_add($end_object, date_interval_create_from_date_string('1 hour')); |
|
| 1557 | + if ($span > 0) { |
|
| 1558 | + date_add($end_object, date_interval_create_from_date_string($span . ' days')); |
|
| 1559 | + } else { |
|
| 1560 | + date_add($end_object, date_interval_create_from_date_string('1 hour')); |
|
| 1561 | + } |
|
| 1508 | 1562 | } |
| 1509 | 1563 | |
| 1510 | 1564 | // Is $end_object too late? |
@@ -1517,9 +1571,9 @@ discard block |
||
| 1517 | 1571 | { |
| 1518 | 1572 | $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, $start_hour, $start_minute, $start_second) . ' ' . $tz); |
| 1519 | 1573 | date_add($end_object, date_interval_create_from_date_string($modSettings['cal_maxspan'] . ' days')); |
| 1574 | + } else { |
|
| 1575 | + $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, '11', '59', '59') . ' ' . $tz); |
|
| 1520 | 1576 | } |
| 1521 | - else |
|
| 1522 | - $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, '11', '59', '59') . ' ' . $tz); |
|
| 1523 | 1577 | } |
| 1524 | 1578 | } |
| 1525 | 1579 | |
@@ -1532,8 +1586,7 @@ discard block |
||
| 1532 | 1586 | $start_time = null; |
| 1533 | 1587 | $end_time = null; |
| 1534 | 1588 | $tz = null; |
| 1535 | - } |
|
| 1536 | - else |
|
| 1589 | + } else |
|
| 1537 | 1590 | { |
| 1538 | 1591 | $start_time = date_format($start_object, 'H:i:s'); |
| 1539 | 1592 | $end_time = date_format($end_object, 'H:i:s'); |
@@ -1561,19 +1614,21 @@ discard block |
||
| 1561 | 1614 | // First, try to create a better date format, ignoring the "time" elements. |
| 1562 | 1615 | if (empty($date_format)) |
| 1563 | 1616 | { |
| 1564 | - if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
| 1565 | - $date_format = '%F'; |
|
| 1566 | - else |
|
| 1567 | - $date_format = $matches[0]; |
|
| 1617 | + if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
| 1618 | + $date_format = '%F'; |
|
| 1619 | + } else { |
|
| 1620 | + $date_format = $matches[0]; |
|
| 1621 | + } |
|
| 1568 | 1622 | } |
| 1569 | 1623 | |
| 1570 | 1624 | // We want a fairly compact version of the time, but as close as possible to the user's settings. |
| 1571 | 1625 | if (empty($time_format)) |
| 1572 | 1626 | { |
| 1573 | - if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
| 1574 | - $time_format = '%k:%M'; |
|
| 1575 | - else |
|
| 1576 | - $time_format = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
| 1627 | + if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
| 1628 | + $time_format = '%k:%M'; |
|
| 1629 | + } else { |
|
| 1630 | + $time_format = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
| 1631 | + } |
|
| 1577 | 1632 | } |
| 1578 | 1633 | |
| 1579 | 1634 | // Should this be an all day event? |
@@ -1583,11 +1638,13 @@ discard block |
||
| 1583 | 1638 | $span = 1 + date_interval_format(date_diff(date_create($row['start_date']), date_create($row['end_date'])), '%d'); |
| 1584 | 1639 | |
| 1585 | 1640 | // We need to have a defined timezone in the steps below |
| 1586 | - if (empty($row['timezone'])) |
|
| 1587 | - $row['timezone'] = getUserTimezone(); |
|
| 1641 | + if (empty($row['timezone'])) { |
|
| 1642 | + $row['timezone'] = getUserTimezone(); |
|
| 1643 | + } |
|
| 1588 | 1644 | |
| 1589 | - if (empty($timezone_array[$row['timezone']])) |
|
| 1590 | - $timezone_array[$row['timezone']] = timezone_open($row['timezone']); |
|
| 1645 | + if (empty($timezone_array[$row['timezone']])) { |
|
| 1646 | + $timezone_array[$row['timezone']] = timezone_open($row['timezone']); |
|
| 1647 | + } |
|
| 1591 | 1648 | |
| 1592 | 1649 | // Get most of the standard date information for the start and end datetimes |
| 1593 | 1650 | $start = date_parse($row['start_date'] . (!$allday ? ' ' . $row['start_time'] : '')); |
@@ -1622,8 +1679,9 @@ discard block |
||
| 1622 | 1679 | $tz_abbrev = date_format($start_object, 'T'); |
| 1623 | 1680 | |
| 1624 | 1681 | // If the abbreviation is just a numerical offset from UTC, make that clear. |
| 1625 | - if (strspn($tz_abbrev, '+-') > 0) |
|
| 1626 | - $tz_abbrev = 'UTC' . $tz_abbrev; |
|
| 1682 | + if (strspn($tz_abbrev, '+-') > 0) { |
|
| 1683 | + $tz_abbrev = 'UTC' . $tz_abbrev; |
|
| 1684 | + } |
|
| 1627 | 1685 | |
| 1628 | 1686 | return array($start, $end, $allday, $span, $tz, $tz_abbrev); |
| 1629 | 1687 | } |
@@ -1639,8 +1697,9 @@ discard block |
||
| 1639 | 1697 | global $smcFunc, $context, $user_info, $modSettings, $user_settings; |
| 1640 | 1698 | static $member_cache = array(); |
| 1641 | 1699 | |
| 1642 | - if (is_null($id_member) && $user_info['is_guest'] == false) |
|
| 1643 | - $id_member = $context['user']['id']; |
|
| 1700 | + if (is_null($id_member) && $user_info['is_guest'] == false) { |
|
| 1701 | + $id_member = $context['user']['id']; |
|
| 1702 | + } |
|
| 1644 | 1703 | |
| 1645 | 1704 | //check if the cache got the data |
| 1646 | 1705 | if (isset($id_member) && isset($member_cache[$id_member])) |
@@ -1669,11 +1728,13 @@ discard block |
||
| 1669 | 1728 | $smcFunc['db_free_result']($request); |
| 1670 | 1729 | } |
| 1671 | 1730 | |
| 1672 | - if (empty($timezone) || !in_array($timezone, timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
| 1673 | - $timezone = isset($modSettings['default_timezone']) ? $modSettings['default_timezone'] : date_default_timezone_get(); |
|
| 1731 | + if (empty($timezone) || !in_array($timezone, timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
| 1732 | + $timezone = isset($modSettings['default_timezone']) ? $modSettings['default_timezone'] : date_default_timezone_get(); |
|
| 1733 | + } |
|
| 1674 | 1734 | |
| 1675 | - if (isset($id_member)) |
|
| 1676 | - $member_cache[$id_member] = $timezone; |
|
| 1735 | + if (isset($id_member)) { |
|
| 1736 | + $member_cache[$id_member] = $timezone; |
|
| 1737 | + } |
|
| 1677 | 1738 | |
| 1678 | 1739 | return $timezone; |
| 1679 | 1740 | } |
@@ -1702,8 +1763,9 @@ discard block |
||
| 1702 | 1763 | ) |
| 1703 | 1764 | ); |
| 1704 | 1765 | $holidays = array(); |
| 1705 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1706 | - $holidays[] = $row; |
|
| 1766 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1767 | + $holidays[] = $row; |
|
| 1768 | + } |
|
| 1707 | 1769 | $smcFunc['db_free_result']($request); |
| 1708 | 1770 | |
| 1709 | 1771 | return $holidays; |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 4 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Show the list of topics in this board, along with any child boards. |
@@ -56,8 +57,9 @@ discard block |
||
| 56 | 57 | |
| 57 | 58 | $context['name'] = $board_info['name']; |
| 58 | 59 | $context['description'] = $board_info['description']; |
| 59 | - if (!empty($board_info['description'])) |
|
| 60 | - $context['meta_description'] = strip_tags($board_info['description']); |
|
| 60 | + if (!empty($board_info['description'])) { |
|
| 61 | + $context['meta_description'] = strip_tags($board_info['description']); |
|
| 62 | + } |
|
| 61 | 63 | |
| 62 | 64 | // How many topics do we have in total? |
| 63 | 65 | $board_info['total_topics'] = allowedTo('approve_posts') ? $board_info['num_topics'] + $board_info['unapproved_topics'] : $board_info['num_topics'] + $board_info['unapproved_user_topics']; |
@@ -73,12 +75,14 @@ discard block |
||
| 73 | 75 | $session_name = session_name(); |
| 74 | 76 | foreach ($_GET as $k => $v) |
| 75 | 77 | { |
| 76 | - if (!in_array($k, array('board', 'start', $session_name))) |
|
| 77 | - $context['robot_no_index'] = true; |
|
| 78 | + if (!in_array($k, array('board', 'start', $session_name))) { |
|
| 79 | + $context['robot_no_index'] = true; |
|
| 80 | + } |
|
| 78 | 81 | } |
| 79 | 82 | } |
| 80 | - if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) |
|
| 81 | - $context['robot_no_index'] = true; |
|
| 83 | + if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) { |
|
| 84 | + $context['robot_no_index'] = true; |
|
| 85 | + } |
|
| 82 | 86 | |
| 83 | 87 | // If we can view unapproved messages and there are some build up a list. |
| 84 | 88 | if (allowedTo('approve_posts') && ($board_info['unapproved_topics'] || $board_info['unapproved_posts'])) |
@@ -89,14 +93,16 @@ discard block |
||
| 89 | 93 | } |
| 90 | 94 | |
| 91 | 95 | // We only know these. |
| 92 | - if (isset($_REQUEST['sort']) && !in_array($_REQUEST['sort'], array('subject', 'starter', 'last_poster', 'replies', 'views', 'first_post', 'last_post'))) |
|
| 93 | - $_REQUEST['sort'] = 'last_post'; |
|
| 96 | + if (isset($_REQUEST['sort']) && !in_array($_REQUEST['sort'], array('subject', 'starter', 'last_poster', 'replies', 'views', 'first_post', 'last_post'))) { |
|
| 97 | + $_REQUEST['sort'] = 'last_post'; |
|
| 98 | + } |
|
| 94 | 99 | |
| 95 | 100 | // Make sure the starting place makes sense and construct the page index. |
| 96 | - if (isset($_REQUEST['sort'])) |
|
| 97 | - $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true); |
|
| 98 | - else |
|
| 99 | - $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d', $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true); |
|
| 101 | + if (isset($_REQUEST['sort'])) { |
|
| 102 | + $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true); |
|
| 103 | + } else { |
|
| 104 | + $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d', $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true); |
|
| 105 | + } |
|
| 100 | 106 | $context['start'] = &$_REQUEST['start']; |
| 101 | 107 | |
| 102 | 108 | // Set a canonical URL for this page. |
@@ -132,14 +138,16 @@ discard block |
||
| 132 | 138 | $context['link_moderators'] = array(); |
| 133 | 139 | if (!empty($board_info['moderators'])) |
| 134 | 140 | { |
| 135 | - foreach ($board_info['moderators'] as $mod) |
|
| 136 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
| 141 | + foreach ($board_info['moderators'] as $mod) { |
|
| 142 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
| 143 | + } |
|
| 137 | 144 | } |
| 138 | 145 | if (!empty($board_info['moderator_groups'])) |
| 139 | 146 | { |
| 140 | 147 | // By default just tack the moderator groups onto the end of the members |
| 141 | - foreach ($board_info['moderator_groups'] as $mod_group) |
|
| 142 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
| 148 | + foreach ($board_info['moderator_groups'] as $mod_group) { |
|
| 149 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
| 150 | + } |
|
| 143 | 151 | } |
| 144 | 152 | |
| 145 | 153 | // Now we tack the info onto the end of the linktree |
@@ -191,20 +199,24 @@ discard block |
||
| 191 | 199 | ); |
| 192 | 200 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 193 | 201 | { |
| 194 | - if (empty($row['id_member'])) |
|
| 195 | - continue; |
|
| 202 | + if (empty($row['id_member'])) { |
|
| 203 | + continue; |
|
| 204 | + } |
|
| 196 | 205 | |
| 197 | - if (!empty($row['online_color'])) |
|
| 198 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
| 199 | - else |
|
| 200 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 206 | + if (!empty($row['online_color'])) { |
|
| 207 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
| 208 | + } else { |
|
| 209 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 210 | + } |
|
| 201 | 211 | |
| 202 | 212 | $is_buddy = in_array($row['id_member'], $user_info['buddies']); |
| 203 | - if ($is_buddy) |
|
| 204 | - $link = '<strong>' . $link . '</strong>'; |
|
| 213 | + if ($is_buddy) { |
|
| 214 | + $link = '<strong>' . $link . '</strong>'; |
|
| 215 | + } |
|
| 205 | 216 | |
| 206 | - if (!empty($row['show_online']) || allowedTo('moderate_forum')) |
|
| 207 | - $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
| 217 | + if (!empty($row['show_online']) || allowedTo('moderate_forum')) { |
|
| 218 | + $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
| 219 | + } |
|
| 208 | 220 | // @todo why are we filling this array of data that are just counted (twice) and discarded? ??? |
| 209 | 221 | $context['view_members'][$row['log_time'] . $row['member_name']] = array( |
| 210 | 222 | 'id' => $row['id_member'], |
@@ -217,8 +229,9 @@ discard block |
||
| 217 | 229 | 'hidden' => empty($row['show_online']), |
| 218 | 230 | ); |
| 219 | 231 | |
| 220 | - if (empty($row['show_online'])) |
|
| 221 | - $context['view_num_hidden']++; |
|
| 232 | + if (empty($row['show_online'])) { |
|
| 233 | + $context['view_num_hidden']++; |
|
| 234 | + } |
|
| 222 | 235 | } |
| 223 | 236 | $context['view_num_guests'] = $smcFunc['db_num_rows']($request) - count($context['view_members']); |
| 224 | 237 | $smcFunc['db_free_result']($request); |
@@ -260,8 +273,9 @@ discard block |
||
| 260 | 273 | // Bring in any changes we want to make before the query. |
| 261 | 274 | call_integration_hook('integrate_pre_messageindex', array(&$sort_methods)); |
| 262 | 275 | |
| 263 | - foreach ($sort_methods as $key => $val) |
|
| 264 | - $context['topics_headers'][$key] = '<a href="' . $scripturl . '?board=' . $context['current_board'] . '.' . $context['start'] . ';sort=' . $key . ($context['sort_by'] == $key && $context['sort_direction'] == 'up' ? ';desc' : '') . '">' . $txt[$key] . ($context['sort_by'] == $key ? '<span class="sort sort_' . $context['sort_direction'] . '"></span>' : '') . '</a>'; |
|
| 276 | + foreach ($sort_methods as $key => $val) { |
|
| 277 | + $context['topics_headers'][$key] = '<a href="' . $scripturl . '?board=' . $context['current_board'] . '.' . $context['start'] . ';sort=' . $key . ($context['sort_by'] == $key && $context['sort_direction'] == 'up' ? ';desc' : '') . '">' . $txt[$key] . ($context['sort_by'] == $key ? '<span class="sort sort_' . $context['sort_direction'] . '"></span>' : '') . '</a>'; |
|
| 278 | + } |
|
| 265 | 279 | |
| 266 | 280 | // Calculate the fastest way to get the topics. |
| 267 | 281 | $start = (int) $_REQUEST['start']; |
@@ -271,14 +285,15 @@ discard block |
||
| 271 | 285 | $fake_ascending = true; |
| 272 | 286 | $context['maxindex'] = $board_info['total_topics'] < $start + $context['maxindex'] + 1 ? $board_info['total_topics'] - $start : $context['maxindex']; |
| 273 | 287 | $start = $board_info['total_topics'] < $start + $context['maxindex'] + 1 ? 0 : $board_info['total_topics'] - $start - $context['maxindex']; |
| 288 | + } else { |
|
| 289 | + $fake_ascending = false; |
|
| 274 | 290 | } |
| 275 | - else |
|
| 276 | - $fake_ascending = false; |
|
| 277 | 291 | |
| 278 | 292 | // Setup the default topic icons... |
| 279 | 293 | $context['icon_sources'] = array(); |
| 280 | - foreach ($context['stable_icons'] as $icon) |
|
| 281 | - $context['icon_sources'][$icon] = 'images_url'; |
|
| 294 | + foreach ($context['stable_icons'] as $icon) { |
|
| 295 | + $context['icon_sources'][$icon] = 'images_url'; |
|
| 296 | + } |
|
| 282 | 297 | |
| 283 | 298 | $topic_ids = array(); |
| 284 | 299 | $context['topics'] = array(); |
@@ -316,8 +331,9 @@ discard block |
||
| 316 | 331 | $message_pre_index_parameters |
| 317 | 332 | ); |
| 318 | 333 | $topic_ids = array(); |
| 319 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 320 | - $topic_ids[] = $row['id_topic']; |
|
| 334 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 335 | + $topic_ids[] = $row['id_topic']; |
|
| 336 | + } |
|
| 321 | 337 | } |
| 322 | 338 | |
| 323 | 339 | // Grab the appropriate topic information... |
@@ -340,10 +356,11 @@ discard block |
||
| 340 | 356 | $message_index_wheres = array(); |
| 341 | 357 | call_integration_hook('integrate_message_index', array(&$message_index_selects, &$message_index_tables, &$message_index_parameters, &$message_index_wheres, &$topic_ids)); |
| 342 | 358 | |
| 343 | - if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest']) |
|
| 344 | - $enableParticipation = true; |
|
| 345 | - else |
|
| 346 | - $enableParticipation = false; |
|
| 359 | + if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest']) { |
|
| 360 | + $enableParticipation = true; |
|
| 361 | + } else { |
|
| 362 | + $enableParticipation = false; |
|
| 363 | + } |
|
| 347 | 364 | |
| 348 | 365 | $result = $smcFunc['db_query']('substring', ' |
| 349 | 366 | SELECT |
@@ -382,11 +399,13 @@ discard block |
||
| 382 | 399 | // Begin 'printing' the message index for current board. |
| 383 | 400 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 384 | 401 | { |
| 385 | - if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') |
|
| 386 | - continue; |
|
| 402 | + if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') { |
|
| 403 | + continue; |
|
| 404 | + } |
|
| 387 | 405 | |
| 388 | - if (!$pre_query) |
|
| 389 | - $topic_ids[] = $row['id_topic']; |
|
| 406 | + if (!$pre_query) { |
|
| 407 | + $topic_ids[] = $row['id_topic']; |
|
| 408 | + } |
|
| 390 | 409 | |
| 391 | 410 | // Reference the main color class. |
| 392 | 411 | $colorClass = 'windowbg'; |
@@ -396,8 +415,9 @@ discard block |
||
| 396 | 415 | { |
| 397 | 416 | // Limit them to $modSettings['preview_characters'] characters |
| 398 | 417 | $row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['id_first_msg']), array('<br>' => ' '))); |
| 399 | - if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters']) |
|
| 400 | - $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...'; |
|
| 418 | + if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters']) { |
|
| 419 | + $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...'; |
|
| 420 | + } |
|
| 401 | 421 | |
| 402 | 422 | // Censor the subject and message preview. |
| 403 | 423 | censorText($row['first_subject']); |
@@ -408,27 +428,27 @@ discard block |
||
| 408 | 428 | { |
| 409 | 429 | $row['last_subject'] = $row['first_subject']; |
| 410 | 430 | $row['last_body'] = $row['first_body']; |
| 411 | - } |
|
| 412 | - else |
|
| 431 | + } else |
|
| 413 | 432 | { |
| 414 | 433 | $row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['id_last_msg']), array('<br>' => ' '))); |
| 415 | - if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters']) |
|
| 416 | - $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...'; |
|
| 434 | + if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters']) { |
|
| 435 | + $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...'; |
|
| 436 | + } |
|
| 417 | 437 | |
| 418 | 438 | censorText($row['last_subject']); |
| 419 | 439 | censorText($row['last_body']); |
| 420 | 440 | } |
| 421 | - } |
|
| 422 | - else |
|
| 441 | + } else |
|
| 423 | 442 | { |
| 424 | 443 | $row['first_body'] = ''; |
| 425 | 444 | $row['last_body'] = ''; |
| 426 | 445 | censorText($row['first_subject']); |
| 427 | 446 | |
| 428 | - if ($row['id_first_msg'] == $row['id_last_msg']) |
|
| 429 | - $row['last_subject'] = $row['first_subject']; |
|
| 430 | - else |
|
| 431 | - censorText($row['last_subject']); |
|
| 447 | + if ($row['id_first_msg'] == $row['id_last_msg']) { |
|
| 448 | + $row['last_subject'] = $row['first_subject']; |
|
| 449 | + } else { |
|
| 450 | + censorText($row['last_subject']); |
|
| 451 | + } |
|
| 432 | 452 | } |
| 433 | 453 | |
| 434 | 454 | // Decide how many pages the topic should have. |
@@ -439,42 +459,50 @@ discard block |
||
| 439 | 459 | $pages = constructPageIndex($scripturl . '?topic=' . $row['id_topic'] . '.%1$d', $start, $row['num_replies'] + 1, $context['messages_per_page'], true, false); |
| 440 | 460 | |
| 441 | 461 | // If we can use all, show all. |
| 442 | - if (!empty($modSettings['enableAllMessages']) && $row['num_replies'] + 1 < $modSettings['enableAllMessages']) |
|
| 443 | - $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
| 462 | + if (!empty($modSettings['enableAllMessages']) && $row['num_replies'] + 1 < $modSettings['enableAllMessages']) { |
|
| 463 | + $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
| 464 | + } |
|
| 465 | + } else { |
|
| 466 | + $pages = ''; |
|
| 444 | 467 | } |
| 445 | - else |
|
| 446 | - $pages = ''; |
|
| 447 | 468 | |
| 448 | 469 | // We need to check the topic icons exist... |
| 449 | 470 | if (!empty($modSettings['messageIconChecks_enable'])) |
| 450 | 471 | { |
| 451 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
| 452 | - $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 453 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
| 454 | - $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 455 | - } |
|
| 456 | - else |
|
| 472 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
| 473 | + $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 474 | + } |
|
| 475 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
| 476 | + $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 477 | + } |
|
| 478 | + } else |
|
| 457 | 479 | { |
| 458 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
| 459 | - $context['icon_sources'][$row['first_icon']] = 'images_url'; |
|
| 460 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
| 461 | - $context['icon_sources'][$row['last_icon']] = 'images_url'; |
|
| 480 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
| 481 | + $context['icon_sources'][$row['first_icon']] = 'images_url'; |
|
| 482 | + } |
|
| 483 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
| 484 | + $context['icon_sources'][$row['last_icon']] = 'images_url'; |
|
| 485 | + } |
|
| 462 | 486 | } |
| 463 | 487 | |
| 464 | - if (!empty($board_info['recycle'])) |
|
| 465 | - $row['first_icon'] = 'recycled'; |
|
| 488 | + if (!empty($board_info['recycle'])) { |
|
| 489 | + $row['first_icon'] = 'recycled'; |
|
| 490 | + } |
|
| 466 | 491 | |
| 467 | 492 | // Is this topic pending approval, or does it have any posts pending approval? |
| 468 | - if ($context['can_approve_posts'] && $row['unapproved_posts']) |
|
| 469 | - $colorClass .= (!$row['approved'] ? ' approvetopic' : ' approvepost'); |
|
| 493 | + if ($context['can_approve_posts'] && $row['unapproved_posts']) { |
|
| 494 | + $colorClass .= (!$row['approved'] ? ' approvetopic' : ' approvepost'); |
|
| 495 | + } |
|
| 470 | 496 | |
| 471 | 497 | // Sticky topics should get a different color, too. |
| 472 | - if ($row['is_sticky']) |
|
| 473 | - $colorClass .= ' sticky'; |
|
| 498 | + if ($row['is_sticky']) { |
|
| 499 | + $colorClass .= ' sticky'; |
|
| 500 | + } |
|
| 474 | 501 | |
| 475 | 502 | // Locked topics get special treatment as well. |
| 476 | - if ($row['locked']) |
|
| 477 | - $colorClass .= ' locked'; |
|
| 503 | + if ($row['locked']) { |
|
| 504 | + $colorClass .= ' locked'; |
|
| 505 | + } |
|
| 478 | 506 | |
| 479 | 507 | // 'Print' the topic info. |
| 480 | 508 | $context['topics'][$row['id_topic']] = array_merge($row, array( |
@@ -555,8 +583,9 @@ discard block |
||
| 555 | 583 | $smcFunc['db_free_result']($result); |
| 556 | 584 | |
| 557 | 585 | // Fix the sequence of topics if they were retrieved in the wrong order. (for speed reasons...) |
| 558 | - if ($fake_ascending) |
|
| 559 | - $context['topics'] = array_reverse($context['topics'], true); |
|
| 586 | + if ($fake_ascending) { |
|
| 587 | + $context['topics'] = array_reverse($context['topics'], true); |
|
| 588 | + } |
|
| 560 | 589 | } |
| 561 | 590 | |
| 562 | 591 | $context['jump_to'] = array( |
@@ -579,9 +608,9 @@ discard block |
||
| 579 | 608 | // Can we restore topics? |
| 580 | 609 | $context['can_restore'] = allowedTo('move_any') && !empty($board_info['recycle']); |
| 581 | 610 | |
| 582 | - if ($user_info['is_admin'] || $modSettings['topic_move_any']) |
|
| 583 | - $context['can_move_any'] = true; |
|
| 584 | - else |
|
| 611 | + if ($user_info['is_admin'] || $modSettings['topic_move_any']) { |
|
| 612 | + $context['can_move_any'] = true; |
|
| 613 | + } else |
|
| 585 | 614 | { |
| 586 | 615 | // We'll use this in a minute |
| 587 | 616 | $boards_allowed = boardsAllowedTo('post_new'); |
@@ -608,11 +637,13 @@ discard block |
||
| 608 | 637 | } |
| 609 | 638 | |
| 610 | 639 | // Can we use quick moderation checkboxes? |
| 611 | - if ($options['display_quick_mod'] == 1) |
|
| 612 | - $context['can_quick_mod'] = $context['user']['is_logged'] || $context['can_approve'] || $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'] || $context['can_merge'] || $context['can_restore']; |
|
| 640 | + if ($options['display_quick_mod'] == 1) { |
|
| 641 | + $context['can_quick_mod'] = $context['user']['is_logged'] || $context['can_approve'] || $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'] || $context['can_merge'] || $context['can_restore']; |
|
| 642 | + } |
|
| 613 | 643 | // Or the icons? |
| 614 | - else |
|
| 615 | - $context['can_quick_mod'] = $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move']; |
|
| 644 | + else { |
|
| 645 | + $context['can_quick_mod'] = $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move']; |
|
| 646 | + } |
|
| 616 | 647 | } |
| 617 | 648 | |
| 618 | 649 | if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1) |
@@ -646,13 +677,15 @@ discard block |
||
| 646 | 677 | ); |
| 647 | 678 | |
| 648 | 679 | // We've seen all these boards now! |
| 649 | - foreach ($board_info['parent_boards'] as $k => $dummy) |
|
| 650 | - if (isset($_SESSION['topicseen_cache'][$k])) |
|
| 680 | + foreach ($board_info['parent_boards'] as $k => $dummy) { |
|
| 681 | + if (isset($_SESSION['topicseen_cache'][$k])) |
|
| 651 | 682 | unset($_SESSION['topicseen_cache'][$k]); |
| 683 | + } |
|
| 652 | 684 | } |
| 653 | 685 | |
| 654 | - if (isset($_SESSION['topicseen_cache'][$board])) |
|
| 655 | - unset($_SESSION['topicseen_cache'][$board]); |
|
| 686 | + if (isset($_SESSION['topicseen_cache'][$board])) { |
|
| 687 | + unset($_SESSION['topicseen_cache'][$board]); |
|
| 688 | + } |
|
| 656 | 689 | |
| 657 | 690 | $request = $smcFunc['db_query']('', ' |
| 658 | 691 | SELECT id_topic, id_board, sent |
@@ -673,8 +706,9 @@ discard block |
||
| 673 | 706 | $context['is_marked_notify'] = true; |
| 674 | 707 | $board_sent = $row['sent']; |
| 675 | 708 | } |
| 676 | - if (!empty($row['id_topic'])) |
|
| 677 | - $context['topics'][$row['id_topic']]['is_watched'] = true; |
|
| 709 | + if (!empty($row['id_topic'])) { |
|
| 710 | + $context['topics'][$row['id_topic']]['is_watched'] = true; |
|
| 711 | + } |
|
| 678 | 712 | } |
| 679 | 713 | $smcFunc['db_free_result']($request); |
| 680 | 714 | |
@@ -698,8 +732,7 @@ discard block |
||
| 698 | 732 | $pref = !empty($pref[$user_info['id']]) ? $pref[$user_info['id']] : array(); |
| 699 | 733 | $pref = isset($pref['board_notify_' . $board]) ? $pref['board_notify_' . $board] : (!empty($pref['board_notify']) ? $pref['board_notify'] : 0); |
| 700 | 734 | $context['board_notification_mode'] = !$context['is_marked_notify'] ? 1 : ($pref & 0x02 ? 3 : ($pref & 0x01 ? 2 : 1)); |
| 701 | - } |
|
| 702 | - else |
|
| 735 | + } else |
|
| 703 | 736 | { |
| 704 | 737 | $context['is_marked_notify'] = false; |
| 705 | 738 | $context['board_notification_mode'] = 1; |
@@ -712,23 +745,27 @@ discard block |
||
| 712 | 745 | $context['becomesUnapproved'] = !empty($_SESSION['becomesUnapproved']) ? true : false; |
| 713 | 746 | |
| 714 | 747 | // Don't want to show this forever... |
| 715 | - if ($context['becomesUnapproved']) |
|
| 716 | - unset($_SESSION['becomesUnapproved']); |
|
| 748 | + if ($context['becomesUnapproved']) { |
|
| 749 | + unset($_SESSION['becomesUnapproved']); |
|
| 750 | + } |
|
| 717 | 751 | |
| 718 | 752 | // Build the message index button array. |
| 719 | 753 | $context['normal_buttons'] = array(); |
| 720 | 754 | |
| 721 | - if ($context['can_post_new']) |
|
| 722 | - $context['normal_buttons']['new_topic'] = array('text' => 'new_topic', 'image' => 'new_topic.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true); |
|
| 755 | + if ($context['can_post_new']) { |
|
| 756 | + $context['normal_buttons']['new_topic'] = array('text' => 'new_topic', 'image' => 'new_topic.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true); |
|
| 757 | + } |
|
| 723 | 758 | |
| 724 | - if ($context['can_post_poll']) |
|
| 725 | - $context['normal_buttons']['post_poll'] = array('text' => 'new_poll', 'image' => 'new_poll.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll'); |
|
| 759 | + if ($context['can_post_poll']) { |
|
| 760 | + $context['normal_buttons']['post_poll'] = array('text' => 'new_poll', 'image' => 'new_poll.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll'); |
|
| 761 | + } |
|
| 726 | 762 | |
| 727 | - if ($context['user']['is_logged']) |
|
| 728 | - $context['normal_buttons']['markread'] = array('text' => 'mark_read_short', 'image' => 'markread.png', 'lang' => true, 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
| 763 | + if ($context['user']['is_logged']) { |
|
| 764 | + $context['normal_buttons']['markread'] = array('text' => 'mark_read_short', 'image' => 'markread.png', 'lang' => true, 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
| 765 | + } |
|
| 729 | 766 | |
| 730 | - if ($context['can_mark_notify']) |
|
| 731 | - $context['normal_buttons']['notify'] = array( |
|
| 767 | + if ($context['can_mark_notify']) { |
|
| 768 | + $context['normal_buttons']['notify'] = array( |
|
| 732 | 769 | 'lang' => true, |
| 733 | 770 | 'text' => 'notify_board_' . $context['board_notification_mode'], |
| 734 | 771 | 'sub_buttons' => array( |
@@ -746,6 +783,7 @@ discard block |
||
| 746 | 783 | ), |
| 747 | 784 | ), |
| 748 | 785 | ); |
| 786 | + } |
|
| 749 | 787 | |
| 750 | 788 | // Javascript for inline editing. |
| 751 | 789 | loadJavaScriptFile('topic.js', array('defer' => false, 'minimize' => true), 'smf_topic'); |
@@ -767,18 +805,21 @@ discard block |
||
| 767 | 805 | checkSession('request'); |
| 768 | 806 | |
| 769 | 807 | // Lets go straight to the restore area. |
| 770 | - if (isset($_REQUEST['qaction']) && $_REQUEST['qaction'] == 'restore' && !empty($_REQUEST['topics'])) |
|
| 771 | - redirectexit('action=restoretopic;topics=' . implode(',', $_REQUEST['topics']) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 808 | + if (isset($_REQUEST['qaction']) && $_REQUEST['qaction'] == 'restore' && !empty($_REQUEST['topics'])) { |
|
| 809 | + redirectexit('action=restoretopic;topics=' . implode(',', $_REQUEST['topics']) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 810 | + } |
|
| 772 | 811 | |
| 773 | - if (isset($_SESSION['topicseen_cache'])) |
|
| 774 | - $_SESSION['topicseen_cache'] = array(); |
|
| 812 | + if (isset($_SESSION['topicseen_cache'])) { |
|
| 813 | + $_SESSION['topicseen_cache'] = array(); |
|
| 814 | + } |
|
| 775 | 815 | |
| 776 | 816 | // This is going to be needed to send off the notifications and for updateLastMessages(). |
| 777 | 817 | require_once($sourcedir . '/Subs-Post.php'); |
| 778 | 818 | |
| 779 | 819 | // Remember the last board they moved things to. |
| 780 | - if (isset($_REQUEST['move_to'])) |
|
| 781 | - $_SESSION['move_to_topic'] = $_REQUEST['move_to']; |
|
| 820 | + if (isset($_REQUEST['move_to'])) { |
|
| 821 | + $_SESSION['move_to_topic'] = $_REQUEST['move_to']; |
|
| 822 | + } |
|
| 782 | 823 | |
| 783 | 824 | // Only a few possible actions. |
| 784 | 825 | $possibleActions = array(); |
@@ -798,8 +839,7 @@ discard block |
||
| 798 | 839 | ); |
| 799 | 840 | |
| 800 | 841 | $redirect_url = 'board=' . $board . '.' . $_REQUEST['start']; |
| 801 | - } |
|
| 802 | - else |
|
| 842 | + } else |
|
| 803 | 843 | { |
| 804 | 844 | /** |
| 805 | 845 | * @todo Ugly. There's no getting around this, is there? |
@@ -817,8 +857,7 @@ discard block |
||
| 817 | 857 | if (!empty($board)) |
| 818 | 858 | { |
| 819 | 859 | $boards_can['post_new'] = array_diff(boardsAllowedTo('post_new'), array($board)); |
| 820 | - } |
|
| 821 | - else |
|
| 860 | + } else |
|
| 822 | 861 | { |
| 823 | 862 | $boards_can['post_new'] = boardsAllowedTo('post_new'); |
| 824 | 863 | } |
@@ -829,55 +868,67 @@ discard block |
||
| 829 | 868 | } |
| 830 | 869 | } |
| 831 | 870 | |
| 832 | - if (!$user_info['is_guest']) |
|
| 833 | - $possibleActions[] = 'markread'; |
|
| 834 | - if (!empty($boards_can['make_sticky'])) |
|
| 835 | - $possibleActions[] = 'sticky'; |
|
| 836 | - if (!empty($boards_can['move_any']) || !empty($boards_can['move_own'])) |
|
| 837 | - $possibleActions[] = 'move'; |
|
| 838 | - if (!empty($boards_can['remove_any']) || !empty($boards_can['remove_own'])) |
|
| 839 | - $possibleActions[] = 'remove'; |
|
| 840 | - if (!empty($boards_can['lock_any']) || !empty($boards_can['lock_own'])) |
|
| 841 | - $possibleActions[] = 'lock'; |
|
| 842 | - if (!empty($boards_can['merge_any'])) |
|
| 843 | - $possibleActions[] = 'merge'; |
|
| 844 | - if (!empty($boards_can['approve_posts'])) |
|
| 845 | - $possibleActions[] = 'approve'; |
|
| 871 | + if (!$user_info['is_guest']) { |
|
| 872 | + $possibleActions[] = 'markread'; |
|
| 873 | + } |
|
| 874 | + if (!empty($boards_can['make_sticky'])) { |
|
| 875 | + $possibleActions[] = 'sticky'; |
|
| 876 | + } |
|
| 877 | + if (!empty($boards_can['move_any']) || !empty($boards_can['move_own'])) { |
|
| 878 | + $possibleActions[] = 'move'; |
|
| 879 | + } |
|
| 880 | + if (!empty($boards_can['remove_any']) || !empty($boards_can['remove_own'])) { |
|
| 881 | + $possibleActions[] = 'remove'; |
|
| 882 | + } |
|
| 883 | + if (!empty($boards_can['lock_any']) || !empty($boards_can['lock_own'])) { |
|
| 884 | + $possibleActions[] = 'lock'; |
|
| 885 | + } |
|
| 886 | + if (!empty($boards_can['merge_any'])) { |
|
| 887 | + $possibleActions[] = 'merge'; |
|
| 888 | + } |
|
| 889 | + if (!empty($boards_can['approve_posts'])) { |
|
| 890 | + $possibleActions[] = 'approve'; |
|
| 891 | + } |
|
| 846 | 892 | |
| 847 | 893 | // Two methods: $_REQUEST['actions'] (id_topic => action), and $_REQUEST['topics'] and $_REQUEST['qaction']. |
| 848 | 894 | // (if action is 'move', $_REQUEST['move_to'] or $_REQUEST['move_tos'][$topic] is used.) |
| 849 | 895 | if (!empty($_REQUEST['topics'])) |
| 850 | 896 | { |
| 851 | 897 | // If the action isn't valid, just quit now. |
| 852 | - if (empty($_REQUEST['qaction']) || !in_array($_REQUEST['qaction'], $possibleActions)) |
|
| 853 | - redirectexit($redirect_url); |
|
| 898 | + if (empty($_REQUEST['qaction']) || !in_array($_REQUEST['qaction'], $possibleActions)) { |
|
| 899 | + redirectexit($redirect_url); |
|
| 900 | + } |
|
| 854 | 901 | |
| 855 | 902 | // Merge requires all topics as one parameter and can be done at once. |
| 856 | 903 | if ($_REQUEST['qaction'] == 'merge') |
| 857 | 904 | { |
| 858 | 905 | // Merge requires at least two topics. |
| 859 | - if (empty($_REQUEST['topics']) || count($_REQUEST['topics']) < 2) |
|
| 860 | - redirectexit($redirect_url); |
|
| 906 | + if (empty($_REQUEST['topics']) || count($_REQUEST['topics']) < 2) { |
|
| 907 | + redirectexit($redirect_url); |
|
| 908 | + } |
|
| 861 | 909 | |
| 862 | 910 | require_once($sourcedir . '/SplitTopics.php'); |
| 863 | 911 | return MergeExecute($_REQUEST['topics']); |
| 864 | 912 | } |
| 865 | 913 | |
| 866 | 914 | // Just convert to the other method, to make it easier. |
| 867 | - foreach ($_REQUEST['topics'] as $topic) |
|
| 868 | - $_REQUEST['actions'][(int) $topic] = $_REQUEST['qaction']; |
|
| 915 | + foreach ($_REQUEST['topics'] as $topic) { |
|
| 916 | + $_REQUEST['actions'][(int) $topic] = $_REQUEST['qaction']; |
|
| 917 | + } |
|
| 869 | 918 | } |
| 870 | 919 | |
| 871 | 920 | // Weird... how'd you get here? |
| 872 | - if (empty($_REQUEST['actions'])) |
|
| 873 | - redirectexit($redirect_url); |
|
| 921 | + if (empty($_REQUEST['actions'])) { |
|
| 922 | + redirectexit($redirect_url); |
|
| 923 | + } |
|
| 874 | 924 | |
| 875 | 925 | // Validate each action. |
| 876 | 926 | $temp = array(); |
| 877 | 927 | foreach ($_REQUEST['actions'] as $topic => $action) |
| 878 | 928 | { |
| 879 | - if (in_array($action, $possibleActions)) |
|
| 880 | - $temp[(int) $topic] = $action; |
|
| 929 | + if (in_array($action, $possibleActions)) { |
|
| 930 | + $temp[(int) $topic] = $action; |
|
| 931 | + } |
|
| 881 | 932 | } |
| 882 | 933 | $_REQUEST['actions'] = $temp; |
| 883 | 934 | |
@@ -898,27 +949,31 @@ discard block |
||
| 898 | 949 | { |
| 899 | 950 | if (!empty($board)) |
| 900 | 951 | { |
| 901 | - if ($row['id_board'] != $board || ($modSettings['postmod_active'] && !$row['approved'] && !allowedTo('approve_posts'))) |
|
| 902 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 903 | - } |
|
| 904 | - else |
|
| 952 | + if ($row['id_board'] != $board || ($modSettings['postmod_active'] && !$row['approved'] && !allowedTo('approve_posts'))) { |
|
| 953 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 954 | + } |
|
| 955 | + } else |
|
| 905 | 956 | { |
| 906 | 957 | // Don't allow them to act on unapproved posts they can't see... |
| 907 | - if ($modSettings['postmod_active'] && !$row['approved'] && !in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])) |
|
| 908 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 958 | + if ($modSettings['postmod_active'] && !$row['approved'] && !in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])) { |
|
| 959 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 960 | + } |
|
| 909 | 961 | // Goodness, this is fun. We need to validate the action. |
| 910 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'sticky' && !in_array(0, $boards_can['make_sticky']) && !in_array($row['id_board'], $boards_can['make_sticky'])) |
|
| 911 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 912 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'move' && !in_array(0, $boards_can['move_any']) && !in_array($row['id_board'], $boards_can['move_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['move_own']) && !in_array($row['id_board'], $boards_can['move_own'])))) |
|
| 913 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 914 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'remove' && !in_array(0, $boards_can['remove_any']) && !in_array($row['id_board'], $boards_can['remove_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['remove_own']) && !in_array($row['id_board'], $boards_can['remove_own'])))) |
|
| 915 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 962 | + elseif ($_REQUEST['actions'][$row['id_topic']] == 'sticky' && !in_array(0, $boards_can['make_sticky']) && !in_array($row['id_board'], $boards_can['make_sticky'])) { |
|
| 963 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 964 | + } elseif ($_REQUEST['actions'][$row['id_topic']] == 'move' && !in_array(0, $boards_can['move_any']) && !in_array($row['id_board'], $boards_can['move_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['move_own']) && !in_array($row['id_board'], $boards_can['move_own'])))) { |
|
| 965 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 966 | + } elseif ($_REQUEST['actions'][$row['id_topic']] == 'remove' && !in_array(0, $boards_can['remove_any']) && !in_array($row['id_board'], $boards_can['remove_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['remove_own']) && !in_array($row['id_board'], $boards_can['remove_own'])))) { |
|
| 967 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 968 | + } |
|
| 916 | 969 | // @todo $locked is not set, what are you trying to do? (taking the change it is supposed to be $row['locked']) |
| 917 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'lock' && !in_array(0, $boards_can['lock_any']) && !in_array($row['id_board'], $boards_can['lock_any']) && ($row['id_member_started'] != $user_info['id'] || $row['locked'] == 1 || (!in_array(0, $boards_can['lock_own']) && !in_array($row['id_board'], $boards_can['lock_own'])))) |
|
| 918 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 970 | + elseif ($_REQUEST['actions'][$row['id_topic']] == 'lock' && !in_array(0, $boards_can['lock_any']) && !in_array($row['id_board'], $boards_can['lock_any']) && ($row['id_member_started'] != $user_info['id'] || $row['locked'] == 1 || (!in_array(0, $boards_can['lock_own']) && !in_array($row['id_board'], $boards_can['lock_own'])))) { |
|
| 971 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 972 | + } |
|
| 919 | 973 | // If the topic is approved then you need permission to approve the posts within. |
| 920 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'approve' && (!$row['unapproved_posts'] || (!in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])))) |
|
| 921 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 974 | + elseif ($_REQUEST['actions'][$row['id_topic']] == 'approve' && (!$row['unapproved_posts'] || (!in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])))) { |
|
| 975 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 976 | + } |
|
| 922 | 977 | } |
| 923 | 978 | } |
| 924 | 979 | $smcFunc['db_free_result']($request); |
@@ -936,11 +991,11 @@ discard block |
||
| 936 | 991 | { |
| 937 | 992 | $topic = (int) $topic; |
| 938 | 993 | |
| 939 | - if ($action == 'markread') |
|
| 940 | - $markCache[] = $topic; |
|
| 941 | - elseif ($action == 'sticky') |
|
| 942 | - $stickyCache[] = $topic; |
|
| 943 | - elseif ($action == 'move') |
|
| 994 | + if ($action == 'markread') { |
|
| 995 | + $markCache[] = $topic; |
|
| 996 | + } elseif ($action == 'sticky') { |
|
| 997 | + $stickyCache[] = $topic; |
|
| 998 | + } elseif ($action == 'move') |
|
| 944 | 999 | { |
| 945 | 1000 | require_once($sourcedir . '/MoveTopic.php'); |
| 946 | 1001 | moveTopicConcurrence(); |
@@ -948,23 +1003,25 @@ discard block |
||
| 948 | 1003 | // $moveCache[0] is the topic, $moveCache[1] is the board to move to. |
| 949 | 1004 | $moveCache[1][$topic] = (int) (isset($_REQUEST['move_tos'][$topic]) ? $_REQUEST['move_tos'][$topic] : $_REQUEST['move_to']); |
| 950 | 1005 | |
| 951 | - if (empty($moveCache[1][$topic])) |
|
| 952 | - continue; |
|
| 1006 | + if (empty($moveCache[1][$topic])) { |
|
| 1007 | + continue; |
|
| 1008 | + } |
|
| 953 | 1009 | |
| 954 | 1010 | $moveCache[0][] = $topic; |
| 1011 | + } elseif ($action == 'remove') { |
|
| 1012 | + $removeCache[] = $topic; |
|
| 1013 | + } elseif ($action == 'lock') { |
|
| 1014 | + $lockCache[] = $topic; |
|
| 1015 | + } elseif ($action == 'approve') { |
|
| 1016 | + $approveCache[] = $topic; |
|
| 955 | 1017 | } |
| 956 | - elseif ($action == 'remove') |
|
| 957 | - $removeCache[] = $topic; |
|
| 958 | - elseif ($action == 'lock') |
|
| 959 | - $lockCache[] = $topic; |
|
| 960 | - elseif ($action == 'approve') |
|
| 961 | - $approveCache[] = $topic; |
|
| 962 | 1018 | } |
| 963 | 1019 | |
| 964 | - if (empty($board)) |
|
| 965 | - $affectedBoards = array(); |
|
| 966 | - else |
|
| 967 | - $affectedBoards = array($board => array(0, 0)); |
|
| 1020 | + if (empty($board)) { |
|
| 1021 | + $affectedBoards = array(); |
|
| 1022 | + } else { |
|
| 1023 | + $affectedBoards = array($board => array(0, 0)); |
|
| 1024 | + } |
|
| 968 | 1025 | |
| 969 | 1026 | // Do all the stickies... |
| 970 | 1027 | if (!empty($stickyCache)) |
@@ -1024,14 +1081,16 @@ discard block |
||
| 1024 | 1081 | { |
| 1025 | 1082 | $to = $moveCache[1][$row['id_topic']]; |
| 1026 | 1083 | |
| 1027 | - if (empty($to)) |
|
| 1028 | - continue; |
|
| 1084 | + if (empty($to)) { |
|
| 1085 | + continue; |
|
| 1086 | + } |
|
| 1029 | 1087 | |
| 1030 | 1088 | // Does this topic's board count the posts or not? |
| 1031 | 1089 | $countPosts[$row['id_topic']] = empty($row['count_posts']); |
| 1032 | 1090 | |
| 1033 | - if (!isset($moveTos[$to])) |
|
| 1034 | - $moveTos[$to] = array(); |
|
| 1091 | + if (!isset($moveTos[$to])) { |
|
| 1092 | + $moveTos[$to] = array(); |
|
| 1093 | + } |
|
| 1035 | 1094 | |
| 1036 | 1095 | $moveTos[$to][] = $row['id_topic']; |
| 1037 | 1096 | |
@@ -1045,8 +1104,9 @@ discard block |
||
| 1045 | 1104 | require_once($sourcedir . '/MoveTopic.php'); |
| 1046 | 1105 | |
| 1047 | 1106 | // Do the actual moves... |
| 1048 | - foreach ($moveTos as $to => $topics) |
|
| 1049 | - moveTopics($topics, $to); |
|
| 1107 | + foreach ($moveTos as $to => $topics) { |
|
| 1108 | + moveTopics($topics, $to); |
|
| 1109 | + } |
|
| 1050 | 1110 | |
| 1051 | 1111 | // Does the post counts need to be updated? |
| 1052 | 1112 | if (!empty($moveTos)) |
@@ -1095,20 +1155,23 @@ discard block |
||
| 1095 | 1155 | |
| 1096 | 1156 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1097 | 1157 | { |
| 1098 | - if (!isset($members[$row['id_member']])) |
|
| 1099 | - $members[$row['id_member']] = 0; |
|
| 1158 | + if (!isset($members[$row['id_member']])) { |
|
| 1159 | + $members[$row['id_member']] = 0; |
|
| 1160 | + } |
|
| 1100 | 1161 | |
| 1101 | - if ($topicRecounts[$row['id_topic']] === '+') |
|
| 1102 | - $members[$row['id_member']] += 1; |
|
| 1103 | - else |
|
| 1104 | - $members[$row['id_member']] -= 1; |
|
| 1162 | + if ($topicRecounts[$row['id_topic']] === '+') { |
|
| 1163 | + $members[$row['id_member']] += 1; |
|
| 1164 | + } else { |
|
| 1165 | + $members[$row['id_member']] -= 1; |
|
| 1166 | + } |
|
| 1105 | 1167 | } |
| 1106 | 1168 | |
| 1107 | 1169 | $smcFunc['db_free_result']($request); |
| 1108 | 1170 | |
| 1109 | 1171 | // And now update them member's post counts |
| 1110 | - foreach ($members as $id_member => $post_adj) |
|
| 1111 | - updateMemberData($id_member, array('posts' => 'posts + ' . $post_adj)); |
|
| 1172 | + foreach ($members as $id_member => $post_adj) { |
|
| 1173 | + updateMemberData($id_member, array('posts' => 'posts + ' . $post_adj)); |
|
| 1174 | + } |
|
| 1112 | 1175 | } |
| 1113 | 1176 | } |
| 1114 | 1177 | } |
@@ -1187,8 +1250,9 @@ discard block |
||
| 1187 | 1250 | approveTopics($approveCache); |
| 1188 | 1251 | |
| 1189 | 1252 | // Time for some logging! |
| 1190 | - foreach ($approveCache as $topic) |
|
| 1191 | - logAction('approve_topic', array('topic' => $topic, 'member' => $approveCacheMembers[$topic])); |
|
| 1253 | + foreach ($approveCache as $topic) { |
|
| 1254 | + logAction('approve_topic', array('topic' => $topic, 'member' => $approveCacheMembers[$topic])); |
|
| 1255 | + } |
|
| 1192 | 1256 | } |
| 1193 | 1257 | } |
| 1194 | 1258 | |
@@ -1223,8 +1287,7 @@ discard block |
||
| 1223 | 1287 | $lockStatus[$row['id_topic']] = empty($row['locked']); |
| 1224 | 1288 | } |
| 1225 | 1289 | $smcFunc['db_free_result']($result); |
| 1226 | - } |
|
| 1227 | - else |
|
| 1290 | + } else |
|
| 1228 | 1291 | { |
| 1229 | 1292 | $result = $smcFunc['db_query']('', ' |
| 1230 | 1293 | SELECT id_topic, locked, id_board |
@@ -1274,13 +1337,15 @@ discard block |
||
| 1274 | 1337 | ) |
| 1275 | 1338 | ); |
| 1276 | 1339 | $logged_topics = array(); |
| 1277 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1278 | - $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
| 1340 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1341 | + $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
| 1342 | + } |
|
| 1279 | 1343 | $smcFunc['db_free_result']($request); |
| 1280 | 1344 | |
| 1281 | 1345 | $markArray = array(); |
| 1282 | - foreach ($markCache as $topic) |
|
| 1283 | - $markArray[] = array($modSettings['maxMsgID'], $user_info['id'], $topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
| 1346 | + foreach ($markCache as $topic) { |
|
| 1347 | + $markArray[] = array($modSettings['maxMsgID'], $user_info['id'], $topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
| 1348 | + } |
|
| 1284 | 1349 | |
| 1285 | 1350 | $smcFunc['db_insert']('replace', |
| 1286 | 1351 | '{db_prefix}log_topics', |
@@ -1293,8 +1358,9 @@ discard block |
||
| 1293 | 1358 | foreach ($moveCache as $topic) |
| 1294 | 1359 | { |
| 1295 | 1360 | // Didn't actually move anything! |
| 1296 | - if (!isset($topic[0])) |
|
| 1297 | - break; |
|
| 1361 | + if (!isset($topic[0])) { |
|
| 1362 | + break; |
|
| 1363 | + } |
|
| 1298 | 1364 | |
| 1299 | 1365 | logAction('move', array('topic' => $topic[0], 'board_from' => $topic[1], 'board_to' => $topic[2])); |
| 1300 | 1366 | sendNotifications($topic[0], 'move'); |
@@ -1316,8 +1382,9 @@ discard block |
||
| 1316 | 1382 | 'calendar_updated' => time(), |
| 1317 | 1383 | )); |
| 1318 | 1384 | |
| 1319 | - if (!empty($affectedBoards)) |
|
| 1320 | - updateLastMessages(array_keys($affectedBoards)); |
|
| 1385 | + if (!empty($affectedBoards)) { |
|
| 1386 | + updateLastMessages(array_keys($affectedBoards)); |
|
| 1387 | + } |
|
| 1321 | 1388 | |
| 1322 | 1389 | redirectexit($redirect_url); |
| 1323 | 1390 | } |