@@ -88,9 +88,13 @@ |
||
88 | 88 | $bbcTags = $codes->getTags(); |
89 | 89 | |
90 | 90 | if (!isset($this->_req->post->disabledBBC_enabledTags)) |
91 | - $this->_req->post->disabledBBC_enabledTags = array(); |
|
91 | + { |
|
92 | + $this->_req->post->disabledBBC_enabledTags = array(); |
|
93 | + } |
|
92 | 94 | elseif (!is_array($this->_req->post->disabledBBC_enabledTags)) |
93 | - $this->_req->post->disabledBBC_enabledTags = array($this->_req->post->disabledBBC_enabledTags); |
|
95 | + { |
|
96 | + $this->_req->post->disabledBBC_enabledTags = array($this->_req->post->disabledBBC_enabledTags); |
|
97 | + } |
|
94 | 98 | |
95 | 99 | // Work out what is actually disabled! |
96 | 100 | $this->_req->post->disabledBBC = implode(',', array_diff($bbcTags, $this->_req->post->disabledBBC_enabledTags)); |
@@ -146,7 +146,9 @@ discard block |
||
146 | 146 | |
147 | 147 | // Doing something special, does it exist? |
148 | 148 | if (isset($this->_req->query->activity, $subActions[$subAction]['activities'][$this->_req->query->activity])) |
149 | - $activity = $this->_req->query->activity; |
|
149 | + { |
|
150 | + $activity = $this->_req->query->activity; |
|
151 | + } |
|
150 | 152 | |
151 | 153 | // Set a few things. |
152 | 154 | $context[$context['admin_menu_name']]['current_subsection'] = $subAction; |
@@ -160,9 +162,13 @@ discard block |
||
160 | 162 | if (isset($activity)) |
161 | 163 | { |
162 | 164 | if (is_string($subActions[$subAction]['activities'][$activity]) && method_exists($this, $subActions[$subAction]['activities'][$activity])) |
163 | - $this->{$subActions[$subAction]['activities'][$activity]}(); |
|
165 | + { |
|
166 | + $this->{$subActions[$subAction]['activities'][$activity]}(); |
|
167 | + } |
|
164 | 168 | elseif (is_string($subActions[$subAction]['activities'][$activity])) |
165 | - $subActions[$subAction]['activities'][$activity](); |
|
169 | + { |
|
170 | + $subActions[$subAction]['activities'][$activity](); |
|
171 | + } |
|
166 | 172 | else |
167 | 173 | { |
168 | 174 | if (is_array($subActions[$subAction]['activities'][$activity])) |
@@ -243,9 +249,13 @@ discard block |
||
243 | 249 | // * cannot change the execution time OR |
244 | 250 | // * cannot reset timeout |
245 | 251 | if ($context['safe_mode_enable'] || empty($new_time_limit) || ($current_time_limit == $new_time_limit && !function_exists('apache_reset_timeout'))) |
246 | - $context['suggested_method'] = 'use_external_tool'; |
|
252 | + { |
|
253 | + $context['suggested_method'] = 'use_external_tool'; |
|
254 | + } |
|
247 | 255 | elseif ($zip_limit < $plain_limit && $messages < $zip_limit) |
248 | - $context['suggested_method'] = 'zipped_file'; |
|
256 | + { |
|
257 | + $context['suggested_method'] = 'zipped_file'; |
|
258 | + } |
|
249 | 259 | elseif ($zip_limit > $plain_limit || ($zip_limit < $plain_limit && $plain_limit < $messages)) |
250 | 260 | { |
251 | 261 | $context['suggested_method'] = 'use_external_tool'; |
@@ -287,7 +297,9 @@ discard block |
||
287 | 297 | global $context, $txt, $scripturl; |
288 | 298 | |
289 | 299 | if ($this->_req->getQuery('done', 'trim|strval') === 'recount') |
290 | - $context['maintenance_finished'] = $txt['maintain_recount']; |
|
300 | + { |
|
301 | + $context['maintenance_finished'] = $txt['maintain_recount']; |
|
302 | + } |
|
291 | 303 | |
292 | 304 | // set up the sub-template |
293 | 305 | $context['sub_template'] = 'maintain_routine'; |
@@ -360,9 +372,11 @@ discard block |
||
360 | 372 | |
361 | 373 | // Show that we completed this action |
362 | 374 | if ($this->_req->getQuery('done', 'strval') === 'recountposts') |
363 | - $context['maintenance_finished'] = array( |
|
375 | + { |
|
376 | + $context['maintenance_finished'] = array( |
|
364 | 377 | 'errors' => array(sprintf($txt['maintain_done'], $txt['maintain_recountposts'])), |
365 | 378 | ); |
379 | + } |
|
366 | 380 | |
367 | 381 | loadJavascriptFile('suggest.js'); |
368 | 382 | |
@@ -424,13 +438,17 @@ discard block |
||
424 | 438 | call_integration_hook('integrate_topics_maintenance', array(&$context['topics_actions'])); |
425 | 439 | |
426 | 440 | if ($this->_req->getQuery('done', 'strval') === 'purgeold') |
427 | - $context['maintenance_finished'] = array( |
|
441 | + { |
|
442 | + $context['maintenance_finished'] = array( |
|
428 | 443 | 'errors' => array(sprintf($txt['maintain_done'], $txt['maintain_old'])), |
429 | 444 | ); |
445 | + } |
|
430 | 446 | elseif ($this->_req->getQuery('done', 'strval') === 'massmove') |
431 | - $context['maintenance_finished'] = array( |
|
447 | + { |
|
448 | + $context['maintenance_finished'] = array( |
|
432 | 449 | 'errors' => array(sprintf($txt['maintain_done'], $txt['move_topics_maintenance'])), |
433 | 450 | ); |
451 | + } |
|
434 | 452 | |
435 | 453 | // Set up the sub-template |
436 | 454 | $context['sub_template'] = 'maintain_topics'; |
@@ -519,7 +537,9 @@ discard block |
||
519 | 537 | isAllowedTo('admin_forum'); |
520 | 538 | |
521 | 539 | if (DB_TYPE !== 'MySQL') |
522 | - return; |
|
540 | + { |
|
541 | + return; |
|
542 | + } |
|
523 | 543 | |
524 | 544 | $body_type = ''; |
525 | 545 | |
@@ -543,15 +563,20 @@ discard block |
||
543 | 563 | |
544 | 564 | // Make it longer so we can do their limit. |
545 | 565 | if ($body_type === 'text') |
546 | - resizeMessageTableBody('mediumtext'); |
|
566 | + { |
|
567 | + resizeMessageTableBody('mediumtext'); |
|
568 | + } |
|
547 | 569 | // Shorten the column so we can have a bit (literally per record) less space occupied |
548 | - else |
|
549 | - resizeMessageTableBody('text'); |
|
570 | + else { |
|
571 | + resizeMessageTableBody('text'); |
|
572 | + } |
|
550 | 573 | |
551 | 574 | $colData = getMessageTableColumns(); |
552 | 575 | foreach ($colData as $column) |
553 | - if ($column['name'] === 'body') |
|
576 | + { |
|
577 | + if ($column['name'] === 'body') |
|
554 | 578 | $body_type = $column['type']; |
579 | + } |
|
555 | 580 | |
556 | 581 | $context['maintenance_finished'] = $txt[$context['convert_to'] . '_title']; |
557 | 582 | $context['convert_to'] = $body_type === 'text' ? 'mediumtext' : 'text'; |
@@ -564,9 +589,12 @@ discard block |
||
564 | 589 | checkSession(); |
565 | 590 | |
566 | 591 | if (empty($this->_req->query->start)) |
567 | - validateToken('admin-maint'); |
|
568 | - else |
|
569 | - validateToken('admin-convertMsg'); |
|
592 | + { |
|
593 | + validateToken('admin-maint'); |
|
594 | + } |
|
595 | + else { |
|
596 | + validateToken('admin-convertMsg'); |
|
597 | + } |
|
570 | 598 | |
571 | 599 | $context['page_title'] = $txt['not_done_title']; |
572 | 600 | $context['continue_post_data'] = ''; |
@@ -613,8 +641,9 @@ discard block |
||
613 | 641 | $query_msg = array_slice($id_msg_exceeding, 0, 100); |
614 | 642 | $context['exceeding_messages_morethan'] = sprintf($txt['exceeding_messages_morethan'], count($id_msg_exceeding)); |
615 | 643 | } |
616 | - else |
|
617 | - $query_msg = $id_msg_exceeding; |
|
644 | + else { |
|
645 | + $query_msg = $id_msg_exceeding; |
|
646 | + } |
|
618 | 647 | |
619 | 648 | $context['exceeding_messages'] = getExceedingMessages($query_msg); |
620 | 649 | } |
@@ -653,7 +682,9 @@ discard block |
||
653 | 682 | // If there aren't any tables then I believe that would mean the world has exploded... |
654 | 683 | $context['num_tables'] = count($tables); |
655 | 684 | if ($context['num_tables'] == 0) |
656 | - throw new Elk_Exception('You appear to be running ElkArte in a flat file mode... fantastic!', false); |
|
685 | + { |
|
686 | + throw new Elk_Exception('You appear to be running ElkArte in a flat file mode... fantastic!', false); |
|
687 | + } |
|
657 | 688 | |
658 | 689 | // For each table.... |
659 | 690 | $context['optimized_tables'] = array(); |
@@ -663,10 +694,12 @@ discard block |
||
663 | 694 | $data_freed = optimizeTable($table['table_name']); |
664 | 695 | |
665 | 696 | if ($data_freed > 0) |
666 | - $context['optimized_tables'][] = array( |
|
697 | + { |
|
698 | + $context['optimized_tables'][] = array( |
|
667 | 699 | 'name' => $table['table_name'], |
668 | 700 | 'data_freed' => $data_freed, |
669 | 701 | ); |
702 | + } |
|
670 | 703 | } |
671 | 704 | |
672 | 705 | // Number of tables, etc.... |
@@ -709,9 +742,12 @@ discard block |
||
709 | 742 | |
710 | 743 | // Validate the request or the loop |
711 | 744 | if (!isset($this->_req->query->step)) |
712 | - validateToken('admin-maint'); |
|
713 | - else |
|
714 | - validateToken('admin-boardrecount'); |
|
745 | + { |
|
746 | + validateToken('admin-maint'); |
|
747 | + } |
|
748 | + else { |
|
749 | + validateToken('admin-boardrecount'); |
|
750 | + } |
|
715 | 751 | |
716 | 752 | // For the loop template |
717 | 753 | $context['page_title'] = $txt['not_done_title']; |
@@ -757,7 +793,9 @@ discard block |
||
757 | 793 | if ($this->step <= 1) |
758 | 794 | { |
759 | 795 | if (empty($this->start)) |
760 | - resetBoardsCounter('num_posts'); |
|
796 | + { |
|
797 | + resetBoardsCounter('num_posts'); |
|
798 | + } |
|
761 | 799 | |
762 | 800 | while ($this->start < $this->max_topics) |
763 | 801 | { |
@@ -781,7 +819,9 @@ discard block |
||
781 | 819 | if ($this->step <= 2) |
782 | 820 | { |
783 | 821 | if (empty($this->start)) |
784 | - resetBoardsCounter('num_topics'); |
|
822 | + { |
|
823 | + resetBoardsCounter('num_topics'); |
|
824 | + } |
|
785 | 825 | |
786 | 826 | while ($this->start < $this->max_topics) |
787 | 827 | { |
@@ -804,7 +844,9 @@ discard block |
||
804 | 844 | if ($this->step <= 3) |
805 | 845 | { |
806 | 846 | if (empty($this->start)) |
807 | - resetBoardsCounter('unapproved_posts'); |
|
847 | + { |
|
848 | + resetBoardsCounter('unapproved_posts'); |
|
849 | + } |
|
808 | 850 | |
809 | 851 | while ($this->start < $this->max_topics) |
810 | 852 | { |
@@ -827,7 +869,9 @@ discard block |
||
827 | 869 | if ($this->step <= 4) |
828 | 870 | { |
829 | 871 | if (empty($this->start)) |
830 | - resetBoardsCounter('unapproved_topics'); |
|
872 | + { |
|
873 | + resetBoardsCounter('unapproved_topics'); |
|
874 | + } |
|
831 | 875 | |
832 | 876 | while ($this->start < $this->max_topics) |
833 | 877 | { |
@@ -997,7 +1041,9 @@ discard block |
||
997 | 1041 | |
998 | 1042 | // No members, no further |
999 | 1043 | if (empty($members)) |
1000 | - throw new Elk_Exception('reattribute_cannot_find_member'); |
|
1044 | + { |
|
1045 | + throw new Elk_Exception('reattribute_cannot_find_member'); |
|
1046 | + } |
|
1001 | 1047 | |
1002 | 1048 | $memID = array_shift($members); |
1003 | 1049 | $memID = $memID['id']; |
@@ -1017,9 +1063,12 @@ discard block |
||
1017 | 1063 | { |
1018 | 1064 | // Show them the correct error |
1019 | 1065 | if ($our_post['type'] === 'name' && empty($our_post['from_name'])) |
1020 | - $error = $validator->validation_errors(array('from_name', 'to')); |
|
1021 | - else |
|
1022 | - $error = $validator->validation_errors(array('from_email', 'to')); |
|
1066 | + { |
|
1067 | + $error = $validator->validation_errors(array('from_name', 'to')); |
|
1068 | + } |
|
1069 | + else { |
|
1070 | + $error = $validator->validation_errors(array('from_email', 'to')); |
|
1071 | + } |
|
1023 | 1072 | |
1024 | 1073 | $context['maintenance_finished'] = array( |
1025 | 1074 | 'errors' => $error, |
@@ -1042,13 +1091,17 @@ discard block |
||
1042 | 1091 | |
1043 | 1092 | // Administrators only! |
1044 | 1093 | if (!allowedTo('admin_forum')) |
1045 | - throw new Elk_Exception('no_dump_database', 'critical'); |
|
1094 | + { |
|
1095 | + throw new Elk_Exception('no_dump_database', 'critical'); |
|
1096 | + } |
|
1046 | 1097 | |
1047 | 1098 | checkSession('post'); |
1048 | 1099 | |
1049 | 1100 | // Validate access |
1050 | 1101 | if (empty($iknowitmaybeunsafe) && !$this->_validate_access()) |
1051 | - return $this->action_database(); |
|
1102 | + { |
|
1103 | + return $this->action_database(); |
|
1104 | + } |
|
1052 | 1105 | else |
1053 | 1106 | { |
1054 | 1107 | require_once(SUBSDIR . '/Admin.subs.php'); |
@@ -1084,7 +1137,9 @@ discard block |
||
1084 | 1137 | { |
1085 | 1138 | // I know, I know... but a lot of people want to type /home/xyz/... which is wrong, but logical. |
1086 | 1139 | if (!$ftp->chdir($this->_req->post->ftp_path)) |
1087 | - $ftp->chdir(preg_replace('~^/home[2]?/[^/]+?~', '', $this->_req->post->ftp_path)); |
|
1140 | + { |
|
1141 | + $ftp->chdir(preg_replace('~^/home[2]?/[^/]+?~', '', $this->_req->post->ftp_path)); |
|
1142 | + } |
|
1088 | 1143 | } |
1089 | 1144 | |
1090 | 1145 | // If we had an error... |
@@ -1135,7 +1190,9 @@ discard block |
||
1135 | 1190 | |
1136 | 1191 | $groups = array(); |
1137 | 1192 | foreach ($our_post['groups'] as $id => $dummy) |
1138 | - $groups[] = (int) $id; |
|
1193 | + { |
|
1194 | + $groups[] = (int) $id; |
|
1195 | + } |
|
1139 | 1196 | |
1140 | 1197 | $time_limit = (time() - ($our_post['maxdays'] * 24 * 3600)); |
1141 | 1198 | $members = purgeMembers($our_post['del_type'], $groups, $time_limit); |
@@ -1167,14 +1224,19 @@ discard block |
||
1167 | 1224 | |
1168 | 1225 | // No boards at all? Forget it then :/. |
1169 | 1226 | if (empty($this->_req->post->boards)) |
1170 | - redirectexit('action=admin;area=maintain;sa=topics'); |
|
1227 | + { |
|
1228 | + redirectexit('action=admin;area=maintain;sa=topics'); |
|
1229 | + } |
|
1171 | 1230 | |
1172 | 1231 | $boards = array_keys($this->_req->post->boards); |
1173 | 1232 | |
1174 | 1233 | if (!isset($this->_req->post->delete_type) || !in_array($this->_req->post->delete_type, array('moved', 'nothing', 'locked'))) |
1175 | - $delete_type = 'nothing'; |
|
1176 | - else |
|
1177 | - $delete_type = $this->_req->post->delete_type; |
|
1234 | + { |
|
1235 | + $delete_type = 'nothing'; |
|
1236 | + } |
|
1237 | + else { |
|
1238 | + $delete_type = $this->_req->post->delete_type; |
|
1239 | + } |
|
1178 | 1240 | |
1179 | 1241 | $exclude_stickies = isset($this->_req->post->delete_old_not_sticky); |
1180 | 1242 | |
@@ -1219,7 +1281,9 @@ discard block |
||
1219 | 1281 | |
1220 | 1282 | // No boards then this is your stop. |
1221 | 1283 | if (empty($id_board_from) || empty($id_board_to)) |
1222 | - return; |
|
1284 | + { |
|
1285 | + return; |
|
1286 | + } |
|
1223 | 1287 | |
1224 | 1288 | // These will be needed |
1225 | 1289 | require_once(SUBSDIR . '/Maintenance.subs.php'); |
@@ -1243,7 +1307,9 @@ discard block |
||
1243 | 1307 | |
1244 | 1308 | // Just return if we don't have any topics left to move. |
1245 | 1309 | if (empty($topics)) |
1246 | - break; |
|
1310 | + { |
|
1311 | + break; |
|
1312 | + } |
|
1247 | 1313 | |
1248 | 1314 | // Lets move them. |
1249 | 1315 | moveTopics($topics, $id_board_to); |
@@ -1333,9 +1399,12 @@ discard block |
||
1333 | 1399 | global $txt; |
1334 | 1400 | |
1335 | 1401 | if (!empty($data['included_file'])) |
1336 | - return $txt['hooks_field_function'] . ': ' . $data['real_function'] . '<br />' . $txt['hooks_field_included_file'] . ': ' . $data['included_file']; |
|
1337 | - else |
|
1338 | - return $data['real_function']; |
|
1402 | + { |
|
1403 | + return $txt['hooks_field_function'] . ': ' . $data['real_function'] . '<br />' . $txt['hooks_field_included_file'] . ': ' . $data['included_file']; |
|
1404 | + } |
|
1405 | + else { |
|
1406 | + return $data['real_function']; |
|
1407 | + } |
|
1339 | 1408 | }, |
1340 | 1409 | ), |
1341 | 1410 | 'sort' => array( |
@@ -1492,7 +1561,9 @@ discard block |
||
1492 | 1561 | |
1493 | 1562 | $context['filter'] = false; |
1494 | 1563 | if (isset($this->_req->query->filter)) |
1495 | - $context['filter'] = $this->_req->query->filter; |
|
1564 | + { |
|
1565 | + $context['filter'] = $this->_req->query->filter; |
|
1566 | + } |
|
1496 | 1567 | |
1497 | 1568 | return integration_hooks_count($context['filter']); |
1498 | 1569 | } |
@@ -1329,7 +1329,7 @@ discard block |
||
1329 | 1329 | 'value' => $txt['hooks_field_function_name'], |
1330 | 1330 | ), |
1331 | 1331 | 'data' => array( |
1332 | - 'function' => function ($data) { |
|
1332 | + 'function' => function($data) { |
|
1333 | 1333 | global $txt; |
1334 | 1334 | |
1335 | 1335 | if (!empty($data['included_file'])) |
@@ -1361,7 +1361,7 @@ discard block |
||
1361 | 1361 | 'class' => 'nowrap', |
1362 | 1362 | ), |
1363 | 1363 | 'data' => array( |
1364 | - 'function' => function ($data) { |
|
1364 | + 'function' => function($data) { |
|
1365 | 1365 | return '<i class="icon i-post_moderation_' . $data['status'] . '" title="' . $data['img_text'] . '"></i>'; |
1366 | 1366 | }, |
1367 | 1367 | 'class' => 'centertext', |
@@ -231,7 +231,9 @@ discard block |
||
231 | 231 | |
232 | 232 | // Follow the sa or just go to administration. |
233 | 233 | if (isset($this->_req->query->sa) && !empty($subActions[$this->_req->query->sa])) |
234 | - $this->{$subActions[$this->_req->query->sa]}(); |
|
234 | + { |
|
235 | + $this->{$subActions[$this->_req->query->sa]}(); |
|
236 | + } |
|
235 | 237 | else |
236 | 238 | { |
237 | 239 | loadLanguage('Errors'); |
@@ -272,13 +274,18 @@ discard block |
||
272 | 274 | if (isset($this->_req->post->options['known_themes'])) |
273 | 275 | { |
274 | 276 | foreach ($this->_req->post->options['known_themes'] as $key => $id) |
275 | - $this->_req->post->options['known_themes'][$key] = (int) $id; |
|
277 | + { |
|
278 | + $this->_req->post->options['known_themes'][$key] = (int) $id; |
|
279 | + } |
|
280 | + } |
|
281 | + else { |
|
282 | + throw new Elk_Exception('themes_none_selectable', false); |
|
276 | 283 | } |
277 | - else |
|
278 | - throw new Elk_Exception('themes_none_selectable', false); |
|
279 | 284 | |
280 | 285 | if (!in_array($this->_req->post->options['theme_guests'], $this->_req->post->options['known_themes'])) |
281 | - throw new Elk_Exception('themes_default_selectable', false); |
|
286 | + { |
|
287 | + throw new Elk_Exception('themes_default_selectable', false); |
|
288 | + } |
|
282 | 289 | |
283 | 290 | // Commit the new settings. |
284 | 291 | updateSettings(array( |
@@ -316,7 +323,9 @@ discard block |
||
316 | 323 | $theme_dir = BOARDDIR . '/themes/theme'; |
317 | 324 | $i = 1; |
318 | 325 | while (file_exists($theme_dir . $i)) |
319 | - $i++; |
|
326 | + { |
|
327 | + $i++; |
|
328 | + } |
|
320 | 329 | $context['new_theme_name'] = 'theme' . $i; |
321 | 330 | |
322 | 331 | createToken('admin-tm'); |
@@ -338,7 +347,9 @@ discard block |
||
338 | 347 | loadLanguage('Admin'); |
339 | 348 | |
340 | 349 | if (isset($this->_req->query->th)) |
341 | - return $this->action_setthemesettings(); |
|
350 | + { |
|
351 | + return $this->action_setthemesettings(); |
|
352 | + } |
|
342 | 353 | |
343 | 354 | // Saving? |
344 | 355 | if (isset($this->_req->post->save)) |
@@ -369,7 +380,9 @@ discard block |
||
369 | 380 | } |
370 | 381 | |
371 | 382 | if (!empty($setValues)) |
372 | - updateThemeOptions($setValues); |
|
383 | + { |
|
384 | + updateThemeOptions($setValues); |
|
385 | + } |
|
373 | 386 | |
374 | 387 | redirectexit('action=admin;area=theme;sa=list;' . $context['session_var'] . '=' . $context['session_id']); |
375 | 388 | } |
@@ -392,7 +405,9 @@ discard block |
||
392 | 405 | |
393 | 406 | // Can we find a version comment, at all? |
394 | 407 | if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
395 | - $context['themes'][$i]['version'] = $match[1]; |
|
408 | + { |
|
409 | + $context['themes'][$i]['version'] = $match[1]; |
|
410 | + } |
|
396 | 411 | } |
397 | 412 | |
398 | 413 | $context['themes'][$i]['valid_path'] = file_exists($context['themes'][$i]['theme_dir']) && is_dir($context['themes'][$i]['theme_dir']); |
@@ -430,17 +445,23 @@ discard block |
||
430 | 445 | // How many options do we have setup for guests? |
431 | 446 | $guestOptions = countConfiguredGuestOptions(); |
432 | 447 | foreach ($guestOptions as $guest_option) |
433 | - $context['themes'][$guest_option['id_theme']]['num_default_options'] = $guest_option['value']; |
|
448 | + { |
|
449 | + $context['themes'][$guest_option['id_theme']]['num_default_options'] = $guest_option['value']; |
|
450 | + } |
|
434 | 451 | |
435 | 452 | // How many options do we have setup for members? |
436 | 453 | $memberOptions = countConfiguredMemberOptions(); |
437 | 454 | foreach ($memberOptions as $member_option) |
438 | - $context['themes'][$member_option['id_theme']]['num_members'] = $member_option['value']; |
|
455 | + { |
|
456 | + $context['themes'][$member_option['id_theme']]['num_members'] = $member_option['value']; |
|
457 | + } |
|
439 | 458 | |
440 | 459 | // There has to be a Settings template! |
441 | 460 | foreach ($context['themes'] as $k => $v) |
442 | - if (empty($v['theme_dir']) || (!file_exists($v['theme_dir'] . '/Settings.template.php') && empty($v['num_members']))) |
|
461 | + { |
|
462 | + if (empty($v['theme_dir']) || (!file_exists($v['theme_dir'] . '/Settings.template.php') && empty($v['num_members']))) |
|
443 | 463 | unset($context['themes'][$k]); |
464 | + } |
|
444 | 465 | |
445 | 466 | loadTemplate('ManageThemes'); |
446 | 467 | $context['sub_template'] = 'reset_list'; |
@@ -461,7 +482,9 @@ discard block |
||
461 | 482 | // Set up the query values. |
462 | 483 | $setValues = array(); |
463 | 484 | foreach ($this->_options as $opt => $val) |
464 | - $setValues[] = array($theme, -1, $opt, is_array($val) ? implode(',', $val) : $val); |
|
485 | + { |
|
486 | + $setValues[] = array($theme, -1, $opt, is_array($val) ? implode(',', $val) : $val); |
|
487 | + } |
|
465 | 488 | |
466 | 489 | $old_settings = array(); |
467 | 490 | foreach ($this->_default_options as $opt => $val) |
@@ -475,7 +498,9 @@ discard block |
||
475 | 498 | { |
476 | 499 | // Are there options in non-default themes set that should be cleared? |
477 | 500 | if (!empty($old_settings)) |
478 | - removeThemeOptions('custom', 'guests', $old_settings); |
|
501 | + { |
|
502 | + removeThemeOptions('custom', 'guests', $old_settings); |
|
503 | + } |
|
479 | 504 | |
480 | 505 | updateThemeOptions($setValues); |
481 | 506 | } |
@@ -502,7 +527,9 @@ discard block |
||
502 | 527 | foreach ($this->_default_options as $opt => $val) |
503 | 528 | { |
504 | 529 | if ($this->_default_options_master[$opt] == 0) |
505 | - continue; |
|
530 | + { |
|
531 | + continue; |
|
532 | + } |
|
506 | 533 | elseif ($this->_default_options_master[$opt] == 1) |
507 | 534 | { |
508 | 535 | // Delete then insert for ease of database compatibility! |
@@ -512,17 +539,23 @@ discard block |
||
512 | 539 | $old_settings[] = $opt; |
513 | 540 | } |
514 | 541 | elseif ($this->_default_options_master[$opt] == 2) |
515 | - removeThemeOptions('all', 'members', $opt); |
|
542 | + { |
|
543 | + removeThemeOptions('all', 'members', $opt); |
|
544 | + } |
|
516 | 545 | } |
517 | 546 | |
518 | 547 | // Delete options from other themes. |
519 | 548 | if (!empty($old_settings)) |
520 | - removeThemeOptions('custom', 'members', $old_settings); |
|
549 | + { |
|
550 | + removeThemeOptions('custom', 'members', $old_settings); |
|
551 | + } |
|
521 | 552 | |
522 | 553 | foreach ($this->_options as $opt => $val) |
523 | 554 | { |
524 | 555 | if ($this->_options_master[$opt] == 0) |
525 | - continue; |
|
556 | + { |
|
557 | + continue; |
|
558 | + } |
|
526 | 559 | elseif ($this->_options_master[$opt] == 1) |
527 | 560 | { |
528 | 561 | // Delete then insert for ease of database compatibility - again! |
@@ -530,7 +563,9 @@ discard block |
||
530 | 563 | addThemeOptions($theme, $opt, $val); |
531 | 564 | } |
532 | 565 | elseif ($this->_options_master[$opt] == 2) |
533 | - removeThemeOptions($theme, 'all', $opt); |
|
566 | + { |
|
567 | + removeThemeOptions($theme, 'all', $opt); |
|
568 | + } |
|
534 | 569 | } |
535 | 570 | |
536 | 571 | redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=reset'); |
@@ -594,14 +629,22 @@ discard block |
||
594 | 629 | |
595 | 630 | // Type of field so we display the right input field |
596 | 631 | if (!isset($setting['type']) || $setting['type'] === 'bool') |
597 | - $context['options'][$i]['type'] = 'checkbox'; |
|
632 | + { |
|
633 | + $context['options'][$i]['type'] = 'checkbox'; |
|
634 | + } |
|
598 | 635 | elseif ($setting['type'] === 'int' || $setting['type'] === 'integer') |
599 | - $context['options'][$i]['type'] = 'number'; |
|
636 | + { |
|
637 | + $context['options'][$i]['type'] = 'number'; |
|
638 | + } |
|
600 | 639 | elseif ($setting['type'] === 'string') |
601 | - $context['options'][$i]['type'] = 'text'; |
|
640 | + { |
|
641 | + $context['options'][$i]['type'] = 'text'; |
|
642 | + } |
|
602 | 643 | |
603 | 644 | if (isset($setting['options'])) |
604 | - $context['options'][$i]['type'] = 'list'; |
|
645 | + { |
|
646 | + $context['options'][$i]['type'] = 'list'; |
|
647 | + } |
|
605 | 648 | |
606 | 649 | $context['options'][$i]['value'] = !isset($context['theme_options'][$setting['id']]) ? '' : $context['theme_options'][$setting['id']]; |
607 | 650 | } |
@@ -635,14 +678,18 @@ discard block |
||
635 | 678 | |
636 | 679 | // Nothing chosen, back to the start you go |
637 | 680 | if (empty($this->_req->query->th) && empty($this->_req->query->id)) |
638 | - return $this->action_admin(); |
|
681 | + { |
|
682 | + return $this->action_admin(); |
|
683 | + } |
|
639 | 684 | |
640 | 685 | // The theme's ID is needed |
641 | 686 | $theme = $this->_req->getQuery('th', 'intval', $this->_req->getQuery('id', 'intval', 0)); |
642 | 687 | |
643 | 688 | // Validate inputs/user. |
644 | 689 | if (empty($theme)) |
645 | - throw new Elk_Exception('no_theme', false); |
|
690 | + { |
|
691 | + throw new Elk_Exception('no_theme', false); |
|
692 | + } |
|
646 | 693 | |
647 | 694 | // Select the best fitting tab. |
648 | 695 | $context[$context['admin_menu_name']]['current_subsection'] = 'list'; |
@@ -655,7 +702,9 @@ discard block |
||
655 | 702 | '' => $txt['smileys_no_default'] |
656 | 703 | ); |
657 | 704 | foreach ($sets as $i => $set) |
658 | - $context['smiley_sets'][$set] = htmlspecialchars($set_names[$i], ENT_COMPAT, 'UTF-8'); |
|
705 | + { |
|
706 | + $context['smiley_sets'][$set] = htmlspecialchars($set_names[$i], ENT_COMPAT, 'UTF-8'); |
|
707 | + } |
|
659 | 708 | |
660 | 709 | $old_id = $settings['theme_id']; |
661 | 710 | $old_settings = $settings; |
@@ -678,7 +727,9 @@ discard block |
||
678 | 727 | { |
679 | 728 | $file_contents = implode("\n", file($settings['theme_dir'] . '/index.template.php')); |
680 | 729 | if (preg_match('~\'theme_variants\'\s*=>(.+?\)),$~sm', $file_contents, $matches)) |
681 | - eval('global $settings; $settings[\'theme_variants\'] = ' . $matches[1] . ';'); |
|
730 | + { |
|
731 | + eval('global $settings; $settings[\'theme_variants\'] = ' . $matches[1] . ';'); |
|
732 | + } |
|
682 | 733 | |
683 | 734 | call_integration_hook('integrate_init_theme', array($theme, &$settings)); |
684 | 735 | } |
@@ -699,33 +750,47 @@ discard block |
||
699 | 750 | { |
700 | 751 | // Unwatch this item if this is just a separator. |
701 | 752 | if (!is_array($item)) |
702 | - continue; |
|
753 | + { |
|
754 | + continue; |
|
755 | + } |
|
703 | 756 | |
704 | 757 | // Clean them up for the database |
705 | 758 | foreach (array('options', 'default_options') as $option) |
706 | 759 | { |
707 | 760 | if (!isset($options[$option][$item['id']])) |
708 | - continue; |
|
761 | + { |
|
762 | + continue; |
|
763 | + } |
|
709 | 764 | // Checkbox. |
710 | 765 | elseif (empty($item['type'])) |
711 | - $options[$option][$item['id']] = $options[$option][$item['id']] ? 1 : 0; |
|
766 | + { |
|
767 | + $options[$option][$item['id']] = $options[$option][$item['id']] ? 1 : 0; |
|
768 | + } |
|
712 | 769 | // Number |
713 | 770 | elseif ($item['type'] === 'number') |
714 | - $options[$option][$item['id']] = (int) $options[$option][$item['id']]; |
|
771 | + { |
|
772 | + $options[$option][$item['id']] = (int) $options[$option][$item['id']]; |
|
773 | + } |
|
715 | 774 | } |
716 | 775 | } |
717 | 776 | |
718 | 777 | // Set up the sql query. |
719 | 778 | $inserts = array(); |
720 | 779 | foreach ($options['options'] as $opt => $val) |
721 | - $inserts[] = array($theme, 0, $opt, is_array($val) ? implode(',', $val) : $val); |
|
780 | + { |
|
781 | + $inserts[] = array($theme, 0, $opt, is_array($val) ? implode(',', $val) : $val); |
|
782 | + } |
|
722 | 783 | |
723 | 784 | foreach ($options['default_options'] as $opt => $val) |
724 | - $inserts[] = array(1, 0, $opt, is_array($val) ? implode(',', $val) : $val); |
|
785 | + { |
|
786 | + $inserts[] = array(1, 0, $opt, is_array($val) ? implode(',', $val) : $val); |
|
787 | + } |
|
725 | 788 | |
726 | 789 | // If we're actually inserting something.. |
727 | 790 | if (!empty($inserts)) |
728 | - updateThemeOptions($inserts); |
|
791 | + { |
|
792 | + updateThemeOptions($inserts); |
|
793 | + } |
|
729 | 794 | |
730 | 795 | // Clear and Invalidate the cache. |
731 | 796 | Cache::instance()->remove('theme_settings-' . $theme); |
@@ -741,7 +806,9 @@ discard block |
||
741 | 806 | foreach ($settings as $setting => $dummy) |
742 | 807 | { |
743 | 808 | if (!in_array($setting, array('theme_url', 'theme_dir', 'images_url', 'template_dirs'))) |
744 | - $settings[$setting] = htmlspecialchars__recursive($settings[$setting]); |
|
809 | + { |
|
810 | + $settings[$setting] = htmlspecialchars__recursive($settings[$setting]); |
|
811 | + } |
|
745 | 812 | } |
746 | 813 | |
747 | 814 | $context['settings'] = $context['theme_settings']; |
@@ -751,18 +818,28 @@ discard block |
||
751 | 818 | { |
752 | 819 | // Separators are dummies, so leave them alone. |
753 | 820 | if (!is_array($setting)) |
754 | - continue; |
|
821 | + { |
|
822 | + continue; |
|
823 | + } |
|
755 | 824 | |
756 | 825 | // Create the right input fields for the data |
757 | 826 | if (!isset($setting['type']) || $setting['type'] === 'bool') |
758 | - $context['settings'][$i]['type'] = 'checkbox'; |
|
827 | + { |
|
828 | + $context['settings'][$i]['type'] = 'checkbox'; |
|
829 | + } |
|
759 | 830 | elseif ($setting['type'] === 'int' || $setting['type'] === 'integer') |
760 | - $context['settings'][$i]['type'] = 'number'; |
|
831 | + { |
|
832 | + $context['settings'][$i]['type'] = 'number'; |
|
833 | + } |
|
761 | 834 | elseif ($setting['type'] === 'string') |
762 | - $context['settings'][$i]['type'] = 'text'; |
|
835 | + { |
|
836 | + $context['settings'][$i]['type'] = 'text'; |
|
837 | + } |
|
763 | 838 | |
764 | 839 | if (isset($setting['options'])) |
765 | - $context['settings'][$i]['type'] = 'list'; |
|
840 | + { |
|
841 | + $context['settings'][$i]['type'] = 'list'; |
|
842 | + } |
|
766 | 843 | |
767 | 844 | $context['settings'][$i]['value'] = !isset($settings[$setting['id']]) ? '' : $settings[$setting['id']]; |
768 | 845 | } |
@@ -789,7 +866,9 @@ discard block |
||
789 | 866 | |
790 | 867 | // Reinit just incase. |
791 | 868 | if (function_exists('template_init')) |
792 | - $settings += template_init(); |
|
869 | + { |
|
870 | + $settings += template_init(); |
|
871 | + } |
|
793 | 872 | |
794 | 873 | loadTemplate('ManageThemes'); |
795 | 874 | |
@@ -820,14 +899,18 @@ discard block |
||
820 | 899 | |
821 | 900 | // You can't delete the default theme! |
822 | 901 | if ($theme == 1) |
823 | - throw new Elk_Exception('no_access', false); |
|
902 | + { |
|
903 | + throw new Elk_Exception('no_access', false); |
|
904 | + } |
|
824 | 905 | |
825 | 906 | // Its no longer known |
826 | 907 | $known = explode(',', $modSettings['knownThemes']); |
827 | 908 | for ($i = 0, $n = count($known); $i < $n; $i++) |
828 | 909 | { |
829 | 910 | if ($known[$i] == $theme) |
830 | - unset($known[$i]); |
|
911 | + { |
|
912 | + unset($known[$i]); |
|
913 | + } |
|
831 | 914 | } |
832 | 915 | $known = strtr(implode(',', $known), array(',,' => ',')); |
833 | 916 | |
@@ -836,9 +919,12 @@ discard block |
||
836 | 919 | |
837 | 920 | // Fix it if the theme was the overall default theme. |
838 | 921 | if ($modSettings['theme_guests'] == $theme) |
839 | - updateSettings(array('theme_guests' => '1', 'knownThemes' => $known)); |
|
840 | - else |
|
841 | - updateSettings(array('knownThemes' => $known)); |
|
922 | + { |
|
923 | + updateSettings(array('theme_guests' => '1', 'knownThemes' => $known)); |
|
924 | + } |
|
925 | + else { |
|
926 | + updateSettings(array('knownThemes' => $known)); |
|
927 | + } |
|
842 | 928 | |
843 | 929 | redirectexit('action=admin;area=theme;sa=list;' . $context['session_var'] . '=' . $context['session_id']); |
844 | 930 | } |
@@ -912,7 +998,9 @@ discard block |
||
912 | 998 | for ($i = 0, $n = count($known); $i < $n; $i++) |
913 | 999 | { |
914 | 1000 | if ($known[$i] == $theme) |
915 | - unset($known[$i]); |
|
1001 | + { |
|
1002 | + unset($known[$i]); |
|
1003 | + } |
|
916 | 1004 | } |
917 | 1005 | |
918 | 1006 | // Finally, remove it |
@@ -922,9 +1010,12 @@ discard block |
||
922 | 1010 | |
923 | 1011 | // Fix it if the theme was the overall default theme. |
924 | 1012 | if ($modSettings['theme_guests'] == $theme) |
925 | - updateSettings(array('theme_guests' => '1', 'knownThemes' => $known)); |
|
926 | - else |
|
927 | - updateSettings(array('knownThemes' => $known)); |
|
1013 | + { |
|
1014 | + updateSettings(array('theme_guests' => '1', 'knownThemes' => $known)); |
|
1015 | + } |
|
1016 | + else { |
|
1017 | + updateSettings(array('knownThemes' => $known)); |
|
1018 | + } |
|
928 | 1019 | |
929 | 1020 | // Let them know it worked, all without a page refresh |
930 | 1021 | createToken('admin-tr', 'request'); |
@@ -957,7 +1048,9 @@ discard block |
||
957 | 1048 | require_once(SUBSDIR . '/Themes.subs.php'); |
958 | 1049 | |
959 | 1050 | if (!$modSettings['theme_allow'] && $settings['disable_user_variant'] && !allowedTo('admin_forum')) |
960 | - throw new Elk_Exception('no_access', false); |
|
1051 | + { |
|
1052 | + throw new Elk_Exception('no_access', false); |
|
1053 | + } |
|
961 | 1054 | |
962 | 1055 | loadLanguage('Profile'); |
963 | 1056 | loadTemplate('ManageThemes'); |
@@ -972,17 +1065,23 @@ discard block |
||
972 | 1065 | $_SESSION['id_theme'] = 0; |
973 | 1066 | |
974 | 1067 | if (isset($this->_req->query->id)) |
975 | - $this->_req->query->th = $this->_req->query->id; |
|
1068 | + { |
|
1069 | + $this->_req->query->th = $this->_req->query->id; |
|
1070 | + } |
|
976 | 1071 | |
977 | 1072 | // Saving a variant cause JS doesn't work - pretend it did ;) |
978 | 1073 | if (isset($this->_req->post->save)) |
979 | 1074 | { |
980 | 1075 | // Which theme? |
981 | 1076 | foreach ($this->_req->post->save as $k => $v) |
982 | - $this->_req->query->th = (int) $k; |
|
1077 | + { |
|
1078 | + $this->_req->query->th = (int) $k; |
|
1079 | + } |
|
983 | 1080 | |
984 | 1081 | if (isset($this->_req->post->vrt[$k])) |
985 | - $this->_req->query->vrt = $this->_req->post->vrt[$k]; |
|
1082 | + { |
|
1083 | + $this->_req->query->vrt = $this->_req->post->vrt[$k]; |
|
1084 | + } |
|
986 | 1085 | } |
987 | 1086 | |
988 | 1087 | // Have we made a decision, or are we just browsing? |
@@ -1030,7 +1129,9 @@ discard block |
||
1030 | 1129 | |
1031 | 1130 | // Remove any custom variants. |
1032 | 1131 | if (!empty($vrt)) |
1033 | - deleteVariants($th); |
|
1132 | + { |
|
1133 | + deleteVariants($th); |
|
1134 | + } |
|
1034 | 1135 | |
1035 | 1136 | redirectexit('action=admin;area=theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id']); |
1036 | 1137 | } |
@@ -1046,7 +1147,9 @@ discard block |
||
1046 | 1147 | { |
1047 | 1148 | // The forum's default theme is always 0 and we |
1048 | 1149 | if (isset($th) && $th == 0) |
1049 | - $th = $modSettings['theme_guests']; |
|
1150 | + { |
|
1151 | + $th = $modSettings['theme_guests']; |
|
1152 | + } |
|
1050 | 1153 | |
1051 | 1154 | require_once(SUBSDIR . '/Members.subs.php'); |
1052 | 1155 | updateMemberData($u, array('id_theme' => $th)); |
@@ -1057,7 +1160,9 @@ discard block |
||
1057 | 1160 | Cache::instance()->remove('theme_settings-' . $th . ':' . $u); |
1058 | 1161 | |
1059 | 1162 | if ($user_info['id'] == $u) |
1060 | - $_SESSION['id_variant'] = 0; |
|
1163 | + { |
|
1164 | + $_SESSION['id_variant'] = 0; |
|
1165 | + } |
|
1061 | 1166 | } |
1062 | 1167 | |
1063 | 1168 | redirectexit('action=profile;u=' . $u . ';area=theme'); |
@@ -1102,7 +1207,9 @@ discard block |
||
1102 | 1207 | if (!isset($u) || $u >= 0) |
1103 | 1208 | { |
1104 | 1209 | if ($guest_theme != 0) |
1105 | - $context['available_themes'][0] = $context['available_themes'][$guest_theme]; |
|
1210 | + { |
|
1211 | + $context['available_themes'][0] = $context['available_themes'][$guest_theme]; |
|
1212 | + } |
|
1106 | 1213 | |
1107 | 1214 | $context['available_themes'][0]['id'] = 0; |
1108 | 1215 | $context['available_themes'][0]['name'] = $txt['theme_forum_default']; |
@@ -1156,23 +1263,35 @@ discard block |
||
1156 | 1263 | |
1157 | 1264 | // How are we going to install this theme, from a dir, zip, copy of default? |
1158 | 1265 | if ((!empty($_FILES['theme_gz']) && (!isset($_FILES['theme_gz']['error']) || $_FILES['theme_gz']['error'] != 4)) || !empty($this->_req->query->theme_gz)) |
1159 | - $method = 'upload'; |
|
1266 | + { |
|
1267 | + $method = 'upload'; |
|
1268 | + } |
|
1160 | 1269 | elseif (isset($this->_req->post->theme_dir) && rtrim(realpath($this->_req->post->theme_dir), '/\\') != realpath(BOARDDIR . '/themes') && file_exists($this->_req->post->theme_dir)) |
1161 | - $method = 'path'; |
|
1162 | - else |
|
1163 | - $method = 'copy'; |
|
1270 | + { |
|
1271 | + $method = 'path'; |
|
1272 | + } |
|
1273 | + else { |
|
1274 | + $method = 'copy'; |
|
1275 | + } |
|
1164 | 1276 | |
1165 | 1277 | // Copy the default theme? |
1166 | 1278 | if (!empty($this->_req->post->copy) && $method === 'copy') |
1167 | - $this->copyDefault(); |
|
1279 | + { |
|
1280 | + $this->copyDefault(); |
|
1281 | + } |
|
1168 | 1282 | // Install from another directory |
1169 | 1283 | elseif (isset($this->_req->post->theme_dir) && $method === 'path') |
1170 | - $this->installFromDir(); |
|
1284 | + { |
|
1285 | + $this->installFromDir(); |
|
1286 | + } |
|
1171 | 1287 | // Uploaded a zip file to install from |
1172 | 1288 | elseif ($method === 'upload') |
1173 | - $this->installFromZip(); |
|
1174 | - else |
|
1175 | - throw new Elk_Exception('theme_install_general', false); |
|
1289 | + { |
|
1290 | + $this->installFromZip(); |
|
1291 | + } |
|
1292 | + else { |
|
1293 | + throw new Elk_Exception('theme_install_general', false); |
|
1294 | + } |
|
1176 | 1295 | |
1177 | 1296 | // Something go wrong? |
1178 | 1297 | if ($this->theme_dir != '' && basename($this->theme_dir) !== 'themes') |
@@ -1195,7 +1314,9 @@ discard block |
||
1195 | 1314 | |
1196 | 1315 | // @todo Error message of some sort? |
1197 | 1316 | if (!$theme_info_xml->exists('theme-info[0]')) |
1198 | - return 'package_get_error_packageinfo_corrupt'; |
|
1317 | + { |
|
1318 | + return 'package_get_error_packageinfo_corrupt'; |
|
1319 | + } |
|
1199 | 1320 | |
1200 | 1321 | $theme_info_xml = $theme_info_xml->path('theme-info[0]'); |
1201 | 1322 | $theme_info_xml = $theme_info_xml->to_array(); |
@@ -1209,7 +1330,9 @@ discard block |
||
1209 | 1330 | foreach ($xml_elements as $var => $name) |
1210 | 1331 | { |
1211 | 1332 | if (!empty($theme_info_xml[$name])) |
1212 | - $install_info[$var] = $theme_info_xml[$name]; |
|
1333 | + { |
|
1334 | + $install_info[$var] = $theme_info_xml[$name]; |
|
1335 | + } |
|
1213 | 1336 | } |
1214 | 1337 | |
1215 | 1338 | if (!empty($theme_info_xml['images'])) |
@@ -1219,7 +1342,9 @@ discard block |
||
1219 | 1342 | } |
1220 | 1343 | |
1221 | 1344 | if (!empty($theme_info_xml['extra'])) |
1222 | - $install_info += Util::unserialize($theme_info_xml['extra']); |
|
1345 | + { |
|
1346 | + $install_info += Util::unserialize($theme_info_xml['extra']); |
|
1347 | + } |
|
1223 | 1348 | } |
1224 | 1349 | |
1225 | 1350 | if (isset($install_info['based_on'])) |
@@ -1241,7 +1366,9 @@ discard block |
||
1241 | 1366 | $install_info = $temp + $install_info; |
1242 | 1367 | |
1243 | 1368 | if (empty($explicit_images) && !empty($install_info['base_theme_url'])) |
1244 | - $install_info['theme_url'] = $install_info['base_theme_url']; |
|
1369 | + { |
|
1370 | + $install_info['theme_url'] = $install_info['base_theme_url']; |
|
1371 | + } |
|
1245 | 1372 | } |
1246 | 1373 | } |
1247 | 1374 | |
@@ -1253,10 +1380,14 @@ discard block |
||
1253 | 1380 | |
1254 | 1381 | $inserts = array(); |
1255 | 1382 | foreach ($install_info as $var => $val) |
1256 | - $inserts[] = array($id_theme, $var, $val); |
|
1383 | + { |
|
1384 | + $inserts[] = array($id_theme, $var, $val); |
|
1385 | + } |
|
1257 | 1386 | |
1258 | 1387 | if (!empty($inserts)) |
1259 | - addTheme($inserts); |
|
1388 | + { |
|
1389 | + addTheme($inserts); |
|
1390 | + } |
|
1260 | 1391 | |
1261 | 1392 | updateSettings(array('knownThemes' => strtr($modSettings['knownThemes'] . ',' . $id_theme, array(',,' => ',')))); |
1262 | 1393 | |
@@ -1273,11 +1404,15 @@ discard block |
||
1273 | 1404 | { |
1274 | 1405 | // Hopefully the themes directory is writable, or we might have a problem. |
1275 | 1406 | if (!is_writable(BOARDDIR . '/themes')) |
1276 | - throw new Elk_Exception('theme_install_write_error', 'critical'); |
|
1407 | + { |
|
1408 | + throw new Elk_Exception('theme_install_write_error', 'critical'); |
|
1409 | + } |
|
1277 | 1410 | |
1278 | 1411 | // This happens when the admin session is gone and the user has to login again |
1279 | 1412 | if (empty($_FILES['theme_gz']) && empty($this->_req->post->theme_gz)) |
1280 | - return; |
|
1413 | + { |
|
1414 | + return; |
|
1415 | + } |
|
1281 | 1416 | |
1282 | 1417 | // Set the default settings... |
1283 | 1418 | $this->theme_name = strtok(basename(isset($_FILES['theme_gz']) ? $_FILES['theme_gz']['name'] : $this->_req->post->theme_gz), '.'); |
@@ -1285,11 +1420,15 @@ discard block |
||
1285 | 1420 | $this->theme_dir = BOARDDIR . '/themes/' . $this->theme_name; |
1286 | 1421 | |
1287 | 1422 | if (isset($_FILES['theme_gz']) && is_uploaded_file($_FILES['theme_gz']['tmp_name']) && (ini_get('open_basedir') != '' || file_exists($_FILES['theme_gz']['tmp_name']))) |
1288 | - read_tgz_file($_FILES['theme_gz']['tmp_name'], BOARDDIR . '/themes/' . $this->theme_name, false, true); |
|
1423 | + { |
|
1424 | + read_tgz_file($_FILES['theme_gz']['tmp_name'], BOARDDIR . '/themes/' . $this->theme_name, false, true); |
|
1425 | + } |
|
1289 | 1426 | elseif (isset($this->_req->post->theme_gz)) |
1290 | 1427 | { |
1291 | 1428 | if (!isAuthorizedServer($this->_req->post->theme_gz)) |
1292 | - throw new Elk_Exception('not_valid_server'); |
|
1429 | + { |
|
1430 | + throw new Elk_Exception('not_valid_server'); |
|
1431 | + } |
|
1293 | 1432 | |
1294 | 1433 | read_tgz_file($this->_req->post->theme_gz, BOARDDIR . '/themes/' . $this->theme_name, false, true); |
1295 | 1434 | } |
@@ -1303,7 +1442,9 @@ discard block |
||
1303 | 1442 | public function installFromDir() |
1304 | 1443 | { |
1305 | 1444 | if (!is_dir($this->_req->post->theme_dir) || !file_exists($this->_req->post->theme_dir . '/theme_info.xml')) |
1306 | - throw new Elk_Exception('theme_install_error', false); |
|
1445 | + { |
|
1446 | + throw new Elk_Exception('theme_install_error', false); |
|
1447 | + } |
|
1307 | 1448 | |
1308 | 1449 | $this->theme_name = basename($this->_req->post->theme_dir); |
1309 | 1450 | $this->theme_dir = $this->_req->post->theme_dir; |
@@ -1318,7 +1459,9 @@ discard block |
||
1318 | 1459 | |
1319 | 1460 | // Hopefully the themes directory is writable, or we might have a problem. |
1320 | 1461 | if (!is_writable(BOARDDIR . '/themes')) |
1321 | - throw new Elk_Exception('theme_install_write_error', 'critical'); |
|
1462 | + { |
|
1463 | + throw new Elk_Exception('theme_install_write_error', 'critical'); |
|
1464 | + } |
|
1322 | 1465 | |
1323 | 1466 | // Make the new directory, standard characters only |
1324 | 1467 | $this->theme_dir = BOARDDIR . '/themes/' . preg_replace('~[^A-Za-z0-9_\- ]~', '', $this->_req->post->copy); |
@@ -1380,11 +1523,15 @@ discard block |
||
1380 | 1523 | |
1381 | 1524 | // This good-for-nothing pixel is being used to keep the session alive. |
1382 | 1525 | if (empty($this->_req->query->var) || !isset($this->_req->query->val)) |
1383 | - redirectexit($settings['images_url'] . '/blank.png'); |
|
1526 | + { |
|
1527 | + redirectexit($settings['images_url'] . '/blank.png'); |
|
1528 | + } |
|
1384 | 1529 | |
1385 | 1530 | // Sorry, guests can't go any further than this.. |
1386 | 1531 | if ($user_info['is_guest'] || $user_info['id'] == 0) |
1387 | - obExit(false); |
|
1532 | + { |
|
1533 | + obExit(false); |
|
1534 | + } |
|
1388 | 1535 | |
1389 | 1536 | $reservedVars = array( |
1390 | 1537 | 'actual_theme_url', |
@@ -1408,7 +1555,9 @@ discard block |
||
1408 | 1555 | |
1409 | 1556 | // Can't change reserved vars. |
1410 | 1557 | if (in_array(strtolower($this->_req->query->var), $reservedVars)) |
1411 | - redirectexit($settings['images_url'] . '/blank.png'); |
|
1558 | + { |
|
1559 | + redirectexit($settings['images_url'] . '/blank.png'); |
|
1560 | + } |
|
1412 | 1561 | |
1413 | 1562 | // Use a specific theme? |
1414 | 1563 | if (isset($this->_req->query->th) || isset($this->_req->query->id)) |
@@ -1439,7 +1588,9 @@ discard block |
||
1439 | 1588 | |
1440 | 1589 | // New thingy... |
1441 | 1590 | if (isset($this->_req->query->admin_key) && strlen($this->_req->query->admin_key) < 5) |
1442 | - $options['admin_preferences'][$this->_req->query->admin_key] = $this->_req->query->val; |
|
1591 | + { |
|
1592 | + $options['admin_preferences'][$this->_req->query->admin_key] = $this->_req->query->val; |
|
1593 | + } |
|
1443 | 1594 | |
1444 | 1595 | // Change the value to be something nice, |
1445 | 1596 | $this->_req->query->val = json_encode($options['admin_preferences']); |
@@ -1464,7 +1615,9 @@ discard block |
||
1464 | 1615 | |
1465 | 1616 | // New value for them |
1466 | 1617 | if (isset($this->_req->query->minmax_key) && strlen($this->_req->query->minmax_key) < 10) |
1467 | - $minmax_preferences[$this->_req->query->minmax_key] = $this->_req->query->val; |
|
1618 | + { |
|
1619 | + $minmax_preferences[$this->_req->query->minmax_key] = $this->_req->query->val; |
|
1620 | + } |
|
1468 | 1621 | |
1469 | 1622 | // Change the value to be something nice, |
1470 | 1623 | $this->_req->query->val = json_encode($minmax_preferences); |
@@ -1506,10 +1659,14 @@ discard block |
||
1506 | 1659 | |
1507 | 1660 | // Unfortunately we cannot edit an unknown theme.. redirect. |
1508 | 1661 | if (empty($selectedTheme)) |
1509 | - redirectexit('action=admin;area=theme;sa=themelist'); |
|
1662 | + { |
|
1663 | + redirectexit('action=admin;area=theme;sa=themelist'); |
|
1664 | + } |
|
1510 | 1665 | // You're browsing around, aren't you |
1511 | 1666 | elseif (!isset($this->_req->query->filename) && !isset($this->_req->post->save)) |
1512 | - redirectexit('action=admin;area=theme;sa=browse;th=' . $selectedTheme); |
|
1667 | + { |
|
1668 | + redirectexit('action=admin;area=theme;sa=browse;th=' . $selectedTheme); |
|
1669 | + } |
|
1513 | 1670 | |
1514 | 1671 | // We don't have errors. Yet. |
1515 | 1672 | $context['session_error'] = false; |
@@ -1534,11 +1691,16 @@ discard block |
||
1534 | 1691 | // Note: we're here sending $theme_dir as parameter to action_() |
1535 | 1692 | // controller functions, which isn't cool. To be refactored. |
1536 | 1693 | if (substr($this->_req->query->filename, -4) === '.css') |
1537 | - $this->_action_edit_style(); |
|
1694 | + { |
|
1695 | + $this->_action_edit_style(); |
|
1696 | + } |
|
1538 | 1697 | elseif (substr($this->_req->query->filename, -13) === '.template.php') |
1539 | - $this->_action_edit_template(); |
|
1540 | - else |
|
1541 | - $this->_action_edit_file(); |
|
1698 | + { |
|
1699 | + $this->_action_edit_template(); |
|
1700 | + } |
|
1701 | + else { |
|
1702 | + $this->_action_edit_file(); |
|
1703 | + } |
|
1542 | 1704 | |
1543 | 1705 | // Create a special token to allow editing of multiple files. |
1544 | 1706 | createToken('admin-te-' . md5($selectedTheme . '-' . $this->_req->query->filename)); |
@@ -1595,7 +1757,9 @@ discard block |
||
1595 | 1757 | $context['file_parts'][$j]['data'] = trim($context['file_parts'][$j]['data']); |
1596 | 1758 | |
1597 | 1759 | if (empty($context['file_parts'][$j]['lines'])) |
1598 | - unset($context['file_parts'][$j]); |
|
1760 | + { |
|
1761 | + unset($context['file_parts'][$j]); |
|
1762 | + } |
|
1599 | 1763 | |
1600 | 1764 | // Start a new function block |
1601 | 1765 | $context['file_parts'][++$j] = array('lines' => 0, 'line' => $i, 'data' => ''); |
@@ -1663,9 +1827,12 @@ discard block |
||
1663 | 1827 | { |
1664 | 1828 | // Consolidate the format in which we received the file contents |
1665 | 1829 | if (is_array($file)) |
1666 | - $entire_file = implode("\n", $file); |
|
1667 | - else |
|
1668 | - $entire_file = $file; |
|
1830 | + { |
|
1831 | + $entire_file = implode("\n", $file); |
|
1832 | + } |
|
1833 | + else { |
|
1834 | + $entire_file = $file; |
|
1835 | + } |
|
1669 | 1836 | |
1670 | 1837 | // Convert our tabs back to tabs! |
1671 | 1838 | $entire_file = rtrim(strtr($entire_file, array("\r" => '', ' ' => "\t"))); |
@@ -1717,7 +1884,9 @@ discard block |
||
1717 | 1884 | fclose($fp); |
1718 | 1885 | |
1719 | 1886 | if ($this->_checkOpcache()) |
1720 | - opcache_invalidate($theme_dir . '/' . $_REQUEST['filename']); |
|
1887 | + { |
|
1888 | + opcache_invalidate($theme_dir . '/' . $_REQUEST['filename']); |
|
1889 | + } |
|
1721 | 1890 | |
1722 | 1891 | // We're done here. |
1723 | 1892 | redirectexit('action=admin;area=theme;th=' . $selectedTheme . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=browse;directory=' . dirname($this->_req->post->filename)); |
@@ -1727,17 +1896,24 @@ discard block |
||
1727 | 1896 | { |
1728 | 1897 | // Pick the right sub-template for the next try |
1729 | 1898 | if ($is_template) |
1730 | - $context['sub_template'] = 'edit_template'; |
|
1731 | - else |
|
1732 | - $context['sub_template'] = 'edit_file'; |
|
1899 | + { |
|
1900 | + $context['sub_template'] = 'edit_template'; |
|
1901 | + } |
|
1902 | + else { |
|
1903 | + $context['sub_template'] = 'edit_file'; |
|
1904 | + } |
|
1733 | 1905 | |
1734 | 1906 | // Fill contextual data for the template, the errors to show |
1735 | 1907 | foreach ($errors as $error) |
1736 | - $context['parse_error'][] = $error; |
|
1908 | + { |
|
1909 | + $context['parse_error'][] = $error; |
|
1910 | + } |
|
1737 | 1911 | |
1738 | 1912 | // The format of the data depends on template/non-template file. |
1739 | 1913 | if (!is_array($file)) |
1740 | - $file = array($file); |
|
1914 | + { |
|
1915 | + $file = array($file); |
|
1916 | + } |
|
1741 | 1917 | |
1742 | 1918 | // Send back the file contents |
1743 | 1919 | $context['entire_file'] = htmlspecialchars(strtr(implode('', $file), array("\t" => ' ')), ENT_COMPAT, 'UTF-8'); |
@@ -1764,15 +1940,20 @@ discard block |
||
1764 | 1940 | |
1765 | 1941 | // Recycle the submitted data. |
1766 | 1942 | if (is_array($file)) |
1767 | - $context['entire_file'] = htmlspecialchars(implode("\n", $file), ENT_COMPAT, 'UTF-8'); |
|
1768 | - else |
|
1769 | - $context['entire_file'] = htmlspecialchars($file, ENT_COMPAT, 'UTF-8'); |
|
1943 | + { |
|
1944 | + $context['entire_file'] = htmlspecialchars(implode("\n", $file), ENT_COMPAT, 'UTF-8'); |
|
1945 | + } |
|
1946 | + else { |
|
1947 | + $context['entire_file'] = htmlspecialchars($file, ENT_COMPAT, 'UTF-8'); |
|
1948 | + } |
|
1770 | 1949 | |
1771 | 1950 | $context['edit_filename'] = htmlspecialchars($this->_req->post->filename, ENT_COMPAT, 'UTF-8'); |
1772 | 1951 | |
1773 | 1952 | // Choose sub-template |
1774 | 1953 | if ($is_template) |
1775 | - $context['sub_template'] = 'edit_template'; |
|
1954 | + { |
|
1955 | + $context['sub_template'] = 'edit_template'; |
|
1956 | + } |
|
1776 | 1957 | elseif ($is_css) |
1777 | 1958 | { |
1778 | 1959 | addJavascriptVar(array( |
@@ -1784,8 +1965,9 @@ discard block |
||
1784 | 1965 | )); |
1785 | 1966 | $context['sub_template'] = 'edit_style'; |
1786 | 1967 | } |
1787 | - else |
|
1788 | - $context['sub_template'] = 'edit_file'; |
|
1968 | + else { |
|
1969 | + $context['sub_template'] = 'edit_file'; |
|
1970 | + } |
|
1789 | 1971 | |
1790 | 1972 | // Re-create the token so that it can be used |
1791 | 1973 | createToken('admin-te-' . md5($selectedTheme . '-' . $this->_req->post->filename)); |
@@ -1824,7 +2006,9 @@ discard block |
||
1824 | 2006 | |
1825 | 2007 | $selectedTheme = $this->_req->getQuery('th', 'intval', $this->_req->getQuery('id', 'intval', 0)); |
1826 | 2008 | if (empty($selectedTheme)) |
1827 | - redirectexit('action=admin;area=theme;sa=themelist'); |
|
2009 | + { |
|
2010 | + redirectexit('action=admin;area=theme;sa=themelist'); |
|
2011 | + } |
|
1828 | 2012 | |
1829 | 2013 | // Get first the directory of the theme we are editing. |
1830 | 2014 | $context['theme_id'] = isset($this->_req->query->th) ? (int) $this->_req->query->th : (isset($this->_req->query->id) ? (int) $this->_req->query->id : 0); |
@@ -1832,20 +2016,26 @@ discard block |
||
1832 | 2016 | |
1833 | 2017 | // Eh? not trying to sneak a peek outside the theme directory are we |
1834 | 2018 | if (!file_exists($theme_dir . '/index.template.php') && !file_exists($theme_dir . '/css/index.css')) |
1835 | - throw new Elk_Exception('theme_edit_missing', false); |
|
2019 | + { |
|
2020 | + throw new Elk_Exception('theme_edit_missing', false); |
|
2021 | + } |
|
1836 | 2022 | |
1837 | 2023 | // Now, where exactly are you? |
1838 | 2024 | if (isset($this->_req->query->directory)) |
1839 | 2025 | { |
1840 | 2026 | if (substr($this->_req->query->directory, 0, 1) === '.') |
1841 | - $this->_req->query->directory = ''; |
|
2027 | + { |
|
2028 | + $this->_req->query->directory = ''; |
|
2029 | + } |
|
1842 | 2030 | else |
1843 | 2031 | { |
1844 | 2032 | $this->_req->query->directory = preg_replace(array('~^[\./\\:\0\n\r]+~', '~[\\\\]~', '~/[\./]+~'), array('', '/', '/'), $this->_req->query->directory); |
1845 | 2033 | |
1846 | 2034 | $temp = realpath($theme_dir . '/' . $this->_req->query->directory); |
1847 | 2035 | if (empty($temp) || substr($temp, 0, strlen(realpath($theme_dir))) != realpath($theme_dir)) |
1848 | - $this->_req->query->directory = ''; |
|
2036 | + { |
|
2037 | + $this->_req->query->directory = ''; |
|
2038 | + } |
|
1849 | 2039 | } |
1850 | 2040 | } |
1851 | 2041 | |
@@ -1865,8 +2055,9 @@ discard block |
||
1865 | 2055 | 'size' => '', |
1866 | 2056 | )); |
1867 | 2057 | } |
1868 | - else |
|
1869 | - $context['theme_files'] = get_file_listing($theme_dir, ''); |
|
2058 | + else { |
|
2059 | + $context['theme_files'] = get_file_listing($theme_dir, ''); |
|
2060 | + } |
|
1870 | 2061 | |
1871 | 2062 | // finally, load the sub-template |
1872 | 2063 | $context['sub_template'] = 'browse'; |
@@ -1891,19 +2082,26 @@ discard block |
||
1891 | 2082 | { |
1892 | 2083 | // There has to be a Settings template! |
1893 | 2084 | if (!file_exists($theme['theme_dir'] . '/index.template.php') && !file_exists($theme['theme_dir'] . '/css/index.css')) |
1894 | - unset($context['themes'][$key]); |
|
2085 | + { |
|
2086 | + unset($context['themes'][$key]); |
|
2087 | + } |
|
1895 | 2088 | else |
1896 | 2089 | { |
1897 | 2090 | if (!isset($theme['theme_templates'])) |
1898 | - $templates = array('index'); |
|
1899 | - else |
|
1900 | - $templates = explode(',', $theme['theme_templates']); |
|
2091 | + { |
|
2092 | + $templates = array('index'); |
|
2093 | + } |
|
2094 | + else { |
|
2095 | + $templates = explode(',', $theme['theme_templates']); |
|
2096 | + } |
|
1901 | 2097 | |
1902 | 2098 | foreach ($templates as $template) |
1903 | - if (file_exists($theme['theme_dir'] . '/' . $template . '.template.php')) |
|
2099 | + { |
|
2100 | + if (file_exists($theme['theme_dir'] . '/' . $template . '.template.php')) |
|
1904 | 2101 | { |
1905 | 2102 | // Fetch the header... a good 256 bytes should be more than enough. |
1906 | 2103 | $fp = fopen($theme['theme_dir'] . '/' . $template . '.template.php', 'rb'); |
2104 | + } |
|
1907 | 2105 | $header = fread($fp, 256); |
1908 | 2106 | fclose($fp); |
1909 | 2107 | |
@@ -1912,7 +2110,9 @@ discard block |
||
1912 | 2110 | { |
1913 | 2111 | $ver = $match[1]; |
1914 | 2112 | if (!isset($context['themes'][$key]['version']) || $context['themes'][$key]['version'] > $ver) |
1915 | - $context['themes'][$key]['version'] = $ver; |
|
2113 | + { |
|
2114 | + $context['themes'][$key]['version'] = $ver; |
|
2115 | + } |
|
1916 | 2116 | } |
1917 | 2117 | } |
1918 | 2118 | |
@@ -1945,36 +2145,50 @@ discard block |
||
1945 | 2145 | if (isset($this->_req->query->template) && preg_match('~[\./\\\\:\0]~', $this->_req->query->template) == 0) |
1946 | 2146 | { |
1947 | 2147 | if (!empty($theme_dirs['base_theme_dir']) && file_exists($theme_dirs['base_theme_dir'] . '/' . $this->_req->query->template . '.template.php')) |
1948 | - $filename = $theme_dirs['base_theme_dir'] . '/' . $this->_req->query->template . '.template.php'; |
|
2148 | + { |
|
2149 | + $filename = $theme_dirs['base_theme_dir'] . '/' . $this->_req->query->template . '.template.php'; |
|
2150 | + } |
|
1949 | 2151 | elseif (file_exists($settings['default_theme_dir'] . '/' . $this->_req->query->template . '.template.php')) |
1950 | - $filename = $settings['default_theme_dir'] . '/' . $this->_req->query->template . '.template.php'; |
|
1951 | - else |
|
1952 | - throw new Elk_Exception('no_access', false); |
|
2152 | + { |
|
2153 | + $filename = $settings['default_theme_dir'] . '/' . $this->_req->query->template . '.template.php'; |
|
2154 | + } |
|
2155 | + else { |
|
2156 | + throw new Elk_Exception('no_access', false); |
|
2157 | + } |
|
1953 | 2158 | |
1954 | 2159 | $fp = fopen($theme_dirs['theme_dir'] . '/' . $this->_req->query->template . '.template.php', 'w'); |
1955 | 2160 | fwrite($fp, file_get_contents($filename)); |
1956 | 2161 | fclose($fp); |
1957 | 2162 | |
1958 | 2163 | if ($this->_checkOpcache()) |
1959 | - opcache_invalidate($filename); |
|
2164 | + { |
|
2165 | + opcache_invalidate($filename); |
|
2166 | + } |
|
1960 | 2167 | |
1961 | 2168 | redirectexit('action=admin;area=theme;th=' . $context['theme_id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=copy'); |
1962 | 2169 | } |
1963 | 2170 | elseif (isset($this->_req->query->lang_file) && preg_match('~^[^\./\\\\:\0]\.[^\./\\\\:\0]$~', $this->_req->query->lang_file) != 0) |
1964 | 2171 | { |
1965 | 2172 | if (!empty($theme_dirs['base_theme_dir']) && file_exists($theme_dirs['base_theme_dir'] . '/languages/' . $this->_req->query->lang_file . '.php')) |
1966 | - $filename = $theme_dirs['base_theme_dir'] . '/languages/' . $this->_req->query->template . '.php'; |
|
2173 | + { |
|
2174 | + $filename = $theme_dirs['base_theme_dir'] . '/languages/' . $this->_req->query->template . '.php'; |
|
2175 | + } |
|
1967 | 2176 | elseif (file_exists($settings['default_theme_dir'] . '/languages/' . $this->_req->query->template . '.php')) |
1968 | - $filename = $settings['default_theme_dir'] . '/languages/' . $this->_req->query->template . '.php'; |
|
1969 | - else |
|
1970 | - throw new Elk_Exception('no_access', false); |
|
2177 | + { |
|
2178 | + $filename = $settings['default_theme_dir'] . '/languages/' . $this->_req->query->template . '.php'; |
|
2179 | + } |
|
2180 | + else { |
|
2181 | + throw new Elk_Exception('no_access', false); |
|
2182 | + } |
|
1971 | 2183 | |
1972 | 2184 | $fp = fopen($theme_dirs['theme_dir'] . '/languages/' . $this->_req->query->lang_file . '.php', 'w'); |
1973 | 2185 | fwrite($fp, file_get_contents($filename)); |
1974 | 2186 | fclose($fp); |
1975 | 2187 | |
1976 | 2188 | if ($this->_checkOpcache()) |
1977 | - opcache_invalidate($filename); |
|
2189 | + { |
|
2190 | + opcache_invalidate($filename); |
|
2191 | + } |
|
1978 | 2192 | |
1979 | 2193 | redirectexit('action=admin;area=theme;th=' . $context['theme_id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=copy'); |
1980 | 2194 | } |
@@ -1986,7 +2200,9 @@ discard block |
||
1986 | 2200 | while ($entry = $dir->read()) |
1987 | 2201 | { |
1988 | 2202 | if (substr($entry, -13) === '.template.php') |
1989 | - $templates[] = substr($entry, 0, -13); |
|
2203 | + { |
|
2204 | + $templates[] = substr($entry, 0, -13); |
|
2205 | + } |
|
1990 | 2206 | } |
1991 | 2207 | $dir->close(); |
1992 | 2208 | |
@@ -1994,7 +2210,9 @@ discard block |
||
1994 | 2210 | while ($entry = $dir->read()) |
1995 | 2211 | { |
1996 | 2212 | if (preg_match('~^([^\.]+\.[^\.]+)\.php$~', $entry, $matches)) |
1997 | - $lang_files[] = $matches[1]; |
|
2213 | + { |
|
2214 | + $lang_files[] = $matches[1]; |
|
2215 | + } |
|
1998 | 2216 | } |
1999 | 2217 | $dir->close(); |
2000 | 2218 | |
@@ -2004,7 +2222,9 @@ discard block |
||
2004 | 2222 | while ($entry = $dir->read()) |
2005 | 2223 | { |
2006 | 2224 | if (substr($entry, -13) === '.template.php' && !in_array(substr($entry, 0, -13), $templates)) |
2007 | - $templates[] = substr($entry, 0, -13); |
|
2225 | + { |
|
2226 | + $templates[] = substr($entry, 0, -13); |
|
2227 | + } |
|
2008 | 2228 | } |
2009 | 2229 | $dir->close(); |
2010 | 2230 | |
@@ -2014,7 +2234,9 @@ discard block |
||
2014 | 2234 | while ($entry = $dir->read()) |
2015 | 2235 | { |
2016 | 2236 | if (preg_match('~^([^\.]+\.[^\.]+)\.php$~', $entry, $matches) && !in_array($matches[1], $lang_files)) |
2017 | - $lang_files[] = $matches[1]; |
|
2237 | + { |
|
2238 | + $lang_files[] = $matches[1]; |
|
2239 | + } |
|
2018 | 2240 | } |
2019 | 2241 | $dir->close(); |
2020 | 2242 | } |
@@ -2025,20 +2247,24 @@ discard block |
||
2025 | 2247 | |
2026 | 2248 | $context['available_templates'] = array(); |
2027 | 2249 | foreach ($templates as $template) |
2028 | - $context['available_templates'][$template] = array( |
|
2250 | + { |
|
2251 | + $context['available_templates'][$template] = array( |
|
2029 | 2252 | 'filename' => $template . '.template.php', |
2030 | 2253 | 'value' => $template, |
2031 | 2254 | 'already_exists' => false, |
2032 | 2255 | 'can_copy' => is_writable($theme_dirs['theme_dir']), |
2033 | 2256 | ); |
2257 | + } |
|
2034 | 2258 | $context['available_language_files'] = array(); |
2035 | 2259 | foreach ($lang_files as $file) |
2036 | - $context['available_language_files'][$file] = array( |
|
2260 | + { |
|
2261 | + $context['available_language_files'][$file] = array( |
|
2037 | 2262 | 'filename' => $file . '.php', |
2038 | 2263 | 'value' => $file, |
2039 | 2264 | 'already_exists' => false, |
2040 | 2265 | 'can_copy' => file_exists($theme_dirs['theme_dir'] . '/languages') ? is_writable($theme_dirs['theme_dir'] . '/languages') : is_writable($theme_dirs['theme_dir']), |
2041 | 2266 | ); |
2267 | + } |
|
2042 | 2268 | |
2043 | 2269 | $dir = dir($theme_dirs['theme_dir']); |
2044 | 2270 | while ($entry = $dir->read()) |
@@ -2078,26 +2304,34 @@ discard block |
||
2078 | 2304 | |
2079 | 2305 | // Eh? not trying to sneak a peek outside the theme directory are we |
2080 | 2306 | if (!file_exists($this->theme_dir . '/index.template.php') && !file_exists($this->theme_dir . '/css/index.css')) |
2081 | - throw new Elk_Exception('theme_edit_missing', false); |
|
2307 | + { |
|
2308 | + throw new Elk_Exception('theme_edit_missing', false); |
|
2309 | + } |
|
2082 | 2310 | |
2083 | 2311 | // Get the filename from the appropriate spot |
2084 | 2312 | $filename = isset($this->_req->post->save) ? $this->_req->getPost('filename', 'strval', '') : $this->_req->getQuery('filename', 'strval', ''); |
2085 | 2313 | |
2086 | 2314 | // You're editing a file: we have extra-checks coming up first. |
2087 | 2315 | if (substr($filename, 0, 1) === '.') |
2088 | - $filename = ''; |
|
2316 | + { |
|
2317 | + $filename = ''; |
|
2318 | + } |
|
2089 | 2319 | else |
2090 | 2320 | { |
2091 | 2321 | $filename = preg_replace(array('~^[\./\\:\0\n\r]+~', '~[\\\\]~', '~/[\./]+~'), array('', '/', '/'), $filename); |
2092 | 2322 | |
2093 | 2323 | $temp = realpath($this->theme_dir . '/' . $filename); |
2094 | 2324 | if (empty($temp) || substr($temp, 0, strlen(realpath($this->theme_dir))) !== realpath($this->theme_dir)) |
2095 | - $filename = ''; |
|
2325 | + { |
|
2326 | + $filename = ''; |
|
2327 | + } |
|
2096 | 2328 | } |
2097 | 2329 | |
2098 | 2330 | // We shouldn't end up with no file |
2099 | 2331 | if (empty($filename)) |
2100 | - throw new Elk_Exception('theme_edit_missing', false); |
|
2332 | + { |
|
2333 | + throw new Elk_Exception('theme_edit_missing', false); |
|
2334 | + } |
|
2101 | 2335 | |
2102 | 2336 | // Initialize context |
2103 | 2337 | $context['allow_save'] = is_writable($this->theme_dir . '/' . $filename); |
@@ -1424,7 +1424,7 @@ discard block |
||
1424 | 1424 | { |
1425 | 1425 | if (!empty($options['admin_preferences'])) |
1426 | 1426 | { |
1427 | - $options['admin_preferences'] = serializeToJson($options['admin_preferences'], function ($array_form) { |
|
1427 | + $options['admin_preferences'] = serializeToJson($options['admin_preferences'], function($array_form) { |
|
1428 | 1428 | global $context; |
1429 | 1429 | |
1430 | 1430 | $context['admin_preferences'] = $array_form; |
@@ -1449,7 +1449,7 @@ discard block |
||
1449 | 1449 | { |
1450 | 1450 | if (!empty($options['minmax_preferences'])) |
1451 | 1451 | { |
1452 | - $minmax_preferences = serializeToJson($options['minmax_preferences'], function ($array_form) { |
|
1452 | + $minmax_preferences = serializeToJson($options['minmax_preferences'], function($array_form) { |
|
1453 | 1453 | global $settings, $user_info; |
1454 | 1454 | |
1455 | 1455 | // Update the option. |
@@ -190,9 +190,12 @@ discard block |
||
190 | 190 | 'data_check' => array( |
191 | 191 | 'class' => function ($rowData) { |
192 | 192 | if ($rowData['default']) |
193 | - return 'highlight2'; |
|
194 | - else |
|
195 | - return ''; |
|
193 | + { |
|
194 | + return 'highlight2'; |
|
195 | + } |
|
196 | + else { |
|
197 | + return ''; |
|
198 | + } |
|
196 | 199 | }, |
197 | 200 | ), |
198 | 201 | 'get_items' => array( |
@@ -266,11 +269,13 @@ discard block |
||
266 | 269 | |
267 | 270 | // Display a warning if we cannot edit the default setting. |
268 | 271 | if (!is_writable(BOARDDIR . '/Settings.php')) |
269 | - $listOptions['additional_rows'][] = array( |
|
272 | + { |
|
273 | + $listOptions['additional_rows'][] = array( |
|
270 | 274 | 'position' => 'after_title', |
271 | 275 | 'value' => $txt['language_settings_writable'], |
272 | 276 | 'class' => 'smalltext alert', |
273 | 277 | ); |
278 | + } |
|
274 | 279 | |
275 | 280 | createList($listOptions); |
276 | 281 | |
@@ -301,7 +306,9 @@ discard block |
||
301 | 306 | |
302 | 307 | // Clearly we need to know what to request. |
303 | 308 | if (!isset($this->_req->query->did)) |
304 | - throw new Elk_Exception('no_access', false); |
|
309 | + { |
|
310 | + throw new Elk_Exception('no_access', false); |
|
311 | + } |
|
305 | 312 | |
306 | 313 | // Some lovely context. |
307 | 314 | $context['download_id'] = $this->_req->query->did; |
@@ -322,7 +329,9 @@ discard block |
||
322 | 329 | { |
323 | 330 | // Check it's not very bad. |
324 | 331 | if (strpos($file, '..') !== false || (strpos($file, 'themes') !== 0 && !preg_match('~agreement\.[A-Za-z-_0-9]+\.txt$~', $file))) |
325 | - throw new Elk_Exception($txt['languages_download_illegal_paths']); |
|
332 | + { |
|
333 | + throw new Elk_Exception($txt['languages_download_illegal_paths']); |
|
334 | + } |
|
326 | 335 | |
327 | 336 | $chmod_files[] = BOARDDIR . '/' . $file; |
328 | 337 | $install_files[] = $file; |
@@ -334,7 +343,9 @@ discard block |
||
334 | 343 | |
335 | 344 | // Something not writable? |
336 | 345 | if (!empty($files_left)) |
337 | - $context['error_message'] = $txt['languages_download_not_chmod']; |
|
346 | + { |
|
347 | + $context['error_message'] = $txt['languages_download_not_chmod']; |
|
348 | + } |
|
338 | 349 | // Otherwise, go go go! |
339 | 350 | elseif (!empty($install_files)) |
340 | 351 | { |
@@ -353,7 +364,9 @@ discard block |
||
353 | 364 | $archive_content = read_tgz_file('http://download.elkarte.net/fetch_language.php?version=' . urlencode(strtr(FORUM_VERSION, array('ElkArte ' => ''))) . ';fetch=' . urlencode($this->_req->query->did), null); |
354 | 365 | |
355 | 366 | if (empty($archive_content)) |
356 | - throw new Elk_Exception($txt['add_language_error_no_response']); |
|
367 | + { |
|
368 | + throw new Elk_Exception($txt['add_language_error_no_response']); |
|
369 | + } |
|
357 | 370 | |
358 | 371 | // Now for each of the files, let's do some *stuff* |
359 | 372 | $context['files'] = array( |
@@ -369,7 +382,9 @@ discard block |
||
369 | 382 | |
370 | 383 | // Don't do anything with files we don't understand. |
371 | 384 | if (!in_array($extension, array('php', 'jpg', 'gif', 'jpeg', 'png', 'txt'))) |
372 | - continue; |
|
385 | + { |
|
386 | + continue; |
|
387 | + } |
|
373 | 388 | |
374 | 389 | // Basic data. |
375 | 390 | $context_data = array( |
@@ -389,7 +404,9 @@ discard block |
||
389 | 404 | if (file_exists(BOARDDIR . '/' . $file['filename'])) |
390 | 405 | { |
391 | 406 | if (is_writable(BOARDDIR . '/' . $file['filename'])) |
392 | - $context_data['writable'] = true; |
|
407 | + { |
|
408 | + $context_data['writable'] = true; |
|
409 | + } |
|
393 | 410 | |
394 | 411 | // Finally, do we actually think the content has changed? |
395 | 412 | if ($file['size'] == filesize(BOARDDIR . '/' . $file['filename']) && $file['md5'] === md5_file(BOARDDIR . '/' . $file['filename'])) |
@@ -403,15 +420,18 @@ discard block |
||
403 | 420 | $context_data['exists'] = 'same'; |
404 | 421 | $context_data['default_copy'] = false; |
405 | 422 | } |
406 | - else |
|
407 | - $context_data['exists'] = 'different'; |
|
423 | + else { |
|
424 | + $context_data['exists'] = 'different'; |
|
425 | + } |
|
408 | 426 | } |
409 | 427 | // No overwrite? |
410 | 428 | else |
411 | 429 | { |
412 | 430 | // Can we at least stick it in the directory... |
413 | 431 | if (is_writable(BOARDDIR . '/' . $dirname)) |
414 | - $context_data['writable'] = true; |
|
432 | + { |
|
433 | + $context_data['writable'] = true; |
|
434 | + } |
|
415 | 435 | } |
416 | 436 | |
417 | 437 | // I love PHP files, that's why I'm a developer and not an artistic type spending my time drinking absinth and living a life of sin... |
@@ -427,7 +447,9 @@ discard block |
||
427 | 447 | |
428 | 448 | // Let's get the new version, I like versions, they tell me that I'm up to date. |
429 | 449 | if (preg_match('~\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '~i', $file['preview'], $match) == 1) |
430 | - $context_data['version'] = $match[1]; |
|
450 | + { |
|
451 | + $context_data['version'] = $match[1]; |
|
452 | + } |
|
431 | 453 | |
432 | 454 | // Now does the old file exist - if so what is it's version? |
433 | 455 | if (file_exists(BOARDDIR . '/' . $file['filename'])) |
@@ -444,13 +466,19 @@ discard block |
||
444 | 466 | |
445 | 467 | // How does this compare? |
446 | 468 | if ($context_data['cur_version'] == $context_data['version']) |
447 | - $context_data['version_compare'] = 'same'; |
|
469 | + { |
|
470 | + $context_data['version_compare'] = 'same'; |
|
471 | + } |
|
448 | 472 | elseif ($context_data['cur_version'] > $context_data['version']) |
449 | - $context_data['version_compare'] = 'older'; |
|
473 | + { |
|
474 | + $context_data['version_compare'] = 'older'; |
|
475 | + } |
|
450 | 476 | |
451 | 477 | // Don't recommend copying if the version is the same. |
452 | 478 | if ($context_data['version_compare'] != 'newer') |
453 | - $context_data['default_copy'] = false; |
|
479 | + { |
|
480 | + $context_data['default_copy'] = false; |
|
481 | + } |
|
454 | 482 | } |
455 | 483 | } |
456 | 484 | |
@@ -461,9 +489,12 @@ discard block |
||
461 | 489 | { |
462 | 490 | // If we think it's a theme thing, work out what the theme is. |
463 | 491 | if (strpos($dirname, 'themes') === 0 && preg_match('~themes[\\/]([^\\/]+)[\\/]~', $dirname, $match)) |
464 | - $theme_name = $match[1]; |
|
465 | - else |
|
466 | - $theme_name = 'misc'; |
|
492 | + { |
|
493 | + $theme_name = $match[1]; |
|
494 | + } |
|
495 | + else { |
|
496 | + $theme_name = 'misc'; |
|
497 | + } |
|
467 | 498 | |
468 | 499 | // Assume it's an image, could be an acceptance note etc but rare. |
469 | 500 | $context['files']['images'][$theme_name][] = $context_data; |
@@ -471,13 +502,17 @@ discard block |
||
471 | 502 | |
472 | 503 | // Collect together all non-writable areas. |
473 | 504 | if (!$context_data['writable']) |
474 | - $context['make_writable'][] = $context_data['destination']; |
|
505 | + { |
|
506 | + $context['make_writable'][] = $context_data['destination']; |
|
507 | + } |
|
475 | 508 | } |
476 | 509 | |
477 | 510 | // So, I'm a perfectionist - let's get the theme names. |
478 | 511 | $indexes = array(); |
479 | 512 | foreach ($context['files']['images'] as $k => $dummy) |
480 | - $indexes[] = $k; |
|
513 | + { |
|
514 | + $indexes[] = $k; |
|
515 | + } |
|
481 | 516 | |
482 | 517 | $context['theme_names'] = array(); |
483 | 518 | if (!empty($indexes)) |
@@ -498,7 +533,9 @@ discard block |
||
498 | 533 | |
499 | 534 | // Now we have the id_theme we can get the pretty description. |
500 | 535 | if (!empty($themes)) |
501 | - $context['theme_names'] = getBasicThemeInfos($themes); |
|
536 | + { |
|
537 | + $context['theme_names'] = getBasicThemeInfos($themes); |
|
538 | + } |
|
502 | 539 | } |
503 | 540 | |
504 | 541 | // Before we go to far can we make anything writable, eh, eh? |
@@ -514,21 +551,27 @@ discard block |
||
514 | 551 | if ($type == 'lang') |
515 | 552 | { |
516 | 553 | foreach ($data as $k => $file) |
517 | - if (!$file['writable'] && !in_array($file['destination'], $context['still_not_writable'])) |
|
554 | + { |
|
555 | + if (!$file['writable'] && !in_array($file['destination'], $context['still_not_writable'])) |
|
518 | 556 | $context['files'][$type][$k]['writable'] = true; |
557 | + } |
|
519 | 558 | } |
520 | 559 | else |
521 | 560 | { |
522 | 561 | foreach ($data as $theme => $files) |
523 | - foreach ($files as $k => $file) |
|
562 | + { |
|
563 | + foreach ($files as $k => $file) |
|
524 | 564 | if (!$file['writable'] && !in_array($file['destination'], $context['still_not_writable'])) |
525 | 565 | $context['files'][$type][$theme][$k]['writable'] = true; |
566 | + } |
|
526 | 567 | } |
527 | 568 | } |
528 | 569 | |
529 | 570 | // Are we going to need more language stuff? |
530 | 571 | if (!empty($context['still_not_writable'])) |
531 | - loadLanguage('Packages'); |
|
572 | + { |
|
573 | + loadLanguage('Packages'); |
|
574 | + } |
|
532 | 575 | } |
533 | 576 | |
534 | 577 | // This is the list for the main files. |
@@ -647,13 +690,19 @@ discard block |
||
647 | 690 | foreach ($themes as $id => $data) |
648 | 691 | { |
649 | 692 | if (count($data) != 2) |
650 | - unset($themes[$id]); |
|
693 | + { |
|
694 | + unset($themes[$id]); |
|
695 | + } |
|
651 | 696 | elseif (is_dir($data['theme_dir'] . '/languages/' . $context['lang_id'])) |
652 | - $lang_dirs[$id] = $data['theme_dir'] . '/languages/' . $context['lang_id']; |
|
697 | + { |
|
698 | + $lang_dirs[$id] = $data['theme_dir'] . '/languages/' . $context['lang_id']; |
|
699 | + } |
|
653 | 700 | |
654 | 701 | // How about image directories? |
655 | 702 | if (is_dir($data['theme_dir'] . '/images/' . $context['lang_id'])) |
656 | - $images_dirs[$id] = $data['theme_dir'] . '/images/' . $context['lang_id']; |
|
703 | + { |
|
704 | + $images_dirs[$id] = $data['theme_dir'] . '/images/' . $context['lang_id']; |
|
705 | + } |
|
657 | 706 | } |
658 | 707 | |
659 | 708 | $current_file = $file_id ? $lang_dirs[$theme_id] . '/' . $file_id . '.' . $context['lang_id'] . '.php' : ''; |
@@ -668,14 +717,18 @@ discard block |
||
668 | 717 | { |
669 | 718 | // We're only after the files for this language. |
670 | 719 | if (preg_match('~^([A-Za-z]+)\.' . $context['lang_id'] . '\.php$~', $entry, $matches) == 0) |
671 | - continue; |
|
720 | + { |
|
721 | + continue; |
|
722 | + } |
|
672 | 723 | |
673 | 724 | if (!isset($context['possible_files'][$theme])) |
674 | - $context['possible_files'][$theme] = array( |
|
725 | + { |
|
726 | + $context['possible_files'][$theme] = array( |
|
675 | 727 | 'id' => $theme, |
676 | 728 | 'name' => $themes[$theme]['name'], |
677 | 729 | 'files' => array(), |
678 | 730 | ); |
731 | + } |
|
679 | 732 | |
680 | 733 | $context['possible_files'][$theme]['files'][] = array( |
681 | 734 | 'id' => $matches[1], |
@@ -721,17 +774,23 @@ discard block |
||
721 | 774 | foreach ($lang_dirs as $curPath) |
722 | 775 | { |
723 | 776 | foreach ($context['possible_files'][1]['files'] as $lang) |
724 | - if (file_exists($curPath . '/' . $lang['id'] . '.' . $context['lang_id'] . '.php')) |
|
777 | + { |
|
778 | + if (file_exists($curPath . '/' . $lang['id'] . '.' . $context['lang_id'] . '.php')) |
|
725 | 779 | unlink($curPath . '/' . $lang['id'] . '.' . $context['lang_id'] . '.php'); |
780 | + } |
|
726 | 781 | |
727 | 782 | // Check for the email template. |
728 | 783 | if (file_exists($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php')) |
729 | - unlink($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php'); |
|
784 | + { |
|
785 | + unlink($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php'); |
|
786 | + } |
|
730 | 787 | } |
731 | 788 | |
732 | 789 | // Third, the agreement file. |
733 | 790 | if (file_exists(BOARDDIR . '/agreement.' . $context['lang_id'] . '.txt')) |
734 | - unlink(BOARDDIR . '/agreement.' . $context['lang_id'] . '.txt'); |
|
791 | + { |
|
792 | + unlink(BOARDDIR . '/agreement.' . $context['lang_id'] . '.txt'); |
|
793 | + } |
|
735 | 794 | |
736 | 795 | // Fourth, a related images folder? |
737 | 796 | if (!empty($images_dirs)) |
@@ -739,7 +798,9 @@ discard block |
||
739 | 798 | foreach ($images_dirs as $curPath) |
740 | 799 | { |
741 | 800 | if (is_dir($curPath)) |
742 | - deltree($curPath); |
|
801 | + { |
|
802 | + deltree($curPath); |
|
803 | + } |
|
743 | 804 | } |
744 | 805 | } |
745 | 806 | |
@@ -784,7 +845,9 @@ discard block |
||
784 | 845 | fclose($fp); |
785 | 846 | |
786 | 847 | if ($this->_checkOpcache()) |
787 | - opcache_invalidate($settings['default_theme_dir'] . '/languages/' . $context['lang_id'] . '/index.' . $context['lang_id'] . '.php'); |
|
848 | + { |
|
849 | + opcache_invalidate($settings['default_theme_dir'] . '/languages/' . $context['lang_id'] . '/index.' . $context['lang_id'] . '.php'); |
|
850 | + } |
|
788 | 851 | |
789 | 852 | $madeSave = true; |
790 | 853 | } |
@@ -818,7 +881,9 @@ discard block |
||
818 | 881 | { |
819 | 882 | // Only try to save if it's changed! |
820 | 883 | if ($this->_req->post->entry[$k] != $this->_req->post->comp[$k]) |
821 | - $save_strings[$k] = cleanLangString($v, false); |
|
884 | + { |
|
885 | + $save_strings[$k] = cleanLangString($v, false); |
|
886 | + } |
|
822 | 887 | } |
823 | 888 | } |
824 | 889 | |
@@ -855,11 +920,13 @@ discard block |
||
855 | 920 | { |
856 | 921 | preg_match('~\$(helptxt|txt|editortxt)\[\'(.+)\'\]\s?=\s?(.+);~ms', strtr($multiline_cache, array("\r" => '')), $matches); |
857 | 922 | if (!empty($matches[3])) |
858 | - $entries[$matches[2]] = array( |
|
923 | + { |
|
924 | + $entries[$matches[2]] = array( |
|
859 | 925 | 'type' => $matches[1], |
860 | 926 | 'full' => $matches[0], |
861 | 927 | 'entry' => $matches[3], |
862 | 928 | ); |
929 | + } |
|
863 | 930 | } |
864 | 931 | |
865 | 932 | // These are the entries we can definitely save. |
@@ -874,7 +941,9 @@ discard block |
||
874 | 941 | // Ignore some things we set separately. |
875 | 942 | $ignore_files = array('lang_character_set', 'lang_locale', 'lang_dictionary', 'lang_spelling', 'lang_rtl'); |
876 | 943 | if (in_array($entryKey, $ignore_files)) |
877 | - continue; |
|
944 | + { |
|
945 | + continue; |
|
946 | + } |
|
878 | 947 | |
879 | 948 | // These are arrays that need breaking out. |
880 | 949 | $arrays = array('days', 'days_short', 'months', 'months_titles', 'months_short', 'happy_birthday_author', 'karlbenson1_author', 'nite0859_author', 'zwaldowski_author', 'geezmo_author', 'karlbenson2_author'); |
@@ -908,8 +977,9 @@ discard block |
||
908 | 977 | $save_cache['entries'][$cur_index] = strtr($save_strings[$md5EntryKey . '-+- ' . $cur_index], array('\'' => '')); |
909 | 978 | $save_cache['enabled'] = true; |
910 | 979 | } |
911 | - else |
|
912 | - $save_cache['entries'][$cur_index] = $subValue; |
|
980 | + else { |
|
981 | + $save_cache['entries'][$cur_index] = $subValue; |
|
982 | + } |
|
913 | 983 | |
914 | 984 | $context['file_entries'][] = array( |
915 | 985 | 'key' => $entryKey . '-+- ' . $cur_index, |
@@ -934,8 +1004,9 @@ discard block |
||
934 | 1004 | $items[] = $k2 . ' => \'' . $v2 . '\''; |
935 | 1005 | $cur_index = $k2; |
936 | 1006 | } |
937 | - else |
|
938 | - $items[] = '\'' . $v2 . '\''; |
|
1007 | + else { |
|
1008 | + $items[] = '\'' . $v2 . '\''; |
|
1009 | + } |
|
939 | 1010 | |
940 | 1011 | $cur_index++; |
941 | 1012 | } |
@@ -954,7 +1025,9 @@ discard block |
||
954 | 1025 | { |
955 | 1026 | // @todo Fix this properly. |
956 | 1027 | if ($save_strings[$md5EntryKey] == '') |
957 | - $save_strings[$md5EntryKey] = '\'\''; |
|
1028 | + { |
|
1029 | + $save_strings[$md5EntryKey] = '\'\''; |
|
1030 | + } |
|
958 | 1031 | |
959 | 1032 | // Set the new value. |
960 | 1033 | $entryValue['entry'] = $save_strings[$md5EntryKey]; |
@@ -983,7 +1056,9 @@ discard block |
||
983 | 1056 | |
984 | 1057 | $file_contents = implode('', file($current_file)); |
985 | 1058 | foreach ($final_saves as $save) |
986 | - $file_contents = strtr($file_contents, array($save['find'] => $save['replace'])); |
|
1059 | + { |
|
1060 | + $file_contents = strtr($file_contents, array($save['find'] => $save['replace'])); |
|
1061 | + } |
|
987 | 1062 | |
988 | 1063 | // Save the actual changes. |
989 | 1064 | $fp = fopen($current_file, 'w+'); |
@@ -991,7 +1066,9 @@ discard block |
||
991 | 1066 | fclose($fp); |
992 | 1067 | |
993 | 1068 | if ($this->_checkOpcache()) |
994 | - opcache_invalidate($current_file); |
|
1069 | + { |
|
1070 | + opcache_invalidate($current_file); |
|
1071 | + } |
|
995 | 1072 | |
996 | 1073 | $madeSave = true; |
997 | 1074 | } |
@@ -1002,7 +1079,9 @@ discard block |
||
1002 | 1079 | |
1003 | 1080 | // If we saved, redirect. |
1004 | 1081 | if ($madeSave) |
1005 | - redirectexit('action=admin;area=languages;sa=editlang;lid=' . $context['lang_id']); |
|
1082 | + { |
|
1083 | + redirectexit('action=admin;area=languages;sa=editlang;lid=' . $context['lang_id']); |
|
1084 | + } |
|
1006 | 1085 | |
1007 | 1086 | createToken('admin-mlang'); |
1008 | 1087 | } |
@@ -1095,7 +1174,9 @@ discard block |
||
1095 | 1174 | // Get our languages. No cache. |
1096 | 1175 | $languages = getLanguages(false); |
1097 | 1176 | foreach ($languages as $lang) |
1098 | - $config_vars['language'][4][] = array($lang['filename'], strtr($lang['name'], array('-utf8' => ' (UTF-8)'))); |
|
1177 | + { |
|
1178 | + $config_vars['language'][4][] = array($lang['filename'], strtr($lang['name'], array('-utf8' => ' (UTF-8)'))); |
|
1179 | + } |
|
1099 | 1180 | |
1100 | 1181 | return $config_vars; |
1101 | 1182 | } |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | 'base_href' => $scripturl . '?action=admin;area=languages', |
189 | 189 | 'title' => $txt['edit_languages'], |
190 | 190 | 'data_check' => array( |
191 | - 'class' => function ($rowData) { |
|
191 | + 'class' => function($rowData) { |
|
192 | 192 | if ($rowData['default']) |
193 | 193 | return 'highlight2'; |
194 | 194 | else |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | 'class' => 'centertext', |
209 | 209 | ), |
210 | 210 | 'data' => array( |
211 | - 'function' => function ($rowData) { |
|
211 | + 'function' => function($rowData) { |
|
212 | 212 | return '<input type="radio" name="def_language" value="' . $rowData['id'] . '" ' . ($rowData['default'] ? 'checked="checked"' : '') . ' class="input_radio" />'; |
213 | 213 | }, |
214 | 214 | 'style' => 'width: 8%;', |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | 'value' => $txt['languages_lang_name'], |
221 | 221 | ), |
222 | 222 | 'data' => array( |
223 | - 'function' => function ($rowData) { |
|
223 | + 'function' => function($rowData) { |
|
224 | 224 | global $scripturl; |
225 | 225 | |
226 | 226 | return sprintf('<a href="%1$s?action=admin;area=languages;sa=editlang;lid=%2$s">%3$s<i class="icon icon-small i-modify"></i></a>', $scripturl, $rowData['id'], $rowData['name']); |
@@ -536,7 +536,7 @@ discard block |
||
536 | 536 | 'id' => 'lang_main_files_list', |
537 | 537 | 'title' => $txt['languages_download_main_files'], |
538 | 538 | 'get_items' => array( |
539 | - 'function' => function () { |
|
539 | + 'function' => function() { |
|
540 | 540 | global $context; |
541 | 541 | return $context['files']['lang']; |
542 | 542 | }, |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | 'value' => $txt['languages_download_filename'], |
548 | 548 | ), |
549 | 549 | 'data' => array( |
550 | - 'function' => function ($rowData) { |
|
550 | + 'function' => function($rowData) { |
|
551 | 551 | global $txt; |
552 | 552 | |
553 | 553 | return '<strong>' . $rowData['name'] . '</strong><br /><span class="smalltext">' . $txt['languages_download_dest'] . ': ' . $rowData['destination'] . '</span>' . ($rowData['version_compare'] == 'older' ? '<br />' . $txt['languages_download_older'] : ''); |
@@ -559,7 +559,7 @@ discard block |
||
559 | 559 | 'value' => $txt['languages_download_writable'], |
560 | 560 | ), |
561 | 561 | 'data' => array( |
562 | - 'function' => function ($rowData) { |
|
562 | + 'function' => function($rowData) { |
|
563 | 563 | global $txt; |
564 | 564 | |
565 | 565 | return '<span class="' . ($rowData['writable'] ? 'success' : 'error') . ';">' . ($rowData['writable'] ? $txt['yes'] : $txt['no']) . '</span>'; |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | 'value' => $txt['languages_download_version'], |
572 | 572 | ), |
573 | 573 | 'data' => array( |
574 | - 'function' => function ($rowData) { |
|
574 | + 'function' => function($rowData) { |
|
575 | 575 | return '<span class="' . ($rowData['version_compare'] == 'older' ? 'error' : ($rowData['version_compare'] == 'same' ? 'softalert' : 'success')) . ';">' . $rowData['version'] . '</span>'; |
576 | 576 | }, |
577 | 577 | ), |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | 'value' => $txt['languages_download_exists'], |
582 | 582 | ), |
583 | 583 | 'data' => array( |
584 | - 'function' => function ($rowData) { |
|
584 | + 'function' => function($rowData) { |
|
585 | 585 | global $txt; |
586 | 586 | |
587 | 587 | return $rowData['exists'] ? ($rowData['exists'] == 'same' ? $txt['languages_download_exists_same'] : $txt['languages_download_exists_different']) : $txt['no']; |
@@ -594,7 +594,7 @@ discard block |
||
594 | 594 | 'class' => 'centertext', |
595 | 595 | ), |
596 | 596 | 'data' => array( |
597 | - 'function' => function ($rowData) { |
|
597 | + 'function' => function($rowData) { |
|
598 | 598 | return '<input type="checkbox" name="copy_file[]" value="' . $rowData['generaldest'] . '" ' . ($rowData['default_copy'] ? 'checked="checked"' : '') . ' class="input_check" />'; |
599 | 599 | }, |
600 | 600 | 'style' => 'width: 4%;', |
@@ -684,7 +684,7 @@ discard block |
||
684 | 684 | ); |
685 | 685 | } |
686 | 686 | $dir->close(); |
687 | - usort($context['possible_files'][$theme]['files'], function ($val1, $val2) { |
|
687 | + usort($context['possible_files'][$theme]['files'], function($val1, $val2) { |
|
688 | 688 | return strcmp($val1['name'], $val2['name']); |
689 | 689 | }); |
690 | 690 | } |
@@ -113,7 +113,9 @@ discard block |
||
113 | 113 | $context['package_download_broken'] = !is_writable(BOARDDIR . '/packages') || !is_writable(BOARDDIR . '/packages/installed.list'); |
114 | 114 | |
115 | 115 | if ($context['package_download_broken']) |
116 | - $this->ftp_connect(); |
|
116 | + { |
|
117 | + $this->ftp_connect(); |
|
118 | + } |
|
117 | 119 | } |
118 | 120 | |
119 | 121 | /** |
@@ -130,11 +132,14 @@ discard block |
||
130 | 132 | |
131 | 133 | // Browsing the packages from a server |
132 | 134 | if (isset($this->_req->query->server)) |
133 | - list($name, $url, $server) = $this->_package_server(); |
|
135 | + { |
|
136 | + list($name, $url, $server) = $this->_package_server(); |
|
137 | + } |
|
134 | 138 | |
135 | 139 | // Minimum required parameter did not exist so dump out. |
136 | - else |
|
137 | - throw new Elk_Exception('couldnt_connect', false); |
|
140 | + else { |
|
141 | + throw new Elk_Exception('couldnt_connect', false); |
|
142 | + } |
|
138 | 143 | |
139 | 144 | // Might take some time. |
140 | 145 | detectServer()->setTimeLimit(60); |
@@ -159,11 +164,15 @@ discard block |
||
159 | 164 | // Look through the list of installed mods and get version information for the compare |
160 | 165 | $installed_adds = array(); |
161 | 166 | foreach ($instadds as $installed_add) |
162 | - $installed_adds[$installed_add['package_id']] = $installed_add['version']; |
|
167 | + { |
|
168 | + $installed_adds[$installed_add['package_id']] = $installed_add['version']; |
|
169 | + } |
|
163 | 170 | |
164 | 171 | $the_version = strtr(FORUM_VERSION, array('ElkArte ' => '')); |
165 | 172 | if (!empty($_SESSION['version_emulate'])) |
166 | - $the_version = $_SESSION['version_emulate']; |
|
173 | + { |
|
174 | + $the_version = $_SESSION['version_emulate']; |
|
175 | + } |
|
167 | 176 | |
168 | 177 | // Parse the json file, each section contains a category of addons |
169 | 178 | $packageNum = 0; |
@@ -352,12 +361,15 @@ discard block |
||
352 | 361 | // not always accurate, especially when dealing with repos. So for now just put in in no conflict mode |
353 | 362 | // and do the save. |
354 | 363 | if ($this->_req->getQuery('area') === 'packageservers' && $this->_req->getQuery('sa') === 'download') |
355 | - $this->_req->query->auto = true; |
|
364 | + { |
|
365 | + $this->_req->query->auto = true; |
|
366 | + } |
|
356 | 367 | |
357 | 368 | return str_replace($invalid, '_', $newname) . $matches[6]; |
358 | 369 | } |
359 | - else |
|
360 | - return basename($name); |
|
370 | + else { |
|
371 | + return basename($name); |
|
372 | + } |
|
361 | 373 | } |
362 | 374 | |
363 | 375 | /** |
@@ -384,13 +396,18 @@ discard block |
||
384 | 396 | |
385 | 397 | // Security is good... |
386 | 398 | if (isset($this->_req->query->server)) |
387 | - checkSession('get'); |
|
388 | - else |
|
389 | - checkSession(); |
|
399 | + { |
|
400 | + checkSession('get'); |
|
401 | + } |
|
402 | + else { |
|
403 | + checkSession(); |
|
404 | + } |
|
390 | 405 | |
391 | 406 | // To download something, we need either a valid server or url. |
392 | 407 | if (empty($this->_req->query->server) && (!empty($this->_req->query->get) && !empty($this->_req->post->package))) |
393 | - throw new Elk_Exception('package_get_error_is_zero', false); |
|
408 | + { |
|
409 | + throw new Elk_Exception('package_get_error_is_zero', false); |
|
410 | + } |
|
394 | 411 | |
395 | 412 | // Start off with nothing |
396 | 413 | $server = ''; |
@@ -418,8 +435,9 @@ discard block |
||
418 | 435 | $url = isset($path_url['dirname']) ? $path_url['dirname'] . '/' : ''; |
419 | 436 | } |
420 | 437 | // Not found or some monkey business |
421 | - else |
|
422 | - throw new Elk_Exception('package_cant_download', false); |
|
438 | + else { |
|
439 | + throw new Elk_Exception('package_cant_download', false); |
|
440 | + } |
|
423 | 441 | } |
424 | 442 | // Entered a url and optional filename |
425 | 443 | elseif (isset($this->_req->post->byurl) && !empty($this->_req->post->filename)) |
@@ -443,13 +461,16 @@ discard block |
||
443 | 461 | $ext = substr($package_name, strrpos(substr($package_name, 0, -3), '.')); |
444 | 462 | $package_name = substr($package_name, 0, strrpos(substr($package_name, 0, -3), '.')) . '_'; |
445 | 463 | } |
446 | - else |
|
447 | - $ext = ''; |
|
464 | + else { |
|
465 | + $ext = ''; |
|
466 | + } |
|
448 | 467 | |
449 | 468 | // Find the first available free name |
450 | 469 | $i = 1; |
451 | 470 | while (file_exists(BOARDDIR . '/packages/' . $package_name . $i . $ext)) |
452 | - $i++; |
|
471 | + { |
|
472 | + $i++; |
|
473 | + } |
|
453 | 474 | |
454 | 475 | $package_name = $package_name . $i . $ext; |
455 | 476 | } |
@@ -458,7 +479,9 @@ discard block |
||
458 | 479 | $packageInfo = getPackageInfo($url . $package_id); |
459 | 480 | |
460 | 481 | if (!is_array($packageInfo)) |
461 | - throw new Elk_Exception($packageInfo); |
|
482 | + { |
|
483 | + throw new Elk_Exception($packageInfo); |
|
484 | + } |
|
462 | 485 | |
463 | 486 | // Save the package to disk, use FTP if necessary |
464 | 487 | create_chmod_control( |
@@ -473,7 +496,9 @@ discard block |
||
473 | 496 | |
474 | 497 | // Done! Did we get this package automatically? |
475 | 498 | if (preg_match('~^http://[\w_\-]+\.elkarte\.net/~', $package_id) == 1 && strpos($package_id, 'dlattach') === false && isset($this->_req->query->auto)) |
476 | - redirectexit('action=admin;area=packages;sa=install;package=' . $package_name); |
|
499 | + { |
|
500 | + redirectexit('action=admin;area=packages;sa=install;package=' . $package_name); |
|
501 | + } |
|
477 | 502 | |
478 | 503 | // You just downloaded a addon from SERVER_NAME_GOES_HERE. |
479 | 504 | $context['package_server'] = $server; |
@@ -482,16 +507,25 @@ discard block |
||
482 | 507 | $context['package'] = getPackageInfo($package_name); |
483 | 508 | |
484 | 509 | if (!is_array($context['package'])) |
485 | - throw new Elk_Exception('package_cant_download', false); |
|
510 | + { |
|
511 | + throw new Elk_Exception('package_cant_download', false); |
|
512 | + } |
|
486 | 513 | |
487 | 514 | if ($context['package']['type'] === 'modification' || $context['package']['type'] === 'addon') |
488 | - $context['package']['install']['link'] = '<a class="linkbutton" href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">' . $txt['install_mod'] . '</a>'; |
|
515 | + { |
|
516 | + $context['package']['install']['link'] = '<a class="linkbutton" href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">' . $txt['install_mod'] . '</a>'; |
|
517 | + } |
|
489 | 518 | elseif ($context['package']['type'] === 'avatar') |
490 | - $context['package']['install']['link'] = '<a class="linkbutton" href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">' . $txt['use_avatars'] . '</a>'; |
|
519 | + { |
|
520 | + $context['package']['install']['link'] = '<a class="linkbutton" href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">' . $txt['use_avatars'] . '</a>'; |
|
521 | + } |
|
491 | 522 | elseif ($context['package']['type'] === 'language') |
492 | - $context['package']['install']['link'] = '<a class="linkbutton" href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">' . $txt['add_languages'] . '</a>'; |
|
493 | - else |
|
494 | - $context['package']['install']['link'] = ''; |
|
523 | + { |
|
524 | + $context['package']['install']['link'] = '<a class="linkbutton" href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">' . $txt['add_languages'] . '</a>'; |
|
525 | + } |
|
526 | + else { |
|
527 | + $context['package']['install']['link'] = ''; |
|
528 | + } |
|
495 | 529 | |
496 | 530 | $context['package']['list_files']['link'] = '<a class="linkbutton" href="' . $scripturl . '?action=admin;area=packages;sa=list;package=' . $context['package']['filename'] . '">' . $txt['list_files'] . '</a>'; |
497 | 531 | |
@@ -519,7 +553,9 @@ discard block |
||
519 | 553 | if (isset($this->_req->query->server)) |
520 | 554 | { |
521 | 555 | if ($this->_req->query->server == '') |
522 | - redirectexit('action=admin;area=packageservers'); |
|
556 | + { |
|
557 | + redirectexit('action=admin;area=packageservers'); |
|
558 | + } |
|
523 | 559 | |
524 | 560 | $server = $this->_req->getQuery('server', 'intval'); |
525 | 561 | |
@@ -530,7 +566,9 @@ discard block |
||
530 | 566 | |
531 | 567 | // If server does not exist then dump out. |
532 | 568 | if (empty($url)) |
533 | - throw new Elk_Exception('couldnt_connect', false); |
|
569 | + { |
|
570 | + throw new Elk_Exception('couldnt_connect', false); |
|
571 | + } |
|
534 | 572 | } |
535 | 573 | |
536 | 574 | return array($name, $url, $server); |
@@ -551,15 +589,21 @@ discard block |
||
551 | 589 | // @todo Use FTP if the packages directory is not writable. |
552 | 590 | // Check the file was even sent! |
553 | 591 | if (!isset($_FILES['package']['name']) || $_FILES['package']['name'] == '') |
554 | - throw new Elk_Exception('package_upload_error_nofile'); |
|
592 | + { |
|
593 | + throw new Elk_Exception('package_upload_error_nofile'); |
|
594 | + } |
|
555 | 595 | elseif (!is_uploaded_file($_FILES['package']['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['package']['tmp_name']))) |
556 | - throw new Elk_Exception('package_upload_error_failed'); |
|
596 | + { |
|
597 | + throw new Elk_Exception('package_upload_error_failed'); |
|
598 | + } |
|
557 | 599 | |
558 | 600 | // Make sure it has a sane filename. |
559 | 601 | $_FILES['package']['name'] = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $_FILES['package']['name']); |
560 | 602 | |
561 | 603 | if (strtolower(substr($_FILES['package']['name'], -4)) !== '.zip' && strtolower(substr($_FILES['package']['name'], -4)) !== '.tgz' && strtolower(substr($_FILES['package']['name'], -7)) !== '.tar.gz') |
562 | - throw new Elk_Exception('package_upload_error_supports', false, array('zip, tgz, tar.gz')); |
|
604 | + { |
|
605 | + throw new Elk_Exception('package_upload_error_supports', false, array('zip, tgz, tar.gz')); |
|
606 | + } |
|
563 | 607 | |
564 | 608 | // We only need the filename... |
565 | 609 | $packageName = basename($_FILES['package']['name']); |
@@ -569,7 +613,9 @@ discard block |
||
569 | 613 | |
570 | 614 | // @todo Maybe just roll it like we do for downloads? |
571 | 615 | if (file_exists($destination)) |
572 | - throw new Elk_Exception('package_upload_error_exists'); |
|
616 | + { |
|
617 | + throw new Elk_Exception('package_upload_error_exists'); |
|
618 | + } |
|
573 | 619 | |
574 | 620 | // Now move the file. |
575 | 621 | move_uploaded_file($_FILES['package']['tmp_name'], $destination); |
@@ -601,12 +647,16 @@ discard block |
||
601 | 647 | { |
602 | 648 | // No need to check these |
603 | 649 | if ($package->getFilename() == $packageName) |
604 | - continue; |
|
650 | + { |
|
651 | + continue; |
|
652 | + } |
|
605 | 653 | |
606 | 654 | // Read package info for the archive we found |
607 | 655 | $packageInfo = getPackageInfo($package->getFilename()); |
608 | 656 | if (!is_array($packageInfo)) |
609 | - continue; |
|
657 | + { |
|
658 | + continue; |
|
659 | + } |
|
610 | 660 | |
611 | 661 | // If it was already uploaded under another name don't upload it again. |
612 | 662 | if ($packageInfo['id'] == $context['package']['id'] && compareVersions($packageInfo['version'], $context['package']['version']) == 0) |
@@ -624,13 +674,20 @@ discard block |
||
624 | 674 | } |
625 | 675 | |
626 | 676 | if ($context['package']['type'] === 'modification' || $context['package']['type'] === 'addon') |
627 | - $context['package']['install']['link'] = '<a class="linkbutton" href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">' . $txt['install_mod'] . '</a>'; |
|
677 | + { |
|
678 | + $context['package']['install']['link'] = '<a class="linkbutton" href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">' . $txt['install_mod'] . '</a>'; |
|
679 | + } |
|
628 | 680 | elseif ($context['package']['type'] === 'avatar') |
629 | - $context['package']['install']['link'] = '<a class="linkbutton" href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">' . $txt['use_avatars'] . '</a>'; |
|
681 | + { |
|
682 | + $context['package']['install']['link'] = '<a class="linkbutton" href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">' . $txt['use_avatars'] . '</a>'; |
|
683 | + } |
|
630 | 684 | elseif ($context['package']['type'] === 'language') |
631 | - $context['package']['install']['link'] = '<a class="linkbutton" href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">' . $txt['add_languages'] . '</a>'; |
|
632 | - else |
|
633 | - $context['package']['install']['link'] = ''; |
|
685 | + { |
|
686 | + $context['package']['install']['link'] = '<a class="linkbutton" href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">' . $txt['add_languages'] . '</a>'; |
|
687 | + } |
|
688 | + else { |
|
689 | + $context['package']['install']['link'] = ''; |
|
690 | + } |
|
634 | 691 | |
635 | 692 | $context['package']['list_files']['link'] = '<a class="linkbutton" href="' . $scripturl . '?action=admin;area=packages;sa=list;package=' . $context['package']['filename'] . '">' . $txt['list_files'] . '</a>'; |
636 | 693 | |
@@ -654,7 +711,9 @@ discard block |
||
654 | 711 | |
655 | 712 | // If they put a slash on the end, get rid of it. |
656 | 713 | if (substr($this->_req->post->serverurl, -1) === '/') |
657 | - $this->_req->post->serverurl = substr($this->_req->post->serverurl, 0, -1); |
|
714 | + { |
|
715 | + $this->_req->post->serverurl = substr($this->_req->post->serverurl, 0, -1); |
|
716 | + } |
|
658 | 717 | |
659 | 718 | // Are they both nice and clean? |
660 | 719 | $servername = trim(Util::htmlspecialchars($this->_req->post->servername)); |
@@ -712,7 +771,9 @@ discard block |
||
712 | 771 | |
713 | 772 | // Give FTP a chance... |
714 | 773 | if ($context['package_download_broken']) |
715 | - $this->ftp_connect(); |
|
774 | + { |
|
775 | + $this->ftp_connect(); |
|
776 | + } |
|
716 | 777 | } |
717 | 778 | |
718 | 779 | /** |
@@ -769,15 +830,21 @@ discard block |
||
769 | 830 | } |
770 | 831 | // ...or we failed |
771 | 832 | elseif ($ftp->error !== false && !isset($ftp_error)) |
772 | - $ftp_error = $ftp->last_message === null ? '' : $ftp->last_message; |
|
833 | + { |
|
834 | + $ftp_error = $ftp->last_message === null ? '' : $ftp->last_message; |
|
835 | + } |
|
773 | 836 | |
774 | 837 | list ($username, $detect_path, $found_path) = $ftp->detect_path(BOARDDIR); |
775 | 838 | |
776 | 839 | if ($found_path || !isset($this->_req->post->ftp_path)) |
777 | - $this->_req->post->ftp_path = $detect_path; |
|
840 | + { |
|
841 | + $this->_req->post->ftp_path = $detect_path; |
|
842 | + } |
|
778 | 843 | |
779 | 844 | if (!isset($this->_req->post->ftp_username)) |
780 | - $this->_req->post->ftp_username = $username; |
|
845 | + { |
|
846 | + $this->_req->post->ftp_username = $username; |
|
847 | + } |
|
781 | 848 | |
782 | 849 | // Fill the boxes for a FTP connection with data from the previous attempt too, if any |
783 | 850 | $context['package_ftp'] = array( |
@@ -176,7 +176,9 @@ discard block |
||
176 | 176 | // You have to specify a file!! |
177 | 177 | $file = $this->_req->getQuery('package', 'trim'); |
178 | 178 | if (empty($file)) |
179 | - redirectexit('action=admin;area=packages'); |
|
179 | + { |
|
180 | + redirectexit('action=admin;area=packages'); |
|
181 | + } |
|
180 | 182 | |
181 | 183 | // What are we trying to do |
182 | 184 | $this->_filename = (string) preg_replace('~[\.]+~', '.', $file); |
@@ -184,7 +186,9 @@ discard block |
||
184 | 186 | |
185 | 187 | // If we can't find the file, our install ends here |
186 | 188 | if (!file_exists(BOARDDIR . '/packages/' . $this->_filename)) |
187 | - throw new Elk_Exception('package_no_file', false); |
|
189 | + { |
|
190 | + throw new Elk_Exception('package_no_file', false); |
|
191 | + } |
|
188 | 192 | |
189 | 193 | // Do we have an existing id, for uninstalls and the like. |
190 | 194 | $this->install_id = $this->_req->getQuery('pid', 'intval', 0); |
@@ -197,9 +201,12 @@ discard block |
||
197 | 201 | |
198 | 202 | // Make sure our temp directory exists and is empty. |
199 | 203 | if (file_exists(BOARDDIR . '/packages/temp')) |
200 | - deltree(BOARDDIR . '/packages/temp', false); |
|
201 | - else |
|
202 | - $this->_create_temp_dir(); |
|
204 | + { |
|
205 | + deltree(BOARDDIR . '/packages/temp', false); |
|
206 | + } |
|
207 | + else { |
|
208 | + $this->_create_temp_dir(); |
|
209 | + } |
|
203 | 210 | |
204 | 211 | // Extract the files in to the temp so we can get things like the readme, etc. |
205 | 212 | $this->_extract_files_temp(); |
@@ -210,7 +217,9 @@ discard block |
||
210 | 217 | // Get the package info... |
211 | 218 | $packageInfo = getPackageInfo($this->_filename); |
212 | 219 | if (!is_array($packageInfo)) |
213 | - throw new Elk_Exception($packageInfo); |
|
220 | + { |
|
221 | + throw new Elk_Exception($packageInfo); |
|
222 | + } |
|
214 | 223 | |
215 | 224 | $packageInfo['filename'] = $this->_filename; |
216 | 225 | |
@@ -222,17 +231,24 @@ discard block |
||
222 | 231 | |
223 | 232 | $context['database_changes'] = array(); |
224 | 233 | if (isset($packageInfo['uninstall']['database'])) |
225 | - $context['database_changes'][] = $txt['execute_database_changes'] . ' - ' . $packageInfo['uninstall']['database']; |
|
234 | + { |
|
235 | + $context['database_changes'][] = $txt['execute_database_changes'] . ' - ' . $packageInfo['uninstall']['database']; |
|
236 | + } |
|
226 | 237 | elseif (!empty($package_installed['db_changes'])) |
227 | 238 | { |
228 | 239 | foreach ($package_installed['db_changes'] as $change) |
229 | 240 | { |
230 | 241 | if (isset($change[2]) && isset($txt['package_db_' . $change[0]])) |
231 | - $context['database_changes'][] = sprintf($txt['package_db_' . $change[0]], $change[1], $change[2]); |
|
242 | + { |
|
243 | + $context['database_changes'][] = sprintf($txt['package_db_' . $change[0]], $change[1], $change[2]); |
|
244 | + } |
|
232 | 245 | elseif (isset($txt['package_db_' . $change[0]])) |
233 | - $context['database_changes'][] = sprintf($txt['package_db_' . $change[0]], $change[1]); |
|
234 | - else |
|
235 | - $context['database_changes'][] = $change[0] . '-' . $change[1] . (isset($change[2]) ? '-' . $change[2] : ''); |
|
246 | + { |
|
247 | + $context['database_changes'][] = sprintf($txt['package_db_' . $change[0]], $change[1]); |
|
248 | + } |
|
249 | + else { |
|
250 | + $context['database_changes'][] = $change[0] . '-' . $change[1] . (isset($change[2]) ? '-' . $change[2] : ''); |
|
251 | + } |
|
236 | 252 | } |
237 | 253 | } |
238 | 254 | |
@@ -243,7 +259,9 @@ discard block |
||
243 | 259 | |
244 | 260 | // No actions found, return so we can display an error |
245 | 261 | if (empty($actions)) |
246 | - redirectexit('action=admin;area=packages'); |
|
262 | + { |
|
263 | + redirectexit('action=admin;area=packages'); |
|
264 | + } |
|
247 | 265 | |
248 | 266 | // Now prepare things for the template using the package actions class |
249 | 267 | $pka = new Package_Actions(); |
@@ -276,7 +294,9 @@ discard block |
||
276 | 294 | |
277 | 295 | // Clear the temp directory |
278 | 296 | if (file_exists(BOARDDIR . '/packages/temp')) |
279 | - deltree(BOARDDIR . '/packages/temp'); |
|
297 | + { |
|
298 | + deltree(BOARDDIR . '/packages/temp'); |
|
299 | + } |
|
280 | 300 | |
281 | 301 | // Will we need chmod permissions to pull this off |
282 | 302 | $this->chmod_files = !empty($pka->chmod_files) ? $pka->chmod_files : array(); |
@@ -306,17 +326,26 @@ discard block |
||
306 | 326 | preg_match('~^\$(languagedir|languages_dir|imagesdir|themedir)(\\|/)*(.+)*~i', $action_data['unparsed_destination'], $matches); |
307 | 327 | |
308 | 328 | if ($matches[1] === 'imagesdir') |
309 | - $path = '/' . basename($settings['default_images_url']); |
|
329 | + { |
|
330 | + $path = '/' . basename($settings['default_images_url']); |
|
331 | + } |
|
310 | 332 | elseif ($matches[1] === 'languagedir' || $matches[1] === 'languages_dir') |
311 | - $path = '/languages'; |
|
312 | - else |
|
313 | - $path = ''; |
|
333 | + { |
|
334 | + $path = '/languages'; |
|
335 | + } |
|
336 | + else { |
|
337 | + $path = ''; |
|
338 | + } |
|
314 | 339 | |
315 | 340 | if (!empty($matches[3])) |
316 | - $path .= $matches[3]; |
|
341 | + { |
|
342 | + $path .= $matches[3]; |
|
343 | + } |
|
317 | 344 | |
318 | 345 | if (!$this->_uninstalling) |
319 | - $path .= '/' . basename($action_data['filename']); |
|
346 | + { |
|
347 | + $path .= '/' . basename($action_data['filename']); |
|
348 | + } |
|
320 | 349 | |
321 | 350 | // Loop through each custom theme to note it's candidacy! |
322 | 351 | foreach ($this->theme_paths as $id => $theme_data) |
@@ -333,36 +362,45 @@ discard block |
||
333 | 362 | { |
334 | 363 | $temp = dirname($real_path); |
335 | 364 | while (!file_exists($temp) && strlen($temp) > 1) |
336 | - $temp = dirname($temp); |
|
365 | + { |
|
366 | + $temp = dirname($temp); |
|
367 | + } |
|
337 | 368 | |
338 | 369 | $this->chmod_files[] = $temp; |
339 | 370 | } |
340 | 371 | |
341 | 372 | if ($action_data['type'] === 'require-dir' && !is_writable($real_path) && (file_exists($real_path) || !is_writable(dirname($real_path)))) |
342 | - $this->chmod_files[] = $real_path; |
|
373 | + { |
|
374 | + $this->chmod_files[] = $real_path; |
|
375 | + } |
|
343 | 376 | |
344 | 377 | if (!isset($context['theme_actions'][$id])) |
345 | - $context['theme_actions'][$id] = array( |
|
378 | + { |
|
379 | + $context['theme_actions'][$id] = array( |
|
346 | 380 | 'name' => $theme_data['name'], |
347 | 381 | 'actions' => array(), |
348 | 382 | ); |
383 | + } |
|
349 | 384 | |
350 | 385 | if ($this->_uninstalling) |
351 | - $context['theme_actions'][$id]['actions'][] = array( |
|
386 | + { |
|
387 | + $context['theme_actions'][$id]['actions'][] = array( |
|
352 | 388 | 'type' => $txt['package_delete'] . ' ' . ($action_data['type'] === 'require-dir' ? $txt['package_tree'] : $txt['package_file']), |
353 | 389 | 'action' => strtr($real_path, array('\\' => '/', BOARDDIR => '.')), |
354 | 390 | 'description' => '', |
355 | 391 | 'value' => base64_encode(json_encode(array('type' => $action_data['type'], 'orig' => $action_data['filename'], 'future' => $real_path, 'id' => $id))), |
356 | 392 | 'not_mod' => true, |
357 | 393 | ); |
358 | - else |
|
359 | - $context['theme_actions'][$id]['actions'][] = array( |
|
394 | + } |
|
395 | + else { |
|
396 | + $context['theme_actions'][$id]['actions'][] = array( |
|
360 | 397 | 'type' => $txt['package_extract'] . ' ' . ($action_data['type'] === 'require-dir' ? $txt['package_tree'] : $txt['package_file']), |
361 | 398 | 'action' => strtr($real_path, array('\\' => '/', BOARDDIR => '.')), |
362 | 399 | 'description' => '', |
363 | 400 | 'value' => base64_encode(json_encode(array('type' => $action_data['type'], 'orig' => $action_data['destination'], 'future' => $real_path, 'id' => $id))), |
364 | 401 | 'not_mod' => true, |
365 | 402 | ); |
403 | + } |
|
366 | 404 | } |
367 | 405 | } |
368 | 406 | } |
@@ -398,7 +436,9 @@ discard block |
||
398 | 436 | } |
399 | 437 | |
400 | 438 | if (!isset($this->_base_path)) |
401 | - $this->_base_path = ''; |
|
439 | + { |
|
440 | + $this->_base_path = ''; |
|
441 | + } |
|
402 | 442 | } |
403 | 443 | // Perhaps its a directory then, assumed to be extracted |
404 | 444 | elseif (!empty($this->_filename) && is_dir(BOARDDIR . '/packages/' . $this->_filename)) |
@@ -411,8 +451,9 @@ discard block |
||
411 | 451 | $this->_base_path = ''; |
412 | 452 | } |
413 | 453 | // Well we don't know what it is then, so we stop |
414 | - else |
|
415 | - throw new Elk_Exception('no_access', false); |
|
454 | + else { |
|
455 | + throw new Elk_Exception('no_access', false); |
|
456 | + } |
|
416 | 457 | } |
417 | 458 | |
418 | 459 | /** |
@@ -459,7 +500,9 @@ discard block |
||
459 | 500 | foreach ($this->theme_paths as $id => $data) |
460 | 501 | { |
461 | 502 | if ($id != 1 && !in_array($id, $package_installed['old_themes'])) |
462 | - unset($this->theme_paths[$id]); |
|
503 | + { |
|
504 | + unset($this->theme_paths[$id]); |
|
505 | + } |
|
463 | 506 | } |
464 | 507 | } |
465 | 508 | // Or is it already installed and you want to upgrade |
@@ -470,23 +513,31 @@ discard block |
||
470 | 513 | |
471 | 514 | // There was no upgrade.... |
472 | 515 | if (empty($actions)) |
473 | - $this->_is_installed = true; |
|
516 | + { |
|
517 | + $this->_is_installed = true; |
|
518 | + } |
|
474 | 519 | else |
475 | 520 | { |
476 | 521 | // Otherwise they can only upgrade themes from the first time around. |
477 | 522 | foreach ($this->theme_paths as $id => $data) |
478 | 523 | { |
479 | 524 | if ($id != 1 && !in_array($id, $package_installed['old_themes'])) |
480 | - unset($this->theme_paths[$id]); |
|
525 | + { |
|
526 | + unset($this->theme_paths[$id]); |
|
527 | + } |
|
481 | 528 | } |
482 | 529 | } |
483 | 530 | } |
484 | 531 | // Simply already installed |
485 | 532 | elseif (isset($package_installed['old_version']) && $package_installed['old_version'] == $packageInfo['version']) |
486 | - $this->_is_installed = true; |
|
533 | + { |
|
534 | + $this->_is_installed = true; |
|
535 | + } |
|
487 | 536 | |
488 | 537 | if (!isset($package_installed['old_version']) || $this->_is_installed) |
489 | - $actions = parsePackageInfo($packageInfo['xml'], $testing, 'install'); |
|
538 | + { |
|
539 | + $actions = parsePackageInfo($packageInfo['xml'], $testing, 'install'); |
|
540 | + } |
|
490 | 541 | |
491 | 542 | return $actions; |
492 | 543 | } |
@@ -516,7 +567,9 @@ discard block |
||
516 | 567 | // No temp directory was able to be made, that's fatal |
517 | 568 | deltree(BOARDDIR . '/packages/temp', false); |
518 | 569 | if (!mktree(BOARDDIR . '/packages/temp', 0777)) |
519 | - throw new Elk_Exception('package_cant_download', false); |
|
570 | + { |
|
571 | + throw new Elk_Exception('package_cant_download', false); |
|
572 | + } |
|
520 | 573 | } |
521 | 574 | } |
522 | 575 | } |
@@ -535,11 +588,15 @@ discard block |
||
535 | 588 | // If there's no package file, what are we installing? |
536 | 589 | $this->_filename = $this->_req->getQuery('package', 'trim'); |
537 | 590 | if (empty($this->_filename)) |
538 | - redirectexit('action=admin;area=packages'); |
|
591 | + { |
|
592 | + redirectexit('action=admin;area=packages'); |
|
593 | + } |
|
539 | 594 | |
540 | 595 | // And if the file does not exist there is a problem |
541 | 596 | if (!file_exists(BOARDDIR . '/packages/' . $this->_filename)) |
542 | - throw new Elk_Exception('package_no_file', false); |
|
597 | + { |
|
598 | + throw new Elk_Exception('package_no_file', false); |
|
599 | + } |
|
543 | 600 | |
544 | 601 | // If this is an uninstall, we'll have an id. |
545 | 602 | $this->install_id = $this->_req->getQuery('pid', 'intval', 0); |
@@ -555,9 +612,12 @@ discard block |
||
555 | 612 | |
556 | 613 | // Make sure temp directory exists and is empty! |
557 | 614 | if (file_exists(BOARDDIR . '/packages/temp')) |
558 | - deltree(BOARDDIR . '/packages/temp', false); |
|
559 | - else |
|
560 | - $this->_create_temp_dir(); |
|
615 | + { |
|
616 | + deltree(BOARDDIR . '/packages/temp', false); |
|
617 | + } |
|
618 | + else { |
|
619 | + $this->_create_temp_dir(); |
|
620 | + } |
|
561 | 621 | |
562 | 622 | // Let the unpacker do the work. |
563 | 623 | $this->_extract_files_temp(); |
@@ -568,8 +628,10 @@ discard block |
||
568 | 628 | if (!empty($this->_req->post->custom_theme)) |
569 | 629 | { |
570 | 630 | foreach ($this->_req->post->custom_theme as $tid) |
571 | - if (in_array($tid, $known_themes)) |
|
631 | + { |
|
632 | + if (in_array($tid, $known_themes)) |
|
572 | 633 | $custom_themes[] = (int) $tid; |
634 | + } |
|
573 | 635 | } |
574 | 636 | |
575 | 637 | // Now load up the paths of the themes that we need to know about. |
@@ -587,11 +649,15 @@ discard block |
||
587 | 649 | foreach ($this->_req->post->theme_changes as $change) |
588 | 650 | { |
589 | 651 | if (empty($change)) |
590 | - continue; |
|
652 | + { |
|
653 | + continue; |
|
654 | + } |
|
591 | 655 | |
592 | 656 | $theme_data = json_decode(base64_decode($change), true); |
593 | 657 | if (empty($theme_data['type'])) |
594 | - continue; |
|
658 | + { |
|
659 | + continue; |
|
660 | + } |
|
595 | 661 | |
596 | 662 | $themes_installed[] = $theme_data['id']; |
597 | 663 | $context['theme_copies'][$theme_data['type']][$theme_data['orig']][] = $theme_data['future']; |
@@ -601,7 +667,9 @@ discard block |
||
601 | 667 | // Get the package info... |
602 | 668 | $packageInfo = getPackageInfo($this->_filename); |
603 | 669 | if (!is_array($packageInfo)) |
604 | - throw new Elk_Exception($packageInfo); |
|
670 | + { |
|
671 | + throw new Elk_Exception($packageInfo); |
|
672 | + } |
|
605 | 673 | |
606 | 674 | $packageInfo['filename'] = $this->_filename; |
607 | 675 | |
@@ -664,7 +732,9 @@ discard block |
||
664 | 732 | if (!empty($package_check['install_state'])) |
665 | 733 | { |
666 | 734 | if ($this->_uninstalling) |
667 | - setPackageState($package_check['package_id'], $this->install_id); |
|
735 | + { |
|
736 | + setPackageState($package_check['package_id'], $this->install_id); |
|
737 | + } |
|
668 | 738 | else |
669 | 739 | { |
670 | 740 | // not uninstalling so must be an upgrade |
@@ -680,9 +750,12 @@ discard block |
||
680 | 750 | $table_log = $table_installer->package_log(); |
681 | 751 | |
682 | 752 | if (!empty($old_db_changes)) |
683 | - $db_package_log = empty($table_log) ? $old_db_changes : array_merge($old_db_changes, $table_log); |
|
684 | - else |
|
685 | - $db_package_log = $table_log; |
|
753 | + { |
|
754 | + $db_package_log = empty($table_log) ? $old_db_changes : array_merge($old_db_changes, $table_log); |
|
755 | + } |
|
756 | + else { |
|
757 | + $db_package_log = $table_log; |
|
758 | + } |
|
686 | 759 | |
687 | 760 | // If there are some database changes we might want to remove then filter them out. |
688 | 761 | if (!empty($db_package_log)) |
@@ -693,15 +766,20 @@ discard block |
||
693 | 766 | foreach ($db_package_log as $k => $log) |
694 | 767 | { |
695 | 768 | if ($log[0] === 'remove_table') |
696 | - $tables[] = $log[1]; |
|
769 | + { |
|
770 | + $tables[] = $log[1]; |
|
771 | + } |
|
697 | 772 | elseif (in_array($log[1], $tables)) |
698 | - unset($db_package_log[$k]); |
|
773 | + { |
|
774 | + unset($db_package_log[$k]); |
|
775 | + } |
|
699 | 776 | } |
700 | 777 | |
701 | 778 | $package_installed['db_changes'] = serialize($db_package_log); |
702 | 779 | } |
703 | - else |
|
704 | - $package_installed['db_changes'] = ''; |
|
780 | + else { |
|
781 | + $package_installed['db_changes'] = ''; |
|
782 | + } |
|
705 | 783 | |
706 | 784 | // What themes did we actually install? |
707 | 785 | $themes_installed = array_unique($themes_installed); |
@@ -726,17 +804,25 @@ discard block |
||
726 | 804 | foreach ($package_installed['db_changes'] as $change) |
727 | 805 | { |
728 | 806 | if ($change[0] === 'remove_table' && isset($change[1])) |
729 | - $table_installer->db_drop_table($change[1]); |
|
807 | + { |
|
808 | + $table_installer->db_drop_table($change[1]); |
|
809 | + } |
|
730 | 810 | elseif ($change[0] === 'remove_column' && isset($change[2])) |
731 | - $table_installer->db_remove_column($change[1], $change[2]); |
|
811 | + { |
|
812 | + $table_installer->db_remove_column($change[1], $change[2]); |
|
813 | + } |
|
732 | 814 | elseif ($change[0] === 'remove_index' && isset($change[2])) |
733 | - $table_installer->db_remove_index($change[1], $change[2]); |
|
815 | + { |
|
816 | + $table_installer->db_remove_index($change[1], $change[2]); |
|
817 | + } |
|
734 | 818 | } |
735 | 819 | } |
736 | 820 | |
737 | 821 | // Clean house... get rid of the evidence ;). |
738 | 822 | if (file_exists(BOARDDIR . '/packages/temp')) |
739 | - deltree(BOARDDIR . '/packages/temp'); |
|
823 | + { |
|
824 | + deltree(BOARDDIR . '/packages/temp'); |
|
825 | + } |
|
740 | 826 | |
741 | 827 | // Log what we just did. |
742 | 828 | logAction($this->_uninstalling ? 'uninstall_package' : (!empty($is_upgrade) ? 'upgrade_package' : 'install_package'), array('package' => Util::htmlspecialchars($packageInfo['name']), 'version' => Util::htmlspecialchars($packageInfo['version'])), 'admin'); |
@@ -757,7 +843,9 @@ discard block |
||
757 | 843 | private function _sort_table_first($a, $b) |
758 | 844 | { |
759 | 845 | if ($a[0] == $b[0]) |
760 | - return 0; |
|
846 | + { |
|
847 | + return 0; |
|
848 | + } |
|
761 | 849 | |
762 | 850 | return $a[0] === 'remove_table' ? -1 : 1; |
763 | 851 | } |
@@ -771,7 +859,9 @@ discard block |
||
771 | 859 | |
772 | 860 | // No package? Show him or her the door. |
773 | 861 | if (!isset($this->_req->query->package) || $this->_req->query->package == '') |
774 | - redirectexit('action=admin;area=packages'); |
|
862 | + { |
|
863 | + redirectexit('action=admin;area=packages'); |
|
864 | + } |
|
775 | 865 | |
776 | 866 | $context['linktree'][] = array( |
777 | 867 | 'url' => $scripturl . '?action=admin;area=packages;sa=list;package=' . $this->_req->query->package, |
@@ -785,9 +875,13 @@ discard block |
||
785 | 875 | |
786 | 876 | // Let the unpacker do the work. |
787 | 877 | if (is_file(BOARDDIR . '/packages/' . $context['filename'])) |
788 | - $context['files'] = read_tgz_file(BOARDDIR . '/packages/' . $context['filename'], null); |
|
878 | + { |
|
879 | + $context['files'] = read_tgz_file(BOARDDIR . '/packages/' . $context['filename'], null); |
|
880 | + } |
|
789 | 881 | elseif (is_dir(BOARDDIR . '/packages/' . $context['filename'])) |
790 | - $context['files'] = listtree(BOARDDIR . '/packages/' . $context['filename']); |
|
882 | + { |
|
883 | + $context['files'] = listtree(BOARDDIR . '/packages/' . $context['filename']); |
|
884 | + } |
|
791 | 885 | } |
792 | 886 | |
793 | 887 | /** |
@@ -799,11 +893,15 @@ discard block |
||
799 | 893 | |
800 | 894 | // No package? Show him or her the door. |
801 | 895 | if (!isset($this->_req->query->package) || $this->_req->query->package == '') |
802 | - redirectexit('action=admin;area=packages'); |
|
896 | + { |
|
897 | + redirectexit('action=admin;area=packages'); |
|
898 | + } |
|
803 | 899 | |
804 | 900 | // No file? Show him or her the door. |
805 | 901 | if (!isset($this->_req->query->file) || $this->_req->query->file == '') |
806 | - redirectexit('action=admin;area=packages'); |
|
902 | + { |
|
903 | + redirectexit('action=admin;area=packages'); |
|
904 | + } |
|
807 | 905 | |
808 | 906 | $this->_req->query->package = preg_replace('~[\.]+~', '.', strtr($this->_req->query->package, array('/' => '_', '\\' => '_'))); |
809 | 907 | $this->_req->query->file = preg_replace('~[\.]+~', '.', $this->_req->query->file); |
@@ -811,9 +909,13 @@ discard block |
||
811 | 909 | if (isset($this->_req->query->raw)) |
812 | 910 | { |
813 | 911 | if (is_file(BOARDDIR . '/packages/' . $this->_req->query->package)) |
814 | - echo read_tgz_file(BOARDDIR . '/packages/' . $this->_req->query->package, $this->_req->query->file, true); |
|
912 | + { |
|
913 | + echo read_tgz_file(BOARDDIR . '/packages/' . $this->_req->query->package, $this->_req->query->file, true); |
|
914 | + } |
|
815 | 915 | elseif (is_dir(BOARDDIR . '/packages/' . $this->_req->query->package)) |
816 | - echo file_get_contents(BOARDDIR . '/packages/' . $this->_req->query->package . '/' . $this->_req->query->file); |
|
916 | + { |
|
917 | + echo file_get_contents(BOARDDIR . '/packages/' . $this->_req->query->package . '/' . $this->_req->query->file); |
|
918 | + } |
|
817 | 919 | |
818 | 920 | obExit(false); |
819 | 921 | } |
@@ -831,16 +933,24 @@ discard block |
||
831 | 933 | |
832 | 934 | // Let the unpacker do the work.... but make sure we handle images properly. |
833 | 935 | if (in_array(strtolower(strrchr($this->_req->query->file, '.')), array('.bmp', '.gif', '.jpeg', '.jpg', '.png'))) |
834 | - $context['filedata'] = '<img src="' . $scripturl . '?action=admin;area=packages;sa=examine;package=' . $this->_req->query->package . ';file=' . $this->_req->query->file . ';raw" alt="' . $this->_req->query->file . '" />'; |
|
936 | + { |
|
937 | + $context['filedata'] = '<img src="' . $scripturl . '?action=admin;area=packages;sa=examine;package=' . $this->_req->query->package . ';file=' . $this->_req->query->file . ';raw" alt="' . $this->_req->query->file . '" />'; |
|
938 | + } |
|
835 | 939 | else |
836 | 940 | { |
837 | 941 | if (is_file(BOARDDIR . '/packages/' . $this->_req->query->package)) |
838 | - $context['filedata'] = htmlspecialchars(read_tgz_file(BOARDDIR . '/packages/' . $this->_req->query->package, $this->_req->query->file, true)); |
|
942 | + { |
|
943 | + $context['filedata'] = htmlspecialchars(read_tgz_file(BOARDDIR . '/packages/' . $this->_req->query->package, $this->_req->query->file, true)); |
|
944 | + } |
|
839 | 945 | elseif (is_dir(BOARDDIR . '/packages/' . $this->_req->query->package)) |
840 | - $context['filedata'] = htmlspecialchars(file_get_contents(BOARDDIR . '/packages/' . $this->_req->query->package . '/' . $this->_req->query->file)); |
|
946 | + { |
|
947 | + $context['filedata'] = htmlspecialchars(file_get_contents(BOARDDIR . '/packages/' . $this->_req->query->package . '/' . $this->_req->query->file)); |
|
948 | + } |
|
841 | 949 | |
842 | 950 | if (strtolower(strrchr($this->_req->query->file, '.')) === '.php') |
843 | - $context['filedata'] = highlight_php_code($context['filedata']); |
|
951 | + { |
|
952 | + $context['filedata'] = highlight_php_code($context['filedata']); |
|
953 | + } |
|
844 | 954 | } |
845 | 955 | } |
846 | 956 | |
@@ -875,7 +985,9 @@ discard block |
||
875 | 985 | |
876 | 986 | // Ack, don't allow deletion of arbitrary files here, could become a security hole somehow! |
877 | 987 | if (!isset($this->_req->query->package) || $this->_req->query->package === 'index.php' || $this->_req->query->package === 'installed.list' || $this->_req->query->package === 'backups') |
878 | - redirectexit('action=admin;area=packages;sa=browse'); |
|
988 | + { |
|
989 | + redirectexit('action=admin;area=packages;sa=browse'); |
|
990 | + } |
|
879 | 991 | $this->_req->query->package = preg_replace('~[\.]+~', '.', strtr($this->_req->query->package, array('/' => '_', '\\' => '_'))); |
880 | 992 | |
881 | 993 | // Can't delete what's not there. |
@@ -886,7 +998,9 @@ discard block |
||
886 | 998 | create_chmod_control(array(BOARDDIR . '/packages/' . $this->_req->query->package), array('destination_url' => $scripturl . '?action=admin;area=packages;sa=remove;package=' . $this->_req->query->package, 'crash_on_error' => true)); |
887 | 999 | |
888 | 1000 | if (is_dir(BOARDDIR . '/packages/' . $this->_req->query->package)) |
889 | - deltree(BOARDDIR . '/packages/' . $this->_req->query->package); |
|
1001 | + { |
|
1002 | + deltree(BOARDDIR . '/packages/' . $this->_req->query->package); |
|
1003 | + } |
|
890 | 1004 | else |
891 | 1005 | { |
892 | 1006 | @chmod(BOARDDIR . '/packages/' . $this->_req->query->package, 0777); |
@@ -939,7 +1053,9 @@ discard block |
||
939 | 1053 | global $context; |
940 | 1054 | |
941 | 1055 | if (isset($context['available_' . $type . ''][$package_md5])) |
942 | - return $context['available_' . $type . ''][$package_md5]['name']; |
|
1056 | + { |
|
1057 | + return $context['available_' . $type . ''][$package_md5]['name']; |
|
1058 | + } |
|
943 | 1059 | |
944 | 1060 | return ''; |
945 | 1061 | }, |
@@ -959,7 +1075,9 @@ discard block |
||
959 | 1075 | global $context; |
960 | 1076 | |
961 | 1077 | if (isset($context['available_' . $type . ''][$package_md5])) |
962 | - return $context['available_' . $type . ''][$package_md5]['version']; |
|
1078 | + { |
|
1079 | + return $context['available_' . $type . ''][$package_md5]['version']; |
|
1080 | + } |
|
963 | 1081 | |
964 | 1082 | return ''; |
965 | 1083 | }, |
@@ -978,27 +1096,39 @@ discard block |
||
978 | 1096 | global $context, $scripturl, $txt; |
979 | 1097 | |
980 | 1098 | if (!isset($context['available_' . $type . ''][$package_md5])) |
981 | - return ''; |
|
1099 | + { |
|
1100 | + return ''; |
|
1101 | + } |
|
982 | 1102 | |
983 | 1103 | // Rewrite shortcut |
984 | 1104 | $package = $context['available_' . $type . ''][$package_md5]; |
985 | 1105 | $return = ''; |
986 | 1106 | |
987 | 1107 | if ($package['can_uninstall']) |
988 | - $return = ' |
|
1108 | + { |
|
1109 | + $return = ' |
|
989 | 1110 | <a class="linkbutton" href="' . $scripturl . '?action=admin;area=packages;sa=uninstall;package=' . $package['filename'] . ';pid=' . $package['installed_id'] . '">' . $txt['uninstall'] . '</a>'; |
1111 | + } |
|
990 | 1112 | elseif ($package['can_emulate_uninstall']) |
991 | - $return = ' |
|
1113 | + { |
|
1114 | + $return = ' |
|
992 | 1115 | <a class="linkbutton" href="' . $scripturl . '?action=admin;area=packages;sa=uninstall;ve=' . $package['can_emulate_uninstall'] . ';package=' . $package['filename'] . ';pid=' . $package['installed_id'] . '">' . $txt['package_emulate_uninstall'] . ' ' . $package['can_emulate_uninstall'] . '</a>'; |
1116 | + } |
|
993 | 1117 | elseif ($package['can_upgrade']) |
994 | - $return = ' |
|
1118 | + { |
|
1119 | + $return = ' |
|
995 | 1120 | <a class="linkbutton" href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $package['filename'] . '">' . $txt['package_upgrade'] . '</a>'; |
1121 | + } |
|
996 | 1122 | elseif ($package['can_install']) |
997 | - $return = ' |
|
1123 | + { |
|
1124 | + $return = ' |
|
998 | 1125 | <a class="linkbutton" href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $package['filename'] . '">' . $txt['install_mod'] . '</a>'; |
1126 | + } |
|
999 | 1127 | elseif ($package['can_emulate_install']) |
1000 | - $return = ' |
|
1128 | + { |
|
1129 | + $return = ' |
|
1001 | 1130 | <a class="linkbutton" href="' . $scripturl . '?action=admin;area=packages;sa=install;ve=' . $package['can_emulate_install'] . ';package=' . $package['filename'] . '">' . $txt['package_emulate_install'] . ' ' . $package['can_emulate_install'] . '</a>'; |
1131 | + } |
|
1002 | 1132 | |
1003 | 1133 | return $return . ' |
1004 | 1134 | <a class="linkbutton" href="' . $scripturl . '?action=admin;area=packages;sa=list;package=' . $package['filename'] . '">' . $txt['list_files'] . '</a> |
@@ -1086,9 +1216,12 @@ discard block |
||
1086 | 1216 | } |
1087 | 1217 | |
1088 | 1218 | if (preg_match('~^/home\d*/([^/]+?)/public_html~', $this->_req->server->DOCUMENT_ROOT, $match)) |
1089 | - $default_username = $match[1]; |
|
1090 | - else |
|
1091 | - $default_username = ''; |
|
1219 | + { |
|
1220 | + $default_username = $match[1]; |
|
1221 | + } |
|
1222 | + else { |
|
1223 | + $default_username = ''; |
|
1224 | + } |
|
1092 | 1225 | |
1093 | 1226 | $context['page_title'] = $txt['package_settings']; |
1094 | 1227 | $context['sub_template'] = 'install_options'; |
@@ -1111,7 +1244,9 @@ discard block |
||
1111 | 1244 | |
1112 | 1245 | // We need to know the operation key for the search and replace? |
1113 | 1246 | if (!isset($this->_req->query->operation_key, $this->_req->query->filename) && !is_numeric($this->_req->query->operation_key)) |
1114 | - throw new Elk_Exception('operation_invalid', 'general'); |
|
1247 | + { |
|
1248 | + throw new Elk_Exception('operation_invalid', 'general'); |
|
1249 | + } |
|
1115 | 1250 | |
1116 | 1251 | // Load the required file. |
1117 | 1252 | require_once(SUBSDIR . '/Themes.subs.php'); |
@@ -1139,7 +1274,9 @@ discard block |
||
1139 | 1274 | } |
1140 | 1275 | |
1141 | 1276 | if (!isset($context['base_path'])) |
1142 | - $context['base_path'] = ''; |
|
1277 | + { |
|
1278 | + $context['base_path'] = ''; |
|
1279 | + } |
|
1143 | 1280 | } |
1144 | 1281 | elseif (is_dir(BOARDDIR . '/packages/' . $context['filename'])) |
1145 | 1282 | { |
@@ -1161,7 +1298,9 @@ discard block |
||
1161 | 1298 | foreach ($theme_paths as $id => $data) |
1162 | 1299 | { |
1163 | 1300 | if ($id != 1 && !in_array($id, $old_themes)) |
1164 | - unset($theme_paths[$id]); |
|
1301 | + { |
|
1302 | + unset($theme_paths[$id]); |
|
1303 | + } |
|
1165 | 1304 | } |
1166 | 1305 | } |
1167 | 1306 | } |
@@ -1223,8 +1362,9 @@ discard block |
||
1223 | 1362 | 'form_elements_only' => true, |
1224 | 1363 | ); |
1225 | 1364 | } |
1226 | - else |
|
1227 | - $context['ftp_connected'] = true; |
|
1365 | + else { |
|
1366 | + $context['ftp_connected'] = true; |
|
1367 | + } |
|
1228 | 1368 | |
1229 | 1369 | // Define the template. |
1230 | 1370 | $context['page_title'] = $txt['package_file_perms']; |
@@ -1336,14 +1476,18 @@ discard block |
||
1336 | 1476 | unset($context['file_tree'][strtr(BOARDDIR, array('\\' => '/'))]['contents']['attachments']); |
1337 | 1477 | |
1338 | 1478 | if (!is_array($modSettings['attachmentUploadDir'])) |
1339 | - $modSettings['attachmentUploadDir'] = Util::unserialize($modSettings['attachmentUploadDir']); |
|
1479 | + { |
|
1480 | + $modSettings['attachmentUploadDir'] = Util::unserialize($modSettings['attachmentUploadDir']); |
|
1481 | + } |
|
1340 | 1482 | |
1341 | 1483 | // @todo Should we suggest non-current directories be read only? |
1342 | 1484 | foreach ($modSettings['attachmentUploadDir'] as $dir) |
1343 | - $context['file_tree'][strtr($dir, array('\\' => '/'))] = array( |
|
1485 | + { |
|
1486 | + $context['file_tree'][strtr($dir, array('\\' => '/'))] = array( |
|
1344 | 1487 | 'type' => 'dir', |
1345 | 1488 | 'writable_on' => 'restrictive', |
1346 | 1489 | ); |
1490 | + } |
|
1347 | 1491 | } |
1348 | 1492 | elseif (substr($modSettings['attachmentUploadDir'], 0, strlen(BOARDDIR)) != BOARDDIR) |
1349 | 1493 | { |
@@ -1388,7 +1532,9 @@ discard block |
||
1388 | 1532 | { |
1389 | 1533 | // Skip the default |
1390 | 1534 | if ($id == 1) |
1391 | - continue; |
|
1535 | + { |
|
1536 | + continue; |
|
1537 | + } |
|
1392 | 1538 | |
1393 | 1539 | if (substr(strtolower(strtr($theme['theme_dir'], array('\\' => '/'))), 0, strlen(BOARDDIR) + 7) === strtolower(strtr(BOARDDIR, array('\\' => '/')) . '/themes')) |
1394 | 1540 | { |
@@ -1420,30 +1566,40 @@ discard block |
||
1420 | 1566 | |
1421 | 1567 | // If we're submitting then let's move on to another function to keep things cleaner.. |
1422 | 1568 | if (isset($this->_req->post->action_changes)) |
1423 | - return $this->action_perms_save(); |
|
1569 | + { |
|
1570 | + return $this->action_perms_save(); |
|
1571 | + } |
|
1424 | 1572 | |
1425 | 1573 | $context['look_for'] = array(); |
1426 | 1574 | |
1427 | 1575 | // Are we looking for a particular tree - normally an expansion? |
1428 | 1576 | if (!empty($this->_req->query->find)) |
1429 | - $context['look_for'][] = base64_decode($this->_req->query->find); |
|
1577 | + { |
|
1578 | + $context['look_for'][] = base64_decode($this->_req->query->find); |
|
1579 | + } |
|
1430 | 1580 | |
1431 | 1581 | // Only that tree? |
1432 | 1582 | $context['only_find'] = isset($this->_req->query->xml) && !empty($this->_req->query->onlyfind) ? $this->_req->query->onlyfind : ''; |
1433 | 1583 | if ($context['only_find']) |
1434 | - $context['look_for'][] = $context['only_find']; |
|
1584 | + { |
|
1585 | + $context['look_for'][] = $context['only_find']; |
|
1586 | + } |
|
1435 | 1587 | |
1436 | 1588 | // Have we got a load of back-catalogue trees to expand from a submit etc? |
1437 | 1589 | if (!empty($this->_req->query->back_look)) |
1438 | 1590 | { |
1439 | 1591 | $potententialTrees = json_decode(base64_decode($this->_req->query->back_look), true); |
1440 | 1592 | foreach ($potententialTrees as $tree) |
1441 | - $context['look_for'][] = $tree; |
|
1593 | + { |
|
1594 | + $context['look_for'][] = $tree; |
|
1595 | + } |
|
1442 | 1596 | } |
1443 | 1597 | |
1444 | 1598 | // ... maybe posted? |
1445 | 1599 | if (!empty($this->_req->post->back_look)) |
1446 | - $context['only_find'] = array_merge($context['only_find'], $this->_req->post->back_look); |
|
1600 | + { |
|
1601 | + $context['only_find'] = array_merge($context['only_find'], $this->_req->post->back_look); |
|
1602 | + } |
|
1447 | 1603 | |
1448 | 1604 | $context['back_look_data'] = base64_encode(json_encode(array_slice($context['look_for'], 0, 15))); |
1449 | 1605 | |
@@ -1484,8 +1640,9 @@ discard block |
||
1484 | 1640 | 'perms' => @fileperms($path), |
1485 | 1641 | ); |
1486 | 1642 | } |
1487 | - else |
|
1488 | - unset($context['file_tree'][$path]); |
|
1643 | + else { |
|
1644 | + unset($context['file_tree'][$path]); |
|
1645 | + } |
|
1489 | 1646 | } |
1490 | 1647 | |
1491 | 1648 | // Is this actually xml? |
@@ -1512,7 +1669,9 @@ discard block |
||
1512 | 1669 | |
1513 | 1670 | // Skipping use of FTP? |
1514 | 1671 | if (empty($package_ftp)) |
1515 | - $context['skip_ftp'] = true; |
|
1672 | + { |
|
1673 | + $context['skip_ftp'] = true; |
|
1674 | + } |
|
1516 | 1675 | |
1517 | 1676 | // We'll start off in a good place, security. Make sure that if we're dealing with individual files that they seem in the right place. |
1518 | 1677 | if ($context['method'] === 'individual') |
@@ -1523,7 +1682,9 @@ discard block |
||
1523 | 1682 | |
1524 | 1683 | // Continuing? |
1525 | 1684 | if (isset($this->_req->post->toProcess)) |
1526 | - $this->_req->post->permStatus = json_decode(base64_decode($this->_req->post->toProcess), true); |
|
1685 | + { |
|
1686 | + $this->_req->post->permStatus = json_decode(base64_decode($this->_req->post->toProcess), true); |
|
1687 | + } |
|
1527 | 1688 | |
1528 | 1689 | if (isset($this->_req->post->permStatus)) |
1529 | 1690 | { |
@@ -1533,22 +1694,32 @@ discard block |
||
1533 | 1694 | { |
1534 | 1695 | // Nothing to see here? |
1535 | 1696 | if ($status === 'no_change') |
1536 | - continue; |
|
1697 | + { |
|
1698 | + continue; |
|
1699 | + } |
|
1537 | 1700 | |
1538 | 1701 | $legal = false; |
1539 | 1702 | foreach ($legal_roots as $root) |
1540 | - if (substr($path, 0, strlen($root)) == $root) |
|
1703 | + { |
|
1704 | + if (substr($path, 0, strlen($root)) == $root) |
|
1541 | 1705 | $legal = true; |
1706 | + } |
|
1542 | 1707 | |
1543 | 1708 | if (!$legal) |
1544 | - continue; |
|
1709 | + { |
|
1710 | + continue; |
|
1711 | + } |
|
1545 | 1712 | |
1546 | 1713 | // Check it exists. |
1547 | 1714 | if (!file_exists($path)) |
1548 | - continue; |
|
1715 | + { |
|
1716 | + continue; |
|
1717 | + } |
|
1549 | 1718 | |
1550 | 1719 | if ($status === 'custom') |
1551 | - $validate_custom = true; |
|
1720 | + { |
|
1721 | + $validate_custom = true; |
|
1722 | + } |
|
1552 | 1723 | |
1553 | 1724 | // Now add it. |
1554 | 1725 | $context['to_process'][$path] = $status; |
@@ -1559,16 +1730,21 @@ discard block |
||
1559 | 1730 | if ($validate_custom) |
1560 | 1731 | { |
1561 | 1732 | if (!preg_match('~^[4567][4567][4567]$~', $context['custom_value'])) |
1562 | - throw new Elk_Exception($txt['chmod_value_invalid']); |
|
1733 | + { |
|
1734 | + throw new Elk_Exception($txt['chmod_value_invalid']); |
|
1735 | + } |
|
1563 | 1736 | } |
1564 | 1737 | |
1565 | 1738 | // Nothing to do? |
1566 | 1739 | if (empty($context['to_process'])) |
1567 | - redirectexit('action=admin;area=packages;sa=perms' . (!empty($context['back_look_data']) ? ';back_look=' . base64_encode(json_encode($context['back_look_data'])) : '') . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1740 | + { |
|
1741 | + redirectexit('action=admin;area=packages;sa=perms' . (!empty($context['back_look_data']) ? ';back_look=' . base64_encode(json_encode($context['back_look_data'])) : '') . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1742 | + } |
|
1568 | 1743 | } |
1569 | 1744 | // Should never get here, |
1570 | - else |
|
1571 | - throw new Elk_Exception('no_access', false); |
|
1745 | + else { |
|
1746 | + throw new Elk_Exception('no_access', false); |
|
1747 | + } |
|
1572 | 1748 | |
1573 | 1749 | // Setup the custom value. |
1574 | 1750 | $custom_value = octdec('0' . $context['custom_value']); |
@@ -1577,7 +1753,9 @@ discard block |
||
1577 | 1753 | foreach ($context['to_process'] as $path => $status) |
1578 | 1754 | { |
1579 | 1755 | if (in_array($status, array('execute', 'writable', 'read'))) |
1580 | - package_chmod($path, $status); |
|
1756 | + { |
|
1757 | + package_chmod($path, $status); |
|
1758 | + } |
|
1581 | 1759 | elseif ($status === 'custom' && !empty($custom_value)) |
1582 | 1760 | { |
1583 | 1761 | // Use FTP if we have it. |
@@ -1586,8 +1764,9 @@ discard block |
||
1586 | 1764 | $ftp_file = strtr($path, array($_SESSION['pack_ftp']['root'] => '')); |
1587 | 1765 | $package_ftp->chmod($ftp_file, $custom_value); |
1588 | 1766 | } |
1589 | - else |
|
1590 | - @chmod($path, $custom_value); |
|
1767 | + else { |
|
1768 | + @chmod($path, $custom_value); |
|
1769 | + } |
|
1591 | 1770 | } |
1592 | 1771 | |
1593 | 1772 | // This fish is fried... |
@@ -1595,7 +1774,9 @@ discard block |
||
1595 | 1774 | |
1596 | 1775 | // See if we're out of time? |
1597 | 1776 | if (time() - array_sum(explode(' ', $time_start)) > $timeout_limit) |
1598 | - pausePermsSave(); |
|
1777 | + { |
|
1778 | + pausePermsSave(); |
|
1779 | + } |
|
1599 | 1780 | } |
1600 | 1781 | } |
1601 | 1782 | // If predefined this is a little different. |
@@ -1626,13 +1807,18 @@ discard block |
||
1626 | 1807 | $context['special_files'] = array(); |
1627 | 1808 | |
1628 | 1809 | foreach ($context['file_tree'] as $path => $data) |
1629 | - $this->build_special_files__recursive($path, $data); |
|
1810 | + { |
|
1811 | + $this->build_special_files__recursive($path, $data); |
|
1812 | + } |
|
1630 | 1813 | } |
1631 | 1814 | // Free doesn't need special files. |
1632 | 1815 | elseif ($context['predefined_type'] === 'free') |
1633 | - $context['special_files'] = array(); |
|
1634 | - else |
|
1635 | - $context['special_files'] = json_decode(base64_decode($this->_req->post->specialFiles), true); |
|
1816 | + { |
|
1817 | + $context['special_files'] = array(); |
|
1818 | + } |
|
1819 | + else { |
|
1820 | + $context['special_files'] = json_decode(base64_decode($this->_req->post->specialFiles), true); |
|
1821 | + } |
|
1636 | 1822 | |
1637 | 1823 | // Now we definitely know where we are, we need to go through again doing the chmod! |
1638 | 1824 | foreach ($context['directory_list'] as $path => $dummy) |
@@ -1688,7 +1874,9 @@ discard block |
||
1688 | 1874 | |
1689 | 1875 | // See if we're out of time? |
1690 | 1876 | if (time() - array_sum(explode(' ', $time_start)) > $timeout_limit) |
1691 | - pausePermsSave(); |
|
1877 | + { |
|
1878 | + pausePermsSave(); |
|
1879 | + } |
|
1692 | 1880 | } |
1693 | 1881 | } |
1694 | 1882 | |
@@ -1707,12 +1895,16 @@ discard block |
||
1707 | 1895 | global $context; |
1708 | 1896 | |
1709 | 1897 | if (!empty($data['writable_on'])) |
1710 | - if ($context['predefined_type'] === 'standard' || $data['writable_on'] === 'restrictive') |
|
1898 | + { |
|
1899 | + if ($context['predefined_type'] === 'standard' || $data['writable_on'] === 'restrictive') |
|
1711 | 1900 | $context['special_files'][$path] = 1; |
1901 | + } |
|
1712 | 1902 | |
1713 | 1903 | if (!empty($data['contents'])) |
1714 | - foreach ($data['contents'] as $name => $contents) |
|
1904 | + { |
|
1905 | + foreach ($data['contents'] as $name => $contents) |
|
1715 | 1906 | $this->build_special_files__recursive($path . '/' . $name, $contents); |
1907 | + } |
|
1716 | 1908 | } |
1717 | 1909 | |
1718 | 1910 | /** |
@@ -1771,23 +1963,33 @@ discard block |
||
1771 | 1963 | |
1772 | 1964 | // Start things up |
1773 | 1965 | if (!isset($packages[$params])) |
1774 | - $packages[$params] = array(); |
|
1966 | + { |
|
1967 | + $packages[$params] = array(); |
|
1968 | + } |
|
1775 | 1969 | |
1776 | 1970 | // We need the packages directory to be writable for this. |
1777 | 1971 | if (!@is_writable(BOARDDIR . '/packages')) |
1778 | - create_chmod_control(array(BOARDDIR . '/packages'), array('destination_url' => $scripturl . '?action=admin;area=packages', 'crash_on_error' => true)); |
|
1972 | + { |
|
1973 | + create_chmod_control(array(BOARDDIR . '/packages'), array('destination_url' => $scripturl . '?action=admin;area=packages', 'crash_on_error' => true)); |
|
1974 | + } |
|
1779 | 1975 | |
1780 | 1976 | list ($the_brand, $the_version) = explode(' ', FORUM_VERSION, 2); |
1781 | 1977 | |
1782 | 1978 | // Here we have a little code to help those who class themselves as something of gods, version emulation ;) |
1783 | 1979 | if (isset($this->_req->query->version_emulate) && strtr($this->_req->query->version_emulate, array($the_brand => '')) == $the_version) |
1784 | - unset($_SESSION['version_emulate']); |
|
1980 | + { |
|
1981 | + unset($_SESSION['version_emulate']); |
|
1982 | + } |
|
1785 | 1983 | elseif (isset($this->_req->query->version_emulate)) |
1786 | 1984 | { |
1787 | 1985 | if (($this->_req->query->version_emulate === 0 || $this->_req->query->version_emulate === FORUM_VERSION) && isset($this->_req->session->version_emulate)) |
1788 | - unset($_SESSION['version_emulate']); |
|
1986 | + { |
|
1987 | + unset($_SESSION['version_emulate']); |
|
1988 | + } |
|
1789 | 1989 | elseif ($this->_req->query->version_emulate !== 0) |
1790 | - $_SESSION['version_emulate'] = strtr($this->_req->query->version_emulate, array('-' => ' ', '+' => ' ', $the_brand . ' ' => '')); |
|
1990 | + { |
|
1991 | + $_SESSION['version_emulate'] = strtr($this->_req->query->version_emulate, array('-' => ' ', '+' => ' ', $the_brand . ' ' => '')); |
|
1992 | + } |
|
1791 | 1993 | } |
1792 | 1994 | |
1793 | 1995 | if (!empty($_SESSION['version_emulate'])) |
@@ -1797,7 +1999,9 @@ discard block |
||
1797 | 1999 | } |
1798 | 2000 | |
1799 | 2001 | if (isset($_SESSION['single_version_emulate'])) |
1800 | - unset($_SESSION['single_version_emulate']); |
|
2002 | + { |
|
2003 | + unset($_SESSION['single_version_emulate']); |
|
2004 | + } |
|
1801 | 2005 | |
1802 | 2006 | if (empty($instadds)) |
1803 | 2007 | { |
@@ -1806,10 +2010,12 @@ discard block |
||
1806 | 2010 | |
1807 | 2011 | // Look through the list of installed mods... |
1808 | 2012 | foreach ($instadds as $installed_add) |
1809 | - $installed_adds[$installed_add['package_id']] = array( |
|
2013 | + { |
|
2014 | + $installed_adds[$installed_add['package_id']] = array( |
|
1810 | 2015 | 'id' => $installed_add['id'], |
1811 | 2016 | 'version' => $installed_add['version'], |
1812 | 2017 | ); |
2018 | + } |
|
1813 | 2019 | |
1814 | 2020 | // Get a list of all the ids installed, so the latest packages won't include already installed ones. |
1815 | 2021 | $context['installed_adds'] = array_keys($installed_adds); |
@@ -1834,8 +2040,10 @@ discard block |
||
1834 | 2040 | } |
1835 | 2041 | |
1836 | 2042 | if (empty($packages)) |
1837 | - foreach ($context['package_types'] as $type) |
|
2043 | + { |
|
2044 | + foreach ($context['package_types'] as $type) |
|
1838 | 2045 | $packages[$type] = array(); |
2046 | + } |
|
1839 | 2047 | |
1840 | 2048 | try |
1841 | 2049 | { |
@@ -1853,32 +2061,42 @@ discard block |
||
1853 | 2061 | foreach ($filtered_dir as $package) |
1854 | 2062 | { |
1855 | 2063 | foreach ($context['package_types'] as $type) |
1856 | - if (isset($context['available_' . $type][md5($package->getFilename())])) |
|
2064 | + { |
|
2065 | + if (isset($context['available_' . $type][md5($package->getFilename())])) |
|
1857 | 2066 | continue 2; |
2067 | + } |
|
1858 | 2068 | |
1859 | 2069 | // Skip directories or files that are named the same. |
1860 | 2070 | if ($package->isDir()) |
1861 | 2071 | { |
1862 | 2072 | if (in_array($package, $dirs)) |
1863 | - continue; |
|
2073 | + { |
|
2074 | + continue; |
|
2075 | + } |
|
1864 | 2076 | $dirs[] = $package; |
1865 | 2077 | } |
1866 | 2078 | elseif (substr(strtolower($package->getFilename()), -7) === '.tar.gz') |
1867 | 2079 | { |
1868 | 2080 | if (in_array(substr($package, 0, -7), $dirs)) |
1869 | - continue; |
|
2081 | + { |
|
2082 | + continue; |
|
2083 | + } |
|
1870 | 2084 | $dirs[] = substr($package, 0, -7); |
1871 | 2085 | } |
1872 | 2086 | elseif (strtolower($package->getExtension()) === 'zip' || strtolower($package->getExtension()) === 'tgz') |
1873 | 2087 | { |
1874 | 2088 | if (in_array(substr($package->getBasename(), 0, -4), $dirs)) |
1875 | - continue; |
|
2089 | + { |
|
2090 | + continue; |
|
2091 | + } |
|
1876 | 2092 | $dirs[] = substr($package->getBasename(), 0, -4); |
1877 | 2093 | } |
1878 | 2094 | |
1879 | 2095 | $packageInfo = getPackageInfo($package->getFilename()); |
1880 | 2096 | if (!is_array($packageInfo)) |
1881 | - continue; |
|
2097 | + { |
|
2098 | + continue; |
|
2099 | + } |
|
1882 | 2100 | |
1883 | 2101 | if (!empty($packageInfo)) |
1884 | 2102 | { |
@@ -1931,9 +2149,11 @@ discard block |
||
1931 | 2149 | { |
1932 | 2150 | // Even if it is for this ElkArte, is it for the installed version of the mod? |
1933 | 2151 | if (!$upgrade->exists('@for') || matchPackageVersion($the_version, $upgrade->fetch('@for'))) |
1934 | - if (!$upgrade->exists('@from') || matchPackageVersion($installed_adds[$packageInfo['id']]['version'], $upgrade->fetch('@from'))) |
|
2152 | + { |
|
2153 | + if (!$upgrade->exists('@from') || matchPackageVersion($installed_adds[$packageInfo['id']]['version'], $upgrade->fetch('@from'))) |
|
1935 | 2154 | { |
1936 | 2155 | $packageInfo['can_upgrade'] = true; |
2156 | + } |
|
1937 | 2157 | break; |
1938 | 2158 | } |
1939 | 2159 | } |
@@ -2022,9 +2242,12 @@ discard block |
||
2022 | 2242 | } |
2023 | 2243 | |
2024 | 2244 | if (isset($this->_req->query->desc)) |
2025 | - krsort($packages[$params]); |
|
2026 | - else |
|
2027 | - ksort($packages[$params]); |
|
2245 | + { |
|
2246 | + krsort($packages[$params]); |
|
2247 | + } |
|
2248 | + else { |
|
2249 | + ksort($packages[$params]); |
|
2250 | + } |
|
2028 | 2251 | |
2029 | 2252 | return $packages[$params]; |
2030 | 2253 | } |
@@ -2049,21 +2272,29 @@ discard block |
||
2049 | 2272 | foreach ($context['look_for'] as $possiblePath) |
2050 | 2273 | { |
2051 | 2274 | if (substr($possiblePath, 0, strlen($path)) == $path) |
2052 | - $isLikelyPath = true; |
|
2275 | + { |
|
2276 | + $isLikelyPath = true; |
|
2277 | + } |
|
2053 | 2278 | } |
2054 | 2279 | |
2055 | 2280 | // Is this where we stop? |
2056 | 2281 | if (isset($_GET['xml']) && !empty($context['look_for']) && !$isLikelyPath) |
2057 | - return; |
|
2282 | + { |
|
2283 | + return; |
|
2284 | + } |
|
2058 | 2285 | elseif ($level > $context['default_level'] && !$isLikelyPath) |
2059 | - return; |
|
2286 | + { |
|
2287 | + return; |
|
2288 | + } |
|
2060 | 2289 | |
2061 | 2290 | // Are we actually interested in saving this data? |
2062 | 2291 | $save_data = empty($context['only_find']) || $context['only_find'] == $path; |
2063 | 2292 | |
2064 | 2293 | // @todo Shouldn't happen - but better error message? |
2065 | 2294 | if (!is_dir($path)) |
2066 | - throw new Elk_Exception('no_access', false); |
|
2295 | + { |
|
2296 | + throw new Elk_Exception('no_access', false); |
|
2297 | + } |
|
2067 | 2298 | |
2068 | 2299 | // This is where we put stuff we've found for sorting. |
2069 | 2300 | $foundData = array( |
@@ -2081,10 +2312,14 @@ discard block |
||
2081 | 2312 | { |
2082 | 2313 | // Are we listing PHP files in this directory? |
2083 | 2314 | if ($save_data && !empty($data['list_contents']) && $entry->getExtension() === 'php') |
2084 | - $foundData['files'][$entry->getFilename()] = true; |
|
2315 | + { |
|
2316 | + $foundData['files'][$entry->getFilename()] = true; |
|
2317 | + } |
|
2085 | 2318 | // A file we were looking for. |
2086 | 2319 | elseif ($save_data && isset($data['contents'][$entry->getFilename()])) |
2087 | - $foundData['files'][$entry->getFilename()] = true; |
|
2320 | + { |
|
2321 | + $foundData['files'][$entry->getFilename()] = true; |
|
2322 | + } |
|
2088 | 2323 | } |
2089 | 2324 | // It's a directory - we're interested one way or another, probably... |
2090 | 2325 | elseif ($entry->isDir()) |
@@ -2097,23 +2332,30 @@ discard block |
||
2097 | 2332 | && $data['contents'][$entry->getFilename()]['type'] === 'dir_recursive')))) |
2098 | 2333 | { |
2099 | 2334 | if (!isset($data['contents'][$entry->getFilename()])) |
2100 | - $foundData['folders'][$entry->getFilename()] = 'dir_recursive'; |
|
2101 | - else |
|
2102 | - $foundData['folders'][$entry->getFilename()] = true; |
|
2335 | + { |
|
2336 | + $foundData['folders'][$entry->getFilename()] = 'dir_recursive'; |
|
2337 | + } |
|
2338 | + else { |
|
2339 | + $foundData['folders'][$entry->getFilename()] = true; |
|
2340 | + } |
|
2103 | 2341 | |
2104 | 2342 | // If this wasn't expected inherit the recusiveness... |
2105 | 2343 | if (!isset($data['contents'][$entry->getFilename()])) |
2106 | - // We need to do this as we will be going all recursive. |
|
2344 | + { |
|
2345 | + // We need to do this as we will be going all recursive. |
|
2107 | 2346 | $data['contents'][$entry->getFilename()] = array( |
2108 | 2347 | 'type' => 'dir_recursive', |
2109 | 2348 | ); |
2349 | + } |
|
2110 | 2350 | |
2111 | 2351 | // Actually do the recursive stuff... |
2112 | 2352 | fetchPerms__recursive($entry->getPathname(), $data['contents'][$entry->getFilename()], $level + 1); |
2113 | 2353 | } |
2114 | 2354 | // Maybe it is a folder we are not descending into. |
2115 | 2355 | elseif (isset($data['contents'][$entry->getFilename()])) |
2116 | - $foundData['folders'][$entry->getFilename()] = true; |
|
2356 | + { |
|
2357 | + $foundData['folders'][$entry->getFilename()] = true; |
|
2358 | + } |
|
2117 | 2359 | // Otherwise we stop here. |
2118 | 2360 | } |
2119 | 2361 | } |
@@ -2125,7 +2367,9 @@ discard block |
||
2125 | 2367 | |
2126 | 2368 | // Nothing to see here? |
2127 | 2369 | if (!$save_data) |
2128 | - return; |
|
2370 | + { |
|
2371 | + return; |
|
2372 | + } |
|
2129 | 2373 | |
2130 | 2374 | // Now actually add the data, starting with the folders. |
2131 | 2375 | uksort($foundData['folders'], 'strcasecmp'); |
@@ -2138,7 +2382,9 @@ discard block |
||
2138 | 2382 | ), |
2139 | 2383 | ); |
2140 | 2384 | if ($type !== true) |
2141 | - $additional_data['type'] = $type; |
|
2385 | + { |
|
2386 | + $additional_data['type'] = $type; |
|
2387 | + } |
|
2142 | 2388 | |
2143 | 2389 | // If there's an offset ignore any folders in XML mode. |
2144 | 2390 | if (isset($_GET['xml']) && $context['file_offset'] == 0) |
@@ -2161,9 +2407,12 @@ discard block |
||
2161 | 2407 | elseif (!isset($_GET['xml'])) |
2162 | 2408 | { |
2163 | 2409 | if (isset($data['contents'][$folder])) |
2164 | - $data['contents'][$folder] = array_merge($data['contents'][$folder], $additional_data); |
|
2165 | - else |
|
2166 | - $data['contents'][$folder] = $additional_data; |
|
2410 | + { |
|
2411 | + $data['contents'][$folder] = array_merge($data['contents'][$folder], $additional_data); |
|
2412 | + } |
|
2413 | + else { |
|
2414 | + $data['contents'][$folder] = $additional_data; |
|
2415 | + } |
|
2167 | 2416 | } |
2168 | 2417 | } |
2169 | 2418 | |
@@ -2176,11 +2425,15 @@ discard block |
||
2176 | 2425 | |
2177 | 2426 | // Have we reached our offset? |
2178 | 2427 | if ($context['file_offset'] > $counter) |
2179 | - continue; |
|
2428 | + { |
|
2429 | + continue; |
|
2430 | + } |
|
2180 | 2431 | |
2181 | 2432 | // Gone too far? |
2182 | 2433 | if ($counter > ($context['file_offset'] + $context['file_limit'])) |
2183 | - continue; |
|
2434 | + { |
|
2435 | + continue; |
|
2436 | + } |
|
2184 | 2437 | |
2185 | 2438 | $additional_data = array( |
2186 | 2439 | 'perms' => array( |
@@ -2210,9 +2463,12 @@ discard block |
||
2210 | 2463 | elseif ($counter != ($context['file_offset'] + $context['file_limit'])) |
2211 | 2464 | { |
2212 | 2465 | if (isset($data['contents'][$file])) |
2213 | - $data['contents'][$file] = array_merge($data['contents'][$file], $additional_data); |
|
2214 | - else |
|
2215 | - $data['contents'][$file] = $additional_data; |
|
2466 | + { |
|
2467 | + $data['contents'][$file] = array_merge($data['contents'][$file], $additional_data); |
|
2468 | + } |
|
2469 | + else { |
|
2470 | + $data['contents'][$file] = $additional_data; |
|
2471 | + } |
|
2216 | 2472 | } |
2217 | 2473 | } |
2218 | 2474 | } |
@@ -935,7 +935,7 @@ discard block |
||
935 | 935 | 'style' => 'width: 25%;', |
936 | 936 | ), |
937 | 937 | 'data' => array( |
938 | - 'function' => function ($package_md5) use ($type) { |
|
938 | + 'function' => function($package_md5) use ($type) { |
|
939 | 939 | global $context; |
940 | 940 | |
941 | 941 | if (isset($context['available_' . $type . ''][$package_md5])) |
@@ -955,7 +955,7 @@ discard block |
||
955 | 955 | 'style' => 'width: 25%;', |
956 | 956 | ), |
957 | 957 | 'data' => array( |
958 | - 'function' => function ($package_md5) use ($type) { |
|
958 | + 'function' => function($package_md5) use ($type) { |
|
959 | 959 | global $context; |
960 | 960 | |
961 | 961 | if (isset($context['available_' . $type . ''][$package_md5])) |
@@ -974,7 +974,7 @@ discard block |
||
974 | 974 | 'value' => '', |
975 | 975 | ), |
976 | 976 | 'data' => array( |
977 | - 'function' => function ($package_md5) use ($type) { |
|
977 | + 'function' => function($package_md5) use ($type) { |
|
978 | 978 | global $context, $scripturl, $txt; |
979 | 979 | |
980 | 980 | if (!isset($context['available_' . $type . ''][$package_md5])) |
@@ -255,11 +255,17 @@ discard block |
||
255 | 255 | $type = 'package_' . $this->_action['type']; |
256 | 256 | |
257 | 257 | if (file_exists(BOARDDIR . '/packages/temp/' . $this->_base_path . $this->_action['filename'])) |
258 | - $context[$type] = htmlspecialchars(trim(file_get_contents(BOARDDIR . '/packages/temp/' . $this->_base_path . $this->_action['filename']), "\n\r"), ENT_COMPAT, 'UTF-8'); |
|
258 | + { |
|
259 | + $context[$type] = htmlspecialchars(trim(file_get_contents(BOARDDIR . '/packages/temp/' . $this->_base_path . $this->_action['filename']), "\n\r"), ENT_COMPAT, 'UTF-8'); |
|
260 | + } |
|
259 | 261 | elseif (file_exists($this->_action['filename'])) |
260 | - $context[$type] = htmlspecialchars(trim(file_get_contents($this->_action['filename']), "\n\r"), ENT_COMPAT, 'UTF-8'); |
|
262 | + { |
|
263 | + $context[$type] = htmlspecialchars(trim(file_get_contents($this->_action['filename']), "\n\r"), ENT_COMPAT, 'UTF-8'); |
|
264 | + } |
|
261 | 265 | elseif (file_exists(BOARDDIR . '/packages/temp/' . $this->_action['filename'])) |
262 | - $context[$type] = htmlspecialchars(trim(file_get_contents(BOARDDIR . '/packages/temp/' . $this->_action['filename']), "\n\r"), ENT_COMPAT, 'UTF-8'); |
|
266 | + { |
|
267 | + $context[$type] = htmlspecialchars(trim(file_get_contents(BOARDDIR . '/packages/temp/' . $this->_action['filename']), "\n\r"), ENT_COMPAT, 'UTF-8'); |
|
268 | + } |
|
263 | 269 | |
264 | 270 | // Fancy or plain |
265 | 271 | if (!empty($this->_action['parse_bbc'])) |
@@ -271,8 +277,9 @@ discard block |
||
271 | 277 | |
272 | 278 | $context[$type] = $bbc_parser->parsePackage($context[$type]); |
273 | 279 | } |
274 | - else |
|
275 | - $context[$type] = nl2br($context[$type]); |
|
280 | + else { |
|
281 | + $context[$type] = nl2br($context[$type]); |
|
282 | + } |
|
276 | 283 | } |
277 | 284 | |
278 | 285 | /** |
@@ -301,9 +308,13 @@ discard block |
||
301 | 308 | $this->has_failure = true; |
302 | 309 | |
303 | 310 | if (isset($this->_action['error_msg']) && isset($this->_action['error_var'])) |
304 | - $this->failure_details = sprintf($txt['package_will_fail_' . $this->_action['error_msg']], $this->_action['error_var']); |
|
311 | + { |
|
312 | + $this->failure_details = sprintf($txt['package_will_fail_' . $this->_action['error_msg']], $this->_action['error_var']); |
|
313 | + } |
|
305 | 314 | elseif (isset($this->_action['error_msg'])) |
306 | - $this->failure_details = isset($txt['package_will_fail_' . $this->_action['error_msg']]) ? $txt['package_will_fail_' . $this->_action['error_msg']] : $this->_action['error_msg']; |
|
315 | + { |
|
316 | + $this->failure_details = isset($txt['package_will_fail_' . $this->_action['error_msg']]) ? $txt['package_will_fail_' . $this->_action['error_msg']] : $this->_action['error_msg']; |
|
317 | + } |
|
307 | 318 | } |
308 | 319 | |
309 | 320 | /** |
@@ -332,7 +343,9 @@ discard block |
||
332 | 343 | $mod_actions = parseModification(@file_get_contents(BOARDDIR . '/packages/temp/' . $this->_base_path . $this->_action['filename']), true, $this->_action['reverse'], $this->_theme_paths); |
333 | 344 | |
334 | 345 | if (count($mod_actions) === 1 && isset($mod_actions[0]) && $mod_actions[0]['type'] === 'error' && $mod_actions[0]['filename'] === '-') |
335 | - $mod_actions[0]['filename'] = $this->_action['filename']; |
|
346 | + { |
|
347 | + $mod_actions[0]['filename'] = $this->_action['filename']; |
|
348 | + } |
|
336 | 349 | |
337 | 350 | foreach ($mod_actions as $key => $mod_action) |
338 | 351 | { |
@@ -360,11 +373,15 @@ discard block |
||
360 | 373 | ); |
361 | 374 | |
362 | 375 | if (empty($mod_action['is_custom'])) |
363 | - $this->ourActions[$this->_actual_filename]['operations'][] = $summary; |
|
376 | + { |
|
377 | + $this->ourActions[$this->_actual_filename]['operations'][] = $summary; |
|
378 | + } |
|
364 | 379 | |
365 | 380 | // Themes are under the saved type. |
366 | 381 | if (isset($mod_action['is_custom']) && isset($context['theme_actions'][$mod_action['is_custom']])) |
367 | - $context['theme_actions'][$mod_action['is_custom']]['actions'][$this->_actual_filename]['operations'][] = $summary; |
|
382 | + { |
|
383 | + $context['theme_actions'][$mod_action['is_custom']]['actions'][$this->_actual_filename]['operations'][] = $summary; |
|
384 | + } |
|
368 | 385 | } |
369 | 386 | } |
370 | 387 | } |
@@ -380,11 +397,16 @@ discard block |
||
380 | 397 | { |
381 | 398 | // Lets get the last section of the file name. |
382 | 399 | if (isset($mod_action['filename']) && substr($mod_action['filename'], -13) !== '.template.php') |
383 | - $this->_actual_filename = strtolower(substr(strrchr($mod_action['filename'], '/'), 1) . '||' . $this->_action['filename']); |
|
400 | + { |
|
401 | + $this->_actual_filename = strtolower(substr(strrchr($mod_action['filename'], '/'), 1) . '||' . $this->_action['filename']); |
|
402 | + } |
|
384 | 403 | elseif (isset($mod_action['filename']) && preg_match('~([\w]*)/([\w]*)\.template\.php$~', $mod_action['filename'], $matches)) |
385 | - $this->_actual_filename = strtolower($matches[1] . '/' . $matches[2] . '.template.php||' . $this->_action['filename']); |
|
386 | - else |
|
387 | - $this->_actual_filename = $key; |
|
404 | + { |
|
405 | + $this->_actual_filename = strtolower($matches[1] . '/' . $matches[2] . '.template.php||' . $this->_action['filename']); |
|
406 | + } |
|
407 | + else { |
|
408 | + $this->_actual_filename = $key; |
|
409 | + } |
|
388 | 410 | } |
389 | 411 | |
390 | 412 | /** |
@@ -403,7 +425,9 @@ discard block |
||
403 | 425 | break; |
404 | 426 | case 'failure': |
405 | 427 | if (empty($mod_action['is_custom'])) |
406 | - $this->has_failure = true; |
|
428 | + { |
|
429 | + $this->has_failure = true; |
|
430 | + } |
|
407 | 431 | |
408 | 432 | $this->_failure = true; |
409 | 433 | break; |
@@ -414,13 +438,16 @@ discard block |
||
414 | 438 | if (!empty($mod_action['is_custom'])) |
415 | 439 | { |
416 | 440 | if (!isset($context['theme_actions'][$mod_action['is_custom']])) |
417 | - $context['theme_actions'][$mod_action['is_custom']] = array( |
|
441 | + { |
|
442 | + $context['theme_actions'][$mod_action['is_custom']] = array( |
|
418 | 443 | 'name' => $this->_theme_paths[$mod_action['is_custom']]['name'], |
419 | 444 | 'actions' => array(), |
420 | 445 | 'has_failure' => $this->_failure, |
421 | 446 | ); |
422 | - else |
|
423 | - $context['theme_actions'][$mod_action['is_custom']]['has_failure'] |= $this->_failure; |
|
447 | + } |
|
448 | + else { |
|
449 | + $context['theme_actions'][$mod_action['is_custom']]['has_failure'] |= $this->_failure; |
|
450 | + } |
|
424 | 451 | |
425 | 452 | $context['theme_actions'][$mod_action['is_custom']]['actions'][$this->_actual_filename] = array( |
426 | 453 | 'type' => $txt['execute_modification'], |
@@ -530,7 +557,9 @@ discard block |
||
530 | 557 | $this->_action['description'] = !isset($this->_action['hook'], $this->_action['function']) ? $txt['package_action_failure'] : $txt['package_action_success']; |
531 | 558 | |
532 | 559 | if (!isset($this->_action['hook'], $this->_action['function'])) |
533 | - $this->has_failure = true; |
|
560 | + { |
|
561 | + $this->has_failure = true; |
|
562 | + } |
|
534 | 563 | |
535 | 564 | $this->thisAction = array( |
536 | 565 | 'type' => $this->_action['reverse'] ? $txt['execute_hook_remove'] : $txt['execute_hook_add'], |
@@ -563,7 +592,9 @@ discard block |
||
563 | 592 | |
564 | 593 | // Package missing required values? |
565 | 594 | if (!isset($this->_action['id'])) |
566 | - $this->has_failure = true; |
|
595 | + { |
|
596 | + $this->has_failure = true; |
|
597 | + } |
|
567 | 598 | else |
568 | 599 | { |
569 | 600 | // See if this dependency is installed |
@@ -599,7 +630,9 @@ discard block |
||
599 | 630 | |
600 | 631 | // Could this be theme related? |
601 | 632 | if (!empty($this->_action['unparsed_destination'])) |
602 | - $this->_check_theme_actions($this->_action['unparsed_destination']); |
|
633 | + { |
|
634 | + $this->_check_theme_actions($this->_action['unparsed_destination']); |
|
635 | + } |
|
603 | 636 | } |
604 | 637 | |
605 | 638 | /** |
@@ -633,7 +666,9 @@ discard block |
||
633 | 666 | |
634 | 667 | // Could this be theme related? |
635 | 668 | if (!empty($this->_action['unparsed_filename'])) |
636 | - $this->_check_theme_actions($this->_action['unparsed_filename'], true); |
|
669 | + { |
|
670 | + $this->_check_theme_actions($this->_action['unparsed_filename'], true); |
|
671 | + } |
|
637 | 672 | } |
638 | 673 | |
639 | 674 | /** |
@@ -651,21 +686,31 @@ discard block |
||
651 | 686 | |
652 | 687 | // Need to set it? |
653 | 688 | if ($set_destination) |
654 | - $this->_action['unparsed_destination'] = $this->_action['unparsed_filename']; |
|
689 | + { |
|
690 | + $this->_action['unparsed_destination'] = $this->_action['unparsed_filename']; |
|
691 | + } |
|
655 | 692 | |
656 | 693 | // If it's not auto do we think we have something we can act upon? |
657 | 694 | if ($theme_action !== 'auto' && !in_array($matches[1], array('languagedir', 'languages_dir', 'imagesdir', 'themedir'))) |
658 | - $theme_action = ''; |
|
695 | + { |
|
696 | + $theme_action = ''; |
|
697 | + } |
|
659 | 698 | // ... or if it's auto do we even want to do anything? |
660 | 699 | elseif ($theme_action === 'auto' && $matches[1] !== 'imagesdir') |
661 | - $theme_action = ''; |
|
700 | + { |
|
701 | + $theme_action = ''; |
|
702 | + } |
|
662 | 703 | |
663 | 704 | // So, we still want to do something? |
664 | 705 | if ($theme_action != '') |
665 | - $this->themeFinds['candidates'][] = $this->_action; |
|
706 | + { |
|
707 | + $this->themeFinds['candidates'][] = $this->_action; |
|
708 | + } |
|
666 | 709 | // Otherwise is this is going into another theme record it. |
667 | 710 | elseif ($matches[1] === 'themes_dir') |
668 | - $this->themeFinds['other_themes'][] = strtolower(strtr(parse_path($destination), array('\\' => '/')) . '/' . basename($this->_action['filename'])); |
|
711 | + { |
|
712 | + $this->themeFinds['other_themes'][] = strtolower(strtr(parse_path($destination), array('\\' => '/')) . '/' . basename($this->_action['filename'])); |
|
713 | + } |
|
669 | 714 | } |
670 | 715 | } |
671 | 716 | |
@@ -678,14 +723,19 @@ discard block |
||
678 | 723 | |
679 | 724 | // Now prepare things for the template. |
680 | 725 | if (empty($this->thisAction)) |
681 | - return; |
|
726 | + { |
|
727 | + return; |
|
728 | + } |
|
682 | 729 | |
683 | 730 | if (isset($this->_action['filename'])) |
684 | 731 | { |
685 | 732 | if ($this->_uninstalling) |
686 | - $file = in_array($this->_action['type'], array('remove-dir', 'remove-file')) ? $this->_action['filename'] : BOARDDIR . '/packages/temp/' . $this->_base_path . $this->_action['filename']; |
|
687 | - else |
|
688 | - $file = BOARDDIR . '/packages/temp/' . $this->_base_path . $this->_action['filename']; |
|
733 | + { |
|
734 | + $file = in_array($this->_action['type'], array('remove-dir', 'remove-file')) ? $this->_action['filename'] : BOARDDIR . '/packages/temp/' . $this->_base_path . $this->_action['filename']; |
|
735 | + } |
|
736 | + else { |
|
737 | + $file = BOARDDIR . '/packages/temp/' . $this->_base_path . $this->_action['filename']; |
|
738 | + } |
|
689 | 739 | |
690 | 740 | if (!file_exists($file)) |
691 | 741 | { |
@@ -700,7 +750,9 @@ discard block |
||
700 | 750 | |
701 | 751 | // @todo None given? |
702 | 752 | if (empty($this->thisAction['description'])) |
703 | - $this->thisAction['description'] = isset($this->_action['description']) ? $this->_action['description'] : ''; |
|
753 | + { |
|
754 | + $this->thisAction['description'] = isset($this->_action['description']) ? $this->_action['description'] : ''; |
|
755 | + } |
|
704 | 756 | |
705 | 757 | $this->ourActions[] = $this->thisAction; |
706 | 758 | } |
@@ -763,16 +815,20 @@ discard block |
||
763 | 815 | foreach ($mod_actions as $key => $action) |
764 | 816 | { |
765 | 817 | if ($this->_action['type'] === 'failure') |
766 | - $this->failed_steps[] = array( |
|
818 | + { |
|
819 | + $this->failed_steps[] = array( |
|
767 | 820 | 'file' => $action['filename'], |
768 | 821 | 'large_step' => $this->_failed_count, |
769 | 822 | 'sub_step' => $key, |
770 | 823 | 'theme' => 1, |
771 | 824 | ); |
825 | + } |
|
772 | 826 | |
773 | 827 | // Gather the themes we installed into. |
774 | 828 | if (!empty($this->_action['is_custom'])) |
775 | - $this->themes_installed[] = $this->_action['is_custom']; |
|
829 | + { |
|
830 | + $this->themes_installed[] = $this->_action['is_custom']; |
|
831 | + } |
|
776 | 832 | } |
777 | 833 | } |
778 | 834 | } |
@@ -789,7 +845,9 @@ discard block |
||
789 | 845 | |
790 | 846 | // Now include the file and be done with it ;). |
791 | 847 | if (file_exists(BOARDDIR . '/packages/temp/' . $this->_base_path . $this->_action['filename'])) |
792 | - require(BOARDDIR . '/packages/temp/' . $this->_base_path . $this->_action['filename']); |
|
848 | + { |
|
849 | + require(BOARDDIR . '/packages/temp/' . $this->_base_path . $this->_action['filename']); |
|
850 | + } |
|
793 | 851 | } |
794 | 852 | } |
795 | 853 | |
@@ -818,9 +876,12 @@ discard block |
||
818 | 876 | if (isset($this->_action['hook'], $this->_action['function'])) |
819 | 877 | { |
820 | 878 | if ($this->_action['reverse']) |
821 | - remove_integration_function($this->_action['hook'], $this->_action['function'], $this->_action['include_file']); |
|
822 | - else |
|
823 | - add_integration_function($this->_action['hook'], $this->_action['function'], $this->_action['include_file']); |
|
879 | + { |
|
880 | + remove_integration_function($this->_action['hook'], $this->_action['function'], $this->_action['include_file']); |
|
881 | + } |
|
882 | + else { |
|
883 | + add_integration_function($this->_action['hook'], $this->_action['function'], $this->_action['include_file']); |
|
884 | + } |
|
824 | 885 | } |
825 | 886 | } |
826 | 887 | |
@@ -837,7 +898,9 @@ discard block |
||
837 | 898 | |
838 | 899 | // Let the file work its magic ;) |
839 | 900 | if (file_exists(BOARDDIR . '/packages/temp/' . $this->_base_path . $this->_action['filename'])) |
840 | - require(BOARDDIR . '/packages/temp/' . $this->_base_path . $this->_action['filename']); |
|
901 | + { |
|
902 | + require(BOARDDIR . '/packages/temp/' . $this->_base_path . $this->_action['filename']); |
|
903 | + } |
|
841 | 904 | } |
842 | 905 | } |
843 | 906 |
@@ -188,13 +188,17 @@ discard block |
||
188 | 188 | |
189 | 189 | // Default/Manual implies no subdirectories |
190 | 190 | if (empty($this->_req->post->automanage_attachments)) |
191 | - $this->_req->post->use_subdirectories_for_attachments = 0; |
|
191 | + { |
|
192 | + $this->_req->post->use_subdirectories_for_attachments = 0; |
|
193 | + } |
|
192 | 194 | |
193 | 195 | // Changing the attachment upload directory |
194 | 196 | if (isset($this->_req->post->attachmentUploadDir)) |
195 | 197 | { |
196 | 198 | if (!empty($this->_req->post->attachmentUploadDir) && file_exists($modSettings['attachmentUploadDir']) && $modSettings['attachmentUploadDir'] != $this->_req->post->attachmentUploadDir) |
197 | - rename($modSettings['attachmentUploadDir'], $this->_req->post->attachmentUploadDir); |
|
199 | + { |
|
200 | + rename($modSettings['attachmentUploadDir'], $this->_req->post->attachmentUploadDir); |
|
201 | + } |
|
198 | 202 | |
199 | 203 | $modSettings['attachmentUploadDir'] = array(1 => $this->_req->post->attachmentUploadDir); |
200 | 204 | $this->_req->post->attachmentUploadDir = serialize($modSettings['attachmentUploadDir']); |
@@ -205,16 +209,21 @@ discard block |
||
205 | 209 | { |
206 | 210 | // Make sure we have a base directory defined |
207 | 211 | if (empty($this->_req->post->basedirectory_for_attachments)) |
208 | - $this->_req->post->basedirectory_for_attachments = !empty($modSettings['basedirectory_for_attachments']) ? ($modSettings['basedirectory_for_attachments']) : BOARDDIR; |
|
212 | + { |
|
213 | + $this->_req->post->basedirectory_for_attachments = !empty($modSettings['basedirectory_for_attachments']) ? ($modSettings['basedirectory_for_attachments']) : BOARDDIR; |
|
214 | + } |
|
209 | 215 | |
210 | 216 | // The current base directories that we know |
211 | 217 | if (!empty($modSettings['attachment_basedirectories'])) |
212 | 218 | { |
213 | 219 | if (!is_array($modSettings['attachment_basedirectories'])) |
214 | - $modSettings['attachment_basedirectories'] = Util::unserialize($modSettings['attachment_basedirectories']); |
|
220 | + { |
|
221 | + $modSettings['attachment_basedirectories'] = Util::unserialize($modSettings['attachment_basedirectories']); |
|
222 | + } |
|
223 | + } |
|
224 | + else { |
|
225 | + $modSettings['attachment_basedirectories'] = array(); |
|
215 | 226 | } |
216 | - else |
|
217 | - $modSettings['attachment_basedirectories'] = array(); |
|
218 | 227 | |
219 | 228 | // Trying to use a non existent base directory |
220 | 229 | if (!empty($this->_req->post->basedirectory_for_attachments) && !in_array($this->_req->post->basedirectory_for_attachments, $modSettings['attachment_basedirectories'])) |
@@ -225,7 +234,9 @@ discard block |
||
225 | 234 | if (!in_array($this->_req->post->basedirectory_for_attachments, $modSettings['attachmentUploadDir'])) |
226 | 235 | { |
227 | 236 | if (!automanage_attachments_create_directory($this->_req->post->basedirectory_for_attachments)) |
228 | - $this->_req->post->basedirectory_for_attachments = $modSettings['basedirectory_for_attachments']; |
|
237 | + { |
|
238 | + $this->_req->post->basedirectory_for_attachments = $modSettings['basedirectory_for_attachments']; |
|
239 | + } |
|
229 | 240 | } |
230 | 241 | |
231 | 242 | // The base directory should be in our list of available bases |
@@ -279,18 +290,25 @@ discard block |
||
279 | 290 | |
280 | 291 | // First time here? |
281 | 292 | if (empty($modSettings['attachment_basedirectories']) && $modSettings['currentAttachmentUploadDir'] == 1 && (is_array($modSettings['attachmentUploadDir']) && count($modSettings['attachmentUploadDir']) == 1)) |
282 | - $modSettings['attachmentUploadDir'] = $modSettings['attachmentUploadDir'][1]; |
|
293 | + { |
|
294 | + $modSettings['attachmentUploadDir'] = $modSettings['attachmentUploadDir'][1]; |
|
295 | + } |
|
283 | 296 | |
284 | 297 | // If not set, show a default path for the base directory |
285 | 298 | if (!isset($this->_req->query->save) && empty($modSettings['basedirectory_for_attachments'])) |
286 | - $modSettings['basedirectory_for_attachments'] = $context['attachmentUploadDir']; |
|
299 | + { |
|
300 | + $modSettings['basedirectory_for_attachments'] = $context['attachmentUploadDir']; |
|
301 | + } |
|
287 | 302 | |
288 | 303 | $context['valid_upload_dir'] = is_dir($context['attachmentUploadDir']) && is_writable($context['attachmentUploadDir']); |
289 | 304 | |
290 | 305 | if (!empty($modSettings['automanage_attachments'])) |
291 | - $context['valid_basedirectory'] = !empty($modSettings['basedirectory_for_attachments']) && is_writable($modSettings['basedirectory_for_attachments']); |
|
292 | - else |
|
293 | - $context['valid_basedirectory'] = true; |
|
306 | + { |
|
307 | + $context['valid_basedirectory'] = !empty($modSettings['basedirectory_for_attachments']) && is_writable($modSettings['basedirectory_for_attachments']); |
|
308 | + } |
|
309 | + else { |
|
310 | + $context['valid_basedirectory'] = true; |
|
311 | + } |
|
294 | 312 | |
295 | 313 | // A bit of razzle dazzle with the $txt strings. :) |
296 | 314 | $txt['basedirectory_for_attachments_warning'] = str_replace('{attach_repair_url}', $scripturl . '?action=admin;area=manageattachments;sa=attachpaths', $txt['basedirectory_for_attachments_warning']); |
@@ -437,27 +455,36 @@ discard block |
||
437 | 455 | |
438 | 456 | // In case of a custom avatar URL attachments have a fixed directory. |
439 | 457 | if ($rowData['attachment_type'] == 1) |
440 | - $link .= sprintf('%1$s/%2$s', $modSettings['custom_avatar_url'], $rowData['filename']); |
|
458 | + { |
|
459 | + $link .= sprintf('%1$s/%2$s', $modSettings['custom_avatar_url'], $rowData['filename']); |
|
460 | + } |
|
441 | 461 | |
442 | 462 | // By default avatars are downloaded almost as attachments. |
443 | 463 | elseif ($context['browse_type'] == 'avatars') |
444 | - $link .= sprintf('%1$s?action=dlattach;type=avatar;attach=%2$d', $scripturl, $rowData['id_attach']); |
|
464 | + { |
|
465 | + $link .= sprintf('%1$s?action=dlattach;type=avatar;attach=%2$d', $scripturl, $rowData['id_attach']); |
|
466 | + } |
|
445 | 467 | |
446 | 468 | // Normal attachments are always linked to a topic ID. |
447 | - else |
|
448 | - $link .= sprintf('%1$s?action=dlattach;topic=%2$d.0;attach=%3$d', $scripturl, $rowData['id_topic'], $rowData['id_attach']); |
|
469 | + else { |
|
470 | + $link .= sprintf('%1$s?action=dlattach;topic=%2$d.0;attach=%3$d', $scripturl, $rowData['id_topic'], $rowData['id_attach']); |
|
471 | + } |
|
449 | 472 | |
450 | 473 | $link .= '"'; |
451 | 474 | |
452 | 475 | // Show a popup on click if it's a picture and we know its dimensions. |
453 | 476 | if (!empty($rowData['width']) && !empty($rowData['height'])) |
454 | - $link .= sprintf(' onclick="return reqWin(this.href' . ($rowData['attachment_type'] == 1 ? '' : ' + \';image\'') . ', %1$d, %2$d, true);"', $rowData['width'] + 20, $rowData['height'] + 20); |
|
477 | + { |
|
478 | + $link .= sprintf(' onclick="return reqWin(this.href' . ($rowData['attachment_type'] == 1 ? '' : ' + \';image\'') . ', %1$d, %2$d, true);"', $rowData['width'] + 20, $rowData['height'] + 20); |
|
479 | + } |
|
455 | 480 | |
456 | 481 | $link .= sprintf('>%1$s</a>', preg_replace('~&#(\\\\d{1,7}|x[0-9a-fA-F]{1,6});~', '&#\\\\1;', htmlspecialchars($rowData['filename'], ENT_COMPAT, 'UTF-8'))); |
457 | 482 | |
458 | 483 | // Show the dimensions. |
459 | 484 | if (!empty($rowData['width']) && !empty($rowData['height'])) |
460 | - $link .= sprintf(' <span class="smalltext">%1$dx%2$d</span>', $rowData['width'], $rowData['height']); |
|
485 | + { |
|
486 | + $link .= sprintf(' <span class="smalltext">%1$dx%2$d</span>', $rowData['width'], $rowData['height']); |
|
487 | + } |
|
461 | 488 | |
462 | 489 | return $link; |
463 | 490 | }, |
@@ -493,11 +520,14 @@ discard block |
||
493 | 520 | |
494 | 521 | // In case of an attachment, return the poster of the attachment. |
495 | 522 | if (empty($rowData['id_member'])) |
496 | - return htmlspecialchars($rowData['poster_name'], ENT_COMPAT, 'UTF-8'); |
|
523 | + { |
|
524 | + return htmlspecialchars($rowData['poster_name'], ENT_COMPAT, 'UTF-8'); |
|
525 | + } |
|
497 | 526 | |
498 | 527 | // Otherwise it must be an avatar, return the link to the owner of it. |
499 | - else |
|
500 | - return sprintf('<a href="%1$s?action=profile;u=%2$d">%3$s</a>', $scripturl, $rowData['id_member'], $rowData['poster_name']); |
|
528 | + else { |
|
529 | + return sprintf('<a href="%1$s?action=profile;u=%2$d">%3$s</a>', $scripturl, $rowData['id_member'], $rowData['poster_name']); |
|
530 | + } |
|
501 | 531 | }, |
502 | 532 | ), |
503 | 533 | 'sort' => array( |
@@ -519,7 +549,9 @@ discard block |
||
519 | 549 | |
520 | 550 | // Add a link to the topic in case of an attachment. |
521 | 551 | if ($context['browse_type'] !== 'avatars') |
522 | - $date .= sprintf('<br />%1$s <a href="%2$s?topic=%3$d.msg%4$d#msg%4$d">%5$s</a>', $txt['in'], $scripturl, $rowData['id_topic'], $rowData['id_msg'], $rowData['subject']); |
|
552 | + { |
|
553 | + $date .= sprintf('<br />%1$s <a href="%2$s?topic=%3$d.msg%4$d#msg%4$d">%5$s</a>', $txt['in'], $scripturl, $rowData['id_topic'], $rowData['id_msg'], $rowData['subject']); |
|
554 | + } |
|
523 | 555 | |
524 | 556 | return $date; |
525 | 557 | }, |
@@ -634,11 +666,15 @@ discard block |
||
634 | 666 | |
635 | 667 | // If they specified a limit only.... |
636 | 668 | if (!empty($modSettings['attachmentDirSizeLimit'])) |
637 | - $context['attachment_space'] = comma_format(max($modSettings['attachmentDirSizeLimit'] - $current_dir['size'], 0), 2); |
|
669 | + { |
|
670 | + $context['attachment_space'] = comma_format(max($modSettings['attachmentDirSizeLimit'] - $current_dir['size'], 0), 2); |
|
671 | + } |
|
638 | 672 | $context['attachment_current_size'] = byte_format($current_dir['size']); |
639 | 673 | |
640 | 674 | if (!empty($modSettings['attachmentDirFileLimit'])) |
641 | - $context['attachment_files'] = comma_format(max($modSettings['attachmentDirFileLimit'] - $current_dir['files'], 0), 0); |
|
675 | + { |
|
676 | + $context['attachment_files'] = comma_format(max($modSettings['attachmentDirFileLimit'] - $current_dir['files'], 0), 0); |
|
677 | + } |
|
642 | 678 | $context['attachment_current_files'] = comma_format($current_dir['files'], 0); |
643 | 679 | |
644 | 680 | $context['attach_multiple_dirs'] = count($attach_dirs) > 1 ? true : false; |
@@ -669,7 +705,9 @@ discard block |
||
669 | 705 | |
670 | 706 | // Guess that didn't work? |
671 | 707 | if (!is_writable($modSettings['custom_avatar_dir'])) |
672 | - throw new Elk_Exception('attachments_no_write', 'critical'); |
|
708 | + { |
|
709 | + throw new Elk_Exception('attachments_no_write', 'critical'); |
|
710 | + } |
|
673 | 711 | } |
674 | 712 | |
675 | 713 | // Finally move the attachments.. |
@@ -699,7 +737,9 @@ discard block |
||
699 | 737 | |
700 | 738 | // Update the messages to reflect the change. |
701 | 739 | if (!empty($messages) && !empty($this->_req->post->notice)) |
702 | - setRemovalNotice($messages, $this->_req->post->notice); |
|
740 | + { |
|
741 | + setRemovalNotice($messages, $this->_req->post->notice); |
|
742 | + } |
|
703 | 743 | } |
704 | 744 | else |
705 | 745 | { |
@@ -725,7 +765,9 @@ discard block |
||
725 | 765 | |
726 | 766 | // And make a note on the post. |
727 | 767 | if (!empty($messages) && !empty($this->_req->post->notice)) |
728 | - setRemovalNotice($messages, $this->_req->post->notice); |
|
768 | + { |
|
769 | + setRemovalNotice($messages, $this->_req->post->notice); |
|
770 | + } |
|
729 | 771 | |
730 | 772 | redirectexit('action=admin;area=manageattachments;sa=maintenance'); |
731 | 773 | } |
@@ -746,10 +788,14 @@ discard block |
||
746 | 788 | // There must be a quicker way to pass this safety test?? |
747 | 789 | $attachments = array(); |
748 | 790 | foreach ($this->_req->post->remove as $removeID => $dummy) |
749 | - $attachments[] = (int) $removeID; |
|
791 | + { |
|
792 | + $attachments[] = (int) $removeID; |
|
793 | + } |
|
750 | 794 | |
751 | 795 | if ($this->_req->query->type == 'avatars' && !empty($attachments)) |
752 | - removeAttachments(array('id_attach' => $attachments)); |
|
796 | + { |
|
797 | + removeAttachments(array('id_attach' => $attachments)); |
|
798 | + } |
|
753 | 799 | elseif (!empty($attachments)) |
754 | 800 | { |
755 | 801 | $messages = removeAttachments(array('id_attach' => $attachments), 'messages', true); |
@@ -785,7 +831,9 @@ discard block |
||
785 | 831 | |
786 | 832 | // Add the notice on the end of the changed messages. |
787 | 833 | if (!empty($messages)) |
788 | - setRemovalNotice($messages, $notice); |
|
834 | + { |
|
835 | + setRemovalNotice($messages, $notice); |
|
836 | + } |
|
789 | 837 | |
790 | 838 | redirectexit('action=admin;area=manageattachments;sa=maintenance'); |
791 | 839 | } |
@@ -815,7 +863,9 @@ discard block |
||
815 | 863 | |
816 | 864 | // If we choose cancel, redirect right back. |
817 | 865 | if (isset($this->_req->post->cancel)) |
818 | - redirectexit('action=admin;area=manageattachments;sa=maintenance'); |
|
866 | + { |
|
867 | + redirectexit('action=admin;area=manageattachments;sa=maintenance'); |
|
868 | + } |
|
819 | 869 | |
820 | 870 | // Try give us a while to sort this out... |
821 | 871 | detectServer()->setTimeLimit(600); |
@@ -834,10 +884,14 @@ discard block |
||
834 | 884 | { |
835 | 885 | // Nothing? |
836 | 886 | if (empty($this->_req->post->to_fix)) |
837 | - redirectexit('action=admin;area=manageattachments;sa=maintenance'); |
|
887 | + { |
|
888 | + redirectexit('action=admin;area=manageattachments;sa=maintenance'); |
|
889 | + } |
|
838 | 890 | |
839 | 891 | foreach ($this->_req->post->to_fix as $key => $value) |
840 | - $_SESSION['attachments_to_fix'][] = $value; |
|
892 | + { |
|
893 | + $_SESSION['attachments_to_fix'][] = $value; |
|
894 | + } |
|
841 | 895 | } |
842 | 896 | } |
843 | 897 | |
@@ -907,7 +961,9 @@ discard block |
||
907 | 961 | $repair_errors = repairAttachmentData($this->substep, $fix_errors, $to_fix); |
908 | 962 | |
909 | 963 | foreach ($repair_errors as $key => $value) |
910 | - $context['repair_errors'][$key] += $value; |
|
964 | + { |
|
965 | + $context['repair_errors'][$key] += $value; |
|
966 | + } |
|
911 | 967 | |
912 | 968 | $this->_pauseAttachmentMaintenance($to_fix, $thumbnails); |
913 | 969 | } |
@@ -959,7 +1015,9 @@ discard block |
||
959 | 1015 | { |
960 | 1016 | // Just use the current path for temp files. |
961 | 1017 | if (!is_array($modSettings['attachmentUploadDir'])) |
962 | - $modSettings['attachmentUploadDir'] = Util::unserialize($modSettings['attachmentUploadDir']); |
|
1018 | + { |
|
1019 | + $modSettings['attachmentUploadDir'] = Util::unserialize($modSettings['attachmentUploadDir']); |
|
1020 | + } |
|
963 | 1021 | |
964 | 1022 | $attach_dirs = $modSettings['attachmentUploadDir']; |
965 | 1023 | $current_check = 0; |
@@ -974,7 +1032,9 @@ discard block |
||
974 | 1032 | foreach ($files as $file) |
975 | 1033 | { |
976 | 1034 | if ($file->getFilename() === '.htaccess') |
977 | - continue; |
|
1035 | + { |
|
1036 | + continue; |
|
1037 | + } |
|
978 | 1038 | |
979 | 1039 | if ($files_checked <= $current_check) |
980 | 1040 | { |
@@ -983,7 +1043,9 @@ discard block |
||
983 | 1043 | { |
984 | 1044 | // Temp file is more than 5 hours old! |
985 | 1045 | if ($file->getMTime() < time() - 18000) |
986 | - @unlink($file->getPathname()); |
|
1046 | + { |
|
1047 | + @unlink($file->getPathname()); |
|
1048 | + } |
|
987 | 1049 | } |
988 | 1050 | // That should be an attachment, let's check if we have it in the database |
989 | 1051 | elseif (strpos($file->getFilename(), '_') !== false) |
@@ -994,25 +1056,33 @@ discard block |
||
994 | 1056 | if (!validateAttachID($attachID)) |
995 | 1057 | { |
996 | 1058 | if ($fix_errors && in_array('files_without_attachment', $to_fix)) |
997 | - @unlink($file->getPathname()); |
|
998 | - else |
|
999 | - $context['repair_errors']['files_without_attachment']++; |
|
1059 | + { |
|
1060 | + @unlink($file->getPathname()); |
|
1061 | + } |
|
1062 | + else { |
|
1063 | + $context['repair_errors']['files_without_attachment']++; |
|
1064 | + } |
|
1000 | 1065 | } |
1001 | 1066 | } |
1002 | 1067 | } |
1003 | 1068 | elseif ($file->getFilename() !== 'index.php' && !$file->isDir()) |
1004 | 1069 | { |
1005 | 1070 | if ($fix_errors && in_array('files_without_attachment', $to_fix)) |
1006 | - @unlink($file->getPathname()); |
|
1007 | - else |
|
1008 | - $context['repair_errors']['files_without_attachment']++; |
|
1071 | + { |
|
1072 | + @unlink($file->getPathname()); |
|
1073 | + } |
|
1074 | + else { |
|
1075 | + $context['repair_errors']['files_without_attachment']++; |
|
1076 | + } |
|
1009 | 1077 | } |
1010 | 1078 | } |
1011 | 1079 | $current_check++; |
1012 | 1080 | $this->substep = (int) $current_check; |
1013 | 1081 | |
1014 | 1082 | if ($current_check - $files_checked >= $max_checks) |
1015 | - $this->_pauseAttachmentMaintenance($to_fix); |
|
1083 | + { |
|
1084 | + $this->_pauseAttachmentMaintenance($to_fix); |
|
1085 | + } |
|
1016 | 1086 | } |
1017 | 1087 | } |
1018 | 1088 | catch (UnexpectedValueException $e) |
@@ -1053,12 +1123,18 @@ discard block |
||
1053 | 1123 | |
1054 | 1124 | // Since this needs to be done eventually. |
1055 | 1125 | if (!is_array($modSettings['attachmentUploadDir'])) |
1056 | - $modSettings['attachmentUploadDir'] = Util::unserialize($modSettings['attachmentUploadDir']); |
|
1126 | + { |
|
1127 | + $modSettings['attachmentUploadDir'] = Util::unserialize($modSettings['attachmentUploadDir']); |
|
1128 | + } |
|
1057 | 1129 | |
1058 | 1130 | if (!isset($modSettings['attachment_basedirectories'])) |
1059 | - $modSettings['attachment_basedirectories'] = array(); |
|
1131 | + { |
|
1132 | + $modSettings['attachment_basedirectories'] = array(); |
|
1133 | + } |
|
1060 | 1134 | elseif (!is_array($modSettings['attachment_basedirectories'])) |
1061 | - $modSettings['attachment_basedirectories'] = Util::unserialize($modSettings['attachment_basedirectories']); |
|
1135 | + { |
|
1136 | + $modSettings['attachment_basedirectories'] = Util::unserialize($modSettings['attachment_basedirectories']); |
|
1137 | + } |
|
1062 | 1138 | |
1063 | 1139 | $errors = array(); |
1064 | 1140 | |
@@ -1074,20 +1150,26 @@ discard block |
||
1074 | 1150 | $themes = installedThemes(); |
1075 | 1151 | $reserved_dirs = array(BOARDDIR, SOURCEDIR, SUBSDIR, CONTROLLERDIR, CACHEDIR, EXTDIR, LANGUAGEDIR, ADMINDIR); |
1076 | 1152 | foreach ($themes as $theme) |
1077 | - $reserved_dirs[] = $theme['theme_dir']; |
|
1153 | + { |
|
1154 | + $reserved_dirs[] = $theme['theme_dir']; |
|
1155 | + } |
|
1078 | 1156 | |
1079 | 1157 | foreach ($this->_req->post->dirs as $id => $path) |
1080 | 1158 | { |
1081 | 1159 | $error = ''; |
1082 | 1160 | $id = (int) $id; |
1083 | 1161 | if ($id < 1) |
1084 | - continue; |
|
1162 | + { |
|
1163 | + continue; |
|
1164 | + } |
|
1085 | 1165 | |
1086 | 1166 | $real_path = rtrim(trim($path), DIRECTORY_SEPARATOR); |
1087 | 1167 | |
1088 | 1168 | // If it doesn't look like a directory, probably is not a directory |
1089 | 1169 | if (preg_match('~[/\\\\]~', $real_path) !== 1) |
1090 | - $real_path = realpath(BOARDDIR . DIRECTORY_SEPARATOR . ltrim($real_path, DIRECTORY_SEPARATOR)); |
|
1170 | + { |
|
1171 | + $real_path = realpath(BOARDDIR . DIRECTORY_SEPARATOR . ltrim($real_path, DIRECTORY_SEPARATOR)); |
|
1172 | + } |
|
1091 | 1173 | |
1092 | 1174 | // Hmm, a new path maybe? |
1093 | 1175 | if (!array_key_exists($id, $modSettings['attachmentUploadDir'])) |
@@ -1108,9 +1190,12 @@ discard block |
||
1108 | 1190 | |
1109 | 1191 | // OK, so let's try to create it then. |
1110 | 1192 | if (automanage_attachments_create_directory($path)) |
1111 | - $this->current_dir = $modSettings['currentAttachmentUploadDir']; |
|
1112 | - else |
|
1113 | - $errors[] = $path . ': ' . $txt[$context['dir_creation_error']]; |
|
1193 | + { |
|
1194 | + $this->current_dir = $modSettings['currentAttachmentUploadDir']; |
|
1195 | + } |
|
1196 | + else { |
|
1197 | + $errors[] = $path . ': ' . $txt[$context['dir_creation_error']]; |
|
1198 | + } |
|
1114 | 1199 | } |
1115 | 1200 | |
1116 | 1201 | // Changing a directory name? |
@@ -1150,10 +1235,14 @@ discard block |
||
1150 | 1235 | |
1151 | 1236 | // It's not a good idea to delete the current directory. |
1152 | 1237 | if ($id == (!empty($this->current_dir) ? $this->current_dir : $modSettings['currentAttachmentUploadDir'])) |
1153 | - $errors[] = $real_path . ': ' . $txt['attach_dir_is_current']; |
|
1238 | + { |
|
1239 | + $errors[] = $real_path . ': ' . $txt['attach_dir_is_current']; |
|
1240 | + } |
|
1154 | 1241 | // Or the current base directory |
1155 | 1242 | elseif (!empty($modSettings['basedirectory_for_attachments']) && $modSettings['basedirectory_for_attachments'] == $modSettings['attachmentUploadDir'][$id]) |
1156 | - $errors[] = $real_path . ': ' . $txt['attach_dir_is_current_bd']; |
|
1243 | + { |
|
1244 | + $errors[] = $real_path . ': ' . $txt['attach_dir_is_current_bd']; |
|
1245 | + } |
|
1157 | 1246 | else |
1158 | 1247 | { |
1159 | 1248 | // Let's not try to delete a path with files in it. |
@@ -1164,15 +1253,19 @@ discard block |
||
1164 | 1253 | { |
1165 | 1254 | // Count any sub-folders. |
1166 | 1255 | foreach ($modSettings['attachmentUploadDir'] as $sub) |
1167 | - if (strpos($sub, $real_path . DIRECTORY_SEPARATOR) !== false) |
|
1256 | + { |
|
1257 | + if (strpos($sub, $real_path . DIRECTORY_SEPARATOR) !== false) |
|
1168 | 1258 | $num_attach++; |
1259 | + } |
|
1169 | 1260 | } |
1170 | 1261 | |
1171 | 1262 | // It's safe to delete. So try to delete the folder also |
1172 | 1263 | if ($num_attach == 0) |
1173 | 1264 | { |
1174 | 1265 | if (is_dir($real_path)) |
1175 | - $doit = true; |
|
1266 | + { |
|
1267 | + $doit = true; |
|
1268 | + } |
|
1176 | 1269 | elseif (is_dir(BOARDDIR . DIRECTORY_SEPARATOR . $real_path)) |
1177 | 1270 | { |
1178 | 1271 | $doit = true; |
@@ -1184,7 +1277,9 @@ discard block |
||
1184 | 1277 | unlink($real_path . '/.htaccess'); |
1185 | 1278 | unlink($real_path . '/index.php'); |
1186 | 1279 | if (!@rmdir($real_path)) |
1187 | - $error = $real_path . ': ' . $txt['attach_dir_no_delete']; |
|
1280 | + { |
|
1281 | + $error = $real_path . ': ' . $txt['attach_dir_no_delete']; |
|
1282 | + } |
|
1188 | 1283 | } |
1189 | 1284 | |
1190 | 1285 | // Remove it from the base directory list. |
@@ -1195,13 +1290,17 @@ discard block |
||
1195 | 1290 | $modSettings['attachment_basedirectories'] = Util::unserialize($modSettings['attachment_basedirectories']); |
1196 | 1291 | } |
1197 | 1292 | } |
1198 | - else |
|
1199 | - $error = $real_path . ': ' . $txt['attach_dir_no_remove']; |
|
1293 | + else { |
|
1294 | + $error = $real_path . ': ' . $txt['attach_dir_no_remove']; |
|
1295 | + } |
|
1200 | 1296 | |
1201 | 1297 | if (empty($error)) |
1202 | - continue; |
|
1203 | - else |
|
1204 | - $errors[] = $error; |
|
1298 | + { |
|
1299 | + continue; |
|
1300 | + } |
|
1301 | + else { |
|
1302 | + $errors[] = $error; |
|
1303 | + } |
|
1205 | 1304 | } |
1206 | 1305 | } |
1207 | 1306 | |
@@ -1210,22 +1309,29 @@ discard block |
||
1210 | 1309 | |
1211 | 1310 | // We need to make sure the current directory is right. |
1212 | 1311 | if (empty($this->current_dir) && !empty($modSettings['currentAttachmentUploadDir'])) |
1213 | - $this->current_dir = $modSettings['currentAttachmentUploadDir']; |
|
1312 | + { |
|
1313 | + $this->current_dir = $modSettings['currentAttachmentUploadDir']; |
|
1314 | + } |
|
1214 | 1315 | |
1215 | 1316 | // Find the current directory if there's no value carried, |
1216 | 1317 | if (empty($this->current_dir) || empty($new_dirs[$this->current_dir])) |
1217 | 1318 | { |
1218 | 1319 | if (array_key_exists($modSettings['currentAttachmentUploadDir'], $modSettings['attachmentUploadDir'])) |
1219 | - $this->current_dir = $modSettings['currentAttachmentUploadDir']; |
|
1220 | - else |
|
1221 | - $this->current_dir = max(array_keys($modSettings['attachmentUploadDir'])); |
|
1320 | + { |
|
1321 | + $this->current_dir = $modSettings['currentAttachmentUploadDir']; |
|
1322 | + } |
|
1323 | + else { |
|
1324 | + $this->current_dir = max(array_keys($modSettings['attachmentUploadDir'])); |
|
1325 | + } |
|
1222 | 1326 | } |
1223 | 1327 | |
1224 | 1328 | // If the user wishes to go back, update the last_dir array |
1225 | 1329 | if ($this->current_dir != $modSettings['currentAttachmentUploadDir'] && !empty($modSettings['last_attachments_directory']) && (isset($modSettings['last_attachments_directory'][$this->current_dir]) || isset($modSettings['last_attachments_directory'][0]))) |
1226 | 1330 | { |
1227 | 1331 | if (!is_array($modSettings['last_attachments_directory'])) |
1228 | - $modSettings['last_attachments_directory'] = Util::unserialize($modSettings['last_attachments_directory']); |
|
1332 | + { |
|
1333 | + $modSettings['last_attachments_directory'] = Util::unserialize($modSettings['last_attachments_directory']); |
|
1334 | + } |
|
1229 | 1335 | |
1230 | 1336 | $num = substr(strrchr($modSettings['attachmentUploadDir'][$this->current_dir], '_'), 1); |
1231 | 1337 | if (is_numeric($num)) |
@@ -1234,17 +1340,21 @@ discard block |
||
1234 | 1340 | $bid = -1; |
1235 | 1341 | $use_subdirectories_for_attachments = 0; |
1236 | 1342 | if (!empty($modSettings['attachment_basedirectories'])) |
1237 | - foreach ($modSettings['attachment_basedirectories'] as $bid => $base) |
|
1343 | + { |
|
1344 | + foreach ($modSettings['attachment_basedirectories'] as $bid => $base) |
|
1238 | 1345 | { |
1239 | 1346 | if (strpos($modSettings['attachmentUploadDir'][$this->current_dir], $base . DIRECTORY_SEPARATOR) !== false) |
1240 | 1347 | { |
1241 | 1348 | $use_subdirectories_for_attachments = 1; |
1349 | + } |
|
1242 | 1350 | break; |
1243 | 1351 | } |
1244 | 1352 | } |
1245 | 1353 | |
1246 | 1354 | if ($use_subdirectories_for_attachments == 0 && strpos($modSettings['attachmentUploadDir'][$this->current_dir], BOARDDIR . DIRECTORY_SEPARATOR) !== false) |
1247 | - $bid = 0; |
|
1355 | + { |
|
1356 | + $bid = 0; |
|
1357 | + } |
|
1248 | 1358 | |
1249 | 1359 | $modSettings['last_attachments_directory'][$bid] = (int) $num; |
1250 | 1360 | $modSettings['basedirectory_for_attachments'] = !empty($modSettings['basedirectory_for_attachments']) ? $modSettings['basedirectory_for_attachments'] : ''; |
@@ -1264,7 +1374,9 @@ discard block |
||
1264 | 1374 | foreach ($new_dirs as $id => $dir) |
1265 | 1375 | { |
1266 | 1376 | if ($id != 1) |
1267 | - updateAttachmentIdFolder($id, 1); |
|
1377 | + { |
|
1378 | + updateAttachmentIdFolder($id, 1); |
|
1379 | + } |
|
1268 | 1380 | |
1269 | 1381 | $update = array( |
1270 | 1382 | 'currentAttachmentUploadDir' => 1, |
@@ -1282,10 +1394,14 @@ discard block |
||
1282 | 1394 | } |
1283 | 1395 | |
1284 | 1396 | if (!empty($update)) |
1285 | - updateSettings($update); |
|
1397 | + { |
|
1398 | + updateSettings($update); |
|
1399 | + } |
|
1286 | 1400 | |
1287 | 1401 | if (!empty($errors)) |
1288 | - $_SESSION['errors']['dir'] = $errors; |
|
1402 | + { |
|
1403 | + $_SESSION['errors']['dir'] = $errors; |
|
1404 | + } |
|
1289 | 1405 | |
1290 | 1406 | redirectexit('action=admin;area=manageattachments;sa=attachpaths;' . $context['session_var'] . '=' . $context['session_id']); |
1291 | 1407 | } |
@@ -1300,9 +1416,11 @@ discard block |
||
1300 | 1416 | if (empty($this->_req->post->new_base_dir) && !empty($this->current_base_dir)) |
1301 | 1417 | { |
1302 | 1418 | if ($modSettings['basedirectory_for_attachments'] != $modSettings['attachmentUploadDir'][$this->current_base_dir]) |
1303 | - $update = (array( |
|
1419 | + { |
|
1420 | + $update = (array( |
|
1304 | 1421 | 'basedirectory_for_attachments' => $modSettings['attachmentUploadDir'][$this->current_base_dir], |
1305 | 1422 | )); |
1423 | + } |
|
1306 | 1424 | } |
1307 | 1425 | |
1308 | 1426 | if (isset($this->_req->post->base_dir)) |
@@ -1350,12 +1468,16 @@ discard block |
||
1350 | 1468 | if (!in_array($this->_req->post->new_base_dir, $modSettings['attachmentUploadDir'])) |
1351 | 1469 | { |
1352 | 1470 | if (!automanage_attachments_create_directory($this->_req->post->new_base_dir)) |
1353 | - $errors[] = $this->_req->post->new_base_dir . ': ' . $txt['attach_dir_base_no_create']; |
|
1471 | + { |
|
1472 | + $errors[] = $this->_req->post->new_base_dir . ': ' . $txt['attach_dir_base_no_create']; |
|
1473 | + } |
|
1354 | 1474 | } |
1355 | 1475 | |
1356 | 1476 | $modSettings['currentAttachmentUploadDir'] = array_search($this->_req->post->new_base_dir, $modSettings['attachmentUploadDir']); |
1357 | 1477 | if (!in_array($this->_req->post->new_base_dir, $modSettings['attachment_basedirectories'])) |
1358 | - $modSettings['attachment_basedirectories'][$modSettings['currentAttachmentUploadDir']] = $this->_req->post->new_base_dir; |
|
1478 | + { |
|
1479 | + $modSettings['attachment_basedirectories'][$modSettings['currentAttachmentUploadDir']] = $this->_req->post->new_base_dir; |
|
1480 | + } |
|
1359 | 1481 | ksort($modSettings['attachment_basedirectories']); |
1360 | 1482 | |
1361 | 1483 | $update = (array( |
@@ -1366,10 +1488,14 @@ discard block |
||
1366 | 1488 | } |
1367 | 1489 | |
1368 | 1490 | if (!empty($errors)) |
1369 | - $_SESSION['errors']['base'] = $errors; |
|
1491 | + { |
|
1492 | + $_SESSION['errors']['base'] = $errors; |
|
1493 | + } |
|
1370 | 1494 | |
1371 | 1495 | if (!empty($update)) |
1372 | - updateSettings($update); |
|
1496 | + { |
|
1497 | + updateSettings($update); |
|
1498 | + } |
|
1373 | 1499 | |
1374 | 1500 | redirectexit('action=admin;area=manageattachments;sa=attachpaths;' . $context['session_var'] . '=' . $context['session_id']); |
1375 | 1501 | } |
@@ -1380,12 +1506,16 @@ discard block |
||
1380 | 1506 | { |
1381 | 1507 | $errors = array(); |
1382 | 1508 | if (!empty($this->_req->session->errors['dir'])) |
1383 | - foreach ($this->_req->session->errors['dir'] as $error) |
|
1509 | + { |
|
1510 | + foreach ($this->_req->session->errors['dir'] as $error) |
|
1384 | 1511 | $errors['dir'][] = Util::htmlspecialchars($error, ENT_QUOTES); |
1512 | + } |
|
1385 | 1513 | |
1386 | 1514 | if (!empty($this->_req->session->errors['base'])) |
1387 | - foreach ($this->_req->session->errors['base'] as $error) |
|
1515 | + { |
|
1516 | + foreach ($this->_req->session->errors['base'] as $error) |
|
1388 | 1517 | $errors['base'][] = Util::htmlspecialchars($error, ENT_QUOTES); |
1518 | + } |
|
1389 | 1519 | } |
1390 | 1520 | unset($_SESSION['errors'], $this->_req->session->errors); |
1391 | 1521 | } |
@@ -1572,9 +1702,12 @@ discard block |
||
1572 | 1702 | // The list(s) of directory's that are available. |
1573 | 1703 | $modSettings['attachmentUploadDir'] = Util::unserialize($modSettings['attachmentUploadDir']); |
1574 | 1704 | if (!empty($modSettings['attachment_basedirectories'])) |
1575 | - $modSettings['attachment_basedirectories'] = Util::unserialize($modSettings['attachment_basedirectories']); |
|
1576 | - else |
|
1577 | - $modSettings['basedirectory_for_attachments'] = array(); |
|
1705 | + { |
|
1706 | + $modSettings['attachment_basedirectories'] = Util::unserialize($modSettings['attachment_basedirectories']); |
|
1707 | + } |
|
1708 | + else { |
|
1709 | + $modSettings['basedirectory_for_attachments'] = array(); |
|
1710 | + } |
|
1578 | 1711 | |
1579 | 1712 | // Clean the inputs |
1580 | 1713 | $this->from = $this->_req->getPost('from', 'intval'); |
@@ -1594,11 +1727,15 @@ discard block |
||
1594 | 1727 | |
1595 | 1728 | // Need to know where we are moving things from |
1596 | 1729 | if (empty($this->from) || (empty($this->auto) && empty($this->to))) |
1597 | - $results[] = $txt['attachment_transfer_no_dir']; |
|
1730 | + { |
|
1731 | + $results[] = $txt['attachment_transfer_no_dir']; |
|
1732 | + } |
|
1598 | 1733 | |
1599 | 1734 | // Same location, that's easy |
1600 | 1735 | if ($this->from == $this->to) |
1601 | - $results[] = $txt['attachment_transfer_same_dir']; |
|
1736 | + { |
|
1737 | + $results[] = $txt['attachment_transfer_same_dir']; |
|
1738 | + } |
|
1602 | 1739 | |
1603 | 1740 | // No errors so determine how many we may have to move |
1604 | 1741 | if (empty($results)) |
@@ -1608,7 +1745,9 @@ discard block |
||
1608 | 1745 | $total_progress -= $start; |
1609 | 1746 | |
1610 | 1747 | if ($total_progress < 1) |
1611 | - $results[] = $txt['attachment_transfer_no_find']; |
|
1748 | + { |
|
1749 | + $results[] = $txt['attachment_transfer_no_find']; |
|
1750 | + } |
|
1612 | 1751 | } |
1613 | 1752 | |
1614 | 1753 | // Nothing to move (no files in source or below the max limit) |
@@ -1628,8 +1767,9 @@ discard block |
||
1628 | 1767 | $new_dir = $modSettings['currentAttachmentUploadDir']; |
1629 | 1768 | } |
1630 | 1769 | // Or to a specified directory |
1631 | - else |
|
1632 | - $new_dir = $this->to; |
|
1770 | + else { |
|
1771 | + $new_dir = $this->to; |
|
1772 | + } |
|
1633 | 1773 | |
1634 | 1774 | $modSettings['currentAttachmentUploadDir'] = $new_dir; |
1635 | 1775 | $break = false; |
@@ -1652,13 +1792,17 @@ discard block |
||
1652 | 1792 | if ($tomove_count === 0) |
1653 | 1793 | { |
1654 | 1794 | if (empty($current_progress)) |
1655 | - $results[] = $txt['attachment_transfer_no_find']; |
|
1795 | + { |
|
1796 | + $results[] = $txt['attachment_transfer_no_find']; |
|
1797 | + } |
|
1656 | 1798 | break; |
1657 | 1799 | } |
1658 | 1800 | |
1659 | 1801 | // No more to move after this batch then set the finished flag. |
1660 | 1802 | if ($tomove_count < $limit) |
1661 | - $break = true; |
|
1803 | + { |
|
1804 | + $break = true; |
|
1805 | + } |
|
1662 | 1806 | |
1663 | 1807 | // Move them |
1664 | 1808 | $moved = array(); |
@@ -1684,7 +1828,9 @@ discard block |
||
1684 | 1828 | |
1685 | 1829 | $results[] = sprintf($txt['attachments_transfered'], $total_moved, $modSettings['attachmentUploadDir'][$new_dir]); |
1686 | 1830 | if (!empty($total_not_moved)) |
1687 | - $results[] = sprintf($txt['attachments_not_transfered'], $total_not_moved); |
|
1831 | + { |
|
1832 | + $results[] = sprintf($txt['attachments_not_transfered'], $total_not_moved); |
|
1833 | + } |
|
1688 | 1834 | |
1689 | 1835 | $dir_files = 0; |
1690 | 1836 | $total_moved = 0; |
@@ -1710,13 +1856,16 @@ discard block |
||
1710 | 1856 | $current_progress++; |
1711 | 1857 | $moved[] = $row['id_attach']; |
1712 | 1858 | } |
1713 | - else |
|
1714 | - $total_not_moved++; |
|
1859 | + else { |
|
1860 | + $total_not_moved++; |
|
1861 | + } |
|
1715 | 1862 | } |
1716 | 1863 | |
1717 | 1864 | // Update the database to reflect the new file location |
1718 | 1865 | if (!empty($moved)) |
1719 | - moveAttachments($moved, $new_dir); |
|
1866 | + { |
|
1867 | + moveAttachments($moved, $new_dir); |
|
1868 | + } |
|
1720 | 1869 | |
1721 | 1870 | $new_dir = $modSettings['currentAttachmentUploadDir']; |
1722 | 1871 | |
@@ -1741,13 +1890,17 @@ discard block |
||
1741 | 1890 | |
1742 | 1891 | $results[] = sprintf($txt['attachments_transfered'], $total_moved, $modSettings['attachmentUploadDir'][$new_dir]); |
1743 | 1892 | if (!empty($total_not_moved)) |
1744 | - $results[] = sprintf($txt['attachments_not_transfered'], $total_not_moved); |
|
1893 | + { |
|
1894 | + $results[] = sprintf($txt['attachments_not_transfered'], $total_not_moved); |
|
1895 | + } |
|
1745 | 1896 | } |
1746 | 1897 | |
1747 | 1898 | // All done, time to clean up |
1748 | 1899 | $_SESSION['results'] = $results; |
1749 | 1900 | if (file_exists(BOARDDIR . '/progress.php')) |
1750 | - unlink(BOARDDIR . '/progress.php'); |
|
1901 | + { |
|
1902 | + unlink(BOARDDIR . '/progress.php'); |
|
1903 | + } |
|
1751 | 1904 | |
1752 | 1905 | redirectexit('action=admin;area=manageattachments;sa=maintenance#transfer'); |
1753 | 1906 | } |
@@ -1775,7 +1928,9 @@ discard block |
||
1775 | 1928 | |
1776 | 1929 | // Have we already used our maximum time? |
1777 | 1930 | if (microtime(true) - $time_start < 3 || $this->starting_substep == $this->substep) |
1778 | - return; |
|
1931 | + { |
|
1932 | + return; |
|
1933 | + } |
|
1779 | 1934 | |
1780 | 1935 | $context['continue_get_data'] = '?action=admin;area=manageattachments;sa=repair' . (isset($this->_req->query->fixErrors) ? ';fixErrors' : '') . ';step=' . $this->step . ';substep=' . $this->substep . ';' . $context['session_var'] . '=' . $context['session_id']; |
1781 | 1936 | $context['page_title'] = $txt['not_done_title']; |
@@ -1788,9 +1943,12 @@ discard block |
||
1788 | 1943 | |
1789 | 1944 | // Change these two if more steps are added! |
1790 | 1945 | if (empty($max_substep)) |
1791 | - $context['continue_percent'] = round(($this->step * 100) / 25); |
|
1792 | - else |
|
1793 | - $context['continue_percent'] = round(($this->step * 100 + ($this->substep * 100) / $max_substep) / 25); |
|
1946 | + { |
|
1947 | + $context['continue_percent'] = round(($this->step * 100) / 25); |
|
1948 | + } |
|
1949 | + else { |
|
1950 | + $context['continue_percent'] = round(($this->step * 100 + ($this->substep * 100) / $max_substep) / 25); |
|
1951 | + } |
|
1794 | 1952 | |
1795 | 1953 | // Never more than 100%! |
1796 | 1954 | $context['continue_percent'] = min($context['continue_percent'], 100); |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | 'class' => 'grid50', |
431 | 431 | ), |
432 | 432 | 'data' => array( |
433 | - 'function' => function ($rowData) { |
|
433 | + 'function' => function($rowData) { |
|
434 | 434 | global $modSettings, $context, $scripturl; |
435 | 435 | |
436 | 436 | $link = '<a href="'; |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | 'class' => 'nowrap', |
474 | 474 | ), |
475 | 475 | 'data' => array( |
476 | - 'function' => function ($rowData) { |
|
476 | + 'function' => function($rowData) { |
|
477 | 477 | return byte_format($rowData['size']); |
478 | 478 | }, |
479 | 479 | ), |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | 'class' => 'nowrap', |
489 | 489 | ), |
490 | 490 | 'data' => array( |
491 | - 'function' => function ($rowData) { |
|
491 | + 'function' => function($rowData) { |
|
492 | 492 | global $scripturl; |
493 | 493 | |
494 | 494 | // In case of an attachment, return the poster of the attachment. |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | 'class' => 'nowrap', |
512 | 512 | ), |
513 | 513 | 'data' => array( |
514 | - 'function' => function ($rowData) { |
|
514 | + 'function' => function($rowData) { |
|
515 | 515 | global $txt, $context, $scripturl; |
516 | 516 | |
517 | 517 | // The date the message containing the attachment was posted or the owner of the avatar was active. |
@@ -1404,7 +1404,7 @@ discard block |
||
1404 | 1404 | 'class' => 'centertext', |
1405 | 1405 | ), |
1406 | 1406 | 'data' => array( |
1407 | - 'function' => function ($rowData) { |
|
1407 | + 'function' => function($rowData) { |
|
1408 | 1408 | return '<input type="radio" name="current_dir" value="' . $rowData['id'] . '" ' . ($rowData['current'] ? ' checked="checked"' : '') . (!empty($rowData['disable_current']) ? ' disabled="disabled"' : '') . ' class="input_radio" />'; |
1409 | 1409 | }, |
1410 | 1410 | 'style' => 'width: 10%;', |
@@ -1416,7 +1416,7 @@ discard block |
||
1416 | 1416 | 'value' => $txt['attach_path'], |
1417 | 1417 | ), |
1418 | 1418 | 'data' => array( |
1419 | - 'function' => function ($rowData) { |
|
1419 | + 'function' => function($rowData) { |
|
1420 | 1420 | return '<input type="hidden" name="dirs[' . $rowData['id'] . ']" value="' . $rowData['path'] . '" /><input type="text" size="40" name="dirs[' . $rowData['id'] . ']" value="' . $rowData['path'] . '"' . (!empty($rowData['disable_base_dir']) ? ' disabled="disabled"' : '') . ' class="input_text"/>'; |
1421 | 1421 | }, |
1422 | 1422 | 'style' => 'width: 40%;', |
@@ -1493,7 +1493,7 @@ discard block |
||
1493 | 1493 | 'class' => 'centertext', |
1494 | 1494 | ), |
1495 | 1495 | 'data' => array( |
1496 | - 'function' => function ($rowData) { |
|
1496 | + 'function' => function($rowData) { |
|
1497 | 1497 | return '<input type="radio" name="current_base_dir" value="' . $rowData['id'] . '" ' . ($rowData['current'] ? ' checked="checked"' : '') . ' class="input_radio" />'; |
1498 | 1498 | }, |
1499 | 1499 | 'style' => 'width: 10%;', |
@@ -157,7 +157,9 @@ |
||
157 | 157 | |
158 | 158 | // If we have old drafts, remove them |
159 | 159 | if (count($drafts) > 0) |
160 | - deleteDrafts($drafts, -1, false); |
|
160 | + { |
|
161 | + deleteDrafts($drafts, -1, false); |
|
162 | + } |
|
161 | 163 | |
162 | 164 | // Errors? no errors, only success ! |
163 | 165 | $context['maintenance_finished'] = array( |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | 'drafts_autosave_enabled' => 2, |
35 | 35 | 'drafts_show_saved_enabled' => 2, |
36 | 36 | ), |
37 | - 'setting_callback' => function ($value) { |
|
37 | + 'setting_callback' => function($value) { |
|
38 | 38 | require_once(SUBSDIR . '/ScheduledTasks.subs.php'); |
39 | 39 | toggleTaskStatusByName('remove_old_drafts', $value); |
40 | 40 | |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | */ |
137 | 137 | public static function integrate_sa_manage_maintenance(&$subActions) |
138 | 138 | { |
139 | - $subActions['topics']['activities']['olddrafts'] = function () { |
|
139 | + $subActions['topics']['activities']['olddrafts'] = function() { |
|
140 | 140 | $controller = new ManageDraftsModule_Controller(new Event_manager()); |
141 | 141 | $controller->pre_dispatch(); |
142 | 142 | $controller->action_olddrafts_display(); |