@@ -36,10 +36,12 @@ |
||
| 36 | 36 | <ul>'; |
| 37 | 37 | |
| 38 | 38 | foreach ($context['groups'] as $group) |
| 39 | - echo ' |
|
| 39 | + { |
|
| 40 | + echo ' |
|
| 40 | 41 | <li> |
| 41 | 42 | <label for="who_', $group['id'], '"><input type="checkbox" name="who[', $group['id'], ']" id="who_', $group['id'], '" value="', $group['id'], '" checked="checked" /> ', $group['name'], '</label> <em>(', $group['member_count'], ')</em> |
| 42 | 43 | </li>'; |
| 44 | + } |
|
| 43 | 45 | |
| 44 | 46 | echo ' |
| 45 | 47 | <li> |
@@ -275,8 +275,10 @@ discard block |
||
| 275 | 275 | </div>'; |
| 276 | 276 | |
| 277 | 277 | foreach ($context['recipients'] as $key => $values) |
| 278 | - echo ' |
|
| 278 | + { |
|
| 279 | + echo ' |
|
| 279 | 280 | <input type="hidden" name="', $key, '" value="', implode(($key == 'emails' ? ';' : ','), $values), '" />'; |
| 281 | + } |
|
| 280 | 282 | |
| 281 | 283 | // The vars used to preview a newsletter without loading a new page, used by post.js previewControl() |
| 282 | 284 | addInlineJavascript(' |
@@ -338,8 +340,10 @@ discard block |
||
| 338 | 340 | |
| 339 | 341 | // All the things we must remember! |
| 340 | 342 | foreach ($context['recipients'] as $key => $values) |
| 341 | - echo ' |
|
| 343 | + { |
|
| 344 | + echo ' |
|
| 342 | 345 | <input type="hidden" name="', $key, '" value="', implode(($key == 'emails' ? ';' : ','), $values), '" />'; |
| 346 | + } |
|
| 343 | 347 | |
| 344 | 348 | echo ' |
| 345 | 349 | </div> |
@@ -79,8 +79,10 @@ discard block |
||
| 79 | 79 | <select name="targetboard" onchange="this.form.submit();">'; |
| 80 | 80 | |
| 81 | 81 | foreach ($context['boards'] as $board) |
| 82 | - echo ' |
|
| 82 | + { |
|
| 83 | + echo ' |
|
| 83 | 84 | <option value="', $board['id'], '"', $board['id'] == $context['target_board'] ? ' selected="selected"' : '', '>', $board['category'], ' - ', $board['name'], '</option>'; |
| 85 | + } |
|
| 84 | 86 | |
| 85 | 87 | echo ' |
| 86 | 88 | </select> |
@@ -115,13 +117,15 @@ discard block |
||
| 115 | 117 | <ul class="merge_topics">'; |
| 116 | 118 | |
| 117 | 119 | foreach ($context['topics'] as $topic) |
| 118 | - echo ' |
|
| 120 | + { |
|
| 121 | + echo ' |
|
| 119 | 122 | <li> |
| 120 | 123 | <a class="linkbutton" href="', $scripturl, '?action=mergetopics;sa=options;board=', $context['current_board'], '.0;from=', $context['origin_topic'], ';to=', $topic['id'], ';', $context['session_var'], '=', $context['session_id'], '"> |
| 121 | 124 | <img class="centericon" src="', $settings['images_url'], '/buttons/merge.png" alt="', $txt['merge'], '" /> |
| 122 | 125 | </a> |
| 123 | 126 | <a href="', $scripturl, '?topic=', $topic['id'], '.0" target="_blank" class="new_win">', $topic['subject'], '</a> ', sprintf($txt['topic_started_by'], $topic['poster']['link']), ' |
| 124 | 127 | </li>'; |
| 128 | + } |
|
| 125 | 129 | |
| 126 | 130 | echo ' |
| 127 | 131 | </ul> |
@@ -153,7 +157,8 @@ discard block |
||
| 153 | 157 | <tbody>'; |
| 154 | 158 | |
| 155 | 159 | foreach ($context['topics'] as $topic) |
| 156 | - echo ' |
|
| 160 | + { |
|
| 161 | + echo ' |
|
| 157 | 162 | <tr> |
| 158 | 163 | <td class="centertext"> |
| 159 | 164 | <input type="checkbox" name="topics[]" value="', $topic['id'], '" checked="checked" /> |
@@ -173,6 +178,7 @@ discard block |
||
| 173 | 178 | <input type="checkbox" name="notifications[]" value="' . $topic['id'] . '" checked="checked" /> |
| 174 | 179 | </td> |
| 175 | 180 | </tr>'; |
| 181 | + } |
|
| 176 | 182 | |
| 177 | 183 | echo ' |
| 178 | 184 | </tbody> |
@@ -185,8 +191,10 @@ discard block |
||
| 185 | 191 | <select name="subject" onchange="this.form.custom_subject.style.display = (this.options[this.selectedIndex].value != 0) ? \'none\': \'block\' ;">'; |
| 186 | 192 | |
| 187 | 193 | foreach ($context['topics'] as $topic) |
| 188 | - echo ' |
|
| 194 | + { |
|
| 195 | + echo ' |
|
| 189 | 196 | <option value="', $topic['id'], '"' . ($topic['selected'] ? ' selected="selected"' : '') . '>', $topic['subject'], '</option>'; |
| 197 | + } |
|
| 190 | 198 | |
| 191 | 199 | echo ' |
| 192 | 200 | <option value="0">', $txt['merge_custom_subject'], ':</option> |
@@ -218,10 +226,12 @@ discard block |
||
| 218 | 226 | <ul>'; |
| 219 | 227 | |
| 220 | 228 | foreach ($context['polls'] as $poll) |
| 221 | - echo ' |
|
| 229 | + { |
|
| 230 | + echo ' |
|
| 222 | 231 | <li> |
| 223 | 232 | <input type="radio" id="poll', $poll['id'], '" name="poll" value="', $poll['id'], '"', $poll['selected'] ? ' checked="checked"' : '', ' /> <label for="poll', $poll['id'], '">', $poll['question'], '</label> (', $txt['topic'], ': <a href="', $scripturl, '?topic=', $poll['topic']['id'], '.0" target="_blank" class="new_win">', $poll['topic']['subject'], '</a>) |
| 224 | 233 | </li>'; |
| 234 | + } |
|
| 225 | 235 | |
| 226 | 236 | echo ' |
| 227 | 237 | <li> |
@@ -130,7 +130,8 @@ discard block |
||
| 130 | 130 | |
| 131 | 131 | // Loop through all the shiny features. |
| 132 | 132 | foreach ($context['features'] as $id => $feature) |
| 133 | - echo ' |
|
| 133 | + { |
|
| 134 | + echo ' |
|
| 134 | 135 | <div class="features"> |
| 135 | 136 | <img class="features_image" src="', $feature['image'], '" alt="', $feature['title'], '" /> |
| 136 | 137 | <div class="features_switch" id="js_feature_', $id, '"> |
@@ -141,6 +142,7 @@ discard block |
||
| 141 | 142 | <p>', $feature['desc'], '</p> |
| 142 | 143 | <hr /> |
| 143 | 144 | </div>'; |
| 145 | + } |
|
| 144 | 146 | |
| 145 | 147 | echo ' |
| 146 | 148 | <div class="righttext"> |
@@ -168,7 +168,8 @@ discard block |
||
| 168 | 168 | <tbody>'; |
| 169 | 169 | |
| 170 | 170 | foreach ($context['membergroups'] as $membergroup) |
| 171 | - echo ' |
|
| 171 | + { |
|
| 172 | + echo ' |
|
| 172 | 173 | <tr> |
| 173 | 174 | <td>', $membergroup['name'], '</td> |
| 174 | 175 | <td class="centertext"> |
@@ -178,6 +179,7 @@ discard block |
||
| 178 | 179 | ', $membergroup['can_be_additional'] ? '<input type="checkbox" name="membergroups[2][]" value="' . $membergroup['id'] . '" checked="checked" />' : '', ' |
| 179 | 180 | </td> |
| 180 | 181 | </tr>'; |
| 182 | + } |
|
| 181 | 183 | |
| 182 | 184 | echo ' |
| 183 | 185 | <tr> |
@@ -206,7 +208,8 @@ discard block |
||
| 206 | 208 | <tbody>'; |
| 207 | 209 | |
| 208 | 210 | foreach ($context['postgroups'] as $postgroup) |
| 209 | - echo ' |
|
| 211 | + { |
|
| 212 | + echo ' |
|
| 210 | 213 | <tr> |
| 211 | 214 | <td> |
| 212 | 215 | ', $postgroup['name'], ' |
@@ -215,6 +218,7 @@ discard block |
||
| 215 | 218 | <input type="checkbox" name="postgroups[]" value="', $postgroup['id'], '" checked="checked" /> |
| 216 | 219 | </td> |
| 217 | 220 | </tr>'; |
| 221 | + } |
|
| 218 | 222 | |
| 219 | 223 | echo ' |
| 220 | 224 | <tr> |
@@ -59,8 +59,10 @@ |
||
| 59 | 59 | <ul>'; |
| 60 | 60 | |
| 61 | 61 | foreach ($context['manual_sections'] as $section_id => $wiki_id) |
| 62 | - echo ' |
|
| 62 | + { |
|
| 63 | + echo ' |
|
| 63 | 64 | <li><a href="', $context['wiki_url'], '/', $wiki_id, ($txt['lang_dictionary'] != 'en' && $txt['lang_dictionary'] != 'english' ? '/' . $txt['lang_dictionary'] : ''), '" target="_blank" class="new_win">', $txt['manual_section_' . $section_id . '_title'], '</a> - ', $txt['manual_section_' . $section_id . '_desc'], '</li>'; |
| 65 | + } |
|
| 64 | 66 | |
| 65 | 67 | echo ' |
| 66 | 68 | </ul> |
@@ -59,7 +59,9 @@ |
||
| 59 | 59 | 'can_remove_poll' => 'poll_remove', |
| 60 | 60 | ); |
| 61 | 61 | foreach ($anyown_permissions as $contextual => $perm) |
| 62 | - $context[$contextual] = allowedTo($perm . '_any') || ($context['user']['started'] && allowedTo($perm . '_own')); |
|
| 62 | + { |
|
| 63 | + $context[$contextual] = allowedTo($perm . '_any') || ($context['user']['started'] && allowedTo($perm . '_own')); |
|
| 64 | + } |
|
| 63 | 65 | |
| 64 | 66 | $context['can_add_poll'] &= self::$_enabled && $topicinfo['id_poll'] <= 0; |
| 65 | 67 | $context['can_remove_poll'] &= self::$_enabled && $topicinfo['id_poll'] > 0; |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | LEFT JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic) |
| 110 | 110 | WHERE t.id_topic IS NULL |
| 111 | 111 | GROUP BY m.id_topic, m.id_board', |
| 112 | - 'fix_processing' => function ($row) { |
|
| 112 | + 'fix_processing' => function($row) { |
|
| 113 | 113 | global $salvageBoardID; |
| 114 | 114 | |
| 115 | 115 | $db = database(); |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | // Remove all topics that have zero messages in the messages table. |
| 198 | 198 | 'fix_collect' => array( |
| 199 | 199 | 'index' => 'id_topic', |
| 200 | - 'process' => function ($topics) { |
|
| 200 | + 'process' => function($topics) { |
|
| 201 | 201 | $db = database(); |
| 202 | 202 | |
| 203 | 203 | $db->query('', ' |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | LEFT JOIN {db_prefix}topics AS t ON (t.id_poll = p.id_poll) |
| 232 | 232 | WHERE p.id_poll BETWEEN {STEP_LOW} AND {STEP_HIGH} |
| 233 | 233 | AND t.id_poll IS NULL', |
| 234 | - 'fix_processing' => function ($row) { |
|
| 234 | + 'fix_processing' => function($row) { |
|
| 235 | 235 | global $salvageBoardID, $txt; |
| 236 | 236 | |
| 237 | 237 | $db = database(); |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | WHERE t.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH} |
| 347 | 347 | GROUP BY t.id_topic, t.id_first_msg, t.id_last_msg, t.approved, mf.approved |
| 348 | 348 | ORDER BY t.id_topic', |
| 349 | - 'fix_processing' => function ($row) { |
|
| 349 | + 'fix_processing' => function($row) { |
|
| 350 | 350 | $row['firstmsg_approved'] = (int) $row['firstmsg_approved']; |
| 351 | 351 | $row['myid_first_msg'] = (int) $row['myid_first_msg']; |
| 352 | 352 | $row['myid_last_msg'] = (int) $row['myid_last_msg']; |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | 'approved' => $row['firstmsg_approved'], |
| 367 | 367 | )); |
| 368 | 368 | }, |
| 369 | - 'message_function' => function ($row) { |
|
| 369 | + 'message_function' => function($row) { |
|
| 370 | 370 | global $txt, $context; |
| 371 | 371 | |
| 372 | 372 | // A pretend error? |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | WHERE t.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH} |
| 402 | 402 | GROUP BY t.id_topic, t.num_replies, mf.approved |
| 403 | 403 | ORDER BY t.id_topic', |
| 404 | - 'fix_processing' => function ($row) { |
|
| 404 | + 'fix_processing' => function($row) { |
|
| 405 | 405 | $row['my_num_replies'] = (int) $row['my_num_replies']; |
| 406 | 406 | |
| 407 | 407 | // Not really a problem? |
@@ -412,7 +412,7 @@ discard block |
||
| 412 | 412 | 'num_replies' => $row['my_num_replies'], |
| 413 | 413 | )); |
| 414 | 414 | }, |
| 415 | - 'message_function' => function ($row) { |
|
| 415 | + 'message_function' => function($row) { |
|
| 416 | 416 | global $txt, $context; |
| 417 | 417 | |
| 418 | 418 | // Just joking? |
@@ -442,7 +442,7 @@ discard block |
||
| 442 | 442 | GROUP BY t.id_topic, t.unapproved_posts |
| 443 | 443 | HAVING unapproved_posts != COUNT(mu.id_msg) |
| 444 | 444 | ORDER BY t.id_topic', |
| 445 | - 'fix_processing' => function ($row) { |
|
| 445 | + 'fix_processing' => function($row) { |
|
| 446 | 446 | $row['my_unapproved_posts'] = (int) $row['my_unapproved_posts']; |
| 447 | 447 | |
| 448 | 448 | setTopicAttribute($row['id_topic'], array( |
@@ -474,7 +474,7 @@ discard block |
||
| 474 | 474 | WHERE b.id_board IS NULL |
| 475 | 475 | AND t.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH} |
| 476 | 476 | GROUP BY t.id_board', |
| 477 | - 'fix_processing' => function ($row) { |
|
| 477 | + 'fix_processing' => function($row) { |
|
| 478 | 478 | global $salvageCatID, $txt; |
| 479 | 479 | |
| 480 | 480 | $db = database(); |
@@ -522,7 +522,7 @@ discard block |
||
| 522 | 522 | ORDER BY b.id_cat, b.id_board', |
| 523 | 523 | 'fix_collect' => array( |
| 524 | 524 | 'index' => 'id_cat', |
| 525 | - 'process' => function ($cats) { |
|
| 525 | + 'process' => function($cats) { |
|
| 526 | 526 | global $salvageCatID; |
| 527 | 527 | |
| 528 | 528 | $db = database(); |
@@ -559,7 +559,7 @@ discard block |
||
| 559 | 559 | // Last step-make sure all non-guest posters still exist. |
| 560 | 560 | 'fix_collect' => array( |
| 561 | 561 | 'index' => 'id_msg', |
| 562 | - 'process' => function ($msgs) { |
|
| 562 | + 'process' => function($msgs) { |
|
| 563 | 563 | $db = database(); |
| 564 | 564 | |
| 565 | 565 | $db->query('', ' |
@@ -586,7 +586,7 @@ discard block |
||
| 586 | 586 | ORDER BY b.id_parent, b.id_board', |
| 587 | 587 | 'fix_collect' => array( |
| 588 | 588 | 'index' => 'id_parent', |
| 589 | - 'process' => function ($parents) { |
|
| 589 | + 'process' => function($parents) { |
|
| 590 | 590 | global $salvageBoardID, $salvageCatID; |
| 591 | 591 | |
| 592 | 592 | $db = database(); |
@@ -621,7 +621,7 @@ discard block |
||
| 621 | 621 | AND p.id_poll IS NULL', |
| 622 | 622 | 'fix_collect' => array( |
| 623 | 623 | 'index' => 'id_poll', |
| 624 | - 'process' => function ($polls) { |
|
| 624 | + 'process' => function($polls) { |
|
| 625 | 625 | $db = database(); |
| 626 | 626 | |
| 627 | 627 | $db->query('', ' |
@@ -653,7 +653,7 @@ discard block |
||
| 653 | 653 | ORDER BY cal.id_topic', |
| 654 | 654 | 'fix_collect' => array( |
| 655 | 655 | 'index' => 'id_topic', |
| 656 | - 'process' => function ($events) { |
|
| 656 | + 'process' => function($events) { |
|
| 657 | 657 | $db = database(); |
| 658 | 658 | |
| 659 | 659 | $db->query('', ' |
@@ -683,7 +683,7 @@ discard block |
||
| 683 | 683 | AND lt.id_member BETWEEN {STEP_LOW} AND {STEP_HIGH}', |
| 684 | 684 | 'fix_collect' => array( |
| 685 | 685 | 'index' => 'id_topic', |
| 686 | - 'process' => function ($topics) { |
|
| 686 | + 'process' => function($topics) { |
|
| 687 | 687 | $db = database(); |
| 688 | 688 | |
| 689 | 689 | $db->query('', ' |
@@ -713,7 +713,7 @@ discard block |
||
| 713 | 713 | GROUP BY lt.id_member', |
| 714 | 714 | 'fix_collect' => array( |
| 715 | 715 | 'index' => 'id_member', |
| 716 | - 'process' => function ($members) { |
|
| 716 | + 'process' => function($members) { |
|
| 717 | 717 | $db = database(); |
| 718 | 718 | |
| 719 | 719 | $db->query('', ' |
@@ -743,7 +743,7 @@ discard block |
||
| 743 | 743 | GROUP BY lb.id_board', |
| 744 | 744 | 'fix_collect' => array( |
| 745 | 745 | 'index' => 'id_board', |
| 746 | - 'process' => function ($boards) { |
|
| 746 | + 'process' => function($boards) { |
|
| 747 | 747 | $db = database(); |
| 748 | 748 | |
| 749 | 749 | $db->query('', ' |
@@ -773,7 +773,7 @@ discard block |
||
| 773 | 773 | GROUP BY lb.id_member', |
| 774 | 774 | 'fix_collect' => array( |
| 775 | 775 | 'index' => 'id_member', |
| 776 | - 'process' => function ($members) { |
|
| 776 | + 'process' => function($members) { |
|
| 777 | 777 | $db = database(); |
| 778 | 778 | |
| 779 | 779 | $db->query('', ' |
@@ -803,7 +803,7 @@ discard block |
||
| 803 | 803 | GROUP BY lmr.id_board', |
| 804 | 804 | 'fix_collect' => array( |
| 805 | 805 | 'index' => 'id_board', |
| 806 | - 'process' => function ($boards) { |
|
| 806 | + 'process' => function($boards) { |
|
| 807 | 807 | $db = database(); |
| 808 | 808 | |
| 809 | 809 | $db->query('', ' |
@@ -833,7 +833,7 @@ discard block |
||
| 833 | 833 | GROUP BY lmr.id_member', |
| 834 | 834 | 'fix_collect' => array( |
| 835 | 835 | 'index' => 'id_member', |
| 836 | - 'process' => function ($members) { |
|
| 836 | + 'process' => function($members) { |
|
| 837 | 837 | $db = database(); |
| 838 | 838 | |
| 839 | 839 | $db->query('', ' |
@@ -863,7 +863,7 @@ discard block |
||
| 863 | 863 | GROUP BY pmr.id_pm', |
| 864 | 864 | 'fix_collect' => array( |
| 865 | 865 | 'index' => 'id_pm', |
| 866 | - 'process' => function ($pms) { |
|
| 866 | + 'process' => function($pms) { |
|
| 867 | 867 | $db = database(); |
| 868 | 868 | |
| 869 | 869 | $db->query('', ' |
@@ -894,7 +894,7 @@ discard block |
||
| 894 | 894 | GROUP BY pmr.id_member', |
| 895 | 895 | 'fix_collect' => array( |
| 896 | 896 | 'index' => 'id_member', |
| 897 | - 'process' => function ($members) { |
|
| 897 | + 'process' => function($members) { |
|
| 898 | 898 | $db = database(); |
| 899 | 899 | |
| 900 | 900 | $db->query('', ' |
@@ -924,7 +924,7 @@ discard block |
||
| 924 | 924 | AND mem.id_member IS NULL', |
| 925 | 925 | 'fix_collect' => array( |
| 926 | 926 | 'index' => 'id_pm', |
| 927 | - 'process' => function ($guestMessages) { |
|
| 927 | + 'process' => function($guestMessages) { |
|
| 928 | 928 | $db = database(); |
| 929 | 929 | |
| 930 | 930 | $db->query('', ' |
@@ -954,7 +954,7 @@ discard block |
||
| 954 | 954 | GROUP BY ln.id_member', |
| 955 | 955 | 'fix_collect' => array( |
| 956 | 956 | 'index' => 'id_member', |
| 957 | - 'process' => function ($members) { |
|
| 957 | + 'process' => function($members) { |
|
| 958 | 958 | $db = database(); |
| 959 | 959 | |
| 960 | 960 | $db->query('', ' |
@@ -982,7 +982,7 @@ discard block |
||
| 982 | 982 | LEFT JOIN {db_prefix}log_search_subjects AS lss ON (lss.id_topic = t.id_topic) |
| 983 | 983 | WHERE t.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH} |
| 984 | 984 | AND lss.id_topic IS NULL', |
| 985 | - 'fix_full_processing' => function ($result) { |
|
| 985 | + 'fix_full_processing' => function($result) { |
|
| 986 | 986 | |
| 987 | 987 | $db = database(); |
| 988 | 988 | |
@@ -1012,7 +1012,7 @@ discard block |
||
| 1012 | 1012 | array('word', 'id_topic') |
| 1013 | 1013 | ); |
| 1014 | 1014 | }, |
| 1015 | - 'message_function' => function ($row) { |
|
| 1015 | + 'message_function' => function($row) { |
|
| 1016 | 1016 | global $txt, $context; |
| 1017 | 1017 | |
| 1018 | 1018 | if (count(text2words($row['subject'])) != 0) |
@@ -1039,7 +1039,7 @@ discard block |
||
| 1039 | 1039 | AND t.id_topic IS NULL', |
| 1040 | 1040 | 'fix_collect' => array( |
| 1041 | 1041 | 'index' => 'id_topic', |
| 1042 | - 'process' => function ($deleteTopics) { |
|
| 1042 | + 'process' => function($deleteTopics) { |
|
| 1043 | 1043 | $db = database(); |
| 1044 | 1044 | |
| 1045 | 1045 | $db->query('', ' |
@@ -1069,7 +1069,7 @@ discard block |
||
| 1069 | 1069 | AND mem.id_member IS NULL', |
| 1070 | 1070 | 'fix_collect' => array( |
| 1071 | 1071 | 'index' => 'id_member', |
| 1072 | - 'process' => function ($members) { |
|
| 1072 | + 'process' => function($members) { |
|
| 1073 | 1073 | $db = database(); |
| 1074 | 1074 | |
| 1075 | 1075 | $db->query('', ' |
@@ -1098,7 +1098,7 @@ discard block |
||
| 1098 | 1098 | AND p.id_poll IS NULL', |
| 1099 | 1099 | 'fix_collect' => array( |
| 1100 | 1100 | 'index' => 'id_poll', |
| 1101 | - 'process' => function ($polls) { |
|
| 1101 | + 'process' => function($polls) { |
|
| 1102 | 1102 | $db = database(); |
| 1103 | 1103 | |
| 1104 | 1104 | $db->query('', ' |
@@ -1127,7 +1127,7 @@ discard block |
||
| 1127 | 1127 | AND lrc.id_report IS NULL', |
| 1128 | 1128 | 'fix_collect' => array( |
| 1129 | 1129 | 'index' => 'id_report', |
| 1130 | - 'process' => function ($reports) { |
|
| 1130 | + 'process' => function($reports) { |
|
| 1131 | 1131 | $db = database(); |
| 1132 | 1132 | |
| 1133 | 1133 | $db->query('', ' |
@@ -1156,7 +1156,7 @@ discard block |
||
| 1156 | 1156 | AND lr.id_report IS NULL', |
| 1157 | 1157 | 'fix_collect' => array( |
| 1158 | 1158 | 'index' => 'id_report', |
| 1159 | - 'process' => function ($reports) { |
|
| 1159 | + 'process' => function($reports) { |
|
| 1160 | 1160 | $db = database(); |
| 1161 | 1161 | |
| 1162 | 1162 | $db->query('', ' |
@@ -1186,7 +1186,7 @@ discard block |
||
| 1186 | 1186 | GROUP BY lgr.id_member', |
| 1187 | 1187 | 'fix_collect' => array( |
| 1188 | 1188 | 'index' => 'id_member', |
| 1189 | - 'process' => function ($members) { |
|
| 1189 | + 'process' => function($members) { |
|
| 1190 | 1190 | $db = database(); |
| 1191 | 1191 | |
| 1192 | 1192 | $db->query('', ' |
@@ -1216,7 +1216,7 @@ discard block |
||
| 1216 | 1216 | GROUP BY lgr.id_group', |
| 1217 | 1217 | 'fix_collect' => array( |
| 1218 | 1218 | 'index' => 'id_group', |
| 1219 | - 'process' => function ($groups) { |
|
| 1219 | + 'process' => function($groups) { |
|
| 1220 | 1220 | $db = database(); |
| 1221 | 1221 | |
| 1222 | 1222 | $db->query('', ' |
@@ -348,7 +348,9 @@ discard block |
||
| 348 | 348 | |
| 349 | 349 | // Not really a problem? |
| 350 | 350 | if ($row['id_first_msg'] == $row['myid_first_msg'] && $row['id_last_msg'] == $row['myid_last_msg'] && $row['approved'] == $row['firstmsg_approved']) |
| 351 | - return false; |
|
| 351 | + { |
|
| 352 | + return false; |
|
| 353 | + } |
|
| 352 | 354 | |
| 353 | 355 | $memberStartedID = getMsgMemberID($row['myid_first_msg']); |
| 354 | 356 | $memberUpdatedID = getMsgMemberID($row['myid_last_msg']); |
@@ -367,13 +369,21 @@ discard block |
||
| 367 | 369 | |
| 368 | 370 | // A pretend error? |
| 369 | 371 | if ($row['id_first_msg'] == $row['myid_first_msg'] && $row['id_last_msg'] == $row['myid_last_msg'] && $row['approved'] == $row['firstmsg_approved']) |
| 370 | - return false; |
|
| 372 | + { |
|
| 373 | + return false; |
|
| 374 | + } |
|
| 371 | 375 | if ($row['id_first_msg'] != $row['myid_first_msg']) |
| 372 | - $context['repair_errors'][] = sprintf($txt['repair_stats_topics_1'], $row['id_topic'], $row['id_first_msg']); |
|
| 376 | + { |
|
| 377 | + $context['repair_errors'][] = sprintf($txt['repair_stats_topics_1'], $row['id_topic'], $row['id_first_msg']); |
|
| 378 | + } |
|
| 373 | 379 | if ($row['id_last_msg'] != $row['myid_last_msg']) |
| 374 | - $context['repair_errors'][] = sprintf($txt['repair_stats_topics_2'], $row['id_topic'], $row['id_last_msg']); |
|
| 380 | + { |
|
| 381 | + $context['repair_errors'][] = sprintf($txt['repair_stats_topics_2'], $row['id_topic'], $row['id_last_msg']); |
|
| 382 | + } |
|
| 375 | 383 | if ($row['approved'] != $row['firstmsg_approved']) |
| 376 | - $context['repair_errors'][] = sprintf($txt['repair_stats_topics_5'], $row['id_topic']); |
|
| 384 | + { |
|
| 385 | + $context['repair_errors'][] = sprintf($txt['repair_stats_topics_5'], $row['id_topic']); |
|
| 386 | + } |
|
| 377 | 387 | |
| 378 | 388 | return true; |
| 379 | 389 | }, |
@@ -401,7 +411,9 @@ discard block |
||
| 401 | 411 | |
| 402 | 412 | // Not really a problem? |
| 403 | 413 | if ($row['my_num_replies'] == $row['num_replies']) |
| 404 | - return false; |
|
| 414 | + { |
|
| 415 | + return false; |
|
| 416 | + } |
|
| 405 | 417 | |
| 406 | 418 | require_once(SUBSDIR . '/Topic.subs.php'); |
| 407 | 419 | setTopicAttribute($row['id_topic'], array( |
@@ -413,10 +425,14 @@ discard block |
||
| 413 | 425 | |
| 414 | 426 | // Just joking? |
| 415 | 427 | if ($row['my_num_replies'] == $row['num_replies']) |
| 416 | - return false; |
|
| 428 | + { |
|
| 429 | + return false; |
|
| 430 | + } |
|
| 417 | 431 | |
| 418 | 432 | if ($row['num_replies'] != $row['my_num_replies']) |
| 419 | - $context['repair_errors'][] = sprintf($txt['repair_stats_topics_3'], $row['id_topic'], $row['num_replies']); |
|
| 433 | + { |
|
| 434 | + $context['repair_errors'][] = sprintf($txt['repair_stats_topics_3'], $row['id_topic'], $row['num_replies']); |
|
| 435 | + } |
|
| 420 | 436 | |
| 421 | 437 | return true; |
| 422 | 438 | }, |
@@ -986,7 +1002,9 @@ discard block |
||
| 986 | 1002 | while ($row = $db->fetch_assoc($result)) |
| 987 | 1003 | { |
| 988 | 1004 | foreach (text2words($row['subject']) as $word) |
| 989 | - $inserts[] = array($word, $row['id_topic']); |
|
| 1005 | + { |
|
| 1006 | + $inserts[] = array($word, $row['id_topic']); |
|
| 1007 | + } |
|
| 990 | 1008 | if (count($inserts) > 500) |
| 991 | 1009 | { |
| 992 | 1010 | $db->insert('ignore', |
@@ -1001,12 +1019,14 @@ discard block |
||
| 1001 | 1019 | } |
| 1002 | 1020 | |
| 1003 | 1021 | if (!empty($inserts)) |
| 1004 | - $db->insert('ignore', |
|
| 1022 | + { |
|
| 1023 | + $db->insert('ignore', |
|
| 1005 | 1024 | '{db_prefix}log_search_subjects', |
| 1006 | 1025 | array('word' => 'string', 'id_topic' => 'int'), |
| 1007 | 1026 | $inserts, |
| 1008 | 1027 | array('word', 'id_topic') |
| 1009 | 1028 | ); |
| 1029 | + } |
|
| 1010 | 1030 | }, |
| 1011 | 1031 | 'message_function' => function ($row) { |
| 1012 | 1032 | global $txt, $context; |
@@ -1242,9 +1262,12 @@ discard block |
||
| 1242 | 1262 | |
| 1243 | 1263 | // Have we already created it? |
| 1244 | 1264 | if ($createOnce) |
| 1245 | - return; |
|
| 1246 | - else |
|
| 1247 | - $createOnce = true; |
|
| 1265 | + { |
|
| 1266 | + return; |
|
| 1267 | + } |
|
| 1268 | + else { |
|
| 1269 | + $createOnce = true; |
|
| 1270 | + } |
|
| 1248 | 1271 | |
| 1249 | 1272 | // Back to the forum's default language. |
| 1250 | 1273 | loadLanguage('Admin', $language); |
@@ -1260,7 +1283,9 @@ discard block |
||
| 1260 | 1283 | ) |
| 1261 | 1284 | ); |
| 1262 | 1285 | if ($db->num_rows($result) != 0) |
| 1263 | - list ($salvageCatID) = $db->fetch_row($result); |
|
| 1286 | + { |
|
| 1287 | + list ($salvageCatID) = $db->fetch_row($result); |
|
| 1288 | + } |
|
| 1264 | 1289 | $db->free_result($result); |
| 1265 | 1290 | |
| 1266 | 1291 | if (empty($salvageCatID)) |
@@ -1294,7 +1319,9 @@ discard block |
||
| 1294 | 1319 | ) |
| 1295 | 1320 | ); |
| 1296 | 1321 | if ($db->num_rows($result) != 0) |
| 1297 | - list ($salvageBoardID) = $db->fetch_row($result); |
|
| 1322 | + { |
|
| 1323 | + list ($salvageBoardID) = $db->fetch_row($result); |
|
| 1324 | + } |
|
| 1298 | 1325 | $db->free_result($result); |
| 1299 | 1326 | |
| 1300 | 1327 | if (empty($salvageBoardID)) |
@@ -1348,11 +1375,15 @@ discard block |
||
| 1348 | 1375 | |
| 1349 | 1376 | // Errr, wait. How much time has this taken already? |
| 1350 | 1377 | if (!$force && microtime(true) - $time_start < 3000) |
| 1351 | - return; |
|
| 1378 | + { |
|
| 1379 | + return; |
|
| 1380 | + } |
|
| 1352 | 1381 | |
| 1353 | 1382 | // Restore the query cache if interested. |
| 1354 | 1383 | if ($db_show_debug === true) |
| 1355 | - Debug::instance()->on(); |
|
| 1384 | + { |
|
| 1385 | + Debug::instance()->on(); |
|
| 1386 | + } |
|
| 1356 | 1387 | |
| 1357 | 1388 | $context['continue_get_data'] = '?action=admin;area=repairboards' . (isset($_GET['fixErrors']) ? ';fixErrors' : '') . ';step=' . $_GET['step'] . ';substep=' . $_GET['substep'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
| 1358 | 1389 | $context['page_title'] = $txt['not_done_title']; |
@@ -1362,9 +1393,12 @@ discard block |
||
| 1362 | 1393 | |
| 1363 | 1394 | // Change these two if more steps are added! |
| 1364 | 1395 | if (empty($max_substep)) |
| 1365 | - $context['continue_percent'] = round(($_GET['step'] * 100) / $context['total_steps']); |
|
| 1366 | - else |
|
| 1367 | - $context['continue_percent'] = round((($_GET['step'] + ($_GET['substep'] / $max_substep)) * 100) / $context['total_steps']); |
|
| 1396 | + { |
|
| 1397 | + $context['continue_percent'] = round(($_GET['step'] * 100) / $context['total_steps']); |
|
| 1398 | + } |
|
| 1399 | + else { |
|
| 1400 | + $context['continue_percent'] = round((($_GET['step'] + ($_GET['substep'] / $max_substep)) * 100) / $context['total_steps']); |
|
| 1401 | + } |
|
| 1368 | 1402 | |
| 1369 | 1403 | // Never more than 100%! |
| 1370 | 1404 | $context['continue_percent'] = min($context['continue_percent'], 100); |
@@ -1408,7 +1442,9 @@ discard block |
||
| 1408 | 1442 | |
| 1409 | 1443 | // Don't allow the cache to get too full. |
| 1410 | 1444 | if ($db_show_debug === true) |
| 1411 | - Debug::instance()->off(); |
|
| 1445 | + { |
|
| 1446 | + Debug::instance()->off(); |
|
| 1447 | + } |
|
| 1412 | 1448 | |
| 1413 | 1449 | $context['total_steps'] = count($errorTests); |
| 1414 | 1450 | |
@@ -1422,7 +1458,9 @@ discard block |
||
| 1422 | 1458 | |
| 1423 | 1459 | // Already done this? |
| 1424 | 1460 | if ($_GET['step'] > $current_step) |
| 1425 | - continue; |
|
| 1461 | + { |
|
| 1462 | + continue; |
|
| 1463 | + } |
|
| 1426 | 1464 | |
| 1427 | 1465 | // If we're fixing it but it ain't broke why try? |
| 1428 | 1466 | if ($do_fix && !in_array($error_type, $to_fix)) |
@@ -1452,13 +1490,18 @@ discard block |
||
| 1452 | 1490 | { |
| 1453 | 1491 | // Make sure there's at least one ID to test. |
| 1454 | 1492 | if (isset($test['substeps']) && empty($step_max)) |
| 1455 | - break; |
|
| 1493 | + { |
|
| 1494 | + break; |
|
| 1495 | + } |
|
| 1456 | 1496 | |
| 1457 | 1497 | // What is the testing query (Changes if we are testing or fixing) |
| 1458 | 1498 | if (!$do_fix) |
| 1459 | - $test_query = 'check_query'; |
|
| 1460 | - else |
|
| 1461 | - $test_query = isset($test['fix_query']) ? 'fix_query' : 'check_query'; |
|
| 1499 | + { |
|
| 1500 | + $test_query = 'check_query'; |
|
| 1501 | + } |
|
| 1502 | + else { |
|
| 1503 | + $test_query = isset($test['fix_query']) ? 'fix_query' : 'check_query'; |
|
| 1504 | + } |
|
| 1462 | 1505 | |
| 1463 | 1506 | // Do the test... |
| 1464 | 1507 | $request = $db->query('', |
@@ -1469,9 +1512,12 @@ discard block |
||
| 1469 | 1512 | |
| 1470 | 1513 | // Does it need a fix? |
| 1471 | 1514 | if (!empty($test['check_type']) && $test['check_type'] == 'count') |
| 1472 | - list ($needs_fix) = $db->fetch_row($request); |
|
| 1473 | - else |
|
| 1474 | - $needs_fix = $db->num_rows($request); |
|
| 1515 | + { |
|
| 1516 | + list ($needs_fix) = $db->fetch_row($request); |
|
| 1517 | + } |
|
| 1518 | + else { |
|
| 1519 | + $needs_fix = $db->num_rows($request); |
|
| 1520 | + } |
|
| 1475 | 1521 | |
| 1476 | 1522 | $total_queries++; |
| 1477 | 1523 | |
@@ -1484,7 +1530,9 @@ discard block |
||
| 1484 | 1530 | $found_errors = true; |
| 1485 | 1531 | |
| 1486 | 1532 | if (isset($test['message'])) |
| 1487 | - $context['repair_errors'][] = $txt[$test['message']]; |
|
| 1533 | + { |
|
| 1534 | + $context['repair_errors'][] = $txt[$test['message']]; |
|
| 1535 | + } |
|
| 1488 | 1536 | |
| 1489 | 1537 | // One per row! |
| 1490 | 1538 | elseif (isset($test['messages'])) |
@@ -1495,9 +1543,13 @@ discard block |
||
| 1495 | 1543 | foreach ($variables as $k => $v) |
| 1496 | 1544 | { |
| 1497 | 1545 | if ($k == 0 && isset($txt[$v])) |
| 1498 | - $variables[$k] = $txt[$v]; |
|
| 1546 | + { |
|
| 1547 | + $variables[$k] = $txt[$v]; |
|
| 1548 | + } |
|
| 1499 | 1549 | elseif ($k > 0 && isset($row[$v])) |
| 1500 | - $variables[$k] = $row[$v]; |
|
| 1550 | + { |
|
| 1551 | + $variables[$k] = $row[$v]; |
|
| 1552 | + } |
|
| 1501 | 1553 | } |
| 1502 | 1554 | $context['repair_errors'][] = call_user_func_array('sprintf', $variables); |
| 1503 | 1555 | } |
@@ -1509,12 +1561,16 @@ discard block |
||
| 1509 | 1561 | // Find out if there are actually errors. |
| 1510 | 1562 | $found_errors = false; |
| 1511 | 1563 | while ($row = $db->fetch_assoc($request)) |
| 1512 | - $found_errors |= $test['message_function']($row); |
|
| 1564 | + { |
|
| 1565 | + $found_errors |= $test['message_function']($row); |
|
| 1566 | + } |
|
| 1513 | 1567 | } |
| 1514 | 1568 | |
| 1515 | 1569 | // Actually have something to fix? |
| 1516 | 1570 | if ($found_errors) |
| 1517 | - $to_fix[] = $error_type; |
|
| 1571 | + { |
|
| 1572 | + $to_fix[] = $error_type; |
|
| 1573 | + } |
|
| 1518 | 1574 | } |
| 1519 | 1575 | |
| 1520 | 1576 | // We want to fix, we need to fix - so work out what exactly to do! |
@@ -1525,7 +1581,9 @@ discard block |
||
| 1525 | 1581 | { |
| 1526 | 1582 | $ids = array(); |
| 1527 | 1583 | while ($row = $db->fetch_assoc($request)) |
| 1528 | - $ids[] = $row[$test['fix_collect']['index']]; |
|
| 1584 | + { |
|
| 1585 | + $ids[] = $row[$test['fix_collect']['index']]; |
|
| 1586 | + } |
|
| 1529 | 1587 | if (!empty($ids)) |
| 1530 | 1588 | { |
| 1531 | 1589 | // Fix it! |
@@ -1535,29 +1593,37 @@ discard block |
||
| 1535 | 1593 | |
| 1536 | 1594 | // Simply executing a fix it query? |
| 1537 | 1595 | elseif (isset($test['fix_it_query'])) |
| 1538 | - $db->query('', |
|
| 1596 | + { |
|
| 1597 | + $db->query('', |
|
| 1539 | 1598 | $test['fix_it_query'], |
| 1540 | 1599 | array( |
| 1541 | 1600 | ) |
| 1542 | 1601 | ); |
| 1602 | + } |
|
| 1543 | 1603 | |
| 1544 | 1604 | // Do we have some processing to do? |
| 1545 | 1605 | elseif (isset($test['fix_processing'])) |
| 1546 | 1606 | { |
| 1547 | 1607 | while ($row = $db->fetch_assoc($request)) |
| 1548 | - $test['fix_processing']($row); |
|
| 1608 | + { |
|
| 1609 | + $test['fix_processing']($row); |
|
| 1610 | + } |
|
| 1549 | 1611 | } |
| 1550 | 1612 | |
| 1551 | 1613 | // What about the full set of processing? |
| 1552 | 1614 | elseif (isset($test['fix_full_processing'])) |
| 1553 | - $test['fix_full_processing']($request); |
|
| 1615 | + { |
|
| 1616 | + $test['fix_full_processing']($request); |
|
| 1617 | + } |
|
| 1554 | 1618 | |
| 1555 | 1619 | // Do we have other things we need to fix as a result? |
| 1556 | 1620 | if (!empty($test['force_fix'])) |
| 1557 | 1621 | { |
| 1558 | 1622 | foreach ($test['force_fix'] as $item) |
| 1559 | - if (!in_array($item, $to_fix)) |
|
| 1623 | + { |
|
| 1624 | + if (!in_array($item, $to_fix)) |
|
| 1560 | 1625 | $to_fix[] = $item; |
| 1626 | + } |
|
| 1561 | 1627 | } |
| 1562 | 1628 | } |
| 1563 | 1629 | } |
@@ -1574,15 +1640,19 @@ discard block |
||
| 1574 | 1640 | { |
| 1575 | 1641 | pauseRepairProcess($to_fix, $error_type, $step_max); |
| 1576 | 1642 | } |
| 1577 | - else |
|
| 1578 | - $done = true; |
|
| 1643 | + else { |
|
| 1644 | + $done = true; |
|
| 1645 | + } |
|
| 1646 | + } |
|
| 1647 | + else { |
|
| 1648 | + $done = true; |
|
| 1579 | 1649 | } |
| 1580 | - else |
|
| 1581 | - $done = true; |
|
| 1582 | 1650 | |
| 1583 | 1651 | // Don't allow more than 1000 queries at a time. |
| 1584 | 1652 | if ($total_queries >= 1000) |
| 1585 | - pauseRepairProcess($to_fix, $error_type, $step_max, true); |
|
| 1653 | + { |
|
| 1654 | + pauseRepairProcess($to_fix, $error_type, $step_max, true); |
|
| 1655 | + } |
|
| 1586 | 1656 | } |
| 1587 | 1657 | |
| 1588 | 1658 | // Keep going. |
@@ -1596,7 +1666,9 @@ discard block |
||
| 1596 | 1666 | { |
| 1597 | 1667 | $key = array_search($error_type, $to_fix); |
| 1598 | 1668 | if ($key !== false && isset($to_fix[$key])) |
| 1599 | - unset($to_fix[$key]); |
|
| 1669 | + { |
|
| 1670 | + unset($to_fix[$key]); |
|
| 1671 | + } |
|
| 1600 | 1672 | } |
| 1601 | 1673 | |
| 1602 | 1674 | // Are we done? |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | 'value' => $txt['package_restore_permissions_cur_status'], |
| 326 | 326 | ), |
| 327 | 327 | 'data' => array( |
| 328 | - 'function' => function ($rowData) { |
|
| 328 | + 'function' => function($rowData) { |
|
| 329 | 329 | global $txt; |
| 330 | 330 | |
| 331 | 331 | $formatTxt = $rowData['result'] == '' || $rowData['result'] == 'skipped' ? $txt['package_restore_permissions_pre_change'] : $txt['package_restore_permissions_post_change']; |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | 'value' => $txt['package_restore_permissions_result'], |
| 355 | 355 | ), |
| 356 | 356 | 'data' => array( |
| 357 | - 'function' => function ($rowData) { |
|
| 357 | + 'function' => function($rowData) { |
|
| 358 | 358 | global $txt; |
| 359 | 359 | |
| 360 | 360 | return $txt['package_restore_permissions_action_' . $rowData['result']]; |
@@ -35,7 +35,9 @@ discard block |
||
| 35 | 35 | $data = fetch_web_data($gzfilename); |
| 36 | 36 | |
| 37 | 37 | if ($data === false) |
| 38 | - return false; |
|
| 38 | + { |
|
| 39 | + return false; |
|
| 40 | + } |
|
| 39 | 41 | } |
| 40 | 42 | // Or a file on the system |
| 41 | 43 | else |
@@ -43,7 +45,9 @@ discard block |
||
| 43 | 45 | $data = @file_get_contents($gzfilename); |
| 44 | 46 | |
| 45 | 47 | if ($data === false) |
| 46 | - return false; |
|
| 48 | + { |
|
| 49 | + return false; |
|
| 50 | + } |
|
| 47 | 51 | } |
| 48 | 52 | |
| 49 | 53 | return read_tgz_data($data, $destination, $single_file, $overwrite, $files_to_extract); |
@@ -83,7 +87,9 @@ discard block |
||
| 83 | 87 | |
| 84 | 88 | // Choose the right method for the file |
| 85 | 89 | if ($untgz->check_valid_tgz()) |
| 86 | - return $untgz->read_tgz_data(); |
|
| 90 | + { |
|
| 91 | + return $untgz->read_tgz_data(); |
|
| 92 | + } |
|
| 87 | 93 | else |
| 88 | 94 | { |
| 89 | 95 | unset($untgz); |
@@ -125,7 +131,9 @@ discard block |
||
| 125 | 131 | $a_url = parse_url($url); |
| 126 | 132 | |
| 127 | 133 | if (!isset($a_url['scheme'])) |
| 128 | - return false; |
|
| 134 | + { |
|
| 135 | + return false; |
|
| 136 | + } |
|
| 129 | 137 | |
| 130 | 138 | // Attempt to connect... |
| 131 | 139 | $temp = ''; |
@@ -133,7 +141,9 @@ discard block |
||
| 133 | 141 | |
| 134 | 142 | // Can't make a connection |
| 135 | 143 | if (!$fid) |
| 136 | - return false; |
|
| 144 | + { |
|
| 145 | + return false; |
|
| 146 | + } |
|
| 137 | 147 | |
| 138 | 148 | // See if the file is where its supposed to be |
| 139 | 149 | fputs($fid, 'HEAD ' . $a_url['path'] . ' HTTP/1.0' . "\r\n" . 'Host: ' . $a_url['host'] . "\r\n\r\n"); |
@@ -190,7 +200,9 @@ discard block |
||
| 190 | 200 | { |
| 191 | 201 | // Already found this? If so don't add it twice! |
| 192 | 202 | if (in_array($row['package_id'], $found)) |
| 193 | - continue; |
|
| 203 | + { |
|
| 204 | + continue; |
|
| 205 | + } |
|
| 194 | 206 | |
| 195 | 207 | $found[] = $row['package_id']; |
| 196 | 208 | |
@@ -226,20 +238,29 @@ discard block |
||
| 226 | 238 | |
| 227 | 239 | // Extract package-info.xml from downloaded file. (*/ is used because it could be in any directory.) |
| 228 | 240 | if (preg_match('~^https?://~i', $gzfilename) === 1) |
| 229 | - $packageInfo = read_tgz_data(fetch_web_data($gzfilename, '', true), '*/package-info.xml', true); |
|
| 241 | + { |
|
| 242 | + $packageInfo = read_tgz_data(fetch_web_data($gzfilename, '', true), '*/package-info.xml', true); |
|
| 243 | + } |
|
| 230 | 244 | else |
| 231 | 245 | { |
| 232 | 246 | // It must be in the package directory then |
| 233 | 247 | if (!file_exists(BOARDDIR . '/packages/' . $gzfilename)) |
| 234 | - return 'package_get_error_not_found'; |
|
| 248 | + { |
|
| 249 | + return 'package_get_error_not_found'; |
|
| 250 | + } |
|
| 235 | 251 | |
| 236 | 252 | // Make sure an package.xml file is available |
| 237 | 253 | if (is_file(BOARDDIR . '/packages/' . $gzfilename)) |
| 238 | - $packageInfo = read_tgz_file(BOARDDIR . '/packages/' . $gzfilename, '*/package-info.xml', true); |
|
| 254 | + { |
|
| 255 | + $packageInfo = read_tgz_file(BOARDDIR . '/packages/' . $gzfilename, '*/package-info.xml', true); |
|
| 256 | + } |
|
| 239 | 257 | elseif (file_exists(BOARDDIR . '/packages/' . $gzfilename . '/package-info.xml')) |
| 240 | - $packageInfo = file_get_contents(BOARDDIR . '/packages/' . $gzfilename . '/package-info.xml'); |
|
| 241 | - else |
|
| 242 | - return 'package_get_error_missing_xml'; |
|
| 258 | + { |
|
| 259 | + $packageInfo = file_get_contents(BOARDDIR . '/packages/' . $gzfilename . '/package-info.xml'); |
|
| 260 | + } |
|
| 261 | + else { |
|
| 262 | + return 'package_get_error_missing_xml'; |
|
| 263 | + } |
|
| 243 | 264 | } |
| 244 | 265 | |
| 245 | 266 | // Nothing? |
@@ -248,9 +269,12 @@ discard block |
||
| 248 | 269 | // Perhaps they are trying to install a theme, lets tell them nicely this is the wrong function |
| 249 | 270 | $packageInfo = read_tgz_file(BOARDDIR . '/packages/' . $gzfilename, '*/theme_info.xml', true); |
| 250 | 271 | if (!empty($packageInfo)) |
| 251 | - return 'package_get_error_is_theme'; |
|
| 252 | - else |
|
| 253 | - return 'package_get_error_is_zero'; |
|
| 272 | + { |
|
| 273 | + return 'package_get_error_is_theme'; |
|
| 274 | + } |
|
| 275 | + else { |
|
| 276 | + return 'package_get_error_is_zero'; |
|
| 277 | + } |
|
| 254 | 278 | } |
| 255 | 279 | |
| 256 | 280 | // Parse package-info.xml into an Xml_Array. |
@@ -258,7 +282,9 @@ discard block |
||
| 258 | 282 | |
| 259 | 283 | // @todo Error message of some sort? |
| 260 | 284 | if (!$packageInfo->exists('package-info[0]')) |
| 261 | - return 'package_get_error_packageinfo_corrupt'; |
|
| 285 | + { |
|
| 286 | + return 'package_get_error_packageinfo_corrupt'; |
|
| 287 | + } |
|
| 262 | 288 | |
| 263 | 289 | $packageInfo = $packageInfo->path('package-info[0]'); |
| 264 | 290 | |
@@ -269,7 +295,9 @@ discard block |
||
| 269 | 295 | |
| 270 | 296 | // Set a default type if none was supplied in the package |
| 271 | 297 | if (!isset($package['type'])) |
| 272 | - $package['type'] = 'modification'; |
|
| 298 | + { |
|
| 299 | + $package['type'] = 'modification'; |
|
| 300 | + } |
|
| 273 | 301 | |
| 274 | 302 | return $package; |
| 275 | 303 | } |
@@ -397,11 +425,15 @@ discard block |
||
| 397 | 425 | |
| 398 | 426 | // If we just restored permissions then wherever we are, we are now done and dusted. |
| 399 | 427 | if (!empty($_POST['restore_perms'])) |
| 400 | - obExit(); |
|
| 428 | + { |
|
| 429 | + obExit(); |
|
| 430 | + } |
|
| 401 | 431 | } |
| 402 | 432 | // Otherwise, it's entirely irrelevant? |
| 403 | 433 | elseif ($restore_write_status) |
| 404 | - return true; |
|
| 434 | + { |
|
| 435 | + return true; |
|
| 436 | + } |
|
| 405 | 437 | |
| 406 | 438 | // This is where we report what we got up to. |
| 407 | 439 | $return_data = array( |
@@ -418,7 +450,9 @@ discard block |
||
| 418 | 450 | |
| 419 | 451 | // Check for a valid connection |
| 420 | 452 | if ($package_ftp->error !== false) |
| 421 | - unset($package_ftp, $_SESSION['pack_ftp']); |
|
| 453 | + { |
|
| 454 | + unset($package_ftp, $_SESSION['pack_ftp']); |
|
| 455 | + } |
|
| 422 | 456 | } |
| 423 | 457 | |
| 424 | 458 | // Just got a submission did we? |
@@ -440,10 +474,13 @@ discard block |
||
| 440 | 474 | { |
| 441 | 475 | $ftp_root = strtr(BOARDDIR, array($_POST['ftp_path'] => '')); |
| 442 | 476 | if (substr($ftp_root, -1) == '/' && ($_POST['ftp_path'] == '' || substr($_POST['ftp_path'], 0, 1) == '/')) |
| 443 | - $ftp_root = substr($ftp_root, 0, -1); |
|
| 477 | + { |
|
| 478 | + $ftp_root = substr($ftp_root, 0, -1); |
|
| 479 | + } |
|
| 480 | + } |
|
| 481 | + else { |
|
| 482 | + $ftp_root = BOARDDIR; |
|
| 444 | 483 | } |
| 445 | - else |
|
| 446 | - $ftp_root = BOARDDIR; |
|
| 447 | 484 | |
| 448 | 485 | $_SESSION['pack_ftp'] = array( |
| 449 | 486 | 'server' => $_POST['ftp_server'], |
@@ -456,7 +493,9 @@ discard block |
||
| 456 | 493 | ); |
| 457 | 494 | |
| 458 | 495 | if (!isset($modSettings['package_path']) || $modSettings['package_path'] != $_POST['ftp_path']) |
| 459 | - updateSettings(array('package_path' => $_POST['ftp_path'])); |
|
| 496 | + { |
|
| 497 | + updateSettings(array('package_path' => $_POST['ftp_path'])); |
|
| 498 | + } |
|
| 460 | 499 | |
| 461 | 500 | // This is now the primary connection. |
| 462 | 501 | $package_ftp = $ftp; |
@@ -470,10 +509,14 @@ discard block |
||
| 470 | 509 | { |
| 471 | 510 | // Sometimes this can somehow happen maybe? |
| 472 | 511 | if (empty($file)) |
| 473 | - unset($chmodFiles[$k]); |
|
| 512 | + { |
|
| 513 | + unset($chmodFiles[$k]); |
|
| 514 | + } |
|
| 474 | 515 | // Already writable? |
| 475 | 516 | elseif (@is_writable($file)) |
| 476 | - $return_data['files']['writable'][] = $file; |
|
| 517 | + { |
|
| 518 | + $return_data['files']['writable'][] = $file; |
|
| 519 | + } |
|
| 477 | 520 | else |
| 478 | 521 | { |
| 479 | 522 | // Now try to change that. |
@@ -492,17 +535,25 @@ discard block |
||
| 492 | 535 | $ftp = new Ftp_Connection(null); |
| 493 | 536 | } |
| 494 | 537 | elseif ($ftp->error !== false && !isset($ftp_error)) |
| 495 | - $ftp_error = $ftp->last_message === null ? '' : $ftp->last_message; |
|
| 538 | + { |
|
| 539 | + $ftp_error = $ftp->last_message === null ? '' : $ftp->last_message; |
|
| 540 | + } |
|
| 496 | 541 | |
| 497 | 542 | list ($username, $detect_path, $found_path) = $ftp->detect_path(BOARDDIR); |
| 498 | 543 | |
| 499 | 544 | if ($found_path) |
| 500 | - $_POST['ftp_path'] = $detect_path; |
|
| 545 | + { |
|
| 546 | + $_POST['ftp_path'] = $detect_path; |
|
| 547 | + } |
|
| 501 | 548 | elseif (!isset($_POST['ftp_path'])) |
| 502 | - $_POST['ftp_path'] = isset($modSettings['package_path']) ? $modSettings['package_path'] : $detect_path; |
|
| 549 | + { |
|
| 550 | + $_POST['ftp_path'] = isset($modSettings['package_path']) ? $modSettings['package_path'] : $detect_path; |
|
| 551 | + } |
|
| 503 | 552 | |
| 504 | 553 | if (!isset($_POST['ftp_username'])) |
| 505 | - $_POST['ftp_username'] = $username; |
|
| 554 | + { |
|
| 555 | + $_POST['ftp_username'] = $username; |
|
| 556 | + } |
|
| 506 | 557 | } |
| 507 | 558 | |
| 508 | 559 | $context['package_ftp'] = array( |
@@ -516,7 +567,9 @@ discard block |
||
| 516 | 567 | |
| 517 | 568 | // Which files failed? |
| 518 | 569 | if (!isset($context['notwritable_files'])) |
| 519 | - $context['notwritable_files'] = array(); |
|
| 570 | + { |
|
| 571 | + $context['notwritable_files'] = array(); |
|
| 572 | + } |
|
| 520 | 573 | $context['notwritable_files'] = array_merge($context['notwritable_files'], $return_data['files']['notwritable']); |
| 521 | 574 | |
| 522 | 575 | // Sent here to die? |
@@ -564,8 +617,9 @@ discard block |
||
| 564 | 617 | $ftp_file = strtr($file, array($_SESSION['pack_ftp']['root'] => '')); |
| 565 | 618 | $package_ftp->chmod($ftp_file, $perms); |
| 566 | 619 | } |
| 567 | - else |
|
| 568 | - elk_chmod($file, $perms); |
|
| 620 | + else { |
|
| 621 | + elk_chmod($file, $perms); |
|
| 622 | + } |
|
| 569 | 623 | |
| 570 | 624 | $new_permissions = @fileperms($file); |
| 571 | 625 | $result = $new_permissions == $perms ? 'success' : 'failure'; |
@@ -613,39 +667,56 @@ discard block |
||
| 613 | 667 | { |
| 614 | 668 | // If this file doesn't exist, then we actually want to look at the directory, no? |
| 615 | 669 | if (!file_exists($file)) |
| 616 | - $file = dirname($file); |
|
| 670 | + { |
|
| 671 | + $file = dirname($file); |
|
| 672 | + } |
|
| 617 | 673 | |
| 618 | 674 | // This looks odd, but it's an attempt to work around PHP suExec. |
| 619 | 675 | if (!@is_writable($file)) |
| 620 | - elk_chmod($file, 0755); |
|
| 676 | + { |
|
| 677 | + elk_chmod($file, 0755); |
|
| 678 | + } |
|
| 621 | 679 | if (!@is_writable($file)) |
| 622 | - elk_chmod($file, 0777); |
|
| 680 | + { |
|
| 681 | + elk_chmod($file, 0777); |
|
| 682 | + } |
|
| 623 | 683 | if (!@is_writable(dirname($file))) |
| 624 | - elk_chmod($file, 0755); |
|
| 684 | + { |
|
| 685 | + elk_chmod($file, 0755); |
|
| 686 | + } |
|
| 625 | 687 | if (!@is_writable(dirname($file))) |
| 626 | - elk_chmod($file, 0777); |
|
| 688 | + { |
|
| 689 | + elk_chmod($file, 0777); |
|
| 690 | + } |
|
| 627 | 691 | |
| 628 | 692 | $fp = is_dir($file) ? @opendir($file) : @fopen($file, 'rb'); |
| 629 | 693 | if (@is_writable($file) && $fp) |
| 630 | 694 | { |
| 631 | 695 | unset($files[$k]); |
| 632 | 696 | if (!is_dir($file)) |
| 633 | - fclose($fp); |
|
| 634 | - else |
|
| 635 | - closedir($fp); |
|
| 697 | + { |
|
| 698 | + fclose($fp); |
|
| 699 | + } |
|
| 700 | + else { |
|
| 701 | + closedir($fp); |
|
| 702 | + } |
|
| 636 | 703 | } |
| 637 | 704 | } |
| 638 | 705 | |
| 639 | 706 | // No FTP required! |
| 640 | 707 | if (empty($files)) |
| 641 | - return array(); |
|
| 708 | + { |
|
| 709 | + return array(); |
|
| 710 | + } |
|
| 642 | 711 | } |
| 643 | 712 | |
| 644 | 713 | // They've opted to not use FTP, and try anyway. |
| 645 | 714 | if (isset($_SESSION['pack_ftp']) && $_SESSION['pack_ftp'] === false) |
| 646 | 715 | { |
| 647 | 716 | if ($files === null) |
| 648 | - return array(); |
|
| 717 | + { |
|
| 718 | + return array(); |
|
| 719 | + } |
|
| 649 | 720 | |
| 650 | 721 | foreach ($files as $k => $file) |
| 651 | 722 | { |
@@ -657,12 +728,18 @@ discard block |
||
| 657 | 728 | elk_chmod($file, 0755); |
| 658 | 729 | } |
| 659 | 730 | if (!@is_writable($file)) |
| 660 | - elk_chmod($file, 0777); |
|
| 731 | + { |
|
| 732 | + elk_chmod($file, 0777); |
|
| 733 | + } |
|
| 661 | 734 | if (!@is_writable(dirname($file))) |
| 662 | - elk_chmod(dirname($file), 0777); |
|
| 735 | + { |
|
| 736 | + elk_chmod(dirname($file), 0777); |
|
| 737 | + } |
|
| 663 | 738 | |
| 664 | 739 | if (@is_writable($file)) |
| 665 | - unset($files[$k]); |
|
| 740 | + { |
|
| 741 | + unset($files[$k]); |
|
| 742 | + } |
|
| 666 | 743 | } |
| 667 | 744 | |
| 668 | 745 | return $files; |
@@ -672,7 +749,9 @@ discard block |
||
| 672 | 749 | $package_ftp = new Ftp_Connection($_SESSION['pack_ftp']['server'], $_SESSION['pack_ftp']['port'], $_SESSION['pack_ftp']['username'], package_crypt($_SESSION['pack_ftp']['password'])); |
| 673 | 750 | |
| 674 | 751 | if ($files === null) |
| 675 | - return array(); |
|
| 752 | + { |
|
| 753 | + return array(); |
|
| 754 | + } |
|
| 676 | 755 | |
| 677 | 756 | foreach ($files as $k => $file) |
| 678 | 757 | { |
@@ -688,14 +767,20 @@ discard block |
||
| 688 | 767 | |
| 689 | 768 | // Still not writable, true full permissions |
| 690 | 769 | if (!@is_writable($file)) |
| 691 | - $package_ftp->chmod($ftp_file, 0777); |
|
| 770 | + { |
|
| 771 | + $package_ftp->chmod($ftp_file, 0777); |
|
| 772 | + } |
|
| 692 | 773 | |
| 693 | 774 | // Directory not writable, try to chmod to 777 then |
| 694 | 775 | if (!@is_writable(dirname($file))) |
| 695 | - $package_ftp->chmod(dirname($ftp_file), 0777); |
|
| 776 | + { |
|
| 777 | + $package_ftp->chmod(dirname($ftp_file), 0777); |
|
| 778 | + } |
|
| 696 | 779 | |
| 697 | 780 | if (@is_writable($file)) |
| 698 | - unset($files[$k]); |
|
| 781 | + { |
|
| 782 | + unset($files[$k]); |
|
| 783 | + } |
|
| 699 | 784 | } |
| 700 | 785 | |
| 701 | 786 | return $files; |
@@ -731,17 +816,25 @@ discard block |
||
| 731 | 816 | $ftp = new Ftp_Connection(null); |
| 732 | 817 | } |
| 733 | 818 | elseif ($ftp->error !== false && !isset($ftp_error)) |
| 734 | - $ftp_error = $ftp->last_message === null ? '' : $ftp->last_message; |
|
| 819 | + { |
|
| 820 | + $ftp_error = $ftp->last_message === null ? '' : $ftp->last_message; |
|
| 821 | + } |
|
| 735 | 822 | |
| 736 | 823 | list ($username, $detect_path, $found_path) = $ftp->detect_path(BOARDDIR); |
| 737 | 824 | |
| 738 | 825 | if ($found_path) |
| 739 | - $_POST['ftp_path'] = $detect_path; |
|
| 826 | + { |
|
| 827 | + $_POST['ftp_path'] = $detect_path; |
|
| 828 | + } |
|
| 740 | 829 | elseif (!isset($_POST['ftp_path'])) |
| 741 | - $_POST['ftp_path'] = isset($modSettings['package_path']) ? $modSettings['package_path'] : $detect_path; |
|
| 830 | + { |
|
| 831 | + $_POST['ftp_path'] = isset($modSettings['package_path']) ? $modSettings['package_path'] : $detect_path; |
|
| 832 | + } |
|
| 742 | 833 | |
| 743 | 834 | if (!isset($_POST['ftp_username'])) |
| 744 | - $_POST['ftp_username'] = $username; |
|
| 835 | + { |
|
| 836 | + $_POST['ftp_username'] = $username; |
|
| 837 | + } |
|
| 745 | 838 | |
| 746 | 839 | $context['package_ftp'] = array( |
| 747 | 840 | 'server' => isset($_POST['ftp_server']) ? $_POST['ftp_server'] : (isset($modSettings['package_server']) ? $modSettings['package_server'] : 'localhost'), |
@@ -754,7 +847,9 @@ discard block |
||
| 754 | 847 | |
| 755 | 848 | // If we're returning dump out here. |
| 756 | 849 | if ($return) |
| 757 | - return $files; |
|
| 850 | + { |
|
| 851 | + return $files; |
|
| 852 | + } |
|
| 758 | 853 | |
| 759 | 854 | $context['page_title'] = $txt['package_ftp_necessary']; |
| 760 | 855 | $context['sub_template'] = 'ftp_required'; |
@@ -766,10 +861,13 @@ discard block |
||
| 766 | 861 | { |
| 767 | 862 | $ftp_root = strtr(BOARDDIR, array($_POST['ftp_path'] => '')); |
| 768 | 863 | if (substr($ftp_root, -1) == '/' && ($_POST['ftp_path'] == '' || $_POST['ftp_path'][0] == '/')) |
| 769 | - $ftp_root = substr($ftp_root, 0, -1); |
|
| 864 | + { |
|
| 865 | + $ftp_root = substr($ftp_root, 0, -1); |
|
| 866 | + } |
|
| 867 | + } |
|
| 868 | + else { |
|
| 869 | + $ftp_root = BOARDDIR; |
|
| 770 | 870 | } |
| 771 | - else |
|
| 772 | - $ftp_root = BOARDDIR; |
|
| 773 | 871 | |
| 774 | 872 | $_SESSION['pack_ftp'] = array( |
| 775 | 873 | 'server' => $_POST['ftp_server'], |
@@ -781,7 +879,9 @@ discard block |
||
| 781 | 879 | ); |
| 782 | 880 | |
| 783 | 881 | if (!isset($modSettings['package_path']) || $modSettings['package_path'] != $_POST['ftp_path']) |
| 784 | - updateSettings(array('package_path' => $_POST['ftp_path'])); |
|
| 882 | + { |
|
| 883 | + updateSettings(array('package_path' => $_POST['ftp_path'])); |
|
| 884 | + } |
|
| 785 | 885 | |
| 786 | 886 | $files = packageRequireFTP($destination_url, $files, $return); |
| 787 | 887 | } |
@@ -813,7 +913,9 @@ discard block |
||
| 813 | 913 | |
| 814 | 914 | // Mayday! That action doesn't exist!! |
| 815 | 915 | if (empty($packageXML) || !$packageXML->exists($method)) |
| 816 | - return array(); |
|
| 916 | + { |
|
| 917 | + return array(); |
|
| 918 | + } |
|
| 817 | 919 | |
| 818 | 920 | // We haven't found the package script yet... |
| 819 | 921 | $script = false; |
@@ -821,7 +923,9 @@ discard block |
||
| 821 | 923 | |
| 822 | 924 | // Emulation support... |
| 823 | 925 | if (!empty($_SESSION['version_emulate'])) |
| 824 | - $the_version = $_SESSION['version_emulate']; |
|
| 926 | + { |
|
| 927 | + $the_version = $_SESSION['version_emulate']; |
|
| 928 | + } |
|
| 825 | 929 | |
| 826 | 930 | // Single package emulation |
| 827 | 931 | if (!empty($_REQUEST['ve']) && !empty($_REQUEST['package'])) |
@@ -830,7 +934,9 @@ discard block |
||
| 830 | 934 | $_SESSION['single_version_emulate'][$_REQUEST['package']] = $the_version; |
| 831 | 935 | } |
| 832 | 936 | if (!empty($_REQUEST['package']) && (!empty($_SESSION['single_version_emulate'][$_REQUEST['package']]))) |
| 833 | - $the_version = $_SESSION['single_version_emulate'][$_REQUEST['package']]; |
|
| 937 | + { |
|
| 938 | + $the_version = $_SESSION['single_version_emulate'][$_REQUEST['package']]; |
|
| 939 | + } |
|
| 834 | 940 | |
| 835 | 941 | // Get all the versions of this method and find the right one. |
| 836 | 942 | $these_methods = $packageXML->set($method); |
@@ -841,7 +947,9 @@ discard block |
||
| 841 | 947 | { |
| 842 | 948 | // Don't keep going if this won't work for this version. |
| 843 | 949 | if (!matchPackageVersion($the_version, $this_method->fetch('@for'))) |
| 844 | - continue; |
|
| 950 | + { |
|
| 951 | + continue; |
|
| 952 | + } |
|
| 845 | 953 | } |
| 846 | 954 | |
| 847 | 955 | // Upgrades may go from a certain old version of the mod. |
@@ -849,7 +957,9 @@ discard block |
||
| 849 | 957 | { |
| 850 | 958 | // Well, this is for the wrong old version... |
| 851 | 959 | if (!matchPackageVersion($previous_version, $this_method->fetch('@from'))) |
| 852 | - continue; |
|
| 960 | + { |
|
| 961 | + continue; |
|
| 962 | + } |
|
| 853 | 963 | } |
| 854 | 964 | |
| 855 | 965 | // We've found it! |
@@ -859,7 +969,9 @@ discard block |
||
| 859 | 969 | |
| 860 | 970 | // Bad news, a matching script wasn't found! |
| 861 | 971 | if ($script === false) |
| 862 | - return array(); |
|
| 972 | + { |
|
| 973 | + return array(); |
|
| 974 | + } |
|
| 863 | 975 | |
| 864 | 976 | // Find all the actions in this method - in theory, these should only be allowed actions. (* means all.) |
| 865 | 977 | $actions = $script->set('*'); |
@@ -895,7 +1007,9 @@ discard block |
||
| 895 | 1007 | { |
| 896 | 1008 | // In case the user put the blocks in the wrong order. |
| 897 | 1009 | if (isset($context[$type]['selected']) && $context[$type]['selected'] == 'default') |
| 898 | - $context[$type][] = 'default'; |
|
| 1010 | + { |
|
| 1011 | + $context[$type][] = 'default'; |
|
| 1012 | + } |
|
| 899 | 1013 | |
| 900 | 1014 | $context[$type]['selected'] = htmlspecialchars($action->fetch('@lang'), ENT_COMPAT, 'UTF-8'); |
| 901 | 1015 | } |
@@ -915,8 +1029,9 @@ discard block |
||
| 915 | 1029 | $context[$type][] = 'default'; |
| 916 | 1030 | continue; |
| 917 | 1031 | } |
| 918 | - else |
|
| 919 | - $context[$type]['selected'] = 'default'; |
|
| 1032 | + else { |
|
| 1033 | + $context[$type]['selected'] = 'default'; |
|
| 1034 | + } |
|
| 920 | 1035 | } |
| 921 | 1036 | } |
| 922 | 1037 | |
@@ -927,8 +1042,9 @@ discard block |
||
| 927 | 1042 | package_put_contents($filename, $action->fetch('.')); |
| 928 | 1043 | $filename = strtr($filename, array($temp_path => '')); |
| 929 | 1044 | } |
| 930 | - else |
|
| 931 | - $filename = $action->fetch('.'); |
|
| 1045 | + else { |
|
| 1046 | + $filename = $action->fetch('.'); |
|
| 1047 | + } |
|
| 932 | 1048 | |
| 933 | 1049 | $return[] = array( |
| 934 | 1050 | 'type' => $actionType, |
@@ -964,7 +1080,9 @@ discard block |
||
| 964 | 1080 | $url = addProtocol($url, array('http://', 'https://')); |
| 965 | 1081 | |
| 966 | 1082 | if (strlen($url) < 8) |
| 967 | - $url = ''; |
|
| 1083 | + { |
|
| 1084 | + $url = ''; |
|
| 1085 | + } |
|
| 968 | 1086 | } |
| 969 | 1087 | |
| 970 | 1088 | $return[] = array( |
@@ -1034,7 +1152,9 @@ discard block |
||
| 1034 | 1152 | { |
| 1035 | 1153 | $temp = $this_action['destination']; |
| 1036 | 1154 | while (!file_exists($temp) && strlen($temp) > 1) |
| 1037 | - $temp = dirname($temp); |
|
| 1155 | + { |
|
| 1156 | + $temp = dirname($temp); |
|
| 1157 | + } |
|
| 1038 | 1158 | |
| 1039 | 1159 | $return[] = array( |
| 1040 | 1160 | 'type' => 'chmod', |
@@ -1049,7 +1169,9 @@ discard block |
||
| 1049 | 1169 | { |
| 1050 | 1170 | $temp = dirname($this_action['destination']); |
| 1051 | 1171 | while (!file_exists($temp) && strlen($temp) > 1) |
| 1052 | - $temp = dirname($temp); |
|
| 1172 | + { |
|
| 1173 | + $temp = dirname($temp); |
|
| 1174 | + } |
|
| 1053 | 1175 | |
| 1054 | 1176 | $return[] = array( |
| 1055 | 1177 | 'type' => 'chmod', |
@@ -1058,10 +1180,12 @@ discard block |
||
| 1058 | 1180 | } |
| 1059 | 1181 | |
| 1060 | 1182 | if (!is_writable($this_action['destination']) && (file_exists($this_action['destination']) || !is_writable(dirname($this_action['destination'])))) |
| 1061 | - $return[] = array( |
|
| 1183 | + { |
|
| 1184 | + $return[] = array( |
|
| 1062 | 1185 | 'type' => 'chmod', |
| 1063 | 1186 | 'filename' => $this_action['destination'] |
| 1064 | 1187 | ); |
| 1188 | + } |
|
| 1065 | 1189 | } |
| 1066 | 1190 | elseif ($actionType == 'require-dir') |
| 1067 | 1191 | { |
@@ -1069,7 +1193,9 @@ discard block |
||
| 1069 | 1193 | { |
| 1070 | 1194 | $temp = $this_action['destination']; |
| 1071 | 1195 | while (!file_exists($temp) && strlen($temp) > 1) |
| 1072 | - $temp = dirname($temp); |
|
| 1196 | + { |
|
| 1197 | + $temp = dirname($temp); |
|
| 1198 | + } |
|
| 1073 | 1199 | |
| 1074 | 1200 | $return[] = array( |
| 1075 | 1201 | 'type' => 'chmod', |
@@ -1080,13 +1206,17 @@ discard block |
||
| 1080 | 1206 | elseif ($actionType == 'require-file') |
| 1081 | 1207 | { |
| 1082 | 1208 | if ($action->exists('@theme')) |
| 1083 | - $this_action['theme_action'] = $action->fetch('@theme'); |
|
| 1209 | + { |
|
| 1210 | + $this_action['theme_action'] = $action->fetch('@theme'); |
|
| 1211 | + } |
|
| 1084 | 1212 | |
| 1085 | 1213 | if (!mktree(dirname($this_action['destination']), false)) |
| 1086 | 1214 | { |
| 1087 | 1215 | $temp = dirname($this_action['destination']); |
| 1088 | 1216 | while (!file_exists($temp) && strlen($temp) > 1) |
| 1089 | - $temp = dirname($temp); |
|
| 1217 | + { |
|
| 1218 | + $temp = dirname($temp); |
|
| 1219 | + } |
|
| 1090 | 1220 | |
| 1091 | 1221 | $return[] = array( |
| 1092 | 1222 | 'type' => 'chmod', |
@@ -1095,10 +1225,12 @@ discard block |
||
| 1095 | 1225 | } |
| 1096 | 1226 | |
| 1097 | 1227 | if (!is_writable($this_action['destination']) && (file_exists($this_action['destination']) || !is_writable(dirname($this_action['destination'])))) |
| 1098 | - $return[] = array( |
|
| 1228 | + { |
|
| 1229 | + $return[] = array( |
|
| 1099 | 1230 | 'type' => 'chmod', |
| 1100 | 1231 | 'filename' => $this_action['destination'] |
| 1101 | 1232 | ); |
| 1233 | + } |
|
| 1102 | 1234 | } |
| 1103 | 1235 | elseif ($actionType == 'move-dir' || $actionType == 'move-file') |
| 1104 | 1236 | { |
@@ -1106,7 +1238,9 @@ discard block |
||
| 1106 | 1238 | { |
| 1107 | 1239 | $temp = dirname($this_action['destination']); |
| 1108 | 1240 | while (!file_exists($temp) && strlen($temp) > 1) |
| 1109 | - $temp = dirname($temp); |
|
| 1241 | + { |
|
| 1242 | + $temp = dirname($temp); |
|
| 1243 | + } |
|
| 1110 | 1244 | |
| 1111 | 1245 | $return[] = array( |
| 1112 | 1246 | 'type' => 'chmod', |
@@ -1115,26 +1249,32 @@ discard block |
||
| 1115 | 1249 | } |
| 1116 | 1250 | |
| 1117 | 1251 | if (!is_writable($this_action['destination']) && (file_exists($this_action['destination']) || !is_writable(dirname($this_action['destination'])))) |
| 1118 | - $return[] = array( |
|
| 1252 | + { |
|
| 1253 | + $return[] = array( |
|
| 1119 | 1254 | 'type' => 'chmod', |
| 1120 | 1255 | 'filename' => $this_action['destination'] |
| 1121 | 1256 | ); |
| 1257 | + } |
|
| 1122 | 1258 | } |
| 1123 | 1259 | elseif ($actionType == 'remove-dir') |
| 1124 | 1260 | { |
| 1125 | 1261 | if (!is_writable($this_action['filename']) && file_exists($this_action['filename'])) |
| 1126 | - $return[] = array( |
|
| 1262 | + { |
|
| 1263 | + $return[] = array( |
|
| 1127 | 1264 | 'type' => 'chmod', |
| 1128 | 1265 | 'filename' => $this_action['filename'] |
| 1129 | 1266 | ); |
| 1267 | + } |
|
| 1130 | 1268 | } |
| 1131 | 1269 | elseif ($actionType == 'remove-file') |
| 1132 | 1270 | { |
| 1133 | 1271 | if (!is_writable($this_action['filename']) && file_exists($this_action['filename'])) |
| 1134 | - $return[] = array( |
|
| 1272 | + { |
|
| 1273 | + $return[] = array( |
|
| 1135 | 1274 | 'type' => 'chmod', |
| 1136 | 1275 | 'filename' => $this_action['filename'] |
| 1137 | 1276 | ); |
| 1277 | + } |
|
| 1138 | 1278 | } |
| 1139 | 1279 | } |
| 1140 | 1280 | else |
@@ -1163,7 +1303,9 @@ discard block |
||
| 1163 | 1303 | |
| 1164 | 1304 | // Only testing - just return a list of things to be done. |
| 1165 | 1305 | if ($testing_only) |
| 1166 | - return $return; |
|
| 1306 | + { |
|
| 1307 | + return $return; |
|
| 1308 | + } |
|
| 1167 | 1309 | |
| 1168 | 1310 | umask(0); |
| 1169 | 1311 | |
@@ -1172,36 +1314,48 @@ discard block |
||
| 1172 | 1314 | foreach ($return as $action) |
| 1173 | 1315 | { |
| 1174 | 1316 | if (in_array($action['type'], array('modification', 'code', 'database', 'redirect', 'hook', 'credits'))) |
| 1175 | - $not_done[] = $action; |
|
| 1317 | + { |
|
| 1318 | + $not_done[] = $action; |
|
| 1319 | + } |
|
| 1176 | 1320 | |
| 1177 | 1321 | if ($action['type'] == 'create-dir') |
| 1178 | 1322 | { |
| 1179 | 1323 | if (!mktree($action['destination'], 0755) || !is_writable($action['destination'])) |
| 1180 | - $failure |= !mktree($action['destination'], 0777); |
|
| 1324 | + { |
|
| 1325 | + $failure |= !mktree($action['destination'], 0777); |
|
| 1326 | + } |
|
| 1181 | 1327 | } |
| 1182 | 1328 | elseif ($action['type'] == 'create-file') |
| 1183 | 1329 | { |
| 1184 | 1330 | if (!mktree(dirname($action['destination']), 0755) || !is_writable(dirname($action['destination']))) |
| 1185 | - $failure |= !mktree(dirname($action['destination']), 0777); |
|
| 1331 | + { |
|
| 1332 | + $failure |= !mktree(dirname($action['destination']), 0777); |
|
| 1333 | + } |
|
| 1186 | 1334 | |
| 1187 | 1335 | // Create an empty file. |
| 1188 | 1336 | package_put_contents($action['destination'], package_get_contents($action['source']), $testing_only); |
| 1189 | 1337 | |
| 1190 | 1338 | if (!file_exists($action['destination'])) |
| 1191 | - $failure = true; |
|
| 1339 | + { |
|
| 1340 | + $failure = true; |
|
| 1341 | + } |
|
| 1192 | 1342 | } |
| 1193 | 1343 | elseif ($action['type'] == 'require-dir') |
| 1194 | 1344 | { |
| 1195 | 1345 | copytree($action['source'], $action['destination']); |
| 1196 | 1346 | // Any other theme folders? |
| 1197 | 1347 | if (!empty($context['theme_copies']) && !empty($context['theme_copies'][$action['type']][$action['destination']])) |
| 1198 | - foreach ($context['theme_copies'][$action['type']][$action['destination']] as $theme_destination) |
|
| 1348 | + { |
|
| 1349 | + foreach ($context['theme_copies'][$action['type']][$action['destination']] as $theme_destination) |
|
| 1199 | 1350 | copytree($action['source'], $theme_destination); |
| 1351 | + } |
|
| 1200 | 1352 | } |
| 1201 | 1353 | elseif ($action['type'] == 'require-file') |
| 1202 | 1354 | { |
| 1203 | 1355 | if (!mktree(dirname($action['destination']), 0755) || !is_writable(dirname($action['destination']))) |
| 1204 | - $failure |= !mktree(dirname($action['destination']), 0777); |
|
| 1356 | + { |
|
| 1357 | + $failure |= !mktree(dirname($action['destination']), 0777); |
|
| 1358 | + } |
|
| 1205 | 1359 | |
| 1206 | 1360 | package_put_contents($action['destination'], package_get_contents($action['source']), $testing_only); |
| 1207 | 1361 | |
@@ -1209,10 +1363,12 @@ discard block |
||
| 1209 | 1363 | |
| 1210 | 1364 | // Any other theme files? |
| 1211 | 1365 | if (!empty($context['theme_copies']) && !empty($context['theme_copies'][$action['type']][$action['destination']])) |
| 1212 | - foreach ($context['theme_copies'][$action['type']][$action['destination']] as $theme_destination) |
|
| 1366 | + { |
|
| 1367 | + foreach ($context['theme_copies'][$action['type']][$action['destination']] as $theme_destination) |
|
| 1213 | 1368 | { |
| 1214 | 1369 | if (!mktree(dirname($theme_destination), 0755) || !is_writable(dirname($theme_destination))) |
| 1215 | 1370 | $failure |= !mktree(dirname($theme_destination), 0777); |
| 1371 | + } |
|
| 1216 | 1372 | |
| 1217 | 1373 | package_put_contents($theme_destination, package_get_contents($action['source']), $testing_only); |
| 1218 | 1374 | |
@@ -1222,14 +1378,18 @@ discard block |
||
| 1222 | 1378 | elseif ($action['type'] == 'move-file') |
| 1223 | 1379 | { |
| 1224 | 1380 | if (!mktree(dirname($action['destination']), 0755) || !is_writable(dirname($action['destination']))) |
| 1225 | - $failure |= !mktree(dirname($action['destination']), 0777); |
|
| 1381 | + { |
|
| 1382 | + $failure |= !mktree(dirname($action['destination']), 0777); |
|
| 1383 | + } |
|
| 1226 | 1384 | |
| 1227 | 1385 | $failure |= !rename($action['source'], $action['destination']); |
| 1228 | 1386 | } |
| 1229 | 1387 | elseif ($action['type'] == 'move-dir') |
| 1230 | 1388 | { |
| 1231 | 1389 | if (!mktree($action['destination'], 0755) || !is_writable($action['destination'])) |
| 1232 | - $failure |= !mktree($action['destination'], 0777); |
|
| 1390 | + { |
|
| 1391 | + $failure |= !mktree($action['destination'], 0777); |
|
| 1392 | + } |
|
| 1233 | 1393 | |
| 1234 | 1394 | $failure |= !rename($action['source'], $action['destination']); |
| 1235 | 1395 | } |
@@ -1239,8 +1399,10 @@ discard block |
||
| 1239 | 1399 | |
| 1240 | 1400 | // Any other theme folders? |
| 1241 | 1401 | if (!empty($context['theme_copies']) && !empty($context['theme_copies'][$action['type']][$action['filename']])) |
| 1242 | - foreach ($context['theme_copies'][$action['type']][$action['filename']] as $theme_destination) |
|
| 1402 | + { |
|
| 1403 | + foreach ($context['theme_copies'][$action['type']][$action['filename']] as $theme_destination) |
|
| 1243 | 1404 | deltree($theme_destination); |
| 1405 | + } |
|
| 1244 | 1406 | } |
| 1245 | 1407 | elseif ($action['type'] == 'remove-file') |
| 1246 | 1408 | { |
@@ -1251,16 +1413,20 @@ discard block |
||
| 1251 | 1413 | $failure |= !unlink($action['filename']); |
| 1252 | 1414 | } |
| 1253 | 1415 | // The file that was supposed to be deleted couldn't be found. |
| 1254 | - else |
|
| 1255 | - $failure = true; |
|
| 1416 | + else { |
|
| 1417 | + $failure = true; |
|
| 1418 | + } |
|
| 1256 | 1419 | |
| 1257 | 1420 | // Any other theme folders? |
| 1258 | 1421 | if (!empty($context['theme_copies']) && !empty($context['theme_copies'][$action['type']][$action['filename']])) |
| 1259 | - foreach ($context['theme_copies'][$action['type']][$action['filename']] as $theme_destination) |
|
| 1422 | + { |
|
| 1423 | + foreach ($context['theme_copies'][$action['type']][$action['filename']] as $theme_destination) |
|
| 1260 | 1424 | if (file_exists($theme_destination)) |
| 1261 | 1425 | $failure |= !unlink($theme_destination); |
| 1262 | - else |
|
| 1263 | - $failure = true; |
|
| 1426 | + } |
|
| 1427 | + else { |
|
| 1428 | + $failure = true; |
|
| 1429 | + } |
|
| 1264 | 1430 | } |
| 1265 | 1431 | } |
| 1266 | 1432 | |
@@ -1285,7 +1451,9 @@ discard block |
||
| 1285 | 1451 | static $near_version = 0; |
| 1286 | 1452 | |
| 1287 | 1453 | if ($reset) |
| 1288 | - $near_version = 0; |
|
| 1454 | + { |
|
| 1455 | + $near_version = 0; |
|
| 1456 | + } |
|
| 1289 | 1457 | |
| 1290 | 1458 | // Normalize the $versions |
| 1291 | 1459 | $versions = explode(',', str_replace(' ', '', strtolower($versions))); |
@@ -1293,22 +1461,30 @@ discard block |
||
| 1293 | 1461 | // If it is not ElkArte, let's just give up |
| 1294 | 1462 | list ($the_brand,) = explode(' ', FORUM_VERSION, 2); |
| 1295 | 1463 | if ($the_brand != 'ElkArte') |
| 1296 | - return false; |
|
| 1464 | + { |
|
| 1465 | + return false; |
|
| 1466 | + } |
|
| 1297 | 1467 | |
| 1298 | 1468 | // Loop through each version, save the highest we can find |
| 1299 | 1469 | foreach ($versions as $for) |
| 1300 | 1470 | { |
| 1301 | 1471 | // Adjust for those wild cards |
| 1302 | 1472 | if (strpos($for, '*') !== false) |
| 1303 | - $for = str_replace('*', '0', $for) . '-' . str_replace('*', '999', $for); |
|
| 1473 | + { |
|
| 1474 | + $for = str_replace('*', '0', $for) . '-' . str_replace('*', '999', $for); |
|
| 1475 | + } |
|
| 1304 | 1476 | |
| 1305 | 1477 | // If we have a range, grab the lower value, done this way so it looks normal-er to the user e.g. 1.0 vs 1.0.99 |
| 1306 | 1478 | if (strpos($for, '-') !== false) |
| 1307 | - list ($for,) = explode('-', $for); |
|
| 1479 | + { |
|
| 1480 | + list ($for,) = explode('-', $for); |
|
| 1481 | + } |
|
| 1308 | 1482 | |
| 1309 | 1483 | // Do the compare, if the for is greater, than what we have but not greater than what we are running ..... |
| 1310 | 1484 | if (compareVersions($near_version, $for) === -1 && compareVersions($for, $the_version) !== 1) |
| 1311 | - $near_version = $for; |
|
| 1485 | + { |
|
| 1486 | + $near_version = $for; |
|
| 1487 | + } |
|
| 1312 | 1488 | } |
| 1313 | 1489 | |
| 1314 | 1490 | return !empty($near_version) ? $near_version : false; |
@@ -1334,14 +1510,18 @@ discard block |
||
| 1334 | 1510 | |
| 1335 | 1511 | // Perhaps we do accept anything? |
| 1336 | 1512 | if (in_array('all', $versions)) |
| 1337 | - return true; |
|
| 1513 | + { |
|
| 1514 | + return true; |
|
| 1515 | + } |
|
| 1338 | 1516 | |
| 1339 | 1517 | // Loop through each version. |
| 1340 | 1518 | foreach ($versions as $for) |
| 1341 | 1519 | { |
| 1342 | 1520 | // Wild card spotted? |
| 1343 | 1521 | if (strpos($for, '*') !== false) |
| 1344 | - $for = str_replace('*', '0dev0', $for) . '-' . str_replace('*', '999', $for); |
|
| 1522 | + { |
|
| 1523 | + $for = str_replace('*', '0dev0', $for) . '-' . str_replace('*', '999', $for); |
|
| 1524 | + } |
|
| 1345 | 1525 | |
| 1346 | 1526 | // Do we have a range? |
| 1347 | 1527 | if (strpos($for, '-') !== false) |
@@ -1350,11 +1530,15 @@ discard block |
||
| 1350 | 1530 | |
| 1351 | 1531 | // Compare the version against lower and upper bounds. |
| 1352 | 1532 | if (compareVersions($version, $lower) > -1 && compareVersions($version, $upper) < 1) |
| 1353 | - return true; |
|
| 1533 | + { |
|
| 1534 | + return true; |
|
| 1535 | + } |
|
| 1354 | 1536 | } |
| 1355 | 1537 | // Otherwise check if they are equal... |
| 1356 | 1538 | elseif (compareVersions($version, $for) === 0) |
| 1357 | - return true; |
|
| 1539 | + { |
|
| 1540 | + return true; |
|
| 1541 | + } |
|
| 1358 | 1542 | } |
| 1359 | 1543 | |
| 1360 | 1544 | return false; |
@@ -1397,11 +1581,15 @@ discard block |
||
| 1397 | 1581 | |
| 1398 | 1582 | // Are they the same, perhaps? |
| 1399 | 1583 | if ($versions[1] === $versions[2]) |
| 1400 | - return 0; |
|
| 1584 | + { |
|
| 1585 | + return 0; |
|
| 1586 | + } |
|
| 1401 | 1587 | |
| 1402 | 1588 | // Get version numbering categories... |
| 1403 | 1589 | if (!isset($categories)) |
| 1404 | - $categories = array_keys($versions[1]); |
|
| 1590 | + { |
|
| 1591 | + $categories = array_keys($versions[1]); |
|
| 1592 | + } |
|
| 1405 | 1593 | |
| 1406 | 1594 | // Loop through each category. |
| 1407 | 1595 | foreach ($categories as $category) |
@@ -1412,12 +1600,17 @@ discard block |
||
| 1412 | 1600 | // Dev builds are a problematic exception. |
| 1413 | 1601 | // (stable) dev < (stable) but (unstable) dev = (unstable) |
| 1414 | 1602 | if ($category == 'type') |
| 1415 | - return $versions[1][$category] > $versions[2][$category] ? ($versions[1]['dev'] ? -1 : 1) : ($versions[2]['dev'] ? 1 : -1); |
|
| 1603 | + { |
|
| 1604 | + return $versions[1][$category] > $versions[2][$category] ? ($versions[1]['dev'] ? -1 : 1) : ($versions[2]['dev'] ? 1 : -1); |
|
| 1605 | + } |
|
| 1416 | 1606 | elseif ($category == 'dev') |
| 1417 | - return $versions[1]['dev'] ? ($versions[2]['type'] == 'stable' ? -1 : 0) : ($versions[1]['type'] == 'stable' ? 1 : 0); |
|
| 1607 | + { |
|
| 1608 | + return $versions[1]['dev'] ? ($versions[2]['type'] == 'stable' ? -1 : 0) : ($versions[1]['type'] == 'stable' ? 1 : 0); |
|
| 1609 | + } |
|
| 1418 | 1610 | // Otherwise a simple comparison. |
| 1419 | - else |
|
| 1420 | - return $versions[1][$category] > $versions[2][$category] ? 1 : -1; |
|
| 1611 | + else { |
|
| 1612 | + return $versions[1][$category] > $versions[2][$category] ? 1 : -1; |
|
| 1613 | + } |
|
| 1421 | 1614 | } |
| 1422 | 1615 | } |
| 1423 | 1616 | |
@@ -1437,7 +1630,9 @@ discard block |
||
| 1437 | 1630 | global $modSettings, $settings, $temp_path; |
| 1438 | 1631 | |
| 1439 | 1632 | if (empty($path)) |
| 1440 | - return ''; |
|
| 1633 | + { |
|
| 1634 | + return ''; |
|
| 1635 | + } |
|
| 1441 | 1636 | |
| 1442 | 1637 | $dirs = array( |
| 1443 | 1638 | '\\' => '/', |
@@ -1457,14 +1652,20 @@ discard block |
||
| 1457 | 1652 | |
| 1458 | 1653 | // Do we parse in a package directory? |
| 1459 | 1654 | if (!empty($temp_path)) |
| 1460 | - $dirs['PACKAGE'] = $temp_path; |
|
| 1655 | + { |
|
| 1656 | + $dirs['PACKAGE'] = $temp_path; |
|
| 1657 | + } |
|
| 1461 | 1658 | |
| 1462 | 1659 | if (strlen($path) == 0) |
| 1463 | - trigger_error('parse_path(): There should never be an empty filename', E_USER_ERROR); |
|
| 1660 | + { |
|
| 1661 | + trigger_error('parse_path(): There should never be an empty filename', E_USER_ERROR); |
|
| 1662 | + } |
|
| 1464 | 1663 | |
| 1465 | 1664 | // Check if they are using some old software install paths |
| 1466 | 1665 | if (strpos($path, '$') === 0 && isset($dirs[strtoupper(substr($path, 1))])) |
| 1467 | - $path = strtoupper(substr($path, 1)); |
|
| 1666 | + { |
|
| 1667 | + $path = strtoupper(substr($path, 1)); |
|
| 1668 | + } |
|
| 1468 | 1669 | |
| 1469 | 1670 | return strtr($path, $dirs); |
| 1470 | 1671 | } |
@@ -1487,7 +1688,9 @@ discard block |
||
| 1487 | 1688 | global $package_ftp; |
| 1488 | 1689 | |
| 1489 | 1690 | if (!file_exists($dir)) |
| 1490 | - return; |
|
| 1691 | + { |
|
| 1692 | + return; |
|
| 1693 | + } |
|
| 1491 | 1694 | |
| 1492 | 1695 | // Read all the files in the directory |
| 1493 | 1696 | try |
@@ -1497,7 +1700,9 @@ discard block |
||
| 1497 | 1700 | { |
| 1498 | 1701 | // Recursively dive in to each directory looking for files to delete |
| 1499 | 1702 | if ($entryname->isDir()) |
| 1500 | - deltree($entryname->getPathname()); |
|
| 1703 | + { |
|
| 1704 | + deltree($entryname->getPathname()); |
|
| 1705 | + } |
|
| 1501 | 1706 | // A file, delete it by any means necessary |
| 1502 | 1707 | else |
| 1503 | 1708 | { |
@@ -1507,14 +1712,18 @@ discard block |
||
| 1507 | 1712 | $ftp_file = strtr($entryname->getPathname(), array($_SESSION['pack_ftp']['root'] => '')); |
| 1508 | 1713 | |
| 1509 | 1714 | if (!$entryname->isWritable()) |
| 1510 | - $package_ftp->chmod($ftp_file, 0777); |
|
| 1715 | + { |
|
| 1716 | + $package_ftp->chmod($ftp_file, 0777); |
|
| 1717 | + } |
|
| 1511 | 1718 | |
| 1512 | 1719 | $package_ftp->unlink($ftp_file); |
| 1513 | 1720 | } |
| 1514 | 1721 | else |
| 1515 | 1722 | { |
| 1516 | 1723 | if (!$entryname->isWritable()) |
| 1517 | - elk_chmod($entryname->getPathname(), 0777); |
|
| 1724 | + { |
|
| 1725 | + elk_chmod($entryname->getPathname(), 0777); |
|
| 1726 | + } |
|
| 1518 | 1727 | |
| 1519 | 1728 | @unlink($entryname->getPathname()); |
| 1520 | 1729 | } |
@@ -1528,8 +1737,10 @@ discard block |
||
| 1528 | 1737 | { |
| 1529 | 1738 | $ftp_file = strtr($dir, array($_SESSION['pack_ftp']['root'] => '')); |
| 1530 | 1739 | if (!is_writable($dir . '/')) |
| 1531 | - $package_ftp->chmod($ftp_file, 0777); |
|
| 1532 | - $package_ftp->unlink($ftp_file); |
|
| 1740 | + { |
|
| 1741 | + $package_ftp->chmod($ftp_file, 0777); |
|
| 1742 | + } |
|
| 1743 | + $package_ftp->unlink($ftp_file); |
|
| 1533 | 1744 | } |
| 1534 | 1745 | |
| 1535 | 1746 | return; |
@@ -1543,14 +1754,18 @@ discard block |
||
| 1543 | 1754 | $ftp_file = strtr($dir, array($_SESSION['pack_ftp']['root'] => '')); |
| 1544 | 1755 | |
| 1545 | 1756 | if (!is_writable($dir . '/')) |
| 1546 | - $package_ftp->chmod($ftp_file, 0777); |
|
| 1757 | + { |
|
| 1758 | + $package_ftp->chmod($ftp_file, 0777); |
|
| 1759 | + } |
|
| 1547 | 1760 | |
| 1548 | 1761 | $package_ftp->unlink($ftp_file); |
| 1549 | 1762 | } |
| 1550 | 1763 | else |
| 1551 | 1764 | { |
| 1552 | 1765 | if (!is_writable($dir)) |
| 1553 | - elk_chmod($dir, 0777); |
|
| 1766 | + { |
|
| 1767 | + elk_chmod($dir, 0777); |
|
| 1768 | + } |
|
| 1554 | 1769 | |
| 1555 | 1770 | @rmdir($dir); |
| 1556 | 1771 | } |
@@ -1578,9 +1793,12 @@ discard block |
||
| 1578 | 1793 | if (!is_writable($strPath) && $mode !== false) |
| 1579 | 1794 | { |
| 1580 | 1795 | if (isset($package_ftp)) |
| 1581 | - $package_ftp->chmod(strtr($strPath, array($_SESSION['pack_ftp']['root'] => '')), $mode); |
|
| 1582 | - else |
|
| 1583 | - elk_chmod($strPath, $mode); |
|
| 1796 | + { |
|
| 1797 | + $package_ftp->chmod(strtr($strPath, array($_SESSION['pack_ftp']['root'] => '')), $mode); |
|
| 1798 | + } |
|
| 1799 | + else { |
|
| 1800 | + elk_chmod($strPath, $mode); |
|
| 1801 | + } |
|
| 1584 | 1802 | } |
| 1585 | 1803 | |
| 1586 | 1804 | // See if we can open it for access, return the result |
@@ -1590,26 +1808,34 @@ discard block |
||
| 1590 | 1808 | closedir($test); |
| 1591 | 1809 | return is_writable($strPath); |
| 1592 | 1810 | } |
| 1593 | - else |
|
| 1594 | - return false; |
|
| 1811 | + else { |
|
| 1812 | + return false; |
|
| 1813 | + } |
|
| 1595 | 1814 | } |
| 1596 | 1815 | |
| 1597 | 1816 | // Is this an invalid path and/or we can't make the directory? |
| 1598 | 1817 | if ($strPath == dirname($strPath) || !mktree(dirname($strPath), $mode)) |
| 1599 | - return false; |
|
| 1818 | + { |
|
| 1819 | + return false; |
|
| 1820 | + } |
|
| 1600 | 1821 | |
| 1601 | 1822 | // Is the dir writable and do we have permission to attempt to make it so |
| 1602 | 1823 | if (!is_writable(dirname($strPath)) && $mode !== false) |
| 1603 | 1824 | { |
| 1604 | 1825 | if (isset($package_ftp)) |
| 1605 | - $package_ftp->chmod(dirname(strtr($strPath, array($_SESSION['pack_ftp']['root'] => ''))), $mode); |
|
| 1606 | - else |
|
| 1607 | - elk_chmod(dirname($strPath), $mode); |
|
| 1826 | + { |
|
| 1827 | + $package_ftp->chmod(dirname(strtr($strPath, array($_SESSION['pack_ftp']['root'] => ''))), $mode); |
|
| 1828 | + } |
|
| 1829 | + else { |
|
| 1830 | + elk_chmod(dirname($strPath), $mode); |
|
| 1831 | + } |
|
| 1608 | 1832 | } |
| 1609 | 1833 | |
| 1610 | 1834 | // Return an ftp control if using FTP |
| 1611 | 1835 | if ($mode !== false && isset($package_ftp)) |
| 1612 | - return $package_ftp->create_dir(strtr($strPath, array($_SESSION['pack_ftp']['root'] => ''))); |
|
| 1836 | + { |
|
| 1837 | + return $package_ftp->create_dir(strtr($strPath, array($_SESSION['pack_ftp']['root'] => ''))); |
|
| 1838 | + } |
|
| 1613 | 1839 | // Can't change the mode so just return the current availability |
| 1614 | 1840 | elseif ($mode === false) |
| 1615 | 1841 | { |
@@ -1619,8 +1845,9 @@ discard block |
||
| 1619 | 1845 | closedir($test); |
| 1620 | 1846 | return true; |
| 1621 | 1847 | } |
| 1622 | - else |
|
| 1623 | - return false; |
|
| 1848 | + else { |
|
| 1849 | + return false; |
|
| 1850 | + } |
|
| 1624 | 1851 | } |
| 1625 | 1852 | // Only one choice left and thats to try and make a directory |
| 1626 | 1853 | else |
@@ -1634,8 +1861,9 @@ discard block |
||
| 1634 | 1861 | closedir($test); |
| 1635 | 1862 | return true; |
| 1636 | 1863 | } |
| 1637 | - else |
|
| 1638 | - return false; |
|
| 1864 | + else { |
|
| 1865 | + return false; |
|
| 1866 | + } |
|
| 1639 | 1867 | } |
| 1640 | 1868 | } |
| 1641 | 1869 | |
@@ -1653,39 +1881,58 @@ discard block |
||
| 1653 | 1881 | global $package_ftp; |
| 1654 | 1882 | |
| 1655 | 1883 | if (!file_exists($destination) || !is_writable($destination)) |
| 1656 | - mktree($destination, 0755); |
|
| 1884 | + { |
|
| 1885 | + mktree($destination, 0755); |
|
| 1886 | + } |
|
| 1657 | 1887 | |
| 1658 | 1888 | if (!is_writable($destination)) |
| 1659 | - mktree($destination, 0777); |
|
| 1889 | + { |
|
| 1890 | + mktree($destination, 0777); |
|
| 1891 | + } |
|
| 1660 | 1892 | |
| 1661 | 1893 | $current_dir = opendir($source); |
| 1662 | 1894 | if ($current_dir === false) |
| 1663 | - return; |
|
| 1895 | + { |
|
| 1896 | + return; |
|
| 1897 | + } |
|
| 1664 | 1898 | |
| 1665 | 1899 | while ($entryname = readdir($current_dir)) |
| 1666 | 1900 | { |
| 1667 | 1901 | if (in_array($entryname, array('.', '..'))) |
| 1668 | - continue; |
|
| 1902 | + { |
|
| 1903 | + continue; |
|
| 1904 | + } |
|
| 1669 | 1905 | |
| 1670 | 1906 | if (isset($package_ftp)) |
| 1671 | - $ftp_file = strtr($destination . '/' . $entryname, array($_SESSION['pack_ftp']['root'] => '')); |
|
| 1907 | + { |
|
| 1908 | + $ftp_file = strtr($destination . '/' . $entryname, array($_SESSION['pack_ftp']['root'] => '')); |
|
| 1909 | + } |
|
| 1672 | 1910 | |
| 1673 | 1911 | if (is_file($source . '/' . $entryname)) |
| 1674 | 1912 | { |
| 1675 | 1913 | if (isset($package_ftp) && !file_exists($destination . '/' . $entryname)) |
| 1676 | - $package_ftp->create_file($ftp_file); |
|
| 1914 | + { |
|
| 1915 | + $package_ftp->create_file($ftp_file); |
|
| 1916 | + } |
|
| 1677 | 1917 | elseif (!file_exists($destination . '/' . $entryname)) |
| 1678 | - @touch($destination . '/' . $entryname); |
|
| 1918 | + { |
|
| 1919 | + @touch($destination . '/' . $entryname); |
|
| 1920 | + } |
|
| 1679 | 1921 | } |
| 1680 | 1922 | |
| 1681 | 1923 | package_chmod($destination . '/' . $entryname); |
| 1682 | 1924 | |
| 1683 | 1925 | if (is_dir($source . '/' . $entryname)) |
| 1684 | - copytree($source . '/' . $entryname, $destination . '/' . $entryname); |
|
| 1926 | + { |
|
| 1927 | + copytree($source . '/' . $entryname, $destination . '/' . $entryname); |
|
| 1928 | + } |
|
| 1685 | 1929 | elseif (file_exists($destination . '/' . $entryname)) |
| 1686 | - package_put_contents($destination . '/' . $entryname, package_get_contents($source . '/' . $entryname)); |
|
| 1687 | - else |
|
| 1688 | - copy($source . '/' . $entryname, $destination . '/' . $entryname); |
|
| 1930 | + { |
|
| 1931 | + package_put_contents($destination . '/' . $entryname, package_get_contents($source . '/' . $entryname)); |
|
| 1932 | + } |
|
| 1933 | + else { |
|
| 1934 | + copy($source . '/' . $entryname, $destination . '/' . $entryname); |
|
| 1935 | + } |
|
| 1689 | 1936 | } |
| 1690 | 1937 | |
| 1691 | 1938 | closedir($current_dir); |
@@ -1705,21 +1952,28 @@ discard block |
||
| 1705 | 1952 | |
| 1706 | 1953 | $dir = @dir($path . $sub_path); |
| 1707 | 1954 | if (!$dir) |
| 1708 | - return array(); |
|
| 1955 | + { |
|
| 1956 | + return array(); |
|
| 1957 | + } |
|
| 1709 | 1958 | |
| 1710 | 1959 | while ($entry = $dir->read()) |
| 1711 | 1960 | { |
| 1712 | 1961 | if ($entry == '.' || $entry == '..') |
| 1713 | - continue; |
|
| 1962 | + { |
|
| 1963 | + continue; |
|
| 1964 | + } |
|
| 1714 | 1965 | |
| 1715 | 1966 | if (is_dir($path . $sub_path . '/' . $entry)) |
| 1716 | - $data = array_merge($data, listtree($path, $sub_path . '/' . $entry)); |
|
| 1717 | - else |
|
| 1718 | - $data[] = array( |
|
| 1967 | + { |
|
| 1968 | + $data = array_merge($data, listtree($path, $sub_path . '/' . $entry)); |
|
| 1969 | + } |
|
| 1970 | + else { |
|
| 1971 | + $data[] = array( |
|
| 1719 | 1972 | 'filename' => $sub_path == '' ? $entry : $sub_path . '/' . $entry, |
| 1720 | 1973 | 'size' => filesize($path . $sub_path . '/' . $entry), |
| 1721 | 1974 | 'skipped' => false, |
| 1722 | 1975 | ); |
| 1976 | + } |
|
| 1723 | 1977 | } |
| 1724 | 1978 | $dir->close(); |
| 1725 | 1979 | |
@@ -1777,7 +2031,9 @@ discard block |
||
| 1777 | 2031 | // If this filename is relative, if so take a guess at what it should be. |
| 1778 | 2032 | $real_filename = $filename; |
| 1779 | 2033 | if (strpos($filename, 'themes') === 0) |
| 1780 | - $real_filename = BOARDDIR . '/' . $filename; |
|
| 2034 | + { |
|
| 2035 | + $real_filename = BOARDDIR . '/' . $filename; |
|
| 2036 | + } |
|
| 1781 | 2037 | |
| 1782 | 2038 | if (strpos($real_filename, $theme['theme_dir']) === 0) |
| 1783 | 2039 | { |
@@ -1797,7 +2053,9 @@ discard block |
||
| 1797 | 2053 | { |
| 1798 | 2054 | // Default is getting done anyway, so no need for involvement here. |
| 1799 | 2055 | if ($id == 1) |
| 1800 | - continue; |
|
| 2056 | + { |
|
| 2057 | + continue; |
|
| 2058 | + } |
|
| 1801 | 2059 | |
| 1802 | 2060 | // For every template, do we want it? Yea, no, maybe? |
| 1803 | 2061 | foreach ($template_changes[1] as $index => $template_file) |
@@ -1821,7 +2079,9 @@ discard block |
||
| 1821 | 2079 | |
| 1822 | 2080 | // Sometimes though, we have some additional files for other themes, if we have add them to the mix. |
| 1823 | 2081 | if (isset($custom_themes_add[$files_to_change[1]])) |
| 1824 | - $files_to_change += $custom_themes_add[$files_to_change[1]]; |
|
| 2082 | + { |
|
| 2083 | + $files_to_change += $custom_themes_add[$files_to_change[1]]; |
|
| 2084 | + } |
|
| 1825 | 2085 | |
| 1826 | 2086 | // Now, loop through all the files we're changing, and, well, change them ;) |
| 1827 | 2087 | foreach ($files_to_change as $theme => $working_file) |
@@ -1856,10 +2116,13 @@ discard block |
||
| 1856 | 2116 | } |
| 1857 | 2117 | // Okay, we're creating this file then...? |
| 1858 | 2118 | elseif (!file_exists($working_file)) |
| 1859 | - $working_data = ''; |
|
| 2119 | + { |
|
| 2120 | + $working_data = ''; |
|
| 2121 | + } |
|
| 1860 | 2122 | // Phew, it exists! Load 'er up! |
| 1861 | - else |
|
| 1862 | - $working_data = str_replace("\r", '', package_get_contents($working_file)); |
|
| 2123 | + else { |
|
| 2124 | + $working_data = str_replace("\r", '', package_get_contents($working_file)); |
|
| 2125 | + } |
|
| 1863 | 2126 | |
| 1864 | 2127 | $actions[] = array( |
| 1865 | 2128 | 'type' => 'opened', |
@@ -1881,7 +2144,8 @@ discard block |
||
| 1881 | 2144 | // Grab all search items of this operation (in most cases just 1). |
| 1882 | 2145 | $searches = $operation->set('search'); |
| 1883 | 2146 | foreach ($searches as $i => $search) |
| 1884 | - $actual_operation['searches'][] = array( |
|
| 2147 | + { |
|
| 2148 | + $actual_operation['searches'][] = array( |
|
| 1885 | 2149 | 'position' => $search->exists('@position') && in_array(trim($search->fetch('@position')), array('before', 'after', 'replace', 'end')) ? trim($search->fetch('@position')) : 'replace', |
| 1886 | 2150 | 'is_reg_exp' => $search->exists('@regexp') && trim($search->fetch('@regexp')) === 'true', |
| 1887 | 2151 | 'loose_whitespace' => $search->exists('@whitespace') && trim($search->fetch('@whitespace')) === 'loose', |
@@ -1890,6 +2154,7 @@ discard block |
||
| 1890 | 2154 | 'preg_search' => '', |
| 1891 | 2155 | 'preg_replace' => '', |
| 1892 | 2156 | ); |
| 2157 | + } |
|
| 1893 | 2158 | |
| 1894 | 2159 | // At least one search should be defined. |
| 1895 | 2160 | if (empty($actual_operation['searches'])) |
@@ -1914,12 +2179,14 @@ discard block |
||
| 1914 | 2179 | if ($search['is_reg_exp']) |
| 1915 | 2180 | { |
| 1916 | 2181 | if ($actual_operation['error'] === 'fatal') |
| 1917 | - $actions[] = array( |
|
| 2182 | + { |
|
| 2183 | + $actions[] = array( |
|
| 1918 | 2184 | 'type' => 'failure', |
| 1919 | 2185 | 'filename' => $working_file, |
| 1920 | 2186 | 'search' => $search['search'], |
| 1921 | 2187 | 'is_custom' => $theme > 1 ? $theme : 0, |
| 1922 | 2188 | ); |
| 2189 | + } |
|
| 1923 | 2190 | |
| 1924 | 2191 | // Continue to the next operation. |
| 1925 | 2192 | continue 2; |
@@ -1927,16 +2194,22 @@ discard block |
||
| 1927 | 2194 | |
| 1928 | 2195 | // The replacement is now the search subject... |
| 1929 | 2196 | if ($search['position'] === 'replace' || $search['position'] === 'end') |
| 1930 | - $actual_operation['searches'][$i]['search'] = $search['add']; |
|
| 2197 | + { |
|
| 2198 | + $actual_operation['searches'][$i]['search'] = $search['add']; |
|
| 2199 | + } |
|
| 1931 | 2200 | else |
| 1932 | 2201 | { |
| 1933 | 2202 | // Reversing a before/after modification becomes a replacement. |
| 1934 | 2203 | $actual_operation['searches'][$i]['position'] = 'replace'; |
| 1935 | 2204 | |
| 1936 | 2205 | if ($search['position'] === 'before') |
| 1937 | - $actual_operation['searches'][$i]['search'] .= $search['add']; |
|
| 2206 | + { |
|
| 2207 | + $actual_operation['searches'][$i]['search'] .= $search['add']; |
|
| 2208 | + } |
|
| 1938 | 2209 | elseif ($search['position'] === 'after') |
| 1939 | - $actual_operation['searches'][$i]['search'] = $search['add'] . $search['search']; |
|
| 2210 | + { |
|
| 2211 | + $actual_operation['searches'][$i]['search'] = $search['add'] . $search['search']; |
|
| 2212 | + } |
|
| 1940 | 2213 | } |
| 1941 | 2214 | |
| 1942 | 2215 | // ...and the search subject is now the replacement. |
@@ -1965,7 +2238,9 @@ discard block |
||
| 1965 | 2238 | { |
| 1966 | 2239 | // Not much needed if the search subject is already a regexp. |
| 1967 | 2240 | if ($search['is_reg_exp']) |
| 1968 | - $actual_operation['searches'][$i]['preg_search'] = $search['search']; |
|
| 2241 | + { |
|
| 2242 | + $actual_operation['searches'][$i]['preg_search'] = $search['search']; |
|
| 2243 | + } |
|
| 1969 | 2244 | else |
| 1970 | 2245 | { |
| 1971 | 2246 | // Make the search subject fit into a regular expression. |
@@ -1973,7 +2248,9 @@ discard block |
||
| 1973 | 2248 | |
| 1974 | 2249 | // Using 'loose', a random amount of tabs and spaces may be used. |
| 1975 | 2250 | if ($search['loose_whitespace']) |
| 1976 | - $actual_operation['searches'][$i]['preg_search'] = preg_replace('~[ \t]+~', '[ \t]+', $actual_operation['searches'][$i]['preg_search']); |
|
| 2251 | + { |
|
| 2252 | + $actual_operation['searches'][$i]['preg_search'] = preg_replace('~[ \t]+~', '[ \t]+', $actual_operation['searches'][$i]['preg_search']); |
|
| 2253 | + } |
|
| 1977 | 2254 | } |
| 1978 | 2255 | |
| 1979 | 2256 | // Shuzzup. This is done so we can safely use a regular expression. ($0 is bad!!) |
@@ -2048,7 +2325,9 @@ discard block |
||
| 2048 | 2325 | |
| 2049 | 2326 | // Replace it into nothing? That's not an option...unless it's an undoing end. |
| 2050 | 2327 | if ($search['add'] === '' && ($search['position'] !== 'end' || !$undo)) |
| 2051 | - continue; |
|
| 2328 | + { |
|
| 2329 | + continue; |
|
| 2330 | + } |
|
| 2052 | 2331 | |
| 2053 | 2332 | // Finally, we're doing some replacements. |
| 2054 | 2333 | $working_data = preg_replace('~' . $actual_operation['searches'][$i]['preg_search'] . '~s', $actual_operation['searches'][$i]['preg_replace'], $working_data, 1); |
@@ -2074,21 +2353,28 @@ discard block |
||
| 2074 | 2353 | package_chmod($working_file); |
| 2075 | 2354 | |
| 2076 | 2355 | if ((file_exists($working_file) && !is_writable($working_file)) || (!file_exists($working_file) && !is_writable(dirname($working_file)))) |
| 2077 | - $actions[] = array( |
|
| 2356 | + { |
|
| 2357 | + $actions[] = array( |
|
| 2078 | 2358 | 'type' => 'chmod', |
| 2079 | 2359 | 'filename' => $working_file |
| 2080 | 2360 | ); |
| 2361 | + } |
|
| 2081 | 2362 | |
| 2082 | 2363 | if (basename($working_file) == 'Settings_bak.php') |
| 2083 | - continue; |
|
| 2364 | + { |
|
| 2365 | + continue; |
|
| 2366 | + } |
|
| 2084 | 2367 | |
| 2085 | 2368 | if (!$testing && !empty($modSettings['package_make_backups']) && file_exists($working_file)) |
| 2086 | 2369 | { |
| 2087 | 2370 | // No, no, not Settings.php! |
| 2088 | 2371 | if (basename($working_file) == 'Settings.php') |
| 2089 | - @copy($working_file, dirname($working_file) . '/Settings_bak.php'); |
|
| 2090 | - else |
|
| 2091 | - @copy($working_file, $working_file . '~'); |
|
| 2372 | + { |
|
| 2373 | + @copy($working_file, dirname($working_file) . '/Settings_bak.php'); |
|
| 2374 | + } |
|
| 2375 | + else { |
|
| 2376 | + @copy($working_file, $working_file . '~'); |
|
| 2377 | + } |
|
| 2092 | 2378 | } |
| 2093 | 2379 | |
| 2094 | 2380 | // Always call this, even if in testing, because it won't really be written in testing mode. |
@@ -2127,16 +2413,22 @@ discard block |
||
| 2127 | 2413 | |
| 2128 | 2414 | // Windows doesn't seem to care about the memory_limit. |
| 2129 | 2415 | if (!empty($modSettings['package_disable_cache']) || $mem_check || stripos(PHP_OS, 'win') !== false) |
| 2130 | - $package_cache = array(); |
|
| 2131 | - else |
|
| 2132 | - $package_cache = false; |
|
| 2416 | + { |
|
| 2417 | + $package_cache = array(); |
|
| 2418 | + } |
|
| 2419 | + else { |
|
| 2420 | + $package_cache = false; |
|
| 2421 | + } |
|
| 2133 | 2422 | } |
| 2134 | 2423 | |
| 2135 | 2424 | if (strpos($filename, 'packages/') !== false || $package_cache === false || !isset($package_cache[$filename])) |
| 2136 | - return file_get_contents($filename); |
|
| 2137 | - else |
|
| 2138 | - return $package_cache[$filename]; |
|
| 2139 | -} |
|
| 2425 | + { |
|
| 2426 | + return file_get_contents($filename); |
|
| 2427 | + } |
|
| 2428 | + else { |
|
| 2429 | + return $package_cache[$filename]; |
|
| 2430 | + } |
|
| 2431 | + } |
|
| 2140 | 2432 | |
| 2141 | 2433 | /** |
| 2142 | 2434 | * Writes data to a file, almost exactly like the file_put_contents() function. |
@@ -2162,18 +2454,27 @@ discard block |
||
| 2162 | 2454 | $mem_check = detectServer()->setMemoryLimit('128M'); |
| 2163 | 2455 | |
| 2164 | 2456 | if (!empty($modSettings['package_disable_cache']) || $mem_check || stripos(PHP_OS, 'win') !== false) |
| 2165 | - $package_cache = array(); |
|
| 2166 | - else |
|
| 2167 | - $package_cache = false; |
|
| 2457 | + { |
|
| 2458 | + $package_cache = array(); |
|
| 2459 | + } |
|
| 2460 | + else { |
|
| 2461 | + $package_cache = false; |
|
| 2462 | + } |
|
| 2168 | 2463 | } |
| 2169 | 2464 | |
| 2170 | 2465 | if (isset($package_ftp)) |
| 2171 | - $ftp_file = strtr($filename, array($_SESSION['pack_ftp']['root'] => '')); |
|
| 2466 | + { |
|
| 2467 | + $ftp_file = strtr($filename, array($_SESSION['pack_ftp']['root'] => '')); |
|
| 2468 | + } |
|
| 2172 | 2469 | |
| 2173 | 2470 | if (!file_exists($filename) && isset($package_ftp)) |
| 2174 | - $package_ftp->create_file($ftp_file); |
|
| 2471 | + { |
|
| 2472 | + $package_ftp->create_file($ftp_file); |
|
| 2473 | + } |
|
| 2175 | 2474 | elseif (!file_exists($filename)) |
| 2176 | - @touch($filename); |
|
| 2475 | + { |
|
| 2476 | + @touch($filename); |
|
| 2477 | + } |
|
| 2177 | 2478 | |
| 2178 | 2479 | package_chmod($filename); |
| 2179 | 2480 | |
@@ -2183,13 +2484,17 @@ discard block |
||
| 2183 | 2484 | |
| 2184 | 2485 | // We should show an error message or attempt a rollback, no? |
| 2185 | 2486 | if (!$fp) |
| 2186 | - return false; |
|
| 2487 | + { |
|
| 2488 | + return false; |
|
| 2489 | + } |
|
| 2187 | 2490 | |
| 2188 | 2491 | fwrite($fp, $data); |
| 2189 | 2492 | fclose($fp); |
| 2190 | 2493 | } |
| 2191 | 2494 | elseif (strpos($filename, 'packages/') !== false || $package_cache === false) |
| 2192 | - return strlen($data); |
|
| 2495 | + { |
|
| 2496 | + return strlen($data); |
|
| 2497 | + } |
|
| 2193 | 2498 | else |
| 2194 | 2499 | { |
| 2195 | 2500 | $package_cache[$filename] = $data; |
@@ -2197,7 +2502,9 @@ discard block |
||
| 2197 | 2502 | // Permission denied, eh? |
| 2198 | 2503 | $fp = @fopen($filename, 'r+'); |
| 2199 | 2504 | if (!$fp) |
| 2200 | - return false; |
|
| 2505 | + { |
|
| 2506 | + return false; |
|
| 2507 | + } |
|
| 2201 | 2508 | fclose($fp); |
| 2202 | 2509 | } |
| 2203 | 2510 | |
@@ -2216,18 +2523,26 @@ discard block |
||
| 2216 | 2523 | static $text_filetypes = array('php', 'txt', '.js', 'css', 'vbs', 'tml', 'htm'); |
| 2217 | 2524 | |
| 2218 | 2525 | if (empty($package_cache)) |
| 2219 | - return; |
|
| 2526 | + { |
|
| 2527 | + return; |
|
| 2528 | + } |
|
| 2220 | 2529 | |
| 2221 | 2530 | // First, let's check permissions! |
| 2222 | 2531 | foreach ($package_cache as $filename => $data) |
| 2223 | 2532 | { |
| 2224 | 2533 | if (isset($package_ftp)) |
| 2225 | - $ftp_file = strtr($filename, array($_SESSION['pack_ftp']['root'] => '')); |
|
| 2534 | + { |
|
| 2535 | + $ftp_file = strtr($filename, array($_SESSION['pack_ftp']['root'] => '')); |
|
| 2536 | + } |
|
| 2226 | 2537 | |
| 2227 | 2538 | if (!file_exists($filename) && isset($package_ftp)) |
| 2228 | - $package_ftp->create_file($ftp_file); |
|
| 2539 | + { |
|
| 2540 | + $package_ftp->create_file($ftp_file); |
|
| 2541 | + } |
|
| 2229 | 2542 | elseif (!file_exists($filename)) |
| 2230 | - @touch($filename); |
|
| 2543 | + { |
|
| 2544 | + @touch($filename); |
|
| 2545 | + } |
|
| 2231 | 2546 | |
| 2232 | 2547 | $result = package_chmod($filename); |
| 2233 | 2548 | |
@@ -2279,7 +2594,9 @@ discard block |
||
| 2279 | 2594 | global $package_ftp; |
| 2280 | 2595 | |
| 2281 | 2596 | if (file_exists($filename) && is_writable($filename) && $perm_state == 'writable') |
| 2282 | - return true; |
|
| 2597 | + { |
|
| 2598 | + return true; |
|
| 2599 | + } |
|
| 2283 | 2600 | |
| 2284 | 2601 | // Start off checking without FTP. |
| 2285 | 2602 | if (!isset($package_ftp) || $package_ftp === false) |
@@ -2313,23 +2630,34 @@ discard block |
||
| 2313 | 2630 | @touch($chmod_file); |
| 2314 | 2631 | elk_chmod($chmod_file, 0755); |
| 2315 | 2632 | } |
| 2316 | - else |
|
| 2317 | - $file_permissions = @fileperms($chmod_file); |
|
| 2633 | + else { |
|
| 2634 | + $file_permissions = @fileperms($chmod_file); |
|
| 2635 | + } |
|
| 2318 | 2636 | } |
| 2319 | 2637 | |
| 2320 | 2638 | // This looks odd, but it's another attempt to work around PHP suExec. |
| 2321 | 2639 | if ($perm_state != 'writable') |
| 2322 | - elk_chmod($chmod_file, $perm_state == 'execute' ? 0755 : 0644); |
|
| 2640 | + { |
|
| 2641 | + elk_chmod($chmod_file, $perm_state == 'execute' ? 0755 : 0644); |
|
| 2642 | + } |
|
| 2323 | 2643 | else |
| 2324 | 2644 | { |
| 2325 | 2645 | if (!@is_writable($chmod_file)) |
| 2326 | - elk_chmod($chmod_file, 0755); |
|
| 2646 | + { |
|
| 2647 | + elk_chmod($chmod_file, 0755); |
|
| 2648 | + } |
|
| 2327 | 2649 | if (!@is_writable($chmod_file)) |
| 2328 | - elk_chmod($chmod_file, 0777); |
|
| 2650 | + { |
|
| 2651 | + elk_chmod($chmod_file, 0777); |
|
| 2652 | + } |
|
| 2329 | 2653 | if (!@is_writable(dirname($chmod_file))) |
| 2330 | - elk_chmod($chmod_file, 0755); |
|
| 2654 | + { |
|
| 2655 | + elk_chmod($chmod_file, 0755); |
|
| 2656 | + } |
|
| 2331 | 2657 | if (!@is_writable(dirname($chmod_file))) |
| 2332 | - elk_chmod($chmod_file, 0777); |
|
| 2658 | + { |
|
| 2659 | + elk_chmod($chmod_file, 0777); |
|
| 2660 | + } |
|
| 2333 | 2661 | } |
| 2334 | 2662 | |
| 2335 | 2663 | // The ultimate writable test. |
@@ -2339,19 +2667,26 @@ discard block |
||
| 2339 | 2667 | if (@is_writable($chmod_file) && $fp) |
| 2340 | 2668 | { |
| 2341 | 2669 | if (!is_dir($chmod_file)) |
| 2342 | - fclose($fp); |
|
| 2343 | - else |
|
| 2344 | - closedir($fp); |
|
| 2670 | + { |
|
| 2671 | + fclose($fp); |
|
| 2672 | + } |
|
| 2673 | + else { |
|
| 2674 | + closedir($fp); |
|
| 2675 | + } |
|
| 2345 | 2676 | |
| 2346 | 2677 | // It worked! |
| 2347 | 2678 | if ($track_change) |
| 2348 | - $_SESSION['pack_ftp']['original_perms'][$chmod_file] = $file_permissions; |
|
| 2679 | + { |
|
| 2680 | + $_SESSION['pack_ftp']['original_perms'][$chmod_file] = $file_permissions; |
|
| 2681 | + } |
|
| 2349 | 2682 | |
| 2350 | 2683 | return true; |
| 2351 | 2684 | } |
| 2352 | 2685 | } |
| 2353 | 2686 | elseif ($perm_state != 'writable' && isset($_SESSION['pack_ftp']['original_perms'][$chmod_file])) |
| 2354 | - unset($_SESSION['pack_ftp']['original_perms'][$chmod_file]); |
|
| 2687 | + { |
|
| 2688 | + unset($_SESSION['pack_ftp']['original_perms'][$chmod_file]); |
|
| 2689 | + } |
|
| 2355 | 2690 | } |
| 2356 | 2691 | |
| 2357 | 2692 | // If we're here we're a failure. |
@@ -2371,8 +2706,9 @@ discard block |
||
| 2371 | 2706 | $package_ftp->create_file($ftp_file); |
| 2372 | 2707 | $package_ftp->chmod($ftp_file, 0755); |
| 2373 | 2708 | } |
| 2374 | - else |
|
| 2375 | - $file_permissions = @fileperms($filename); |
|
| 2709 | + else { |
|
| 2710 | + $file_permissions = @fileperms($filename); |
|
| 2711 | + } |
|
| 2376 | 2712 | |
| 2377 | 2713 | if ($perm_state != 'writable') |
| 2378 | 2714 | { |
@@ -2381,20 +2717,28 @@ discard block |
||
| 2381 | 2717 | else |
| 2382 | 2718 | { |
| 2383 | 2719 | if (!@is_writable($filename)) |
| 2384 | - $package_ftp->chmod($ftp_file, 0777); |
|
| 2720 | + { |
|
| 2721 | + $package_ftp->chmod($ftp_file, 0777); |
|
| 2722 | + } |
|
| 2385 | 2723 | if (!@is_writable(dirname($filename))) |
| 2386 | - $package_ftp->chmod(dirname($ftp_file), 0777); |
|
| 2724 | + { |
|
| 2725 | + $package_ftp->chmod(dirname($ftp_file), 0777); |
|
| 2726 | + } |
|
| 2387 | 2727 | } |
| 2388 | 2728 | |
| 2389 | 2729 | if (@is_writable($filename)) |
| 2390 | 2730 | { |
| 2391 | 2731 | if ($track_change) |
| 2392 | - $_SESSION['pack_ftp']['original_perms'][$filename] = $file_permissions; |
|
| 2732 | + { |
|
| 2733 | + $_SESSION['pack_ftp']['original_perms'][$filename] = $file_permissions; |
|
| 2734 | + } |
|
| 2393 | 2735 | |
| 2394 | 2736 | return true; |
| 2395 | 2737 | } |
| 2396 | 2738 | elseif ($perm_state != 'writable' && isset($_SESSION['pack_ftp']['original_perms'][$filename])) |
| 2397 | - unset($_SESSION['pack_ftp']['original_perms'][$filename]); |
|
| 2739 | + { |
|
| 2740 | + unset($_SESSION['pack_ftp']['original_perms'][$filename]); |
|
| 2741 | + } |
|
| 2398 | 2742 | } |
| 2399 | 2743 | |
| 2400 | 2744 | // Oh dear, we failed if we get here. |
@@ -2414,10 +2758,14 @@ discard block |
||
| 2414 | 2758 | |
| 2415 | 2759 | $salt = session_id(); |
| 2416 | 2760 | while (strlen($salt) < $n) |
| 2417 | - $salt .= session_id(); |
|
| 2761 | + { |
|
| 2762 | + $salt .= session_id(); |
|
| 2763 | + } |
|
| 2418 | 2764 | |
| 2419 | 2765 | for ($i = 0; $i < $n; $i++) |
| 2420 | - $pass[$i] = chr(ord($pass[$i]) ^ (ord($salt[$i]) - 32)); |
|
| 2766 | + { |
|
| 2767 | + $pass[$i] = chr(ord($pass[$i]) ^ (ord($salt[$i]) - 32)); |
|
| 2768 | + } |
|
| 2421 | 2769 | |
| 2422 | 2770 | return $pass; |
| 2423 | 2771 | } |
@@ -2441,7 +2789,9 @@ discard block |
||
| 2441 | 2789 | foreach ($base_files as $file) |
| 2442 | 2790 | { |
| 2443 | 2791 | if (file_exists(BOARDDIR . '/' . $file)) |
| 2444 | - $files[$use_relative_paths ? $file : realpath(BOARDDIR . '/' . $file)] = BOARDDIR . '/' . $file; |
|
| 2792 | + { |
|
| 2793 | + $files[$use_relative_paths ? $file : realpath(BOARDDIR . '/' . $file)] = BOARDDIR . '/' . $file; |
|
| 2794 | + } |
|
| 2445 | 2795 | } |
| 2446 | 2796 | |
| 2447 | 2797 | // Root directory where most of our files reside |
@@ -2461,7 +2811,9 @@ discard block |
||
| 2461 | 2811 | ) |
| 2462 | 2812 | ); |
| 2463 | 2813 | while ($row = $db->fetch_assoc($request)) |
| 2464 | - $dirs[$row['value']] = $use_relative_paths ? 'themes/' . basename($row['value']) . '/' : strtr($row['value'] . '/', '\\', '/'); |
|
| 2814 | + { |
|
| 2815 | + $dirs[$row['value']] = $use_relative_paths ? 'themes/' . basename($row['value']) . '/' : strtr($row['value'] . '/', '\\', '/'); |
|
| 2816 | + } |
|
| 2465 | 2817 | $db->free_result($request); |
| 2466 | 2818 | |
| 2467 | 2819 | try |
@@ -2477,10 +2829,14 @@ discard block |
||
| 2477 | 2829 | foreach ($iter as $entry => $dir) |
| 2478 | 2830 | { |
| 2479 | 2831 | if ($dir->isDir()) |
| 2480 | - continue; |
|
| 2832 | + { |
|
| 2833 | + continue; |
|
| 2834 | + } |
|
| 2481 | 2835 | |
| 2482 | 2836 | if (preg_match('~^(\.{1,2}|CVS|backup.*|help|images|.*\~)$~', $entry) != 0) |
| 2483 | - continue; |
|
| 2837 | + { |
|
| 2838 | + continue; |
|
| 2839 | + } |
|
| 2484 | 2840 | |
| 2485 | 2841 | $files[$use_relative_paths ? str_replace(realpath(BOARDDIR), '', $entry) : $entry] = $entry; |
| 2486 | 2842 | } |
@@ -2488,10 +2844,14 @@ discard block |
||
| 2488 | 2844 | |
| 2489 | 2845 | // Make sure we have a backup directory and its writable |
| 2490 | 2846 | if (!file_exists(BOARDDIR . '/packages/backups')) |
| 2491 | - mktree(BOARDDIR . '/packages/backups', 0777); |
|
| 2847 | + { |
|
| 2848 | + mktree(BOARDDIR . '/packages/backups', 0777); |
|
| 2849 | + } |
|
| 2492 | 2850 | |
| 2493 | 2851 | if (!is_writable(BOARDDIR . '/packages/backups')) |
| 2494 | - package_chmod(BOARDDIR . '/packages/backups'); |
|
| 2852 | + { |
|
| 2853 | + package_chmod(BOARDDIR . '/packages/backups'); |
|
| 2854 | + } |
|
| 2495 | 2855 | |
| 2496 | 2856 | // Name the output file, yyyy-mm-dd_before_package_name.tar.gz |
| 2497 | 2857 | $output_file = BOARDDIR . '/packages/backups/' . Util::strftime('%Y-%m-%d_') . preg_replace('~[$\\\\/:<>|?*"\']~', '', $id); |
@@ -2501,11 +2861,14 @@ discard block |
||
| 2501 | 2861 | { |
| 2502 | 2862 | $i = 2; |
| 2503 | 2863 | while (file_exists($output_file . '_' . $i . $output_ext . '.gz')) |
| 2504 | - $i++; |
|
| 2864 | + { |
|
| 2865 | + $i++; |
|
| 2866 | + } |
|
| 2505 | 2867 | $output_file = $output_file . '_' . $i . $output_ext; |
| 2506 | 2868 | } |
| 2507 | - else |
|
| 2508 | - $output_file .= $output_ext; |
|
| 2869 | + else { |
|
| 2870 | + $output_file .= $output_ext; |
|
| 2871 | + } |
|
| 2509 | 2872 | |
| 2510 | 2873 | // Buy some more time so we have enough to create this archive |
| 2511 | 2874 | detectServer()->setTimeLimit(300); |
@@ -2555,13 +2918,17 @@ discard block |
||
| 2555 | 2918 | |
| 2556 | 2919 | // An FTP url. We should try connecting and RETRieving it... |
| 2557 | 2920 | if (empty($match[1])) |
| 2558 | - return false; |
|
| 2921 | + { |
|
| 2922 | + return false; |
|
| 2923 | + } |
|
| 2559 | 2924 | elseif ($match[1] == 'ftp') |
| 2560 | 2925 | { |
| 2561 | 2926 | // Establish a connection and attempt to enable passive mode. |
| 2562 | 2927 | $ftp = new Ftp_Connection(($match[2] ? 'ssl://' : '') . $match[3], empty($match[5]) ? 21 : $match[5], 'anonymous', $webmaster_email); |
| 2563 | 2928 | if ($ftp->error !== false || !$ftp->passive()) |
| 2564 | - return false; |
|
| 2929 | + { |
|
| 2930 | + return false; |
|
| 2931 | + } |
|
| 2565 | 2932 | |
| 2566 | 2933 | // I want that one *points*! |
| 2567 | 2934 | fwrite($ftp->connection, 'RETR ' . $match[6] . "\r\n"); |
@@ -2569,14 +2936,18 @@ discard block |
||
| 2569 | 2936 | // Since passive mode worked (or we would have returned already!) open the connection. |
| 2570 | 2937 | $fp = @fsockopen($ftp->pasv['ip'], $ftp->pasv['port'], $err, $err, 5); |
| 2571 | 2938 | if (!$fp) |
| 2572 | - return false; |
|
| 2939 | + { |
|
| 2940 | + return false; |
|
| 2941 | + } |
|
| 2573 | 2942 | |
| 2574 | 2943 | // The server should now say something in acknowledgement. |
| 2575 | 2944 | $ftp->check_response(150); |
| 2576 | 2945 | |
| 2577 | 2946 | $data = ''; |
| 2578 | 2947 | while (!feof($fp)) |
| 2579 | - $data .= fread($fp, 4096); |
|
| 2948 | + { |
|
| 2949 | + $data .= fread($fp, 4096); |
|
| 2950 | + } |
|
| 2580 | 2951 | fclose($fp); |
| 2581 | 2952 | |
| 2582 | 2953 | // All done, right? Good. |
@@ -2591,21 +2962,28 @@ discard block |
||
| 2591 | 2962 | |
| 2592 | 2963 | // no errors and a 200 result, then we have a good dataset, well we at least have data ;) |
| 2593 | 2964 | if ($fetch_data->result('code') == 200 && !$fetch_data->result('error')) |
| 2594 | - $data = $fetch_data->result('body'); |
|
| 2595 | - else |
|
| 2596 | - return false; |
|
| 2965 | + { |
|
| 2966 | + $data = $fetch_data->result('body'); |
|
| 2967 | + } |
|
| 2968 | + else { |
|
| 2969 | + return false; |
|
| 2970 | + } |
|
| 2597 | 2971 | } |
| 2598 | 2972 | // This is more likely; a standard HTTP URL. |
| 2599 | 2973 | elseif (isset($match[1]) && $match[1] == 'http') |
| 2600 | 2974 | { |
| 2601 | 2975 | if ($keep_alive && $match[3] == $keep_alive_dom) |
| 2602 | - $fp = $keep_alive_fp; |
|
| 2976 | + { |
|
| 2977 | + $fp = $keep_alive_fp; |
|
| 2978 | + } |
|
| 2603 | 2979 | if (empty($fp)) |
| 2604 | 2980 | { |
| 2605 | 2981 | // Open the socket on the port we want... |
| 2606 | 2982 | $fp = @fsockopen(($match[2] ? 'ssl://' : '') . $match[3], empty($match[5]) ? ($match[2] ? 443 : 80) : $match[5], $err, $err, 5); |
| 2607 | 2983 | if (!$fp) |
| 2608 | - return false; |
|
| 2984 | + { |
|
| 2985 | + return false; |
|
| 2986 | + } |
|
| 2609 | 2987 | } |
| 2610 | 2988 | |
| 2611 | 2989 | if ($keep_alive) |
@@ -2621,9 +2999,12 @@ discard block |
||
| 2621 | 2999 | fwrite($fp, 'Host: ' . $match[3] . (empty($match[5]) ? ($match[2] ? ':443' : '') : ':' . $match[5]) . "\r\n"); |
| 2622 | 3000 | fwrite($fp, 'User-Agent: PHP/ELK' . "\r\n"); |
| 2623 | 3001 | if ($keep_alive) |
| 2624 | - fwrite($fp, 'Connection: Keep-Alive' . "\r\n\r\n"); |
|
| 2625 | - else |
|
| 2626 | - fwrite($fp, 'Connection: close' . "\r\n\r\n"); |
|
| 3002 | + { |
|
| 3003 | + fwrite($fp, 'Connection: Keep-Alive' . "\r\n\r\n"); |
|
| 3004 | + } |
|
| 3005 | + else { |
|
| 3006 | + fwrite($fp, 'Connection: close' . "\r\n\r\n"); |
|
| 3007 | + } |
|
| 2627 | 3008 | } |
| 2628 | 3009 | else |
| 2629 | 3010 | { |
@@ -2631,9 +3012,12 @@ discard block |
||
| 2631 | 3012 | fwrite($fp, 'Host: ' . $match[3] . (empty($match[5]) ? ($match[2] ? ':443' : '') : ':' . $match[5]) . "\r\n"); |
| 2632 | 3013 | fwrite($fp, 'User-Agent: PHP/ELK' . "\r\n"); |
| 2633 | 3014 | if ($keep_alive) |
| 2634 | - fwrite($fp, 'Connection: Keep-Alive' . "\r\n"); |
|
| 2635 | - else |
|
| 2636 | - fwrite($fp, 'Connection: close' . "\r\n"); |
|
| 3015 | + { |
|
| 3016 | + fwrite($fp, 'Connection: Keep-Alive' . "\r\n"); |
|
| 3017 | + } |
|
| 3018 | + else { |
|
| 3019 | + fwrite($fp, 'Connection: close' . "\r\n"); |
|
| 3020 | + } |
|
| 2637 | 3021 | fwrite($fp, 'Content-Type: application/x-www-form-urlencoded' . "\r\n"); |
| 2638 | 3022 | fwrite($fp, 'Content-Length: ' . strlen($post_data) . "\r\n\r\n"); |
| 2639 | 3023 | fwrite($fp, $post_data); |
@@ -2646,28 +3030,38 @@ discard block |
||
| 2646 | 3030 | { |
| 2647 | 3031 | $location = ''; |
| 2648 | 3032 | while (!feof($fp) && trim($header = fgets($fp, 4096)) != '') |
| 2649 | - if (strpos($header, 'Location:') !== false) |
|
| 3033 | + { |
|
| 3034 | + if (strpos($header, 'Location:') !== false) |
|
| 2650 | 3035 | $location = trim(substr($header, strpos($header, ':') + 1)); |
| 3036 | + } |
|
| 2651 | 3037 | |
| 2652 | 3038 | if (empty($location)) |
| 2653 | - return false; |
|
| 3039 | + { |
|
| 3040 | + return false; |
|
| 3041 | + } |
|
| 2654 | 3042 | else |
| 2655 | 3043 | { |
| 2656 | 3044 | if (!$keep_alive) |
| 2657 | - fclose($fp); |
|
| 3045 | + { |
|
| 3046 | + fclose($fp); |
|
| 3047 | + } |
|
| 2658 | 3048 | return fetch_web_data($location, $post_data, $keep_alive, $redirection_level + 1); |
| 2659 | 3049 | } |
| 2660 | 3050 | } |
| 2661 | 3051 | |
| 2662 | 3052 | // Make sure we get a 200 OK. |
| 2663 | 3053 | elseif (preg_match('~^HTTP/\S+\s+20[01]~i', $response) === 0) |
| 2664 | - return false; |
|
| 3054 | + { |
|
| 3055 | + return false; |
|
| 3056 | + } |
|
| 2665 | 3057 | |
| 2666 | 3058 | // Skip the headers... |
| 2667 | 3059 | while (!feof($fp) && trim($header = fgets($fp, 4096)) != '') |
| 2668 | 3060 | { |
| 2669 | 3061 | if (preg_match('~content-length:\s*(\d+)~i', $header, $match) != 0) |
| 2670 | - $content_length = $match[1]; |
|
| 3062 | + { |
|
| 3063 | + $content_length = $match[1]; |
|
| 3064 | + } |
|
| 2671 | 3065 | elseif (preg_match('~connection:\s*close~i', $header) != 0) |
| 2672 | 3066 | { |
| 2673 | 3067 | $keep_alive_dom = null; |
@@ -2681,16 +3075,22 @@ discard block |
||
| 2681 | 3075 | if (isset($content_length)) |
| 2682 | 3076 | { |
| 2683 | 3077 | while (!feof($fp) && strlen($data) < $content_length) |
| 2684 | - $data .= fread($fp, $content_length - strlen($data)); |
|
| 3078 | + { |
|
| 3079 | + $data .= fread($fp, $content_length - strlen($data)); |
|
| 3080 | + } |
|
| 2685 | 3081 | } |
| 2686 | 3082 | else |
| 2687 | 3083 | { |
| 2688 | 3084 | while (!feof($fp)) |
| 2689 | - $data .= fread($fp, 4096); |
|
| 3085 | + { |
|
| 3086 | + $data .= fread($fp, 4096); |
|
| 3087 | + } |
|
| 2690 | 3088 | } |
| 2691 | 3089 | |
| 2692 | 3090 | if (!$keep_alive) |
| 2693 | - fclose($fp); |
|
| 3091 | + { |
|
| 3092 | + fclose($fp); |
|
| 3093 | + } |
|
| 2694 | 3094 | } |
| 2695 | 3095 | else |
| 2696 | 3096 | { |
@@ -2727,7 +3127,9 @@ discard block |
||
| 2727 | 3127 | ); |
| 2728 | 3128 | |
| 2729 | 3129 | if (empty($id)) |
| 2730 | - return $result; |
|
| 3130 | + { |
|
| 3131 | + return $result; |
|
| 3132 | + } |
|
| 2731 | 3133 | |
| 2732 | 3134 | // See if it is installed? |
| 2733 | 3135 | $request = $db->query('', ' |
@@ -2812,7 +3214,9 @@ discard block |
||
| 2812 | 3214 | ) |
| 2813 | 3215 | ); |
| 2814 | 3216 | while ($row = $db->fetch_row($request)) |
| 2815 | - list ($version) = $row; |
|
| 3217 | + { |
|
| 3218 | + list ($version) = $row; |
|
| 3219 | + } |
|
| 2816 | 3220 | $db->free_result($request); |
| 2817 | 3221 | |
| 2818 | 3222 | return $version; |
@@ -2884,11 +3288,15 @@ discard block |
||
| 2884 | 3288 | // Know addon servers |
| 2885 | 3289 | $servers = Util::unserialize($modSettings['authorized_package_servers']); |
| 2886 | 3290 | if (empty($servers)) |
| 2887 | - return false; |
|
| 3291 | + { |
|
| 3292 | + return false; |
|
| 3293 | + } |
|
| 2888 | 3294 | |
| 2889 | 3295 | foreach ($servers as $server) |
| 2890 | - if (preg_match('~^' . preg_quote($server) . '~', $remote_url) == 0) |
|
| 3296 | + { |
|
| 3297 | + if (preg_match('~^' . preg_quote($server) . '~', $remote_url) == 0) |
|
| 2891 | 3298 | return true; |
| 3299 | + } |
|
| 2892 | 3300 | |
| 2893 | 3301 | return false; |
| 2894 | 3302 | } |
@@ -2923,9 +3331,13 @@ discard block |
||
| 2923 | 3331 | |
| 2924 | 3332 | // Make sure we have a form of 0777 or '777' or '0777' so its safe for intval '8' |
| 2925 | 3333 | if (($mode % 10) >= 8) |
| 2926 | - $mode = decoct($mode); |
|
| 3334 | + { |
|
| 3335 | + $mode = decoct($mode); |
|
| 3336 | + } |
|
| 2927 | 3337 | if ($mode == decoct(octdec($mode))) |
| 2928 | - $result = @chmod($file, intval($mode, 8)); |
|
| 3338 | + { |
|
| 3339 | + $result = @chmod($file, intval($mode, 8)); |
|
| 3340 | + } |
|
| 2929 | 3341 | |
| 2930 | 3342 | return $result; |
| 2931 | 3343 | } |