@@ -18,11 +18,12 @@ discard block |
||
| 18 | 18 | global $context, $txt, $scripturl; |
| 19 | 19 | |
| 20 | 20 | // Let them know the action was a success. |
| 21 | - if (!empty($context['report_post_action'])) |
|
| 22 | - echo ' |
|
| 21 | + if (!empty($context['report_post_action'])) { |
|
| 22 | + echo ' |
|
| 23 | 23 | <div class="infobox"> |
| 24 | 24 | ', $txt['report_action_' . $context['report_post_action']], ' |
| 25 | 25 | </div>'; |
| 26 | + } |
|
| 26 | 27 | |
| 27 | 28 | echo ' |
| 28 | 29 | <form id="reported_posts" action="', $scripturl, '?action=moderate;area=reportedposts;sa=show', $context['view_closed'] ? ';closed' : '', ';start=', $context['start'], '" method="post" accept-charset="', $context['character_set'], '"> |
@@ -52,8 +53,9 @@ discard block |
||
| 52 | 53 | |
| 53 | 54 | // Prepare the comments... |
| 54 | 55 | $comments = array(); |
| 55 | - foreach ($report['comments'] as $comment) |
|
| 56 | - $comments[$comment['member']['id']] = $comment['member']['link']; |
|
| 56 | + foreach ($report['comments'] as $comment) { |
|
| 57 | + $comments[$comment['member']['id']] = $comment['member']['link']; |
|
| 58 | + } |
|
| 57 | 59 | |
| 58 | 60 | echo ' |
| 59 | 61 | ', $txt['mc_reportedp_reported_by'], ': ', implode(', ', $comments), ' |
@@ -69,18 +71,21 @@ discard block |
||
| 69 | 71 | <li><a href="', $scripturl, '?action=moderate;area=reportedposts;sa=handle;closed=', (int) !$report['closed'], ';rid=', $report['id'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], ';', $context['mod-report-closed_token_var'], '=', $context['mod-report-closed_token'], '">', $close_button, '</a></li>'; |
| 70 | 72 | |
| 71 | 73 | // Delete message button. |
| 72 | - if (!$report['closed'] && (is_array($context['report_remove_any_boards']) && in_array($report['topic']['id_board'], $context['report_remove_any_boards']))) |
|
| 73 | - echo ' |
|
| 74 | + if (!$report['closed'] && (is_array($context['report_remove_any_boards']) && in_array($report['topic']['id_board'], $context['report_remove_any_boards']))) { |
|
| 75 | + echo ' |
|
| 74 | 76 | <li><a href="', $scripturl, '?action=deletemsg;topic=', $report['topic']['id'], '.0;msg=', $report['topic']['id_msg'], ';modcenter;', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['mc_reportedp_delete_confirm'], '" class="you_sure">', $delete_button, '</a></li>'; |
| 77 | + } |
|
| 75 | 78 | |
| 76 | 79 | // Ban this user button. |
| 77 | - if (!$report['closed'] && !empty($context['report_manage_bans'])) |
|
| 78 | - echo ' |
|
| 80 | + if (!$report['closed'] && !empty($context['report_manage_bans'])) { |
|
| 81 | + echo ' |
|
| 79 | 82 | <li><a href="', $scripturl, '?action=admin;area=ban;sa=add', (!empty($report['author']['id']) ? ';u=' . $report['author']['id'] : ';msg=' . $report['topic']['id_msg']), ';', $context['session_var'], '=', $context['session_id'], '">', $ban_button, '</a></li>'; |
| 83 | + } |
|
| 80 | 84 | |
| 81 | - if (!$context['view_closed']) |
|
| 82 | - echo ' |
|
| 85 | + if (!$context['view_closed']) { |
|
| 86 | + echo ' |
|
| 83 | 87 | <li><input type="checkbox" name="close[]" value="' . $report['id'] . '"></li>'; |
| 88 | + } |
|
| 84 | 89 | |
| 85 | 90 | echo ' |
| 86 | 91 | </ul> |
@@ -88,18 +93,20 @@ discard block |
||
| 88 | 93 | } |
| 89 | 94 | |
| 90 | 95 | // Were none found? |
| 91 | - if (empty($context['reports'])) |
|
| 92 | - echo ' |
|
| 96 | + if (empty($context['reports'])) { |
|
| 97 | + echo ' |
|
| 93 | 98 | <div class="windowbg"> |
| 94 | 99 | <p class="centertext">', $txt['mc_reportedp_none_found'], '</p> |
| 95 | 100 | </div>'; |
| 101 | + } |
|
| 96 | 102 | |
| 97 | 103 | echo ' |
| 98 | 104 | <div class="pagesection">'; |
| 99 | 105 | |
| 100 | - if (!empty($context['total_reports']) && $context['total_reports'] >= $context['reports_how_many']) |
|
| 101 | - echo ' |
|
| 106 | + if (!empty($context['total_reports']) && $context['total_reports'] >= $context['reports_how_many']) { |
|
| 107 | + echo ' |
|
| 102 | 108 | <div class="pagelinks floatleft">' . $context['page_index'] . '</div>'; |
| 109 | + } |
|
| 103 | 110 | |
| 104 | 111 | echo ' |
| 105 | 112 | <div class="floatright">', !$context['view_closed'] ? ' |
@@ -130,18 +137,20 @@ discard block |
||
| 130 | 137 | <div class="modbox"> |
| 131 | 138 | <ul>'; |
| 132 | 139 | |
| 133 | - foreach ($context['reported_posts'] as $report) |
|
| 134 | - echo ' |
|
| 140 | + foreach ($context['reported_posts'] as $report) { |
|
| 141 | + echo ' |
|
| 135 | 142 | <li class="smalltext"> |
| 136 | 143 | <a href="', $report['report_href'], '">', $report['subject'], '</a> ', $txt['mc_reportedp_by'], ' ', $report['author']['link'], ' |
| 137 | 144 | </li>'; |
| 145 | + } |
|
| 138 | 146 | |
| 139 | 147 | // Don't have any watched users right now? |
| 140 | - if (empty($context['reported_posts'])) |
|
| 141 | - echo ' |
|
| 148 | + if (empty($context['reported_posts'])) { |
|
| 149 | + echo ' |
|
| 142 | 150 | <li> |
| 143 | 151 | <strong class="smalltext">', $txt['mc_recent_reports_none'], '</strong> |
| 144 | 152 | </li>'; |
| 153 | + } |
|
| 145 | 154 | |
| 146 | 155 | echo ' |
| 147 | 156 | </ul> |
@@ -189,11 +198,12 @@ discard block |
||
| 189 | 198 | global $context, $scripturl, $txt; |
| 190 | 199 | |
| 191 | 200 | // Let them know the action was a success. |
| 192 | - if (!empty($context['report_post_action'])) |
|
| 193 | - echo ' |
|
| 201 | + if (!empty($context['report_post_action'])) { |
|
| 202 | + echo ' |
|
| 194 | 203 | <div class="infobox"> |
| 195 | 204 | ', $txt['report_action_' . $context['report_post_action']], ' |
| 196 | 205 | </div>'; |
| 206 | + } |
|
| 197 | 207 | |
| 198 | 208 | echo ' |
| 199 | 209 | <div id="modcenter"> |
@@ -229,14 +239,15 @@ discard block |
||
| 229 | 239 | <h3 class="catbg">', $txt['mc_modreport_whoreported_title'], '</h3> |
| 230 | 240 | </div>'; |
| 231 | 241 | |
| 232 | - foreach ($context['report']['comments'] as $comment) |
|
| 233 | - echo ' |
|
| 242 | + foreach ($context['report']['comments'] as $comment) { |
|
| 243 | + echo ' |
|
| 234 | 244 | <div class="windowbg"> |
| 235 | 245 | <p class="smalltext"> |
| 236 | 246 | ', sprintf($txt['mc_modreport_whoreported_data'], $comment['member']['link'] . (empty($comment['member']['id']) && !empty($comment['member']['ip']) ? ' (' . $comment['member']['ip'] . ')' : ''), $comment['time']), ' |
| 237 | 247 | </p> |
| 238 | 248 | <p>', $comment['message'], '</p> |
| 239 | 249 | </div>'; |
| 250 | + } |
|
| 240 | 251 | |
| 241 | 252 | echo ' |
| 242 | 253 | <br> |
@@ -245,11 +256,12 @@ discard block |
||
| 245 | 256 | </div> |
| 246 | 257 | <div>'; |
| 247 | 258 | |
| 248 | - if (empty($context['report']['mod_comments'])) |
|
| 249 | - echo ' |
|
| 259 | + if (empty($context['report']['mod_comments'])) { |
|
| 260 | + echo ' |
|
| 250 | 261 | <div class="information"> |
| 251 | 262 | <p class="centertext">', $txt['mc_modreport_no_mod_comment'], '</p> |
| 252 | 263 | </div>'; |
| 264 | + } |
|
| 253 | 265 | |
| 254 | 266 | foreach ($context['report']['mod_comments'] as $comment) |
| 255 | 267 | { |
@@ -335,18 +347,20 @@ discard block |
||
| 335 | 347 | <div class="modbox"> |
| 336 | 348 | <ul>'; |
| 337 | 349 | |
| 338 | - foreach ($context['reported_members'] as $report) |
|
| 339 | - echo ' |
|
| 350 | + foreach ($context['reported_members'] as $report) { |
|
| 351 | + echo ' |
|
| 340 | 352 | <li class="smalltext"> |
| 341 | 353 | <a href="', $report['report_href'], '">', $report['user_name'], '</a> |
| 342 | 354 | </li>'; |
| 355 | + } |
|
| 343 | 356 | |
| 344 | 357 | // Don't have any reported members right now? |
| 345 | - if (empty($context['reported_members'])) |
|
| 346 | - echo ' |
|
| 358 | + if (empty($context['reported_members'])) { |
|
| 359 | + echo ' |
|
| 347 | 360 | <li> |
| 348 | 361 | <strong class="smalltext">', $txt['mc_recent_reports_none'], '</strong> |
| 349 | 362 | </li>'; |
| 363 | + } |
|
| 350 | 364 | |
| 351 | 365 | echo ' |
| 352 | 366 | </ul> |
@@ -394,11 +408,12 @@ discard block |
||
| 394 | 408 | global $context, $txt, $scripturl; |
| 395 | 409 | |
| 396 | 410 | // Let them know the action was a success. |
| 397 | - if (!empty($context['report_post_action']) && !empty($txt['report_action_' . $context['report_post_action']])) |
|
| 398 | - echo ' |
|
| 411 | + if (!empty($context['report_post_action']) && !empty($txt['report_action_' . $context['report_post_action']])) { |
|
| 412 | + echo ' |
|
| 399 | 413 | <div class="infobox"> |
| 400 | 414 | ', $txt['report_action_' . $context['report_post_action']], ' |
| 401 | 415 | </div>'; |
| 416 | + } |
|
| 402 | 417 | |
| 403 | 418 | echo ' |
| 404 | 419 | <form id="reported_members" action="', $scripturl, '?action=moderate;area=reportedmembers;sa=show', $context['view_closed'] ? ';closed' : '', ';start=', $context['start'], '" method="post" accept-charset="', $context['character_set'], '"> |
@@ -430,8 +445,9 @@ discard block |
||
| 430 | 445 | |
| 431 | 446 | // Prepare the comments... |
| 432 | 447 | $comments = array(); |
| 433 | - foreach ($report['comments'] as $comment) |
|
| 434 | - $comments[$comment['member']['id']] = $comment['member']['link']; |
|
| 448 | + foreach ($report['comments'] as $comment) { |
|
| 449 | + $comments[$comment['member']['id']] = $comment['member']['link']; |
|
| 450 | + } |
|
| 435 | 451 | |
| 436 | 452 | echo ' |
| 437 | 453 | ', $txt['mc_reportedp_reported_by'], ': ', implode(', ', $comments), ' |
@@ -443,13 +459,15 @@ discard block |
||
| 443 | 459 | <li><a href="', $scripturl, '?action=moderate;area=reportedmembers;sa=handle;closed=', (int) !$report['closed'], ';rid=', $report['id'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], ';', $context['mod-report-closed_token_var'], '=', $context['mod-report-closed_token'], '">', $close_button, '</a></li>'; |
| 444 | 460 | |
| 445 | 461 | // Ban this user button. |
| 446 | - if (!$report['closed'] && !empty($context['report_manage_bans']) && !empty($report['user']['id'])) |
|
| 447 | - echo ' |
|
| 462 | + if (!$report['closed'] && !empty($context['report_manage_bans']) && !empty($report['user']['id'])) { |
|
| 463 | + echo ' |
|
| 448 | 464 | <li><a href="', $scripturl, '?action=admin;area=ban;sa=add;u=', $report['user']['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $ban_button, '</a></li>'; |
| 465 | + } |
|
| 449 | 466 | |
| 450 | - if (!$context['view_closed']) |
|
| 451 | - echo ' |
|
| 467 | + if (!$context['view_closed']) { |
|
| 468 | + echo ' |
|
| 452 | 469 | <li><input type="checkbox" name="close[]" value="' . $report['id'] . '"></li>'; |
| 470 | + } |
|
| 453 | 471 | |
| 454 | 472 | echo ' |
| 455 | 473 | </ul> |
@@ -457,11 +475,12 @@ discard block |
||
| 457 | 475 | } |
| 458 | 476 | |
| 459 | 477 | // Were none found? |
| 460 | - if (empty($context['reports'])) |
|
| 461 | - echo ' |
|
| 478 | + if (empty($context['reports'])) { |
|
| 479 | + echo ' |
|
| 462 | 480 | <div class="windowbg"> |
| 463 | 481 | <p class="centertext">', $txt['mc_reportedp_none_found'], '</p> |
| 464 | 482 | </div>'; |
| 483 | + } |
|
| 465 | 484 | |
| 466 | 485 | echo ' |
| 467 | 486 | <div class="pagesection"> |
@@ -482,11 +501,12 @@ discard block |
||
| 482 | 501 | global $context, $scripturl, $txt; |
| 483 | 502 | |
| 484 | 503 | // Let them know the action was a success. |
| 485 | - if (!empty($context['report_post_action'])) |
|
| 486 | - echo ' |
|
| 504 | + if (!empty($context['report_post_action'])) { |
|
| 505 | + echo ' |
|
| 487 | 506 | <div class="infobox"> |
| 488 | 507 | ', $txt['report_action_' . $context['report_post_action']], ' |
| 489 | 508 | </div>'; |
| 509 | + } |
|
| 490 | 510 | |
| 491 | 511 | echo ' |
| 492 | 512 | <div id="modcenter"> |
@@ -519,14 +539,15 @@ discard block |
||
| 519 | 539 | <h3 class="catbg">', $txt['mc_memberreport_whoreported_title'], '</h3> |
| 520 | 540 | </div>'; |
| 521 | 541 | |
| 522 | - foreach ($context['report']['comments'] as $comment) |
|
| 523 | - echo ' |
|
| 542 | + foreach ($context['report']['comments'] as $comment) { |
|
| 543 | + echo ' |
|
| 524 | 544 | <div class="windowbg"> |
| 525 | 545 | <p class="smalltext"> |
| 526 | 546 | ', sprintf($txt['mc_modreport_whoreported_data'], $comment['member']['link'] . (empty($comment['member']['id']) && !empty($comment['member']['ip']) ? ' (' . $comment['member']['ip'] . ')' : ''), $comment['time']), ' |
| 527 | 547 | </p> |
| 528 | 548 | <p>', $comment['message'], '</p> |
| 529 | 549 | </div>'; |
| 550 | + } |
|
| 530 | 551 | |
| 531 | 552 | echo ' |
| 532 | 553 | <br> |
@@ -535,11 +556,12 @@ discard block |
||
| 535 | 556 | </div> |
| 536 | 557 | <div>'; |
| 537 | 558 | |
| 538 | - if (empty($context['report']['mod_comments'])) |
|
| 539 | - echo ' |
|
| 559 | + if (empty($context['report']['mod_comments'])) { |
|
| 560 | + echo ' |
|
| 540 | 561 | <div class="information"> |
| 541 | 562 | <p class="centertext">', $txt['mc_modreport_no_mod_comment'], '</p> |
| 542 | 563 | </div>'; |
| 564 | + } |
|
| 543 | 565 | |
| 544 | 566 | foreach ($context['report']['mod_comments'] as $comment) |
| 545 | 567 | { |
@@ -40,9 +40,10 @@ discard block |
||
| 40 | 40 | <option value="0000"', $context['holiday']['year'] == '0000' ? ' selected' : '', '>', $txt['every_year'], '</option>'; |
| 41 | 41 | |
| 42 | 42 | // Show a list of all the years we allow... |
| 43 | - for ($year = $modSettings['cal_minyear']; $year <= $modSettings['cal_maxyear']; $year++) |
|
| 44 | - echo ' |
|
| 43 | + for ($year = $modSettings['cal_minyear']; $year <= $modSettings['cal_maxyear']; $year++) { |
|
| 44 | + echo ' |
|
| 45 | 45 | <option value="', $year, '"', $year == $context['holiday']['year'] ? ' selected' : '', '>', $year, '</option>'; |
| 46 | + } |
|
| 46 | 47 | |
| 47 | 48 | echo ' |
| 48 | 49 | </select> |
@@ -50,9 +51,10 @@ discard block |
||
| 50 | 51 | <select name="month" id="month" onchange="generateDays();">'; |
| 51 | 52 | |
| 52 | 53 | // There are 12 months per year - ensure that they all get listed. |
| 53 | - for ($month = 1; $month <= 12; $month++) |
|
| 54 | - echo ' |
|
| 54 | + for ($month = 1; $month <= 12; $month++) { |
|
| 55 | + echo ' |
|
| 55 | 56 | <option value="', $month, '"', $month == $context['holiday']['month'] ? ' selected' : '', '>', $txt['months'][$month], '</option>'; |
| 57 | + } |
|
| 56 | 58 | |
| 57 | 59 | echo ' |
| 58 | 60 | </select> |
@@ -60,23 +62,25 @@ discard block |
||
| 60 | 62 | <select name="day" id="day" onchange="generateDays();">'; |
| 61 | 63 | |
| 62 | 64 | // This prints out all the days in the current month - this changes dynamically as we switch months. |
| 63 | - for ($day = 1; $day <= $context['holiday']['last_day']; $day++) |
|
| 64 | - echo ' |
|
| 65 | + for ($day = 1; $day <= $context['holiday']['last_day']; $day++) { |
|
| 66 | + echo ' |
|
| 65 | 67 | <option value="', $day, '"', $day == $context['holiday']['day'] ? ' selected' : '', '>', $day, '</option>'; |
| 68 | + } |
|
| 66 | 69 | |
| 67 | 70 | echo ' |
| 68 | 71 | </select> |
| 69 | 72 | </dd> |
| 70 | 73 | </dl>'; |
| 71 | 74 | |
| 72 | - if ($context['is_new']) |
|
| 73 | - echo ' |
|
| 75 | + if ($context['is_new']) { |
|
| 76 | + echo ' |
|
| 74 | 77 | <input type="submit" value="', $txt['holidays_button_add'], '" class="button">'; |
| 75 | - else |
|
| 76 | - echo ' |
|
| 78 | + } else { |
|
| 79 | + echo ' |
|
| 77 | 80 | <input type="submit" name="edit" value="', $txt['holidays_button_edit'], '" class="button"> |
| 78 | 81 | <input type="submit" name="delete" value="', $txt['holidays_button_remove'], '" class="button"> |
| 79 | 82 | <input type="hidden" name="holiday" value="', $context['holiday']['id'], '">'; |
| 83 | + } |
|
| 80 | 84 | echo ' |
| 81 | 85 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
| 82 | 86 | </div><!-- .windowbg --> |
@@ -106,7 +106,7 @@ |
||
| 106 | 106 | if (!empty($context['custom_profile_fields']['columns'])) |
| 107 | 107 | foreach ($context['custom_profile_fields']['columns'] as $key => $column) |
| 108 | 108 | echo ' |
| 109 | - <td class="' , $key , ' centertext">', $member['options'][$key], '</td>'; |
|
| 109 | + <td class="' , $key, ' centertext">', $member['options'][$key], '</td>'; |
|
| 110 | 110 | |
| 111 | 111 | echo ' |
| 112 | 112 | </tr>'; |
@@ -27,9 +27,10 @@ discard block |
||
| 27 | 27 | <h3 class="catbg"> |
| 28 | 28 | <span class="floatleft">', $txt['members_list'], '</span>'; |
| 29 | 29 | |
| 30 | - if (!isset($context['old_search'])) |
|
| 31 | - echo ' |
|
| 30 | + if (!isset($context['old_search'])) { |
|
| 31 | + echo ' |
|
| 32 | 32 | <span class="floatright">', $context['letter_links'], '</span>'; |
| 33 | + } |
|
| 33 | 34 | echo ' |
| 34 | 35 | </h3> |
| 35 | 36 | </div>'; |
@@ -44,20 +45,23 @@ discard block |
||
| 44 | 45 | foreach ($context['columns'] as $key => $column) |
| 45 | 46 | { |
| 46 | 47 | // @TODO maybe find something nicer? |
| 47 | - if ($key == 'email_address' && !$context['can_send_email']) |
|
| 48 | - continue; |
|
| 48 | + if ($key == 'email_address' && !$context['can_send_email']) { |
|
| 49 | + continue; |
|
| 50 | + } |
|
| 49 | 51 | |
| 50 | 52 | // This is a selected column, so underline it or some such. |
| 51 | - if ($column['selected']) |
|
| 52 | - echo ' |
|
| 53 | + if ($column['selected']) { |
|
| 54 | + echo ' |
|
| 53 | 55 | <th scope="col" class="', $key, isset($column['class']) ? ' ' . $column['class'] : '', ' selected" style="width: auto;"' . (isset($column['colspan']) ? ' colspan="' . $column['colspan'] . '"' : '') . '> |
| 54 | 56 | <a href="' . $column['href'] . '" rel="nofollow">' . $column['label'] . '</a><span class="generic_icons sort_' . $context['sort_direction'] . '"></span></th>'; |
| 57 | + } |
|
| 55 | 58 | |
| 56 | 59 | // This is just some column... show the link and be done with it. |
| 57 | - else |
|
| 58 | - echo ' |
|
| 60 | + else { |
|
| 61 | + echo ' |
|
| 59 | 62 | <th scope="col" class="', $key, isset($column['class']) ? ' ' . $column['class'] : '', '"', isset($column['width']) ? ' style="width: ' . $column['width'] . '"' : '', isset($column['colspan']) ? ' colspan="' . $column['colspan'] . '"' : '', '> |
| 60 | 63 | ', $column['link'], '</th>'; |
| 64 | + } |
|
| 61 | 65 | } |
| 62 | 66 | |
| 63 | 67 | echo ' |
@@ -77,9 +81,10 @@ discard block |
||
| 77 | 81 | </td> |
| 78 | 82 | <td class="real_name lefttext">', $member['link'], '</td>'; |
| 79 | 83 | |
| 80 | - if (!isset($context['disabled_fields']['website'])) |
|
| 81 | - echo ' |
|
| 84 | + if (!isset($context['disabled_fields']['website'])) { |
|
| 85 | + echo ' |
|
| 82 | 86 | <td class="website_url centertext">', $member['website']['url'] != '' ? '<a href="' . $member['website']['url'] . '" target="_blank" rel="noopener"><span class="generic_icons www" title="' . $member['website']['title'] . '"></span></a>' : '', '</td>'; |
| 87 | + } |
|
| 83 | 88 | |
| 84 | 89 | // Group and date. |
| 85 | 90 | echo ' |
@@ -91,33 +96,36 @@ discard block |
||
| 91 | 96 | echo ' |
| 92 | 97 | <td class="post_count centertext">'; |
| 93 | 98 | |
| 94 | - if (!empty($member['post_percent'])) |
|
| 95 | - echo ' |
|
| 99 | + if (!empty($member['post_percent'])) { |
|
| 100 | + echo ' |
|
| 96 | 101 | <div class="generic_bar"> |
| 97 | 102 | <div class="bar" style="width: ', $member['post_percent'], '%;"></div> |
| 98 | 103 | <span>', $member['posts'], '</span> |
| 99 | 104 | </div>'; |
| 105 | + } |
|
| 100 | 106 | |
| 101 | 107 | echo ' |
| 102 | 108 | </td>'; |
| 103 | 109 | } |
| 104 | 110 | |
| 105 | 111 | // Show custom fields marked to be shown here |
| 106 | - if (!empty($context['custom_profile_fields']['columns'])) |
|
| 107 | - foreach ($context['custom_profile_fields']['columns'] as $key => $column) |
|
| 112 | + if (!empty($context['custom_profile_fields']['columns'])) { |
|
| 113 | + foreach ($context['custom_profile_fields']['columns'] as $key => $column) |
|
| 108 | 114 | echo ' |
| 109 | 115 | <td class="' , $key , ' centertext">', $member['options'][$key], '</td>'; |
| 116 | + } |
|
| 110 | 117 | |
| 111 | 118 | echo ' |
| 112 | 119 | </tr>'; |
| 113 | 120 | } |
| 114 | 121 | } |
| 115 | 122 | // No members? |
| 116 | - else |
|
| 117 | - echo ' |
|
| 123 | + else { |
|
| 124 | + echo ' |
|
| 118 | 125 | <tr> |
| 119 | 126 | <td colspan="', $context['colspan'], '" class="windowbg">', $txt['search_no_results'], '</td> |
| 120 | 127 | </tr>'; |
| 128 | + } |
|
| 121 | 129 | |
| 122 | 130 | echo ' |
| 123 | 131 | </tbody> |
@@ -130,11 +138,12 @@ discard block |
||
| 130 | 138 | <div class="pagelinks floatleft">', $context['page_index'], '</div>'; |
| 131 | 139 | |
| 132 | 140 | // If it is displaying the result of a search show a "search again" link to edit their criteria. |
| 133 | - if (isset($context['old_search'])) |
|
| 134 | - echo ' |
|
| 141 | + if (isset($context['old_search'])) { |
|
| 142 | + echo ' |
|
| 135 | 143 | <div class="buttonlist floatright"> |
| 136 | 144 | <a class="button" href="', $scripturl, '?action=mlist;sa=search;search=', $context['old_search_value'], '">', $txt['mlist_search_again'], '</a> |
| 137 | 145 | </div>'; |
| 146 | + } |
|
| 138 | 147 | echo ' |
| 139 | 148 | </div> |
| 140 | 149 | </div><!-- #memberlist -->'; |
@@ -174,12 +183,13 @@ discard block |
||
| 174 | 183 | <dd> |
| 175 | 184 | <ul>'; |
| 176 | 185 | |
| 177 | - foreach ($context['search_fields'] as $id => $title) |
|
| 178 | - echo ' |
|
| 186 | + foreach ($context['search_fields'] as $id => $title) { |
|
| 187 | + echo ' |
|
| 179 | 188 | <li> |
| 180 | 189 | <input type="checkbox" name="fields[]" id="fields-', $id, '" value="', $id, '"', in_array($id, $context['search_defaults']) ? ' checked' : '', '> |
| 181 | 190 | <label for="fields-', $id, '">', $title, '</label> |
| 182 | 191 | </li>'; |
| 192 | + } |
|
| 183 | 193 | |
| 184 | 194 | echo ' |
| 185 | 195 | </ul> |
@@ -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 | - send_http_status(400); |
|
| 882 | + if (in_array('gd', get_loaded_extensions()) && !showCodeImage($code)) { |
|
| 883 | + send_http_status(400); |
|
| 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 | - send_http_status(400); |
|
| 906 | + if (!createWaveFile($code)) { |
|
| 907 | + send_http_status(400); |
|
| 908 | + } |
|
| 859 | 909 | } |
| 860 | 910 | |
| 861 | 911 | // We all die one day... |
@@ -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 | * Downloads an avatar or attachment based on $_GET['attach'], and increments the download count. |
@@ -40,11 +41,11 @@ discard block |
||
| 40 | 41 | |
| 41 | 42 | if (!empty($modSettings['enableCompressedOutput']) && !headers_sent() && ob_get_length() == 0) |
| 42 | 43 | { |
| 43 | - if (@ini_get('zlib.output_compression') == '1' || @ini_get('output_handler') == 'ob_gzhandler') |
|
| 44 | - $modSettings['enableCompressedOutput'] = 0; |
|
| 45 | - |
|
| 46 | - else |
|
| 47 | - ob_start('ob_gzhandler'); |
|
| 44 | + if (@ini_get('zlib.output_compression') == '1' || @ini_get('output_handler') == 'ob_gzhandler') { |
|
| 45 | + $modSettings['enableCompressedOutput'] = 0; |
|
| 46 | + } else { |
|
| 47 | + ob_start('ob_gzhandler'); |
|
| 48 | + } |
|
| 48 | 49 | } |
| 49 | 50 | |
| 50 | 51 | if (empty($modSettings['enableCompressedOutput'])) |
@@ -76,8 +77,9 @@ discard block |
||
| 76 | 77 | } |
| 77 | 78 | |
| 78 | 79 | // Use cache when possible. |
| 79 | - if (($cache = cache_get_data('attachment_lookup_id-' . $attachId)) != null) |
|
| 80 | - list($file, $thumbFile) = $cache; |
|
| 80 | + if (($cache = cache_get_data('attachment_lookup_id-' . $attachId)) != null) { |
|
| 81 | + list($file, $thumbFile) = $cache; |
|
| 82 | + } |
|
| 81 | 83 | |
| 82 | 84 | // Get the info from the DB. |
| 83 | 85 | if (empty($file) || empty($thumbFile) && !empty($file['id_thumb'])) |
@@ -85,10 +87,9 @@ discard block |
||
| 85 | 87 | // Do we have a hook wanting to use our attachment system? We use $attachRequest to prevent accidental usage of $request. |
| 86 | 88 | $attachRequest = null; |
| 87 | 89 | call_integration_hook('integrate_download_request', array(&$attachRequest)); |
| 88 | - if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest)) |
|
| 89 | - $request = $attachRequest; |
|
| 90 | - |
|
| 91 | - else |
|
| 90 | + if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest)) { |
|
| 91 | + $request = $attachRequest; |
|
| 92 | + } else |
|
| 92 | 93 | { |
| 93 | 94 | // Make sure this attachment is on this board and load its info while we are at it. |
| 94 | 95 | $request = $smcFunc['db_query']('', ' |
@@ -181,13 +182,15 @@ discard block |
||
| 181 | 182 | } |
| 182 | 183 | |
| 183 | 184 | // Cache it. |
| 184 | - if (!empty($file) || !empty($thumbFile)) |
|
| 185 | - cache_put_data('attachment_lookup_id-' . $file['id_attach'], array($file, $thumbFile), mt_rand(850, 900)); |
|
| 185 | + if (!empty($file) || !empty($thumbFile)) { |
|
| 186 | + cache_put_data('attachment_lookup_id-' . $file['id_attach'], array($file, $thumbFile), mt_rand(850, 900)); |
|
| 187 | + } |
|
| 186 | 188 | } |
| 187 | 189 | |
| 188 | 190 | // Replace the normal file with its thumbnail if it has one! |
| 189 | - if (!empty($showThumb) && !empty($thumbFile)) |
|
| 190 | - $file = $thumbFile; |
|
| 191 | + if (!empty($showThumb) && !empty($thumbFile)) { |
|
| 192 | + $file = $thumbFile; |
|
| 193 | + } |
|
| 191 | 194 | |
| 192 | 195 | // No point in a nicer message, because this is supposed to be an attachment anyway... |
| 193 | 196 | if (!file_exists($file['filePath'])) |
@@ -237,8 +240,8 @@ discard block |
||
| 237 | 240 | } |
| 238 | 241 | |
| 239 | 242 | // Update the download counter (unless it's a thumbnail or resuming an incomplete download). |
| 240 | - if ($file['attachment_type'] != 3 && empty($showThumb) && $range === 0) |
|
| 241 | - $smcFunc['db_query']('', ' |
|
| 243 | + if ($file['attachment_type'] != 3 && empty($showThumb) && $range === 0) { |
|
| 244 | + $smcFunc['db_query']('', ' |
|
| 242 | 245 | UPDATE {db_prefix}attachments |
| 243 | 246 | SET downloads = downloads + 1 |
| 244 | 247 | WHERE id_attach = {int:id_attach}', |
@@ -246,12 +249,14 @@ discard block |
||
| 246 | 249 | 'id_attach' => $attachId, |
| 247 | 250 | ) |
| 248 | 251 | ); |
| 252 | + } |
|
| 249 | 253 | |
| 250 | 254 | // Send the attachment headers. |
| 251 | 255 | header('pragma: '); |
| 252 | 256 | |
| 253 | - if (!isBrowser('gecko')) |
|
| 254 | - header('content-transfer-encoding: binary'); |
|
| 257 | + if (!isBrowser('gecko')) { |
|
| 258 | + header('content-transfer-encoding: binary'); |
|
| 259 | + } |
|
| 255 | 260 | |
| 256 | 261 | header('expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT'); |
| 257 | 262 | header('last-modified: ' . gmdate('D, d M Y H:i:s', filemtime($file['filePath'])) . ' GMT'); |
@@ -260,18 +265,19 @@ discard block |
||
| 260 | 265 | header('etag: ' . $eTag); |
| 261 | 266 | |
| 262 | 267 | // Make sure the mime type warrants an inline display. |
| 263 | - if (isset($_REQUEST['image']) && !empty($file['mime_type']) && strpos($file['mime_type'], 'image/') !== 0) |
|
| 264 | - unset($_REQUEST['image']); |
|
| 268 | + if (isset($_REQUEST['image']) && !empty($file['mime_type']) && strpos($file['mime_type'], 'image/') !== 0) { |
|
| 269 | + unset($_REQUEST['image']); |
|
| 270 | + } |
|
| 265 | 271 | |
| 266 | 272 | // Does this have a mime type? |
| 267 | - elseif (!empty($file['mime_type']) && (isset($_REQUEST['image']) || !in_array($file['fileext'], array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff')))) |
|
| 268 | - header('content-type: ' . strtr($file['mime_type'], array('image/bmp' => 'image/x-ms-bmp'))); |
|
| 269 | - |
|
| 270 | - else |
|
| 273 | + elseif (!empty($file['mime_type']) && (isset($_REQUEST['image']) || !in_array($file['fileext'], array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff')))) { |
|
| 274 | + header('content-type: ' . strtr($file['mime_type'], array('image/bmp' => 'image/x-ms-bmp'))); |
|
| 275 | + } else |
|
| 271 | 276 | { |
| 272 | 277 | header('content-type: ' . (isBrowser('ie') || isBrowser('opera') ? 'application/octetstream' : 'application/octet-stream')); |
| 273 | - if (isset($_REQUEST['image'])) |
|
| 274 | - unset($_REQUEST['image']); |
|
| 278 | + if (isset($_REQUEST['image'])) { |
|
| 279 | + unset($_REQUEST['image']); |
|
| 280 | + } |
|
| 275 | 281 | } |
| 276 | 282 | |
| 277 | 283 | // Convert the file to UTF-8, cuz most browsers dig that. |
@@ -279,24 +285,22 @@ discard block |
||
| 279 | 285 | $disposition = !isset($_REQUEST['image']) ? 'attachment' : 'inline'; |
| 280 | 286 | |
| 281 | 287 | // Different browsers like different standards... |
| 282 | - if (isBrowser('firefox')) |
|
| 283 | - header('content-disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name))); |
|
| 284 | - |
|
| 285 | - elseif (isBrowser('opera')) |
|
| 286 | - header('content-disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"'); |
|
| 287 | - |
|
| 288 | - elseif (isBrowser('ie')) |
|
| 289 | - header('content-disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"'); |
|
| 290 | - |
|
| 291 | - else |
|
| 292 | - header('content-disposition: ' . $disposition . '; filename="' . $utf8name . '"'); |
|
| 288 | + if (isBrowser('firefox')) { |
|
| 289 | + header('content-disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name))); |
|
| 290 | + } elseif (isBrowser('opera')) { |
|
| 291 | + header('content-disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"'); |
|
| 292 | + } elseif (isBrowser('ie')) { |
|
| 293 | + header('content-disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"'); |
|
| 294 | + } else { |
|
| 295 | + header('content-disposition: ' . $disposition . '; filename="' . $utf8name . '"'); |
|
| 296 | + } |
|
| 293 | 297 | |
| 294 | 298 | // If this has an "image extension" - but isn't actually an image - then ensure it isn't cached cause of silly IE. |
| 295 | - if (!isset($_REQUEST['image']) && in_array($file['fileext'], array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff'))) |
|
| 296 | - header('cache-control: no-cache'); |
|
| 297 | - |
|
| 298 | - else |
|
| 299 | - header('cache-control: max-age=' . (525600 * 60) . ', private'); |
|
| 299 | + if (!isset($_REQUEST['image']) && in_array($file['fileext'], array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff'))) { |
|
| 300 | + header('cache-control: no-cache'); |
|
| 301 | + } else { |
|
| 302 | + header('cache-control: max-age=' . (525600 * 60) . ', private'); |
|
| 303 | + } |
|
| 300 | 304 | |
| 301 | 305 | // Multipart and resuming support |
| 302 | 306 | if (isset($_SERVER['HTTP_RANGE'])) |
@@ -304,9 +308,9 @@ discard block |
||
| 304 | 308 | send_http_status(206); |
| 305 | 309 | header("content-length: $new_length"); |
| 306 | 310 | header("content-range: bytes $range-$range_end/$size"); |
| 311 | + } else { |
|
| 312 | + header("content-length: " . $size); |
|
| 307 | 313 | } |
| 308 | - else |
|
| 309 | - header("content-length: " . $size); |
|
| 310 | 314 | |
| 311 | 315 | |
| 312 | 316 | // Try to buy some time... |
@@ -315,8 +319,9 @@ discard block |
||
| 315 | 319 | // For multipart/resumable downloads, send the requested chunk(s) of the file |
| 316 | 320 | if (isset($_SERVER['HTTP_RANGE'])) |
| 317 | 321 | { |
| 318 | - while (@ob_get_level() > 0) |
|
| 319 | - @ob_end_clean(); |
|
| 322 | + while (@ob_get_level() > 0) { |
|
| 323 | + @ob_end_clean(); |
|
| 324 | + } |
|
| 320 | 325 | |
| 321 | 326 | // 40 kilobytes is a good-ish amount |
| 322 | 327 | $chunksize = 40 * 1024; |
@@ -340,8 +345,9 @@ discard block |
||
| 340 | 345 | elseif ($size > 4194304) |
| 341 | 346 | { |
| 342 | 347 | // Forcibly end any output buffering going on. |
| 343 | - while (@ob_get_level() > 0) |
|
| 344 | - @ob_end_clean(); |
|
| 348 | + while (@ob_get_level() > 0) { |
|
| 349 | + @ob_end_clean(); |
|
| 350 | + } |
|
| 345 | 351 | |
| 346 | 352 | $fp = fopen($file['filePath'], 'rb'); |
| 347 | 353 | while (!feof($fp)) |
@@ -353,8 +359,9 @@ discard block |
||
| 353 | 359 | } |
| 354 | 360 | |
| 355 | 361 | // On some of the less-bright hosts, readfile() is disabled. It's just a faster, more byte safe, version of what's in the if. |
| 356 | - elseif (@readfile($file['filePath']) === null) |
|
| 357 | - echo file_get_contents($file['filePath']); |
|
| 362 | + elseif (@readfile($file['filePath']) === null) { |
|
| 363 | + echo file_get_contents($file['filePath']); |
|
| 364 | + } |
|
| 358 | 365 | |
| 359 | 366 | die(); |
| 360 | 367 | } |
@@ -502,6 +502,9 @@ discard block |
||
| 502 | 502 | } |
| 503 | 503 | |
| 504 | 504 | // Used to direct the user to another location. |
| 505 | +/** |
|
| 506 | + * @param string $location |
|
| 507 | + */ |
|
| 505 | 508 | function redirectLocation($location, $addForm = true) |
| 506 | 509 | { |
| 507 | 510 | global $upgradeurl, $upcontext, $command_line; |
@@ -1745,6 +1748,9 @@ discard block |
||
| 1745 | 1748 | return addslashes(preg_replace(array('~^\.([/\\\]|$)~', '~[/]+~', '~[\\\]+~', '~[/\\\]$~'), array($install_path . '$1', '/', '\\', ''), $path)); |
| 1746 | 1749 | } |
| 1747 | 1750 | |
| 1751 | +/** |
|
| 1752 | + * @param string $filename |
|
| 1753 | + */ |
|
| 1748 | 1754 | function parse_sql($filename) |
| 1749 | 1755 | { |
| 1750 | 1756 | global $db_prefix, $db_collation, $boarddir, $boardurl, $command_line, $file_steps, $step_progress, $custom_warning; |
@@ -1779,6 +1785,10 @@ discard block |
||
| 1779 | 1785 | |
| 1780 | 1786 | // Our custom error handler - does nothing but does stop public errors from XML! |
| 1781 | 1787 | set_error_handler( |
| 1788 | + |
|
| 1789 | + /** |
|
| 1790 | + * @param string $errno |
|
| 1791 | + */ |
|
| 1782 | 1792 | function ($errno, $errstr, $errfile, $errline) use ($support_js) |
| 1783 | 1793 | { |
| 1784 | 1794 | if ($support_js) |
@@ -1993,6 +2003,9 @@ discard block |
||
| 1993 | 2003 | return true; |
| 1994 | 2004 | } |
| 1995 | 2005 | |
| 2006 | +/** |
|
| 2007 | + * @param string $string |
|
| 2008 | + */ |
|
| 1996 | 2009 | function upgrade_query($string, $unbuffered = false) |
| 1997 | 2010 | { |
| 1998 | 2011 | global $db_connection, $db_server, $db_user, $db_passwd, $db_type, $command_line, $upcontext, $upgradeurl, $modSettings; |
@@ -4763,7 +4776,7 @@ discard block |
||
| 4763 | 4776 | * @param int $setSize The amount of entries after which to update the database. |
| 4764 | 4777 | * |
| 4765 | 4778 | * newCol needs to be a varbinary(16) null able field |
| 4766 | - * @return bool |
|
| 4779 | + * @return boolean|null |
|
| 4767 | 4780 | */ |
| 4768 | 4781 | function MySQLConvertOldIp($targetTable, $oldCol, $newCol, $limit = 50000, $setSize = 100) |
| 4769 | 4782 | { |
@@ -4931,9 +4944,8 @@ discard block |
||
| 4931 | 4944 | * settings file isn't using any advanced configuration setups in the Settings.php file. A copy is made as Settings_org.php |
| 4932 | 4945 | * to preserve all changes prior to migration. |
| 4933 | 4946 | * |
| 4934 | - * @param array $config_vars An array of one or more variables to update |
|
| 4935 | 4947 | * |
| 4936 | - * @return void We either succesfully update the Settings file, or throw a error here. |
|
| 4948 | + * @return boolean|null We either succesfully update the Settings file, or throw a error here. |
|
| 4937 | 4949 | */ |
| 4938 | 4950 | function migrateSettingsFile($changes) |
| 4939 | 4951 | { |
@@ -5343,9 +5355,8 @@ discard block |
||
| 5343 | 5355 | * Prior to checking these settings, we look for advanced setups such as integrations or if variables have been moved |
| 5344 | 5356 | * to another file. If these are detected, we abort. |
| 5345 | 5357 | * |
| 5346 | - * @param array $config_vars An array of one or more variables to update |
|
| 5347 | 5358 | * |
| 5348 | - * @return void We either succesfully update the Settings file, or throw a error here. |
|
| 5359 | + * @return boolean We either succesfully update the Settings file, or throw a error here. |
|
| 5349 | 5360 | */ |
| 5350 | 5361 | |
| 5351 | 5362 | function detectSettingsFileMigrationNeeded() |
@@ -841,13 +841,13 @@ discard block |
||
| 841 | 841 | // We're going to check that their board dir setting is right in case they've been moving stuff around. |
| 842 | 842 | if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) |
| 843 | 843 | $upcontext['warning'] = ' |
| 844 | - '. sprintf($txt['upgrade_boarddir_settings'], $boarddir, dirname(__FILE__)) .'<br> |
|
| 844 | + '. sprintf($txt['upgrade_boarddir_settings'], $boarddir, dirname(__FILE__)) . '<br> |
|
| 845 | 845 | <ul> |
| 846 | - <li>'. $txt['upgrade_boarddir'] .' ' . $boarddir . '</li> |
|
| 847 | - <li>'. $txt['upgrade_sourcedir'] .' ' . $boarddir . '</li> |
|
| 848 | - <li>'. $txt['upgrade_cachedir'] .' ' . $cachedir_temp . '</li> |
|
| 846 | + <li>'. $txt['upgrade_boarddir'] . ' ' . $boarddir . '</li> |
|
| 847 | + <li>'. $txt['upgrade_sourcedir'] . ' ' . $boarddir . '</li> |
|
| 848 | + <li>'. $txt['upgrade_cachedir'] . ' ' . $cachedir_temp . '</li> |
|
| 849 | 849 | </ul> |
| 850 | - '. $txt['upgrade_incorrect_settings'] .''; |
|
| 850 | + '. $txt['upgrade_incorrect_settings'] . ''; |
|
| 851 | 851 | |
| 852 | 852 | // Confirm mbstring is loaded... |
| 853 | 853 | if (!extension_loaded('mbstring')) |
@@ -1781,7 +1781,7 @@ discard block |
||
| 1781 | 1781 | |
| 1782 | 1782 | // Our custom error handler - does nothing but does stop public errors from XML! |
| 1783 | 1783 | set_error_handler( |
| 1784 | - function ($errno, $errstr, $errfile, $errline) use ($support_js) |
|
| 1784 | + function($errno, $errstr, $errfile, $errline) use ($support_js) |
|
| 1785 | 1785 | { |
| 1786 | 1786 | if ($support_js) |
| 1787 | 1787 | return true; |
@@ -2109,13 +2109,13 @@ discard block |
||
| 2109 | 2109 | |
| 2110 | 2110 | // Otherwise we have to display this somewhere appropriate if possible. |
| 2111 | 2111 | $upcontext['forced_error_message'] = ' |
| 2112 | - <strong>'. $txt['upgrade_unsuccessful'] .'</strong><br> |
|
| 2112 | + <strong>'. $txt['upgrade_unsuccessful'] . '</strong><br> |
|
| 2113 | 2113 | |
| 2114 | 2114 | <div style="margin: 2ex;"> |
| 2115 | - '. $txt['upgrade_thisquery'] .' |
|
| 2115 | + '. $txt['upgrade_thisquery'] . ' |
|
| 2116 | 2116 | <blockquote><pre>' . nl2br(htmlspecialchars(trim($string))) . ';</pre></blockquote> |
| 2117 | 2117 | |
| 2118 | - '. $txt['upgrade_causerror'] .' |
|
| 2118 | + '. $txt['upgrade_causerror'] . ' |
|
| 2119 | 2119 | <blockquote>' . nl2br(htmlspecialchars($db_error_message)) . '</blockquote> |
| 2120 | 2120 | </div> |
| 2121 | 2121 | |
@@ -2780,94 +2780,94 @@ discard block |
||
| 2780 | 2780 | // Translation table for the character sets not native for MySQL. |
| 2781 | 2781 | $translation_tables = array( |
| 2782 | 2782 | 'windows-1255' => array( |
| 2783 | - '0x81' => '\'\'', '0x8A' => '\'\'', '0x8C' => '\'\'', |
|
| 2784 | - '0x8D' => '\'\'', '0x8E' => '\'\'', '0x8F' => '\'\'', |
|
| 2785 | - '0x90' => '\'\'', '0x9A' => '\'\'', '0x9C' => '\'\'', |
|
| 2786 | - '0x9D' => '\'\'', '0x9E' => '\'\'', '0x9F' => '\'\'', |
|
| 2787 | - '0xCA' => '\'\'', '0xD9' => '\'\'', '0xDA' => '\'\'', |
|
| 2788 | - '0xDB' => '\'\'', '0xDC' => '\'\'', '0xDD' => '\'\'', |
|
| 2789 | - '0xDE' => '\'\'', '0xDF' => '\'\'', '0xFB' => '0xD792', |
|
| 2790 | - '0xFC' => '0xE282AC', '0xFF' => '0xD6B2', '0xC2' => '0xFF', |
|
| 2791 | - '0x80' => '0xFC', '0xE2' => '0xFB', '0xA0' => '0xC2A0', |
|
| 2792 | - '0xA1' => '0xC2A1', '0xA2' => '0xC2A2', '0xA3' => '0xC2A3', |
|
| 2793 | - '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
| 2794 | - '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
| 2795 | - '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
| 2796 | - '0xAF' => '0xC2AF', '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', |
|
| 2797 | - '0xB2' => '0xC2B2', '0xB3' => '0xC2B3', '0xB4' => '0xC2B4', |
|
| 2798 | - '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
| 2799 | - '0xB8' => '0xC2B8', '0xB9' => '0xC2B9', '0xBB' => '0xC2BB', |
|
| 2800 | - '0xBC' => '0xC2BC', '0xBD' => '0xC2BD', '0xBE' => '0xC2BE', |
|
| 2801 | - '0xBF' => '0xC2BF', '0xD7' => '0xD7B3', '0xD1' => '0xD781', |
|
| 2802 | - '0xD4' => '0xD7B0', '0xD5' => '0xD7B1', '0xD6' => '0xD7B2', |
|
| 2803 | - '0xE0' => '0xD790', '0xEA' => '0xD79A', '0xEC' => '0xD79C', |
|
| 2804 | - '0xED' => '0xD79D', '0xEE' => '0xD79E', '0xEF' => '0xD79F', |
|
| 2805 | - '0xF0' => '0xD7A0', '0xF1' => '0xD7A1', '0xF2' => '0xD7A2', |
|
| 2806 | - '0xF3' => '0xD7A3', '0xF5' => '0xD7A5', '0xF6' => '0xD7A6', |
|
| 2807 | - '0xF7' => '0xD7A7', '0xF8' => '0xD7A8', '0xF9' => '0xD7A9', |
|
| 2808 | - '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
| 2809 | - '0x86' => '0xE280A0', '0x87' => '0xE280A1', '0x89' => '0xE280B0', |
|
| 2810 | - '0x8B' => '0xE280B9', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
| 2811 | - '0x95' => '0xE280A2', '0x97' => '0xE28094', '0x99' => '0xE284A2', |
|
| 2812 | - '0xC0' => '0xD6B0', '0xC1' => '0xD6B1', '0xC3' => '0xD6B3', |
|
| 2813 | - '0xC4' => '0xD6B4', '0xC5' => '0xD6B5', '0xC6' => '0xD6B6', |
|
| 2814 | - '0xC7' => '0xD6B7', '0xC8' => '0xD6B8', '0xC9' => '0xD6B9', |
|
| 2815 | - '0xCB' => '0xD6BB', '0xCC' => '0xD6BC', '0xCD' => '0xD6BD', |
|
| 2816 | - '0xCE' => '0xD6BE', '0xCF' => '0xD6BF', '0xD0' => '0xD780', |
|
| 2817 | - '0xD2' => '0xD782', '0xE3' => '0xD793', '0xE4' => '0xD794', |
|
| 2818 | - '0xE5' => '0xD795', '0xE7' => '0xD797', '0xE9' => '0xD799', |
|
| 2819 | - '0xFD' => '0xE2808E', '0xFE' => '0xE2808F', '0x92' => '0xE28099', |
|
| 2820 | - '0x83' => '0xC692', '0xD3' => '0xD783', '0x88' => '0xCB86', |
|
| 2821 | - '0x98' => '0xCB9C', '0x91' => '0xE28098', '0x96' => '0xE28093', |
|
| 2822 | - '0xBA' => '0xC3B7', '0x9B' => '0xE280BA', '0xAA' => '0xC397', |
|
| 2823 | - '0xA4' => '0xE282AA', '0xE1' => '0xD791', '0xE6' => '0xD796', |
|
| 2824 | - '0xE8' => '0xD798', '0xEB' => '0xD79B', '0xF4' => '0xD7A4', |
|
| 2783 | + '0x81' => '\'\'', '0x8A' => '\'\'', '0x8C' => '\'\'', |
|
| 2784 | + '0x8D' => '\'\'', '0x8E' => '\'\'', '0x8F' => '\'\'', |
|
| 2785 | + '0x90' => '\'\'', '0x9A' => '\'\'', '0x9C' => '\'\'', |
|
| 2786 | + '0x9D' => '\'\'', '0x9E' => '\'\'', '0x9F' => '\'\'', |
|
| 2787 | + '0xCA' => '\'\'', '0xD9' => '\'\'', '0xDA' => '\'\'', |
|
| 2788 | + '0xDB' => '\'\'', '0xDC' => '\'\'', '0xDD' => '\'\'', |
|
| 2789 | + '0xDE' => '\'\'', '0xDF' => '\'\'', '0xFB' => '0xD792', |
|
| 2790 | + '0xFC' => '0xE282AC', '0xFF' => '0xD6B2', '0xC2' => '0xFF', |
|
| 2791 | + '0x80' => '0xFC', '0xE2' => '0xFB', '0xA0' => '0xC2A0', |
|
| 2792 | + '0xA1' => '0xC2A1', '0xA2' => '0xC2A2', '0xA3' => '0xC2A3', |
|
| 2793 | + '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
| 2794 | + '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
| 2795 | + '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
| 2796 | + '0xAF' => '0xC2AF', '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', |
|
| 2797 | + '0xB2' => '0xC2B2', '0xB3' => '0xC2B3', '0xB4' => '0xC2B4', |
|
| 2798 | + '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
| 2799 | + '0xB8' => '0xC2B8', '0xB9' => '0xC2B9', '0xBB' => '0xC2BB', |
|
| 2800 | + '0xBC' => '0xC2BC', '0xBD' => '0xC2BD', '0xBE' => '0xC2BE', |
|
| 2801 | + '0xBF' => '0xC2BF', '0xD7' => '0xD7B3', '0xD1' => '0xD781', |
|
| 2802 | + '0xD4' => '0xD7B0', '0xD5' => '0xD7B1', '0xD6' => '0xD7B2', |
|
| 2803 | + '0xE0' => '0xD790', '0xEA' => '0xD79A', '0xEC' => '0xD79C', |
|
| 2804 | + '0xED' => '0xD79D', '0xEE' => '0xD79E', '0xEF' => '0xD79F', |
|
| 2805 | + '0xF0' => '0xD7A0', '0xF1' => '0xD7A1', '0xF2' => '0xD7A2', |
|
| 2806 | + '0xF3' => '0xD7A3', '0xF5' => '0xD7A5', '0xF6' => '0xD7A6', |
|
| 2807 | + '0xF7' => '0xD7A7', '0xF8' => '0xD7A8', '0xF9' => '0xD7A9', |
|
| 2808 | + '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
| 2809 | + '0x86' => '0xE280A0', '0x87' => '0xE280A1', '0x89' => '0xE280B0', |
|
| 2810 | + '0x8B' => '0xE280B9', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
| 2811 | + '0x95' => '0xE280A2', '0x97' => '0xE28094', '0x99' => '0xE284A2', |
|
| 2812 | + '0xC0' => '0xD6B0', '0xC1' => '0xD6B1', '0xC3' => '0xD6B3', |
|
| 2813 | + '0xC4' => '0xD6B4', '0xC5' => '0xD6B5', '0xC6' => '0xD6B6', |
|
| 2814 | + '0xC7' => '0xD6B7', '0xC8' => '0xD6B8', '0xC9' => '0xD6B9', |
|
| 2815 | + '0xCB' => '0xD6BB', '0xCC' => '0xD6BC', '0xCD' => '0xD6BD', |
|
| 2816 | + '0xCE' => '0xD6BE', '0xCF' => '0xD6BF', '0xD0' => '0xD780', |
|
| 2817 | + '0xD2' => '0xD782', '0xE3' => '0xD793', '0xE4' => '0xD794', |
|
| 2818 | + '0xE5' => '0xD795', '0xE7' => '0xD797', '0xE9' => '0xD799', |
|
| 2819 | + '0xFD' => '0xE2808E', '0xFE' => '0xE2808F', '0x92' => '0xE28099', |
|
| 2820 | + '0x83' => '0xC692', '0xD3' => '0xD783', '0x88' => '0xCB86', |
|
| 2821 | + '0x98' => '0xCB9C', '0x91' => '0xE28098', '0x96' => '0xE28093', |
|
| 2822 | + '0xBA' => '0xC3B7', '0x9B' => '0xE280BA', '0xAA' => '0xC397', |
|
| 2823 | + '0xA4' => '0xE282AA', '0xE1' => '0xD791', '0xE6' => '0xD796', |
|
| 2824 | + '0xE8' => '0xD798', '0xEB' => '0xD79B', '0xF4' => '0xD7A4', |
|
| 2825 | 2825 | '0xFA' => '0xD7AA', |
| 2826 | 2826 | ), |
| 2827 | 2827 | 'windows-1253' => array( |
| 2828 | - '0x81' => '\'\'', '0x88' => '\'\'', '0x8A' => '\'\'', |
|
| 2829 | - '0x8C' => '\'\'', '0x8D' => '\'\'', '0x8E' => '\'\'', |
|
| 2830 | - '0x8F' => '\'\'', '0x90' => '\'\'', '0x98' => '\'\'', |
|
| 2831 | - '0x9A' => '\'\'', '0x9C' => '\'\'', '0x9D' => '\'\'', |
|
| 2832 | - '0x9E' => '\'\'', '0x9F' => '\'\'', '0xAA' => '\'\'', |
|
| 2833 | - '0xD2' => '0xE282AC', '0xFF' => '0xCE92', '0xCE' => '0xCE9E', |
|
| 2834 | - '0xB8' => '0xCE88', '0xBA' => '0xCE8A', '0xBC' => '0xCE8C', |
|
| 2835 | - '0xBE' => '0xCE8E', '0xBF' => '0xCE8F', '0xC0' => '0xCE90', |
|
| 2836 | - '0xC8' => '0xCE98', '0xCA' => '0xCE9A', '0xCC' => '0xCE9C', |
|
| 2837 | - '0xCD' => '0xCE9D', '0xCF' => '0xCE9F', '0xDA' => '0xCEAA', |
|
| 2838 | - '0xE8' => '0xCEB8', '0xEA' => '0xCEBA', '0xEC' => '0xCEBC', |
|
| 2839 | - '0xEE' => '0xCEBE', '0xEF' => '0xCEBF', '0xC2' => '0xFF', |
|
| 2840 | - '0xBD' => '0xC2BD', '0xED' => '0xCEBD', '0xB2' => '0xC2B2', |
|
| 2841 | - '0xA0' => '0xC2A0', '0xA3' => '0xC2A3', '0xA4' => '0xC2A4', |
|
| 2842 | - '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
| 2843 | - '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
| 2844 | - '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
| 2845 | - '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', '0xB3' => '0xC2B3', |
|
| 2846 | - '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
| 2847 | - '0xBB' => '0xC2BB', '0xE2' => '0xCEB2', '0x80' => '0xD2', |
|
| 2848 | - '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
| 2849 | - '0x86' => '0xE280A0', '0xA1' => '0xCE85', '0xA2' => '0xCE86', |
|
| 2850 | - '0x87' => '0xE280A1', '0x89' => '0xE280B0', '0xB9' => '0xCE89', |
|
| 2851 | - '0x8B' => '0xE280B9', '0x91' => '0xE28098', '0x99' => '0xE284A2', |
|
| 2852 | - '0x92' => '0xE28099', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
| 2853 | - '0x95' => '0xE280A2', '0x96' => '0xE28093', '0x97' => '0xE28094', |
|
| 2854 | - '0x9B' => '0xE280BA', '0xAF' => '0xE28095', '0xB4' => '0xCE84', |
|
| 2855 | - '0xC1' => '0xCE91', '0xC3' => '0xCE93', '0xC4' => '0xCE94', |
|
| 2856 | - '0xC5' => '0xCE95', '0xC6' => '0xCE96', '0x83' => '0xC692', |
|
| 2857 | - '0xC7' => '0xCE97', '0xC9' => '0xCE99', '0xCB' => '0xCE9B', |
|
| 2858 | - '0xD0' => '0xCEA0', '0xD1' => '0xCEA1', '0xD3' => '0xCEA3', |
|
| 2859 | - '0xD4' => '0xCEA4', '0xD5' => '0xCEA5', '0xD6' => '0xCEA6', |
|
| 2860 | - '0xD7' => '0xCEA7', '0xD8' => '0xCEA8', '0xD9' => '0xCEA9', |
|
| 2861 | - '0xDB' => '0xCEAB', '0xDC' => '0xCEAC', '0xDD' => '0xCEAD', |
|
| 2862 | - '0xDE' => '0xCEAE', '0xDF' => '0xCEAF', '0xE0' => '0xCEB0', |
|
| 2863 | - '0xE1' => '0xCEB1', '0xE3' => '0xCEB3', '0xE4' => '0xCEB4', |
|
| 2864 | - '0xE5' => '0xCEB5', '0xE6' => '0xCEB6', '0xE7' => '0xCEB7', |
|
| 2865 | - '0xE9' => '0xCEB9', '0xEB' => '0xCEBB', '0xF0' => '0xCF80', |
|
| 2866 | - '0xF1' => '0xCF81', '0xF2' => '0xCF82', '0xF3' => '0xCF83', |
|
| 2867 | - '0xF4' => '0xCF84', '0xF5' => '0xCF85', '0xF6' => '0xCF86', |
|
| 2868 | - '0xF7' => '0xCF87', '0xF8' => '0xCF88', '0xF9' => '0xCF89', |
|
| 2869 | - '0xFA' => '0xCF8A', '0xFB' => '0xCF8B', '0xFC' => '0xCF8C', |
|
| 2870 | - '0xFD' => '0xCF8D', '0xFE' => '0xCF8E', |
|
| 2828 | + '0x81' => '\'\'', '0x88' => '\'\'', '0x8A' => '\'\'', |
|
| 2829 | + '0x8C' => '\'\'', '0x8D' => '\'\'', '0x8E' => '\'\'', |
|
| 2830 | + '0x8F' => '\'\'', '0x90' => '\'\'', '0x98' => '\'\'', |
|
| 2831 | + '0x9A' => '\'\'', '0x9C' => '\'\'', '0x9D' => '\'\'', |
|
| 2832 | + '0x9E' => '\'\'', '0x9F' => '\'\'', '0xAA' => '\'\'', |
|
| 2833 | + '0xD2' => '0xE282AC', '0xFF' => '0xCE92', '0xCE' => '0xCE9E', |
|
| 2834 | + '0xB8' => '0xCE88', '0xBA' => '0xCE8A', '0xBC' => '0xCE8C', |
|
| 2835 | + '0xBE' => '0xCE8E', '0xBF' => '0xCE8F', '0xC0' => '0xCE90', |
|
| 2836 | + '0xC8' => '0xCE98', '0xCA' => '0xCE9A', '0xCC' => '0xCE9C', |
|
| 2837 | + '0xCD' => '0xCE9D', '0xCF' => '0xCE9F', '0xDA' => '0xCEAA', |
|
| 2838 | + '0xE8' => '0xCEB8', '0xEA' => '0xCEBA', '0xEC' => '0xCEBC', |
|
| 2839 | + '0xEE' => '0xCEBE', '0xEF' => '0xCEBF', '0xC2' => '0xFF', |
|
| 2840 | + '0xBD' => '0xC2BD', '0xED' => '0xCEBD', '0xB2' => '0xC2B2', |
|
| 2841 | + '0xA0' => '0xC2A0', '0xA3' => '0xC2A3', '0xA4' => '0xC2A4', |
|
| 2842 | + '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
| 2843 | + '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
| 2844 | + '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
| 2845 | + '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', '0xB3' => '0xC2B3', |
|
| 2846 | + '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
| 2847 | + '0xBB' => '0xC2BB', '0xE2' => '0xCEB2', '0x80' => '0xD2', |
|
| 2848 | + '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
| 2849 | + '0x86' => '0xE280A0', '0xA1' => '0xCE85', '0xA2' => '0xCE86', |
|
| 2850 | + '0x87' => '0xE280A1', '0x89' => '0xE280B0', '0xB9' => '0xCE89', |
|
| 2851 | + '0x8B' => '0xE280B9', '0x91' => '0xE28098', '0x99' => '0xE284A2', |
|
| 2852 | + '0x92' => '0xE28099', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
| 2853 | + '0x95' => '0xE280A2', '0x96' => '0xE28093', '0x97' => '0xE28094', |
|
| 2854 | + '0x9B' => '0xE280BA', '0xAF' => '0xE28095', '0xB4' => '0xCE84', |
|
| 2855 | + '0xC1' => '0xCE91', '0xC3' => '0xCE93', '0xC4' => '0xCE94', |
|
| 2856 | + '0xC5' => '0xCE95', '0xC6' => '0xCE96', '0x83' => '0xC692', |
|
| 2857 | + '0xC7' => '0xCE97', '0xC9' => '0xCE99', '0xCB' => '0xCE9B', |
|
| 2858 | + '0xD0' => '0xCEA0', '0xD1' => '0xCEA1', '0xD3' => '0xCEA3', |
|
| 2859 | + '0xD4' => '0xCEA4', '0xD5' => '0xCEA5', '0xD6' => '0xCEA6', |
|
| 2860 | + '0xD7' => '0xCEA7', '0xD8' => '0xCEA8', '0xD9' => '0xCEA9', |
|
| 2861 | + '0xDB' => '0xCEAB', '0xDC' => '0xCEAC', '0xDD' => '0xCEAD', |
|
| 2862 | + '0xDE' => '0xCEAE', '0xDF' => '0xCEAF', '0xE0' => '0xCEB0', |
|
| 2863 | + '0xE1' => '0xCEB1', '0xE3' => '0xCEB3', '0xE4' => '0xCEB4', |
|
| 2864 | + '0xE5' => '0xCEB5', '0xE6' => '0xCEB6', '0xE7' => '0xCEB7', |
|
| 2865 | + '0xE9' => '0xCEB9', '0xEB' => '0xCEBB', '0xF0' => '0xCF80', |
|
| 2866 | + '0xF1' => '0xCF81', '0xF2' => '0xCF82', '0xF3' => '0xCF83', |
|
| 2867 | + '0xF4' => '0xCF84', '0xF5' => '0xCF85', '0xF6' => '0xCF86', |
|
| 2868 | + '0xF7' => '0xCF87', '0xF8' => '0xCF88', '0xF9' => '0xCF89', |
|
| 2869 | + '0xFA' => '0xCF8A', '0xFB' => '0xCF8B', '0xFC' => '0xCF8C', |
|
| 2870 | + '0xFD' => '0xCF8D', '0xFE' => '0xCF8E', |
|
| 2871 | 2871 | ), |
| 2872 | 2872 | ); |
| 2873 | 2873 | |
@@ -3081,7 +3081,7 @@ discard block |
||
| 3081 | 3081 | |
| 3082 | 3082 | if ($upcontext['dropping_index'] && $command_line) |
| 3083 | 3083 | { |
| 3084 | - echo "\n" . '', $txt['upgrade_fulltext_error'] ,''; |
|
| 3084 | + echo "\n" . '', $txt['upgrade_fulltext_error'], ''; |
|
| 3085 | 3085 | flush(); |
| 3086 | 3086 | } |
| 3087 | 3087 | } |
@@ -3425,7 +3425,7 @@ discard block |
||
| 3425 | 3425 | { |
| 3426 | 3426 | echo ' |
| 3427 | 3427 | <div class="error"> |
| 3428 | - <p>', $txt['upgrade_writable_files'] ,'</p> |
|
| 3428 | + <p>', $txt['upgrade_writable_files'], '</p> |
|
| 3429 | 3429 | <ul class="error_content"> |
| 3430 | 3430 | <li>' . implode('</li> |
| 3431 | 3431 | <li>', $upcontext['chmod']['files']) . '</li> |
@@ -3791,12 +3791,12 @@ discard block |
||
| 3791 | 3791 | <div class="errorbox"> |
| 3792 | 3792 | <h3>', $txt['upgrade_warning'], '</h3> |
| 3793 | 3793 | <p>', sprintf($txt['upgrade_time_user'], $upcontext['user']['name']), '</p> |
| 3794 | - <p>', sprintf($txt[$agoTxt], $ago_seconds, $ago_minutes, $ago_hours), '</p> |
|
| 3794 | + <p>', sprintf($txt[$agoTxt], $ago_seconds, $ago_minutes, $ago_hours), '</p> |
|
| 3795 | 3795 | <p>', sprintf($txt[$updatedTxt], $updated_seconds, $updated_minutes, $updated_hours), '</p>'; |
| 3796 | 3796 | |
| 3797 | 3797 | if ($updated < 600) |
| 3798 | 3798 | echo ' |
| 3799 | - <p>', $txt['upgrade_run_script'], ' ', $upcontext['user']['name'],' ', $txt['upgrade_run_script2'], '</p>'; |
|
| 3799 | + <p>', $txt['upgrade_run_script'], ' ', $upcontext['user']['name'], ' ', $txt['upgrade_run_script2'], '</p>'; |
|
| 3800 | 3800 | |
| 3801 | 3801 | if ($updated > $upcontext['inactive_timeout']) |
| 3802 | 3802 | echo ' |
@@ -3905,7 +3905,7 @@ discard block |
||
| 3905 | 3905 | if (!empty($upcontext['upgrade_options_warning'])) |
| 3906 | 3906 | echo ' |
| 3907 | 3907 | <div class="errorbox"> |
| 3908 | - <h3>', $txt['upgrade_warning'] ,'</h3> |
|
| 3908 | + <h3>', $txt['upgrade_warning'], '</h3> |
|
| 3909 | 3909 | ', $upcontext['upgrade_options_warning'], ' |
| 3910 | 3910 | </div>'; |
| 3911 | 3911 | |
@@ -3969,7 +3969,7 @@ discard block |
||
| 3969 | 3969 | echo ' |
| 3970 | 3970 | <form action="', $upcontext['form_url'], '" name="upform" id="upform" method="post"> |
| 3971 | 3971 | <input type="hidden" name="backup_done" id="backup_done" value="0"> |
| 3972 | - <strong>', sprintf($txt['upgrade_completedtables_outof'], $upcontext['cur_table_num'], $upcontext['table_count']) ,'</strong> |
|
| 3972 | + <strong>', sprintf($txt['upgrade_completedtables_outof'], $upcontext['cur_table_num'], $upcontext['table_count']), '</strong> |
|
| 3973 | 3973 | <div id="debug_section"> |
| 3974 | 3974 | <span id="debuginfo"></span> |
| 3975 | 3975 | </div>'; |
@@ -75,8 +75,9 @@ discard block |
||
| 75 | 75 | $upcontext['inactive_timeout'] = 10; |
| 76 | 76 | |
| 77 | 77 | // The helper is crucial. Include it first thing. |
| 78 | -if (!file_exists($upgrade_path . '/upgrade-helper.php')) |
|
| 78 | +if (!file_exists($upgrade_path . '/upgrade-helper.php')) { |
|
| 79 | 79 | die('upgrade-helper.php not found where it was expected: ' . $upgrade_path . '/upgrade-helper.php! Make sure you have uploaded ALL files from the upgrade package. The upgrader cannot continue.'); |
| 80 | +} |
|
| 80 | 81 | |
| 81 | 82 | require_once($upgrade_path . '/upgrade-helper.php'); |
| 82 | 83 | |
@@ -107,11 +108,14 @@ discard block |
||
| 107 | 108 | ini_set('default_socket_timeout', 900); |
| 108 | 109 | } |
| 109 | 110 | // Clean the upgrade path if this is from the client. |
| 110 | -if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) |
|
| 111 | - for ($i = 1; $i < $_SERVER['argc']; $i++) |
|
| 111 | +if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) { |
|
| 112 | + for ($i = 1; |
|
| 113 | +} |
|
| 114 | +$i < $_SERVER['argc']; $i++) |
|
| 112 | 115 | { |
| 113 | - if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) |
|
| 114 | - $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
| 116 | + if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) { |
|
| 117 | + $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
| 118 | + } |
|
| 115 | 119 | } |
| 116 | 120 | |
| 117 | 121 | // Are we from the client? |
@@ -119,16 +123,17 @@ discard block |
||
| 119 | 123 | { |
| 120 | 124 | $command_line = true; |
| 121 | 125 | $disable_security = true; |
| 122 | -} |
|
| 123 | -else |
|
| 126 | +} else { |
|
| 124 | 127 | $command_line = false; |
| 128 | +} |
|
| 125 | 129 | |
| 126 | 130 | // Load this now just because we can. |
| 127 | 131 | require_once($upgrade_path . '/Settings.php'); |
| 128 | 132 | |
| 129 | 133 | // We don't use "-utf8" anymore... Tweak the entry that may have been loaded by Settings.php |
| 130 | -if (isset($language)) |
|
| 134 | +if (isset($language)) { |
|
| 131 | 135 | $language = str_ireplace('-utf8', '', $language); |
| 136 | +} |
|
| 132 | 137 | |
| 133 | 138 | // Are we logged in? |
| 134 | 139 | if (isset($upgradeData)) |
@@ -136,10 +141,12 @@ discard block |
||
| 136 | 141 | $upcontext['user'] = json_decode(base64_decode($upgradeData), true); |
| 137 | 142 | |
| 138 | 143 | // Check for sensible values. |
| 139 | - if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) |
|
| 140 | - $upcontext['user']['started'] = time(); |
|
| 141 | - if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) |
|
| 142 | - $upcontext['user']['updated'] = 0; |
|
| 144 | + if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) { |
|
| 145 | + $upcontext['user']['started'] = time(); |
|
| 146 | + } |
|
| 147 | + if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) { |
|
| 148 | + $upcontext['user']['updated'] = 0; |
|
| 149 | + } |
|
| 143 | 150 | |
| 144 | 151 | $upcontext['started'] = $upcontext['user']['started']; |
| 145 | 152 | $upcontext['updated'] = $upcontext['user']['updated']; |
@@ -204,8 +211,9 @@ discard block |
||
| 204 | 211 | 'db_error_skip' => true, |
| 205 | 212 | ) |
| 206 | 213 | ); |
| 207 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 208 | - $modSettings[$row['variable']] = $row['value']; |
|
| 214 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 215 | + $modSettings[$row['variable']] = $row['value']; |
|
| 216 | + } |
|
| 209 | 217 | $smcFunc['db_free_result']($request); |
| 210 | 218 | } |
| 211 | 219 | |
@@ -215,14 +223,17 @@ discard block |
||
| 215 | 223 | $modSettings['theme_url'] = 'Themes/default'; |
| 216 | 224 | $modSettings['images_url'] = 'Themes/default/images'; |
| 217 | 225 | } |
| 218 | -if (!isset($settings['default_theme_url'])) |
|
| 226 | +if (!isset($settings['default_theme_url'])) { |
|
| 219 | 227 | $settings['default_theme_url'] = $modSettings['theme_url']; |
| 220 | -if (!isset($settings['default_theme_dir'])) |
|
| 228 | +} |
|
| 229 | +if (!isset($settings['default_theme_dir'])) { |
|
| 221 | 230 | $settings['default_theme_dir'] = $modSettings['theme_dir']; |
| 231 | +} |
|
| 222 | 232 | |
| 223 | 233 | // This is needed in case someone invokes the upgrader using https when upgrading an http forum |
| 224 | -if (httpsOn()) |
|
| 234 | +if (httpsOn()) { |
|
| 225 | 235 | $settings['default_theme_url'] = strtr($settings['default_theme_url'], array('http://' => 'https://')); |
| 236 | +} |
|
| 226 | 237 | |
| 227 | 238 | $upcontext['is_large_forum'] = (empty($modSettings['smfVersion']) || $modSettings['smfVersion'] <= '1.1 RC1') && !empty($modSettings['totalMessages']) && $modSettings['totalMessages'] > 75000; |
| 228 | 239 | // Default title... |
@@ -240,13 +251,15 @@ discard block |
||
| 240 | 251 | $support_js = $upcontext['upgrade_status']['js']; |
| 241 | 252 | |
| 242 | 253 | // Only set this if the upgrader status says so. |
| 243 | - if (empty($is_debug)) |
|
| 244 | - $is_debug = $upcontext['upgrade_status']['debug']; |
|
| 254 | + if (empty($is_debug)) { |
|
| 255 | + $is_debug = $upcontext['upgrade_status']['debug']; |
|
| 256 | + } |
|
| 245 | 257 | |
| 246 | 258 | // Load the language. |
| 247 | - if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 248 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 249 | -} |
|
| 259 | + if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 260 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 261 | + } |
|
| 262 | + } |
|
| 250 | 263 | // Set the defaults. |
| 251 | 264 | else |
| 252 | 265 | { |
@@ -264,15 +277,18 @@ discard block |
||
| 264 | 277 | } |
| 265 | 278 | |
| 266 | 279 | // If this isn't the first stage see whether they are logging in and resuming. |
| 267 | -if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) |
|
| 280 | +if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) { |
|
| 268 | 281 | checkLogin(); |
| 282 | +} |
|
| 269 | 283 | |
| 270 | -if ($command_line) |
|
| 284 | +if ($command_line) { |
|
| 271 | 285 | cmdStep0(); |
| 286 | +} |
|
| 272 | 287 | |
| 273 | 288 | // Don't error if we're using xml. |
| 274 | -if (isset($_GET['xml'])) |
|
| 289 | +if (isset($_GET['xml'])) { |
|
| 275 | 290 | $upcontext['return_error'] = true; |
| 291 | +} |
|
| 276 | 292 | |
| 277 | 293 | // Loop through all the steps doing each one as required. |
| 278 | 294 | $upcontext['overall_percent'] = 0; |
@@ -293,9 +309,9 @@ discard block |
||
| 293 | 309 | } |
| 294 | 310 | |
| 295 | 311 | // Call the step and if it returns false that means pause! |
| 296 | - if (function_exists($step[2]) && $step[2]() === false) |
|
| 297 | - break; |
|
| 298 | - elseif (function_exists($step[2])) { |
|
| 312 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
| 313 | + break; |
|
| 314 | + } elseif (function_exists($step[2])) { |
|
| 299 | 315 | //Start each new step with this unset, so the 'normal' template is called first |
| 300 | 316 | unset($_GET['xml']); |
| 301 | 317 | //Clear out warnings at the start of each step |
@@ -341,17 +357,18 @@ discard block |
||
| 341 | 357 | // This should not happen my dear... HELP ME DEVELOPERS!! |
| 342 | 358 | if (!empty($command_line)) |
| 343 | 359 | { |
| 344 | - if (function_exists('debug_print_backtrace')) |
|
| 345 | - debug_print_backtrace(); |
|
| 360 | + if (function_exists('debug_print_backtrace')) { |
|
| 361 | + debug_print_backtrace(); |
|
| 362 | + } |
|
| 346 | 363 | |
| 347 | 364 | echo "\n" . 'Error: Unexpected call to use the ' . (isset($upcontext['sub_template']) ? $upcontext['sub_template'] : '') . ' template. Please copy and paste all the text above and visit the SMF support forum to tell the Developers that they\'ve made a boo boo; they\'ll get you up and running again.'; |
| 348 | 365 | flush(); |
| 349 | 366 | die(); |
| 350 | 367 | } |
| 351 | 368 | |
| 352 | - if (!isset($_GET['xml'])) |
|
| 353 | - template_upgrade_above(); |
|
| 354 | - else |
|
| 369 | + if (!isset($_GET['xml'])) { |
|
| 370 | + template_upgrade_above(); |
|
| 371 | + } else |
|
| 355 | 372 | { |
| 356 | 373 | header('content-type: text/xml; charset=UTF-8'); |
| 357 | 374 | // Sadly we need to retain the $_GET data thanks to the old upgrade scripts. |
@@ -373,25 +390,29 @@ discard block |
||
| 373 | 390 | $upcontext['form_url'] = $upgradeurl . '?step=' . $upcontext['current_step'] . '&substep=' . $_GET['substep'] . '&data=' . base64_encode(json_encode($upcontext['upgrade_status'])); |
| 374 | 391 | |
| 375 | 392 | // Custom stuff to pass back? |
| 376 | - if (!empty($upcontext['query_string'])) |
|
| 377 | - $upcontext['form_url'] .= $upcontext['query_string']; |
|
| 393 | + if (!empty($upcontext['query_string'])) { |
|
| 394 | + $upcontext['form_url'] .= $upcontext['query_string']; |
|
| 395 | + } |
|
| 378 | 396 | |
| 379 | 397 | // Call the appropriate subtemplate |
| 380 | - if (is_callable('template_' . $upcontext['sub_template'])) |
|
| 381 | - call_user_func('template_' . $upcontext['sub_template']); |
|
| 382 | - else |
|
| 383 | - die('Upgrade aborted! Invalid template: template_' . $upcontext['sub_template']); |
|
| 398 | + if (is_callable('template_' . $upcontext['sub_template'])) { |
|
| 399 | + call_user_func('template_' . $upcontext['sub_template']); |
|
| 400 | + } else { |
|
| 401 | + die('Upgrade aborted! Invalid template: template_' . $upcontext['sub_template']); |
|
| 402 | + } |
|
| 384 | 403 | } |
| 385 | 404 | |
| 386 | 405 | // Was there an error? |
| 387 | - if (!empty($upcontext['forced_error_message'])) |
|
| 388 | - echo $upcontext['forced_error_message']; |
|
| 406 | + if (!empty($upcontext['forced_error_message'])) { |
|
| 407 | + echo $upcontext['forced_error_message']; |
|
| 408 | + } |
|
| 389 | 409 | |
| 390 | 410 | // Show the footer. |
| 391 | - if (!isset($_GET['xml'])) |
|
| 392 | - template_upgrade_below(); |
|
| 393 | - else |
|
| 394 | - template_xml_below(); |
|
| 411 | + if (!isset($_GET['xml'])) { |
|
| 412 | + template_upgrade_below(); |
|
| 413 | + } else { |
|
| 414 | + template_xml_below(); |
|
| 415 | + } |
|
| 395 | 416 | } |
| 396 | 417 | |
| 397 | 418 | // Show the upgrade time for CLI when we are completely done, if in debug mode. |
@@ -403,12 +424,13 @@ discard block |
||
| 403 | 424 | $seconds = intval($active % 60); |
| 404 | 425 | |
| 405 | 426 | $totalTime = ''; |
| 406 | - if ($hours > 0) |
|
| 407 | - echo "\n" . '', sprintf($txt['upgrade_completed_time_hms'], $hours, $minutes, $seconds), '' . "\n"; |
|
| 408 | - elseif ($minutes > 0) |
|
| 409 | - echo "\n" . '', sprintf($txt['upgrade_completed_time_ms'], $minutes, $seconds), '' . "\n"; |
|
| 410 | - elseif ($seconds > 0) |
|
| 411 | - echo "\n" . '', sprintf($txt['upgrade_completed_time_s'], $seconds), '' . "\n"; |
|
| 427 | + if ($hours > 0) { |
|
| 428 | + echo "\n" . '', sprintf($txt['upgrade_completed_time_hms'], $hours, $minutes, $seconds), '' . "\n"; |
|
| 429 | + } elseif ($minutes > 0) { |
|
| 430 | + echo "\n" . '', sprintf($txt['upgrade_completed_time_ms'], $minutes, $seconds), '' . "\n"; |
|
| 431 | + } elseif ($seconds > 0) { |
|
| 432 | + echo "\n" . '', sprintf($txt['upgrade_completed_time_s'], $seconds), '' . "\n"; |
|
| 433 | + } |
|
| 412 | 434 | } |
| 413 | 435 | |
| 414 | 436 | // Bang - gone! |
@@ -429,8 +451,9 @@ discard block |
||
| 429 | 451 | $dir = dir(dirname(__FILE__) . '/Themes/default/languages'); |
| 430 | 452 | while ($entry = $dir->read()) |
| 431 | 453 | { |
| 432 | - if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') |
|
| 433 | - $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
| 454 | + if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') { |
|
| 455 | + $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
| 456 | + } |
|
| 434 | 457 | } |
| 435 | 458 | $dir->close(); |
| 436 | 459 | } |
@@ -474,10 +497,11 @@ discard block |
||
| 474 | 497 | } |
| 475 | 498 | |
| 476 | 499 | // Override the language file? |
| 477 | - if (isset($_GET['lang_file'])) |
|
| 478 | - $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
| 479 | - elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) |
|
| 480 | - $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
| 500 | + if (isset($_GET['lang_file'])) { |
|
| 501 | + $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
| 502 | + } elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) { |
|
| 503 | + $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
| 504 | + } |
|
| 481 | 505 | |
| 482 | 506 | // Make sure it exists, if it doesn't reset it. |
| 483 | 507 | 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'])) |
@@ -486,12 +510,14 @@ discard block |
||
| 486 | 510 | list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
| 487 | 511 | |
| 488 | 512 | // If we have english and some other language, use the other language. We Americans hate english :P. |
| 489 | - if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) |
|
| 490 | - list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
| 513 | + if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) { |
|
| 514 | + list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
| 515 | + } |
|
| 491 | 516 | |
| 492 | 517 | // For backup we load the english at first -> second language overwrite the english one |
| 493 | - if (count($incontext['detected_languages']) > 1) |
|
| 494 | - require_once(dirname(__FILE__) . '/Themes/default/languages/Install.english.php'); |
|
| 518 | + if (count($incontext['detected_languages']) > 1) { |
|
| 519 | + require_once(dirname(__FILE__) . '/Themes/default/languages/Install.english.php'); |
|
| 520 | + } |
|
| 495 | 521 | } |
| 496 | 522 | |
| 497 | 523 | // And now include the actual language file itself. |
@@ -499,11 +525,12 @@ discard block |
||
| 499 | 525 | |
| 500 | 526 | // Which language did we load? Assume that he likes his language. |
| 501 | 527 | preg_match('~^Install\.(.+[^-utf8])\.php$~', $_SESSION['installer_temp_lang'], $matches); |
| 502 | - if (empty($matches[1])) |
|
| 503 | - $matches = [ |
|
| 528 | + if (empty($matches[1])) { |
|
| 529 | + $matches = [ |
|
| 504 | 530 | 0 => 'nothing', |
| 505 | 531 | 1 => 'english', |
| 506 | 532 | ]; |
| 533 | + } |
|
| 507 | 534 | $user_info['language'] = $matches[1]; |
| 508 | 535 | } |
| 509 | 536 | |
@@ -513,8 +540,9 @@ discard block |
||
| 513 | 540 | global $upgradeurl, $upcontext, $command_line; |
| 514 | 541 | |
| 515 | 542 | // Command line users can't be redirected. |
| 516 | - if ($command_line) |
|
| 517 | - upgradeExit(true); |
|
| 543 | + if ($command_line) { |
|
| 544 | + upgradeExit(true); |
|
| 545 | + } |
|
| 518 | 546 | |
| 519 | 547 | // Are we providing the core info? |
| 520 | 548 | if ($addForm) |
@@ -540,12 +568,14 @@ discard block |
||
| 540 | 568 | define('SMF', 1); |
| 541 | 569 | |
| 542 | 570 | // Start the session. |
| 543 | - if (@ini_get('session.save_handler') == 'user') |
|
| 544 | - @ini_set('session.save_handler', 'files'); |
|
| 571 | + if (@ini_get('session.save_handler') == 'user') { |
|
| 572 | + @ini_set('session.save_handler', 'files'); |
|
| 573 | + } |
|
| 545 | 574 | @session_start(); |
| 546 | 575 | |
| 547 | - if (empty($smcFunc)) |
|
| 548 | - $smcFunc = array(); |
|
| 576 | + if (empty($smcFunc)) { |
|
| 577 | + $smcFunc = array(); |
|
| 578 | + } |
|
| 549 | 579 | |
| 550 | 580 | // We need this for authentication and some upgrade code |
| 551 | 581 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -576,30 +606,34 @@ discard block |
||
| 576 | 606 | { |
| 577 | 607 | $options = array('non_fatal' => true); |
| 578 | 608 | // Add in the port if needed |
| 579 | - if (!empty($db_port)) |
|
| 580 | - $options['port'] = $db_port; |
|
| 609 | + if (!empty($db_port)) { |
|
| 610 | + $options['port'] = $db_port; |
|
| 611 | + } |
|
| 581 | 612 | |
| 582 | - if (!empty($db_mb4)) |
|
| 583 | - $options['db_mb4'] = $db_mb4; |
|
| 613 | + if (!empty($db_mb4)) { |
|
| 614 | + $options['db_mb4'] = $db_mb4; |
|
| 615 | + } |
|
| 584 | 616 | |
| 585 | 617 | $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $options); |
| 586 | - } |
|
| 587 | - else |
|
| 588 | - // If we've returned here, ping/reconnect to be safe |
|
| 618 | + } else { |
|
| 619 | + // If we've returned here, ping/reconnect to be safe |
|
| 589 | 620 | $smcFunc['db_ping']($db_connection); |
| 621 | + } |
|
| 590 | 622 | |
| 591 | 623 | // Oh dear god!! |
| 592 | - if ($db_connection === null) |
|
| 593 | - die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
| 624 | + if ($db_connection === null) { |
|
| 625 | + die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
| 626 | + } |
|
| 594 | 627 | |
| 595 | - if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) |
|
| 596 | - $smcFunc['db_query']('', ' |
|
| 628 | + if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) { |
|
| 629 | + $smcFunc['db_query']('', ' |
|
| 597 | 630 | SET NAMES {string:db_character_set}', |
| 598 | 631 | array( |
| 599 | 632 | 'db_error_skip' => true, |
| 600 | 633 | 'db_character_set' => $db_character_set, |
| 601 | 634 | ) |
| 602 | 635 | ); |
| 636 | + } |
|
| 603 | 637 | |
| 604 | 638 | // Load the modSettings data... |
| 605 | 639 | $request = $smcFunc['db_query']('', ' |
@@ -610,11 +644,11 @@ discard block |
||
| 610 | 644 | ) |
| 611 | 645 | ); |
| 612 | 646 | $modSettings = array(); |
| 613 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 614 | - $modSettings[$row['variable']] = $row['value']; |
|
| 647 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 648 | + $modSettings[$row['variable']] = $row['value']; |
|
| 649 | + } |
|
| 615 | 650 | $smcFunc['db_free_result']($request); |
| 616 | - } |
|
| 617 | - else |
|
| 651 | + } else |
|
| 618 | 652 | { |
| 619 | 653 | 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.'); |
| 620 | 654 | } |
@@ -628,9 +662,10 @@ discard block |
||
| 628 | 662 | cleanRequest(); |
| 629 | 663 | } |
| 630 | 664 | |
| 631 | - if (!isset($_GET['substep'])) |
|
| 632 | - $_GET['substep'] = 0; |
|
| 633 | -} |
|
| 665 | + if (!isset($_GET['substep'])) { |
|
| 666 | + $_GET['substep'] = 0; |
|
| 667 | + } |
|
| 668 | + } |
|
| 634 | 669 | |
| 635 | 670 | function initialize_inputs() |
| 636 | 671 | { |
@@ -660,8 +695,9 @@ discard block |
||
| 660 | 695 | $dh = opendir(dirname(__FILE__)); |
| 661 | 696 | while ($file = readdir($dh)) |
| 662 | 697 | { |
| 663 | - if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) |
|
| 664 | - @unlink(dirname(__FILE__) . '/' . $file); |
|
| 698 | + if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) { |
|
| 699 | + @unlink(dirname(__FILE__) . '/' . $file); |
|
| 700 | + } |
|
| 665 | 701 | } |
| 666 | 702 | closedir($dh); |
| 667 | 703 | |
@@ -690,8 +726,9 @@ discard block |
||
| 690 | 726 | $temp = 'upgrade_php?step'; |
| 691 | 727 | while (strlen($temp) > 4) |
| 692 | 728 | { |
| 693 | - if (isset($_GET[$temp])) |
|
| 694 | - unset($_GET[$temp]); |
|
| 729 | + if (isset($_GET[$temp])) { |
|
| 730 | + unset($_GET[$temp]); |
|
| 731 | + } |
|
| 695 | 732 | $temp = substr($temp, 1); |
| 696 | 733 | } |
| 697 | 734 | |
@@ -718,32 +755,39 @@ discard block |
||
| 718 | 755 | && @file_exists(dirname(__FILE__) . '/upgrade_2-1_' . $db_type . '.sql'); |
| 719 | 756 | |
| 720 | 757 | // Need legacy scripts? |
| 721 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) |
|
| 722 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
| 723 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) |
|
| 724 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
| 725 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) |
|
| 726 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
| 758 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) { |
|
| 759 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
| 760 | + } |
|
| 761 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) { |
|
| 762 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
| 763 | + } |
|
| 764 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) { |
|
| 765 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
| 766 | + } |
|
| 727 | 767 | |
| 728 | 768 | // We don't need "-utf8" files anymore... |
| 729 | 769 | $upcontext['language'] = str_ireplace('-utf8', '', $upcontext['language']); |
| 730 | 770 | |
| 731 | 771 | // This needs to exist! |
| 732 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 733 | - 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>]'); |
|
| 734 | - else |
|
| 735 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 772 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 773 | + 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>]'); |
|
| 774 | + } else { |
|
| 775 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 776 | + } |
|
| 736 | 777 | |
| 737 | - if (!$check) |
|
| 738 | - // 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. |
|
| 778 | + if (!$check) { |
|
| 779 | + // 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. |
|
| 739 | 780 | 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.'); |
| 781 | + } |
|
| 740 | 782 | |
| 741 | 783 | // Do they meet the install requirements? |
| 742 | - if (!php_version_check()) |
|
| 743 | - 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.'); |
|
| 784 | + if (!php_version_check()) { |
|
| 785 | + 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.'); |
|
| 786 | + } |
|
| 744 | 787 | |
| 745 | - if (!db_version_check()) |
|
| 746 | - 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.'); |
|
| 788 | + if (!db_version_check()) { |
|
| 789 | + 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.'); |
|
| 790 | + } |
|
| 747 | 791 | |
| 748 | 792 | // Do some checks to make sure they have proper privileges |
| 749 | 793 | db_extend('packages'); |
@@ -758,14 +802,16 @@ discard block |
||
| 758 | 802 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
| 759 | 803 | |
| 760 | 804 | // Sorry... we need CREATE, ALTER and DROP |
| 761 | - if (!$create || !$alter || !$drop) |
|
| 762 | - 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.'); |
|
| 805 | + if (!$create || !$alter || !$drop) { |
|
| 806 | + 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.'); |
|
| 807 | + } |
|
| 763 | 808 | |
| 764 | 809 | // Do a quick version spot check. |
| 765 | 810 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
| 766 | 811 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
| 767 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
| 768 | - 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.'); |
|
| 812 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
| 813 | + 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.'); |
|
| 814 | + } |
|
| 769 | 815 | |
| 770 | 816 | // What absolutely needs to be writable? |
| 771 | 817 | $writable_files = array( |
@@ -774,12 +820,13 @@ discard block |
||
| 774 | 820 | ); |
| 775 | 821 | |
| 776 | 822 | // Only check for minified writable files if we have it enabled or not set. |
| 777 | - if (!empty($modSettings['minimize_files']) || !isset($modSettings['minimize_files'])) |
|
| 778 | - $writable_files += array( |
|
| 823 | + if (!empty($modSettings['minimize_files']) || !isset($modSettings['minimize_files'])) { |
|
| 824 | + $writable_files += array( |
|
| 779 | 825 | $modSettings['theme_dir'] . '/css/minified.css', |
| 780 | 826 | $modSettings['theme_dir'] . '/scripts/minified.js', |
| 781 | 827 | $modSettings['theme_dir'] . '/scripts/minified_deferred.js', |
| 782 | 828 | ); |
| 829 | + } |
|
| 783 | 830 | |
| 784 | 831 | // Do we need to add this setting? |
| 785 | 832 | $need_settings_update = empty($modSettings['custom_avatar_dir']); |
@@ -791,12 +838,13 @@ discard block |
||
| 791 | 838 | quickFileWritable($custom_av_dir); |
| 792 | 839 | |
| 793 | 840 | // Are we good now? |
| 794 | - if (!is_writable($custom_av_dir)) |
|
| 795 | - 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)); |
|
| 796 | - elseif ($need_settings_update) |
|
| 841 | + if (!is_writable($custom_av_dir)) { |
|
| 842 | + 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)); |
|
| 843 | + } elseif ($need_settings_update) |
|
| 797 | 844 | { |
| 798 | - if (!function_exists('cache_put_data')) |
|
| 799 | - require_once($sourcedir . '/Load.php'); |
|
| 845 | + if (!function_exists('cache_put_data')) { |
|
| 846 | + require_once($sourcedir . '/Load.php'); |
|
| 847 | + } |
|
| 800 | 848 | |
| 801 | 849 | updateSettings(array('custom_avatar_dir' => $custom_av_dir)); |
| 802 | 850 | updateSettings(array('custom_avatar_url' => $custom_av_url)); |
@@ -806,29 +854,34 @@ discard block |
||
| 806 | 854 | |
| 807 | 855 | // Check the cache directory. |
| 808 | 856 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
| 809 | - if (!file_exists($cachedir_temp)) |
|
| 810 | - @mkdir($cachedir_temp); |
|
| 857 | + if (!file_exists($cachedir_temp)) { |
|
| 858 | + @mkdir($cachedir_temp); |
|
| 859 | + } |
|
| 811 | 860 | |
| 812 | - if (!file_exists($cachedir_temp)) |
|
| 813 | - 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.'); |
|
| 861 | + if (!file_exists($cachedir_temp)) { |
|
| 862 | + 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.'); |
|
| 863 | + } |
|
| 814 | 864 | |
| 815 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
| 816 | - 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>.'); |
|
| 817 | - elseif (!isset($_GET['skiplang'])) |
|
| 865 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
| 866 | + 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>.'); |
|
| 867 | + } elseif (!isset($_GET['skiplang'])) |
|
| 818 | 868 | { |
| 819 | 869 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
| 820 | 870 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 821 | 871 | |
| 822 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 823 | - 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>]'); |
|
| 872 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 873 | + 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>]'); |
|
| 874 | + } |
|
| 824 | 875 | } |
| 825 | 876 | |
| 826 | - if (!makeFilesWritable($writable_files)) |
|
| 827 | - return false; |
|
| 877 | + if (!makeFilesWritable($writable_files)) { |
|
| 878 | + return false; |
|
| 879 | + } |
|
| 828 | 880 | |
| 829 | 881 | // Check agreement.txt. (it may not exist, in which case $boarddir must be writable.) |
| 830 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
| 831 | - 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.'); |
|
| 882 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
| 883 | + 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.'); |
|
| 884 | + } |
|
| 832 | 885 | |
| 833 | 886 | // Upgrade the agreement. |
| 834 | 887 | elseif (isset($modSettings['agreement'])) |
@@ -839,8 +892,8 @@ discard block |
||
| 839 | 892 | } |
| 840 | 893 | |
| 841 | 894 | // We're going to check that their board dir setting is right in case they've been moving stuff around. |
| 842 | - if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) |
|
| 843 | - $upcontext['warning'] = ' |
|
| 895 | + if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) { |
|
| 896 | + $upcontext['warning'] = ' |
|
| 844 | 897 | '. sprintf($txt['upgrade_boarddir_settings'], $boarddir, dirname(__FILE__)) .'<br> |
| 845 | 898 | <ul> |
| 846 | 899 | <li>'. $txt['upgrade_boarddir'] .' ' . $boarddir . '</li> |
@@ -848,19 +901,23 @@ discard block |
||
| 848 | 901 | <li>'. $txt['upgrade_cachedir'] .' ' . $cachedir_temp . '</li> |
| 849 | 902 | </ul> |
| 850 | 903 | '. $txt['upgrade_incorrect_settings'] .''; |
| 904 | + } |
|
| 851 | 905 | |
| 852 | 906 | // Confirm mbstring is loaded... |
| 853 | - if (!extension_loaded('mbstring')) |
|
| 854 | - return throw_error($txt['install_no_mbstring']); |
|
| 907 | + if (!extension_loaded('mbstring')) { |
|
| 908 | + return throw_error($txt['install_no_mbstring']); |
|
| 909 | + } |
|
| 855 | 910 | |
| 856 | 911 | // Check for https stream support. |
| 857 | 912 | $supported_streams = stream_get_wrappers(); |
| 858 | - if (!in_array('https', $supported_streams)) |
|
| 859 | - $upcontext['custom_warning'] = $txt['install_no_https']; |
|
| 913 | + if (!in_array('https', $supported_streams)) { |
|
| 914 | + $upcontext['custom_warning'] = $txt['install_no_https']; |
|
| 915 | + } |
|
| 860 | 916 | |
| 861 | 917 | // Either we're logged in or we're going to present the login. |
| 862 | - if (checkLogin()) |
|
| 863 | - return true; |
|
| 918 | + if (checkLogin()) { |
|
| 919 | + return true; |
|
| 920 | + } |
|
| 864 | 921 | |
| 865 | 922 | $upcontext += createToken('login'); |
| 866 | 923 | |
@@ -874,15 +931,17 @@ discard block |
||
| 874 | 931 | global $smcFunc, $db_type, $support_js; |
| 875 | 932 | |
| 876 | 933 | // Don't bother if the security is disabled. |
| 877 | - if ($disable_security) |
|
| 878 | - return true; |
|
| 934 | + if ($disable_security) { |
|
| 935 | + return true; |
|
| 936 | + } |
|
| 879 | 937 | |
| 880 | 938 | // Are we trying to login? |
| 881 | 939 | if (isset($_POST['contbutt']) && (!empty($_POST['user']))) |
| 882 | 940 | { |
| 883 | 941 | // If we've disabled security pick a suitable name! |
| 884 | - if (empty($_POST['user'])) |
|
| 885 | - $_POST['user'] = 'Administrator'; |
|
| 942 | + if (empty($_POST['user'])) { |
|
| 943 | + $_POST['user'] = 'Administrator'; |
|
| 944 | + } |
|
| 886 | 945 | |
| 887 | 946 | // Before 2.0 these column names were different! |
| 888 | 947 | $oldDB = false; |
@@ -897,16 +956,17 @@ discard block |
||
| 897 | 956 | 'db_error_skip' => true, |
| 898 | 957 | ) |
| 899 | 958 | ); |
| 900 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 901 | - $oldDB = true; |
|
| 959 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 960 | + $oldDB = true; |
|
| 961 | + } |
|
| 902 | 962 | $smcFunc['db_free_result']($request); |
| 903 | 963 | } |
| 904 | 964 | |
| 905 | 965 | // Get what we believe to be their details. |
| 906 | 966 | if (!$disable_security) |
| 907 | 967 | { |
| 908 | - if ($oldDB) |
|
| 909 | - $request = $smcFunc['db_query']('', ' |
|
| 968 | + if ($oldDB) { |
|
| 969 | + $request = $smcFunc['db_query']('', ' |
|
| 910 | 970 | SELECT id_member, memberName AS member_name, passwd, id_group, |
| 911 | 971 | additionalGroups AS additional_groups, lngfile |
| 912 | 972 | FROM {db_prefix}members |
@@ -916,8 +976,8 @@ discard block |
||
| 916 | 976 | 'db_error_skip' => true, |
| 917 | 977 | ) |
| 918 | 978 | ); |
| 919 | - else |
|
| 920 | - $request = $smcFunc['db_query']('', ' |
|
| 979 | + } else { |
|
| 980 | + $request = $smcFunc['db_query']('', ' |
|
| 921 | 981 | SELECT id_member, member_name, passwd, id_group, additional_groups, lngfile |
| 922 | 982 | FROM {db_prefix}members |
| 923 | 983 | WHERE member_name = {string:member_name}', |
@@ -926,6 +986,7 @@ discard block |
||
| 926 | 986 | 'db_error_skip' => true, |
| 927 | 987 | ) |
| 928 | 988 | ); |
| 989 | + } |
|
| 929 | 990 | if ($smcFunc['db_num_rows']($request) != 0) |
| 930 | 991 | { |
| 931 | 992 | list ($id_member, $name, $password, $id_group, $addGroups, $user_language) = $smcFunc['db_fetch_row']($request); |
@@ -933,16 +994,17 @@ discard block |
||
| 933 | 994 | $groups = explode(',', $addGroups); |
| 934 | 995 | $groups[] = $id_group; |
| 935 | 996 | |
| 936 | - foreach ($groups as $k => $v) |
|
| 937 | - $groups[$k] = (int) $v; |
|
| 997 | + foreach ($groups as $k => $v) { |
|
| 998 | + $groups[$k] = (int) $v; |
|
| 999 | + } |
|
| 938 | 1000 | |
| 939 | 1001 | $sha_passwd = sha1(strtolower($name) . un_htmlspecialchars($_REQUEST['passwrd'])); |
| 940 | 1002 | |
| 941 | 1003 | // We don't use "-utf8" anymore... |
| 942 | 1004 | $user_language = str_ireplace('-utf8', '', $user_language); |
| 1005 | + } else { |
|
| 1006 | + $upcontext['username_incorrect'] = true; |
|
| 943 | 1007 | } |
| 944 | - else |
|
| 945 | - $upcontext['username_incorrect'] = true; |
|
| 946 | 1008 | |
| 947 | 1009 | $smcFunc['db_free_result']($request); |
| 948 | 1010 | } |
@@ -953,13 +1015,14 @@ discard block |
||
| 953 | 1015 | { |
| 954 | 1016 | $upcontext['upgrade_status']['js'] = 1; |
| 955 | 1017 | $support_js = 1; |
| 1018 | + } else { |
|
| 1019 | + $support_js = 0; |
|
| 956 | 1020 | } |
| 957 | - else |
|
| 958 | - $support_js = 0; |
|
| 959 | 1021 | |
| 960 | 1022 | // Note down the version we are coming from. |
| 961 | - if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) |
|
| 962 | - $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
| 1023 | + if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) { |
|
| 1024 | + $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
| 1025 | + } |
|
| 963 | 1026 | |
| 964 | 1027 | // Didn't get anywhere? |
| 965 | 1028 | 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'])) |
@@ -993,15 +1056,15 @@ discard block |
||
| 993 | 1056 | 'db_error_skip' => true, |
| 994 | 1057 | ) |
| 995 | 1058 | ); |
| 996 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 997 | - return throw_error('You need to be an admin to perform an upgrade!'); |
|
| 1059 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1060 | + return throw_error('You need to be an admin to perform an upgrade!'); |
|
| 1061 | + } |
|
| 998 | 1062 | $smcFunc['db_free_result']($request); |
| 999 | 1063 | } |
| 1000 | 1064 | |
| 1001 | 1065 | $upcontext['user']['id'] = $id_member; |
| 1002 | 1066 | $upcontext['user']['name'] = $name; |
| 1003 | - } |
|
| 1004 | - else |
|
| 1067 | + } else |
|
| 1005 | 1068 | { |
| 1006 | 1069 | $upcontext['user']['id'] = 1; |
| 1007 | 1070 | $upcontext['user']['name'] = 'Administrator'; |
@@ -1017,11 +1080,11 @@ discard block |
||
| 1017 | 1080 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $user_language . '.php')), 0, 4096); |
| 1018 | 1081 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 1019 | 1082 | |
| 1020 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 1021 | - $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'] . '.'; |
|
| 1022 | - elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) |
|
| 1023 | - $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'] . '.'; |
|
| 1024 | - else |
|
| 1083 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 1084 | + $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'] . '.'; |
|
| 1085 | + } elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) { |
|
| 1086 | + $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'] . '.'; |
|
| 1087 | + } else |
|
| 1025 | 1088 | { |
| 1026 | 1089 | // Set this as the new language. |
| 1027 | 1090 | $upcontext['language'] = $user_language; |
@@ -1068,8 +1131,9 @@ discard block |
||
| 1068 | 1131 | $upcontext['migrateSettingsNeeded'] = detectSettingsFileMigrationNeeded() ? 1 : 0; |
| 1069 | 1132 | |
| 1070 | 1133 | // If we've not submitted then we're done. |
| 1071 | - if (empty($_POST['upcont'])) |
|
| 1072 | - return false; |
|
| 1134 | + if (empty($_POST['upcont'])) { |
|
| 1135 | + return false; |
|
| 1136 | + } |
|
| 1073 | 1137 | |
| 1074 | 1138 | // Firstly, if they're enabling SM stat collection just do it. |
| 1075 | 1139 | if (!empty($_POST['stats']) && substr($boardurl, 0, 16) != 'http://localhost' && empty($modSettings['allow_sm_stats']) && empty($modSettings['enable_sm_stats'])) |
@@ -1089,16 +1153,17 @@ discard block |
||
| 1089 | 1153 | fwrite($fp, $out); |
| 1090 | 1154 | |
| 1091 | 1155 | $return_data = ''; |
| 1092 | - while (!feof($fp)) |
|
| 1093 | - $return_data .= fgets($fp, 128); |
|
| 1156 | + while (!feof($fp)) { |
|
| 1157 | + $return_data .= fgets($fp, 128); |
|
| 1158 | + } |
|
| 1094 | 1159 | |
| 1095 | 1160 | fclose($fp); |
| 1096 | 1161 | |
| 1097 | 1162 | // Get the unique site ID. |
| 1098 | 1163 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
| 1099 | 1164 | |
| 1100 | - if (!empty($ID[1])) |
|
| 1101 | - $smcFunc['db_insert']('replace', |
|
| 1165 | + if (!empty($ID[1])) { |
|
| 1166 | + $smcFunc['db_insert']('replace', |
|
| 1102 | 1167 | $db_prefix . 'settings', |
| 1103 | 1168 | array('variable' => 'string', 'value' => 'string'), |
| 1104 | 1169 | array( |
@@ -1107,9 +1172,9 @@ discard block |
||
| 1107 | 1172 | ), |
| 1108 | 1173 | array('variable') |
| 1109 | 1174 | ); |
| 1175 | + } |
|
| 1110 | 1176 | } |
| 1111 | - } |
|
| 1112 | - else |
|
| 1177 | + } else |
|
| 1113 | 1178 | { |
| 1114 | 1179 | $smcFunc['db_insert']('replace', |
| 1115 | 1180 | $db_prefix . 'settings', |
@@ -1120,8 +1185,8 @@ discard block |
||
| 1120 | 1185 | } |
| 1121 | 1186 | } |
| 1122 | 1187 | // Don't remove stat collection unless we unchecked the box for real, not from the loop. |
| 1123 | - elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) |
|
| 1124 | - $smcFunc['db_query']('', ' |
|
| 1188 | + elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) { |
|
| 1189 | + $smcFunc['db_query']('', ' |
|
| 1125 | 1190 | DELETE FROM {db_prefix}settings |
| 1126 | 1191 | WHERE variable = {string:enable_sm_stats}', |
| 1127 | 1192 | array( |
@@ -1129,6 +1194,7 @@ discard block |
||
| 1129 | 1194 | 'db_error_skip' => true, |
| 1130 | 1195 | ) |
| 1131 | 1196 | ); |
| 1197 | + } |
|
| 1132 | 1198 | |
| 1133 | 1199 | // Deleting old karma stuff? |
| 1134 | 1200 | if (!empty($_POST['delete_karma'])) |
@@ -1143,20 +1209,22 @@ discard block |
||
| 1143 | 1209 | ); |
| 1144 | 1210 | |
| 1145 | 1211 | // Cleaning up old karma member settings. |
| 1146 | - if ($upcontext['karma_installed']['good']) |
|
| 1147 | - $smcFunc['db_query']('', ' |
|
| 1212 | + if ($upcontext['karma_installed']['good']) { |
|
| 1213 | + $smcFunc['db_query']('', ' |
|
| 1148 | 1214 | ALTER TABLE {db_prefix}members |
| 1149 | 1215 | DROP karma_good', |
| 1150 | 1216 | array() |
| 1151 | 1217 | ); |
| 1218 | + } |
|
| 1152 | 1219 | |
| 1153 | 1220 | // Does karma bad was enable? |
| 1154 | - if ($upcontext['karma_installed']['bad']) |
|
| 1155 | - $smcFunc['db_query']('', ' |
|
| 1221 | + if ($upcontext['karma_installed']['bad']) { |
|
| 1222 | + $smcFunc['db_query']('', ' |
|
| 1156 | 1223 | ALTER TABLE {db_prefix}members |
| 1157 | 1224 | DROP karma_bad', |
| 1158 | 1225 | array() |
| 1159 | 1226 | ); |
| 1227 | + } |
|
| 1160 | 1228 | |
| 1161 | 1229 | // Cleaning up old karma permissions. |
| 1162 | 1230 | $smcFunc['db_query']('', ' |
@@ -1174,32 +1242,37 @@ discard block |
||
| 1174 | 1242 | } |
| 1175 | 1243 | |
| 1176 | 1244 | // Emptying the error log? |
| 1177 | - if (!empty($_POST['empty_error'])) |
|
| 1178 | - $smcFunc['db_query']('truncate_table', ' |
|
| 1245 | + if (!empty($_POST['empty_error'])) { |
|
| 1246 | + $smcFunc['db_query']('truncate_table', ' |
|
| 1179 | 1247 | TRUNCATE {db_prefix}log_errors', |
| 1180 | 1248 | array( |
| 1181 | 1249 | ) |
| 1182 | 1250 | ); |
| 1251 | + } |
|
| 1183 | 1252 | |
| 1184 | 1253 | $changes = array(); |
| 1185 | 1254 | |
| 1186 | 1255 | // Add proxy settings. |
| 1187 | - if (!isset($GLOBALS['image_proxy_maxsize'])) |
|
| 1188 | - $changes += array( |
|
| 1256 | + if (!isset($GLOBALS['image_proxy_maxsize'])) { |
|
| 1257 | + $changes += array( |
|
| 1189 | 1258 | 'image_proxy_secret' => '\'' . substr(sha1(mt_rand()), 0, 20) . '\'', |
| 1190 | 1259 | 'image_proxy_maxsize' => 5190, |
| 1191 | 1260 | 'image_proxy_enabled' => 0, |
| 1192 | 1261 | ); |
| 1262 | + } |
|
| 1193 | 1263 | |
| 1194 | 1264 | // If $boardurl reflects https, set force_ssl |
| 1195 | - if (!function_exists('cache_put_data')) |
|
| 1196 | - require_once($sourcedir . '/Load.php'); |
|
| 1197 | - if (stripos($boardurl, 'https://') !== false) |
|
| 1198 | - updateSettings(array('force_ssl' => '1')); |
|
| 1265 | + if (!function_exists('cache_put_data')) { |
|
| 1266 | + require_once($sourcedir . '/Load.php'); |
|
| 1267 | + } |
|
| 1268 | + if (stripos($boardurl, 'https://') !== false) { |
|
| 1269 | + updateSettings(array('force_ssl' => '1')); |
|
| 1270 | + } |
|
| 1199 | 1271 | |
| 1200 | 1272 | // If we're overriding the language follow it through. |
| 1201 | - if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) |
|
| 1202 | - $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
| 1273 | + if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) { |
|
| 1274 | + $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
| 1275 | + } |
|
| 1203 | 1276 | |
| 1204 | 1277 | if (!empty($_POST['maint'])) |
| 1205 | 1278 | { |
@@ -1211,26 +1284,29 @@ discard block |
||
| 1211 | 1284 | { |
| 1212 | 1285 | $changes['mtitle'] = '\'' . addslashes($_POST['maintitle']) . '\''; |
| 1213 | 1286 | $changes['mmessage'] = '\'' . addslashes($_POST['mainmessage']) . '\''; |
| 1214 | - } |
|
| 1215 | - else |
|
| 1287 | + } else |
|
| 1216 | 1288 | { |
| 1217 | 1289 | $changes['mtitle'] = '\'Upgrading the forum...\''; |
| 1218 | 1290 | $changes['mmessage'] = '\'Don\\\'t worry, we will be back shortly with an updated forum. It will only be a minute ;).\''; |
| 1219 | 1291 | } |
| 1220 | 1292 | } |
| 1221 | 1293 | |
| 1222 | - if ($command_line) |
|
| 1223 | - echo ' * Updating Settings.php...'; |
|
| 1294 | + if ($command_line) { |
|
| 1295 | + echo ' * Updating Settings.php...'; |
|
| 1296 | + } |
|
| 1224 | 1297 | |
| 1225 | 1298 | // Fix some old paths. |
| 1226 | - if (substr($boarddir, 0, 1) == '.') |
|
| 1227 | - $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
| 1299 | + if (substr($boarddir, 0, 1) == '.') { |
|
| 1300 | + $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
| 1301 | + } |
|
| 1228 | 1302 | |
| 1229 | - if (substr($sourcedir, 0, 1) == '.') |
|
| 1230 | - $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
| 1303 | + if (substr($sourcedir, 0, 1) == '.') { |
|
| 1304 | + $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
| 1305 | + } |
|
| 1231 | 1306 | |
| 1232 | - if (empty($cachedir) || substr($cachedir, 0, 1) == '.') |
|
| 1233 | - $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
| 1307 | + if (empty($cachedir) || substr($cachedir, 0, 1) == '.') { |
|
| 1308 | + $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
| 1309 | + } |
|
| 1234 | 1310 | |
| 1235 | 1311 | // If they have a "host:port" setup for the host, split that into separate values |
| 1236 | 1312 | // You should never have a : in the hostname if you're not on MySQL, but better safe than sorry |
@@ -1241,32 +1317,36 @@ discard block |
||
| 1241 | 1317 | $changes['db_server'] = '\'' . $db_server . '\''; |
| 1242 | 1318 | |
| 1243 | 1319 | // Only set this if we're not using the default port |
| 1244 | - if ($db_port != ini_get('mysqli.default_port')) |
|
| 1245 | - $changes['db_port'] = (int) $db_port; |
|
| 1246 | - } |
|
| 1247 | - elseif (!empty($db_port)) |
|
| 1320 | + if ($db_port != ini_get('mysqli.default_port')) { |
|
| 1321 | + $changes['db_port'] = (int) $db_port; |
|
| 1322 | + } |
|
| 1323 | + } elseif (!empty($db_port)) |
|
| 1248 | 1324 | { |
| 1249 | 1325 | // If db_port is set and is the same as the default, set it to '' |
| 1250 | 1326 | if ($db_type == 'mysql') |
| 1251 | 1327 | { |
| 1252 | - if ($db_port == ini_get('mysqli.default_port')) |
|
| 1253 | - $changes['db_port'] = '\'\''; |
|
| 1254 | - elseif ($db_type == 'postgresql' && $db_port == 5432) |
|
| 1255 | - $changes['db_port'] = '\'\''; |
|
| 1328 | + if ($db_port == ini_get('mysqli.default_port')) { |
|
| 1329 | + $changes['db_port'] = '\'\''; |
|
| 1330 | + } elseif ($db_type == 'postgresql' && $db_port == 5432) { |
|
| 1331 | + $changes['db_port'] = '\'\''; |
|
| 1332 | + } |
|
| 1256 | 1333 | } |
| 1257 | 1334 | } |
| 1258 | 1335 | |
| 1259 | 1336 | // Maybe we haven't had this option yet? |
| 1260 | - if (empty($packagesdir)) |
|
| 1261 | - $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
| 1337 | + if (empty($packagesdir)) { |
|
| 1338 | + $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
| 1339 | + } |
|
| 1262 | 1340 | |
| 1263 | 1341 | // Add support for $tasksdir var. |
| 1264 | - if (empty($tasksdir)) |
|
| 1265 | - $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
| 1342 | + if (empty($tasksdir)) { |
|
| 1343 | + $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
| 1344 | + } |
|
| 1266 | 1345 | |
| 1267 | 1346 | // Make sure we fix the language as well. |
| 1268 | - if (stristr($language, '-utf8')) |
|
| 1269 | - $changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\''; |
|
| 1347 | + if (stristr($language, '-utf8')) { |
|
| 1348 | + $changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\''; |
|
| 1349 | + } |
|
| 1270 | 1350 | |
| 1271 | 1351 | // @todo Maybe change the cookie name if going to 1.1, too? |
| 1272 | 1352 | |
@@ -1277,8 +1357,7 @@ discard block |
||
| 1277 | 1357 | $changes['upgradeData'] = '"' . base64_encode(json_encode($upcontext['user'])) . '"'; |
| 1278 | 1358 | |
| 1279 | 1359 | migrateSettingsFile($changes); |
| 1280 | - } |
|
| 1281 | - else |
|
| 1360 | + } else |
|
| 1282 | 1361 | { |
| 1283 | 1362 | // Update Settings.php with the new settings. |
| 1284 | 1363 | require_once($sourcedir . '/Subs-Admin.php'); |
@@ -1288,8 +1367,9 @@ discard block |
||
| 1288 | 1367 | move_db_last_error_to_cachedir(); |
| 1289 | 1368 | } |
| 1290 | 1369 | |
| 1291 | - if ($command_line) |
|
| 1292 | - echo ' Successful.' . "\n"; |
|
| 1370 | + if ($command_line) { |
|
| 1371 | + echo ' Successful.' . "\n"; |
|
| 1372 | + } |
|
| 1293 | 1373 | |
| 1294 | 1374 | // Are we doing debug? |
| 1295 | 1375 | if (isset($_POST['debug'])) |
@@ -1299,8 +1379,9 @@ discard block |
||
| 1299 | 1379 | } |
| 1300 | 1380 | |
| 1301 | 1381 | // If we're not backing up then jump one. |
| 1302 | - if (empty($_POST['backup'])) |
|
| 1303 | - $upcontext['current_step']++; |
|
| 1382 | + if (empty($_POST['backup'])) { |
|
| 1383 | + $upcontext['current_step']++; |
|
| 1384 | + } |
|
| 1304 | 1385 | |
| 1305 | 1386 | // If we've got here then let's proceed to the next step! |
| 1306 | 1387 | return true; |
@@ -1315,8 +1396,9 @@ discard block |
||
| 1315 | 1396 | $upcontext['page_title'] = $txt['backup_database']; |
| 1316 | 1397 | |
| 1317 | 1398 | // Done it already - js wise? |
| 1318 | - if (!empty($_POST['backup_done'])) |
|
| 1319 | - return true; |
|
| 1399 | + if (!empty($_POST['backup_done'])) { |
|
| 1400 | + return true; |
|
| 1401 | + } |
|
| 1320 | 1402 | |
| 1321 | 1403 | // Some useful stuff here. |
| 1322 | 1404 | db_extend(); |
@@ -1330,9 +1412,10 @@ discard block |
||
| 1330 | 1412 | $tables = $smcFunc['db_list_tables']($db, $filter); |
| 1331 | 1413 | |
| 1332 | 1414 | $table_names = array(); |
| 1333 | - foreach ($tables as $table) |
|
| 1334 | - if (substr($table, 0, 7) !== 'backup_') |
|
| 1415 | + foreach ($tables as $table) { |
|
| 1416 | + if (substr($table, 0, 7) !== 'backup_') |
|
| 1335 | 1417 | $table_names[] = $table; |
| 1418 | + } |
|
| 1336 | 1419 | |
| 1337 | 1420 | $upcontext['table_count'] = count($table_names); |
| 1338 | 1421 | $upcontext['cur_table_num'] = $_GET['substep']; |
@@ -1342,12 +1425,14 @@ discard block |
||
| 1342 | 1425 | $file_steps = $upcontext['table_count']; |
| 1343 | 1426 | |
| 1344 | 1427 | // What ones have we already done? |
| 1345 | - foreach ($table_names as $id => $table) |
|
| 1346 | - if ($id < $_GET['substep']) |
|
| 1428 | + foreach ($table_names as $id => $table) { |
|
| 1429 | + if ($id < $_GET['substep']) |
|
| 1347 | 1430 | $upcontext['previous_tables'][] = $table; |
| 1431 | + } |
|
| 1348 | 1432 | |
| 1349 | - if ($command_line) |
|
| 1350 | - echo 'Backing Up Tables.'; |
|
| 1433 | + if ($command_line) { |
|
| 1434 | + echo 'Backing Up Tables.'; |
|
| 1435 | + } |
|
| 1351 | 1436 | |
| 1352 | 1437 | // If we don't support javascript we backup here. |
| 1353 | 1438 | if (!$support_js || isset($_GET['xml'])) |
@@ -1366,8 +1451,9 @@ discard block |
||
| 1366 | 1451 | backupTable($table_names[$substep]); |
| 1367 | 1452 | |
| 1368 | 1453 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 1369 | - if (isset($_GET['xml'])) |
|
| 1370 | - return upgradeExit(); |
|
| 1454 | + if (isset($_GET['xml'])) { |
|
| 1455 | + return upgradeExit(); |
|
| 1456 | + } |
|
| 1371 | 1457 | } |
| 1372 | 1458 | |
| 1373 | 1459 | if ($command_line) |
@@ -1400,9 +1486,10 @@ discard block |
||
| 1400 | 1486 | |
| 1401 | 1487 | $smcFunc['db_backup_table']($table, 'backup_' . $table); |
| 1402 | 1488 | |
| 1403 | - if ($command_line) |
|
| 1404 | - echo ' done.'; |
|
| 1405 | -} |
|
| 1489 | + if ($command_line) { |
|
| 1490 | + echo ' done.'; |
|
| 1491 | + } |
|
| 1492 | + } |
|
| 1406 | 1493 | |
| 1407 | 1494 | // Step 2: Everything. |
| 1408 | 1495 | function DatabaseChanges() |
@@ -1411,8 +1498,9 @@ discard block |
||
| 1411 | 1498 | global $upcontext, $support_js, $db_type; |
| 1412 | 1499 | |
| 1413 | 1500 | // Have we just completed this? |
| 1414 | - if (!empty($_POST['database_done'])) |
|
| 1415 | - return true; |
|
| 1501 | + if (!empty($_POST['database_done'])) { |
|
| 1502 | + return true; |
|
| 1503 | + } |
|
| 1416 | 1504 | |
| 1417 | 1505 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'database_xml' : 'database_changes'; |
| 1418 | 1506 | $upcontext['page_title'] = $txt['database_changes']; |
@@ -1427,15 +1515,16 @@ discard block |
||
| 1427 | 1515 | ); |
| 1428 | 1516 | |
| 1429 | 1517 | // How many files are there in total? |
| 1430 | - if (isset($_GET['filecount'])) |
|
| 1431 | - $upcontext['file_count'] = (int) $_GET['filecount']; |
|
| 1432 | - else |
|
| 1518 | + if (isset($_GET['filecount'])) { |
|
| 1519 | + $upcontext['file_count'] = (int) $_GET['filecount']; |
|
| 1520 | + } else |
|
| 1433 | 1521 | { |
| 1434 | 1522 | $upcontext['file_count'] = 0; |
| 1435 | 1523 | foreach ($files as $file) |
| 1436 | 1524 | { |
| 1437 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) |
|
| 1438 | - $upcontext['file_count']++; |
|
| 1525 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) { |
|
| 1526 | + $upcontext['file_count']++; |
|
| 1527 | + } |
|
| 1439 | 1528 | } |
| 1440 | 1529 | } |
| 1441 | 1530 | |
@@ -1445,9 +1534,9 @@ discard block |
||
| 1445 | 1534 | $upcontext['cur_file_num'] = 0; |
| 1446 | 1535 | foreach ($files as $file) |
| 1447 | 1536 | { |
| 1448 | - if ($did_not_do) |
|
| 1449 | - $did_not_do--; |
|
| 1450 | - else |
|
| 1537 | + if ($did_not_do) { |
|
| 1538 | + $did_not_do--; |
|
| 1539 | + } else |
|
| 1451 | 1540 | { |
| 1452 | 1541 | $upcontext['cur_file_num']++; |
| 1453 | 1542 | $upcontext['cur_file_name'] = $file[0]; |
@@ -1474,12 +1563,13 @@ discard block |
||
| 1474 | 1563 | // Flag to move on to the next. |
| 1475 | 1564 | $upcontext['completed_step'] = true; |
| 1476 | 1565 | // Did we complete the whole file? |
| 1477 | - if ($nextFile) |
|
| 1478 | - $upcontext['current_debug_item_num'] = -1; |
|
| 1566 | + if ($nextFile) { |
|
| 1567 | + $upcontext['current_debug_item_num'] = -1; |
|
| 1568 | + } |
|
| 1479 | 1569 | return upgradeExit(); |
| 1570 | + } elseif ($support_js) { |
|
| 1571 | + break; |
|
| 1480 | 1572 | } |
| 1481 | - elseif ($support_js) |
|
| 1482 | - break; |
|
| 1483 | 1573 | } |
| 1484 | 1574 | // Set the progress bar to be right as if we had - even if we hadn't... |
| 1485 | 1575 | $upcontext['step_progress'] = ($upcontext['cur_file_num'] / $upcontext['file_count']) * 100; |
@@ -1505,8 +1595,9 @@ discard block |
||
| 1505 | 1595 | global $user_info, $maintenance, $smcFunc, $db_type, $txt, $settings; |
| 1506 | 1596 | |
| 1507 | 1597 | // Now it's nice to have some of the basic SMF source files. |
| 1508 | - if (!isset($_GET['ssi']) && !$command_line) |
|
| 1509 | - redirectLocation('&ssi=1'); |
|
| 1598 | + if (!isset($_GET['ssi']) && !$command_line) { |
|
| 1599 | + redirectLocation('&ssi=1'); |
|
| 1600 | + } |
|
| 1510 | 1601 | |
| 1511 | 1602 | $upcontext['sub_template'] = 'upgrade_complete'; |
| 1512 | 1603 | $upcontext['page_title'] = $txt['upgrade_complete']; |
@@ -1522,14 +1613,16 @@ discard block |
||
| 1522 | 1613 | // Are we in maintenance mode? |
| 1523 | 1614 | if (isset($upcontext['user']['main'])) |
| 1524 | 1615 | { |
| 1525 | - if ($command_line) |
|
| 1526 | - echo ' * '; |
|
| 1616 | + if ($command_line) { |
|
| 1617 | + echo ' * '; |
|
| 1618 | + } |
|
| 1527 | 1619 | $upcontext['removed_maintenance'] = true; |
| 1528 | 1620 | $changes['maintenance'] = $upcontext['user']['main']; |
| 1529 | 1621 | } |
| 1530 | 1622 | // Otherwise if somehow we are in 2 let's go to 1. |
| 1531 | - elseif (!empty($maintenance) && $maintenance == 2) |
|
| 1532 | - $changes['maintenance'] = 1; |
|
| 1623 | + elseif (!empty($maintenance) && $maintenance == 2) { |
|
| 1624 | + $changes['maintenance'] = 1; |
|
| 1625 | + } |
|
| 1533 | 1626 | |
| 1534 | 1627 | // Wipe this out... |
| 1535 | 1628 | $upcontext['user'] = array(); |
@@ -1544,21 +1637,23 @@ discard block |
||
| 1544 | 1637 | $upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__); |
| 1545 | 1638 | |
| 1546 | 1639 | // Now is the perfect time to fetch the SM files. |
| 1547 | - if ($command_line) |
|
| 1548 | - cli_scheduled_fetchSMfiles(); |
|
| 1549 | - else |
|
| 1640 | + if ($command_line) { |
|
| 1641 | + cli_scheduled_fetchSMfiles(); |
|
| 1642 | + } else |
|
| 1550 | 1643 | { |
| 1551 | 1644 | require_once($sourcedir . '/ScheduledTasks.php'); |
| 1552 | 1645 | $forum_version = SMF_VERSION; // The variable is usually defined in index.php so lets just use the constant to do it for us. |
| 1553 | 1646 | scheduled_fetchSMfiles(); // Now go get those files! |
| 1554 | 1647 | // This is needed in case someone invokes the upgrader using https when upgrading an http forum |
| 1555 | - if (httpsOn()) |
|
| 1556 | - $settings['default_theme_url'] = strtr($settings['default_theme_url'], array('http://' => 'https://')); |
|
| 1648 | + if (httpsOn()) { |
|
| 1649 | + $settings['default_theme_url'] = strtr($settings['default_theme_url'], array('http://' => 'https://')); |
|
| 1650 | + } |
|
| 1557 | 1651 | } |
| 1558 | 1652 | |
| 1559 | 1653 | // Log what we've done. |
| 1560 | - if (empty($user_info['id'])) |
|
| 1561 | - $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
| 1654 | + if (empty($user_info['id'])) { |
|
| 1655 | + $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
| 1656 | + } |
|
| 1562 | 1657 | |
| 1563 | 1658 | // Log the action manually, so CLI still works. |
| 1564 | 1659 | $smcFunc['db_insert']('', |
@@ -1577,8 +1672,9 @@ discard block |
||
| 1577 | 1672 | |
| 1578 | 1673 | // Save the current database version. |
| 1579 | 1674 | $server_version = $smcFunc['db_server_info'](); |
| 1580 | - if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
| 1581 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1675 | + if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
| 1676 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1677 | + } |
|
| 1582 | 1678 | |
| 1583 | 1679 | if ($command_line) |
| 1584 | 1680 | { |
@@ -1590,8 +1686,9 @@ discard block |
||
| 1590 | 1686 | |
| 1591 | 1687 | // Make sure it says we're done. |
| 1592 | 1688 | $upcontext['overall_percent'] = 100; |
| 1593 | - if (isset($upcontext['step_progress'])) |
|
| 1594 | - unset($upcontext['step_progress']); |
|
| 1689 | + if (isset($upcontext['step_progress'])) { |
|
| 1690 | + unset($upcontext['step_progress']); |
|
| 1691 | + } |
|
| 1595 | 1692 | |
| 1596 | 1693 | $_GET['substep'] = 0; |
| 1597 | 1694 | return false; |
@@ -1602,8 +1699,9 @@ discard block |
||
| 1602 | 1699 | { |
| 1603 | 1700 | global $sourcedir, $language, $forum_version, $modSettings, $smcFunc; |
| 1604 | 1701 | |
| 1605 | - if (empty($modSettings['time_format'])) |
|
| 1606 | - $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
| 1702 | + if (empty($modSettings['time_format'])) { |
|
| 1703 | + $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
| 1704 | + } |
|
| 1607 | 1705 | |
| 1608 | 1706 | // What files do we want to get |
| 1609 | 1707 | $request = $smcFunc['db_query']('', ' |
@@ -1637,8 +1735,9 @@ discard block |
||
| 1637 | 1735 | $file_data = fetch_web_data($url); |
| 1638 | 1736 | |
| 1639 | 1737 | // If we got an error - give up - the site might be down. |
| 1640 | - if ($file_data === false) |
|
| 1641 | - return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
| 1738 | + if ($file_data === false) { |
|
| 1739 | + return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
| 1740 | + } |
|
| 1642 | 1741 | |
| 1643 | 1742 | // Save the file to the database. |
| 1644 | 1743 | $smcFunc['db_query']('substring', ' |
@@ -1680,8 +1779,9 @@ discard block |
||
| 1680 | 1779 | $themeData = array(); |
| 1681 | 1780 | foreach ($values as $variable => $value) |
| 1682 | 1781 | { |
| 1683 | - if (!isset($value) || $value === null) |
|
| 1684 | - $value = 0; |
|
| 1782 | + if (!isset($value) || $value === null) { |
|
| 1783 | + $value = 0; |
|
| 1784 | + } |
|
| 1685 | 1785 | |
| 1686 | 1786 | $themeData[] = array(0, 1, $variable, $value); |
| 1687 | 1787 | } |
@@ -1710,8 +1810,9 @@ discard block |
||
| 1710 | 1810 | |
| 1711 | 1811 | foreach ($values as $variable => $value) |
| 1712 | 1812 | { |
| 1713 | - if (empty($modSettings[$value[0]])) |
|
| 1714 | - continue; |
|
| 1813 | + if (empty($modSettings[$value[0]])) { |
|
| 1814 | + continue; |
|
| 1815 | + } |
|
| 1715 | 1816 | |
| 1716 | 1817 | $smcFunc['db_query']('', ' |
| 1717 | 1818 | INSERT IGNORE INTO {db_prefix}themes |
@@ -1797,19 +1898,21 @@ discard block |
||
| 1797 | 1898 | set_error_handler( |
| 1798 | 1899 | function ($errno, $errstr, $errfile, $errline) use ($support_js) |
| 1799 | 1900 | { |
| 1800 | - if ($support_js) |
|
| 1801 | - return true; |
|
| 1802 | - else |
|
| 1803 | - echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
| 1901 | + if ($support_js) { |
|
| 1902 | + return true; |
|
| 1903 | + } else { |
|
| 1904 | + echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
| 1905 | + } |
|
| 1804 | 1906 | } |
| 1805 | 1907 | ); |
| 1806 | 1908 | |
| 1807 | 1909 | // If we're on MySQL, set {db_collation}; this approach is used throughout upgrade_2-0_mysql.php to set new tables to utf8 |
| 1808 | 1910 | // Note it is expected to be in the format: ENGINE=MyISAM{$db_collation}; |
| 1809 | - if ($db_type == 'mysql') |
|
| 1810 | - $db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
| 1811 | - else |
|
| 1812 | - $db_collation = ''; |
|
| 1911 | + if ($db_type == 'mysql') { |
|
| 1912 | + $db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
| 1913 | + } else { |
|
| 1914 | + $db_collation = ''; |
|
| 1915 | + } |
|
| 1813 | 1916 | |
| 1814 | 1917 | $endl = $command_line ? "\n" : '<br>' . "\n"; |
| 1815 | 1918 | |
@@ -1821,8 +1924,9 @@ discard block |
||
| 1821 | 1924 | $last_step = ''; |
| 1822 | 1925 | |
| 1823 | 1926 | // Make sure all newly created tables will have the proper characters set; this approach is used throughout upgrade_2-1_mysql.php |
| 1824 | - if (isset($db_character_set) && $db_character_set === 'utf8') |
|
| 1825 | - $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
| 1927 | + if (isset($db_character_set) && $db_character_set === 'utf8') { |
|
| 1928 | + $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
| 1929 | + } |
|
| 1826 | 1930 | |
| 1827 | 1931 | // Count the total number of steps within this file - for progress. |
| 1828 | 1932 | $file_steps = substr_count(implode('', $lines), '---#'); |
@@ -1842,15 +1946,18 @@ discard block |
||
| 1842 | 1946 | $do_current = $substep >= $_GET['substep']; |
| 1843 | 1947 | |
| 1844 | 1948 | // Get rid of any comments in the beginning of the line... |
| 1845 | - if (substr(trim($line), 0, 2) === '/*') |
|
| 1846 | - $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
| 1949 | + if (substr(trim($line), 0, 2) === '/*') { |
|
| 1950 | + $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
| 1951 | + } |
|
| 1847 | 1952 | |
| 1848 | 1953 | // Always flush. Flush, flush, flush. Flush, flush, flush, flush! FLUSH! |
| 1849 | - if ($is_debug && !$support_js && $command_line) |
|
| 1850 | - flush(); |
|
| 1954 | + if ($is_debug && !$support_js && $command_line) { |
|
| 1955 | + flush(); |
|
| 1956 | + } |
|
| 1851 | 1957 | |
| 1852 | - if (trim($line) === '') |
|
| 1853 | - continue; |
|
| 1958 | + if (trim($line) === '') { |
|
| 1959 | + continue; |
|
| 1960 | + } |
|
| 1854 | 1961 | |
| 1855 | 1962 | if (trim(substr($line, 0, 3)) === '---') |
| 1856 | 1963 | { |
@@ -1860,8 +1967,9 @@ discard block |
||
| 1860 | 1967 | if (trim($current_data) != '' && $type !== '}') |
| 1861 | 1968 | { |
| 1862 | 1969 | $upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl; |
| 1863 | - if ($command_line) |
|
| 1864 | - echo $upcontext['error_message']; |
|
| 1970 | + if ($command_line) { |
|
| 1971 | + echo $upcontext['error_message']; |
|
| 1972 | + } |
|
| 1865 | 1973 | } |
| 1866 | 1974 | |
| 1867 | 1975 | if ($type == ' ') |
@@ -1879,17 +1987,18 @@ discard block |
||
| 1879 | 1987 | if ($do_current) |
| 1880 | 1988 | { |
| 1881 | 1989 | $upcontext['actioned_items'][] = $last_step; |
| 1882 | - if ($command_line) |
|
| 1883 | - echo ' * '; |
|
| 1990 | + if ($command_line) { |
|
| 1991 | + echo ' * '; |
|
| 1992 | + } |
|
| 1884 | 1993 | } |
| 1885 | - } |
|
| 1886 | - elseif ($type == '#') |
|
| 1994 | + } elseif ($type == '#') |
|
| 1887 | 1995 | { |
| 1888 | 1996 | $upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps; |
| 1889 | 1997 | |
| 1890 | 1998 | $upcontext['current_debug_item_num']++; |
| 1891 | - if (trim($line) != '---#') |
|
| 1892 | - $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1999 | + if (trim($line) != '---#') { |
|
| 2000 | + $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 2001 | + } |
|
| 1893 | 2002 | |
| 1894 | 2003 | // Have we already done something? |
| 1895 | 2004 | if (isset($_GET['xml']) && $done_something) |
@@ -1900,34 +2009,36 @@ discard block |
||
| 1900 | 2009 | |
| 1901 | 2010 | if ($do_current) |
| 1902 | 2011 | { |
| 1903 | - if (trim($line) == '---#' && $command_line) |
|
| 1904 | - echo ' done.', $endl; |
|
| 1905 | - elseif ($command_line) |
|
| 1906 | - echo ' +++ ', rtrim(substr($line, 4)); |
|
| 1907 | - elseif (trim($line) != '---#') |
|
| 2012 | + if (trim($line) == '---#' && $command_line) { |
|
| 2013 | + echo ' done.', $endl; |
|
| 2014 | + } elseif ($command_line) { |
|
| 2015 | + echo ' +++ ', rtrim(substr($line, 4)); |
|
| 2016 | + } elseif (trim($line) != '---#') |
|
| 1908 | 2017 | { |
| 1909 | - if ($is_debug) |
|
| 1910 | - $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 2018 | + if ($is_debug) { |
|
| 2019 | + $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 2020 | + } |
|
| 1911 | 2021 | } |
| 1912 | 2022 | } |
| 1913 | 2023 | |
| 1914 | 2024 | if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep']) |
| 1915 | 2025 | { |
| 1916 | - if ($command_line) |
|
| 1917 | - echo ' * '; |
|
| 1918 | - else |
|
| 1919 | - $upcontext['actioned_items'][] = $last_step; |
|
| 2026 | + if ($command_line) { |
|
| 2027 | + echo ' * '; |
|
| 2028 | + } else { |
|
| 2029 | + $upcontext['actioned_items'][] = $last_step; |
|
| 2030 | + } |
|
| 1920 | 2031 | } |
| 1921 | 2032 | |
| 1922 | 2033 | // Small step - only if we're actually doing stuff. |
| 1923 | - if ($do_current) |
|
| 1924 | - nextSubstep(++$substep); |
|
| 1925 | - else |
|
| 1926 | - $substep++; |
|
| 1927 | - } |
|
| 1928 | - elseif ($type == '{') |
|
| 1929 | - $current_type = 'code'; |
|
| 1930 | - elseif ($type == '}') |
|
| 2034 | + if ($do_current) { |
|
| 2035 | + nextSubstep(++$substep); |
|
| 2036 | + } else { |
|
| 2037 | + $substep++; |
|
| 2038 | + } |
|
| 2039 | + } elseif ($type == '{') { |
|
| 2040 | + $current_type = 'code'; |
|
| 2041 | + } elseif ($type == '}') |
|
| 1931 | 2042 | { |
| 1932 | 2043 | $current_type = 'sql'; |
| 1933 | 2044 | |
@@ -1940,8 +2051,9 @@ discard block |
||
| 1940 | 2051 | if (eval('global $db_prefix, $modSettings, $smcFunc, $txt; ' . $current_data) === false) |
| 1941 | 2052 | { |
| 1942 | 2053 | $upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl; |
| 1943 | - if ($command_line) |
|
| 1944 | - echo $upcontext['error_message']; |
|
| 2054 | + if ($command_line) { |
|
| 2055 | + echo $upcontext['error_message']; |
|
| 2056 | + } |
|
| 1945 | 2057 | } |
| 1946 | 2058 | |
| 1947 | 2059 | // Done with code! |
@@ -2029,8 +2141,9 @@ discard block |
||
| 2029 | 2141 | $db_unbuffered = false; |
| 2030 | 2142 | |
| 2031 | 2143 | // Failure?! |
| 2032 | - if ($result !== false) |
|
| 2033 | - return $result; |
|
| 2144 | + if ($result !== false) { |
|
| 2145 | + return $result; |
|
| 2146 | + } |
|
| 2034 | 2147 | |
| 2035 | 2148 | $db_error_message = $smcFunc['db_error']($db_connection); |
| 2036 | 2149 | // If MySQL we do something more clever. |
@@ -2058,54 +2171,61 @@ discard block |
||
| 2058 | 2171 | { |
| 2059 | 2172 | mysqli_query($db_connection, 'REPAIR TABLE `' . $match[1] . '`'); |
| 2060 | 2173 | $result = mysqli_query($db_connection, $string); |
| 2061 | - if ($result !== false) |
|
| 2062 | - return $result; |
|
| 2174 | + if ($result !== false) { |
|
| 2175 | + return $result; |
|
| 2176 | + } |
|
| 2063 | 2177 | } |
| 2064 | - } |
|
| 2065 | - elseif ($mysqli_errno == 2013) |
|
| 2178 | + } elseif ($mysqli_errno == 2013) |
|
| 2066 | 2179 | { |
| 2067 | 2180 | $db_connection = mysqli_connect($db_server, $db_user, $db_passwd); |
| 2068 | 2181 | mysqli_select_db($db_connection, $db_name); |
| 2069 | 2182 | if ($db_connection) |
| 2070 | 2183 | { |
| 2071 | 2184 | $result = mysqli_query($db_connection, $string); |
| 2072 | - if ($result !== false) |
|
| 2073 | - return $result; |
|
| 2185 | + if ($result !== false) { |
|
| 2186 | + return $result; |
|
| 2187 | + } |
|
| 2074 | 2188 | } |
| 2075 | 2189 | } |
| 2076 | 2190 | // Duplicate column name... should be okay ;). |
| 2077 | - elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) |
|
| 2078 | - return false; |
|
| 2191 | + elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) { |
|
| 2192 | + return false; |
|
| 2193 | + } |
|
| 2079 | 2194 | // Duplicate insert... make sure it's the proper type of query ;). |
| 2080 | - elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) |
|
| 2081 | - return false; |
|
| 2195 | + elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) { |
|
| 2196 | + return false; |
|
| 2197 | + } |
|
| 2082 | 2198 | // Creating an index on a non-existent column. |
| 2083 | - elseif ($mysqli_errno == 1072) |
|
| 2084 | - return false; |
|
| 2085 | - elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') |
|
| 2086 | - return false; |
|
| 2199 | + elseif ($mysqli_errno == 1072) { |
|
| 2200 | + return false; |
|
| 2201 | + } elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') { |
|
| 2202 | + return false; |
|
| 2203 | + } |
|
| 2087 | 2204 | } |
| 2088 | 2205 | // If a table already exists don't go potty. |
| 2089 | 2206 | else |
| 2090 | 2207 | { |
| 2091 | 2208 | if (in_array(substr(trim($string), 0, 8), array('CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U'))) |
| 2092 | 2209 | { |
| 2093 | - if (strpos($db_error_message, 'exist') !== false) |
|
| 2094 | - return true; |
|
| 2095 | - } |
|
| 2096 | - elseif (strpos(trim($string), 'INSERT ') !== false) |
|
| 2210 | + if (strpos($db_error_message, 'exist') !== false) { |
|
| 2211 | + return true; |
|
| 2212 | + } |
|
| 2213 | + } elseif (strpos(trim($string), 'INSERT ') !== false) |
|
| 2097 | 2214 | { |
| 2098 | - if (strpos($db_error_message, 'duplicate') !== false || $ignore_insert_error) |
|
| 2099 | - return true; |
|
| 2215 | + if (strpos($db_error_message, 'duplicate') !== false || $ignore_insert_error) { |
|
| 2216 | + return true; |
|
| 2217 | + } |
|
| 2100 | 2218 | } |
| 2101 | 2219 | } |
| 2102 | 2220 | |
| 2103 | 2221 | // Get the query string so we pass everything. |
| 2104 | 2222 | $query_string = ''; |
| 2105 | - foreach ($_GET as $k => $v) |
|
| 2106 | - $query_string .= ';' . $k . '=' . $v; |
|
| 2107 | - if (strlen($query_string) != 0) |
|
| 2108 | - $query_string = '?' . substr($query_string, 1); |
|
| 2223 | + foreach ($_GET as $k => $v) { |
|
| 2224 | + $query_string .= ';' . $k . '=' . $v; |
|
| 2225 | + } |
|
| 2226 | + if (strlen($query_string) != 0) { |
|
| 2227 | + $query_string = '?' . substr($query_string, 1); |
|
| 2228 | + } |
|
| 2109 | 2229 | |
| 2110 | 2230 | if ($command_line) |
| 2111 | 2231 | { |
@@ -2160,16 +2280,18 @@ discard block |
||
| 2160 | 2280 | { |
| 2161 | 2281 | $found |= 1; |
| 2162 | 2282 | // Do some checks on the data if we have it set. |
| 2163 | - if (isset($change['col_type'])) |
|
| 2164 | - $found &= $change['col_type'] === $column['type']; |
|
| 2165 | - if (isset($change['null_allowed'])) |
|
| 2166 | - $found &= $column['null'] == $change['null_allowed']; |
|
| 2167 | - if (isset($change['default'])) |
|
| 2168 | - $found &= $change['default'] === $column['default']; |
|
| 2283 | + if (isset($change['col_type'])) { |
|
| 2284 | + $found &= $change['col_type'] === $column['type']; |
|
| 2285 | + } |
|
| 2286 | + if (isset($change['null_allowed'])) { |
|
| 2287 | + $found &= $column['null'] == $change['null_allowed']; |
|
| 2288 | + } |
|
| 2289 | + if (isset($change['default'])) { |
|
| 2290 | + $found &= $change['default'] === $column['default']; |
|
| 2291 | + } |
|
| 2169 | 2292 | } |
| 2170 | 2293 | } |
| 2171 | - } |
|
| 2172 | - elseif ($change['type'] === 'index') |
|
| 2294 | + } elseif ($change['type'] === 'index') |
|
| 2173 | 2295 | { |
| 2174 | 2296 | $request = upgrade_query(' |
| 2175 | 2297 | SHOW INDEX |
@@ -2178,9 +2300,10 @@ discard block |
||
| 2178 | 2300 | { |
| 2179 | 2301 | $cur_index = array(); |
| 2180 | 2302 | |
| 2181 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2182 | - if ($row['Key_name'] === $change['name']) |
|
| 2303 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2304 | + if ($row['Key_name'] === $change['name']) |
|
| 2183 | 2305 | $cur_index[(int) $row['Seq_in_index']] = $row['Column_name']; |
| 2306 | + } |
|
| 2184 | 2307 | |
| 2185 | 2308 | ksort($cur_index, SORT_NUMERIC); |
| 2186 | 2309 | $found = array_values($cur_index) === $change['target_columns']; |
@@ -2190,14 +2313,17 @@ discard block |
||
| 2190 | 2313 | } |
| 2191 | 2314 | |
| 2192 | 2315 | // If we're trying to add and it's added, we're done. |
| 2193 | - if ($found && in_array($change['method'], array('add', 'change'))) |
|
| 2194 | - return true; |
|
| 2316 | + if ($found && in_array($change['method'], array('add', 'change'))) { |
|
| 2317 | + return true; |
|
| 2318 | + } |
|
| 2195 | 2319 | // Otherwise if we're removing and it wasn't found we're also done. |
| 2196 | - elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) |
|
| 2197 | - return true; |
|
| 2320 | + elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) { |
|
| 2321 | + return true; |
|
| 2322 | + } |
|
| 2198 | 2323 | // Otherwise is it just a test? |
| 2199 | - elseif ($is_test) |
|
| 2200 | - return false; |
|
| 2324 | + elseif ($is_test) { |
|
| 2325 | + return false; |
|
| 2326 | + } |
|
| 2201 | 2327 | |
| 2202 | 2328 | // Not found it yet? Bummer! How about we see if we're currently doing it? |
| 2203 | 2329 | $running = false; |
@@ -2208,8 +2334,9 @@ discard block |
||
| 2208 | 2334 | SHOW FULL PROCESSLIST'); |
| 2209 | 2335 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2210 | 2336 | { |
| 2211 | - if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) |
|
| 2212 | - $found = true; |
|
| 2337 | + if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) { |
|
| 2338 | + $found = true; |
|
| 2339 | + } |
|
| 2213 | 2340 | } |
| 2214 | 2341 | |
| 2215 | 2342 | // Can't find it? Then we need to run it fools! |
@@ -2221,8 +2348,9 @@ discard block |
||
| 2221 | 2348 | ALTER TABLE ' . $db_prefix . $change['table'] . ' |
| 2222 | 2349 | ' . $change['text'], true) !== false; |
| 2223 | 2350 | |
| 2224 | - if (!$success) |
|
| 2225 | - return false; |
|
| 2351 | + if (!$success) { |
|
| 2352 | + return false; |
|
| 2353 | + } |
|
| 2226 | 2354 | |
| 2227 | 2355 | // Return |
| 2228 | 2356 | $running = true; |
@@ -2264,8 +2392,9 @@ discard block |
||
| 2264 | 2392 | 'db_error_skip' => true, |
| 2265 | 2393 | ) |
| 2266 | 2394 | ); |
| 2267 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 2268 | - die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
| 2395 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 2396 | + die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
| 2397 | + } |
|
| 2269 | 2398 | $table_row = $smcFunc['db_fetch_assoc']($request); |
| 2270 | 2399 | $smcFunc['db_free_result']($request); |
| 2271 | 2400 | |
@@ -2287,18 +2416,19 @@ discard block |
||
| 2287 | 2416 | ) |
| 2288 | 2417 | ); |
| 2289 | 2418 | // No results? Just forget it all together. |
| 2290 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 2291 | - unset($table_row['Collation']); |
|
| 2292 | - else |
|
| 2293 | - $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 2419 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 2420 | + unset($table_row['Collation']); |
|
| 2421 | + } else { |
|
| 2422 | + $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 2423 | + } |
|
| 2294 | 2424 | $smcFunc['db_free_result']($request); |
| 2295 | 2425 | } |
| 2296 | 2426 | |
| 2297 | 2427 | if ($column_fix) |
| 2298 | 2428 | { |
| 2299 | 2429 | // Make sure there are no NULL's left. |
| 2300 | - if ($null_fix) |
|
| 2301 | - $smcFunc['db_query']('', ' |
|
| 2430 | + if ($null_fix) { |
|
| 2431 | + $smcFunc['db_query']('', ' |
|
| 2302 | 2432 | UPDATE {db_prefix}' . $change['table'] . ' |
| 2303 | 2433 | SET ' . $change['column'] . ' = {string:default} |
| 2304 | 2434 | WHERE ' . $change['column'] . ' IS NULL', |
@@ -2307,6 +2437,7 @@ discard block |
||
| 2307 | 2437 | 'db_error_skip' => true, |
| 2308 | 2438 | ) |
| 2309 | 2439 | ); |
| 2440 | + } |
|
| 2310 | 2441 | |
| 2311 | 2442 | // Do the actual alteration. |
| 2312 | 2443 | $smcFunc['db_query']('', ' |
@@ -2335,8 +2466,9 @@ discard block |
||
| 2335 | 2466 | } |
| 2336 | 2467 | |
| 2337 | 2468 | // Not a column we need to check on? |
| 2338 | - if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) |
|
| 2339 | - return; |
|
| 2469 | + if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) { |
|
| 2470 | + return; |
|
| 2471 | + } |
|
| 2340 | 2472 | |
| 2341 | 2473 | // Break it up you (six|seven). |
| 2342 | 2474 | $temp = explode(' ', str_replace('NOT NULL', 'NOT_NULL', $change['text'])); |
@@ -2355,13 +2487,13 @@ discard block |
||
| 2355 | 2487 | 'new_name' => $temp[2], |
| 2356 | 2488 | )); |
| 2357 | 2489 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
| 2358 | - if ($smcFunc['db_num_rows'] != 1) |
|
| 2359 | - return; |
|
| 2490 | + if ($smcFunc['db_num_rows'] != 1) { |
|
| 2491 | + return; |
|
| 2492 | + } |
|
| 2360 | 2493 | |
| 2361 | 2494 | list (, $current_type) = $smcFunc['db_fetch_assoc']($request); |
| 2362 | 2495 | $smcFunc['db_free_result']($request); |
| 2363 | - } |
|
| 2364 | - else |
|
| 2496 | + } else |
|
| 2365 | 2497 | { |
| 2366 | 2498 | // Do this the old fashion, sure method way. |
| 2367 | 2499 | $request = $smcFunc['db_query']('', ' |
@@ -2372,21 +2504,24 @@ discard block |
||
| 2372 | 2504 | )); |
| 2373 | 2505 | // Mayday! |
| 2374 | 2506 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
| 2375 | - if ($smcFunc['db_num_rows'] == 0) |
|
| 2376 | - return; |
|
| 2507 | + if ($smcFunc['db_num_rows'] == 0) { |
|
| 2508 | + return; |
|
| 2509 | + } |
|
| 2377 | 2510 | |
| 2378 | 2511 | // Oh where, oh where has my little field gone. Oh where can it be... |
| 2379 | - while ($row = $smcFunc['db_query']($request)) |
|
| 2380 | - if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
| 2512 | + while ($row = $smcFunc['db_query']($request)) { |
|
| 2513 | + if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
| 2381 | 2514 | { |
| 2382 | 2515 | $current_type = $row['Type']; |
| 2516 | + } |
|
| 2383 | 2517 | break; |
| 2384 | 2518 | } |
| 2385 | 2519 | } |
| 2386 | 2520 | |
| 2387 | 2521 | // If this doesn't match, the column may of been altered for a reason. |
| 2388 | - if (trim($current_type) != trim($temp[3])) |
|
| 2389 | - $temp[3] = $current_type; |
|
| 2522 | + if (trim($current_type) != trim($temp[3])) { |
|
| 2523 | + $temp[3] = $current_type; |
|
| 2524 | + } |
|
| 2390 | 2525 | |
| 2391 | 2526 | // Piece this back together. |
| 2392 | 2527 | $change['text'] = str_replace('NOT_NULL', 'NOT NULL', implode(' ', $temp)); |
@@ -2398,8 +2533,9 @@ discard block |
||
| 2398 | 2533 | global $start_time, $timeLimitThreshold, $command_line, $custom_warning; |
| 2399 | 2534 | global $step_progress, $is_debug, $upcontext; |
| 2400 | 2535 | |
| 2401 | - if ($_GET['substep'] < $substep) |
|
| 2402 | - $_GET['substep'] = $substep; |
|
| 2536 | + if ($_GET['substep'] < $substep) { |
|
| 2537 | + $_GET['substep'] = $substep; |
|
| 2538 | + } |
|
| 2403 | 2539 | |
| 2404 | 2540 | if ($command_line) |
| 2405 | 2541 | { |
@@ -2412,29 +2548,33 @@ discard block |
||
| 2412 | 2548 | } |
| 2413 | 2549 | |
| 2414 | 2550 | @set_time_limit(300); |
| 2415 | - if (function_exists('apache_reset_timeout')) |
|
| 2416 | - @apache_reset_timeout(); |
|
| 2551 | + if (function_exists('apache_reset_timeout')) { |
|
| 2552 | + @apache_reset_timeout(); |
|
| 2553 | + } |
|
| 2417 | 2554 | |
| 2418 | - if (time() - $start_time <= $timeLimitThreshold) |
|
| 2419 | - return; |
|
| 2555 | + if (time() - $start_time <= $timeLimitThreshold) { |
|
| 2556 | + return; |
|
| 2557 | + } |
|
| 2420 | 2558 | |
| 2421 | 2559 | // Do we have some custom step progress stuff? |
| 2422 | 2560 | if (!empty($step_progress)) |
| 2423 | 2561 | { |
| 2424 | 2562 | $upcontext['substep_progress'] = 0; |
| 2425 | 2563 | $upcontext['substep_progress_name'] = $step_progress['name']; |
| 2426 | - if ($step_progress['current'] > $step_progress['total']) |
|
| 2427 | - $upcontext['substep_progress'] = 99.9; |
|
| 2428 | - else |
|
| 2429 | - $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
| 2564 | + if ($step_progress['current'] > $step_progress['total']) { |
|
| 2565 | + $upcontext['substep_progress'] = 99.9; |
|
| 2566 | + } else { |
|
| 2567 | + $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
| 2568 | + } |
|
| 2430 | 2569 | |
| 2431 | 2570 | // Make it nicely rounded. |
| 2432 | 2571 | $upcontext['substep_progress'] = round($upcontext['substep_progress'], 1); |
| 2433 | 2572 | } |
| 2434 | 2573 | |
| 2435 | 2574 | // If this is XML we just exit right away! |
| 2436 | - if (isset($_GET['xml'])) |
|
| 2437 | - return upgradeExit(); |
|
| 2575 | + if (isset($_GET['xml'])) { |
|
| 2576 | + return upgradeExit(); |
|
| 2577 | + } |
|
| 2438 | 2578 | |
| 2439 | 2579 | // We're going to pause after this! |
| 2440 | 2580 | $upcontext['pause'] = true; |
@@ -2442,13 +2582,15 @@ discard block |
||
| 2442 | 2582 | $upcontext['query_string'] = ''; |
| 2443 | 2583 | foreach ($_GET as $k => $v) |
| 2444 | 2584 | { |
| 2445 | - if ($k != 'data' && $k != 'substep' && $k != 'step') |
|
| 2446 | - $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
| 2585 | + if ($k != 'data' && $k != 'substep' && $k != 'step') { |
|
| 2586 | + $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
| 2587 | + } |
|
| 2447 | 2588 | } |
| 2448 | 2589 | |
| 2449 | 2590 | // Custom warning? |
| 2450 | - if (!empty($custom_warning)) |
|
| 2451 | - $upcontext['custom_warning'] = $custom_warning; |
|
| 2591 | + if (!empty($custom_warning)) { |
|
| 2592 | + $upcontext['custom_warning'] = $custom_warning; |
|
| 2593 | + } |
|
| 2452 | 2594 | |
| 2453 | 2595 | upgradeExit(); |
| 2454 | 2596 | } |
@@ -2463,25 +2605,26 @@ discard block |
||
| 2463 | 2605 | ob_implicit_flush(true); |
| 2464 | 2606 | @set_time_limit(600); |
| 2465 | 2607 | |
| 2466 | - if (!isset($_SERVER['argv'])) |
|
| 2467 | - $_SERVER['argv'] = array(); |
|
| 2608 | + if (!isset($_SERVER['argv'])) { |
|
| 2609 | + $_SERVER['argv'] = array(); |
|
| 2610 | + } |
|
| 2468 | 2611 | $_GET['maint'] = 1; |
| 2469 | 2612 | |
| 2470 | 2613 | foreach ($_SERVER['argv'] as $i => $arg) |
| 2471 | 2614 | { |
| 2472 | - if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) |
|
| 2473 | - $_GET['lang'] = $match[1]; |
|
| 2474 | - elseif (preg_match('~^--path=(.+)$~', $arg) != 0) |
|
| 2475 | - continue; |
|
| 2476 | - elseif ($arg == '--no-maintenance') |
|
| 2477 | - $_GET['maint'] = 0; |
|
| 2478 | - elseif ($arg == '--debug') |
|
| 2479 | - $is_debug = true; |
|
| 2480 | - elseif ($arg == '--backup') |
|
| 2481 | - $_POST['backup'] = 1; |
|
| 2482 | - elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) |
|
| 2483 | - $_GET['conv'] = 1; |
|
| 2484 | - elseif ($i != 0) |
|
| 2615 | + if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) { |
|
| 2616 | + $_GET['lang'] = $match[1]; |
|
| 2617 | + } elseif (preg_match('~^--path=(.+)$~', $arg) != 0) { |
|
| 2618 | + continue; |
|
| 2619 | + } elseif ($arg == '--no-maintenance') { |
|
| 2620 | + $_GET['maint'] = 0; |
|
| 2621 | + } elseif ($arg == '--debug') { |
|
| 2622 | + $is_debug = true; |
|
| 2623 | + } elseif ($arg == '--backup') { |
|
| 2624 | + $_POST['backup'] = 1; |
|
| 2625 | + } elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) { |
|
| 2626 | + $_GET['conv'] = 1; |
|
| 2627 | + } elseif ($i != 0) |
|
| 2485 | 2628 | { |
| 2486 | 2629 | echo 'SMF Command-line Upgrader |
| 2487 | 2630 | Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]... |
@@ -2495,10 +2638,12 @@ discard block |
||
| 2495 | 2638 | } |
| 2496 | 2639 | } |
| 2497 | 2640 | |
| 2498 | - if (!php_version_check()) |
|
| 2499 | - print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
| 2500 | - if (!db_version_check()) |
|
| 2501 | - print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
| 2641 | + if (!php_version_check()) { |
|
| 2642 | + print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
| 2643 | + } |
|
| 2644 | + if (!db_version_check()) { |
|
| 2645 | + print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
| 2646 | + } |
|
| 2502 | 2647 | |
| 2503 | 2648 | // Do some checks to make sure they have proper privileges |
| 2504 | 2649 | db_extend('packages'); |
@@ -2513,34 +2658,39 @@ discard block |
||
| 2513 | 2658 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
| 2514 | 2659 | |
| 2515 | 2660 | // Sorry... we need CREATE, ALTER and DROP |
| 2516 | - if (!$create || !$alter || !$drop) |
|
| 2517 | - 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); |
|
| 2661 | + if (!$create || !$alter || !$drop) { |
|
| 2662 | + 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); |
|
| 2663 | + } |
|
| 2518 | 2664 | |
| 2519 | 2665 | $check = @file_exists($modSettings['theme_dir'] . '/index.template.php') |
| 2520 | 2666 | && @file_exists($sourcedir . '/QueryString.php') |
| 2521 | 2667 | && @file_exists($sourcedir . '/ManageBoards.php'); |
| 2522 | - if (!$check && !isset($modSettings['smfVersion'])) |
|
| 2523 | - print_error('Error: Some files are missing or out-of-date.', true); |
|
| 2668 | + if (!$check && !isset($modSettings['smfVersion'])) { |
|
| 2669 | + print_error('Error: Some files are missing or out-of-date.', true); |
|
| 2670 | + } |
|
| 2524 | 2671 | |
| 2525 | 2672 | // Do a quick version spot check. |
| 2526 | 2673 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
| 2527 | 2674 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
| 2528 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
| 2529 | - print_error('Error: Some files have not yet been updated properly.'); |
|
| 2675 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
| 2676 | + print_error('Error: Some files have not yet been updated properly.'); |
|
| 2677 | + } |
|
| 2530 | 2678 | |
| 2531 | 2679 | // Make sure Settings.php is writable. |
| 2532 | 2680 | quickFileWritable($boarddir . '/Settings.php'); |
| 2533 | - if (!is_writable($boarddir . '/Settings.php')) |
|
| 2534 | - print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
| 2681 | + if (!is_writable($boarddir . '/Settings.php')) { |
|
| 2682 | + print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
| 2683 | + } |
|
| 2535 | 2684 | |
| 2536 | 2685 | // Make sure Settings_bak.php is writable. |
| 2537 | 2686 | quickFileWritable($boarddir . '/Settings_bak.php'); |
| 2538 | - if (!is_writable($boarddir . '/Settings_bak.php')) |
|
| 2539 | - print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
| 2687 | + if (!is_writable($boarddir . '/Settings_bak.php')) { |
|
| 2688 | + print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
| 2689 | + } |
|
| 2540 | 2690 | |
| 2541 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
| 2542 | - print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
| 2543 | - elseif (isset($modSettings['agreement'])) |
|
| 2691 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
| 2692 | + print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
| 2693 | + } elseif (isset($modSettings['agreement'])) |
|
| 2544 | 2694 | { |
| 2545 | 2695 | $fp = fopen($boarddir . '/agreement.txt', 'w'); |
| 2546 | 2696 | fwrite($fp, $modSettings['agreement']); |
@@ -2550,36 +2700,42 @@ discard block |
||
| 2550 | 2700 | // Make sure Themes is writable. |
| 2551 | 2701 | quickFileWritable($modSettings['theme_dir']); |
| 2552 | 2702 | |
| 2553 | - if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) |
|
| 2554 | - print_error('Error: Unable to obtain write access to "Themes".'); |
|
| 2703 | + if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) { |
|
| 2704 | + print_error('Error: Unable to obtain write access to "Themes".'); |
|
| 2705 | + } |
|
| 2555 | 2706 | |
| 2556 | 2707 | // Make sure cache directory exists and is writable! |
| 2557 | 2708 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
| 2558 | - if (!file_exists($cachedir_temp)) |
|
| 2559 | - @mkdir($cachedir_temp); |
|
| 2709 | + if (!file_exists($cachedir_temp)) { |
|
| 2710 | + @mkdir($cachedir_temp); |
|
| 2711 | + } |
|
| 2560 | 2712 | |
| 2561 | 2713 | // Make sure the cache temp dir is writable. |
| 2562 | 2714 | quickFileWritable($cachedir_temp); |
| 2563 | 2715 | |
| 2564 | - if (!is_writable($cachedir_temp)) |
|
| 2565 | - print_error('Error: Unable to obtain write access to "cache".', true); |
|
| 2716 | + if (!is_writable($cachedir_temp)) { |
|
| 2717 | + print_error('Error: Unable to obtain write access to "cache".', true); |
|
| 2718 | + } |
|
| 2566 | 2719 | |
| 2567 | 2720 | // Make sure db_last_error.php is writable. |
| 2568 | 2721 | quickFileWritable($cachedir_temp . '/db_last_error.php'); |
| 2569 | - if (!is_writable($cachedir_temp . '/db_last_error.php')) |
|
| 2570 | - print_error('Error: Unable to obtain write access to "db_last_error.php".'); |
|
| 2722 | + if (!is_writable($cachedir_temp . '/db_last_error.php')) { |
|
| 2723 | + print_error('Error: Unable to obtain write access to "db_last_error.php".'); |
|
| 2724 | + } |
|
| 2571 | 2725 | |
| 2572 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
| 2573 | - print_error('Error: Unable to find language files!', true); |
|
| 2574 | - else |
|
| 2726 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
| 2727 | + print_error('Error: Unable to find language files!', true); |
|
| 2728 | + } else |
|
| 2575 | 2729 | { |
| 2576 | 2730 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
| 2577 | 2731 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 2578 | 2732 | |
| 2579 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 2580 | - print_error('Error: Language files out of date.', true); |
|
| 2581 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 2582 | - print_error('Error: Install language is missing for selected language.', true); |
|
| 2733 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 2734 | + print_error('Error: Language files out of date.', true); |
|
| 2735 | + } |
|
| 2736 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 2737 | + print_error('Error: Install language is missing for selected language.', true); |
|
| 2738 | + } |
|
| 2583 | 2739 | |
| 2584 | 2740 | // Otherwise include it! |
| 2585 | 2741 | require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
@@ -2599,8 +2755,9 @@ discard block |
||
| 2599 | 2755 | global $db_prefix, $db_type, $command_line, $support_js, $txt; |
| 2600 | 2756 | |
| 2601 | 2757 | // Done it already? |
| 2602 | - if (!empty($_POST['utf8_done'])) |
|
| 2603 | - return true; |
|
| 2758 | + if (!empty($_POST['utf8_done'])) { |
|
| 2759 | + return true; |
|
| 2760 | + } |
|
| 2604 | 2761 | |
| 2605 | 2762 | // First make sure they aren't already on UTF-8 before we go anywhere... |
| 2606 | 2763 | if ($db_type == 'postgresql' || ($db_character_set === 'utf8' && !empty($modSettings['global_character_set']) && $modSettings['global_character_set'] === 'UTF-8')) |
@@ -2613,8 +2770,7 @@ discard block |
||
| 2613 | 2770 | ); |
| 2614 | 2771 | |
| 2615 | 2772 | return true; |
| 2616 | - } |
|
| 2617 | - else |
|
| 2773 | + } else |
|
| 2618 | 2774 | { |
| 2619 | 2775 | $upcontext['page_title'] = $txt['converting_utf8']; |
| 2620 | 2776 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'convert_xml' : 'convert_utf8'; |
@@ -2658,8 +2814,9 @@ discard block |
||
| 2658 | 2814 | ) |
| 2659 | 2815 | ); |
| 2660 | 2816 | $db_charsets = array(); |
| 2661 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2662 | - $db_charsets[] = $row['Charset']; |
|
| 2817 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2818 | + $db_charsets[] = $row['Charset']; |
|
| 2819 | + } |
|
| 2663 | 2820 | |
| 2664 | 2821 | $smcFunc['db_free_result']($request); |
| 2665 | 2822 | |
@@ -2695,13 +2852,15 @@ discard block |
||
| 2695 | 2852 | // If there's a fulltext index, we need to drop it first... |
| 2696 | 2853 | if ($request !== false || $smcFunc['db_num_rows']($request) != 0) |
| 2697 | 2854 | { |
| 2698 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2699 | - if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 2855 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2856 | + if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 2700 | 2857 | $upcontext['fulltext_index'][] = $row['Key_name']; |
| 2858 | + } |
|
| 2701 | 2859 | $smcFunc['db_free_result']($request); |
| 2702 | 2860 | |
| 2703 | - if (isset($upcontext['fulltext_index'])) |
|
| 2704 | - $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
| 2861 | + if (isset($upcontext['fulltext_index'])) { |
|
| 2862 | + $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
| 2863 | + } |
|
| 2705 | 2864 | } |
| 2706 | 2865 | |
| 2707 | 2866 | // Drop it and make a note... |
@@ -2891,8 +3050,9 @@ discard block |
||
| 2891 | 3050 | $replace = '%field%'; |
| 2892 | 3051 | |
| 2893 | 3052 | // Build a huge REPLACE statement... |
| 2894 | - foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) |
|
| 2895 | - $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
| 3053 | + foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) { |
|
| 3054 | + $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
| 3055 | + } |
|
| 2896 | 3056 | } |
| 2897 | 3057 | |
| 2898 | 3058 | // Get a list of table names ahead of time... This makes it easier to set our substep and such |
@@ -2902,9 +3062,10 @@ discard block |
||
| 2902 | 3062 | $upcontext['table_count'] = count($queryTables); |
| 2903 | 3063 | |
| 2904 | 3064 | // What ones have we already done? |
| 2905 | - foreach ($queryTables as $id => $table) |
|
| 2906 | - if ($id < $_GET['substep']) |
|
| 3065 | + foreach ($queryTables as $id => $table) { |
|
| 3066 | + if ($id < $_GET['substep']) |
|
| 2907 | 3067 | $upcontext['previous_tables'][] = $table; |
| 3068 | + } |
|
| 2908 | 3069 | |
| 2909 | 3070 | $upcontext['cur_table_num'] = $_GET['substep']; |
| 2910 | 3071 | $upcontext['cur_table_name'] = str_replace($db_prefix, '', $queryTables[$_GET['substep']]); |
@@ -2941,8 +3102,9 @@ discard block |
||
| 2941 | 3102 | nextSubstep($substep); |
| 2942 | 3103 | |
| 2943 | 3104 | // Just to make sure it doesn't time out. |
| 2944 | - if (function_exists('apache_reset_timeout')) |
|
| 2945 | - @apache_reset_timeout(); |
|
| 3105 | + if (function_exists('apache_reset_timeout')) { |
|
| 3106 | + @apache_reset_timeout(); |
|
| 3107 | + } |
|
| 2946 | 3108 | |
| 2947 | 3109 | $table_charsets = array(); |
| 2948 | 3110 | |
@@ -2965,8 +3127,9 @@ discard block |
||
| 2965 | 3127 | |
| 2966 | 3128 | // Build structure of columns to operate on organized by charset; only operate on columns not yet utf8 |
| 2967 | 3129 | if ($charset != 'utf8') { |
| 2968 | - if (!isset($table_charsets[$charset])) |
|
| 2969 | - $table_charsets[$charset] = array(); |
|
| 3130 | + if (!isset($table_charsets[$charset])) { |
|
| 3131 | + $table_charsets[$charset] = array(); |
|
| 3132 | + } |
|
| 2970 | 3133 | |
| 2971 | 3134 | $table_charsets[$charset][] = $column_info; |
| 2972 | 3135 | } |
@@ -3007,10 +3170,11 @@ discard block |
||
| 3007 | 3170 | if (isset($translation_tables[$upcontext['charset_detected']])) |
| 3008 | 3171 | { |
| 3009 | 3172 | $update = ''; |
| 3010 | - foreach ($table_charsets as $charset => $columns) |
|
| 3011 | - foreach ($columns as $column) |
|
| 3173 | + foreach ($table_charsets as $charset => $columns) { |
|
| 3174 | + foreach ($columns as $column) |
|
| 3012 | 3175 | $update .= ' |
| 3013 | 3176 | ' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ','; |
| 3177 | + } |
|
| 3014 | 3178 | |
| 3015 | 3179 | $smcFunc['db_query']('', ' |
| 3016 | 3180 | UPDATE {raw:table_name} |
@@ -3035,8 +3199,9 @@ discard block |
||
| 3035 | 3199 | // Now do the actual conversion (if still needed). |
| 3036 | 3200 | if ($charsets[$upcontext['charset_detected']] !== 'utf8') |
| 3037 | 3201 | { |
| 3038 | - if ($command_line) |
|
| 3039 | - echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
| 3202 | + if ($command_line) { |
|
| 3203 | + echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
| 3204 | + } |
|
| 3040 | 3205 | |
| 3041 | 3206 | $smcFunc['db_query']('', ' |
| 3042 | 3207 | ALTER TABLE {raw:table_name} |
@@ -3046,12 +3211,14 @@ discard block |
||
| 3046 | 3211 | ) |
| 3047 | 3212 | ); |
| 3048 | 3213 | |
| 3049 | - if ($command_line) |
|
| 3050 | - echo " done.\n"; |
|
| 3214 | + if ($command_line) { |
|
| 3215 | + echo " done.\n"; |
|
| 3216 | + } |
|
| 3051 | 3217 | } |
| 3052 | 3218 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 3053 | - if (isset($_GET['xml']) && $upcontext['cur_table_num'] < $upcontext['table_count']) |
|
| 3054 | - return upgradeExit(); |
|
| 3219 | + if (isset($_GET['xml']) && $upcontext['cur_table_num'] < $upcontext['table_count']) { |
|
| 3220 | + return upgradeExit(); |
|
| 3221 | + } |
|
| 3055 | 3222 | } |
| 3056 | 3223 | |
| 3057 | 3224 | $prev_charset = empty($translation_tables[$upcontext['charset_detected']]) ? $charsets[$upcontext['charset_detected']] : $translation_tables[$upcontext['charset_detected']]; |
@@ -3080,8 +3247,8 @@ discard block |
||
| 3080 | 3247 | ); |
| 3081 | 3248 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 3082 | 3249 | { |
| 3083 | - 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) |
|
| 3084 | - $smcFunc['db_query']('', ' |
|
| 3250 | + 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) { |
|
| 3251 | + $smcFunc['db_query']('', ' |
|
| 3085 | 3252 | UPDATE {db_prefix}log_actions |
| 3086 | 3253 | SET extra = {string:extra} |
| 3087 | 3254 | WHERE id_action = {int:current_action}', |
@@ -3090,6 +3257,7 @@ discard block |
||
| 3090 | 3257 | 'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4], |
| 3091 | 3258 | ) |
| 3092 | 3259 | ); |
| 3260 | + } |
|
| 3093 | 3261 | } |
| 3094 | 3262 | $smcFunc['db_free_result']($request); |
| 3095 | 3263 | |
@@ -3111,15 +3279,17 @@ discard block |
||
| 3111 | 3279 | // First thing's first - did we already do this? |
| 3112 | 3280 | if (!empty($modSettings['json_done'])) |
| 3113 | 3281 | { |
| 3114 | - if ($command_line) |
|
| 3115 | - return DeleteUpgrade(); |
|
| 3116 | - else |
|
| 3117 | - return true; |
|
| 3282 | + if ($command_line) { |
|
| 3283 | + return DeleteUpgrade(); |
|
| 3284 | + } else { |
|
| 3285 | + return true; |
|
| 3286 | + } |
|
| 3118 | 3287 | } |
| 3119 | 3288 | |
| 3120 | 3289 | // Done it already - js wise? |
| 3121 | - if (!empty($_POST['json_done'])) |
|
| 3122 | - return true; |
|
| 3290 | + if (!empty($_POST['json_done'])) { |
|
| 3291 | + return true; |
|
| 3292 | + } |
|
| 3123 | 3293 | |
| 3124 | 3294 | // List of tables affected by this function |
| 3125 | 3295 | // name => array('key', col1[,col2|true[,col3]]) |
@@ -3151,12 +3321,14 @@ discard block |
||
| 3151 | 3321 | $upcontext['cur_table_name'] = isset($keys[$_GET['substep']]) ? $keys[$_GET['substep']] : $keys[0]; |
| 3152 | 3322 | $upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100); |
| 3153 | 3323 | |
| 3154 | - foreach ($keys as $id => $table) |
|
| 3155 | - if ($id < $_GET['substep']) |
|
| 3324 | + foreach ($keys as $id => $table) { |
|
| 3325 | + if ($id < $_GET['substep']) |
|
| 3156 | 3326 | $upcontext['previous_tables'][] = $table; |
| 3327 | + } |
|
| 3157 | 3328 | |
| 3158 | - if ($command_line) |
|
| 3159 | - echo 'Converting data from serialize() to json_encode().'; |
|
| 3329 | + if ($command_line) { |
|
| 3330 | + echo 'Converting data from serialize() to json_encode().'; |
|
| 3331 | + } |
|
| 3160 | 3332 | |
| 3161 | 3333 | if (!$support_js || isset($_GET['xml'])) |
| 3162 | 3334 | { |
@@ -3196,8 +3368,9 @@ discard block |
||
| 3196 | 3368 | |
| 3197 | 3369 | // Loop through and fix these... |
| 3198 | 3370 | $new_settings = array(); |
| 3199 | - if ($command_line) |
|
| 3200 | - echo "\n" . 'Fixing some settings...'; |
|
| 3371 | + if ($command_line) { |
|
| 3372 | + echo "\n" . 'Fixing some settings...'; |
|
| 3373 | + } |
|
| 3201 | 3374 | |
| 3202 | 3375 | foreach ($serialized_settings as $var) |
| 3203 | 3376 | { |
@@ -3205,22 +3378,24 @@ discard block |
||
| 3205 | 3378 | { |
| 3206 | 3379 | // Attempt to unserialize the setting |
| 3207 | 3380 | $temp = @safe_unserialize($modSettings[$var]); |
| 3208 | - if (!$temp && $command_line) |
|
| 3209 | - echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
| 3210 | - elseif ($temp !== false) |
|
| 3211 | - $new_settings[$var] = json_encode($temp); |
|
| 3381 | + if (!$temp && $command_line) { |
|
| 3382 | + echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
| 3383 | + } elseif ($temp !== false) { |
|
| 3384 | + $new_settings[$var] = json_encode($temp); |
|
| 3385 | + } |
|
| 3212 | 3386 | } |
| 3213 | 3387 | } |
| 3214 | 3388 | |
| 3215 | 3389 | // Update everything at once |
| 3216 | - if (!function_exists('cache_put_data')) |
|
| 3217 | - require_once($sourcedir . '/Load.php'); |
|
| 3390 | + if (!function_exists('cache_put_data')) { |
|
| 3391 | + require_once($sourcedir . '/Load.php'); |
|
| 3392 | + } |
|
| 3218 | 3393 | updateSettings($new_settings, true); |
| 3219 | 3394 | |
| 3220 | - if ($command_line) |
|
| 3221 | - echo ' done.'; |
|
| 3222 | - } |
|
| 3223 | - elseif ($table == 'themes') |
|
| 3395 | + if ($command_line) { |
|
| 3396 | + echo ' done.'; |
|
| 3397 | + } |
|
| 3398 | + } elseif ($table == 'themes') |
|
| 3224 | 3399 | { |
| 3225 | 3400 | // Finally, fix the admin prefs. Unfortunately this is stored per theme, but hopefully they only have one theme installed at this point... |
| 3226 | 3401 | $query = $smcFunc['db_query']('', ' |
@@ -3239,10 +3414,11 @@ discard block |
||
| 3239 | 3414 | |
| 3240 | 3415 | if ($command_line) |
| 3241 | 3416 | { |
| 3242 | - if ($temp === false) |
|
| 3243 | - echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
| 3244 | - else |
|
| 3245 | - echo "\n" . 'Fixing admin preferences...'; |
|
| 3417 | + if ($temp === false) { |
|
| 3418 | + echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
| 3419 | + } else { |
|
| 3420 | + echo "\n" . 'Fixing admin preferences...'; |
|
| 3421 | + } |
|
| 3246 | 3422 | } |
| 3247 | 3423 | |
| 3248 | 3424 | if ($temp !== false) |
@@ -3264,15 +3440,15 @@ discard block |
||
| 3264 | 3440 | ) |
| 3265 | 3441 | ); |
| 3266 | 3442 | |
| 3267 | - if ($command_line) |
|
| 3268 | - echo ' done.'; |
|
| 3443 | + if ($command_line) { |
|
| 3444 | + echo ' done.'; |
|
| 3445 | + } |
|
| 3269 | 3446 | } |
| 3270 | 3447 | } |
| 3271 | 3448 | |
| 3272 | 3449 | $smcFunc['db_free_result']($query); |
| 3273 | 3450 | } |
| 3274 | - } |
|
| 3275 | - else |
|
| 3451 | + } else |
|
| 3276 | 3452 | { |
| 3277 | 3453 | // First item is always the key... |
| 3278 | 3454 | $key = $info[0]; |
@@ -3283,8 +3459,7 @@ discard block |
||
| 3283 | 3459 | { |
| 3284 | 3460 | $col_select = $info[1]; |
| 3285 | 3461 | $where = ' WHERE ' . $info[1] . ' != {empty}'; |
| 3286 | - } |
|
| 3287 | - else |
|
| 3462 | + } else |
|
| 3288 | 3463 | { |
| 3289 | 3464 | $col_select = implode(', ', $info); |
| 3290 | 3465 | } |
@@ -3317,8 +3492,7 @@ discard block |
||
| 3317 | 3492 | if ($temp === false && $command_line) |
| 3318 | 3493 | { |
| 3319 | 3494 | echo "\nFailed to unserialize " . $row[$col] . "... Skipping\n"; |
| 3320 | - } |
|
| 3321 | - else |
|
| 3495 | + } else |
|
| 3322 | 3496 | { |
| 3323 | 3497 | $row[$col] = json_encode($temp); |
| 3324 | 3498 | |
@@ -3343,16 +3517,18 @@ discard block |
||
| 3343 | 3517 | } |
| 3344 | 3518 | } |
| 3345 | 3519 | |
| 3346 | - if ($command_line) |
|
| 3347 | - echo ' done.'; |
|
| 3520 | + if ($command_line) { |
|
| 3521 | + echo ' done.'; |
|
| 3522 | + } |
|
| 3348 | 3523 | |
| 3349 | 3524 | // Free up some memory... |
| 3350 | 3525 | $smcFunc['db_free_result']($query); |
| 3351 | 3526 | } |
| 3352 | 3527 | } |
| 3353 | 3528 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 3354 | - if (isset($_GET['xml'])) |
|
| 3355 | - return upgradeExit(); |
|
| 3529 | + if (isset($_GET['xml'])) { |
|
| 3530 | + return upgradeExit(); |
|
| 3531 | + } |
|
| 3356 | 3532 | } |
| 3357 | 3533 | |
| 3358 | 3534 | if ($command_line) |
@@ -3367,8 +3543,9 @@ discard block |
||
| 3367 | 3543 | |
| 3368 | 3544 | $_GET['substep'] = 0; |
| 3369 | 3545 | // Make sure we move on! |
| 3370 | - if ($command_line) |
|
| 3371 | - return DeleteUpgrade(); |
|
| 3546 | + if ($command_line) { |
|
| 3547 | + return DeleteUpgrade(); |
|
| 3548 | + } |
|
| 3372 | 3549 | |
| 3373 | 3550 | return true; |
| 3374 | 3551 | } |
@@ -3425,14 +3602,16 @@ discard block |
||
| 3425 | 3602 | global $upcontext, $txt, $settings; |
| 3426 | 3603 | |
| 3427 | 3604 | // Don't call me twice! |
| 3428 | - if (!empty($upcontext['chmod_called'])) |
|
| 3429 | - return; |
|
| 3605 | + if (!empty($upcontext['chmod_called'])) { |
|
| 3606 | + return; |
|
| 3607 | + } |
|
| 3430 | 3608 | |
| 3431 | 3609 | $upcontext['chmod_called'] = true; |
| 3432 | 3610 | |
| 3433 | 3611 | // Nothing? |
| 3434 | - if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) |
|
| 3435 | - return; |
|
| 3612 | + if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) { |
|
| 3613 | + return; |
|
| 3614 | + } |
|
| 3436 | 3615 | |
| 3437 | 3616 | // Was it a problem with Windows? |
| 3438 | 3617 | if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess') |
@@ -3464,11 +3643,12 @@ discard block |
||
| 3464 | 3643 | content.write(\'<div class="windowbg description">\n\t\t\t<h4>', $txt['upgrade_ftp_files'], '</h4>\n\t\t\t\'); |
| 3465 | 3644 | content.write(\'<p>', implode('<br>\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');'; |
| 3466 | 3645 | |
| 3467 | - if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') |
|
| 3468 | - echo ' |
|
| 3646 | + if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') { |
|
| 3647 | + echo ' |
|
| 3469 | 3648 | content.write(\'<hr>\n\t\t\t\'); |
| 3470 | 3649 | content.write(\'<p>', $txt['upgrade_ftp_shell'], '</p>\n\t\t\t\'); |
| 3471 | 3650 | content.write(\'<tt># chmod a+w ', implode(' ', $upcontext['chmod']['files']), '</tt>\n\t\t\t\');'; |
| 3651 | + } |
|
| 3472 | 3652 | |
| 3473 | 3653 | echo ' |
| 3474 | 3654 | content.write(\'<a href="javascript:self.close();">close</a>\n\t\t</div>\n\t</body>\n</html>\'); |
@@ -3476,16 +3656,18 @@ discard block |
||
| 3476 | 3656 | } |
| 3477 | 3657 | </script>'; |
| 3478 | 3658 | |
| 3479 | - if (!empty($upcontext['chmod']['ftp_error'])) |
|
| 3480 | - echo ' |
|
| 3659 | + if (!empty($upcontext['chmod']['ftp_error'])) { |
|
| 3660 | + echo ' |
|
| 3481 | 3661 | <div class="error_message red"> |
| 3482 | 3662 | <p>', $txt['upgrade_ftp_error'], '<p> |
| 3483 | 3663 | <code>', $upcontext['chmod']['ftp_error'], '</code> |
| 3484 | 3664 | </div>'; |
| 3665 | + } |
|
| 3485 | 3666 | |
| 3486 | - if (empty($upcontext['chmod_in_form'])) |
|
| 3487 | - echo ' |
|
| 3667 | + if (empty($upcontext['chmod_in_form'])) { |
|
| 3668 | + echo ' |
|
| 3488 | 3669 | <form action="', $upcontext['form_url'], '" method="post">'; |
| 3670 | + } |
|
| 3489 | 3671 | |
| 3490 | 3672 | echo ' |
| 3491 | 3673 | <dl class="settings"> |
@@ -3527,9 +3709,10 @@ discard block |
||
| 3527 | 3709 | <input type="submit" value="', $txt['ftp_connect'], '" class="button"> |
| 3528 | 3710 | </div>'; |
| 3529 | 3711 | |
| 3530 | - if (empty($upcontext['chmod_in_form'])) |
|
| 3531 | - echo ' |
|
| 3712 | + if (empty($upcontext['chmod_in_form'])) { |
|
| 3713 | + echo ' |
|
| 3532 | 3714 | </form>'; |
| 3715 | + } |
|
| 3533 | 3716 | |
| 3534 | 3717 | echo ' |
| 3535 | 3718 | </div><!-- .panel -->'; |
@@ -3593,9 +3776,10 @@ discard block |
||
| 3593 | 3776 | <h2>', $txt['upgrade_progress'], '</h2> |
| 3594 | 3777 | <ul>'; |
| 3595 | 3778 | |
| 3596 | - foreach ($upcontext['steps'] as $num => $step) |
|
| 3597 | - echo ' |
|
| 3779 | + foreach ($upcontext['steps'] as $num => $step) { |
|
| 3780 | + echo ' |
|
| 3598 | 3781 | <li class="', $num < $upcontext['current_step'] ? 'stepdone' : ($num == $upcontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
| 3782 | + } |
|
| 3599 | 3783 | |
| 3600 | 3784 | echo ' |
| 3601 | 3785 | </ul> |
@@ -3608,13 +3792,14 @@ discard block |
||
| 3608 | 3792 | <span id="overall_text">', $upcontext['overall_percent'], '%</span> |
| 3609 | 3793 | </div>'; |
| 3610 | 3794 | |
| 3611 | - if (isset($upcontext['step_progress'])) |
|
| 3612 | - echo ' |
|
| 3795 | + if (isset($upcontext['step_progress'])) { |
|
| 3796 | + echo ' |
|
| 3613 | 3797 | <div id="progress_bar_step" class="progress_bar progress_yellow"> |
| 3614 | 3798 | <h3>', $txt['upgrade_step_progress'], '</h3> |
| 3615 | 3799 | <div id="step_progress" class="bar" style="width: ', $upcontext['step_progress'], '%;"></div> |
| 3616 | 3800 | <span id="step_text">', $upcontext['step_progress'], '%</span> |
| 3617 | 3801 | </div>'; |
| 3802 | + } |
|
| 3618 | 3803 | |
| 3619 | 3804 | echo ' |
| 3620 | 3805 | <div id="substep_bar_div" class="progress_bar ', isset($upcontext['substep_progress']) ? '' : 'hidden', '"> |
@@ -3645,31 +3830,35 @@ discard block |
||
| 3645 | 3830 | { |
| 3646 | 3831 | global $upcontext, $txt; |
| 3647 | 3832 | |
| 3648 | - if (!empty($upcontext['pause'])) |
|
| 3649 | - echo ' |
|
| 3833 | + if (!empty($upcontext['pause'])) { |
|
| 3834 | + echo ' |
|
| 3650 | 3835 | <em>', $txt['upgrade_incomplete'], '.</em><br> |
| 3651 | 3836 | |
| 3652 | 3837 | <h2 style="margin-top: 2ex;">', $txt['upgrade_not_quite_done'], '</h2> |
| 3653 | 3838 | <h3> |
| 3654 | 3839 | ', $txt['upgrade_paused_overload'], ' |
| 3655 | 3840 | </h3>'; |
| 3841 | + } |
|
| 3656 | 3842 | |
| 3657 | - if (!empty($upcontext['custom_warning'])) |
|
| 3658 | - echo ' |
|
| 3843 | + if (!empty($upcontext['custom_warning'])) { |
|
| 3844 | + echo ' |
|
| 3659 | 3845 | <div class="errorbox"> |
| 3660 | 3846 | <h3>', $txt['upgrade_note'], '</h3> |
| 3661 | 3847 | ', $upcontext['custom_warning'], ' |
| 3662 | 3848 | </div>'; |
| 3849 | + } |
|
| 3663 | 3850 | |
| 3664 | 3851 | echo ' |
| 3665 | 3852 | <div class="righttext" style="margin: 1ex;">'; |
| 3666 | 3853 | |
| 3667 | - if (!empty($upcontext['continue'])) |
|
| 3668 | - echo ' |
|
| 3854 | + if (!empty($upcontext['continue'])) { |
|
| 3855 | + echo ' |
|
| 3669 | 3856 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled' : '', ' class="button">'; |
| 3670 | - if (!empty($upcontext['skip'])) |
|
| 3671 | - echo ' |
|
| 3857 | + } |
|
| 3858 | + if (!empty($upcontext['skip'])) { |
|
| 3859 | + echo ' |
|
| 3672 | 3860 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button">'; |
| 3861 | + } |
|
| 3673 | 3862 | |
| 3674 | 3863 | echo ' |
| 3675 | 3864 | </div> |
@@ -3720,11 +3909,12 @@ discard block |
||
| 3720 | 3909 | echo '<', '?xml version="1.0" encoding="UTF-8"?', '> |
| 3721 | 3910 | <smf>'; |
| 3722 | 3911 | |
| 3723 | - if (!empty($upcontext['get_data'])) |
|
| 3724 | - foreach ($upcontext['get_data'] as $k => $v) |
|
| 3912 | + if (!empty($upcontext['get_data'])) { |
|
| 3913 | + foreach ($upcontext['get_data'] as $k => $v) |
|
| 3725 | 3914 | echo ' |
| 3726 | 3915 | <get key="', $k, '">', $v, '</get>'; |
| 3727 | -} |
|
| 3916 | + } |
|
| 3917 | + } |
|
| 3728 | 3918 | |
| 3729 | 3919 | function template_xml_below() |
| 3730 | 3920 | { |
@@ -3764,20 +3954,22 @@ discard block |
||
| 3764 | 3954 | template_chmod(); |
| 3765 | 3955 | |
| 3766 | 3956 | // For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade! |
| 3767 | - if ($upcontext['is_large_forum']) |
|
| 3768 | - echo ' |
|
| 3957 | + if ($upcontext['is_large_forum']) { |
|
| 3958 | + echo ' |
|
| 3769 | 3959 | <div class="errorbox"> |
| 3770 | 3960 | <h3>', $txt['upgrade_warning'], '</h3> |
| 3771 | 3961 | ', $txt['upgrade_warning_lots_data'], ' |
| 3772 | 3962 | </div>'; |
| 3963 | + } |
|
| 3773 | 3964 | |
| 3774 | 3965 | // A warning message? |
| 3775 | - if (!empty($upcontext['warning'])) |
|
| 3776 | - echo ' |
|
| 3966 | + if (!empty($upcontext['warning'])) { |
|
| 3967 | + echo ' |
|
| 3777 | 3968 | <div class="errorbox"> |
| 3778 | 3969 | <h3>', $txt['upgrade_warning'], '</h3> |
| 3779 | 3970 | ', $upcontext['warning'], ' |
| 3780 | 3971 | </div>'; |
| 3972 | + } |
|
| 3781 | 3973 | |
| 3782 | 3974 | // Paths are incorrect? |
| 3783 | 3975 | echo ' |
@@ -3808,16 +4000,18 @@ discard block |
||
| 3808 | 4000 | <p>', sprintf($txt[$agoTxt], $ago_seconds, $ago_minutes, $ago_hours), '</p> |
| 3809 | 4001 | <p>', sprintf($txt[$updatedTxt], $updated_seconds, $updated_minutes, $updated_hours), '</p>'; |
| 3810 | 4002 | |
| 3811 | - if ($updated < 600) |
|
| 3812 | - echo ' |
|
| 4003 | + if ($updated < 600) { |
|
| 4004 | + echo ' |
|
| 3813 | 4005 | <p>', $txt['upgrade_run_script'], ' ', $upcontext['user']['name'],' ', $txt['upgrade_run_script2'], '</p>'; |
| 4006 | + } |
|
| 3814 | 4007 | |
| 3815 | - if ($updated > $upcontext['inactive_timeout']) |
|
| 3816 | - echo ' |
|
| 4008 | + if ($updated > $upcontext['inactive_timeout']) { |
|
| 4009 | + echo ' |
|
| 3817 | 4010 | <p>',$txt['upgrade_run'], '</p>'; |
| 3818 | - else |
|
| 3819 | - echo ' |
|
| 4011 | + } else { |
|
| 4012 | + echo ' |
|
| 3820 | 4013 | <p>', $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!'), '</p>'; |
| 4014 | + } |
|
| 3821 | 4015 | |
| 3822 | 4016 | echo ' |
| 3823 | 4017 | </div>'; |
@@ -3833,9 +4027,10 @@ discard block |
||
| 3833 | 4027 | <dd> |
| 3834 | 4028 | <input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '"', $disable_security ? ' disabled' : '', '>'; |
| 3835 | 4029 | |
| 3836 | - if (!empty($upcontext['username_incorrect'])) |
|
| 3837 | - echo ' |
|
| 4030 | + if (!empty($upcontext['username_incorrect'])) { |
|
| 4031 | + echo ' |
|
| 3838 | 4032 | <div class="smalltext red">', $txt['upgrade_wrong_username'], '</div>'; |
| 4033 | + } |
|
| 3839 | 4034 | |
| 3840 | 4035 | echo ' |
| 3841 | 4036 | </dd> |
@@ -3846,9 +4041,10 @@ discard block |
||
| 3846 | 4041 | <input type="password" name="passwrd" value=""', $disable_security ? ' disabled' : '', '> |
| 3847 | 4042 | <input type="hidden" name="hash_passwrd" value="">'; |
| 3848 | 4043 | |
| 3849 | - if (!empty($upcontext['password_failed'])) |
|
| 3850 | - echo ' |
|
| 4044 | + if (!empty($upcontext['password_failed'])) { |
|
| 4045 | + echo ' |
|
| 3851 | 4046 | <div class="smalltext red">', $txt['upgrade_wrong_password'], '</div>'; |
| 4047 | + } |
|
| 3852 | 4048 | |
| 3853 | 4049 | echo ' |
| 3854 | 4050 | </dd>'; |
@@ -3916,12 +4112,13 @@ discard block |
||
| 3916 | 4112 | <form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">'; |
| 3917 | 4113 | |
| 3918 | 4114 | // Warning message? |
| 3919 | - if (!empty($upcontext['upgrade_options_warning'])) |
|
| 3920 | - echo ' |
|
| 4115 | + if (!empty($upcontext['upgrade_options_warning'])) { |
|
| 4116 | + echo ' |
|
| 3921 | 4117 | <div class="errorbox"> |
| 3922 | 4118 | <h3>', $txt['upgrade_warning'] ,'</h3> |
| 3923 | 4119 | ', $upcontext['upgrade_options_warning'], ' |
| 3924 | 4120 | </div>'; |
| 4121 | + } |
|
| 3925 | 4122 | |
| 3926 | 4123 | echo ' |
| 3927 | 4124 | <ul class="upgrade_settings"> |
@@ -3950,12 +4147,13 @@ discard block |
||
| 3950 | 4147 | <label for="empty_error">', $txt['upgrade_empty_errlog'], '</label> |
| 3951 | 4148 | </li>'; |
| 3952 | 4149 | |
| 3953 | - if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) |
|
| 3954 | - echo ' |
|
| 4150 | + if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) { |
|
| 4151 | + echo ' |
|
| 3955 | 4152 | <li> |
| 3956 | 4153 | <input type="checkbox" name="delete_karma" id="delete_karma" value="1"> |
| 3957 | 4154 | <label for="delete_karma">', $txt['upgrade_delete_karma'], '</label> |
| 3958 | 4155 | </li>'; |
| 4156 | + } |
|
| 3959 | 4157 | |
| 3960 | 4158 | echo ' |
| 3961 | 4159 | <li> |
@@ -3995,10 +4193,11 @@ discard block |
||
| 3995 | 4193 | </div>'; |
| 3996 | 4194 | |
| 3997 | 4195 | // Dont any tables so far? |
| 3998 | - if (!empty($upcontext['previous_tables'])) |
|
| 3999 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4196 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4197 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 4000 | 4198 | echo ' |
| 4001 | 4199 | <br>', $txt['upgrade_completed_table'], ' "', $table, '".'; |
| 4200 | + } |
|
| 4002 | 4201 | |
| 4003 | 4202 | echo ' |
| 4004 | 4203 | <h3 id="current_tab"> |
@@ -4037,12 +4236,13 @@ discard block |
||
| 4037 | 4236 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 4038 | 4237 | |
| 4039 | 4238 | // If debug flood the screen. |
| 4040 | - if ($is_debug) |
|
| 4041 | - echo ' |
|
| 4239 | + if ($is_debug) { |
|
| 4240 | + echo ' |
|
| 4042 | 4241 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 4043 | 4242 | |
| 4044 | 4243 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4045 | 4244 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4245 | + } |
|
| 4046 | 4246 | |
| 4047 | 4247 | echo ' |
| 4048 | 4248 | // Get the next update... |
@@ -4075,8 +4275,9 @@ discard block |
||
| 4075 | 4275 | { |
| 4076 | 4276 | global $upcontext, $support_js, $is_debug, $timeLimitThreshold, $txt; |
| 4077 | 4277 | |
| 4078 | - if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) |
|
| 4079 | - $is_debug = true; |
|
| 4278 | + if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) { |
|
| 4279 | + $is_debug = true; |
|
| 4280 | + } |
|
| 4080 | 4281 | |
| 4081 | 4282 | echo ' |
| 4082 | 4283 | <h3>', $txt['upgrade_db_changes'], '</h3> |
@@ -4091,8 +4292,9 @@ discard block |
||
| 4091 | 4292 | { |
| 4092 | 4293 | foreach ($upcontext['actioned_items'] as $num => $item) |
| 4093 | 4294 | { |
| 4094 | - if ($num != 0) |
|
| 4095 | - echo ' Successful!'; |
|
| 4295 | + if ($num != 0) { |
|
| 4296 | + echo ' Successful!'; |
|
| 4297 | + } |
|
| 4096 | 4298 | echo '<br>' . $item; |
| 4097 | 4299 | } |
| 4098 | 4300 | |
@@ -4107,20 +4309,20 @@ discard block |
||
| 4107 | 4309 | $seconds = intval($active % 60); |
| 4108 | 4310 | |
| 4109 | 4311 | echo '', sprintf($txt['upgrade_success_time_db'], $seconds, $minutes, $hours), '<br>'; |
| 4312 | + } else { |
|
| 4313 | + echo '', $txt['upgrade_success'], '<br>'; |
|
| 4110 | 4314 | } |
| 4111 | - else |
|
| 4112 | - echo '', $txt['upgrade_success'], '<br>'; |
|
| 4113 | 4315 | |
| 4114 | 4316 | echo ' |
| 4115 | 4317 | <p id="commess">', $txt['upgrade_db_complete'], '</p>'; |
| 4116 | 4318 | } |
| 4117 | - } |
|
| 4118 | - else |
|
| 4319 | + } else |
|
| 4119 | 4320 | { |
| 4120 | 4321 | // Tell them how many files we have in total. |
| 4121 | - if ($upcontext['file_count'] > 1) |
|
| 4122 | - echo ' |
|
| 4322 | + if ($upcontext['file_count'] > 1) { |
|
| 4323 | + echo ' |
|
| 4123 | 4324 | <strong id="info1">', $txt['upgrade_script'], ' <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>'; |
| 4325 | + } |
|
| 4124 | 4326 | |
| 4125 | 4327 | echo ' |
| 4126 | 4328 | <h3 id="info2"> |
@@ -4140,10 +4342,10 @@ discard block |
||
| 4140 | 4342 | |
| 4141 | 4343 | echo ' |
| 4142 | 4344 | <p id="upgradeCompleted">', sprintf($txt['upgrade_success_time_db'], $seconds, $minutes, $hours), '</p>'; |
| 4143 | - } |
|
| 4144 | - else |
|
| 4145 | - echo ' |
|
| 4345 | + } else { |
|
| 4346 | + echo ' |
|
| 4146 | 4347 | <p id="upgradeCompleted"></p>'; |
| 4348 | + } |
|
| 4147 | 4349 | |
| 4148 | 4350 | echo ' |
| 4149 | 4351 | <div id="debug_section"> |
@@ -4179,9 +4381,10 @@ discard block |
||
| 4179 | 4381 | var getData = ""; |
| 4180 | 4382 | var debugItems = ', $upcontext['debug_items'], ';'; |
| 4181 | 4383 | |
| 4182 | - if ($is_debug) |
|
| 4183 | - echo ' |
|
| 4384 | + if ($is_debug) { |
|
| 4385 | + echo ' |
|
| 4184 | 4386 | var upgradeStartTime = ' . $upcontext['started'] . ';'; |
| 4387 | + } |
|
| 4185 | 4388 | |
| 4186 | 4389 | echo ' |
| 4187 | 4390 | function getNextItem() |
@@ -4221,9 +4424,10 @@ discard block |
||
| 4221 | 4424 | document.getElementById("error_block").classList.remove("hidden"); |
| 4222 | 4425 | setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));'; |
| 4223 | 4426 | |
| 4224 | - if ($is_debug) |
|
| 4225 | - echo ' |
|
| 4427 | + if ($is_debug) { |
|
| 4428 | + echo ' |
|
| 4226 | 4429 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span class="red">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
| 4430 | + } |
|
| 4227 | 4431 | |
| 4228 | 4432 | echo ' |
| 4229 | 4433 | } |
@@ -4244,9 +4448,10 @@ discard block |
||
| 4244 | 4448 | document.getElementById("error_block").classList.remove("hidden"); |
| 4245 | 4449 | setInnerHTML(document.getElementById("error_message"), "', $txt['upgrade_loop'], '" + sDebugName);'; |
| 4246 | 4450 | |
| 4247 | - if ($is_debug) |
|
| 4248 | - echo ' |
|
| 4451 | + if ($is_debug) { |
|
| 4452 | + echo ' |
|
| 4249 | 4453 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span class="red">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
| 4454 | + } |
|
| 4250 | 4455 | |
| 4251 | 4456 | echo ' |
| 4252 | 4457 | } |
@@ -4304,8 +4509,8 @@ discard block |
||
| 4304 | 4509 | {'; |
| 4305 | 4510 | |
| 4306 | 4511 | // Database Changes, tell us how much time we spen to do this. If this gets updated via JS. |
| 4307 | - if ($is_debug) |
|
| 4308 | - echo ' |
|
| 4512 | + if ($is_debug) { |
|
| 4513 | + echo ' |
|
| 4309 | 4514 | document.getElementById(\'debug_section\').classList.add("hidden"); |
| 4310 | 4515 | |
| 4311 | 4516 | var upgradeFinishedTime = parseInt(oXMLDoc.getElementsByTagName("curtime")[0].childNodes[0].nodeValue); |
@@ -4320,6 +4525,7 @@ discard block |
||
| 4320 | 4525 | completedTxt = completedTxt.replace("%1$d", diffSeconds).replace("%2$d", diffMinutes).replace("%3$d", diffHours); |
| 4321 | 4526 | console.log(completedTxt, upgradeFinishedTime, diffTime, diffHours, diffMinutes, diffSeconds); |
| 4322 | 4527 | setInnerHTML(document.getElementById("upgradeCompleted"), completedTxt);'; |
| 4528 | + } |
|
| 4323 | 4529 | |
| 4324 | 4530 | echo ' |
| 4325 | 4531 | |
@@ -4327,9 +4533,10 @@ discard block |
||
| 4327 | 4533 | document.getElementById(\'contbutt\').disabled = 0; |
| 4328 | 4534 | document.getElementById(\'database_done\').value = 1;'; |
| 4329 | 4535 | |
| 4330 | - if ($upcontext['file_count'] > 1) |
|
| 4331 | - echo ' |
|
| 4536 | + if ($upcontext['file_count'] > 1) { |
|
| 4537 | + echo ' |
|
| 4332 | 4538 | document.getElementById(\'info1\').classList.add(\'hidden\');'; |
| 4539 | + } |
|
| 4333 | 4540 | |
| 4334 | 4541 | echo ' |
| 4335 | 4542 | document.getElementById(\'info2\').classList.add(\'hidden\'); |
@@ -4342,9 +4549,10 @@ discard block |
||
| 4342 | 4549 | lastItem = 0; |
| 4343 | 4550 | prevFile = curFile;'; |
| 4344 | 4551 | |
| 4345 | - if ($is_debug) |
|
| 4346 | - echo ' |
|
| 4552 | + if ($is_debug) { |
|
| 4553 | + echo ' |
|
| 4347 | 4554 | setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br><span id="debuginfo"><\' + \'/span>\');'; |
| 4555 | + } |
|
| 4348 | 4556 | |
| 4349 | 4557 | echo ' |
| 4350 | 4558 | getNextItem(); |
@@ -4352,8 +4560,8 @@ discard block |
||
| 4352 | 4560 | }'; |
| 4353 | 4561 | |
| 4354 | 4562 | // If debug scroll the screen. |
| 4355 | - if ($is_debug) |
|
| 4356 | - echo ' |
|
| 4563 | + if ($is_debug) { |
|
| 4564 | + echo ' |
|
| 4357 | 4565 | if (iLastSubStepProgress == -1) |
| 4358 | 4566 | { |
| 4359 | 4567 | // Give it consistent dots. |
@@ -4372,6 +4580,7 @@ discard block |
||
| 4372 | 4580 | |
| 4373 | 4581 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4374 | 4582 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4583 | + } |
|
| 4375 | 4584 | |
| 4376 | 4585 | echo ' |
| 4377 | 4586 | // Update the page. |
@@ -4432,9 +4641,10 @@ discard block |
||
| 4432 | 4641 | }'; |
| 4433 | 4642 | |
| 4434 | 4643 | // Start things off assuming we've not errored. |
| 4435 | - if (empty($upcontext['error_message'])) |
|
| 4436 | - echo ' |
|
| 4644 | + if (empty($upcontext['error_message'])) { |
|
| 4645 | + echo ' |
|
| 4437 | 4646 | getNextItem();'; |
| 4647 | + } |
|
| 4438 | 4648 | |
| 4439 | 4649 | echo ' |
| 4440 | 4650 | //# sourceURL=dynamicScript-dbch.js |
@@ -4452,18 +4662,21 @@ discard block |
||
| 4452 | 4662 | <item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item> |
| 4453 | 4663 | <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>'; |
| 4454 | 4664 | |
| 4455 | - if (!empty($upcontext['error_message'])) |
|
| 4456 | - echo ' |
|
| 4665 | + if (!empty($upcontext['error_message'])) { |
|
| 4666 | + echo ' |
|
| 4457 | 4667 | <error>', $upcontext['error_message'], '</error>'; |
| 4668 | + } |
|
| 4458 | 4669 | |
| 4459 | - if (!empty($upcontext['error_string'])) |
|
| 4460 | - echo ' |
|
| 4670 | + if (!empty($upcontext['error_string'])) { |
|
| 4671 | + echo ' |
|
| 4461 | 4672 | <sql>', $upcontext['error_string'], '</sql>'; |
| 4673 | + } |
|
| 4462 | 4674 | |
| 4463 | - if ($is_debug) |
|
| 4464 | - echo ' |
|
| 4675 | + if ($is_debug) { |
|
| 4676 | + echo ' |
|
| 4465 | 4677 | <curtime>', time(), '</curtime>'; |
| 4466 | -} |
|
| 4678 | + } |
|
| 4679 | + } |
|
| 4467 | 4680 | |
| 4468 | 4681 | // Template for the UTF-8 conversion step. Basically a copy of the backup stuff with slight modifications.... |
| 4469 | 4682 | function template_convert_utf8() |
@@ -4480,10 +4693,11 @@ discard block |
||
| 4480 | 4693 | </div>'; |
| 4481 | 4694 | |
| 4482 | 4695 | // Done any tables so far? |
| 4483 | - if (!empty($upcontext['previous_tables'])) |
|
| 4484 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4696 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4697 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 4485 | 4698 | echo ' |
| 4486 | 4699 | <br>', $txt['upgrade_completed_table'], ' "', $table, '".'; |
| 4700 | + } |
|
| 4487 | 4701 | |
| 4488 | 4702 | echo ' |
| 4489 | 4703 | <h3 id="current_tab"> |
@@ -4491,9 +4705,10 @@ discard block |
||
| 4491 | 4705 | </h3>'; |
| 4492 | 4706 | |
| 4493 | 4707 | // If we dropped their index, let's let them know |
| 4494 | - if ($upcontext['dropping_index']) |
|
| 4495 | - echo ' |
|
| 4708 | + if ($upcontext['dropping_index']) { |
|
| 4709 | + echo ' |
|
| 4496 | 4710 | <p id="indexmsg" class="', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline_block' : 'hidden', ' style="font-weight: bold; font-style: italic">', $txt['upgrade_fulltext'], '</p>'; |
| 4711 | + } |
|
| 4497 | 4712 | |
| 4498 | 4713 | // Completion notification |
| 4499 | 4714 | echo ' |
@@ -4530,12 +4745,13 @@ discard block |
||
| 4530 | 4745 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 4531 | 4746 | |
| 4532 | 4747 | // If debug flood the screen. |
| 4533 | - if ($is_debug) |
|
| 4534 | - echo ' |
|
| 4748 | + if ($is_debug) { |
|
| 4749 | + echo ' |
|
| 4535 | 4750 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 4536 | 4751 | |
| 4537 | 4752 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4538 | 4753 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4754 | + } |
|
| 4539 | 4755 | |
| 4540 | 4756 | echo ' |
| 4541 | 4757 | // Get the next update... |
@@ -4581,10 +4797,11 @@ discard block |
||
| 4581 | 4797 | </div>'; |
| 4582 | 4798 | |
| 4583 | 4799 | // Dont any tables so far? |
| 4584 | - if (!empty($upcontext['previous_tables'])) |
|
| 4585 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4800 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4801 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 4586 | 4802 | echo ' |
| 4587 | 4803 | <br>', $txt['upgrade_completed_table'], ' "', $table, '".'; |
| 4804 | + } |
|
| 4588 | 4805 | |
| 4589 | 4806 | echo ' |
| 4590 | 4807 | <h3 id="current_tab"> |
@@ -4593,9 +4810,10 @@ discard block |
||
| 4593 | 4810 | <p id="commess" class="', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline_block' : 'hidden', '">', $txt['upgrade_json_completed'], '</p>'; |
| 4594 | 4811 | |
| 4595 | 4812 | // Try to make sure substep was reset. |
| 4596 | - if ($upcontext['cur_table_num'] == $upcontext['table_count']) |
|
| 4597 | - echo ' |
|
| 4813 | + if ($upcontext['cur_table_num'] == $upcontext['table_count']) { |
|
| 4814 | + echo ' |
|
| 4598 | 4815 | <input type="hidden" name="substep" id="substep" value="0">'; |
| 4816 | + } |
|
| 4599 | 4817 | |
| 4600 | 4818 | // Continue please! |
| 4601 | 4819 | $upcontext['continue'] = $support_js ? 2 : 1; |
@@ -4628,12 +4846,13 @@ discard block |
||
| 4628 | 4846 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 4629 | 4847 | |
| 4630 | 4848 | // If debug flood the screen. |
| 4631 | - if ($is_debug) |
|
| 4632 | - echo ' |
|
| 4849 | + if ($is_debug) { |
|
| 4850 | + echo ' |
|
| 4633 | 4851 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>', $txt['upgrade_completed_table'], ' "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 4634 | 4852 | |
| 4635 | 4853 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4636 | 4854 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4855 | + } |
|
| 4637 | 4856 | |
| 4638 | 4857 | echo ' |
| 4639 | 4858 | // Get the next update... |
@@ -4669,8 +4888,8 @@ discard block |
||
| 4669 | 4888 | <h3>', $txt['upgrade_done'], ' <a href="', $boardurl, '/index.php">', $txt['upgrade_done2'], '</a>. ', $txt['upgrade_done3'], '</h3> |
| 4670 | 4889 | <form action="', $boardurl, '/index.php">'; |
| 4671 | 4890 | |
| 4672 | - if (!empty($upcontext['can_delete_script'])) |
|
| 4673 | - echo ' |
|
| 4891 | + if (!empty($upcontext['can_delete_script'])) { |
|
| 4892 | + echo ' |
|
| 4674 | 4893 | <label> |
| 4675 | 4894 | <input type="checkbox" id="delete_self" onclick="doTheDelete(this);"> ', $txt['upgrade_delete_now'], ' |
| 4676 | 4895 | </label> |
@@ -4684,6 +4903,7 @@ discard block |
||
| 4684 | 4903 | } |
| 4685 | 4904 | </script> |
| 4686 | 4905 | <img src="', $settings['default_theme_url'], '/images/blank.png" alt="" id="delete_upgrader"><br>'; |
| 4906 | + } |
|
| 4687 | 4907 | |
| 4688 | 4908 | // Show Upgrade time in debug mode when we completed the upgrade process totatly |
| 4689 | 4909 | if ($is_debug) |
@@ -4693,12 +4913,13 @@ discard block |
||
| 4693 | 4913 | $minutes = intval(($active / 60) % 60); |
| 4694 | 4914 | $seconds = intval($active % 60); |
| 4695 | 4915 | |
| 4696 | - if ($hours > 0) |
|
| 4697 | - echo '', sprintf($txt['upgrade_completed_time_hms'], $seconds, $minutes, $hours), ''; |
|
| 4698 | - elseif ($minutes > 0) |
|
| 4699 | - echo '', sprintf($txt['upgrade_completed_time_ms'], $seconds, $minutes), ''; |
|
| 4700 | - elseif ($seconds > 0) |
|
| 4701 | - echo '', sprintf($txt['upgrade_completed_time_s'], $seconds), ''; |
|
| 4916 | + if ($hours > 0) { |
|
| 4917 | + echo '', sprintf($txt['upgrade_completed_time_hms'], $seconds, $minutes, $hours), ''; |
|
| 4918 | + } elseif ($minutes > 0) { |
|
| 4919 | + echo '', sprintf($txt['upgrade_completed_time_ms'], $seconds, $minutes), ''; |
|
| 4920 | + } elseif ($seconds > 0) { |
|
| 4921 | + echo '', sprintf($txt['upgrade_completed_time_s'], $seconds), ''; |
|
| 4922 | + } |
|
| 4702 | 4923 | } |
| 4703 | 4924 | |
| 4704 | 4925 | echo ' |
@@ -4728,8 +4949,9 @@ discard block |
||
| 4728 | 4949 | |
| 4729 | 4950 | $current_substep = $_GET['substep']; |
| 4730 | 4951 | |
| 4731 | - if (empty($_GET['a'])) |
|
| 4732 | - $_GET['a'] = 0; |
|
| 4952 | + if (empty($_GET['a'])) { |
|
| 4953 | + $_GET['a'] = 0; |
|
| 4954 | + } |
|
| 4733 | 4955 | $step_progress['name'] = 'Converting ips'; |
| 4734 | 4956 | $step_progress['current'] = $_GET['a']; |
| 4735 | 4957 | |
@@ -4772,16 +4994,19 @@ discard block |
||
| 4772 | 4994 | 'empty' => '', |
| 4773 | 4995 | 'limit' => $limit, |
| 4774 | 4996 | )); |
| 4775 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 4776 | - $arIp[] = $row[$oldCol]; |
|
| 4997 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 4998 | + $arIp[] = $row[$oldCol]; |
|
| 4999 | + } |
|
| 4777 | 5000 | $smcFunc['db_free_result']($request); |
| 4778 | 5001 | |
| 4779 | 5002 | // Special case, null ip could keep us in a loop. |
| 4780 | - if (is_null($arIp[0])) |
|
| 4781 | - unset($arIp[0]); |
|
| 5003 | + if (is_null($arIp[0])) { |
|
| 5004 | + unset($arIp[0]); |
|
| 5005 | + } |
|
| 4782 | 5006 | |
| 4783 | - if (empty($arIp)) |
|
| 4784 | - $is_done = true; |
|
| 5007 | + if (empty($arIp)) { |
|
| 5008 | + $is_done = true; |
|
| 5009 | + } |
|
| 4785 | 5010 | |
| 4786 | 5011 | $updates = array(); |
| 4787 | 5012 | $cases = array(); |
@@ -4790,16 +5015,18 @@ discard block |
||
| 4790 | 5015 | { |
| 4791 | 5016 | $arIp[$i] = trim($arIp[$i]); |
| 4792 | 5017 | |
| 4793 | - if (empty($arIp[$i])) |
|
| 4794 | - continue; |
|
| 5018 | + if (empty($arIp[$i])) { |
|
| 5019 | + continue; |
|
| 5020 | + } |
|
| 4795 | 5021 | |
| 4796 | 5022 | $updates['ip' . $i] = $arIp[$i]; |
| 4797 | 5023 | $cases[$arIp[$i]] = 'WHEN ' . $oldCol . ' = {string:ip' . $i . '} THEN {inet:ip' . $i . '}'; |
| 4798 | 5024 | |
| 4799 | 5025 | if ($setSize > 0 && $i % $setSize === 0) |
| 4800 | 5026 | { |
| 4801 | - if (count($updates) == 1) |
|
| 4802 | - continue; |
|
| 5027 | + if (count($updates) == 1) { |
|
| 5028 | + continue; |
|
| 5029 | + } |
|
| 4803 | 5030 | |
| 4804 | 5031 | $updates['whereSet'] = array_values($updates); |
| 4805 | 5032 | $smcFunc['db_query']('', ' |
@@ -4833,8 +5060,7 @@ discard block |
||
| 4833 | 5060 | 'ip' => $ip |
| 4834 | 5061 | )); |
| 4835 | 5062 | } |
| 4836 | - } |
|
| 4837 | - else |
|
| 5063 | + } else |
|
| 4838 | 5064 | { |
| 4839 | 5065 | $updates['whereSet'] = array_values($updates); |
| 4840 | 5066 | $smcFunc['db_query']('', ' |
@@ -4848,9 +5074,9 @@ discard block |
||
| 4848 | 5074 | $updates |
| 4849 | 5075 | ); |
| 4850 | 5076 | } |
| 5077 | + } else { |
|
| 5078 | + $is_done = true; |
|
| 4851 | 5079 | } |
| 4852 | - else |
|
| 4853 | - $is_done = true; |
|
| 4854 | 5080 | |
| 4855 | 5081 | $_GET['a'] += $limit; |
| 4856 | 5082 | $step_progress['current'] = $_GET['a']; |
@@ -4876,11 +5102,12 @@ discard block |
||
| 4876 | 5102 | |
| 4877 | 5103 | $columns = $smcFunc['db_list_columns']($targetTable, true); |
| 4878 | 5104 | |
| 4879 | - if (isset($columns[$column])) |
|
| 4880 | - return $columns[$column]; |
|
| 4881 | - else |
|
| 4882 | - return null; |
|
| 4883 | -} |
|
| 5105 | + if (isset($columns[$column])) { |
|
| 5106 | + return $columns[$column]; |
|
| 5107 | + } else { |
|
| 5108 | + return null; |
|
| 5109 | + } |
|
| 5110 | + } |
|
| 4884 | 5111 | |
| 4885 | 5112 | /** |
| 4886 | 5113 | * Takes the changes to be made during the upgradeOptions step, grabs all known Settings data from Settings.php, then runs |
@@ -5154,18 +5381,20 @@ discard block |
||
| 5154 | 5381 | global $$setVar; |
| 5155 | 5382 | |
| 5156 | 5383 | // Find the setting. |
| 5157 | - if ($setType == 'string' || $setType == 'string_fatal') |
|
| 5158 | - $original[$setVar] = isset($$setVar) ? '\'' . addslashes($$setVar) . '\'' : (strpos('fatal', $setType) ? null : '\'\''); |
|
| 5159 | - elseif ($setType == 'int' || $setType == 'int_fatal') |
|
| 5160 | - $original[$setVar] = isset($$setVar) ? (int) $$setVar : (strpos('fatal', $setType) ? null : 0); |
|
| 5161 | - elseif ($setType == 'bool' || $setType == 'bool_fatal') |
|
| 5162 | - $original[$setVar] = isset($$setVar) && in_array($$setVar, array(1, true)) ? 'true' : (strpos('fatal', $setType) ? null : 'false'); |
|
| 5163 | - elseif ($setType == 'null' || $setType == 'null_fatal') |
|
| 5164 | - $original[$setVar] = isset($$setVar) && in_array($$setVar, array(1, true)) ? 'true' : (strpos('fatal', $setType) ? null : 'null'); |
|
| 5384 | + if ($setType == 'string' || $setType == 'string_fatal') { |
|
| 5385 | + $original[$setVar] = isset($$setVar) ? '\'' . addslashes($$setVar) . '\'' : (strpos('fatal', $setType) ? null : '\'\''); |
|
| 5386 | + } elseif ($setType == 'int' || $setType == 'int_fatal') { |
|
| 5387 | + $original[$setVar] = isset($$setVar) ? (int) $$setVar : (strpos('fatal', $setType) ? null : 0); |
|
| 5388 | + } elseif ($setType == 'bool' || $setType == 'bool_fatal') { |
|
| 5389 | + $original[$setVar] = isset($$setVar) && in_array($$setVar, array(1, true)) ? 'true' : (strpos('fatal', $setType) ? null : 'false'); |
|
| 5390 | + } elseif ($setType == 'null' || $setType == 'null_fatal') { |
|
| 5391 | + $original[$setVar] = isset($$setVar) && in_array($$setVar, array(1, true)) ? 'true' : (strpos('fatal', $setType) ? null : 'null'); |
|
| 5392 | + } |
|
| 5165 | 5393 | |
| 5166 | 5394 | // Well this isn't good. Do we fix it or bail? |
| 5167 | - if (is_null($original) && $setType != 'null' && strpos('fatal', $setType) > -1) |
|
| 5168 | - return throw_error('The upgrader could not copy a setting (' . $setVar . ') from your Settings file. Unable to migrate your Settings file to a new version.'); |
|
| 5395 | + if (is_null($original) && $setType != 'null' && strpos('fatal', $setType) > -1) { |
|
| 5396 | + return throw_error('The upgrader could not copy a setting (' . $setVar . ') from your Settings file. Unable to migrate your Settings file to a new version.'); |
|
| 5397 | + } |
|
| 5169 | 5398 | } |
| 5170 | 5399 | |
| 5171 | 5400 | // Finally, merge the changes with the new ones. |
@@ -5173,8 +5402,9 @@ discard block |
||
| 5173 | 5402 | foreach ($changes as $setVar => $value) |
| 5174 | 5403 | { |
| 5175 | 5404 | // Nothing needed here. |
| 5176 | - if ($setVar != 'upgradeData' && $config_vars[$setVar] == $changes[$setVar]) |
|
| 5177 | - continue; |
|
| 5405 | + if ($setVar != 'upgradeData' && $config_vars[$setVar] == $changes[$setVar]) { |
|
| 5406 | + continue; |
|
| 5407 | + } |
|
| 5178 | 5408 | |
| 5179 | 5409 | $config_vars[$setVar] = $value; |
| 5180 | 5410 | } |
@@ -5187,15 +5417,17 @@ discard block |
||
| 5187 | 5417 | $last_settings_change = filemtime($boarddir . '/Settings.php'); |
| 5188 | 5418 | |
| 5189 | 5419 | // remove any /r's that made there way in here |
| 5190 | - foreach ($settingsArray as $k => $dummy) |
|
| 5191 | - $settingsArray[$k] = strtr($dummy, array("\r" => '')) . "\n"; |
|
| 5420 | + foreach ($settingsArray as $k => $dummy) { |
|
| 5421 | + $settingsArray[$k] = strtr($dummy, array("\r" => '')) . "\n"; |
|
| 5422 | + } |
|
| 5192 | 5423 | |
| 5193 | 5424 | // go line by line and see whats changing |
| 5194 | 5425 | for ($i = 0, $n = count($settingsArray); $i < $n; $i++) |
| 5195 | 5426 | { |
| 5196 | 5427 | // Don't trim or bother with it if it's not a variable. |
| 5197 | - if (substr($settingsArray[$i], 0, 1) != '$') |
|
| 5198 | - continue; |
|
| 5428 | + if (substr($settingsArray[$i], 0, 1) != '$') { |
|
| 5429 | + continue; |
|
| 5430 | + } |
|
| 5199 | 5431 | |
| 5200 | 5432 | $settingsArray[$i] = trim($settingsArray[$i]) . "\n"; |
| 5201 | 5433 | |
@@ -5203,9 +5435,9 @@ discard block |
||
| 5203 | 5435 | foreach ($config_vars as $var => $val) |
| 5204 | 5436 | { |
| 5205 | 5437 | // be sure someone is not updating db_last_error this with a group |
| 5206 | - if ($var === 'db_last_error') |
|
| 5207 | - unset($config_vars[$var]); |
|
| 5208 | - elseif (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
| 5438 | + if ($var === 'db_last_error') { |
|
| 5439 | + unset($config_vars[$var]); |
|
| 5440 | + } elseif (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
| 5209 | 5441 | { |
| 5210 | 5442 | $comment = strstr(substr($settingsArray[$i], strpos($settingsArray[$i], ';')), '#'); |
| 5211 | 5443 | $settingsArray[$i] = '$' . $var . ' = ' . $val . ';' . ($comment == '' ? '' : "\t\t" . rtrim($comment)) . "\n"; |
@@ -5216,34 +5448,39 @@ discard block |
||
| 5216 | 5448 | } |
| 5217 | 5449 | |
| 5218 | 5450 | // End of the file ... maybe |
| 5219 | - if (substr(trim($settingsArray[$i]), 0, 2) == '?' . '>') |
|
| 5220 | - $end = $i; |
|
| 5451 | + if (substr(trim($settingsArray[$i]), 0, 2) == '?' . '>') { |
|
| 5452 | + $end = $i; |
|
| 5453 | + } |
|
| 5221 | 5454 | } |
| 5222 | 5455 | |
| 5223 | 5456 | // This should never happen, but apparently it is happening. |
| 5224 | - if (empty($end) || $end < 10) |
|
| 5225 | - $end = count($settingsArray) - 1; |
|
| 5457 | + if (empty($end) || $end < 10) { |
|
| 5458 | + $end = count($settingsArray) - 1; |
|
| 5459 | + } |
|
| 5226 | 5460 | |
| 5227 | 5461 | // Still more variables to go? Then lets add them at the end. |
| 5228 | 5462 | if (!empty($config_vars)) |
| 5229 | 5463 | { |
| 5230 | - if (trim($settingsArray[$end]) == '?' . '>') |
|
| 5231 | - $settingsArray[$end++] = ''; |
|
| 5232 | - else |
|
| 5233 | - $end++; |
|
| 5464 | + if (trim($settingsArray[$end]) == '?' . '>') { |
|
| 5465 | + $settingsArray[$end++] = ''; |
|
| 5466 | + } else { |
|
| 5467 | + $end++; |
|
| 5468 | + } |
|
| 5234 | 5469 | |
| 5235 | 5470 | // Add in any newly defined vars that were passed |
| 5236 | - foreach ($config_vars as $var => $val) |
|
| 5237 | - $settingsArray[$end++] = '$' . $var . ' = ' . $val . ';' . "\n"; |
|
| 5471 | + foreach ($config_vars as $var => $val) { |
|
| 5472 | + $settingsArray[$end++] = '$' . $var . ' = ' . $val . ';' . "\n"; |
|
| 5473 | + } |
|
| 5238 | 5474 | |
| 5239 | 5475 | $settingsArray[$end] = '?' . '>'; |
| 5476 | + } else { |
|
| 5477 | + $settingsArray[$end] = trim($settingsArray[$end]); |
|
| 5240 | 5478 | } |
| 5241 | - else |
|
| 5242 | - $settingsArray[$end] = trim($settingsArray[$end]); |
|
| 5243 | 5479 | |
| 5244 | 5480 | // Sanity error checking: the file needs to be at least 12 lines. |
| 5245 | - if (count($settingsArray) < 12) |
|
| 5246 | - return throw_error('The upgrader could not process your Settings file for updates. Unable to migrate your Settings file to a new version.'); |
|
| 5481 | + if (count($settingsArray) < 12) { |
|
| 5482 | + return throw_error('The upgrader could not process your Settings file for updates. Unable to migrate your Settings file to a new version.'); |
|
| 5483 | + } |
|
| 5247 | 5484 | |
| 5248 | 5485 | // Try to avoid a few pitfalls: |
| 5249 | 5486 | // - like a possible race condition, |
@@ -5251,8 +5488,9 @@ discard block |
||
| 5251 | 5488 | // |
| 5252 | 5489 | // Check before you act: if cache is enabled, we can do a simple write test |
| 5253 | 5490 | // to validate that we even write things on this filesystem. |
| 5254 | - if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) |
|
| 5255 | - $cachedir = $boarddir . '/cache'; |
|
| 5491 | + if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) { |
|
| 5492 | + $cachedir = $boarddir . '/cache'; |
|
| 5493 | + } |
|
| 5256 | 5494 | |
| 5257 | 5495 | $test_fp = @fopen($cachedir . '/settings_update.tmp', "w+"); |
| 5258 | 5496 | if ($test_fp) |
@@ -5263,8 +5501,9 @@ discard block |
||
| 5263 | 5501 | |
| 5264 | 5502 | // Oops. Low disk space, perhaps. Don't mess with Settings.php then. |
| 5265 | 5503 | // No means no. :P |
| 5266 | - if ($written_bytes !== 4) |
|
| 5267 | - return throw_error('The upgrader could not write a test file, perhaps not enough storage? Unable to migrate your Settings file to a new version.'); |
|
| 5504 | + if ($written_bytes !== 4) { |
|
| 5505 | + return throw_error('The upgrader could not write a test file, perhaps not enough storage? Unable to migrate your Settings file to a new version.'); |
|
| 5506 | + } |
|
| 5268 | 5507 | } |
| 5269 | 5508 | |
| 5270 | 5509 | // Protect me from what I want! :P |
@@ -5282,8 +5521,9 @@ discard block |
||
| 5282 | 5521 | // survey says ... |
| 5283 | 5522 | if ($written_bytes !== strlen($write_settings) && !$settings_backup_fail) |
| 5284 | 5523 | { |
| 5285 | - if (file_exists($boarddir . '/Settings_bak.php')) |
|
| 5286 | - @copy($boarddir . '/Settings_bak.php', $boarddir . '/Settings.php'); |
|
| 5524 | + if (file_exists($boarddir . '/Settings_bak.php')) { |
|
| 5525 | + @copy($boarddir . '/Settings_bak.php', $boarddir . '/Settings.php'); |
|
| 5526 | + } |
|
| 5287 | 5527 | |
| 5288 | 5528 | return throw_error('The upgrader detected a bad Settings file and reverted the changes. Unable to migrate your Settings file to a new version.'); |
| 5289 | 5529 | } |
@@ -5291,9 +5531,10 @@ discard block |
||
| 5291 | 5531 | |
| 5292 | 5532 | // Even though on normal installations the filemtime should prevent this being used by the installer incorrectly |
| 5293 | 5533 | // it seems that there are times it might not. So let's MAKE it dump the cache. |
| 5294 | - if (function_exists('opcache_invalidate')) |
|
| 5295 | - opcache_invalidate($boarddir . '/Settings.php', true); |
|
| 5296 | -} |
|
| 5534 | + if (function_exists('opcache_invalidate')) { |
|
| 5535 | + opcache_invalidate($boarddir . '/Settings.php', true); |
|
| 5536 | + } |
|
| 5537 | + } |
|
| 5297 | 5538 | |
| 5298 | 5539 | /** |
| 5299 | 5540 | * Determine if we should auto select the migrate Settings file. This is determined by a variety of missing settings. |
@@ -5310,23 +5551,27 @@ discard block |
||
| 5310 | 5551 | global $boarddir, $packagesdir, $tasksdir, $db_server, $db_type, $image_proxy_enabled, $db_show_debug; |
| 5311 | 5552 | |
| 5312 | 5553 | // We should not migrate if db_show_debug is in there, some dev stuff going on here. |
| 5313 | - if (isset($db_show_debug)) |
|
| 5314 | - return false; |
|
| 5554 | + if (isset($db_show_debug)) { |
|
| 5555 | + return false; |
|
| 5556 | + } |
|
| 5315 | 5557 | |
| 5316 | 5558 | $file_contents = file_get_contents($boarddir . '/Settings.php'); |
| 5317 | 5559 | |
| 5318 | 5560 | // Is there a include statement somewhere in there? Some advanced handling of the variables elsewhere? |
| 5319 | 5561 | // Try our best to stay away from the cachedir match. |
| 5320 | - if (preg_match('~\sinclude\((?:(?!\(isset\(\$cachedir))~im', $file_contents)) |
|
| 5321 | - return false; |
|
| 5562 | + if (preg_match('~\sinclude\((?:(?!\(isset\(\$cachedir))~im', $file_contents)) { |
|
| 5563 | + return false; |
|
| 5564 | + } |
|
| 5322 | 5565 | |
| 5323 | 5566 | // If we find a mention of $GLOBALS, there may be a integration going on. |
| 5324 | - if (preg_match('~\$GLOBALS\[~im', $file_contents)) |
|
| 5325 | - return false; |
|
| 5567 | + if (preg_match('~\$GLOBALS\[~im', $file_contents)) { |
|
| 5568 | + return false; |
|
| 5569 | + } |
|
| 5326 | 5570 | |
| 5327 | 5571 | // If these are not set, it makes us a canidate to migrate. |
| 5328 | - if (!isset($packagesdir, $tasksdir, $db_server, $db_type, $image_proxy_enabled)) |
|
| 5329 | - return true; |
|
| 5572 | + if (!isset($packagesdir, $tasksdir, $db_server, $db_type, $image_proxy_enabled)) { |
|
| 5573 | + return true; |
|
| 5574 | + } |
|
| 5330 | 5575 | |
| 5331 | 5576 | return false; |
| 5332 | 5577 | } |
@@ -18,11 +18,12 @@ discard block |
||
| 18 | 18 | global $context, $txt, $scripturl, $modSettings; |
| 19 | 19 | |
| 20 | 20 | // If maintenance has finished tell the user. |
| 21 | - if (!empty($context['maintenance_finished'])) |
|
| 22 | - echo ' |
|
| 21 | + if (!empty($context['maintenance_finished'])) { |
|
| 22 | + echo ' |
|
| 23 | 23 | <div class="infobox"> |
| 24 | 24 | ', sprintf($txt['maintain_done'], $context['maintenance_finished']), ' |
| 25 | 25 | </div>'; |
| 26 | + } |
|
| 26 | 27 | |
| 27 | 28 | echo ' |
| 28 | 29 | <div id="manage_maintenance"> |
@@ -39,8 +40,8 @@ discard block |
||
| 39 | 40 | </div>'; |
| 40 | 41 | |
| 41 | 42 | // Show an option to convert the body column of the post table to MEDIUMTEXT or TEXT |
| 42 | - if (isset($context['convert_to'])) |
|
| 43 | - echo ' |
|
| 43 | + if (isset($context['convert_to'])) { |
|
| 44 | + echo ' |
|
| 44 | 45 | <div class="cat_bar"> |
| 45 | 46 | <h3 class="catbg">', $txt[$context['convert_to'] . '_title'], '</h3> |
| 46 | 47 | </div> |
@@ -53,10 +54,11 @@ discard block |
||
| 53 | 54 | <input type="hidden" name="', $context['admin-maint_token_var'], '" value="', $context['admin-maint_token'], '"> |
| 54 | 55 | </form> |
| 55 | 56 | </div>'; |
| 57 | + } |
|
| 56 | 58 | |
| 57 | 59 | // We might want to convert entities if we're on UTF-8. |
| 58 | - if ($context['convert_entities']) |
|
| 59 | - echo ' |
|
| 60 | + if ($context['convert_entities']) { |
|
| 61 | + echo ' |
|
| 60 | 62 | <div class="cat_bar"> |
| 61 | 63 | <h3 class="catbg">', $txt['entity_convert_title'], '</h3> |
| 62 | 64 | </div> |
@@ -68,6 +70,7 @@ discard block |
||
| 68 | 70 | <input type="hidden" name="', $context['admin-maint_token_var'], '" value="', $context['admin-maint_token'], '"> |
| 69 | 71 | </form> |
| 70 | 72 | </div>'; |
| 73 | + } |
|
| 71 | 74 | |
| 72 | 75 | echo ' |
| 73 | 76 | </div><!-- #manage_maintenance -->'; |
@@ -85,11 +88,12 @@ discard block |
||
| 85 | 88 | <div id="manage_maintenance">'; |
| 86 | 89 | |
| 87 | 90 | // If maintenance has finished tell the user. |
| 88 | - if (!empty($context['maintenance_finished'])) |
|
| 89 | - echo ' |
|
| 91 | + if (!empty($context['maintenance_finished'])) { |
|
| 92 | + echo ' |
|
| 90 | 93 | <div class="infobox"> |
| 91 | 94 | ', sprintf($txt['maintain_done'], $context['maintenance_finished']), ' |
| 92 | 95 | </div>'; |
| 96 | + } |
|
| 93 | 97 | |
| 94 | 98 | echo ' |
| 95 | 99 | <div class="cat_bar"> |
@@ -221,11 +225,12 @@ discard block |
||
| 221 | 225 | <div id="manage_maintenance">'; |
| 222 | 226 | |
| 223 | 227 | // If maintenance has finished, tell the user. |
| 224 | - if (!empty($context['maintenance_finished'])) |
|
| 225 | - echo ' |
|
| 228 | + if (!empty($context['maintenance_finished'])) { |
|
| 229 | + echo ' |
|
| 226 | 230 | <div class="infobox"> |
| 227 | 231 | ', sprintf($txt['maintain_done'], $context['maintenance_finished']), ' |
| 228 | 232 | </div>'; |
| 233 | + } |
|
| 229 | 234 | |
| 230 | 235 | echo ' |
| 231 | 236 | <div class="cat_bar"> |
@@ -287,9 +292,10 @@ discard block |
||
| 287 | 292 | </p> |
| 288 | 293 | <div style="display: none;" id="membersPanel">'; |
| 289 | 294 | |
| 290 | - foreach ($context['membergroups'] as $group) |
|
| 291 | - echo ' |
|
| 295 | + foreach ($context['membergroups'] as $group) { |
|
| 296 | + echo ' |
|
| 292 | 297 | <label for="groups', $group['id'], '"><input type="checkbox" name="groups[', $group['id'], ']" id="groups', $group['id'], '" checked> ', $group['name'], '</label><br>'; |
| 298 | + } |
|
| 293 | 299 | |
| 294 | 300 | echo ' |
| 295 | 301 | </div> |
@@ -333,11 +339,12 @@ discard block |
||
| 333 | 339 | global $scripturl, $txt, $context, $settings, $modSettings; |
| 334 | 340 | |
| 335 | 341 | // If maintenance has finished tell the user. |
| 336 | - if (!empty($context['maintenance_finished'])) |
|
| 337 | - echo ' |
|
| 342 | + if (!empty($context['maintenance_finished'])) { |
|
| 343 | + echo ' |
|
| 338 | 344 | <div class="infobox"> |
| 339 | 345 | ', sprintf($txt['maintain_done'], $context['maintenance_finished']), ' |
| 340 | 346 | </div>'; |
| 347 | + } |
|
| 341 | 348 | |
| 342 | 349 | // Bit of javascript for showing which boards to prune in an otherwise hidden list. |
| 343 | 350 | echo ' |
@@ -405,21 +412,23 @@ discard block |
||
| 405 | 412 | <ul>'; |
| 406 | 413 | |
| 407 | 414 | // Display a checkbox with every board. |
| 408 | - foreach ($category['boards'] as $board) |
|
| 409 | - echo ' |
|
| 415 | + foreach ($category['boards'] as $board) { |
|
| 416 | + echo ' |
|
| 410 | 417 | <li style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'] * 1.5, 'em;"> |
| 411 | 418 | <label for="boards_', $board['id'], '"><input type="checkbox" name="boards[', $board['id'], ']" id="boards_', $board['id'], '" checked>', $board['name'], '</label> |
| 412 | 419 | </li>'; |
| 420 | + } |
|
| 413 | 421 | |
| 414 | 422 | echo ' |
| 415 | 423 | </ul> |
| 416 | 424 | </fieldset>'; |
| 417 | 425 | |
| 418 | 426 | // Increase $i, and check if we're at the middle yet. |
| 419 | - if (++$i == $middle) |
|
| 420 | - echo ' |
|
| 427 | + if (++$i == $middle) { |
|
| 428 | + echo ' |
|
| 421 | 429 | </div><!-- .floatleft --> |
| 422 | 430 | <div class="floatright" style="width: 49%;">'; |
| 431 | + } |
|
| 423 | 432 | } |
| 424 | 433 | |
| 425 | 434 | echo ' |
@@ -461,9 +470,10 @@ discard block |
||
| 461 | 470 | echo ' |
| 462 | 471 | <optgroup label="', $category['name'], '">'; |
| 463 | 472 | |
| 464 | - foreach ($category['boards'] as $board) |
|
| 465 | - echo ' |
|
| 473 | + foreach ($category['boards'] as $board) { |
|
| 474 | + echo ' |
|
| 466 | 475 | <option value="', $board['id'], '"> ', str_repeat('==', $board['child_level']), '=> ', $board['name'], '</option>'; |
| 476 | + } |
|
| 467 | 477 | |
| 468 | 478 | echo ' |
| 469 | 479 | </optgroup>'; |
@@ -481,9 +491,10 @@ discard block |
||
| 481 | 491 | echo ' |
| 482 | 492 | <optgroup label="', $category['name'], '">'; |
| 483 | 493 | |
| 484 | - foreach ($category['boards'] as $board) |
|
| 485 | - echo ' |
|
| 494 | + foreach ($category['boards'] as $board) { |
|
| 495 | + echo ' |
|
| 486 | 496 | <option value="', $board['id'], '"> ', str_repeat('==', $board['child_level']), '=> ', $board['name'], '</option>'; |
| 497 | + } |
|
| 487 | 498 | |
| 488 | 499 | echo ' |
| 489 | 500 | </optgroup>'; |
@@ -526,9 +537,10 @@ discard block |
||
| 526 | 537 | ', $txt['database_optimize_attempt'], '<br>'; |
| 527 | 538 | |
| 528 | 539 | // List each table being optimized... |
| 529 | - foreach ($context['optimized_tables'] as $table) |
|
| 530 | - echo ' |
|
| 540 | + foreach ($context['optimized_tables'] as $table) { |
|
| 541 | + echo ' |
|
| 531 | 542 | ', sprintf($txt['database_optimizing'], $table['name'], $table['data_freed']), '<br>'; |
| 543 | + } |
|
| 532 | 544 | |
| 533 | 545 | // How did we go? |
| 534 | 546 | echo ' |
@@ -588,13 +600,14 @@ discard block |
||
| 588 | 600 | </li> |
| 589 | 601 | </ul>'; |
| 590 | 602 | |
| 591 | - if (!empty($context['exceeding_messages_morethan'])) |
|
| 592 | - echo ' |
|
| 603 | + if (!empty($context['exceeding_messages_morethan'])) { |
|
| 604 | + echo ' |
|
| 593 | 605 | <p>', $context['exceeding_messages_morethan'], '</p>'; |
| 594 | - } |
|
| 595 | - else |
|
| 596 | - echo ' |
|
| 606 | + } |
|
| 607 | + } else { |
|
| 608 | + echo ' |
|
| 597 | 609 | <p class="infobox">', $txt['convert_to_text'], '</p>'; |
| 610 | + } |
|
| 598 | 611 | |
| 599 | 612 | echo ' |
| 600 | 613 | <form action="', $scripturl, '?action=admin;area=maintain;sa=database;activity=convertmsgbody" method="post" accept-charset="', $context['character_set'], '"> |
@@ -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"> |
| 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"> |
| 284 | 297 | <h3 class="titlebg">', $txt['verification'], '</h3> |
| 285 | 298 | </div> |
@@ -288,19 +301,21 @@ discard block |
||
| 288 | 301 | ', template_control_verification($context['visual_verification_id'], 'all'), ' |
| 289 | 302 | </fieldset> |
| 290 | 303 | </div>'; |
| 304 | + } |
|
| 291 | 305 | |
| 292 | 306 | echo ' |
| 293 | 307 | <div id="confirm_buttons" class="flow_auto">'; |
| 294 | 308 | |
| 295 | 309 | // Age restriction in effect? |
| 296 | - if (!$context['require_agreement'] && $context['show_coppa']) |
|
| 297 | - echo ' |
|
| 310 | + if (!$context['require_agreement'] && $context['show_coppa']) { |
|
| 311 | + echo ' |
|
| 298 | 312 | <input type="submit" name="accept_agreement" value="', $context['coppa_agree_above'], '" class="button"><br> |
| 299 | 313 | <br> |
| 300 | 314 | <input type="submit" name="accept_agreement_coppa" value="', $context['coppa_agree_below'], '" class="button">'; |
| 301 | - else |
|
| 302 | - echo ' |
|
| 315 | + } else { |
|
| 316 | + echo ' |
|
| 303 | 317 | <input type="submit" name="regSubmit" value="', $txt['register'], '" tabindex="', $context['tabindex']++, '" class="button">'; |
| 318 | + } |
|
| 304 | 319 | |
| 305 | 320 | echo ' |
| 306 | 321 | </div> |
@@ -362,25 +377,28 @@ discard block |
||
| 362 | 377 | <p>', $context['coppa']['many_options'] ? $txt['coppa_send_to_two_options'] : $txt['coppa_send_to_one_option'], '</p>'; |
| 363 | 378 | |
| 364 | 379 | // Can they send by post? |
| 365 | - if (!empty($context['coppa']['post'])) |
|
| 366 | - echo ' |
|
| 380 | + if (!empty($context['coppa']['post'])) { |
|
| 381 | + echo ' |
|
| 367 | 382 | <h4>1) ', $txt['coppa_send_by_post'], '</h4> |
| 368 | 383 | <div class="coppa_contact"> |
| 369 | 384 | ', $context['coppa']['post'], ' |
| 370 | 385 | </div>'; |
| 386 | + } |
|
| 371 | 387 | |
| 372 | 388 | // Can they send by fax?? |
| 373 | - if (!empty($context['coppa']['fax'])) |
|
| 374 | - echo ' |
|
| 389 | + if (!empty($context['coppa']['fax'])) { |
|
| 390 | + echo ' |
|
| 375 | 391 | <h4>', !empty($context['coppa']['post']) ? '2' : '1', ') ', $txt['coppa_send_by_fax'], '</h4> |
| 376 | 392 | <div class="coppa_contact"> |
| 377 | 393 | ', $context['coppa']['fax'], ' |
| 378 | 394 | </div>'; |
| 395 | + } |
|
| 379 | 396 | |
| 380 | 397 | // Offer an alternative Phone Number? |
| 381 | - if ($context['coppa']['phone']) |
|
| 382 | - echo ' |
|
| 398 | + if ($context['coppa']['phone']) { |
|
| 399 | + echo ' |
|
| 383 | 400 | <p>', $context['coppa']['phone'], '</p>'; |
| 401 | + } |
|
| 384 | 402 | |
| 385 | 403 | echo ' |
| 386 | 404 | </div><!-- #coppa -->'; |
@@ -445,19 +463,20 @@ discard block |
||
| 445 | 463 | <body style="margin: 1ex;"> |
| 446 | 464 | <div class="windowbg description" style="text-align: center;">'; |
| 447 | 465 | |
| 448 | - if (isBrowser('is_ie') || isBrowser('is_ie11')) |
|
| 449 | - echo ' |
|
| 466 | + if (isBrowser('is_ie') || isBrowser('is_ie11')) { |
|
| 467 | + echo ' |
|
| 450 | 468 | <object classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" type="audio/x-wav"> |
| 451 | 469 | <param name="AutoStart" value="1"> |
| 452 | 470 | <param name="FileName" value="', $context['verification_sound_href'], '"> |
| 453 | 471 | </object>'; |
| 454 | - else |
|
| 455 | - echo ' |
|
| 472 | + } else { |
|
| 473 | + echo ' |
|
| 456 | 474 | <audio src="', $context['verification_sound_href'], '" controls> |
| 457 | 475 | <object type="audio/x-wav" data="', $context['verification_sound_href'], '"> |
| 458 | 476 | <a href="', $context['verification_sound_href'], '" rel="nofollow">', $context['verification_sound_href'], '</a> |
| 459 | 477 | </object> |
| 460 | 478 | </audio>'; |
| 479 | + } |
|
| 461 | 480 | |
| 462 | 481 | echo ' |
| 463 | 482 | <br> |
@@ -485,11 +504,12 @@ discard block |
||
| 485 | 504 | </div> |
| 486 | 505 | <div id="register_screen" class="windowbg">'; |
| 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,18 +604,19 @@ 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 | // Warning for if the file isn't writable. |
| 594 | - if (!empty($context['warning'])) |
|
| 595 | - echo ' |
|
| 616 | + if (!empty($context['warning'])) { |
|
| 617 | + echo ' |
|
| 596 | 618 | <div class="errorbox">', $context['warning'], '</div>'; |
| 619 | + } |
|
| 597 | 620 | |
| 598 | 621 | // Just a big box to edit the text file ;) |
| 599 | 622 | echo ' |
@@ -615,9 +638,10 @@ discard block |
||
| 615 | 638 | <strong>', $txt['admin_agreement_select_language'], ':</strong> |
| 616 | 639 | <select name="agree_lang" onchange="document.getElementById(\'change_reg\').submit();" tabindex="', $context['tabindex']++, '">'; |
| 617 | 640 | |
| 618 | - foreach ($context['editable_agreements'] as $file => $name) |
|
| 619 | - echo ' |
|
| 641 | + foreach ($context['editable_agreements'] as $file => $name) { |
|
| 642 | + echo ' |
|
| 620 | 643 | <option value="', $file, '"', $context['current_agreement'] == $file ? ' selected' : '', '>', $name, '</option>'; |
| 644 | + } |
|
| 621 | 645 | |
| 622 | 646 | echo ' |
| 623 | 647 | </select> |
@@ -657,9 +681,10 @@ discard block |
||
| 657 | 681 | { |
| 658 | 682 | global $context, $scripturl, $txt; |
| 659 | 683 | |
| 660 | - if (!empty($context['saved_successful'])) |
|
| 661 | - echo ' |
|
| 684 | + if (!empty($context['saved_successful'])) { |
|
| 685 | + echo ' |
|
| 662 | 686 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
| 687 | + } |
|
| 663 | 688 | |
| 664 | 689 | echo ' |
| 665 | 690 | <form id="admin_form_wrapper" action="', $scripturl, '?action=admin;area=regcenter" method="post" accept-charset="', $context['character_set'], '"> |
@@ -29,9 +29,10 @@ discard block |
||
| 29 | 29 | <strong>', $txt['ban_errors_detected'], '</strong> |
| 30 | 30 | <ul>'; |
| 31 | 31 | |
| 32 | - foreach ($context['error_messages'] as $error) |
|
| 33 | - echo ' |
|
| 32 | + foreach ($context['error_messages'] as $error) { |
|
| 33 | + echo ' |
|
| 34 | 34 | <li class="error">', $error, '</li>'; |
| 35 | + } |
|
| 35 | 36 | |
| 36 | 37 | echo ' |
| 37 | 38 | </ul> |
@@ -45,9 +46,10 @@ discard block |
||
| 45 | 46 | </h3> |
| 46 | 47 | </div>'; |
| 47 | 48 | |
| 48 | - if ($context['ban']['is_new']) |
|
| 49 | - echo ' |
|
| 49 | + if ($context['ban']['is_new']) { |
|
| 50 | + echo ' |
|
| 50 | 51 | <div class="information noup">', $txt['ban_add_notes'], '</div>'; |
| 52 | + } |
|
| 51 | 53 | |
| 52 | 54 | echo ' |
| 53 | 55 | <div class="windowbg noup"> |
@@ -59,8 +61,8 @@ discard block |
||
| 59 | 61 | <input type="text" id="ban_name" name="ban_name" value="', $context['ban']['name'], '" size="45" maxlength="60"> |
| 60 | 62 | </dd>'; |
| 61 | 63 | |
| 62 | - if (isset($context['ban']['reason'])) |
|
| 63 | - echo ' |
|
| 64 | + if (isset($context['ban']['reason'])) { |
|
| 65 | + echo ' |
|
| 64 | 66 | <dt> |
| 65 | 67 | <strong><label for="reason">', $txt['ban_reason'], ':</label></strong><br> |
| 66 | 68 | <span class="smalltext">', $txt['ban_reason_desc'], '</span> |
@@ -68,9 +70,10 @@ discard block |
||
| 68 | 70 | <dd> |
| 69 | 71 | <textarea name="reason" id="reason" cols="40" rows="3">', $context['ban']['reason'], '</textarea> |
| 70 | 72 | </dd>'; |
| 73 | + } |
|
| 71 | 74 | |
| 72 | - if (isset($context['ban']['notes'])) |
|
| 73 | - echo ' |
|
| 75 | + if (isset($context['ban']['notes'])) { |
|
| 76 | + echo ' |
|
| 74 | 77 | <dt> |
| 75 | 78 | <strong><label for="ban_notes">', $txt['ban_notes'], ':</label></strong><br> |
| 76 | 79 | <span class="smalltext">', $txt['ban_notes_desc'], '</span> |
@@ -78,6 +81,7 @@ discard block |
||
| 78 | 81 | <dd> |
| 79 | 82 | <textarea name="notes" id="ban_notes" cols="40" rows="3">', $context['ban']['notes'], '</textarea> |
| 80 | 83 | </dd>'; |
| 84 | + } |
|
| 81 | 85 | |
| 82 | 86 | echo ' |
| 83 | 87 | </dl> |
@@ -117,8 +121,8 @@ discard block |
||
| 117 | 121 | <input type="text" name="main_ip" value="', $context['ban_suggestions']['main_ip'], '" size="44" onfocus="document.getElementById(\'main_ip_check\').checked = true;"> |
| 118 | 122 | </dd>'; |
| 119 | 123 | |
| 120 | - if (empty($modSettings['disableHostnameLookup'])) |
|
| 121 | - echo ' |
|
| 124 | + if (empty($modSettings['disableHostnameLookup'])) { |
|
| 125 | + echo ' |
|
| 122 | 126 | <dt> |
| 123 | 127 | <input type="checkbox" name="ban_suggestions[]" id="hostname_check" value="hostname"', !empty($context['ban_suggestions']['hostname']) ? ' checked' : '', '> |
| 124 | 128 | <label for="hostname_check">', $txt['ban_on_hostname'], '</label> |
@@ -126,6 +130,7 @@ discard block |
||
| 126 | 130 | <dd> |
| 127 | 131 | <input type="text" name="hostname" value="', $context['ban_suggestions']['hostname'], '" size="44" onfocus="document.getElementById(\'hostname_check\').checked = true;"> |
| 128 | 132 | </dd>'; |
| 133 | + } |
|
| 129 | 134 | |
| 130 | 135 | echo ' |
| 131 | 136 | <dt> |
@@ -155,14 +160,15 @@ discard block |
||
| 155 | 160 | <dl class="settings">'; |
| 156 | 161 | |
| 157 | 162 | $count = 0; |
| 158 | - foreach ($ban_ips as $ip) |
|
| 159 | - echo ' |
|
| 163 | + foreach ($ban_ips as $ip) { |
|
| 164 | + echo ' |
|
| 160 | 165 | <dt> |
| 161 | 166 | <input type="checkbox" id="suggestions_', $key, '_', $count, '" name="ban_suggestions[', $key, '][]"', !empty($context['ban_suggestions']['saved_triggers'][$key]) && in_array($ip, $context['ban_suggestions']['saved_triggers'][$key]) ? ' checked' : '', ' value="', $ip, '"> |
| 162 | 167 | </dt> |
| 163 | 168 | <dd> |
| 164 | 169 | <label for="suggestions_', $key, '_', $count++, '">', $ip, '</label> |
| 165 | 170 | </dd>'; |
| 171 | + } |
|
| 166 | 172 | |
| 167 | 173 | echo ' |
| 168 | 174 | </dl>'; |
@@ -204,8 +210,8 @@ discard block |
||
| 204 | 210 | addLoadEvent(fUpdateStatus);'; |
| 205 | 211 | |
| 206 | 212 | // Auto suggest only needed for adding new bans, not editing |
| 207 | - if ($context['ban']['is_new'] && empty($_REQUEST['u'])) |
|
| 208 | - echo ' |
|
| 213 | + if ($context['ban']['is_new'] && empty($_REQUEST['u'])) { |
|
| 214 | + echo ' |
|
| 209 | 215 | var oAddMemberSuggest = new smc_AutoSuggest({ |
| 210 | 216 | sSelf: \'oAddMemberSuggest\', |
| 211 | 217 | sSessionId: smf_session_id, |
@@ -223,6 +229,7 @@ discard block |
||
| 223 | 229 | return true; |
| 224 | 230 | } |
| 225 | 231 | oAddMemberSuggest.registerCallback(\'onBeforeUpdate\', \'onUpdateName\');'; |
| 232 | + } |
|
| 226 | 233 | |
| 227 | 234 | echo ' |
| 228 | 235 | function confirmBan(aForm) |
@@ -271,8 +278,8 @@ discard block |
||
| 271 | 278 | <input type="text" name="main_ip" value="', $context['ban_trigger']['ip']['value'], '" size="44" onfocus="document.getElementById(\'main_ip_check\').checked = true;"> |
| 272 | 279 | </dd>'; |
| 273 | 280 | |
| 274 | - if (empty($modSettings['disableHostnameLookup'])) |
|
| 275 | - echo ' |
|
| 281 | + if (empty($modSettings['disableHostnameLookup'])) { |
|
| 282 | + echo ' |
|
| 276 | 283 | <dt> |
| 277 | 284 | <input type="checkbox" name="ban_suggestions[]" id="hostname_check" value="hostname"', $context['ban_trigger']['hostname']['selected'] ? ' checked' : '', '> |
| 278 | 285 | <label for="hostname_check">', $txt['ban_on_hostname'], '</label> |
@@ -280,6 +287,7 @@ discard block |
||
| 280 | 287 | <dd> |
| 281 | 288 | <input type="text" name="hostname" value="', $context['ban_trigger']['hostname']['value'], '" size="44" onfocus="document.getElementById(\'hostname_check\').checked = true;"> |
| 282 | 289 | </dd>'; |
| 290 | + } |
|
| 283 | 291 | |
| 284 | 292 | echo ' |
| 285 | 293 | <dt> |