@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Retrieve a list and several other statistics of the users currently online. |
@@ -45,8 +46,9 @@ discard block |
||
45 | 46 | } |
46 | 47 | |
47 | 48 | // Not allowed sort method? Bang! Error! |
48 | - elseif (!in_array($membersOnlineOptions['sort'], $allowed_sort_options)) |
|
49 | - trigger_error('Sort method for getMembersOnlineStats() function is not allowed', E_USER_NOTICE); |
|
49 | + elseif (!in_array($membersOnlineOptions['sort'], $allowed_sort_options)) { |
|
50 | + trigger_error('Sort method for getMembersOnlineStats() function is not allowed', E_USER_NOTICE); |
|
51 | + } |
|
50 | 52 | |
51 | 53 | // Initialize the array that'll be returned later on. |
52 | 54 | $membersOnlineStats = array( |
@@ -63,8 +65,9 @@ discard block |
||
63 | 65 | // Get any spiders if enabled. |
64 | 66 | $spiders = array(); |
65 | 67 | $spider_finds = array(); |
66 | - if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] < 3 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) |
|
67 | - $spiders = $smcFunc['json_decode']($modSettings['spider_name_cache'], true); |
|
68 | + if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] < 3 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) { |
|
69 | + $spiders = $smcFunc['json_decode']($modSettings['spider_name_cache'], true); |
|
70 | + } |
|
68 | 71 | |
69 | 72 | // Load the users online right now. |
70 | 73 | $request = $smcFunc['db_query']('', ' |
@@ -92,9 +95,7 @@ discard block |
||
92 | 95 | $membersOnlineStats['num_guests']++; |
93 | 96 | |
94 | 97 | continue; |
95 | - } |
|
96 | - |
|
97 | - elseif (empty($row['show_online']) && empty($membersOnlineOptions['show_hidden'])) |
|
98 | + } elseif (empty($row['show_online']) && empty($membersOnlineOptions['show_hidden'])) |
|
98 | 99 | { |
99 | 100 | // Just increase the stats and don't add this hidden user to any list. |
100 | 101 | $membersOnlineStats['num_users_hidden']++; |
@@ -102,10 +103,11 @@ discard block |
||
102 | 103 | } |
103 | 104 | |
104 | 105 | // Some basic color coding... |
105 | - if (!empty($row['online_color'])) |
|
106 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
107 | - else |
|
108 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
106 | + if (!empty($row['online_color'])) { |
|
107 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
108 | + } else { |
|
109 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
110 | + } |
|
109 | 111 | |
110 | 112 | // Buddies get counted and highlighted. |
111 | 113 | $is_buddy = in_array($row['id_member'], $user_info['buddies']); |
@@ -132,8 +134,8 @@ discard block |
||
132 | 134 | $membersOnlineStats['list_users_online'][$row[$membersOnlineOptions['sort']] . '_' . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
133 | 135 | |
134 | 136 | // Store all distinct (primary) membergroups that are shown. |
135 | - if (!isset($membersOnlineStats['online_groups'][$row['id_group']])) |
|
136 | - $membersOnlineStats['online_groups'][$row['id_group']] = array( |
|
137 | + if (!isset($membersOnlineStats['online_groups'][$row['id_group']])) { |
|
138 | + $membersOnlineStats['online_groups'][$row['id_group']] = array( |
|
137 | 139 | 'id' => $row['id_group'], |
138 | 140 | 'name' => $row['group_name'], |
139 | 141 | 'color' => $row['online_color'], |
@@ -141,6 +143,7 @@ discard block |
||
141 | 143 | 'type' => $row['group_type'], |
142 | 144 | 'parent' => $row['id_parent'], |
143 | 145 | ); |
146 | + } |
|
144 | 147 | } |
145 | 148 | $smcFunc['db_free_result']($request); |
146 | 149 | |
@@ -201,11 +204,12 @@ discard block |
||
201 | 204 | $settingsToUpdate = array(); |
202 | 205 | |
203 | 206 | // More members on now than ever were? Update it! |
204 | - if (!isset($modSettings['mostOnline']) || $total_users_online >= $modSettings['mostOnline']) |
|
205 | - $settingsToUpdate = array( |
|
207 | + if (!isset($modSettings['mostOnline']) || $total_users_online >= $modSettings['mostOnline']) { |
|
208 | + $settingsToUpdate = array( |
|
206 | 209 | 'mostOnline' => $total_users_online, |
207 | 210 | 'mostDate' => time() |
208 | 211 | ); |
212 | + } |
|
209 | 213 | |
210 | 214 | $date = strftime('%Y-%m-%d', forum_time(false)); |
211 | 215 | |
@@ -237,8 +241,9 @@ discard block |
||
237 | 241 | { |
238 | 242 | list ($modSettings['mostOnlineToday']) = $smcFunc['db_fetch_row']($request); |
239 | 243 | |
240 | - if ($total_users_online > $modSettings['mostOnlineToday']) |
|
241 | - trackStats(array('most_on' => $total_users_online)); |
|
244 | + if ($total_users_online > $modSettings['mostOnlineToday']) { |
|
245 | + trackStats(array('most_on' => $total_users_online)); |
|
246 | + } |
|
242 | 247 | |
243 | 248 | $total_users_online = max($total_users_online, $modSettings['mostOnlineToday']); |
244 | 249 | } |
@@ -255,8 +260,9 @@ discard block |
||
255 | 260 | $settingsToUpdate['mostOnlineToday'] = $total_users_online; |
256 | 261 | } |
257 | 262 | |
258 | - if (!empty($settingsToUpdate)) |
|
259 | - updateSettings($settingsToUpdate); |
|
260 | -} |
|
263 | + if (!empty($settingsToUpdate)) { |
|
264 | + updateSettings($settingsToUpdate); |
|
265 | + } |
|
266 | + } |
|
261 | 267 | |
262 | 268 | ?> |
263 | 269 | \ No newline at end of file |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * The main 'Attachments and Avatars' management function. |
@@ -63,10 +64,11 @@ discard block |
||
63 | 64 | call_integration_hook('integrate_manage_attachments', array(&$subActions)); |
64 | 65 | |
65 | 66 | // Pick the correct sub-action. |
66 | - if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) |
|
67 | - $context['sub_action'] = $_REQUEST['sa']; |
|
68 | - else |
|
69 | - $context['sub_action'] = 'browse'; |
|
67 | + if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) { |
|
68 | + $context['sub_action'] = $_REQUEST['sa']; |
|
69 | + } else { |
|
70 | + $context['sub_action'] = 'browse'; |
|
71 | + } |
|
70 | 72 | |
71 | 73 | // Default page title is good. |
72 | 74 | $context['page_title'] = $txt['attachments_avatars']; |
@@ -94,20 +96,20 @@ discard block |
||
94 | 96 | $context['attachmentUploadDir'] = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']]; |
95 | 97 | |
96 | 98 | // If not set, show a default path for the base directory |
97 | - if (!isset($_GET['save']) && empty($modSettings['basedirectory_for_attachments'])) |
|
98 | - if (is_dir($modSettings['attachmentUploadDir'][1])) |
|
99 | + if (!isset($_GET['save']) && empty($modSettings['basedirectory_for_attachments'])) { |
|
100 | + if (is_dir($modSettings['attachmentUploadDir'][1])) |
|
99 | 101 | $modSettings['basedirectory_for_attachments'] = $modSettings['attachmentUploadDir'][1]; |
100 | - |
|
101 | - else |
|
102 | - $modSettings['basedirectory_for_attachments'] = $context['attachmentUploadDir']; |
|
102 | + } else { |
|
103 | + $modSettings['basedirectory_for_attachments'] = $context['attachmentUploadDir']; |
|
104 | + } |
|
103 | 105 | |
104 | 106 | $context['valid_upload_dir'] = is_dir($context['attachmentUploadDir']) && is_writable($context['attachmentUploadDir']); |
105 | 107 | |
106 | - if (!empty($modSettings['automanage_attachments'])) |
|
107 | - $context['valid_basedirectory'] = !empty($modSettings['basedirectory_for_attachments']) && is_writable($modSettings['basedirectory_for_attachments']); |
|
108 | - |
|
109 | - else |
|
110 | - $context['valid_basedirectory'] = true; |
|
108 | + if (!empty($modSettings['automanage_attachments'])) { |
|
109 | + $context['valid_basedirectory'] = !empty($modSettings['basedirectory_for_attachments']) && is_writable($modSettings['basedirectory_for_attachments']); |
|
110 | + } else { |
|
111 | + $context['valid_basedirectory'] = true; |
|
112 | + } |
|
111 | 113 | |
112 | 114 | // A bit of razzle dazzle with the $txt strings. :) |
113 | 115 | $txt['attachment_path'] = $context['attachmentUploadDir']; |
@@ -185,8 +187,9 @@ discard block |
||
185 | 187 | |
186 | 188 | call_integration_hook('integrate_modify_attachment_settings', array(&$config_vars)); |
187 | 189 | |
188 | - if ($return_config) |
|
189 | - return $config_vars; |
|
190 | + if ($return_config) { |
|
191 | + return $config_vars; |
|
192 | + } |
|
190 | 193 | |
191 | 194 | // These are very likely to come in handy! (i.e. without them we're doomed!) |
192 | 195 | require_once($sourcedir . '/ManagePermissions.php'); |
@@ -197,21 +200,24 @@ discard block |
||
197 | 200 | { |
198 | 201 | checkSession(); |
199 | 202 | |
200 | - if (isset($_POST['attachmentUploadDir'])) |
|
201 | - unset($_POST['attachmentUploadDir']); |
|
203 | + if (isset($_POST['attachmentUploadDir'])) { |
|
204 | + unset($_POST['attachmentUploadDir']); |
|
205 | + } |
|
202 | 206 | |
203 | 207 | if (!empty($_POST['use_subdirectories_for_attachments'])) |
204 | 208 | { |
205 | - if (isset($_POST['use_subdirectories_for_attachments']) && empty($_POST['basedirectory_for_attachments'])) |
|
206 | - $_POST['basedirectory_for_attachments'] = (!empty($modSettings['basedirectory_for_attachments']) ? ($modSettings['basedirectory_for_attachments']) : $boarddir); |
|
209 | + if (isset($_POST['use_subdirectories_for_attachments']) && empty($_POST['basedirectory_for_attachments'])) { |
|
210 | + $_POST['basedirectory_for_attachments'] = (!empty($modSettings['basedirectory_for_attachments']) ? ($modSettings['basedirectory_for_attachments']) : $boarddir); |
|
211 | + } |
|
207 | 212 | |
208 | 213 | if (!empty($_POST['use_subdirectories_for_attachments']) && !empty($modSettings['attachment_basedirectories'])) |
209 | 214 | { |
210 | - if (!is_array($modSettings['attachment_basedirectories'])) |
|
211 | - $modSettings['attachment_basedirectories'] = $smcFunc['json_decode']($modSettings['attachment_basedirectories'], true); |
|
215 | + if (!is_array($modSettings['attachment_basedirectories'])) { |
|
216 | + $modSettings['attachment_basedirectories'] = $smcFunc['json_decode']($modSettings['attachment_basedirectories'], true); |
|
217 | + } |
|
218 | + } else { |
|
219 | + $modSettings['attachment_basedirectories'] = array(); |
|
212 | 220 | } |
213 | - else |
|
214 | - $modSettings['attachment_basedirectories'] = array(); |
|
215 | 221 | |
216 | 222 | if (!empty($_POST['use_subdirectories_for_attachments']) && !empty($_POST['basedirectory_for_attachments']) && !in_array($_POST['basedirectory_for_attachments'], $modSettings['attachment_basedirectories'])) |
217 | 223 | { |
@@ -219,8 +225,9 @@ discard block |
||
219 | 225 | |
220 | 226 | if (!in_array($_POST['basedirectory_for_attachments'], $modSettings['attachmentUploadDir'])) |
221 | 227 | { |
222 | - if (!automanage_attachments_create_directory($_POST['basedirectory_for_attachments'])) |
|
223 | - $_POST['basedirectory_for_attachments'] = $modSettings['basedirectory_for_attachments']; |
|
228 | + if (!automanage_attachments_create_directory($_POST['basedirectory_for_attachments'])) { |
|
229 | + $_POST['basedirectory_for_attachments'] = $modSettings['basedirectory_for_attachments']; |
|
230 | + } |
|
224 | 231 | } |
225 | 232 | |
226 | 233 | if (!in_array($_POST['basedirectory_for_attachments'], $modSettings['attachment_basedirectories'])) |
@@ -336,8 +343,9 @@ discard block |
||
336 | 343 | |
337 | 344 | call_integration_hook('integrate_modify_avatar_settings', array(&$config_vars)); |
338 | 345 | |
339 | - if ($return_config) |
|
340 | - return $config_vars; |
|
346 | + if ($return_config) { |
|
347 | + return $config_vars; |
|
348 | + } |
|
341 | 349 | |
342 | 350 | // We need this file for the settings template. |
343 | 351 | require_once($sourcedir . '/ManageServer.php'); |
@@ -348,17 +356,21 @@ discard block |
||
348 | 356 | checkSession(); |
349 | 357 | |
350 | 358 | // These settings cannot be left empty! |
351 | - if (empty($_POST['custom_avatar_dir'])) |
|
352 | - $_POST['custom_avatar_dir'] = $boarddir . '/custom_avatar'; |
|
359 | + if (empty($_POST['custom_avatar_dir'])) { |
|
360 | + $_POST['custom_avatar_dir'] = $boarddir . '/custom_avatar'; |
|
361 | + } |
|
353 | 362 | |
354 | - if (empty($_POST['custom_avatar_url'])) |
|
355 | - $_POST['custom_avatar_url'] = $boardurl . '/custom_avatar'; |
|
363 | + if (empty($_POST['custom_avatar_url'])) { |
|
364 | + $_POST['custom_avatar_url'] = $boardurl . '/custom_avatar'; |
|
365 | + } |
|
356 | 366 | |
357 | - if (empty($_POST['avatar_directory'])) |
|
358 | - $_POST['avatar_directory'] = $boarddir . '/avatars'; |
|
367 | + if (empty($_POST['avatar_directory'])) { |
|
368 | + $_POST['avatar_directory'] = $boarddir . '/avatars'; |
|
369 | + } |
|
359 | 370 | |
360 | - if (empty($_POST['avatar_url'])) |
|
361 | - $_POST['avatar_url'] = $boardurl . '/avatars'; |
|
371 | + if (empty($_POST['avatar_url'])) { |
|
372 | + $_POST['avatar_url'] = $boardurl . '/avatars'; |
|
373 | + } |
|
362 | 374 | |
363 | 375 | call_integration_hook('integrate_save_avatar_settings'); |
364 | 376 | |
@@ -406,11 +418,13 @@ discard block |
||
406 | 418 | $list_title = $txt['attachment_manager_browse_files'] . ': '; |
407 | 419 | foreach ($titles as $browse_type => $details) |
408 | 420 | { |
409 | - if ($browse_type != 'attachments') |
|
410 | - $list_title .= ' | '; |
|
421 | + if ($browse_type != 'attachments') { |
|
422 | + $list_title .= ' | '; |
|
423 | + } |
|
411 | 424 | |
412 | - if ($context['browse_type'] == $browse_type) |
|
413 | - $list_title .= '<img src="' . $settings['images_url'] . '/selected.png" alt=">"> '; |
|
425 | + if ($context['browse_type'] == $browse_type) { |
|
426 | + $list_title .= '<img src="' . $settings['images_url'] . '/selected.png" alt=">"> '; |
|
427 | + } |
|
414 | 428 | |
415 | 429 | $list_title .= '<a href="' . $scripturl . $details[0] . '">' . $details[1] . '</a>'; |
416 | 430 | } |
@@ -446,28 +460,33 @@ discard block |
||
446 | 460 | $link = '<a href="'; |
447 | 461 | |
448 | 462 | // In case of a custom avatar URL attachments have a fixed directory. |
449 | - if ($rowData['attachment_type'] == 1) |
|
450 | - $link .= sprintf('%1$s/%2$s', $modSettings['custom_avatar_url'], $rowData['filename']); |
|
463 | + if ($rowData['attachment_type'] == 1) { |
|
464 | + $link .= sprintf('%1$s/%2$s', $modSettings['custom_avatar_url'], $rowData['filename']); |
|
465 | + } |
|
451 | 466 | |
452 | 467 | // By default avatars are downloaded almost as attachments. |
453 | - elseif ($context['browse_type'] == 'avatars') |
|
454 | - $link .= sprintf('%1$s?action=dlattach;type=avatar;attach=%2$d', $scripturl, $rowData['id_attach']); |
|
468 | + elseif ($context['browse_type'] == 'avatars') { |
|
469 | + $link .= sprintf('%1$s?action=dlattach;type=avatar;attach=%2$d', $scripturl, $rowData['id_attach']); |
|
470 | + } |
|
455 | 471 | |
456 | 472 | // Normal attachments are always linked to a topic ID. |
457 | - else |
|
458 | - $link .= sprintf('%1$s?action=dlattach;topic=%2$d.0;attach=%3$d', $scripturl, $rowData['id_topic'], $rowData['id_attach']); |
|
473 | + else { |
|
474 | + $link .= sprintf('%1$s?action=dlattach;topic=%2$d.0;attach=%3$d', $scripturl, $rowData['id_topic'], $rowData['id_attach']); |
|
475 | + } |
|
459 | 476 | |
460 | 477 | $link .= '"'; |
461 | 478 | |
462 | 479 | // Show a popup on click if it's a picture and we know its dimensions. |
463 | - if (!empty($rowData['width']) && !empty($rowData['height'])) |
|
464 | - $link .= sprintf(' onclick="return reqWin(this.href' . ($rowData['attachment_type'] == 1 ? '' : ' + \';image\'') . ', %1$d, %2$d, true);"', $rowData['width'] + 20, $rowData['height'] + 20); |
|
480 | + if (!empty($rowData['width']) && !empty($rowData['height'])) { |
|
481 | + $link .= sprintf(' onclick="return reqWin(this.href' . ($rowData['attachment_type'] == 1 ? '' : ' + \';image\'') . ', %1$d, %2$d, true);"', $rowData['width'] + 20, $rowData['height'] + 20); |
|
482 | + } |
|
465 | 483 | |
466 | 484 | $link .= sprintf('>%1$s</a>', preg_replace('~&#(\\\\d{1,7}|x[0-9a-fA-F]{1,6});~', '&#\\\\1;', $smcFunc['htmlspecialchars']($rowData['filename']))); |
467 | 485 | |
468 | 486 | // Show the dimensions. |
469 | - if (!empty($rowData['width']) && !empty($rowData['height'])) |
|
470 | - $link .= sprintf(' <span class="smalltext">%1$dx%2$d</span>', $rowData['width'], $rowData['height']); |
|
487 | + if (!empty($rowData['width']) && !empty($rowData['height'])) { |
|
488 | + $link .= sprintf(' <span class="smalltext">%1$dx%2$d</span>', $rowData['width'], $rowData['height']); |
|
489 | + } |
|
471 | 490 | |
472 | 491 | return $link; |
473 | 492 | }, |
@@ -500,12 +519,14 @@ discard block |
||
500 | 519 | 'function' => function($rowData) use ($scripturl, $smcFunc) |
501 | 520 | { |
502 | 521 | // In case of an attachment, return the poster of the attachment. |
503 | - if (empty($rowData['id_member'])) |
|
504 | - return $smcFunc['htmlspecialchars']($rowData['poster_name']); |
|
522 | + if (empty($rowData['id_member'])) { |
|
523 | + return $smcFunc['htmlspecialchars']($rowData['poster_name']); |
|
524 | + } |
|
505 | 525 | |
506 | 526 | // Otherwise it must be an avatar, return the link to the owner of it. |
507 | - else |
|
508 | - return sprintf('<a href="%1$s?action=profile;u=%2$d">%3$s</a>', $scripturl, $rowData['id_member'], $rowData['poster_name']); |
|
527 | + else { |
|
528 | + return sprintf('<a href="%1$s?action=profile;u=%2$d">%3$s</a>', $scripturl, $rowData['id_member'], $rowData['poster_name']); |
|
529 | + } |
|
509 | 530 | }, |
510 | 531 | ), |
511 | 532 | 'sort' => array( |
@@ -524,8 +545,9 @@ discard block |
||
524 | 545 | $date = empty($rowData['poster_time']) ? $txt['never'] : timeformat($rowData['poster_time']); |
525 | 546 | |
526 | 547 | // Add a link to the topic in case of an attachment. |
527 | - if ($context['browse_type'] !== 'avatars') |
|
528 | - $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']); |
|
548 | + if ($context['browse_type'] !== 'avatars') { |
|
549 | + $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']); |
|
550 | + } |
|
529 | 551 | |
530 | 552 | return $date; |
531 | 553 | }, |
@@ -610,8 +632,8 @@ discard block |
||
610 | 632 | global $smcFunc, $txt; |
611 | 633 | |
612 | 634 | // Choose a query depending on what we are viewing. |
613 | - if ($browse_type === 'avatars') |
|
614 | - $request = $smcFunc['db_query']('', ' |
|
635 | + if ($browse_type === 'avatars') { |
|
636 | + $request = $smcFunc['db_query']('', ' |
|
615 | 637 | SELECT |
616 | 638 | {string:blank_text} AS id_msg, COALESCE(mem.real_name, {string:not_applicable_text}) AS poster_name, |
617 | 639 | mem.last_login AS poster_time, 0 AS id_topic, a.id_member, a.id_attach, a.filename, a.file_hash, a.attachment_type, |
@@ -630,8 +652,8 @@ discard block |
||
630 | 652 | 'per_page' => $items_per_page, |
631 | 653 | ) |
632 | 654 | ); |
633 | - else |
|
634 | - $request = $smcFunc['db_query']('', ' |
|
655 | + } else { |
|
656 | + $request = $smcFunc['db_query']('', ' |
|
635 | 657 | SELECT |
636 | 658 | m.id_msg, COALESCE(mem.real_name, m.poster_name) AS poster_name, m.poster_time, m.id_topic, m.id_member, |
637 | 659 | a.id_attach, a.filename, a.file_hash, a.attachment_type, a.size, a.width, a.height, a.downloads, mf.subject, t.id_board |
@@ -650,9 +672,11 @@ discard block |
||
650 | 672 | 'per_page' => $items_per_page, |
651 | 673 | ) |
652 | 674 | ); |
675 | + } |
|
653 | 676 | $files = array(); |
654 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
655 | - $files[] = $row; |
|
677 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
678 | + $files[] = $row; |
|
679 | + } |
|
656 | 680 | $smcFunc['db_free_result']($request); |
657 | 681 | |
658 | 682 | return $files; |
@@ -670,8 +694,8 @@ discard block |
||
670 | 694 | global $smcFunc; |
671 | 695 | |
672 | 696 | // Depending on the type of file, different queries are used. |
673 | - if ($browse_type === 'avatars') |
|
674 | - $request = $smcFunc['db_query']('', ' |
|
697 | + if ($browse_type === 'avatars') { |
|
698 | + $request = $smcFunc['db_query']('', ' |
|
675 | 699 | SELECT COUNT(*) |
676 | 700 | FROM {db_prefix}attachments |
677 | 701 | WHERE id_member != {int:guest_id_member}', |
@@ -679,8 +703,8 @@ discard block |
||
679 | 703 | 'guest_id_member' => 0, |
680 | 704 | ) |
681 | 705 | ); |
682 | - else |
|
683 | - $request = $smcFunc['db_query']('', ' |
|
706 | + } else { |
|
707 | + $request = $smcFunc['db_query']('', ' |
|
684 | 708 | SELECT COUNT(*) AS num_attach |
685 | 709 | FROM {db_prefix}attachments AS a |
686 | 710 | INNER JOIN {db_prefix}messages AS m ON (m.id_msg = a.id_msg) |
@@ -693,6 +717,7 @@ discard block |
||
693 | 717 | 'guest_id_member' => 0, |
694 | 718 | ) |
695 | 719 | ); |
720 | + } |
|
696 | 721 | |
697 | 722 | list ($num_files) = $smcFunc['db_fetch_row']($request); |
698 | 723 | $smcFunc['db_free_result']($request); |
@@ -775,12 +800,14 @@ discard block |
||
775 | 800 | $current_dir_size /= 1024; |
776 | 801 | |
777 | 802 | // If they specified a limit only.... |
778 | - if (!empty($modSettings['attachmentDirSizeLimit'])) |
|
779 | - $context['attachment_space'] = comma_format(max($modSettings['attachmentDirSizeLimit'] - $current_dir_size, 0), 2); |
|
803 | + if (!empty($modSettings['attachmentDirSizeLimit'])) { |
|
804 | + $context['attachment_space'] = comma_format(max($modSettings['attachmentDirSizeLimit'] - $current_dir_size, 0), 2); |
|
805 | + } |
|
780 | 806 | $context['attachment_current_size'] = comma_format($current_dir_size, 2); |
781 | 807 | |
782 | - if (!empty($modSettings['attachmentDirFileLimit'])) |
|
783 | - $context['attachment_files'] = comma_format(max($modSettings['attachmentDirFileLimit'] - $current_dir_files, 0), 0); |
|
808 | + if (!empty($modSettings['attachmentDirFileLimit'])) { |
|
809 | + $context['attachment_files'] = comma_format(max($modSettings['attachmentDirFileLimit'] - $current_dir_files, 0), 0); |
|
810 | + } |
|
784 | 811 | $context['attachment_current_files'] = comma_format($current_dir_files, 0); |
785 | 812 | |
786 | 813 | $context['attach_multiple_dirs'] = count($attach_dirs) > 1 ? true : false; |
@@ -817,8 +844,8 @@ discard block |
||
817 | 844 | $messages = removeAttachments(array('attachment_type' => 0, 'poster_time' => (time() - 24 * 60 * 60 * $_POST['age'])), 'messages', true); |
818 | 845 | |
819 | 846 | // Update the messages to reflect the change. |
820 | - if (!empty($messages) && !empty($_POST['notice'])) |
|
821 | - $smcFunc['db_query']('', ' |
|
847 | + if (!empty($messages) && !empty($_POST['notice'])) { |
|
848 | + $smcFunc['db_query']('', ' |
|
822 | 849 | UPDATE {db_prefix}messages |
823 | 850 | SET body = CONCAT(body, {string:notice}) |
824 | 851 | WHERE id_msg IN ({array_int:messages})', |
@@ -827,8 +854,8 @@ discard block |
||
827 | 854 | 'notice' => '<br><br>' . $_POST['notice'], |
828 | 855 | ) |
829 | 856 | ); |
830 | - } |
|
831 | - else |
|
857 | + } |
|
858 | + } else |
|
832 | 859 | { |
833 | 860 | // Remove all the old avatars. |
834 | 861 | removeAttachments(array('not_id_member' => 0, 'last_login' => (time() - 24 * 60 * 60 * $_POST['age'])), 'members'); |
@@ -853,8 +880,8 @@ discard block |
||
853 | 880 | $messages = removeAttachments(array('attachment_type' => 0, 'size' => 1024 * $_POST['size']), 'messages', true); |
854 | 881 | |
855 | 882 | // And make a note on the post. |
856 | - if (!empty($messages) && !empty($_POST['notice'])) |
|
857 | - $smcFunc['db_query']('', ' |
|
883 | + if (!empty($messages) && !empty($_POST['notice'])) { |
|
884 | + $smcFunc['db_query']('', ' |
|
858 | 885 | UPDATE {db_prefix}messages |
859 | 886 | SET body = CONCAT(body, {string:notice}) |
860 | 887 | WHERE id_msg IN ({array_int:messages})', |
@@ -863,6 +890,7 @@ discard block |
||
863 | 890 | 'notice' => '<br><br>' . $_POST['notice'], |
864 | 891 | ) |
865 | 892 | ); |
893 | + } |
|
866 | 894 | |
867 | 895 | redirectexit('action=admin;area=manageattachments;sa=maintenance'); |
868 | 896 | } |
@@ -882,16 +910,17 @@ discard block |
||
882 | 910 | { |
883 | 911 | $attachments = array(); |
884 | 912 | // There must be a quicker way to pass this safety test?? |
885 | - foreach ($_POST['remove'] as $removeID => $dummy) |
|
886 | - $attachments[] = (int) $removeID; |
|
913 | + foreach ($_POST['remove'] as $removeID => $dummy) { |
|
914 | + $attachments[] = (int) $removeID; |
|
915 | + } |
|
887 | 916 | |
888 | 917 | // If the attachments are from a 3rd party, let them remove it. Hooks should remove their ids from the array. |
889 | 918 | $filesRemoved = false; |
890 | 919 | call_integration_hook('integrate_attachment_remove', array(&$filesRemoved, $attachments)); |
891 | 920 | |
892 | - if ($_REQUEST['type'] == 'avatars' && !empty($attachments)) |
|
893 | - removeAttachments(array('id_attach' => $attachments)); |
|
894 | - else if (!empty($attachments)) |
|
921 | + if ($_REQUEST['type'] == 'avatars' && !empty($attachments)) { |
|
922 | + removeAttachments(array('id_attach' => $attachments)); |
|
923 | + } else if (!empty($attachments)) |
|
895 | 924 | { |
896 | 925 | $messages = removeAttachments(array('id_attach' => $attachments), 'messages', true); |
897 | 926 | |
@@ -930,12 +959,13 @@ discard block |
||
930 | 959 | |
931 | 960 | $messages = removeAttachments(array('attachment_type' => 0), '', true); |
932 | 961 | |
933 | - if (!isset($_POST['notice'])) |
|
934 | - $_POST['notice'] = $txt['attachment_delete_admin']; |
|
962 | + if (!isset($_POST['notice'])) { |
|
963 | + $_POST['notice'] = $txt['attachment_delete_admin']; |
|
964 | + } |
|
935 | 965 | |
936 | 966 | // Add the notice on the end of the changed messages. |
937 | - if (!empty($messages)) |
|
938 | - $smcFunc['db_query']('', ' |
|
967 | + if (!empty($messages)) { |
|
968 | + $smcFunc['db_query']('', ' |
|
939 | 969 | UPDATE {db_prefix}messages |
940 | 970 | SET body = CONCAT(body, {string:deleted_message}) |
941 | 971 | WHERE id_msg IN ({array_int:messages})', |
@@ -944,6 +974,7 @@ discard block |
||
944 | 974 | 'deleted_message' => '<br><br>' . $_POST['notice'], |
945 | 975 | ) |
946 | 976 | ); |
977 | + } |
|
947 | 978 | |
948 | 979 | redirectexit('action=admin;area=manageattachments;sa=maintenance'); |
949 | 980 | } |
@@ -982,24 +1013,26 @@ discard block |
||
982 | 1013 | $is_not = substr($real_type, 0, 4) == 'not_'; |
983 | 1014 | $type = $is_not ? substr($real_type, 4) : $real_type; |
984 | 1015 | |
985 | - if (in_array($type, array('id_member', 'id_attach', 'id_msg'))) |
|
986 | - $new_condition[] = 'a.' . $type . ($is_not ? ' NOT' : '') . ' IN (' . (is_array($restriction) ? '{array_int:' . $real_type . '}' : '{int:' . $real_type . '}') . ')'; |
|
987 | - elseif ($type == 'attachment_type') |
|
988 | - $new_condition[] = 'a.attachment_type = {int:' . $real_type . '}'; |
|
989 | - elseif ($type == 'poster_time') |
|
990 | - $new_condition[] = 'm.poster_time < {int:' . $real_type . '}'; |
|
991 | - elseif ($type == 'last_login') |
|
992 | - $new_condition[] = 'mem.last_login < {int:' . $real_type . '}'; |
|
993 | - elseif ($type == 'size') |
|
994 | - $new_condition[] = 'a.size > {int:' . $real_type . '}'; |
|
995 | - elseif ($type == 'id_topic') |
|
996 | - $new_condition[] = 'm.id_topic IN (' . (is_array($restriction) ? '{array_int:' . $real_type . '}' : '{int:' . $real_type . '}') . ')'; |
|
1016 | + if (in_array($type, array('id_member', 'id_attach', 'id_msg'))) { |
|
1017 | + $new_condition[] = 'a.' . $type . ($is_not ? ' NOT' : '') . ' IN (' . (is_array($restriction) ? '{array_int:' . $real_type . '}' : '{int:' . $real_type . '}') . ')'; |
|
1018 | + } elseif ($type == 'attachment_type') { |
|
1019 | + $new_condition[] = 'a.attachment_type = {int:' . $real_type . '}'; |
|
1020 | + } elseif ($type == 'poster_time') { |
|
1021 | + $new_condition[] = 'm.poster_time < {int:' . $real_type . '}'; |
|
1022 | + } elseif ($type == 'last_login') { |
|
1023 | + $new_condition[] = 'mem.last_login < {int:' . $real_type . '}'; |
|
1024 | + } elseif ($type == 'size') { |
|
1025 | + $new_condition[] = 'a.size > {int:' . $real_type . '}'; |
|
1026 | + } elseif ($type == 'id_topic') { |
|
1027 | + $new_condition[] = 'm.id_topic IN (' . (is_array($restriction) ? '{array_int:' . $real_type . '}' : '{int:' . $real_type . '}') . ')'; |
|
1028 | + } |
|
997 | 1029 | |
998 | 1030 | // Add the parameter! |
999 | 1031 | $query_parameter[$real_type] = $restriction; |
1000 | 1032 | |
1001 | - if ($type == 'do_logging') |
|
1002 | - $do_logging = $condition['id_attach']; |
|
1033 | + if ($type == 'do_logging') { |
|
1034 | + $do_logging = $condition['id_attach']; |
|
1035 | + } |
|
1003 | 1036 | } |
1004 | 1037 | $condition = implode(' AND ', $new_condition); |
1005 | 1038 | } |
@@ -1031,15 +1064,15 @@ discard block |
||
1031 | 1064 | // wasn't it obvious? :P |
1032 | 1065 | // @todo look again at this. |
1033 | 1066 | @unlink($modSettings['custom_avatar_dir'] . '/' . $row['filename']); |
1034 | - } |
|
1035 | - else |
|
1067 | + } else |
|
1036 | 1068 | { |
1037 | 1069 | $filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']); |
1038 | 1070 | @unlink($filename); |
1039 | 1071 | |
1040 | 1072 | // If this was a thumb, the parent attachment should know about it. |
1041 | - if (!empty($row['id_parent'])) |
|
1042 | - $parents[] = $row['id_parent']; |
|
1073 | + if (!empty($row['id_parent'])) { |
|
1074 | + $parents[] = $row['id_parent']; |
|
1075 | + } |
|
1043 | 1076 | |
1044 | 1077 | // If this attachments has a thumb, remove it as well. |
1045 | 1078 | if (!empty($row['id_thumb']) && $autoThumbRemoval) |
@@ -1051,8 +1084,9 @@ discard block |
||
1051 | 1084 | } |
1052 | 1085 | |
1053 | 1086 | // Make a list. |
1054 | - if ($return_affected_messages && empty($row['attachment_type'])) |
|
1055 | - $msgs[] = $row['id_msg']; |
|
1087 | + if ($return_affected_messages && empty($row['attachment_type'])) { |
|
1088 | + $msgs[] = $row['id_msg']; |
|
1089 | + } |
|
1056 | 1090 | |
1057 | 1091 | $attach[] = $row['id_attach']; |
1058 | 1092 | } |
@@ -1060,8 +1094,8 @@ discard block |
||
1060 | 1094 | |
1061 | 1095 | // Removed attachments don't have to be updated anymore. |
1062 | 1096 | $parents = array_diff($parents, $attach); |
1063 | - if (!empty($parents)) |
|
1064 | - $smcFunc['db_query']('', ' |
|
1097 | + if (!empty($parents)) { |
|
1098 | + $smcFunc['db_query']('', ' |
|
1065 | 1099 | UPDATE {db_prefix}attachments |
1066 | 1100 | SET id_thumb = {int:no_thumb} |
1067 | 1101 | WHERE id_attach IN ({array_int:parent_attachments})', |
@@ -1070,6 +1104,7 @@ discard block |
||
1070 | 1104 | 'no_thumb' => 0, |
1071 | 1105 | ) |
1072 | 1106 | ); |
1107 | + } |
|
1073 | 1108 | |
1074 | 1109 | if (!empty($do_logging)) |
1075 | 1110 | { |
@@ -1086,31 +1121,34 @@ discard block |
||
1086 | 1121 | ) |
1087 | 1122 | ); |
1088 | 1123 | |
1089 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1090 | - logAction( |
|
1124 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1125 | + logAction( |
|
1091 | 1126 | 'remove_attach', |
1092 | 1127 | array( |
1093 | 1128 | 'message' => $row['id_msg'], |
1094 | 1129 | 'filename' => preg_replace('~&#(\\d{1,7}|x[0-9a-fA-F]{1,6});~', '&#\\1;', $smcFunc['htmlspecialchars']($row['filename'])), |
1095 | 1130 | ) |
1096 | 1131 | ); |
1132 | + } |
|
1097 | 1133 | $smcFunc['db_free_result']($request); |
1098 | 1134 | } |
1099 | 1135 | |
1100 | - if (!empty($attach)) |
|
1101 | - $smcFunc['db_query']('', ' |
|
1136 | + if (!empty($attach)) { |
|
1137 | + $smcFunc['db_query']('', ' |
|
1102 | 1138 | DELETE FROM {db_prefix}attachments |
1103 | 1139 | WHERE id_attach IN ({array_int:attachment_list})', |
1104 | 1140 | array( |
1105 | 1141 | 'attachment_list' => $attach, |
1106 | 1142 | ) |
1107 | 1143 | ); |
1144 | + } |
|
1108 | 1145 | |
1109 | 1146 | call_integration_hook('integrate_remove_attachments', array($attach)); |
1110 | 1147 | |
1111 | - if ($return_affected_messages) |
|
1112 | - return array_unique($msgs); |
|
1113 | -} |
|
1148 | + if ($return_affected_messages) { |
|
1149 | + return array_unique($msgs); |
|
1150 | + } |
|
1151 | + } |
|
1114 | 1152 | |
1115 | 1153 | /** |
1116 | 1154 | * This function should find attachments in the database that no longer exist and clear them, and fix filesize issues. |
@@ -1122,8 +1160,9 @@ discard block |
||
1122 | 1160 | checkSession('get'); |
1123 | 1161 | |
1124 | 1162 | // If we choose cancel, redirect right back. |
1125 | - if (isset($_POST['cancel'])) |
|
1126 | - redirectexit('action=admin;area=manageattachments;sa=maintenance'); |
|
1163 | + if (isset($_POST['cancel'])) { |
|
1164 | + redirectexit('action=admin;area=manageattachments;sa=maintenance'); |
|
1165 | + } |
|
1127 | 1166 | |
1128 | 1167 | // Try give us a while to sort this out... |
1129 | 1168 | @set_time_limit(600); |
@@ -1140,13 +1179,15 @@ discard block |
||
1140 | 1179 | if (isset($_GET['fixErrors'])) |
1141 | 1180 | { |
1142 | 1181 | // Nothing? |
1143 | - if (empty($_POST['to_fix'])) |
|
1144 | - redirectexit('action=admin;area=manageattachments;sa=maintenance'); |
|
1182 | + if (empty($_POST['to_fix'])) { |
|
1183 | + redirectexit('action=admin;area=manageattachments;sa=maintenance'); |
|
1184 | + } |
|
1145 | 1185 | |
1146 | 1186 | $_SESSION['attachments_to_fix'] = array(); |
1147 | 1187 | // @todo No need to do this I think. |
1148 | - foreach ($_POST['to_fix'] as $value) |
|
1149 | - $_SESSION['attachments_to_fix'][] = $value; |
|
1188 | + foreach ($_POST['to_fix'] as $value) { |
|
1189 | + $_SESSION['attachments_to_fix'][] = $value; |
|
1190 | + } |
|
1150 | 1191 | } |
1151 | 1192 | } |
1152 | 1193 | |
@@ -1213,13 +1254,14 @@ discard block |
||
1213 | 1254 | } |
1214 | 1255 | } |
1215 | 1256 | } |
1216 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
1217 | - $to_fix[] = 'missing_thumbnail_parent'; |
|
1257 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
1258 | + $to_fix[] = 'missing_thumbnail_parent'; |
|
1259 | + } |
|
1218 | 1260 | $smcFunc['db_free_result']($result); |
1219 | 1261 | |
1220 | 1262 | // Do we need to delete what we have? |
1221 | - if ($fix_errors && !empty($to_remove) && in_array('missing_thumbnail_parent', $to_fix)) |
|
1222 | - $smcFunc['db_query']('', ' |
|
1263 | + if ($fix_errors && !empty($to_remove) && in_array('missing_thumbnail_parent', $to_fix)) { |
|
1264 | + $smcFunc['db_query']('', ' |
|
1223 | 1265 | DELETE FROM {db_prefix}attachments |
1224 | 1266 | WHERE id_attach IN ({array_int:to_remove}) |
1225 | 1267 | AND attachment_type = {int:attachment_type}', |
@@ -1228,6 +1270,7 @@ discard block |
||
1228 | 1270 | 'attachment_type' => 3, |
1229 | 1271 | ) |
1230 | 1272 | ); |
1273 | + } |
|
1231 | 1274 | |
1232 | 1275 | pauseAttachmentMaintenance($to_fix, $thumbnails); |
1233 | 1276 | } |
@@ -1272,13 +1315,14 @@ discard block |
||
1272 | 1315 | $to_update[] = $row['id_attach']; |
1273 | 1316 | $context['repair_errors']['parent_missing_thumbnail']++; |
1274 | 1317 | } |
1275 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
1276 | - $to_fix[] = 'parent_missing_thumbnail'; |
|
1318 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
1319 | + $to_fix[] = 'parent_missing_thumbnail'; |
|
1320 | + } |
|
1277 | 1321 | $smcFunc['db_free_result']($result); |
1278 | 1322 | |
1279 | 1323 | // Do we need to delete what we have? |
1280 | - if ($fix_errors && !empty($to_update) && in_array('parent_missing_thumbnail', $to_fix)) |
|
1281 | - $smcFunc['db_query']('', ' |
|
1324 | + if ($fix_errors && !empty($to_update) && in_array('parent_missing_thumbnail', $to_fix)) { |
|
1325 | + $smcFunc['db_query']('', ' |
|
1282 | 1326 | UPDATE {db_prefix}attachments |
1283 | 1327 | SET id_thumb = {int:no_thumb} |
1284 | 1328 | WHERE id_attach IN ({array_int:to_update})', |
@@ -1287,6 +1331,7 @@ discard block |
||
1287 | 1331 | 'no_thumb' => 0, |
1288 | 1332 | ) |
1289 | 1333 | ); |
1334 | + } |
|
1290 | 1335 | |
1291 | 1336 | pauseAttachmentMaintenance($to_fix, $thumbnails); |
1292 | 1337 | } |
@@ -1324,10 +1369,11 @@ discard block |
||
1324 | 1369 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
1325 | 1370 | { |
1326 | 1371 | // Get the filename. |
1327 | - if ($row['attachment_type'] == 1) |
|
1328 | - $filename = $modSettings['custom_avatar_dir'] . '/' . $row['filename']; |
|
1329 | - else |
|
1330 | - $filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']); |
|
1372 | + if ($row['attachment_type'] == 1) { |
|
1373 | + $filename = $modSettings['custom_avatar_dir'] . '/' . $row['filename']; |
|
1374 | + } else { |
|
1375 | + $filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']); |
|
1376 | + } |
|
1331 | 1377 | |
1332 | 1378 | // File doesn't exist? |
1333 | 1379 | if (!file_exists($filename)) |
@@ -1339,15 +1385,16 @@ discard block |
||
1339 | 1385 | $attachment_name = $row['id_attach'] . '_' . $row['file_hash'] . '.dat'; |
1340 | 1386 | |
1341 | 1387 | // Loop through the other folders. |
1342 | - foreach ($modSettings['attachmentUploadDir'] as $id => $dir) |
|
1343 | - if (file_exists($dir . '/' . $attachment_name)) |
|
1388 | + foreach ($modSettings['attachmentUploadDir'] as $id => $dir) { |
|
1389 | + if (file_exists($dir . '/' . $attachment_name)) |
|
1344 | 1390 | { |
1345 | 1391 | $context['repair_errors']['wrong_folder']++; |
1392 | + } |
|
1346 | 1393 | $errors_found[] = 'wrong_folder'; |
1347 | 1394 | |
1348 | 1395 | // Are we going to fix this now? |
1349 | - if ($fix_errors && in_array('wrong_folder', $to_fix)) |
|
1350 | - $smcFunc['db_query']('', ' |
|
1396 | + if ($fix_errors && in_array('wrong_folder', $to_fix)) { |
|
1397 | + $smcFunc['db_query']('', ' |
|
1351 | 1398 | UPDATE {db_prefix}attachments |
1352 | 1399 | SET id_folder = {int:new_folder} |
1353 | 1400 | WHERE id_attach = {int:id_attach}', |
@@ -1356,6 +1403,7 @@ discard block |
||
1356 | 1403 | 'id_attach' => $row['id_attach'], |
1357 | 1404 | ) |
1358 | 1405 | ); |
1406 | + } |
|
1359 | 1407 | |
1360 | 1408 | continue 2; |
1361 | 1409 | } |
@@ -1364,8 +1412,7 @@ discard block |
||
1364 | 1412 | $to_remove[] = $row['id_attach']; |
1365 | 1413 | $context['repair_errors']['file_missing_on_disk']++; |
1366 | 1414 | $errors_found[] = 'file_missing_on_disk'; |
1367 | - } |
|
1368 | - elseif (filesize($filename) == 0) |
|
1415 | + } elseif (filesize($filename) == 0) |
|
1369 | 1416 | { |
1370 | 1417 | $context['repair_errors']['file_size_of_zero']++; |
1371 | 1418 | $errors_found[] = 'file_size_of_zero'; |
@@ -1376,8 +1423,7 @@ discard block |
||
1376 | 1423 | $to_remove[] = $row['id_attach']; |
1377 | 1424 | @unlink($filename); |
1378 | 1425 | } |
1379 | - } |
|
1380 | - elseif (filesize($filename) != $row['size']) |
|
1426 | + } elseif (filesize($filename) != $row['size']) |
|
1381 | 1427 | { |
1382 | 1428 | $context['repair_errors']['file_wrong_size']++; |
1383 | 1429 | $errors_found[] = 'file_wrong_size'; |
@@ -1398,14 +1444,18 @@ discard block |
||
1398 | 1444 | } |
1399 | 1445 | } |
1400 | 1446 | |
1401 | - if (in_array('file_missing_on_disk', $errors_found)) |
|
1402 | - $to_fix[] = 'file_missing_on_disk'; |
|
1403 | - if (in_array('file_size_of_zero', $errors_found)) |
|
1404 | - $to_fix[] = 'file_size_of_zero'; |
|
1405 | - if (in_array('file_wrong_size', $errors_found)) |
|
1406 | - $to_fix[] = 'file_wrong_size'; |
|
1407 | - if (in_array('wrong_folder', $errors_found)) |
|
1408 | - $to_fix[] = 'wrong_folder'; |
|
1447 | + if (in_array('file_missing_on_disk', $errors_found)) { |
|
1448 | + $to_fix[] = 'file_missing_on_disk'; |
|
1449 | + } |
|
1450 | + if (in_array('file_size_of_zero', $errors_found)) { |
|
1451 | + $to_fix[] = 'file_size_of_zero'; |
|
1452 | + } |
|
1453 | + if (in_array('file_wrong_size', $errors_found)) { |
|
1454 | + $to_fix[] = 'file_wrong_size'; |
|
1455 | + } |
|
1456 | + if (in_array('wrong_folder', $errors_found)) { |
|
1457 | + $to_fix[] = 'wrong_folder'; |
|
1458 | + } |
|
1409 | 1459 | $smcFunc['db_free_result']($result); |
1410 | 1460 | |
1411 | 1461 | // Do we need to delete what we have? |
@@ -1475,20 +1525,22 @@ discard block |
||
1475 | 1525 | // If we are repairing remove the file from disk now. |
1476 | 1526 | if ($fix_errors && in_array('avatar_no_member', $to_fix)) |
1477 | 1527 | { |
1478 | - if ($row['attachment_type'] == 1) |
|
1479 | - $filename = $modSettings['custom_avatar_dir'] . '/' . $row['filename']; |
|
1480 | - else |
|
1481 | - $filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']); |
|
1528 | + if ($row['attachment_type'] == 1) { |
|
1529 | + $filename = $modSettings['custom_avatar_dir'] . '/' . $row['filename']; |
|
1530 | + } else { |
|
1531 | + $filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']); |
|
1532 | + } |
|
1482 | 1533 | @unlink($filename); |
1483 | 1534 | } |
1484 | 1535 | } |
1485 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
1486 | - $to_fix[] = 'avatar_no_member'; |
|
1536 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
1537 | + $to_fix[] = 'avatar_no_member'; |
|
1538 | + } |
|
1487 | 1539 | $smcFunc['db_free_result']($result); |
1488 | 1540 | |
1489 | 1541 | // Do we need to delete what we have? |
1490 | - if ($fix_errors && !empty($to_remove) && in_array('avatar_no_member', $to_fix)) |
|
1491 | - $smcFunc['db_query']('', ' |
|
1542 | + if ($fix_errors && !empty($to_remove) && in_array('avatar_no_member', $to_fix)) { |
|
1543 | + $smcFunc['db_query']('', ' |
|
1492 | 1544 | DELETE FROM {db_prefix}attachments |
1493 | 1545 | WHERE id_attach IN ({array_int:to_remove}) |
1494 | 1546 | AND id_member != {int:no_member} |
@@ -1499,6 +1551,7 @@ discard block |
||
1499 | 1551 | 'no_msg' => 0, |
1500 | 1552 | ) |
1501 | 1553 | ); |
1554 | + } |
|
1502 | 1555 | |
1503 | 1556 | pauseAttachmentMaintenance($to_fix, $thumbnails); |
1504 | 1557 | } |
@@ -1558,13 +1611,14 @@ discard block |
||
1558 | 1611 | @unlink($filename); |
1559 | 1612 | } |
1560 | 1613 | } |
1561 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
1562 | - $to_fix[] = 'attachment_no_msg'; |
|
1614 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
1615 | + $to_fix[] = 'attachment_no_msg'; |
|
1616 | + } |
|
1563 | 1617 | $smcFunc['db_free_result']($result); |
1564 | 1618 | |
1565 | 1619 | // Do we need to delete what we have? |
1566 | - if ($fix_errors && !empty($to_remove) && in_array('attachment_no_msg', $to_fix)) |
|
1567 | - $smcFunc['db_query']('', ' |
|
1620 | + if ($fix_errors && !empty($to_remove) && in_array('attachment_no_msg', $to_fix)) { |
|
1621 | + $smcFunc['db_query']('', ' |
|
1568 | 1622 | DELETE FROM {db_prefix}attachments |
1569 | 1623 | WHERE id_attach IN ({array_int:to_remove}) |
1570 | 1624 | AND id_member = {int:no_member} |
@@ -1575,6 +1629,7 @@ discard block |
||
1575 | 1629 | 'attach_thumb' => array(0,3), |
1576 | 1630 | ) |
1577 | 1631 | ); |
1632 | + } |
|
1578 | 1633 | |
1579 | 1634 | pauseAttachmentMaintenance($to_fix, $thumbnails); |
1580 | 1635 | } |
@@ -1598,8 +1653,9 @@ discard block |
||
1598 | 1653 | { |
1599 | 1654 | while ($file = readdir($dir)) |
1600 | 1655 | { |
1601 | - if (in_array($file, array('.', '..', '.htaccess', 'index.php'))) |
|
1602 | - continue; |
|
1656 | + if (in_array($file, array('.', '..', '.htaccess', 'index.php'))) { |
|
1657 | + continue; |
|
1658 | + } |
|
1603 | 1659 | |
1604 | 1660 | if ($files_checked <= $current_check) |
1605 | 1661 | { |
@@ -1607,8 +1663,9 @@ discard block |
||
1607 | 1663 | if (strpos($file, 'post_tmp_') !== false) |
1608 | 1664 | { |
1609 | 1665 | // Temp file is more than 5 hours old! |
1610 | - if (filemtime($attach_dir . '/' . $file) < time() - 18000) |
|
1611 | - @unlink($attach_dir . '/' . $file); |
|
1666 | + if (filemtime($attach_dir . '/' . $file) < time() - 18000) { |
|
1667 | + @unlink($attach_dir . '/' . $file); |
|
1668 | + } |
|
1612 | 1669 | } |
1613 | 1670 | // That should be an attachment, let's check if we have it in the database |
1614 | 1671 | elseif (strpos($file, '_') !== false) |
@@ -1630,8 +1687,7 @@ discard block |
||
1630 | 1687 | if ($fix_errors && in_array('files_without_attachment', $to_fix)) |
1631 | 1688 | { |
1632 | 1689 | @unlink($attach_dir . '/' . $file); |
1633 | - } |
|
1634 | - else |
|
1690 | + } else |
|
1635 | 1691 | { |
1636 | 1692 | $context['repair_errors']['files_without_attachment']++; |
1637 | 1693 | $to_fix[] = 'files_without_attachment'; |
@@ -1639,14 +1695,12 @@ discard block |
||
1639 | 1695 | } |
1640 | 1696 | $smcFunc['db_free_result']($request); |
1641 | 1697 | } |
1642 | - } |
|
1643 | - else |
|
1698 | + } else |
|
1644 | 1699 | { |
1645 | 1700 | if ($fix_errors && in_array('files_without_attachment', $to_fix)) |
1646 | 1701 | { |
1647 | 1702 | @unlink($attach_dir . '/' . $file); |
1648 | - } |
|
1649 | - else |
|
1703 | + } else |
|
1650 | 1704 | { |
1651 | 1705 | $context['repair_errors']['files_without_attachment']++; |
1652 | 1706 | $to_fix[] = 'files_without_attachment'; |
@@ -1655,8 +1709,9 @@ discard block |
||
1655 | 1709 | } |
1656 | 1710 | $current_check++; |
1657 | 1711 | $_GET['substep'] = $current_check; |
1658 | - if ($current_check - $files_checked >= $max_checks) |
|
1659 | - pauseAttachmentMaintenance($to_fix); |
|
1712 | + if ($current_check - $files_checked >= $max_checks) { |
|
1713 | + pauseAttachmentMaintenance($to_fix); |
|
1714 | + } |
|
1660 | 1715 | } |
1661 | 1716 | closedir($dir); |
1662 | 1717 | } |
@@ -1692,12 +1747,14 @@ discard block |
||
1692 | 1747 | |
1693 | 1748 | // Try get more time... |
1694 | 1749 | @set_time_limit(600); |
1695 | - if (function_exists('apache_reset_timeout')) |
|
1696 | - @apache_reset_timeout(); |
|
1750 | + if (function_exists('apache_reset_timeout')) { |
|
1751 | + @apache_reset_timeout(); |
|
1752 | + } |
|
1697 | 1753 | |
1698 | 1754 | // Have we already used our maximum time? |
1699 | - if ((time() - $time_start) < 3 || $context['starting_substep'] == $_GET['substep']) |
|
1700 | - return; |
|
1755 | + if ((time() - $time_start) < 3 || $context['starting_substep'] == $_GET['substep']) { |
|
1756 | + return; |
|
1757 | + } |
|
1701 | 1758 | |
1702 | 1759 | $context['continue_get_data'] = '?action=admin;area=manageattachments;sa=repair' . (isset($_GET['fixErrors']) ? ';fixErrors' : '') . ';step=' . $_GET['step'] . ';substep=' . $_GET['substep'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
1703 | 1760 | $context['page_title'] = $txt['not_done_title']; |
@@ -1709,10 +1766,11 @@ discard block |
||
1709 | 1766 | $context[$context['admin_menu_name']]['current_subsection'] = 'maintenance'; |
1710 | 1767 | |
1711 | 1768 | // Change these two if more steps are added! |
1712 | - if (empty($max_substep)) |
|
1713 | - $context['continue_percent'] = round(($_GET['step'] * 100) / 25); |
|
1714 | - else |
|
1715 | - $context['continue_percent'] = round(($_GET['step'] * 100 + ($_GET['substep'] * 100) / $max_substep) / 25); |
|
1769 | + if (empty($max_substep)) { |
|
1770 | + $context['continue_percent'] = round(($_GET['step'] * 100) / 25); |
|
1771 | + } else { |
|
1772 | + $context['continue_percent'] = round(($_GET['step'] * 100 + ($_GET['substep'] * 100) / $max_substep) / 25); |
|
1773 | + } |
|
1716 | 1774 | |
1717 | 1775 | // Never more than 100%! |
1718 | 1776 | $context['continue_percent'] = min($context['continue_percent'], 100); |
@@ -1754,15 +1812,17 @@ discard block |
||
1754 | 1812 | 'attachment_type' => 0, |
1755 | 1813 | ) |
1756 | 1814 | ); |
1757 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1758 | - $attachments[] = $row['id_attach']; |
|
1815 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1816 | + $attachments[] = $row['id_attach']; |
|
1817 | + } |
|
1759 | 1818 | $smcFunc['db_free_result']($request); |
1819 | + } elseif (!empty($_GET['aid'])) { |
|
1820 | + $attachments[] = (int) $_GET['aid']; |
|
1760 | 1821 | } |
1761 | - elseif (!empty($_GET['aid'])) |
|
1762 | - $attachments[] = (int) $_GET['aid']; |
|
1763 | 1822 | |
1764 | - if (empty($attachments)) |
|
1765 | - fatal_lang_error('no_access', false); |
|
1823 | + if (empty($attachments)) { |
|
1824 | + fatal_lang_error('no_access', false); |
|
1825 | + } |
|
1766 | 1826 | |
1767 | 1827 | // Now we have some ID's cleaned and ready to approve, but first - let's check we have permission! |
1768 | 1828 | $allowed_boards = boardsAllowedTo('approve_posts'); |
@@ -1795,17 +1855,18 @@ discard block |
||
1795 | 1855 | } |
1796 | 1856 | $smcFunc['db_free_result']($request); |
1797 | 1857 | |
1798 | - if (empty($attachments)) |
|
1799 | - fatal_lang_error('no_access', false); |
|
1858 | + if (empty($attachments)) { |
|
1859 | + fatal_lang_error('no_access', false); |
|
1860 | + } |
|
1800 | 1861 | |
1801 | 1862 | // Finally, we are there. Follow through! |
1802 | 1863 | if ($is_approve) |
1803 | 1864 | { |
1804 | 1865 | // Checked and deemed worthy. |
1805 | 1866 | ApproveAttachments($attachments); |
1867 | + } else { |
|
1868 | + removeAttachments(array('id_attach' => $attachments, 'do_logging' => true)); |
|
1806 | 1869 | } |
1807 | - else |
|
1808 | - removeAttachments(array('id_attach' => $attachments, 'do_logging' => true)); |
|
1809 | 1870 | |
1810 | 1871 | // Return to the topic.... |
1811 | 1872 | redirectexit($redirect); |
@@ -1821,8 +1882,9 @@ discard block |
||
1821 | 1882 | { |
1822 | 1883 | global $smcFunc; |
1823 | 1884 | |
1824 | - if (empty($attachments)) |
|
1825 | - return 0; |
|
1885 | + if (empty($attachments)) { |
|
1886 | + return 0; |
|
1887 | + } |
|
1826 | 1888 | |
1827 | 1889 | // For safety, check for thumbnails... |
1828 | 1890 | $request = $smcFunc['db_query']('', ' |
@@ -1841,15 +1903,17 @@ discard block |
||
1841 | 1903 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1842 | 1904 | { |
1843 | 1905 | // Update the thumbnail too... |
1844 | - if (!empty($row['id_thumb'])) |
|
1845 | - $attachments[] = $row['id_thumb']; |
|
1906 | + if (!empty($row['id_thumb'])) { |
|
1907 | + $attachments[] = $row['id_thumb']; |
|
1908 | + } |
|
1846 | 1909 | |
1847 | 1910 | $attachments[] = $row['id_attach']; |
1848 | 1911 | } |
1849 | 1912 | $smcFunc['db_free_result']($request); |
1850 | 1913 | |
1851 | - if (empty($attachments)) |
|
1852 | - return 0; |
|
1914 | + if (empty($attachments)) { |
|
1915 | + return 0; |
|
1916 | + } |
|
1853 | 1917 | |
1854 | 1918 | // Approving an attachment is not hard - it's easy. |
1855 | 1919 | $smcFunc['db_query']('', ' |
@@ -1875,14 +1939,15 @@ discard block |
||
1875 | 1939 | ) |
1876 | 1940 | ); |
1877 | 1941 | |
1878 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1879 | - logAction( |
|
1942 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1943 | + logAction( |
|
1880 | 1944 | 'approve_attach', |
1881 | 1945 | array( |
1882 | 1946 | 'message' => $row['id_msg'], |
1883 | 1947 | 'filename' => preg_replace('~&#(\\d{1,7}|x[0-9a-fA-F]{1,6});~', '&#\\1;', $smcFunc['htmlspecialchars']($row['filename'])), |
1884 | 1948 | ) |
1885 | 1949 | ); |
1950 | + } |
|
1886 | 1951 | $smcFunc['db_free_result']($request); |
1887 | 1952 | |
1888 | 1953 | // Remove from the approval queue. |
@@ -1905,11 +1970,11 @@ discard block |
||
1905 | 1970 | global $modSettings, $scripturl, $context, $txt, $sourcedir, $boarddir, $smcFunc, $settings; |
1906 | 1971 | |
1907 | 1972 | // Since this needs to be done eventually. |
1908 | - if (!isset($modSettings['attachment_basedirectories'])) |
|
1909 | - $modSettings['attachment_basedirectories'] = array(); |
|
1910 | - |
|
1911 | - elseif (!is_array($modSettings['attachment_basedirectories'])) |
|
1912 | - $modSettings['attachment_basedirectories'] = $smcFunc['json_decode']($modSettings['attachment_basedirectories'], true); |
|
1973 | + if (!isset($modSettings['attachment_basedirectories'])) { |
|
1974 | + $modSettings['attachment_basedirectories'] = array(); |
|
1975 | + } elseif (!is_array($modSettings['attachment_basedirectories'])) { |
|
1976 | + $modSettings['attachment_basedirectories'] = $smcFunc['json_decode']($modSettings['attachment_basedirectories'], true); |
|
1977 | + } |
|
1913 | 1978 | |
1914 | 1979 | $errors = array(); |
1915 | 1980 | |
@@ -1924,8 +1989,9 @@ discard block |
||
1924 | 1989 | { |
1925 | 1990 | $error = ''; |
1926 | 1991 | $id = (int) $id; |
1927 | - if ($id < 1) |
|
1928 | - continue; |
|
1992 | + if ($id < 1) { |
|
1993 | + continue; |
|
1994 | + } |
|
1929 | 1995 | |
1930 | 1996 | // Sorry, these dirs are NOT valid |
1931 | 1997 | $invalid_dirs = array($boarddir, $settings['default_theme_dir'], $sourcedir); |
@@ -1944,8 +2010,7 @@ discard block |
||
1944 | 2010 | { |
1945 | 2011 | $errors[] = $path . ': ' . $txt['attach_dir_duplicate_msg']; |
1946 | 2012 | continue; |
1947 | - } |
|
1948 | - elseif (empty($path)) |
|
2013 | + } elseif (empty($path)) |
|
1949 | 2014 | { |
1950 | 2015 | // Ignore this and set $id to one less |
1951 | 2016 | continue; |
@@ -1953,10 +2018,11 @@ discard block |
||
1953 | 2018 | |
1954 | 2019 | // OK, so let's try to create it then. |
1955 | 2020 | require_once($sourcedir . '/Subs-Attachments.php'); |
1956 | - if (automanage_attachments_create_directory($path)) |
|
1957 | - $_POST['current_dir'] = $modSettings['currentAttachmentUploadDir']; |
|
1958 | - else |
|
1959 | - $errors[] = $path . ': ' . $txt[$context['dir_creation_error']]; |
|
2021 | + if (automanage_attachments_create_directory($path)) { |
|
2022 | + $_POST['current_dir'] = $modSettings['currentAttachmentUploadDir']; |
|
2023 | + } else { |
|
2024 | + $errors[] = $path . ': ' . $txt[$context['dir_creation_error']]; |
|
2025 | + } |
|
1960 | 2026 | } |
1961 | 2027 | |
1962 | 2028 | // Changing a directory name? |
@@ -1969,8 +2035,7 @@ discard block |
||
1969 | 2035 | $errors[] = $path . ': ' . $txt['attach_dir_no_rename']; |
1970 | 2036 | $path = $modSettings['attachmentUploadDir'][$id]; |
1971 | 2037 | } |
1972 | - } |
|
1973 | - else |
|
2038 | + } else |
|
1974 | 2039 | { |
1975 | 2040 | $errors[] = $path . ': ' . $txt['attach_dir_exists_msg']; |
1976 | 2041 | $path = $modSettings['attachmentUploadDir'][$id]; |
@@ -1995,12 +2060,13 @@ discard block |
||
1995 | 2060 | $path = $modSettings['attachmentUploadDir'][$id]; |
1996 | 2061 | |
1997 | 2062 | // It's not a good idea to delete the current directory. |
1998 | - if ($id == (!empty($_POST['current_dir']) ? $_POST['current_dir'] : $modSettings['currentAttachmentUploadDir'])) |
|
1999 | - $errors[] = $path . ': ' . $txt['attach_dir_is_current']; |
|
2063 | + if ($id == (!empty($_POST['current_dir']) ? $_POST['current_dir'] : $modSettings['currentAttachmentUploadDir'])) { |
|
2064 | + $errors[] = $path . ': ' . $txt['attach_dir_is_current']; |
|
2065 | + } |
|
2000 | 2066 | // Or the current base directory |
2001 | - elseif (!empty($modSettings['basedirectory_for_attachments']) && $modSettings['basedirectory_for_attachments'] == $modSettings['attachmentUploadDir'][$id]) |
|
2002 | - $errors[] = $path . ': ' . $txt['attach_dir_is_current_bd']; |
|
2003 | - else |
|
2067 | + elseif (!empty($modSettings['basedirectory_for_attachments']) && $modSettings['basedirectory_for_attachments'] == $modSettings['attachmentUploadDir'][$id]) { |
|
2068 | + $errors[] = $path . ': ' . $txt['attach_dir_is_current_bd']; |
|
2069 | + } else |
|
2004 | 2070 | { |
2005 | 2071 | // Let's not try to delete a path with files in it. |
2006 | 2072 | $request = $smcFunc['db_query']('', ' |
@@ -2019,17 +2085,18 @@ discard block |
||
2019 | 2085 | if (!empty($modSettings['attachment_basedirectories'])) |
2020 | 2086 | { |
2021 | 2087 | // Count any sub-folders. |
2022 | - foreach ($modSettings['attachmentUploadDir'] as $sub) |
|
2023 | - if (strpos($sub, $path . DIRECTORY_SEPARATOR) !== false) |
|
2088 | + foreach ($modSettings['attachmentUploadDir'] as $sub) { |
|
2089 | + if (strpos($sub, $path . DIRECTORY_SEPARATOR) !== false) |
|
2024 | 2090 | $num_attach++; |
2091 | + } |
|
2025 | 2092 | } |
2026 | 2093 | |
2027 | 2094 | // It's safe to delete. So try to delete the folder also |
2028 | 2095 | if ($num_attach == 0) |
2029 | 2096 | { |
2030 | - if (is_dir($path)) |
|
2031 | - $doit = true; |
|
2032 | - elseif (is_dir($boarddir . DIRECTORY_SEPARATOR . $path)) |
|
2097 | + if (is_dir($path)) { |
|
2098 | + $doit = true; |
|
2099 | + } elseif (is_dir($boarddir . DIRECTORY_SEPARATOR . $path)) |
|
2033 | 2100 | { |
2034 | 2101 | $doit = true; |
2035 | 2102 | $path = $boarddir . DIRECTORY_SEPARATOR . $path; |
@@ -2039,8 +2106,9 @@ discard block |
||
2039 | 2106 | { |
2040 | 2107 | unlink($path . '/.htaccess'); |
2041 | 2108 | unlink($path . '/index.php'); |
2042 | - if (!@rmdir($path)) |
|
2043 | - $error = $path . ': ' . $txt['attach_dir_no_delete']; |
|
2109 | + if (!@rmdir($path)) { |
|
2110 | + $error = $path . ': ' . $txt['attach_dir_no_delete']; |
|
2111 | + } |
|
2044 | 2112 | } |
2045 | 2113 | |
2046 | 2114 | // Remove it from the base directory list. |
@@ -2050,14 +2118,15 @@ discard block |
||
2050 | 2118 | updateSettings(array('attachment_basedirectories' => $smcFunc['json_encode']($modSettings['attachment_basedirectories']))); |
2051 | 2119 | $modSettings['attachment_basedirectories'] = $smcFunc['json_decode']($modSettings['attachment_basedirectories'], true); |
2052 | 2120 | } |
2121 | + } else { |
|
2122 | + $error = $path . ': ' . $txt['attach_dir_no_remove']; |
|
2053 | 2123 | } |
2054 | - else |
|
2055 | - $error = $path . ': ' . $txt['attach_dir_no_remove']; |
|
2056 | 2124 | |
2057 | - if (empty($error)) |
|
2058 | - continue; |
|
2059 | - else |
|
2060 | - $errors[] = $error; |
|
2125 | + if (empty($error)) { |
|
2126 | + continue; |
|
2127 | + } else { |
|
2128 | + $errors[] = $error; |
|
2129 | + } |
|
2061 | 2130 | } |
2062 | 2131 | } |
2063 | 2132 | |
@@ -2065,23 +2134,26 @@ discard block |
||
2065 | 2134 | } |
2066 | 2135 | |
2067 | 2136 | // We need to make sure the current directory is right. |
2068 | - if (empty($_POST['current_dir']) && !empty($modSettings['currentAttachmentUploadDir'])) |
|
2069 | - $_POST['current_dir'] = $modSettings['currentAttachmentUploadDir']; |
|
2137 | + if (empty($_POST['current_dir']) && !empty($modSettings['currentAttachmentUploadDir'])) { |
|
2138 | + $_POST['current_dir'] = $modSettings['currentAttachmentUploadDir']; |
|
2139 | + } |
|
2070 | 2140 | |
2071 | 2141 | // Find the current directory if there's no value carried, |
2072 | 2142 | if (empty($_POST['current_dir']) || empty($new_dirs[$_POST['current_dir']])) |
2073 | 2143 | { |
2074 | - if (array_key_exists($modSettings['currentAttachmentUploadDir'], $modSettings['attachmentUploadDir'])) |
|
2075 | - $_POST['current_dir'] = $modSettings['currentAttachmentUploadDir']; |
|
2076 | - else |
|
2077 | - $_POST['current_dir'] = max(array_keys($modSettings['attachmentUploadDir'])); |
|
2144 | + if (array_key_exists($modSettings['currentAttachmentUploadDir'], $modSettings['attachmentUploadDir'])) { |
|
2145 | + $_POST['current_dir'] = $modSettings['currentAttachmentUploadDir']; |
|
2146 | + } else { |
|
2147 | + $_POST['current_dir'] = max(array_keys($modSettings['attachmentUploadDir'])); |
|
2148 | + } |
|
2078 | 2149 | } |
2079 | 2150 | |
2080 | 2151 | // If the user wishes to go back, update the last_dir array |
2081 | 2152 | if ($_POST['current_dir'] != $modSettings['currentAttachmentUploadDir'] && !empty($modSettings['last_attachments_directory']) && (isset($modSettings['last_attachments_directory'][$_POST['current_dir']]) || isset($modSettings['last_attachments_directory'][0]))) |
2082 | 2153 | { |
2083 | - if (!is_array($modSettings['last_attachments_directory'])) |
|
2084 | - $modSettings['last_attachments_directory'] = $smcFunc['json_decode']($modSettings['last_attachments_directory'], true); |
|
2154 | + if (!is_array($modSettings['last_attachments_directory'])) { |
|
2155 | + $modSettings['last_attachments_directory'] = $smcFunc['json_decode']($modSettings['last_attachments_directory'], true); |
|
2156 | + } |
|
2085 | 2157 | $num = substr(strrchr($modSettings['attachmentUploadDir'][$_POST['current_dir']], '_'), 1); |
2086 | 2158 | |
2087 | 2159 | if (is_numeric($num)) |
@@ -2089,16 +2161,18 @@ discard block |
||
2089 | 2161 | // Need to find the base folder. |
2090 | 2162 | $bid = -1; |
2091 | 2163 | $use_subdirectories_for_attachments = 0; |
2092 | - if (!empty($modSettings['attachment_basedirectories'])) |
|
2093 | - foreach ($modSettings['attachment_basedirectories'] as $bid => $base) |
|
2164 | + if (!empty($modSettings['attachment_basedirectories'])) { |
|
2165 | + foreach ($modSettings['attachment_basedirectories'] as $bid => $base) |
|
2094 | 2166 | if (strpos($modSettings['attachmentUploadDir'][$_POST['current_dir']], $base . DIRECTORY_SEPARATOR) !== false) |
2095 | 2167 | { |
2096 | 2168 | $use_subdirectories_for_attachments = 1; |
2169 | + } |
|
2097 | 2170 | break; |
2098 | 2171 | } |
2099 | 2172 | |
2100 | - if ($use_subdirectories_for_attachments == 0 && strpos($modSettings['attachmentUploadDir'][$_POST['current_dir']], $boarddir . DIRECTORY_SEPARATOR) !== false) |
|
2101 | - $bid = 0; |
|
2173 | + if ($use_subdirectories_for_attachments == 0 && strpos($modSettings['attachmentUploadDir'][$_POST['current_dir']], $boarddir . DIRECTORY_SEPARATOR) !== false) { |
|
2174 | + $bid = 0; |
|
2175 | + } |
|
2102 | 2176 | |
2103 | 2177 | $modSettings['last_attachments_directory'][$bid] = (int) $num; |
2104 | 2178 | $modSettings['basedirectory_for_attachments'] = !empty($modSettings['basedirectory_for_attachments']) ? $modSettings['basedirectory_for_attachments'] : ''; |
@@ -2117,8 +2191,8 @@ discard block |
||
2117 | 2191 | // We might need to reset the paths. This loop will just loop through once. |
2118 | 2192 | foreach ($new_dirs as $id => $dir) |
2119 | 2193 | { |
2120 | - if ($id != 1) |
|
2121 | - $smcFunc['db_query']('', ' |
|
2194 | + if ($id != 1) { |
|
2195 | + $smcFunc['db_query']('', ' |
|
2122 | 2196 | UPDATE {db_prefix}attachments |
2123 | 2197 | SET id_folder = {int:default_folder} |
2124 | 2198 | WHERE id_folder = {int:current_folder}', |
@@ -2127,14 +2201,14 @@ discard block |
||
2127 | 2201 | 'current_folder' => $id, |
2128 | 2202 | ) |
2129 | 2203 | ); |
2204 | + } |
|
2130 | 2205 | |
2131 | 2206 | $update = array( |
2132 | 2207 | 'currentAttachmentUploadDir' => 1, |
2133 | 2208 | 'attachmentUploadDir' => $smcFunc['json_encode'](array(1 => $dir)), |
2134 | 2209 | ); |
2135 | 2210 | } |
2136 | - } |
|
2137 | - else |
|
2211 | + } else |
|
2138 | 2212 | { |
2139 | 2213 | // Save it to the database. |
2140 | 2214 | $update = array( |
@@ -2143,11 +2217,13 @@ discard block |
||
2143 | 2217 | ); |
2144 | 2218 | } |
2145 | 2219 | |
2146 | - if (!empty($update)) |
|
2147 | - updateSettings($update); |
|
2220 | + if (!empty($update)) { |
|
2221 | + updateSettings($update); |
|
2222 | + } |
|
2148 | 2223 | |
2149 | - if (!empty($errors)) |
|
2150 | - $_SESSION['errors']['dir'] = $errors; |
|
2224 | + if (!empty($errors)) { |
|
2225 | + $_SESSION['errors']['dir'] = $errors; |
|
2226 | + } |
|
2151 | 2227 | |
2152 | 2228 | redirectexit('action=admin;area=manageattachments;sa=attachpaths;' . $context['session_var'] . '=' . $context['session_id']); |
2153 | 2229 | } |
@@ -2161,10 +2237,11 @@ discard block |
||
2161 | 2237 | $_POST['current_base_dir'] = isset($_POST['current_base_dir']) ? (int) $_POST['current_base_dir'] : 1; |
2162 | 2238 | if (empty($_POST['new_base_dir']) && !empty($_POST['current_base_dir'])) |
2163 | 2239 | { |
2164 | - if ($modSettings['basedirectory_for_attachments'] != $modSettings['attachmentUploadDir'][$_POST['current_base_dir']]) |
|
2165 | - $update = (array( |
|
2240 | + if ($modSettings['basedirectory_for_attachments'] != $modSettings['attachmentUploadDir'][$_POST['current_base_dir']]) { |
|
2241 | + $update = (array( |
|
2166 | 2242 | 'basedirectory_for_attachments' => $modSettings['attachmentUploadDir'][$_POST['current_base_dir']], |
2167 | 2243 | )); |
2244 | + } |
|
2168 | 2245 | } |
2169 | 2246 | |
2170 | 2247 | if (isset($_POST['base_dir'])) |
@@ -2212,13 +2289,15 @@ discard block |
||
2212 | 2289 | |
2213 | 2290 | if (!in_array($_POST['new_base_dir'], $modSettings['attachmentUploadDir'])) |
2214 | 2291 | { |
2215 | - if (!automanage_attachments_create_directory($_POST['new_base_dir'])) |
|
2216 | - $errors[] = $_POST['new_base_dir'] . ': ' . $txt['attach_dir_base_no_create']; |
|
2292 | + if (!automanage_attachments_create_directory($_POST['new_base_dir'])) { |
|
2293 | + $errors[] = $_POST['new_base_dir'] . ': ' . $txt['attach_dir_base_no_create']; |
|
2294 | + } |
|
2217 | 2295 | } |
2218 | 2296 | |
2219 | 2297 | $modSettings['currentAttachmentUploadDir'] = array_search($_POST['new_base_dir'], $modSettings['attachmentUploadDir']); |
2220 | - if (!in_array($_POST['new_base_dir'], $modSettings['attachment_basedirectories'])) |
|
2221 | - $modSettings['attachment_basedirectories'][$modSettings['currentAttachmentUploadDir']] = $_POST['new_base_dir']; |
|
2298 | + if (!in_array($_POST['new_base_dir'], $modSettings['attachment_basedirectories'])) { |
|
2299 | + $modSettings['attachment_basedirectories'][$modSettings['currentAttachmentUploadDir']] = $_POST['new_base_dir']; |
|
2300 | + } |
|
2222 | 2301 | ksort($modSettings['attachment_basedirectories']); |
2223 | 2302 | |
2224 | 2303 | $update = (array( |
@@ -2228,11 +2307,13 @@ discard block |
||
2228 | 2307 | )); |
2229 | 2308 | } |
2230 | 2309 | |
2231 | - if (!empty($errors)) |
|
2232 | - $_SESSION['errors']['base'] = $errors; |
|
2310 | + if (!empty($errors)) { |
|
2311 | + $_SESSION['errors']['base'] = $errors; |
|
2312 | + } |
|
2233 | 2313 | |
2234 | - if (!empty($update)) |
|
2235 | - updateSettings($update); |
|
2314 | + if (!empty($update)) { |
|
2315 | + updateSettings($update); |
|
2316 | + } |
|
2236 | 2317 | |
2237 | 2318 | redirectexit('action=admin;area=manageattachments;sa=attachpaths;' . $context['session_var'] . '=' . $context['session_id']); |
2238 | 2319 | } |
@@ -2242,13 +2323,15 @@ discard block |
||
2242 | 2323 | if (is_array($_SESSION['errors'])) |
2243 | 2324 | { |
2244 | 2325 | $errors = array(); |
2245 | - if (!empty($_SESSION['errors']['dir'])) |
|
2246 | - foreach ($_SESSION['errors']['dir'] as $error) |
|
2326 | + if (!empty($_SESSION['errors']['dir'])) { |
|
2327 | + foreach ($_SESSION['errors']['dir'] as $error) |
|
2247 | 2328 | $errors['dir'][] = $smcFunc['htmlspecialchars']($error, ENT_QUOTES); |
2329 | + } |
|
2248 | 2330 | |
2249 | - if (!empty($_SESSION['errors']['base'])) |
|
2250 | - foreach ($_SESSION['errors']['base'] as $error) |
|
2331 | + if (!empty($_SESSION['errors']['base'])) { |
|
2332 | + foreach ($_SESSION['errors']['base'] as $error) |
|
2251 | 2333 | $errors['base'][] = $smcFunc['htmlspecialchars']($error, ENT_QUOTES); |
2334 | + } |
|
2252 | 2335 | } |
2253 | 2336 | unset($_SESSION['errors']); |
2254 | 2337 | } |
@@ -2458,8 +2541,9 @@ discard block |
||
2458 | 2541 | foreach ($modSettings['attachmentUploadDir'] as $id => $dir) |
2459 | 2542 | { |
2460 | 2543 | // If there aren't any attachments in this directory this won't exist. |
2461 | - if (!isset($expected_files[$id])) |
|
2462 | - $expected_files[$id] = 0; |
|
2544 | + if (!isset($expected_files[$id])) { |
|
2545 | + $expected_files[$id] = 0; |
|
2546 | + } |
|
2463 | 2547 | |
2464 | 2548 | // Check if the directory is doing okay. |
2465 | 2549 | list ($status, $error, $files) = attachDirStatus($dir, $expected_files[$id]); |
@@ -2472,10 +2556,11 @@ discard block |
||
2472 | 2556 | $is_base_dir = in_array($dir, $modSettings['attachment_basedirectories']); |
2473 | 2557 | |
2474 | 2558 | // Count any sub-folders. |
2475 | - foreach ($modSettings['attachmentUploadDir'] as $sid => $sub) |
|
2476 | - if (strpos($sub, $dir . DIRECTORY_SEPARATOR) !== false) |
|
2559 | + foreach ($modSettings['attachmentUploadDir'] as $sid => $sub) { |
|
2560 | + if (strpos($sub, $dir . DIRECTORY_SEPARATOR) !== false) |
|
2477 | 2561 | { |
2478 | 2562 | $expected_files[$id]++; |
2563 | + } |
|
2479 | 2564 | $sub_dirs++; |
2480 | 2565 | } |
2481 | 2566 | } |
@@ -2493,8 +2578,8 @@ discard block |
||
2493 | 2578 | } |
2494 | 2579 | |
2495 | 2580 | // Just stick a new directory on at the bottom. |
2496 | - if (isset($_REQUEST['new_path'])) |
|
2497 | - $attachdirs[] = array( |
|
2581 | + if (isset($_REQUEST['new_path'])) { |
|
2582 | + $attachdirs[] = array( |
|
2498 | 2583 | 'id' => max(array_merge(array_keys($expected_files), array_keys($modSettings['attachmentUploadDir']))) + 1, |
2499 | 2584 | 'current' => false, |
2500 | 2585 | 'path' => '', |
@@ -2502,6 +2587,7 @@ discard block |
||
2502 | 2587 | 'num_files' => '', |
2503 | 2588 | 'status' => '', |
2504 | 2589 | ); |
2590 | + } |
|
2505 | 2591 | |
2506 | 2592 | return $attachdirs; |
2507 | 2593 | } |
@@ -2514,8 +2600,9 @@ discard block |
||
2514 | 2600 | { |
2515 | 2601 | global $modSettings, $txt; |
2516 | 2602 | |
2517 | - if (empty($modSettings['attachment_basedirectories'])) |
|
2518 | - return; |
|
2603 | + if (empty($modSettings['attachment_basedirectories'])) { |
|
2604 | + return; |
|
2605 | + } |
|
2519 | 2606 | |
2520 | 2607 | $basedirs = array(); |
2521 | 2608 | // Get a list of the base directories. |
@@ -2523,16 +2610,18 @@ discard block |
||
2523 | 2610 | { |
2524 | 2611 | // Loop through the attach directory array to count any sub-directories |
2525 | 2612 | $expected_dirs = 0; |
2526 | - foreach ($modSettings['attachmentUploadDir'] as $sid => $sub) |
|
2527 | - if (strpos($sub, $dir . DIRECTORY_SEPARATOR) !== false) |
|
2613 | + foreach ($modSettings['attachmentUploadDir'] as $sid => $sub) { |
|
2614 | + if (strpos($sub, $dir . DIRECTORY_SEPARATOR) !== false) |
|
2528 | 2615 | $expected_dirs++; |
2616 | + } |
|
2529 | 2617 | |
2530 | - if (!is_dir($dir)) |
|
2531 | - $status = 'does_not_exist'; |
|
2532 | - elseif (!is_writeable($dir)) |
|
2533 | - $status = 'not_writable'; |
|
2534 | - else |
|
2535 | - $status = 'ok'; |
|
2618 | + if (!is_dir($dir)) { |
|
2619 | + $status = 'does_not_exist'; |
|
2620 | + } elseif (!is_writeable($dir)) { |
|
2621 | + $status = 'not_writable'; |
|
2622 | + } else { |
|
2623 | + $status = 'ok'; |
|
2624 | + } |
|
2536 | 2625 | |
2537 | 2626 | $basedirs[] = array( |
2538 | 2627 | 'id' => $id, |
@@ -2543,14 +2632,15 @@ discard block |
||
2543 | 2632 | ); |
2544 | 2633 | } |
2545 | 2634 | |
2546 | - if (isset($_REQUEST['new_base_path'])) |
|
2547 | - $basedirs[] = array( |
|
2635 | + if (isset($_REQUEST['new_base_path'])) { |
|
2636 | + $basedirs[] = array( |
|
2548 | 2637 | 'id' => '', |
2549 | 2638 | 'current' => false, |
2550 | 2639 | 'path' => '<input type="text" name="new_base_dir" value="" size="40">', |
2551 | 2640 | 'num_dirs' => '', |
2552 | 2641 | 'status' => '', |
2553 | 2642 | ); |
2643 | + } |
|
2554 | 2644 | |
2555 | 2645 | return $basedirs; |
2556 | 2646 | } |
@@ -2566,10 +2656,11 @@ discard block |
||
2566 | 2656 | */ |
2567 | 2657 | function attachDirStatus($dir, $expected_files) |
2568 | 2658 | { |
2569 | - if (!is_dir($dir)) |
|
2570 | - return array('does_not_exist', true, ''); |
|
2571 | - elseif (!is_writable($dir)) |
|
2572 | - return array('not_writable', true, ''); |
|
2659 | + if (!is_dir($dir)) { |
|
2660 | + return array('does_not_exist', true, ''); |
|
2661 | + } elseif (!is_writable($dir)) { |
|
2662 | + return array('not_writable', true, ''); |
|
2663 | + } |
|
2573 | 2664 | |
2574 | 2665 | // Everything is okay so far, start to scan through the directory. |
2575 | 2666 | $num_files = 0; |
@@ -2577,22 +2668,26 @@ discard block |
||
2577 | 2668 | while ($file = $dir_handle->read()) |
2578 | 2669 | { |
2579 | 2670 | // Now do we have a real file here? |
2580 | - if (in_array($file, array('.', '..', '.htaccess', 'index.php'))) |
|
2581 | - continue; |
|
2671 | + if (in_array($file, array('.', '..', '.htaccess', 'index.php'))) { |
|
2672 | + continue; |
|
2673 | + } |
|
2582 | 2674 | |
2583 | 2675 | $num_files++; |
2584 | 2676 | } |
2585 | 2677 | $dir_handle->close(); |
2586 | 2678 | |
2587 | - if ($num_files < $expected_files) |
|
2588 | - return array('files_missing', true, $num_files); |
|
2679 | + if ($num_files < $expected_files) { |
|
2680 | + return array('files_missing', true, $num_files); |
|
2681 | + } |
|
2589 | 2682 | // Empty? |
2590 | - elseif ($expected_files == 0) |
|
2591 | - return array('unused', false, $num_files); |
|
2683 | + elseif ($expected_files == 0) { |
|
2684 | + return array('unused', false, $num_files); |
|
2685 | + } |
|
2592 | 2686 | // All good! |
2593 | - else |
|
2594 | - return array('ok', false, $num_files); |
|
2595 | -} |
|
2687 | + else { |
|
2688 | + return array('ok', false, $num_files); |
|
2689 | + } |
|
2690 | + } |
|
2596 | 2691 | |
2597 | 2692 | /** |
2598 | 2693 | * Maintance function to move attachments from one directory to another |
@@ -2604,10 +2699,11 @@ discard block |
||
2604 | 2699 | checkSession(); |
2605 | 2700 | |
2606 | 2701 | $modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true); |
2607 | - if (!empty($modSettings['attachment_basedirectories'])) |
|
2608 | - $modSettings['attachment_basedirectories'] = $smcFunc['json_decode']($modSettings['attachment_basedirectories'], true); |
|
2609 | - else |
|
2610 | - $modSettings['basedirectory_for_attachments'] = array(); |
|
2702 | + if (!empty($modSettings['attachment_basedirectories'])) { |
|
2703 | + $modSettings['attachment_basedirectories'] = $smcFunc['json_decode']($modSettings['attachment_basedirectories'], true); |
|
2704 | + } else { |
|
2705 | + $modSettings['basedirectory_for_attachments'] = array(); |
|
2706 | + } |
|
2611 | 2707 | |
2612 | 2708 | $_POST['from'] = (int) $_POST['from']; |
2613 | 2709 | $_POST['auto'] = !empty($_POST['auto']) ? (int) $_POST['auto'] : 0; |
@@ -2621,11 +2717,13 @@ discard block |
||
2621 | 2717 | $total_moved = 0; |
2622 | 2718 | $total_not_moved = 0; |
2623 | 2719 | |
2624 | - if (empty($_POST['from']) || (empty($_POST['auto']) && empty($_POST['to']))) |
|
2625 | - $results[] = $txt['attachment_transfer_no_dir']; |
|
2720 | + if (empty($_POST['from']) || (empty($_POST['auto']) && empty($_POST['to']))) { |
|
2721 | + $results[] = $txt['attachment_transfer_no_dir']; |
|
2722 | + } |
|
2626 | 2723 | |
2627 | - if ($_POST['from'] == $_POST['to']) |
|
2628 | - $results[] = $txt['attachment_transfer_same_dir']; |
|
2724 | + if ($_POST['from'] == $_POST['to']) { |
|
2725 | + $results[] = $txt['attachment_transfer_same_dir']; |
|
2726 | + } |
|
2629 | 2727 | |
2630 | 2728 | if (empty($results)) |
2631 | 2729 | { |
@@ -2644,8 +2742,9 @@ discard block |
||
2644 | 2742 | $smcFunc['db_free_result']($request); |
2645 | 2743 | $total_progress -= $start; |
2646 | 2744 | |
2647 | - if ($total_progress < 1) |
|
2648 | - $results[] = $txt['attachment_transfer_no_find']; |
|
2745 | + if ($total_progress < 1) { |
|
2746 | + $results[] = $txt['attachment_transfer_no_find']; |
|
2747 | + } |
|
2649 | 2748 | } |
2650 | 2749 | |
2651 | 2750 | if (empty($results)) |
@@ -2661,9 +2760,9 @@ discard block |
||
2661 | 2760 | |
2662 | 2761 | automanage_attachments_check_directory(); |
2663 | 2762 | $new_dir = $modSettings['currentAttachmentUploadDir']; |
2763 | + } else { |
|
2764 | + $new_dir = $_POST['to']; |
|
2664 | 2765 | } |
2665 | - else |
|
2666 | - $new_dir = $_POST['to']; |
|
2667 | 2766 | |
2668 | 2767 | $modSettings['currentAttachmentUploadDir'] = $new_dir; |
2669 | 2768 | |
@@ -2671,8 +2770,9 @@ discard block |
||
2671 | 2770 | while ($break == false) |
2672 | 2771 | { |
2673 | 2772 | @set_time_limit(300); |
2674 | - if (function_exists('apache_reset_timeout')) |
|
2675 | - @apache_reset_timeout(); |
|
2773 | + if (function_exists('apache_reset_timeout')) { |
|
2774 | + @apache_reset_timeout(); |
|
2775 | + } |
|
2676 | 2776 | |
2677 | 2777 | // If limits are set, get the file count and size for the destination folder |
2678 | 2778 | if ($dir_files <= 0 && (!empty($modSettings['attachmentDirSizeLimit']) || !empty($modSettings['attachmentDirFileLimit']))) |
@@ -2708,13 +2808,15 @@ discard block |
||
2708 | 2808 | |
2709 | 2809 | if ($smcFunc['db_num_rows']($request) === 0) |
2710 | 2810 | { |
2711 | - if (empty($current_progress)) |
|
2712 | - $results[] = $txt['attachment_transfer_no_find']; |
|
2811 | + if (empty($current_progress)) { |
|
2812 | + $results[] = $txt['attachment_transfer_no_find']; |
|
2813 | + } |
|
2713 | 2814 | break; |
2714 | 2815 | } |
2715 | 2816 | |
2716 | - if ($smcFunc['db_num_rows']($request) < $limit) |
|
2717 | - $break = true; |
|
2817 | + if ($smcFunc['db_num_rows']($request) < $limit) { |
|
2818 | + $break = true; |
|
2819 | + } |
|
2718 | 2820 | |
2719 | 2821 | // Move them |
2720 | 2822 | $moved = array(); |
@@ -2738,8 +2840,9 @@ discard block |
||
2738 | 2840 | automanage_attachments_by_space(); |
2739 | 2841 | |
2740 | 2842 | $results[] = sprintf($txt['attachments_transferred'], $total_moved, $modSettings['attachmentUploadDir'][$new_dir]); |
2741 | - if (!empty($total_not_moved)) |
|
2742 | - $results[] = sprintf($txt['attachments_not_transferred'], $total_not_moved); |
|
2843 | + if (!empty($total_not_moved)) { |
|
2844 | + $results[] = sprintf($txt['attachments_not_transferred'], $total_not_moved); |
|
2845 | + } |
|
2743 | 2846 | |
2744 | 2847 | $dir_files = 0; |
2745 | 2848 | $total_moved = 0; |
@@ -2747,8 +2850,7 @@ discard block |
||
2747 | 2850 | |
2748 | 2851 | $break = false; |
2749 | 2852 | break; |
2750 | - } |
|
2751 | - else |
|
2853 | + } else |
|
2752 | 2854 | { |
2753 | 2855 | // Hmm, not in auto. Time to bail out then... |
2754 | 2856 | $results[] = $txt['attachment_transfer_no_room']; |
@@ -2763,9 +2865,9 @@ discard block |
||
2763 | 2865 | $total_moved++; |
2764 | 2866 | $current_progress++; |
2765 | 2867 | $moved[] = $row['id_attach']; |
2868 | + } else { |
|
2869 | + $total_not_moved++; |
|
2766 | 2870 | } |
2767 | - else |
|
2768 | - $total_not_moved++; |
|
2769 | 2871 | } |
2770 | 2872 | $smcFunc['db_free_result']($request); |
2771 | 2873 | |
@@ -2803,13 +2905,15 @@ discard block |
||
2803 | 2905 | } |
2804 | 2906 | |
2805 | 2907 | $results[] = sprintf($txt['attachments_transferred'], $total_moved, $modSettings['attachmentUploadDir'][$new_dir]); |
2806 | - if (!empty($total_not_moved)) |
|
2807 | - $results[] = sprintf($txt['attachments_not_transferred'], $total_not_moved); |
|
2908 | + if (!empty($total_not_moved)) { |
|
2909 | + $results[] = sprintf($txt['attachments_not_transferred'], $total_not_moved); |
|
2910 | + } |
|
2808 | 2911 | } |
2809 | 2912 | |
2810 | 2913 | $_SESSION['results'] = $results; |
2811 | - if (file_exists($boarddir . '/progress.php')) |
|
2812 | - unlink($boarddir . '/progress.php'); |
|
2914 | + if (file_exists($boarddir . '/progress.php')) { |
|
2915 | + unlink($boarddir . '/progress.php'); |
|
2916 | + } |
|
2813 | 2917 | |
2814 | 2918 | redirectexit('action=admin;area=manageattachments;sa=maintenance#transfer'); |
2815 | 2919 | } |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Add the file functions to the $smcFunc array. |
@@ -53,8 +54,9 @@ discard block |
||
53 | 54 | 'messages', 'moderator_groups', 'moderators', 'package_servers', 'permission_profiles', 'permissions', 'personal_messages', |
54 | 55 | 'pm_labeled_messages', 'pm_labels', 'pm_recipients', 'pm_rules', 'poll_choices', 'polls', 'scheduled_tasks', 'sessions', 'settings', 'smileys', |
55 | 56 | 'spiders', 'subscriptions', 'themes', 'topics', 'user_alerts', 'user_alerts_prefs', 'user_drafts', 'user_likes'); |
56 | - foreach ($reservedTables as $k => $table_name) |
|
57 | - $reservedTables[$k] = strtolower($db_prefix . $table_name); |
|
57 | + foreach ($reservedTables as $k => $table_name) { |
|
58 | + $reservedTables[$k] = strtolower($db_prefix . $table_name); |
|
59 | + } |
|
58 | 60 | |
59 | 61 | // We in turn may need the extra stuff. |
60 | 62 | db_extend('extra'); |
@@ -109,8 +111,9 @@ discard block |
||
109 | 111 | $table_name = str_replace('{db_prefix}', $db_prefix, $table_name); |
110 | 112 | |
111 | 113 | // First - no way do we touch SMF tables. |
112 | - if (in_array(strtolower($table_name), $reservedTables)) |
|
113 | - return false; |
|
114 | + if (in_array(strtolower($table_name), $reservedTables)) { |
|
115 | + return false; |
|
116 | + } |
|
114 | 117 | |
115 | 118 | // Log that we'll want to remove this on uninstall. |
116 | 119 | $db_package_log[] = array('remove_table', $table_name); |
@@ -120,9 +123,9 @@ discard block |
||
120 | 123 | if (in_array($full_table_name, $tables)) |
121 | 124 | { |
122 | 125 | // This is a sad day... drop the table? If not, return false (error) by default. |
123 | - if ($if_exists == 'overwrite') |
|
124 | - $smcFunc['db_drop_table']($table_name); |
|
125 | - else if ($if_exists == 'update') |
|
126 | + if ($if_exists == 'overwrite') { |
|
127 | + $smcFunc['db_drop_table']($table_name); |
|
128 | + } else if ($if_exists == 'update') |
|
126 | 129 | { |
127 | 130 | $smcFunc['db_transaction']('begin'); |
128 | 131 | $db_trans = true; |
@@ -134,15 +137,16 @@ discard block |
||
134 | 137 | ) |
135 | 138 | ); |
136 | 139 | $old_table_exists = true; |
140 | + } else { |
|
141 | + return $if_exists == 'ignore'; |
|
137 | 142 | } |
138 | - else |
|
139 | - return $if_exists == 'ignore'; |
|
140 | 143 | } |
141 | 144 | |
142 | 145 | // Righty - let's do the damn thing! |
143 | 146 | $table_query = 'CREATE TABLE ' . $table_name . "\n" . '('; |
144 | - foreach ($columns as $column) |
|
145 | - $table_query .= "\n\t" . smf_db_create_query_column($column) . ','; |
|
147 | + foreach ($columns as $column) { |
|
148 | + $table_query .= "\n\t" . smf_db_create_query_column($column) . ','; |
|
149 | + } |
|
146 | 150 | |
147 | 151 | // Loop through the indexes next... |
148 | 152 | foreach ($indexes as $index) |
@@ -150,19 +154,21 @@ discard block |
||
150 | 154 | $columns = implode(',', $index['columns']); |
151 | 155 | |
152 | 156 | // Is it the primary? |
153 | - if (isset($index['type']) && $index['type'] == 'primary') |
|
154 | - $table_query .= "\n\t" . 'PRIMARY KEY (' . implode(',', $index['columns']) . '),'; |
|
155 | - else |
|
157 | + if (isset($index['type']) && $index['type'] == 'primary') { |
|
158 | + $table_query .= "\n\t" . 'PRIMARY KEY (' . implode(',', $index['columns']) . '),'; |
|
159 | + } else |
|
156 | 160 | { |
157 | - if (empty($index['name'])) |
|
158 | - $index['name'] = implode('_', $index['columns']); |
|
161 | + if (empty($index['name'])) { |
|
162 | + $index['name'] = implode('_', $index['columns']); |
|
163 | + } |
|
159 | 164 | $table_query .= "\n\t" . (isset($index['type']) && $index['type'] == 'unique' ? 'UNIQUE' : 'KEY') . ' ' . $index['name'] . ' (' . $columns . '),'; |
160 | 165 | } |
161 | 166 | } |
162 | 167 | |
163 | 168 | // No trailing commas! |
164 | - if (substr($table_query, -1) == ',') |
|
165 | - $table_query = substr($table_query, 0, -1); |
|
169 | + if (substr($table_query, -1) == ',') { |
|
170 | + $table_query = substr($table_query, 0, -1); |
|
171 | + } |
|
166 | 172 | |
167 | 173 | // Which engine do we want here? |
168 | 174 | if (empty($engines)) |
@@ -172,8 +178,9 @@ discard block |
||
172 | 178 | |
173 | 179 | while ($row = $smcFunc['db_fetch_assoc']($get_engines)) |
174 | 180 | { |
175 | - if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') |
|
176 | - $engines[] = $row['Engine']; |
|
181 | + if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') { |
|
182 | + $engines[] = $row['Engine']; |
|
183 | + } |
|
177 | 184 | } |
178 | 185 | |
179 | 186 | $smcFunc['db_free_result']($get_engines); |
@@ -187,8 +194,9 @@ discard block |
||
187 | 194 | } |
188 | 195 | |
189 | 196 | $table_query .= ') ENGINE=' . $parameters['engine']; |
190 | - if (!empty($db_character_set) && $db_character_set == 'utf8') |
|
191 | - $table_query .= ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
197 | + if (!empty($db_character_set) && $db_character_set == 'utf8') { |
|
198 | + $table_query .= ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
199 | + } |
|
192 | 200 | |
193 | 201 | // Create the table! |
194 | 202 | $smcFunc['db_query']('', $table_query, |
@@ -255,8 +263,9 @@ discard block |
||
255 | 263 | $table_name = str_replace('{db_prefix}', $db_prefix, $table_name); |
256 | 264 | |
257 | 265 | // God no - dropping one of these = bad. |
258 | - if (in_array(strtolower($table_name), $reservedTables)) |
|
259 | - return false; |
|
266 | + if (in_array(strtolower($table_name), $reservedTables)) { |
|
267 | + return false; |
|
268 | + } |
|
260 | 269 | |
261 | 270 | // Does it exist? |
262 | 271 | if (in_array($full_table_name, $smcFunc['db_list_tables']())) |
@@ -297,14 +306,16 @@ discard block |
||
297 | 306 | |
298 | 307 | // Does it exist - if so don't add it again! |
299 | 308 | $columns = $smcFunc['db_list_columns']($table_name, false); |
300 | - foreach ($columns as $column) |
|
301 | - if ($column == $column_info['name']) |
|
309 | + foreach ($columns as $column) { |
|
310 | + if ($column == $column_info['name']) |
|
302 | 311 | { |
303 | 312 | // If we're going to overwrite then use change column. |
304 | 313 | if ($if_exists == 'update') |
305 | 314 | return $smcFunc['db_change_column']($table_name, $column_info['name'], $column_info); |
306 | - else |
|
307 | - return false; |
|
315 | + } |
|
316 | + else { |
|
317 | + return false; |
|
318 | + } |
|
308 | 319 | } |
309 | 320 | |
310 | 321 | // Get the specifics... |
@@ -340,8 +351,8 @@ discard block |
||
340 | 351 | |
341 | 352 | // Does it exist? |
342 | 353 | $columns = $smcFunc['db_list_columns']($table_name, true); |
343 | - foreach ($columns as $column) |
|
344 | - if ($column['name'] == $column_name) |
|
354 | + foreach ($columns as $column) { |
|
355 | + if ($column['name'] == $column_name) |
|
345 | 356 | { |
346 | 357 | $smcFunc['db_query']('', ' |
347 | 358 | ALTER TABLE ' . $table_name . ' |
@@ -350,6 +361,7 @@ discard block |
||
350 | 361 | 'security_override' => true, |
351 | 362 | ) |
352 | 363 | ); |
364 | + } |
|
353 | 365 | |
354 | 366 | return true; |
355 | 367 | } |
@@ -375,37 +387,47 @@ discard block |
||
375 | 387 | // Check it does exist! |
376 | 388 | $columns = $smcFunc['db_list_columns']($table_name, true); |
377 | 389 | $old_info = null; |
378 | - foreach ($columns as $column) |
|
379 | - if ($column['name'] == $old_column) |
|
390 | + foreach ($columns as $column) { |
|
391 | + if ($column['name'] == $old_column) |
|
380 | 392 | $old_info = $column; |
393 | + } |
|
381 | 394 | |
382 | 395 | // Nothing? |
383 | - if ($old_info == null) |
|
384 | - return false; |
|
396 | + if ($old_info == null) { |
|
397 | + return false; |
|
398 | + } |
|
385 | 399 | |
386 | 400 | // Get the right bits. |
387 | - if (!isset($column_info['name'])) |
|
388 | - $column_info['name'] = $old_column; |
|
389 | - if (!isset($column_info['default'])) |
|
390 | - $column_info['default'] = $old_info['default']; |
|
391 | - if (!isset($column_info['null'])) |
|
392 | - $column_info['null'] = $old_info['null']; |
|
393 | - if (!isset($column_info['auto'])) |
|
394 | - $column_info['auto'] = $old_info['auto']; |
|
395 | - if (!isset($column_info['type'])) |
|
396 | - $column_info['type'] = $old_info['type']; |
|
397 | - if (!isset($column_info['size']) || !is_numeric($column_info['size'])) |
|
398 | - $column_info['size'] = $old_info['size']; |
|
399 | - if (!isset($column_info['unsigned']) || !in_array($column_info['type'], array('int', 'tinyint', 'smallint', 'mediumint', 'bigint'))) |
|
400 | - $column_info['unsigned'] = ''; |
|
401 | + if (!isset($column_info['name'])) { |
|
402 | + $column_info['name'] = $old_column; |
|
403 | + } |
|
404 | + if (!isset($column_info['default'])) { |
|
405 | + $column_info['default'] = $old_info['default']; |
|
406 | + } |
|
407 | + if (!isset($column_info['null'])) { |
|
408 | + $column_info['null'] = $old_info['null']; |
|
409 | + } |
|
410 | + if (!isset($column_info['auto'])) { |
|
411 | + $column_info['auto'] = $old_info['auto']; |
|
412 | + } |
|
413 | + if (!isset($column_info['type'])) { |
|
414 | + $column_info['type'] = $old_info['type']; |
|
415 | + } |
|
416 | + if (!isset($column_info['size']) || !is_numeric($column_info['size'])) { |
|
417 | + $column_info['size'] = $old_info['size']; |
|
418 | + } |
|
419 | + if (!isset($column_info['unsigned']) || !in_array($column_info['type'], array('int', 'tinyint', 'smallint', 'mediumint', 'bigint'))) { |
|
420 | + $column_info['unsigned'] = ''; |
|
421 | + } |
|
401 | 422 | |
402 | 423 | list ($type, $size) = $smcFunc['db_calculate_type']($column_info['type'], $column_info['size']); |
403 | 424 | |
404 | 425 | // Allow for unsigned integers (mysql only) |
405 | 426 | $unsigned = in_array($type, array('int', 'tinyint', 'smallint', 'mediumint', 'bigint')) && !empty($column_info['unsigned']) ? 'unsigned ' : ''; |
406 | 427 | |
407 | - if ($size !== null) |
|
408 | - $type = $type . '(' . $size . ')'; |
|
428 | + if ($size !== null) { |
|
429 | + $type = $type . '(' . $size . ')'; |
|
430 | + } |
|
409 | 431 | |
410 | 432 | $smcFunc['db_query']('', ' |
411 | 433 | ALTER TABLE ' . $table_name . ' |
@@ -435,18 +457,20 @@ discard block |
||
435 | 457 | $table_name = str_replace('{db_prefix}', $db_prefix, $table_name); |
436 | 458 | |
437 | 459 | // No columns = no index. |
438 | - if (empty($index_info['columns'])) |
|
439 | - return false; |
|
460 | + if (empty($index_info['columns'])) { |
|
461 | + return false; |
|
462 | + } |
|
440 | 463 | $columns = implode(',', $index_info['columns']); |
441 | 464 | |
442 | 465 | // No name - make it up! |
443 | 466 | if (empty($index_info['name'])) |
444 | 467 | { |
445 | 468 | // No need for primary. |
446 | - if (isset($index_info['type']) && $index_info['type'] == 'primary') |
|
447 | - $index_info['name'] = ''; |
|
448 | - else |
|
449 | - $index_info['name'] = implode('_', $index_info['columns']); |
|
469 | + if (isset($index_info['type']) && $index_info['type'] == 'primary') { |
|
470 | + $index_info['name'] = ''; |
|
471 | + } else { |
|
472 | + $index_info['name'] = implode('_', $index_info['columns']); |
|
473 | + } |
|
450 | 474 | } |
451 | 475 | |
452 | 476 | // Log that we are going to want to remove this! |
@@ -460,10 +484,11 @@ discard block |
||
460 | 484 | if ($index['name'] == $index_info['name'] || ($index['type'] == 'primary' && isset($index_info['type']) && $index_info['type'] == 'primary')) |
461 | 485 | { |
462 | 486 | // If we want to overwrite simply remove the current one then continue. |
463 | - if ($if_exists != 'update' || $index['type'] == 'primary') |
|
464 | - return false; |
|
465 | - else |
|
466 | - $smcFunc['db_remove_index']($table_name, $index_info['name']); |
|
487 | + if ($if_exists != 'update' || $index['type'] == 'primary') { |
|
488 | + return false; |
|
489 | + } else { |
|
490 | + $smcFunc['db_remove_index']($table_name, $index_info['name']); |
|
491 | + } |
|
467 | 492 | } |
468 | 493 | } |
469 | 494 | |
@@ -477,8 +502,7 @@ discard block |
||
477 | 502 | 'security_override' => true, |
478 | 503 | ) |
479 | 504 | ); |
480 | - } |
|
481 | - else |
|
505 | + } else |
|
482 | 506 | { |
483 | 507 | $smcFunc['db_query']('', ' |
484 | 508 | ALTER TABLE ' . $table_name . ' |
@@ -562,8 +586,7 @@ discard block |
||
562 | 586 | $types = array( |
563 | 587 | 'inet' => 'varbinary', |
564 | 588 | ); |
565 | - } |
|
566 | - else |
|
589 | + } else |
|
567 | 590 | { |
568 | 591 | $types = array( |
569 | 592 | 'varbinary' => 'inet', |
@@ -577,16 +600,15 @@ discard block |
||
577 | 600 | { |
578 | 601 | $type_size = 16; |
579 | 602 | $type_name = 'varbinary'; |
580 | - } |
|
581 | - elseif ($type_name == 'varbinary' && $reverse && $type_size == 16) |
|
603 | + } elseif ($type_name == 'varbinary' && $reverse && $type_size == 16) |
|
582 | 604 | { |
583 | 605 | $type_name = 'inet'; |
584 | 606 | $type_size = null; |
607 | + } elseif ($type_name == 'varbinary') { |
|
608 | + $type_name = 'varbinary'; |
|
609 | + } else { |
|
610 | + $type_name = $types[$type_name]; |
|
585 | 611 | } |
586 | - elseif ($type_name == 'varbinary') |
|
587 | - $type_name = 'varbinary'; |
|
588 | - else |
|
589 | - $type_name = $types[$type_name]; |
|
590 | 612 | } |
591 | 613 | |
592 | 614 | return array($type_name, $type_size); |
@@ -653,8 +675,7 @@ discard block |
||
653 | 675 | if (!$detail) |
654 | 676 | { |
655 | 677 | $columns[] = $row['Field']; |
656 | - } |
|
657 | - else |
|
678 | + } else |
|
658 | 679 | { |
659 | 680 | // Is there an auto_increment? |
660 | 681 | $auto = strpos($row['Extra'], 'auto_increment') !== false ? true : false; |
@@ -664,10 +685,10 @@ discard block |
||
664 | 685 | { |
665 | 686 | $type = $matches[1]; |
666 | 687 | $size = $matches[2]; |
667 | - if (!empty($matches[3]) && $matches[3] == 'unsigned') |
|
668 | - $unsigned = true; |
|
669 | - } |
|
670 | - else |
|
688 | + if (!empty($matches[3]) && $matches[3] == 'unsigned') { |
|
689 | + $unsigned = true; |
|
690 | + } |
|
691 | + } else |
|
671 | 692 | { |
672 | 693 | $type = $row['Type']; |
673 | 694 | $size = null; |
@@ -718,19 +739,20 @@ discard block |
||
718 | 739 | $indexes = array(); |
719 | 740 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
720 | 741 | { |
721 | - if (!$detail) |
|
722 | - $indexes[] = $row['Key_name']; |
|
723 | - else |
|
742 | + if (!$detail) { |
|
743 | + $indexes[] = $row['Key_name']; |
|
744 | + } else |
|
724 | 745 | { |
725 | 746 | // What is the type? |
726 | - if ($row['Key_name'] == 'PRIMARY') |
|
727 | - $type = 'primary'; |
|
728 | - elseif (empty($row['Non_unique'])) |
|
729 | - $type = 'unique'; |
|
730 | - elseif (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT') |
|
731 | - $type = 'fulltext'; |
|
732 | - else |
|
733 | - $type = 'index'; |
|
747 | + if ($row['Key_name'] == 'PRIMARY') { |
|
748 | + $type = 'primary'; |
|
749 | + } elseif (empty($row['Non_unique'])) { |
|
750 | + $type = 'unique'; |
|
751 | + } elseif (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT') { |
|
752 | + $type = 'fulltext'; |
|
753 | + } else { |
|
754 | + $type = 'index'; |
|
755 | + } |
|
734 | 756 | |
735 | 757 | // This is the first column we've seen? |
736 | 758 | if (empty($indexes[$row['Key_name']])) |
@@ -743,10 +765,11 @@ discard block |
||
743 | 765 | } |
744 | 766 | |
745 | 767 | // Is it a partial index? |
746 | - if (!empty($row['Sub_part'])) |
|
747 | - $indexes[$row['Key_name']]['columns'][] = $row['Column_name'] . '(' . $row['Sub_part'] . ')'; |
|
748 | - else |
|
749 | - $indexes[$row['Key_name']]['columns'][] = $row['Column_name']; |
|
768 | + if (!empty($row['Sub_part'])) { |
|
769 | + $indexes[$row['Key_name']]['columns'][] = $row['Column_name'] . '(' . $row['Sub_part'] . ')'; |
|
770 | + } else { |
|
771 | + $indexes[$row['Key_name']]['columns'][] = $row['Column_name']; |
|
772 | + } |
|
750 | 773 | } |
751 | 774 | } |
752 | 775 | $smcFunc['db_free_result']($result); |
@@ -768,11 +791,11 @@ discard block |
||
768 | 791 | if (!empty($column['auto'])) |
769 | 792 | { |
770 | 793 | $default = 'auto_increment'; |
794 | + } elseif (isset($column['default']) && $column['default'] !== null) { |
|
795 | + $default = 'default \'' . $smcFunc['db_escape_string']($column['default']) . '\''; |
|
796 | + } else { |
|
797 | + $default = ''; |
|
771 | 798 | } |
772 | - elseif (isset($column['default']) && $column['default'] !== null) |
|
773 | - $default = 'default \'' . $smcFunc['db_escape_string']($column['default']) . '\''; |
|
774 | - else |
|
775 | - $default = ''; |
|
776 | 799 | |
777 | 800 | // Sort out the size... and stuff... |
778 | 801 | $column['size'] = isset($column['size']) && is_numeric($column['size']) ? $column['size'] : null; |
@@ -781,8 +804,9 @@ discard block |
||
781 | 804 | // Allow unsigned integers (mysql only) |
782 | 805 | $unsigned = in_array($type, array('int', 'tinyint', 'smallint', 'mediumint', 'bigint')) && !empty($column['unsigned']) ? 'unsigned ' : ''; |
783 | 806 | |
784 | - if ($size !== null) |
|
785 | - $type = $type . '(' . $size . ')'; |
|
807 | + if ($size !== null) { |
|
808 | + $type = $type . '(' . $size . ')'; |
|
809 | + } |
|
786 | 810 | |
787 | 811 | // Now just put it together! |
788 | 812 | return '`' . $column['name'] . '` ' . $type . ' ' . (!empty($unsigned) ? $unsigned : '') . (!empty($column['null']) ? '' : 'NOT NULL') . ' ' . $default; |
@@ -148,8 +148,8 @@ discard block |
||
148 | 148 | </thead> |
149 | 149 | <tbody>'; |
150 | 150 | |
151 | - foreach ($context['membergroups'] as $membergroup) |
|
152 | - echo ' |
|
151 | + foreach ($context['membergroups'] as $membergroup) { |
|
152 | + echo ' |
|
153 | 153 | <tr class="windowbg"> |
154 | 154 | <td>', $membergroup['name'], '</td> |
155 | 155 | <td class="centercol"> |
@@ -159,6 +159,7 @@ discard block |
||
159 | 159 | ', $membergroup['can_be_additional'] ? '<input type="checkbox" name="membergroups[2][]" value="' . $membergroup['id'] . '" checked>' : '', ' |
160 | 160 | </td> |
161 | 161 | </tr>'; |
162 | + } |
|
162 | 163 | |
163 | 164 | echo ' |
164 | 165 | <tr class="windowbg"> |
@@ -185,8 +186,8 @@ discard block |
||
185 | 186 | </thead> |
186 | 187 | <tbody>'; |
187 | 188 | |
188 | - foreach ($context['postgroups'] as $postgroup) |
|
189 | - echo ' |
|
189 | + foreach ($context['postgroups'] as $postgroup) { |
|
190 | + echo ' |
|
190 | 191 | <tr class="windowbg"> |
191 | 192 | <td> |
192 | 193 | ', $postgroup['name'], ' |
@@ -195,6 +196,7 @@ discard block |
||
195 | 196 | <input type="checkbox" name="postgroups[]" value="', $postgroup['id'], '" checked> |
196 | 197 | </td> |
197 | 198 | </tr>'; |
199 | + } |
|
198 | 200 | |
199 | 201 | echo ' |
200 | 202 | <tr class="windowbg"> |
@@ -144,11 +144,12 @@ discard block |
||
144 | 144 | <div class="question">', $txt['poll_question'], ': <strong>', $context['poll']['question'], '</strong>'; |
145 | 145 | |
146 | 146 | $options = 1; |
147 | - foreach ($context['poll']['options'] as $option) |
|
148 | - echo ' |
|
147 | + foreach ($context['poll']['options'] as $option) { |
|
148 | + echo ' |
|
149 | 149 | <div class="', $option['voted_this'] ? 'voted' : '', '">', $txt['option'], ' ', $options++, ': <strong>', $option['option'], '</strong> |
150 | 150 | ', $context['allow_poll_view'] ? $txt['votes'] . ': ' . $option['votes'] . '' : '', ' |
151 | 151 | </div>'; |
152 | + } |
|
152 | 153 | |
153 | 154 | echo ' |
154 | 155 | </div>'; |
@@ -170,9 +171,10 @@ discard block |
||
170 | 171 | echo ' |
171 | 172 | <hr>'; |
172 | 173 | |
173 | - foreach ($context['printattach'][$post['id_msg']] as $attach) |
|
174 | - echo ' |
|
174 | + foreach ($context['printattach'][$post['id_msg']] as $attach) { |
|
175 | + echo ' |
|
175 | 176 | <img width="' . $attach['width'] . '" height="' . $attach['height'] . '" src="', $scripturl . '?action=dlattach;topic=' . $topic . '.0;attach=' . $attach['id_attach'] . '" alt="">'; |
177 | + } |
|
176 | 178 | } |
177 | 179 | |
178 | 180 | echo ' |
@@ -207,12 +209,13 @@ discard block |
||
207 | 209 | <div class="print_options">'; |
208 | 210 | |
209 | 211 | // Which option is set, text or text&images |
210 | - if (isset($_REQUEST['images'])) |
|
211 | - echo ' |
|
212 | + if (isset($_REQUEST['images'])) { |
|
213 | + echo ' |
|
212 | 214 | <a href="', $url_text, '">', $txt['print_page_text'], '</a> | <strong><a href="', $url_images, '">', $txt['print_page_images'], '</a></strong>'; |
213 | - else |
|
214 | - echo ' |
|
215 | + } else { |
|
216 | + echo ' |
|
215 | 217 | <strong><a href="', $url_text, '">', $txt['print_page_text'], '</a></strong> | <a href="', $url_images, '">', $txt['print_page_images'], '</a>'; |
218 | + } |
|
216 | 219 | |
217 | 220 | echo ' |
218 | 221 | </div><!-- .print_options -->'; |
@@ -31,8 +31,8 @@ discard block |
||
31 | 31 | <div class="windowbg"> |
32 | 32 | <ul id="likes">'; |
33 | 33 | |
34 | - foreach ($context['likers'] as $liker => $like_details) |
|
35 | - echo ' |
|
34 | + foreach ($context['likers'] as $liker => $like_details) { |
|
35 | + echo ' |
|
36 | 36 | <li> |
37 | 37 | ', $like_details['profile']['avatar']['image'], ' |
38 | 38 | <span> |
@@ -41,6 +41,7 @@ discard block |
||
41 | 41 | </span> |
42 | 42 | <span class="floatright">', $like_details['time'], '</span> |
43 | 43 | </li>'; |
44 | + } |
|
44 | 45 | |
45 | 46 | echo ' |
46 | 47 | </ul> |
@@ -61,11 +62,12 @@ discard block |
||
61 | 62 | echo ' |
62 | 63 | <ul class="floatleft">'; |
63 | 64 | |
64 | - if (!empty($context['data']['can_like'])) |
|
65 | - echo ' |
|
65 | + if (!empty($context['data']['can_like'])) { |
|
66 | + echo ' |
|
66 | 67 | <li class="like_button" id="', $context['data']['type'], '_', $context['data']['id_content'], '_likes"', '> |
67 | 68 | <a href="', $scripturl, '?action=likes;ltype=', $context['data']['type'], ';sa=like;like=', $context['data']['id_content'], ';', $context['session_var'], '=', $context['session_id'], '" class="', $context['data']['type'], '_like"><span class="generic_icons ', $context['data']['already_liked'] ? 'unlike' : 'like', '"></span> ', $context['data']['already_liked'] ? $txt['unlike'] : $txt['like'], '</a> |
68 | 69 | </li>'; |
70 | + } |
|
69 | 71 | |
70 | 72 | if (!empty($context['data']['count'])) |
71 | 73 | { |
@@ -20,13 +20,12 @@ discard block |
||
20 | 20 | // We completed some tasks? |
21 | 21 | if (!empty($context['tasks_were_run'])) |
22 | 22 | { |
23 | - if (empty($context['scheduled_errors'])) |
|
24 | - echo ' |
|
23 | + if (empty($context['scheduled_errors'])) { |
|
24 | + echo ' |
|
25 | 25 | <div class="infobox"> |
26 | 26 | ', $txt['scheduled_tasks_were_run'], ' |
27 | 27 | </div>'; |
28 | - |
|
29 | - else |
|
28 | + } else |
|
30 | 29 | { |
31 | 30 | echo ' |
32 | 31 | <div class="errorbox" id="errors"> |
@@ -35,14 +34,15 @@ discard block |
||
35 | 34 | <strong id="error_serious">', $txt['scheduled_tasks_were_run_errors'], '</strong> |
36 | 35 | </dt>'; |
37 | 36 | |
38 | - foreach ($context['scheduled_errors'] as $task => $errors) |
|
39 | - echo ' |
|
37 | + foreach ($context['scheduled_errors'] as $task => $errors) { |
|
38 | + echo ' |
|
40 | 39 | <dd class="error"> |
41 | 40 | <strong>', isset($txt['scheduled_task_' . $task]) ? $txt['scheduled_task_' . $task] : $task, '</strong> |
42 | 41 | <ul> |
43 | 42 | <li>', implode('</li><li>', $errors), '</li> |
44 | 43 | </ul> |
45 | 44 | </dd>'; |
45 | + } |
|
46 | 46 | |
47 | 47 | echo ' |
48 | 48 | </dl> |
@@ -62,16 +62,17 @@ |
||
62 | 62 | <div id="error_box" class="errorbox"> |
63 | 63 | <ul id="error_list">'; |
64 | 64 | |
65 | - foreach ($context['post_errors'] as $key => $error) |
|
66 | - echo ' |
|
65 | + foreach ($context['post_errors'] as $key => $error) { |
|
66 | + echo ' |
|
67 | 67 | <li id="error_', $key, '" class="error">', $error, '</li>'; |
68 | + } |
|
68 | 69 | |
69 | 70 | echo ' |
70 | 71 | </ul>'; |
71 | - } |
|
72 | - else |
|
73 | - echo ' |
|
72 | + } else { |
|
73 | + echo ' |
|
74 | 74 | <div style="display:none" id="error_box" class="errorbox">'; |
75 | + } |
|
75 | 76 | |
76 | 77 | echo ' |
77 | 78 | </div>'; |
@@ -72,9 +72,10 @@ discard block |
||
72 | 72 | |
73 | 73 | // Allow css/js files to be disabled for this specific theme. |
74 | 74 | // Add the identifier as an array key. IE array('smf_script'); Some external files might not add identifiers, on those cases SMF uses its filename as reference. |
75 | - if (!isset($settings['disable_files'])) |
|
76 | - $settings['disable_files'] = array(); |
|
77 | -} |
|
75 | + if (!isset($settings['disable_files'])) { |
|
76 | + $settings['disable_files'] = array(); |
|
77 | + } |
|
78 | + } |
|
78 | 79 | |
79 | 80 | /** |
80 | 81 | * The main sub template above the content. |
@@ -112,8 +113,9 @@ discard block |
||
112 | 113 | echo ' |
113 | 114 | <meta'; |
114 | 115 | |
115 | - foreach ($meta_tag as $meta_key => $meta_value) |
|
116 | - echo ' ', $meta_key, '="', $meta_value, '"'; |
|
116 | + foreach ($meta_tag as $meta_key => $meta_value) { |
|
117 | + echo ' ', $meta_key, '="', $meta_value, '"'; |
|
118 | + } |
|
117 | 119 | |
118 | 120 | echo '>'; |
119 | 121 | } |
@@ -124,14 +126,16 @@ discard block |
||
124 | 126 | <meta name="theme-color" content="#557EA0">'; |
125 | 127 | |
126 | 128 | // Please don't index these Mr Robot. |
127 | - if (!empty($context['robot_no_index'])) |
|
128 | - echo ' |
|
129 | + if (!empty($context['robot_no_index'])) { |
|
130 | + echo ' |
|
129 | 131 | <meta name="robots" content="noindex">'; |
132 | + } |
|
130 | 133 | |
131 | 134 | // Present a canonical url for search engines to prevent duplicate content in their indices. |
132 | - if (!empty($context['canonical_url'])) |
|
133 | - echo ' |
|
135 | + if (!empty($context['canonical_url'])) { |
|
136 | + echo ' |
|
134 | 137 | <link rel="canonical" href="', $context['canonical_url'], '">'; |
138 | + } |
|
135 | 139 | |
136 | 140 | // Show all the relative links, such as help, search, contents, and the like. |
137 | 141 | echo ' |
@@ -140,24 +144,28 @@ discard block |
||
140 | 144 | <link rel="search" href="' . $scripturl . '?action=search">' : ''); |
141 | 145 | |
142 | 146 | // If RSS feeds are enabled, advertise the presence of one. |
143 | - if (!empty($modSettings['xmlnews_enable']) && (!empty($modSettings['allow_guestAccess']) || $context['user']['is_logged'])) |
|
144 | - echo ' |
|
147 | + if (!empty($modSettings['xmlnews_enable']) && (!empty($modSettings['allow_guestAccess']) || $context['user']['is_logged'])) { |
|
148 | + echo ' |
|
145 | 149 | <link rel="alternate" type="application/rss+xml" title="', $context['forum_name_html_safe'], ' - ', $txt['rss'], '" href="', $scripturl, '?action=.xml;type=rss2', !empty($context['current_board']) ? ';board=' . $context['current_board'] : '', '"> |
146 | 150 | <link rel="alternate" type="application/atom+xml" title="', $context['forum_name_html_safe'], ' - ', $txt['atom'], '" href="', $scripturl, '?action=.xml;type=atom', !empty($context['current_board']) ? ';board=' . $context['current_board'] : '', '">'; |
151 | + } |
|
147 | 152 | |
148 | 153 | // If we're viewing a topic, these should be the previous and next topics, respectively. |
149 | - if (!empty($context['links']['next'])) |
|
150 | - echo ' |
|
154 | + if (!empty($context['links']['next'])) { |
|
155 | + echo ' |
|
151 | 156 | <link rel="next" href="', $context['links']['next'], '">'; |
157 | + } |
|
152 | 158 | |
153 | - if (!empty($context['links']['prev'])) |
|
154 | - echo ' |
|
159 | + if (!empty($context['links']['prev'])) { |
|
160 | + echo ' |
|
155 | 161 | <link rel="prev" href="', $context['links']['prev'], '">'; |
162 | + } |
|
156 | 163 | |
157 | 164 | // If we're in a board, or a topic for that matter, the index will be the board's index. |
158 | - if (!empty($context['current_board'])) |
|
159 | - echo ' |
|
165 | + if (!empty($context['current_board'])) { |
|
166 | + echo ' |
|
160 | 167 | <link rel="index" href="', $scripturl, '?board=', $context['current_board'], '.0">'; |
168 | + } |
|
161 | 169 | |
162 | 170 | // Output any remaining HTML headers. (from mods, maybe?) |
163 | 171 | echo $context['html_headers']; |
@@ -190,20 +198,22 @@ discard block |
||
190 | 198 | <li> |
191 | 199 | <a href="', $scripturl, '?action=profile"', !empty($context['self_profile']) ? ' class="active"' : '', ' id="profile_menu_top" onclick="return false;">'; |
192 | 200 | |
193 | - if (!empty($context['user']['avatar'])) |
|
194 | - echo $context['user']['avatar']['image']; |
|
201 | + if (!empty($context['user']['avatar'])) { |
|
202 | + echo $context['user']['avatar']['image']; |
|
203 | + } |
|
195 | 204 | |
196 | 205 | echo $context['user']['name'], '</a> |
197 | 206 | <div id="profile_menu" class="top_menu"></div> |
198 | 207 | </li>'; |
199 | 208 | |
200 | 209 | // Secondly, PMs if we're doing them |
201 | - if ($context['allow_pm']) |
|
202 | - echo ' |
|
210 | + if ($context['allow_pm']) { |
|
211 | + echo ' |
|
203 | 212 | <li> |
204 | 213 | <a href="', $scripturl, '?action=pm"', !empty($context['self_pm']) ? ' class="active"' : '', ' id="pm_menu_top">', $txt['pm_short'], !empty($context['user']['unread_messages']) ? ' <span class="amt">' . $context['user']['unread_messages'] . '</span>' : '', '</a> |
205 | 214 | <div id="pm_menu" class="top_menu scrollable"></div> |
206 | 215 | </li>'; |
216 | + } |
|
207 | 217 | |
208 | 218 | // Thirdly, alerts |
209 | 219 | echo ' |
@@ -218,17 +228,18 @@ discard block |
||
218 | 228 | } |
219 | 229 | // Otherwise they're a guest. Ask them to either register or login. |
220 | 230 | else |
221 | - if (empty($maintenance)) |
|
222 | - echo ' |
|
231 | + if (empty($maintenance)) { |
|
232 | + echo ' |
|
223 | 233 | <ul class="floatleft welcome"> |
224 | 234 | <li>', sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup'), '</li> |
225 | 235 | </ul>'; |
226 | - else |
|
227 | - // In maintenance mode, only login is allowed and don't show OverlayDiv |
|
236 | + } else { |
|
237 | + // In maintenance mode, only login is allowed and don't show OverlayDiv |
|
228 | 238 | echo ' |
229 | 239 | <ul class="floatleft welcome"> |
230 | 240 | <li>', sprintf($txt['welcome_guest'], $txt['guest_title'], '', $scripturl. '?action=login', 'return true;'), '</li> |
231 | 241 | </ul>'; |
242 | + } |
|
232 | 243 | |
233 | 244 | if (!empty($modSettings['userLanguage']) && !empty($context['languages']) && count($context['languages']) > 1) |
234 | 245 | { |
@@ -236,9 +247,10 @@ discard block |
||
236 | 247 | <form id="languages_form" method="get" class="floatright"> |
237 | 248 | <select id="language_select" name="language" onchange="this.form.submit()">'; |
238 | 249 | |
239 | - foreach ($context['languages'] as $language) |
|
240 | - echo ' |
|
250 | + foreach ($context['languages'] as $language) { |
|
251 | + echo ' |
|
241 | 252 | <option value="', $language['filename'], '"', isset($context['user']['language']) && $context['user']['language'] == $language['filename'] ? ' selected="selected"' : '', '>', str_replace('-utf8', '', $language['name']), '</option>'; |
253 | + } |
|
242 | 254 | |
243 | 255 | echo ' |
244 | 256 | </select> |
@@ -262,32 +274,37 @@ discard block |
||
262 | 274 | <option value="all"', ($selected == 'all' ? ' selected' : ''), '>', $txt['search_entireforum'], ' </option>'; |
263 | 275 | |
264 | 276 | // Can't limit it to a specific topic if we are not in one |
265 | - if (!empty($context['current_topic'])) |
|
266 | - echo ' |
|
277 | + if (!empty($context['current_topic'])) { |
|
278 | + echo ' |
|
267 | 279 | <option value="topic"', ($selected == 'current_topic' ? ' selected' : ''), '>', $txt['search_thistopic'], '</option>'; |
280 | + } |
|
268 | 281 | |
269 | 282 | // Can't limit it to a specific board if we are not in one |
270 | - if (!empty($context['current_board'])) |
|
271 | - echo ' |
|
283 | + if (!empty($context['current_board'])) { |
|
284 | + echo ' |
|
272 | 285 | <option value="board"', ($selected == 'current_board' ? ' selected' : ''), '>', $txt['search_thisbrd'], '</option>'; |
286 | + } |
|
273 | 287 | |
274 | 288 | // Can't search for members if we can't see the memberlist |
275 | - if (!empty($context['allow_memberlist'])) |
|
276 | - echo ' |
|
289 | + if (!empty($context['allow_memberlist'])) { |
|
290 | + echo ' |
|
277 | 291 | <option value="members"', ($selected == 'members' ? ' selected' : ''), '>', $txt['search_members'], ' </option>'; |
292 | + } |
|
278 | 293 | |
279 | 294 | echo ' |
280 | 295 | </select>'; |
281 | 296 | |
282 | 297 | // Search within current topic? |
283 | - if (!empty($context['current_topic'])) |
|
284 | - echo ' |
|
298 | + if (!empty($context['current_topic'])) { |
|
299 | + echo ' |
|
285 | 300 | <input type="hidden" name="sd_topic" value="', $context['current_topic'], '">'; |
301 | + } |
|
286 | 302 | |
287 | 303 | // If we're on a certain board, limit it to this board ;). |
288 | - elseif (!empty($context['current_board'])) |
|
289 | - echo ' |
|
304 | + elseif (!empty($context['current_board'])) { |
|
305 | + echo ' |
|
290 | 306 | <input type="hidden" name="sd_brd" value="', $context['current_board'], '">'; |
307 | + } |
|
291 | 308 | |
292 | 309 | echo ' |
293 | 310 | <input type="submit" name="search2" value="', $txt['search'], '" class="button"> |
@@ -319,12 +336,13 @@ discard block |
||
319 | 336 | </div>'; |
320 | 337 | |
321 | 338 | // Show a random news item? (or you could pick one from news_lines...) |
322 | - if (!empty($settings['enable_news']) && !empty($context['random_news_line'])) |
|
323 | - echo ' |
|
339 | + if (!empty($settings['enable_news']) && !empty($context['random_news_line'])) { |
|
340 | + echo ' |
|
324 | 341 | <div class="news"> |
325 | 342 | <h2>', $txt['news'], ': </h2> |
326 | 343 | <p>', $context['random_news_line'], '</p> |
327 | 344 | </div>'; |
345 | + } |
|
328 | 346 | |
329 | 347 | echo ' |
330 | 348 | <hr class="clear"> |
@@ -385,9 +403,10 @@ discard block |
||
385 | 403 | </ul>'; |
386 | 404 | |
387 | 405 | // Show the load time? |
388 | - if ($context['show_load_time']) |
|
389 | - echo ' |
|
406 | + if ($context['show_load_time']) { |
|
407 | + echo ' |
|
390 | 408 | <p>', sprintf($txt['page_created_full'], $context['load_time'], $context['load_queries']), '</p>'; |
409 | + } |
|
391 | 410 | |
392 | 411 | echo ' |
393 | 412 | </div> |
@@ -418,18 +437,20 @@ discard block |
||
418 | 437 | global $context, $shown_linktree, $scripturl, $txt; |
419 | 438 | |
420 | 439 | // If linktree is empty, just return - also allow an override. |
421 | - if (empty($context['linktree']) || (!empty($context['dont_default_linktree']) && !$force_show)) |
|
422 | - return; |
|
440 | + if (empty($context['linktree']) || (!empty($context['dont_default_linktree']) && !$force_show)) { |
|
441 | + return; |
|
442 | + } |
|
423 | 443 | echo ' |
424 | 444 | <div class="navigate_section"> |
425 | 445 | <ul>'; |
426 | 446 | |
427 | - if ($context['user']['is_logged']) |
|
428 | - echo ' |
|
447 | + if ($context['user']['is_logged']) { |
|
448 | + echo ' |
|
429 | 449 | <li class="unread_links"> |
430 | 450 | <a href="', $scripturl, '?action=unread" title="', $txt['unread_since_visit'], '">', $txt['view_unread_category'], '</a> |
431 | 451 | <a href="', $scripturl, '?action=unreadreplies" title="', $txt['show_unread_replies'], '">', $txt['unread_replies'], '</a> |
432 | 452 | </li>'; |
453 | + } |
|
433 | 454 | |
434 | 455 | // Each tree item has a URL and name. Some may have extra_before and extra_after. |
435 | 456 | foreach ($context['linktree'] as $link_num => $tree) |
@@ -440,25 +461,29 @@ discard block |
||
440 | 461 | // Don't show a separator for the first one. |
441 | 462 | // Better here. Always points to the next level when the linktree breaks to a second line. |
442 | 463 | // Picked a better looking HTML entity, and added support for RTL plus a span for styling. |
443 | - if ($link_num != 0) |
|
444 | - echo ' |
|
464 | + if ($link_num != 0) { |
|
465 | + echo ' |
|
445 | 466 | <span class="dividers">', $context['right_to_left'] ? ' ◄ ' : ' ► ', '</span>'; |
467 | + } |
|
446 | 468 | |
447 | 469 | // Show something before the link? |
448 | - if (isset($tree['extra_before'])) |
|
449 | - echo $tree['extra_before'], ' '; |
|
470 | + if (isset($tree['extra_before'])) { |
|
471 | + echo $tree['extra_before'], ' '; |
|
472 | + } |
|
450 | 473 | |
451 | 474 | // Show the link, including a URL if it should have one. |
452 | - if (isset($tree['url'])) |
|
453 | - echo ' |
|
475 | + if (isset($tree['url'])) { |
|
476 | + echo ' |
|
454 | 477 | <a href="' . $tree['url'] . '"><span>' . $tree['name'] . '</span></a>'; |
455 | - else |
|
456 | - echo ' |
|
478 | + } else { |
|
479 | + echo ' |
|
457 | 480 | <span>' . $tree['name'] . '</span>'; |
481 | + } |
|
458 | 482 | |
459 | 483 | // Show something after the link...? |
460 | - if (isset($tree['extra_after'])) |
|
461 | - echo ' ', $tree['extra_after']; |
|
484 | + if (isset($tree['extra_after'])) { |
|
485 | + echo ' ', $tree['extra_after']; |
|
486 | + } |
|
462 | 487 | |
463 | 488 | echo ' |
464 | 489 | </li>'; |
@@ -509,13 +534,14 @@ discard block |
||
509 | 534 | echo ' |
510 | 535 | <ul>'; |
511 | 536 | |
512 | - foreach ($childbutton['sub_buttons'] as $grandchildbutton) |
|
513 | - echo ' |
|
537 | + foreach ($childbutton['sub_buttons'] as $grandchildbutton) { |
|
538 | + echo ' |
|
514 | 539 | <li> |
515 | 540 | <a href="', $grandchildbutton['href'], '"', isset($grandchildbutton['target']) ? ' target="' . $grandchildbutton['target'] . '"' : '', '> |
516 | 541 | ', $grandchildbutton['title'], ' |
517 | 542 | </a> |
518 | 543 | </li>'; |
544 | + } |
|
519 | 545 | |
520 | 546 | echo ' |
521 | 547 | </ul>'; |
@@ -546,8 +572,9 @@ discard block |
||
546 | 572 | { |
547 | 573 | global $context, $txt; |
548 | 574 | |
549 | - if (!is_array($strip_options)) |
|
550 | - $strip_options = array(); |
|
575 | + if (!is_array($strip_options)) { |
|
576 | + $strip_options = array(); |
|
577 | + } |
|
551 | 578 | |
552 | 579 | // Create the buttons... |
553 | 580 | $buttons = array(); |
@@ -556,8 +583,9 @@ discard block |
||
556 | 583 | // As of 2.1, the 'test' for each button happens while the array is being generated. The extra 'test' check here is deprecated but kept for backward compatibility (update your mods, folks!) |
557 | 584 | if (!isset($value['test']) || !empty($context[$value['test']])) |
558 | 585 | { |
559 | - if (!isset($value['id'])) |
|
560 | - $value['id'] = $key; |
|
586 | + if (!isset($value['id'])) { |
|
587 | + $value['id'] = $key; |
|
588 | + } |
|
561 | 589 | |
562 | 590 | $button = ' |
563 | 591 | <a class="button button_strip_' . $key . (!empty($value['active']) ? ' active' : '') . (isset($value['class']) ? ' ' . $value['class'] : '') . '" ' . (!empty($value['url']) ? 'href="' . $value['url'] . '"' : '') . ' ' . (isset($value['custom']) ? ' ' . $value['custom'] : '') . '>' . $txt[$value['text']] . '</a>'; |
@@ -570,13 +598,15 @@ discard block |
||
570 | 598 | <div class="overview">'; |
571 | 599 | foreach ($value['sub_buttons'] as $element) |
572 | 600 | { |
573 | - if (isset($element['test']) && empty($context[$element['test']])) |
|
574 | - continue; |
|
601 | + if (isset($element['test']) && empty($context[$element['test']])) { |
|
602 | + continue; |
|
603 | + } |
|
575 | 604 | |
576 | 605 | $button .= ' |
577 | 606 | <a href="' . $element['url'] . '"><strong>' . $txt[$element['text']] . '</strong>'; |
578 | - if (isset($txt[$element['text'] . '_desc'])) |
|
579 | - $button .= '<br><span>' . $txt[$element['text'] . '_desc'] . '</span>'; |
|
607 | + if (isset($txt[$element['text'] . '_desc'])) { |
|
608 | + $button .= '<br><span>' . $txt[$element['text'] . '_desc'] . '</span>'; |
|
609 | + } |
|
580 | 610 | $button .= '</a>'; |
581 | 611 | } |
582 | 612 | $button .= ' |
@@ -590,8 +620,9 @@ discard block |
||
590 | 620 | } |
591 | 621 | |
592 | 622 | // No buttons? No button strip either. |
593 | - if (empty($buttons)) |
|
594 | - return; |
|
623 | + if (empty($buttons)) { |
|
624 | + return; |
|
625 | + } |
|
595 | 626 | |
596 | 627 | echo ' |
597 | 628 | <div class="buttonlist', !empty($direction) ? ' float' . $direction : '', '"', (empty($buttons) ? ' style="display: none;"' : ''), (!empty($strip_options['id']) ? ' id="' . $strip_options['id'] . '"' : ''), '> |