@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 3 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * This function allows to move a topic, making sure to ask the moderator |
@@ -32,8 +33,9 @@ discard block |
||
32 | 33 | { |
33 | 34 | global $txt, $board, $topic, $user_info, $context, $language, $scripturl, $smcFunc, $modSettings, $sourcedir; |
34 | 35 | |
35 | - if (empty($topic)) |
|
36 | - fatal_lang_error('no_access', false); |
|
36 | + if (empty($topic)) { |
|
37 | + fatal_lang_error('no_access', false); |
|
38 | + } |
|
37 | 39 | |
38 | 40 | $request = $smcFunc['db_query']('', ' |
39 | 41 | SELECT t.id_member_started, ms.subject, t.approved |
@@ -49,8 +51,9 @@ discard block |
||
49 | 51 | $smcFunc['db_free_result']($request); |
50 | 52 | |
51 | 53 | // Can they see it - if not approved? |
52 | - if ($modSettings['postmod_active'] && !$context['is_approved']) |
|
53 | - isAllowedTo('approve_posts'); |
|
54 | + if ($modSettings['postmod_active'] && !$context['is_approved']) { |
|
55 | + isAllowedTo('approve_posts'); |
|
56 | + } |
|
54 | 57 | |
55 | 58 | // Permission check! |
56 | 59 | // @todo |
@@ -59,9 +62,9 @@ discard block |
||
59 | 62 | if ($id_member_started == $user_info['id']) |
60 | 63 | { |
61 | 64 | isAllowedTo('move_own'); |
65 | + } else { |
|
66 | + isAllowedTo('move_any'); |
|
62 | 67 | } |
63 | - else |
|
64 | - isAllowedTo('move_any'); |
|
65 | 68 | } |
66 | 69 | |
67 | 70 | $context['move_any'] = $user_info['is_admin'] || $modSettings['topic_move_any']; |
@@ -83,11 +86,13 @@ discard block |
||
83 | 86 | 'not_redirection' => true, |
84 | 87 | ); |
85 | 88 | |
86 | - if (!empty($_SESSION['move_to_topic']) && $_SESSION['move_to_topic'] != $board) |
|
87 | - $options['selected_board'] = $_SESSION['move_to_topic']; |
|
89 | + if (!empty($_SESSION['move_to_topic']) && $_SESSION['move_to_topic'] != $board) { |
|
90 | + $options['selected_board'] = $_SESSION['move_to_topic']; |
|
91 | + } |
|
88 | 92 | |
89 | - if (!$context['move_any']) |
|
90 | - $options['included_boards'] = $boards; |
|
93 | + if (!$context['move_any']) { |
|
94 | + $options['included_boards'] = $boards; |
|
95 | + } |
|
91 | 96 | |
92 | 97 | require_once($sourcedir . '/Subs-MessageIndex.php'); |
93 | 98 | $context['categories'] = getBoardList($options); |
@@ -138,12 +143,14 @@ discard block |
||
138 | 143 | global $txt, $topic, $scripturl, $sourcedir, $context; |
139 | 144 | global $board, $language, $user_info, $smcFunc; |
140 | 145 | |
141 | - if (empty($topic)) |
|
142 | - fatal_lang_error('no_access', false); |
|
146 | + if (empty($topic)) { |
|
147 | + fatal_lang_error('no_access', false); |
|
148 | + } |
|
143 | 149 | |
144 | 150 | // You can't choose to have a redirection topic and use an empty reason. |
145 | - if (isset($_POST['postRedirect']) && (!isset($_POST['reason']) || trim($_POST['reason']) == '')) |
|
146 | - fatal_lang_error('movetopic_no_reason', false); |
|
151 | + if (isset($_POST['postRedirect']) && (!isset($_POST['reason']) || trim($_POST['reason']) == '')) { |
|
152 | + fatal_lang_error('movetopic_no_reason', false); |
|
153 | + } |
|
147 | 154 | |
148 | 155 | moveTopicConcurrence(); |
149 | 156 | |
@@ -163,16 +170,18 @@ discard block |
||
163 | 170 | $smcFunc['db_free_result']($request); |
164 | 171 | |
165 | 172 | // Can they see it? |
166 | - if (!$context['is_approved']) |
|
167 | - isAllowedTo('approve_posts'); |
|
173 | + if (!$context['is_approved']) { |
|
174 | + isAllowedTo('approve_posts'); |
|
175 | + } |
|
168 | 176 | |
169 | 177 | // Can they move topics on this board? |
170 | 178 | if (!allowedTo('move_any')) |
171 | 179 | { |
172 | - if ($id_member_started == $user_info['id']) |
|
173 | - isAllowedTo('move_own'); |
|
174 | - else |
|
175 | - isAllowedTo('move_any'); |
|
180 | + if ($id_member_started == $user_info['id']) { |
|
181 | + isAllowedTo('move_own'); |
|
182 | + } else { |
|
183 | + isAllowedTo('move_any'); |
|
184 | + } |
|
176 | 185 | } |
177 | 186 | |
178 | 187 | checkSession(); |
@@ -197,8 +206,9 @@ discard block |
||
197 | 206 | 'blank_redirect' => '', |
198 | 207 | ) |
199 | 208 | ); |
200 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
201 | - fatal_lang_error('no_board'); |
|
209 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
210 | + fatal_lang_error('no_board'); |
|
211 | + } |
|
202 | 212 | list ($pcounter, $board_name, $subject) = $smcFunc['db_fetch_row']($request); |
203 | 213 | $smcFunc['db_free_result']($request); |
204 | 214 | |
@@ -210,8 +220,9 @@ discard block |
||
210 | 220 | { |
211 | 221 | $_POST['custom_subject'] = strtr($smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['custom_subject'])), array("\r" => '', "\n" => '', "\t" => '')); |
212 | 222 | // Keep checking the length. |
213 | - if ($smcFunc['strlen']($_POST['custom_subject']) > 100) |
|
214 | - $_POST['custom_subject'] = $smcFunc['substr']($_POST['custom_subject'], 0, 100); |
|
223 | + if ($smcFunc['strlen']($_POST['custom_subject']) > 100) { |
|
224 | + $_POST['custom_subject'] = $smcFunc['substr']($_POST['custom_subject'], 0, 100); |
|
225 | + } |
|
215 | 226 | |
216 | 227 | // If it's still valid move onwards and upwards. |
217 | 228 | if ($_POST['custom_subject'] != '') |
@@ -221,9 +232,9 @@ discard block |
||
221 | 232 | // Get a response prefix, but in the forum's default language. |
222 | 233 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
223 | 234 | { |
224 | - if ($language === $user_info['language']) |
|
225 | - $context['response_prefix'] = $txt['response_prefix']; |
|
226 | - else |
|
235 | + if ($language === $user_info['language']) { |
|
236 | + $context['response_prefix'] = $txt['response_prefix']; |
|
237 | + } else |
|
227 | 238 | { |
228 | 239 | loadLanguage('index', $language, false); |
229 | 240 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -263,8 +274,9 @@ discard block |
||
263 | 274 | if (isset($_POST['postRedirect'])) |
264 | 275 | { |
265 | 276 | // Should be in the boardwide language. |
266 | - if ($user_info['language'] != $language) |
|
267 | - loadLanguage('index', $language); |
|
277 | + if ($user_info['language'] != $language) { |
|
278 | + loadLanguage('index', $language); |
|
279 | + } |
|
268 | 280 | |
269 | 281 | $_POST['reason'] = $smcFunc['htmlspecialchars']($_POST['reason'], ENT_QUOTES); |
270 | 282 | preparsecode($_POST['reason']); |
@@ -328,8 +340,9 @@ discard block |
||
328 | 340 | $posters = array(); |
329 | 341 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
330 | 342 | { |
331 | - if (!isset($posters[$row['id_member']])) |
|
332 | - $posters[$row['id_member']] = 0; |
|
343 | + if (!isset($posters[$row['id_member']])) { |
|
344 | + $posters[$row['id_member']] = 0; |
|
345 | + } |
|
333 | 346 | |
334 | 347 | $posters[$row['id_member']]++; |
335 | 348 | } |
@@ -338,11 +351,13 @@ discard block |
||
338 | 351 | foreach ($posters as $id_member => $posts) |
339 | 352 | { |
340 | 353 | // The board we're moving from counted posts, but not to. |
341 | - if (empty($pcounter_from)) |
|
342 | - updateMemberData($id_member, array('posts' => 'posts - ' . $posts)); |
|
354 | + if (empty($pcounter_from)) { |
|
355 | + updateMemberData($id_member, array('posts' => 'posts - ' . $posts)); |
|
356 | + } |
|
343 | 357 | // The reverse: from didn't, to did. |
344 | - else |
|
345 | - updateMemberData($id_member, array('posts' => 'posts + ' . $posts)); |
|
358 | + else { |
|
359 | + updateMemberData($id_member, array('posts' => 'posts + ' . $posts)); |
|
360 | + } |
|
346 | 361 | } |
347 | 362 | } |
348 | 363 | |
@@ -350,17 +365,19 @@ discard block |
||
350 | 365 | moveTopics($topic, $_POST['toboard']); |
351 | 366 | |
352 | 367 | // Log that they moved this topic. |
353 | - if (!allowedTo('move_own') || $id_member_started != $user_info['id']) |
|
354 | - logAction('move', array('topic' => $topic, 'board_from' => $board, 'board_to' => $_POST['toboard'])); |
|
368 | + if (!allowedTo('move_own') || $id_member_started != $user_info['id']) { |
|
369 | + logAction('move', array('topic' => $topic, 'board_from' => $board, 'board_to' => $_POST['toboard'])); |
|
370 | + } |
|
355 | 371 | // Notify people that this topic has been moved? |
356 | 372 | sendNotifications($topic, 'move'); |
357 | 373 | |
358 | 374 | // Why not go back to the original board in case they want to keep moving? |
359 | - if (!isset($_REQUEST['goback'])) |
|
360 | - redirectexit('board=' . $board . '.0'); |
|
361 | - else |
|
362 | - redirectexit('topic=' . $topic . '.0'); |
|
363 | -} |
|
375 | + if (!isset($_REQUEST['goback'])) { |
|
376 | + redirectexit('board=' . $board . '.0'); |
|
377 | + } else { |
|
378 | + redirectexit('topic=' . $topic . '.0'); |
|
379 | + } |
|
380 | + } |
|
364 | 381 | |
365 | 382 | /** |
366 | 383 | * Moves one or more topics to a specific board. (doesn't check permissions.) |
@@ -376,18 +393,21 @@ discard block |
||
376 | 393 | global $sourcedir, $user_info, $modSettings, $smcFunc; |
377 | 394 | |
378 | 395 | // Empty array? |
379 | - if (empty($topics)) |
|
380 | - return; |
|
396 | + if (empty($topics)) { |
|
397 | + return; |
|
398 | + } |
|
381 | 399 | |
382 | 400 | // Only a single topic. |
383 | - if (is_numeric($topics)) |
|
384 | - $topics = array($topics); |
|
401 | + if (is_numeric($topics)) { |
|
402 | + $topics = array($topics); |
|
403 | + } |
|
385 | 404 | |
386 | 405 | $fromBoards = array(); |
387 | 406 | |
388 | 407 | // Destination board empty or equal to 0? |
389 | - if (empty($toBoard)) |
|
390 | - return; |
|
408 | + if (empty($toBoard)) { |
|
409 | + return; |
|
410 | + } |
|
391 | 411 | |
392 | 412 | // Are we moving to the recycle board? |
393 | 413 | $isRecycleDest = !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] == $toBoard; |
@@ -395,8 +415,9 @@ discard block |
||
395 | 415 | // Callback for search APIs to do their thing |
396 | 416 | require_once($sourcedir . '/Search.php'); |
397 | 417 | $searchAPI = findSearchAPI(); |
398 | - if ($searchAPI->supportsMethod('topicsMoved')) |
|
399 | - $searchAPI->topicsMoved($topics, $toBoard); |
|
418 | + if ($searchAPI->supportsMethod('topicsMoved')) { |
|
419 | + $searchAPI->topicsMoved($topics, $toBoard); |
|
420 | + } |
|
400 | 421 | |
401 | 422 | // Determine the source boards... |
402 | 423 | $request = $smcFunc['db_query']('', ' |
@@ -410,8 +431,9 @@ discard block |
||
410 | 431 | ) |
411 | 432 | ); |
412 | 433 | // Num of rows = 0 -> no topics found. Num of rows > 1 -> topics are on multiple boards. |
413 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
414 | - return; |
|
434 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
435 | + return; |
|
436 | + } |
|
415 | 437 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
416 | 438 | { |
417 | 439 | if (!isset($fromBoards[$row['id_board']]['num_posts'])) |
@@ -429,10 +451,11 @@ discard block |
||
429 | 451 | $fromBoards[$row['id_board']]['unapproved_posts'] += $row['unapproved_posts']; |
430 | 452 | |
431 | 453 | // Add the topics to the right type. |
432 | - if ($row['approved']) |
|
433 | - $fromBoards[$row['id_board']]['num_topics'] += $row['num_topics']; |
|
434 | - else |
|
435 | - $fromBoards[$row['id_board']]['unapproved_topics'] += $row['num_topics']; |
|
454 | + if ($row['approved']) { |
|
455 | + $fromBoards[$row['id_board']]['num_topics'] += $row['num_topics']; |
|
456 | + } else { |
|
457 | + $fromBoards[$row['id_board']]['unapproved_topics'] += $row['num_topics']; |
|
458 | + } |
|
436 | 459 | } |
437 | 460 | $smcFunc['db_free_result']($request); |
438 | 461 | |
@@ -558,13 +581,14 @@ discard block |
||
558 | 581 | ) |
559 | 582 | ); |
560 | 583 | $approval_msgs = array(); |
561 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
562 | - $approval_msgs[] = $row['id_msg']; |
|
584 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
585 | + $approval_msgs[] = $row['id_msg']; |
|
586 | + } |
|
563 | 587 | $smcFunc['db_free_result']($request); |
564 | 588 | |
565 | 589 | // Empty the approval queue for these, as we're going to approve them next. |
566 | - if (!empty($approval_msgs)) |
|
567 | - $smcFunc['db_query']('', ' |
|
590 | + if (!empty($approval_msgs)) { |
|
591 | + $smcFunc['db_query']('', ' |
|
568 | 592 | DELETE FROM {db_prefix}approval_queue |
569 | 593 | WHERE id_msg IN ({array_int:message_list}) |
570 | 594 | AND id_attach = {int:id_attach}', |
@@ -573,6 +597,7 @@ discard block |
||
573 | 597 | 'id_attach' => 0, |
574 | 598 | ) |
575 | 599 | ); |
600 | + } |
|
576 | 601 | |
577 | 602 | // Get all the current max and mins. |
578 | 603 | $request = $smcFunc['db_query']('', ' |
@@ -606,8 +631,8 @@ discard block |
||
606 | 631 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
607 | 632 | { |
608 | 633 | // If not, update. |
609 | - if ($row['first_msg'] != $topicMaxMin[$row['id_topic']]['min'] || $row['last_msg'] != $topicMaxMin[$row['id_topic']]['max']) |
|
610 | - $smcFunc['db_query']('', ' |
|
634 | + if ($row['first_msg'] != $topicMaxMin[$row['id_topic']]['min'] || $row['last_msg'] != $topicMaxMin[$row['id_topic']]['max']) { |
|
635 | + $smcFunc['db_query']('', ' |
|
611 | 636 | UPDATE {db_prefix}topics |
612 | 637 | SET id_first_msg = {int:first_msg}, id_last_msg = {int:last_msg} |
613 | 638 | WHERE id_topic = {int:selected_topic}', |
@@ -617,6 +642,7 @@ discard block |
||
617 | 642 | 'selected_topic' => $row['id_topic'], |
618 | 643 | ) |
619 | 644 | ); |
645 | + } |
|
620 | 646 | } |
621 | 647 | $smcFunc['db_free_result']($request); |
622 | 648 | } |
@@ -675,9 +701,10 @@ discard block |
||
675 | 701 | } |
676 | 702 | |
677 | 703 | // Update the cache? |
678 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) |
|
679 | - foreach ($topics as $topic_id) |
|
704 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) { |
|
705 | + foreach ($topics as $topic_id) |
|
680 | 706 | cache_put_data('topic_board-' . $topic_id, null, 120); |
707 | + } |
|
681 | 708 | |
682 | 709 | require_once($sourcedir . '/Subs-Post.php'); |
683 | 710 | |
@@ -701,15 +728,17 @@ discard block |
||
701 | 728 | { |
702 | 729 | global $board, $topic, $smcFunc, $scripturl; |
703 | 730 | |
704 | - if (isset($_GET['current_board'])) |
|
705 | - $move_from = (int) $_GET['current_board']; |
|
731 | + if (isset($_GET['current_board'])) { |
|
732 | + $move_from = (int) $_GET['current_board']; |
|
733 | + } |
|
706 | 734 | |
707 | - if (empty($move_from) || empty($board) || empty($topic)) |
|
708 | - return true; |
|
735 | + if (empty($move_from) || empty($board) || empty($topic)) { |
|
736 | + return true; |
|
737 | + } |
|
709 | 738 | |
710 | - if ($move_from == $board) |
|
711 | - return true; |
|
712 | - else |
|
739 | + if ($move_from == $board) { |
|
740 | + return true; |
|
741 | + } else |
|
713 | 742 | { |
714 | 743 | $request = $smcFunc['db_query']('', ' |
715 | 744 | SELECT m.subject, b.name |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * This is the dispatcher of smileys administration. |
@@ -91,8 +92,9 @@ discard block |
||
91 | 92 | ); |
92 | 93 | |
93 | 94 | // Some settings may not be enabled, disallow these from the tabs as appropriate. |
94 | - if (empty($modSettings['messageIcons_enable'])) |
|
95 | - $context[$context['admin_menu_name']]['tab_data']['tabs']['editicons']['disabled'] = true; |
|
95 | + if (empty($modSettings['messageIcons_enable'])) { |
|
96 | + $context[$context['admin_menu_name']]['tab_data']['tabs']['editicons']['disabled'] = true; |
|
97 | + } |
|
96 | 98 | if (empty($modSettings['smiley_enable'])) |
97 | 99 | { |
98 | 100 | $context[$context['admin_menu_name']]['tab_data']['tabs']['addsmiley']['disabled'] = true; |
@@ -125,8 +127,9 @@ discard block |
||
125 | 127 | $set_names = explode("\n", $modSettings['smiley_sets_names']); |
126 | 128 | |
127 | 129 | $smiley_context = array(); |
128 | - foreach ($smiley_sets as $i => $set) |
|
129 | - $smiley_context[$set] = $set_names[$i]; |
|
130 | + foreach ($smiley_sets as $i => $set) { |
|
131 | + $smiley_context[$set] = $set_names[$i]; |
|
132 | + } |
|
130 | 133 | |
131 | 134 | // All the settings for the page... |
132 | 135 | $config_vars = array( |
@@ -147,8 +150,9 @@ discard block |
||
147 | 150 | |
148 | 151 | call_integration_hook('integrate_modify_smiley_settings', array(&$config_vars)); |
149 | 152 | |
150 | - if ($return_config) |
|
151 | - return $config_vars; |
|
153 | + if ($return_config) { |
|
154 | + return $config_vars; |
|
155 | + } |
|
152 | 156 | |
153 | 157 | // Setup the basics of the settings template. |
154 | 158 | require_once($sourcedir . '/ManageServer.php'); |
@@ -207,8 +211,9 @@ discard block |
||
207 | 211 | foreach ($_POST['smiley_set'] as $id => $val) |
208 | 212 | { |
209 | 213 | // If this is the set you've marked as default, or the only one remaining, you can't delete it |
210 | - if ($modSettings['smiley_sets_default'] != $set_paths[$id] && count($set_paths) != 1 && isset($set_paths[$id], $set_names[$id])) |
|
211 | - unset($set_paths[$id], $set_names[$id]); |
|
214 | + if ($modSettings['smiley_sets_default'] != $set_paths[$id] && count($set_paths) != 1 && isset($set_paths[$id], $set_names[$id])) { |
|
215 | + unset($set_paths[$id], $set_names[$id]); |
|
216 | + } |
|
212 | 217 | } |
213 | 218 | |
214 | 219 | // Shortcut... array_merge() on a single array resets the numeric keys |
@@ -222,8 +227,9 @@ discard block |
||
222 | 227 | )); |
223 | 228 | } |
224 | 229 | // Add a new smiley set. |
225 | - elseif (!empty($_POST['add'])) |
|
226 | - $context['sub_action'] = 'modifyset'; |
|
230 | + elseif (!empty($_POST['add'])) { |
|
231 | + $context['sub_action'] = 'modifyset'; |
|
232 | + } |
|
227 | 233 | // Create or modify a smiley set. |
228 | 234 | elseif (isset($_POST['set'])) |
229 | 235 | { |
@@ -233,8 +239,9 @@ discard block |
||
233 | 239 | // Create a new smiley set. |
234 | 240 | if ($_POST['set'] == -1 && isset($_POST['smiley_sets_path'])) |
235 | 241 | { |
236 | - if (in_array($_POST['smiley_sets_path'], $set_paths)) |
|
237 | - fatal_lang_error('smiley_set_already_exists'); |
|
242 | + if (in_array($_POST['smiley_sets_path'], $set_paths)) { |
|
243 | + fatal_lang_error('smiley_set_already_exists'); |
|
244 | + } |
|
238 | 245 | |
239 | 246 | updateSettings(array( |
240 | 247 | 'smiley_sets_known' => $modSettings['smiley_sets_known'] . ',' . $_POST['smiley_sets_path'], |
@@ -246,12 +253,14 @@ discard block |
||
246 | 253 | else |
247 | 254 | { |
248 | 255 | // Make sure the smiley set exists. |
249 | - if (!isset($set_paths[$_POST['set']]) || !isset($set_names[$_POST['set']])) |
|
250 | - fatal_lang_error('smiley_set_not_found'); |
|
256 | + if (!isset($set_paths[$_POST['set']]) || !isset($set_names[$_POST['set']])) { |
|
257 | + fatal_lang_error('smiley_set_not_found'); |
|
258 | + } |
|
251 | 259 | |
252 | 260 | // Make sure the path is not yet used by another smileyset. |
253 | - if (in_array($_POST['smiley_sets_path'], $set_paths) && $_POST['smiley_sets_path'] != $set_paths[$_POST['set']]) |
|
254 | - fatal_lang_error('smiley_set_path_already_used'); |
|
261 | + if (in_array($_POST['smiley_sets_path'], $set_paths) && $_POST['smiley_sets_path'] != $set_paths[$_POST['set']]) { |
|
262 | + fatal_lang_error('smiley_set_path_already_used'); |
|
263 | + } |
|
255 | 264 | |
256 | 265 | $set_paths[$_POST['set']] = $_POST['smiley_sets_path']; |
257 | 266 | $set_names[$_POST['set']] = $_POST['smiley_sets_name']; |
@@ -263,8 +272,9 @@ discard block |
||
263 | 272 | } |
264 | 273 | |
265 | 274 | // The user might have checked to also import smileys. |
266 | - if (!empty($_POST['smiley_sets_import'])) |
|
267 | - ImportSmileys($_POST['smiley_sets_path']); |
|
275 | + if (!empty($_POST['smiley_sets_import'])) { |
|
276 | + ImportSmileys($_POST['smiley_sets_path']); |
|
277 | + } |
|
268 | 278 | } |
269 | 279 | cache_put_data('parsing_smileys', null, 480); |
270 | 280 | cache_put_data('posting_smileys', null, 480); |
@@ -273,13 +283,14 @@ discard block |
||
273 | 283 | // Load all available smileysets... |
274 | 284 | $context['smiley_sets'] = explode(',', $modSettings['smiley_sets_known']); |
275 | 285 | $set_names = explode("\n", $modSettings['smiley_sets_names']); |
276 | - foreach ($context['smiley_sets'] as $i => $set) |
|
277 | - $context['smiley_sets'][$i] = array( |
|
286 | + foreach ($context['smiley_sets'] as $i => $set) { |
|
287 | + $context['smiley_sets'][$i] = array( |
|
278 | 288 | 'id' => $i, |
279 | 289 | 'path' => $smcFunc['htmlspecialchars']($set), |
280 | 290 | 'name' => $smcFunc['htmlspecialchars']($set_names[$i]), |
281 | 291 | 'selected' => $set == $modSettings['smiley_sets_default'] |
282 | 292 | ); |
293 | + } |
|
283 | 294 | |
284 | 295 | // Importing any smileys from an existing set? |
285 | 296 | if ($context['sub_action'] == 'import') |
@@ -290,8 +301,9 @@ discard block |
||
290 | 301 | $_GET['set'] = (int) $_GET['set']; |
291 | 302 | |
292 | 303 | // Sanity check - then import. |
293 | - if (isset($context['smiley_sets'][$_GET['set']])) |
|
294 | - ImportSmileys(un_htmlspecialchars($context['smiley_sets'][$_GET['set']]['path'])); |
|
304 | + if (isset($context['smiley_sets'][$_GET['set']])) { |
|
305 | + ImportSmileys(un_htmlspecialchars($context['smiley_sets'][$_GET['set']]['path'])); |
|
306 | + } |
|
295 | 307 | |
296 | 308 | // Force the process to continue. |
297 | 309 | $context['sub_action'] = 'modifyset'; |
@@ -301,15 +313,15 @@ discard block |
||
301 | 313 | if ($context['sub_action'] == 'modifyset') |
302 | 314 | { |
303 | 315 | $_GET['set'] = !isset($_GET['set']) ? -1 : (int) $_GET['set']; |
304 | - if ($_GET['set'] == -1 || !isset($context['smiley_sets'][$_GET['set']])) |
|
305 | - $context['current_set'] = array( |
|
316 | + if ($_GET['set'] == -1 || !isset($context['smiley_sets'][$_GET['set']])) { |
|
317 | + $context['current_set'] = array( |
|
306 | 318 | 'id' => '-1', |
307 | 319 | 'path' => '', |
308 | 320 | 'name' => '', |
309 | 321 | 'selected' => false, |
310 | 322 | 'is_new' => true, |
311 | 323 | ); |
312 | - else |
|
324 | + } else |
|
313 | 325 | { |
314 | 326 | $context['current_set'] = &$context['smiley_sets'][$_GET['set']]; |
315 | 327 | $context['current_set']['is_new'] = false; |
@@ -321,13 +333,15 @@ discard block |
||
321 | 333 | $dir = dir($modSettings['smileys_dir'] . '/' . $context['current_set']['path']); |
322 | 334 | while ($entry = $dir->read()) |
323 | 335 | { |
324 | - if (in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) |
|
325 | - $smileys[strtolower($entry)] = $entry; |
|
336 | + if (in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) { |
|
337 | + $smileys[strtolower($entry)] = $entry; |
|
338 | + } |
|
326 | 339 | } |
327 | 340 | $dir->close(); |
328 | 341 | |
329 | - if (empty($smileys)) |
|
330 | - fatal_lang_error('smiley_set_dir_not_found', false, array($context['current_set']['name'])); |
|
342 | + if (empty($smileys)) { |
|
343 | + fatal_lang_error('smiley_set_dir_not_found', false, array($context['current_set']['name'])); |
|
344 | + } |
|
331 | 345 | |
332 | 346 | // Exclude the smileys that are already in the database. |
333 | 347 | $request = $smcFunc['db_query']('', ' |
@@ -338,9 +352,10 @@ discard block |
||
338 | 352 | 'smiley_list' => $smileys, |
339 | 353 | ) |
340 | 354 | ); |
341 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
342 | - if (isset($smileys[strtolower($row['filename'])])) |
|
355 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
356 | + if (isset($smileys[strtolower($row['filename'])])) |
|
343 | 357 | unset($smileys[strtolower($row['filename'])]); |
358 | + } |
|
344 | 359 | $smcFunc['db_free_result']($request); |
345 | 360 | |
346 | 361 | $context['current_set']['can_import'] = count($smileys); |
@@ -355,13 +370,14 @@ discard block |
||
355 | 370 | $dir = dir($modSettings['smileys_dir']); |
356 | 371 | while ($entry = $dir->read()) |
357 | 372 | { |
358 | - if (!in_array($entry, array('.', '..')) && is_dir($modSettings['smileys_dir'] . '/' . $entry)) |
|
359 | - $context['smiley_set_dirs'][] = array( |
|
373 | + if (!in_array($entry, array('.', '..')) && is_dir($modSettings['smileys_dir'] . '/' . $entry)) { |
|
374 | + $context['smiley_set_dirs'][] = array( |
|
360 | 375 | 'id' => $entry, |
361 | 376 | 'path' => $modSettings['smileys_dir'] . '/' . $entry, |
362 | 377 | 'selectable' => $entry == $context['current_set']['path'] || !in_array($entry, explode(',', $modSettings['smiley_sets_known'])), |
363 | 378 | 'current' => $entry == $context['current_set']['path'], |
364 | 379 | ); |
380 | + } |
|
365 | 381 | } |
366 | 382 | $dir->close(); |
367 | 383 | } |
@@ -371,8 +387,9 @@ discard block |
||
371 | 387 | createToken('admin-mss', 'request'); |
372 | 388 | |
373 | 389 | // In case we need to import smileys, we need to add the token in now. |
374 | - if (isset($context['current_set']['import_url'])) |
|
375 | - $context['current_set']['import_url'] .= ';' . $context['admin-mss_token_var'] . '=' . $context['admin-mss_token']; |
|
390 | + if (isset($context['current_set']['import_url'])) { |
|
391 | + $context['current_set']['import_url'] .= ';' . $context['admin-mss_token_var'] . '=' . $context['admin-mss_token']; |
|
392 | + } |
|
376 | 393 | |
377 | 394 | $listOptions = array( |
378 | 395 | 'id' => 'smiley_set_list', |
@@ -510,21 +527,23 @@ discard block |
||
510 | 527 | $cols['name'][] = $set_names[$i]; |
511 | 528 | } |
512 | 529 | $sort_flag = strpos($sort, 'DESC') === false ? SORT_ASC : SORT_DESC; |
513 | - if (substr($sort, 0, 4) === 'name') |
|
514 | - array_multisort($cols['name'], $sort_flag, SORT_REGULAR, $cols['path'], $cols['selected'], $cols['id']); |
|
515 | - elseif (substr($sort, 0, 4) === 'path') |
|
516 | - array_multisort($cols['path'], $sort_flag, SORT_REGULAR, $cols['name'], $cols['selected'], $cols['id']); |
|
517 | - else |
|
518 | - array_multisort($cols['selected'], $sort_flag, SORT_REGULAR, $cols['path'], $cols['name'], $cols['id']); |
|
530 | + if (substr($sort, 0, 4) === 'name') { |
|
531 | + array_multisort($cols['name'], $sort_flag, SORT_REGULAR, $cols['path'], $cols['selected'], $cols['id']); |
|
532 | + } elseif (substr($sort, 0, 4) === 'path') { |
|
533 | + array_multisort($cols['path'], $sort_flag, SORT_REGULAR, $cols['name'], $cols['selected'], $cols['id']); |
|
534 | + } else { |
|
535 | + array_multisort($cols['selected'], $sort_flag, SORT_REGULAR, $cols['path'], $cols['name'], $cols['id']); |
|
536 | + } |
|
519 | 537 | |
520 | 538 | $smiley_sets = array(); |
521 | - foreach ($cols['id'] as $i => $id) |
|
522 | - $smiley_sets[] = array( |
|
539 | + foreach ($cols['id'] as $i => $id) { |
|
540 | + $smiley_sets[] = array( |
|
523 | 541 | 'id' => $id, |
524 | 542 | 'path' => $cols['path'][$i], |
525 | 543 | 'name' => $cols['name'][$i], |
526 | 544 | 'selected' => $cols['path'][$i] == $modSettings['smiley_sets_default'] |
527 | 545 | ); |
546 | + } |
|
528 | 547 | |
529 | 548 | return $smiley_sets; |
530 | 549 | } |
@@ -553,13 +572,14 @@ discard block |
||
553 | 572 | $context['smileys_dir_found'] = is_dir($context['smileys_dir']); |
554 | 573 | $context['smiley_sets'] = explode(',', $modSettings['smiley_sets_known']); |
555 | 574 | $set_names = explode("\n", $modSettings['smiley_sets_names']); |
556 | - foreach ($context['smiley_sets'] as $i => $set) |
|
557 | - $context['smiley_sets'][$i] = array( |
|
575 | + foreach ($context['smiley_sets'] as $i => $set) { |
|
576 | + $context['smiley_sets'][$i] = array( |
|
558 | 577 | 'id' => $i, |
559 | 578 | 'path' => $smcFunc['htmlspecialchars']($set), |
560 | 579 | 'name' => $smcFunc['htmlspecialchars']($set_names[$i]), |
561 | 580 | 'selected' => $set == $modSettings['smiley_sets_default'] |
562 | 581 | ); |
582 | + } |
|
563 | 583 | |
564 | 584 | // Submitting a form? |
565 | 585 | if (isset($_POST[$context['session_var']], $_POST['smiley_code'])) |
@@ -575,8 +595,9 @@ discard block |
||
575 | 595 | $_POST['smiley_filename'] = htmltrim__recursive($_POST['smiley_filename']); |
576 | 596 | |
577 | 597 | // Make sure some code was entered. |
578 | - if (empty($_POST['smiley_code'])) |
|
579 | - fatal_lang_error('smiley_has_no_code'); |
|
598 | + if (empty($_POST['smiley_code'])) { |
|
599 | + fatal_lang_error('smiley_has_no_code'); |
|
600 | + } |
|
580 | 601 | |
581 | 602 | // Check whether the new code has duplicates. It should be unique. |
582 | 603 | $request = $smcFunc['db_query']('', ' |
@@ -588,8 +609,9 @@ discard block |
||
588 | 609 | 'smiley_code' => $_POST['smiley_code'], |
589 | 610 | ) |
590 | 611 | ); |
591 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
592 | - fatal_lang_error('smiley_not_unique'); |
|
612 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
613 | + fatal_lang_error('smiley_not_unique'); |
|
614 | + } |
|
593 | 615 | $smcFunc['db_free_result']($request); |
594 | 616 | |
595 | 617 | // If we are uploading - check all the smiley sets are writable! |
@@ -598,38 +620,44 @@ discard block |
||
598 | 620 | $writeErrors = array(); |
599 | 621 | foreach ($context['smiley_sets'] as $set) |
600 | 622 | { |
601 | - if (!is_writable($context['smileys_dir'] . '/' . un_htmlspecialchars($set['path']))) |
|
602 | - $writeErrors[] = $set['path']; |
|
623 | + if (!is_writable($context['smileys_dir'] . '/' . un_htmlspecialchars($set['path']))) { |
|
624 | + $writeErrors[] = $set['path']; |
|
625 | + } |
|
626 | + } |
|
627 | + if (!empty($writeErrors)) { |
|
628 | + fatal_lang_error('smileys_upload_error_notwritable', true, array(implode(', ', $writeErrors))); |
|
603 | 629 | } |
604 | - if (!empty($writeErrors)) |
|
605 | - fatal_lang_error('smileys_upload_error_notwritable', true, array(implode(', ', $writeErrors))); |
|
606 | 630 | } |
607 | 631 | |
608 | 632 | // Uploading just one smiley for all of them? |
609 | 633 | if (isset($_POST['sameall']) && isset($_FILES['uploadSmiley']['name']) && $_FILES['uploadSmiley']['name'] != '') |
610 | 634 | { |
611 | - if (!is_uploaded_file($_FILES['uploadSmiley']['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['uploadSmiley']['tmp_name']))) |
|
612 | - fatal_lang_error('smileys_upload_error'); |
|
635 | + if (!is_uploaded_file($_FILES['uploadSmiley']['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['uploadSmiley']['tmp_name']))) { |
|
636 | + fatal_lang_error('smileys_upload_error'); |
|
637 | + } |
|
613 | 638 | |
614 | 639 | // Sorry, no spaces, dots, or anything else but letters allowed. |
615 | 640 | $_FILES['uploadSmiley']['name'] = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $_FILES['uploadSmiley']['name']); |
616 | 641 | |
617 | 642 | // We only allow image files - it's THAT simple - no messing around here... |
618 | - if (!in_array(strtolower(substr(strrchr($_FILES['uploadSmiley']['name'], '.'), 1)), $allowedTypes)) |
|
619 | - fatal_lang_error('smileys_upload_error_types', false, array(implode(', ', $allowedTypes))); |
|
643 | + if (!in_array(strtolower(substr(strrchr($_FILES['uploadSmiley']['name'], '.'), 1)), $allowedTypes)) { |
|
644 | + fatal_lang_error('smileys_upload_error_types', false, array(implode(', ', $allowedTypes))); |
|
645 | + } |
|
620 | 646 | |
621 | 647 | // We only need the filename... |
622 | 648 | $destName = basename($_FILES['uploadSmiley']['name']); |
623 | 649 | |
624 | 650 | // Make sure they aren't trying to upload a nasty file - for their own good here! |
625 | - if (in_array(strtolower($destName), $disabledFiles)) |
|
626 | - fatal_lang_error('smileys_upload_error_illegal'); |
|
651 | + if (in_array(strtolower($destName), $disabledFiles)) { |
|
652 | + fatal_lang_error('smileys_upload_error_illegal'); |
|
653 | + } |
|
627 | 654 | |
628 | 655 | // Check if the file already exists... and if not move it to EVERY smiley set directory. |
629 | 656 | $i = 0; |
630 | 657 | // Keep going until we find a set the file doesn't exist in. (or maybe it exists in all of them?) |
631 | - while (isset($context['smiley_sets'][$i]) && file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($context['smiley_sets'][$i]['path']) . '/' . $destName)) |
|
632 | - $i++; |
|
658 | + while (isset($context['smiley_sets'][$i]) && file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($context['smiley_sets'][$i]['path']) . '/' . $destName)) { |
|
659 | + $i++; |
|
660 | + } |
|
633 | 661 | |
634 | 662 | // Okay, we're going to put the smiley right here, since it's not there yet! |
635 | 663 | if (isset($context['smiley_sets'][$i]['path'])) |
@@ -644,8 +672,9 @@ discard block |
||
644 | 672 | $currentPath = $context['smileys_dir'] . '/' . un_htmlspecialchars($context['smiley_sets'][$i]['path']) . '/' . $destName; |
645 | 673 | |
646 | 674 | // The file is already there! Don't overwrite it! |
647 | - if (file_exists($currentPath)) |
|
648 | - continue; |
|
675 | + if (file_exists($currentPath)) { |
|
676 | + continue; |
|
677 | + } |
|
649 | 678 | |
650 | 679 | // Okay, so copy the first one we made to here. |
651 | 680 | copy($smileyLocation, $currentPath); |
@@ -662,13 +691,15 @@ discard block |
||
662 | 691 | $newName = ''; |
663 | 692 | foreach ($_FILES as $name => $data) |
664 | 693 | { |
665 | - if ($_FILES[$name]['name'] == '') |
|
666 | - fatal_lang_error('smileys_upload_error_blank'); |
|
694 | + if ($_FILES[$name]['name'] == '') { |
|
695 | + fatal_lang_error('smileys_upload_error_blank'); |
|
696 | + } |
|
667 | 697 | |
668 | - if (empty($newName)) |
|
669 | - $newName = basename($_FILES[$name]['name']); |
|
670 | - elseif (basename($_FILES[$name]['name']) != $newName) |
|
671 | - fatal_lang_error('smileys_upload_error_name'); |
|
698 | + if (empty($newName)) { |
|
699 | + $newName = basename($_FILES[$name]['name']); |
|
700 | + } elseif (basename($_FILES[$name]['name']) != $newName) { |
|
701 | + fatal_lang_error('smileys_upload_error_name'); |
|
702 | + } |
|
672 | 703 | } |
673 | 704 | |
674 | 705 | foreach ($context['smiley_sets'] as $i => $set) |
@@ -676,31 +707,36 @@ discard block |
||
676 | 707 | $set['name'] = un_htmlspecialchars($set['name']); |
677 | 708 | $set['path'] = un_htmlspecialchars($set['path']); |
678 | 709 | |
679 | - if (!isset($_FILES['individual_' . $set['name']]['name']) || $_FILES['individual_' . $set['name']]['name'] == '') |
|
680 | - continue; |
|
710 | + if (!isset($_FILES['individual_' . $set['name']]['name']) || $_FILES['individual_' . $set['name']]['name'] == '') { |
|
711 | + continue; |
|
712 | + } |
|
681 | 713 | |
682 | 714 | // Got one... |
683 | - if (!is_uploaded_file($_FILES['individual_' . $set['name']]['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['individual_' . $set['name']]['tmp_name']))) |
|
684 | - fatal_lang_error('smileys_upload_error'); |
|
715 | + if (!is_uploaded_file($_FILES['individual_' . $set['name']]['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['individual_' . $set['name']]['tmp_name']))) { |
|
716 | + fatal_lang_error('smileys_upload_error'); |
|
717 | + } |
|
685 | 718 | |
686 | 719 | // Sorry, no spaces, dots, or anything else but letters allowed. |
687 | 720 | $_FILES['individual_' . $set['name']]['name'] = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $_FILES['individual_' . $set['name']]['name']); |
688 | 721 | |
689 | 722 | // We only allow image files - it's THAT simple - no messing around here... |
690 | - if (!in_array(strtolower(substr(strrchr($_FILES['individual_' . $set['name']]['name'], '.'), 1)), $allowedTypes)) |
|
691 | - fatal_lang_error('smileys_upload_error_types', false, array(implode(', ', $allowedTypes))); |
|
723 | + if (!in_array(strtolower(substr(strrchr($_FILES['individual_' . $set['name']]['name'], '.'), 1)), $allowedTypes)) { |
|
724 | + fatal_lang_error('smileys_upload_error_types', false, array(implode(', ', $allowedTypes))); |
|
725 | + } |
|
692 | 726 | |
693 | 727 | // We only need the filename... |
694 | 728 | $destName = basename($_FILES['individual_' . $set['name']]['name']); |
695 | 729 | |
696 | 730 | // Make sure they aren't trying to upload a nasty file - for their own good here! |
697 | - if (in_array(strtolower($destName), $disabledFiles)) |
|
698 | - fatal_lang_error('smileys_upload_error_illegal'); |
|
731 | + if (in_array(strtolower($destName), $disabledFiles)) { |
|
732 | + fatal_lang_error('smileys_upload_error_illegal'); |
|
733 | + } |
|
699 | 734 | |
700 | 735 | // If the file exists - ignore it. |
701 | 736 | $smileyLocation = $context['smileys_dir'] . '/' . $set['path'] . '/' . $destName; |
702 | - if (file_exists($smileyLocation)) |
|
703 | - continue; |
|
737 | + if (file_exists($smileyLocation)) { |
|
738 | + continue; |
|
739 | + } |
|
704 | 740 | |
705 | 741 | // Finally - move the image! |
706 | 742 | move_uploaded_file($_FILES['individual_' . $set['name']]['tmp_name'], $smileyLocation); |
@@ -712,8 +748,9 @@ discard block |
||
712 | 748 | } |
713 | 749 | |
714 | 750 | // Also make sure a filename was given. |
715 | - if (empty($_POST['smiley_filename'])) |
|
716 | - fatal_lang_error('smiley_has_no_filename'); |
|
751 | + if (empty($_POST['smiley_filename'])) { |
|
752 | + fatal_lang_error('smiley_has_no_filename'); |
|
753 | + } |
|
717 | 754 | |
718 | 755 | // Find the position on the right. |
719 | 756 | $smiley_order = '0'; |
@@ -732,8 +769,9 @@ discard block |
||
732 | 769 | list ($smiley_order) = $smcFunc['db_fetch_row']($request); |
733 | 770 | $smcFunc['db_free_result']($request); |
734 | 771 | |
735 | - if (empty($smiley_order)) |
|
736 | - $smiley_order = '0'; |
|
772 | + if (empty($smiley_order)) { |
|
773 | + $smiley_order = '0'; |
|
774 | + } |
|
737 | 775 | } |
738 | 776 | $smcFunc['db_insert']('', |
739 | 777 | '{db_prefix}smileys', |
@@ -761,17 +799,19 @@ discard block |
||
761 | 799 | { |
762 | 800 | foreach ($context['smiley_sets'] as $smiley_set) |
763 | 801 | { |
764 | - if (!file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path']))) |
|
765 | - continue; |
|
802 | + if (!file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path']))) { |
|
803 | + continue; |
|
804 | + } |
|
766 | 805 | |
767 | 806 | $dir = dir($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path'])); |
768 | 807 | while ($entry = $dir->read()) |
769 | 808 | { |
770 | - if (!in_array($entry, $context['filenames']) && in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) |
|
771 | - $context['filenames'][strtolower($entry)] = array( |
|
809 | + if (!in_array($entry, $context['filenames']) && in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) { |
|
810 | + $context['filenames'][strtolower($entry)] = array( |
|
772 | 811 | 'id' => $smcFunc['htmlspecialchars']($entry), |
773 | 812 | 'selected' => false, |
774 | 813 | ); |
814 | + } |
|
775 | 815 | } |
776 | 816 | $dir->close(); |
777 | 817 | } |
@@ -809,17 +849,19 @@ discard block |
||
809 | 849 | // Changing the selected smileys? |
810 | 850 | if (isset($_POST['smiley_action']) && !empty($_POST['checked_smileys'])) |
811 | 851 | { |
812 | - foreach ($_POST['checked_smileys'] as $id => $smiley_id) |
|
813 | - $_POST['checked_smileys'][$id] = (int) $smiley_id; |
|
852 | + foreach ($_POST['checked_smileys'] as $id => $smiley_id) { |
|
853 | + $_POST['checked_smileys'][$id] = (int) $smiley_id; |
|
854 | + } |
|
814 | 855 | |
815 | - if ($_POST['smiley_action'] == 'delete') |
|
816 | - $smcFunc['db_query']('', ' |
|
856 | + if ($_POST['smiley_action'] == 'delete') { |
|
857 | + $smcFunc['db_query']('', ' |
|
817 | 858 | DELETE FROM {db_prefix}smileys |
818 | 859 | WHERE id_smiley IN ({array_int:checked_smileys})', |
819 | 860 | array( |
820 | 861 | 'checked_smileys' => $_POST['checked_smileys'], |
821 | 862 | ) |
822 | 863 | ); |
864 | + } |
|
823 | 865 | // Changing the status of the smiley? |
824 | 866 | else |
825 | 867 | { |
@@ -829,8 +871,8 @@ discard block |
||
829 | 871 | 'hidden' => 1, |
830 | 872 | 'popup' => 2 |
831 | 873 | ); |
832 | - if (isset($displayTypes[$_POST['smiley_action']])) |
|
833 | - $smcFunc['db_query']('', ' |
|
874 | + if (isset($displayTypes[$_POST['smiley_action']])) { |
|
875 | + $smcFunc['db_query']('', ' |
|
834 | 876 | UPDATE {db_prefix}smileys |
835 | 877 | SET hidden = {int:display_type} |
836 | 878 | WHERE id_smiley IN ({array_int:checked_smileys})', |
@@ -839,6 +881,7 @@ discard block |
||
839 | 881 | 'display_type' => $displayTypes[$_POST['smiley_action']], |
840 | 882 | ) |
841 | 883 | ); |
884 | + } |
|
842 | 885 | } |
843 | 886 | } |
844 | 887 | // Create/modify a smiley. |
@@ -864,12 +907,14 @@ discard block |
||
864 | 907 | $_POST['smiley_location'] = empty($_POST['smiley_location']) || $_POST['smiley_location'] > 2 || $_POST['smiley_location'] < 0 ? 0 : (int) $_POST['smiley_location']; |
865 | 908 | |
866 | 909 | // Make sure some code was entered. |
867 | - if (empty($_POST['smiley_code'])) |
|
868 | - fatal_lang_error('smiley_has_no_code'); |
|
910 | + if (empty($_POST['smiley_code'])) { |
|
911 | + fatal_lang_error('smiley_has_no_code'); |
|
912 | + } |
|
869 | 913 | |
870 | 914 | // Also make sure a filename was given. |
871 | - if (empty($_POST['smiley_filename'])) |
|
872 | - fatal_lang_error('smiley_has_no_filename'); |
|
915 | + if (empty($_POST['smiley_filename'])) { |
|
916 | + fatal_lang_error('smiley_has_no_filename'); |
|
917 | + } |
|
873 | 918 | |
874 | 919 | // Check whether the new code has duplicates. It should be unique. |
875 | 920 | $request = $smcFunc['db_query']('', ' |
@@ -883,8 +928,9 @@ discard block |
||
883 | 928 | 'smiley_code' => $_POST['smiley_code'], |
884 | 929 | ) |
885 | 930 | ); |
886 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
887 | - fatal_lang_error('smiley_not_unique'); |
|
931 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
932 | + fatal_lang_error('smiley_not_unique'); |
|
933 | + } |
|
888 | 934 | $smcFunc['db_free_result']($request); |
889 | 935 | |
890 | 936 | $smcFunc['db_query']('', ' |
@@ -913,13 +959,14 @@ discard block |
||
913 | 959 | // Load all known smiley sets. |
914 | 960 | $context['smiley_sets'] = explode(',', $modSettings['smiley_sets_known']); |
915 | 961 | $set_names = explode("\n", $modSettings['smiley_sets_names']); |
916 | - foreach ($context['smiley_sets'] as $i => $set) |
|
917 | - $context['smiley_sets'][$i] = array( |
|
962 | + foreach ($context['smiley_sets'] as $i => $set) { |
|
963 | + $context['smiley_sets'][$i] = array( |
|
918 | 964 | 'id' => $i, |
919 | 965 | 'path' => $smcFunc['htmlspecialchars']($set), |
920 | 966 | 'name' => $smcFunc['htmlspecialchars']($set_names[$i]), |
921 | 967 | 'selected' => $set == $modSettings['smiley_sets_default'] |
922 | 968 | ); |
969 | + } |
|
923 | 970 | |
924 | 971 | // Prepare overview of all (custom) smileys. |
925 | 972 | if ($context['sub_action'] == 'editsmileys') |
@@ -935,9 +982,10 @@ discard block |
||
935 | 982 | // Create a list of options for selecting smiley sets. |
936 | 983 | $smileyset_option_list = ' |
937 | 984 | <select name="set" onchange="changeSet(this.options[this.selectedIndex].value);">'; |
938 | - foreach ($context['smiley_sets'] as $smiley_set) |
|
939 | - $smileyset_option_list .= ' |
|
985 | + foreach ($context['smiley_sets'] as $smiley_set) { |
|
986 | + $smileyset_option_list .= ' |
|
940 | 987 | <option value="' . $smiley_set['path'] . '"' . ($modSettings['smiley_sets_default'] == $smiley_set['path'] ? ' selected' : '') . '>' . $smiley_set['name'] . '</option>'; |
988 | + } |
|
941 | 989 | $smileyset_option_list .= ' |
942 | 990 | </select>'; |
943 | 991 | |
@@ -999,12 +1047,13 @@ discard block |
||
999 | 1047 | 'data' => array( |
1000 | 1048 | 'function' => function ($rowData) use ($txt) |
1001 | 1049 | { |
1002 | - if (empty($rowData['hidden'])) |
|
1003 | - return $txt['smileys_location_form']; |
|
1004 | - elseif ($rowData['hidden'] == 1) |
|
1005 | - return $txt['smileys_location_hidden']; |
|
1006 | - else |
|
1007 | - return $txt['smileys_location_popup']; |
|
1050 | + if (empty($rowData['hidden'])) { |
|
1051 | + return $txt['smileys_location_form']; |
|
1052 | + } elseif ($rowData['hidden'] == 1) { |
|
1053 | + return $txt['smileys_location_hidden']; |
|
1054 | + } else { |
|
1055 | + return $txt['smileys_location_popup']; |
|
1056 | + } |
|
1008 | 1057 | }, |
1009 | 1058 | ), |
1010 | 1059 | 'sort' => array( |
@@ -1019,19 +1068,22 @@ discard block |
||
1019 | 1068 | 'data' => array( |
1020 | 1069 | 'function' => function ($rowData) use ($context, $txt, $modSettings, $smcFunc) |
1021 | 1070 | { |
1022 | - if (empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir'])) |
|
1023 | - return $smcFunc['htmlspecialchars']($rowData['description']); |
|
1071 | + if (empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir'])) { |
|
1072 | + return $smcFunc['htmlspecialchars']($rowData['description']); |
|
1073 | + } |
|
1024 | 1074 | |
1025 | 1075 | // Check if there are smileys missing in some sets. |
1026 | 1076 | $missing_sets = array(); |
1027 | - foreach ($context['smiley_sets'] as $smiley_set) |
|
1028 | - if (!file_exists(sprintf('%1$s/%2$s/%3$s', $modSettings['smileys_dir'], $smiley_set['path'], $rowData['filename']))) |
|
1077 | + foreach ($context['smiley_sets'] as $smiley_set) { |
|
1078 | + if (!file_exists(sprintf('%1$s/%2$s/%3$s', $modSettings['smileys_dir'], $smiley_set['path'], $rowData['filename']))) |
|
1029 | 1079 | $missing_sets[] = $smiley_set['path']; |
1080 | + } |
|
1030 | 1081 | |
1031 | 1082 | $description = $smcFunc['htmlspecialchars']($rowData['description']); |
1032 | 1083 | |
1033 | - if (!empty($missing_sets)) |
|
1034 | - $description .= sprintf('<br><span class="smalltext"><strong>%1$s:</strong> %2$s</span>', $txt['smileys_not_found_in_set'], implode(', ', $missing_sets)); |
|
1084 | + if (!empty($missing_sets)) { |
|
1085 | + $description .= sprintf('<br><span class="smalltext"><strong>%1$s:</strong> %2$s</span>', $txt['smileys_not_found_in_set'], implode(', ', $missing_sets)); |
|
1086 | + } |
|
1035 | 1087 | |
1036 | 1088 | return $description; |
1037 | 1089 | }, |
@@ -1147,13 +1199,14 @@ discard block |
||
1147 | 1199 | $context['smileys_dir_found'] = is_dir($context['smileys_dir']); |
1148 | 1200 | $context['smiley_sets'] = explode(',', $modSettings['smiley_sets_known']); |
1149 | 1201 | $set_names = explode("\n", $modSettings['smiley_sets_names']); |
1150 | - foreach ($context['smiley_sets'] as $i => $set) |
|
1151 | - $context['smiley_sets'][$i] = array( |
|
1202 | + foreach ($context['smiley_sets'] as $i => $set) { |
|
1203 | + $context['smiley_sets'][$i] = array( |
|
1152 | 1204 | 'id' => $i, |
1153 | 1205 | 'path' => $smcFunc['htmlspecialchars']($set), |
1154 | 1206 | 'name' => $smcFunc['htmlspecialchars']($set_names[$i]), |
1155 | 1207 | 'selected' => $set == $modSettings['smiley_sets_default'] |
1156 | 1208 | ); |
1209 | + } |
|
1157 | 1210 | |
1158 | 1211 | $context['selected_set'] = $modSettings['smiley_sets_default']; |
1159 | 1212 | |
@@ -1163,17 +1216,19 @@ discard block |
||
1163 | 1216 | { |
1164 | 1217 | foreach ($context['smiley_sets'] as $smiley_set) |
1165 | 1218 | { |
1166 | - if (!file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path']))) |
|
1167 | - continue; |
|
1219 | + if (!file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path']))) { |
|
1220 | + continue; |
|
1221 | + } |
|
1168 | 1222 | |
1169 | 1223 | $dir = dir($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path'])); |
1170 | 1224 | while ($entry = $dir->read()) |
1171 | 1225 | { |
1172 | - if (!in_array($entry, $context['filenames']) && in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) |
|
1173 | - $context['filenames'][strtolower($entry)] = array( |
|
1226 | + if (!in_array($entry, $context['filenames']) && in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) { |
|
1227 | + $context['filenames'][strtolower($entry)] = array( |
|
1174 | 1228 | 'id' => $smcFunc['htmlspecialchars']($entry), |
1175 | 1229 | 'selected' => false, |
1176 | 1230 | ); |
1231 | + } |
|
1177 | 1232 | } |
1178 | 1233 | $dir->close(); |
1179 | 1234 | } |
@@ -1188,8 +1243,9 @@ discard block |
||
1188 | 1243 | 'current_smiley' => (int) $_REQUEST['smiley'], |
1189 | 1244 | ) |
1190 | 1245 | ); |
1191 | - if ($smcFunc['db_num_rows']($request) != 1) |
|
1192 | - fatal_lang_error('smiley_not_found'); |
|
1246 | + if ($smcFunc['db_num_rows']($request) != 1) { |
|
1247 | + fatal_lang_error('smiley_not_found'); |
|
1248 | + } |
|
1193 | 1249 | $context['current_smiley'] = $smcFunc['db_fetch_assoc']($request); |
1194 | 1250 | $smcFunc['db_free_result']($request); |
1195 | 1251 | |
@@ -1197,8 +1253,9 @@ discard block |
||
1197 | 1253 | $context['current_smiley']['filename'] = $smcFunc['htmlspecialchars']($context['current_smiley']['filename']); |
1198 | 1254 | $context['current_smiley']['description'] = $smcFunc['htmlspecialchars']($context['current_smiley']['description']); |
1199 | 1255 | |
1200 | - if (isset($context['filenames'][strtolower($context['current_smiley']['filename'])])) |
|
1201 | - $context['filenames'][strtolower($context['current_smiley']['filename'])]['selected'] = true; |
|
1256 | + if (isset($context['filenames'][strtolower($context['current_smiley']['filename'])])) { |
|
1257 | + $context['filenames'][strtolower($context['current_smiley']['filename'])]['selected'] = true; |
|
1258 | + } |
|
1202 | 1259 | } |
1203 | 1260 | } |
1204 | 1261 | |
@@ -1223,8 +1280,9 @@ discard block |
||
1223 | 1280 | ) |
1224 | 1281 | ); |
1225 | 1282 | $smileys = array(); |
1226 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1227 | - $smileys[] = $row; |
|
1283 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1284 | + $smileys[] = $row; |
|
1285 | + } |
|
1228 | 1286 | $smcFunc['db_free_result']($request); |
1229 | 1287 | |
1230 | 1288 | return $smileys; |
@@ -1264,8 +1322,9 @@ discard block |
||
1264 | 1322 | $_GET['location'] = empty($_GET['location']) || $_GET['location'] != 'popup' ? 0 : 2; |
1265 | 1323 | $_GET['source'] = empty($_GET['source']) ? 0 : (int) $_GET['source']; |
1266 | 1324 | |
1267 | - if (empty($_GET['source'])) |
|
1268 | - fatal_lang_error('smiley_not_found'); |
|
1325 | + if (empty($_GET['source'])) { |
|
1326 | + fatal_lang_error('smiley_not_found'); |
|
1327 | + } |
|
1269 | 1328 | |
1270 | 1329 | if (!empty($_GET['after'])) |
1271 | 1330 | { |
@@ -1281,12 +1340,12 @@ discard block |
||
1281 | 1340 | 'after_smiley' => $_GET['after'], |
1282 | 1341 | ) |
1283 | 1342 | ); |
1284 | - if ($smcFunc['db_num_rows']($request) != 1) |
|
1285 | - fatal_lang_error('smiley_not_found'); |
|
1343 | + if ($smcFunc['db_num_rows']($request) != 1) { |
|
1344 | + fatal_lang_error('smiley_not_found'); |
|
1345 | + } |
|
1286 | 1346 | list ($smiley_row, $smiley_order, $smileyLocation) = $smcFunc['db_fetch_row']($request); |
1287 | 1347 | $smcFunc['db_free_result']($request); |
1288 | - } |
|
1289 | - else |
|
1348 | + } else |
|
1290 | 1349 | { |
1291 | 1350 | $smiley_row = (int) $_GET['row']; |
1292 | 1351 | $smiley_order = -1; |
@@ -1360,14 +1419,15 @@ discard block |
||
1360 | 1419 | $context['move_smiley'] = empty($_REQUEST['move']) ? 0 : (int) $_REQUEST['move']; |
1361 | 1420 | |
1362 | 1421 | // Make sure all rows are sequential. |
1363 | - foreach (array_keys($context['smileys']) as $location) |
|
1364 | - $context['smileys'][$location] = array( |
|
1422 | + foreach (array_keys($context['smileys']) as $location) { |
|
1423 | + $context['smileys'][$location] = array( |
|
1365 | 1424 | 'id' => $location, |
1366 | 1425 | 'title' => $location == 'postform' ? $txt['smileys_location_form'] : $txt['smileys_location_popup'], |
1367 | 1426 | 'description' => $location == 'postform' ? $txt['smileys_location_form_description'] : $txt['smileys_location_popup_description'], |
1368 | 1427 | 'last_row' => count($context['smileys'][$location]['rows']), |
1369 | 1428 | 'rows' => array_values($context['smileys'][$location]['rows']), |
1370 | 1429 | ); |
1430 | + } |
|
1371 | 1431 | |
1372 | 1432 | // Check & fix smileys that are not ordered properly in the database. |
1373 | 1433 | foreach (array_keys($context['smileys']) as $location) |
@@ -1392,8 +1452,8 @@ discard block |
||
1392 | 1452 | $context['smileys'][$location]['rows'][$id][0]['row'] = $id; |
1393 | 1453 | } |
1394 | 1454 | // Make sure the smiley order is always sequential. |
1395 | - foreach ($smiley_row as $order_id => $smiley) |
|
1396 | - if ($order_id != $smiley['order']) |
|
1455 | + foreach ($smiley_row as $order_id => $smiley) { |
|
1456 | + if ($order_id != $smiley['order']) |
|
1397 | 1457 | $smcFunc['db_query']('', ' |
1398 | 1458 | UPDATE {db_prefix}smileys |
1399 | 1459 | SET smiley_order = {int:new_order} |
@@ -1403,6 +1463,7 @@ discard block |
||
1403 | 1463 | 'current_smiley' => $smiley['id'], |
1404 | 1464 | ) |
1405 | 1465 | ); |
1466 | + } |
|
1406 | 1467 | } |
1407 | 1468 | } |
1408 | 1469 | |
@@ -1436,19 +1497,20 @@ discard block |
||
1436 | 1497 | |
1437 | 1498 | // Check that the smiley is from simplemachines.org, for now... maybe add mirroring later. |
1438 | 1499 | // @ TODO: Our current xml files serve http links. Allowing both for now until we serve https. |
1439 | - if (preg_match('~^https?://[\w_\-]+\.simplemachines\.org/~', $_REQUEST['set_gz']) == 0 || strpos($_REQUEST['set_gz'], 'dlattach') !== false) |
|
1440 | - fatal_lang_error('not_on_simplemachines'); |
|
1500 | + if (preg_match('~^https?://[\w_\-]+\.simplemachines\.org/~', $_REQUEST['set_gz']) == 0 || strpos($_REQUEST['set_gz'], 'dlattach') !== false) { |
|
1501 | + fatal_lang_error('not_on_simplemachines'); |
|
1502 | + } |
|
1441 | 1503 | |
1442 | 1504 | $destination = $packagesdir . '/' . $base_name; |
1443 | 1505 | |
1444 | - if (file_exists($destination)) |
|
1445 | - fatal_lang_error('package_upload_error_exists'); |
|
1506 | + if (file_exists($destination)) { |
|
1507 | + fatal_lang_error('package_upload_error_exists'); |
|
1508 | + } |
|
1446 | 1509 | |
1447 | 1510 | // Let's copy it to the Packages directory |
1448 | 1511 | file_put_contents($destination, fetch_web_data($_REQUEST['set_gz'])); |
1449 | 1512 | $testing = true; |
1450 | - } |
|
1451 | - elseif (isset($_REQUEST['package'])) |
|
1513 | + } elseif (isset($_REQUEST['package'])) |
|
1452 | 1514 | { |
1453 | 1515 | $base_name = basename($_REQUEST['package']); |
1454 | 1516 | $name = $smcFunc['htmlspecialchars'](strtok(basename($_REQUEST['package']), '.')); |
@@ -1457,12 +1519,14 @@ discard block |
||
1457 | 1519 | $destination = $packagesdir . '/' . basename($_REQUEST['package']); |
1458 | 1520 | } |
1459 | 1521 | |
1460 | - if (empty($destination) || !file_exists($destination)) |
|
1461 | - fatal_lang_error('package_no_file', false); |
|
1522 | + if (empty($destination) || !file_exists($destination)) { |
|
1523 | + fatal_lang_error('package_no_file', false); |
|
1524 | + } |
|
1462 | 1525 | |
1463 | 1526 | // Make sure temp directory exists and is empty. |
1464 | - if (file_exists($packagesdir . '/temp')) |
|
1465 | - deltree($packagesdir . '/temp', false); |
|
1527 | + if (file_exists($packagesdir . '/temp')) { |
|
1528 | + deltree($packagesdir . '/temp', false); |
|
1529 | + } |
|
1466 | 1530 | |
1467 | 1531 | if (!mktree($packagesdir . '/temp', 0755)) |
1468 | 1532 | { |
@@ -1474,31 +1538,37 @@ discard block |
||
1474 | 1538 | create_chmod_control(array($packagesdir . '/temp/delme.tmp'), array('destination_url' => $scripturl . '?action=admin;area=smileys;sa=install;set_gz=' . $_REQUEST['set_gz'], 'crash_on_error' => true)); |
1475 | 1539 | |
1476 | 1540 | deltree($packagesdir . '/temp', false); |
1477 | - if (!mktree($packagesdir . '/temp', 0777)) |
|
1478 | - fatal_lang_error('package_cant_download', false); |
|
1541 | + if (!mktree($packagesdir . '/temp', 0777)) { |
|
1542 | + fatal_lang_error('package_cant_download', false); |
|
1543 | + } |
|
1479 | 1544 | } |
1480 | 1545 | } |
1481 | 1546 | |
1482 | 1547 | $extracted = read_tgz_file($destination, $packagesdir . '/temp'); |
1483 | - if (!$extracted) |
|
1484 | - fatal_lang_error('packageget_unable', false, array('https://custom.simplemachines.org/mods/index.php?action=search;type=12;basic_search=' . $name)); |
|
1485 | - if ($extracted && !file_exists($packagesdir . '/temp/package-info.xml')) |
|
1486 | - foreach ($extracted as $file) |
|
1548 | + if (!$extracted) { |
|
1549 | + fatal_lang_error('packageget_unable', false, array('https://custom.simplemachines.org/mods/index.php?action=search;type=12;basic_search=' . $name)); |
|
1550 | + } |
|
1551 | + if ($extracted && !file_exists($packagesdir . '/temp/package-info.xml')) { |
|
1552 | + foreach ($extracted as $file) |
|
1487 | 1553 | if (basename($file['filename']) == 'package-info.xml') |
1488 | 1554 | { |
1489 | 1555 | $base_path = dirname($file['filename']) . '/'; |
1556 | + } |
|
1490 | 1557 | break; |
1491 | 1558 | } |
1492 | 1559 | |
1493 | - if (!isset($base_path)) |
|
1494 | - $base_path = ''; |
|
1560 | + if (!isset($base_path)) { |
|
1561 | + $base_path = ''; |
|
1562 | + } |
|
1495 | 1563 | |
1496 | - if (!file_exists($packagesdir . '/temp/' . $base_path . 'package-info.xml')) |
|
1497 | - fatal_lang_error('package_get_error_missing_xml', false); |
|
1564 | + if (!file_exists($packagesdir . '/temp/' . $base_path . 'package-info.xml')) { |
|
1565 | + fatal_lang_error('package_get_error_missing_xml', false); |
|
1566 | + } |
|
1498 | 1567 | |
1499 | 1568 | $smileyInfo = getPackageInfo($context['filename']); |
1500 | - if (!is_array($smileyInfo)) |
|
1501 | - fatal_lang_error($smileyInfo); |
|
1569 | + if (!is_array($smileyInfo)) { |
|
1570 | + fatal_lang_error($smileyInfo); |
|
1571 | + } |
|
1502 | 1572 | |
1503 | 1573 | // See if it is installed? |
1504 | 1574 | $request = $smcFunc['db_query']('', ' |
@@ -1514,8 +1584,9 @@ discard block |
||
1514 | 1584 | ) |
1515 | 1585 | ); |
1516 | 1586 | |
1517 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
1518 | - fatal_lang_error('package_installed_warning1'); |
|
1587 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
1588 | + fatal_lang_error('package_installed_warning1'); |
|
1589 | + } |
|
1519 | 1590 | |
1520 | 1591 | // Everything is fine, now it's time to do something |
1521 | 1592 | $actions = parsePackageInfo($smileyInfo['xml'], true, 'install'); |
@@ -1530,23 +1601,23 @@ discard block |
||
1530 | 1601 | if ($action['type'] == 'readme' || $action['type'] == 'license') |
1531 | 1602 | { |
1532 | 1603 | $type = 'package_' . $action['type']; |
1533 | - if (file_exists($packagesdir . '/temp/' . $base_path . $action['filename'])) |
|
1534 | - $context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($packagesdir . '/temp/' . $base_path . $action['filename']), "\n\r")); |
|
1535 | - elseif (file_exists($action['filename'])) |
|
1536 | - $context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($action['filename']), "\n\r")); |
|
1604 | + if (file_exists($packagesdir . '/temp/' . $base_path . $action['filename'])) { |
|
1605 | + $context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($packagesdir . '/temp/' . $base_path . $action['filename']), "\n\r")); |
|
1606 | + } elseif (file_exists($action['filename'])) { |
|
1607 | + $context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($action['filename']), "\n\r")); |
|
1608 | + } |
|
1537 | 1609 | |
1538 | 1610 | if (!empty($action['parse_bbc'])) |
1539 | 1611 | { |
1540 | 1612 | require_once($sourcedir . '/Subs-Post.php'); |
1541 | 1613 | preparsecode($context[$type]); |
1542 | 1614 | $context[$type] = parse_bbc($context[$type]); |
1615 | + } else { |
|
1616 | + $context[$type] = nl2br($context[$type]); |
|
1543 | 1617 | } |
1544 | - else |
|
1545 | - $context[$type] = nl2br($context[$type]); |
|
1546 | 1618 | |
1547 | 1619 | continue; |
1548 | - } |
|
1549 | - elseif ($action['type'] == 'require-dir') |
|
1620 | + } elseif ($action['type'] == 'require-dir') |
|
1550 | 1621 | { |
1551 | 1622 | // Do this one... |
1552 | 1623 | $thisAction = array( |
@@ -1565,12 +1636,12 @@ discard block |
||
1565 | 1636 | ); |
1566 | 1637 | } |
1567 | 1638 | // @todo None given? |
1568 | - if (empty($thisAction['description'])) |
|
1569 | - $thisAction['description'] = isset($action['description']) ? $action['description'] : ''; |
|
1639 | + if (empty($thisAction['description'])) { |
|
1640 | + $thisAction['description'] = isset($action['description']) ? $action['description'] : ''; |
|
1641 | + } |
|
1570 | 1642 | |
1571 | 1643 | $context['actions'][] = $thisAction; |
1572 | - } |
|
1573 | - elseif ($action['type'] == 'credits') |
|
1644 | + } elseif ($action['type'] == 'credits') |
|
1574 | 1645 | { |
1575 | 1646 | // Time to build the billboard |
1576 | 1647 | $credits_tag = array( |
@@ -1630,12 +1701,14 @@ discard block |
||
1630 | 1701 | cache_put_data('posting_smileys', null, 480); |
1631 | 1702 | } |
1632 | 1703 | |
1633 | - if (file_exists($packagesdir . '/temp')) |
|
1634 | - deltree($packagesdir . '/temp'); |
|
1704 | + if (file_exists($packagesdir . '/temp')) { |
|
1705 | + deltree($packagesdir . '/temp'); |
|
1706 | + } |
|
1635 | 1707 | |
1636 | - if (!$testing) |
|
1637 | - redirectexit('action=admin;area=smileys'); |
|
1638 | -} |
|
1708 | + if (!$testing) { |
|
1709 | + redirectexit('action=admin;area=smileys'); |
|
1710 | + } |
|
1711 | + } |
|
1639 | 1712 | |
1640 | 1713 | /** |
1641 | 1714 | * A function to import new smileys from an existing directory into the database. |
@@ -1646,15 +1719,17 @@ discard block |
||
1646 | 1719 | { |
1647 | 1720 | global $modSettings, $smcFunc; |
1648 | 1721 | |
1649 | - if (empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir'] . '/' . $smileyPath)) |
|
1650 | - fatal_lang_error('smiley_set_unable_to_import'); |
|
1722 | + if (empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir'] . '/' . $smileyPath)) { |
|
1723 | + fatal_lang_error('smiley_set_unable_to_import'); |
|
1724 | + } |
|
1651 | 1725 | |
1652 | 1726 | $smileys = array(); |
1653 | 1727 | $dir = dir($modSettings['smileys_dir'] . '/' . $smileyPath); |
1654 | 1728 | while ($entry = $dir->read()) |
1655 | 1729 | { |
1656 | - if (in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) |
|
1657 | - $smileys[strtolower($entry)] = $entry; |
|
1730 | + if (in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) { |
|
1731 | + $smileys[strtolower($entry)] = $entry; |
|
1732 | + } |
|
1658 | 1733 | } |
1659 | 1734 | $dir->close(); |
1660 | 1735 | |
@@ -1667,9 +1742,10 @@ discard block |
||
1667 | 1742 | 'smiley_list' => $smileys, |
1668 | 1743 | ) |
1669 | 1744 | ); |
1670 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1671 | - if (isset($smileys[strtolower($row['filename'])])) |
|
1745 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1746 | + if (isset($smileys[strtolower($row['filename'])])) |
|
1672 | 1747 | unset($smileys[strtolower($row['filename'])]); |
1748 | + } |
|
1673 | 1749 | $smcFunc['db_free_result']($request); |
1674 | 1750 | |
1675 | 1751 | $request = $smcFunc['db_query']('', ' |
@@ -1686,9 +1762,10 @@ discard block |
||
1686 | 1762 | $smcFunc['db_free_result']($request); |
1687 | 1763 | |
1688 | 1764 | $new_smileys = array(); |
1689 | - foreach ($smileys as $smiley) |
|
1690 | - if (strlen($smiley) <= 48) |
|
1765 | + foreach ($smileys as $smiley) { |
|
1766 | + if (strlen($smiley) <= 48) |
|
1691 | 1767 | $new_smileys[] = array(':' . strtok($smiley, '.') . ':', $smiley, strtok($smiley, '.'), 0, ++$smiley_order); |
1768 | + } |
|
1692 | 1769 | |
1693 | 1770 | if (!empty($new_smileys)) |
1694 | 1771 | { |
@@ -1753,8 +1830,9 @@ discard block |
||
1753 | 1830 | if (isset($_POST['delete']) && !empty($_POST['checked_icons'])) |
1754 | 1831 | { |
1755 | 1832 | $deleteIcons = array(); |
1756 | - foreach ($_POST['checked_icons'] as $icon) |
|
1757 | - $deleteIcons[] = (int) $icon; |
|
1833 | + foreach ($_POST['checked_icons'] as $icon) { |
|
1834 | + $deleteIcons[] = (int) $icon; |
|
1835 | + } |
|
1758 | 1836 | |
1759 | 1837 | // Do the actual delete! |
1760 | 1838 | $smcFunc['db_query']('', ' |
@@ -1771,35 +1849,41 @@ discard block |
||
1771 | 1849 | $_GET['icon'] = (int) $_GET['icon']; |
1772 | 1850 | |
1773 | 1851 | // Do some preperation with the data... like check the icon exists *somewhere* |
1774 | - if (strpos($_POST['icon_filename'], '.png') !== false) |
|
1775 | - $_POST['icon_filename'] = substr($_POST['icon_filename'], 0, -4); |
|
1776 | - if (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon_filename'] . '.png')) |
|
1777 | - fatal_lang_error('icon_not_found'); |
|
1852 | + if (strpos($_POST['icon_filename'], '.png') !== false) { |
|
1853 | + $_POST['icon_filename'] = substr($_POST['icon_filename'], 0, -4); |
|
1854 | + } |
|
1855 | + if (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon_filename'] . '.png')) { |
|
1856 | + fatal_lang_error('icon_not_found'); |
|
1857 | + } |
|
1778 | 1858 | // There is a 16 character limit on message icons... |
1779 | - elseif (strlen($_POST['icon_filename']) > 16) |
|
1780 | - fatal_lang_error('icon_name_too_long'); |
|
1781 | - elseif ($_POST['icon_location'] == $_GET['icon'] && !empty($_GET['icon'])) |
|
1782 | - fatal_lang_error('icon_after_itself'); |
|
1859 | + elseif (strlen($_POST['icon_filename']) > 16) { |
|
1860 | + fatal_lang_error('icon_name_too_long'); |
|
1861 | + } elseif ($_POST['icon_location'] == $_GET['icon'] && !empty($_GET['icon'])) { |
|
1862 | + fatal_lang_error('icon_after_itself'); |
|
1863 | + } |
|
1783 | 1864 | |
1784 | 1865 | // First do the sorting... if this is an edit reduce the order of everything after it by one ;) |
1785 | 1866 | if ($_GET['icon'] != 0) |
1786 | 1867 | { |
1787 | 1868 | $oldOrder = $context['icons'][$_GET['icon']]['true_order']; |
1788 | - foreach ($context['icons'] as $id => $data) |
|
1789 | - if ($data['true_order'] > $oldOrder) |
|
1869 | + foreach ($context['icons'] as $id => $data) { |
|
1870 | + if ($data['true_order'] > $oldOrder) |
|
1790 | 1871 | $context['icons'][$id]['true_order']--; |
1872 | + } |
|
1791 | 1873 | } |
1792 | 1874 | |
1793 | 1875 | // If there are no existing icons and this is a new one, set the id to 1 (mainly for non-mysql) |
1794 | - if (empty($_GET['icon']) && empty($context['icons'])) |
|
1795 | - $_GET['icon'] = 1; |
|
1876 | + if (empty($_GET['icon']) && empty($context['icons'])) { |
|
1877 | + $_GET['icon'] = 1; |
|
1878 | + } |
|
1796 | 1879 | |
1797 | 1880 | // Get the new order. |
1798 | 1881 | $newOrder = $_POST['icon_location'] == 0 ? 0 : $context['icons'][$_POST['icon_location']]['true_order'] + 1; |
1799 | 1882 | // Do the same, but with the one that used to be after this icon, done to avoid conflict. |
1800 | - foreach ($context['icons'] as $id => $data) |
|
1801 | - if ($data['true_order'] >= $newOrder) |
|
1883 | + foreach ($context['icons'] as $id => $data) { |
|
1884 | + if ($data['true_order'] >= $newOrder) |
|
1802 | 1885 | $context['icons'][$id]['true_order']++; |
1886 | + } |
|
1803 | 1887 | |
1804 | 1888 | // Finally set the current icon's position! |
1805 | 1889 | $context['icons'][$_GET['icon']]['true_order'] = $newOrder; |
@@ -1817,8 +1901,7 @@ discard block |
||
1817 | 1901 | if ($id != 0) |
1818 | 1902 | { |
1819 | 1903 | $iconInsert[] = array($id, $icon['board_id'], $icon['title'], $icon['filename'], $icon['true_order']); |
1820 | - } |
|
1821 | - else |
|
1904 | + } else |
|
1822 | 1905 | { |
1823 | 1906 | $iconInsert_new[] = array($icon['board_id'], $icon['title'], $icon['filename'], $icon['true_order']); |
1824 | 1907 | } |
@@ -1843,8 +1926,9 @@ discard block |
||
1843 | 1926 | } |
1844 | 1927 | |
1845 | 1928 | // Unless we're adding a new thing, we'll escape |
1846 | - if (!isset($_POST['add'])) |
|
1847 | - redirectexit('action=admin;area=smileys;sa=editicons'); |
|
1929 | + if (!isset($_POST['add'])) { |
|
1930 | + redirectexit('action=admin;area=smileys;sa=editicons'); |
|
1931 | + } |
|
1848 | 1932 | } |
1849 | 1933 | |
1850 | 1934 | $context[$context['admin_menu_name']]['current_subsection'] = 'editicons'; |
@@ -1954,8 +2038,9 @@ discard block |
||
1954 | 2038 | $context['new_icon'] = !isset($_GET['icon']); |
1955 | 2039 | |
1956 | 2040 | // Get the properties of the current icon from the icon list. |
1957 | - if (!$context['new_icon']) |
|
1958 | - $context['icon'] = $context['icons'][$_GET['icon']]; |
|
2041 | + if (!$context['new_icon']) { |
|
2042 | + $context['icon'] = $context['icons'][$_GET['icon']]; |
|
2043 | + } |
|
1959 | 2044 | |
1960 | 2045 | // Get a list of boards needed for assigning this icon to a specific board. |
1961 | 2046 | $boardListOptions = array( |
@@ -1989,8 +2074,9 @@ discard block |
||
1989 | 2074 | ); |
1990 | 2075 | |
1991 | 2076 | $message_icons = array(); |
1992 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1993 | - $message_icons[] = $row; |
|
2077 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2078 | + $message_icons[] = $row; |
|
2079 | + } |
|
1994 | 2080 | $smcFunc['db_free_result']($request); |
1995 | 2081 | |
1996 | 2082 | return $message_icons; |
@@ -75,8 +75,9 @@ discard block |
||
75 | 75 | $upcontext['inactive_timeout'] = 10; |
76 | 76 | |
77 | 77 | // The helper is crucial. Include it first thing. |
78 | -if (!file_exists($upgrade_path . '/upgrade-helper.php')) |
|
78 | +if (!file_exists($upgrade_path . '/upgrade-helper.php')) { |
|
79 | 79 | die('upgrade-helper.php not found where it was expected: ' . $upgrade_path . '/upgrade-helper.php! Make sure you have uploaded ALL files from the upgrade package. The upgrader cannot continue.'); |
80 | +} |
|
80 | 81 | |
81 | 82 | require_once($upgrade_path . '/upgrade-helper.php'); |
82 | 83 | |
@@ -100,11 +101,14 @@ discard block |
||
100 | 101 | ini_set('default_socket_timeout', 900); |
101 | 102 | } |
102 | 103 | // Clean the upgrade path if this is from the client. |
103 | -if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) |
|
104 | - for ($i = 1; $i < $_SERVER['argc']; $i++) |
|
104 | +if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) { |
|
105 | + for ($i = 1; |
|
106 | +} |
|
107 | +$i < $_SERVER['argc']; $i++) |
|
105 | 108 | { |
106 | - if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) |
|
107 | - $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
109 | + if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) { |
|
110 | + $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
111 | + } |
|
108 | 112 | } |
109 | 113 | |
110 | 114 | // Are we from the client? |
@@ -112,16 +116,17 @@ discard block |
||
112 | 116 | { |
113 | 117 | $command_line = true; |
114 | 118 | $disable_security = true; |
115 | -} |
|
116 | -else |
|
119 | +} else { |
|
117 | 120 | $command_line = false; |
121 | +} |
|
118 | 122 | |
119 | 123 | // Load this now just because we can. |
120 | 124 | require_once($upgrade_path . '/Settings.php'); |
121 | 125 | |
122 | 126 | // We don't use "-utf8" anymore... Tweak the entry that may have been loaded by Settings.php |
123 | -if (isset($language)) |
|
127 | +if (isset($language)) { |
|
124 | 128 | $language = str_ireplace('-utf8', '', $language); |
129 | +} |
|
125 | 130 | |
126 | 131 | // Are we logged in? |
127 | 132 | if (isset($upgradeData)) |
@@ -129,10 +134,12 @@ discard block |
||
129 | 134 | $upcontext['user'] = json_decode(base64_decode($upgradeData), true); |
130 | 135 | |
131 | 136 | // Check for sensible values. |
132 | - if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) |
|
133 | - $upcontext['user']['started'] = time(); |
|
134 | - if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) |
|
135 | - $upcontext['user']['updated'] = 0; |
|
137 | + if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) { |
|
138 | + $upcontext['user']['started'] = time(); |
|
139 | + } |
|
140 | + if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) { |
|
141 | + $upcontext['user']['updated'] = 0; |
|
142 | + } |
|
136 | 143 | |
137 | 144 | $upcontext['started'] = $upcontext['user']['started']; |
138 | 145 | $upcontext['updated'] = $upcontext['user']['updated']; |
@@ -190,8 +197,9 @@ discard block |
||
190 | 197 | 'db_error_skip' => true, |
191 | 198 | ) |
192 | 199 | ); |
193 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
194 | - $modSettings[$row['variable']] = $row['value']; |
|
200 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
201 | + $modSettings[$row['variable']] = $row['value']; |
|
202 | + } |
|
195 | 203 | $smcFunc['db_free_result']($request); |
196 | 204 | } |
197 | 205 | |
@@ -201,10 +209,12 @@ discard block |
||
201 | 209 | $modSettings['theme_url'] = 'Themes/default'; |
202 | 210 | $modSettings['images_url'] = 'Themes/default/images'; |
203 | 211 | } |
204 | -if (!isset($settings['default_theme_url'])) |
|
212 | +if (!isset($settings['default_theme_url'])) { |
|
205 | 213 | $settings['default_theme_url'] = $modSettings['theme_url']; |
206 | -if (!isset($settings['default_theme_dir'])) |
|
214 | +} |
|
215 | +if (!isset($settings['default_theme_dir'])) { |
|
207 | 216 | $settings['default_theme_dir'] = $modSettings['theme_dir']; |
217 | +} |
|
208 | 218 | |
209 | 219 | $upcontext['is_large_forum'] = (empty($modSettings['smfVersion']) || $modSettings['smfVersion'] <= '1.1 RC1') && !empty($modSettings['totalMessages']) && $modSettings['totalMessages'] > 75000; |
210 | 220 | // Default title... |
@@ -222,13 +232,15 @@ discard block |
||
222 | 232 | $support_js = $upcontext['upgrade_status']['js']; |
223 | 233 | |
224 | 234 | // Only set this if the upgrader status says so. |
225 | - if (empty($is_debug)) |
|
226 | - $is_debug = $upcontext['upgrade_status']['debug']; |
|
235 | + if (empty($is_debug)) { |
|
236 | + $is_debug = $upcontext['upgrade_status']['debug']; |
|
237 | + } |
|
227 | 238 | |
228 | 239 | // Load the language. |
229 | - if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
230 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
231 | -} |
|
240 | + if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
241 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
242 | + } |
|
243 | + } |
|
232 | 244 | // Set the defaults. |
233 | 245 | else |
234 | 246 | { |
@@ -246,15 +258,18 @@ discard block |
||
246 | 258 | } |
247 | 259 | |
248 | 260 | // If this isn't the first stage see whether they are logging in and resuming. |
249 | -if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) |
|
261 | +if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) { |
|
250 | 262 | checkLogin(); |
263 | +} |
|
251 | 264 | |
252 | -if ($command_line) |
|
265 | +if ($command_line) { |
|
253 | 266 | cmdStep0(); |
267 | +} |
|
254 | 268 | |
255 | 269 | // Don't error if we're using xml. |
256 | -if (isset($_GET['xml'])) |
|
270 | +if (isset($_GET['xml'])) { |
|
257 | 271 | $upcontext['return_error'] = true; |
272 | +} |
|
258 | 273 | |
259 | 274 | // Loop through all the steps doing each one as required. |
260 | 275 | $upcontext['overall_percent'] = 0; |
@@ -275,9 +290,9 @@ discard block |
||
275 | 290 | } |
276 | 291 | |
277 | 292 | // Call the step and if it returns false that means pause! |
278 | - if (function_exists($step[2]) && $step[2]() === false) |
|
279 | - break; |
|
280 | - elseif (function_exists($step[2])) { |
|
293 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
294 | + break; |
|
295 | + } elseif (function_exists($step[2])) { |
|
281 | 296 | //Start each new step with this unset, so the 'normal' template is called first |
282 | 297 | unset($_GET['xml']); |
283 | 298 | $_GET['substep'] = 0; |
@@ -321,17 +336,18 @@ discard block |
||
321 | 336 | // This should not happen my dear... HELP ME DEVELOPERS!! |
322 | 337 | if (!empty($command_line)) |
323 | 338 | { |
324 | - if (function_exists('debug_print_backtrace')) |
|
325 | - debug_print_backtrace(); |
|
339 | + if (function_exists('debug_print_backtrace')) { |
|
340 | + debug_print_backtrace(); |
|
341 | + } |
|
326 | 342 | |
327 | 343 | echo "\n" . 'Error: Unexpected call to use the ' . (isset($upcontext['sub_template']) ? $upcontext['sub_template'] : '') . ' template. Please copy and paste all the text above and visit the SMF support forum to tell the Developers that they\'ve made a boo boo; they\'ll get you up and running again.'; |
328 | 344 | flush(); |
329 | 345 | die(); |
330 | 346 | } |
331 | 347 | |
332 | - if (!isset($_GET['xml'])) |
|
333 | - template_upgrade_above(); |
|
334 | - else |
|
348 | + if (!isset($_GET['xml'])) { |
|
349 | + template_upgrade_above(); |
|
350 | + } else |
|
335 | 351 | { |
336 | 352 | header('Content-Type: text/xml; charset=UTF-8'); |
337 | 353 | // Sadly we need to retain the $_GET data thanks to the old upgrade scripts. |
@@ -353,25 +369,29 @@ discard block |
||
353 | 369 | $upcontext['form_url'] = $upgradeurl . '?step=' . $upcontext['current_step'] . '&substep=' . $_GET['substep'] . '&data=' . base64_encode(json_encode($upcontext['upgrade_status'])); |
354 | 370 | |
355 | 371 | // Custom stuff to pass back? |
356 | - if (!empty($upcontext['query_string'])) |
|
357 | - $upcontext['form_url'] .= $upcontext['query_string']; |
|
372 | + if (!empty($upcontext['query_string'])) { |
|
373 | + $upcontext['form_url'] .= $upcontext['query_string']; |
|
374 | + } |
|
358 | 375 | |
359 | 376 | // Call the appropriate subtemplate |
360 | - if (is_callable('template_' . $upcontext['sub_template'])) |
|
361 | - call_user_func('template_' . $upcontext['sub_template']); |
|
362 | - else |
|
363 | - die('Upgrade aborted! Invalid template: template_' . $upcontext['sub_template']); |
|
377 | + if (is_callable('template_' . $upcontext['sub_template'])) { |
|
378 | + call_user_func('template_' . $upcontext['sub_template']); |
|
379 | + } else { |
|
380 | + die('Upgrade aborted! Invalid template: template_' . $upcontext['sub_template']); |
|
381 | + } |
|
364 | 382 | } |
365 | 383 | |
366 | 384 | // Was there an error? |
367 | - if (!empty($upcontext['forced_error_message'])) |
|
368 | - echo $upcontext['forced_error_message']; |
|
385 | + if (!empty($upcontext['forced_error_message'])) { |
|
386 | + echo $upcontext['forced_error_message']; |
|
387 | + } |
|
369 | 388 | |
370 | 389 | // Show the footer. |
371 | - if (!isset($_GET['xml'])) |
|
372 | - template_upgrade_below(); |
|
373 | - else |
|
374 | - template_xml_below(); |
|
390 | + if (!isset($_GET['xml'])) { |
|
391 | + template_upgrade_below(); |
|
392 | + } else { |
|
393 | + template_xml_below(); |
|
394 | + } |
|
375 | 395 | } |
376 | 396 | |
377 | 397 | |
@@ -383,15 +403,19 @@ discard block |
||
383 | 403 | $seconds = intval($active % 60); |
384 | 404 | |
385 | 405 | $totalTime = ''; |
386 | - if ($hours > 0) |
|
387 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
388 | - if ($minutes > 0) |
|
389 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
390 | - if ($seconds > 0) |
|
391 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
406 | + if ($hours > 0) { |
|
407 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
408 | + } |
|
409 | + if ($minutes > 0) { |
|
410 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
411 | + } |
|
412 | + if ($seconds > 0) { |
|
413 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
414 | + } |
|
392 | 415 | |
393 | - if (!empty($totalTime)) |
|
394 | - echo "\n" . 'Upgrade completed in ' . $totalTime . "\n"; |
|
416 | + if (!empty($totalTime)) { |
|
417 | + echo "\n" . 'Upgrade completed in ' . $totalTime . "\n"; |
|
418 | + } |
|
395 | 419 | } |
396 | 420 | |
397 | 421 | // Bang - gone! |
@@ -404,8 +428,9 @@ discard block |
||
404 | 428 | global $upgradeurl, $upcontext, $command_line; |
405 | 429 | |
406 | 430 | // Command line users can't be redirected. |
407 | - if ($command_line) |
|
408 | - upgradeExit(true); |
|
431 | + if ($command_line) { |
|
432 | + upgradeExit(true); |
|
433 | + } |
|
409 | 434 | |
410 | 435 | // Are we providing the core info? |
411 | 436 | if ($addForm) |
@@ -431,12 +456,14 @@ discard block |
||
431 | 456 | define('SMF', 1); |
432 | 457 | |
433 | 458 | // Start the session. |
434 | - if (@ini_get('session.save_handler') == 'user') |
|
435 | - @ini_set('session.save_handler', 'files'); |
|
459 | + if (@ini_get('session.save_handler') == 'user') { |
|
460 | + @ini_set('session.save_handler', 'files'); |
|
461 | + } |
|
436 | 462 | @session_start(); |
437 | 463 | |
438 | - if (empty($smcFunc)) |
|
439 | - $smcFunc = array(); |
|
464 | + if (empty($smcFunc)) { |
|
465 | + $smcFunc = array(); |
|
466 | + } |
|
440 | 467 | |
441 | 468 | // We need this for authentication and some upgrade code |
442 | 469 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -448,32 +475,36 @@ discard block |
||
448 | 475 | initialize_inputs(); |
449 | 476 | |
450 | 477 | // Get the database going! |
451 | - if (empty($db_type) || $db_type == 'mysqli') |
|
452 | - $db_type = 'mysql'; |
|
478 | + if (empty($db_type) || $db_type == 'mysqli') { |
|
479 | + $db_type = 'mysql'; |
|
480 | + } |
|
453 | 481 | |
454 | 482 | if (file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
455 | 483 | { |
456 | 484 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
457 | 485 | |
458 | 486 | // Make the connection... |
459 | - if (empty($db_connection)) |
|
460 | - $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true)); |
|
461 | - else |
|
462 | - // If we've returned here, ping/reconnect to be safe |
|
487 | + if (empty($db_connection)) { |
|
488 | + $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true)); |
|
489 | + } else { |
|
490 | + // If we've returned here, ping/reconnect to be safe |
|
463 | 491 | $smcFunc['db_ping']($db_connection); |
492 | + } |
|
464 | 493 | |
465 | 494 | // Oh dear god!! |
466 | - if ($db_connection === null) |
|
467 | - die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
495 | + if ($db_connection === null) { |
|
496 | + die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
497 | + } |
|
468 | 498 | |
469 | - if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) |
|
470 | - $smcFunc['db_query']('', ' |
|
499 | + if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) { |
|
500 | + $smcFunc['db_query']('', ' |
|
471 | 501 | SET NAMES {string:db_character_set}', |
472 | 502 | array( |
473 | 503 | 'db_error_skip' => true, |
474 | 504 | 'db_character_set' => $db_character_set, |
475 | 505 | ) |
476 | 506 | ); |
507 | + } |
|
477 | 508 | |
478 | 509 | // Load the modSettings data... |
479 | 510 | $request = $smcFunc['db_query']('', ' |
@@ -484,11 +515,11 @@ discard block |
||
484 | 515 | ) |
485 | 516 | ); |
486 | 517 | $modSettings = array(); |
487 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
488 | - $modSettings[$row['variable']] = $row['value']; |
|
518 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
519 | + $modSettings[$row['variable']] = $row['value']; |
|
520 | + } |
|
489 | 521 | $smcFunc['db_free_result']($request); |
490 | - } |
|
491 | - else |
|
522 | + } else |
|
492 | 523 | { |
493 | 524 | return throw_error('Cannot find ' . $sourcedir . '/Subs-Db-' . $db_type . '.php' . '. Please check you have uploaded all source files and have the correct paths set.'); |
494 | 525 | } |
@@ -502,9 +533,10 @@ discard block |
||
502 | 533 | cleanRequest(); |
503 | 534 | } |
504 | 535 | |
505 | - if (!isset($_GET['substep'])) |
|
506 | - $_GET['substep'] = 0; |
|
507 | -} |
|
536 | + if (!isset($_GET['substep'])) { |
|
537 | + $_GET['substep'] = 0; |
|
538 | + } |
|
539 | + } |
|
508 | 540 | |
509 | 541 | function initialize_inputs() |
510 | 542 | { |
@@ -534,8 +566,9 @@ discard block |
||
534 | 566 | $dh = opendir(dirname(__FILE__)); |
535 | 567 | while ($file = readdir($dh)) |
536 | 568 | { |
537 | - if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) |
|
538 | - @unlink(dirname(__FILE__) . '/' . $file); |
|
569 | + if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) { |
|
570 | + @unlink(dirname(__FILE__) . '/' . $file); |
|
571 | + } |
|
539 | 572 | } |
540 | 573 | closedir($dh); |
541 | 574 | |
@@ -564,8 +597,9 @@ discard block |
||
564 | 597 | $temp = 'upgrade_php?step'; |
565 | 598 | while (strlen($temp) > 4) |
566 | 599 | { |
567 | - if (isset($_GET[$temp])) |
|
568 | - unset($_GET[$temp]); |
|
600 | + if (isset($_GET[$temp])) { |
|
601 | + unset($_GET[$temp]); |
|
602 | + } |
|
569 | 603 | $temp = substr($temp, 1); |
570 | 604 | } |
571 | 605 | |
@@ -592,32 +626,39 @@ discard block |
||
592 | 626 | && @file_exists(dirname(__FILE__) . '/upgrade_2-1_' . $db_type . '.sql'); |
593 | 627 | |
594 | 628 | // Need legacy scripts? |
595 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) |
|
596 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
597 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) |
|
598 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
599 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) |
|
600 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
629 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) { |
|
630 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
631 | + } |
|
632 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) { |
|
633 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
634 | + } |
|
635 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) { |
|
636 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
637 | + } |
|
601 | 638 | |
602 | 639 | // We don't need "-utf8" files anymore... |
603 | 640 | $upcontext['language'] = str_ireplace('-utf8', '', $upcontext['language']); |
604 | 641 | |
605 | 642 | // This needs to exist! |
606 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
607 | - return throw_error('The upgrader could not find the "Install" language file for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
608 | - else |
|
609 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
643 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
644 | + return throw_error('The upgrader could not find the "Install" language file for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
645 | + } else { |
|
646 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
647 | + } |
|
610 | 648 | |
611 | - if (!$check) |
|
612 | - // Don't tell them what files exactly because it's a spot check - just like teachers don't tell which problems they are spot checking, that's dumb. |
|
649 | + if (!$check) { |
|
650 | + // Don't tell them what files exactly because it's a spot check - just like teachers don't tell which problems they are spot checking, that's dumb. |
|
613 | 651 | return throw_error('The upgrader was unable to find some crucial files.<br><br>Please make sure you uploaded all of the files included in the package, including the Themes, Sources, and other directories.'); |
652 | + } |
|
614 | 653 | |
615 | 654 | // Do they meet the install requirements? |
616 | - if (!php_version_check()) |
|
617 | - return throw_error('Warning! You do not appear to have a version of PHP installed on your webserver that meets SMF\'s minimum installations requirements.<br><br>Please ask your host to upgrade.'); |
|
655 | + if (!php_version_check()) { |
|
656 | + return throw_error('Warning! You do not appear to have a version of PHP installed on your webserver that meets SMF\'s minimum installations requirements.<br><br>Please ask your host to upgrade.'); |
|
657 | + } |
|
618 | 658 | |
619 | - if (!db_version_check()) |
|
620 | - return throw_error('Your ' . $databases[$db_type]['name'] . ' version does not meet the minimum requirements of SMF.<br><br>Please ask your host to upgrade.'); |
|
659 | + if (!db_version_check()) { |
|
660 | + return throw_error('Your ' . $databases[$db_type]['name'] . ' version does not meet the minimum requirements of SMF.<br><br>Please ask your host to upgrade.'); |
|
661 | + } |
|
621 | 662 | |
622 | 663 | // Do some checks to make sure they have proper privileges |
623 | 664 | db_extend('packages'); |
@@ -632,14 +673,16 @@ discard block |
||
632 | 673 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
633 | 674 | |
634 | 675 | // Sorry... we need CREATE, ALTER and DROP |
635 | - if (!$create || !$alter || !$drop) |
|
636 | - return throw_error('The ' . $databases[$db_type]['name'] . ' user you have set in Settings.php does not have proper privileges.<br><br>Please ask your host to give this user the ALTER, CREATE, and DROP privileges.'); |
|
676 | + if (!$create || !$alter || !$drop) { |
|
677 | + return throw_error('The ' . $databases[$db_type]['name'] . ' user you have set in Settings.php does not have proper privileges.<br><br>Please ask your host to give this user the ALTER, CREATE, and DROP privileges.'); |
|
678 | + } |
|
637 | 679 | |
638 | 680 | // Do a quick version spot check. |
639 | 681 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
640 | 682 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
641 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
642 | - return throw_error('The upgrader found some old or outdated files.<br><br>Please make certain you uploaded the new versions of all the files included in the package.'); |
|
683 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
684 | + return throw_error('The upgrader found some old or outdated files.<br><br>Please make certain you uploaded the new versions of all the files included in the package.'); |
|
685 | + } |
|
643 | 686 | |
644 | 687 | // What absolutely needs to be writable? |
645 | 688 | $writable_files = array( |
@@ -661,12 +704,13 @@ discard block |
||
661 | 704 | quickFileWritable($custom_av_dir); |
662 | 705 | |
663 | 706 | // Are we good now? |
664 | - if (!is_writable($custom_av_dir)) |
|
665 | - return throw_error(sprintf('The directory: %1$s has to be writable to continue the upgrade. Please make sure permissions are correctly set to allow this.', $custom_av_dir)); |
|
666 | - elseif ($need_settings_update) |
|
707 | + if (!is_writable($custom_av_dir)) { |
|
708 | + return throw_error(sprintf('The directory: %1$s has to be writable to continue the upgrade. Please make sure permissions are correctly set to allow this.', $custom_av_dir)); |
|
709 | + } elseif ($need_settings_update) |
|
667 | 710 | { |
668 | - if (!function_exists('cache_put_data')) |
|
669 | - require_once($sourcedir . '/Load.php'); |
|
711 | + if (!function_exists('cache_put_data')) { |
|
712 | + require_once($sourcedir . '/Load.php'); |
|
713 | + } |
|
670 | 714 | updateSettings(array('custom_avatar_dir' => $custom_av_dir)); |
671 | 715 | updateSettings(array('custom_avatar_url' => $custom_av_url)); |
672 | 716 | } |
@@ -675,28 +719,33 @@ discard block |
||
675 | 719 | |
676 | 720 | // Check the cache directory. |
677 | 721 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
678 | - if (!file_exists($cachedir_temp)) |
|
679 | - @mkdir($cachedir_temp); |
|
680 | - if (!file_exists($cachedir_temp)) |
|
681 | - return throw_error('The cache directory could not be found.<br><br>Please make sure you have a directory called "cache" in your forum directory before continuing.'); |
|
682 | - |
|
683 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
684 | - return throw_error('The upgrader was unable to find language files for the language specified in Settings.php.<br>SMF will not work without the primary language files installed.<br><br>Please either install them, or <a href="' . $upgradeurl . '?step=0;lang=english">use english instead</a>.'); |
|
685 | - elseif (!isset($_GET['skiplang'])) |
|
722 | + if (!file_exists($cachedir_temp)) { |
|
723 | + @mkdir($cachedir_temp); |
|
724 | + } |
|
725 | + if (!file_exists($cachedir_temp)) { |
|
726 | + return throw_error('The cache directory could not be found.<br><br>Please make sure you have a directory called "cache" in your forum directory before continuing.'); |
|
727 | + } |
|
728 | + |
|
729 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
730 | + return throw_error('The upgrader was unable to find language files for the language specified in Settings.php.<br>SMF will not work without the primary language files installed.<br><br>Please either install them, or <a href="' . $upgradeurl . '?step=0;lang=english">use english instead</a>.'); |
|
731 | + } elseif (!isset($_GET['skiplang'])) |
|
686 | 732 | { |
687 | 733 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
688 | 734 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
689 | 735 | |
690 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
691 | - return throw_error('The upgrader found some old or outdated language files, for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded the new versions of all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?skiplang">SKIP</a>] [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
736 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
737 | + return throw_error('The upgrader found some old or outdated language files, for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded the new versions of all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?skiplang">SKIP</a>] [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
738 | + } |
|
692 | 739 | } |
693 | 740 | |
694 | - if (!makeFilesWritable($writable_files)) |
|
695 | - return false; |
|
741 | + if (!makeFilesWritable($writable_files)) { |
|
742 | + return false; |
|
743 | + } |
|
696 | 744 | |
697 | 745 | // Check agreement.txt. (it may not exist, in which case $boarddir must be writable.) |
698 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
699 | - return throw_error('The upgrader was unable to obtain write access to agreement.txt.<br><br>If you are using a linux or unix based server, please ensure that the file is chmod\'d to 777, or if it does not exist that the directory this upgrader is in is 777.<br>If your server is running Windows, please ensure that the internet guest account has the proper permissions on it or its folder.'); |
|
746 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
747 | + return throw_error('The upgrader was unable to obtain write access to agreement.txt.<br><br>If you are using a linux or unix based server, please ensure that the file is chmod\'d to 777, or if it does not exist that the directory this upgrader is in is 777.<br>If your server is running Windows, please ensure that the internet guest account has the proper permissions on it or its folder.'); |
|
748 | + } |
|
700 | 749 | |
701 | 750 | // Upgrade the agreement. |
702 | 751 | elseif (isset($modSettings['agreement'])) |
@@ -707,8 +756,8 @@ discard block |
||
707 | 756 | } |
708 | 757 | |
709 | 758 | // We're going to check that their board dir setting is right in case they've been moving stuff around. |
710 | - if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) |
|
711 | - $upcontext['warning'] = ' |
|
759 | + if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) { |
|
760 | + $upcontext['warning'] = ' |
|
712 | 761 | It looks as if your board directory settings <em>might</em> be incorrect. Your board directory is currently set to "' . $boarddir . '" but should probably be "' . dirname(__FILE__) . '". Settings.php currently lists your paths as:<br> |
713 | 762 | <ul> |
714 | 763 | <li>Board Directory: ' . $boarddir . '</li> |
@@ -716,10 +765,12 @@ discard block |
||
716 | 765 | <li>Cache Directory: ' . $cachedir_temp . '</li> |
717 | 766 | </ul> |
718 | 767 | If these seem incorrect please open Settings.php in a text editor before proceeding with this upgrade. If they are incorrect due to you moving your forum to a new location please download and execute the <a href="https://download.simplemachines.org/?tools">Repair Settings</a> tool from the Simple Machines website before continuing.'; |
768 | + } |
|
719 | 769 | |
720 | 770 | // Either we're logged in or we're going to present the login. |
721 | - if (checkLogin()) |
|
722 | - return true; |
|
771 | + if (checkLogin()) { |
|
772 | + return true; |
|
773 | + } |
|
723 | 774 | |
724 | 775 | $upcontext += createToken('login'); |
725 | 776 | |
@@ -733,15 +784,17 @@ discard block |
||
733 | 784 | global $smcFunc, $db_type, $support_js; |
734 | 785 | |
735 | 786 | // Don't bother if the security is disabled. |
736 | - if ($disable_security) |
|
737 | - return true; |
|
787 | + if ($disable_security) { |
|
788 | + return true; |
|
789 | + } |
|
738 | 790 | |
739 | 791 | // Are we trying to login? |
740 | 792 | if (isset($_POST['contbutt']) && (!empty($_POST['user']))) |
741 | 793 | { |
742 | 794 | // If we've disabled security pick a suitable name! |
743 | - if (empty($_POST['user'])) |
|
744 | - $_POST['user'] = 'Administrator'; |
|
795 | + if (empty($_POST['user'])) { |
|
796 | + $_POST['user'] = 'Administrator'; |
|
797 | + } |
|
745 | 798 | |
746 | 799 | // Before 2.0 these column names were different! |
747 | 800 | $oldDB = false; |
@@ -756,16 +809,17 @@ discard block |
||
756 | 809 | 'db_error_skip' => true, |
757 | 810 | ) |
758 | 811 | ); |
759 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
760 | - $oldDB = true; |
|
812 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
813 | + $oldDB = true; |
|
814 | + } |
|
761 | 815 | $smcFunc['db_free_result']($request); |
762 | 816 | } |
763 | 817 | |
764 | 818 | // Get what we believe to be their details. |
765 | 819 | if (!$disable_security) |
766 | 820 | { |
767 | - if ($oldDB) |
|
768 | - $request = $smcFunc['db_query']('', ' |
|
821 | + if ($oldDB) { |
|
822 | + $request = $smcFunc['db_query']('', ' |
|
769 | 823 | SELECT id_member, memberName AS member_name, passwd, id_group, |
770 | 824 | additionalGroups AS additional_groups, lngfile |
771 | 825 | FROM {db_prefix}members |
@@ -775,8 +829,8 @@ discard block |
||
775 | 829 | 'db_error_skip' => true, |
776 | 830 | ) |
777 | 831 | ); |
778 | - else |
|
779 | - $request = $smcFunc['db_query']('', ' |
|
832 | + } else { |
|
833 | + $request = $smcFunc['db_query']('', ' |
|
780 | 834 | SELECT id_member, member_name, passwd, id_group, additional_groups, lngfile |
781 | 835 | FROM {db_prefix}members |
782 | 836 | WHERE member_name = {string:member_name}', |
@@ -785,6 +839,7 @@ discard block |
||
785 | 839 | 'db_error_skip' => true, |
786 | 840 | ) |
787 | 841 | ); |
842 | + } |
|
788 | 843 | if ($smcFunc['db_num_rows']($request) != 0) |
789 | 844 | { |
790 | 845 | list ($id_member, $name, $password, $id_group, $addGroups, $user_language) = $smcFunc['db_fetch_row']($request); |
@@ -792,16 +847,17 @@ discard block |
||
792 | 847 | $groups = explode(',', $addGroups); |
793 | 848 | $groups[] = $id_group; |
794 | 849 | |
795 | - foreach ($groups as $k => $v) |
|
796 | - $groups[$k] = (int) $v; |
|
850 | + foreach ($groups as $k => $v) { |
|
851 | + $groups[$k] = (int) $v; |
|
852 | + } |
|
797 | 853 | |
798 | 854 | $sha_passwd = sha1(strtolower($name) . un_htmlspecialchars($_REQUEST['passwrd'])); |
799 | 855 | |
800 | 856 | // We don't use "-utf8" anymore... |
801 | 857 | $user_language = str_ireplace('-utf8', '', $user_language); |
858 | + } else { |
|
859 | + $upcontext['username_incorrect'] = true; |
|
802 | 860 | } |
803 | - else |
|
804 | - $upcontext['username_incorrect'] = true; |
|
805 | 861 | $smcFunc['db_free_result']($request); |
806 | 862 | } |
807 | 863 | $upcontext['username'] = $_POST['user']; |
@@ -811,13 +867,14 @@ discard block |
||
811 | 867 | { |
812 | 868 | $upcontext['upgrade_status']['js'] = 1; |
813 | 869 | $support_js = 1; |
870 | + } else { |
|
871 | + $support_js = 0; |
|
814 | 872 | } |
815 | - else |
|
816 | - $support_js = 0; |
|
817 | 873 | |
818 | 874 | // Note down the version we are coming from. |
819 | - if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) |
|
820 | - $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
875 | + if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) { |
|
876 | + $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
877 | + } |
|
821 | 878 | |
822 | 879 | // Didn't get anywhere? |
823 | 880 | if (!$disable_security && (empty($sha_passwd) || (!empty($password) ? $password : '') != $sha_passwd) && !hash_verify_password((!empty($name) ? $name : ''), $_REQUEST['passwrd'], (!empty($password) ? $password : '')) && empty($upcontext['username_incorrect'])) |
@@ -851,15 +908,15 @@ discard block |
||
851 | 908 | 'db_error_skip' => true, |
852 | 909 | ) |
853 | 910 | ); |
854 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
855 | - return throw_error('You need to be an admin to perform an upgrade!'); |
|
911 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
912 | + return throw_error('You need to be an admin to perform an upgrade!'); |
|
913 | + } |
|
856 | 914 | $smcFunc['db_free_result']($request); |
857 | 915 | } |
858 | 916 | |
859 | 917 | $upcontext['user']['id'] = $id_member; |
860 | 918 | $upcontext['user']['name'] = $name; |
861 | - } |
|
862 | - else |
|
919 | + } else |
|
863 | 920 | { |
864 | 921 | $upcontext['user']['id'] = 1; |
865 | 922 | $upcontext['user']['name'] = 'Administrator'; |
@@ -875,11 +932,11 @@ discard block |
||
875 | 932 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $user_language . '.php')), 0, 4096); |
876 | 933 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
877 | 934 | |
878 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
879 | - $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been updated to the latest version. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
880 | - elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) |
|
881 | - $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been uploaded/updated as the "Install" language file is missing. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
882 | - else |
|
935 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
936 | + $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been updated to the latest version. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
937 | + } elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) { |
|
938 | + $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been uploaded/updated as the "Install" language file is missing. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
939 | + } else |
|
883 | 940 | { |
884 | 941 | // Set this as the new language. |
885 | 942 | $upcontext['language'] = $user_language; |
@@ -923,8 +980,9 @@ discard block |
||
923 | 980 | unset($member_columns); |
924 | 981 | |
925 | 982 | // If we've not submitted then we're done. |
926 | - if (empty($_POST['upcont'])) |
|
927 | - return false; |
|
983 | + if (empty($_POST['upcont'])) { |
|
984 | + return false; |
|
985 | + } |
|
928 | 986 | |
929 | 987 | // Firstly, if they're enabling SM stat collection just do it. |
930 | 988 | if (!empty($_POST['stats']) && (substr($boardurl, 0, 16) != 'http://localhost' || substr($boardurl, 0, 16) != 'https://localhost') && empty($modSettings['allow_sm_stats'])) |
@@ -939,25 +997,26 @@ discard block |
||
939 | 997 | fwrite($fp, $out); |
940 | 998 | |
941 | 999 | $return_data = ''; |
942 | - while (!feof($fp)) |
|
943 | - $return_data .= fgets($fp, 128); |
|
1000 | + while (!feof($fp)) { |
|
1001 | + $return_data .= fgets($fp, 128); |
|
1002 | + } |
|
944 | 1003 | |
945 | 1004 | fclose($fp); |
946 | 1005 | |
947 | 1006 | // Get the unique site ID. |
948 | 1007 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
949 | 1008 | |
950 | - if (!empty($ID[1])) |
|
951 | - $smcFunc['db_insert']('replace', |
|
1009 | + if (!empty($ID[1])) { |
|
1010 | + $smcFunc['db_insert']('replace', |
|
952 | 1011 | $db_prefix . 'settings', |
953 | 1012 | array('variable' => 'string', 'value' => 'string'), |
954 | 1013 | array('allow_sm_stats', $ID[1]), |
955 | 1014 | array('variable') |
956 | 1015 | ); |
1016 | + } |
|
957 | 1017 | } |
958 | - } |
|
959 | - else |
|
960 | - $smcFunc['db_query']('', ' |
|
1018 | + } else { |
|
1019 | + $smcFunc['db_query']('', ' |
|
961 | 1020 | DELETE FROM {db_prefix}settings |
962 | 1021 | WHERE variable = {string:allow_sm_stats}', |
963 | 1022 | array( |
@@ -965,6 +1024,7 @@ discard block |
||
965 | 1024 | 'db_error_skip' => true, |
966 | 1025 | ) |
967 | 1026 | ); |
1027 | + } |
|
968 | 1028 | |
969 | 1029 | // Deleting old karma stuff? |
970 | 1030 | if (!empty($_POST['delete_karma'])) |
@@ -979,20 +1039,22 @@ discard block |
||
979 | 1039 | ); |
980 | 1040 | |
981 | 1041 | // Cleaning up old karma member settings. |
982 | - if ($upcontext['karma_installed']['good']) |
|
983 | - $smcFunc['db_query']('', ' |
|
1042 | + if ($upcontext['karma_installed']['good']) { |
|
1043 | + $smcFunc['db_query']('', ' |
|
984 | 1044 | ALTER TABLE {db_prefix}members |
985 | 1045 | DROP karma_good', |
986 | 1046 | array() |
987 | 1047 | ); |
1048 | + } |
|
988 | 1049 | |
989 | 1050 | // Does karma bad was enable? |
990 | - if ($upcontext['karma_installed']['bad']) |
|
991 | - $smcFunc['db_query']('', ' |
|
1051 | + if ($upcontext['karma_installed']['bad']) { |
|
1052 | + $smcFunc['db_query']('', ' |
|
992 | 1053 | ALTER TABLE {db_prefix}members |
993 | 1054 | DROP karma_bad', |
994 | 1055 | array() |
995 | 1056 | ); |
1057 | + } |
|
996 | 1058 | |
997 | 1059 | // Cleaning up old karma permissions. |
998 | 1060 | $smcFunc['db_query']('', ' |
@@ -1005,26 +1067,29 @@ discard block |
||
1005 | 1067 | } |
1006 | 1068 | |
1007 | 1069 | // Emptying the error log? |
1008 | - if (!empty($_POST['empty_error'])) |
|
1009 | - $smcFunc['db_query']('truncate_table', ' |
|
1070 | + if (!empty($_POST['empty_error'])) { |
|
1071 | + $smcFunc['db_query']('truncate_table', ' |
|
1010 | 1072 | TRUNCATE {db_prefix}log_errors', |
1011 | 1073 | array( |
1012 | 1074 | ) |
1013 | 1075 | ); |
1076 | + } |
|
1014 | 1077 | |
1015 | 1078 | $changes = array(); |
1016 | 1079 | |
1017 | 1080 | // Add proxy settings. |
1018 | - if (!isset($GLOBALS['image_proxy_maxsize'])) |
|
1019 | - $changes += array( |
|
1081 | + if (!isset($GLOBALS['image_proxy_maxsize'])) { |
|
1082 | + $changes += array( |
|
1020 | 1083 | 'image_proxy_secret' => '\'' . substr(sha1(mt_rand()), 0, 20) . '\'', |
1021 | 1084 | 'image_proxy_maxsize' => 5190, |
1022 | 1085 | 'image_proxy_enabled' => 0, |
1023 | 1086 | ); |
1087 | + } |
|
1024 | 1088 | |
1025 | 1089 | // If we're overriding the language follow it through. |
1026 | - if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) |
|
1027 | - $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
1090 | + if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) { |
|
1091 | + $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
1092 | + } |
|
1028 | 1093 | |
1029 | 1094 | if (!empty($_POST['maint'])) |
1030 | 1095 | { |
@@ -1036,30 +1101,34 @@ discard block |
||
1036 | 1101 | { |
1037 | 1102 | $changes['mtitle'] = '\'' . addslashes($_POST['maintitle']) . '\''; |
1038 | 1103 | $changes['mmessage'] = '\'' . addslashes($_POST['mainmessage']) . '\''; |
1039 | - } |
|
1040 | - else |
|
1104 | + } else |
|
1041 | 1105 | { |
1042 | 1106 | $changes['mtitle'] = '\'Upgrading the forum...\''; |
1043 | 1107 | $changes['mmessage'] = '\'Don\\\'t worry, we will be back shortly with an updated forum. It will only be a minute ;).\''; |
1044 | 1108 | } |
1045 | 1109 | } |
1046 | 1110 | |
1047 | - if ($command_line) |
|
1048 | - echo ' * Updating Settings.php...'; |
|
1111 | + if ($command_line) { |
|
1112 | + echo ' * Updating Settings.php...'; |
|
1113 | + } |
|
1049 | 1114 | |
1050 | 1115 | // Fix some old paths. |
1051 | - if (substr($boarddir, 0, 1) == '.') |
|
1052 | - $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
1116 | + if (substr($boarddir, 0, 1) == '.') { |
|
1117 | + $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
1118 | + } |
|
1053 | 1119 | |
1054 | - if (substr($sourcedir, 0, 1) == '.') |
|
1055 | - $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
1120 | + if (substr($sourcedir, 0, 1) == '.') { |
|
1121 | + $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
1122 | + } |
|
1056 | 1123 | |
1057 | - if (empty($cachedir) || substr($cachedir, 0, 1) == '.') |
|
1058 | - $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
1124 | + if (empty($cachedir) || substr($cachedir, 0, 1) == '.') { |
|
1125 | + $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
1126 | + } |
|
1059 | 1127 | |
1060 | 1128 | // Not had the database type added before? |
1061 | - if (empty($db_type)) |
|
1062 | - $changes['db_type'] = 'mysql'; |
|
1129 | + if (empty($db_type)) { |
|
1130 | + $changes['db_type'] = 'mysql'; |
|
1131 | + } |
|
1063 | 1132 | |
1064 | 1133 | // If they have a "host:port" setup for the host, split that into separate values |
1065 | 1134 | // You should never have a : in the hostname if you're not on MySQL, but better safe than sorry |
@@ -1070,32 +1139,36 @@ discard block |
||
1070 | 1139 | $changes['db_server'] = '\'' . $db_server . '\''; |
1071 | 1140 | |
1072 | 1141 | // Only set this if we're not using the default port |
1073 | - if ($db_port != ini_get('mysqli.default_port')) |
|
1074 | - $changes['db_port'] = (int) $db_port; |
|
1075 | - } |
|
1076 | - elseif (!empty($db_port)) |
|
1142 | + if ($db_port != ini_get('mysqli.default_port')) { |
|
1143 | + $changes['db_port'] = (int) $db_port; |
|
1144 | + } |
|
1145 | + } elseif (!empty($db_port)) |
|
1077 | 1146 | { |
1078 | 1147 | // If db_port is set and is the same as the default, set it to '' |
1079 | 1148 | if ($db_type == 'mysql') |
1080 | 1149 | { |
1081 | - if ($db_port == ini_get('mysqli.default_port')) |
|
1082 | - $changes['db_port'] = '\'\''; |
|
1083 | - elseif ($db_type == 'postgresql' && $db_port == 5432) |
|
1084 | - $changes['db_port'] = '\'\''; |
|
1150 | + if ($db_port == ini_get('mysqli.default_port')) { |
|
1151 | + $changes['db_port'] = '\'\''; |
|
1152 | + } elseif ($db_type == 'postgresql' && $db_port == 5432) { |
|
1153 | + $changes['db_port'] = '\'\''; |
|
1154 | + } |
|
1085 | 1155 | } |
1086 | 1156 | } |
1087 | 1157 | |
1088 | 1158 | // Maybe we haven't had this option yet? |
1089 | - if (empty($packagesdir)) |
|
1090 | - $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
1159 | + if (empty($packagesdir)) { |
|
1160 | + $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
1161 | + } |
|
1091 | 1162 | |
1092 | 1163 | // Add support for $tasksdir var. |
1093 | - if (empty($tasksdir)) |
|
1094 | - $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
1164 | + if (empty($tasksdir)) { |
|
1165 | + $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
1166 | + } |
|
1095 | 1167 | |
1096 | 1168 | // Make sure we fix the language as well. |
1097 | - if (stristr($language, '-utf8')) |
|
1098 | - $changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\''; |
|
1169 | + if (stristr($language, '-utf8')) { |
|
1170 | + $changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\''; |
|
1171 | + } |
|
1099 | 1172 | |
1100 | 1173 | // @todo Maybe change the cookie name if going to 1.1, too? |
1101 | 1174 | |
@@ -1103,8 +1176,9 @@ discard block |
||
1103 | 1176 | require_once($sourcedir . '/Subs-Admin.php'); |
1104 | 1177 | updateSettingsFile($changes); |
1105 | 1178 | |
1106 | - if ($command_line) |
|
1107 | - echo ' Successful.' . "\n"; |
|
1179 | + if ($command_line) { |
|
1180 | + echo ' Successful.' . "\n"; |
|
1181 | + } |
|
1108 | 1182 | |
1109 | 1183 | // Are we doing debug? |
1110 | 1184 | if (isset($_POST['debug'])) |
@@ -1114,8 +1188,9 @@ discard block |
||
1114 | 1188 | } |
1115 | 1189 | |
1116 | 1190 | // If we're not backing up then jump one. |
1117 | - if (empty($_POST['backup'])) |
|
1118 | - $upcontext['current_step']++; |
|
1191 | + if (empty($_POST['backup'])) { |
|
1192 | + $upcontext['current_step']++; |
|
1193 | + } |
|
1119 | 1194 | |
1120 | 1195 | // If we've got here then let's proceed to the next step! |
1121 | 1196 | return true; |
@@ -1130,8 +1205,9 @@ discard block |
||
1130 | 1205 | $upcontext['page_title'] = 'Backup Database'; |
1131 | 1206 | |
1132 | 1207 | // Done it already - js wise? |
1133 | - if (!empty($_POST['backup_done'])) |
|
1134 | - return true; |
|
1208 | + if (!empty($_POST['backup_done'])) { |
|
1209 | + return true; |
|
1210 | + } |
|
1135 | 1211 | |
1136 | 1212 | // Some useful stuff here. |
1137 | 1213 | db_extend(); |
@@ -1145,9 +1221,10 @@ discard block |
||
1145 | 1221 | $tables = $smcFunc['db_list_tables']($db, $filter); |
1146 | 1222 | |
1147 | 1223 | $table_names = array(); |
1148 | - foreach ($tables as $table) |
|
1149 | - if (substr($table, 0, 7) !== 'backup_') |
|
1224 | + foreach ($tables as $table) { |
|
1225 | + if (substr($table, 0, 7) !== 'backup_') |
|
1150 | 1226 | $table_names[] = $table; |
1227 | + } |
|
1151 | 1228 | |
1152 | 1229 | $upcontext['table_count'] = count($table_names); |
1153 | 1230 | $upcontext['cur_table_num'] = $_GET['substep']; |
@@ -1157,12 +1234,14 @@ discard block |
||
1157 | 1234 | $file_steps = $upcontext['table_count']; |
1158 | 1235 | |
1159 | 1236 | // What ones have we already done? |
1160 | - foreach ($table_names as $id => $table) |
|
1161 | - if ($id < $_GET['substep']) |
|
1237 | + foreach ($table_names as $id => $table) { |
|
1238 | + if ($id < $_GET['substep']) |
|
1162 | 1239 | $upcontext['previous_tables'][] = $table; |
1240 | + } |
|
1163 | 1241 | |
1164 | - if ($command_line) |
|
1165 | - echo 'Backing Up Tables.'; |
|
1242 | + if ($command_line) { |
|
1243 | + echo 'Backing Up Tables.'; |
|
1244 | + } |
|
1166 | 1245 | |
1167 | 1246 | // If we don't support javascript we backup here. |
1168 | 1247 | if (!$support_js || isset($_GET['xml'])) |
@@ -1181,8 +1260,9 @@ discard block |
||
1181 | 1260 | backupTable($table_names[$substep]); |
1182 | 1261 | |
1183 | 1262 | // If this is XML to keep it nice for the user do one table at a time anyway! |
1184 | - if (isset($_GET['xml'])) |
|
1185 | - return upgradeExit(); |
|
1263 | + if (isset($_GET['xml'])) { |
|
1264 | + return upgradeExit(); |
|
1265 | + } |
|
1186 | 1266 | } |
1187 | 1267 | |
1188 | 1268 | if ($command_line) |
@@ -1215,9 +1295,10 @@ discard block |
||
1215 | 1295 | |
1216 | 1296 | $smcFunc['db_backup_table']($table, 'backup_' . $table); |
1217 | 1297 | |
1218 | - if ($command_line) |
|
1219 | - echo ' done.'; |
|
1220 | -} |
|
1298 | + if ($command_line) { |
|
1299 | + echo ' done.'; |
|
1300 | + } |
|
1301 | + } |
|
1221 | 1302 | |
1222 | 1303 | // Step 2: Everything. |
1223 | 1304 | function DatabaseChanges() |
@@ -1226,8 +1307,9 @@ discard block |
||
1226 | 1307 | global $upcontext, $support_js, $db_type; |
1227 | 1308 | |
1228 | 1309 | // Have we just completed this? |
1229 | - if (!empty($_POST['database_done'])) |
|
1230 | - return true; |
|
1310 | + if (!empty($_POST['database_done'])) { |
|
1311 | + return true; |
|
1312 | + } |
|
1231 | 1313 | |
1232 | 1314 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'database_xml' : 'database_changes'; |
1233 | 1315 | $upcontext['page_title'] = 'Database Changes'; |
@@ -1242,15 +1324,16 @@ discard block |
||
1242 | 1324 | ); |
1243 | 1325 | |
1244 | 1326 | // How many files are there in total? |
1245 | - if (isset($_GET['filecount'])) |
|
1246 | - $upcontext['file_count'] = (int) $_GET['filecount']; |
|
1247 | - else |
|
1327 | + if (isset($_GET['filecount'])) { |
|
1328 | + $upcontext['file_count'] = (int) $_GET['filecount']; |
|
1329 | + } else |
|
1248 | 1330 | { |
1249 | 1331 | $upcontext['file_count'] = 0; |
1250 | 1332 | foreach ($files as $file) |
1251 | 1333 | { |
1252 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) |
|
1253 | - $upcontext['file_count']++; |
|
1334 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) { |
|
1335 | + $upcontext['file_count']++; |
|
1336 | + } |
|
1254 | 1337 | } |
1255 | 1338 | } |
1256 | 1339 | |
@@ -1260,9 +1343,9 @@ discard block |
||
1260 | 1343 | $upcontext['cur_file_num'] = 0; |
1261 | 1344 | foreach ($files as $file) |
1262 | 1345 | { |
1263 | - if ($did_not_do) |
|
1264 | - $did_not_do--; |
|
1265 | - else |
|
1346 | + if ($did_not_do) { |
|
1347 | + $did_not_do--; |
|
1348 | + } else |
|
1266 | 1349 | { |
1267 | 1350 | $upcontext['cur_file_num']++; |
1268 | 1351 | $upcontext['cur_file_name'] = $file[0]; |
@@ -1289,12 +1372,13 @@ discard block |
||
1289 | 1372 | // Flag to move on to the next. |
1290 | 1373 | $upcontext['completed_step'] = true; |
1291 | 1374 | // Did we complete the whole file? |
1292 | - if ($nextFile) |
|
1293 | - $upcontext['current_debug_item_num'] = -1; |
|
1375 | + if ($nextFile) { |
|
1376 | + $upcontext['current_debug_item_num'] = -1; |
|
1377 | + } |
|
1294 | 1378 | return upgradeExit(); |
1379 | + } elseif ($support_js) { |
|
1380 | + break; |
|
1295 | 1381 | } |
1296 | - elseif ($support_js) |
|
1297 | - break; |
|
1298 | 1382 | } |
1299 | 1383 | // Set the progress bar to be right as if we had - even if we hadn't... |
1300 | 1384 | $upcontext['step_progress'] = ($upcontext['cur_file_num'] / $upcontext['file_count']) * 100; |
@@ -1319,8 +1403,9 @@ discard block |
||
1319 | 1403 | global $command_line, $language, $upcontext, $sourcedir, $forum_version, $user_info, $maintenance, $smcFunc, $db_type; |
1320 | 1404 | |
1321 | 1405 | // Now it's nice to have some of the basic SMF source files. |
1322 | - if (!isset($_GET['ssi']) && !$command_line) |
|
1323 | - redirectLocation('&ssi=1'); |
|
1406 | + if (!isset($_GET['ssi']) && !$command_line) { |
|
1407 | + redirectLocation('&ssi=1'); |
|
1408 | + } |
|
1324 | 1409 | |
1325 | 1410 | $upcontext['sub_template'] = 'upgrade_complete'; |
1326 | 1411 | $upcontext['page_title'] = 'Upgrade Complete'; |
@@ -1336,14 +1421,16 @@ discard block |
||
1336 | 1421 | // Are we in maintenance mode? |
1337 | 1422 | if (isset($upcontext['user']['main'])) |
1338 | 1423 | { |
1339 | - if ($command_line) |
|
1340 | - echo ' * '; |
|
1424 | + if ($command_line) { |
|
1425 | + echo ' * '; |
|
1426 | + } |
|
1341 | 1427 | $upcontext['removed_maintenance'] = true; |
1342 | 1428 | $changes['maintenance'] = $upcontext['user']['main']; |
1343 | 1429 | } |
1344 | 1430 | // Otherwise if somehow we are in 2 let's go to 1. |
1345 | - elseif (!empty($maintenance) && $maintenance == 2) |
|
1346 | - $changes['maintenance'] = 1; |
|
1431 | + elseif (!empty($maintenance) && $maintenance == 2) { |
|
1432 | + $changes['maintenance'] = 1; |
|
1433 | + } |
|
1347 | 1434 | |
1348 | 1435 | // Wipe this out... |
1349 | 1436 | $upcontext['user'] = array(); |
@@ -1358,9 +1445,9 @@ discard block |
||
1358 | 1445 | $upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__); |
1359 | 1446 | |
1360 | 1447 | // Now is the perfect time to fetch the SM files. |
1361 | - if ($command_line) |
|
1362 | - cli_scheduled_fetchSMfiles(); |
|
1363 | - else |
|
1448 | + if ($command_line) { |
|
1449 | + cli_scheduled_fetchSMfiles(); |
|
1450 | + } else |
|
1364 | 1451 | { |
1365 | 1452 | require_once($sourcedir . '/ScheduledTasks.php'); |
1366 | 1453 | $forum_version = SMF_VERSION; // The variable is usually defined in index.php so lets just use the constant to do it for us. |
@@ -1368,8 +1455,9 @@ discard block |
||
1368 | 1455 | } |
1369 | 1456 | |
1370 | 1457 | // Log what we've done. |
1371 | - if (empty($user_info['id'])) |
|
1372 | - $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
1458 | + if (empty($user_info['id'])) { |
|
1459 | + $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
1460 | + } |
|
1373 | 1461 | |
1374 | 1462 | // Log the action manually, so CLI still works. |
1375 | 1463 | $smcFunc['db_insert']('', |
@@ -1388,8 +1476,9 @@ discard block |
||
1388 | 1476 | |
1389 | 1477 | // Save the current database version. |
1390 | 1478 | $server_version = $smcFunc['db_server_info'](); |
1391 | - if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
1392 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
1479 | + if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
1480 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
1481 | + } |
|
1393 | 1482 | |
1394 | 1483 | if ($command_line) |
1395 | 1484 | { |
@@ -1401,8 +1490,9 @@ discard block |
||
1401 | 1490 | |
1402 | 1491 | // Make sure it says we're done. |
1403 | 1492 | $upcontext['overall_percent'] = 100; |
1404 | - if (isset($upcontext['step_progress'])) |
|
1405 | - unset($upcontext['step_progress']); |
|
1493 | + if (isset($upcontext['step_progress'])) { |
|
1494 | + unset($upcontext['step_progress']); |
|
1495 | + } |
|
1406 | 1496 | |
1407 | 1497 | $_GET['substep'] = 0; |
1408 | 1498 | return false; |
@@ -1413,8 +1503,9 @@ discard block |
||
1413 | 1503 | { |
1414 | 1504 | global $sourcedir, $language, $forum_version, $modSettings, $smcFunc; |
1415 | 1505 | |
1416 | - if (empty($modSettings['time_format'])) |
|
1417 | - $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
1506 | + if (empty($modSettings['time_format'])) { |
|
1507 | + $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
1508 | + } |
|
1418 | 1509 | |
1419 | 1510 | // What files do we want to get |
1420 | 1511 | $request = $smcFunc['db_query']('', ' |
@@ -1448,8 +1539,9 @@ discard block |
||
1448 | 1539 | $file_data = fetch_web_data($url); |
1449 | 1540 | |
1450 | 1541 | // If we got an error - give up - the site might be down. |
1451 | - if ($file_data === false) |
|
1452 | - return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
1542 | + if ($file_data === false) { |
|
1543 | + return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
1544 | + } |
|
1453 | 1545 | |
1454 | 1546 | // Save the file to the database. |
1455 | 1547 | $smcFunc['db_query']('substring', ' |
@@ -1491,8 +1583,9 @@ discard block |
||
1491 | 1583 | $themeData = array(); |
1492 | 1584 | foreach ($values as $variable => $value) |
1493 | 1585 | { |
1494 | - if (!isset($value) || $value === null) |
|
1495 | - $value = 0; |
|
1586 | + if (!isset($value) || $value === null) { |
|
1587 | + $value = 0; |
|
1588 | + } |
|
1496 | 1589 | |
1497 | 1590 | $themeData[] = array(0, 1, $variable, $value); |
1498 | 1591 | } |
@@ -1521,8 +1614,9 @@ discard block |
||
1521 | 1614 | |
1522 | 1615 | foreach ($values as $variable => $value) |
1523 | 1616 | { |
1524 | - if (empty($modSettings[$value[0]])) |
|
1525 | - continue; |
|
1617 | + if (empty($modSettings[$value[0]])) { |
|
1618 | + continue; |
|
1619 | + } |
|
1526 | 1620 | |
1527 | 1621 | $smcFunc['db_query']('', ' |
1528 | 1622 | INSERT IGNORE INTO {db_prefix}themes |
@@ -1608,19 +1702,21 @@ discard block |
||
1608 | 1702 | set_error_handler( |
1609 | 1703 | function ($errno, $errstr, $errfile, $errline) use ($support_js) |
1610 | 1704 | { |
1611 | - if ($support_js) |
|
1612 | - return true; |
|
1613 | - else |
|
1614 | - echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
1705 | + if ($support_js) { |
|
1706 | + return true; |
|
1707 | + } else { |
|
1708 | + echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
1709 | + } |
|
1615 | 1710 | } |
1616 | 1711 | ); |
1617 | 1712 | |
1618 | 1713 | // If we're on MySQL, set {db_collation}; this approach is used throughout upgrade_2-0_mysql.php to set new tables to utf8 |
1619 | 1714 | // Note it is expected to be in the format: ENGINE=MyISAM{$db_collation}; |
1620 | - if ($db_type == 'mysql') |
|
1621 | - $db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
1622 | - else |
|
1623 | - $db_collation = ''; |
|
1715 | + if ($db_type == 'mysql') { |
|
1716 | + $db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
1717 | + } else { |
|
1718 | + $db_collation = ''; |
|
1719 | + } |
|
1624 | 1720 | |
1625 | 1721 | $endl = $command_line ? "\n" : '<br>' . "\n"; |
1626 | 1722 | |
@@ -1632,8 +1728,9 @@ discard block |
||
1632 | 1728 | $last_step = ''; |
1633 | 1729 | |
1634 | 1730 | // Make sure all newly created tables will have the proper characters set; this approach is used throughout upgrade_2-1_mysql.php |
1635 | - if (isset($db_character_set) && $db_character_set === 'utf8') |
|
1636 | - $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
1731 | + if (isset($db_character_set) && $db_character_set === 'utf8') { |
|
1732 | + $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
1733 | + } |
|
1637 | 1734 | |
1638 | 1735 | // Count the total number of steps within this file - for progress. |
1639 | 1736 | $file_steps = substr_count(implode('', $lines), '---#'); |
@@ -1653,15 +1750,18 @@ discard block |
||
1653 | 1750 | $do_current = $substep >= $_GET['substep']; |
1654 | 1751 | |
1655 | 1752 | // Get rid of any comments in the beginning of the line... |
1656 | - if (substr(trim($line), 0, 2) === '/*') |
|
1657 | - $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
1753 | + if (substr(trim($line), 0, 2) === '/*') { |
|
1754 | + $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
1755 | + } |
|
1658 | 1756 | |
1659 | 1757 | // Always flush. Flush, flush, flush. Flush, flush, flush, flush! FLUSH! |
1660 | - if ($is_debug && !$support_js && $command_line) |
|
1661 | - flush(); |
|
1758 | + if ($is_debug && !$support_js && $command_line) { |
|
1759 | + flush(); |
|
1760 | + } |
|
1662 | 1761 | |
1663 | - if (trim($line) === '') |
|
1664 | - continue; |
|
1762 | + if (trim($line) === '') { |
|
1763 | + continue; |
|
1764 | + } |
|
1665 | 1765 | |
1666 | 1766 | if (trim(substr($line, 0, 3)) === '---') |
1667 | 1767 | { |
@@ -1671,8 +1771,9 @@ discard block |
||
1671 | 1771 | if (trim($current_data) != '' && $type !== '}') |
1672 | 1772 | { |
1673 | 1773 | $upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl; |
1674 | - if ($command_line) |
|
1675 | - echo $upcontext['error_message']; |
|
1774 | + if ($command_line) { |
|
1775 | + echo $upcontext['error_message']; |
|
1776 | + } |
|
1676 | 1777 | } |
1677 | 1778 | |
1678 | 1779 | if ($type == ' ') |
@@ -1690,17 +1791,18 @@ discard block |
||
1690 | 1791 | if ($do_current) |
1691 | 1792 | { |
1692 | 1793 | $upcontext['actioned_items'][] = $last_step; |
1693 | - if ($command_line) |
|
1694 | - echo ' * '; |
|
1794 | + if ($command_line) { |
|
1795 | + echo ' * '; |
|
1796 | + } |
|
1695 | 1797 | } |
1696 | - } |
|
1697 | - elseif ($type == '#') |
|
1798 | + } elseif ($type == '#') |
|
1698 | 1799 | { |
1699 | 1800 | $upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps; |
1700 | 1801 | |
1701 | 1802 | $upcontext['current_debug_item_num']++; |
1702 | - if (trim($line) != '---#') |
|
1703 | - $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
1803 | + if (trim($line) != '---#') { |
|
1804 | + $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
1805 | + } |
|
1704 | 1806 | |
1705 | 1807 | // Have we already done something? |
1706 | 1808 | if (isset($_GET['xml']) && $done_something) |
@@ -1711,34 +1813,36 @@ discard block |
||
1711 | 1813 | |
1712 | 1814 | if ($do_current) |
1713 | 1815 | { |
1714 | - if (trim($line) == '---#' && $command_line) |
|
1715 | - echo ' done.', $endl; |
|
1716 | - elseif ($command_line) |
|
1717 | - echo ' +++ ', rtrim(substr($line, 4)); |
|
1718 | - elseif (trim($line) != '---#') |
|
1816 | + if (trim($line) == '---#' && $command_line) { |
|
1817 | + echo ' done.', $endl; |
|
1818 | + } elseif ($command_line) { |
|
1819 | + echo ' +++ ', rtrim(substr($line, 4)); |
|
1820 | + } elseif (trim($line) != '---#') |
|
1719 | 1821 | { |
1720 | - if ($is_debug) |
|
1721 | - $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
1822 | + if ($is_debug) { |
|
1823 | + $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
1824 | + } |
|
1722 | 1825 | } |
1723 | 1826 | } |
1724 | 1827 | |
1725 | 1828 | if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep']) |
1726 | 1829 | { |
1727 | - if ($command_line) |
|
1728 | - echo ' * '; |
|
1729 | - else |
|
1730 | - $upcontext['actioned_items'][] = $last_step; |
|
1830 | + if ($command_line) { |
|
1831 | + echo ' * '; |
|
1832 | + } else { |
|
1833 | + $upcontext['actioned_items'][] = $last_step; |
|
1834 | + } |
|
1731 | 1835 | } |
1732 | 1836 | |
1733 | 1837 | // Small step - only if we're actually doing stuff. |
1734 | - if ($do_current) |
|
1735 | - nextSubstep(++$substep); |
|
1736 | - else |
|
1737 | - $substep++; |
|
1738 | - } |
|
1739 | - elseif ($type == '{') |
|
1740 | - $current_type = 'code'; |
|
1741 | - elseif ($type == '}') |
|
1838 | + if ($do_current) { |
|
1839 | + nextSubstep(++$substep); |
|
1840 | + } else { |
|
1841 | + $substep++; |
|
1842 | + } |
|
1843 | + } elseif ($type == '{') { |
|
1844 | + $current_type = 'code'; |
|
1845 | + } elseif ($type == '}') |
|
1742 | 1846 | { |
1743 | 1847 | $current_type = 'sql'; |
1744 | 1848 | |
@@ -1751,8 +1855,9 @@ discard block |
||
1751 | 1855 | if (eval('global $db_prefix, $modSettings, $smcFunc; ' . $current_data) === false) |
1752 | 1856 | { |
1753 | 1857 | $upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl; |
1754 | - if ($command_line) |
|
1755 | - echo $upcontext['error_message']; |
|
1858 | + if ($command_line) { |
|
1859 | + echo $upcontext['error_message']; |
|
1860 | + } |
|
1756 | 1861 | } |
1757 | 1862 | |
1758 | 1863 | // Done with code! |
@@ -1832,8 +1937,9 @@ discard block |
||
1832 | 1937 | $db_unbuffered = false; |
1833 | 1938 | |
1834 | 1939 | // Failure?! |
1835 | - if ($result !== false) |
|
1836 | - return $result; |
|
1940 | + if ($result !== false) { |
|
1941 | + return $result; |
|
1942 | + } |
|
1837 | 1943 | |
1838 | 1944 | $db_error_message = $smcFunc['db_error']($db_connection); |
1839 | 1945 | // If MySQL we do something more clever. |
@@ -1861,54 +1967,61 @@ discard block |
||
1861 | 1967 | { |
1862 | 1968 | mysqli_query($db_connection, 'REPAIR TABLE `' . $match[1] . '`'); |
1863 | 1969 | $result = mysqli_query($db_connection, $string); |
1864 | - if ($result !== false) |
|
1865 | - return $result; |
|
1970 | + if ($result !== false) { |
|
1971 | + return $result; |
|
1972 | + } |
|
1866 | 1973 | } |
1867 | - } |
|
1868 | - elseif ($mysqli_errno == 2013) |
|
1974 | + } elseif ($mysqli_errno == 2013) |
|
1869 | 1975 | { |
1870 | 1976 | $db_connection = mysqli_connect($db_server, $db_user, $db_passwd); |
1871 | 1977 | mysqli_select_db($db_connection, $db_name); |
1872 | 1978 | if ($db_connection) |
1873 | 1979 | { |
1874 | 1980 | $result = mysqli_query($db_connection, $string); |
1875 | - if ($result !== false) |
|
1876 | - return $result; |
|
1981 | + if ($result !== false) { |
|
1982 | + return $result; |
|
1983 | + } |
|
1877 | 1984 | } |
1878 | 1985 | } |
1879 | 1986 | // Duplicate column name... should be okay ;). |
1880 | - elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) |
|
1881 | - return false; |
|
1987 | + elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) { |
|
1988 | + return false; |
|
1989 | + } |
|
1882 | 1990 | // Duplicate insert... make sure it's the proper type of query ;). |
1883 | - elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) |
|
1884 | - return false; |
|
1991 | + elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) { |
|
1992 | + return false; |
|
1993 | + } |
|
1885 | 1994 | // Creating an index on a non-existent column. |
1886 | - elseif ($mysqli_errno == 1072) |
|
1887 | - return false; |
|
1888 | - elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') |
|
1889 | - return false; |
|
1995 | + elseif ($mysqli_errno == 1072) { |
|
1996 | + return false; |
|
1997 | + } elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') { |
|
1998 | + return false; |
|
1999 | + } |
|
1890 | 2000 | } |
1891 | 2001 | // If a table already exists don't go potty. |
1892 | 2002 | else |
1893 | 2003 | { |
1894 | 2004 | if (in_array(substr(trim($string), 0, 8), array('CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U'))) |
1895 | 2005 | { |
1896 | - if (strpos($db_error_message, 'exist') !== false) |
|
1897 | - return true; |
|
1898 | - } |
|
1899 | - elseif (strpos(trim($string), 'INSERT ') !== false) |
|
2006 | + if (strpos($db_error_message, 'exist') !== false) { |
|
2007 | + return true; |
|
2008 | + } |
|
2009 | + } elseif (strpos(trim($string), 'INSERT ') !== false) |
|
1900 | 2010 | { |
1901 | - if (strpos($db_error_message, 'duplicate') !== false) |
|
1902 | - return true; |
|
2011 | + if (strpos($db_error_message, 'duplicate') !== false) { |
|
2012 | + return true; |
|
2013 | + } |
|
1903 | 2014 | } |
1904 | 2015 | } |
1905 | 2016 | |
1906 | 2017 | // Get the query string so we pass everything. |
1907 | 2018 | $query_string = ''; |
1908 | - foreach ($_GET as $k => $v) |
|
1909 | - $query_string .= ';' . $k . '=' . $v; |
|
1910 | - if (strlen($query_string) != 0) |
|
1911 | - $query_string = '?' . substr($query_string, 1); |
|
2019 | + foreach ($_GET as $k => $v) { |
|
2020 | + $query_string .= ';' . $k . '=' . $v; |
|
2021 | + } |
|
2022 | + if (strlen($query_string) != 0) { |
|
2023 | + $query_string = '?' . substr($query_string, 1); |
|
2024 | + } |
|
1912 | 2025 | |
1913 | 2026 | if ($command_line) |
1914 | 2027 | { |
@@ -1963,16 +2076,18 @@ discard block |
||
1963 | 2076 | { |
1964 | 2077 | $found |= 1; |
1965 | 2078 | // Do some checks on the data if we have it set. |
1966 | - if (isset($change['col_type'])) |
|
1967 | - $found &= $change['col_type'] === $column['type']; |
|
1968 | - if (isset($change['null_allowed'])) |
|
1969 | - $found &= $column['null'] == $change['null_allowed']; |
|
1970 | - if (isset($change['default'])) |
|
1971 | - $found &= $change['default'] === $column['default']; |
|
2079 | + if (isset($change['col_type'])) { |
|
2080 | + $found &= $change['col_type'] === $column['type']; |
|
2081 | + } |
|
2082 | + if (isset($change['null_allowed'])) { |
|
2083 | + $found &= $column['null'] == $change['null_allowed']; |
|
2084 | + } |
|
2085 | + if (isset($change['default'])) { |
|
2086 | + $found &= $change['default'] === $column['default']; |
|
2087 | + } |
|
1972 | 2088 | } |
1973 | 2089 | } |
1974 | - } |
|
1975 | - elseif ($change['type'] === 'index') |
|
2090 | + } elseif ($change['type'] === 'index') |
|
1976 | 2091 | { |
1977 | 2092 | $request = upgrade_query(' |
1978 | 2093 | SHOW INDEX |
@@ -1981,9 +2096,10 @@ discard block |
||
1981 | 2096 | { |
1982 | 2097 | $cur_index = array(); |
1983 | 2098 | |
1984 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1985 | - if ($row['Key_name'] === $change['name']) |
|
2099 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2100 | + if ($row['Key_name'] === $change['name']) |
|
1986 | 2101 | $cur_index[(int) $row['Seq_in_index']] = $row['Column_name']; |
2102 | + } |
|
1987 | 2103 | |
1988 | 2104 | ksort($cur_index, SORT_NUMERIC); |
1989 | 2105 | $found = array_values($cur_index) === $change['target_columns']; |
@@ -1993,14 +2109,17 @@ discard block |
||
1993 | 2109 | } |
1994 | 2110 | |
1995 | 2111 | // If we're trying to add and it's added, we're done. |
1996 | - if ($found && in_array($change['method'], array('add', 'change'))) |
|
1997 | - return true; |
|
2112 | + if ($found && in_array($change['method'], array('add', 'change'))) { |
|
2113 | + return true; |
|
2114 | + } |
|
1998 | 2115 | // Otherwise if we're removing and it wasn't found we're also done. |
1999 | - elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) |
|
2000 | - return true; |
|
2116 | + elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) { |
|
2117 | + return true; |
|
2118 | + } |
|
2001 | 2119 | // Otherwise is it just a test? |
2002 | - elseif ($is_test) |
|
2003 | - return false; |
|
2120 | + elseif ($is_test) { |
|
2121 | + return false; |
|
2122 | + } |
|
2004 | 2123 | |
2005 | 2124 | // Not found it yet? Bummer! How about we see if we're currently doing it? |
2006 | 2125 | $running = false; |
@@ -2011,8 +2130,9 @@ discard block |
||
2011 | 2130 | SHOW FULL PROCESSLIST'); |
2012 | 2131 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2013 | 2132 | { |
2014 | - if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) |
|
2015 | - $found = true; |
|
2133 | + if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) { |
|
2134 | + $found = true; |
|
2135 | + } |
|
2016 | 2136 | } |
2017 | 2137 | |
2018 | 2138 | // Can't find it? Then we need to run it fools! |
@@ -2024,8 +2144,9 @@ discard block |
||
2024 | 2144 | ALTER TABLE ' . $db_prefix . $change['table'] . ' |
2025 | 2145 | ' . $change['text'], true) !== false; |
2026 | 2146 | |
2027 | - if (!$success) |
|
2028 | - return false; |
|
2147 | + if (!$success) { |
|
2148 | + return false; |
|
2149 | + } |
|
2029 | 2150 | |
2030 | 2151 | // Return |
2031 | 2152 | $running = true; |
@@ -2067,8 +2188,9 @@ discard block |
||
2067 | 2188 | 'db_error_skip' => true, |
2068 | 2189 | ) |
2069 | 2190 | ); |
2070 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
2071 | - die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
2191 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
2192 | + die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
2193 | + } |
|
2072 | 2194 | $table_row = $smcFunc['db_fetch_assoc']($request); |
2073 | 2195 | $smcFunc['db_free_result']($request); |
2074 | 2196 | |
@@ -2090,18 +2212,19 @@ discard block |
||
2090 | 2212 | ) |
2091 | 2213 | ); |
2092 | 2214 | // No results? Just forget it all together. |
2093 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
2094 | - unset($table_row['Collation']); |
|
2095 | - else |
|
2096 | - $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
2215 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
2216 | + unset($table_row['Collation']); |
|
2217 | + } else { |
|
2218 | + $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
2219 | + } |
|
2097 | 2220 | $smcFunc['db_free_result']($request); |
2098 | 2221 | } |
2099 | 2222 | |
2100 | 2223 | if ($column_fix) |
2101 | 2224 | { |
2102 | 2225 | // Make sure there are no NULL's left. |
2103 | - if ($null_fix) |
|
2104 | - $smcFunc['db_query']('', ' |
|
2226 | + if ($null_fix) { |
|
2227 | + $smcFunc['db_query']('', ' |
|
2105 | 2228 | UPDATE {db_prefix}' . $change['table'] . ' |
2106 | 2229 | SET ' . $change['column'] . ' = {string:default} |
2107 | 2230 | WHERE ' . $change['column'] . ' IS NULL', |
@@ -2110,6 +2233,7 @@ discard block |
||
2110 | 2233 | 'db_error_skip' => true, |
2111 | 2234 | ) |
2112 | 2235 | ); |
2236 | + } |
|
2113 | 2237 | |
2114 | 2238 | // Do the actual alteration. |
2115 | 2239 | $smcFunc['db_query']('', ' |
@@ -2138,8 +2262,9 @@ discard block |
||
2138 | 2262 | } |
2139 | 2263 | |
2140 | 2264 | // Not a column we need to check on? |
2141 | - if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) |
|
2142 | - return; |
|
2265 | + if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) { |
|
2266 | + return; |
|
2267 | + } |
|
2143 | 2268 | |
2144 | 2269 | // Break it up you (six|seven). |
2145 | 2270 | $temp = explode(' ', str_replace('NOT NULL', 'NOT_NULL', $change['text'])); |
@@ -2158,13 +2283,13 @@ discard block |
||
2158 | 2283 | 'new_name' => $temp[2], |
2159 | 2284 | )); |
2160 | 2285 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
2161 | - if ($smcFunc['db_num_rows'] != 1) |
|
2162 | - return; |
|
2286 | + if ($smcFunc['db_num_rows'] != 1) { |
|
2287 | + return; |
|
2288 | + } |
|
2163 | 2289 | |
2164 | 2290 | list (, $current_type) = $smcFunc['db_fetch_assoc']($request); |
2165 | 2291 | $smcFunc['db_free_result']($request); |
2166 | - } |
|
2167 | - else |
|
2292 | + } else |
|
2168 | 2293 | { |
2169 | 2294 | // Do this the old fashion, sure method way. |
2170 | 2295 | $request = $smcFunc['db_query']('', ' |
@@ -2175,21 +2300,24 @@ discard block |
||
2175 | 2300 | )); |
2176 | 2301 | // Mayday! |
2177 | 2302 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
2178 | - if ($smcFunc['db_num_rows'] == 0) |
|
2179 | - return; |
|
2303 | + if ($smcFunc['db_num_rows'] == 0) { |
|
2304 | + return; |
|
2305 | + } |
|
2180 | 2306 | |
2181 | 2307 | // Oh where, oh where has my little field gone. Oh where can it be... |
2182 | - while ($row = $smcFunc['db_query']($request)) |
|
2183 | - if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
2308 | + while ($row = $smcFunc['db_query']($request)) { |
|
2309 | + if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
2184 | 2310 | { |
2185 | 2311 | $current_type = $row['Type']; |
2312 | + } |
|
2186 | 2313 | break; |
2187 | 2314 | } |
2188 | 2315 | } |
2189 | 2316 | |
2190 | 2317 | // If this doesn't match, the column may of been altered for a reason. |
2191 | - if (trim($current_type) != trim($temp[3])) |
|
2192 | - $temp[3] = $current_type; |
|
2318 | + if (trim($current_type) != trim($temp[3])) { |
|
2319 | + $temp[3] = $current_type; |
|
2320 | + } |
|
2193 | 2321 | |
2194 | 2322 | // Piece this back together. |
2195 | 2323 | $change['text'] = str_replace('NOT_NULL', 'NOT NULL', implode(' ', $temp)); |
@@ -2201,8 +2329,9 @@ discard block |
||
2201 | 2329 | global $start_time, $timeLimitThreshold, $command_line, $custom_warning; |
2202 | 2330 | global $step_progress, $is_debug, $upcontext; |
2203 | 2331 | |
2204 | - if ($_GET['substep'] < $substep) |
|
2205 | - $_GET['substep'] = $substep; |
|
2332 | + if ($_GET['substep'] < $substep) { |
|
2333 | + $_GET['substep'] = $substep; |
|
2334 | + } |
|
2206 | 2335 | |
2207 | 2336 | if ($command_line) |
2208 | 2337 | { |
@@ -2215,29 +2344,33 @@ discard block |
||
2215 | 2344 | } |
2216 | 2345 | |
2217 | 2346 | @set_time_limit(300); |
2218 | - if (function_exists('apache_reset_timeout')) |
|
2219 | - @apache_reset_timeout(); |
|
2347 | + if (function_exists('apache_reset_timeout')) { |
|
2348 | + @apache_reset_timeout(); |
|
2349 | + } |
|
2220 | 2350 | |
2221 | - if (time() - $start_time <= $timeLimitThreshold) |
|
2222 | - return; |
|
2351 | + if (time() - $start_time <= $timeLimitThreshold) { |
|
2352 | + return; |
|
2353 | + } |
|
2223 | 2354 | |
2224 | 2355 | // Do we have some custom step progress stuff? |
2225 | 2356 | if (!empty($step_progress)) |
2226 | 2357 | { |
2227 | 2358 | $upcontext['substep_progress'] = 0; |
2228 | 2359 | $upcontext['substep_progress_name'] = $step_progress['name']; |
2229 | - if ($step_progress['current'] > $step_progress['total']) |
|
2230 | - $upcontext['substep_progress'] = 99.9; |
|
2231 | - else |
|
2232 | - $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
2360 | + if ($step_progress['current'] > $step_progress['total']) { |
|
2361 | + $upcontext['substep_progress'] = 99.9; |
|
2362 | + } else { |
|
2363 | + $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
2364 | + } |
|
2233 | 2365 | |
2234 | 2366 | // Make it nicely rounded. |
2235 | 2367 | $upcontext['substep_progress'] = round($upcontext['substep_progress'], 1); |
2236 | 2368 | } |
2237 | 2369 | |
2238 | 2370 | // If this is XML we just exit right away! |
2239 | - if (isset($_GET['xml'])) |
|
2240 | - return upgradeExit(); |
|
2371 | + if (isset($_GET['xml'])) { |
|
2372 | + return upgradeExit(); |
|
2373 | + } |
|
2241 | 2374 | |
2242 | 2375 | // We're going to pause after this! |
2243 | 2376 | $upcontext['pause'] = true; |
@@ -2245,13 +2378,15 @@ discard block |
||
2245 | 2378 | $upcontext['query_string'] = ''; |
2246 | 2379 | foreach ($_GET as $k => $v) |
2247 | 2380 | { |
2248 | - if ($k != 'data' && $k != 'substep' && $k != 'step') |
|
2249 | - $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
2381 | + if ($k != 'data' && $k != 'substep' && $k != 'step') { |
|
2382 | + $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
2383 | + } |
|
2250 | 2384 | } |
2251 | 2385 | |
2252 | 2386 | // Custom warning? |
2253 | - if (!empty($custom_warning)) |
|
2254 | - $upcontext['custom_warning'] = $custom_warning; |
|
2387 | + if (!empty($custom_warning)) { |
|
2388 | + $upcontext['custom_warning'] = $custom_warning; |
|
2389 | + } |
|
2255 | 2390 | |
2256 | 2391 | upgradeExit(); |
2257 | 2392 | } |
@@ -2266,25 +2401,26 @@ discard block |
||
2266 | 2401 | ob_implicit_flush(true); |
2267 | 2402 | @set_time_limit(600); |
2268 | 2403 | |
2269 | - if (!isset($_SERVER['argv'])) |
|
2270 | - $_SERVER['argv'] = array(); |
|
2404 | + if (!isset($_SERVER['argv'])) { |
|
2405 | + $_SERVER['argv'] = array(); |
|
2406 | + } |
|
2271 | 2407 | $_GET['maint'] = 1; |
2272 | 2408 | |
2273 | 2409 | foreach ($_SERVER['argv'] as $i => $arg) |
2274 | 2410 | { |
2275 | - if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) |
|
2276 | - $_GET['lang'] = $match[1]; |
|
2277 | - elseif (preg_match('~^--path=(.+)$~', $arg) != 0) |
|
2278 | - continue; |
|
2279 | - elseif ($arg == '--no-maintenance') |
|
2280 | - $_GET['maint'] = 0; |
|
2281 | - elseif ($arg == '--debug') |
|
2282 | - $is_debug = true; |
|
2283 | - elseif ($arg == '--backup') |
|
2284 | - $_POST['backup'] = 1; |
|
2285 | - elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) |
|
2286 | - $_GET['conv'] = 1; |
|
2287 | - elseif ($i != 0) |
|
2411 | + if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) { |
|
2412 | + $_GET['lang'] = $match[1]; |
|
2413 | + } elseif (preg_match('~^--path=(.+)$~', $arg) != 0) { |
|
2414 | + continue; |
|
2415 | + } elseif ($arg == '--no-maintenance') { |
|
2416 | + $_GET['maint'] = 0; |
|
2417 | + } elseif ($arg == '--debug') { |
|
2418 | + $is_debug = true; |
|
2419 | + } elseif ($arg == '--backup') { |
|
2420 | + $_POST['backup'] = 1; |
|
2421 | + } elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) { |
|
2422 | + $_GET['conv'] = 1; |
|
2423 | + } elseif ($i != 0) |
|
2288 | 2424 | { |
2289 | 2425 | echo 'SMF Command-line Upgrader |
2290 | 2426 | Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]... |
@@ -2298,10 +2434,12 @@ discard block |
||
2298 | 2434 | } |
2299 | 2435 | } |
2300 | 2436 | |
2301 | - if (!php_version_check()) |
|
2302 | - print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
2303 | - if (!db_version_check()) |
|
2304 | - print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
2437 | + if (!php_version_check()) { |
|
2438 | + print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
2439 | + } |
|
2440 | + if (!db_version_check()) { |
|
2441 | + print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
2442 | + } |
|
2305 | 2443 | |
2306 | 2444 | // Do some checks to make sure they have proper privileges |
2307 | 2445 | db_extend('packages'); |
@@ -2316,34 +2454,39 @@ discard block |
||
2316 | 2454 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
2317 | 2455 | |
2318 | 2456 | // Sorry... we need CREATE, ALTER and DROP |
2319 | - if (!$create || !$alter || !$drop) |
|
2320 | - print_error("The " . $databases[$db_type]['name'] . " user you have set in Settings.php does not have proper privileges.\n\nPlease ask your host to give this user the ALTER, CREATE, and DROP privileges.", true); |
|
2457 | + if (!$create || !$alter || !$drop) { |
|
2458 | + print_error("The " . $databases[$db_type]['name'] . " user you have set in Settings.php does not have proper privileges.\n\nPlease ask your host to give this user the ALTER, CREATE, and DROP privileges.", true); |
|
2459 | + } |
|
2321 | 2460 | |
2322 | 2461 | $check = @file_exists($modSettings['theme_dir'] . '/index.template.php') |
2323 | 2462 | && @file_exists($sourcedir . '/QueryString.php') |
2324 | 2463 | && @file_exists($sourcedir . '/ManageBoards.php'); |
2325 | - if (!$check && !isset($modSettings['smfVersion'])) |
|
2326 | - print_error('Error: Some files are missing or out-of-date.', true); |
|
2464 | + if (!$check && !isset($modSettings['smfVersion'])) { |
|
2465 | + print_error('Error: Some files are missing or out-of-date.', true); |
|
2466 | + } |
|
2327 | 2467 | |
2328 | 2468 | // Do a quick version spot check. |
2329 | 2469 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
2330 | 2470 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
2331 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
2332 | - print_error('Error: Some files have not yet been updated properly.'); |
|
2471 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
2472 | + print_error('Error: Some files have not yet been updated properly.'); |
|
2473 | + } |
|
2333 | 2474 | |
2334 | 2475 | // Make sure Settings.php is writable. |
2335 | 2476 | quickFileWritable($boarddir . '/Settings.php'); |
2336 | - if (!is_writable($boarddir . '/Settings.php')) |
|
2337 | - print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
2477 | + if (!is_writable($boarddir . '/Settings.php')) { |
|
2478 | + print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
2479 | + } |
|
2338 | 2480 | |
2339 | 2481 | // Make sure Settings_bak.php is writable. |
2340 | 2482 | quickFileWritable($boarddir . '/Settings_bak.php'); |
2341 | - if (!is_writable($boarddir . '/Settings_bak.php')) |
|
2342 | - print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
2483 | + if (!is_writable($boarddir . '/Settings_bak.php')) { |
|
2484 | + print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
2485 | + } |
|
2343 | 2486 | |
2344 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
2345 | - print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
2346 | - elseif (isset($modSettings['agreement'])) |
|
2487 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
2488 | + print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
2489 | + } elseif (isset($modSettings['agreement'])) |
|
2347 | 2490 | { |
2348 | 2491 | $fp = fopen($boarddir . '/agreement.txt', 'w'); |
2349 | 2492 | fwrite($fp, $modSettings['agreement']); |
@@ -2353,31 +2496,36 @@ discard block |
||
2353 | 2496 | // Make sure Themes is writable. |
2354 | 2497 | quickFileWritable($modSettings['theme_dir']); |
2355 | 2498 | |
2356 | - if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) |
|
2357 | - print_error('Error: Unable to obtain write access to "Themes".'); |
|
2499 | + if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) { |
|
2500 | + print_error('Error: Unable to obtain write access to "Themes".'); |
|
2501 | + } |
|
2358 | 2502 | |
2359 | 2503 | // Make sure cache directory exists and is writable! |
2360 | 2504 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
2361 | - if (!file_exists($cachedir_temp)) |
|
2362 | - @mkdir($cachedir_temp); |
|
2505 | + if (!file_exists($cachedir_temp)) { |
|
2506 | + @mkdir($cachedir_temp); |
|
2507 | + } |
|
2363 | 2508 | |
2364 | 2509 | // Make sure the cache temp dir is writable. |
2365 | 2510 | quickFileWritable($cachedir_temp); |
2366 | 2511 | |
2367 | - if (!is_writable($cachedir_temp)) |
|
2368 | - print_error('Error: Unable to obtain write access to "cache".', true); |
|
2512 | + if (!is_writable($cachedir_temp)) { |
|
2513 | + print_error('Error: Unable to obtain write access to "cache".', true); |
|
2514 | + } |
|
2369 | 2515 | |
2370 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
2371 | - print_error('Error: Unable to find language files!', true); |
|
2372 | - else |
|
2516 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
2517 | + print_error('Error: Unable to find language files!', true); |
|
2518 | + } else |
|
2373 | 2519 | { |
2374 | 2520 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
2375 | 2521 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
2376 | 2522 | |
2377 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
2378 | - print_error('Error: Language files out of date.', true); |
|
2379 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
2380 | - print_error('Error: Install language is missing for selected language.', true); |
|
2523 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
2524 | + print_error('Error: Language files out of date.', true); |
|
2525 | + } |
|
2526 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
2527 | + print_error('Error: Install language is missing for selected language.', true); |
|
2528 | + } |
|
2381 | 2529 | |
2382 | 2530 | // Otherwise include it! |
2383 | 2531 | require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
@@ -2396,8 +2544,9 @@ discard block |
||
2396 | 2544 | global $upcontext, $db_character_set, $sourcedir, $smcFunc, $modSettings, $language, $db_prefix, $db_type, $command_line, $support_js; |
2397 | 2545 | |
2398 | 2546 | // Done it already? |
2399 | - if (!empty($_POST['utf8_done'])) |
|
2400 | - return true; |
|
2547 | + if (!empty($_POST['utf8_done'])) { |
|
2548 | + return true; |
|
2549 | + } |
|
2401 | 2550 | |
2402 | 2551 | // First make sure they aren't already on UTF-8 before we go anywhere... |
2403 | 2552 | if ($db_type == 'postgresql' || ($db_character_set === 'utf8' && !empty($modSettings['global_character_set']) && $modSettings['global_character_set'] === 'UTF-8')) |
@@ -2410,8 +2559,7 @@ discard block |
||
2410 | 2559 | ); |
2411 | 2560 | |
2412 | 2561 | return true; |
2413 | - } |
|
2414 | - else |
|
2562 | + } else |
|
2415 | 2563 | { |
2416 | 2564 | $upcontext['page_title'] = 'Converting to UTF8'; |
2417 | 2565 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'convert_xml' : 'convert_utf8'; |
@@ -2455,8 +2603,9 @@ discard block |
||
2455 | 2603 | ) |
2456 | 2604 | ); |
2457 | 2605 | $db_charsets = array(); |
2458 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2459 | - $db_charsets[] = $row['Charset']; |
|
2606 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2607 | + $db_charsets[] = $row['Charset']; |
|
2608 | + } |
|
2460 | 2609 | |
2461 | 2610 | $smcFunc['db_free_result']($request); |
2462 | 2611 | |
@@ -2492,13 +2641,15 @@ discard block |
||
2492 | 2641 | // If there's a fulltext index, we need to drop it first... |
2493 | 2642 | if ($request !== false || $smcFunc['db_num_rows']($request) != 0) |
2494 | 2643 | { |
2495 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2496 | - if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
2644 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2645 | + if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
2497 | 2646 | $upcontext['fulltext_index'][] = $row['Key_name']; |
2647 | + } |
|
2498 | 2648 | $smcFunc['db_free_result']($request); |
2499 | 2649 | |
2500 | - if (isset($upcontext['fulltext_index'])) |
|
2501 | - $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
2650 | + if (isset($upcontext['fulltext_index'])) { |
|
2651 | + $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
2652 | + } |
|
2502 | 2653 | } |
2503 | 2654 | |
2504 | 2655 | // Drop it and make a note... |
@@ -2688,8 +2839,9 @@ discard block |
||
2688 | 2839 | $replace = '%field%'; |
2689 | 2840 | |
2690 | 2841 | // Build a huge REPLACE statement... |
2691 | - foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) |
|
2692 | - $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
2842 | + foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) { |
|
2843 | + $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
2844 | + } |
|
2693 | 2845 | } |
2694 | 2846 | |
2695 | 2847 | // Get a list of table names ahead of time... This makes it easier to set our substep and such |
@@ -2699,9 +2851,10 @@ discard block |
||
2699 | 2851 | $upcontext['table_count'] = count($queryTables); |
2700 | 2852 | |
2701 | 2853 | // What ones have we already done? |
2702 | - foreach ($queryTables as $id => $table) |
|
2703 | - if ($id < $_GET['substep']) |
|
2854 | + foreach ($queryTables as $id => $table) { |
|
2855 | + if ($id < $_GET['substep']) |
|
2704 | 2856 | $upcontext['previous_tables'][] = $table; |
2857 | + } |
|
2705 | 2858 | |
2706 | 2859 | $upcontext['cur_table_num'] = $_GET['substep']; |
2707 | 2860 | $upcontext['cur_table_name'] = str_replace($db_prefix, '', $queryTables[$_GET['substep']]); |
@@ -2738,8 +2891,9 @@ discard block |
||
2738 | 2891 | nextSubstep($substep); |
2739 | 2892 | |
2740 | 2893 | // Just to make sure it doesn't time out. |
2741 | - if (function_exists('apache_reset_timeout')) |
|
2742 | - @apache_reset_timeout(); |
|
2894 | + if (function_exists('apache_reset_timeout')) { |
|
2895 | + @apache_reset_timeout(); |
|
2896 | + } |
|
2743 | 2897 | |
2744 | 2898 | $table_charsets = array(); |
2745 | 2899 | |
@@ -2760,8 +2914,9 @@ discard block |
||
2760 | 2914 | { |
2761 | 2915 | list($charset) = explode('_', $collation); |
2762 | 2916 | |
2763 | - if (!isset($table_charsets[$charset])) |
|
2764 | - $table_charsets[$charset] = array(); |
|
2917 | + if (!isset($table_charsets[$charset])) { |
|
2918 | + $table_charsets[$charset] = array(); |
|
2919 | + } |
|
2765 | 2920 | |
2766 | 2921 | $table_charsets[$charset][] = $column_info; |
2767 | 2922 | } |
@@ -2801,10 +2956,11 @@ discard block |
||
2801 | 2956 | if (isset($translation_tables[$upcontext['charset_detected']])) |
2802 | 2957 | { |
2803 | 2958 | $update = ''; |
2804 | - foreach ($table_charsets as $charset => $columns) |
|
2805 | - foreach ($columns as $column) |
|
2959 | + foreach ($table_charsets as $charset => $columns) { |
|
2960 | + foreach ($columns as $column) |
|
2806 | 2961 | $update .= ' |
2807 | 2962 | ' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ','; |
2963 | + } |
|
2808 | 2964 | |
2809 | 2965 | $smcFunc['db_query']('', ' |
2810 | 2966 | UPDATE {raw:table_name} |
@@ -2829,8 +2985,9 @@ discard block |
||
2829 | 2985 | // Now do the actual conversion (if still needed). |
2830 | 2986 | if ($charsets[$upcontext['charset_detected']] !== 'utf8') |
2831 | 2987 | { |
2832 | - if ($command_line) |
|
2833 | - echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
2988 | + if ($command_line) { |
|
2989 | + echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
2990 | + } |
|
2834 | 2991 | |
2835 | 2992 | $smcFunc['db_query']('', ' |
2836 | 2993 | ALTER TABLE {raw:table_name} |
@@ -2840,12 +2997,14 @@ discard block |
||
2840 | 2997 | ) |
2841 | 2998 | ); |
2842 | 2999 | |
2843 | - if ($command_line) |
|
2844 | - echo " done.\n"; |
|
3000 | + if ($command_line) { |
|
3001 | + echo " done.\n"; |
|
3002 | + } |
|
2845 | 3003 | } |
2846 | 3004 | // If this is XML to keep it nice for the user do one table at a time anyway! |
2847 | - if (isset($_GET['xml'])) |
|
2848 | - return upgradeExit(); |
|
3005 | + if (isset($_GET['xml'])) { |
|
3006 | + return upgradeExit(); |
|
3007 | + } |
|
2849 | 3008 | } |
2850 | 3009 | |
2851 | 3010 | $prev_charset = empty($translation_tables[$upcontext['charset_detected']]) ? $charsets[$upcontext['charset_detected']] : $translation_tables[$upcontext['charset_detected']]; |
@@ -2874,8 +3033,8 @@ discard block |
||
2874 | 3033 | ); |
2875 | 3034 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2876 | 3035 | { |
2877 | - if (@safe_unserialize($row['extra']) === false && preg_match('~^(a:3:{s:5:"topic";i:\d+;s:7:"subject";s:)(\d+):"(.+)"(;s:6:"member";s:5:"\d+";})$~', $row['extra'], $matches) === 1) |
|
2878 | - $smcFunc['db_query']('', ' |
|
3036 | + if (@safe_unserialize($row['extra']) === false && preg_match('~^(a:3:{s:5:"topic";i:\d+;s:7:"subject";s:)(\d+):"(.+)"(;s:6:"member";s:5:"\d+";})$~', $row['extra'], $matches) === 1) { |
|
3037 | + $smcFunc['db_query']('', ' |
|
2879 | 3038 | UPDATE {db_prefix}log_actions |
2880 | 3039 | SET extra = {string:extra} |
2881 | 3040 | WHERE id_action = {int:current_action}', |
@@ -2884,6 +3043,7 @@ discard block |
||
2884 | 3043 | 'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4], |
2885 | 3044 | ) |
2886 | 3045 | ); |
3046 | + } |
|
2887 | 3047 | } |
2888 | 3048 | $smcFunc['db_free_result']($request); |
2889 | 3049 | |
@@ -2905,15 +3065,17 @@ discard block |
||
2905 | 3065 | // First thing's first - did we already do this? |
2906 | 3066 | if (!empty($modSettings['json_done'])) |
2907 | 3067 | { |
2908 | - if ($command_line) |
|
2909 | - return DeleteUpgrade(); |
|
2910 | - else |
|
2911 | - return true; |
|
3068 | + if ($command_line) { |
|
3069 | + return DeleteUpgrade(); |
|
3070 | + } else { |
|
3071 | + return true; |
|
3072 | + } |
|
2912 | 3073 | } |
2913 | 3074 | |
2914 | 3075 | // Done it already - js wise? |
2915 | - if (!empty($_POST['json_done'])) |
|
2916 | - return true; |
|
3076 | + if (!empty($_POST['json_done'])) { |
|
3077 | + return true; |
|
3078 | + } |
|
2917 | 3079 | |
2918 | 3080 | // List of tables affected by this function |
2919 | 3081 | // name => array('key', col1[,col2|true[,col3]]) |
@@ -2945,12 +3107,14 @@ discard block |
||
2945 | 3107 | $upcontext['cur_table_name'] = isset($keys[$_GET['substep']]) ? $keys[$_GET['substep']] : $keys[0]; |
2946 | 3108 | $upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100); |
2947 | 3109 | |
2948 | - foreach ($keys as $id => $table) |
|
2949 | - if ($id < $_GET['substep']) |
|
3110 | + foreach ($keys as $id => $table) { |
|
3111 | + if ($id < $_GET['substep']) |
|
2950 | 3112 | $upcontext['previous_tables'][] = $table; |
3113 | + } |
|
2951 | 3114 | |
2952 | - if ($command_line) |
|
2953 | - echo 'Converting data from serialize() to json_encode().'; |
|
3115 | + if ($command_line) { |
|
3116 | + echo 'Converting data from serialize() to json_encode().'; |
|
3117 | + } |
|
2954 | 3118 | |
2955 | 3119 | if (!$support_js || isset($_GET['xml'])) |
2956 | 3120 | { |
@@ -2990,8 +3154,9 @@ discard block |
||
2990 | 3154 | |
2991 | 3155 | // Loop through and fix these... |
2992 | 3156 | $new_settings = array(); |
2993 | - if ($command_line) |
|
2994 | - echo "\n" . 'Fixing some settings...'; |
|
3157 | + if ($command_line) { |
|
3158 | + echo "\n" . 'Fixing some settings...'; |
|
3159 | + } |
|
2995 | 3160 | |
2996 | 3161 | foreach ($serialized_settings as $var) |
2997 | 3162 | { |
@@ -2999,22 +3164,24 @@ discard block |
||
2999 | 3164 | { |
3000 | 3165 | // Attempt to unserialize the setting |
3001 | 3166 | $temp = @safe_unserialize($modSettings[$var]); |
3002 | - if (!$temp && $command_line) |
|
3003 | - echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
3004 | - elseif ($temp !== false) |
|
3005 | - $new_settings[$var] = json_encode($temp); |
|
3167 | + if (!$temp && $command_line) { |
|
3168 | + echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
3169 | + } elseif ($temp !== false) { |
|
3170 | + $new_settings[$var] = json_encode($temp); |
|
3171 | + } |
|
3006 | 3172 | } |
3007 | 3173 | } |
3008 | 3174 | |
3009 | 3175 | // Update everything at once |
3010 | - if (!function_exists('cache_put_data')) |
|
3011 | - require_once($sourcedir . '/Load.php'); |
|
3176 | + if (!function_exists('cache_put_data')) { |
|
3177 | + require_once($sourcedir . '/Load.php'); |
|
3178 | + } |
|
3012 | 3179 | updateSettings($new_settings, true); |
3013 | 3180 | |
3014 | - if ($command_line) |
|
3015 | - echo ' done.'; |
|
3016 | - } |
|
3017 | - elseif ($table == 'themes') |
|
3181 | + if ($command_line) { |
|
3182 | + echo ' done.'; |
|
3183 | + } |
|
3184 | + } elseif ($table == 'themes') |
|
3018 | 3185 | { |
3019 | 3186 | // Finally, fix the admin prefs. Unfortunately this is stored per theme, but hopefully they only have one theme installed at this point... |
3020 | 3187 | $query = $smcFunc['db_query']('', ' |
@@ -3033,10 +3200,11 @@ discard block |
||
3033 | 3200 | |
3034 | 3201 | if ($command_line) |
3035 | 3202 | { |
3036 | - if ($temp === false) |
|
3037 | - echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
3038 | - else |
|
3039 | - echo "\n" . 'Fixing admin preferences...'; |
|
3203 | + if ($temp === false) { |
|
3204 | + echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
3205 | + } else { |
|
3206 | + echo "\n" . 'Fixing admin preferences...'; |
|
3207 | + } |
|
3040 | 3208 | } |
3041 | 3209 | |
3042 | 3210 | if ($temp !== false) |
@@ -3058,15 +3226,15 @@ discard block |
||
3058 | 3226 | ) |
3059 | 3227 | ); |
3060 | 3228 | |
3061 | - if ($command_line) |
|
3062 | - echo ' done.'; |
|
3229 | + if ($command_line) { |
|
3230 | + echo ' done.'; |
|
3231 | + } |
|
3063 | 3232 | } |
3064 | 3233 | } |
3065 | 3234 | |
3066 | 3235 | $smcFunc['db_free_result']($query); |
3067 | 3236 | } |
3068 | - } |
|
3069 | - else |
|
3237 | + } else |
|
3070 | 3238 | { |
3071 | 3239 | // First item is always the key... |
3072 | 3240 | $key = $info[0]; |
@@ -3077,8 +3245,7 @@ discard block |
||
3077 | 3245 | { |
3078 | 3246 | $col_select = $info[1]; |
3079 | 3247 | $where = ' WHERE ' . $info[1] . ' != {empty}'; |
3080 | - } |
|
3081 | - else |
|
3248 | + } else |
|
3082 | 3249 | { |
3083 | 3250 | $col_select = implode(', ', $info); |
3084 | 3251 | } |
@@ -3111,8 +3278,7 @@ discard block |
||
3111 | 3278 | if ($temp === false && $command_line) |
3112 | 3279 | { |
3113 | 3280 | echo "\nFailed to unserialize " . $row[$col] . "... Skipping\n"; |
3114 | - } |
|
3115 | - else |
|
3281 | + } else |
|
3116 | 3282 | { |
3117 | 3283 | $row[$col] = json_encode($temp); |
3118 | 3284 | |
@@ -3137,16 +3303,18 @@ discard block |
||
3137 | 3303 | } |
3138 | 3304 | } |
3139 | 3305 | |
3140 | - if ($command_line) |
|
3141 | - echo ' done.'; |
|
3306 | + if ($command_line) { |
|
3307 | + echo ' done.'; |
|
3308 | + } |
|
3142 | 3309 | |
3143 | 3310 | // Free up some memory... |
3144 | 3311 | $smcFunc['db_free_result']($query); |
3145 | 3312 | } |
3146 | 3313 | } |
3147 | 3314 | // If this is XML to keep it nice for the user do one table at a time anyway! |
3148 | - if (isset($_GET['xml'])) |
|
3149 | - return upgradeExit(); |
|
3315 | + if (isset($_GET['xml'])) { |
|
3316 | + return upgradeExit(); |
|
3317 | + } |
|
3150 | 3318 | } |
3151 | 3319 | |
3152 | 3320 | if ($command_line) |
@@ -3161,8 +3329,9 @@ discard block |
||
3161 | 3329 | |
3162 | 3330 | $_GET['substep'] = 0; |
3163 | 3331 | // Make sure we move on! |
3164 | - if ($command_line) |
|
3165 | - return DeleteUpgrade(); |
|
3332 | + if ($command_line) { |
|
3333 | + return DeleteUpgrade(); |
|
3334 | + } |
|
3166 | 3335 | |
3167 | 3336 | return true; |
3168 | 3337 | } |
@@ -3182,14 +3351,16 @@ discard block |
||
3182 | 3351 | global $upcontext, $txt, $settings; |
3183 | 3352 | |
3184 | 3353 | // Don't call me twice! |
3185 | - if (!empty($upcontext['chmod_called'])) |
|
3186 | - return; |
|
3354 | + if (!empty($upcontext['chmod_called'])) { |
|
3355 | + return; |
|
3356 | + } |
|
3187 | 3357 | |
3188 | 3358 | $upcontext['chmod_called'] = true; |
3189 | 3359 | |
3190 | 3360 | // Nothing? |
3191 | - if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) |
|
3192 | - return; |
|
3361 | + if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) { |
|
3362 | + return; |
|
3363 | + } |
|
3193 | 3364 | |
3194 | 3365 | // Was it a problem with Windows? |
3195 | 3366 | if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess') |
@@ -3221,11 +3392,12 @@ discard block |
||
3221 | 3392 | content.write(\'<div class="windowbg description">\n\t\t\t<h4>The following files needs to be made writable to continue:</h4>\n\t\t\t\'); |
3222 | 3393 | content.write(\'<p>', implode('<br>\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');'; |
3223 | 3394 | |
3224 | - if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') |
|
3225 | - echo ' |
|
3395 | + if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') { |
|
3396 | + echo ' |
|
3226 | 3397 | content.write(\'<hr>\n\t\t\t\'); |
3227 | 3398 | content.write(\'<p>If you have a shell account, the convenient below command can automatically correct permissions on these files</p>\n\t\t\t\'); |
3228 | 3399 | content.write(\'<tt># chmod a+w ', implode(' ', $upcontext['chmod']['files']), '</tt>\n\t\t\t\');'; |
3400 | + } |
|
3229 | 3401 | |
3230 | 3402 | echo ' |
3231 | 3403 | content.write(\'<a href="javascript:self.close();">close</a>\n\t\t</div>\n\t</body>\n</html>\'); |
@@ -3233,17 +3405,19 @@ discard block |
||
3233 | 3405 | } |
3234 | 3406 | </script>'; |
3235 | 3407 | |
3236 | - if (!empty($upcontext['chmod']['ftp_error'])) |
|
3237 | - echo ' |
|
3408 | + if (!empty($upcontext['chmod']['ftp_error'])) { |
|
3409 | + echo ' |
|
3238 | 3410 | <div class="error_message red"> |
3239 | 3411 | The following error was encountered when trying to connect:<br><br> |
3240 | 3412 | <code>', $upcontext['chmod']['ftp_error'], '</code> |
3241 | 3413 | </div> |
3242 | 3414 | <br>'; |
3415 | + } |
|
3243 | 3416 | |
3244 | - if (empty($upcontext['chmod_in_form'])) |
|
3245 | - echo ' |
|
3417 | + if (empty($upcontext['chmod_in_form'])) { |
|
3418 | + echo ' |
|
3246 | 3419 | <form action="', $upcontext['form_url'], '" method="post">'; |
3420 | + } |
|
3247 | 3421 | |
3248 | 3422 | echo ' |
3249 | 3423 | <table width="520" border="0" align="center" style="margin-bottom: 1ex;"> |
@@ -3278,10 +3452,11 @@ discard block |
||
3278 | 3452 | <div class="righttext" style="margin: 1ex;"><input type="submit" value="', $txt['ftp_connect'], '" class="button_submit"></div> |
3279 | 3453 | </div>'; |
3280 | 3454 | |
3281 | - if (empty($upcontext['chmod_in_form'])) |
|
3282 | - echo ' |
|
3455 | + if (empty($upcontext['chmod_in_form'])) { |
|
3456 | + echo ' |
|
3283 | 3457 | </form>'; |
3284 | -} |
|
3458 | + } |
|
3459 | + } |
|
3285 | 3460 | |
3286 | 3461 | function template_upgrade_above() |
3287 | 3462 | { |
@@ -3341,9 +3516,10 @@ discard block |
||
3341 | 3516 | <h2>', $txt['upgrade_progress'], '</h2> |
3342 | 3517 | <ul>'; |
3343 | 3518 | |
3344 | - foreach ($upcontext['steps'] as $num => $step) |
|
3345 | - echo ' |
|
3519 | + foreach ($upcontext['steps'] as $num => $step) { |
|
3520 | + echo ' |
|
3346 | 3521 | <li class="', $num < $upcontext['current_step'] ? 'stepdone' : ($num == $upcontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
3522 | + } |
|
3347 | 3523 | |
3348 | 3524 | echo ' |
3349 | 3525 | </ul> |
@@ -3356,8 +3532,8 @@ discard block |
||
3356 | 3532 | </div> |
3357 | 3533 | </div>'; |
3358 | 3534 | |
3359 | - if (isset($upcontext['step_progress'])) |
|
3360 | - echo ' |
|
3535 | + if (isset($upcontext['step_progress'])) { |
|
3536 | + echo ' |
|
3361 | 3537 | <br> |
3362 | 3538 | <br> |
3363 | 3539 | <div id="progress_bar_step"> |
@@ -3366,6 +3542,7 @@ discard block |
||
3366 | 3542 | <span>', $txt['upgrade_step_progress'], '</span> |
3367 | 3543 | </div> |
3368 | 3544 | </div>'; |
3545 | + } |
|
3369 | 3546 | |
3370 | 3547 | echo ' |
3371 | 3548 | <div id="substep_bar_div" class="smalltext" style="float: left;width: 50%;margin-top: 0.6em;display: ', isset($upcontext['substep_progress']) ? '' : 'none', ';">', isset($upcontext['substep_progress_name']) ? trim(strtr($upcontext['substep_progress_name'], array('.' => ''))) : '', ':</div> |
@@ -3396,32 +3573,36 @@ discard block |
||
3396 | 3573 | { |
3397 | 3574 | global $upcontext, $txt; |
3398 | 3575 | |
3399 | - if (!empty($upcontext['pause'])) |
|
3400 | - echo ' |
|
3576 | + if (!empty($upcontext['pause'])) { |
|
3577 | + echo ' |
|
3401 | 3578 | <em>', $txt['upgrade_incomplete'], '.</em><br> |
3402 | 3579 | |
3403 | 3580 | <h2 style="margin-top: 2ex;">', $txt['upgrade_not_quite_done'], '</h2> |
3404 | 3581 | <h3> |
3405 | 3582 | ', $txt['upgrade_paused_overload'], ' |
3406 | 3583 | </h3>'; |
3584 | + } |
|
3407 | 3585 | |
3408 | - if (!empty($upcontext['custom_warning'])) |
|
3409 | - echo ' |
|
3586 | + if (!empty($upcontext['custom_warning'])) { |
|
3587 | + echo ' |
|
3410 | 3588 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
3411 | 3589 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
3412 | 3590 | <strong style="text-decoration: underline;">', $txt['upgrade_note'], '</strong><br> |
3413 | 3591 | <div style="padding-left: 6ex;">', $upcontext['custom_warning'], '</div> |
3414 | 3592 | </div>'; |
3593 | + } |
|
3415 | 3594 | |
3416 | 3595 | echo ' |
3417 | 3596 | <div class="righttext" style="margin: 1ex;">'; |
3418 | 3597 | |
3419 | - if (!empty($upcontext['continue'])) |
|
3420 | - echo ' |
|
3598 | + if (!empty($upcontext['continue'])) { |
|
3599 | + echo ' |
|
3421 | 3600 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled' : '', ' class="button_submit">'; |
3422 | - if (!empty($upcontext['skip'])) |
|
3423 | - echo ' |
|
3601 | + } |
|
3602 | + if (!empty($upcontext['skip'])) { |
|
3603 | + echo ' |
|
3424 | 3604 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button_submit">'; |
3605 | + } |
|
3425 | 3606 | |
3426 | 3607 | echo ' |
3427 | 3608 | </div> |
@@ -3471,11 +3652,12 @@ discard block |
||
3471 | 3652 | echo '<', '?xml version="1.0" encoding="UTF-8"?', '> |
3472 | 3653 | <smf>'; |
3473 | 3654 | |
3474 | - if (!empty($upcontext['get_data'])) |
|
3475 | - foreach ($upcontext['get_data'] as $k => $v) |
|
3655 | + if (!empty($upcontext['get_data'])) { |
|
3656 | + foreach ($upcontext['get_data'] as $k => $v) |
|
3476 | 3657 | echo ' |
3477 | 3658 | <get key="', $k, '">', $v, '</get>'; |
3478 | -} |
|
3659 | + } |
|
3660 | + } |
|
3479 | 3661 | |
3480 | 3662 | function template_xml_below() |
3481 | 3663 | { |
@@ -3516,8 +3698,8 @@ discard block |
||
3516 | 3698 | template_chmod(); |
3517 | 3699 | |
3518 | 3700 | // For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade! |
3519 | - if ($upcontext['is_large_forum']) |
|
3520 | - echo ' |
|
3701 | + if ($upcontext['is_large_forum']) { |
|
3702 | + echo ' |
|
3521 | 3703 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
3522 | 3704 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
3523 | 3705 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -3525,10 +3707,11 @@ discard block |
||
3525 | 3707 | ', $txt['upgrade_warning_lots_data'], ' |
3526 | 3708 | </div> |
3527 | 3709 | </div>'; |
3710 | + } |
|
3528 | 3711 | |
3529 | 3712 | // A warning message? |
3530 | - if (!empty($upcontext['warning'])) |
|
3531 | - echo ' |
|
3713 | + if (!empty($upcontext['warning'])) { |
|
3714 | + echo ' |
|
3532 | 3715 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
3533 | 3716 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
3534 | 3717 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -3536,6 +3719,7 @@ discard block |
||
3536 | 3719 | ', $upcontext['warning'], ' |
3537 | 3720 | </div> |
3538 | 3721 | </div>'; |
3722 | + } |
|
3539 | 3723 | |
3540 | 3724 | // Paths are incorrect? |
3541 | 3725 | echo ' |
@@ -3551,20 +3735,22 @@ discard block |
||
3551 | 3735 | if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600)) |
3552 | 3736 | { |
3553 | 3737 | $ago = time() - $upcontext['started']; |
3554 | - if ($ago < 60) |
|
3555 | - $ago = $ago . ' seconds'; |
|
3556 | - elseif ($ago < 3600) |
|
3557 | - $ago = (int) ($ago / 60) . ' minutes'; |
|
3558 | - else |
|
3559 | - $ago = (int) ($ago / 3600) . ' hours'; |
|
3738 | + if ($ago < 60) { |
|
3739 | + $ago = $ago . ' seconds'; |
|
3740 | + } elseif ($ago < 3600) { |
|
3741 | + $ago = (int) ($ago / 60) . ' minutes'; |
|
3742 | + } else { |
|
3743 | + $ago = (int) ($ago / 3600) . ' hours'; |
|
3744 | + } |
|
3560 | 3745 | |
3561 | 3746 | $active = time() - $upcontext['updated']; |
3562 | - if ($active < 60) |
|
3563 | - $updated = $active . ' seconds'; |
|
3564 | - elseif ($active < 3600) |
|
3565 | - $updated = (int) ($active / 60) . ' minutes'; |
|
3566 | - else |
|
3567 | - $updated = (int) ($active / 3600) . ' hours'; |
|
3747 | + if ($active < 60) { |
|
3748 | + $updated = $active . ' seconds'; |
|
3749 | + } elseif ($active < 3600) { |
|
3750 | + $updated = (int) ($active / 60) . ' minutes'; |
|
3751 | + } else { |
|
3752 | + $updated = (int) ($active / 3600) . ' hours'; |
|
3753 | + } |
|
3568 | 3754 | |
3569 | 3755 | echo ' |
3570 | 3756 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
@@ -3573,16 +3759,18 @@ discard block |
||
3573 | 3759 | <div style="padding-left: 6ex;"> |
3574 | 3760 | "', $upcontext['user']['name'], '" has been running the upgrade script for the last ', $ago, ' - and was last active ', $updated, ' ago.'; |
3575 | 3761 | |
3576 | - if ($active < 600) |
|
3577 | - echo ' |
|
3762 | + if ($active < 600) { |
|
3763 | + echo ' |
|
3578 | 3764 | We recommend that you do not run this script unless you are sure that ', $upcontext['user']['name'], ' has completed their upgrade.'; |
3765 | + } |
|
3579 | 3766 | |
3580 | - if ($active > $upcontext['inactive_timeout']) |
|
3581 | - echo ' |
|
3767 | + if ($active > $upcontext['inactive_timeout']) { |
|
3768 | + echo ' |
|
3582 | 3769 | <br><br>You can choose to either run the upgrade again from the beginning - or alternatively continue from the last step reached during the last upgrade.'; |
3583 | - else |
|
3584 | - echo ' |
|
3770 | + } else { |
|
3771 | + echo ' |
|
3585 | 3772 | <br><br>This upgrade script cannot be run until ', $upcontext['user']['name'], ' has been inactive for at least ', ($upcontext['inactive_timeout'] > 120 ? round($upcontext['inactive_timeout'] / 60, 1) . ' minutes!' : $upcontext['inactive_timeout'] . ' seconds!'); |
3773 | + } |
|
3586 | 3774 | |
3587 | 3775 | echo ' |
3588 | 3776 | </div> |
@@ -3598,9 +3786,10 @@ discard block |
||
3598 | 3786 | <td> |
3599 | 3787 | <input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '"', $disable_security ? ' disabled' : '', ' class="input_text">'; |
3600 | 3788 | |
3601 | - if (!empty($upcontext['username_incorrect'])) |
|
3602 | - echo ' |
|
3789 | + if (!empty($upcontext['username_incorrect'])) { |
|
3790 | + echo ' |
|
3603 | 3791 | <div class="smalltext" style="color: red;">Username Incorrect</div>'; |
3792 | + } |
|
3604 | 3793 | |
3605 | 3794 | echo ' |
3606 | 3795 | </td> |
@@ -3611,9 +3800,10 @@ discard block |
||
3611 | 3800 | <input type="password" name="passwrd" value=""', $disable_security ? ' disabled' : '', ' class="input_password"> |
3612 | 3801 | <input type="hidden" name="hash_passwrd" value="">'; |
3613 | 3802 | |
3614 | - if (!empty($upcontext['password_failed'])) |
|
3615 | - echo ' |
|
3803 | + if (!empty($upcontext['password_failed'])) { |
|
3804 | + echo ' |
|
3616 | 3805 | <div class="smalltext" style="color: red;">Password Incorrect</div>'; |
3806 | + } |
|
3617 | 3807 | |
3618 | 3808 | echo ' |
3619 | 3809 | </td> |
@@ -3684,8 +3874,8 @@ discard block |
||
3684 | 3874 | <form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">'; |
3685 | 3875 | |
3686 | 3876 | // Warning message? |
3687 | - if (!empty($upcontext['upgrade_options_warning'])) |
|
3688 | - echo ' |
|
3877 | + if (!empty($upcontext['upgrade_options_warning'])) { |
|
3878 | + echo ' |
|
3689 | 3879 | <div style="margin: 1ex; padding: 1ex; border: 1px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
3690 | 3880 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
3691 | 3881 | <strong style="text-decoration: underline;">Warning!</strong><br> |
@@ -3693,6 +3883,7 @@ discard block |
||
3693 | 3883 | ', $upcontext['upgrade_options_warning'], ' |
3694 | 3884 | </div> |
3695 | 3885 | </div>'; |
3886 | + } |
|
3696 | 3887 | |
3697 | 3888 | echo ' |
3698 | 3889 | <table> |
@@ -3735,8 +3926,8 @@ discard block |
||
3735 | 3926 | </td> |
3736 | 3927 | </tr>'; |
3737 | 3928 | |
3738 | - if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) |
|
3739 | - echo ' |
|
3929 | + if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) { |
|
3930 | + echo ' |
|
3740 | 3931 | <tr valign="top"> |
3741 | 3932 | <td width="2%"> |
3742 | 3933 | <input type="checkbox" name="delete_karma" id="delete_karma" value="1" class="input_check"> |
@@ -3745,6 +3936,7 @@ discard block |
||
3745 | 3936 | <label for="delete_karma">Delete all karma settings and info from the DB</label> |
3746 | 3937 | </td> |
3747 | 3938 | </tr>'; |
3939 | + } |
|
3748 | 3940 | |
3749 | 3941 | echo ' |
3750 | 3942 | <tr valign="top"> |
@@ -3782,10 +3974,11 @@ discard block |
||
3782 | 3974 | </div>'; |
3783 | 3975 | |
3784 | 3976 | // Dont any tables so far? |
3785 | - if (!empty($upcontext['previous_tables'])) |
|
3786 | - foreach ($upcontext['previous_tables'] as $table) |
|
3977 | + if (!empty($upcontext['previous_tables'])) { |
|
3978 | + foreach ($upcontext['previous_tables'] as $table) |
|
3787 | 3979 | echo ' |
3788 | 3980 | <br>Completed Table: "', $table, '".'; |
3981 | + } |
|
3789 | 3982 | |
3790 | 3983 | echo ' |
3791 | 3984 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
@@ -3822,12 +4015,13 @@ discard block |
||
3822 | 4015 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
3823 | 4016 | |
3824 | 4017 | // If debug flood the screen. |
3825 | - if ($is_debug) |
|
3826 | - echo ' |
|
4018 | + if ($is_debug) { |
|
4019 | + echo ' |
|
3827 | 4020 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
3828 | 4021 | |
3829 | 4022 | if (document.getElementById(\'debug_section\').scrollHeight) |
3830 | 4023 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
4024 | + } |
|
3831 | 4025 | |
3832 | 4026 | echo ' |
3833 | 4027 | // Get the next update... |
@@ -3860,8 +4054,9 @@ discard block |
||
3860 | 4054 | { |
3861 | 4055 | global $upcontext, $support_js, $is_debug, $timeLimitThreshold; |
3862 | 4056 | |
3863 | - if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) |
|
3864 | - $is_debug = true; |
|
4057 | + if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) { |
|
4058 | + $is_debug = true; |
|
4059 | + } |
|
3865 | 4060 | |
3866 | 4061 | echo ' |
3867 | 4062 | <h3>Executing database changes</h3> |
@@ -3876,8 +4071,9 @@ discard block |
||
3876 | 4071 | { |
3877 | 4072 | foreach ($upcontext['actioned_items'] as $num => $item) |
3878 | 4073 | { |
3879 | - if ($num != 0) |
|
3880 | - echo ' Successful!'; |
|
4074 | + if ($num != 0) { |
|
4075 | + echo ' Successful!'; |
|
4076 | + } |
|
3881 | 4077 | echo '<br>' . $item; |
3882 | 4078 | } |
3883 | 4079 | if (!empty($upcontext['changes_complete'])) |
@@ -3890,28 +4086,32 @@ discard block |
||
3890 | 4086 | $seconds = intval($active % 60); |
3891 | 4087 | |
3892 | 4088 | $totalTime = ''; |
3893 | - if ($hours > 0) |
|
3894 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
3895 | - if ($minutes > 0) |
|
3896 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
3897 | - if ($seconds > 0) |
|
3898 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4089 | + if ($hours > 0) { |
|
4090 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
4091 | + } |
|
4092 | + if ($minutes > 0) { |
|
4093 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
4094 | + } |
|
4095 | + if ($seconds > 0) { |
|
4096 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4097 | + } |
|
3899 | 4098 | } |
3900 | 4099 | |
3901 | - if ($is_debug && !empty($totalTime)) |
|
3902 | - echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
3903 | - else |
|
3904 | - echo ' Successful!<br><br>'; |
|
4100 | + if ($is_debug && !empty($totalTime)) { |
|
4101 | + echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
4102 | + } else { |
|
4103 | + echo ' Successful!<br><br>'; |
|
4104 | + } |
|
3905 | 4105 | |
3906 | 4106 | echo '<span id="commess" style="font-weight: bold;">1 Database Updates Complete! Click Continue to Proceed.</span><br>'; |
3907 | 4107 | } |
3908 | - } |
|
3909 | - else |
|
4108 | + } else |
|
3910 | 4109 | { |
3911 | 4110 | // Tell them how many files we have in total. |
3912 | - if ($upcontext['file_count'] > 1) |
|
3913 | - echo ' |
|
4111 | + if ($upcontext['file_count'] > 1) { |
|
4112 | + echo ' |
|
3914 | 4113 | <strong id="info1">Executing upgrade script <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>'; |
4114 | + } |
|
3915 | 4115 | |
3916 | 4116 | echo ' |
3917 | 4117 | <h3 id="info2"><strong>Executing:</strong> "<span id="cur_item_name">', $upcontext['current_item_name'], '</span>" (<span id="item_num">', $upcontext['current_item_num'], '</span> of <span id="total_items"><span id="item_count">', $upcontext['total_items'], '</span>', $upcontext['file_count'] > 1 ? ' - of this script' : '', ')</span></h3> |
@@ -3927,19 +4127,23 @@ discard block |
||
3927 | 4127 | $seconds = intval($active % 60); |
3928 | 4128 | |
3929 | 4129 | $totalTime = ''; |
3930 | - if ($hours > 0) |
|
3931 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
3932 | - if ($minutes > 0) |
|
3933 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
3934 | - if ($seconds > 0) |
|
3935 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4130 | + if ($hours > 0) { |
|
4131 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
4132 | + } |
|
4133 | + if ($minutes > 0) { |
|
4134 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
4135 | + } |
|
4136 | + if ($seconds > 0) { |
|
4137 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4138 | + } |
|
3936 | 4139 | } |
3937 | 4140 | |
3938 | 4141 | echo ' |
3939 | 4142 | <br><span id="upgradeCompleted">'; |
3940 | 4143 | |
3941 | - if (!empty($totalTime)) |
|
3942 | - echo 'Completed in ', $totalTime, '<br>'; |
|
4144 | + if (!empty($totalTime)) { |
|
4145 | + echo 'Completed in ', $totalTime, '<br>'; |
|
4146 | + } |
|
3943 | 4147 | |
3944 | 4148 | echo '</span> |
3945 | 4149 | <div id="debug_section" style="height: 59px; overflow: auto;"> |
@@ -3976,9 +4180,10 @@ discard block |
||
3976 | 4180 | var getData = ""; |
3977 | 4181 | var debugItems = ', $upcontext['debug_items'], ';'; |
3978 | 4182 | |
3979 | - if ($is_debug) |
|
3980 | - echo ' |
|
4183 | + if ($is_debug) { |
|
4184 | + echo ' |
|
3981 | 4185 | var upgradeStartTime = ' . $upcontext['started'] . ';'; |
4186 | + } |
|
3982 | 4187 | |
3983 | 4188 | echo ' |
3984 | 4189 | function getNextItem() |
@@ -4018,9 +4223,10 @@ discard block |
||
4018 | 4223 | document.getElementById("error_block").style.display = ""; |
4019 | 4224 | setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));'; |
4020 | 4225 | |
4021 | - if ($is_debug) |
|
4022 | - echo ' |
|
4226 | + if ($is_debug) { |
|
4227 | + echo ' |
|
4023 | 4228 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
4229 | + } |
|
4024 | 4230 | |
4025 | 4231 | echo ' |
4026 | 4232 | } |
@@ -4041,9 +4247,10 @@ discard block |
||
4041 | 4247 | document.getElementById("error_block").style.display = ""; |
4042 | 4248 | setInnerHTML(document.getElementById("error_message"), "Upgrade script appears to be going into a loop - step: " + sDebugName);'; |
4043 | 4249 | |
4044 | - if ($is_debug) |
|
4045 | - echo ' |
|
4250 | + if ($is_debug) { |
|
4251 | + echo ' |
|
4046 | 4252 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
4253 | + } |
|
4047 | 4254 | |
4048 | 4255 | echo ' |
4049 | 4256 | } |
@@ -4102,8 +4309,8 @@ discard block |
||
4102 | 4309 | if (bIsComplete && iDebugNum == -1 && curFile >= ', $upcontext['file_count'], ') |
4103 | 4310 | {'; |
4104 | 4311 | |
4105 | - if ($is_debug) |
|
4106 | - echo ' |
|
4312 | + if ($is_debug) { |
|
4313 | + echo ' |
|
4107 | 4314 | document.getElementById(\'debug_section\').style.display = "none"; |
4108 | 4315 | |
4109 | 4316 | var upgradeFinishedTime = parseInt(oXMLDoc.getElementsByTagName("curtime")[0].childNodes[0].nodeValue); |
@@ -4121,6 +4328,7 @@ discard block |
||
4121 | 4328 | totalTime = totalTime + diffSeconds + " second" + (diffSeconds > 1 ? "s" : ""); |
4122 | 4329 | |
4123 | 4330 | setInnerHTML(document.getElementById("upgradeCompleted"), "Completed in " + totalTime);'; |
4331 | + } |
|
4124 | 4332 | |
4125 | 4333 | echo ' |
4126 | 4334 | |
@@ -4128,9 +4336,10 @@ discard block |
||
4128 | 4336 | document.getElementById(\'contbutt\').disabled = 0; |
4129 | 4337 | document.getElementById(\'database_done\').value = 1;'; |
4130 | 4338 | |
4131 | - if ($upcontext['file_count'] > 1) |
|
4132 | - echo ' |
|
4339 | + if ($upcontext['file_count'] > 1) { |
|
4340 | + echo ' |
|
4133 | 4341 | document.getElementById(\'info1\').style.display = "none";'; |
4342 | + } |
|
4134 | 4343 | |
4135 | 4344 | echo ' |
4136 | 4345 | document.getElementById(\'info2\').style.display = "none"; |
@@ -4143,9 +4352,10 @@ discard block |
||
4143 | 4352 | lastItem = 0; |
4144 | 4353 | prevFile = curFile;'; |
4145 | 4354 | |
4146 | - if ($is_debug) |
|
4147 | - echo ' |
|
4355 | + if ($is_debug) { |
|
4356 | + echo ' |
|
4148 | 4357 | setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br><span id="debuginfo"><\' + \'/span>\');'; |
4358 | + } |
|
4149 | 4359 | |
4150 | 4360 | echo ' |
4151 | 4361 | getNextItem(); |
@@ -4153,8 +4363,8 @@ discard block |
||
4153 | 4363 | }'; |
4154 | 4364 | |
4155 | 4365 | // If debug scroll the screen. |
4156 | - if ($is_debug) |
|
4157 | - echo ' |
|
4366 | + if ($is_debug) { |
|
4367 | + echo ' |
|
4158 | 4368 | if (iLastSubStepProgress == -1) |
4159 | 4369 | { |
4160 | 4370 | // Give it consistent dots. |
@@ -4173,6 +4383,7 @@ discard block |
||
4173 | 4383 | |
4174 | 4384 | if (document.getElementById(\'debug_section\').scrollHeight) |
4175 | 4385 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
4386 | + } |
|
4176 | 4387 | |
4177 | 4388 | echo ' |
4178 | 4389 | // Update the page. |
@@ -4233,9 +4444,10 @@ discard block |
||
4233 | 4444 | }'; |
4234 | 4445 | |
4235 | 4446 | // Start things off assuming we've not errored. |
4236 | - if (empty($upcontext['error_message'])) |
|
4237 | - echo ' |
|
4447 | + if (empty($upcontext['error_message'])) { |
|
4448 | + echo ' |
|
4238 | 4449 | getNextItem();'; |
4450 | + } |
|
4239 | 4451 | |
4240 | 4452 | echo ' |
4241 | 4453 | //# sourceURL=dynamicScript-dbch.js |
@@ -4253,18 +4465,21 @@ discard block |
||
4253 | 4465 | <item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item> |
4254 | 4466 | <debug num="', $upcontext['current_debug_item_num'], '" percent="', isset($upcontext['substep_progress']) ? $upcontext['substep_progress'] : '-1', '" complete="', empty($upcontext['completed_step']) ? 0 : 1, '">', $upcontext['current_debug_item_name'], '</debug>'; |
4255 | 4467 | |
4256 | - if (!empty($upcontext['error_message'])) |
|
4257 | - echo ' |
|
4468 | + if (!empty($upcontext['error_message'])) { |
|
4469 | + echo ' |
|
4258 | 4470 | <error>', $upcontext['error_message'], '</error>'; |
4471 | + } |
|
4259 | 4472 | |
4260 | - if (!empty($upcontext['error_string'])) |
|
4261 | - echo ' |
|
4473 | + if (!empty($upcontext['error_string'])) { |
|
4474 | + echo ' |
|
4262 | 4475 | <sql>', $upcontext['error_string'], '</sql>'; |
4476 | + } |
|
4263 | 4477 | |
4264 | - if ($is_debug) |
|
4265 | - echo ' |
|
4478 | + if ($is_debug) { |
|
4479 | + echo ' |
|
4266 | 4480 | <curtime>', time(), '</curtime>'; |
4267 | -} |
|
4481 | + } |
|
4482 | + } |
|
4268 | 4483 | |
4269 | 4484 | // Template for the UTF-8 conversion step. Basically a copy of the backup stuff with slight modifications.... |
4270 | 4485 | function template_convert_utf8() |
@@ -4283,18 +4498,20 @@ discard block |
||
4283 | 4498 | </div>'; |
4284 | 4499 | |
4285 | 4500 | // Done any tables so far? |
4286 | - if (!empty($upcontext['previous_tables'])) |
|
4287 | - foreach ($upcontext['previous_tables'] as $table) |
|
4501 | + if (!empty($upcontext['previous_tables'])) { |
|
4502 | + foreach ($upcontext['previous_tables'] as $table) |
|
4288 | 4503 | echo ' |
4289 | 4504 | <br>Completed Table: "', $table, '".'; |
4505 | + } |
|
4290 | 4506 | |
4291 | 4507 | echo ' |
4292 | 4508 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3>'; |
4293 | 4509 | |
4294 | 4510 | // If we dropped their index, let's let them know |
4295 | - if ($upcontext['cur_table_num'] == $upcontext['table_count'] && $upcontext['dropping_index']) |
|
4296 | - echo ' |
|
4511 | + if ($upcontext['cur_table_num'] == $upcontext['table_count'] && $upcontext['dropping_index']) { |
|
4512 | + echo ' |
|
4297 | 4513 | <br><span style="display:inline;">Please note that your fulltext index was dropped to facilitate the conversion and will need to be recreated.</span>'; |
4514 | + } |
|
4298 | 4515 | |
4299 | 4516 | echo ' |
4300 | 4517 | <br><span id="commess" style="font-weight: bold; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">Conversion Complete! Click Continue to Proceed.</span>'; |
@@ -4330,12 +4547,13 @@ discard block |
||
4330 | 4547 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
4331 | 4548 | |
4332 | 4549 | // If debug flood the screen. |
4333 | - if ($is_debug) |
|
4334 | - echo ' |
|
4550 | + if ($is_debug) { |
|
4551 | + echo ' |
|
4335 | 4552 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
4336 | 4553 | |
4337 | 4554 | if (document.getElementById(\'debug_section\').scrollHeight) |
4338 | 4555 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
4556 | + } |
|
4339 | 4557 | |
4340 | 4558 | echo ' |
4341 | 4559 | // Get the next update... |
@@ -4380,19 +4598,21 @@ discard block |
||
4380 | 4598 | </div>'; |
4381 | 4599 | |
4382 | 4600 | // Dont any tables so far? |
4383 | - if (!empty($upcontext['previous_tables'])) |
|
4384 | - foreach ($upcontext['previous_tables'] as $table) |
|
4601 | + if (!empty($upcontext['previous_tables'])) { |
|
4602 | + foreach ($upcontext['previous_tables'] as $table) |
|
4385 | 4603 | echo ' |
4386 | 4604 | <br>Completed Table: "', $table, '".'; |
4605 | + } |
|
4387 | 4606 | |
4388 | 4607 | echo ' |
4389 | 4608 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
4390 | 4609 | <br><span id="commess" style="font-weight: bold; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">Convert to JSON Complete! Click Continue to Proceed.</span>'; |
4391 | 4610 | |
4392 | 4611 | // Try to make sure substep was reset. |
4393 | - if ($upcontext['cur_table_num'] == $upcontext['table_count']) |
|
4394 | - echo ' |
|
4612 | + if ($upcontext['cur_table_num'] == $upcontext['table_count']) { |
|
4613 | + echo ' |
|
4395 | 4614 | <input type="hidden" name="substep" id="substep" value="0">'; |
4615 | + } |
|
4396 | 4616 | |
4397 | 4617 | // Continue please! |
4398 | 4618 | $upcontext['continue'] = $support_js ? 2 : 1; |
@@ -4425,12 +4645,13 @@ discard block |
||
4425 | 4645 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
4426 | 4646 | |
4427 | 4647 | // If debug flood the screen. |
4428 | - if ($is_debug) |
|
4429 | - echo ' |
|
4648 | + if ($is_debug) { |
|
4649 | + echo ' |
|
4430 | 4650 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
4431 | 4651 | |
4432 | 4652 | if (document.getElementById(\'debug_section\').scrollHeight) |
4433 | 4653 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
4654 | + } |
|
4434 | 4655 | |
4435 | 4656 | echo ' |
4436 | 4657 | // Get the next update... |
@@ -4466,8 +4687,8 @@ discard block |
||
4466 | 4687 | <h3>That wasn\'t so hard, was it? Now you are ready to use <a href="', $boardurl, '/index.php">your installation of SMF</a>. Hope you like it!</h3> |
4467 | 4688 | <form action="', $boardurl, '/index.php">'; |
4468 | 4689 | |
4469 | - if (!empty($upcontext['can_delete_script'])) |
|
4470 | - echo ' |
|
4690 | + if (!empty($upcontext['can_delete_script'])) { |
|
4691 | + echo ' |
|
4471 | 4692 | <label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete(this);" class="input_check"> Delete upgrade.php and its data files now</label> <em>(doesn\'t work on all servers).</em> |
4472 | 4693 | <script> |
4473 | 4694 | function doTheDelete(theCheck) |
@@ -4479,6 +4700,7 @@ discard block |
||
4479 | 4700 | } |
4480 | 4701 | </script> |
4481 | 4702 | <img src="', $settings['default_theme_url'], '/images/blank.png" alt="" id="delete_upgrader"><br>'; |
4703 | + } |
|
4482 | 4704 | |
4483 | 4705 | $active = time() - $upcontext['started']; |
4484 | 4706 | $hours = floor($active / 3600); |
@@ -4488,16 +4710,20 @@ discard block |
||
4488 | 4710 | if ($is_debug) |
4489 | 4711 | { |
4490 | 4712 | $totalTime = ''; |
4491 | - if ($hours > 0) |
|
4492 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
4493 | - if ($minutes > 0) |
|
4494 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
4495 | - if ($seconds > 0) |
|
4496 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4713 | + if ($hours > 0) { |
|
4714 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
4715 | + } |
|
4716 | + if ($minutes > 0) { |
|
4717 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
4718 | + } |
|
4719 | + if ($seconds > 0) { |
|
4720 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4721 | + } |
|
4497 | 4722 | } |
4498 | 4723 | |
4499 | - if ($is_debug && !empty($totalTime)) |
|
4500 | - echo '<br> Upgrade completed in ', $totalTime, '<br><br>'; |
|
4724 | + if ($is_debug && !empty($totalTime)) { |
|
4725 | + echo '<br> Upgrade completed in ', $totalTime, '<br><br>'; |
|
4726 | + } |
|
4501 | 4727 | |
4502 | 4728 | echo '<br> |
4503 | 4729 | If you had any problems with this upgrade, or have any problems using SMF, please don\'t hesitate to <a href="https://www.simplemachines.org/community/index.php">look to us for assistance</a>.<br> |
@@ -4524,8 +4750,9 @@ discard block |
||
4524 | 4750 | |
4525 | 4751 | $current_substep = $_GET['substep']; |
4526 | 4752 | |
4527 | - if (empty($_GET['a'])) |
|
4528 | - $_GET['a'] = 0; |
|
4753 | + if (empty($_GET['a'])) { |
|
4754 | + $_GET['a'] = 0; |
|
4755 | + } |
|
4529 | 4756 | $step_progress['name'] = 'Converting ips'; |
4530 | 4757 | $step_progress['current'] = $_GET['a']; |
4531 | 4758 | |
@@ -4568,16 +4795,19 @@ discard block |
||
4568 | 4795 | 'empty' => '', |
4569 | 4796 | 'limit' => $limit, |
4570 | 4797 | )); |
4571 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
4572 | - $arIp[] = $row[$oldCol]; |
|
4798 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
4799 | + $arIp[] = $row[$oldCol]; |
|
4800 | + } |
|
4573 | 4801 | $smcFunc['db_free_result']($request); |
4574 | 4802 | |
4575 | 4803 | // Special case, null ip could keep us in a loop. |
4576 | - if (is_null($arIp[0])) |
|
4577 | - unset($arIp[0]); |
|
4804 | + if (is_null($arIp[0])) { |
|
4805 | + unset($arIp[0]); |
|
4806 | + } |
|
4578 | 4807 | |
4579 | - if (empty($arIp)) |
|
4580 | - $is_done = true; |
|
4808 | + if (empty($arIp)) { |
|
4809 | + $is_done = true; |
|
4810 | + } |
|
4581 | 4811 | |
4582 | 4812 | $updates = array(); |
4583 | 4813 | $cases = array(); |
@@ -4586,16 +4816,18 @@ discard block |
||
4586 | 4816 | { |
4587 | 4817 | $arIp[$i] = trim($arIp[$i]); |
4588 | 4818 | |
4589 | - if (empty($arIp[$i])) |
|
4590 | - continue; |
|
4819 | + if (empty($arIp[$i])) { |
|
4820 | + continue; |
|
4821 | + } |
|
4591 | 4822 | |
4592 | 4823 | $updates['ip' . $i] = $arIp[$i]; |
4593 | 4824 | $cases[$arIp[$i]] = 'WHEN ' . $oldCol . ' = {string:ip' . $i . '} THEN {inet:ip' . $i . '}'; |
4594 | 4825 | |
4595 | 4826 | if ($setSize > 0 && $i % $setSize === 0) |
4596 | 4827 | { |
4597 | - if (count($updates) == 1) |
|
4598 | - continue; |
|
4828 | + if (count($updates) == 1) { |
|
4829 | + continue; |
|
4830 | + } |
|
4599 | 4831 | |
4600 | 4832 | $updates['whereSet'] = array_values($updates); |
4601 | 4833 | $smcFunc['db_query']('', ' |
@@ -4629,8 +4861,7 @@ discard block |
||
4629 | 4861 | 'ip' => $ip |
4630 | 4862 | )); |
4631 | 4863 | } |
4632 | - } |
|
4633 | - else |
|
4864 | + } else |
|
4634 | 4865 | { |
4635 | 4866 | $updates['whereSet'] = array_values($updates); |
4636 | 4867 | $smcFunc['db_query']('', ' |
@@ -4644,9 +4875,9 @@ discard block |
||
4644 | 4875 | $updates |
4645 | 4876 | ); |
4646 | 4877 | } |
4878 | + } else { |
|
4879 | + $is_done = true; |
|
4647 | 4880 | } |
4648 | - else |
|
4649 | - $is_done = true; |
|
4650 | 4881 | |
4651 | 4882 | $_GET['a'] += $limit; |
4652 | 4883 | $step_progress['current'] = $_GET['a']; |
@@ -4672,10 +4903,11 @@ discard block |
||
4672 | 4903 | |
4673 | 4904 | $columns = $smcFunc['db_list_columns']($targetTable, true); |
4674 | 4905 | |
4675 | - if (isset($columns[$column])) |
|
4676 | - return $columns[$column]; |
|
4677 | - else |
|
4678 | - return null; |
|
4679 | -} |
|
4906 | + if (isset($columns[$column])) { |
|
4907 | + return $columns[$column]; |
|
4908 | + } else { |
|
4909 | + return null; |
|
4910 | + } |
|
4911 | + } |
|
4680 | 4912 | |
4681 | 4913 | ?> |
4682 | 4914 | \ No newline at end of file |
@@ -40,16 +40,14 @@ discard block |
||
40 | 40 | ', template_show_upcoming_list('main'), ' |
41 | 41 | </div> |
42 | 42 | '; |
43 | - } |
|
44 | - elseif ($context['calendar_view'] == 'view_week') |
|
43 | + } elseif ($context['calendar_view'] == 'view_week') |
|
45 | 44 | { |
46 | 45 | echo ' |
47 | 46 | <div id="main_grid"> |
48 | 47 | ', template_show_week_grid('main'), ' |
49 | 48 | </div> |
50 | 49 | '; |
51 | - } |
|
52 | - else |
|
50 | + } else |
|
53 | 51 | { |
54 | 52 | echo ' |
55 | 53 | <div id="main_grid"> |
@@ -75,8 +73,9 @@ discard block |
||
75 | 73 | global $context, $scripturl, $txt; |
76 | 74 | |
77 | 75 | // Bail out if we have nothing to work with |
78 | - if (!isset($context['calendar_grid_' . $grid_name])) |
|
79 | - return false; |
|
76 | + if (!isset($context['calendar_grid_' . $grid_name])) { |
|
77 | + return false; |
|
78 | + } |
|
80 | 79 | |
81 | 80 | // Protect programmer sanity |
82 | 81 | $calendar_data = &$context['calendar_grid_' . $grid_name]; |
@@ -113,11 +112,13 @@ discard block |
||
113 | 112 | <li class="windowbg"> |
114 | 113 | <b class="event_title">', $event['link'], '</b>'; |
115 | 114 | |
116 | - if ($event['can_edit']) |
|
117 | - echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>'; |
|
115 | + if ($event['can_edit']) { |
|
116 | + echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>'; |
|
117 | + } |
|
118 | 118 | |
119 | - if ($event['can_export']) |
|
120 | - echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>'; |
|
119 | + if ($event['can_export']) { |
|
120 | + echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>'; |
|
121 | + } |
|
121 | 122 | |
122 | 123 | echo ' |
123 | 124 | <br>'; |
@@ -125,14 +126,14 @@ discard block |
||
125 | 126 | if (!empty($event['allday'])) |
126 | 127 | { |
127 | 128 | echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), '</time>', ($event['start_date'] != $event['end_date']) ? ' – <time datetime="' . $event['end_iso_gmdate'] . '">' . trim($event['end_date_local']) . '</time>' : ''; |
128 | - } |
|
129 | - else |
|
129 | + } else |
|
130 | 130 | { |
131 | 131 | // Display event info relative to user's local timezone |
132 | 132 | echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), ', ', trim($event['start_time_local']), '</time> – <time datetime="' . $event['end_iso_gmdate'] . '">'; |
133 | 133 | |
134 | - if ($event['start_date_local'] != $event['end_date_local']) |
|
135 | - echo trim($event['end_date_local']) . ', '; |
|
134 | + if ($event['start_date_local'] != $event['end_date_local']) { |
|
135 | + echo trim($event['end_date_local']) . ', '; |
|
136 | + } |
|
136 | 137 | |
137 | 138 | echo trim($event['end_time_local']); |
138 | 139 | |
@@ -141,23 +142,27 @@ discard block |
||
141 | 142 | { |
142 | 143 | echo '</time> (<time datetime="' . $event['start_iso_gmdate'] . '">'; |
143 | 144 | |
144 | - if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig']) |
|
145 | - echo trim($event['start_date_orig']), ', '; |
|
145 | + if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig']) { |
|
146 | + echo trim($event['start_date_orig']), ', '; |
|
147 | + } |
|
146 | 148 | |
147 | 149 | echo trim($event['start_time_orig']), '</time> – <time datetime="' . $event['end_iso_gmdate'] . '">'; |
148 | 150 | |
149 | - if ($event['start_date_orig'] != $event['end_date_orig']) |
|
150 | - echo trim($event['end_date_orig']) . ', '; |
|
151 | + if ($event['start_date_orig'] != $event['end_date_orig']) { |
|
152 | + echo trim($event['end_date_orig']) . ', '; |
|
153 | + } |
|
151 | 154 | |
152 | 155 | echo trim($event['end_time_orig']), ' ', $event['tz_abbrev'], '</time>)'; |
153 | 156 | } |
154 | 157 | // Event is scheduled in the user's own timezone? Let 'em know, just to avoid confusion |
155 | - else |
|
156 | - echo ' ', $event['tz_abbrev'], '</time>'; |
|
158 | + else { |
|
159 | + echo ' ', $event['tz_abbrev'], '</time>'; |
|
160 | + } |
|
157 | 161 | } |
158 | 162 | |
159 | - if (!empty($event['location'])) |
|
160 | - echo '<br>', $event['location']; |
|
163 | + if (!empty($event['location'])) { |
|
164 | + echo '<br>', $event['location']; |
|
165 | + } |
|
161 | 166 | |
162 | 167 | echo ' |
163 | 168 | </li>'; |
@@ -189,8 +194,9 @@ discard block |
||
189 | 194 | |
190 | 195 | $birthdays = array(); |
191 | 196 | |
192 | - foreach ($date as $member) |
|
193 | - $birthdays[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '">' . $member['name'] . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>'; |
|
197 | + foreach ($date as $member) { |
|
198 | + $birthdays[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '">' . $member['name'] . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>'; |
|
199 | + } |
|
194 | 200 | |
195 | 201 | echo implode(', ', $birthdays); |
196 | 202 | |
@@ -221,8 +227,9 @@ discard block |
||
221 | 227 | $date_local = $date['date_local']; |
222 | 228 | unset($date['date_local']); |
223 | 229 | |
224 | - foreach ($date as $holiday) |
|
225 | - $holidays[] = $holiday . ' (' . $date_local . ')'; |
|
230 | + foreach ($date as $holiday) { |
|
231 | + $holidays[] = $holiday . ' (' . $date_local . ')'; |
|
232 | + } |
|
226 | 233 | } |
227 | 234 | |
228 | 235 | echo implode(', ', $holidays); |
@@ -245,17 +252,19 @@ discard block |
||
245 | 252 | global $context, $txt, $scripturl, $modSettings; |
246 | 253 | |
247 | 254 | // If the grid doesn't exist, no point in proceeding. |
248 | - if (!isset($context['calendar_grid_' . $grid_name])) |
|
249 | - return false; |
|
255 | + if (!isset($context['calendar_grid_' . $grid_name])) { |
|
256 | + return false; |
|
257 | + } |
|
250 | 258 | |
251 | 259 | // A handy little pointer variable. |
252 | 260 | $calendar_data = &$context['calendar_grid_' . $grid_name]; |
253 | 261 | |
254 | 262 | // Some conditions for whether or not we should show the week links *here*. |
255 | - if (isset($calendar_data['show_week_links']) && ($calendar_data['show_week_links'] == 3 || (($calendar_data['show_week_links'] == 1 && $is_mini === true) || $calendar_data['show_week_links'] == 2 && $is_mini === false))) |
|
256 | - $show_week_links = true; |
|
257 | - else |
|
258 | - $show_week_links = false; |
|
263 | + if (isset($calendar_data['show_week_links']) && ($calendar_data['show_week_links'] == 3 || (($calendar_data['show_week_links'] == 1 && $is_mini === true) || $calendar_data['show_week_links'] == 2 && $is_mini === false))) { |
|
264 | + $show_week_links = true; |
|
265 | + } else { |
|
266 | + $show_week_links = false; |
|
267 | + } |
|
259 | 268 | |
260 | 269 | // Assuming that we've not disabled it, show the title block! |
261 | 270 | if (empty($calendar_data['disable_title'])) |
@@ -294,8 +303,9 @@ discard block |
||
294 | 303 | } |
295 | 304 | |
296 | 305 | // Show the controls on main grids |
297 | - if ($is_mini === false) |
|
298 | - template_calendar_top($calendar_data); |
|
306 | + if ($is_mini === false) { |
|
307 | + template_calendar_top($calendar_data); |
|
308 | + } |
|
299 | 309 | |
300 | 310 | // Finally, the main calendar table. |
301 | 311 | echo '<table class="calendar_table">'; |
@@ -306,8 +316,9 @@ discard block |
||
306 | 316 | echo '<tr>'; |
307 | 317 | |
308 | 318 | // If we're showing week links, there's an extra column ahead of the week links, so let's think ahead and be prepared! |
309 | - if ($show_week_links === true) |
|
310 | - echo '<th> </th>'; |
|
319 | + if ($show_week_links === true) { |
|
320 | + echo '<th> </th>'; |
|
321 | + } |
|
311 | 322 | |
312 | 323 | // Now, loop through each actual day of the week. |
313 | 324 | foreach ($calendar_data['week_days'] as $day) |
@@ -354,27 +365,29 @@ discard block |
||
354 | 365 | // Additional classes are given for events, holidays, and birthdays. |
355 | 366 | if (!empty($day['events']) && !empty($calendar_data['highlight']['events'])) |
356 | 367 | { |
357 | - if ($is_mini === true && in_array($calendar_data['highlight']['events'], array(1, 3))) |
|
358 | - $classes[] = 'events'; |
|
359 | - elseif ($is_mini === false && in_array($calendar_data['highlight']['events'], array(2, 3))) |
|
360 | - $classes[] = 'events'; |
|
368 | + if ($is_mini === true && in_array($calendar_data['highlight']['events'], array(1, 3))) { |
|
369 | + $classes[] = 'events'; |
|
370 | + } elseif ($is_mini === false && in_array($calendar_data['highlight']['events'], array(2, 3))) { |
|
371 | + $classes[] = 'events'; |
|
372 | + } |
|
361 | 373 | } |
362 | 374 | if (!empty($day['holidays']) && !empty($calendar_data['highlight']['holidays'])) |
363 | 375 | { |
364 | - if ($is_mini === true && in_array($calendar_data['highlight']['holidays'], array(1, 3))) |
|
365 | - $classes[] = 'holidays'; |
|
366 | - elseif ($is_mini === false && in_array($calendar_data['highlight']['holidays'], array(2, 3))) |
|
367 | - $classes[] = 'holidays'; |
|
376 | + if ($is_mini === true && in_array($calendar_data['highlight']['holidays'], array(1, 3))) { |
|
377 | + $classes[] = 'holidays'; |
|
378 | + } elseif ($is_mini === false && in_array($calendar_data['highlight']['holidays'], array(2, 3))) { |
|
379 | + $classes[] = 'holidays'; |
|
380 | + } |
|
368 | 381 | } |
369 | 382 | if (!empty($day['birthdays']) && !empty($calendar_data['highlight']['birthdays'])) |
370 | 383 | { |
371 | - if ($is_mini === true && in_array($calendar_data['highlight']['birthdays'], array(1, 3))) |
|
372 | - $classes[] = 'birthdays'; |
|
373 | - elseif ($is_mini === false && in_array($calendar_data['highlight']['birthdays'], array(2, 3))) |
|
374 | - $classes[] = 'birthdays'; |
|
384 | + if ($is_mini === true && in_array($calendar_data['highlight']['birthdays'], array(1, 3))) { |
|
385 | + $classes[] = 'birthdays'; |
|
386 | + } elseif ($is_mini === false && in_array($calendar_data['highlight']['birthdays'], array(2, 3))) { |
|
387 | + $classes[] = 'birthdays'; |
|
388 | + } |
|
375 | 389 | } |
376 | - } |
|
377 | - else |
|
390 | + } else |
|
378 | 391 | { |
379 | 392 | // Default Classes (either compact or comfortable and disabled). |
380 | 393 | $classes[] = !empty($calendar_data['size']) && $calendar_data['size'] == 'small' ? 'compact' : 'comfortable'; |
@@ -392,17 +405,19 @@ discard block |
||
392 | 405 | $title_prefix = !empty($day['is_first_of_month']) && $context['current_month'] == $calendar_data['current_month'] && $is_mini === false ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$calendar_data['current_month']] . ' ' : $txt['months_titles'][$calendar_data['current_month']] . ' ') : ''; |
393 | 406 | |
394 | 407 | // The actual day number - be it a link, or just plain old text! |
395 | - if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) |
|
396 | - echo '<a href="', $scripturl, '?action=calendar;sa=post;year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="day_text">', $title_prefix, $day['day'], '</span></a>'; |
|
397 | - else |
|
398 | - echo '<span class="day_text">', $title_prefix, $day['day'], '</span>'; |
|
408 | + if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) { |
|
409 | + echo '<a href="', $scripturl, '?action=calendar;sa=post;year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="day_text">', $title_prefix, $day['day'], '</span></a>'; |
|
410 | + } else { |
|
411 | + echo '<span class="day_text">', $title_prefix, $day['day'], '</span>'; |
|
412 | + } |
|
399 | 413 | |
400 | 414 | // A lot of stuff, we're not showing on mini-calendars to conserve space. |
401 | 415 | if ($is_mini === false) |
402 | 416 | { |
403 | 417 | // Holidays are always fun, let's show them! |
404 | - if (!empty($day['holidays'])) |
|
405 | - echo '<div class="smalltext holiday"><span>', $txt['calendar_prompt'], '</span> ', implode(', ', $day['holidays']), '</div>'; |
|
418 | + if (!empty($day['holidays'])) { |
|
419 | + echo '<div class="smalltext holiday"><span>', $txt['calendar_prompt'], '</span> ', implode(', ', $day['holidays']), '</div>'; |
|
420 | + } |
|
406 | 421 | |
407 | 422 | // Happy Birthday Dear, Member! |
408 | 423 | if (!empty($day['birthdays'])) |
@@ -420,14 +435,16 @@ discard block |
||
420 | 435 | echo '<a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">', $member['name'], '</span>', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', $member['is_last'] || ($count == 10 && $use_js_hide) ? '' : ', '; |
421 | 436 | |
422 | 437 | // 9...10! Let's stop there. |
423 | - if ($birthday_count == 10 && $use_js_hide) |
|
424 | - // !!TODO - Inline CSS and JavaScript should be moved. |
|
438 | + if ($birthday_count == 10 && $use_js_hide) { |
|
439 | + // !!TODO - Inline CSS and JavaScript should be moved. |
|
425 | 440 | echo '<span class="hidelink" id="bdhidelink_', $day['day'], '">...<br><a href="', $scripturl, '?action=calendar;month=', $calendar_data['current_month'], ';year=', $calendar_data['current_year'], ';showbd" onclick="document.getElementById(\'bdhide_', $day['day'], '\').style.display = \'\'; document.getElementById(\'bdhidelink_', $day['day'], '\').style.display = \'none\'; return false;">(', sprintf($txt['calendar_click_all'], count($day['birthdays'])), ')</a></span><span id="bdhide_', $day['day'], '" style="display: none;">, '; |
441 | + } |
|
426 | 442 | |
427 | 443 | ++$birthday_count; |
428 | 444 | } |
429 | - if ($use_js_hide) |
|
430 | - echo '</span>'; |
|
445 | + if ($use_js_hide) { |
|
446 | + echo '</span>'; |
|
447 | + } |
|
431 | 448 | |
432 | 449 | echo '</div>'; |
433 | 450 | } |
@@ -437,8 +454,9 @@ discard block |
||
437 | 454 | { |
438 | 455 | // Sort events by start time (all day events will be listed first) |
439 | 456 | uasort($day['events'], function($a, $b) { |
440 | - if ($a['start_timestamp'] == $b['start_timestamp']) |
|
441 | - return 0; |
|
457 | + if ($a['start_timestamp'] == $b['start_timestamp']) { |
|
458 | + return 0; |
|
459 | + } |
|
442 | 460 | return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1; |
443 | 461 | }); |
444 | 462 | |
@@ -454,17 +472,19 @@ discard block |
||
454 | 472 | |
455 | 473 | echo '<div class="event_wrapper', $event['starts_today'] == true ? ' event_starts_today' : '', $event['ends_today'] == true ? ' event_ends_today' : '', $event['allday'] == true ? ' allday' : '', $event['is_selected'] ? ' sel_event' : '', '">', $event['link'], '<br><span class="event_time', empty($event_icons_needed) ? ' floatright' : '', '">'; |
456 | 474 | |
457 | - if (!empty($event['start_time_local']) && $event['starts_today'] == true) |
|
458 | - echo trim(str_replace(':00 ', ' ', $event['start_time_local'])); |
|
459 | - elseif (!empty($event['end_time_local']) && $event['ends_today'] == true) |
|
460 | - echo strtolower($txt['ends']), ' ', trim(str_replace(':00 ', ' ', $event['end_time_local'])); |
|
461 | - elseif (!empty($event['allday'])) |
|
462 | - echo $txt['calendar_allday']; |
|
475 | + if (!empty($event['start_time_local']) && $event['starts_today'] == true) { |
|
476 | + echo trim(str_replace(':00 ', ' ', $event['start_time_local'])); |
|
477 | + } elseif (!empty($event['end_time_local']) && $event['ends_today'] == true) { |
|
478 | + echo strtolower($txt['ends']), ' ', trim(str_replace(':00 ', ' ', $event['end_time_local'])); |
|
479 | + } elseif (!empty($event['allday'])) { |
|
480 | + echo $txt['calendar_allday']; |
|
481 | + } |
|
463 | 482 | |
464 | 483 | echo '</span>'; |
465 | 484 | |
466 | - if (!empty($event['location'])) |
|
467 | - echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>'; |
|
485 | + if (!empty($event['location'])) { |
|
486 | + echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>'; |
|
487 | + } |
|
468 | 488 | |
469 | 489 | if ($event['can_edit'] || $event['can_export']) |
470 | 490 | { |
@@ -501,10 +521,11 @@ discard block |
||
501 | 521 | // Otherwise, assuming it's not a mini-calendar, we can show previous / next month days! |
502 | 522 | elseif ($is_mini === false) |
503 | 523 | { |
504 | - if (empty($current_month_started) && !empty($context['calendar_grid_prev'])) |
|
505 | - echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_prev']['current_year'], ';month=', $context['calendar_grid_prev']['current_month'], '">', $context['calendar_grid_prev']['last_of_month'] - $calendar_data['shift']-- +1, '</a>'; |
|
506 | - elseif (!empty($current_month_started) && !empty($context['calendar_grid_next'])) |
|
507 | - echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_next']['current_year'], ';month=', $context['calendar_grid_next']['current_month'], '">', $current_month_started + 1 == $count ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$context['calendar_grid_next']['current_month']] . ' ' : $txt['months_titles'][$context['calendar_grid_next']['current_month']] . ' ') : '', $final_count++, '</a>'; |
|
524 | + if (empty($current_month_started) && !empty($context['calendar_grid_prev'])) { |
|
525 | + echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_prev']['current_year'], ';month=', $context['calendar_grid_prev']['current_month'], '">', $context['calendar_grid_prev']['last_of_month'] - $calendar_data['shift']-- +1, '</a>'; |
|
526 | + } elseif (!empty($current_month_started) && !empty($context['calendar_grid_next'])) { |
|
527 | + echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_next']['current_year'], ';month=', $context['calendar_grid_next']['current_month'], '">', $current_month_started + 1 == $count ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$context['calendar_grid_next']['current_month']] . ' ' : $txt['months_titles'][$context['calendar_grid_next']['current_month']] . ' ') : '', $final_count++, '</a>'; |
|
528 | + } |
|
508 | 529 | } |
509 | 530 | |
510 | 531 | // Close this day and increase var count. |
@@ -530,8 +551,9 @@ discard block |
||
530 | 551 | global $context, $txt, $scripturl, $modSettings; |
531 | 552 | |
532 | 553 | // We might have no reason to proceed, if the variable isn't there. |
533 | - if (!isset($context['calendar_grid_' . $grid_name])) |
|
534 | - return false; |
|
554 | + if (!isset($context['calendar_grid_' . $grid_name])) { |
|
555 | + return false; |
|
556 | + } |
|
535 | 557 | |
536 | 558 | // Handy pointer. |
537 | 559 | $calendar_data = &$context['calendar_grid_' . $grid_name]; |
@@ -566,8 +588,9 @@ discard block |
||
566 | 588 | } |
567 | 589 | |
568 | 590 | // The Month Title + Week Number... |
569 | - if (!empty($calendar_data['week_title'])) |
|
570 | - echo $calendar_data['week_title']; |
|
591 | + if (!empty($calendar_data['week_title'])) { |
|
592 | + echo $calendar_data['week_title']; |
|
593 | + } |
|
571 | 594 | |
572 | 595 | echo ' |
573 | 596 | </h3> |
@@ -606,10 +629,11 @@ discard block |
||
606 | 629 | <tr class="days_wrapper"> |
607 | 630 | <td class="', implode(' ', $classes), ' act_day">'; |
608 | 631 | // Should the day number be a link? |
609 | - if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) |
|
610 | - echo '<a href="', $scripturl, '?action=calendar;sa=post;month=', $month_data['current_month'], ';year=', $month_data['current_year'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['days'][$day['day_of_week']], ' - ', $day['day'], '</a>'; |
|
611 | - else |
|
612 | - echo $txt['days'][$day['day_of_week']], ' - ', $day['day']; |
|
632 | + if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) { |
|
633 | + echo '<a href="', $scripturl, '?action=calendar;sa=post;month=', $month_data['current_month'], ';year=', $month_data['current_year'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['days'][$day['day_of_week']], ' - ', $day['day'], '</a>'; |
|
634 | + } else { |
|
635 | + echo $txt['days'][$day['day_of_week']], ' - ', $day['day']; |
|
636 | + } |
|
613 | 637 | |
614 | 638 | echo '</td> |
615 | 639 | <td class="', implode(' ', $classes), '', empty($day['events']) ? (' disabled' . ($context['can_post'] ? ' week_post' : '')) : ' events', ' event_col" data-css-prefix="' . $txt['events'] . ' ', (empty($day['events']) && empty($context['can_post'])) ? $txt['none'] : '', '">'; |
@@ -618,8 +642,9 @@ discard block |
||
618 | 642 | { |
619 | 643 | // Sort events by start time (all day events will be listed first) |
620 | 644 | uasort($day['events'], function($a, $b) { |
621 | - if ($a['start_timestamp'] == $b['start_timestamp']) |
|
622 | - return 0; |
|
645 | + if ($a['start_timestamp'] == $b['start_timestamp']) { |
|
646 | + return 0; |
|
647 | + } |
|
623 | 648 | return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1; |
624 | 649 | }); |
625 | 650 | |
@@ -631,15 +656,17 @@ discard block |
||
631 | 656 | |
632 | 657 | echo $event['link'], '<br><span class="event_time', empty($event_icons_needed) ? ' floatright' : '', '">'; |
633 | 658 | |
634 | - if (!empty($event['start_time_local'])) |
|
635 | - echo trim($event['start_time_local']), !empty($event['end_time_local']) ? ' – ' . trim($event['end_time_local']) : ''; |
|
636 | - else |
|
637 | - echo $txt['calendar_allday']; |
|
659 | + if (!empty($event['start_time_local'])) { |
|
660 | + echo trim($event['start_time_local']), !empty($event['end_time_local']) ? ' – ' . trim($event['end_time_local']) : ''; |
|
661 | + } else { |
|
662 | + echo $txt['calendar_allday']; |
|
663 | + } |
|
638 | 664 | |
639 | 665 | echo '</span>'; |
640 | 666 | |
641 | - if (!empty($event['location'])) |
|
642 | - echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>'; |
|
667 | + if (!empty($event['location'])) { |
|
668 | + echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>'; |
|
669 | + } |
|
643 | 670 | |
644 | 671 | if (!empty($event_icons_needed)) |
645 | 672 | { |
@@ -676,8 +703,7 @@ discard block |
||
676 | 703 | </div> |
677 | 704 | <br class="clear">'; |
678 | 705 | } |
679 | - } |
|
680 | - else |
|
706 | + } else |
|
681 | 707 | { |
682 | 708 | if (!empty($context['can_post'])) |
683 | 709 | { |
@@ -690,8 +716,9 @@ discard block |
||
690 | 716 | echo '</td> |
691 | 717 | <td class="', implode(' ', $classes), !empty($day['holidays']) ? ' holidays' : ' disabled', ' holiday_col" data-css-prefix="' . $txt['calendar_prompt'] . ' ">'; |
692 | 718 | // Show any holidays! |
693 | - if (!empty($day['holidays'])) |
|
694 | - echo implode('<br>', $day['holidays']); |
|
719 | + if (!empty($day['holidays'])) { |
|
720 | + echo implode('<br>', $day['holidays']); |
|
721 | + } |
|
695 | 722 | |
696 | 723 | echo '</td> |
697 | 724 | <td class="', implode(' ', $classes), '', !empty($day['birthdays']) ? ' birthdays' : ' disabled', ' birthday_col" data-css-prefix="' . $txt['birthdays'] . ' ">'; |
@@ -749,8 +776,7 @@ discard block |
||
749 | 776 | <input type="text" name="end_date" id="end_date" maxlength="10" value="', $calendar_data['end_date'], '" tabindex="', $context['tabindex']++, '" class="input_text date_input end" data-type="date"> |
750 | 777 | <input type="submit" class="button_submit" style="float:none" id="view_button" value="', $txt['view'], '"> |
751 | 778 | </form>'; |
752 | - } |
|
753 | - else |
|
779 | + } else |
|
754 | 780 | { |
755 | 781 | echo' |
756 | 782 | <form action="', $scripturl, '?action=calendar" id="calendar_navigation" method="post" accept-charset="', $context['character_set'], '"> |
@@ -792,8 +818,9 @@ discard block |
||
792 | 818 | echo ' |
793 | 819 | <form action="', $scripturl, '?action=calendar;sa=post" method="post" name="postevent" accept-charset="', $context['character_set'], '" onsubmit="submitonce(this);smc_saveEntities(\'postevent\', [\'evtitle\']);" style="margin: 0;">'; |
794 | 820 | |
795 | - if (!empty($context['event']['new'])) |
|
796 | - echo '<input type="hidden" name="eventid" value="', $context['event']['eventid'], '">'; |
|
821 | + if (!empty($context['event']['new'])) { |
|
822 | + echo '<input type="hidden" name="eventid" value="', $context['event']['eventid'], '">'; |
|
823 | + } |
|
797 | 824 | |
798 | 825 | // Start the main table. |
799 | 826 | echo ' |
@@ -843,9 +870,10 @@ discard block |
||
843 | 870 | { |
844 | 871 | echo ' |
845 | 872 | <optgroup label="', $category['name'], '">'; |
846 | - foreach ($category['boards'] as $board) |
|
847 | - echo ' |
|
873 | + foreach ($category['boards'] as $board) { |
|
874 | + echo ' |
|
848 | 875 | <option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=>' : '', ' ', $board['name'], ' </option>'; |
876 | + } |
|
849 | 877 | echo ' |
850 | 878 | </optgroup>'; |
851 | 879 | } |
@@ -881,9 +909,10 @@ discard block |
||
881 | 909 | <span class="label">', $txt['calendar_timezone'], '</span> |
882 | 910 | <select name="tz" id="tz"', !empty($context['event']['allday']) ? ' disabled' : '', '>'; |
883 | 911 | |
884 | - foreach ($context['all_timezones'] as $tz => $tzname) |
|
885 | - echo ' |
|
912 | + foreach ($context['all_timezones'] as $tz => $tzname) { |
|
913 | + echo ' |
|
886 | 914 | <option value="', $tz, '"', $tz == $context['event']['tz'] ? ' selected' : '', '>', $tzname, '</option>'; |
915 | + } |
|
887 | 916 | |
888 | 917 | echo ' |
889 | 918 | </select> |
@@ -898,9 +927,10 @@ discard block |
||
898 | 927 | echo ' |
899 | 928 | <input type="submit" value="', empty($context['event']['new']) ? $txt['save'] : $txt['post'], '" class="button_submit">'; |
900 | 929 | // Delete button? |
901 | - if (empty($context['event']['new'])) |
|
902 | - echo ' |
|
930 | + if (empty($context['event']['new'])) { |
|
931 | + echo ' |
|
903 | 932 | <input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['calendar_confirm_delete'], '" class="button_submit you_sure">'; |
933 | + } |
|
904 | 934 | |
905 | 935 | echo ' |
906 | 936 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -944,9 +974,10 @@ discard block |
||
944 | 974 | |
945 | 975 | foreach ($context['clockicons'] as $t => $v) |
946 | 976 | { |
947 | - foreach ($v as $i) |
|
948 | - echo ' |
|
977 | + foreach ($v as $i) { |
|
978 | + echo ' |
|
949 | 979 | icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');'; |
980 | + } |
|
950 | 981 | } |
951 | 982 | |
952 | 983 | echo ' |
@@ -971,13 +1002,14 @@ discard block |
||
971 | 1002 | |
972 | 1003 | foreach ($context['clockicons'] as $t => $v) |
973 | 1004 | { |
974 | - foreach ($v as $i) |
|
975 | - echo ' |
|
1005 | + foreach ($v as $i) { |
|
1006 | + echo ' |
|
976 | 1007 | if (', $t, ' >= ', $i, ') |
977 | 1008 | { |
978 | 1009 | turnon.push("', $t, '_', $i, '"); |
979 | 1010 | ', $t, ' -= ', $i, '; |
980 | 1011 | }'; |
1012 | + } |
|
981 | 1013 | } |
982 | 1014 | |
983 | 1015 | echo ' |
@@ -1041,9 +1073,10 @@ discard block |
||
1041 | 1073 | |
1042 | 1074 | foreach ($context['clockicons'] as $t => $v) |
1043 | 1075 | { |
1044 | - foreach ($v as $i) |
|
1045 | - echo ' |
|
1076 | + foreach ($v as $i) { |
|
1077 | + echo ' |
|
1046 | 1078 | icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');'; |
1079 | + } |
|
1047 | 1080 | } |
1048 | 1081 | |
1049 | 1082 | echo ' |
@@ -1060,13 +1093,14 @@ discard block |
||
1060 | 1093 | |
1061 | 1094 | foreach ($context['clockicons'] as $t => $v) |
1062 | 1095 | { |
1063 | - foreach ($v as $i) |
|
1064 | - echo ' |
|
1096 | + foreach ($v as $i) { |
|
1097 | + echo ' |
|
1065 | 1098 | if (', $t, ' >= ', $i, ') |
1066 | 1099 | { |
1067 | 1100 | turnon.push("', $t, '_', $i, '"); |
1068 | 1101 | ', $t, ' -= ', $i, '; |
1069 | 1102 | }'; |
1103 | + } |
|
1070 | 1104 | } |
1071 | 1105 | |
1072 | 1106 | echo ' |
@@ -1125,9 +1159,10 @@ discard block |
||
1125 | 1159 | |
1126 | 1160 | foreach ($context['clockicons'] as $t => $v) |
1127 | 1161 | { |
1128 | - foreach ($v as $i) |
|
1129 | - echo ' |
|
1162 | + foreach ($v as $i) { |
|
1163 | + echo ' |
|
1130 | 1164 | icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');'; |
1165 | + } |
|
1131 | 1166 | } |
1132 | 1167 | |
1133 | 1168 | echo ' |
@@ -1148,13 +1183,14 @@ discard block |
||
1148 | 1183 | |
1149 | 1184 | foreach ($context['clockicons'] as $t => $v) |
1150 | 1185 | { |
1151 | - foreach ($v as $i) |
|
1152 | - echo ' |
|
1186 | + foreach ($v as $i) { |
|
1187 | + echo ' |
|
1153 | 1188 | if (', $t, ' >= ', $i, ') |
1154 | 1189 | { |
1155 | 1190 | turnon.push("', $t, '_', $i, '"); |
1156 | 1191 | ', $t, ' -= ', $i, '; |
1157 | 1192 | }'; |
1193 | + } |
|
1158 | 1194 | } |
1159 | 1195 | |
1160 | 1196 | echo ' |
@@ -64,9 +64,10 @@ discard block |
||
64 | 64 | <strong>', $txt['administrators'], ':</strong> |
65 | 65 | ', implode(', ', $context['administrators']); |
66 | 66 | // If we have lots of admins... don't show them all. |
67 | - if (!empty($context['more_admins_link'])) |
|
68 | - echo ' |
|
67 | + if (!empty($context['more_admins_link'])) { |
|
68 | + echo ' |
|
69 | 69 | (', $context['more_admins_link'], ')'; |
70 | + } |
|
70 | 71 | |
71 | 72 | echo ' |
72 | 73 | </div> |
@@ -83,16 +84,18 @@ discard block |
||
83 | 84 | foreach ($area['areas'] as $item_id => $item) |
84 | 85 | { |
85 | 86 | // No point showing the 'home' page here, we're already on it! |
86 | - if ($area_id == 'forum' && $item_id == 'index') |
|
87 | - continue; |
|
87 | + if ($area_id == 'forum' && $item_id == 'index') { |
|
88 | + continue; |
|
89 | + } |
|
88 | 90 | |
89 | 91 | $url = isset($item['url']) ? $item['url'] : $scripturl . '?action=admin;area=' . $item_id . (!empty($context[$context['admin_menu_name']]['extra_parameters']) ? $context[$context['admin_menu_name']]['extra_parameters'] : ''); |
90 | - if (!empty($item['icon_file'])) |
|
91 | - echo ' |
|
92 | + if (!empty($item['icon_file'])) { |
|
93 | + echo ' |
|
92 | 94 | <a href="', $url, '" class="admin_group', !empty($item['inactive']) ? ' inactive' : '', '"><img class="large_admin_menu_icon_file" src="', $item['icon_file'], '" alt="">', $item['label'], '</a>'; |
93 | - else |
|
94 | - echo ' |
|
95 | + } else { |
|
96 | + echo ' |
|
95 | 97 | <a href="', $url, '"><span class="large_', $item['icon_class'], !empty($item['inactive']) ? ' inactive' : '', '"></span>', $item['label'], '</a>'; |
98 | + } |
|
96 | 99 | } |
97 | 100 | |
98 | 101 | echo ' |
@@ -103,10 +106,11 @@ discard block |
||
103 | 106 | </div>'; |
104 | 107 | |
105 | 108 | // The below functions include all the scripts needed from the simplemachines.org site. The language and format are passed for internationalization. |
106 | - if (empty($modSettings['disable_smf_js'])) |
|
107 | - echo ' |
|
109 | + if (empty($modSettings['disable_smf_js'])) { |
|
110 | + echo ' |
|
108 | 111 | <script src="', $scripturl, '?action=viewsmfile;filename=current-version.js"></script> |
109 | 112 | <script src="', $scripturl, '?action=viewsmfile;filename=latest-news.js"></script>'; |
113 | + } |
|
110 | 114 | |
111 | 115 | // This sets the announcements and current versions themselves ;). |
112 | 116 | echo ' |
@@ -185,9 +189,10 @@ discard block |
||
185 | 189 | <em>', $version['version'], '</em>'; |
186 | 190 | |
187 | 191 | // more details for this item, show them a link |
188 | - if ($context['can_admin'] && isset($version['more'])) |
|
189 | - echo |
|
192 | + if ($context['can_admin'] && isset($version['more'])) { |
|
193 | + echo |
|
190 | 194 | ' <a href="', $scripturl, $version['more'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['version_check_more'], '</a>'; |
195 | + } |
|
191 | 196 | echo ' |
192 | 197 | <br>'; |
193 | 198 | } |
@@ -218,20 +223,22 @@ discard block |
||
218 | 223 | |
219 | 224 | foreach ($context['credits'] as $section) |
220 | 225 | { |
221 | - if (isset($section['pretext'])) |
|
222 | - echo ' |
|
226 | + if (isset($section['pretext'])) { |
|
227 | + echo ' |
|
223 | 228 | <p>', $section['pretext'], '</p><hr>'; |
229 | + } |
|
224 | 230 | |
225 | 231 | echo ' |
226 | 232 | <dl>'; |
227 | 233 | |
228 | 234 | foreach ($section['groups'] as $group) |
229 | 235 | { |
230 | - if (isset($group['title'])) |
|
231 | - echo ' |
|
236 | + if (isset($group['title'])) { |
|
237 | + echo ' |
|
232 | 238 | <dt> |
233 | 239 | <strong>', $group['title'], ':</strong> |
234 | 240 | </dt>'; |
241 | + } |
|
235 | 242 | |
236 | 243 | echo ' |
237 | 244 | <dd>', implode(', ', $group['members']), '</dd>'; |
@@ -240,10 +247,11 @@ discard block |
||
240 | 247 | echo ' |
241 | 248 | </dl>'; |
242 | 249 | |
243 | - if (isset($section['posttext'])) |
|
244 | - echo ' |
|
250 | + if (isset($section['posttext'])) { |
|
251 | + echo ' |
|
245 | 252 | <hr> |
246 | 253 | <p>', $section['posttext'], '</p>'; |
254 | + } |
|
247 | 255 | } |
248 | 256 | |
249 | 257 | echo ' |
@@ -259,9 +267,10 @@ discard block |
||
259 | 267 | smfSupportVersions.forum = "', $context['forum_version'], '";'; |
260 | 268 | |
261 | 269 | // Don't worry, none of this is logged, it's just used to give information that might be of use. |
262 | - foreach ($context['current_versions'] as $variable => $version) |
|
263 | - echo ' |
|
270 | + foreach ($context['current_versions'] as $variable => $version) { |
|
271 | + echo ' |
|
264 | 272 | smfSupportVersions.', $variable, ' = "', $version['version'], '";'; |
273 | + } |
|
265 | 274 | |
266 | 275 | // Now we just have to include the script and wait ;). |
267 | 276 | echo ' |
@@ -358,8 +367,8 @@ discard block |
||
358 | 367 | <tbody>'; |
359 | 368 | |
360 | 369 | // Loop through every source file displaying its version - using javascript. |
361 | - foreach ($context['file_versions'] as $filename => $version) |
|
362 | - echo ' |
|
370 | + foreach ($context['file_versions'] as $filename => $version) { |
|
371 | + echo ' |
|
363 | 372 | <tr class="windowbg"> |
364 | 373 | <td class="half_table"> |
365 | 374 | ', $filename, ' |
@@ -371,6 +380,7 @@ discard block |
||
371 | 380 | <em id="currentSources', $filename, '">??</em> |
372 | 381 | </td> |
373 | 382 | </tr>'; |
383 | + } |
|
374 | 384 | |
375 | 385 | // Default template files. |
376 | 386 | echo ' |
@@ -396,8 +406,8 @@ discard block |
||
396 | 406 | <table id="Default" class="table_grid"> |
397 | 407 | <tbody>'; |
398 | 408 | |
399 | - foreach ($context['default_template_versions'] as $filename => $version) |
|
400 | - echo ' |
|
409 | + foreach ($context['default_template_versions'] as $filename => $version) { |
|
410 | + echo ' |
|
401 | 411 | <tr class="windowbg"> |
402 | 412 | <td class="half_table"> |
403 | 413 | ', $filename, ' |
@@ -409,6 +419,7 @@ discard block |
||
409 | 419 | <em id="currentDefault', $filename, '">??</em> |
410 | 420 | </td> |
411 | 421 | </tr>'; |
422 | + } |
|
412 | 423 | |
413 | 424 | // Now the language files... |
414 | 425 | echo ' |
@@ -436,8 +447,8 @@ discard block |
||
436 | 447 | |
437 | 448 | foreach ($context['default_language_versions'] as $language => $files) |
438 | 449 | { |
439 | - foreach ($files as $filename => $version) |
|
440 | - echo ' |
|
450 | + foreach ($files as $filename => $version) { |
|
451 | + echo ' |
|
441 | 452 | <tr class="windowbg"> |
442 | 453 | <td class="half_table"> |
443 | 454 | ', $filename, '.<em>', $language, '</em>.php |
@@ -449,6 +460,7 @@ discard block |
||
449 | 460 | <em id="current', $filename, '.', $language, '">??</em> |
450 | 461 | </td> |
451 | 462 | </tr>'; |
463 | + } |
|
452 | 464 | } |
453 | 465 | |
454 | 466 | echo ' |
@@ -478,8 +490,8 @@ discard block |
||
478 | 490 | <table id="Templates" class="table_grid"> |
479 | 491 | <tbody>'; |
480 | 492 | |
481 | - foreach ($context['template_versions'] as $filename => $version) |
|
482 | - echo ' |
|
493 | + foreach ($context['template_versions'] as $filename => $version) { |
|
494 | + echo ' |
|
483 | 495 | <tr class="windowbg"> |
484 | 496 | <td class="half_table"> |
485 | 497 | ', $filename, ' |
@@ -491,6 +503,7 @@ discard block |
||
491 | 503 | <em id="currentTemplates', $filename, '">??</em> |
492 | 504 | </td> |
493 | 505 | </tr>'; |
506 | + } |
|
494 | 507 | |
495 | 508 | echo ' |
496 | 509 | </tbody> |
@@ -520,8 +533,8 @@ discard block |
||
520 | 533 | <table id="Tasks" class="table_grid"> |
521 | 534 | <tbody>'; |
522 | 535 | |
523 | - foreach ($context['tasks_versions'] as $filename => $version) |
|
524 | - echo ' |
|
536 | + foreach ($context['tasks_versions'] as $filename => $version) { |
|
537 | + echo ' |
|
525 | 538 | <tr class="windowbg"> |
526 | 539 | <td class="half_table"> |
527 | 540 | ', $filename, ' |
@@ -533,6 +546,7 @@ discard block |
||
533 | 546 | <em id="currentTasks', $filename, '">??</em> |
534 | 547 | </td> |
535 | 548 | </tr>'; |
549 | + } |
|
536 | 550 | |
537 | 551 | echo ' |
538 | 552 | </tbody> |
@@ -574,9 +588,10 @@ discard block |
||
574 | 588 | { |
575 | 589 | global $context, $scripturl, $txt, $modSettings; |
576 | 590 | |
577 | - if (!empty($context['saved_successful'])) |
|
578 | - echo ' |
|
591 | + if (!empty($context['saved_successful'])) { |
|
592 | + echo ' |
|
579 | 593 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
594 | + } |
|
580 | 595 | |
581 | 596 | // First section is for adding/removing words from the censored list. |
582 | 597 | echo ' |
@@ -591,11 +606,12 @@ discard block |
||
591 | 606 | <p>', $txt['admin_censored_where'], '</p>'; |
592 | 607 | |
593 | 608 | // Show text boxes for censoring [bad ] => [good ]. |
594 | - foreach ($context['censored_words'] as $vulgar => $proper) |
|
595 | - echo ' |
|
609 | + foreach ($context['censored_words'] as $vulgar => $proper) { |
|
610 | + echo ' |
|
596 | 611 | <div class="block"> |
597 | 612 | <input type="text" name="censor_vulgar[]" value="', $vulgar, '" size="30"> => <input type="text" name="censor_proper[]" value="', $proper, '" size="30"> |
598 | 613 | </div>'; |
614 | + } |
|
599 | 615 | |
600 | 616 | // Now provide a way to censor more words. |
601 | 617 | echo ' |
@@ -669,19 +685,21 @@ discard block |
||
669 | 685 | <div class="windowbg2 noup"> |
670 | 686 | ', $txt['not_done_reason']; |
671 | 687 | |
672 | - if (!empty($context['continue_percent'])) |
|
673 | - echo ' |
|
688 | + if (!empty($context['continue_percent'])) { |
|
689 | + echo ' |
|
674 | 690 | <div class="progress_bar"> |
675 | 691 | <div class="full_bar">', $context['continue_percent'], '%</div> |
676 | 692 | <div class="green_percent" style="width: ', $context['continue_percent'], '%;"> </div> |
677 | 693 | </div>'; |
694 | + } |
|
678 | 695 | |
679 | - if (!empty($context['substep_enabled'])) |
|
680 | - echo ' |
|
696 | + if (!empty($context['substep_enabled'])) { |
|
697 | + echo ' |
|
681 | 698 | <div class="progress_bar"> |
682 | 699 | <div class="full_bar">', $context['substep_title'], ' (', $context['substep_continue_percent'], '%)</div> |
683 | 700 | <div class="blue_percent" style="width: ', $context['substep_continue_percent'], '%;"> </div> |
684 | 701 | </div>'; |
702 | + } |
|
685 | 703 | |
686 | 704 | echo ' |
687 | 705 | <form action="', $scripturl, $context['continue_get_data'], '" method="post" accept-charset="', $context['character_set'], '" name="autoSubmit" id="autoSubmit"> |
@@ -716,35 +734,40 @@ discard block |
||
716 | 734 | { |
717 | 735 | global $context, $txt, $scripturl; |
718 | 736 | |
719 | - if (!empty($context['saved_successful'])) |
|
720 | - echo ' |
|
737 | + if (!empty($context['saved_successful'])) { |
|
738 | + echo ' |
|
721 | 739 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
722 | - elseif (!empty($context['saved_failed'])) |
|
723 | - echo ' |
|
740 | + } elseif (!empty($context['saved_failed'])) { |
|
741 | + echo ' |
|
724 | 742 | <div class="errorbox">', sprintf($txt['settings_not_saved'], $context['saved_failed']), '</div>'; |
743 | + } |
|
725 | 744 | |
726 | - if (!empty($context['settings_pre_javascript'])) |
|
727 | - echo ' |
|
745 | + if (!empty($context['settings_pre_javascript'])) { |
|
746 | + echo ' |
|
728 | 747 | <script>', $context['settings_pre_javascript'], '</script>'; |
748 | + } |
|
729 | 749 | |
730 | - if (!empty($context['settings_insert_above'])) |
|
731 | - echo $context['settings_insert_above']; |
|
750 | + if (!empty($context['settings_insert_above'])) { |
|
751 | + echo $context['settings_insert_above']; |
|
752 | + } |
|
732 | 753 | |
733 | 754 | echo ' |
734 | 755 | <div id="admincenter"> |
735 | 756 | <form id="admin_form_wrapper" action="', $context['post_url'], '" method="post" accept-charset="', $context['character_set'], '"', !empty($context['force_form_onsubmit']) ? ' onsubmit="' . $context['force_form_onsubmit'] . '"' : '', '>'; |
736 | 757 | |
737 | 758 | // Is there a custom title? |
738 | - if (isset($context['settings_title'])) |
|
739 | - echo ' |
|
759 | + if (isset($context['settings_title'])) { |
|
760 | + echo ' |
|
740 | 761 | <div class="cat_bar"> |
741 | 762 | <h3 class="catbg">', $context['settings_title'], '</h3> |
742 | 763 | </div>'; |
764 | + } |
|
743 | 765 | |
744 | 766 | // Have we got a message to display? |
745 | - if (!empty($context['settings_message'])) |
|
746 | - echo ' |
|
767 | + if (!empty($context['settings_message'])) { |
|
768 | + echo ' |
|
747 | 769 | <div class="information">', $context['settings_message'], '</div>'; |
770 | + } |
|
748 | 771 | |
749 | 772 | // Now actually loop through all the variables. |
750 | 773 | $is_open = false; |
@@ -797,8 +820,9 @@ discard block |
||
797 | 820 | // Hang about? Are you pulling my leg - a callback?! |
798 | 821 | if (is_array($config_var) && $config_var['type'] == 'callback') |
799 | 822 | { |
800 | - if (function_exists('template_callback_' . $config_var['name'])) |
|
801 | - call_user_func('template_callback_' . $config_var['name']); |
|
823 | + if (function_exists('template_callback_' . $config_var['name'])) { |
|
824 | + call_user_func('template_callback_' . $config_var['name']); |
|
825 | + } |
|
802 | 826 | |
803 | 827 | continue; |
804 | 828 | } |
@@ -828,9 +852,10 @@ discard block |
||
828 | 852 | $text_types = array('color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time'); |
829 | 853 | |
830 | 854 | // Show the [?] button. |
831 | - if ($config_var['help']) |
|
832 | - echo ' |
|
855 | + if ($config_var['help']) { |
|
856 | + echo ' |
|
833 | 857 | <a id="setting_', $config_var['name'], '_help" href="', $scripturl, '?action=helpadmin;help=', $config_var['help'], '" onclick="return reqOverlayDiv(this.href);"><span class="generic_icons help" title="', $txt['help'], '"></span></a> '; |
858 | + } |
|
834 | 859 | |
835 | 860 | echo ' |
836 | 861 | <a id="setting_', $config_var['name'], '"></a> <span', ($config_var['disabled'] ? ' style="color: #777777;"' : ($config_var['invalid'] ? ' class="error"' : '')), '><label for="', $config_var['name'], '">', $config_var['label'], '</label>', $subtext, ($config_var['type'] == 'password' ? '<br><em>' . $txt['admin_confirm_password'] . '</em>' : ''), '</span> |
@@ -839,22 +864,25 @@ discard block |
||
839 | 864 | $config_var['preinput']; |
840 | 865 | |
841 | 866 | // Show a check box. |
842 | - if ($config_var['type'] == 'check') |
|
843 | - echo ' |
|
867 | + if ($config_var['type'] == 'check') { |
|
868 | + echo ' |
|
844 | 869 | <input type="checkbox"', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '"', ($config_var['value'] ? ' checked' : ''), ' value="1" class="input_check">'; |
870 | + } |
|
845 | 871 | // Escape (via htmlspecialchars.) the text box. |
846 | - elseif ($config_var['type'] == 'password') |
|
847 | - echo ' |
|
872 | + elseif ($config_var['type'] == 'password') { |
|
873 | + echo ' |
|
848 | 874 | <input type="password"', $disabled, $javascript, ' name="', $config_var['name'], '[0]"', ($config_var['size'] ? ' size="' . $config_var['size'] . '"' : ''), ' value="*#fakepass#*" onfocus="this.value = \'\'; this.form.', $config_var['name'], '.disabled = false;" class="input_password"><br> |
849 | 875 | <input type="password" disabled id="', $config_var['name'], '" name="', $config_var['name'], '[1]"', ($config_var['size'] ? ' size="' . $config_var['size'] . '"' : ''), ' class="input_password">'; |
876 | + } |
|
850 | 877 | // Show a selection box. |
851 | 878 | elseif ($config_var['type'] == 'select') |
852 | 879 | { |
853 | 880 | echo ' |
854 | 881 | <select name="', $config_var['name'], '" id="', $config_var['name'], '" ', $javascript, $disabled, (!empty($config_var['multiple']) ? ' multiple="multiple"' : ''), (!empty($config_var['multiple']) && !empty($config_var['size']) ? ' size="' . $config_var['size'] . '"' : ''), '>'; |
855 | - foreach ($config_var['data'] as $option) |
|
856 | - echo ' |
|
882 | + foreach ($config_var['data'] as $option) { |
|
883 | + echo ' |
|
857 | 884 | <option value="', $option[0], '"', (!empty($config_var['value']) && ($option[0] == $config_var['value'] || (!empty($config_var['multiple']) && in_array($option[0], $config_var['value']))) ? ' selected' : ''), '>', $option[1], '</option>'; |
885 | + } |
|
858 | 886 | echo ' |
859 | 887 | </select>'; |
860 | 888 | } |
@@ -868,15 +896,17 @@ discard block |
||
868 | 896 | <legend class="board_selector"><a href="#">', $txt['select_boards_from_list'], '</a></legend>'; |
869 | 897 | foreach ($context['board_list'] as $id_cat => $cat) |
870 | 898 | { |
871 | - if (!$first) |
|
872 | - echo ' |
|
899 | + if (!$first) { |
|
900 | + echo ' |
|
873 | 901 | <hr>'; |
902 | + } |
|
874 | 903 | echo ' |
875 | 904 | <strong>', $cat['name'], '</strong> |
876 | 905 | <ul>'; |
877 | - foreach ($cat['boards'] as $id_board => $brd) |
|
878 | - echo ' |
|
906 | + foreach ($cat['boards'] as $id_board => $brd) { |
|
907 | + echo ' |
|
879 | 908 | <li><label><input type="checkbox" name="', $config_var['name'], '[', $brd['id'], ']" value="1" class="input_check"', in_array($brd['id'], $config_var['value']) ? ' checked' : '', '> ', $brd['child_level'] > 0 ? str_repeat(' ', $brd['child_level']) : '', $brd['name'], '</label></li>'; |
909 | + } |
|
880 | 910 | |
881 | 911 | echo ' |
882 | 912 | </ul>'; |
@@ -886,12 +916,14 @@ discard block |
||
886 | 916 | </fieldset>'; |
887 | 917 | } |
888 | 918 | // Text area? |
889 | - elseif ($config_var['type'] == 'large_text') |
|
890 | - echo ' |
|
919 | + elseif ($config_var['type'] == 'large_text') { |
|
920 | + echo ' |
|
891 | 921 | <textarea rows="', (!empty($config_var['size']) ? $config_var['size'] : (!empty($config_var['rows']) ? $config_var['rows'] : 4)), '" cols="', (!empty($config_var['cols']) ? $config_var['cols'] : 30), '" ', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '">', $config_var['value'], '</textarea>'; |
922 | + } |
|
892 | 923 | // Permission group? |
893 | - elseif ($config_var['type'] == 'permissions') |
|
894 | - theme_inline_permissions($config_var['name']); |
|
924 | + elseif ($config_var['type'] == 'permissions') { |
|
925 | + theme_inline_permissions($config_var['name']); |
|
926 | + } |
|
895 | 927 | // BBC selection? |
896 | 928 | elseif ($config_var['type'] == 'bbc') |
897 | 929 | { |
@@ -902,20 +934,22 @@ discard block |
||
902 | 934 | |
903 | 935 | foreach ($context['bbc_columns'] as $bbcColumn) |
904 | 936 | { |
905 | - foreach ($bbcColumn as $bbcTag) |
|
906 | - echo ' |
|
937 | + foreach ($bbcColumn as $bbcTag) { |
|
938 | + echo ' |
|
907 | 939 | <li class="list_bbc floatleft"> |
908 | 940 | <input type="checkbox" name="', $config_var['name'], '_enabledTags[]" id="tag_', $config_var['name'], '_', $bbcTag['tag'], '" value="', $bbcTag['tag'], '"', !in_array($bbcTag['tag'], $context['bbc_sections'][$config_var['name']]['disabled']) ? ' checked' : '', ' class="input_check"> <label for="tag_', $config_var['name'], '_', $bbcTag['tag'], '">', $bbcTag['tag'], '</label>', $bbcTag['show_help'] ? ' (<a href="' . $scripturl . '?action=helpadmin;help=tag_' . $bbcTag['tag'] . '" onclick="return reqOverlayDiv(this.href);">?</a>)' : '', ' |
909 | 941 | </li>'; |
942 | + } |
|
910 | 943 | } |
911 | 944 | echo ' </ul> |
912 | 945 | <input type="checkbox" id="bbc_', $config_var['name'], '_select_all" onclick="invertAll(this, this.form, \'', $config_var['name'], '_enabledTags\');"', $context['bbc_sections'][$config_var['name']]['all_selected'] ? ' checked' : '', ' class="input_check"> <label for="bbc_', $config_var['name'], '_select_all"><em>', $txt['bbcTagsToUse_select_all'], '</em></label> |
913 | 946 | </fieldset>'; |
914 | 947 | } |
915 | 948 | // A simple message? |
916 | - elseif ($config_var['type'] == 'var_message') |
|
917 | - echo ' |
|
949 | + elseif ($config_var['type'] == 'var_message') { |
|
950 | + echo ' |
|
918 | 951 | <div', !empty($config_var['name']) ? ' id="' . $config_var['name'] . '"' : '', '>', $config_var['var_message'], '</div>'; |
952 | + } |
|
919 | 953 | // Assume it must be a text box |
920 | 954 | else |
921 | 955 | { |
@@ -940,63 +974,70 @@ discard block |
||
940 | 974 | ' . $config_var['postinput'] : '', |
941 | 975 | '</dd>'; |
942 | 976 | } |
943 | - } |
|
944 | - |
|
945 | - else |
|
977 | + } else |
|
946 | 978 | { |
947 | 979 | // Just show a separator. |
948 | - if ($config_var == '') |
|
949 | - echo ' |
|
980 | + if ($config_var == '') { |
|
981 | + echo ' |
|
950 | 982 | </dl> |
951 | 983 | <hr> |
952 | 984 | <dl class="settings">'; |
953 | - else |
|
954 | - echo ' |
|
985 | + } else { |
|
986 | + echo ' |
|
955 | 987 | <dd> |
956 | 988 | <strong>' . $config_var . '</strong> |
957 | 989 | </dd>'; |
990 | + } |
|
958 | 991 | } |
959 | 992 | } |
960 | 993 | |
961 | - if ($is_open) |
|
962 | - echo ' |
|
994 | + if ($is_open) { |
|
995 | + echo ' |
|
963 | 996 | </dl>'; |
997 | + } |
|
964 | 998 | |
965 | - if (empty($context['settings_save_dont_show'])) |
|
966 | - echo ' |
|
999 | + if (empty($context['settings_save_dont_show'])) { |
|
1000 | + echo ' |
|
967 | 1001 | <input type="submit" value="', $txt['save'], '"', (!empty($context['save_disabled']) ? ' disabled' : ''), (!empty($context['settings_save_onclick']) ? ' onclick="' . $context['settings_save_onclick'] . '"' : ''), ' class="button_submit">'; |
1002 | + } |
|
968 | 1003 | |
969 | - if ($is_open) |
|
970 | - echo ' |
|
1004 | + if ($is_open) { |
|
1005 | + echo ' |
|
971 | 1006 | </div>'; |
1007 | + } |
|
972 | 1008 | |
973 | 1009 | |
974 | 1010 | // At least one token has to be used! |
975 | - if (isset($context['admin-ssc_token'])) |
|
976 | - echo ' |
|
1011 | + if (isset($context['admin-ssc_token'])) { |
|
1012 | + echo ' |
|
977 | 1013 | <input type="hidden" name="', $context['admin-ssc_token_var'], '" value="', $context['admin-ssc_token'], '">'; |
1014 | + } |
|
978 | 1015 | |
979 | - if (isset($context['admin-dbsc_token'])) |
|
980 | - echo ' |
|
1016 | + if (isset($context['admin-dbsc_token'])) { |
|
1017 | + echo ' |
|
981 | 1018 | <input type="hidden" name="', $context['admin-dbsc_token_var'], '" value="', $context['admin-dbsc_token'], '">'; |
1019 | + } |
|
982 | 1020 | |
983 | - if (isset($context['admin-mp_token'])) |
|
984 | - echo ' |
|
1021 | + if (isset($context['admin-mp_token'])) { |
|
1022 | + echo ' |
|
985 | 1023 | <input type="hidden" name="', $context['admin-mp_token_var'], '" value="', $context['admin-mp_token'], '">'; |
1024 | + } |
|
986 | 1025 | |
987 | 1026 | echo ' |
988 | 1027 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
989 | 1028 | </form> |
990 | 1029 | </div>'; |
991 | 1030 | |
992 | - if (!empty($context['settings_post_javascript'])) |
|
993 | - echo ' |
|
1031 | + if (!empty($context['settings_post_javascript'])) { |
|
1032 | + echo ' |
|
994 | 1033 | <script> |
995 | 1034 | ', $context['settings_post_javascript'], ' |
996 | 1035 | </script>'; |
1036 | + } |
|
997 | 1037 | |
998 | - if (!empty($context['settings_insert_below'])) |
|
999 | - echo $context['settings_insert_below']; |
|
1038 | + if (!empty($context['settings_insert_below'])) { |
|
1039 | + echo $context['settings_insert_below']; |
|
1040 | + } |
|
1000 | 1041 | |
1001 | 1042 | // We may have added a board listing. If we did, we need to make it work. |
1002 | 1043 | addInlineJavascript(' |
@@ -1019,9 +1060,10 @@ discard block |
||
1019 | 1060 | { |
1020 | 1061 | global $context, $txt; |
1021 | 1062 | |
1022 | - if (!empty($context['saved_successful'])) |
|
1023 | - echo ' |
|
1063 | + if (!empty($context['saved_successful'])) { |
|
1064 | + echo ' |
|
1024 | 1065 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
1066 | + } |
|
1025 | 1067 | |
1026 | 1068 | // Standard fields. |
1027 | 1069 | template_show_list('standard_profile_fields'); |
@@ -1053,11 +1095,12 @@ discard block |
||
1053 | 1095 | if (isset($_GET['msg'])) |
1054 | 1096 | { |
1055 | 1097 | loadLanguage('Errors'); |
1056 | - if (isset($txt['custom_option_' . $_GET['msg']])) |
|
1057 | - echo ' |
|
1098 | + if (isset($txt['custom_option_' . $_GET['msg']])) { |
|
1099 | + echo ' |
|
1058 | 1100 | <div class="errorbox">', |
1059 | 1101 | $txt['custom_option_' . $_GET['msg']], ' |
1060 | 1102 | </div>'; |
1103 | + } |
|
1061 | 1104 | } |
1062 | 1105 | |
1063 | 1106 | echo ' |
@@ -1123,9 +1166,10 @@ discard block |
||
1123 | 1166 | <dd> |
1124 | 1167 | <select name="placement" id="placement">'; |
1125 | 1168 | |
1126 | - foreach ($context['cust_profile_fields_placement'] as $order => $name) |
|
1127 | - echo ' |
|
1169 | + foreach ($context['cust_profile_fields_placement'] as $order => $name) { |
|
1170 | + echo ' |
|
1128 | 1171 | <option value="', $order, '"', $context['field']['placement'] == $order ? ' selected' : '', '>', $txt['custom_profile_placement_' . $name], '</option>'; |
1172 | + } |
|
1129 | 1173 | |
1130 | 1174 | echo ' |
1131 | 1175 | </select> |
@@ -1148,9 +1192,10 @@ discard block |
||
1148 | 1192 | </dt> |
1149 | 1193 | <dd> |
1150 | 1194 | <select name="field_type" id="field_type" onchange="updateInputBoxes();">'; |
1151 | - foreach (array('text', 'textarea', 'select', 'radio', 'check') as $field_type) |
|
1152 | - echo ' |
|
1195 | + foreach (array('text', 'textarea', 'select', 'radio', 'check') as $field_type) { |
|
1196 | + echo ' |
|
1153 | 1197 | <option value="', $field_type, '"', $context['field']['type'] == $field_type ? ' selected' : '', '>', $txt['custom_profile_type_' . $field_type], '</option>'; |
1198 | + } |
|
1154 | 1199 | |
1155 | 1200 | echo ' |
1156 | 1201 | </select> |
@@ -1251,9 +1296,10 @@ discard block |
||
1251 | 1296 | </fieldset> |
1252 | 1297 | <input type="submit" name="save" value="', $txt['save'], '" class="button_submit">'; |
1253 | 1298 | |
1254 | - if ($context['fid']) |
|
1255 | - echo ' |
|
1299 | + if ($context['fid']) { |
|
1300 | + echo ' |
|
1256 | 1301 | <input type="submit" name="delete" value="', $txt['delete'], '" data-confirm="', $txt['custom_edit_delete_sure'], '" class="button_submit you_sure">'; |
1302 | + } |
|
1257 | 1303 | |
1258 | 1304 | echo ' |
1259 | 1305 | </div> |
@@ -1296,8 +1342,7 @@ discard block |
||
1296 | 1342 | { |
1297 | 1343 | echo ' |
1298 | 1344 | <p class="centertext"><strong>', $txt['admin_search_results_none'], '</strong></p>'; |
1299 | - } |
|
1300 | - else |
|
1345 | + } else |
|
1301 | 1346 | { |
1302 | 1347 | echo ' |
1303 | 1348 | <ol class="search_results">'; |
@@ -1323,9 +1368,10 @@ discard block |
||
1323 | 1368 | <li> |
1324 | 1369 | <a href="', $result['url'], '"><strong>', $result['name'], '</strong></a> [', isset($txt['admin_search_section_' . $result['type']]) ? $txt['admin_search_section_' . $result['type']] : $result['type'], ']'; |
1325 | 1370 | |
1326 | - if ($result['help']) |
|
1327 | - echo ' |
|
1371 | + if ($result['help']) { |
|
1372 | + echo ' |
|
1328 | 1373 | <p class="double_height">', $result['help'], '</p>'; |
1374 | + } |
|
1329 | 1375 | |
1330 | 1376 | echo ' |
1331 | 1377 | </li>'; |
@@ -1365,18 +1411,20 @@ discard block |
||
1365 | 1411 | <strong>', $txt['setup_verification_answer'], '</strong> |
1366 | 1412 | </dd>'; |
1367 | 1413 | |
1368 | - if (!empty($context['qa_by_lang'][$lang_id])) |
|
1369 | - foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
1414 | + if (!empty($context['qa_by_lang'][$lang_id])) { |
|
1415 | + foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
1370 | 1416 | { |
1371 | 1417 | $question = $context['question_answers'][$q_id]; |
1418 | + } |
|
1372 | 1419 | echo ' |
1373 | 1420 | <dt> |
1374 | 1421 | <input type="text" name="question[', $lang_id, '][', $q_id, ']" value="', $question['question'], '" size="50" class="input_text verification_question"> |
1375 | 1422 | </dt> |
1376 | 1423 | <dd>'; |
1377 | - foreach ($question['answers'] as $answer) |
|
1378 | - echo ' |
|
1424 | + foreach ($question['answers'] as $answer) { |
|
1425 | + echo ' |
|
1379 | 1426 | <input type="text" name="answer[', $lang_id, '][', $q_id, '][]" value="', $answer, '" size="50" class="input_text verification_answer">'; |
1427 | + } |
|
1380 | 1428 | |
1381 | 1429 | echo ' |
1382 | 1430 | <div class="qa_add_answer"><a href="javascript:void(0);" onclick="return addAnswer(this);">[ ', $txt['setup_verification_add_answer'], ' ]</a></div> |
@@ -1415,11 +1463,12 @@ discard block |
||
1415 | 1463 | ', $txt['errors_found'], ': |
1416 | 1464 | <ul>'; |
1417 | 1465 | |
1418 | - foreach ($context['repair_errors'] as $error) |
|
1419 | - echo ' |
|
1466 | + foreach ($context['repair_errors'] as $error) { |
|
1467 | + echo ' |
|
1420 | 1468 | <li> |
1421 | 1469 | ', $error, ' |
1422 | 1470 | </li>'; |
1471 | + } |
|
1423 | 1472 | |
1424 | 1473 | echo ' |
1425 | 1474 | </ul> |
@@ -1429,16 +1478,15 @@ discard block |
||
1429 | 1478 | <p class="padding"> |
1430 | 1479 | <strong><a href="', $scripturl, '?action=admin;area=repairboards;fixErrors;', $context['session_var'], '=', $context['session_id'], '">', $txt['yes'], '</a> - <a href="', $scripturl, '?action=admin;area=maintain">', $txt['no'], '</a></strong> |
1431 | 1480 | </p>'; |
1432 | - } |
|
1433 | - else |
|
1434 | - echo ' |
|
1481 | + } else { |
|
1482 | + echo ' |
|
1435 | 1483 | <p>', $txt['maintain_no_errors'], '</p> |
1436 | 1484 | <p class="padding"> |
1437 | 1485 | <a href="', $scripturl, '?action=admin;area=maintain;sa=routine">', $txt['maintain_return'], '</a> |
1438 | 1486 | </p>'; |
1487 | + } |
|
1439 | 1488 | |
1440 | - } |
|
1441 | - else |
|
1489 | + } else |
|
1442 | 1490 | { |
1443 | 1491 | if (!empty($context['redirect_to_recount'])) |
1444 | 1492 | { |
@@ -1450,8 +1498,7 @@ discard block |
||
1450 | 1498 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
1451 | 1499 | <input type="submit" name="recount" id="recount_now" value="', $txt['errors_recount_now'], '"> |
1452 | 1500 | </form>'; |
1453 | - } |
|
1454 | - else |
|
1501 | + } else |
|
1455 | 1502 | { |
1456 | 1503 | echo ' |
1457 | 1504 | <p>', $txt['errors_fixed'], '</p> |
@@ -1603,8 +1650,8 @@ discard block |
||
1603 | 1650 | function template_admin_quick_search() |
1604 | 1651 | { |
1605 | 1652 | global $context, $txt; |
1606 | - if ($context['user']['is_admin']) |
|
1607 | - echo ' |
|
1653 | + if ($context['user']['is_admin']) { |
|
1654 | + echo ' |
|
1608 | 1655 | <span class="floatright admin_search"> |
1609 | 1656 | <span class="generic_icons filter centericon"></span> |
1610 | 1657 | <input type="search" name="search_term" value="', $txt['admin_search'], '" onclick="if (this.value == \'', $txt['admin_search'], '\') this.value = \'\';" class="input_text"> |
@@ -1615,6 +1662,7 @@ discard block |
||
1615 | 1662 | </select> |
1616 | 1663 | <input type="submit" name="search_go" id="search_go" value="', $txt['admin_search_go'], '" class="button_submit"> |
1617 | 1664 | </span>'; |
1618 | -} |
|
1665 | + } |
|
1666 | + } |
|
1619 | 1667 | |
1620 | 1668 | ?> |
1621 | 1669 | \ No newline at end of file |
@@ -16,8 +16,9 @@ discard block |
||
16 | 16 | * @version 2.1 Beta 3 |
17 | 17 | */ |
18 | 18 | |
19 | -if (!defined('SMF')) |
|
19 | +if (!defined('SMF')) { |
|
20 | 20 | die('No direct access...'); |
21 | +} |
|
21 | 22 | |
22 | 23 | /** |
23 | 24 | * Reads a .tar.gz file, filename, in and extracts file(s) from it. |
@@ -67,47 +68,53 @@ discard block |
||
67 | 68 | loadLanguage('Packages'); |
68 | 69 | |
69 | 70 | // This function sorta needs gzinflate! |
70 | - if (!function_exists('gzinflate')) |
|
71 | - fatal_lang_error('package_no_zlib', 'critical'); |
|
71 | + if (!function_exists('gzinflate')) { |
|
72 | + fatal_lang_error('package_no_zlib', 'critical'); |
|
73 | + } |
|
72 | 74 | |
73 | 75 | if (substr($gzfilename, 0, 7) == 'http://' || substr($gzfilename, 0, 8) == 'https://') |
74 | 76 | { |
75 | 77 | $data = fetch_web_data($gzfilename); |
76 | 78 | |
77 | - if ($data === false) |
|
78 | - return false; |
|
79 | - } |
|
80 | - else |
|
79 | + if ($data === false) { |
|
80 | + return false; |
|
81 | + } |
|
82 | + } else |
|
81 | 83 | { |
82 | 84 | $data = @file_get_contents($gzfilename); |
83 | 85 | |
84 | - if ($data === false) |
|
85 | - return false; |
|
86 | + if ($data === false) { |
|
87 | + return false; |
|
88 | + } |
|
86 | 89 | } |
87 | 90 | |
88 | 91 | umask(0); |
89 | - if (!$single_file && $destination !== null && !file_exists($destination)) |
|
90 | - mktree($destination, 0777); |
|
92 | + if (!$single_file && $destination !== null && !file_exists($destination)) { |
|
93 | + mktree($destination, 0777); |
|
94 | + } |
|
91 | 95 | |
92 | 96 | // No signature? |
93 | - if (strlen($data) < 2) |
|
94 | - return false; |
|
97 | + if (strlen($data) < 2) { |
|
98 | + return false; |
|
99 | + } |
|
95 | 100 | |
96 | 101 | $id = unpack('H2a/H2b', substr($data, 0, 2)); |
97 | 102 | if (strtolower($id['a'] . $id['b']) != '1f8b') |
98 | 103 | { |
99 | 104 | // Okay, this ain't no tar.gz, but maybe it's a zip file. |
100 | - if (substr($data, 0, 2) == 'PK') |
|
101 | - return read_zip_file($gzfilename, $destination, $single_file, $overwrite, $files_to_extract); |
|
102 | - else |
|
103 | - return false; |
|
105 | + if (substr($data, 0, 2) == 'PK') { |
|
106 | + return read_zip_file($gzfilename, $destination, $single_file, $overwrite, $files_to_extract); |
|
107 | + } else { |
|
108 | + return false; |
|
109 | + } |
|
104 | 110 | } |
105 | 111 | |
106 | 112 | $flags = unpack('Ct/Cf', substr($data, 2, 2)); |
107 | 113 | |
108 | 114 | // Not deflate! |
109 | - if ($flags['t'] != 8) |
|
110 | - return false; |
|
115 | + if ($flags['t'] != 8) { |
|
116 | + return false; |
|
117 | + } |
|
111 | 118 | $flags = $flags['f']; |
112 | 119 | |
113 | 120 | $offset = 10; |
@@ -117,18 +124,21 @@ discard block |
||
117 | 124 | // @todo Might be mussed. |
118 | 125 | if ($flags & 12) |
119 | 126 | { |
120 | - while ($flags & 8 && $data{$offset++} != "\0") |
|
121 | - continue; |
|
122 | - while ($flags & 4 && $data{$offset++} != "\0") |
|
123 | - continue; |
|
127 | + while ($flags & 8 && $data{$offset++} != "\0") { |
|
128 | + continue; |
|
129 | + } |
|
130 | + while ($flags & 4 && $data{$offset++} != "\0") { |
|
131 | + continue; |
|
132 | + } |
|
124 | 133 | } |
125 | 134 | |
126 | 135 | $crc = unpack('Vcrc32/Visize', substr($data, strlen($data) - 8, 8)); |
127 | 136 | $data = @gzinflate(substr($data, $offset, strlen($data) - 8 - $offset)); |
128 | 137 | |
129 | 138 | // smf_crc32 and crc32 may not return the same results, so we accept either. |
130 | - if ($crc['crc32'] != smf_crc32($data) && $crc['crc32'] != crc32($data)) |
|
131 | - return false; |
|
139 | + if ($crc['crc32'] != smf_crc32($data) && $crc['crc32'] != crc32($data)) { |
|
140 | + return false; |
|
141 | + } |
|
132 | 142 | |
133 | 143 | $blocks = strlen($data) / 512 - 1; |
134 | 144 | $offset = 0; |
@@ -149,83 +159,98 @@ discard block |
||
149 | 159 | |
150 | 160 | foreach ($current as $k => $v) |
151 | 161 | { |
152 | - if (in_array($k, $octdec)) |
|
153 | - $current[$k] = octdec(trim($v)); |
|
154 | - else |
|
155 | - $current[$k] = trim($v); |
|
162 | + if (in_array($k, $octdec)) { |
|
163 | + $current[$k] = octdec(trim($v)); |
|
164 | + } else { |
|
165 | + $current[$k] = trim($v); |
|
166 | + } |
|
156 | 167 | } |
157 | 168 | |
158 | - if ($current['type'] == 5 && substr($current['filename'], -1) != '/') |
|
159 | - $current['filename'] .= '/'; |
|
169 | + if ($current['type'] == 5 && substr($current['filename'], -1) != '/') { |
|
170 | + $current['filename'] .= '/'; |
|
171 | + } |
|
160 | 172 | |
161 | 173 | $checksum = 256; |
162 | - for ($i = 0; $i < 148; $i++) |
|
163 | - $checksum += ord($header{$i}); |
|
164 | - for ($i = 156; $i < 512; $i++) |
|
165 | - $checksum += ord($header{$i}); |
|
174 | + for ($i = 0; $i < 148; $i++) { |
|
175 | + $checksum += ord($header{$i}); |
|
176 | + } |
|
177 | + for ($i = 156; $i < 512; $i++) { |
|
178 | + $checksum += ord($header{$i}); |
|
179 | + } |
|
166 | 180 | |
167 | - if ($current['checksum'] != $checksum) |
|
168 | - break; |
|
181 | + if ($current['checksum'] != $checksum) { |
|
182 | + break; |
|
183 | + } |
|
169 | 184 | |
170 | 185 | $size = ceil($current['size'] / 512); |
171 | 186 | $current['data'] = substr($data, ++$offset << 9, $current['size']); |
172 | 187 | $offset += $size; |
173 | 188 | |
174 | 189 | // Not a directory and doesn't exist already... |
175 | - if (substr($current['filename'], -1, 1) != '/' && !file_exists($destination . '/' . $current['filename'])) |
|
176 | - $write_this = true; |
|
190 | + if (substr($current['filename'], -1, 1) != '/' && !file_exists($destination . '/' . $current['filename'])) { |
|
191 | + $write_this = true; |
|
192 | + } |
|
177 | 193 | // File exists... check if it is newer. |
178 | - elseif (substr($current['filename'], -1, 1) != '/') |
|
179 | - $write_this = $overwrite || filemtime($destination . '/' . $current['filename']) < $current['mtime']; |
|
194 | + elseif (substr($current['filename'], -1, 1) != '/') { |
|
195 | + $write_this = $overwrite || filemtime($destination . '/' . $current['filename']) < $current['mtime']; |
|
196 | + } |
|
180 | 197 | // Folder... create. |
181 | 198 | elseif ($destination !== null && !$single_file) |
182 | 199 | { |
183 | 200 | // Protect from accidental parent directory writing... |
184 | 201 | $current['filename'] = strtr($current['filename'], array('../' => '', '/..' => '')); |
185 | 202 | |
186 | - if (!file_exists($destination . '/' . $current['filename'])) |
|
187 | - mktree($destination . '/' . $current['filename'], 0777); |
|
203 | + if (!file_exists($destination . '/' . $current['filename'])) { |
|
204 | + mktree($destination . '/' . $current['filename'], 0777); |
|
205 | + } |
|
188 | 206 | $write_this = false; |
207 | + } else { |
|
208 | + $write_this = false; |
|
189 | 209 | } |
190 | - else |
|
191 | - $write_this = false; |
|
192 | 210 | |
193 | 211 | if ($write_this && $destination !== null) |
194 | 212 | { |
195 | - if (strpos($current['filename'], '/') !== false && !$single_file) |
|
196 | - mktree($destination . '/' . dirname($current['filename']), 0777); |
|
213 | + if (strpos($current['filename'], '/') !== false && !$single_file) { |
|
214 | + mktree($destination . '/' . dirname($current['filename']), 0777); |
|
215 | + } |
|
197 | 216 | |
198 | 217 | // Is this the file we're looking for? |
199 | - if ($single_file && ($destination == $current['filename'] || $destination == '*/' . basename($current['filename']))) |
|
200 | - return $current['data']; |
|
218 | + if ($single_file && ($destination == $current['filename'] || $destination == '*/' . basename($current['filename']))) { |
|
219 | + return $current['data']; |
|
220 | + } |
|
201 | 221 | // If we're looking for another file, keep going. |
202 | - elseif ($single_file) |
|
203 | - continue; |
|
222 | + elseif ($single_file) { |
|
223 | + continue; |
|
224 | + } |
|
204 | 225 | // Looking for restricted files? |
205 | - elseif ($files_to_extract !== null && !in_array($current['filename'], $files_to_extract)) |
|
206 | - continue; |
|
226 | + elseif ($files_to_extract !== null && !in_array($current['filename'], $files_to_extract)) { |
|
227 | + continue; |
|
228 | + } |
|
207 | 229 | |
208 | 230 | package_put_contents($destination . '/' . $current['filename'], $current['data']); |
209 | 231 | } |
210 | 232 | |
211 | - if (substr($current['filename'], -1, 1) != '/') |
|
212 | - $return[] = array( |
|
233 | + if (substr($current['filename'], -1, 1) != '/') { |
|
234 | + $return[] = array( |
|
213 | 235 | 'filename' => $current['filename'], |
214 | 236 | 'md5' => md5($current['data']), |
215 | 237 | 'preview' => substr($current['data'], 0, 100), |
216 | 238 | 'size' => $current['size'], |
217 | 239 | 'skipped' => false |
218 | 240 | ); |
241 | + } |
|
219 | 242 | } |
220 | 243 | |
221 | - if ($destination !== null && !$single_file) |
|
222 | - package_flush_cache(); |
|
244 | + if ($destination !== null && !$single_file) { |
|
245 | + package_flush_cache(); |
|
246 | + } |
|
223 | 247 | |
224 | - if ($single_file) |
|
225 | - return false; |
|
226 | - else |
|
227 | - return $return; |
|
228 | -} |
|
248 | + if ($single_file) { |
|
249 | + return false; |
|
250 | + } else { |
|
251 | + return $return; |
|
252 | + } |
|
253 | + } |
|
229 | 254 | |
230 | 255 | /** |
231 | 256 | * Extract zip data. A functional copy of {@list read_zip_data()}. |
@@ -254,65 +279,74 @@ discard block |
||
254 | 279 | { |
255 | 280 | $i = $iterator->getSubPathname(); |
256 | 281 | // If this is a file, and it doesn't exist.... happy days! |
257 | - if (substr($i, -1) != '/' && !file_exists($destination . '/' . $i)) |
|
258 | - $write_this = true; |
|
282 | + if (substr($i, -1) != '/' && !file_exists($destination . '/' . $i)) { |
|
283 | + $write_this = true; |
|
284 | + } |
|
259 | 285 | // If the file exists, we may not want to overwrite it. |
260 | - elseif (substr($i, -1) != '/') |
|
261 | - $write_this = $overwrite; |
|
262 | - else |
|
263 | - $write_this = false; |
|
286 | + elseif (substr($i, -1) != '/') { |
|
287 | + $write_this = $overwrite; |
|
288 | + } else { |
|
289 | + $write_this = false; |
|
290 | + } |
|
264 | 291 | |
265 | 292 | // Get the actual compressed data. |
266 | - if (!$file_info->isDir()) |
|
267 | - $file_data = file_get_contents($file_info); |
|
268 | - elseif ($destination !== null && !$single_file) |
|
293 | + if (!$file_info->isDir()) { |
|
294 | + $file_data = file_get_contents($file_info); |
|
295 | + } elseif ($destination !== null && !$single_file) |
|
269 | 296 | { |
270 | 297 | // Folder... create. |
271 | - if (!file_exists($destination . '/' . $i)) |
|
272 | - mktree($destination . '/' . $i, 0777); |
|
298 | + if (!file_exists($destination . '/' . $i)) { |
|
299 | + mktree($destination . '/' . $i, 0777); |
|
300 | + } |
|
273 | 301 | $file_data = null; |
302 | + } else { |
|
303 | + $file_data = null; |
|
274 | 304 | } |
275 | - else |
|
276 | - $file_data = null; |
|
277 | 305 | |
278 | 306 | // Okay! We can write this file, looks good from here... |
279 | 307 | if ($write_this && $destination !== null) |
280 | 308 | { |
281 | - if (!$single_file && !is_dir($destination . '/' . dirname($i))) |
|
282 | - mktree($destination . '/' . dirname($i), 0777); |
|
309 | + if (!$single_file && !is_dir($destination . '/' . dirname($i))) { |
|
310 | + mktree($destination . '/' . dirname($i), 0777); |
|
311 | + } |
|
283 | 312 | |
284 | 313 | // If we're looking for a specific file, and this is it... ka-bam, baby. |
285 | - if ($single_file && ($destination == $i || $destination == '*/' . basename($i))) |
|
286 | - return $file_data; |
|
314 | + if ($single_file && ($destination == $i || $destination == '*/' . basename($i))) { |
|
315 | + return $file_data; |
|
316 | + } |
|
287 | 317 | // Oh? Another file. Fine. You don't like this file, do you? I know how it is. Yeah... just go away. No, don't apologize. I know this file's just not *good enough* for you. |
288 | - elseif ($single_file) |
|
289 | - continue; |
|
318 | + elseif ($single_file) { |
|
319 | + continue; |
|
320 | + } |
|
290 | 321 | // Don't really want this? |
291 | - elseif ($files_to_extract !== null && !in_array($i, $files_to_extract)) |
|
292 | - continue; |
|
322 | + elseif ($files_to_extract !== null && !in_array($i, $files_to_extract)) { |
|
323 | + continue; |
|
324 | + } |
|
293 | 325 | |
294 | 326 | package_put_contents($destination . '/' . $i, $file_data); |
295 | 327 | } |
296 | 328 | |
297 | - if (substr($i, -1, 1) != '/') |
|
298 | - $return[] = array( |
|
329 | + if (substr($i, -1, 1) != '/') { |
|
330 | + $return[] = array( |
|
299 | 331 | 'filename' => $i, |
300 | 332 | 'md5' => md5($file_data), |
301 | 333 | 'preview' => substr($file_data, 0, 100), |
302 | 334 | 'size' => strlen($file_data), |
303 | 335 | 'skipped' => false |
304 | 336 | ); |
337 | + } |
|
305 | 338 | } |
306 | 339 | |
307 | - if ($destination !== null && !$single_file) |
|
308 | - package_flush_cache(); |
|
340 | + if ($destination !== null && !$single_file) { |
|
341 | + package_flush_cache(); |
|
342 | + } |
|
309 | 343 | |
310 | - if ($single_file) |
|
311 | - return false; |
|
312 | - else |
|
313 | - return $return; |
|
314 | - } |
|
315 | - catch (Exception $e) |
|
344 | + if ($single_file) { |
|
345 | + return false; |
|
346 | + } else { |
|
347 | + return $return; |
|
348 | + } |
|
349 | + } catch (Exception $e) |
|
316 | 350 | { |
317 | 351 | return false; |
318 | 352 | } |
@@ -334,13 +368,15 @@ discard block |
||
334 | 368 | function read_zip_data($data, $destination, $single_file = false, $overwrite = false, $files_to_extract = null) |
335 | 369 | { |
336 | 370 | umask(0); |
337 | - if ($destination !== null && !file_exists($destination) && !$single_file) |
|
338 | - mktree($destination, 0777); |
|
371 | + if ($destination !== null && !file_exists($destination) && !$single_file) { |
|
372 | + mktree($destination, 0777); |
|
373 | + } |
|
339 | 374 | |
340 | 375 | // Look for the end of directory signature 0x06054b50 |
341 | 376 | $data_ecr = explode("\x50\x4b\x05\x06", $data); |
342 | - if (!isset($data_ecr[1])) |
|
343 | - return false; |
|
377 | + if (!isset($data_ecr[1])) { |
|
378 | + return false; |
|
379 | + } |
|
344 | 380 | |
345 | 381 | $return = array(); |
346 | 382 | |
@@ -355,8 +391,9 @@ discard block |
||
355 | 391 | array_shift($file_sections); |
356 | 392 | |
357 | 393 | // sections and count from the signature must match or the zip file is bad |
358 | - if (count($file_sections) != $zip_info['files']) |
|
359 | - return false; |
|
394 | + if (count($file_sections) != $zip_info['files']) { |
|
395 | + return false; |
|
396 | + } |
|
360 | 397 | |
361 | 398 | // go though each file in the archive |
362 | 399 | foreach ($file_sections as $data) |
@@ -378,68 +415,79 @@ discard block |
||
378 | 415 | } |
379 | 416 | |
380 | 417 | // If this is a file, and it doesn't exist.... happy days! |
381 | - if (substr($file_info['filename'], -1) != '/' && !file_exists($destination . '/' . $file_info['filename'])) |
|
382 | - $write_this = true; |
|
418 | + if (substr($file_info['filename'], -1) != '/' && !file_exists($destination . '/' . $file_info['filename'])) { |
|
419 | + $write_this = true; |
|
420 | + } |
|
383 | 421 | // If the file exists, we may not want to overwrite it. |
384 | - elseif (substr($file_info['filename'], -1) != '/') |
|
385 | - $write_this = $overwrite; |
|
422 | + elseif (substr($file_info['filename'], -1) != '/') { |
|
423 | + $write_this = $overwrite; |
|
424 | + } |
|
386 | 425 | // This is a directory, so we're gonna want to create it. (probably...) |
387 | 426 | elseif ($destination !== null && !$single_file) |
388 | 427 | { |
389 | 428 | // Just a little accident prevention, don't mind me. |
390 | 429 | $file_info['filename'] = strtr($file_info['filename'], array('../' => '', '/..' => '')); |
391 | 430 | |
392 | - if (!file_exists($destination . '/' . $file_info['filename'])) |
|
393 | - mktree($destination . '/' . $file_info['filename'], 0777); |
|
431 | + if (!file_exists($destination . '/' . $file_info['filename'])) { |
|
432 | + mktree($destination . '/' . $file_info['filename'], 0777); |
|
433 | + } |
|
394 | 434 | $write_this = false; |
435 | + } else { |
|
436 | + $write_this = false; |
|
395 | 437 | } |
396 | - else |
|
397 | - $write_this = false; |
|
398 | 438 | |
399 | 439 | // Get the actual compressed data. |
400 | 440 | $file_info['data'] = substr($data, 26 + $file_info['filename_length'] + $file_info['extrafield_length']); |
401 | 441 | |
402 | 442 | // Only inflate it if we need to ;) |
403 | - if (!empty($file_info['compress_method']) || ($file_info['compressed_size'] != $file_info['size'])) |
|
404 | - $file_info['data'] = gzinflate($file_info['data']); |
|
443 | + if (!empty($file_info['compress_method']) || ($file_info['compressed_size'] != $file_info['size'])) { |
|
444 | + $file_info['data'] = gzinflate($file_info['data']); |
|
445 | + } |
|
405 | 446 | |
406 | 447 | // Okay! We can write this file, looks good from here... |
407 | 448 | if ($write_this && $destination !== null) |
408 | 449 | { |
409 | - if ((strpos($file_info['filename'], '/') !== false && !$single_file) || (!$single_file && !is_dir($file_info['dir']))) |
|
410 | - mktree($file_info['dir'], 0777); |
|
450 | + if ((strpos($file_info['filename'], '/') !== false && !$single_file) || (!$single_file && !is_dir($file_info['dir']))) { |
|
451 | + mktree($file_info['dir'], 0777); |
|
452 | + } |
|
411 | 453 | |
412 | 454 | // If we're looking for a specific file, and this is it... ka-bam, baby. |
413 | - if ($single_file && ($destination == $file_info['filename'] || $destination == '*/' . basename($file_info['filename']))) |
|
414 | - return $file_info['data']; |
|
455 | + if ($single_file && ($destination == $file_info['filename'] || $destination == '*/' . basename($file_info['filename']))) { |
|
456 | + return $file_info['data']; |
|
457 | + } |
|
415 | 458 | // Oh? Another file. Fine. You don't like this file, do you? I know how it is. Yeah... just go away. No, don't apologize. I know this file's just not *good enough* for you. |
416 | - elseif ($single_file) |
|
417 | - continue; |
|
459 | + elseif ($single_file) { |
|
460 | + continue; |
|
461 | + } |
|
418 | 462 | // Don't really want this? |
419 | - elseif ($files_to_extract !== null && !in_array($file_info['filename'], $files_to_extract)) |
|
420 | - continue; |
|
463 | + elseif ($files_to_extract !== null && !in_array($file_info['filename'], $files_to_extract)) { |
|
464 | + continue; |
|
465 | + } |
|
421 | 466 | |
422 | 467 | package_put_contents($destination . '/' . $file_info['filename'], $file_info['data']); |
423 | 468 | } |
424 | 469 | |
425 | - if (substr($file_info['filename'], -1, 1) != '/') |
|
426 | - $return[] = array( |
|
470 | + if (substr($file_info['filename'], -1, 1) != '/') { |
|
471 | + $return[] = array( |
|
427 | 472 | 'filename' => $file_info['filename'], |
428 | 473 | 'md5' => md5($file_info['data']), |
429 | 474 | 'preview' => substr($file_info['data'], 0, 100), |
430 | 475 | 'size' => $file_info['size'], |
431 | 476 | 'skipped' => false |
432 | 477 | ); |
478 | + } |
|
433 | 479 | } |
434 | 480 | |
435 | - if ($destination !== null && !$single_file) |
|
436 | - package_flush_cache(); |
|
481 | + if ($destination !== null && !$single_file) { |
|
482 | + package_flush_cache(); |
|
483 | + } |
|
437 | 484 | |
438 | - if ($single_file) |
|
439 | - return false; |
|
440 | - else |
|
441 | - return $return; |
|
442 | -} |
|
485 | + if ($single_file) { |
|
486 | + return false; |
|
487 | + } else { |
|
488 | + return $return; |
|
489 | + } |
|
490 | + } |
|
443 | 491 | |
444 | 492 | /** |
445 | 493 | * Checks the existence of a remote file since file_exists() does not do remote. |
@@ -451,14 +499,16 @@ discard block |
||
451 | 499 | { |
452 | 500 | $a_url = parse_url($url); |
453 | 501 | |
454 | - if (!isset($a_url['scheme'])) |
|
455 | - return false; |
|
502 | + if (!isset($a_url['scheme'])) { |
|
503 | + return false; |
|
504 | + } |
|
456 | 505 | |
457 | 506 | // Attempt to connect... |
458 | 507 | $temp = ''; |
459 | 508 | $fid = fsockopen($a_url['host'], !isset($a_url['port']) ? 80 : $a_url['port'], $temp, $temp, 8); |
460 | - if (!$fid) |
|
461 | - return false; |
|
509 | + if (!$fid) { |
|
510 | + return false; |
|
511 | + } |
|
462 | 512 | |
463 | 513 | fputs($fid, 'HEAD ' . $a_url['path'] . ' HTTP/1.0' . "\r\n" . 'Host: ' . $a_url['host'] . "\r\n\r\n"); |
464 | 514 | $head = fread($fid, 1024); |
@@ -493,8 +543,9 @@ discard block |
||
493 | 543 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
494 | 544 | { |
495 | 545 | // Already found this? If so don't add it twice! |
496 | - if (in_array($row['package_id'], $found)) |
|
497 | - continue; |
|
546 | + if (in_array($row['package_id'], $found)) { |
|
547 | + continue; |
|
548 | + } |
|
498 | 549 | |
499 | 550 | $found[] = $row['package_id']; |
500 | 551 | |
@@ -529,19 +580,21 @@ discard block |
||
529 | 580 | global $sourcedir, $packagesdir; |
530 | 581 | |
531 | 582 | // Extract package-info.xml from downloaded file. (*/ is used because it could be in any directory.) |
532 | - if (strpos($gzfilename, 'http://') !== false || strpos($gzfilename, 'https://') !== false) |
|
533 | - $packageInfo = read_tgz_data($gzfilename, 'package-info.xml', true); |
|
534 | - else |
|
583 | + if (strpos($gzfilename, 'http://') !== false || strpos($gzfilename, 'https://') !== false) { |
|
584 | + $packageInfo = read_tgz_data($gzfilename, 'package-info.xml', true); |
|
585 | + } else |
|
535 | 586 | { |
536 | - if (!file_exists($packagesdir . '/' . $gzfilename)) |
|
537 | - return 'package_get_error_not_found'; |
|
587 | + if (!file_exists($packagesdir . '/' . $gzfilename)) { |
|
588 | + return 'package_get_error_not_found'; |
|
589 | + } |
|
538 | 590 | |
539 | - if (is_file($packagesdir . '/' . $gzfilename)) |
|
540 | - $packageInfo = read_tgz_file($packagesdir . '/' . $gzfilename, '*/package-info.xml', true); |
|
541 | - elseif (file_exists($packagesdir . '/' . $gzfilename . '/package-info.xml')) |
|
542 | - $packageInfo = file_get_contents($packagesdir . '/' . $gzfilename . '/package-info.xml'); |
|
543 | - else |
|
544 | - return 'package_get_error_missing_xml'; |
|
591 | + if (is_file($packagesdir . '/' . $gzfilename)) { |
|
592 | + $packageInfo = read_tgz_file($packagesdir . '/' . $gzfilename, '*/package-info.xml', true); |
|
593 | + } elseif (file_exists($packagesdir . '/' . $gzfilename . '/package-info.xml')) { |
|
594 | + $packageInfo = file_get_contents($packagesdir . '/' . $gzfilename . '/package-info.xml'); |
|
595 | + } else { |
|
596 | + return 'package_get_error_missing_xml'; |
|
597 | + } |
|
545 | 598 | } |
546 | 599 | |
547 | 600 | // Nothing? |
@@ -549,10 +602,11 @@ discard block |
||
549 | 602 | { |
550 | 603 | // Perhaps they are trying to install a theme, lets tell them nicely this is the wrong function |
551 | 604 | $packageInfo = read_tgz_file($packagesdir . '/' . $gzfilename, '*/theme_info.xml', true); |
552 | - if (!empty($packageInfo)) |
|
553 | - return 'package_get_error_is_theme'; |
|
554 | - else |
|
555 | - return 'package_get_error_is_zero'; |
|
605 | + if (!empty($packageInfo)) { |
|
606 | + return 'package_get_error_is_theme'; |
|
607 | + } else { |
|
608 | + return 'package_get_error_is_zero'; |
|
609 | + } |
|
556 | 610 | } |
557 | 611 | |
558 | 612 | // Parse package-info.xml into an xmlArray. |
@@ -560,8 +614,9 @@ discard block |
||
560 | 614 | $packageInfo = new xmlArray($packageInfo); |
561 | 615 | |
562 | 616 | // @todo Error message of some sort? |
563 | - if (!$packageInfo->exists('package-info[0]')) |
|
564 | - return 'package_get_error_packageinfo_corrupt'; |
|
617 | + if (!$packageInfo->exists('package-info[0]')) { |
|
618 | + return 'package_get_error_packageinfo_corrupt'; |
|
619 | + } |
|
565 | 620 | |
566 | 621 | $packageInfo = $packageInfo->path('package-info[0]'); |
567 | 622 | |
@@ -580,8 +635,9 @@ discard block |
||
580 | 635 | } |
581 | 636 | } |
582 | 637 | |
583 | - if (!isset($package['type'])) |
|
584 | - $package['type'] = 'modification'; |
|
638 | + if (!isset($package['type'])) { |
|
639 | + $package['type'] = 'modification'; |
|
640 | + } |
|
585 | 641 | |
586 | 642 | return $package; |
587 | 643 | } |
@@ -634,15 +690,14 @@ discard block |
||
634 | 690 | { |
635 | 691 | $ftp_file = strtr($file, array($_SESSION['pack_ftp']['root'] => '')); |
636 | 692 | $package_ftp->chmod($ftp_file, $perms); |
693 | + } else { |
|
694 | + smf_chmod($file, $perms); |
|
637 | 695 | } |
638 | - else |
|
639 | - smf_chmod($file, $perms); |
|
640 | 696 | |
641 | 697 | $new_permissions = @fileperms($file); |
642 | 698 | $result = $new_permissions == $perms ? 'success' : 'failure'; |
643 | 699 | unset($_SESSION['pack_ftp']['original_perms'][$file]); |
644 | - } |
|
645 | - elseif ($do_change) |
|
700 | + } elseif ($do_change) |
|
646 | 701 | { |
647 | 702 | $new_permissions = ''; |
648 | 703 | $result = 'skipped'; |
@@ -758,8 +813,7 @@ discard block |
||
758 | 813 | |
759 | 814 | $context['sub_template'] = 'show_list'; |
760 | 815 | $context['default_list'] = 'restore_file_permissions'; |
761 | - } |
|
762 | - else |
|
816 | + } else |
|
763 | 817 | { |
764 | 818 | unset($listOptions['columns']['result']); |
765 | 819 | } |
@@ -769,12 +823,14 @@ discard block |
||
769 | 823 | createList($listOptions); |
770 | 824 | |
771 | 825 | // If we just restored permissions then whereever we are, we are now done and dusted. |
772 | - if (!empty($_POST['restore_perms'])) |
|
773 | - obExit(); |
|
826 | + if (!empty($_POST['restore_perms'])) { |
|
827 | + obExit(); |
|
828 | + } |
|
774 | 829 | } |
775 | 830 | // Otherwise, it's entirely irrelevant? |
776 | - elseif ($restore_write_status) |
|
777 | - return true; |
|
831 | + elseif ($restore_write_status) { |
|
832 | + return true; |
|
833 | + } |
|
778 | 834 | |
779 | 835 | // This is where we report what we got up to. |
780 | 836 | $return_data = array( |
@@ -812,11 +868,12 @@ discard block |
||
812 | 868 | if (!in_array($_POST['ftp_path'], array('', '/'))) |
813 | 869 | { |
814 | 870 | $ftp_root = strtr($boarddir, array($_POST['ftp_path'] => '')); |
815 | - if (substr($ftp_root, -1) == '/' && ($_POST['ftp_path'] == '' || substr($_POST['ftp_path'], 0, 1) == '/')) |
|
816 | - $ftp_root = substr($ftp_root, 0, -1); |
|
871 | + if (substr($ftp_root, -1) == '/' && ($_POST['ftp_path'] == '' || substr($_POST['ftp_path'], 0, 1) == '/')) { |
|
872 | + $ftp_root = substr($ftp_root, 0, -1); |
|
873 | + } |
|
874 | + } else { |
|
875 | + $ftp_root = $boarddir; |
|
817 | 876 | } |
818 | - else |
|
819 | - $ftp_root = $boarddir; |
|
820 | 877 | |
821 | 878 | $_SESSION['pack_ftp'] = array( |
822 | 879 | 'server' => $_POST['ftp_server'], |
@@ -828,8 +885,9 @@ discard block |
||
828 | 885 | 'connected' => true, |
829 | 886 | ); |
830 | 887 | |
831 | - if (!isset($modSettings['package_path']) || $modSettings['package_path'] != $_POST['ftp_path']) |
|
832 | - updateSettings(array('package_path' => $_POST['ftp_path'])); |
|
888 | + if (!isset($modSettings['package_path']) || $modSettings['package_path'] != $_POST['ftp_path']) { |
|
889 | + updateSettings(array('package_path' => $_POST['ftp_path'])); |
|
890 | + } |
|
833 | 891 | |
834 | 892 | // This is now the primary connection. |
835 | 893 | $package_ftp = $ftp; |
@@ -842,12 +900,13 @@ discard block |
||
842 | 900 | foreach ($chmodFiles as $k => $file) |
843 | 901 | { |
844 | 902 | // Sometimes this can somehow happen maybe? |
845 | - if (empty($file)) |
|
846 | - unset($chmodFiles[$k]); |
|
903 | + if (empty($file)) { |
|
904 | + unset($chmodFiles[$k]); |
|
905 | + } |
|
847 | 906 | // Already writable? |
848 | - elseif (@is_writable($file)) |
|
849 | - $return_data['files']['writable'][] = $file; |
|
850 | - else |
|
907 | + elseif (@is_writable($file)) { |
|
908 | + $return_data['files']['writable'][] = $file; |
|
909 | + } else |
|
851 | 910 | { |
852 | 911 | // Now try to change that. |
853 | 912 | $return_data['files'][package_chmod($file, 'writable', true) ? 'writable' : 'notwritable'][] = $file; |
@@ -864,19 +923,21 @@ discard block |
||
864 | 923 | { |
865 | 924 | require_once($sourcedir . '/Class-Package.php'); |
866 | 925 | $ftp = new ftp_connection(null); |
926 | + } elseif ($ftp->error !== false && !isset($ftp_error)) { |
|
927 | + $ftp_error = $ftp->last_message === null ? '' : $ftp->last_message; |
|
867 | 928 | } |
868 | - elseif ($ftp->error !== false && !isset($ftp_error)) |
|
869 | - $ftp_error = $ftp->last_message === null ? '' : $ftp->last_message; |
|
870 | 929 | |
871 | 930 | list ($username, $detect_path, $found_path) = $ftp->detect_path($boarddir); |
872 | 931 | |
873 | - if ($found_path) |
|
874 | - $_POST['ftp_path'] = $detect_path; |
|
875 | - elseif (!isset($_POST['ftp_path'])) |
|
876 | - $_POST['ftp_path'] = isset($modSettings['package_path']) ? $modSettings['package_path'] : $detect_path; |
|
932 | + if ($found_path) { |
|
933 | + $_POST['ftp_path'] = $detect_path; |
|
934 | + } elseif (!isset($_POST['ftp_path'])) { |
|
935 | + $_POST['ftp_path'] = isset($modSettings['package_path']) ? $modSettings['package_path'] : $detect_path; |
|
936 | + } |
|
877 | 937 | |
878 | - if (!isset($_POST['ftp_username'])) |
|
879 | - $_POST['ftp_username'] = $username; |
|
938 | + if (!isset($_POST['ftp_username'])) { |
|
939 | + $_POST['ftp_username'] = $username; |
|
940 | + } |
|
880 | 941 | } |
881 | 942 | |
882 | 943 | $context['package_ftp'] = array( |
@@ -889,8 +950,9 @@ discard block |
||
889 | 950 | ); |
890 | 951 | |
891 | 952 | // Which files failed? |
892 | - if (!isset($context['notwritable_files'])) |
|
893 | - $context['notwritable_files'] = array(); |
|
953 | + if (!isset($context['notwritable_files'])) { |
|
954 | + $context['notwritable_files'] = array(); |
|
955 | + } |
|
894 | 956 | $context['notwritable_files'] = array_merge($context['notwritable_files'], $return_data['files']['notwritable']); |
895 | 957 | |
896 | 958 | // Sent here to die? |
@@ -923,40 +985,48 @@ discard block |
||
923 | 985 | foreach ($files as $k => $file) |
924 | 986 | { |
925 | 987 | // If this file doesn't exist, then we actually want to look at the directory, no? |
926 | - if (!file_exists($file)) |
|
927 | - $file = dirname($file); |
|
988 | + if (!file_exists($file)) { |
|
989 | + $file = dirname($file); |
|
990 | + } |
|
928 | 991 | |
929 | 992 | // This looks odd, but it's an attempt to work around PHP suExec. |
930 | - if (!@is_writable($file)) |
|
931 | - smf_chmod($file, 0755); |
|
932 | - if (!@is_writable($file)) |
|
933 | - smf_chmod($file, 0777); |
|
934 | - if (!@is_writable(dirname($file))) |
|
935 | - smf_chmod($file, 0755); |
|
936 | - if (!@is_writable(dirname($file))) |
|
937 | - smf_chmod($file, 0777); |
|
993 | + if (!@is_writable($file)) { |
|
994 | + smf_chmod($file, 0755); |
|
995 | + } |
|
996 | + if (!@is_writable($file)) { |
|
997 | + smf_chmod($file, 0777); |
|
998 | + } |
|
999 | + if (!@is_writable(dirname($file))) { |
|
1000 | + smf_chmod($file, 0755); |
|
1001 | + } |
|
1002 | + if (!@is_writable(dirname($file))) { |
|
1003 | + smf_chmod($file, 0777); |
|
1004 | + } |
|
938 | 1005 | |
939 | 1006 | $fp = is_dir($file) ? @opendir($file) : @fopen($file, 'rb'); |
940 | 1007 | if (@is_writable($file) && $fp) |
941 | 1008 | { |
942 | 1009 | unset($files[$k]); |
943 | - if (!is_dir($file)) |
|
944 | - fclose($fp); |
|
945 | - else |
|
946 | - closedir($fp); |
|
1010 | + if (!is_dir($file)) { |
|
1011 | + fclose($fp); |
|
1012 | + } else { |
|
1013 | + closedir($fp); |
|
1014 | + } |
|
947 | 1015 | } |
948 | 1016 | } |
949 | 1017 | |
950 | 1018 | // No FTP required! |
951 | - if (empty($files)) |
|
952 | - return array(); |
|
1019 | + if (empty($files)) { |
|
1020 | + return array(); |
|
1021 | + } |
|
953 | 1022 | } |
954 | 1023 | |
955 | 1024 | // They've opted to not use FTP, and try anyway. |
956 | 1025 | if (isset($_SESSION['pack_ftp']) && $_SESSION['pack_ftp'] == false) |
957 | 1026 | { |
958 | - if ($files === null) |
|
959 | - return array(); |
|
1027 | + if ($files === null) { |
|
1028 | + return array(); |
|
1029 | + } |
|
960 | 1030 | |
961 | 1031 | foreach ($files as $k => $file) |
962 | 1032 | { |
@@ -968,26 +1038,29 @@ discard block |
||
968 | 1038 | smf_chmod($file, 0755); |
969 | 1039 | } |
970 | 1040 | |
971 | - if (!@is_writable($file)) |
|
972 | - smf_chmod($file, 0777); |
|
973 | - if (!@is_writable(dirname($file))) |
|
974 | - smf_chmod(dirname($file), 0777); |
|
1041 | + if (!@is_writable($file)) { |
|
1042 | + smf_chmod($file, 0777); |
|
1043 | + } |
|
1044 | + if (!@is_writable(dirname($file))) { |
|
1045 | + smf_chmod(dirname($file), 0777); |
|
1046 | + } |
|
975 | 1047 | |
976 | - if (@is_writable($file)) |
|
977 | - unset($files[$k]); |
|
1048 | + if (@is_writable($file)) { |
|
1049 | + unset($files[$k]); |
|
1050 | + } |
|
978 | 1051 | } |
979 | 1052 | |
980 | 1053 | return $files; |
981 | - } |
|
982 | - elseif (isset($_SESSION['pack_ftp'])) |
|
1054 | + } elseif (isset($_SESSION['pack_ftp'])) |
|
983 | 1055 | { |
984 | 1056 | // Load the file containing the ftp_connection class. |
985 | 1057 | require_once($sourcedir . '/Class-Package.php'); |
986 | 1058 | |
987 | 1059 | $package_ftp = new ftp_connection($_SESSION['pack_ftp']['server'], $_SESSION['pack_ftp']['port'], $_SESSION['pack_ftp']['username'], package_crypt($_SESSION['pack_ftp']['password'])); |
988 | 1060 | |
989 | - if ($files === null) |
|
990 | - return array(); |
|
1061 | + if ($files === null) { |
|
1062 | + return array(); |
|
1063 | + } |
|
991 | 1064 | |
992 | 1065 | foreach ($files as $k => $file) |
993 | 1066 | { |
@@ -1001,13 +1074,16 @@ discard block |
||
1001 | 1074 | $package_ftp->chmod($ftp_file, 0755); |
1002 | 1075 | } |
1003 | 1076 | |
1004 | - if (!@is_writable($file)) |
|
1005 | - $package_ftp->chmod($ftp_file, 0777); |
|
1006 | - if (!@is_writable(dirname($file))) |
|
1007 | - $package_ftp->chmod(dirname($ftp_file), 0777); |
|
1077 | + if (!@is_writable($file)) { |
|
1078 | + $package_ftp->chmod($ftp_file, 0777); |
|
1079 | + } |
|
1080 | + if (!@is_writable(dirname($file))) { |
|
1081 | + $package_ftp->chmod(dirname($ftp_file), 0777); |
|
1082 | + } |
|
1008 | 1083 | |
1009 | - if (@is_writable($file)) |
|
1010 | - unset($files[$k]); |
|
1084 | + if (@is_writable($file)) { |
|
1085 | + unset($files[$k]); |
|
1086 | + } |
|
1011 | 1087 | } |
1012 | 1088 | |
1013 | 1089 | return $files; |
@@ -1019,8 +1095,7 @@ discard block |
||
1019 | 1095 | |
1020 | 1096 | $files = packageRequireFTP($destination_url, $files, $return); |
1021 | 1097 | return $files; |
1022 | - } |
|
1023 | - elseif (isset($_POST['ftp_username'])) |
|
1098 | + } elseif (isset($_POST['ftp_username'])) |
|
1024 | 1099 | { |
1025 | 1100 | require_once($sourcedir . '/Class-Package.php'); |
1026 | 1101 | $ftp = new ftp_connection($_POST['ftp_server'], $_POST['ftp_port'], $_POST['ftp_username'], $_POST['ftp_password']); |
@@ -1042,19 +1117,21 @@ discard block |
||
1042 | 1117 | { |
1043 | 1118 | require_once($sourcedir . '/Class-Package.php'); |
1044 | 1119 | $ftp = new ftp_connection(null); |
1120 | + } elseif ($ftp->error !== false && !isset($ftp_error)) { |
|
1121 | + $ftp_error = $ftp->last_message === null ? '' : $ftp->last_message; |
|
1045 | 1122 | } |
1046 | - elseif ($ftp->error !== false && !isset($ftp_error)) |
|
1047 | - $ftp_error = $ftp->last_message === null ? '' : $ftp->last_message; |
|
1048 | 1123 | |
1049 | 1124 | list ($username, $detect_path, $found_path) = $ftp->detect_path($boarddir); |
1050 | 1125 | |
1051 | - if ($found_path) |
|
1052 | - $_POST['ftp_path'] = $detect_path; |
|
1053 | - elseif (!isset($_POST['ftp_path'])) |
|
1054 | - $_POST['ftp_path'] = isset($modSettings['package_path']) ? $modSettings['package_path'] : $detect_path; |
|
1126 | + if ($found_path) { |
|
1127 | + $_POST['ftp_path'] = $detect_path; |
|
1128 | + } elseif (!isset($_POST['ftp_path'])) { |
|
1129 | + $_POST['ftp_path'] = isset($modSettings['package_path']) ? $modSettings['package_path'] : $detect_path; |
|
1130 | + } |
|
1055 | 1131 | |
1056 | - if (!isset($_POST['ftp_username'])) |
|
1057 | - $_POST['ftp_username'] = $username; |
|
1132 | + if (!isset($_POST['ftp_username'])) { |
|
1133 | + $_POST['ftp_username'] = $username; |
|
1134 | + } |
|
1058 | 1135 | |
1059 | 1136 | $context['package_ftp'] = array( |
1060 | 1137 | 'server' => isset($_POST['ftp_server']) ? $_POST['ftp_server'] : (isset($modSettings['package_server']) ? $modSettings['package_server'] : 'localhost'), |
@@ -1066,23 +1143,24 @@ discard block |
||
1066 | 1143 | ); |
1067 | 1144 | |
1068 | 1145 | // If we're returning dump out here. |
1069 | - if ($return) |
|
1070 | - return $files; |
|
1146 | + if ($return) { |
|
1147 | + return $files; |
|
1148 | + } |
|
1071 | 1149 | |
1072 | 1150 | $context['page_title'] = $txt['package_ftp_necessary']; |
1073 | 1151 | $context['sub_template'] = 'ftp_required'; |
1074 | 1152 | obExit(); |
1075 | - } |
|
1076 | - else |
|
1153 | + } else |
|
1077 | 1154 | { |
1078 | 1155 | if (!in_array($_POST['ftp_path'], array('', '/'))) |
1079 | 1156 | { |
1080 | 1157 | $ftp_root = strtr($boarddir, array($_POST['ftp_path'] => '')); |
1081 | - if (substr($ftp_root, -1) == '/' && ($_POST['ftp_path'] == '' || $_POST['ftp_path'][0] == '/')) |
|
1082 | - $ftp_root = substr($ftp_root, 0, -1); |
|
1158 | + if (substr($ftp_root, -1) == '/' && ($_POST['ftp_path'] == '' || $_POST['ftp_path'][0] == '/')) { |
|
1159 | + $ftp_root = substr($ftp_root, 0, -1); |
|
1160 | + } |
|
1161 | + } else { |
|
1162 | + $ftp_root = $boarddir; |
|
1083 | 1163 | } |
1084 | - else |
|
1085 | - $ftp_root = $boarddir; |
|
1086 | 1164 | |
1087 | 1165 | $_SESSION['pack_ftp'] = array( |
1088 | 1166 | 'server' => $_POST['ftp_server'], |
@@ -1093,8 +1171,9 @@ discard block |
||
1093 | 1171 | 'root' => $ftp_root, |
1094 | 1172 | ); |
1095 | 1173 | |
1096 | - if (!isset($modSettings['package_path']) || $modSettings['package_path'] != $_POST['ftp_path']) |
|
1097 | - updateSettings(array('package_path' => $_POST['ftp_path'])); |
|
1174 | + if (!isset($modSettings['package_path']) || $modSettings['package_path'] != $_POST['ftp_path']) { |
|
1175 | + updateSettings(array('package_path' => $_POST['ftp_path'])); |
|
1176 | + } |
|
1098 | 1177 | |
1099 | 1178 | $files = packageRequireFTP($destination_url, $files, $return); |
1100 | 1179 | } |
@@ -1122,16 +1201,18 @@ discard block |
||
1122 | 1201 | global $packagesdir, $forum_version, $context, $temp_path, $language, $smcFunc; |
1123 | 1202 | |
1124 | 1203 | // Mayday! That action doesn't exist!! |
1125 | - if (empty($packageXML) || !$packageXML->exists($method)) |
|
1126 | - return array(); |
|
1204 | + if (empty($packageXML) || !$packageXML->exists($method)) { |
|
1205 | + return array(); |
|
1206 | + } |
|
1127 | 1207 | |
1128 | 1208 | // We haven't found the package script yet... |
1129 | 1209 | $script = false; |
1130 | 1210 | $the_version = strtr($forum_version, array('SMF ' => '')); |
1131 | 1211 | |
1132 | 1212 | // Emulation support... |
1133 | - if (!empty($_SESSION['version_emulate'])) |
|
1134 | - $the_version = $_SESSION['version_emulate']; |
|
1213 | + if (!empty($_SESSION['version_emulate'])) { |
|
1214 | + $the_version = $_SESSION['version_emulate']; |
|
1215 | + } |
|
1135 | 1216 | |
1136 | 1217 | // Single package emulation |
1137 | 1218 | if (!empty($_REQUEST['ve']) && !empty($_REQUEST['package'])) |
@@ -1139,8 +1220,9 @@ discard block |
||
1139 | 1220 | $the_version = $_REQUEST['ve']; |
1140 | 1221 | $_SESSION['single_version_emulate'][$_REQUEST['package']] = $the_version; |
1141 | 1222 | } |
1142 | - if (!empty($_REQUEST['package']) && (!empty($_SESSION['single_version_emulate'][$_REQUEST['package']]))) |
|
1143 | - $the_version = $_SESSION['single_version_emulate'][$_REQUEST['package']]; |
|
1223 | + if (!empty($_REQUEST['package']) && (!empty($_SESSION['single_version_emulate'][$_REQUEST['package']]))) { |
|
1224 | + $the_version = $_SESSION['single_version_emulate'][$_REQUEST['package']]; |
|
1225 | + } |
|
1144 | 1226 | |
1145 | 1227 | // Get all the versions of this method and find the right one. |
1146 | 1228 | $these_methods = $packageXML->set($method); |
@@ -1150,16 +1232,18 @@ discard block |
||
1150 | 1232 | if ($this_method->exists('@for')) |
1151 | 1233 | { |
1152 | 1234 | // Don't keep going if this won't work for this version of SMF. |
1153 | - if (!matchPackageVersion($the_version, $this_method->fetch('@for'))) |
|
1154 | - continue; |
|
1235 | + if (!matchPackageVersion($the_version, $this_method->fetch('@for'))) { |
|
1236 | + continue; |
|
1237 | + } |
|
1155 | 1238 | } |
1156 | 1239 | |
1157 | 1240 | // Upgrades may go from a certain old version of the mod. |
1158 | 1241 | if ($method == 'upgrade' && $this_method->exists('@from')) |
1159 | 1242 | { |
1160 | 1243 | // Well, this is for the wrong old version... |
1161 | - if (!matchPackageVersion($previous_version, $this_method->fetch('@from'))) |
|
1162 | - continue; |
|
1244 | + if (!matchPackageVersion($previous_version, $this_method->fetch('@from'))) { |
|
1245 | + continue; |
|
1246 | + } |
|
1163 | 1247 | } |
1164 | 1248 | |
1165 | 1249 | // We've found it! |
@@ -1168,8 +1252,9 @@ discard block |
||
1168 | 1252 | } |
1169 | 1253 | |
1170 | 1254 | // Bad news, a matching script wasn't found! |
1171 | - if (!($script instanceof xmlArray)) |
|
1172 | - return array(); |
|
1255 | + if (!($script instanceof xmlArray)) { |
|
1256 | + return array(); |
|
1257 | + } |
|
1173 | 1258 | |
1174 | 1259 | // Find all the actions in this method - in theory, these should only be allowed actions. (* means all.) |
1175 | 1260 | $actions = $script->set('*'); |
@@ -1198,12 +1283,12 @@ discard block |
||
1198 | 1283 | if ((isset($_REQUEST['readme']) && $action->fetch('@lang') == $_REQUEST['readme']) || (isset($_REQUEST['license']) && $action->fetch('@lang') == $_REQUEST['license']) || (!isset($_REQUEST['readme']) && $action->fetch('@lang') == $language) || (!isset($_REQUEST['license']) && $action->fetch('@lang') == $language)) |
1199 | 1284 | { |
1200 | 1285 | // In case the user put the blocks in the wrong order. |
1201 | - if (isset($context[$type]['selected']) && $context[$type]['selected'] == 'default') |
|
1202 | - $context[$type][] = 'default'; |
|
1286 | + if (isset($context[$type]['selected']) && $context[$type]['selected'] == 'default') { |
|
1287 | + $context[$type][] = 'default'; |
|
1288 | + } |
|
1203 | 1289 | |
1204 | 1290 | $context[$type]['selected'] = $smcFunc['htmlspecialchars']($action->fetch('@lang')); |
1205 | - } |
|
1206 | - else |
|
1291 | + } else |
|
1207 | 1292 | { |
1208 | 1293 | // We don't want this now, but we'll allow the user to select to read it. |
1209 | 1294 | $context[$type][] = $smcFunc['htmlspecialchars']($action->fetch('@lang')); |
@@ -1218,9 +1303,9 @@ discard block |
||
1218 | 1303 | { |
1219 | 1304 | $context[$type][] = 'default'; |
1220 | 1305 | continue; |
1306 | + } else { |
|
1307 | + $context[$type]['selected'] = 'default'; |
|
1221 | 1308 | } |
1222 | - else |
|
1223 | - $context[$type]['selected'] = 'default'; |
|
1224 | 1309 | } |
1225 | 1310 | } |
1226 | 1311 | |
@@ -1230,9 +1315,9 @@ discard block |
||
1230 | 1315 | $filename = $temp_path . '$auto_' . $temp_auto++ . (in_array($actionType, array('readme', 'redirect', 'license')) ? '.txt' : ($actionType == 'code' || $actionType == 'database' ? '.php' : '.mod')); |
1231 | 1316 | package_put_contents($filename, $action->fetch('.')); |
1232 | 1317 | $filename = strtr($filename, array($temp_path => '')); |
1318 | + } else { |
|
1319 | + $filename = $action->fetch('.'); |
|
1233 | 1320 | } |
1234 | - else |
|
1235 | - $filename = $action->fetch('.'); |
|
1236 | 1321 | |
1237 | 1322 | $return[] = array( |
1238 | 1323 | 'type' => $actionType, |
@@ -1247,8 +1332,7 @@ discard block |
||
1247 | 1332 | ); |
1248 | 1333 | |
1249 | 1334 | continue; |
1250 | - } |
|
1251 | - elseif ($actionType == 'hook') |
|
1335 | + } elseif ($actionType == 'hook') |
|
1252 | 1336 | { |
1253 | 1337 | $return[] = array( |
1254 | 1338 | 'type' => $actionType, |
@@ -1260,16 +1344,16 @@ discard block |
||
1260 | 1344 | 'description' => '', |
1261 | 1345 | ); |
1262 | 1346 | continue; |
1263 | - } |
|
1264 | - elseif ($actionType == 'credits') |
|
1347 | + } elseif ($actionType == 'credits') |
|
1265 | 1348 | { |
1266 | 1349 | // quick check of any supplied url |
1267 | 1350 | $url = $action->exists('@url') ? $action->fetch('@url') : ''; |
1268 | 1351 | if (strlen(trim($url)) > 0 && substr($url, 0, 7) !== 'http://' && substr($url, 0, 8) !== 'https://') |
1269 | 1352 | { |
1270 | 1353 | $url = 'http://' . $url; |
1271 | - if (strlen($url) < 8 || (substr($url, 0, 7) !== 'http://' && substr($url, 0, 8) !== 'https://')) |
|
1272 | - $url = ''; |
|
1354 | + if (strlen($url) < 8 || (substr($url, 0, 7) !== 'http://' && substr($url, 0, 8) !== 'https://')) { |
|
1355 | + $url = ''; |
|
1356 | + } |
|
1273 | 1357 | } |
1274 | 1358 | |
1275 | 1359 | $return[] = array( |
@@ -1281,8 +1365,7 @@ discard block |
||
1281 | 1365 | 'title' => $action->fetch('.'), |
1282 | 1366 | ); |
1283 | 1367 | continue; |
1284 | - } |
|
1285 | - elseif ($actionType == 'requires') |
|
1368 | + } elseif ($actionType == 'requires') |
|
1286 | 1369 | { |
1287 | 1370 | $return[] = array( |
1288 | 1371 | 'type' => $actionType, |
@@ -1291,14 +1374,12 @@ discard block |
||
1291 | 1374 | 'description' => '', |
1292 | 1375 | ); |
1293 | 1376 | continue; |
1294 | - } |
|
1295 | - elseif ($actionType == 'error') |
|
1377 | + } elseif ($actionType == 'error') |
|
1296 | 1378 | { |
1297 | 1379 | $return[] = array( |
1298 | 1380 | 'type' => 'error', |
1299 | 1381 | ); |
1300 | - } |
|
1301 | - elseif (in_array($actionType, array('require-file', 'remove-file', 'require-dir', 'remove-dir', 'move-file', 'move-dir', 'create-file', 'create-dir'))) |
|
1382 | + } elseif (in_array($actionType, array('require-file', 'remove-file', 'require-dir', 'remove-dir', 'move-file', 'move-dir', 'create-file', 'create-dir'))) |
|
1302 | 1383 | { |
1303 | 1384 | $this_action = &$return[]; |
1304 | 1385 | $this_action = array( |
@@ -1312,8 +1393,7 @@ discard block |
||
1312 | 1393 | { |
1313 | 1394 | $this_action['unparsed_destination'] = $action->fetch('@destination'); |
1314 | 1395 | $this_action['destination'] = parse_path($action->fetch('@destination')) . '/' . basename($this_action['filename']); |
1315 | - } |
|
1316 | - else |
|
1396 | + } else |
|
1317 | 1397 | { |
1318 | 1398 | $this_action['unparsed_filename'] = $this_action['filename']; |
1319 | 1399 | $this_action['filename'] = parse_path($this_action['filename']); |
@@ -1322,10 +1402,11 @@ discard block |
||
1322 | 1402 | // If we're moving or requiring (copying) a file. |
1323 | 1403 | if (substr($actionType, 0, 4) == 'move' || substr($actionType, 0, 7) == 'require') |
1324 | 1404 | { |
1325 | - if ($action->exists('@from')) |
|
1326 | - $this_action['source'] = parse_path($action->fetch('@from')); |
|
1327 | - else |
|
1328 | - $this_action['source'] = $temp_path . $this_action['filename']; |
|
1405 | + if ($action->exists('@from')) { |
|
1406 | + $this_action['source'] = parse_path($action->fetch('@from')); |
|
1407 | + } else { |
|
1408 | + $this_action['source'] = $temp_path . $this_action['filename']; |
|
1409 | + } |
|
1329 | 1410 | } |
1330 | 1411 | |
1331 | 1412 | // Check if these things can be done. (chmod's etc.) |
@@ -1334,22 +1415,23 @@ discard block |
||
1334 | 1415 | if (!mktree($this_action['destination'], false)) |
1335 | 1416 | { |
1336 | 1417 | $temp = $this_action['destination']; |
1337 | - while (!file_exists($temp) && strlen($temp) > 1) |
|
1338 | - $temp = dirname($temp); |
|
1418 | + while (!file_exists($temp) && strlen($temp) > 1) { |
|
1419 | + $temp = dirname($temp); |
|
1420 | + } |
|
1339 | 1421 | |
1340 | 1422 | $return[] = array( |
1341 | 1423 | 'type' => 'chmod', |
1342 | 1424 | 'filename' => $temp |
1343 | 1425 | ); |
1344 | 1426 | } |
1345 | - } |
|
1346 | - elseif ($actionType == 'create-file') |
|
1427 | + } elseif ($actionType == 'create-file') |
|
1347 | 1428 | { |
1348 | 1429 | if (!mktree(dirname($this_action['destination']), false)) |
1349 | 1430 | { |
1350 | 1431 | $temp = dirname($this_action['destination']); |
1351 | - while (!file_exists($temp) && strlen($temp) > 1) |
|
1352 | - $temp = dirname($temp); |
|
1432 | + while (!file_exists($temp) && strlen($temp) > 1) { |
|
1433 | + $temp = dirname($temp); |
|
1434 | + } |
|
1353 | 1435 | |
1354 | 1436 | $return[] = array( |
1355 | 1437 | 'type' => 'chmod', |
@@ -1357,36 +1439,38 @@ discard block |
||
1357 | 1439 | ); |
1358 | 1440 | } |
1359 | 1441 | |
1360 | - if (!is_writable($this_action['destination']) && (file_exists($this_action['destination']) || !is_writable(dirname($this_action['destination'])))) |
|
1361 | - $return[] = array( |
|
1442 | + if (!is_writable($this_action['destination']) && (file_exists($this_action['destination']) || !is_writable(dirname($this_action['destination'])))) { |
|
1443 | + $return[] = array( |
|
1362 | 1444 | 'type' => 'chmod', |
1363 | 1445 | 'filename' => $this_action['destination'] |
1364 | 1446 | ); |
1365 | - } |
|
1366 | - elseif ($actionType == 'require-dir') |
|
1447 | + } |
|
1448 | + } elseif ($actionType == 'require-dir') |
|
1367 | 1449 | { |
1368 | 1450 | if (!mktree($this_action['destination'], false)) |
1369 | 1451 | { |
1370 | 1452 | $temp = $this_action['destination']; |
1371 | - while (!file_exists($temp) && strlen($temp) > 1) |
|
1372 | - $temp = dirname($temp); |
|
1453 | + while (!file_exists($temp) && strlen($temp) > 1) { |
|
1454 | + $temp = dirname($temp); |
|
1455 | + } |
|
1373 | 1456 | |
1374 | 1457 | $return[] = array( |
1375 | 1458 | 'type' => 'chmod', |
1376 | 1459 | 'filename' => $temp |
1377 | 1460 | ); |
1378 | 1461 | } |
1379 | - } |
|
1380 | - elseif ($actionType == 'require-file') |
|
1462 | + } elseif ($actionType == 'require-file') |
|
1381 | 1463 | { |
1382 | - if ($action->exists('@theme')) |
|
1383 | - $this_action['theme_action'] = $action->fetch('@theme'); |
|
1464 | + if ($action->exists('@theme')) { |
|
1465 | + $this_action['theme_action'] = $action->fetch('@theme'); |
|
1466 | + } |
|
1384 | 1467 | |
1385 | 1468 | if (!mktree(dirname($this_action['destination']), false)) |
1386 | 1469 | { |
1387 | 1470 | $temp = dirname($this_action['destination']); |
1388 | - while (!file_exists($temp) && strlen($temp) > 1) |
|
1389 | - $temp = dirname($temp); |
|
1471 | + while (!file_exists($temp) && strlen($temp) > 1) { |
|
1472 | + $temp = dirname($temp); |
|
1473 | + } |
|
1390 | 1474 | |
1391 | 1475 | $return[] = array( |
1392 | 1476 | 'type' => 'chmod', |
@@ -1394,19 +1478,20 @@ discard block |
||
1394 | 1478 | ); |
1395 | 1479 | } |
1396 | 1480 | |
1397 | - if (!is_writable($this_action['destination']) && (file_exists($this_action['destination']) || !is_writable(dirname($this_action['destination'])))) |
|
1398 | - $return[] = array( |
|
1481 | + if (!is_writable($this_action['destination']) && (file_exists($this_action['destination']) || !is_writable(dirname($this_action['destination'])))) { |
|
1482 | + $return[] = array( |
|
1399 | 1483 | 'type' => 'chmod', |
1400 | 1484 | 'filename' => $this_action['destination'] |
1401 | 1485 | ); |
1402 | - } |
|
1403 | - elseif ($actionType == 'move-dir' || $actionType == 'move-file') |
|
1486 | + } |
|
1487 | + } elseif ($actionType == 'move-dir' || $actionType == 'move-file') |
|
1404 | 1488 | { |
1405 | 1489 | if (!mktree(dirname($this_action['destination']), false)) |
1406 | 1490 | { |
1407 | 1491 | $temp = dirname($this_action['destination']); |
1408 | - while (!file_exists($temp) && strlen($temp) > 1) |
|
1409 | - $temp = dirname($temp); |
|
1492 | + while (!file_exists($temp) && strlen($temp) > 1) { |
|
1493 | + $temp = dirname($temp); |
|
1494 | + } |
|
1410 | 1495 | |
1411 | 1496 | $return[] = array( |
1412 | 1497 | 'type' => 'chmod', |
@@ -1414,30 +1499,30 @@ discard block |
||
1414 | 1499 | ); |
1415 | 1500 | } |
1416 | 1501 | |
1417 | - if (!is_writable($this_action['destination']) && (file_exists($this_action['destination']) || !is_writable(dirname($this_action['destination'])))) |
|
1418 | - $return[] = array( |
|
1502 | + if (!is_writable($this_action['destination']) && (file_exists($this_action['destination']) || !is_writable(dirname($this_action['destination'])))) { |
|
1503 | + $return[] = array( |
|
1419 | 1504 | 'type' => 'chmod', |
1420 | 1505 | 'filename' => $this_action['destination'] |
1421 | 1506 | ); |
1422 | - } |
|
1423 | - elseif ($actionType == 'remove-dir') |
|
1507 | + } |
|
1508 | + } elseif ($actionType == 'remove-dir') |
|
1424 | 1509 | { |
1425 | - if (!is_writable($this_action['filename']) && file_exists($this_action['filename'])) |
|
1426 | - $return[] = array( |
|
1510 | + if (!is_writable($this_action['filename']) && file_exists($this_action['filename'])) { |
|
1511 | + $return[] = array( |
|
1427 | 1512 | 'type' => 'chmod', |
1428 | 1513 | 'filename' => $this_action['filename'] |
1429 | 1514 | ); |
1430 | - } |
|
1431 | - elseif ($actionType == 'remove-file') |
|
1515 | + } |
|
1516 | + } elseif ($actionType == 'remove-file') |
|
1432 | 1517 | { |
1433 | - if (!is_writable($this_action['filename']) && file_exists($this_action['filename'])) |
|
1434 | - $return[] = array( |
|
1518 | + if (!is_writable($this_action['filename']) && file_exists($this_action['filename'])) { |
|
1519 | + $return[] = array( |
|
1435 | 1520 | 'type' => 'chmod', |
1436 | 1521 | 'filename' => $this_action['filename'] |
1437 | 1522 | ); |
1523 | + } |
|
1438 | 1524 | } |
1439 | - } |
|
1440 | - else |
|
1525 | + } else |
|
1441 | 1526 | { |
1442 | 1527 | $return[] = array( |
1443 | 1528 | 'type' => 'error', |
@@ -1448,8 +1533,9 @@ discard block |
||
1448 | 1533 | } |
1449 | 1534 | |
1450 | 1535 | // Only testing - just return a list of things to be done. |
1451 | - if ($testing_only) |
|
1452 | - return $return; |
|
1536 | + if ($testing_only) { |
|
1537 | + return $return; |
|
1538 | + } |
|
1453 | 1539 | |
1454 | 1540 | umask(0); |
1455 | 1541 | |
@@ -1457,78 +1543,81 @@ discard block |
||
1457 | 1543 | $not_done = array(array('type' => '!')); |
1458 | 1544 | foreach ($return as $action) |
1459 | 1545 | { |
1460 | - if (in_array($action['type'], array('modification', 'code', 'database', 'redirect', 'hook', 'credits'))) |
|
1461 | - $not_done[] = $action; |
|
1546 | + if (in_array($action['type'], array('modification', 'code', 'database', 'redirect', 'hook', 'credits'))) { |
|
1547 | + $not_done[] = $action; |
|
1548 | + } |
|
1462 | 1549 | |
1463 | 1550 | if ($action['type'] == 'create-dir') |
1464 | 1551 | { |
1465 | - if (!mktree($action['destination'], 0755) || !is_writable($action['destination'])) |
|
1466 | - $failure |= !mktree($action['destination'], 0777); |
|
1467 | - } |
|
1468 | - elseif ($action['type'] == 'create-file') |
|
1552 | + if (!mktree($action['destination'], 0755) || !is_writable($action['destination'])) { |
|
1553 | + $failure |= !mktree($action['destination'], 0777); |
|
1554 | + } |
|
1555 | + } elseif ($action['type'] == 'create-file') |
|
1469 | 1556 | { |
1470 | - if (!mktree(dirname($action['destination']), 0755) || !is_writable(dirname($action['destination']))) |
|
1471 | - $failure |= !mktree(dirname($action['destination']), 0777); |
|
1557 | + if (!mktree(dirname($action['destination']), 0755) || !is_writable(dirname($action['destination']))) { |
|
1558 | + $failure |= !mktree(dirname($action['destination']), 0777); |
|
1559 | + } |
|
1472 | 1560 | |
1473 | 1561 | // Create an empty file. |
1474 | 1562 | package_put_contents($action['destination'], package_get_contents($action['source']), $testing_only); |
1475 | 1563 | |
1476 | - if (!file_exists($action['destination'])) |
|
1477 | - $failure = true; |
|
1478 | - } |
|
1479 | - elseif ($action['type'] == 'require-dir') |
|
1564 | + if (!file_exists($action['destination'])) { |
|
1565 | + $failure = true; |
|
1566 | + } |
|
1567 | + } elseif ($action['type'] == 'require-dir') |
|
1480 | 1568 | { |
1481 | 1569 | copytree($action['source'], $action['destination']); |
1482 | 1570 | // Any other theme folders? |
1483 | - if (!empty($context['theme_copies']) && !empty($context['theme_copies'][$action['type']][$action['destination']])) |
|
1484 | - foreach ($context['theme_copies'][$action['type']][$action['destination']] as $theme_destination) |
|
1571 | + if (!empty($context['theme_copies']) && !empty($context['theme_copies'][$action['type']][$action['destination']])) { |
|
1572 | + foreach ($context['theme_copies'][$action['type']][$action['destination']] as $theme_destination) |
|
1485 | 1573 | copytree($action['source'], $theme_destination); |
1486 | - } |
|
1487 | - elseif ($action['type'] == 'require-file') |
|
1574 | + } |
|
1575 | + } elseif ($action['type'] == 'require-file') |
|
1488 | 1576 | { |
1489 | - if (!mktree(dirname($action['destination']), 0755) || !is_writable(dirname($action['destination']))) |
|
1490 | - $failure |= !mktree(dirname($action['destination']), 0777); |
|
1577 | + if (!mktree(dirname($action['destination']), 0755) || !is_writable(dirname($action['destination']))) { |
|
1578 | + $failure |= !mktree(dirname($action['destination']), 0777); |
|
1579 | + } |
|
1491 | 1580 | |
1492 | 1581 | package_put_contents($action['destination'], package_get_contents($action['source']), $testing_only); |
1493 | 1582 | |
1494 | 1583 | $failure |= !copy($action['source'], $action['destination']); |
1495 | 1584 | |
1496 | 1585 | // Any other theme files? |
1497 | - if (!empty($context['theme_copies']) && !empty($context['theme_copies'][$action['type']][$action['destination']])) |
|
1498 | - foreach ($context['theme_copies'][$action['type']][$action['destination']] as $theme_destination) |
|
1586 | + if (!empty($context['theme_copies']) && !empty($context['theme_copies'][$action['type']][$action['destination']])) { |
|
1587 | + foreach ($context['theme_copies'][$action['type']][$action['destination']] as $theme_destination) |
|
1499 | 1588 | { |
1500 | 1589 | if (!mktree(dirname($theme_destination), 0755) || !is_writable(dirname($theme_destination))) |
1501 | 1590 | $failure |= !mktree(dirname($theme_destination), 0777); |
1591 | + } |
|
1502 | 1592 | |
1503 | 1593 | package_put_contents($theme_destination, package_get_contents($action['source']), $testing_only); |
1504 | 1594 | |
1505 | 1595 | $failure |= !copy($action['source'], $theme_destination); |
1506 | 1596 | } |
1507 | - } |
|
1508 | - elseif ($action['type'] == 'move-file') |
|
1597 | + } elseif ($action['type'] == 'move-file') |
|
1509 | 1598 | { |
1510 | - if (!mktree(dirname($action['destination']), 0755) || !is_writable(dirname($action['destination']))) |
|
1511 | - $failure |= !mktree(dirname($action['destination']), 0777); |
|
1599 | + if (!mktree(dirname($action['destination']), 0755) || !is_writable(dirname($action['destination']))) { |
|
1600 | + $failure |= !mktree(dirname($action['destination']), 0777); |
|
1601 | + } |
|
1512 | 1602 | |
1513 | 1603 | $failure |= !rename($action['source'], $action['destination']); |
1514 | - } |
|
1515 | - elseif ($action['type'] == 'move-dir') |
|
1604 | + } elseif ($action['type'] == 'move-dir') |
|
1516 | 1605 | { |
1517 | - if (!mktree($action['destination'], 0755) || !is_writable($action['destination'])) |
|
1518 | - $failure |= !mktree($action['destination'], 0777); |
|
1606 | + if (!mktree($action['destination'], 0755) || !is_writable($action['destination'])) { |
|
1607 | + $failure |= !mktree($action['destination'], 0777); |
|
1608 | + } |
|
1519 | 1609 | |
1520 | 1610 | $failure |= !rename($action['source'], $action['destination']); |
1521 | - } |
|
1522 | - elseif ($action['type'] == 'remove-dir') |
|
1611 | + } elseif ($action['type'] == 'remove-dir') |
|
1523 | 1612 | { |
1524 | 1613 | deltree($action['filename']); |
1525 | 1614 | |
1526 | 1615 | // Any other theme folders? |
1527 | - if (!empty($context['theme_copies']) && !empty($context['theme_copies'][$action['type']][$action['filename']])) |
|
1528 | - foreach ($context['theme_copies'][$action['type']][$action['filename']] as $theme_destination) |
|
1616 | + if (!empty($context['theme_copies']) && !empty($context['theme_copies'][$action['type']][$action['filename']])) { |
|
1617 | + foreach ($context['theme_copies'][$action['type']][$action['filename']] as $theme_destination) |
|
1529 | 1618 | deltree($theme_destination); |
1530 | - } |
|
1531 | - elseif ($action['type'] == 'remove-file') |
|
1619 | + } |
|
1620 | + } elseif ($action['type'] == 'remove-file') |
|
1532 | 1621 | { |
1533 | 1622 | // Make sure the file exists before deleting it. |
1534 | 1623 | if (file_exists($action['filename'])) |
@@ -1537,16 +1626,18 @@ discard block |
||
1537 | 1626 | $failure |= !unlink($action['filename']); |
1538 | 1627 | } |
1539 | 1628 | // The file that was supposed to be deleted couldn't be found. |
1540 | - else |
|
1541 | - $failure = true; |
|
1629 | + else { |
|
1630 | + $failure = true; |
|
1631 | + } |
|
1542 | 1632 | |
1543 | 1633 | // Any other theme folders? |
1544 | - if (!empty($context['theme_copies']) && !empty($context['theme_copies'][$action['type']][$action['filename']])) |
|
1545 | - foreach ($context['theme_copies'][$action['type']][$action['filename']] as $theme_destination) |
|
1634 | + if (!empty($context['theme_copies']) && !empty($context['theme_copies'][$action['type']][$action['filename']])) { |
|
1635 | + foreach ($context['theme_copies'][$action['type']][$action['filename']] as $theme_destination) |
|
1546 | 1636 | if (file_exists($theme_destination)) |
1547 | 1637 | $failure |= !unlink($theme_destination); |
1548 | - else |
|
1549 | - $failure = true; |
|
1638 | + } else { |
|
1639 | + $failure = true; |
|
1640 | + } |
|
1550 | 1641 | } |
1551 | 1642 | } |
1552 | 1643 | |
@@ -1568,8 +1659,9 @@ discard block |
||
1568 | 1659 | { |
1569 | 1660 | static $near_version = 0; |
1570 | 1661 | |
1571 | - if ($reset) |
|
1572 | - $near_version = 0; |
|
1662 | + if ($reset) { |
|
1663 | + $near_version = 0; |
|
1664 | + } |
|
1573 | 1665 | |
1574 | 1666 | // Normalize the $versions while we remove our previous Doh! |
1575 | 1667 | $versions = explode(',', str_replace(array(' ', '2.0rc1-1'), array('', '2.0rc1.1'), strtolower($versions))); |
@@ -1578,16 +1670,19 @@ discard block |
||
1578 | 1670 | foreach ($versions as $for) |
1579 | 1671 | { |
1580 | 1672 | // Adjust for those wild cards |
1581 | - if (strpos($for, '*') !== false) |
|
1582 | - $for = str_replace('*', '0dev0', $for) . '-' . str_replace('*', '999', $for); |
|
1673 | + if (strpos($for, '*') !== false) { |
|
1674 | + $for = str_replace('*', '0dev0', $for) . '-' . str_replace('*', '999', $for); |
|
1675 | + } |
|
1583 | 1676 | |
1584 | 1677 | // If we have a range, grab the lower value, done this way so it looks normal-er to the user e.g. 2.0 vs 2.0.99 |
1585 | - if (strpos($for, '-') !== false) |
|
1586 | - list ($for, $higher) = explode('-', $for); |
|
1678 | + if (strpos($for, '-') !== false) { |
|
1679 | + list ($for, $higher) = explode('-', $for); |
|
1680 | + } |
|
1587 | 1681 | |
1588 | 1682 | // Do the compare, if the for is greater, than what we have but not greater than what we are running ..... |
1589 | - if (compareVersions($near_version, $for) === -1 && compareVersions($for, $the_version) !== 1) |
|
1590 | - $near_version = $for; |
|
1683 | + if (compareVersions($near_version, $for) === -1 && compareVersions($for, $the_version) !== 1) { |
|
1684 | + $near_version = $for; |
|
1685 | + } |
|
1591 | 1686 | } |
1592 | 1687 | |
1593 | 1688 | return !empty($near_version) ? $near_version : false; |
@@ -1610,15 +1705,17 @@ discard block |
||
1610 | 1705 | $versions = explode(',', str_replace(array(' ', '2.0rc1-1'), array('', '2.0rc1.1'), strtolower($versions))); |
1611 | 1706 | |
1612 | 1707 | // Perhaps we do accept anything? |
1613 | - if (in_array('all', $versions)) |
|
1614 | - return true; |
|
1708 | + if (in_array('all', $versions)) { |
|
1709 | + return true; |
|
1710 | + } |
|
1615 | 1711 | |
1616 | 1712 | // Loop through each version. |
1617 | 1713 | foreach ($versions as $for) |
1618 | 1714 | { |
1619 | 1715 | // Wild card spotted? |
1620 | - if (strpos($for, '*') !== false) |
|
1621 | - $for = str_replace('*', '0dev0', $for) . '-' . str_replace('*', '999', $for); |
|
1716 | + if (strpos($for, '*') !== false) { |
|
1717 | + $for = str_replace('*', '0dev0', $for) . '-' . str_replace('*', '999', $for); |
|
1718 | + } |
|
1622 | 1719 | |
1623 | 1720 | // Do we have a range? |
1624 | 1721 | if (strpos($for, '-') !== false) |
@@ -1626,12 +1723,14 @@ discard block |
||
1626 | 1723 | list ($lower, $upper) = explode('-', $for); |
1627 | 1724 | |
1628 | 1725 | // Compare the version against lower and upper bounds. |
1629 | - if (compareVersions($version, $lower) > -1 && compareVersions($version, $upper) < 1) |
|
1630 | - return true; |
|
1726 | + if (compareVersions($version, $lower) > -1 && compareVersions($version, $upper) < 1) { |
|
1727 | + return true; |
|
1728 | + } |
|
1631 | 1729 | } |
1632 | 1730 | // Otherwise check if they are equal... |
1633 | - elseif (compareVersions($version, $for) === 0) |
|
1634 | - return true; |
|
1731 | + elseif (compareVersions($version, $for) === 0) { |
|
1732 | + return true; |
|
1733 | + } |
|
1635 | 1734 | } |
1636 | 1735 | |
1637 | 1736 | return false; |
@@ -1671,12 +1770,14 @@ discard block |
||
1671 | 1770 | } |
1672 | 1771 | |
1673 | 1772 | // Are they the same, perhaps? |
1674 | - if ($versions[1] === $versions[2]) |
|
1675 | - return 0; |
|
1773 | + if ($versions[1] === $versions[2]) { |
|
1774 | + return 0; |
|
1775 | + } |
|
1676 | 1776 | |
1677 | 1777 | // Get version numbering categories... |
1678 | - if (!isset($categories)) |
|
1679 | - $categories = array_keys($versions[1]); |
|
1778 | + if (!isset($categories)) { |
|
1779 | + $categories = array_keys($versions[1]); |
|
1780 | + } |
|
1680 | 1781 | |
1681 | 1782 | // Loop through each category. |
1682 | 1783 | foreach ($categories as $category) |
@@ -1686,13 +1787,15 @@ discard block |
||
1686 | 1787 | { |
1687 | 1788 | // Dev builds are a problematic exception. |
1688 | 1789 | // (stable) dev < (stable) but (unstable) dev = (unstable) |
1689 | - if ($category == 'type') |
|
1690 | - return $versions[1][$category] > $versions[2][$category] ? ($versions[1]['dev'] ? -1 : 1) : ($versions[2]['dev'] ? 1 : -1); |
|
1691 | - elseif ($category == 'dev') |
|
1692 | - return $versions[1]['dev'] ? ($versions[2]['type'] == 'stable' ? -1 : 0) : ($versions[1]['type'] == 'stable' ? 1 : 0); |
|
1790 | + if ($category == 'type') { |
|
1791 | + return $versions[1][$category] > $versions[2][$category] ? ($versions[1]['dev'] ? -1 : 1) : ($versions[2]['dev'] ? 1 : -1); |
|
1792 | + } elseif ($category == 'dev') { |
|
1793 | + return $versions[1]['dev'] ? ($versions[2]['type'] == 'stable' ? -1 : 0) : ($versions[1]['type'] == 'stable' ? 1 : 0); |
|
1794 | + } |
|
1693 | 1795 | // Otherwise a simple comparison. |
1694 | - else |
|
1695 | - return $versions[1][$category] > $versions[2][$category] ? 1 : -1; |
|
1796 | + else { |
|
1797 | + return $versions[1][$category] > $versions[2][$category] ? 1 : -1; |
|
1798 | + } |
|
1696 | 1799 | } |
1697 | 1800 | } |
1698 | 1801 | |
@@ -1726,11 +1829,13 @@ discard block |
||
1726 | 1829 | ); |
1727 | 1830 | |
1728 | 1831 | // do we parse in a package directory? |
1729 | - if (!empty($temp_path)) |
|
1730 | - $dirs['$package'] = $temp_path; |
|
1832 | + if (!empty($temp_path)) { |
|
1833 | + $dirs['$package'] = $temp_path; |
|
1834 | + } |
|
1731 | 1835 | |
1732 | - if (strlen($path) == 0) |
|
1733 | - trigger_error('parse_path(): There should never be an empty filename', E_USER_ERROR); |
|
1836 | + if (strlen($path) == 0) { |
|
1837 | + trigger_error('parse_path(): There should never be an empty filename', E_USER_ERROR); |
|
1838 | + } |
|
1734 | 1839 | |
1735 | 1840 | return strtr($path, $dirs); |
1736 | 1841 | } |
@@ -1747,8 +1852,9 @@ discard block |
||
1747 | 1852 | /** @var ftp_connection $package_ftp */ |
1748 | 1853 | global $package_ftp; |
1749 | 1854 | |
1750 | - if (!file_exists($dir)) |
|
1751 | - return; |
|
1855 | + if (!file_exists($dir)) { |
|
1856 | + return; |
|
1857 | + } |
|
1752 | 1858 | |
1753 | 1859 | $current_dir = @opendir($dir); |
1754 | 1860 | if ($current_dir == false) |
@@ -1756,8 +1862,9 @@ discard block |
||
1756 | 1862 | if ($delete_dir && isset($package_ftp)) |
1757 | 1863 | { |
1758 | 1864 | $ftp_file = strtr($dir, array($_SESSION['pack_ftp']['root'] => '')); |
1759 | - if (!is_dir($dir)) |
|
1760 | - $package_ftp->chmod($ftp_file, 0777); |
|
1865 | + if (!is_dir($dir)) { |
|
1866 | + $package_ftp->chmod($ftp_file, 0777); |
|
1867 | + } |
|
1761 | 1868 | $package_ftp->unlink($ftp_file); |
1762 | 1869 | } |
1763 | 1870 | |
@@ -1766,26 +1873,28 @@ discard block |
||
1766 | 1873 | |
1767 | 1874 | while ($entryname = readdir($current_dir)) |
1768 | 1875 | { |
1769 | - if (in_array($entryname, array('.', '..'))) |
|
1770 | - continue; |
|
1876 | + if (in_array($entryname, array('.', '..'))) { |
|
1877 | + continue; |
|
1878 | + } |
|
1771 | 1879 | |
1772 | - if (is_dir($dir . '/' . $entryname)) |
|
1773 | - deltree($dir . '/' . $entryname); |
|
1774 | - else |
|
1880 | + if (is_dir($dir . '/' . $entryname)) { |
|
1881 | + deltree($dir . '/' . $entryname); |
|
1882 | + } else |
|
1775 | 1883 | { |
1776 | 1884 | // Here, 755 doesn't really matter since we're deleting it anyway. |
1777 | 1885 | if (isset($package_ftp)) |
1778 | 1886 | { |
1779 | 1887 | $ftp_file = strtr($dir . '/' . $entryname, array($_SESSION['pack_ftp']['root'] => '')); |
1780 | 1888 | |
1781 | - if (!is_writable($dir . '/' . $entryname)) |
|
1782 | - $package_ftp->chmod($ftp_file, 0777); |
|
1889 | + if (!is_writable($dir . '/' . $entryname)) { |
|
1890 | + $package_ftp->chmod($ftp_file, 0777); |
|
1891 | + } |
|
1783 | 1892 | $package_ftp->unlink($ftp_file); |
1784 | - } |
|
1785 | - else |
|
1893 | + } else |
|
1786 | 1894 | { |
1787 | - if (!is_writable($dir . '/' . $entryname)) |
|
1788 | - smf_chmod($dir . '/' . $entryname, 0777); |
|
1895 | + if (!is_writable($dir . '/' . $entryname)) { |
|
1896 | + smf_chmod($dir . '/' . $entryname, 0777); |
|
1897 | + } |
|
1789 | 1898 | unlink($dir . '/' . $entryname); |
1790 | 1899 | } |
1791 | 1900 | } |
@@ -1798,14 +1907,15 @@ discard block |
||
1798 | 1907 | if (isset($package_ftp)) |
1799 | 1908 | { |
1800 | 1909 | $ftp_file = strtr($dir, array($_SESSION['pack_ftp']['root'] => '')); |
1801 | - if (!is_writable($dir . '/' . $entryname)) |
|
1802 | - $package_ftp->chmod($ftp_file, 0777); |
|
1910 | + if (!is_writable($dir . '/' . $entryname)) { |
|
1911 | + $package_ftp->chmod($ftp_file, 0777); |
|
1912 | + } |
|
1803 | 1913 | $package_ftp->unlink($ftp_file); |
1804 | - } |
|
1805 | - else |
|
1914 | + } else |
|
1806 | 1915 | { |
1807 | - if (!is_writable($dir)) |
|
1808 | - smf_chmod($dir, 0777); |
|
1916 | + if (!is_writable($dir)) { |
|
1917 | + smf_chmod($dir, 0777); |
|
1918 | + } |
|
1809 | 1919 | @rmdir($dir); |
1810 | 1920 | } |
1811 | 1921 | } |
@@ -1828,10 +1938,11 @@ discard block |
||
1828 | 1938 | { |
1829 | 1939 | if (!is_writable($strPath) && $mode !== false) |
1830 | 1940 | { |
1831 | - if (isset($package_ftp)) |
|
1832 | - $package_ftp->chmod(strtr($strPath, array($_SESSION['pack_ftp']['root'] => '')), $mode); |
|
1833 | - else |
|
1834 | - smf_chmod($strPath, $mode); |
|
1941 | + if (isset($package_ftp)) { |
|
1942 | + $package_ftp->chmod(strtr($strPath, array($_SESSION['pack_ftp']['root'] => '')), $mode); |
|
1943 | + } else { |
|
1944 | + smf_chmod($strPath, $mode); |
|
1945 | + } |
|
1835 | 1946 | } |
1836 | 1947 | |
1837 | 1948 | $test = @opendir($strPath); |
@@ -1839,36 +1950,37 @@ discard block |
||
1839 | 1950 | { |
1840 | 1951 | closedir($test); |
1841 | 1952 | return is_writable($strPath); |
1953 | + } else { |
|
1954 | + return false; |
|
1842 | 1955 | } |
1843 | - else |
|
1844 | - return false; |
|
1845 | 1956 | } |
1846 | 1957 | // Is this an invalid path and/or we can't make the directory? |
1847 | - if ($strPath == dirname($strPath) || !mktree(dirname($strPath), $mode)) |
|
1848 | - return false; |
|
1958 | + if ($strPath == dirname($strPath) || !mktree(dirname($strPath), $mode)) { |
|
1959 | + return false; |
|
1960 | + } |
|
1849 | 1961 | |
1850 | 1962 | if (!is_writable(dirname($strPath)) && $mode !== false) |
1851 | 1963 | { |
1852 | - if (isset($package_ftp)) |
|
1853 | - $package_ftp->chmod(dirname(strtr($strPath, array($_SESSION['pack_ftp']['root'] => ''))), $mode); |
|
1854 | - else |
|
1855 | - smf_chmod(dirname($strPath), $mode); |
|
1964 | + if (isset($package_ftp)) { |
|
1965 | + $package_ftp->chmod(dirname(strtr($strPath, array($_SESSION['pack_ftp']['root'] => ''))), $mode); |
|
1966 | + } else { |
|
1967 | + smf_chmod(dirname($strPath), $mode); |
|
1968 | + } |
|
1856 | 1969 | } |
1857 | 1970 | |
1858 | - if ($mode !== false && isset($package_ftp)) |
|
1859 | - return $package_ftp->create_dir(strtr($strPath, array($_SESSION['pack_ftp']['root'] => ''))); |
|
1860 | - elseif ($mode === false) |
|
1971 | + if ($mode !== false && isset($package_ftp)) { |
|
1972 | + return $package_ftp->create_dir(strtr($strPath, array($_SESSION['pack_ftp']['root'] => ''))); |
|
1973 | + } elseif ($mode === false) |
|
1861 | 1974 | { |
1862 | 1975 | $test = @opendir(dirname($strPath)); |
1863 | 1976 | if ($test) |
1864 | 1977 | { |
1865 | 1978 | closedir($test); |
1866 | 1979 | return true; |
1980 | + } else { |
|
1981 | + return false; |
|
1867 | 1982 | } |
1868 | - else |
|
1869 | - return false; |
|
1870 | - } |
|
1871 | - else |
|
1983 | + } else |
|
1872 | 1984 | { |
1873 | 1985 | @mkdir($strPath, $mode); |
1874 | 1986 | $test = @opendir($strPath); |
@@ -1876,9 +1988,9 @@ discard block |
||
1876 | 1988 | { |
1877 | 1989 | closedir($test); |
1878 | 1990 | return true; |
1991 | + } else { |
|
1992 | + return false; |
|
1879 | 1993 | } |
1880 | - else |
|
1881 | - return false; |
|
1882 | 1994 | } |
1883 | 1995 | } |
1884 | 1996 | |
@@ -1894,39 +2006,46 @@ discard block |
||
1894 | 2006 | /** @var ftp_connection $package_ftp */ |
1895 | 2007 | global $package_ftp; |
1896 | 2008 | |
1897 | - if (!file_exists($destination) || !is_writable($destination)) |
|
1898 | - mktree($destination, 0755); |
|
1899 | - if (!is_writable($destination)) |
|
1900 | - mktree($destination, 0777); |
|
2009 | + if (!file_exists($destination) || !is_writable($destination)) { |
|
2010 | + mktree($destination, 0755); |
|
2011 | + } |
|
2012 | + if (!is_writable($destination)) { |
|
2013 | + mktree($destination, 0777); |
|
2014 | + } |
|
1901 | 2015 | |
1902 | 2016 | $current_dir = opendir($source); |
1903 | - if ($current_dir == false) |
|
1904 | - return; |
|
2017 | + if ($current_dir == false) { |
|
2018 | + return; |
|
2019 | + } |
|
1905 | 2020 | |
1906 | 2021 | while ($entryname = readdir($current_dir)) |
1907 | 2022 | { |
1908 | - if (in_array($entryname, array('.', '..'))) |
|
1909 | - continue; |
|
2023 | + if (in_array($entryname, array('.', '..'))) { |
|
2024 | + continue; |
|
2025 | + } |
|
1910 | 2026 | |
1911 | - if (isset($package_ftp)) |
|
1912 | - $ftp_file = strtr($destination . '/' . $entryname, array($_SESSION['pack_ftp']['root'] => '')); |
|
2027 | + if (isset($package_ftp)) { |
|
2028 | + $ftp_file = strtr($destination . '/' . $entryname, array($_SESSION['pack_ftp']['root'] => '')); |
|
2029 | + } |
|
1913 | 2030 | |
1914 | 2031 | if (is_file($source . '/' . $entryname)) |
1915 | 2032 | { |
1916 | - if (isset($package_ftp) && !file_exists($destination . '/' . $entryname)) |
|
1917 | - $package_ftp->create_file($ftp_file); |
|
1918 | - elseif (!file_exists($destination . '/' . $entryname)) |
|
1919 | - @touch($destination . '/' . $entryname); |
|
2033 | + if (isset($package_ftp) && !file_exists($destination . '/' . $entryname)) { |
|
2034 | + $package_ftp->create_file($ftp_file); |
|
2035 | + } elseif (!file_exists($destination . '/' . $entryname)) { |
|
2036 | + @touch($destination . '/' . $entryname); |
|
2037 | + } |
|
1920 | 2038 | } |
1921 | 2039 | |
1922 | 2040 | package_chmod($destination . '/' . $entryname); |
1923 | 2041 | |
1924 | - if (is_dir($source . '/' . $entryname)) |
|
1925 | - copytree($source . '/' . $entryname, $destination . '/' . $entryname); |
|
1926 | - elseif (file_exists($destination . '/' . $entryname)) |
|
1927 | - package_put_contents($destination . '/' . $entryname, package_get_contents($source . '/' . $entryname)); |
|
1928 | - else |
|
1929 | - copy($source . '/' . $entryname, $destination . '/' . $entryname); |
|
2042 | + if (is_dir($source . '/' . $entryname)) { |
|
2043 | + copytree($source . '/' . $entryname, $destination . '/' . $entryname); |
|
2044 | + } elseif (file_exists($destination . '/' . $entryname)) { |
|
2045 | + package_put_contents($destination . '/' . $entryname, package_get_contents($source . '/' . $entryname)); |
|
2046 | + } else { |
|
2047 | + copy($source . '/' . $entryname, $destination . '/' . $entryname); |
|
2048 | + } |
|
1930 | 2049 | } |
1931 | 2050 | |
1932 | 2051 | closedir($current_dir); |
@@ -1944,21 +2063,24 @@ discard block |
||
1944 | 2063 | $data = array(); |
1945 | 2064 | |
1946 | 2065 | $dir = @dir($path . $sub_path); |
1947 | - if (!$dir) |
|
1948 | - return array(); |
|
2066 | + if (!$dir) { |
|
2067 | + return array(); |
|
2068 | + } |
|
1949 | 2069 | while ($entry = $dir->read()) |
1950 | 2070 | { |
1951 | - if ($entry == '.' || $entry == '..') |
|
1952 | - continue; |
|
2071 | + if ($entry == '.' || $entry == '..') { |
|
2072 | + continue; |
|
2073 | + } |
|
1953 | 2074 | |
1954 | - if (is_dir($path . $sub_path . '/' . $entry)) |
|
1955 | - $data = array_merge($data, listtree($path, $sub_path . '/' . $entry)); |
|
1956 | - else |
|
1957 | - $data[] = array( |
|
2075 | + if (is_dir($path . $sub_path . '/' . $entry)) { |
|
2076 | + $data = array_merge($data, listtree($path, $sub_path . '/' . $entry)); |
|
2077 | + } else { |
|
2078 | + $data[] = array( |
|
1958 | 2079 | 'filename' => $sub_path == '' ? $entry : $sub_path . '/' . $entry, |
1959 | 2080 | 'size' => filesize($path . $sub_path . '/' . $entry), |
1960 | 2081 | 'skipped' => false, |
1961 | 2082 | ); |
2083 | + } |
|
1962 | 2084 | } |
1963 | 2085 | $dir->close(); |
1964 | 2086 | |
@@ -2013,8 +2135,9 @@ discard block |
||
2013 | 2135 | { |
2014 | 2136 | // If this filename is relative, if so take a guess at what it should be. |
2015 | 2137 | $real_filename = $filename; |
2016 | - if (strpos($filename, 'Themes') === 0) |
|
2017 | - $real_filename = $boarddir . '/' . $filename; |
|
2138 | + if (strpos($filename, 'Themes') === 0) { |
|
2139 | + $real_filename = $boarddir . '/' . $filename; |
|
2140 | + } |
|
2018 | 2141 | |
2019 | 2142 | if (strpos($real_filename, $theme['theme_dir']) === 0) |
2020 | 2143 | { |
@@ -2033,8 +2156,9 @@ discard block |
||
2033 | 2156 | foreach ($theme_paths as $id => $theme) |
2034 | 2157 | { |
2035 | 2158 | // Default is getting done anyway, so no need for involvement here. |
2036 | - if ($id == 1) |
|
2037 | - continue; |
|
2159 | + if ($id == 1) { |
|
2160 | + continue; |
|
2161 | + } |
|
2038 | 2162 | |
2039 | 2163 | // For every template, do we want it? Yea, no, maybe? |
2040 | 2164 | foreach ($template_changes[1] as $index => $template_file) |
@@ -2057,8 +2181,9 @@ discard block |
||
2057 | 2181 | ); |
2058 | 2182 | |
2059 | 2183 | // Sometimes though, we have some additional files for other themes, if we have add them to the mix. |
2060 | - if (isset($custom_themes_add[$files_to_change[1]])) |
|
2061 | - $files_to_change += $custom_themes_add[$files_to_change[1]]; |
|
2184 | + if (isset($custom_themes_add[$files_to_change[1]])) { |
|
2185 | + $files_to_change += $custom_themes_add[$files_to_change[1]]; |
|
2186 | + } |
|
2062 | 2187 | |
2063 | 2188 | // Now, loop through all the files we're changing, and, well, change them ;) |
2064 | 2189 | foreach ($files_to_change as $theme => $working_file) |
@@ -2092,11 +2217,13 @@ discard block |
||
2092 | 2217 | continue; |
2093 | 2218 | } |
2094 | 2219 | // Okay, we're creating this file then...? |
2095 | - elseif (!file_exists($working_file)) |
|
2096 | - $working_data = ''; |
|
2220 | + elseif (!file_exists($working_file)) { |
|
2221 | + $working_data = ''; |
|
2222 | + } |
|
2097 | 2223 | // Phew, it exists! Load 'er up! |
2098 | - else |
|
2099 | - $working_data = str_replace("\r", '', package_get_contents($working_file)); |
|
2224 | + else { |
|
2225 | + $working_data = str_replace("\r", '', package_get_contents($working_file)); |
|
2226 | + } |
|
2100 | 2227 | |
2101 | 2228 | $actions[] = array( |
2102 | 2229 | 'type' => 'opened', |
@@ -2117,8 +2244,8 @@ discard block |
||
2117 | 2244 | |
2118 | 2245 | // Grab all search items of this operation (in most cases just 1). |
2119 | 2246 | $searches = $operation->set('search'); |
2120 | - foreach ($searches as $i => $search) |
|
2121 | - $actual_operation['searches'][] = array( |
|
2247 | + foreach ($searches as $i => $search) { |
|
2248 | + $actual_operation['searches'][] = array( |
|
2122 | 2249 | 'position' => $search->exists('@position') && in_array(trim($search->fetch('@position')), array('before', 'after', 'replace', 'end')) ? trim($search->fetch('@position')) : 'replace', |
2123 | 2250 | 'is_reg_exp' => $search->exists('@regexp') && trim($search->fetch('@regexp')) === 'true', |
2124 | 2251 | 'loose_whitespace' => $search->exists('@whitespace') && trim($search->fetch('@whitespace')) === 'loose', |
@@ -2127,6 +2254,7 @@ discard block |
||
2127 | 2254 | 'preg_search' => '', |
2128 | 2255 | 'preg_replace' => '', |
2129 | 2256 | ); |
2257 | + } |
|
2130 | 2258 | |
2131 | 2259 | // At least one search should be defined. |
2132 | 2260 | if (empty($actual_operation['searches'])) |
@@ -2151,30 +2279,32 @@ discard block |
||
2151 | 2279 | // Reverse modification of regular expressions are not allowed. |
2152 | 2280 | if ($search['is_reg_exp']) |
2153 | 2281 | { |
2154 | - if ($actual_operation['error'] === 'fatal') |
|
2155 | - $actions[] = array( |
|
2282 | + if ($actual_operation['error'] === 'fatal') { |
|
2283 | + $actions[] = array( |
|
2156 | 2284 | 'type' => 'failure', |
2157 | 2285 | 'filename' => $working_file, |
2158 | 2286 | 'search' => $search['search'], |
2159 | 2287 | 'is_custom' => $theme > 1 ? $theme : 0, |
2160 | 2288 | ); |
2289 | + } |
|
2161 | 2290 | |
2162 | 2291 | // Continue to the next operation. |
2163 | 2292 | continue 2; |
2164 | 2293 | } |
2165 | 2294 | |
2166 | 2295 | // The replacement is now the search subject... |
2167 | - if ($search['position'] === 'replace' || $search['position'] === 'end') |
|
2168 | - $actual_operation['searches'][$i]['search'] = $search['add']; |
|
2169 | - else |
|
2296 | + if ($search['position'] === 'replace' || $search['position'] === 'end') { |
|
2297 | + $actual_operation['searches'][$i]['search'] = $search['add']; |
|
2298 | + } else |
|
2170 | 2299 | { |
2171 | 2300 | // Reversing a before/after modification becomes a replacement. |
2172 | 2301 | $actual_operation['searches'][$i]['position'] = 'replace'; |
2173 | 2302 | |
2174 | - if ($search['position'] === 'before') |
|
2175 | - $actual_operation['searches'][$i]['search'] .= $search['add']; |
|
2176 | - elseif ($search['position'] === 'after') |
|
2177 | - $actual_operation['searches'][$i]['search'] = $search['add'] . $search['search']; |
|
2303 | + if ($search['position'] === 'before') { |
|
2304 | + $actual_operation['searches'][$i]['search'] .= $search['add']; |
|
2305 | + } elseif ($search['position'] === 'after') { |
|
2306 | + $actual_operation['searches'][$i]['search'] = $search['add'] . $search['search']; |
|
2307 | + } |
|
2178 | 2308 | } |
2179 | 2309 | |
2180 | 2310 | // ...and the search subject is now the replacement. |
@@ -2202,16 +2332,17 @@ discard block |
||
2202 | 2332 | foreach ($actual_operation['searches'] as $i => $search) |
2203 | 2333 | { |
2204 | 2334 | // Not much needed if the search subject is already a regexp. |
2205 | - if ($search['is_reg_exp']) |
|
2206 | - $actual_operation['searches'][$i]['preg_search'] = $search['search']; |
|
2207 | - else |
|
2335 | + if ($search['is_reg_exp']) { |
|
2336 | + $actual_operation['searches'][$i]['preg_search'] = $search['search']; |
|
2337 | + } else |
|
2208 | 2338 | { |
2209 | 2339 | // Make the search subject fit into a regular expression. |
2210 | 2340 | $actual_operation['searches'][$i]['preg_search'] = preg_quote($search['search'], '~'); |
2211 | 2341 | |
2212 | 2342 | // Using 'loose', a random amount of tabs and spaces may be used. |
2213 | - if ($search['loose_whitespace']) |
|
2214 | - $actual_operation['searches'][$i]['preg_search'] = preg_replace('~[ \t]+~', '[ \t]+', $actual_operation['searches'][$i]['preg_search']); |
|
2343 | + if ($search['loose_whitespace']) { |
|
2344 | + $actual_operation['searches'][$i]['preg_search'] = preg_replace('~[ \t]+~', '[ \t]+', $actual_operation['searches'][$i]['preg_search']); |
|
2345 | + } |
|
2215 | 2346 | } |
2216 | 2347 | |
2217 | 2348 | // Shuzzup. This is done so we can safely use a regular expression. ($0 is bad!!) |
@@ -2237,8 +2368,7 @@ discard block |
||
2237 | 2368 | if ($undo) |
2238 | 2369 | { |
2239 | 2370 | $actual_operation['searches'][$i]['preg_replace'] = ''; |
2240 | - } |
|
2241 | - else |
|
2371 | + } else |
|
2242 | 2372 | { |
2243 | 2373 | $actual_operation['searches'][$i]['preg_search'] = '(\\n\\?\\>)?$'; |
2244 | 2374 | $actual_operation['searches'][$i]['preg_replace'] .= '$1'; |
@@ -2285,8 +2415,9 @@ discard block |
||
2285 | 2415 | } |
2286 | 2416 | |
2287 | 2417 | // Replace it into nothing? That's not an option...unless it's an undoing end. |
2288 | - if ($search['add'] === '' && ($search['position'] !== 'end' || !$undo)) |
|
2289 | - continue; |
|
2418 | + if ($search['add'] === '' && ($search['position'] !== 'end' || !$undo)) { |
|
2419 | + continue; |
|
2420 | + } |
|
2290 | 2421 | |
2291 | 2422 | // Finally, we're doing some replacements. |
2292 | 2423 | $working_data = preg_replace('~' . $actual_operation['searches'][$i]['preg_search'] . '~s', $actual_operation['searches'][$i]['preg_replace'], $working_data, 1); |
@@ -2311,22 +2442,25 @@ discard block |
||
2311 | 2442 | |
2312 | 2443 | package_chmod($working_file); |
2313 | 2444 | |
2314 | - if ((file_exists($working_file) && !is_writable($working_file)) || (!file_exists($working_file) && !is_writable(dirname($working_file)))) |
|
2315 | - $actions[] = array( |
|
2445 | + if ((file_exists($working_file) && !is_writable($working_file)) || (!file_exists($working_file) && !is_writable(dirname($working_file)))) { |
|
2446 | + $actions[] = array( |
|
2316 | 2447 | 'type' => 'chmod', |
2317 | 2448 | 'filename' => $working_file |
2318 | 2449 | ); |
2450 | + } |
|
2319 | 2451 | |
2320 | - if (basename($working_file) == 'Settings_bak.php') |
|
2321 | - continue; |
|
2452 | + if (basename($working_file) == 'Settings_bak.php') { |
|
2453 | + continue; |
|
2454 | + } |
|
2322 | 2455 | |
2323 | 2456 | if (!$testing && !empty($modSettings['package_make_backups']) && file_exists($working_file)) |
2324 | 2457 | { |
2325 | 2458 | // No, no, not Settings.php! |
2326 | - if (basename($working_file) == 'Settings.php') |
|
2327 | - @copy($working_file, dirname($working_file) . '/Settings_bak.php'); |
|
2328 | - else |
|
2329 | - @copy($working_file, $working_file . '~'); |
|
2459 | + if (basename($working_file) == 'Settings.php') { |
|
2460 | + @copy($working_file, dirname($working_file) . '/Settings_bak.php'); |
|
2461 | + } else { |
|
2462 | + @copy($working_file, $working_file . '~'); |
|
2463 | + } |
|
2330 | 2464 | } |
2331 | 2465 | |
2332 | 2466 | // Always call this, even if in testing, because it won't really be written in testing mode. |
@@ -2393,8 +2527,9 @@ discard block |
||
2393 | 2527 | if ($code_match[1] != 'edit file' && $code_match[1] != 'file') |
2394 | 2528 | { |
2395 | 2529 | // It's a step, let's add that to the current steps. |
2396 | - if (isset($temp_changes[$step_counter])) |
|
2397 | - $temp_changes[$step_counter]['changes'][] = $code_match[0]; |
|
2530 | + if (isset($temp_changes[$step_counter])) { |
|
2531 | + $temp_changes[$step_counter]['changes'][] = $code_match[0]; |
|
2532 | + } |
|
2398 | 2533 | continue; |
2399 | 2534 | } |
2400 | 2535 | |
@@ -2411,11 +2546,13 @@ discard block |
||
2411 | 2546 | foreach ($theme_paths as $id => $theme) |
2412 | 2547 | { |
2413 | 2548 | // If this filename is relative, if so take a guess at what it should be. |
2414 | - if (strpos($filename, 'Themes') === 0) |
|
2415 | - $filename = $boarddir . '/' . $filename; |
|
2549 | + if (strpos($filename, 'Themes') === 0) { |
|
2550 | + $filename = $boarddir . '/' . $filename; |
|
2551 | + } |
|
2416 | 2552 | |
2417 | - if (strpos($filename, $theme['theme_dir']) === 0) |
|
2418 | - $template_changes[$id][$counter] = substr($filename, strlen($theme['theme_dir']) + 1); |
|
2553 | + if (strpos($filename, $theme['theme_dir']) === 0) { |
|
2554 | + $template_changes[$id][$counter] = substr($filename, strlen($theme['theme_dir']) + 1); |
|
2555 | + } |
|
2419 | 2556 | } |
2420 | 2557 | } |
2421 | 2558 | |
@@ -2428,8 +2565,9 @@ discard block |
||
2428 | 2565 | foreach ($theme_paths as $id => $theme) |
2429 | 2566 | { |
2430 | 2567 | // Don't do default, it means nothing to me. |
2431 | - if ($id == 1) |
|
2432 | - continue; |
|
2568 | + if ($id == 1) { |
|
2569 | + continue; |
|
2570 | + } |
|
2433 | 2571 | |
2434 | 2572 | // Now, for each file do we need to edit it? |
2435 | 2573 | foreach ($template_changes[1] as $pos => $template_file) |
@@ -2465,32 +2603,36 @@ discard block |
||
2465 | 2603 | package_chmod($working_file); |
2466 | 2604 | |
2467 | 2605 | // Don't even dare. |
2468 | - if (basename($working_file) == 'Settings_bak.php') |
|
2469 | - continue; |
|
2606 | + if (basename($working_file) == 'Settings_bak.php') { |
|
2607 | + continue; |
|
2608 | + } |
|
2470 | 2609 | |
2471 | - if (!is_writable($working_file)) |
|
2472 | - $actions[] = array( |
|
2610 | + if (!is_writable($working_file)) { |
|
2611 | + $actions[] = array( |
|
2473 | 2612 | 'type' => 'chmod', |
2474 | 2613 | 'filename' => $working_file |
2475 | 2614 | ); |
2615 | + } |
|
2476 | 2616 | |
2477 | 2617 | if (!$testing && !empty($modSettings['package_make_backups']) && file_exists($working_file)) |
2478 | 2618 | { |
2479 | - if (basename($working_file) == 'Settings.php') |
|
2480 | - @copy($working_file, dirname($working_file) . '/Settings_bak.php'); |
|
2481 | - else |
|
2482 | - @copy($working_file, $working_file . '~'); |
|
2619 | + if (basename($working_file) == 'Settings.php') { |
|
2620 | + @copy($working_file, dirname($working_file) . '/Settings_bak.php'); |
|
2621 | + } else { |
|
2622 | + @copy($working_file, $working_file . '~'); |
|
2623 | + } |
|
2483 | 2624 | } |
2484 | 2625 | |
2485 | 2626 | package_put_contents($working_file, $working_data, $testing); |
2486 | 2627 | } |
2487 | 2628 | |
2488 | - if ($working_file !== null) |
|
2489 | - $actions[] = array( |
|
2629 | + if ($working_file !== null) { |
|
2630 | + $actions[] = array( |
|
2490 | 2631 | 'type' => 'saved', |
2491 | 2632 | 'filename' => $working_file, |
2492 | 2633 | 'is_custom' => $is_custom, |
2493 | 2634 | ); |
2635 | + } |
|
2494 | 2636 | |
2495 | 2637 | // Is this "now working on" file a theme specific one? |
2496 | 2638 | $is_custom = isset($theme_id_ref[$counter - 1]) ? $theme_id_ref[$counter - 1] : 0; |
@@ -2509,10 +2651,11 @@ discard block |
||
2509 | 2651 | { |
2510 | 2652 | $places_to_check = array($boarddir, $sourcedir, $settings['default_theme_dir'], $settings['default_theme_dir'] . '/languages'); |
2511 | 2653 | |
2512 | - foreach ($places_to_check as $place) |
|
2513 | - if (file_exists($place . '/' . $working_file)) |
|
2654 | + foreach ($places_to_check as $place) { |
|
2655 | + if (file_exists($place . '/' . $working_file)) |
|
2514 | 2656 | { |
2515 | 2657 | $working_file = $place . '/' . $working_file; |
2658 | + } |
|
2516 | 2659 | break; |
2517 | 2660 | } |
2518 | 2661 | } |
@@ -2526,8 +2669,7 @@ discard block |
||
2526 | 2669 | 'type' => 'opened', |
2527 | 2670 | 'filename' => $working_file |
2528 | 2671 | ); |
2529 | - } |
|
2530 | - else |
|
2672 | + } else |
|
2531 | 2673 | { |
2532 | 2674 | $actions[] = array( |
2533 | 2675 | 'type' => 'missing', |
@@ -2563,11 +2705,13 @@ discard block |
||
2563 | 2705 | $replace_with = $code_match[2]; |
2564 | 2706 | |
2565 | 2707 | // Add this afterward... |
2566 | - if ($code_match[1] == 'add' || $code_match[1] == 'add after') |
|
2567 | - $replace_with = $working_search . "\n" . $replace_with; |
|
2708 | + if ($code_match[1] == 'add' || $code_match[1] == 'add after') { |
|
2709 | + $replace_with = $working_search . "\n" . $replace_with; |
|
2710 | + } |
|
2568 | 2711 | // Add this beforehand. |
2569 | - elseif ($code_match[1] == 'before' || $code_match[1] == 'add before' || $code_match[1] == 'above' || $code_match[1] == 'add above') |
|
2570 | - $replace_with .= "\n" . $working_search; |
|
2712 | + elseif ($code_match[1] == 'before' || $code_match[1] == 'add before' || $code_match[1] == 'above' || $code_match[1] == 'add above') { |
|
2713 | + $replace_with .= "\n" . $working_search; |
|
2714 | + } |
|
2571 | 2715 | // Otherwise.. replace with $replace_with ;). |
2572 | 2716 | } |
2573 | 2717 | |
@@ -2630,29 +2774,32 @@ discard block |
||
2630 | 2774 | { |
2631 | 2775 | package_chmod($working_file); |
2632 | 2776 | |
2633 | - if (!is_writable($working_file)) |
|
2634 | - $actions[] = array( |
|
2777 | + if (!is_writable($working_file)) { |
|
2778 | + $actions[] = array( |
|
2635 | 2779 | 'type' => 'chmod', |
2636 | 2780 | 'filename' => $working_file |
2637 | 2781 | ); |
2782 | + } |
|
2638 | 2783 | |
2639 | 2784 | if (!$testing && !empty($modSettings['package_make_backups']) && file_exists($working_file)) |
2640 | 2785 | { |
2641 | - if (basename($working_file) == 'Settings.php') |
|
2642 | - @copy($working_file, dirname($working_file) . '/Settings_bak.php'); |
|
2643 | - else |
|
2644 | - @copy($working_file, $working_file . '~'); |
|
2786 | + if (basename($working_file) == 'Settings.php') { |
|
2787 | + @copy($working_file, dirname($working_file) . '/Settings_bak.php'); |
|
2788 | + } else { |
|
2789 | + @copy($working_file, $working_file . '~'); |
|
2790 | + } |
|
2645 | 2791 | } |
2646 | 2792 | |
2647 | 2793 | package_put_contents($working_file, $working_data, $testing); |
2648 | 2794 | } |
2649 | 2795 | |
2650 | - if ($working_file !== null) |
|
2651 | - $actions[] = array( |
|
2796 | + if ($working_file !== null) { |
|
2797 | + $actions[] = array( |
|
2652 | 2798 | 'type' => 'saved', |
2653 | 2799 | 'filename' => $working_file, |
2654 | 2800 | 'is_custom' => $is_custom, |
2655 | 2801 | ); |
2802 | + } |
|
2656 | 2803 | |
2657 | 2804 | $actions[] = array( |
2658 | 2805 | 'type' => 'result', |
@@ -2678,17 +2825,19 @@ discard block |
||
2678 | 2825 | $mem_check = setMemoryLimit('128M'); |
2679 | 2826 | |
2680 | 2827 | // Windows doesn't seem to care about the memory_limit. |
2681 | - if (!empty($modSettings['package_disable_cache']) || $mem_check || stripos(PHP_OS, 'win') !== false) |
|
2682 | - $package_cache = array(); |
|
2683 | - else |
|
2684 | - $package_cache = false; |
|
2828 | + if (!empty($modSettings['package_disable_cache']) || $mem_check || stripos(PHP_OS, 'win') !== false) { |
|
2829 | + $package_cache = array(); |
|
2830 | + } else { |
|
2831 | + $package_cache = false; |
|
2832 | + } |
|
2685 | 2833 | } |
2686 | 2834 | |
2687 | - if (strpos($filename, 'Packages/') !== false || $package_cache === false || !isset($package_cache[$filename])) |
|
2688 | - return file_get_contents($filename); |
|
2689 | - else |
|
2690 | - return $package_cache[$filename]; |
|
2691 | -} |
|
2835 | + if (strpos($filename, 'Packages/') !== false || $package_cache === false || !isset($package_cache[$filename])) { |
|
2836 | + return file_get_contents($filename); |
|
2837 | + } else { |
|
2838 | + return $package_cache[$filename]; |
|
2839 | + } |
|
2840 | + } |
|
2692 | 2841 | |
2693 | 2842 | /** |
2694 | 2843 | * Writes data to a file, almost exactly like the file_put_contents() function. |
@@ -2712,19 +2861,22 @@ discard block |
||
2712 | 2861 | // Try to increase the memory limit - we don't want to run out of ram! |
2713 | 2862 | $mem_check = setMemoryLimit('128M'); |
2714 | 2863 | |
2715 | - if (!empty($modSettings['package_disable_cache']) || $mem_check || stripos(PHP_OS, 'win') !== false) |
|
2716 | - $package_cache = array(); |
|
2717 | - else |
|
2718 | - $package_cache = false; |
|
2864 | + if (!empty($modSettings['package_disable_cache']) || $mem_check || stripos(PHP_OS, 'win') !== false) { |
|
2865 | + $package_cache = array(); |
|
2866 | + } else { |
|
2867 | + $package_cache = false; |
|
2868 | + } |
|
2719 | 2869 | } |
2720 | 2870 | |
2721 | - if (isset($package_ftp)) |
|
2722 | - $ftp_file = strtr($filename, array($_SESSION['pack_ftp']['root'] => '')); |
|
2871 | + if (isset($package_ftp)) { |
|
2872 | + $ftp_file = strtr($filename, array($_SESSION['pack_ftp']['root'] => '')); |
|
2873 | + } |
|
2723 | 2874 | |
2724 | - if (!file_exists($filename) && isset($package_ftp)) |
|
2725 | - $package_ftp->create_file($ftp_file); |
|
2726 | - elseif (!file_exists($filename)) |
|
2727 | - @touch($filename); |
|
2875 | + if (!file_exists($filename) && isset($package_ftp)) { |
|
2876 | + $package_ftp->create_file($ftp_file); |
|
2877 | + } elseif (!file_exists($filename)) { |
|
2878 | + @touch($filename); |
|
2879 | + } |
|
2728 | 2880 | |
2729 | 2881 | package_chmod($filename); |
2730 | 2882 | |
@@ -2733,22 +2885,23 @@ discard block |
||
2733 | 2885 | $fp = @fopen($filename, in_array(substr($filename, -3), $text_filetypes) ? 'w' : 'wb'); |
2734 | 2886 | |
2735 | 2887 | // We should show an error message or attempt a rollback, no? |
2736 | - if (!$fp) |
|
2737 | - return false; |
|
2888 | + if (!$fp) { |
|
2889 | + return false; |
|
2890 | + } |
|
2738 | 2891 | |
2739 | 2892 | fwrite($fp, $data); |
2740 | 2893 | fclose($fp); |
2741 | - } |
|
2742 | - elseif (strpos($filename, 'Packages/') !== false || $package_cache === false) |
|
2743 | - return strlen($data); |
|
2744 | - else |
|
2894 | + } elseif (strpos($filename, 'Packages/') !== false || $package_cache === false) { |
|
2895 | + return strlen($data); |
|
2896 | + } else |
|
2745 | 2897 | { |
2746 | 2898 | $package_cache[$filename] = $data; |
2747 | 2899 | |
2748 | 2900 | // Permission denied, eh? |
2749 | 2901 | $fp = @fopen($filename, 'r+'); |
2750 | - if (!$fp) |
|
2751 | - return false; |
|
2902 | + if (!$fp) { |
|
2903 | + return false; |
|
2904 | + } |
|
2752 | 2905 | fclose($fp); |
2753 | 2906 | } |
2754 | 2907 | |
@@ -2766,19 +2919,22 @@ discard block |
||
2766 | 2919 | global $package_ftp, $package_cache; |
2767 | 2920 | static $text_filetypes = array('php', 'txt', '.js', 'css', 'vbs', 'tml', 'htm'); |
2768 | 2921 | |
2769 | - if (empty($package_cache)) |
|
2770 | - return; |
|
2922 | + if (empty($package_cache)) { |
|
2923 | + return; |
|
2924 | + } |
|
2771 | 2925 | |
2772 | 2926 | // First, let's check permissions! |
2773 | 2927 | foreach ($package_cache as $filename => $data) |
2774 | 2928 | { |
2775 | - if (isset($package_ftp)) |
|
2776 | - $ftp_file = strtr($filename, array($_SESSION['pack_ftp']['root'] => '')); |
|
2929 | + if (isset($package_ftp)) { |
|
2930 | + $ftp_file = strtr($filename, array($_SESSION['pack_ftp']['root'] => '')); |
|
2931 | + } |
|
2777 | 2932 | |
2778 | - if (!file_exists($filename) && isset($package_ftp)) |
|
2779 | - $package_ftp->create_file($ftp_file); |
|
2780 | - elseif (!file_exists($filename)) |
|
2781 | - @touch($filename); |
|
2933 | + if (!file_exists($filename) && isset($package_ftp)) { |
|
2934 | + $package_ftp->create_file($ftp_file); |
|
2935 | + } elseif (!file_exists($filename)) { |
|
2936 | + @touch($filename); |
|
2937 | + } |
|
2782 | 2938 | |
2783 | 2939 | $result = package_chmod($filename); |
2784 | 2940 | |
@@ -2832,8 +2988,9 @@ discard block |
||
2832 | 2988 | /** @var ftp_connection $package_ftp */ |
2833 | 2989 | global $package_ftp; |
2834 | 2990 | |
2835 | - if (file_exists($filename) && is_writable($filename) && $perm_state == 'writable') |
|
2836 | - return true; |
|
2991 | + if (file_exists($filename) && is_writable($filename) && $perm_state == 'writable') { |
|
2992 | + return true; |
|
2993 | + } |
|
2837 | 2994 | |
2838 | 2995 | // Start off checking without FTP. |
2839 | 2996 | if (!isset($package_ftp) || $package_ftp === false) |
@@ -2855,8 +3012,7 @@ discard block |
||
2855 | 3012 | |
2856 | 3013 | // Keep track of the writable status here. |
2857 | 3014 | $file_permissions = @fileperms($chmod_file); |
2858 | - } |
|
2859 | - else |
|
3015 | + } else |
|
2860 | 3016 | { |
2861 | 3017 | // This looks odd, but it's an attempt to work around PHP suExec. |
2862 | 3018 | if (!file_exists($chmod_file) && $perm_state == 'writable') |
@@ -2866,24 +3022,28 @@ discard block |
||
2866 | 3022 | mktree(dirname($chmod_file), 0755); |
2867 | 3023 | @touch($chmod_file); |
2868 | 3024 | smf_chmod($chmod_file, 0755); |
3025 | + } else { |
|
3026 | + $file_permissions = @fileperms($chmod_file); |
|
2869 | 3027 | } |
2870 | - else |
|
2871 | - $file_permissions = @fileperms($chmod_file); |
|
2872 | 3028 | } |
2873 | 3029 | |
2874 | 3030 | // This looks odd, but it's another attempt to work around PHP suExec. |
2875 | - if ($perm_state != 'writable') |
|
2876 | - smf_chmod($chmod_file, $perm_state == 'execute' ? 0755 : 0644); |
|
2877 | - else |
|
3031 | + if ($perm_state != 'writable') { |
|
3032 | + smf_chmod($chmod_file, $perm_state == 'execute' ? 0755 : 0644); |
|
3033 | + } else |
|
2878 | 3034 | { |
2879 | - if (!@is_writable($chmod_file)) |
|
2880 | - smf_chmod($chmod_file, 0755); |
|
2881 | - if (!@is_writable($chmod_file)) |
|
2882 | - smf_chmod($chmod_file, 0777); |
|
2883 | - if (!@is_writable(dirname($chmod_file))) |
|
2884 | - smf_chmod($chmod_file, 0755); |
|
2885 | - if (!@is_writable(dirname($chmod_file))) |
|
2886 | - smf_chmod($chmod_file, 0777); |
|
3035 | + if (!@is_writable($chmod_file)) { |
|
3036 | + smf_chmod($chmod_file, 0755); |
|
3037 | + } |
|
3038 | + if (!@is_writable($chmod_file)) { |
|
3039 | + smf_chmod($chmod_file, 0777); |
|
3040 | + } |
|
3041 | + if (!@is_writable(dirname($chmod_file))) { |
|
3042 | + smf_chmod($chmod_file, 0755); |
|
3043 | + } |
|
3044 | + if (!@is_writable(dirname($chmod_file))) { |
|
3045 | + smf_chmod($chmod_file, 0777); |
|
3046 | + } |
|
2887 | 3047 | } |
2888 | 3048 | |
2889 | 3049 | // The ultimate writable test. |
@@ -2892,20 +3052,22 @@ discard block |
||
2892 | 3052 | $fp = is_dir($chmod_file) ? @opendir($chmod_file) : @fopen($chmod_file, 'rb'); |
2893 | 3053 | if (@is_writable($chmod_file) && $fp) |
2894 | 3054 | { |
2895 | - if (!is_dir($chmod_file)) |
|
2896 | - fclose($fp); |
|
2897 | - else |
|
2898 | - closedir($fp); |
|
3055 | + if (!is_dir($chmod_file)) { |
|
3056 | + fclose($fp); |
|
3057 | + } else { |
|
3058 | + closedir($fp); |
|
3059 | + } |
|
2899 | 3060 | |
2900 | 3061 | // It worked! |
2901 | - if ($track_change) |
|
2902 | - $_SESSION['pack_ftp']['original_perms'][$chmod_file] = $file_permissions; |
|
3062 | + if ($track_change) { |
|
3063 | + $_SESSION['pack_ftp']['original_perms'][$chmod_file] = $file_permissions; |
|
3064 | + } |
|
2903 | 3065 | |
2904 | 3066 | return true; |
2905 | 3067 | } |
3068 | + } elseif ($perm_state != 'writable' && isset($_SESSION['pack_ftp']['original_perms'][$chmod_file])) { |
|
3069 | + unset($_SESSION['pack_ftp']['original_perms'][$chmod_file]); |
|
2906 | 3070 | } |
2907 | - elseif ($perm_state != 'writable' && isset($_SESSION['pack_ftp']['original_perms'][$chmod_file])) |
|
2908 | - unset($_SESSION['pack_ftp']['original_perms'][$chmod_file]); |
|
2909 | 3071 | } |
2910 | 3072 | |
2911 | 3073 | // If we're here we're a failure. |
@@ -2924,31 +3086,33 @@ discard block |
||
2924 | 3086 | mktree(dirname($filename), 0755); |
2925 | 3087 | $package_ftp->create_file($ftp_file); |
2926 | 3088 | $package_ftp->chmod($ftp_file, 0755); |
3089 | + } else { |
|
3090 | + $file_permissions = @fileperms($filename); |
|
2927 | 3091 | } |
2928 | - else |
|
2929 | - $file_permissions = @fileperms($filename); |
|
2930 | 3092 | |
2931 | 3093 | if ($perm_state != 'writable') |
2932 | 3094 | { |
2933 | 3095 | $package_ftp->chmod($ftp_file, $perm_state == 'execute' ? 0755 : 0644); |
2934 | - } |
|
2935 | - else |
|
3096 | + } else |
|
2936 | 3097 | { |
2937 | - if (!@is_writable($filename)) |
|
2938 | - $package_ftp->chmod($ftp_file, 0777); |
|
2939 | - if (!@is_writable(dirname($filename))) |
|
2940 | - $package_ftp->chmod(dirname($ftp_file), 0777); |
|
3098 | + if (!@is_writable($filename)) { |
|
3099 | + $package_ftp->chmod($ftp_file, 0777); |
|
3100 | + } |
|
3101 | + if (!@is_writable(dirname($filename))) { |
|
3102 | + $package_ftp->chmod(dirname($ftp_file), 0777); |
|
3103 | + } |
|
2941 | 3104 | } |
2942 | 3105 | |
2943 | 3106 | if (@is_writable($filename)) |
2944 | 3107 | { |
2945 | - if ($track_change) |
|
2946 | - $_SESSION['pack_ftp']['original_perms'][$filename] = $file_permissions; |
|
3108 | + if ($track_change) { |
|
3109 | + $_SESSION['pack_ftp']['original_perms'][$filename] = $file_permissions; |
|
3110 | + } |
|
2947 | 3111 | |
2948 | 3112 | return true; |
3113 | + } elseif ($perm_state != 'writable' && isset($_SESSION['pack_ftp']['original_perms'][$filename])) { |
|
3114 | + unset($_SESSION['pack_ftp']['original_perms'][$filename]); |
|
2949 | 3115 | } |
2950 | - elseif ($perm_state != 'writable' && isset($_SESSION['pack_ftp']['original_perms'][$filename])) |
|
2951 | - unset($_SESSION['pack_ftp']['original_perms'][$filename]); |
|
2952 | 3116 | } |
2953 | 3117 | |
2954 | 3118 | // Oh dear, we failed if we get here. |
@@ -2966,11 +3130,13 @@ discard block |
||
2966 | 3130 | $n = strlen($pass); |
2967 | 3131 | |
2968 | 3132 | $salt = session_id(); |
2969 | - while (strlen($salt) < $n) |
|
2970 | - $salt .= session_id(); |
|
3133 | + while (strlen($salt) < $n) { |
|
3134 | + $salt .= session_id(); |
|
3135 | + } |
|
2971 | 3136 | |
2972 | - for ($i = 0; $i < $n; $i++) |
|
2973 | - $pass{$i} = chr(ord($pass{$i}) ^ (ord($salt{$i}) - 32)); |
|
3137 | + for ($i = 0; $i < $n; $i++) { |
|
3138 | + $pass{$i} = chr(ord($pass{$i}) ^ (ord($salt{$i}) - 32)); |
|
3139 | + } |
|
2974 | 3140 | |
2975 | 3141 | return $pass; |
2976 | 3142 | } |
@@ -2989,8 +3155,9 @@ discard block |
||
2989 | 3155 | $base_files = array('index.php', 'SSI.php', 'agreement.txt', 'cron.php', 'ssi_examples.php', 'ssi_examples.shtml', 'subscriptions.php'); |
2990 | 3156 | foreach ($base_files as $file) |
2991 | 3157 | { |
2992 | - if (file_exists($boarddir . '/' . $file)) |
|
2993 | - $files[empty($_REQUEST['use_full_paths']) ? $file : $boarddir . '/' . $file] = $boarddir . '/' . $file; |
|
3158 | + if (file_exists($boarddir . '/' . $file)) { |
|
3159 | + $files[empty($_REQUEST['use_full_paths']) ? $file : $boarddir . '/' . $file] = $boarddir . '/' . $file; |
|
3160 | + } |
|
2994 | 3161 | } |
2995 | 3162 | |
2996 | 3163 | $dirs = array( |
@@ -3007,8 +3174,9 @@ discard block |
||
3007 | 3174 | 'theme_dir' => 'theme_dir', |
3008 | 3175 | ) |
3009 | 3176 | ); |
3010 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
3011 | - $dirs[$row['value']] = empty($_REQUEST['use_full_paths']) ? 'Themes/' . basename($row['value']) . '/' : strtr($row['value'] . '/', '\\', '/'); |
|
3177 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
3178 | + $dirs[$row['value']] = empty($_REQUEST['use_full_paths']) ? 'Themes/' . basename($row['value']) . '/' : strtr($row['value'] . '/', '\\', '/'); |
|
3179 | + } |
|
3012 | 3180 | $smcFunc['db_free_result']($request); |
3013 | 3181 | |
3014 | 3182 | try |
@@ -3023,11 +3191,13 @@ discard block |
||
3023 | 3191 | |
3024 | 3192 | foreach ($iter as $entry => $dir) |
3025 | 3193 | { |
3026 | - if ($dir->isDir()) |
|
3027 | - continue; |
|
3194 | + if ($dir->isDir()) { |
|
3195 | + continue; |
|
3196 | + } |
|
3028 | 3197 | |
3029 | - if (preg_match('~^(\.{1,2}|CVS|backup.*|help|images|.*\~)$~', $entry) != 0) |
|
3030 | - continue; |
|
3198 | + if (preg_match('~^(\.{1,2}|CVS|backup.*|help|images|.*\~)$~', $entry) != 0) { |
|
3199 | + continue; |
|
3200 | + } |
|
3031 | 3201 | |
3032 | 3202 | $files[empty($_REQUEST['use_full_paths']) ? str_replace(realpath($boarddir), '', $entry) : $entry] = $entry; |
3033 | 3203 | } |
@@ -3035,26 +3205,30 @@ discard block |
||
3035 | 3205 | $obj = new ArrayObject($files); |
3036 | 3206 | $iterator = $obj->getIterator(); |
3037 | 3207 | |
3038 | - if (!file_exists($packagesdir . '/backups')) |
|
3039 | - mktree($packagesdir . '/backups', 0777); |
|
3040 | - if (!is_writable($packagesdir . '/backups')) |
|
3041 | - package_chmod($packagesdir . '/backups'); |
|
3208 | + if (!file_exists($packagesdir . '/backups')) { |
|
3209 | + mktree($packagesdir . '/backups', 0777); |
|
3210 | + } |
|
3211 | + if (!is_writable($packagesdir . '/backups')) { |
|
3212 | + package_chmod($packagesdir . '/backups'); |
|
3213 | + } |
|
3042 | 3214 | $output_file = $packagesdir . '/backups/' . strftime('%Y-%m-%d_') . preg_replace('~[$\\\\/:<>|?*"\']~', '', $id); |
3043 | 3215 | $output_ext = '.tar'; |
3044 | 3216 | |
3045 | 3217 | if (file_exists($output_file . $output_ext)) |
3046 | 3218 | { |
3047 | 3219 | $i = 2; |
3048 | - while (file_exists($output_file . '_' . $i . $output_ext)) |
|
3049 | - $i++; |
|
3220 | + while (file_exists($output_file . '_' . $i . $output_ext)) { |
|
3221 | + $i++; |
|
3222 | + } |
|
3050 | 3223 | $output_file = $output_file . '_' . $i . $output_ext; |
3224 | + } else { |
|
3225 | + $output_file .= $output_ext; |
|
3051 | 3226 | } |
3052 | - else |
|
3053 | - $output_file .= $output_ext; |
|
3054 | 3227 | |
3055 | 3228 | @set_time_limit(300); |
3056 | - if (function_exists('apache_reset_timeout')) |
|
3057 | - @apache_reset_timeout(); |
|
3229 | + if (function_exists('apache_reset_timeout')) { |
|
3230 | + @apache_reset_timeout(); |
|
3231 | + } |
|
3058 | 3232 | |
3059 | 3233 | $a = new PharData($output_file); |
3060 | 3234 | $a->buildFromIterator($iterator); |
@@ -3066,8 +3240,7 @@ discard block |
||
3066 | 3240 | */ |
3067 | 3241 | unset($a); |
3068 | 3242 | unlink($output_file); |
3069 | - } |
|
3070 | - catch (Exception $e) |
|
3243 | + } catch (Exception $e) |
|
3071 | 3244 | { |
3072 | 3245 | log_error($e->getMessage(), 'backup'); |
3073 | 3246 | |
@@ -3099,32 +3272,35 @@ discard block |
||
3099 | 3272 | preg_match('~^(http|ftp)(s)?://([^/:]+)(:(\d+))?(.+)$~', $url, $match); |
3100 | 3273 | |
3101 | 3274 | // An FTP url. We should try connecting and RETRieving it... |
3102 | - if (empty($match[1])) |
|
3103 | - return false; |
|
3104 | - elseif ($match[1] == 'ftp') |
|
3275 | + if (empty($match[1])) { |
|
3276 | + return false; |
|
3277 | + } elseif ($match[1] == 'ftp') |
|
3105 | 3278 | { |
3106 | 3279 | // Include the file containing the ftp_connection class. |
3107 | 3280 | require_once($sourcedir . '/Class-Package.php'); |
3108 | 3281 | |
3109 | 3282 | // Establish a connection and attempt to enable passive mode. |
3110 | 3283 | $ftp = new ftp_connection(($match[2] ? 'ssl://' : '') . $match[3], empty($match[5]) ? 21 : $match[5], 'anonymous', $webmaster_email); |
3111 | - if ($ftp->error !== false || !$ftp->passive()) |
|
3112 | - return false; |
|
3284 | + if ($ftp->error !== false || !$ftp->passive()) { |
|
3285 | + return false; |
|
3286 | + } |
|
3113 | 3287 | |
3114 | 3288 | // I want that one *points*! |
3115 | 3289 | fwrite($ftp->connection, 'RETR ' . $match[6] . "\r\n"); |
3116 | 3290 | |
3117 | 3291 | // Since passive mode worked (or we would have returned already!) open the connection. |
3118 | 3292 | $fp = @fsockopen($ftp->pasv['ip'], $ftp->pasv['port'], $err, $err, 5); |
3119 | - if (!$fp) |
|
3120 | - return false; |
|
3293 | + if (!$fp) { |
|
3294 | + return false; |
|
3295 | + } |
|
3121 | 3296 | |
3122 | 3297 | // The server should now say something in acknowledgement. |
3123 | 3298 | $ftp->check_response(150); |
3124 | 3299 | |
3125 | 3300 | $data = ''; |
3126 | - while (!feof($fp)) |
|
3127 | - $data .= fread($fp, 4096); |
|
3301 | + while (!feof($fp)) { |
|
3302 | + $data .= fread($fp, 4096); |
|
3303 | + } |
|
3128 | 3304 | fclose($fp); |
3129 | 3305 | |
3130 | 3306 | // All done, right? Good. |
@@ -3141,22 +3317,25 @@ discard block |
||
3141 | 3317 | $fetch_data->get_url_data($url, $post_data); |
3142 | 3318 | |
3143 | 3319 | // no errors and a 200 result, then we have a good dataset, well we at least have data ;) |
3144 | - if ($fetch_data->result('code') == 200 && !$fetch_data->result('error')) |
|
3145 | - $data = $fetch_data->result('body'); |
|
3146 | - else |
|
3147 | - return false; |
|
3320 | + if ($fetch_data->result('code') == 200 && !$fetch_data->result('error')) { |
|
3321 | + $data = $fetch_data->result('body'); |
|
3322 | + } else { |
|
3323 | + return false; |
|
3324 | + } |
|
3148 | 3325 | } |
3149 | 3326 | // This is more likely; a standard HTTP URL. |
3150 | 3327 | elseif (isset($match[1]) && $match[1] == 'http') |
3151 | 3328 | { |
3152 | - if ($keep_alive && $match[3] == $keep_alive_dom) |
|
3153 | - $fp = $keep_alive_fp; |
|
3329 | + if ($keep_alive && $match[3] == $keep_alive_dom) { |
|
3330 | + $fp = $keep_alive_fp; |
|
3331 | + } |
|
3154 | 3332 | if (empty($fp)) |
3155 | 3333 | { |
3156 | 3334 | // Open the socket on the port we want... |
3157 | 3335 | $fp = @fsockopen(($match[2] ? 'ssl://' : '') . $match[3], empty($match[5]) ? ($match[2] ? 443 : 80) : $match[5], $err, $err, 5); |
3158 | - if (!$fp) |
|
3159 | - return false; |
|
3336 | + if (!$fp) { |
|
3337 | + return false; |
|
3338 | + } |
|
3160 | 3339 | } |
3161 | 3340 | |
3162 | 3341 | if ($keep_alive) |
@@ -3171,20 +3350,21 @@ discard block |
||
3171 | 3350 | fwrite($fp, 'GET ' . ($match[6] !== '/' ? str_replace(' ', '%20', $match[6]) : '') . ' HTTP/1.0' . "\r\n"); |
3172 | 3351 | fwrite($fp, 'Host: ' . $match[3] . (empty($match[5]) ? ($match[2] ? ':443' : '') : ':' . $match[5]) . "\r\n"); |
3173 | 3352 | fwrite($fp, 'User-Agent: PHP/SMF' . "\r\n"); |
3174 | - if ($keep_alive) |
|
3175 | - fwrite($fp, 'Connection: Keep-Alive' . "\r\n\r\n"); |
|
3176 | - else |
|
3177 | - fwrite($fp, 'Connection: close' . "\r\n\r\n"); |
|
3178 | - } |
|
3179 | - else |
|
3353 | + if ($keep_alive) { |
|
3354 | + fwrite($fp, 'Connection: Keep-Alive' . "\r\n\r\n"); |
|
3355 | + } else { |
|
3356 | + fwrite($fp, 'Connection: close' . "\r\n\r\n"); |
|
3357 | + } |
|
3358 | + } else |
|
3180 | 3359 | { |
3181 | 3360 | fwrite($fp, 'POST ' . ($match[6] !== '/' ? $match[6] : '') . ' HTTP/1.0' . "\r\n"); |
3182 | 3361 | fwrite($fp, 'Host: ' . $match[3] . (empty($match[5]) ? ($match[2] ? ':443' : '') : ':' . $match[5]) . "\r\n"); |
3183 | 3362 | fwrite($fp, 'User-Agent: PHP/SMF' . "\r\n"); |
3184 | - if ($keep_alive) |
|
3185 | - fwrite($fp, 'Connection: Keep-Alive' . "\r\n"); |
|
3186 | - else |
|
3187 | - fwrite($fp, 'Connection: close' . "\r\n"); |
|
3363 | + if ($keep_alive) { |
|
3364 | + fwrite($fp, 'Connection: Keep-Alive' . "\r\n"); |
|
3365 | + } else { |
|
3366 | + fwrite($fp, 'Connection: close' . "\r\n"); |
|
3367 | + } |
|
3188 | 3368 | fwrite($fp, 'Content-Type: application/x-www-form-urlencoded' . "\r\n"); |
3189 | 3369 | fwrite($fp, 'Content-Length: ' . strlen($post_data) . "\r\n\r\n"); |
3190 | 3370 | fwrite($fp, $post_data); |
@@ -3197,30 +3377,33 @@ discard block |
||
3197 | 3377 | { |
3198 | 3378 | $header = ''; |
3199 | 3379 | $location = ''; |
3200 | - while (!feof($fp) && trim($header = fgets($fp, 4096)) != '') |
|
3201 | - if (strpos($header, 'Location:') !== false) |
|
3380 | + while (!feof($fp) && trim($header = fgets($fp, 4096)) != '') { |
|
3381 | + if (strpos($header, 'Location:') !== false) |
|
3202 | 3382 | $location = trim(substr($header, strpos($header, ':') + 1)); |
3383 | + } |
|
3203 | 3384 | |
3204 | - if (empty($location)) |
|
3205 | - return false; |
|
3206 | - else |
|
3385 | + if (empty($location)) { |
|
3386 | + return false; |
|
3387 | + } else |
|
3207 | 3388 | { |
3208 | - if (!$keep_alive) |
|
3209 | - fclose($fp); |
|
3389 | + if (!$keep_alive) { |
|
3390 | + fclose($fp); |
|
3391 | + } |
|
3210 | 3392 | return fetch_web_data($location, $post_data, $keep_alive, $redirection_level + 1); |
3211 | 3393 | } |
3212 | 3394 | } |
3213 | 3395 | |
3214 | 3396 | // Make sure we get a 200 OK. |
3215 | - elseif (preg_match('~^HTTP/\S+\s+20[01]~i', $response) === 0) |
|
3216 | - return false; |
|
3397 | + elseif (preg_match('~^HTTP/\S+\s+20[01]~i', $response) === 0) { |
|
3398 | + return false; |
|
3399 | + } |
|
3217 | 3400 | |
3218 | 3401 | // Skip the headers... |
3219 | 3402 | while (!feof($fp) && trim($header = fgets($fp, 4096)) != '') |
3220 | 3403 | { |
3221 | - if (preg_match('~content-length:\s*(\d+)~i', $header, $match) != 0) |
|
3222 | - $content_length = $match[1]; |
|
3223 | - elseif (preg_match('~connection:\s*close~i', $header) != 0) |
|
3404 | + if (preg_match('~content-length:\s*(\d+)~i', $header, $match) != 0) { |
|
3405 | + $content_length = $match[1]; |
|
3406 | + } elseif (preg_match('~connection:\s*close~i', $header) != 0) |
|
3224 | 3407 | { |
3225 | 3408 | $keep_alive_dom = null; |
3226 | 3409 | $keep_alive = false; |
@@ -3232,19 +3415,20 @@ discard block |
||
3232 | 3415 | $data = ''; |
3233 | 3416 | if (isset($content_length)) |
3234 | 3417 | { |
3235 | - while (!feof($fp) && strlen($data) < $content_length) |
|
3236 | - $data .= fread($fp, $content_length - strlen($data)); |
|
3237 | - } |
|
3238 | - else |
|
3418 | + while (!feof($fp) && strlen($data) < $content_length) { |
|
3419 | + $data .= fread($fp, $content_length - strlen($data)); |
|
3420 | + } |
|
3421 | + } else |
|
3239 | 3422 | { |
3240 | - while (!feof($fp)) |
|
3241 | - $data .= fread($fp, 4096); |
|
3423 | + while (!feof($fp)) { |
|
3424 | + $data .= fread($fp, 4096); |
|
3425 | + } |
|
3242 | 3426 | } |
3243 | 3427 | |
3244 | - if (!$keep_alive) |
|
3245 | - fclose($fp); |
|
3246 | - } |
|
3247 | - else |
|
3428 | + if (!$keep_alive) { |
|
3429 | + fclose($fp); |
|
3430 | + } |
|
3431 | + } else |
|
3248 | 3432 | { |
3249 | 3433 | // Umm, this shouldn't happen? |
3250 | 3434 | trigger_error('fetch_web_data(): Bad URL', E_USER_NOTICE); |
@@ -20,8 +20,9 @@ discard block |
||
20 | 20 | // ><html dir="ltr"><head><title>Error!</title></head><body>Sorry, this installer requires PHP!<div style="display: none;"> |
21 | 21 | |
22 | 22 | // Let's pull in useful classes |
23 | -if (!defined('SMF')) |
|
23 | +if (!defined('SMF')) { |
|
24 | 24 | define('SMF', 1); |
25 | +} |
|
25 | 26 | |
26 | 27 | require_once('Sources/Class-Package.php'); |
27 | 28 | |
@@ -63,10 +64,11 @@ discard block |
||
63 | 64 | |
64 | 65 | list ($charcode) = pg_fetch_row($request); |
65 | 66 | |
66 | - if ($charcode == 'UTF8') |
|
67 | - return true; |
|
68 | - else |
|
69 | - return false; |
|
67 | + if ($charcode == 'UTF8') { |
|
68 | + return true; |
|
69 | + } else { |
|
70 | + return false; |
|
71 | + } |
|
70 | 72 | }, |
71 | 73 | 'utf8_version' => '8.0', |
72 | 74 | 'utf8_version_check' => '$request = pg_query(\'SELECT version()\'); list ($version) = pg_fetch_row($request); list($pgl, $version) = explode(" ", $version); return $version;', |
@@ -76,12 +78,14 @@ discard block |
||
76 | 78 | $value = preg_replace('~[^A-Za-z0-9_\$]~', '', $value); |
77 | 79 | |
78 | 80 | // Is it reserved? |
79 | - if ($value == 'pg_') |
|
80 | - return $txt['error_db_prefix_reserved']; |
|
81 | + if ($value == 'pg_') { |
|
82 | + return $txt['error_db_prefix_reserved']; |
|
83 | + } |
|
81 | 84 | |
82 | 85 | // Is the prefix numeric? |
83 | - if (preg_match('~^\d~', $value)) |
|
84 | - return $txt['error_db_prefix_numeric']; |
|
86 | + if (preg_match('~^\d~', $value)) { |
|
87 | + return $txt['error_db_prefix_numeric']; |
|
88 | + } |
|
85 | 89 | |
86 | 90 | return true; |
87 | 91 | }, |
@@ -128,10 +132,11 @@ discard block |
||
128 | 132 | $incontext['skip'] = false; |
129 | 133 | |
130 | 134 | // Call the step and if it returns false that means pause! |
131 | - if (function_exists($step[2]) && $step[2]() === false) |
|
132 | - break; |
|
133 | - elseif (function_exists($step[2])) |
|
134 | - $incontext['current_step']++; |
|
135 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
136 | + break; |
|
137 | + } elseif (function_exists($step[2])) { |
|
138 | + $incontext['current_step']++; |
|
139 | + } |
|
135 | 140 | |
136 | 141 | // No warnings pass on. |
137 | 142 | $incontext['warning'] = ''; |
@@ -147,8 +152,9 @@ discard block |
||
147 | 152 | global $databases; |
148 | 153 | |
149 | 154 | // Just so people using older versions of PHP aren't left in the cold. |
150 | - if (!isset($_SERVER['PHP_SELF'])) |
|
151 | - $_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php'; |
|
155 | + if (!isset($_SERVER['PHP_SELF'])) { |
|
156 | + $_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php'; |
|
157 | + } |
|
152 | 158 | |
153 | 159 | // Enable error reporting. |
154 | 160 | error_reporting(E_ALL); |
@@ -164,21 +170,23 @@ discard block |
||
164 | 170 | { |
165 | 171 | ob_start(); |
166 | 172 | |
167 | - if (ini_get('session.save_handler') == 'user') |
|
168 | - @ini_set('session.save_handler', 'files'); |
|
169 | - if (function_exists('session_start')) |
|
170 | - @session_start(); |
|
171 | - } |
|
172 | - else |
|
173 | + if (ini_get('session.save_handler') == 'user') { |
|
174 | + @ini_set('session.save_handler', 'files'); |
|
175 | + } |
|
176 | + if (function_exists('session_start')) { |
|
177 | + @session_start(); |
|
178 | + } |
|
179 | + } else |
|
173 | 180 | { |
174 | 181 | ob_start('ob_gzhandler'); |
175 | 182 | |
176 | - if (ini_get('session.save_handler') == 'user') |
|
177 | - @ini_set('session.save_handler', 'files'); |
|
183 | + if (ini_get('session.save_handler') == 'user') { |
|
184 | + @ini_set('session.save_handler', 'files'); |
|
185 | + } |
|
178 | 186 | session_start(); |
179 | 187 | |
180 | - if (!headers_sent()) |
|
181 | - echo '<!DOCTYPE html> |
|
188 | + if (!headers_sent()) { |
|
189 | + echo '<!DOCTYPE html> |
|
182 | 190 | <html> |
183 | 191 | <head> |
184 | 192 | <title>', htmlspecialchars($_GET['pass_string']), '</title> |
@@ -187,14 +195,16 @@ discard block |
||
187 | 195 | <strong>', htmlspecialchars($_GET['pass_string']), '</strong> |
188 | 196 | </body> |
189 | 197 | </html>'; |
198 | + } |
|
190 | 199 | exit; |
191 | 200 | } |
192 | 201 | |
193 | 202 | // Add slashes, as long as they aren't already being added. |
194 | - if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) |
|
195 | - foreach ($_POST as $k => $v) |
|
203 | + if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) { |
|
204 | + foreach ($_POST as $k => $v) |
|
196 | 205 | if (strpos($k, 'password') === false && strpos($k, 'db_passwd') === false) |
197 | 206 | $_POST[$k] = addslashes($v); |
207 | + } |
|
198 | 208 | |
199 | 209 | // This is really quite simple; if ?delete is on the URL, delete the installer... |
200 | 210 | if (isset($_GET['delete'])) |
@@ -215,8 +225,7 @@ discard block |
||
215 | 225 | $ftp->close(); |
216 | 226 | |
217 | 227 | unset($_SESSION['installer_temp_ftp']); |
218 | - } |
|
219 | - else |
|
228 | + } else |
|
220 | 229 | { |
221 | 230 | @unlink(__FILE__); |
222 | 231 | |
@@ -237,10 +246,11 @@ discard block |
||
237 | 246 | { |
238 | 247 | // Get PHP's default timezone, if set |
239 | 248 | $ini_tz = ini_get('date.timezone'); |
240 | - if (!empty($ini_tz)) |
|
241 | - $timezone_id = $ini_tz; |
|
242 | - else |
|
243 | - $timezone_id = ''; |
|
249 | + if (!empty($ini_tz)) { |
|
250 | + $timezone_id = $ini_tz; |
|
251 | + } else { |
|
252 | + $timezone_id = ''; |
|
253 | + } |
|
244 | 254 | |
245 | 255 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
246 | 256 | if (!in_array($timezone_id, timezone_identifiers_list())) |
@@ -270,8 +280,9 @@ discard block |
||
270 | 280 | $dir = dir(dirname(__FILE__) . '/Themes/default/languages'); |
271 | 281 | while ($entry = $dir->read()) |
272 | 282 | { |
273 | - if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') |
|
274 | - $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
283 | + if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') { |
|
284 | + $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
285 | + } |
|
275 | 286 | } |
276 | 287 | $dir->close(); |
277 | 288 | } |
@@ -306,10 +317,11 @@ discard block |
||
306 | 317 | } |
307 | 318 | |
308 | 319 | // Override the language file? |
309 | - if (isset($_GET['lang_file'])) |
|
310 | - $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
311 | - elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) |
|
312 | - $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
320 | + if (isset($_GET['lang_file'])) { |
|
321 | + $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
322 | + } elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) { |
|
323 | + $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
324 | + } |
|
313 | 325 | |
314 | 326 | // Make sure it exists, if it doesn't reset it. |
315 | 327 | if (!isset($_SESSION['installer_temp_lang']) || preg_match('~[^\\w_\\-.]~', $_SESSION['installer_temp_lang']) === 1 || !file_exists(dirname(__FILE__) . '/Themes/default/languages/' . $_SESSION['installer_temp_lang'])) |
@@ -318,8 +330,9 @@ discard block |
||
318 | 330 | list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
319 | 331 | |
320 | 332 | // If we have english and some other language, use the other language. We Americans hate english :P. |
321 | - if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) |
|
322 | - list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
333 | + if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) { |
|
334 | + list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
335 | + } |
|
323 | 336 | } |
324 | 337 | |
325 | 338 | // And now include the actual language file itself. |
@@ -332,15 +345,18 @@ discard block |
||
332 | 345 | global $db_prefix, $db_connection, $sourcedir, $smcFunc, $modSettings; |
333 | 346 | global $db_server, $db_passwd, $db_type, $db_name, $db_user, $db_persist; |
334 | 347 | |
335 | - if (empty($sourcedir)) |
|
336 | - $sourcedir = dirname(__FILE__) . '/Sources'; |
|
348 | + if (empty($sourcedir)) { |
|
349 | + $sourcedir = dirname(__FILE__) . '/Sources'; |
|
350 | + } |
|
337 | 351 | |
338 | 352 | // Need this to check whether we need the database password. |
339 | 353 | require(dirname(__FILE__) . '/Settings.php'); |
340 | - if (!defined('SMF')) |
|
341 | - define('SMF', 1); |
|
342 | - if (empty($smcFunc)) |
|
343 | - $smcFunc = array(); |
|
354 | + if (!defined('SMF')) { |
|
355 | + define('SMF', 1); |
|
356 | + } |
|
357 | + if (empty($smcFunc)) { |
|
358 | + $smcFunc = array(); |
|
359 | + } |
|
344 | 360 | |
345 | 361 | $modSettings['disableQueryCheck'] = true; |
346 | 362 | |
@@ -348,8 +364,9 @@ discard block |
||
348 | 364 | if (!$db_connection) |
349 | 365 | { |
350 | 366 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
351 | - if (version_compare(PHP_VERSION, '5', '<')) |
|
352 | - require_once($sourcedir . '/Subs-Compat.php'); |
|
367 | + if (version_compare(PHP_VERSION, '5', '<')) { |
|
368 | + require_once($sourcedir . '/Subs-Compat.php'); |
|
369 | + } |
|
353 | 370 | |
354 | 371 | $db_options = array('persist' => $db_persist); |
355 | 372 | $port = ''; |
@@ -360,19 +377,20 @@ discard block |
||
360 | 377 | if ($db_type == 'mysql') |
361 | 378 | { |
362 | 379 | $port = ((int) $_POST['db_port'] == ini_get($db_type . 'default_port')) ? '' : (int) $_POST['db_port']; |
363 | - } |
|
364 | - elseif ($db_type == 'postgresql') |
|
380 | + } elseif ($db_type == 'postgresql') |
|
365 | 381 | { |
366 | 382 | // PostgreSQL doesn't have a default port setting in php.ini, so just check against the default |
367 | 383 | $port = ((int) $_POST['db_port'] == 5432) ? '' : (int) $_POST['db_port']; |
368 | 384 | } |
369 | 385 | } |
370 | 386 | |
371 | - if (!empty($port)) |
|
372 | - $db_options['port'] = $port; |
|
387 | + if (!empty($port)) { |
|
388 | + $db_options['port'] = $port; |
|
389 | + } |
|
373 | 390 | |
374 | - if (!$db_connection) |
|
375 | - $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options); |
|
391 | + if (!$db_connection) { |
|
392 | + $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options); |
|
393 | + } |
|
376 | 394 | } |
377 | 395 | } |
378 | 396 | |
@@ -400,8 +418,9 @@ discard block |
||
400 | 418 | // @todo REMOVE THIS!! |
401 | 419 | else |
402 | 420 | { |
403 | - if (function_exists('doStep' . $_GET['step'])) |
|
404 | - call_user_func('doStep' . $_GET['step']); |
|
421 | + if (function_exists('doStep' . $_GET['step'])) { |
|
422 | + call_user_func('doStep' . $_GET['step']); |
|
423 | + } |
|
405 | 424 | } |
406 | 425 | // Show the footer. |
407 | 426 | template_install_below(); |
@@ -419,8 +438,9 @@ discard block |
||
419 | 438 | $incontext['sub_template'] = 'welcome_message'; |
420 | 439 | |
421 | 440 | // Done the submission? |
422 | - if (isset($_POST['contbutt'])) |
|
423 | - return true; |
|
441 | + if (isset($_POST['contbutt'])) { |
|
442 | + return true; |
|
443 | + } |
|
424 | 444 | |
425 | 445 | // See if we think they have already installed it? |
426 | 446 | if (is_readable(dirname(__FILE__) . '/Settings.php')) |
@@ -428,14 +448,17 @@ discard block |
||
428 | 448 | $probably_installed = 0; |
429 | 449 | foreach (file(dirname(__FILE__) . '/Settings.php') as $line) |
430 | 450 | { |
431 | - if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) |
|
432 | - $probably_installed++; |
|
433 | - if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) |
|
434 | - $probably_installed++; |
|
451 | + if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) { |
|
452 | + $probably_installed++; |
|
453 | + } |
|
454 | + if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) { |
|
455 | + $probably_installed++; |
|
456 | + } |
|
435 | 457 | } |
436 | 458 | |
437 | - if ($probably_installed == 2) |
|
438 | - $incontext['warning'] = $txt['error_already_installed']; |
|
459 | + if ($probably_installed == 2) { |
|
460 | + $incontext['warning'] = $txt['error_already_installed']; |
|
461 | + } |
|
439 | 462 | } |
440 | 463 | |
441 | 464 | // Is some database support even compiled in? |
@@ -450,36 +473,43 @@ discard block |
||
450 | 473 | $databases[$key]['supported'] = false; |
451 | 474 | $notFoundSQLFile = true; |
452 | 475 | $txt['error_db_script_missing'] = sprintf($txt['error_db_script_missing'], 'install_' . $GLOBALS['db_script_version'] . '_' . $type . '.sql'); |
476 | + } else { |
|
477 | + $incontext['supported_databases'][] = $db; |
|
453 | 478 | } |
454 | - else |
|
455 | - $incontext['supported_databases'][] = $db; |
|
456 | 479 | } |
457 | 480 | } |
458 | 481 | |
459 | 482 | // Check the PHP version. |
460 | - if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>'))) |
|
461 | - $error = 'error_php_too_low'; |
|
483 | + if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>'))) { |
|
484 | + $error = 'error_php_too_low'; |
|
485 | + } |
|
462 | 486 | // Make sure we have a supported database |
463 | - elseif (empty($incontext['supported_databases'])) |
|
464 | - $error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing'; |
|
487 | + elseif (empty($incontext['supported_databases'])) { |
|
488 | + $error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing'; |
|
489 | + } |
|
465 | 490 | // How about session support? Some crazy sysadmin remove it? |
466 | - elseif (!function_exists('session_start')) |
|
467 | - $error = 'error_session_missing'; |
|
491 | + elseif (!function_exists('session_start')) { |
|
492 | + $error = 'error_session_missing'; |
|
493 | + } |
|
468 | 494 | // Make sure they uploaded all the files. |
469 | - elseif (!file_exists(dirname(__FILE__) . '/index.php')) |
|
470 | - $error = 'error_missing_files'; |
|
495 | + elseif (!file_exists(dirname(__FILE__) . '/index.php')) { |
|
496 | + $error = 'error_missing_files'; |
|
497 | + } |
|
471 | 498 | // Very simple check on the session.save_path for Windows. |
472 | 499 | // @todo Move this down later if they don't use database-driven sessions? |
473 | - elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') |
|
474 | - $error = 'error_session_save_path'; |
|
500 | + elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') { |
|
501 | + $error = 'error_session_save_path'; |
|
502 | + } |
|
475 | 503 | |
476 | 504 | // Since each of the three messages would look the same, anyway... |
477 | - if (isset($error)) |
|
478 | - $incontext['error'] = $txt[$error]; |
|
505 | + if (isset($error)) { |
|
506 | + $incontext['error'] = $txt[$error]; |
|
507 | + } |
|
479 | 508 | |
480 | 509 | // Mod_security blocks everything that smells funny. Let SMF handle security. |
481 | - if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) |
|
482 | - $incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again']; |
|
510 | + if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) { |
|
511 | + $incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again']; |
|
512 | + } |
|
483 | 513 | |
484 | 514 | return false; |
485 | 515 | } |
@@ -505,12 +535,14 @@ discard block |
||
505 | 535 | 'db_last_error.php', |
506 | 536 | ); |
507 | 537 | |
508 | - foreach ($incontext['detected_languages'] as $lang => $temp) |
|
509 | - $extra_files[] = 'Themes/default/languages/' . $lang; |
|
538 | + foreach ($incontext['detected_languages'] as $lang => $temp) { |
|
539 | + $extra_files[] = 'Themes/default/languages/' . $lang; |
|
540 | + } |
|
510 | 541 | |
511 | 542 | // With mod_security installed, we could attempt to fix it with .htaccess. |
512 | - if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) |
|
513 | - $writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.'; |
|
543 | + if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) { |
|
544 | + $writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.'; |
|
545 | + } |
|
514 | 546 | |
515 | 547 | $failed_files = array(); |
516 | 548 | |
@@ -526,12 +558,14 @@ discard block |
||
526 | 558 | @chmod(dirname(__FILE__) . '/' . $file, 0755); |
527 | 559 | |
528 | 560 | // Well, 755 hopefully worked... if not, try 777. |
529 | - if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) |
|
530 | - $failed_files[] = $file; |
|
561 | + if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) { |
|
562 | + $failed_files[] = $file; |
|
563 | + } |
|
531 | 564 | } |
532 | 565 | } |
533 | - foreach ($extra_files as $file) |
|
534 | - @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
566 | + foreach ($extra_files as $file) { |
|
567 | + @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
568 | + } |
|
535 | 569 | } |
536 | 570 | // Windows is trickier. Let's try opening for r+... |
537 | 571 | else |
@@ -541,30 +575,35 @@ discard block |
||
541 | 575 | foreach ($writable_files as $file) |
542 | 576 | { |
543 | 577 | // Folders can't be opened for write... but the index.php in them can ;) |
544 | - if (is_dir(dirname(__FILE__) . '/' . $file)) |
|
545 | - $file .= '/index.php'; |
|
578 | + if (is_dir(dirname(__FILE__) . '/' . $file)) { |
|
579 | + $file .= '/index.php'; |
|
580 | + } |
|
546 | 581 | |
547 | 582 | // Funny enough, chmod actually does do something on windows - it removes the read only attribute. |
548 | 583 | @chmod(dirname(__FILE__) . '/' . $file, 0777); |
549 | 584 | $fp = @fopen(dirname(__FILE__) . '/' . $file, 'r+'); |
550 | 585 | |
551 | 586 | // Hmm, okay, try just for write in that case... |
552 | - if (!is_resource($fp)) |
|
553 | - $fp = @fopen(dirname(__FILE__) . '/' . $file, 'w'); |
|
587 | + if (!is_resource($fp)) { |
|
588 | + $fp = @fopen(dirname(__FILE__) . '/' . $file, 'w'); |
|
589 | + } |
|
554 | 590 | |
555 | - if (!is_resource($fp)) |
|
556 | - $failed_files[] = $file; |
|
591 | + if (!is_resource($fp)) { |
|
592 | + $failed_files[] = $file; |
|
593 | + } |
|
557 | 594 | |
558 | 595 | @fclose($fp); |
559 | 596 | } |
560 | - foreach ($extra_files as $file) |
|
561 | - @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
597 | + foreach ($extra_files as $file) { |
|
598 | + @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
599 | + } |
|
562 | 600 | } |
563 | 601 | |
564 | 602 | $failure = count($failed_files) >= 1; |
565 | 603 | |
566 | - if (!isset($_SERVER)) |
|
567 | - return !$failure; |
|
604 | + if (!isset($_SERVER)) { |
|
605 | + return !$failure; |
|
606 | + } |
|
568 | 607 | |
569 | 608 | // Put the list into context. |
570 | 609 | $incontext['failed_files'] = $failed_files; |
@@ -612,19 +651,23 @@ discard block |
||
612 | 651 | |
613 | 652 | if (!isset($ftp) || $ftp->error !== false) |
614 | 653 | { |
615 | - if (!isset($ftp)) |
|
616 | - $ftp = new ftp_connection(null); |
|
654 | + if (!isset($ftp)) { |
|
655 | + $ftp = new ftp_connection(null); |
|
656 | + } |
|
617 | 657 | // Save the error so we can mess with listing... |
618 | - elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) |
|
619 | - $incontext['ftp_errors'][] = $ftp->last_message; |
|
658 | + elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) { |
|
659 | + $incontext['ftp_errors'][] = $ftp->last_message; |
|
660 | + } |
|
620 | 661 | |
621 | 662 | list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__)); |
622 | 663 | |
623 | - if (empty($_POST['ftp_path']) && $found_path) |
|
624 | - $_POST['ftp_path'] = $detect_path; |
|
664 | + if (empty($_POST['ftp_path']) && $found_path) { |
|
665 | + $_POST['ftp_path'] = $detect_path; |
|
666 | + } |
|
625 | 667 | |
626 | - if (!isset($_POST['ftp_username'])) |
|
627 | - $_POST['ftp_username'] = $username; |
|
668 | + if (!isset($_POST['ftp_username'])) { |
|
669 | + $_POST['ftp_username'] = $username; |
|
670 | + } |
|
628 | 671 | |
629 | 672 | // Set the username etc, into context. |
630 | 673 | $incontext['ftp'] = array( |
@@ -636,8 +679,7 @@ discard block |
||
636 | 679 | ); |
637 | 680 | |
638 | 681 | return false; |
639 | - } |
|
640 | - else |
|
682 | + } else |
|
641 | 683 | { |
642 | 684 | $_SESSION['installer_temp_ftp'] = array( |
643 | 685 | 'server' => $_POST['ftp_server'], |
@@ -651,10 +693,12 @@ discard block |
||
651 | 693 | |
652 | 694 | foreach ($failed_files as $file) |
653 | 695 | { |
654 | - if (!is_writable(dirname(__FILE__) . '/' . $file)) |
|
655 | - $ftp->chmod($file, 0755); |
|
656 | - if (!is_writable(dirname(__FILE__) . '/' . $file)) |
|
657 | - $ftp->chmod($file, 0777); |
|
696 | + if (!is_writable(dirname(__FILE__) . '/' . $file)) { |
|
697 | + $ftp->chmod($file, 0755); |
|
698 | + } |
|
699 | + if (!is_writable(dirname(__FILE__) . '/' . $file)) { |
|
700 | + $ftp->chmod($file, 0777); |
|
701 | + } |
|
658 | 702 | if (!is_writable(dirname(__FILE__) . '/' . $file)) |
659 | 703 | { |
660 | 704 | $failed_files_updated[] = $file; |
@@ -710,15 +754,17 @@ discard block |
||
710 | 754 | |
711 | 755 | if (!$foundOne) |
712 | 756 | { |
713 | - if (isset($db['default_host'])) |
|
714 | - $incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost'; |
|
757 | + if (isset($db['default_host'])) { |
|
758 | + $incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost'; |
|
759 | + } |
|
715 | 760 | if (isset($db['default_user'])) |
716 | 761 | { |
717 | 762 | $incontext['db']['user'] = ini_get($db['default_user']); |
718 | 763 | $incontext['db']['name'] = ini_get($db['default_user']); |
719 | 764 | } |
720 | - if (isset($db['default_password'])) |
|
721 | - $incontext['db']['pass'] = ini_get($db['default_password']); |
|
765 | + if (isset($db['default_password'])) { |
|
766 | + $incontext['db']['pass'] = ini_get($db['default_password']); |
|
767 | + } |
|
722 | 768 | |
723 | 769 | // For simplicity and less confusion, leave the port blank by default |
724 | 770 | $incontext['db']['port'] = ''; |
@@ -737,10 +783,10 @@ discard block |
||
737 | 783 | $incontext['db']['server'] = $_POST['db_server']; |
738 | 784 | $incontext['db']['prefix'] = $_POST['db_prefix']; |
739 | 785 | |
740 | - if (!empty($_POST['db_port'])) |
|
741 | - $incontext['db']['port'] = $_POST['db_port']; |
|
742 | - } |
|
743 | - else |
|
786 | + if (!empty($_POST['db_port'])) { |
|
787 | + $incontext['db']['port'] = $_POST['db_port']; |
|
788 | + } |
|
789 | + } else |
|
744 | 790 | { |
745 | 791 | $incontext['db']['prefix'] = 'smf_'; |
746 | 792 | } |
@@ -776,10 +822,11 @@ discard block |
||
776 | 822 | if (!empty($_POST['db_port'])) |
777 | 823 | { |
778 | 824 | // For MySQL, we can get the "default port" from PHP. PostgreSQL has no such option though. |
779 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) |
|
780 | - $vars['db_port'] = (int) $_POST['db_port']; |
|
781 | - elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) |
|
782 | - $vars['db_port'] = (int) $_POST['db_port']; |
|
825 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) { |
|
826 | + $vars['db_port'] = (int) $_POST['db_port']; |
|
827 | + } elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) { |
|
828 | + $vars['db_port'] = (int) $_POST['db_port']; |
|
829 | + } |
|
783 | 830 | } |
784 | 831 | |
785 | 832 | // God I hope it saved! |
@@ -792,8 +839,9 @@ discard block |
||
792 | 839 | // Make sure it works. |
793 | 840 | require(dirname(__FILE__) . '/Settings.php'); |
794 | 841 | |
795 | - if (empty($sourcedir)) |
|
796 | - $sourcedir = dirname(__FILE__) . '/Sources'; |
|
842 | + if (empty($sourcedir)) { |
|
843 | + $sourcedir = dirname(__FILE__) . '/Sources'; |
|
844 | + } |
|
797 | 845 | |
798 | 846 | // Better find the database file! |
799 | 847 | if (!file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
@@ -803,18 +851,21 @@ discard block |
||
803 | 851 | } |
804 | 852 | |
805 | 853 | // Now include it for database functions! |
806 | - if (!defined('SMF')) |
|
807 | - define('SMF', 1); |
|
854 | + if (!defined('SMF')) { |
|
855 | + define('SMF', 1); |
|
856 | + } |
|
808 | 857 | |
809 | 858 | $modSettings['disableQueryCheck'] = true; |
810 | - if (empty($smcFunc)) |
|
811 | - $smcFunc = array(); |
|
859 | + if (empty($smcFunc)) { |
|
860 | + $smcFunc = array(); |
|
861 | + } |
|
812 | 862 | |
813 | 863 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
814 | 864 | |
815 | 865 | // What - running PHP4? The shame! |
816 | - if (version_compare(PHP_VERSION, '5', '<')) |
|
817 | - require_once($sourcedir . '/Subs-Compat.php'); |
|
866 | + if (version_compare(PHP_VERSION, '5', '<')) { |
|
867 | + require_once($sourcedir . '/Subs-Compat.php'); |
|
868 | + } |
|
818 | 869 | |
819 | 870 | // Attempt a connection. |
820 | 871 | $needsDB = !empty($databases[$db_type]['always_has_db']); |
@@ -902,12 +953,14 @@ discard block |
||
902 | 953 | $incontext['page_title'] = $txt['install_settings']; |
903 | 954 | |
904 | 955 | // Let's see if we got the database type correct. |
905 | - if (isset($_POST['db_type'], $databases[$_POST['db_type']])) |
|
906 | - $db_type = $_POST['db_type']; |
|
956 | + if (isset($_POST['db_type'], $databases[$_POST['db_type']])) { |
|
957 | + $db_type = $_POST['db_type']; |
|
958 | + } |
|
907 | 959 | |
908 | 960 | // Else we'd better be able to get the connection. |
909 | - else |
|
910 | - load_database(); |
|
961 | + else { |
|
962 | + load_database(); |
|
963 | + } |
|
911 | 964 | |
912 | 965 | $db_type = isset($_POST['db_type']) ? $_POST['db_type'] : $db_type; |
913 | 966 | |
@@ -927,12 +980,14 @@ discard block |
||
927 | 980 | // Submitting? |
928 | 981 | if (isset($_POST['boardurl'])) |
929 | 982 | { |
930 | - if (substr($_POST['boardurl'], -10) == '/index.php') |
|
931 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
932 | - elseif (substr($_POST['boardurl'], -1) == '/') |
|
933 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
934 | - if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') |
|
935 | - $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
983 | + if (substr($_POST['boardurl'], -10) == '/index.php') { |
|
984 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
985 | + } elseif (substr($_POST['boardurl'], -1) == '/') { |
|
986 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
987 | + } |
|
988 | + if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') { |
|
989 | + $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
990 | + } |
|
936 | 991 | |
937 | 992 | // Save these variables. |
938 | 993 | $vars = array( |
@@ -969,10 +1024,10 @@ discard block |
||
969 | 1024 | { |
970 | 1025 | $incontext['error'] = sprintf($txt['error_utf8_version'], $databases[$db_type]['utf8_version']); |
971 | 1026 | return false; |
972 | - } |
|
973 | - else |
|
974 | - // Set the character set here. |
|
1027 | + } else { |
|
1028 | + // Set the character set here. |
|
975 | 1029 | updateSettingsFile(array('db_character_set' => 'utf8')); |
1030 | + } |
|
976 | 1031 | } |
977 | 1032 | |
978 | 1033 | // Good, skip on. |
@@ -992,8 +1047,9 @@ discard block |
||
992 | 1047 | $incontext['continue'] = 1; |
993 | 1048 | |
994 | 1049 | // Already done? |
995 | - if (isset($_POST['pop_done'])) |
|
996 | - return true; |
|
1050 | + if (isset($_POST['pop_done'])) { |
|
1051 | + return true; |
|
1052 | + } |
|
997 | 1053 | |
998 | 1054 | // Reload settings. |
999 | 1055 | require(dirname(__FILE__) . '/Settings.php'); |
@@ -1011,8 +1067,9 @@ discard block |
||
1011 | 1067 | $modSettings = array(); |
1012 | 1068 | if ($result !== false) |
1013 | 1069 | { |
1014 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
1015 | - $modSettings[$row['variable']] = $row['value']; |
|
1070 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
1071 | + $modSettings[$row['variable']] = $row['value']; |
|
1072 | + } |
|
1016 | 1073 | $smcFunc['db_free_result']($result); |
1017 | 1074 | |
1018 | 1075 | // Do they match? If so, this is just a refresh so charge on! |
@@ -1025,20 +1082,22 @@ discard block |
||
1025 | 1082 | $modSettings['disableQueryCheck'] = true; |
1026 | 1083 | |
1027 | 1084 | // If doing UTF8, select it. PostgreSQL requires passing it as a string... |
1028 | - if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) |
|
1029 | - $smcFunc['db_query']('', ' |
|
1085 | + if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) { |
|
1086 | + $smcFunc['db_query']('', ' |
|
1030 | 1087 | SET NAMES {string:utf8}', |
1031 | 1088 | array( |
1032 | 1089 | 'db_error_skip' => true, |
1033 | 1090 | 'utf8' => 'utf8', |
1034 | 1091 | ) |
1035 | 1092 | ); |
1093 | + } |
|
1036 | 1094 | |
1037 | 1095 | // Windows likes to leave the trailing slash, which yields to C:\path\to\SMF\/attachments... |
1038 | - if (substr(__DIR__, -1) == '\\') |
|
1039 | - $attachdir = __DIR__ . 'attachments'; |
|
1040 | - else |
|
1041 | - $attachdir = __DIR__ . '/attachments'; |
|
1096 | + if (substr(__DIR__, -1) == '\\') { |
|
1097 | + $attachdir = __DIR__ . 'attachments'; |
|
1098 | + } else { |
|
1099 | + $attachdir = __DIR__ . '/attachments'; |
|
1100 | + } |
|
1042 | 1101 | |
1043 | 1102 | $replaces = array( |
1044 | 1103 | '{$db_prefix}' => $db_prefix, |
@@ -1055,8 +1114,9 @@ discard block |
||
1055 | 1114 | |
1056 | 1115 | foreach ($txt as $key => $value) |
1057 | 1116 | { |
1058 | - if (substr($key, 0, 8) == 'default_') |
|
1059 | - $replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value); |
|
1117 | + if (substr($key, 0, 8) == 'default_') { |
|
1118 | + $replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value); |
|
1119 | + } |
|
1060 | 1120 | } |
1061 | 1121 | $replaces['{$default_reserved_names}'] = strtr($replaces['{$default_reserved_names}'], array('\\\\n' => '\\n')); |
1062 | 1122 | |
@@ -1071,8 +1131,9 @@ discard block |
||
1071 | 1131 | |
1072 | 1132 | while ($row = $smcFunc['db_fetch_assoc']($get_engines)) |
1073 | 1133 | { |
1074 | - if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') |
|
1075 | - $engines[] = $row['Engine']; |
|
1134 | + if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') { |
|
1135 | + $engines[] = $row['Engine']; |
|
1136 | + } |
|
1076 | 1137 | } |
1077 | 1138 | |
1078 | 1139 | // Done with this now |
@@ -1096,8 +1157,7 @@ discard block |
||
1096 | 1157 | $replaces['START TRANSACTION;'] = ''; |
1097 | 1158 | $replaces['COMMIT;'] = ''; |
1098 | 1159 | } |
1099 | - } |
|
1100 | - else |
|
1160 | + } else |
|
1101 | 1161 | { |
1102 | 1162 | $has_innodb = false; |
1103 | 1163 | } |
@@ -1119,21 +1179,24 @@ discard block |
||
1119 | 1179 | foreach ($sql_lines as $count => $line) |
1120 | 1180 | { |
1121 | 1181 | // No comments allowed! |
1122 | - if (substr(trim($line), 0, 1) != '#') |
|
1123 | - $current_statement .= "\n" . rtrim($line); |
|
1182 | + if (substr(trim($line), 0, 1) != '#') { |
|
1183 | + $current_statement .= "\n" . rtrim($line); |
|
1184 | + } |
|
1124 | 1185 | |
1125 | 1186 | // Is this the end of the query string? |
1126 | - if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) |
|
1127 | - continue; |
|
1187 | + if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) { |
|
1188 | + continue; |
|
1189 | + } |
|
1128 | 1190 | |
1129 | 1191 | // Does this table already exist? If so, don't insert more data into it! |
1130 | 1192 | if (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) != 0 && in_array($match[1], $exists)) |
1131 | 1193 | { |
1132 | 1194 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
1133 | - if (!empty($matches[0])) |
|
1134 | - $incontext['sql_results']['insert_dups'] += count($matches[0]); |
|
1135 | - else |
|
1136 | - $incontext['sql_results']['insert_dups']++; |
|
1195 | + if (!empty($matches[0])) { |
|
1196 | + $incontext['sql_results']['insert_dups'] += count($matches[0]); |
|
1197 | + } else { |
|
1198 | + $incontext['sql_results']['insert_dups']++; |
|
1199 | + } |
|
1137 | 1200 | |
1138 | 1201 | $current_statement = ''; |
1139 | 1202 | continue; |
@@ -1142,8 +1205,9 @@ discard block |
||
1142 | 1205 | if ($smcFunc['db_query']('', $current_statement, array('security_override' => true, 'db_error_skip' => true), $db_connection) === false) |
1143 | 1206 | { |
1144 | 1207 | // Use the appropriate function based on the DB type |
1145 | - if ($db_type == 'mysql' || $db_type == 'mysqli') |
|
1146 | - $db_errorno = $db_type . '_errno'; |
|
1208 | + if ($db_type == 'mysql' || $db_type == 'mysqli') { |
|
1209 | + $db_errorno = $db_type . '_errno'; |
|
1210 | + } |
|
1147 | 1211 | |
1148 | 1212 | // Error 1050: Table already exists! |
1149 | 1213 | // @todo Needs to be made better! |
@@ -1158,18 +1222,18 @@ discard block |
||
1158 | 1222 | // MySQLi requires a connection object. It's optional with MySQL and Postgres |
1159 | 1223 | $incontext['failures'][$count] = $smcFunc['db_error']($db_connection); |
1160 | 1224 | } |
1161 | - } |
|
1162 | - else |
|
1225 | + } else |
|
1163 | 1226 | { |
1164 | - if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
1165 | - $incontext['sql_results']['tables']++; |
|
1166 | - elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
1227 | + if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) { |
|
1228 | + $incontext['sql_results']['tables']++; |
|
1229 | + } elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
1167 | 1230 | { |
1168 | 1231 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
1169 | - if (!empty($matches[0])) |
|
1170 | - $incontext['sql_results']['inserts'] += count($matches[0]); |
|
1171 | - else |
|
1172 | - $incontext['sql_results']['inserts']++; |
|
1232 | + if (!empty($matches[0])) { |
|
1233 | + $incontext['sql_results']['inserts'] += count($matches[0]); |
|
1234 | + } else { |
|
1235 | + $incontext['sql_results']['inserts']++; |
|
1236 | + } |
|
1173 | 1237 | } |
1174 | 1238 | } |
1175 | 1239 | |
@@ -1182,15 +1246,17 @@ discard block |
||
1182 | 1246 | // Sort out the context for the SQL. |
1183 | 1247 | foreach ($incontext['sql_results'] as $key => $number) |
1184 | 1248 | { |
1185 | - if ($number == 0) |
|
1186 | - unset($incontext['sql_results'][$key]); |
|
1187 | - else |
|
1188 | - $incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number); |
|
1249 | + if ($number == 0) { |
|
1250 | + unset($incontext['sql_results'][$key]); |
|
1251 | + } else { |
|
1252 | + $incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number); |
|
1253 | + } |
|
1189 | 1254 | } |
1190 | 1255 | |
1191 | 1256 | // Make sure UTF will be used globally. |
1192 | - if ((!empty($databases[$db_type]['utf8_support']) && !empty($databases[$db_type]['utf8_required'])) || (empty($databases[$db_type]['utf8_required']) && !empty($databases[$db_type]['utf8_support']) && isset($_POST['utf8']))) |
|
1193 | - $newSettings[] = array('global_character_set', 'UTF-8'); |
|
1257 | + if ((!empty($databases[$db_type]['utf8_support']) && !empty($databases[$db_type]['utf8_required'])) || (empty($databases[$db_type]['utf8_required']) && !empty($databases[$db_type]['utf8_support']) && isset($_POST['utf8']))) { |
|
1258 | + $newSettings[] = array('global_character_set', 'UTF-8'); |
|
1259 | + } |
|
1194 | 1260 | |
1195 | 1261 | // Maybe we can auto-detect better cookie settings? |
1196 | 1262 | preg_match('~^http[s]?://([^\.]+?)([^/]*?)(/.*)?$~', $boardurl, $matches); |
@@ -1201,16 +1267,20 @@ discard block |
||
1201 | 1267 | $globalCookies = false; |
1202 | 1268 | |
1203 | 1269 | // Okay... let's see. Using a subdomain other than www.? (not a perfect check.) |
1204 | - if ($matches[2] != '' && (strpos(substr($matches[2], 1), '.') === false || in_array($matches[1], array('forum', 'board', 'community', 'forums', 'support', 'chat', 'help', 'talk', 'boards', 'www')))) |
|
1205 | - $globalCookies = true; |
|
1270 | + if ($matches[2] != '' && (strpos(substr($matches[2], 1), '.') === false || in_array($matches[1], array('forum', 'board', 'community', 'forums', 'support', 'chat', 'help', 'talk', 'boards', 'www')))) { |
|
1271 | + $globalCookies = true; |
|
1272 | + } |
|
1206 | 1273 | // If there's a / in the middle of the path, or it starts with ~... we want local. |
1207 | - if (isset($matches[3]) && strlen($matches[3]) > 3 && (substr($matches[3], 0, 2) == '/~' || strpos(substr($matches[3], 1), '/') !== false)) |
|
1208 | - $localCookies = true; |
|
1274 | + if (isset($matches[3]) && strlen($matches[3]) > 3 && (substr($matches[3], 0, 2) == '/~' || strpos(substr($matches[3], 1), '/') !== false)) { |
|
1275 | + $localCookies = true; |
|
1276 | + } |
|
1209 | 1277 | |
1210 | - if ($globalCookies) |
|
1211 | - $newSettings[] = array('globalCookies', '1'); |
|
1212 | - if ($localCookies) |
|
1213 | - $newSettings[] = array('localCookies', '1'); |
|
1278 | + if ($globalCookies) { |
|
1279 | + $newSettings[] = array('globalCookies', '1'); |
|
1280 | + } |
|
1281 | + if ($localCookies) { |
|
1282 | + $newSettings[] = array('localCookies', '1'); |
|
1283 | + } |
|
1214 | 1284 | } |
1215 | 1285 | |
1216 | 1286 | // Are we allowing stat collection? |
@@ -1226,32 +1296,36 @@ discard block |
||
1226 | 1296 | fwrite($fp, $out); |
1227 | 1297 | |
1228 | 1298 | $return_data = ''; |
1229 | - while (!feof($fp)) |
|
1230 | - $return_data .= fgets($fp, 128); |
|
1299 | + while (!feof($fp)) { |
|
1300 | + $return_data .= fgets($fp, 128); |
|
1301 | + } |
|
1231 | 1302 | |
1232 | 1303 | fclose($fp); |
1233 | 1304 | |
1234 | 1305 | // Get the unique site ID. |
1235 | 1306 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
1236 | 1307 | |
1237 | - if (!empty($ID[1])) |
|
1238 | - $newSettings[] = array('allow_sm_stats', $ID[1]); |
|
1308 | + if (!empty($ID[1])) { |
|
1309 | + $newSettings[] = array('allow_sm_stats', $ID[1]); |
|
1310 | + } |
|
1239 | 1311 | } |
1240 | 1312 | } |
1241 | 1313 | |
1242 | 1314 | // Are we enabling SSL? |
1243 | - if (!empty($_POST['force_ssl'])) |
|
1244 | - $newSettings[] = array('force_ssl', 2); |
|
1315 | + if (!empty($_POST['force_ssl'])) { |
|
1316 | + $newSettings[] = array('force_ssl', 2); |
|
1317 | + } |
|
1245 | 1318 | |
1246 | 1319 | // Setting a timezone is required. |
1247 | 1320 | if (!isset($modSettings['default_timezone']) && function_exists('date_default_timezone_set')) |
1248 | 1321 | { |
1249 | 1322 | // Get PHP's default timezone, if set |
1250 | 1323 | $ini_tz = ini_get('date.timezone'); |
1251 | - if (!empty($ini_tz)) |
|
1252 | - $timezone_id = $ini_tz; |
|
1253 | - else |
|
1254 | - $timezone_id = ''; |
|
1324 | + if (!empty($ini_tz)) { |
|
1325 | + $timezone_id = $ini_tz; |
|
1326 | + } else { |
|
1327 | + $timezone_id = ''; |
|
1328 | + } |
|
1255 | 1329 | |
1256 | 1330 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
1257 | 1331 | if (!in_array($timezone_id, timezone_identifiers_list())) |
@@ -1260,8 +1334,9 @@ discard block |
||
1260 | 1334 | $timezone_id = timezone_name_from_abbr('', $server_offset, 0); |
1261 | 1335 | } |
1262 | 1336 | |
1263 | - if (date_default_timezone_set($timezone_id)) |
|
1264 | - $newSettings[] = array('default_timezone', $timezone_id); |
|
1337 | + if (date_default_timezone_set($timezone_id)) { |
|
1338 | + $newSettings[] = array('default_timezone', $timezone_id); |
|
1339 | + } |
|
1265 | 1340 | } |
1266 | 1341 | |
1267 | 1342 | if (!empty($newSettings)) |
@@ -1292,16 +1367,18 @@ discard block |
||
1292 | 1367 | } |
1293 | 1368 | |
1294 | 1369 | // MySQL specific stuff |
1295 | - if (substr($db_type, 0, 5) != 'mysql') |
|
1296 | - return false; |
|
1370 | + if (substr($db_type, 0, 5) != 'mysql') { |
|
1371 | + return false; |
|
1372 | + } |
|
1297 | 1373 | |
1298 | 1374 | // Find database user privileges. |
1299 | 1375 | $privs = array(); |
1300 | 1376 | $get_privs = $smcFunc['db_query']('', 'SHOW PRIVILEGES', array()); |
1301 | 1377 | while ($row = $smcFunc['db_fetch_assoc']($get_privs)) |
1302 | 1378 | { |
1303 | - if ($row['Privilege'] == 'Alter') |
|
1304 | - $privs[] = $row['Privilege']; |
|
1379 | + if ($row['Privilege'] == 'Alter') { |
|
1380 | + $privs[] = $row['Privilege']; |
|
1381 | + } |
|
1305 | 1382 | } |
1306 | 1383 | $smcFunc['db_free_result']($get_privs); |
1307 | 1384 | |
@@ -1331,8 +1408,9 @@ discard block |
||
1331 | 1408 | $incontext['continue'] = 1; |
1332 | 1409 | |
1333 | 1410 | // Skipping? |
1334 | - if (!empty($_POST['skip'])) |
|
1335 | - return true; |
|
1411 | + if (!empty($_POST['skip'])) { |
|
1412 | + return true; |
|
1413 | + } |
|
1336 | 1414 | |
1337 | 1415 | // Need this to check whether we need the database password. |
1338 | 1416 | require(dirname(__FILE__) . '/Settings.php'); |
@@ -1345,18 +1423,22 @@ discard block |
||
1345 | 1423 | // We need this to properly hash the password for Admin |
1346 | 1424 | $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) { |
1347 | 1425 | global $sourcedir; |
1348 | - if (function_exists('mb_strtolower')) |
|
1349 | - return mb_strtolower($string, 'UTF-8'); |
|
1426 | + if (function_exists('mb_strtolower')) { |
|
1427 | + return mb_strtolower($string, 'UTF-8'); |
|
1428 | + } |
|
1350 | 1429 | require_once($sourcedir . '/Subs-Charset.php'); |
1351 | 1430 | return utf8_strtolower($string); |
1352 | 1431 | }; |
1353 | 1432 | |
1354 | - if (!isset($_POST['username'])) |
|
1355 | - $_POST['username'] = ''; |
|
1356 | - if (!isset($_POST['email'])) |
|
1357 | - $_POST['email'] = ''; |
|
1358 | - if (!isset($_POST['server_email'])) |
|
1359 | - $_POST['server_email'] = ''; |
|
1433 | + if (!isset($_POST['username'])) { |
|
1434 | + $_POST['username'] = ''; |
|
1435 | + } |
|
1436 | + if (!isset($_POST['email'])) { |
|
1437 | + $_POST['email'] = ''; |
|
1438 | + } |
|
1439 | + if (!isset($_POST['server_email'])) { |
|
1440 | + $_POST['server_email'] = ''; |
|
1441 | + } |
|
1360 | 1442 | |
1361 | 1443 | $incontext['username'] = htmlspecialchars(stripslashes($_POST['username'])); |
1362 | 1444 | $incontext['email'] = htmlspecialchars(stripslashes($_POST['email'])); |
@@ -1375,8 +1457,9 @@ discard block |
||
1375 | 1457 | 'admin_group' => 1, |
1376 | 1458 | ) |
1377 | 1459 | ); |
1378 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
1379 | - $incontext['skip'] = 1; |
|
1460 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
1461 | + $incontext['skip'] = 1; |
|
1462 | + } |
|
1380 | 1463 | $smcFunc['db_free_result']($request); |
1381 | 1464 | |
1382 | 1465 | // Trying to create an account? |
@@ -1407,8 +1490,9 @@ discard block |
||
1407 | 1490 | } |
1408 | 1491 | |
1409 | 1492 | // Update the webmaster's email? |
1410 | - if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) |
|
1411 | - updateSettingsFile(array('webmaster_email' => $_POST['server_email'])); |
|
1493 | + if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) { |
|
1494 | + updateSettingsFile(array('webmaster_email' => $_POST['server_email'])); |
|
1495 | + } |
|
1412 | 1496 | |
1413 | 1497 | // Work out whether we're going to have dodgy characters and remove them. |
1414 | 1498 | $invalid_characters = preg_match('~[<>&"\'=\\\]~', $_POST['username']) != 0; |
@@ -1431,32 +1515,27 @@ discard block |
||
1431 | 1515 | $smcFunc['db_free_result']($result); |
1432 | 1516 | |
1433 | 1517 | $incontext['account_existed'] = $txt['error_user_settings_taken']; |
1434 | - } |
|
1435 | - elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) |
|
1518 | + } elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) |
|
1436 | 1519 | { |
1437 | 1520 | // Try the previous step again. |
1438 | 1521 | $incontext['error'] = $_POST['username'] == '' ? $txt['error_username_left_empty'] : $txt['error_username_too_long']; |
1439 | 1522 | return false; |
1440 | - } |
|
1441 | - elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) |
|
1523 | + } elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) |
|
1442 | 1524 | { |
1443 | 1525 | // Try the previous step again. |
1444 | 1526 | $incontext['error'] = $txt['error_invalid_characters_username']; |
1445 | 1527 | return false; |
1446 | - } |
|
1447 | - elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255) |
|
1528 | + } elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255) |
|
1448 | 1529 | { |
1449 | 1530 | // One step back, this time fill out a proper admin email address. |
1450 | 1531 | $incontext['error'] = sprintf($txt['error_valid_admin_email_needed'], $_POST['username']); |
1451 | 1532 | return false; |
1452 | - } |
|
1453 | - elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255) |
|
1533 | + } elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255) |
|
1454 | 1534 | { |
1455 | 1535 | // One step back, this time fill out a proper admin email address. |
1456 | 1536 | $incontext['error'] = $txt['error_valid_server_email_needed']; |
1457 | 1537 | return false; |
1458 | - } |
|
1459 | - elseif ($_POST['username'] != '') |
|
1538 | + } elseif ($_POST['username'] != '') |
|
1460 | 1539 | { |
1461 | 1540 | $incontext['member_salt'] = substr(md5(mt_rand()), 0, 4); |
1462 | 1541 | |
@@ -1521,17 +1600,19 @@ discard block |
||
1521 | 1600 | require_once($sourcedir . '/Subs-Auth.php'); |
1522 | 1601 | |
1523 | 1602 | // Bring a warning over. |
1524 | - if (!empty($incontext['account_existed'])) |
|
1525 | - $incontext['warning'] = $incontext['account_existed']; |
|
1603 | + if (!empty($incontext['account_existed'])) { |
|
1604 | + $incontext['warning'] = $incontext['account_existed']; |
|
1605 | + } |
|
1526 | 1606 | |
1527 | - if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) |
|
1528 | - $smcFunc['db_query']('', ' |
|
1607 | + if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) { |
|
1608 | + $smcFunc['db_query']('', ' |
|
1529 | 1609 | SET NAMES {string:db_character_set}', |
1530 | 1610 | array( |
1531 | 1611 | 'db_character_set' => $db_character_set, |
1532 | 1612 | 'db_error_skip' => true, |
1533 | 1613 | ) |
1534 | 1614 | ); |
1615 | + } |
|
1535 | 1616 | |
1536 | 1617 | // As track stats is by default enabled let's add some activity. |
1537 | 1618 | $smcFunc['db_insert']('ignore', |
@@ -1552,14 +1633,16 @@ discard block |
||
1552 | 1633 | // Only proceed if we can load the data. |
1553 | 1634 | if ($request) |
1554 | 1635 | { |
1555 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
1556 | - $modSettings[$row[0]] = $row[1]; |
|
1636 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
1637 | + $modSettings[$row[0]] = $row[1]; |
|
1638 | + } |
|
1557 | 1639 | $smcFunc['db_free_result']($request); |
1558 | 1640 | } |
1559 | 1641 | |
1560 | 1642 | // Automatically log them in ;) |
1561 | - if (isset($incontext['member_id']) && isset($incontext['member_salt'])) |
|
1562 | - setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt'])); |
|
1643 | + if (isset($incontext['member_id']) && isset($incontext['member_salt'])) { |
|
1644 | + setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt'])); |
|
1645 | + } |
|
1563 | 1646 | |
1564 | 1647 | $result = $smcFunc['db_query']('', ' |
1565 | 1648 | SELECT value |
@@ -1570,13 +1653,14 @@ discard block |
||
1570 | 1653 | 'db_error_skip' => true, |
1571 | 1654 | ) |
1572 | 1655 | ); |
1573 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
1574 | - list ($db_sessions) = $smcFunc['db_fetch_row']($result); |
|
1656 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
1657 | + list ($db_sessions) = $smcFunc['db_fetch_row']($result); |
|
1658 | + } |
|
1575 | 1659 | $smcFunc['db_free_result']($result); |
1576 | 1660 | |
1577 | - if (empty($db_sessions)) |
|
1578 | - $_SESSION['admin_time'] = time(); |
|
1579 | - else |
|
1661 | + if (empty($db_sessions)) { |
|
1662 | + $_SESSION['admin_time'] = time(); |
|
1663 | + } else |
|
1580 | 1664 | { |
1581 | 1665 | $_SERVER['HTTP_USER_AGENT'] = substr($_SERVER['HTTP_USER_AGENT'], 0, 211); |
1582 | 1666 | |
@@ -1600,8 +1684,9 @@ discard block |
||
1600 | 1684 | $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : |
1601 | 1685 | function($string){ |
1602 | 1686 | global $sourcedir; |
1603 | - if (function_exists('mb_strtolower')) |
|
1604 | - return mb_strtolower($string, 'UTF-8'); |
|
1687 | + if (function_exists('mb_strtolower')) { |
|
1688 | + return mb_strtolower($string, 'UTF-8'); |
|
1689 | + } |
|
1605 | 1690 | require_once($sourcedir . '/Subs-Charset.php'); |
1606 | 1691 | return utf8_strtolower($string); |
1607 | 1692 | }; |
@@ -1617,8 +1702,9 @@ discard block |
||
1617 | 1702 | ) |
1618 | 1703 | ); |
1619 | 1704 | $context['utf8'] = $db_character_set === 'utf8' || $txt['lang_character_set'] === 'UTF-8'; |
1620 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
1621 | - updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject'])); |
|
1705 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
1706 | + updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject'])); |
|
1707 | + } |
|
1622 | 1708 | $smcFunc['db_free_result']($request); |
1623 | 1709 | |
1624 | 1710 | // Now is the perfect time to fetch the SM files. |
@@ -1637,8 +1723,9 @@ discard block |
||
1637 | 1723 | |
1638 | 1724 | // Check if we need some stupid MySQL fix. |
1639 | 1725 | $server_version = $smcFunc['db_server_info'](); |
1640 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
1641 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
1726 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
1727 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
1728 | + } |
|
1642 | 1729 | |
1643 | 1730 | // Some final context for the template. |
1644 | 1731 | $incontext['dir_still_writable'] = is_writable(dirname(__FILE__)) && substr(__FILE__, 1, 2) != ':\\'; |
@@ -1658,8 +1745,9 @@ discard block |
||
1658 | 1745 | $settingsArray = file(dirname(__FILE__) . '/Settings.php'); |
1659 | 1746 | |
1660 | 1747 | // @todo Do we just want to read the file in clean, and split it this way always? |
1661 | - if (count($settingsArray) == 1) |
|
1662 | - $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
1748 | + if (count($settingsArray) == 1) { |
|
1749 | + $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
1750 | + } |
|
1663 | 1751 | |
1664 | 1752 | for ($i = 0, $n = count($settingsArray); $i < $n; $i++) |
1665 | 1753 | { |
@@ -1674,19 +1762,22 @@ discard block |
||
1674 | 1762 | continue; |
1675 | 1763 | } |
1676 | 1764 | |
1677 | - if (trim($settingsArray[$i]) == '?' . '>') |
|
1678 | - $settingsArray[$i] = ''; |
|
1765 | + if (trim($settingsArray[$i]) == '?' . '>') { |
|
1766 | + $settingsArray[$i] = ''; |
|
1767 | + } |
|
1679 | 1768 | |
1680 | 1769 | // Don't trim or bother with it if it's not a variable. |
1681 | - if (substr($settingsArray[$i], 0, 1) != '$') |
|
1682 | - continue; |
|
1770 | + if (substr($settingsArray[$i], 0, 1) != '$') { |
|
1771 | + continue; |
|
1772 | + } |
|
1683 | 1773 | |
1684 | 1774 | $settingsArray[$i] = rtrim($settingsArray[$i]) . "\n"; |
1685 | 1775 | |
1686 | - foreach ($vars as $var => $val) |
|
1687 | - if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
1776 | + foreach ($vars as $var => $val) { |
|
1777 | + if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
1688 | 1778 | { |
1689 | 1779 | $comment = strstr($settingsArray[$i], '#'); |
1780 | + } |
|
1690 | 1781 | $settingsArray[$i] = '$' . $var . ' = \'' . $val . '\';' . ($comment != '' ? "\t\t" . $comment : "\n"); |
1691 | 1782 | unset($vars[$var]); |
1692 | 1783 | } |
@@ -1696,36 +1787,41 @@ discard block |
||
1696 | 1787 | if (!empty($vars)) |
1697 | 1788 | { |
1698 | 1789 | $settingsArray[$i++] = ''; |
1699 | - foreach ($vars as $var => $val) |
|
1700 | - $settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n"; |
|
1790 | + foreach ($vars as $var => $val) { |
|
1791 | + $settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n"; |
|
1792 | + } |
|
1701 | 1793 | } |
1702 | 1794 | |
1703 | 1795 | // Blank out the file - done to fix a oddity with some servers. |
1704 | 1796 | $fp = @fopen(dirname(__FILE__) . '/Settings.php', 'w'); |
1705 | - if (!$fp) |
|
1706 | - return false; |
|
1797 | + if (!$fp) { |
|
1798 | + return false; |
|
1799 | + } |
|
1707 | 1800 | fclose($fp); |
1708 | 1801 | |
1709 | 1802 | $fp = fopen(dirname(__FILE__) . '/Settings.php', 'r+'); |
1710 | 1803 | |
1711 | 1804 | // Gotta have one of these ;) |
1712 | - if (trim($settingsArray[0]) != '<?php') |
|
1713 | - fwrite($fp, "<?php\n"); |
|
1805 | + if (trim($settingsArray[0]) != '<?php') { |
|
1806 | + fwrite($fp, "<?php\n"); |
|
1807 | + } |
|
1714 | 1808 | |
1715 | 1809 | $lines = count($settingsArray); |
1716 | 1810 | for ($i = 0; $i < $lines - 1; $i++) |
1717 | 1811 | { |
1718 | 1812 | // Don't just write a bunch of blank lines. |
1719 | - if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') |
|
1720 | - fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
1813 | + if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') { |
|
1814 | + fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
1815 | + } |
|
1721 | 1816 | } |
1722 | 1817 | fwrite($fp, $settingsArray[$i] . '?' . '>'); |
1723 | 1818 | fclose($fp); |
1724 | 1819 | |
1725 | 1820 | // Even though on normal installations the filemtime should prevent this being used by the installer incorrectly |
1726 | 1821 | // it seems that there are times it might not. So let's MAKE it dump the cache. |
1727 | - if (function_exists('opcache_invalidate')) |
|
1728 | - opcache_invalidate(dirname(__FILE__) . '/Settings.php', true); |
|
1822 | + if (function_exists('opcache_invalidate')) { |
|
1823 | + opcache_invalidate(dirname(__FILE__) . '/Settings.php', true); |
|
1824 | + } |
|
1729 | 1825 | |
1730 | 1826 | return true; |
1731 | 1827 | } |
@@ -1750,9 +1846,9 @@ discard block |
||
1750 | 1846 | SecFilterScanPOST Off |
1751 | 1847 | </IfModule>'; |
1752 | 1848 | |
1753 | - if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) |
|
1754 | - return true; |
|
1755 | - elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess')) |
|
1849 | + if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) { |
|
1850 | + return true; |
|
1851 | + } elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess')) |
|
1756 | 1852 | { |
1757 | 1853 | $current_htaccess = implode('', file(dirname(__FILE__) . '/.htaccess')); |
1758 | 1854 | |
@@ -1764,29 +1860,28 @@ discard block |
||
1764 | 1860 | fwrite($ht_handle, $htaccess_addition); |
1765 | 1861 | fclose($ht_handle); |
1766 | 1862 | return true; |
1863 | + } else { |
|
1864 | + return false; |
|
1767 | 1865 | } |
1768 | - else |
|
1769 | - return false; |
|
1866 | + } else { |
|
1867 | + return true; |
|
1770 | 1868 | } |
1771 | - else |
|
1772 | - return true; |
|
1773 | - } |
|
1774 | - elseif (file_exists(dirname(__FILE__) . '/.htaccess')) |
|
1775 | - return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false; |
|
1776 | - elseif (is_writable(dirname(__FILE__))) |
|
1869 | + } elseif (file_exists(dirname(__FILE__) . '/.htaccess')) { |
|
1870 | + return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false; |
|
1871 | + } elseif (is_writable(dirname(__FILE__))) |
|
1777 | 1872 | { |
1778 | 1873 | if ($ht_handle = fopen(dirname(__FILE__) . '/.htaccess', 'w')) |
1779 | 1874 | { |
1780 | 1875 | fwrite($ht_handle, $htaccess_addition); |
1781 | 1876 | fclose($ht_handle); |
1782 | 1877 | return true; |
1878 | + } else { |
|
1879 | + return false; |
|
1783 | 1880 | } |
1784 | - else |
|
1881 | + } else { |
|
1785 | 1882 | return false; |
1786 | 1883 | } |
1787 | - else |
|
1788 | - return false; |
|
1789 | -} |
|
1884 | + } |
|
1790 | 1885 | |
1791 | 1886 | function template_install_above() |
1792 | 1887 | { |
@@ -1824,9 +1919,10 @@ discard block |
||
1824 | 1919 | <label for="installer_language">', $txt['installer_language'], ':</label> |
1825 | 1920 | <select id="installer_language" name="lang_file" onchange="location.href = \'', $installurl, '?lang_file=\' + this.options[this.selectedIndex].value;">'; |
1826 | 1921 | |
1827 | - foreach ($incontext['detected_languages'] as $lang => $name) |
|
1828 | - echo ' |
|
1922 | + foreach ($incontext['detected_languages'] as $lang => $name) { |
|
1923 | + echo ' |
|
1829 | 1924 | <option', isset($_SESSION['installer_temp_lang']) && $_SESSION['installer_temp_lang'] == $lang ? ' selected' : '', ' value="', $lang, '">', $name, '</option>'; |
1925 | + } |
|
1830 | 1926 | |
1831 | 1927 | echo ' |
1832 | 1928 | </select> |
@@ -1846,9 +1942,10 @@ discard block |
||
1846 | 1942 | <h2>', $txt['upgrade_progress'], '</h2> |
1847 | 1943 | <ul>'; |
1848 | 1944 | |
1849 | - foreach ($incontext['steps'] as $num => $step) |
|
1850 | - echo ' |
|
1945 | + foreach ($incontext['steps'] as $num => $step) { |
|
1946 | + echo ' |
|
1851 | 1947 | <li class="', $num < $incontext['current_step'] ? 'stepdone' : ($num == $incontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
1948 | + } |
|
1852 | 1949 | |
1853 | 1950 | echo ' |
1854 | 1951 | </ul> |
@@ -1873,20 +1970,23 @@ discard block |
||
1873 | 1970 | echo ' |
1874 | 1971 | <div>'; |
1875 | 1972 | |
1876 | - if (!empty($incontext['continue'])) |
|
1877 | - echo ' |
|
1973 | + if (!empty($incontext['continue'])) { |
|
1974 | + echo ' |
|
1878 | 1975 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '" onclick="return submitThisOnce(this);" class="button_submit" />'; |
1879 | - if (!empty($incontext['skip'])) |
|
1880 | - echo ' |
|
1976 | + } |
|
1977 | + if (!empty($incontext['skip'])) { |
|
1978 | + echo ' |
|
1881 | 1979 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="return submitThisOnce(this);" class="button_submit" />'; |
1980 | + } |
|
1882 | 1981 | echo ' |
1883 | 1982 | </div>'; |
1884 | 1983 | } |
1885 | 1984 | |
1886 | 1985 | // Show the closing form tag and other data only if not in the last step |
1887 | - if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) |
|
1888 | - echo ' |
|
1986 | + if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) { |
|
1987 | + echo ' |
|
1889 | 1988 | </form>'; |
1989 | + } |
|
1890 | 1990 | |
1891 | 1991 | echo ' |
1892 | 1992 | </div> |
@@ -1921,13 +2021,15 @@ discard block |
||
1921 | 2021 | </div>'; |
1922 | 2022 | |
1923 | 2023 | // Show the warnings, or not. |
1924 | - if (template_warning_divs()) |
|
1925 | - echo ' |
|
2024 | + if (template_warning_divs()) { |
|
2025 | + echo ' |
|
1926 | 2026 | <h3>', $txt['install_all_lovely'], '</h3>'; |
2027 | + } |
|
1927 | 2028 | |
1928 | 2029 | // Say we want the continue button! |
1929 | - if (empty($incontext['error'])) |
|
1930 | - $incontext['continue'] = 1; |
|
2030 | + if (empty($incontext['error'])) { |
|
2031 | + $incontext['continue'] = 1; |
|
2032 | + } |
|
1931 | 2033 | |
1932 | 2034 | // For the latest version stuff. |
1933 | 2035 | echo ' |
@@ -1961,8 +2063,8 @@ discard block |
||
1961 | 2063 | global $txt, $incontext; |
1962 | 2064 | |
1963 | 2065 | // Errors are very serious.. |
1964 | - if (!empty($incontext['error'])) |
|
1965 | - echo ' |
|
2066 | + if (!empty($incontext['error'])) { |
|
2067 | + echo ' |
|
1966 | 2068 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
1967 | 2069 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
1968 | 2070 | <strong style="text-decoration: underline;">', $txt['upgrade_critical_error'], '</strong><br> |
@@ -1970,9 +2072,10 @@ discard block |
||
1970 | 2072 | ', $incontext['error'], ' |
1971 | 2073 | </div> |
1972 | 2074 | </div>'; |
2075 | + } |
|
1973 | 2076 | // A warning message? |
1974 | - elseif (!empty($incontext['warning'])) |
|
1975 | - echo ' |
|
2077 | + elseif (!empty($incontext['warning'])) { |
|
2078 | + echo ' |
|
1976 | 2079 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
1977 | 2080 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
1978 | 2081 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -1980,6 +2083,7 @@ discard block |
||
1980 | 2083 | ', $incontext['warning'], ' |
1981 | 2084 | </div> |
1982 | 2085 | </div>'; |
2086 | + } |
|
1983 | 2087 | |
1984 | 2088 | return empty($incontext['error']) && empty($incontext['warning']); |
1985 | 2089 | } |
@@ -1995,27 +2099,30 @@ discard block |
||
1995 | 2099 | <li>', $incontext['failed_files']), '</li> |
1996 | 2100 | </ul>'; |
1997 | 2101 | |
1998 | - if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') |
|
1999 | - echo ' |
|
2102 | + if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') { |
|
2103 | + echo ' |
|
2000 | 2104 | <hr> |
2001 | 2105 | <p>', $txt['chmod_linux_info'], '</p> |
2002 | 2106 | <tt># chmod a+w ', implode(' ' . $incontext['detected_path'] . '/', $incontext['failed_files']), '</tt>'; |
2107 | + } |
|
2003 | 2108 | |
2004 | 2109 | // This is serious! |
2005 | - if (!template_warning_divs()) |
|
2006 | - return; |
|
2110 | + if (!template_warning_divs()) { |
|
2111 | + return; |
|
2112 | + } |
|
2007 | 2113 | |
2008 | 2114 | echo ' |
2009 | 2115 | <hr> |
2010 | 2116 | <p>', $txt['ftp_setup_info'], '</p>'; |
2011 | 2117 | |
2012 | - if (!empty($incontext['ftp_errors'])) |
|
2013 | - echo ' |
|
2118 | + if (!empty($incontext['ftp_errors'])) { |
|
2119 | + echo ' |
|
2014 | 2120 | <div class="error_message"> |
2015 | 2121 | ', $txt['error_ftp_no_connect'], '<br><br> |
2016 | 2122 | <code>', implode('<br>', $incontext['ftp_errors']), '</code> |
2017 | 2123 | </div> |
2018 | 2124 | <br>'; |
2125 | + } |
|
2019 | 2126 | |
2020 | 2127 | echo ' |
2021 | 2128 | <form action="', $incontext['form_url'], '" method="post"> |
@@ -2075,17 +2182,17 @@ discard block |
||
2075 | 2182 | <td> |
2076 | 2183 | <select name="db_type" id="db_type_input" onchange="toggleDBInput();">'; |
2077 | 2184 | |
2078 | - foreach ($incontext['supported_databases'] as $key => $db) |
|
2079 | - echo ' |
|
2185 | + foreach ($incontext['supported_databases'] as $key => $db) { |
|
2186 | + echo ' |
|
2080 | 2187 | <option value="', $key, '"', isset($_POST['db_type']) && $_POST['db_type'] == $key ? ' selected' : '', '>', $db['name'], '</option>'; |
2188 | + } |
|
2081 | 2189 | |
2082 | 2190 | echo ' |
2083 | 2191 | </select> |
2084 | 2192 | <div class="smalltext block">', $txt['db_settings_type_info'], '</div> |
2085 | 2193 | </td> |
2086 | 2194 | </tr>'; |
2087 | - } |
|
2088 | - else |
|
2195 | + } else |
|
2089 | 2196 | { |
2090 | 2197 | echo ' |
2091 | 2198 | <tr style="display: none;"> |
@@ -2277,9 +2384,10 @@ discard block |
||
2277 | 2384 | <div style="color: red;">', $txt['error_db_queries'], '</div> |
2278 | 2385 | <ul>'; |
2279 | 2386 | |
2280 | - foreach ($incontext['failures'] as $line => $fail) |
|
2281 | - echo ' |
|
2387 | + foreach ($incontext['failures'] as $line => $fail) { |
|
2388 | + echo ' |
|
2282 | 2389 | <li><strong>', $txt['error_db_queries_line'], $line + 1, ':</strong> ', nl2br(htmlspecialchars($fail)), '</li>'; |
2390 | + } |
|
2283 | 2391 | |
2284 | 2392 | echo ' |
2285 | 2393 | </ul>'; |
@@ -2340,15 +2448,16 @@ discard block |
||
2340 | 2448 | </tr> |
2341 | 2449 | </table>'; |
2342 | 2450 | |
2343 | - if ($incontext['require_db_confirm']) |
|
2344 | - echo ' |
|
2451 | + if ($incontext['require_db_confirm']) { |
|
2452 | + echo ' |
|
2345 | 2453 | <h2>', $txt['user_settings_database'], '</h2> |
2346 | 2454 | <p>', $txt['user_settings_database_info'], '</p> |
2347 | 2455 | |
2348 | 2456 | <div style="margin-bottom: 2ex; padding-', $txt['lang_rtl'] == false ? 'left' : 'right', ': 50px;"> |
2349 | 2457 | <input type="password" name="password3" size="30" class="input_password" /> |
2350 | 2458 | </div>'; |
2351 | -} |
|
2459 | + } |
|
2460 | + } |
|
2352 | 2461 | |
2353 | 2462 | // Tell them it's done, and to delete. |
2354 | 2463 | function template_delete_install() |
@@ -2361,14 +2470,15 @@ discard block |
||
2361 | 2470 | template_warning_divs(); |
2362 | 2471 | |
2363 | 2472 | // Install directory still writable? |
2364 | - if ($incontext['dir_still_writable']) |
|
2365 | - echo ' |
|
2473 | + if ($incontext['dir_still_writable']) { |
|
2474 | + echo ' |
|
2366 | 2475 | <em>', $txt['still_writable'], '</em><br> |
2367 | 2476 | <br>'; |
2477 | + } |
|
2368 | 2478 | |
2369 | 2479 | // Don't show the box if it's like 99% sure it won't work :P. |
2370 | - if ($incontext['probably_delete_install']) |
|
2371 | - echo ' |
|
2480 | + if ($incontext['probably_delete_install']) { |
|
2481 | + echo ' |
|
2372 | 2482 | <div style="margin: 1ex; font-weight: bold;"> |
2373 | 2483 | <label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete();" class="input_check" /> ', $txt['delete_installer'], !isset($_SESSION['installer_temp_ftp']) ? ' ' . $txt['delete_installer_maybe'] : '', '</label> |
2374 | 2484 | </div> |
@@ -2384,6 +2494,7 @@ discard block |
||
2384 | 2494 | } |
2385 | 2495 | </script> |
2386 | 2496 | <br>'; |
2497 | + } |
|
2387 | 2498 | |
2388 | 2499 | echo ' |
2389 | 2500 | ', sprintf($txt['go_to_your_forum'], $boardurl . '/index.php'), '<br> |