@@ -229,7 +229,7 @@ |
||
229 | 229 | //In maintenance mode, only login is allowed and don't show OverlayDiv |
230 | 230 | echo ' |
231 | 231 | <ul class="floatleft welcome"> |
232 | - <li>', sprintf($txt['welcome_guest'], $txt['guest_title'], '', $scripturl. '?action=login', 'return true;'), '</li> |
|
232 | + <li>', sprintf($txt['welcome_guest'], $txt['guest_title'], '', $scripturl . '?action=login', 'return true;'), '</li> |
|
233 | 233 | </ul>'; |
234 | 234 | |
235 | 235 | if (!empty($modSettings['userLanguage']) && !empty($context['languages']) && count($context['languages']) > 1) |
@@ -72,9 +72,10 @@ discard block |
||
72 | 72 | |
73 | 73 | // Allow css/js files to be disable 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. |
@@ -111,8 +112,9 @@ discard block |
||
111 | 112 | echo ' |
112 | 113 | <meta'; |
113 | 114 | |
114 | - foreach ($meta_tag as $meta_key => $meta_value) |
|
115 | - echo ' ', $meta_key, '="', $meta_value, '"'; |
|
115 | + foreach ($meta_tag as $meta_key => $meta_value) { |
|
116 | + echo ' ', $meta_key, '="', $meta_value, '"'; |
|
117 | + } |
|
116 | 118 | |
117 | 119 | echo '>'; |
118 | 120 | } |
@@ -123,14 +125,16 @@ discard block |
||
123 | 125 | <meta name="theme-color" content="#557EA0">'; |
124 | 126 | |
125 | 127 | // Please don't index these Mr Robot. |
126 | - if (!empty($context['robot_no_index'])) |
|
127 | - echo ' |
|
128 | + if (!empty($context['robot_no_index'])) { |
|
129 | + echo ' |
|
128 | 130 | <meta name="robots" content="noindex">'; |
131 | + } |
|
129 | 132 | |
130 | 133 | // Present a canonical url for search engines to prevent duplicate content in their indices. |
131 | - if (!empty($context['canonical_url'])) |
|
132 | - echo ' |
|
134 | + if (!empty($context['canonical_url'])) { |
|
135 | + echo ' |
|
133 | 136 | <link rel="canonical" href="', $context['canonical_url'], '">'; |
137 | + } |
|
134 | 138 | |
135 | 139 | // Show all the relative links, such as help, search, contents, and the like. |
136 | 140 | echo ' |
@@ -139,10 +143,11 @@ discard block |
||
139 | 143 | <link rel="search" href="' . $scripturl . '?action=search">' : ''); |
140 | 144 | |
141 | 145 | // If RSS feeds are enabled, advertise the presence of one. |
142 | - if (!empty($modSettings['xmlnews_enable']) && (!empty($modSettings['allow_guestAccess']) || $context['user']['is_logged'])) |
|
143 | - echo ' |
|
146 | + if (!empty($modSettings['xmlnews_enable']) && (!empty($modSettings['allow_guestAccess']) || $context['user']['is_logged'])) { |
|
147 | + echo ' |
|
144 | 148 | <link rel="alternate" type="application/rss+xml" title="', $context['forum_name_html_safe'], ' - ', $txt['rss'], '" href="', $scripturl, '?type=rss2;action=.xml"> |
145 | 149 | <link rel="alternate" type="application/rss+xml" title="', $context['forum_name_html_safe'], ' - ', $txt['atom'], '" href="', $scripturl, '?type=atom;action=.xml">'; |
150 | + } |
|
146 | 151 | |
147 | 152 | // If we're viewing a topic, these should be the previous and next topics, respectively. |
148 | 153 | if (!empty($context['links']['next'])) |
@@ -158,9 +163,10 @@ discard block |
||
158 | 163 | } |
159 | 164 | |
160 | 165 | // If we're in a board, or a topic for that matter, the index will be the board's index. |
161 | - if (!empty($context['current_board'])) |
|
162 | - echo ' |
|
166 | + if (!empty($context['current_board'])) { |
|
167 | + echo ' |
|
163 | 168 | <link rel="index" href="', $scripturl, '?board=', $context['current_board'], '.0">'; |
169 | + } |
|
164 | 170 | |
165 | 171 | // Output any remaining HTML headers. (from mods, maybe?) |
166 | 172 | echo $context['html_headers']; |
@@ -191,8 +197,9 @@ discard block |
||
191 | 197 | <ul class="floatleft" id="top_info"> |
192 | 198 | <li> |
193 | 199 | <a href="', $scripturl, '?action=profile"', !empty($context['self_profile']) ? ' class="active"' : '', ' id="profile_menu_top" onclick="return false;">'; |
194 | - if (!empty($context['user']['avatar'])) |
|
195 | - echo $context['user']['avatar']['image']; |
|
200 | + if (!empty($context['user']['avatar'])) { |
|
201 | + echo $context['user']['avatar']['image']; |
|
202 | + } |
|
196 | 203 | echo $context['user']['name'], '</a> |
197 | 204 | <div id="profile_menu" class="top_menu"></div> |
198 | 205 | </li>'; |
@@ -220,17 +227,18 @@ discard block |
||
220 | 227 | } |
221 | 228 | // Otherwise they're a guest. Ask them to either register or login. |
222 | 229 | else |
223 | - if (empty($maintenance)) |
|
224 | - echo ' |
|
230 | + if (empty($maintenance)) { |
|
231 | + echo ' |
|
225 | 232 | <ul class="floatleft welcome"> |
226 | 233 | <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> |
227 | 234 | </ul>'; |
228 | - else |
|
229 | - //In maintenance mode, only login is allowed and don't show OverlayDiv |
|
235 | + } else { |
|
236 | + //In maintenance mode, only login is allowed and don't show OverlayDiv |
|
230 | 237 | echo ' |
231 | 238 | <ul class="floatleft welcome"> |
232 | 239 | <li>', sprintf($txt['welcome_guest'], $txt['guest_title'], '', $scripturl. '?action=login', 'return true;'), '</li> |
233 | 240 | </ul>'; |
241 | + } |
|
234 | 242 | |
235 | 243 | if (!empty($modSettings['userLanguage']) && !empty($context['languages']) && count($context['languages']) > 1) |
236 | 244 | { |
@@ -238,9 +246,10 @@ discard block |
||
238 | 246 | <form id="languages_form" method="get" class="floatright"> |
239 | 247 | <select id="language_select" name="language" onchange="this.form.submit()">'; |
240 | 248 | |
241 | - foreach ($context['languages'] as $language) |
|
242 | - echo ' |
|
249 | + foreach ($context['languages'] as $language) { |
|
250 | + echo ' |
|
243 | 251 | <option value="', $language['filename'], '"', isset($context['user']['language']) && $context['user']['language'] == $language['filename'] ? ' selected="selected"' : '', '>', str_replace('-utf8', '', $language['name']), '</option>'; |
252 | + } |
|
244 | 253 | |
245 | 254 | echo ' |
246 | 255 | </select> |
@@ -264,31 +273,36 @@ discard block |
||
264 | 273 | <option value="all"', ($selected == 'all' ? ' selected' : ''), '>', $txt['search_entireforum'], ' </option>'; |
265 | 274 | |
266 | 275 | // Can't limit it to a specific topic if we are not in one |
267 | - if (!empty($context['current_topic'])) |
|
268 | - echo ' |
|
276 | + if (!empty($context['current_topic'])) { |
|
277 | + echo ' |
|
269 | 278 | <option value="topic"', ($selected == 'current_topic' ? ' selected' : ''), '>', $txt['search_thistopic'], '</option>'; |
279 | + } |
|
270 | 280 | |
271 | 281 | // Can't limit it to a specific board if we are not in one |
272 | - if (!empty($context['current_board'])) |
|
273 | - echo ' |
|
282 | + if (!empty($context['current_board'])) { |
|
283 | + echo ' |
|
274 | 284 | <option value="board"', ($selected == 'current_board' ? ' selected' : ''), '>', $txt['search_thisbrd'], '</option>'; |
285 | + } |
|
275 | 286 | |
276 | 287 | // Can't search for members if we can't see the memberlist |
277 | - if (!empty($context['allow_memberlist'])) |
|
278 | - echo ' |
|
288 | + if (!empty($context['allow_memberlist'])) { |
|
289 | + echo ' |
|
279 | 290 | <option value="members"', ($selected == 'members' ? ' selected' : ''), '>', $txt['search_members'], ' </option>'; |
291 | + } |
|
280 | 292 | |
281 | 293 | echo ' |
282 | 294 | </select>'; |
283 | 295 | |
284 | 296 | // Search within current topic? |
285 | - if (!empty($context['current_topic'])) |
|
286 | - echo ' |
|
297 | + if (!empty($context['current_topic'])) { |
|
298 | + echo ' |
|
287 | 299 | <input type="hidden" name="sd_topic" value="', $context['current_topic'], '">'; |
300 | + } |
|
288 | 301 | // If we're on a certain board, limit it to this board ;). |
289 | - elseif (!empty($context['current_board'])) |
|
290 | - echo ' |
|
302 | + elseif (!empty($context['current_board'])) { |
|
303 | + echo ' |
|
291 | 304 | <input type="hidden" name="sd_brd" value="', $context['current_board'], '">'; |
305 | + } |
|
292 | 306 | |
293 | 307 | echo ' |
294 | 308 | <input type="submit" name="search2" value="', $txt['search'], '" class="button_submit"> |
@@ -318,12 +332,13 @@ discard block |
||
318 | 332 | ', $context['current_time'], ' |
319 | 333 | </div>'; |
320 | 334 | // Show a random news item? (or you could pick one from news_lines...) |
321 | - if (!empty($settings['enable_news']) && !empty($context['random_news_line'])) |
|
322 | - echo ' |
|
335 | + if (!empty($settings['enable_news']) && !empty($context['random_news_line'])) { |
|
336 | + echo ' |
|
323 | 337 | <div class="news"> |
324 | 338 | <h2>', $txt['news'], ': </h2> |
325 | 339 | <p>', $context['random_news_line'], '</p> |
326 | 340 | </div>'; |
341 | + } |
|
327 | 342 | |
328 | 343 | echo ' |
329 | 344 | <hr class="clear"> |
@@ -386,9 +401,10 @@ discard block |
||
386 | 401 | </ul>'; |
387 | 402 | |
388 | 403 | // Show the load time? |
389 | - if ($context['show_load_time']) |
|
390 | - echo ' |
|
404 | + if ($context['show_load_time']) { |
|
405 | + echo ' |
|
391 | 406 | <p>', sprintf($txt['page_created_full'], $context['load_time'], $context['load_queries']), '</p>'; |
407 | + } |
|
392 | 408 | |
393 | 409 | echo ' |
394 | 410 | </div>'; |
@@ -418,19 +434,21 @@ discard block |
||
418 | 434 | global $context, $shown_linktree, $scripturl, $txt; |
419 | 435 | |
420 | 436 | // If linktree is empty, just return - also allow an override. |
421 | - if (empty($context['linktree']) || (!empty($context['dont_default_linktree']) && !$force_show)) |
|
422 | - return; |
|
437 | + if (empty($context['linktree']) || (!empty($context['dont_default_linktree']) && !$force_show)) { |
|
438 | + return; |
|
439 | + } |
|
423 | 440 | |
424 | 441 | echo ' |
425 | 442 | <div class="navigate_section"> |
426 | 443 | <ul>'; |
427 | 444 | |
428 | - if ($context['user']['is_logged']) |
|
429 | - echo ' |
|
445 | + if ($context['user']['is_logged']) { |
|
446 | + echo ' |
|
430 | 447 | <li class="unread_links"> |
431 | 448 | <a href="', $scripturl, '?action=unread" title="', $txt['unread_since_visit'], '">', $txt['view_unread_category'], '</a> |
432 | 449 | <a href="', $scripturl, '?action=unreadreplies" title="', $txt['show_unread_replies'], '">', $txt['unread_replies'], '</a> |
433 | 450 | </li>'; |
451 | + } |
|
434 | 452 | |
435 | 453 | // Each tree item has a URL and name. Some may have extra_before and extra_after. |
436 | 454 | foreach ($context['linktree'] as $link_num => $tree) |
@@ -441,25 +459,29 @@ discard block |
||
441 | 459 | // Don't show a separator for the first one. |
442 | 460 | // Better here. Always points to the next level when the linktree breaks to a second line. |
443 | 461 | // Picked a better looking HTML entity, and added support for RTL plus a span for styling. |
444 | - if ($link_num != 0) |
|
445 | - echo ' |
|
462 | + if ($link_num != 0) { |
|
463 | + echo ' |
|
446 | 464 | <span class="dividers">', $context['right_to_left'] ? ' ◄ ' : ' ► ', '</span>'; |
465 | + } |
|
447 | 466 | |
448 | 467 | // Show something before the link? |
449 | - if (isset($tree['extra_before'])) |
|
450 | - echo $tree['extra_before'], ' '; |
|
468 | + if (isset($tree['extra_before'])) { |
|
469 | + echo $tree['extra_before'], ' '; |
|
470 | + } |
|
451 | 471 | |
452 | 472 | // Show the link, including a URL if it should have one. |
453 | - if (isset($tree['url'])) |
|
454 | - echo ' |
|
473 | + if (isset($tree['url'])) { |
|
474 | + echo ' |
|
455 | 475 | <a href="' . $tree['url'] . '"><span>' . $tree['name'] . '</span></a>'; |
456 | - else |
|
457 | - echo ' |
|
476 | + } else { |
|
477 | + echo ' |
|
458 | 478 | <span>' . $tree['name'] . '</span>'; |
479 | + } |
|
459 | 480 | |
460 | 481 | // Show something after the link...? |
461 | - if (isset($tree['extra_after'])) |
|
462 | - echo ' ', $tree['extra_after']; |
|
482 | + if (isset($tree['extra_after'])) { |
|
483 | + echo ' ', $tree['extra_after']; |
|
484 | + } |
|
463 | 485 | |
464 | 486 | echo ' |
465 | 487 | </li>'; |
@@ -509,13 +531,14 @@ discard block |
||
509 | 531 | echo ' |
510 | 532 | <ul>'; |
511 | 533 | |
512 | - foreach ($childbutton['sub_buttons'] as $grandchildbutton) |
|
513 | - echo ' |
|
534 | + foreach ($childbutton['sub_buttons'] as $grandchildbutton) { |
|
535 | + echo ' |
|
514 | 536 | <li> |
515 | 537 | <a href="', $grandchildbutton['href'], '"', isset($grandchildbutton['target']) ? ' target="' . $grandchildbutton['target'] . '"' : '', '> |
516 | 538 | ', $grandchildbutton['title'], ' |
517 | 539 | </a> |
518 | 540 | </li>'; |
541 | + } |
|
519 | 542 | |
520 | 543 | echo ' |
521 | 544 | </ul>'; |
@@ -546,8 +569,9 @@ discard block |
||
546 | 569 | { |
547 | 570 | global $context, $txt; |
548 | 571 | |
549 | - if (!is_array($strip_options)) |
|
550 | - $strip_options = array(); |
|
572 | + if (!is_array($strip_options)) { |
|
573 | + $strip_options = array(); |
|
574 | + } |
|
551 | 575 | |
552 | 576 | // Create the buttons... |
553 | 577 | $buttons = array(); |
@@ -556,8 +580,9 @@ discard block |
||
556 | 580 | // 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 | 581 | if (!isset($value['test']) || !empty($context[$value['test']])) |
558 | 582 | { |
559 | - if (!isset($value['id'])) |
|
560 | - $value['id'] = $key; |
|
583 | + if (!isset($value['id'])) { |
|
584 | + $value['id'] = $key; |
|
585 | + } |
|
561 | 586 | |
562 | 587 | $button = ' |
563 | 588 | <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 +595,15 @@ discard block |
||
570 | 595 | <div class="overview">'; |
571 | 596 | foreach ($value['sub_buttons'] as $element) |
572 | 597 | { |
573 | - if (isset($element['test']) && empty($context[$element['test']])) |
|
574 | - continue; |
|
598 | + if (isset($element['test']) && empty($context[$element['test']])) { |
|
599 | + continue; |
|
600 | + } |
|
575 | 601 | |
576 | 602 | $button .= ' |
577 | 603 | <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>'; |
|
604 | + if (isset($txt[$element['text'] . '_desc'])) { |
|
605 | + $button .= '<br /><span>' . $txt[$element['text'] . '_desc'] . '</span>'; |
|
606 | + } |
|
580 | 607 | $button .= '</a>'; |
581 | 608 | } |
582 | 609 | $button .= ' |
@@ -590,8 +617,9 @@ discard block |
||
590 | 617 | } |
591 | 618 | |
592 | 619 | // No buttons? No button strip either. |
593 | - if (empty($buttons)) |
|
594 | - return; |
|
620 | + if (empty($buttons)) { |
|
621 | + return; |
|
622 | + } |
|
595 | 623 | |
596 | 624 | echo ' |
597 | 625 | <div class="buttonlist', !empty($direction) ? ' float' . $direction : '', '"', (empty($buttons) ? ' style="display: none;"' : ''), (!empty($strip_options['id']) ? ' id="' . $strip_options['id'] . '"' : ''), '> |
@@ -1542,7 +1542,7 @@ discard block |
||
1542 | 1542 | 'no_msg' => 0, |
1543 | 1543 | 'substep' => $_GET['substep'], |
1544 | 1544 | 'ignore_ids' => $ignore_ids, |
1545 | - 'attach_thumb' => array(0,3), |
|
1545 | + 'attach_thumb' => array(0, 3), |
|
1546 | 1546 | ) |
1547 | 1547 | ); |
1548 | 1548 | |
@@ -1572,7 +1572,7 @@ discard block |
||
1572 | 1572 | array( |
1573 | 1573 | 'to_remove' => $to_remove, |
1574 | 1574 | 'no_member' => 0, |
1575 | - 'attach_thumb' => array(0,3), |
|
1575 | + 'attach_thumb' => array(0, 3), |
|
1576 | 1576 | ) |
1577 | 1577 | ); |
1578 | 1578 |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 3 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * 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'] = smf_json_decode($modSettings['attachment_basedirectories'], true); |
|
215 | + if (!is_array($modSettings['attachment_basedirectories'])) { |
|
216 | + $modSettings['attachment_basedirectories'] = smf_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() - array_sum(explode(' ', $time_start)) < 3 || $context['starting_substep'] == $_GET['substep']) |
|
1700 | - return; |
|
1755 | + if (time() - array_sum(explode(' ', $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'] = smf_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'] = smf_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' => json_encode($modSettings['attachment_basedirectories']))); |
2051 | 2119 | $modSettings['attachment_basedirectories'] = smf_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'] = smf_json_decode($modSettings['last_attachments_directory'], true); |
|
2154 | + if (!is_array($modSettings['last_attachments_directory'])) { |
|
2155 | + $modSettings['last_attachments_directory'] = smf_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' => 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'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
2607 | - if (!empty($modSettings['attachment_basedirectories'])) |
|
2608 | - $modSettings['attachment_basedirectories'] = smf_json_decode($modSettings['attachment_basedirectories'], true); |
|
2609 | - else |
|
2610 | - $modSettings['basedirectory_for_attachments'] = array(); |
|
2702 | + if (!empty($modSettings['attachment_basedirectories'])) { |
|
2703 | + $modSettings['attachment_basedirectories'] = smf_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 | } |
@@ -51,29 +51,34 @@ discard block |
||
51 | 51 | ); |
52 | 52 | |
53 | 53 | // No file? Thats bad. |
54 | -if (!isset($_SERVER['argv'], $_SERVER['argv'][1])) |
|
54 | +if (!isset($_SERVER['argv'], $_SERVER['argv'][1])) { |
|
55 | 55 | die('Error: No File specified' . "\n"); |
56 | +} |
|
56 | 57 | |
57 | 58 | // The file has to exist. |
58 | 59 | $currentFile = $_SERVER['argv'][1]; |
59 | -if (!file_exists($currentFile)) |
|
60 | +if (!file_exists($currentFile)) { |
|
60 | 61 | die('Error: File does not exist' . "\n"); |
62 | +} |
|
61 | 63 | |
62 | 64 | // Is this ignored? |
63 | -foreach ($ignoreFiles as $if) |
|
65 | +foreach ($ignoreFiles as $if) { |
|
64 | 66 | if (preg_match('~' . $if . '~i', $currentFile)) |
65 | 67 | die; |
68 | +} |
|
66 | 69 | |
67 | 70 | // Lets get the main index.php for $forum_version and $software_year. |
68 | 71 | $indexFile = fopen('./index.php', 'r'); |
69 | 72 | $indexContents = fread($indexFile, 850); |
70 | 73 | |
71 | -if (!preg_match('~\$forum_version = \'SMF ([^\']+)\';~i', $indexContents, $versionResults)) |
|
74 | +if (!preg_match('~\$forum_version = \'SMF ([^\']+)\';~i', $indexContents, $versionResults)) { |
|
72 | 75 | die('Error: Could not locate $forum_version' . "\n"); |
76 | +} |
|
73 | 77 | $currentVersion = $versionResults[1]; |
74 | 78 | |
75 | -if (!preg_match('~\$software_year = \'(\d{4})\';~i', $indexContents, $yearResults)) |
|
79 | +if (!preg_match('~\$software_year = \'(\d{4})\';~i', $indexContents, $yearResults)) { |
|
76 | 80 | die('Error: Could not locate $software_year' . "\n"); |
81 | +} |
|
77 | 82 | $currentSoftwareYear = (int) $yearResults[1]; |
78 | 83 | |
79 | 84 | $file = fopen($currentFile, 'r'); |
@@ -94,20 +99,23 @@ discard block |
||
94 | 99 | ); |
95 | 100 | |
96 | 101 | // Just see if the license is there. |
97 | -if (!preg_match('~' . implode('', $match) . '~i', $contents)) |
|
102 | +if (!preg_match('~' . implode('', $match) . '~i', $contents)) { |
|
98 | 103 | die('Error: License File is invalid or not found in ' . $currentFile . "\n"); |
104 | +} |
|
99 | 105 | |
100 | 106 | // Check the year is correct. |
101 | 107 | $yearMatch = $match; |
102 | 108 | $yearMatch[4] = ' \* @copyright ' . $currentSoftwareYear . ' Simple Machines and individual contributors' . '[\r]?\n'; |
103 | -if (!preg_match('~' . implode('', $yearMatch) . '~i', $contents)) |
|
109 | +if (!preg_match('~' . implode('', $yearMatch) . '~i', $contents)) { |
|
104 | 110 | die('Error: The software year is incorrect in ' . $currentFile . "\n"); |
111 | +} |
|
105 | 112 | |
106 | 113 | // Check the version is correct. |
107 | 114 | $versionMatch = $match; |
108 | 115 | $versionMatch[7] = ' \* @version ' . $currentVersion . '[\r]?\n'; |
109 | -if (!preg_match('~' . implode('', $versionMatch) . '~i', $contents)) |
|
116 | +if (!preg_match('~' . implode('', $versionMatch) . '~i', $contents)) { |
|
110 | 117 | die('Error: The version is incorrect in ' . $currentFile . "\n"); |
118 | +} |
|
111 | 119 | |
112 | 120 | // Special check, ugprade.php, install.php copyright templates. |
113 | 121 | if (in_array($currentFile, array('./other/upgrade.php', './other/install.php'))) |
@@ -115,9 +123,11 @@ discard block |
||
115 | 123 | // The code is fairly well into it, just get the entire contents. |
116 | 124 | $upgradeFile = file_get_contents($currentFile); |
117 | 125 | |
118 | - if (!preg_match('~<li class="copyright"><a href="http://www.simplemachines.org/" title="Simple Machines Forum" target="_blank" class="new_win">SMF © (\d{4}), Simple Machines</a></li>~i', $upgradeFile, $upgradeResults)) |
|
119 | - die('Error: Could not locate upgrade template copyright $software_year' . "\n"); |
|
126 | + if (!preg_match('~<li class="copyright"><a href="http://www.simplemachines.org/" title="Simple Machines Forum" target="_blank" class="new_win">SMF © (\d{4}), Simple Machines</a></li>~i', $upgradeFile, $upgradeResults)) { |
|
127 | + die('Error: Could not locate upgrade template copyright $software_year' . "\n"); |
|
128 | + } |
|
120 | 129 | |
121 | - if ((int) $upgradeResults[1] != $currentSoftwareYear) |
|
122 | - die('Error: Upgrade template copyright year is invalid' . "\n"); |
|
123 | -} |
|
124 | 130 | \ No newline at end of file |
131 | + if ((int) $upgradeResults[1] != $currentSoftwareYear) { |
|
132 | + die('Error: Upgrade template copyright year is invalid' . "\n"); |
|
133 | + } |
|
134 | + } |
|
125 | 135 | \ No newline at end of file |
@@ -64,9 +64,10 @@ discard block |
||
64 | 64 | <strong>', $txt['administrators'], ':</strong> |
65 | 65 | ', implode(', ', $context['administrators']); |
66 | 66 | // If we have lots of admins... don't show them all. |
67 | - if (!empty($context['more_admins_link'])) |
|
68 | - echo ' |
|
67 | + if (!empty($context['more_admins_link'])) { |
|
68 | + echo ' |
|
69 | 69 | (', $context['more_admins_link'], ')'; |
70 | + } |
|
70 | 71 | |
71 | 72 | echo ' |
72 | 73 | </div> |
@@ -83,16 +84,18 @@ discard block |
||
83 | 84 | foreach ($area['areas'] as $item_id => $item) |
84 | 85 | { |
85 | 86 | // No point showing the 'home' page here, we're already on it! |
86 | - if ($area_id == 'forum' && $item_id == 'index') |
|
87 | - continue; |
|
87 | + if ($area_id == 'forum' && $item_id == 'index') { |
|
88 | + continue; |
|
89 | + } |
|
88 | 90 | |
89 | 91 | $url = isset($item['url']) ? $item['url'] : $scripturl . '?action=admin;area=' . $item_id . (!empty($context[$context['admin_menu_name']]['extra_parameters']) ? $context[$context['admin_menu_name']]['extra_parameters'] : ''); |
90 | - if (!empty($item['icon_file'])) |
|
91 | - echo ' |
|
92 | + if (!empty($item['icon_file'])) { |
|
93 | + echo ' |
|
92 | 94 | <a href="', $url, '" class="admin_group', !empty($item['inactive']) ? ' inactive' : '', '"><img class="large_admin_menu_icon_file" src="', $item['icon_file'], '" alt="">', $item['label'], '</a>'; |
93 | - else |
|
94 | - echo ' |
|
95 | + } else { |
|
96 | + echo ' |
|
95 | 97 | <a href="', $url, '"><span class="large_', $item['icon_class'], !empty($item['inactive']) ? ' inactive' : '', '"></span>', $item['label'], '</a>'; |
98 | + } |
|
96 | 99 | } |
97 | 100 | |
98 | 101 | echo ' |
@@ -103,10 +106,11 @@ discard block |
||
103 | 106 | </div>'; |
104 | 107 | |
105 | 108 | // The below functions include all the scripts needed from the simplemachines.org site. The language and format are passed for internationalization. |
106 | - if (empty($modSettings['disable_smf_js'])) |
|
107 | - echo ' |
|
109 | + if (empty($modSettings['disable_smf_js'])) { |
|
110 | + echo ' |
|
108 | 111 | <script src="', $scripturl, '?action=viewsmfile;filename=current-version.js"></script> |
109 | 112 | <script src="', $scripturl, '?action=viewsmfile;filename=latest-news.js"></script>'; |
113 | + } |
|
110 | 114 | |
111 | 115 | // This sets the announcements and current versions themselves ;). |
112 | 116 | echo ' |
@@ -185,9 +189,10 @@ discard block |
||
185 | 189 | <em>', $version['version'], '</em>'; |
186 | 190 | |
187 | 191 | // more details for this item, show them a link |
188 | - if ($context['can_admin'] && isset($version['more'])) |
|
189 | - echo |
|
192 | + if ($context['can_admin'] && isset($version['more'])) { |
|
193 | + echo |
|
190 | 194 | ' <a href="', $scripturl, $version['more'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['version_check_more'], '</a>'; |
195 | + } |
|
191 | 196 | echo ' |
192 | 197 | <br>'; |
193 | 198 | } |
@@ -218,20 +223,22 @@ discard block |
||
218 | 223 | |
219 | 224 | foreach ($context['credits'] as $section) |
220 | 225 | { |
221 | - if (isset($section['pretext'])) |
|
222 | - echo ' |
|
226 | + if (isset($section['pretext'])) { |
|
227 | + echo ' |
|
223 | 228 | <p>', $section['pretext'], '</p><hr>'; |
229 | + } |
|
224 | 230 | |
225 | 231 | echo ' |
226 | 232 | <dl>'; |
227 | 233 | |
228 | 234 | foreach ($section['groups'] as $group) |
229 | 235 | { |
230 | - if (isset($group['title'])) |
|
231 | - echo ' |
|
236 | + if (isset($group['title'])) { |
|
237 | + echo ' |
|
232 | 238 | <dt> |
233 | 239 | <strong>', $group['title'], ':</strong> |
234 | 240 | </dt>'; |
241 | + } |
|
235 | 242 | |
236 | 243 | echo ' |
237 | 244 | <dd>', implode(', ', $group['members']), '</dd>'; |
@@ -240,10 +247,11 @@ discard block |
||
240 | 247 | echo ' |
241 | 248 | </dl>'; |
242 | 249 | |
243 | - if (isset($section['posttext'])) |
|
244 | - echo ' |
|
250 | + if (isset($section['posttext'])) { |
|
251 | + echo ' |
|
245 | 252 | <hr> |
246 | 253 | <p>', $section['posttext'], '</p>'; |
254 | + } |
|
247 | 255 | } |
248 | 256 | |
249 | 257 | echo ' |
@@ -259,9 +267,10 @@ discard block |
||
259 | 267 | smfSupportVersions.forum = "', $context['forum_version'], '";'; |
260 | 268 | |
261 | 269 | // Don't worry, none of this is logged, it's just used to give information that might be of use. |
262 | - foreach ($context['current_versions'] as $variable => $version) |
|
263 | - echo ' |
|
270 | + foreach ($context['current_versions'] as $variable => $version) { |
|
271 | + echo ' |
|
264 | 272 | smfSupportVersions.', $variable, ' = "', $version['version'], '";'; |
273 | + } |
|
265 | 274 | |
266 | 275 | // Now we just have to include the script and wait ;). |
267 | 276 | echo ' |
@@ -358,8 +367,8 @@ discard block |
||
358 | 367 | <tbody>'; |
359 | 368 | |
360 | 369 | // Loop through every source file displaying its version - using javascript. |
361 | - foreach ($context['file_versions'] as $filename => $version) |
|
362 | - echo ' |
|
370 | + foreach ($context['file_versions'] as $filename => $version) { |
|
371 | + echo ' |
|
363 | 372 | <tr class="windowbg"> |
364 | 373 | <td class="half_table"> |
365 | 374 | ', $filename, ' |
@@ -371,6 +380,7 @@ discard block |
||
371 | 380 | <em id="currentSources', $filename, '">??</em> |
372 | 381 | </td> |
373 | 382 | </tr>'; |
383 | + } |
|
374 | 384 | |
375 | 385 | // Default template files. |
376 | 386 | echo ' |
@@ -396,8 +406,8 @@ discard block |
||
396 | 406 | <table id="Default" class="table_grid"> |
397 | 407 | <tbody>'; |
398 | 408 | |
399 | - foreach ($context['default_template_versions'] as $filename => $version) |
|
400 | - echo ' |
|
409 | + foreach ($context['default_template_versions'] as $filename => $version) { |
|
410 | + echo ' |
|
401 | 411 | <tr class="windowbg"> |
402 | 412 | <td class="half_table"> |
403 | 413 | ', $filename, ' |
@@ -409,6 +419,7 @@ discard block |
||
409 | 419 | <em id="currentDefault', $filename, '">??</em> |
410 | 420 | </td> |
411 | 421 | </tr>'; |
422 | + } |
|
412 | 423 | |
413 | 424 | // Now the language files... |
414 | 425 | echo ' |
@@ -436,8 +447,8 @@ discard block |
||
436 | 447 | |
437 | 448 | foreach ($context['default_language_versions'] as $language => $files) |
438 | 449 | { |
439 | - foreach ($files as $filename => $version) |
|
440 | - echo ' |
|
450 | + foreach ($files as $filename => $version) { |
|
451 | + echo ' |
|
441 | 452 | <tr class="windowbg"> |
442 | 453 | <td class="half_table"> |
443 | 454 | ', $filename, '.<em>', $language, '</em>.php |
@@ -449,6 +460,7 @@ discard block |
||
449 | 460 | <em id="current', $filename, '.', $language, '">??</em> |
450 | 461 | </td> |
451 | 462 | </tr>'; |
463 | + } |
|
452 | 464 | } |
453 | 465 | |
454 | 466 | echo ' |
@@ -478,8 +490,8 @@ discard block |
||
478 | 490 | <table id="Templates" class="table_grid"> |
479 | 491 | <tbody>'; |
480 | 492 | |
481 | - foreach ($context['template_versions'] as $filename => $version) |
|
482 | - echo ' |
|
493 | + foreach ($context['template_versions'] as $filename => $version) { |
|
494 | + echo ' |
|
483 | 495 | <tr class="windowbg"> |
484 | 496 | <td class="half_table"> |
485 | 497 | ', $filename, ' |
@@ -491,6 +503,7 @@ discard block |
||
491 | 503 | <em id="currentTemplates', $filename, '">??</em> |
492 | 504 | </td> |
493 | 505 | </tr>'; |
506 | + } |
|
494 | 507 | |
495 | 508 | echo ' |
496 | 509 | </tbody> |
@@ -520,8 +533,8 @@ discard block |
||
520 | 533 | <table id="Tasks" class="table_grid"> |
521 | 534 | <tbody>'; |
522 | 535 | |
523 | - foreach ($context['tasks_versions'] as $filename => $version) |
|
524 | - echo ' |
|
536 | + foreach ($context['tasks_versions'] as $filename => $version) { |
|
537 | + echo ' |
|
525 | 538 | <tr class="windowbg"> |
526 | 539 | <td class="half_table"> |
527 | 540 | ', $filename, ' |
@@ -533,6 +546,7 @@ discard block |
||
533 | 546 | <em id="currentTasks', $filename, '">??</em> |
534 | 547 | </td> |
535 | 548 | </tr>'; |
549 | + } |
|
536 | 550 | |
537 | 551 | echo ' |
538 | 552 | </tbody> |
@@ -574,9 +588,10 @@ discard block |
||
574 | 588 | { |
575 | 589 | global $context, $scripturl, $txt, $modSettings; |
576 | 590 | |
577 | - if (!empty($context['saved_successful'])) |
|
578 | - echo ' |
|
591 | + if (!empty($context['saved_successful'])) { |
|
592 | + echo ' |
|
579 | 593 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
594 | + } |
|
580 | 595 | |
581 | 596 | // First section is for adding/removing words from the censored list. |
582 | 597 | echo ' |
@@ -591,11 +606,12 @@ discard block |
||
591 | 606 | <p>', $txt['admin_censored_where'], '</p>'; |
592 | 607 | |
593 | 608 | // Show text boxes for censoring [bad ] => [good ]. |
594 | - foreach ($context['censored_words'] as $vulgar => $proper) |
|
595 | - echo ' |
|
609 | + foreach ($context['censored_words'] as $vulgar => $proper) { |
|
610 | + echo ' |
|
596 | 611 | <div class="block"> |
597 | 612 | <input type="text" name="censor_vulgar[]" value="', $vulgar, '" size="30"> => <input type="text" name="censor_proper[]" value="', $proper, '" size="30"> |
598 | 613 | </div>'; |
614 | + } |
|
599 | 615 | |
600 | 616 | // Now provide a way to censor more words. |
601 | 617 | echo ' |
@@ -669,19 +685,21 @@ discard block |
||
669 | 685 | <div class="windowbg2 noup"> |
670 | 686 | ', $txt['not_done_reason']; |
671 | 687 | |
672 | - if (!empty($context['continue_percent'])) |
|
673 | - echo ' |
|
688 | + if (!empty($context['continue_percent'])) { |
|
689 | + echo ' |
|
674 | 690 | <div class="progress_bar"> |
675 | 691 | <div class="full_bar">', $context['continue_percent'], '%</div> |
676 | 692 | <div class="green_percent" style="width: ', $context['continue_percent'], '%;"> </div> |
677 | 693 | </div>'; |
694 | + } |
|
678 | 695 | |
679 | - if (!empty($context['substep_enabled'])) |
|
680 | - echo ' |
|
696 | + if (!empty($context['substep_enabled'])) { |
|
697 | + echo ' |
|
681 | 698 | <div class="progress_bar"> |
682 | 699 | <div class="full_bar">', $context['substep_title'], ' (', $context['substep_continue_percent'], '%)</div> |
683 | 700 | <div class="blue_percent" style="width: ', $context['substep_continue_percent'], '%;"> </div> |
684 | 701 | </div>'; |
702 | + } |
|
685 | 703 | |
686 | 704 | echo ' |
687 | 705 | <form action="', $scripturl, $context['continue_get_data'], '" method="post" accept-charset="', $context['character_set'], '" name="autoSubmit" id="autoSubmit"> |
@@ -716,35 +734,40 @@ discard block |
||
716 | 734 | { |
717 | 735 | global $context, $txt, $settings, $scripturl; |
718 | 736 | |
719 | - if (!empty($context['saved_successful'])) |
|
720 | - echo ' |
|
737 | + if (!empty($context['saved_successful'])) { |
|
738 | + echo ' |
|
721 | 739 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
722 | - elseif (!empty($context['saved_failed'])) |
|
723 | - echo ' |
|
740 | + } elseif (!empty($context['saved_failed'])) { |
|
741 | + echo ' |
|
724 | 742 | <div class="errorbox">', sprintf($txt['settings_not_saved'], $context['saved_failed']), '</div>'; |
743 | + } |
|
725 | 744 | |
726 | - if (!empty($context['settings_pre_javascript'])) |
|
727 | - echo ' |
|
745 | + if (!empty($context['settings_pre_javascript'])) { |
|
746 | + echo ' |
|
728 | 747 | <script>', $context['settings_pre_javascript'], '</script>'; |
748 | + } |
|
729 | 749 | |
730 | - if (!empty($context['settings_insert_above'])) |
|
731 | - echo $context['settings_insert_above']; |
|
750 | + if (!empty($context['settings_insert_above'])) { |
|
751 | + echo $context['settings_insert_above']; |
|
752 | + } |
|
732 | 753 | |
733 | 754 | echo ' |
734 | 755 | <div id="admincenter"> |
735 | 756 | <form id="admin_form_wrapper" action="', $context['post_url'], '" method="post" accept-charset="', $context['character_set'], '"', !empty($context['force_form_onsubmit']) ? ' onsubmit="' . $context['force_form_onsubmit'] . '"' : '', '>'; |
736 | 757 | |
737 | 758 | // Is there a custom title? |
738 | - if (isset($context['settings_title'])) |
|
739 | - echo ' |
|
759 | + if (isset($context['settings_title'])) { |
|
760 | + echo ' |
|
740 | 761 | <div class="cat_bar"> |
741 | 762 | <h3 class="catbg">', $context['settings_title'], '</h3> |
742 | 763 | </div>'; |
764 | + } |
|
743 | 765 | |
744 | 766 | // Have we got a message to display? |
745 | - if (!empty($context['settings_message'])) |
|
746 | - echo ' |
|
767 | + if (!empty($context['settings_message'])) { |
|
768 | + echo ' |
|
747 | 769 | <div class="information">', $context['settings_message'], '</div>'; |
770 | + } |
|
748 | 771 | |
749 | 772 | // Now actually loop through all the variables. |
750 | 773 | $is_open = false; |
@@ -797,8 +820,9 @@ discard block |
||
797 | 820 | // Hang about? Are you pulling my leg - a callback?! |
798 | 821 | if (is_array($config_var) && $config_var['type'] == 'callback') |
799 | 822 | { |
800 | - if (function_exists('template_callback_' . $config_var['name'])) |
|
801 | - call_user_func('template_callback_' . $config_var['name']); |
|
823 | + if (function_exists('template_callback_' . $config_var['name'])) { |
|
824 | + call_user_func('template_callback_' . $config_var['name']); |
|
825 | + } |
|
802 | 826 | |
803 | 827 | continue; |
804 | 828 | } |
@@ -828,9 +852,10 @@ discard block |
||
828 | 852 | $text_types = array('color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time'); |
829 | 853 | |
830 | 854 | // Show the [?] button. |
831 | - if ($config_var['help']) |
|
832 | - echo ' |
|
855 | + if ($config_var['help']) { |
|
856 | + echo ' |
|
833 | 857 | <a id="setting_', $config_var['name'], '_help" href="', $scripturl, '?action=helpadmin;help=', $config_var['help'], '" onclick="return reqOverlayDiv(this.href);"><span class="generic_icons help" title="', $txt['help'], '"></span></a> '; |
858 | + } |
|
834 | 859 | |
835 | 860 | echo ' |
836 | 861 | <a id="setting_', $config_var['name'], '"></a> <span', ($config_var['disabled'] ? ' style="color: #777777;"' : ($config_var['invalid'] ? ' class="error"' : '')), '><label for="', $config_var['name'], '">', $config_var['label'], '</label>', $subtext, ($config_var['type'] == 'password' ? '<br><em>' . $txt['admin_confirm_password'] . '</em>' : ''), '</span> |
@@ -839,22 +864,25 @@ discard block |
||
839 | 864 | $config_var['preinput']; |
840 | 865 | |
841 | 866 | // Show a check box. |
842 | - if ($config_var['type'] == 'check') |
|
843 | - echo ' |
|
867 | + if ($config_var['type'] == 'check') { |
|
868 | + echo ' |
|
844 | 869 | <input type="checkbox"', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '"', ($config_var['value'] ? ' checked' : ''), ' value="1" class="input_check">'; |
870 | + } |
|
845 | 871 | // Escape (via htmlspecialchars.) the text box. |
846 | - elseif ($config_var['type'] == 'password') |
|
847 | - echo ' |
|
872 | + elseif ($config_var['type'] == 'password') { |
|
873 | + echo ' |
|
848 | 874 | <input type="password"', $disabled, $javascript, ' name="', $config_var['name'], '[0]"', ($config_var['size'] ? ' size="' . $config_var['size'] . '"' : ''), ' value="*#fakepass#*" onfocus="this.value = \'\'; this.form.', $config_var['name'], '.disabled = false;" class="input_password"><br> |
849 | 875 | <input type="password" disabled id="', $config_var['name'], '" name="', $config_var['name'], '[1]"', ($config_var['size'] ? ' size="' . $config_var['size'] . '"' : ''), ' class="input_password">'; |
876 | + } |
|
850 | 877 | // Show a selection box. |
851 | 878 | elseif ($config_var['type'] == 'select') |
852 | 879 | { |
853 | 880 | echo ' |
854 | 881 | <select name="', $config_var['name'], '" id="', $config_var['name'], '" ', $javascript, $disabled, (!empty($config_var['multiple']) ? ' multiple="multiple"' : ''), (!empty($config_var['multiple']) && !empty($config_var['size']) ? ' size="' . $config_var['size'] . '"' : ''), '>'; |
855 | - foreach ($config_var['data'] as $option) |
|
856 | - echo ' |
|
882 | + foreach ($config_var['data'] as $option) { |
|
883 | + echo ' |
|
857 | 884 | <option value="', $option[0], '"', (!empty($config_var['value']) && ($option[0] == $config_var['value'] || (!empty($config_var['multiple']) && in_array($option[0], $config_var['value']))) ? ' selected' : ''), '>', $option[1], '</option>'; |
885 | + } |
|
858 | 886 | echo ' |
859 | 887 | </select>'; |
860 | 888 | } |
@@ -868,15 +896,17 @@ discard block |
||
868 | 896 | <legend class="board_selector"><a href="#">', $txt['select_boards_from_list'], '</a></legend>'; |
869 | 897 | foreach ($context['board_list'] as $id_cat => $cat) |
870 | 898 | { |
871 | - if (!$first) |
|
872 | - echo ' |
|
899 | + if (!$first) { |
|
900 | + echo ' |
|
873 | 901 | <hr>'; |
902 | + } |
|
874 | 903 | echo ' |
875 | 904 | <strong>', $cat['name'], '</strong> |
876 | 905 | <ul>'; |
877 | - foreach ($cat['boards'] as $id_board => $brd) |
|
878 | - echo ' |
|
906 | + foreach ($cat['boards'] as $id_board => $brd) { |
|
907 | + echo ' |
|
879 | 908 | <li><label><input type="checkbox" name="', $config_var['name'], '[', $brd['id'], ']" value="1" class="input_check"', in_array($brd['id'], $config_var['value']) ? ' checked' : '', '> ', $brd['child_level'] > 0 ? str_repeat(' ', $brd['child_level']) : '', $brd['name'], '</label></li>'; |
909 | + } |
|
880 | 910 | |
881 | 911 | echo ' |
882 | 912 | </ul>'; |
@@ -886,12 +916,14 @@ discard block |
||
886 | 916 | </fieldset>'; |
887 | 917 | } |
888 | 918 | // Text area? |
889 | - elseif ($config_var['type'] == 'large_text') |
|
890 | - echo ' |
|
919 | + elseif ($config_var['type'] == 'large_text') { |
|
920 | + echo ' |
|
891 | 921 | <textarea rows="', (!empty($config_var['size']) ? $config_var['size'] : (!empty($config_var['rows']) ? $config_var['rows'] : 4)), '" cols="', (!empty($config_var['cols']) ? $config_var['cols'] : 30), '" ', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '">', $config_var['value'], '</textarea>'; |
922 | + } |
|
892 | 923 | // Permission group? |
893 | - elseif ($config_var['type'] == 'permissions') |
|
894 | - theme_inline_permissions($config_var['name']); |
|
924 | + elseif ($config_var['type'] == 'permissions') { |
|
925 | + theme_inline_permissions($config_var['name']); |
|
926 | + } |
|
895 | 927 | // BBC selection? |
896 | 928 | elseif ($config_var['type'] == 'bbc') |
897 | 929 | { |
@@ -902,20 +934,22 @@ discard block |
||
902 | 934 | |
903 | 935 | foreach ($context['bbc_columns'] as $bbcColumn) |
904 | 936 | { |
905 | - foreach ($bbcColumn as $bbcTag) |
|
906 | - echo ' |
|
937 | + foreach ($bbcColumn as $bbcTag) { |
|
938 | + echo ' |
|
907 | 939 | <li class="list_bbc floatleft"> |
908 | 940 | <input type="checkbox" name="', $config_var['name'], '_enabledTags[]" id="tag_', $config_var['name'], '_', $bbcTag['tag'], '" value="', $bbcTag['tag'], '"', !in_array($bbcTag['tag'], $context['bbc_sections'][$config_var['name']]['disabled']) ? ' checked' : '', ' class="input_check"> <label for="tag_', $config_var['name'], '_', $bbcTag['tag'], '">', $bbcTag['tag'], '</label>', $bbcTag['show_help'] ? ' (<a href="' . $scripturl . '?action=helpadmin;help=tag_' . $bbcTag['tag'] . '" onclick="return reqOverlayDiv(this.href);">?</a>)' : '', ' |
909 | 941 | </li>'; |
942 | + } |
|
910 | 943 | } |
911 | 944 | echo ' </ul> |
912 | 945 | <input type="checkbox" id="bbc_', $config_var['name'], '_select_all" onclick="invertAll(this, this.form, \'', $config_var['name'], '_enabledTags\');"', $context['bbc_sections'][$config_var['name']]['all_selected'] ? ' checked' : '', ' class="input_check"> <label for="bbc_', $config_var['name'], '_select_all"><em>', $txt['bbcTagsToUse_select_all'], '</em></label> |
913 | 946 | </fieldset>'; |
914 | 947 | } |
915 | 948 | // A simple message? |
916 | - elseif ($config_var['type'] == 'var_message') |
|
917 | - echo ' |
|
949 | + elseif ($config_var['type'] == 'var_message') { |
|
950 | + echo ' |
|
918 | 951 | <div', !empty($config_var['name']) ? ' id="' . $config_var['name'] . '"' : '', '>', $config_var['var_message'], '</div>'; |
952 | + } |
|
919 | 953 | // Assume it must be a text box |
920 | 954 | else |
921 | 955 | { |
@@ -940,63 +974,70 @@ discard block |
||
940 | 974 | ' . $config_var['postinput'] : '', |
941 | 975 | '</dd>'; |
942 | 976 | } |
943 | - } |
|
944 | - |
|
945 | - else |
|
977 | + } else |
|
946 | 978 | { |
947 | 979 | // Just show a separator. |
948 | - if ($config_var == '') |
|
949 | - echo ' |
|
980 | + if ($config_var == '') { |
|
981 | + echo ' |
|
950 | 982 | </dl> |
951 | 983 | <hr> |
952 | 984 | <dl class="settings">'; |
953 | - else |
|
954 | - echo ' |
|
985 | + } else { |
|
986 | + echo ' |
|
955 | 987 | <dd> |
956 | 988 | <strong>' . $config_var . '</strong> |
957 | 989 | </dd>'; |
990 | + } |
|
958 | 991 | } |
959 | 992 | } |
960 | 993 | |
961 | - if ($is_open) |
|
962 | - echo ' |
|
994 | + if ($is_open) { |
|
995 | + echo ' |
|
963 | 996 | </dl>'; |
997 | + } |
|
964 | 998 | |
965 | - if (empty($context['settings_save_dont_show'])) |
|
966 | - echo ' |
|
999 | + if (empty($context['settings_save_dont_show'])) { |
|
1000 | + echo ' |
|
967 | 1001 | <input type="submit" value="', $txt['save'], '"', (!empty($context['save_disabled']) ? ' disabled' : ''), (!empty($context['settings_save_onclick']) ? ' onclick="' . $context['settings_save_onclick'] . '"' : ''), ' class="button_submit">'; |
1002 | + } |
|
968 | 1003 | |
969 | - if ($is_open) |
|
970 | - echo ' |
|
1004 | + if ($is_open) { |
|
1005 | + echo ' |
|
971 | 1006 | </div>'; |
1007 | + } |
|
972 | 1008 | |
973 | 1009 | |
974 | 1010 | // At least one token has to be used! |
975 | - if (isset($context['admin-ssc_token'])) |
|
976 | - echo ' |
|
1011 | + if (isset($context['admin-ssc_token'])) { |
|
1012 | + echo ' |
|
977 | 1013 | <input type="hidden" name="', $context['admin-ssc_token_var'], '" value="', $context['admin-ssc_token'], '">'; |
1014 | + } |
|
978 | 1015 | |
979 | - if (isset($context['admin-dbsc_token'])) |
|
980 | - echo ' |
|
1016 | + if (isset($context['admin-dbsc_token'])) { |
|
1017 | + echo ' |
|
981 | 1018 | <input type="hidden" name="', $context['admin-dbsc_token_var'], '" value="', $context['admin-dbsc_token'], '">'; |
1019 | + } |
|
982 | 1020 | |
983 | - if (isset($context['admin-mp_token'])) |
|
984 | - echo ' |
|
1021 | + if (isset($context['admin-mp_token'])) { |
|
1022 | + echo ' |
|
985 | 1023 | <input type="hidden" name="', $context['admin-mp_token_var'], '" value="', $context['admin-mp_token'], '">'; |
1024 | + } |
|
986 | 1025 | |
987 | 1026 | echo ' |
988 | 1027 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
989 | 1028 | </form> |
990 | 1029 | </div>'; |
991 | 1030 | |
992 | - if (!empty($context['settings_post_javascript'])) |
|
993 | - echo ' |
|
1031 | + if (!empty($context['settings_post_javascript'])) { |
|
1032 | + echo ' |
|
994 | 1033 | <script> |
995 | 1034 | ', $context['settings_post_javascript'], ' |
996 | 1035 | </script>'; |
1036 | + } |
|
997 | 1037 | |
998 | - if (!empty($context['settings_insert_below'])) |
|
999 | - echo $context['settings_insert_below']; |
|
1038 | + if (!empty($context['settings_insert_below'])) { |
|
1039 | + echo $context['settings_insert_below']; |
|
1040 | + } |
|
1000 | 1041 | |
1001 | 1042 | // We may have added a board listing. If we did, we need to make it work. |
1002 | 1043 | addInlineJavascript(' |
@@ -1019,9 +1060,10 @@ discard block |
||
1019 | 1060 | { |
1020 | 1061 | global $context, $txt; |
1021 | 1062 | |
1022 | - if (!empty($context['saved_successful'])) |
|
1023 | - echo ' |
|
1063 | + if (!empty($context['saved_successful'])) { |
|
1064 | + echo ' |
|
1024 | 1065 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
1066 | + } |
|
1025 | 1067 | |
1026 | 1068 | // Standard fields. |
1027 | 1069 | template_show_list('standard_profile_fields'); |
@@ -1053,11 +1095,12 @@ discard block |
||
1053 | 1095 | if (isset($_GET['msg'])) |
1054 | 1096 | { |
1055 | 1097 | loadLanguage('Errors'); |
1056 | - if (isset($txt['custom_option_' . $_GET['msg']])) |
|
1057 | - echo ' |
|
1098 | + if (isset($txt['custom_option_' . $_GET['msg']])) { |
|
1099 | + echo ' |
|
1058 | 1100 | <div class="errorbox">', |
1059 | 1101 | $txt['custom_option_' . $_GET['msg']], ' |
1060 | 1102 | </div>'; |
1103 | + } |
|
1061 | 1104 | } |
1062 | 1105 | |
1063 | 1106 | echo ' |
@@ -1123,9 +1166,10 @@ discard block |
||
1123 | 1166 | <dd> |
1124 | 1167 | <select name="placement" id="placement">'; |
1125 | 1168 | |
1126 | - foreach ($context['cust_profile_fields_placement'] as $order => $name) |
|
1127 | - echo ' |
|
1169 | + foreach ($context['cust_profile_fields_placement'] as $order => $name) { |
|
1170 | + echo ' |
|
1128 | 1171 | <option value="', $order, '"', $context['field']['placement'] == $order ? ' selected' : '', '>', $txt['custom_profile_placement_' . $name], '</option>'; |
1172 | + } |
|
1129 | 1173 | |
1130 | 1174 | echo ' |
1131 | 1175 | </select> |
@@ -1148,9 +1192,10 @@ discard block |
||
1148 | 1192 | </dt> |
1149 | 1193 | <dd> |
1150 | 1194 | <select name="field_type" id="field_type" onchange="updateInputBoxes();">'; |
1151 | - foreach (array('text', 'textarea', 'select', 'radio', 'check') as $field_type) |
|
1152 | - echo ' |
|
1195 | + foreach (array('text', 'textarea', 'select', 'radio', 'check') as $field_type) { |
|
1196 | + echo ' |
|
1153 | 1197 | <option value="', $field_type, '"', $context['field']['type'] == $field_type ? ' selected' : '', '>', $txt['custom_profile_type_' . $field_type], '</option>'; |
1198 | + } |
|
1154 | 1199 | |
1155 | 1200 | echo ' |
1156 | 1201 | </select> |
@@ -1251,9 +1296,10 @@ discard block |
||
1251 | 1296 | </fieldset> |
1252 | 1297 | <input type="submit" name="save" value="', $txt['save'], '" class="button_submit">'; |
1253 | 1298 | |
1254 | - if ($context['fid']) |
|
1255 | - echo ' |
|
1299 | + if ($context['fid']) { |
|
1300 | + echo ' |
|
1256 | 1301 | <input type="submit" name="delete" value="', $txt['delete'], '" data-confirm="', $txt['custom_edit_delete_sure'], '" class="button_submit you_sure">'; |
1302 | + } |
|
1257 | 1303 | |
1258 | 1304 | echo ' |
1259 | 1305 | </div> |
@@ -1296,8 +1342,7 @@ discard block |
||
1296 | 1342 | { |
1297 | 1343 | echo ' |
1298 | 1344 | <p class="centertext"><strong>', $txt['admin_search_results_none'], '</strong></p>'; |
1299 | - } |
|
1300 | - else |
|
1345 | + } else |
|
1301 | 1346 | { |
1302 | 1347 | echo ' |
1303 | 1348 | <ol class="search_results">'; |
@@ -1323,9 +1368,10 @@ discard block |
||
1323 | 1368 | <li> |
1324 | 1369 | <a href="', $result['url'], '"><strong>', $result['name'], '</strong></a> [', isset($txt['admin_search_section_' . $result['type']]) ? $txt['admin_search_section_' . $result['type']] : $result['type'], ']'; |
1325 | 1370 | |
1326 | - if ($result['help']) |
|
1327 | - echo ' |
|
1371 | + if ($result['help']) { |
|
1372 | + echo ' |
|
1328 | 1373 | <p class="double_height">', $result['help'], '</p>'; |
1374 | + } |
|
1329 | 1375 | |
1330 | 1376 | echo ' |
1331 | 1377 | </li>'; |
@@ -1365,18 +1411,20 @@ discard block |
||
1365 | 1411 | <strong>', $txt['setup_verification_answer'], '</strong> |
1366 | 1412 | </dd>'; |
1367 | 1413 | |
1368 | - if (!empty($context['qa_by_lang'][$lang_id])) |
|
1369 | - foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
1414 | + if (!empty($context['qa_by_lang'][$lang_id])) { |
|
1415 | + foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
1370 | 1416 | { |
1371 | 1417 | $question = $context['question_answers'][$q_id]; |
1418 | + } |
|
1372 | 1419 | echo ' |
1373 | 1420 | <dt> |
1374 | 1421 | <input type="text" name="question[', $lang_id, '][', $q_id, ']" value="', $question['question'], '" size="50" class="input_text verification_question"> |
1375 | 1422 | </dt> |
1376 | 1423 | <dd>'; |
1377 | - foreach ($question['answers'] as $answer) |
|
1378 | - echo ' |
|
1424 | + foreach ($question['answers'] as $answer) { |
|
1425 | + echo ' |
|
1379 | 1426 | <input type="text" name="answer[', $lang_id, '][', $q_id, '][]" value="', $answer, '" size="50" class="input_text verification_answer">'; |
1427 | + } |
|
1380 | 1428 | |
1381 | 1429 | echo ' |
1382 | 1430 | <div class="qa_add_answer"><a href="javascript:void(0);" onclick="return addAnswer(this);">[ ', $txt['setup_verification_add_answer'], ' ]</a></div> |
@@ -1415,11 +1463,12 @@ discard block |
||
1415 | 1463 | ', $txt['errors_found'], ': |
1416 | 1464 | <ul>'; |
1417 | 1465 | |
1418 | - foreach ($context['repair_errors'] as $error) |
|
1419 | - echo ' |
|
1466 | + foreach ($context['repair_errors'] as $error) { |
|
1467 | + echo ' |
|
1420 | 1468 | <li> |
1421 | 1469 | ', $error, ' |
1422 | 1470 | </li>'; |
1471 | + } |
|
1423 | 1472 | |
1424 | 1473 | echo ' |
1425 | 1474 | </ul> |
@@ -1429,16 +1478,15 @@ discard block |
||
1429 | 1478 | <p class="padding"> |
1430 | 1479 | <strong><a href="', $scripturl, '?action=admin;area=repairboards;fixErrors;', $context['session_var'], '=', $context['session_id'], '">', $txt['yes'], '</a> - <a href="', $scripturl, '?action=admin;area=maintain">', $txt['no'], '</a></strong> |
1431 | 1480 | </p>'; |
1432 | - } |
|
1433 | - else |
|
1434 | - echo ' |
|
1481 | + } else { |
|
1482 | + echo ' |
|
1435 | 1483 | <p>', $txt['maintain_no_errors'], '</p> |
1436 | 1484 | <p class="padding"> |
1437 | 1485 | <a href="', $scripturl, '?action=admin;area=maintain;sa=routine">', $txt['maintain_return'], '</a> |
1438 | 1486 | </p>'; |
1487 | + } |
|
1439 | 1488 | |
1440 | - } |
|
1441 | - else |
|
1489 | + } else |
|
1442 | 1490 | { |
1443 | 1491 | if (!empty($context['redirect_to_recount'])) |
1444 | 1492 | { |
@@ -1450,8 +1498,7 @@ discard block |
||
1450 | 1498 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
1451 | 1499 | <input type="submit" name="recount" id="recount_now" value="', $txt['errors_recount_now'], '"> |
1452 | 1500 | </form>'; |
1453 | - } |
|
1454 | - else |
|
1501 | + } else |
|
1455 | 1502 | { |
1456 | 1503 | echo ' |
1457 | 1504 | <p>', $txt['errors_fixed'], '</p> |
@@ -1603,8 +1650,8 @@ discard block |
||
1603 | 1650 | function template_admin_quick_search() |
1604 | 1651 | { |
1605 | 1652 | global $context, $txt, $scripturl; |
1606 | - if ($context['user']['is_admin']) |
|
1607 | - echo ' |
|
1653 | + if ($context['user']['is_admin']) { |
|
1654 | + echo ' |
|
1608 | 1655 | <span class="floatright"> |
1609 | 1656 | <span class="generic_icons filter centericon"></span> |
1610 | 1657 | <input type="search" name="search_term" value="', $txt['admin_search'], '" onclick="if (this.value == \'', $txt['admin_search'], '\') this.value = \'\';" class="input_text"> |
@@ -1615,6 +1662,7 @@ discard block |
||
1615 | 1662 | </select> |
1616 | 1663 | <input type="submit" name="search_go" id="search_go" value="', $txt['admin_search_go'], '" class="button_submit"> |
1617 | 1664 | </span>'; |
1618 | -} |
|
1665 | + } |
|
1666 | + } |
|
1619 | 1667 | |
1620 | 1668 | ?> |
1621 | 1669 | \ No newline at end of file |
@@ -39,18 +39,21 @@ discard block |
||
39 | 39 | ); |
40 | 40 | |
41 | 41 | // No file? Thats bad. |
42 | -if (!isset($_SERVER['argv'], $_SERVER['argv'][1])) |
|
42 | +if (!isset($_SERVER['argv'], $_SERVER['argv'][1])) { |
|
43 | 43 | die('Error: No File specified' . "\n"); |
44 | +} |
|
44 | 45 | |
45 | 46 | // The file has to exist. |
46 | 47 | $currentFile = $_SERVER['argv'][1]; |
47 | -if (!file_exists($currentFile)) |
|
48 | +if (!file_exists($currentFile)) { |
|
48 | 49 | die('Error: File does not exist' . "\n"); |
50 | +} |
|
49 | 51 | |
50 | 52 | // Is this ignored? |
51 | -foreach ($ignoreFiles as $if) |
|
53 | +foreach ($ignoreFiles as $if) { |
|
52 | 54 | if (preg_match('~' . $if . '~i', $currentFile)) |
53 | 55 | die; |
56 | +} |
|
54 | 57 | |
55 | 58 | // Less efficent than opening a file with fopen, but we want to be sure to get the right end of the file. file_get_contents |
56 | 59 | $file = fopen($currentFile, 'r'); |
@@ -60,17 +63,21 @@ discard block |
||
60 | 63 | $contents = fread($file, 100); |
61 | 64 | |
62 | 65 | // There is some white space here. |
63 | -if (preg_match('~\?>\s+$~', $contents, $matches)) |
|
66 | +if (preg_match('~\?>\s+$~', $contents, $matches)) { |
|
64 | 67 | die('Error: End of File contains extra spaces in ' . $currentFile . "\n"); |
68 | +} |
|
65 | 69 | |
66 | 70 | // Test to see if its there even, SMF 2.1 base package needs it there in our main files to allow package manager to properly handle end operations. Customizations do not need it. |
67 | -if (!preg_match('~\?>$~', $contents, $matches)) |
|
71 | +if (!preg_match('~\?>$~', $contents, $matches)) { |
|
68 | 72 | die('Error: End of File missing in ' . $currentFile . "\n"); |
73 | +} |
|
69 | 74 | |
70 | 75 | // Test to see if a function/class ending is here but with no return (because we are OCD). |
71 | -if (preg_match('~}([\r]?\n)?\?>~', $contents, $matches)) |
|
76 | +if (preg_match('~}([\r]?\n)?\?>~', $contents, $matches)) { |
|
72 | 77 | echo('Error: Incorrect return(s) after last function/class but before EOF in ' . $currentFile . "\n"); |
78 | +} |
|
73 | 79 | |
74 | 80 | // Test to see if a string ending is here but with no return (because we are OCD). |
75 | -if (preg_match('~;([\r]?\n)?\?>~', $contents, $matches)) |
|
76 | - echo('Error: Incorrect return(s) after last string but before EOF in ' . $currentFile . "\n"); |
|
77 | 81 | \ No newline at end of file |
82 | +if (preg_match('~;([\r]?\n)?\?>~', $contents, $matches)) { |
|
83 | + echo('Error: Incorrect return(s) after last string but before EOF in ' . $currentFile . "\n"); |
|
84 | +} |
@@ -15,8 +15,9 @@ discard block |
||
15 | 15 | * @version 2.1 Beta 3 |
16 | 16 | */ |
17 | 17 | |
18 | -if (!defined('SMF')) |
|
18 | +if (!defined('SMF')) { |
|
19 | 19 | die('No direct access...'); |
20 | +} |
|
20 | 21 | |
21 | 22 | /** |
22 | 23 | * Main dispatcher. This function checks permissions and passes control through to the relevant section. |
@@ -245,8 +246,9 @@ discard block |
||
245 | 246 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
246 | 247 | { |
247 | 248 | // Private PM/email subjects and similar shouldn't be shown in the mailbox area. |
248 | - if (!empty($row['private'])) |
|
249 | - $row['subject'] = $txt['personal_message']; |
|
249 | + if (!empty($row['private'])) { |
|
250 | + $row['subject'] = $txt['personal_message']; |
|
251 | + } |
|
250 | 252 | |
251 | 253 | $mails[] = $row; |
252 | 254 | } |
@@ -300,8 +302,9 @@ discard block |
||
300 | 302 | $element = substr($key, strrpos($key, '_') + 1); |
301 | 303 | $processedBirthdayEmails[$index][$element] = $value; |
302 | 304 | } |
303 | - foreach ($processedBirthdayEmails as $index => $dummy) |
|
304 | - $emails[$index] = $index; |
|
305 | + foreach ($processedBirthdayEmails as $index => $dummy) { |
|
306 | + $emails[$index] = $index; |
|
307 | + } |
|
305 | 308 | |
306 | 309 | $config_vars = array( |
307 | 310 | // Mail queue stuff, this rocks ;) |
@@ -322,8 +325,9 @@ discard block |
||
322 | 325 | |
323 | 326 | call_integration_hook('integrate_modify_mail_settings', array(&$config_vars)); |
324 | 327 | |
325 | - if ($return_config) |
|
326 | - return $config_vars; |
|
328 | + if ($return_config) { |
|
329 | + return $config_vars; |
|
330 | + } |
|
327 | 331 | |
328 | 332 | // Saving? |
329 | 333 | if (isset($_GET['save'])) |
@@ -398,9 +402,9 @@ discard block |
||
398 | 402 | ); |
399 | 403 | list ($_GET['te']) = $smcFunc['db_fetch_row']($request); |
400 | 404 | $smcFunc['db_free_result']($request); |
405 | + } else { |
|
406 | + $_GET['te'] = (int) $_GET['te']; |
|
401 | 407 | } |
402 | - else |
|
403 | - $_GET['te'] = (int) $_GET['te']; |
|
404 | 408 | |
405 | 409 | $_GET['sent'] = isset($_GET['sent']) ? (int) $_GET['sent'] : 0; |
406 | 410 | |
@@ -424,12 +428,14 @@ discard block |
||
424 | 428 | |
425 | 429 | // Try get more time... |
426 | 430 | @set_time_limit(600); |
427 | - if (function_exists('apache_reset_timeout')) |
|
428 | - @apache_reset_timeout(); |
|
431 | + if (function_exists('apache_reset_timeout')) { |
|
432 | + @apache_reset_timeout(); |
|
433 | + } |
|
429 | 434 | |
430 | 435 | // Have we already used our maximum time? |
431 | - if (time() - array_sum(explode(' ', $time_start)) < 5) |
|
432 | - return; |
|
436 | + if (time() - array_sum(explode(' ', $time_start)) < 5) { |
|
437 | + return; |
|
438 | + } |
|
433 | 439 | |
434 | 440 | $context['continue_get_data'] = '?action=admin;area=mailqueue;sa=clear;te=' . $_GET['te'] . ';sent=' . $_GET['sent'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
435 | 441 | $context['page_title'] = $txt['not_done_title']; |
@@ -459,8 +465,9 @@ discard block |
||
459 | 465 | { |
460 | 466 | global $txt; |
461 | 467 | |
462 | - if ($time_diff < 0) |
|
463 | - $time_diff = 0; |
|
468 | + if ($time_diff < 0) { |
|
469 | + $time_diff = 0; |
|
470 | + } |
|
464 | 471 | |
465 | 472 | // Just do a bit of an if fest... |
466 | 473 | if ($time_diff > 86400) |
@@ -481,8 +488,9 @@ discard block |
||
481 | 488 | return sprintf($minutes == 1 ? $txt['mq_minute'] : $txt['mq_minutes'], $minutes); |
482 | 489 | } |
483 | 490 | // Otherwise must be second |
484 | - else |
|
485 | - return sprintf($time_diff == 1 ? $txt['mq_second'] : $txt['mq_seconds'], $time_diff); |
|
486 | -} |
|
491 | + else { |
|
492 | + return sprintf($time_diff == 1 ? $txt['mq_second'] : $txt['mq_seconds'], $time_diff); |
|
493 | + } |
|
494 | + } |
|
487 | 495 | |
488 | 496 | ?> |
489 | 497 | \ No newline at end of file |
@@ -58,15 +58,16 @@ |
||
58 | 58 | // Parent hash. |
59 | 59 | 'P' => shell_exec('git show -s --format=%P HEAD'), |
60 | 60 | ))); |
61 | -} |
|
62 | -else |
|
61 | +} else { |
|
63 | 62 | $debugSecondary = base64_encode(json_encode(array(NULL))); |
63 | +} |
|
64 | 64 | |
65 | 65 | $result = stripos($lastLine, 'Signed-off-by:'); |
66 | 66 | if ($result === false) |
67 | 67 | { |
68 | 68 | // Try 2. |
69 | 69 | $result2 = stripos($lastLine, 'Signed by'); |
70 | - if ($result2 === false) |
|
71 | - die('Error: Signed-off-by not found in commit message [' . $lastLine . ']' . '[' . $message . ']' . '[' . $debugSecondary . '][' . $debugMaster . ']' . "\n"); |
|
72 | -} |
|
73 | 70 | \ No newline at end of file |
71 | + if ($result2 === false) { |
|
72 | + die('Error: Signed-off-by not found in commit message [' . $lastLine . ']' . '[' . $message . ']' . '[' . $debugSecondary . '][' . $debugMaster . ']' . "\n"); |
|
73 | + } |
|
74 | + } |
|
74 | 75 | \ No newline at end of file |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * This is the main function for the languages area. |
@@ -153,11 +154,11 @@ discard block |
||
153 | 154 | $language_list = new xmlArray(fetch_web_data($url), true); |
154 | 155 | |
155 | 156 | // Check that the site responded and that the language exists. |
156 | - if (!$language_list->exists('languages')) |
|
157 | - $context['smf_error'] = 'no_response'; |
|
158 | - elseif (!$language_list->exists('languages/language')) |
|
159 | - $context['smf_error'] = 'no_files'; |
|
160 | - else |
|
157 | + if (!$language_list->exists('languages')) { |
|
158 | + $context['smf_error'] = 'no_response'; |
|
159 | + } elseif (!$language_list->exists('languages/language')) { |
|
160 | + $context['smf_error'] = 'no_files'; |
|
161 | + } else |
|
161 | 162 | { |
162 | 163 | $language_list = $language_list->path('languages[0]'); |
163 | 164 | $lang_files = $language_list->set('language'); |
@@ -165,8 +166,9 @@ discard block |
||
165 | 166 | foreach ($lang_files as $file) |
166 | 167 | { |
167 | 168 | // Were we searching? |
168 | - if (!empty($context['smf_search_term']) && strpos($file->fetch('name'), $smcFunc['strtolower']($context['smf_search_term'])) === false) |
|
169 | - continue; |
|
169 | + if (!empty($context['smf_search_term']) && strpos($file->fetch('name'), $smcFunc['strtolower']($context['smf_search_term'])) === false) { |
|
170 | + continue; |
|
171 | + } |
|
170 | 172 | |
171 | 173 | $smf_languages[] = array( |
172 | 174 | 'id' => $file->fetch('id'), |
@@ -177,10 +179,11 @@ discard block |
||
177 | 179 | 'install_link' => '<a href="' . $scripturl . '?action=admin;area=languages;sa=downloadlang;did=' . $file->fetch('id') . ';' . $context['session_var'] . '=' . $context['session_id'] . '">' . $txt['add_language_smf_install'] . '</a>', |
178 | 180 | ); |
179 | 181 | } |
180 | - if (empty($smf_languages)) |
|
181 | - $context['smf_error'] = 'no_files'; |
|
182 | - else |
|
183 | - return $smf_languages; |
|
182 | + if (empty($smf_languages)) { |
|
183 | + $context['smf_error'] = 'no_files'; |
|
184 | + } else { |
|
185 | + return $smf_languages; |
|
186 | + } |
|
184 | 187 | } |
185 | 188 | } |
186 | 189 | |
@@ -202,8 +205,9 @@ discard block |
||
202 | 205 | require_once($sourcedir . '/Subs-Package.php'); |
203 | 206 | |
204 | 207 | // Clearly we need to know what to request. |
205 | - if (!isset($_GET['did'])) |
|
206 | - fatal_lang_error('no_access', false); |
|
208 | + if (!isset($_GET['did'])) { |
|
209 | + fatal_lang_error('no_access', false); |
|
210 | + } |
|
207 | 211 | |
208 | 212 | // Some lovely context. |
209 | 213 | $context['download_id'] = $_GET['did']; |
@@ -223,8 +227,9 @@ discard block |
||
223 | 227 | foreach ($_POST['copy_file'] as $file) |
224 | 228 | { |
225 | 229 | // Check it's not very bad. |
226 | - if (strpos($file, '..') !== false || (strpos($file, 'Themes') !== 0 && !preg_match('~agreement\.[A-Za-z-_0-9]+\.txt$~', $file))) |
|
227 | - fatal_error($txt['languages_download_illegal_paths']); |
|
230 | + if (strpos($file, '..') !== false || (strpos($file, 'Themes') !== 0 && !preg_match('~agreement\.[A-Za-z-_0-9]+\.txt$~', $file))) { |
|
231 | + fatal_error($txt['languages_download_illegal_paths']); |
|
232 | + } |
|
228 | 233 | |
229 | 234 | $chmod_files[] = $boarddir . '/' . $file; |
230 | 235 | $install_files[] = $file; |
@@ -235,8 +240,9 @@ discard block |
||
235 | 240 | $files_left = $file_status['files']['notwritable']; |
236 | 241 | |
237 | 242 | // Something not writable? |
238 | - if (!empty($files_left)) |
|
239 | - $context['error_message'] = $txt['languages_download_not_chmod']; |
|
243 | + if (!empty($files_left)) { |
|
244 | + $context['error_message'] = $txt['languages_download_not_chmod']; |
|
245 | + } |
|
240 | 246 | // Otherwise, go go go! |
241 | 247 | elseif (!empty($install_files)) |
242 | 248 | { |
@@ -251,11 +257,13 @@ discard block |
||
251 | 257 | } |
252 | 258 | |
253 | 259 | // Open up the old china. |
254 | - if (!isset($archive_content)) |
|
255 | - $archive_content = read_tgz_file('http://download.simplemachines.org/fetch_language.php?version=' . urlencode(strtr($forum_version, array('SMF ' => ''))) . ';fetch=' . urlencode($_GET['did']), null); |
|
260 | + if (!isset($archive_content)) { |
|
261 | + $archive_content = read_tgz_file('http://download.simplemachines.org/fetch_language.php?version=' . urlencode(strtr($forum_version, array('SMF ' => ''))) . ';fetch=' . urlencode($_GET['did']), null); |
|
262 | + } |
|
256 | 263 | |
257 | - if (empty($archive_content)) |
|
258 | - fatal_error($txt['add_language_error_no_response']); |
|
264 | + if (empty($archive_content)) { |
|
265 | + fatal_error($txt['add_language_error_no_response']); |
|
266 | + } |
|
259 | 267 | |
260 | 268 | // Now for each of the files, let's do some *stuff* |
261 | 269 | $context['files'] = array( |
@@ -270,8 +278,9 @@ discard block |
||
270 | 278 | $extension = substr($filename, strrpos($filename, '.') + 1); |
271 | 279 | |
272 | 280 | // Don't do anything with files we don't understand. |
273 | - if (!in_array($extension, array('php', 'jpg', 'gif', 'jpeg', 'png', 'txt'))) |
|
274 | - continue; |
|
281 | + if (!in_array($extension, array('php', 'jpg', 'gif', 'jpeg', 'png', 'txt'))) { |
|
282 | + continue; |
|
283 | + } |
|
275 | 284 | |
276 | 285 | // Basic data. |
277 | 286 | $context_data = array( |
@@ -290,8 +299,9 @@ discard block |
||
290 | 299 | // Does the file exist, is it different and can we overwrite? |
291 | 300 | if (file_exists($boarddir . '/' . $file['filename'])) |
292 | 301 | { |
293 | - if (is_writable($boarddir . '/' . $file['filename'])) |
|
294 | - $context_data['writable'] = true; |
|
302 | + if (is_writable($boarddir . '/' . $file['filename'])) { |
|
303 | + $context_data['writable'] = true; |
|
304 | + } |
|
295 | 305 | |
296 | 306 | // Finally, do we actually think the content has changed? |
297 | 307 | if ($file['size'] == filesize($boarddir . '/' . $file['filename']) && $file['md5'] == md5_file($boarddir . '/' . $file['filename'])) |
@@ -304,16 +314,17 @@ discard block |
||
304 | 314 | { |
305 | 315 | $context_data['exists'] = 'same'; |
306 | 316 | $context_data['default_copy'] = false; |
317 | + } else { |
|
318 | + $context_data['exists'] = 'different'; |
|
307 | 319 | } |
308 | - else |
|
309 | - $context_data['exists'] = 'different'; |
|
310 | 320 | } |
311 | 321 | // No overwrite? |
312 | 322 | else |
313 | 323 | { |
314 | 324 | // Can we at least stick it in the directory... |
315 | - if (is_writable($boarddir . '/' . $dirname)) |
|
316 | - $context_data['writable'] = true; |
|
325 | + if (is_writable($boarddir . '/' . $dirname)) { |
|
326 | + $context_data['writable'] = true; |
|
327 | + } |
|
317 | 328 | } |
318 | 329 | |
319 | 330 | // I love PHP files, that's why I'm a developer and not an artistic type spending my time drinking absinth and living a life of sin... |
@@ -328,8 +339,9 @@ discard block |
||
328 | 339 | list ($name, $language) = explode('.', $filename); |
329 | 340 | |
330 | 341 | // Let's get the new version, I like versions, they tell me that I'm up to date. |
331 | - if (preg_match('~\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '~i', $file['preview'], $match) == 1) |
|
332 | - $context_data['version'] = $match[1]; |
|
342 | + if (preg_match('~\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '~i', $file['preview'], $match) == 1) { |
|
343 | + $context_data['version'] = $match[1]; |
|
344 | + } |
|
333 | 345 | |
334 | 346 | // Now does the old file exist - if so what is it's version? |
335 | 347 | if (file_exists($boarddir . '/' . $file['filename'])) |
@@ -345,34 +357,35 @@ discard block |
||
345 | 357 | $context_data['cur_version'] = $match[1]; |
346 | 358 | |
347 | 359 | // How does this compare? |
348 | - if ($context_data['cur_version'] == $context_data['version']) |
|
349 | - $context_data['version_compare'] = 'same'; |
|
350 | - elseif ($context_data['cur_version'] > $context_data['version']) |
|
351 | - $context_data['version_compare'] = 'older'; |
|
360 | + if ($context_data['cur_version'] == $context_data['version']) { |
|
361 | + $context_data['version_compare'] = 'same'; |
|
362 | + } elseif ($context_data['cur_version'] > $context_data['version']) { |
|
363 | + $context_data['version_compare'] = 'older'; |
|
364 | + } |
|
352 | 365 | |
353 | 366 | // Don't recommend copying if the version is the same. |
354 | - if ($context_data['version_compare'] != 'newer') |
|
355 | - $context_data['default_copy'] = false; |
|
367 | + if ($context_data['version_compare'] != 'newer') { |
|
368 | + $context_data['default_copy'] = false; |
|
369 | + } |
|
356 | 370 | } |
357 | 371 | } |
358 | 372 | |
359 | 373 | // Add the context data to the main set. |
360 | 374 | $context['files']['lang'][] = $context_data; |
361 | - } |
|
362 | - elseif ($extension == '.txt' && stripos($filename, 'agreement') !== false) |
|
375 | + } elseif ($extension == '.txt' && stripos($filename, 'agreement') !== false) |
|
363 | 376 | { |
364 | 377 | // Registration agreement is a primary file |
365 | 378 | $context['files']['lang'][] = $context_data; |
366 | - } |
|
367 | - else |
|
379 | + } else |
|
368 | 380 | { |
369 | 381 | // There shouldn't be anything else, but load this into "other" in case we decide to handle it in the future |
370 | 382 | $context['files']['other'][] = $context_data; |
371 | 383 | } |
372 | 384 | |
373 | 385 | // Collect together all non-writable areas. |
374 | - if (!$context_data['writable']) |
|
375 | - $context['make_writable'][] = $context_data['destination']; |
|
386 | + if (!$context_data['writable']) { |
|
387 | + $context['make_writable'][] = $context_data['destination']; |
|
388 | + } |
|
376 | 389 | } |
377 | 390 | |
378 | 391 | // Before we go to far can we make anything writable, eh, eh? |
@@ -387,22 +400,24 @@ discard block |
||
387 | 400 | { |
388 | 401 | if ($type == 'lang') |
389 | 402 | { |
390 | - foreach ($data as $k => $file) |
|
391 | - if (!$file['writable'] && !in_array($file['destination'], $context['still_not_writable'])) |
|
403 | + foreach ($data as $k => $file) { |
|
404 | + if (!$file['writable'] && !in_array($file['destination'], $context['still_not_writable'])) |
|
392 | 405 | $context['files'][$type][$k]['writable'] = true; |
393 | - } |
|
394 | - else |
|
406 | + } |
|
407 | + } else |
|
395 | 408 | { |
396 | - foreach ($data as $theme => $files) |
|
397 | - foreach ($files as $k => $file) |
|
409 | + foreach ($data as $theme => $files) { |
|
410 | + foreach ($files as $k => $file) |
|
398 | 411 | if (!$file['writable'] && !in_array($file['destination'], $context['still_not_writable'])) |
399 | 412 | $context['files'][$type][$theme][$k]['writable'] = true; |
413 | + } |
|
400 | 414 | } |
401 | 415 | } |
402 | 416 | |
403 | 417 | // Are we going to need more language stuff? |
404 | - if (!empty($context['still_not_writable'])) |
|
405 | - loadLanguage('Packages'); |
|
418 | + if (!empty($context['still_not_writable'])) { |
|
419 | + loadLanguage('Packages'); |
|
420 | + } |
|
406 | 421 | } |
407 | 422 | |
408 | 423 | // This is the list for the main files. |
@@ -615,12 +630,13 @@ discard block |
||
615 | 630 | highlightSelected("list_language_list_' . ($language == '' ? 'english' : $language) . '");', true); |
616 | 631 | |
617 | 632 | // Display a warning if we cannot edit the default setting. |
618 | - if (!is_writable($boarddir . '/Settings.php')) |
|
619 | - $listOptions['additional_rows'][] = array( |
|
633 | + if (!is_writable($boarddir . '/Settings.php')) { |
|
634 | + $listOptions['additional_rows'][] = array( |
|
620 | 635 | 'position' => 'after_title', |
621 | 636 | 'value' => $txt['language_settings_writable'], |
622 | 637 | 'class' => 'smalltext alert', |
623 | 638 | ); |
639 | + } |
|
624 | 640 | |
625 | 641 | require_once($sourcedir . '/Subs-List.php'); |
626 | 642 | createList($listOptions); |
@@ -662,10 +678,11 @@ discard block |
||
662 | 678 | |
663 | 679 | // Put them back. |
664 | 680 | $settings['actual_theme_dir'] = $backup_actual_theme_dir; |
665 | - if (!empty($backup_base_theme_dir)) |
|
666 | - $settings['base_theme_dir'] = $backup_base_theme_dir; |
|
667 | - else |
|
668 | - unset($settings['base_theme_dir']); |
|
681 | + if (!empty($backup_base_theme_dir)) { |
|
682 | + $settings['base_theme_dir'] = $backup_base_theme_dir; |
|
683 | + } else { |
|
684 | + unset($settings['base_theme_dir']); |
|
685 | + } |
|
669 | 686 | |
670 | 687 | // Get the language files and data... |
671 | 688 | foreach ($context['languages'] as $lang) |
@@ -694,13 +711,15 @@ discard block |
||
694 | 711 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
695 | 712 | { |
696 | 713 | // Default? |
697 | - if (empty($row['lngfile']) || !isset($languages[$row['lngfile']])) |
|
698 | - $row['lngfile'] = $language; |
|
714 | + if (empty($row['lngfile']) || !isset($languages[$row['lngfile']])) { |
|
715 | + $row['lngfile'] = $language; |
|
716 | + } |
|
699 | 717 | |
700 | - if (!isset($languages[$row['lngfile']]) && isset($languages['english'])) |
|
701 | - $languages['english']['count'] += $row['num_users']; |
|
702 | - elseif (isset($languages[$row['lngfile']])) |
|
703 | - $languages[$row['lngfile']]['count'] += $row['num_users']; |
|
718 | + if (!isset($languages[$row['lngfile']]) && isset($languages['english'])) { |
|
719 | + $languages['english']['count'] += $row['num_users']; |
|
720 | + } elseif (isset($languages[$row['lngfile']])) { |
|
721 | + $languages[$row['lngfile']]['count'] += $row['num_users']; |
|
722 | + } |
|
704 | 723 | } |
705 | 724 | $smcFunc['db_free_result']($request); |
706 | 725 | |
@@ -740,13 +759,15 @@ discard block |
||
740 | 759 | |
741 | 760 | call_integration_hook('integrate_language_settings', array(&$config_vars)); |
742 | 761 | |
743 | - if ($return_config) |
|
744 | - return $config_vars; |
|
762 | + if ($return_config) { |
|
763 | + return $config_vars; |
|
764 | + } |
|
745 | 765 | |
746 | 766 | // Get our languages. No cache |
747 | 767 | getLanguages(false); |
748 | - foreach ($context['languages'] as $lang) |
|
749 | - $config_vars['language'][4][$lang['filename']] = array($lang['filename'], $lang['name']); |
|
768 | + foreach ($context['languages'] as $lang) { |
|
769 | + $config_vars['language'][4][$lang['filename']] = array($lang['filename'], $lang['name']); |
|
770 | + } |
|
750 | 771 | |
751 | 772 | // Saving settings? |
752 | 773 | if (isset($_REQUEST['save'])) |
@@ -756,8 +777,9 @@ discard block |
||
756 | 777 | call_integration_hook('integrate_save_language_settings', array(&$config_vars)); |
757 | 778 | |
758 | 779 | saveSettings($config_vars); |
759 | - if (!$settings_not_writable && !$settings_backup_fail) |
|
760 | - $_SESSION['adm-save'] = true; |
|
780 | + if (!$settings_not_writable && !$settings_backup_fail) { |
|
781 | + $_SESSION['adm-save'] = true; |
|
782 | + } |
|
761 | 783 | redirectexit('action=admin;area=languages;sa=settings'); |
762 | 784 | } |
763 | 785 | |
@@ -766,10 +788,11 @@ discard block |
||
766 | 788 | $context['settings_title'] = $txt['language_settings']; |
767 | 789 | $context['save_disabled'] = $settings_not_writable; |
768 | 790 | |
769 | - if ($settings_not_writable) |
|
770 | - $context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>'; |
|
771 | - elseif ($settings_backup_fail) |
|
772 | - $context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>'; |
|
791 | + if ($settings_not_writable) { |
|
792 | + $context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>'; |
|
793 | + } elseif ($settings_backup_fail) { |
|
794 | + $context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>'; |
|
795 | + } |
|
773 | 796 | |
774 | 797 | // Fill the config array. |
775 | 798 | prepareServerSettingsContext($config_vars); |
@@ -816,8 +839,9 @@ discard block |
||
816 | 839 | 'theme_dir' => $settings['default_theme_dir'], |
817 | 840 | ), |
818 | 841 | ); |
819 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
820 | - $themes[$row['id_theme']][$row['variable']] = $row['value']; |
|
842 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
843 | + $themes[$row['id_theme']][$row['variable']] = $row['value']; |
|
844 | + } |
|
821 | 845 | $smcFunc['db_free_result']($request); |
822 | 846 | |
823 | 847 | // This will be where we look |
@@ -829,14 +853,16 @@ discard block |
||
829 | 853 | // Check we have themes with a path and a name - just in case - and add the path. |
830 | 854 | foreach ($themes as $id => $data) |
831 | 855 | { |
832 | - if (count($data) != 2) |
|
833 | - unset($themes[$id]); |
|
834 | - elseif (is_dir($data['theme_dir'] . '/languages')) |
|
835 | - $lang_dirs[$id] = $data['theme_dir'] . '/languages'; |
|
856 | + if (count($data) != 2) { |
|
857 | + unset($themes[$id]); |
|
858 | + } elseif (is_dir($data['theme_dir'] . '/languages')) { |
|
859 | + $lang_dirs[$id] = $data['theme_dir'] . '/languages'; |
|
860 | + } |
|
836 | 861 | |
837 | 862 | // How about image directories? |
838 | - if (is_dir($data['theme_dir'] . '/images/' . $context['lang_id'])) |
|
839 | - $images_dirs[$id] = $data['theme_dir'] . '/images/' . $context['lang_id']; |
|
863 | + if (is_dir($data['theme_dir'] . '/images/' . $context['lang_id'])) { |
|
864 | + $images_dirs[$id] = $data['theme_dir'] . '/images/' . $context['lang_id']; |
|
865 | + } |
|
840 | 866 | } |
841 | 867 | |
842 | 868 | $current_file = $file_id ? $lang_dirs[$theme_id] . '/' . $file_id . '.' . $context['lang_id'] . '.php' : ''; |
@@ -850,15 +876,17 @@ discard block |
||
850 | 876 | while ($entry = $dir->read()) |
851 | 877 | { |
852 | 878 | // We're only after the files for this language. |
853 | - if (preg_match('~^([A-Za-z]+)\.' . $context['lang_id'] . '\.php$~', $entry, $matches) == 0) |
|
854 | - continue; |
|
879 | + if (preg_match('~^([A-Za-z]+)\.' . $context['lang_id'] . '\.php$~', $entry, $matches) == 0) { |
|
880 | + continue; |
|
881 | + } |
|
855 | 882 | |
856 | - if (!isset($context['possible_files'][$theme])) |
|
857 | - $context['possible_files'][$theme] = array( |
|
883 | + if (!isset($context['possible_files'][$theme])) { |
|
884 | + $context['possible_files'][$theme] = array( |
|
858 | 885 | 'id' => $theme, |
859 | 886 | 'name' => $themes[$theme]['name'], |
860 | 887 | 'files' => array(), |
861 | 888 | ); |
889 | + } |
|
862 | 890 | |
863 | 891 | $context['possible_files'][$theme]['files'][] = array( |
864 | 892 | 'id' => $matches[1], |
@@ -887,31 +915,36 @@ discard block |
||
887 | 915 | { |
888 | 916 | $_SESSION['last_backup_for'] = $context['lang_id'] . '$$$'; |
889 | 917 | $result = package_create_backup('backup_lang_' . $context['lang_id']); |
890 | - if (!$result) |
|
891 | - fatal_lang_error('could_not_language_backup', false); |
|
918 | + if (!$result) { |
|
919 | + fatal_lang_error('could_not_language_backup', false); |
|
920 | + } |
|
892 | 921 | } |
893 | 922 | |
894 | 923 | // Second, loop through the array to remove the files. |
895 | 924 | foreach ($lang_dirs as $curPath) |
896 | 925 | { |
897 | - foreach ($context['possible_files'][1]['files'] as $lang) |
|
898 | - if (file_exists($curPath . '/' . $lang['id'] . '.' . $context['lang_id'] . '.php')) |
|
926 | + foreach ($context['possible_files'][1]['files'] as $lang) { |
|
927 | + if (file_exists($curPath . '/' . $lang['id'] . '.' . $context['lang_id'] . '.php')) |
|
899 | 928 | unlink($curPath . '/' . $lang['id'] . '.' . $context['lang_id'] . '.php'); |
929 | + } |
|
900 | 930 | |
901 | 931 | // Check for the email template. |
902 | - if (file_exists($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php')) |
|
903 | - unlink($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php'); |
|
932 | + if (file_exists($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php')) { |
|
933 | + unlink($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php'); |
|
934 | + } |
|
904 | 935 | } |
905 | 936 | |
906 | 937 | // Third, the agreement file. |
907 | - if (file_exists($boarddir . '/agreement.' . $context['lang_id'] . '.txt')) |
|
908 | - unlink($boarddir . '/agreement.' . $context['lang_id'] . '.txt'); |
|
938 | + if (file_exists($boarddir . '/agreement.' . $context['lang_id'] . '.txt')) { |
|
939 | + unlink($boarddir . '/agreement.' . $context['lang_id'] . '.txt'); |
|
940 | + } |
|
909 | 941 | |
910 | 942 | // Fourth, a related images folder, if it exists... |
911 | - if (!empty($images_dirs)) |
|
912 | - foreach ($images_dirs as $curPath) |
|
943 | + if (!empty($images_dirs)) { |
|
944 | + foreach ($images_dirs as $curPath) |
|
913 | 945 | if (is_dir($curPath)) |
914 | 946 | deltree($curPath); |
947 | + } |
|
915 | 948 | |
916 | 949 | // Members can no longer use this language. |
917 | 950 | $smcFunc['db_query']('', ' |
@@ -995,8 +1028,9 @@ discard block |
||
995 | 1028 | foreach ($_POST['entry'] as $k => $v) |
996 | 1029 | { |
997 | 1030 | // Only try to save if it's changed! |
998 | - if ($_POST['entry'][$k] != $_POST['comp'][$k]) |
|
999 | - $save_strings[$k] = cleanLangString($v, false); |
|
1031 | + if ($_POST['entry'][$k] != $_POST['comp'][$k]) { |
|
1032 | + $save_strings[$k] = cleanLangString($v, false); |
|
1033 | + } |
|
1000 | 1034 | } |
1001 | 1035 | } |
1002 | 1036 | |
@@ -1030,12 +1064,13 @@ discard block |
||
1030 | 1064 | if ($multiline_cache) |
1031 | 1065 | { |
1032 | 1066 | preg_match('~\$(helptxt|txt|editortxt)\[\'(.+)\'\]\s?=\s?(.+);~ms', strtr($multiline_cache, array("\r" => '')), $matches); |
1033 | - if (!empty($matches[3])) |
|
1034 | - $entries[$matches[2]] = array( |
|
1067 | + if (!empty($matches[3])) { |
|
1068 | + $entries[$matches[2]] = array( |
|
1035 | 1069 | 'type' => $matches[1], |
1036 | 1070 | 'full' => $matches[0], |
1037 | 1071 | 'entry' => $matches[3], |
1038 | 1072 | ); |
1073 | + } |
|
1039 | 1074 | } |
1040 | 1075 | |
1041 | 1076 | // These are the entries we can definitely save. |
@@ -1046,8 +1081,9 @@ discard block |
||
1046 | 1081 | { |
1047 | 1082 | // Ignore some things we set separately. |
1048 | 1083 | $ignore_files = array('lang_character_set', 'lang_locale', 'lang_dictionary', 'lang_spelling', 'lang_rtl'); |
1049 | - if (in_array($entryKey, $ignore_files)) |
|
1050 | - continue; |
|
1084 | + if (in_array($entryKey, $ignore_files)) { |
|
1085 | + continue; |
|
1086 | + } |
|
1051 | 1087 | |
1052 | 1088 | // These are arrays that need breaking out. |
1053 | 1089 | $arrays = array('days', 'days_short', 'months', 'months_titles', 'months_short', 'happy_birthday_author', 'karlbenson1_author', 'nite0859_author', 'zwaldowski_author', 'geezmo_author', 'karlbenson2_author'); |
@@ -1080,9 +1116,9 @@ discard block |
||
1080 | 1116 | { |
1081 | 1117 | $save_cache['entries'][$cur_index] = strtr($save_strings[$entryKey . '-+- ' . $cur_index], array('\'' => '')); |
1082 | 1118 | $save_cache['enabled'] = true; |
1119 | + } else { |
|
1120 | + $save_cache['entries'][$cur_index] = $subValue; |
|
1083 | 1121 | } |
1084 | - else |
|
1085 | - $save_cache['entries'][$cur_index] = $subValue; |
|
1086 | 1122 | |
1087 | 1123 | $context['file_entries'][] = array( |
1088 | 1124 | 'key' => $entryKey . '-+- ' . $cur_index, |
@@ -1105,9 +1141,9 @@ discard block |
||
1105 | 1141 | { |
1106 | 1142 | $items[] = $k2 . ' => \'' . $v2 . '\''; |
1107 | 1143 | $cur_index = $k2; |
1144 | + } else { |
|
1145 | + $items[] = '\'' . $v2 . '\''; |
|
1108 | 1146 | } |
1109 | - else |
|
1110 | - $items[] = '\'' . $v2 . '\''; |
|
1111 | 1147 | |
1112 | 1148 | $cur_index++; |
1113 | 1149 | } |
@@ -1117,15 +1153,15 @@ discard block |
||
1117 | 1153 | 'replace' => '$' . $entryValue['type'] . '[\'' . $entryKey . '\'] = array(' . implode(', ', $items) . ');', |
1118 | 1154 | ); |
1119 | 1155 | } |
1120 | - } |
|
1121 | - else |
|
1156 | + } else |
|
1122 | 1157 | { |
1123 | 1158 | // Saving? |
1124 | 1159 | if (isset($save_strings[$entryKey]) && $save_strings[$entryKey] != $entryValue['entry']) |
1125 | 1160 | { |
1126 | 1161 | // @todo Fix this properly. |
1127 | - if ($save_strings[$entryKey] == '') |
|
1128 | - $save_strings[$entryKey] = '\'\''; |
|
1162 | + if ($save_strings[$entryKey] == '') { |
|
1163 | + $save_strings[$entryKey] = '\'\''; |
|
1164 | + } |
|
1129 | 1165 | |
1130 | 1166 | // Set the new value. |
1131 | 1167 | $entryValue['entry'] = $save_strings[$entryKey]; |
@@ -1151,8 +1187,9 @@ discard block |
||
1151 | 1187 | checkSession(); |
1152 | 1188 | |
1153 | 1189 | $file_contents = implode('', file($current_file)); |
1154 | - foreach ($final_saves as $save) |
|
1155 | - $file_contents = strtr($file_contents, array($save['find'] => $save['replace'])); |
|
1190 | + foreach ($final_saves as $save) { |
|
1191 | + $file_contents = strtr($file_contents, array($save['find'] => $save['replace'])); |
|
1192 | + } |
|
1156 | 1193 | |
1157 | 1194 | // Save the actual changes. |
1158 | 1195 | $fp = fopen($current_file, 'w+'); |
@@ -1167,8 +1204,9 @@ discard block |
||
1167 | 1204 | } |
1168 | 1205 | |
1169 | 1206 | // If we saved, redirect. |
1170 | - if ($madeSave) |
|
1171 | - redirectexit('action=admin;area=languages;sa=editlang;lid=' . $context['lang_id']); |
|
1207 | + if ($madeSave) { |
|
1208 | + redirectexit('action=admin;area=languages;sa=editlang;lid=' . $context['lang_id']); |
|
1209 | + } |
|
1172 | 1210 | |
1173 | 1211 | createToken('admin-mlang'); |
1174 | 1212 | } |
@@ -1200,8 +1238,9 @@ discard block |
||
1200 | 1238 | // Toggle the escape. |
1201 | 1239 | $is_escape = !$is_escape; |
1202 | 1240 | // If we're now escaped don't add this string. |
1203 | - if ($is_escape) |
|
1204 | - continue; |
|
1241 | + if ($is_escape) { |
|
1242 | + continue; |
|
1243 | + } |
|
1205 | 1244 | } |
1206 | 1245 | // Special case - parsed string with line break etc? |
1207 | 1246 | elseif (($string{$i} == 'n' || $string{$i} == 't') && $in_string == 2 && $is_escape) |
@@ -1218,11 +1257,13 @@ discard block |
||
1218 | 1257 | if ($in_string != 2 && ($in_string != 1 || !$is_escape)) |
1219 | 1258 | { |
1220 | 1259 | // Is it the end of a single quote string? |
1221 | - if ($in_string == 1) |
|
1222 | - $in_string = 0; |
|
1260 | + if ($in_string == 1) { |
|
1261 | + $in_string = 0; |
|
1262 | + } |
|
1223 | 1263 | // Otherwise it's the start! |
1224 | - else |
|
1225 | - $in_string = 1; |
|
1264 | + else { |
|
1265 | + $in_string = 1; |
|
1266 | + } |
|
1226 | 1267 | |
1227 | 1268 | // Don't actually include this character! |
1228 | 1269 | continue; |
@@ -1235,19 +1276,22 @@ discard block |
||
1235 | 1276 | if ($in_string != 1 && ($in_string != 2 || !$is_escape)) |
1236 | 1277 | { |
1237 | 1278 | // Is it the end of a double quote string? |
1238 | - if ($in_string == 2) |
|
1239 | - $in_string = 0; |
|
1279 | + if ($in_string == 2) { |
|
1280 | + $in_string = 0; |
|
1281 | + } |
|
1240 | 1282 | // Otherwise it's the start! |
1241 | - else |
|
1242 | - $in_string = 2; |
|
1283 | + else { |
|
1284 | + $in_string = 2; |
|
1285 | + } |
|
1243 | 1286 | |
1244 | 1287 | // Don't actually include this character! |
1245 | 1288 | continue; |
1246 | 1289 | } |
1247 | 1290 | } |
1248 | 1291 | // A join/space outside of a string is simply removed. |
1249 | - elseif ($in_string == 0 && (empty($string{$i}) || $string{$i} == '.')) |
|
1250 | - continue; |
|
1292 | + elseif ($in_string == 0 && (empty($string{$i}) || $string{$i} == '.')) { |
|
1293 | + continue; |
|
1294 | + } |
|
1251 | 1295 | // Start of a variable? |
1252 | 1296 | elseif ($in_string == 0 && $string{$i} == '$') |
1253 | 1297 | { |
@@ -1281,8 +1325,7 @@ discard block |
||
1281 | 1325 | |
1282 | 1326 | // Unhtml then rehtml the whole thing! |
1283 | 1327 | $new_string = $smcFunc['htmlspecialchars'](un_htmlspecialchars($new_string)); |
1284 | - } |
|
1285 | - else |
|
1328 | + } else |
|
1286 | 1329 | { |
1287 | 1330 | // Keep track of what we're doing... |
1288 | 1331 | $in_string = 0; |
@@ -1311,10 +1354,11 @@ discard block |
||
1311 | 1354 | preg_match('~\{%([\$A-Za-z0-9\'\[\]_-]+)%\}~', substr($string, $i), $matches); |
1312 | 1355 | if (!empty($matches[1])) |
1313 | 1356 | { |
1314 | - if ($in_string == 1) |
|
1315 | - $new_string .= '\' . '; |
|
1316 | - elseif ($new_string) |
|
1317 | - $new_string .= ' . '; |
|
1357 | + if ($in_string == 1) { |
|
1358 | + $new_string .= '\' . '; |
|
1359 | + } elseif ($new_string) { |
|
1360 | + $new_string .= ' . '; |
|
1361 | + } |
|
1318 | 1362 | |
1319 | 1363 | $new_string .= $matches[1]; |
1320 | 1364 | $i += strlen($matches[1]) + 3; |
@@ -1327,8 +1371,9 @@ discard block |
||
1327 | 1371 | elseif ($string{$i} == '<') |
1328 | 1372 | { |
1329 | 1373 | // Probably HTML? |
1330 | - if ($string{$i + 1} != ' ') |
|
1331 | - $in_html = true; |
|
1374 | + if ($string{$i + 1} != ' ') { |
|
1375 | + $in_html = true; |
|
1376 | + } |
|
1332 | 1377 | // Assume we need an entity... |
1333 | 1378 | else |
1334 | 1379 | { |
@@ -1340,8 +1385,9 @@ discard block |
||
1340 | 1385 | elseif ($string{$i} == '>') |
1341 | 1386 | { |
1342 | 1387 | // Will it be HTML? |
1343 | - if ($in_html) |
|
1344 | - $in_html = false; |
|
1388 | + if ($in_html) { |
|
1389 | + $in_html = false; |
|
1390 | + } |
|
1345 | 1391 | // Otherwise we need an entity... |
1346 | 1392 | else |
1347 | 1393 | { |
@@ -1350,8 +1396,9 @@ discard block |
||
1350 | 1396 | } |
1351 | 1397 | } |
1352 | 1398 | // Is it a slash? If so escape it... |
1353 | - if ($string{$i} == '\\') |
|
1354 | - $new_string .= '\\'; |
|
1399 | + if ($string{$i} == '\\') { |
|
1400 | + $new_string .= '\\'; |
|
1401 | + } |
|
1355 | 1402 | // The infamous double quote? |
1356 | 1403 | elseif ($string{$i} == '"') |
1357 | 1404 | { |
@@ -1374,10 +1421,11 @@ discard block |
||
1374 | 1421 | } |
1375 | 1422 | |
1376 | 1423 | // If we ended as a string then close it off. |
1377 | - if ($in_string == 1) |
|
1378 | - $new_string .= '\''; |
|
1379 | - elseif ($in_string == 2) |
|
1380 | - $new_string .= '"'; |
|
1424 | + if ($in_string == 1) { |
|
1425 | + $new_string .= '\''; |
|
1426 | + } elseif ($in_string == 2) { |
|
1427 | + $new_string .= '"'; |
|
1428 | + } |
|
1381 | 1429 | } |
1382 | 1430 | |
1383 | 1431 | return $new_string; |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Load the $modSettings array. |
@@ -25,13 +26,14 @@ discard block |
||
25 | 26 | global $cache_enable, $sourcedir, $context; |
26 | 27 | |
27 | 28 | // Most database systems have not set UTF-8 as their default input charset. |
28 | - if (!empty($db_character_set)) |
|
29 | - $smcFunc['db_query']('', ' |
|
29 | + if (!empty($db_character_set)) { |
|
30 | + $smcFunc['db_query']('', ' |
|
30 | 31 | SET NAMES {string:db_character_set}', |
31 | 32 | array( |
32 | 33 | 'db_character_set' => $db_character_set, |
33 | 34 | ) |
34 | 35 | ); |
36 | + } |
|
35 | 37 | |
36 | 38 | // We need some caching support, maybe. |
37 | 39 | loadCacheAccelerator(); |
@@ -46,27 +48,35 @@ discard block |
||
46 | 48 | ) |
47 | 49 | ); |
48 | 50 | $modSettings = array(); |
49 | - if (!$request) |
|
50 | - display_db_error(); |
|
51 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
52 | - $modSettings[$row[0]] = $row[1]; |
|
51 | + if (!$request) { |
|
52 | + display_db_error(); |
|
53 | + } |
|
54 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
55 | + $modSettings[$row[0]] = $row[1]; |
|
56 | + } |
|
53 | 57 | $smcFunc['db_free_result']($request); |
54 | 58 | |
55 | 59 | // Do a few things to protect against missing settings or settings with invalid values... |
56 | - if (empty($modSettings['defaultMaxTopics']) || $modSettings['defaultMaxTopics'] <= 0 || $modSettings['defaultMaxTopics'] > 999) |
|
57 | - $modSettings['defaultMaxTopics'] = 20; |
|
58 | - if (empty($modSettings['defaultMaxMessages']) || $modSettings['defaultMaxMessages'] <= 0 || $modSettings['defaultMaxMessages'] > 999) |
|
59 | - $modSettings['defaultMaxMessages'] = 15; |
|
60 | - if (empty($modSettings['defaultMaxMembers']) || $modSettings['defaultMaxMembers'] <= 0 || $modSettings['defaultMaxMembers'] > 999) |
|
61 | - $modSettings['defaultMaxMembers'] = 30; |
|
62 | - if (empty($modSettings['defaultMaxListItems']) || $modSettings['defaultMaxListItems'] <= 0 || $modSettings['defaultMaxListItems'] > 999) |
|
63 | - $modSettings['defaultMaxListItems'] = 15; |
|
60 | + if (empty($modSettings['defaultMaxTopics']) || $modSettings['defaultMaxTopics'] <= 0 || $modSettings['defaultMaxTopics'] > 999) { |
|
61 | + $modSettings['defaultMaxTopics'] = 20; |
|
62 | + } |
|
63 | + if (empty($modSettings['defaultMaxMessages']) || $modSettings['defaultMaxMessages'] <= 0 || $modSettings['defaultMaxMessages'] > 999) { |
|
64 | + $modSettings['defaultMaxMessages'] = 15; |
|
65 | + } |
|
66 | + if (empty($modSettings['defaultMaxMembers']) || $modSettings['defaultMaxMembers'] <= 0 || $modSettings['defaultMaxMembers'] > 999) { |
|
67 | + $modSettings['defaultMaxMembers'] = 30; |
|
68 | + } |
|
69 | + if (empty($modSettings['defaultMaxListItems']) || $modSettings['defaultMaxListItems'] <= 0 || $modSettings['defaultMaxListItems'] > 999) { |
|
70 | + $modSettings['defaultMaxListItems'] = 15; |
|
71 | + } |
|
64 | 72 | |
65 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
66 | - $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
73 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
74 | + $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
75 | + } |
|
67 | 76 | |
68 | - if (!empty($cache_enable)) |
|
69 | - cache_put_data('modSettings', $modSettings, 90); |
|
77 | + if (!empty($cache_enable)) { |
|
78 | + cache_put_data('modSettings', $modSettings, 90); |
|
79 | + } |
|
70 | 80 | } |
71 | 81 | |
72 | 82 | $modSettings['cache_enable'] = $cache_enable; |
@@ -86,8 +96,9 @@ discard block |
||
86 | 96 | }; |
87 | 97 | $fix_utf8mb4 = function($string) use ($utf8) |
88 | 98 | { |
89 | - if (!$utf8) |
|
90 | - return $string; |
|
99 | + if (!$utf8) { |
|
100 | + return $string; |
|
101 | + } |
|
91 | 102 | |
92 | 103 | $i = 0; |
93 | 104 | $len = strlen($string); |
@@ -99,18 +110,15 @@ discard block |
||
99 | 110 | { |
100 | 111 | $new_string .= $string[$i]; |
101 | 112 | $i++; |
102 | - } |
|
103 | - elseif ($ord < 224) |
|
113 | + } elseif ($ord < 224) |
|
104 | 114 | { |
105 | 115 | $new_string .= $string[$i] . $string[$i + 1]; |
106 | 116 | $i += 2; |
107 | - } |
|
108 | - elseif ($ord < 240) |
|
117 | + } elseif ($ord < 240) |
|
109 | 118 | { |
110 | 119 | $new_string .= $string[$i] . $string[$i + 1] . $string[$i + 2]; |
111 | 120 | $i += 3; |
112 | - } |
|
113 | - elseif ($ord < 248) |
|
121 | + } elseif ($ord < 248) |
|
114 | 122 | { |
115 | 123 | // Magic happens. |
116 | 124 | $val = (ord($string[$i]) & 0x07) << 18; |
@@ -154,8 +162,7 @@ discard block |
||
154 | 162 | { |
155 | 163 | $result = array_search($needle, array_slice($haystack_arr, $offset)); |
156 | 164 | return is_int($result) ? $result + $offset : false; |
157 | - } |
|
158 | - else |
|
165 | + } else |
|
159 | 166 | { |
160 | 167 | $needle_arr = preg_split('~(&#' . (empty($modSettings['disableEntityCheck']) ? '\d{1,7}' : '021') . ';|"|&|<|>| |.)~' . ($utf8 ? 'u' : '') . '', $ent_check($needle), -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); |
161 | 168 | $needle_size = count($needle_arr); |
@@ -164,8 +171,9 @@ discard block |
||
164 | 171 | while ((int) $result === $result) |
165 | 172 | { |
166 | 173 | $offset += $result; |
167 | - if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr) |
|
168 | - return $offset; |
|
174 | + if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr) { |
|
175 | + return $offset; |
|
176 | + } |
|
169 | 177 | $result = array_search($needle_arr[0], array_slice($haystack_arr, ++$offset)); |
170 | 178 | } |
171 | 179 | return false; |
@@ -203,8 +211,9 @@ discard block |
||
203 | 211 | $string = $ent_check($string); |
204 | 212 | preg_match('~^(' . $ent_list . '|.){' . $smcFunc['strlen'](substr($string, 0, $length)) . '}~' . ($utf8 ? 'u' : ''), $string, $matches); |
205 | 213 | $string = $matches[0]; |
206 | - while (strlen($string) > $length) |
|
207 | - $string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string); |
|
214 | + while (strlen($string) > $length) { |
|
215 | + $string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string); |
|
216 | + } |
|
208 | 217 | return $string; |
209 | 218 | }, |
210 | 219 | 'ucfirst' => $utf8 ? function($string) use (&$smcFunc) |
@@ -214,23 +223,25 @@ discard block |
||
214 | 223 | 'ucwords' => $utf8 ? function($string) use (&$smcFunc) |
215 | 224 | { |
216 | 225 | $words = preg_split('~([\s\r\n\t]+)~', $string, -1, PREG_SPLIT_DELIM_CAPTURE); |
217 | - for ($i = 0, $n = count($words); $i < $n; $i += 2) |
|
218 | - $words[$i] = $smcFunc['ucfirst']($words[$i]); |
|
226 | + for ($i = 0, $n = count($words); $i < $n; $i += 2) { |
|
227 | + $words[$i] = $smcFunc['ucfirst']($words[$i]); |
|
228 | + } |
|
219 | 229 | return implode('', $words); |
220 | 230 | } : 'ucwords', |
221 | 231 | ); |
222 | 232 | |
223 | 233 | // Setting the timezone is a requirement for some functions. |
224 | - if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list())) |
|
225 | - date_default_timezone_set($modSettings['default_timezone']); |
|
226 | - else |
|
234 | + if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list())) { |
|
235 | + date_default_timezone_set($modSettings['default_timezone']); |
|
236 | + } else |
|
227 | 237 | { |
228 | 238 | // Get PHP's default timezone, if set |
229 | 239 | $ini_tz = ini_get('date.timezone'); |
230 | - if (!empty($ini_tz)) |
|
231 | - $modSettings['default_timezone'] = $ini_tz; |
|
232 | - else |
|
233 | - $modSettings['default_timezone'] = ''; |
|
240 | + if (!empty($ini_tz)) { |
|
241 | + $modSettings['default_timezone'] = $ini_tz; |
|
242 | + } else { |
|
243 | + $modSettings['default_timezone'] = ''; |
|
244 | + } |
|
234 | 245 | |
235 | 246 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
236 | 247 | if (!in_array($modSettings['default_timezone'], timezone_identifiers_list())) |
@@ -248,22 +259,26 @@ discard block |
||
248 | 259 | if (($modSettings['load_average'] = cache_get_data('loadavg', 90)) == null) |
249 | 260 | { |
250 | 261 | $modSettings['load_average'] = @file_get_contents('/proc/loadavg'); |
251 | - if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0) |
|
252 | - $modSettings['load_average'] = (float) $matches[1]; |
|
253 | - elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0) |
|
254 | - $modSettings['load_average'] = (float) $matches[1]; |
|
255 | - else |
|
256 | - unset($modSettings['load_average']); |
|
262 | + if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0) { |
|
263 | + $modSettings['load_average'] = (float) $matches[1]; |
|
264 | + } elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0) { |
|
265 | + $modSettings['load_average'] = (float) $matches[1]; |
|
266 | + } else { |
|
267 | + unset($modSettings['load_average']); |
|
268 | + } |
|
257 | 269 | |
258 | - if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
|
259 | - cache_put_data('loadavg', $modSettings['load_average'], 90); |
|
270 | + if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) { |
|
271 | + cache_put_data('loadavg', $modSettings['load_average'], 90); |
|
272 | + } |
|
260 | 273 | } |
261 | 274 | |
262 | - if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
|
263 | - call_integration_hook('integrate_load_average', array($modSettings['load_average'])); |
|
275 | + if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) { |
|
276 | + call_integration_hook('integrate_load_average', array($modSettings['load_average'])); |
|
277 | + } |
|
264 | 278 | |
265 | - if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum']) |
|
266 | - display_loadavg_error(); |
|
279 | + if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum']) { |
|
280 | + display_loadavg_error(); |
|
281 | + } |
|
267 | 282 | } |
268 | 283 | |
269 | 284 | // Is post moderation alive and well? Everywhere else assumes this has been defined, so let's make sure it is. |
@@ -284,8 +299,9 @@ discard block |
||
284 | 299 | if (defined('SMF_INTEGRATION_SETTINGS')) |
285 | 300 | { |
286 | 301 | $integration_settings = smf_json_decode(SMF_INTEGRATION_SETTINGS, true); |
287 | - foreach ($integration_settings as $hook => $function) |
|
288 | - add_integration_function($hook, $function, '', false); |
|
302 | + foreach ($integration_settings as $hook => $function) { |
|
303 | + add_integration_function($hook, $function, '', false); |
|
304 | + } |
|
289 | 305 | } |
290 | 306 | |
291 | 307 | // Any files to pre include? |
@@ -295,8 +311,9 @@ discard block |
||
295 | 311 | foreach ($pre_includes as $include) |
296 | 312 | { |
297 | 313 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
298 | - if (file_exists($include)) |
|
299 | - require_once($include); |
|
314 | + if (file_exists($include)) { |
|
315 | + require_once($include); |
|
316 | + } |
|
300 | 317 | } |
301 | 318 | } |
302 | 319 | |
@@ -400,27 +417,28 @@ discard block |
||
400 | 417 | break; |
401 | 418 | } |
402 | 419 | } |
420 | + } else { |
|
421 | + $id_member = 0; |
|
403 | 422 | } |
404 | - else |
|
405 | - $id_member = 0; |
|
406 | 423 | |
407 | 424 | if (empty($id_member) && isset($_COOKIE[$cookiename])) |
408 | 425 | { |
409 | 426 | $cookie_data = smf_json_decode($_COOKIE[$cookiename], true, false); |
410 | 427 | |
411 | - if (empty($cookie_data)) |
|
412 | - $cookie_data = safe_unserialize($_COOKIE[$cookiename]); |
|
428 | + if (empty($cookie_data)) { |
|
429 | + $cookie_data = safe_unserialize($_COOKIE[$cookiename]); |
|
430 | + } |
|
413 | 431 | |
414 | 432 | list ($id_member, $password) = $cookie_data; |
415 | 433 | $id_member = !empty($id_member) && strlen($password) > 0 ? (int) $id_member : 0; |
416 | - } |
|
417 | - elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA']))) |
|
434 | + } elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA']))) |
|
418 | 435 | { |
419 | 436 | // @todo Perhaps we can do some more checking on this, such as on the first octet of the IP? |
420 | 437 | $cookie_data = smf_json_decode($_SESSION['login_' . $cookiename]); |
421 | 438 | |
422 | - if (empty($cookie_data)) |
|
423 | - $cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
439 | + if (empty($cookie_data)) { |
|
440 | + $cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
441 | + } |
|
424 | 442 | |
425 | 443 | list ($id_member, $password, $login_span) = $cookie_data; |
426 | 444 | $id_member = !empty($id_member) && strlen($password) == 128 && $login_span > time() ? (int) $id_member : 0; |
@@ -445,30 +463,34 @@ discard block |
||
445 | 463 | $user_settings = $smcFunc['db_fetch_assoc']($request); |
446 | 464 | $smcFunc['db_free_result']($request); |
447 | 465 | |
448 | - if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false) |
|
449 | - $user_settings['avatar'] = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($user_settings['avatar']) . '&hash=' . md5($user_settings['avatar'] . $image_proxy_secret); |
|
466 | + if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false) { |
|
467 | + $user_settings['avatar'] = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($user_settings['avatar']) . '&hash=' . md5($user_settings['avatar'] . $image_proxy_secret); |
|
468 | + } |
|
450 | 469 | |
451 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
452 | - cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
470 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
471 | + cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
472 | + } |
|
453 | 473 | } |
454 | 474 | |
455 | 475 | // Did we find 'im? If not, junk it. |
456 | 476 | if (!empty($user_settings)) |
457 | 477 | { |
458 | 478 | // As much as the password should be right, we can assume the integration set things up. |
459 | - if (!empty($already_verified) && $already_verified === true) |
|
460 | - $check = true; |
|
479 | + if (!empty($already_verified) && $already_verified === true) { |
|
480 | + $check = true; |
|
481 | + } |
|
461 | 482 | // SHA-512 hash should be 128 characters long. |
462 | - elseif (strlen($password) == 128) |
|
463 | - $check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password; |
|
464 | - else |
|
465 | - $check = false; |
|
483 | + elseif (strlen($password) == 128) { |
|
484 | + $check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password; |
|
485 | + } else { |
|
486 | + $check = false; |
|
487 | + } |
|
466 | 488 | |
467 | 489 | // Wrong password or not activated - either way, you're going nowhere. |
468 | 490 | $id_member = $check && ($user_settings['is_activated'] == 1 || $user_settings['is_activated'] == 11) ? (int) $user_settings['id_member'] : 0; |
491 | + } else { |
|
492 | + $id_member = 0; |
|
469 | 493 | } |
470 | - else |
|
471 | - $id_member = 0; |
|
472 | 494 | |
473 | 495 | // If we no longer have the member maybe they're being all hackey, stop brute force! |
474 | 496 | if (!$id_member) |
@@ -490,13 +512,15 @@ discard block |
||
490 | 512 | { |
491 | 513 | $tfa_data = smf_json_decode($_COOKIE[$tfacookie]); |
492 | 514 | |
493 | - if (is_null($tfa_data)) |
|
494 | - $tfa_data = safe_unserialize($_COOKIE[$tfacookie]); |
|
515 | + if (is_null($tfa_data)) { |
|
516 | + $tfa_data = safe_unserialize($_COOKIE[$tfacookie]); |
|
517 | + } |
|
495 | 518 | |
496 | 519 | list ($tfamember, $tfasecret) = $tfa_data; |
497 | 520 | |
498 | - if ((int) $tfamember != $id_member) |
|
499 | - $tfasecret = null; |
|
521 | + if ((int) $tfamember != $id_member) { |
|
522 | + $tfasecret = null; |
|
523 | + } |
|
500 | 524 | } |
501 | 525 | |
502 | 526 | if (empty($tfasecret) || hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']) != $tfasecret) |
@@ -516,10 +540,12 @@ discard block |
||
516 | 540 | // Are we forcing 2FA? Need to check if the user groups actually require 2FA |
517 | 541 | elseif (!empty($modSettings['tfa_mode']) && $modSettings['tfa_mode'] >= 2 && $id_member && empty($user_settings['tfa_secret'])) |
518 | 542 | { |
519 | - if ($modSettings['tfa_mode'] == 2) //only do this if we are just forcing SOME membergroups |
|
543 | + if ($modSettings['tfa_mode'] == 2) { |
|
544 | + //only do this if we are just forcing SOME membergroups |
|
520 | 545 | { |
521 | 546 | //Build an array of ALL user membergroups. |
522 | 547 | $full_groups = array($user_settings['id_group']); |
548 | + } |
|
523 | 549 | if (!empty($user_settings['additional_groups'])) |
524 | 550 | { |
525 | 551 | $full_groups = array_merge($full_groups, explode(',', $user_settings['additional_groups'])); |
@@ -539,15 +565,17 @@ discard block |
||
539 | 565 | ); |
540 | 566 | $row = $smcFunc['db_fetch_assoc']($request); |
541 | 567 | $smcFunc['db_free_result']($request); |
568 | + } else { |
|
569 | + $row['total'] = 1; |
|
542 | 570 | } |
543 | - else |
|
544 | - $row['total'] = 1; //simplifies logics in the next "if" |
|
571 | + //simplifies logics in the next "if" |
|
545 | 572 | |
546 | 573 | $area = !empty($_REQUEST['area']) ? $_REQUEST['area'] : ''; |
547 | 574 | $action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : ''; |
548 | 575 | |
549 | - if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) |
|
550 | - redirectexit('action=profile;area=tfasetup;forced'); |
|
576 | + if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) { |
|
577 | + redirectexit('action=profile;area=tfasetup;forced'); |
|
578 | + } |
|
551 | 579 | } |
552 | 580 | } |
553 | 581 | |
@@ -584,33 +612,37 @@ discard block |
||
584 | 612 | updateMemberData($id_member, array('id_msg_last_visit' => (int) $modSettings['maxMsgID'], 'last_login' => time(), 'member_ip' => $_SERVER['REMOTE_ADDR'], 'member_ip2' => $_SERVER['BAN_CHECK_IP'])); |
585 | 613 | $user_settings['last_login'] = time(); |
586 | 614 | |
587 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
588 | - cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
615 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
616 | + cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
617 | + } |
|
589 | 618 | |
590 | - if (!empty($modSettings['cache_enable'])) |
|
591 | - cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600); |
|
619 | + if (!empty($modSettings['cache_enable'])) { |
|
620 | + cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600); |
|
621 | + } |
|
592 | 622 | } |
623 | + } elseif (empty($_SESSION['id_msg_last_visit'])) { |
|
624 | + $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit']; |
|
593 | 625 | } |
594 | - elseif (empty($_SESSION['id_msg_last_visit'])) |
|
595 | - $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit']; |
|
596 | 626 | |
597 | 627 | $username = $user_settings['member_name']; |
598 | 628 | |
599 | - if (empty($user_settings['additional_groups'])) |
|
600 | - $user_info = array( |
|
629 | + if (empty($user_settings['additional_groups'])) { |
|
630 | + $user_info = array( |
|
601 | 631 | 'groups' => array($user_settings['id_group'], $user_settings['id_post_group']) |
602 | 632 | ); |
603 | - else |
|
604 | - $user_info = array( |
|
633 | + } else { |
|
634 | + $user_info = array( |
|
605 | 635 | 'groups' => array_merge( |
606 | 636 | array($user_settings['id_group'], $user_settings['id_post_group']), |
607 | 637 | explode(',', $user_settings['additional_groups']) |
608 | 638 | ) |
609 | 639 | ); |
640 | + } |
|
610 | 641 | |
611 | 642 | // Because history has proven that it is possible for groups to go bad - clean up in case. |
612 | - foreach ($user_info['groups'] as $k => $v) |
|
613 | - $user_info['groups'][$k] = (int) $v; |
|
643 | + foreach ($user_info['groups'] as $k => $v) { |
|
644 | + $user_info['groups'][$k] = (int) $v; |
|
645 | + } |
|
614 | 646 | |
615 | 647 | // This is a logged in user, so definitely not a spider. |
616 | 648 | $user_info['possibly_robot'] = false; |
@@ -624,8 +656,7 @@ discard block |
||
624 | 656 | $time_system = new DateTime('now', $tz_system); |
625 | 657 | $time_user = new DateTime('now', $tz_user); |
626 | 658 | $user_info['time_offset'] = ($tz_user->getOffset($time_user) - $tz_system->getOffset($time_system)) / 3600; |
627 | - } |
|
628 | - else |
|
659 | + } else |
|
629 | 660 | { |
630 | 661 | // !!! Compatibility. |
631 | 662 | $user_info['time_offset'] = empty($user_settings['time_offset']) ? 0 : $user_settings['time_offset']; |
@@ -639,16 +670,18 @@ discard block |
||
639 | 670 | $user_info = array('groups' => array(-1)); |
640 | 671 | $user_settings = array(); |
641 | 672 | |
642 | - if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) |
|
643 | - $_COOKIE[$cookiename] = ''; |
|
673 | + if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) { |
|
674 | + $_COOKIE[$cookiename] = ''; |
|
675 | + } |
|
644 | 676 | |
645 | 677 | // Expire the 2FA cookie |
646 | 678 | if (isset($_COOKIE[$cookiename . '_tfa']) && empty($context['tfa_member'])) |
647 | 679 | { |
648 | 680 | $tfa_data = smf_json_decode($_COOKIE[$cookiename . '_tfa'], true); |
649 | 681 | |
650 | - if (is_null($tfa_data)) |
|
651 | - $tfa_data = safe_unserialize($_COOKIE[$cookiename . '_tfa']); |
|
682 | + if (is_null($tfa_data)) { |
|
683 | + $tfa_data = safe_unserialize($_COOKIE[$cookiename . '_tfa']); |
|
684 | + } |
|
652 | 685 | |
653 | 686 | list ($id, $user, $exp, $state, $preserve) = $tfa_data; |
654 | 687 | |
@@ -660,19 +693,20 @@ discard block |
||
660 | 693 | } |
661 | 694 | |
662 | 695 | // Create a login token if it doesn't exist yet. |
663 | - if (!isset($_SESSION['token']['post-login'])) |
|
664 | - createToken('login'); |
|
665 | - else |
|
666 | - list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login']; |
|
696 | + if (!isset($_SESSION['token']['post-login'])) { |
|
697 | + createToken('login'); |
|
698 | + } else { |
|
699 | + list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login']; |
|
700 | + } |
|
667 | 701 | |
668 | 702 | // Do we perhaps think this is a search robot? Check every five minutes just in case... |
669 | 703 | if ((!empty($modSettings['spider_mode']) || !empty($modSettings['spider_group'])) && (!isset($_SESSION['robot_check']) || $_SESSION['robot_check'] < time() - 300)) |
670 | 704 | { |
671 | 705 | require_once($sourcedir . '/ManageSearchEngines.php'); |
672 | 706 | $user_info['possibly_robot'] = SpiderCheck(); |
707 | + } elseif (!empty($modSettings['spider_mode'])) { |
|
708 | + $user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0; |
|
673 | 709 | } |
674 | - elseif (!empty($modSettings['spider_mode'])) |
|
675 | - $user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0; |
|
676 | 710 | // If we haven't turned on proper spider hunts then have a guess! |
677 | 711 | else |
678 | 712 | { |
@@ -720,8 +754,9 @@ discard block |
||
720 | 754 | $user_info['groups'] = array_unique($user_info['groups']); |
721 | 755 | |
722 | 756 | // Make sure that the last item in the ignore boards array is valid. If the list was too long it could have an ending comma that could cause problems. |
723 | - if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) |
|
724 | - unset($user_info['ignoreboards'][$tmp]); |
|
757 | + if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) { |
|
758 | + unset($user_info['ignoreboards'][$tmp]); |
|
759 | + } |
|
725 | 760 | |
726 | 761 | // Allow the user to change their language. |
727 | 762 | if (!empty($modSettings['userLanguage'])) |
@@ -734,31 +769,36 @@ discard block |
||
734 | 769 | $user_info['language'] = strtr($_GET['language'], './\\:', '____'); |
735 | 770 | |
736 | 771 | // Make it permanent for members. |
737 | - if (!empty($user_info['id'])) |
|
738 | - updateMemberData($user_info['id'], array('lngfile' => $user_info['language'])); |
|
739 | - else |
|
740 | - $_SESSION['language'] = $user_info['language']; |
|
772 | + if (!empty($user_info['id'])) { |
|
773 | + updateMemberData($user_info['id'], array('lngfile' => $user_info['language'])); |
|
774 | + } else { |
|
775 | + $_SESSION['language'] = $user_info['language']; |
|
776 | + } |
|
777 | + } elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) { |
|
778 | + $user_info['language'] = strtr($_SESSION['language'], './\\:', '____'); |
|
741 | 779 | } |
742 | - elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) |
|
743 | - $user_info['language'] = strtr($_SESSION['language'], './\\:', '____'); |
|
744 | 780 | } |
745 | 781 | |
746 | 782 | // Just build this here, it makes it easier to change/use - administrators can see all boards. |
747 | - if ($user_info['is_admin']) |
|
748 | - $user_info['query_see_board'] = '1=1'; |
|
783 | + if ($user_info['is_admin']) { |
|
784 | + $user_info['query_see_board'] = '1=1'; |
|
785 | + } |
|
749 | 786 | // Otherwise just the groups in $user_info['groups']. |
750 | - else |
|
751 | - $user_info['query_see_board'] = '((FIND_IN_SET(' . implode(', b.member_groups) != 0 OR FIND_IN_SET(', $user_info['groups']) . ', b.member_groups) != 0)' . (!empty($modSettings['deny_boards_access']) ? ' AND (FIND_IN_SET(' . implode(', b.deny_member_groups) = 0 AND FIND_IN_SET(', $user_info['groups']) . ', b.deny_member_groups) = 0)' : '') . (isset($user_info['mod_cache']) ? ' OR ' . $user_info['mod_cache']['mq'] : '') . ')'; |
|
787 | + else { |
|
788 | + $user_info['query_see_board'] = '((FIND_IN_SET(' . implode(', b.member_groups) != 0 OR FIND_IN_SET(', $user_info['groups']) . ', b.member_groups) != 0)' . (!empty($modSettings['deny_boards_access']) ? ' AND (FIND_IN_SET(' . implode(', b.deny_member_groups) = 0 AND FIND_IN_SET(', $user_info['groups']) . ', b.deny_member_groups) = 0)' : '') . (isset($user_info['mod_cache']) ? ' OR ' . $user_info['mod_cache']['mq'] : '') . ')'; |
|
789 | + } |
|
752 | 790 | |
753 | 791 | // Build the list of boards they WANT to see. |
754 | 792 | // This will take the place of query_see_boards in certain spots, so it better include the boards they can see also |
755 | 793 | |
756 | 794 | // If they aren't ignoring any boards then they want to see all the boards they can see |
757 | - if (empty($user_info['ignoreboards'])) |
|
758 | - $user_info['query_wanna_see_board'] = $user_info['query_see_board']; |
|
795 | + if (empty($user_info['ignoreboards'])) { |
|
796 | + $user_info['query_wanna_see_board'] = $user_info['query_see_board']; |
|
797 | + } |
|
759 | 798 | // Ok I guess they don't want to see all the boards |
760 | - else |
|
761 | - $user_info['query_wanna_see_board'] = '(' . $user_info['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $user_info['ignoreboards']) . '))'; |
|
799 | + else { |
|
800 | + $user_info['query_wanna_see_board'] = '(' . $user_info['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $user_info['ignoreboards']) . '))'; |
|
801 | + } |
|
762 | 802 | |
763 | 803 | call_integration_hook('integrate_user_info'); |
764 | 804 | } |
@@ -816,9 +856,9 @@ discard block |
||
816 | 856 | } |
817 | 857 | |
818 | 858 | // Remember redirection is the key to avoiding fallout from your bosses. |
819 | - if (!empty($topic)) |
|
820 | - redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']); |
|
821 | - else |
|
859 | + if (!empty($topic)) { |
|
860 | + redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']); |
|
861 | + } else |
|
822 | 862 | { |
823 | 863 | loadPermissions(); |
824 | 864 | loadTheme(); |
@@ -836,10 +876,11 @@ discard block |
||
836 | 876 | if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3)) |
837 | 877 | { |
838 | 878 | // @todo SLOW? |
839 | - if (!empty($topic)) |
|
840 | - $temp = cache_get_data('topic_board-' . $topic, 120); |
|
841 | - else |
|
842 | - $temp = cache_get_data('board-' . $board, 120); |
|
879 | + if (!empty($topic)) { |
|
880 | + $temp = cache_get_data('topic_board-' . $topic, 120); |
|
881 | + } else { |
|
882 | + $temp = cache_get_data('board-' . $board, 120); |
|
883 | + } |
|
843 | 884 | |
844 | 885 | if (!empty($temp)) |
845 | 886 | { |
@@ -877,8 +918,9 @@ discard block |
||
877 | 918 | $row = $smcFunc['db_fetch_assoc']($request); |
878 | 919 | |
879 | 920 | // Set the current board. |
880 | - if (!empty($row['id_board'])) |
|
881 | - $board = $row['id_board']; |
|
921 | + if (!empty($row['id_board'])) { |
|
922 | + $board = $row['id_board']; |
|
923 | + } |
|
882 | 924 | |
883 | 925 | // Basic operating information. (globals... :/) |
884 | 926 | $board_info = array( |
@@ -914,21 +956,23 @@ discard block |
||
914 | 956 | |
915 | 957 | do |
916 | 958 | { |
917 | - if (!empty($row['id_moderator'])) |
|
918 | - $board_info['moderators'][$row['id_moderator']] = array( |
|
959 | + if (!empty($row['id_moderator'])) { |
|
960 | + $board_info['moderators'][$row['id_moderator']] = array( |
|
919 | 961 | 'id' => $row['id_moderator'], |
920 | 962 | 'name' => $row['real_name'], |
921 | 963 | 'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'], |
922 | 964 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>' |
923 | 965 | ); |
966 | + } |
|
924 | 967 | |
925 | - if (!empty($row['id_moderator_group'])) |
|
926 | - $board_info['moderator_groups'][$row['id_moderator_group']] = array( |
|
968 | + if (!empty($row['id_moderator_group'])) { |
|
969 | + $board_info['moderator_groups'][$row['id_moderator_group']] = array( |
|
927 | 970 | 'id' => $row['id_moderator_group'], |
928 | 971 | 'name' => $row['group_name'], |
929 | 972 | 'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'], |
930 | 973 | 'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>' |
931 | 974 | ); |
975 | + } |
|
932 | 976 | } |
933 | 977 | while ($row = $smcFunc['db_fetch_assoc']($request)); |
934 | 978 | |
@@ -960,12 +1004,12 @@ discard block |
||
960 | 1004 | if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3)) |
961 | 1005 | { |
962 | 1006 | // @todo SLOW? |
963 | - if (!empty($topic)) |
|
964 | - cache_put_data('topic_board-' . $topic, $board_info, 120); |
|
1007 | + if (!empty($topic)) { |
|
1008 | + cache_put_data('topic_board-' . $topic, $board_info, 120); |
|
1009 | + } |
|
965 | 1010 | cache_put_data('board-' . $board, $board_info, 120); |
966 | 1011 | } |
967 | - } |
|
968 | - else |
|
1012 | + } else |
|
969 | 1013 | { |
970 | 1014 | // Otherwise the topic is invalid, there are no moderators, etc. |
971 | 1015 | $board_info = array( |
@@ -979,8 +1023,9 @@ discard block |
||
979 | 1023 | $smcFunc['db_free_result']($request); |
980 | 1024 | } |
981 | 1025 | |
982 | - if (!empty($topic)) |
|
983 | - $_GET['board'] = (int) $board; |
|
1026 | + if (!empty($topic)) { |
|
1027 | + $_GET['board'] = (int) $board; |
|
1028 | + } |
|
984 | 1029 | |
985 | 1030 | if (!empty($board)) |
986 | 1031 | { |
@@ -990,10 +1035,12 @@ discard block |
||
990 | 1035 | // Now check if the user is a moderator. |
991 | 1036 | $user_info['is_mod'] = isset($board_info['moderators'][$user_info['id']]) || count(array_intersect($user_info['groups'], $moderator_groups)) != 0; |
992 | 1037 | |
993 | - if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) |
|
994 | - $board_info['error'] = 'access'; |
|
995 | - if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) |
|
996 | - $board_info['error'] = 'access'; |
|
1038 | + if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) { |
|
1039 | + $board_info['error'] = 'access'; |
|
1040 | + } |
|
1041 | + if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) { |
|
1042 | + $board_info['error'] = 'access'; |
|
1043 | + } |
|
997 | 1044 | |
998 | 1045 | // Build up the linktree. |
999 | 1046 | $context['linktree'] = array_merge( |
@@ -1016,8 +1063,9 @@ discard block |
||
1016 | 1063 | $context['current_board'] = $board; |
1017 | 1064 | |
1018 | 1065 | // No posting in redirection boards! |
1019 | - if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) |
|
1020 | - $board_info['error'] == 'post_in_redirect'; |
|
1066 | + if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) { |
|
1067 | + $board_info['error'] == 'post_in_redirect'; |
|
1068 | + } |
|
1021 | 1069 | |
1022 | 1070 | // Hacker... you can't see this topic, I'll tell you that. (but moderators can!) |
1023 | 1071 | if (!empty($board_info['error']) && (!empty($modSettings['deny_boards_access']) || $board_info['error'] != 'access' || !$user_info['is_mod'])) |
@@ -1043,24 +1091,23 @@ discard block |
||
1043 | 1091 | ob_end_clean(); |
1044 | 1092 | header('HTTP/1.1 403 Forbidden'); |
1045 | 1093 | die; |
1046 | - } |
|
1047 | - elseif ($board_info['error'] == 'post_in_redirect') |
|
1094 | + } elseif ($board_info['error'] == 'post_in_redirect') |
|
1048 | 1095 | { |
1049 | 1096 | // Slightly different error message here... |
1050 | 1097 | fatal_lang_error('cannot_post_redirect', false); |
1051 | - } |
|
1052 | - elseif ($user_info['is_guest']) |
|
1098 | + } elseif ($user_info['is_guest']) |
|
1053 | 1099 | { |
1054 | 1100 | loadLanguage('Errors'); |
1055 | 1101 | is_not_guest($txt['topic_gone']); |
1102 | + } else { |
|
1103 | + fatal_lang_error('topic_gone', false); |
|
1056 | 1104 | } |
1057 | - else |
|
1058 | - fatal_lang_error('topic_gone', false); |
|
1059 | 1105 | } |
1060 | 1106 | |
1061 | - if ($user_info['is_mod']) |
|
1062 | - $user_info['groups'][] = 3; |
|
1063 | -} |
|
1107 | + if ($user_info['is_mod']) { |
|
1108 | + $user_info['groups'][] = 3; |
|
1109 | + } |
|
1110 | + } |
|
1064 | 1111 | |
1065 | 1112 | /** |
1066 | 1113 | * Load this user's permissions. |
@@ -1081,8 +1128,9 @@ discard block |
||
1081 | 1128 | asort($cache_groups); |
1082 | 1129 | $cache_groups = implode(',', $cache_groups); |
1083 | 1130 | // If it's a spider then cache it different. |
1084 | - if ($user_info['possibly_robot']) |
|
1085 | - $cache_groups .= '-spider'; |
|
1131 | + if ($user_info['possibly_robot']) { |
|
1132 | + $cache_groups .= '-spider'; |
|
1133 | + } |
|
1086 | 1134 | |
1087 | 1135 | if ($modSettings['cache_enable'] >= 2 && !empty($board) && ($temp = cache_get_data('permissions:' . $cache_groups . ':' . $board, 240)) != null && time() - 240 > $modSettings['settings_updated']) |
1088 | 1136 | { |
@@ -1090,9 +1138,9 @@ discard block |
||
1090 | 1138 | banPermissions(); |
1091 | 1139 | |
1092 | 1140 | return; |
1141 | + } elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) { |
|
1142 | + list ($user_info['permissions'], $removals) = $temp; |
|
1093 | 1143 | } |
1094 | - elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) |
|
1095 | - list ($user_info['permissions'], $removals) = $temp; |
|
1096 | 1144 | } |
1097 | 1145 | |
1098 | 1146 | // If it is detected as a robot, and we are restricting permissions as a special group - then implement this. |
@@ -1114,23 +1162,26 @@ discard block |
||
1114 | 1162 | $removals = array(); |
1115 | 1163 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1116 | 1164 | { |
1117 | - if (empty($row['add_deny'])) |
|
1118 | - $removals[] = $row['permission']; |
|
1119 | - else |
|
1120 | - $user_info['permissions'][] = $row['permission']; |
|
1165 | + if (empty($row['add_deny'])) { |
|
1166 | + $removals[] = $row['permission']; |
|
1167 | + } else { |
|
1168 | + $user_info['permissions'][] = $row['permission']; |
|
1169 | + } |
|
1121 | 1170 | } |
1122 | 1171 | $smcFunc['db_free_result']($request); |
1123 | 1172 | |
1124 | - if (isset($cache_groups)) |
|
1125 | - cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240); |
|
1173 | + if (isset($cache_groups)) { |
|
1174 | + cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240); |
|
1175 | + } |
|
1126 | 1176 | } |
1127 | 1177 | |
1128 | 1178 | // Get the board permissions. |
1129 | 1179 | if (!empty($board)) |
1130 | 1180 | { |
1131 | 1181 | // Make sure the board (if any) has been loaded by loadBoard(). |
1132 | - if (!isset($board_info['profile'])) |
|
1133 | - fatal_lang_error('no_board'); |
|
1182 | + if (!isset($board_info['profile'])) { |
|
1183 | + fatal_lang_error('no_board'); |
|
1184 | + } |
|
1134 | 1185 | |
1135 | 1186 | $request = $smcFunc['db_query']('', ' |
1136 | 1187 | SELECT permission, add_deny |
@@ -1146,20 +1197,23 @@ discard block |
||
1146 | 1197 | ); |
1147 | 1198 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1148 | 1199 | { |
1149 | - if (empty($row['add_deny'])) |
|
1150 | - $removals[] = $row['permission']; |
|
1151 | - else |
|
1152 | - $user_info['permissions'][] = $row['permission']; |
|
1200 | + if (empty($row['add_deny'])) { |
|
1201 | + $removals[] = $row['permission']; |
|
1202 | + } else { |
|
1203 | + $user_info['permissions'][] = $row['permission']; |
|
1204 | + } |
|
1153 | 1205 | } |
1154 | 1206 | $smcFunc['db_free_result']($request); |
1155 | 1207 | } |
1156 | 1208 | |
1157 | 1209 | // Remove all the permissions they shouldn't have ;). |
1158 | - if (!empty($modSettings['permission_enable_deny'])) |
|
1159 | - $user_info['permissions'] = array_diff($user_info['permissions'], $removals); |
|
1210 | + if (!empty($modSettings['permission_enable_deny'])) { |
|
1211 | + $user_info['permissions'] = array_diff($user_info['permissions'], $removals); |
|
1212 | + } |
|
1160 | 1213 | |
1161 | - if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) |
|
1162 | - cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240); |
|
1214 | + if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) { |
|
1215 | + cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240); |
|
1216 | + } |
|
1163 | 1217 | |
1164 | 1218 | // Banned? Watch, don't touch.. |
1165 | 1219 | banPermissions(); |
@@ -1171,17 +1225,18 @@ discard block |
||
1171 | 1225 | { |
1172 | 1226 | require_once($sourcedir . '/Subs-Auth.php'); |
1173 | 1227 | rebuildModCache(); |
1228 | + } else { |
|
1229 | + $user_info['mod_cache'] = $_SESSION['mc']; |
|
1174 | 1230 | } |
1175 | - else |
|
1176 | - $user_info['mod_cache'] = $_SESSION['mc']; |
|
1177 | 1231 | |
1178 | 1232 | // This is a useful phantom permission added to the current user, and only the current user while they are logged in. |
1179 | 1233 | // For example this drastically simplifies certain changes to the profile area. |
1180 | 1234 | $user_info['permissions'][] = 'is_not_guest'; |
1181 | 1235 | // And now some backwards compatibility stuff for mods and whatnot that aren't expecting the new permissions. |
1182 | 1236 | $user_info['permissions'][] = 'profile_view_own'; |
1183 | - if (in_array('profile_view', $user_info['permissions'])) |
|
1184 | - $user_info['permissions'][] = 'profile_view_any'; |
|
1237 | + if (in_array('profile_view', $user_info['permissions'])) { |
|
1238 | + $user_info['permissions'][] = 'profile_view_any'; |
|
1239 | + } |
|
1185 | 1240 | } |
1186 | 1241 | } |
1187 | 1242 | |
@@ -1199,8 +1254,9 @@ discard block |
||
1199 | 1254 | global $image_proxy_enabled, $image_proxy_secret, $boardurl; |
1200 | 1255 | |
1201 | 1256 | // Can't just look for no users :P. |
1202 | - if (empty($users)) |
|
1203 | - return array(); |
|
1257 | + if (empty($users)) { |
|
1258 | + return array(); |
|
1259 | + } |
|
1204 | 1260 | |
1205 | 1261 | // Pass the set value |
1206 | 1262 | $context['loadMemberContext_set'] = $set; |
@@ -1215,8 +1271,9 @@ discard block |
||
1215 | 1271 | for ($i = 0, $n = count($users); $i < $n; $i++) |
1216 | 1272 | { |
1217 | 1273 | $data = cache_get_data('member_data-' . $set . '-' . $users[$i], 240); |
1218 | - if ($data == null) |
|
1219 | - continue; |
|
1274 | + if ($data == null) { |
|
1275 | + continue; |
|
1276 | + } |
|
1220 | 1277 | |
1221 | 1278 | $loaded_ids[] = $data['id_member']; |
1222 | 1279 | $user_profile[$data['id_member']] = $data; |
@@ -1283,13 +1340,16 @@ discard block |
||
1283 | 1340 | $row['avatar_original'] = $row['avatar']; |
1284 | 1341 | |
1285 | 1342 | // Take care of proxying avatar if required, do this here for maximum reach |
1286 | - if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false) |
|
1287 | - $row['avatar'] = $boardurl . '/proxy.php?request=' . urlencode($row['avatar']) . '&hash=' . md5($row['avatar'] . $image_proxy_secret); |
|
1343 | + if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false) { |
|
1344 | + $row['avatar'] = $boardurl . '/proxy.php?request=' . urlencode($row['avatar']) . '&hash=' . md5($row['avatar'] . $image_proxy_secret); |
|
1345 | + } |
|
1288 | 1346 | |
1289 | - if (isset($row['member_ip'])) |
|
1290 | - $row['member_ip'] = inet_dtop($row['member_ip']); |
|
1291 | - if (isset($row['member_ip2'])) |
|
1292 | - $row['member_ip2'] = inet_dtop($row['member_ip2']); |
|
1347 | + if (isset($row['member_ip'])) { |
|
1348 | + $row['member_ip'] = inet_dtop($row['member_ip']); |
|
1349 | + } |
|
1350 | + if (isset($row['member_ip2'])) { |
|
1351 | + $row['member_ip2'] = inet_dtop($row['member_ip2']); |
|
1352 | + } |
|
1293 | 1353 | $new_loaded_ids[] = $row['id_member']; |
1294 | 1354 | $loaded_ids[] = $row['id_member']; |
1295 | 1355 | $row['options'] = array(); |
@@ -1308,8 +1368,9 @@ discard block |
||
1308 | 1368 | 'loaded_ids' => $new_loaded_ids, |
1309 | 1369 | ) |
1310 | 1370 | ); |
1311 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1312 | - $user_profile[$row['id_member']]['options'][$row['variable']] = $row['value']; |
|
1371 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1372 | + $user_profile[$row['id_member']]['options'][$row['variable']] = $row['value']; |
|
1373 | + } |
|
1313 | 1374 | $smcFunc['db_free_result']($request); |
1314 | 1375 | } |
1315 | 1376 | |
@@ -1320,10 +1381,11 @@ discard block |
||
1320 | 1381 | { |
1321 | 1382 | foreach ($loaded_ids as $a_member) |
1322 | 1383 | { |
1323 | - if (!empty($user_profile[$a_member]['additional_groups'])) |
|
1324 | - $groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups'])); |
|
1325 | - else |
|
1326 | - $groups = array($user_profile[$a_member]['id_group']); |
|
1384 | + if (!empty($user_profile[$a_member]['additional_groups'])) { |
|
1385 | + $groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups'])); |
|
1386 | + } else { |
|
1387 | + $groups = array($user_profile[$a_member]['id_group']); |
|
1388 | + } |
|
1327 | 1389 | |
1328 | 1390 | $temp = array_intersect($groups, array_keys($board_info['moderator_groups'])); |
1329 | 1391 | |
@@ -1336,8 +1398,9 @@ discard block |
||
1336 | 1398 | |
1337 | 1399 | if (!empty($new_loaded_ids) && !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) |
1338 | 1400 | { |
1339 | - for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) |
|
1340 | - cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240); |
|
1401 | + for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) { |
|
1402 | + cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240); |
|
1403 | + } |
|
1341 | 1404 | } |
1342 | 1405 | |
1343 | 1406 | // Are we loading any moderators? If so, fix their group data... |
@@ -1363,14 +1426,17 @@ discard block |
||
1363 | 1426 | foreach ($temp_mods as $id) |
1364 | 1427 | { |
1365 | 1428 | // By popular demand, don't show admins or global moderators as moderators. |
1366 | - if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) |
|
1367 | - $user_profile[$id]['member_group'] = $row['member_group']; |
|
1429 | + if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) { |
|
1430 | + $user_profile[$id]['member_group'] = $row['member_group']; |
|
1431 | + } |
|
1368 | 1432 | |
1369 | 1433 | // If the Moderator group has no color or icons, but their group does... don't overwrite. |
1370 | - if (!empty($row['icons'])) |
|
1371 | - $user_profile[$id]['icons'] = $row['icons']; |
|
1372 | - if (!empty($row['member_group_color'])) |
|
1373 | - $user_profile[$id]['member_group_color'] = $row['member_group_color']; |
|
1434 | + if (!empty($row['icons'])) { |
|
1435 | + $user_profile[$id]['icons'] = $row['icons']; |
|
1436 | + } |
|
1437 | + if (!empty($row['member_group_color'])) { |
|
1438 | + $user_profile[$id]['member_group_color'] = $row['member_group_color']; |
|
1439 | + } |
|
1374 | 1440 | } |
1375 | 1441 | } |
1376 | 1442 | |
@@ -1392,12 +1458,14 @@ discard block |
||
1392 | 1458 | static $loadedLanguages = array(); |
1393 | 1459 | |
1394 | 1460 | // If this person's data is already loaded, skip it. |
1395 | - if (isset($dataLoaded[$user])) |
|
1396 | - return true; |
|
1461 | + if (isset($dataLoaded[$user])) { |
|
1462 | + return true; |
|
1463 | + } |
|
1397 | 1464 | |
1398 | 1465 | // We can't load guests or members not loaded by loadMemberData()! |
1399 | - if ($user == 0) |
|
1400 | - return false; |
|
1466 | + if ($user == 0) { |
|
1467 | + return false; |
|
1468 | + } |
|
1401 | 1469 | if (!isset($user_profile[$user])) |
1402 | 1470 | { |
1403 | 1471 | trigger_error('loadMemberContext(): member id ' . $user . ' not previously loaded by loadMemberData()', E_USER_WARNING); |
@@ -1423,12 +1491,16 @@ discard block |
||
1423 | 1491 | $buddy_list = !empty($profile['buddy_list']) ? explode(',', $profile['buddy_list']) : array(); |
1424 | 1492 | |
1425 | 1493 | //We need a little fallback for the membergroup icons. If it doesn't exist in the current theme, fallback to default theme |
1426 | - if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) //icon is set and exists |
|
1494 | + if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) { |
|
1495 | + //icon is set and exists |
|
1427 | 1496 | $group_icon_url = $settings['images_url'] . '/membericons/' . $profile['icons'][1]; |
1428 | - elseif (isset($profile['icons'][1])) //icon is set and doesn't exist, fallback to default |
|
1497 | + } elseif (isset($profile['icons'][1])) { |
|
1498 | + //icon is set and doesn't exist, fallback to default |
|
1429 | 1499 | $group_icon_url = $settings['default_images_url'] . '/membericons/' . $profile['icons'][1]; |
1430 | - else //not set, bye bye |
|
1500 | + } else { |
|
1501 | + //not set, bye bye |
|
1431 | 1502 | $group_icon_url = ''; |
1503 | + } |
|
1432 | 1504 | |
1433 | 1505 | // These minimal values are always loaded |
1434 | 1506 | $memberContext[$user] = array( |
@@ -1447,8 +1519,9 @@ discard block |
||
1447 | 1519 | if ($context['loadMemberContext_set'] != 'minimal') |
1448 | 1520 | { |
1449 | 1521 | // Go the extra mile and load the user's native language name. |
1450 | - if (empty($loadedLanguages)) |
|
1451 | - $loadedLanguages = getLanguages(); |
|
1522 | + if (empty($loadedLanguages)) { |
|
1523 | + $loadedLanguages = getLanguages(); |
|
1524 | + } |
|
1452 | 1525 | |
1453 | 1526 | $memberContext[$user] += array( |
1454 | 1527 | 'username_color' => '<span ' . (!empty($profile['member_group_color']) ? 'style="color:' . $profile['member_group_color'] . ';"' : '') . '>' . $profile['member_name'] . '</span>', |
@@ -1502,31 +1575,33 @@ discard block |
||
1502 | 1575 | { |
1503 | 1576 | if (!empty($modSettings['gravatarOverride']) || (!empty($modSettings['gravatarEnabled']) && stristr($profile['avatar'], 'gravatar://'))) |
1504 | 1577 | { |
1505 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) |
|
1506 | - $image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11)); |
|
1507 | - else |
|
1508 | - $image = get_gravatar_url($profile['email_address']); |
|
1509 | - } |
|
1510 | - else |
|
1578 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) { |
|
1579 | + $image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11)); |
|
1580 | + } else { |
|
1581 | + $image = get_gravatar_url($profile['email_address']); |
|
1582 | + } |
|
1583 | + } else |
|
1511 | 1584 | { |
1512 | 1585 | // So it's stored in the member table? |
1513 | 1586 | if (!empty($profile['avatar'])) |
1514 | 1587 | { |
1515 | 1588 | $image = (stristr($profile['avatar'], 'http://') || stristr($profile['avatar'], 'https://')) ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar']; |
1589 | + } elseif (!empty($profile['filename'])) { |
|
1590 | + $image = $modSettings['custom_avatar_url'] . '/' . $profile['filename']; |
|
1516 | 1591 | } |
1517 | - elseif (!empty($profile['filename'])) |
|
1518 | - $image = $modSettings['custom_avatar_url'] . '/' . $profile['filename']; |
|
1519 | 1592 | // Right... no avatar...use the default one |
1520 | - else |
|
1521 | - $image = $modSettings['avatar_url'] . '/default.png'; |
|
1593 | + else { |
|
1594 | + $image = $modSettings['avatar_url'] . '/default.png'; |
|
1595 | + } |
|
1522 | 1596 | } |
1523 | - if (!empty($image)) |
|
1524 | - $memberContext[$user]['avatar'] = array( |
|
1597 | + if (!empty($image)) { |
|
1598 | + $memberContext[$user]['avatar'] = array( |
|
1525 | 1599 | 'name' => $profile['avatar'], |
1526 | 1600 | 'image' => '<img class="avatar" src="' . $image . '" alt="avatar_' . $profile['member_name'] . '">', |
1527 | 1601 | 'href' => $image, |
1528 | 1602 | 'url' => $image, |
1529 | 1603 | ); |
1604 | + } |
|
1530 | 1605 | } |
1531 | 1606 | |
1532 | 1607 | // Are we also loading the members custom fields into context? |
@@ -1534,35 +1609,41 @@ discard block |
||
1534 | 1609 | { |
1535 | 1610 | $memberContext[$user]['custom_fields'] = array(); |
1536 | 1611 | |
1537 | - if (!isset($context['display_fields'])) |
|
1538 | - $context['display_fields'] = smf_json_decode($modSettings['displayFields'], true); |
|
1612 | + if (!isset($context['display_fields'])) { |
|
1613 | + $context['display_fields'] = smf_json_decode($modSettings['displayFields'], true); |
|
1614 | + } |
|
1539 | 1615 | |
1540 | 1616 | foreach ($context['display_fields'] as $custom) |
1541 | 1617 | { |
1542 | - if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) |
|
1543 | - continue; |
|
1618 | + if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) { |
|
1619 | + continue; |
|
1620 | + } |
|
1544 | 1621 | |
1545 | 1622 | $value = $profile['options'][$custom['col_name']]; |
1546 | 1623 | |
1547 | 1624 | // Don't show the "disabled" option for the "gender" field. |
1548 | - if ($custom['col_name'] == 'cust_gender' && $value == 'Disabled') |
|
1549 | - continue; |
|
1625 | + if ($custom['col_name'] == 'cust_gender' && $value == 'Disabled') { |
|
1626 | + continue; |
|
1627 | + } |
|
1550 | 1628 | |
1551 | 1629 | // BBC? |
1552 | - if ($custom['bbc']) |
|
1553 | - $value = parse_bbc($value); |
|
1630 | + if ($custom['bbc']) { |
|
1631 | + $value = parse_bbc($value); |
|
1632 | + } |
|
1554 | 1633 | // ... or checkbox? |
1555 | - elseif (isset($custom['type']) && $custom['type'] == 'check') |
|
1556 | - $value = $value ? $txt['yes'] : $txt['no']; |
|
1634 | + elseif (isset($custom['type']) && $custom['type'] == 'check') { |
|
1635 | + $value = $value ? $txt['yes'] : $txt['no']; |
|
1636 | + } |
|
1557 | 1637 | |
1558 | 1638 | // Enclosing the user input within some other text? |
1559 | - if (!empty($custom['enclose'])) |
|
1560 | - $value = strtr($custom['enclose'], array( |
|
1639 | + if (!empty($custom['enclose'])) { |
|
1640 | + $value = strtr($custom['enclose'], array( |
|
1561 | 1641 | '{SCRIPTURL}' => $scripturl, |
1562 | 1642 | '{IMAGES_URL}' => $settings['images_url'], |
1563 | 1643 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
1564 | 1644 | '{INPUT}' => $value, |
1565 | 1645 | )); |
1646 | + } |
|
1566 | 1647 | |
1567 | 1648 | $memberContext[$user]['custom_fields'][] = array( |
1568 | 1649 | 'title' => !empty($custom['title']) ? $custom['title'] : $custom['col_name'], |
@@ -1589,8 +1670,9 @@ discard block |
||
1589 | 1670 | global $smcFunc, $txt, $scripturl, $settings; |
1590 | 1671 | |
1591 | 1672 | // Do not waste my time... |
1592 | - if (empty($users) || empty($params)) |
|
1593 | - return false; |
|
1673 | + if (empty($users) || empty($params)) { |
|
1674 | + return false; |
|
1675 | + } |
|
1594 | 1676 | |
1595 | 1677 | // Make sure it's an array. |
1596 | 1678 | $users = !is_array($users) ? array($users) : array_unique($users); |
@@ -1614,31 +1696,36 @@ discard block |
||
1614 | 1696 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1615 | 1697 | { |
1616 | 1698 | // BBC? |
1617 | - if (!empty($row['bbc'])) |
|
1618 | - $row['value'] = parse_bbc($row['value']); |
|
1699 | + if (!empty($row['bbc'])) { |
|
1700 | + $row['value'] = parse_bbc($row['value']); |
|
1701 | + } |
|
1619 | 1702 | |
1620 | 1703 | // ... or checkbox? |
1621 | - elseif (isset($row['type']) && $row['type'] == 'check') |
|
1622 | - $row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no']; |
|
1704 | + elseif (isset($row['type']) && $row['type'] == 'check') { |
|
1705 | + $row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no']; |
|
1706 | + } |
|
1623 | 1707 | |
1624 | 1708 | // Enclosing the user input within some other text? |
1625 | - if (!empty($row['enclose'])) |
|
1626 | - $row['value'] = strtr($row['enclose'], array( |
|
1709 | + if (!empty($row['enclose'])) { |
|
1710 | + $row['value'] = strtr($row['enclose'], array( |
|
1627 | 1711 | '{SCRIPTURL}' => $scripturl, |
1628 | 1712 | '{IMAGES_URL}' => $settings['images_url'], |
1629 | 1713 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
1630 | 1714 | '{INPUT}' => un_htmlspecialchars($row['value']), |
1631 | 1715 | )); |
1716 | + } |
|
1632 | 1717 | |
1633 | 1718 | // Send a simple array if there is just 1 param |
1634 | - if (count($params) == 1) |
|
1635 | - $return[$row['id_member']] = $row; |
|
1719 | + if (count($params) == 1) { |
|
1720 | + $return[$row['id_member']] = $row; |
|
1721 | + } |
|
1636 | 1722 | |
1637 | 1723 | // More than 1? knock yourself out... |
1638 | 1724 | else |
1639 | 1725 | { |
1640 | - if (!isset($return[$row['id_member']])) |
|
1641 | - $return[$row['id_member']] = array(); |
|
1726 | + if (!isset($return[$row['id_member']])) { |
|
1727 | + $return[$row['id_member']] = array(); |
|
1728 | + } |
|
1642 | 1729 | |
1643 | 1730 | $return[$row['id_member']][$row['variable']] = $row; |
1644 | 1731 | } |
@@ -1672,8 +1759,9 @@ discard block |
||
1672 | 1759 | global $context; |
1673 | 1760 | |
1674 | 1761 | // Don't know any browser! |
1675 | - if (empty($context['browser'])) |
|
1676 | - detectBrowser(); |
|
1762 | + if (empty($context['browser'])) { |
|
1763 | + detectBrowser(); |
|
1764 | + } |
|
1677 | 1765 | |
1678 | 1766 | return !empty($context['browser'][$browser]) || !empty($context['browser']['is_' . $browser]) ? true : false; |
1679 | 1767 | } |
@@ -1691,8 +1779,9 @@ discard block |
||
1691 | 1779 | global $context, $settings, $options, $sourcedir, $ssi_theme, $smcFunc, $language, $board, $image_proxy_enabled; |
1692 | 1780 | |
1693 | 1781 | // The theme was specified by parameter. |
1694 | - if (!empty($id_theme)) |
|
1695 | - $id_theme = (int) $id_theme; |
|
1782 | + if (!empty($id_theme)) { |
|
1783 | + $id_theme = (int) $id_theme; |
|
1784 | + } |
|
1696 | 1785 | // The theme was specified by REQUEST. |
1697 | 1786 | elseif (!empty($_REQUEST['theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) |
1698 | 1787 | { |
@@ -1700,51 +1789,58 @@ discard block |
||
1700 | 1789 | $_SESSION['id_theme'] = $id_theme; |
1701 | 1790 | } |
1702 | 1791 | // The theme was specified by REQUEST... previously. |
1703 | - elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) |
|
1704 | - $id_theme = (int) $_SESSION['id_theme']; |
|
1792 | + elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) { |
|
1793 | + $id_theme = (int) $_SESSION['id_theme']; |
|
1794 | + } |
|
1705 | 1795 | // The theme is just the user's choice. (might use ?board=1;theme=0 to force board theme.) |
1706 | - elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) |
|
1707 | - $id_theme = $user_info['theme']; |
|
1796 | + elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) { |
|
1797 | + $id_theme = $user_info['theme']; |
|
1798 | + } |
|
1708 | 1799 | // The theme was specified by the board. |
1709 | - elseif (!empty($board_info['theme'])) |
|
1710 | - $id_theme = $board_info['theme']; |
|
1800 | + elseif (!empty($board_info['theme'])) { |
|
1801 | + $id_theme = $board_info['theme']; |
|
1802 | + } |
|
1711 | 1803 | // The theme is the forum's default. |
1712 | - else |
|
1713 | - $id_theme = $modSettings['theme_guests']; |
|
1804 | + else { |
|
1805 | + $id_theme = $modSettings['theme_guests']; |
|
1806 | + } |
|
1714 | 1807 | |
1715 | 1808 | // Verify the id_theme... no foul play. |
1716 | 1809 | // Always allow the board specific theme, if they are overriding. |
1717 | - if (!empty($board_info['theme']) && $board_info['override_theme']) |
|
1718 | - $id_theme = $board_info['theme']; |
|
1810 | + if (!empty($board_info['theme']) && $board_info['override_theme']) { |
|
1811 | + $id_theme = $board_info['theme']; |
|
1812 | + } |
|
1719 | 1813 | // If they have specified a particular theme to use with SSI allow it to be used. |
1720 | - elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) |
|
1721 | - $id_theme = (int) $id_theme; |
|
1722 | - elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum')) |
|
1814 | + elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) { |
|
1815 | + $id_theme = (int) $id_theme; |
|
1816 | + } elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum')) |
|
1723 | 1817 | { |
1724 | 1818 | $themes = explode(',', $modSettings['enableThemes']); |
1725 | - if (!in_array($id_theme, $themes)) |
|
1726 | - $id_theme = $modSettings['theme_guests']; |
|
1727 | - else |
|
1819 | + if (!in_array($id_theme, $themes)) { |
|
1820 | + $id_theme = $modSettings['theme_guests']; |
|
1821 | + } else { |
|
1822 | + $id_theme = (int) $id_theme; |
|
1823 | + } |
|
1824 | + } else { |
|
1728 | 1825 | $id_theme = (int) $id_theme; |
1729 | 1826 | } |
1730 | - else |
|
1731 | - $id_theme = (int) $id_theme; |
|
1732 | 1827 | |
1733 | 1828 | $member = empty($user_info['id']) ? -1 : $user_info['id']; |
1734 | 1829 | |
1735 | 1830 | // Disable image proxy if we don't have SSL enabled |
1736 | - if (empty($modSettings['force_ssl']) || $modSettings['force_ssl'] < 2) |
|
1737 | - $image_proxy_enabled = false; |
|
1831 | + if (empty($modSettings['force_ssl']) || $modSettings['force_ssl'] < 2) { |
|
1832 | + $image_proxy_enabled = false; |
|
1833 | + } |
|
1738 | 1834 | |
1739 | 1835 | if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2 && ($temp = cache_get_data('theme_settings-' . $id_theme . ':' . $member, 60)) != null && time() - 60 > $modSettings['settings_updated']) |
1740 | 1836 | { |
1741 | 1837 | $themeData = $temp; |
1742 | 1838 | $flag = true; |
1839 | + } elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) { |
|
1840 | + $themeData = $temp + array($member => array()); |
|
1841 | + } else { |
|
1842 | + $themeData = array(-1 => array(), 0 => array(), $member => array()); |
|
1743 | 1843 | } |
1744 | - elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) |
|
1745 | - $themeData = $temp + array($member => array()); |
|
1746 | - else |
|
1747 | - $themeData = array(-1 => array(), 0 => array(), $member => array()); |
|
1748 | 1844 | |
1749 | 1845 | if (empty($flag)) |
1750 | 1846 | { |
@@ -1763,31 +1859,37 @@ discard block |
||
1763 | 1859 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
1764 | 1860 | { |
1765 | 1861 | // There are just things we shouldn't be able to change as members. |
1766 | - if ($row['id_member'] != 0 && in_array($row['variable'], array('actual_theme_url', 'actual_images_url', 'base_theme_dir', 'base_theme_url', 'default_images_url', 'default_theme_dir', 'default_theme_url', 'default_template', 'images_url', 'number_recent_posts', 'smiley_sets_default', 'theme_dir', 'theme_id', 'theme_layers', 'theme_templates', 'theme_url'))) |
|
1767 | - continue; |
|
1862 | + if ($row['id_member'] != 0 && in_array($row['variable'], array('actual_theme_url', 'actual_images_url', 'base_theme_dir', 'base_theme_url', 'default_images_url', 'default_theme_dir', 'default_theme_url', 'default_template', 'images_url', 'number_recent_posts', 'smiley_sets_default', 'theme_dir', 'theme_id', 'theme_layers', 'theme_templates', 'theme_url'))) { |
|
1863 | + continue; |
|
1864 | + } |
|
1768 | 1865 | |
1769 | 1866 | // If this is the theme_dir of the default theme, store it. |
1770 | - if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) |
|
1771 | - $themeData[0]['default_' . $row['variable']] = $row['value']; |
|
1867 | + if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) { |
|
1868 | + $themeData[0]['default_' . $row['variable']] = $row['value']; |
|
1869 | + } |
|
1772 | 1870 | |
1773 | 1871 | // If this isn't set yet, is a theme option, or is not the default theme.. |
1774 | - if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') |
|
1775 | - $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value']; |
|
1872 | + if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') { |
|
1873 | + $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value']; |
|
1874 | + } |
|
1776 | 1875 | } |
1777 | 1876 | $smcFunc['db_free_result']($result); |
1778 | 1877 | |
1779 | - if (!empty($themeData[-1])) |
|
1780 | - foreach ($themeData[-1] as $k => $v) |
|
1878 | + if (!empty($themeData[-1])) { |
|
1879 | + foreach ($themeData[-1] as $k => $v) |
|
1781 | 1880 | { |
1782 | 1881 | if (!isset($themeData[$member][$k])) |
1783 | 1882 | $themeData[$member][$k] = $v; |
1883 | + } |
|
1784 | 1884 | } |
1785 | 1885 | |
1786 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
1787 | - cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60); |
|
1886 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
1887 | + cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60); |
|
1888 | + } |
|
1788 | 1889 | // Only if we didn't already load that part of the cache... |
1789 | - elseif (!isset($temp)) |
|
1790 | - cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90); |
|
1890 | + elseif (!isset($temp)) { |
|
1891 | + cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90); |
|
1892 | + } |
|
1791 | 1893 | } |
1792 | 1894 | |
1793 | 1895 | $settings = $themeData[0]; |
@@ -1804,20 +1906,24 @@ discard block |
||
1804 | 1906 | $settings['template_dirs'][] = $settings['theme_dir']; |
1805 | 1907 | |
1806 | 1908 | // Based on theme (if there is one). |
1807 | - if (!empty($settings['base_theme_dir'])) |
|
1808 | - $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
1909 | + if (!empty($settings['base_theme_dir'])) { |
|
1910 | + $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
1911 | + } |
|
1809 | 1912 | |
1810 | 1913 | // Lastly the default theme. |
1811 | - if ($settings['theme_dir'] != $settings['default_theme_dir']) |
|
1812 | - $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
1914 | + if ($settings['theme_dir'] != $settings['default_theme_dir']) { |
|
1915 | + $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
1916 | + } |
|
1813 | 1917 | |
1814 | - if (!$initialize) |
|
1815 | - return; |
|
1918 | + if (!$initialize) { |
|
1919 | + return; |
|
1920 | + } |
|
1816 | 1921 | |
1817 | 1922 | // Check to see if we're forcing SSL |
1818 | 1923 | if (!empty($modSettings['force_ssl']) && $modSettings['force_ssl'] == 2 && empty($maintenance) && |
1819 | - (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off') && SMF != 'SSI') |
|
1820 | - redirectexit(strtr($_SERVER['REQUEST_URL'], array('http://' => 'https://'))); |
|
1924 | + (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off') && SMF != 'SSI') { |
|
1925 | + redirectexit(strtr($_SERVER['REQUEST_URL'], array('http://' => 'https://'))); |
|
1926 | + } |
|
1821 | 1927 | |
1822 | 1928 | // Check to see if they're accessing it from the wrong place. |
1823 | 1929 | if (isset($_SERVER['HTTP_HOST']) || isset($_SERVER['SERVER_NAME'])) |
@@ -1825,8 +1931,9 @@ discard block |
||
1825 | 1931 | $detected_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 'https://' : 'http://'; |
1826 | 1932 | $detected_url .= empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] . (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT']) : $_SERVER['HTTP_HOST']; |
1827 | 1933 | $temp = preg_replace('~/' . basename($scripturl) . '(/.+)?$~', '', strtr(dirname($_SERVER['PHP_SELF']), '\\', '/')); |
1828 | - if ($temp != '/') |
|
1829 | - $detected_url .= $temp; |
|
1934 | + if ($temp != '/') { |
|
1935 | + $detected_url .= $temp; |
|
1936 | + } |
|
1830 | 1937 | } |
1831 | 1938 | if (isset($detected_url) && $detected_url != $boardurl) |
1832 | 1939 | { |
@@ -1838,8 +1945,9 @@ discard block |
||
1838 | 1945 | foreach ($aliases as $alias) |
1839 | 1946 | { |
1840 | 1947 | // Rip off all the boring parts, spaces, etc. |
1841 | - if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) |
|
1842 | - $do_fix = true; |
|
1948 | + if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) { |
|
1949 | + $do_fix = true; |
|
1950 | + } |
|
1843 | 1951 | } |
1844 | 1952 | } |
1845 | 1953 | |
@@ -1847,20 +1955,22 @@ discard block |
||
1847 | 1955 | if (empty($do_fix) && strtr($detected_url, array('://' => '://www.')) == $boardurl && (empty($_GET) || count($_GET) == 1) && SMF != 'SSI') |
1848 | 1956 | { |
1849 | 1957 | // Okay, this seems weird, but we don't want an endless loop - this will make $_GET not empty ;). |
1850 | - if (empty($_GET)) |
|
1851 | - redirectexit('wwwRedirect'); |
|
1852 | - else |
|
1958 | + if (empty($_GET)) { |
|
1959 | + redirectexit('wwwRedirect'); |
|
1960 | + } else |
|
1853 | 1961 | { |
1854 | 1962 | list ($k, $v) = each($_GET); |
1855 | 1963 | |
1856 | - if ($k != 'wwwRedirect') |
|
1857 | - redirectexit('wwwRedirect;' . $k . '=' . $v); |
|
1964 | + if ($k != 'wwwRedirect') { |
|
1965 | + redirectexit('wwwRedirect;' . $k . '=' . $v); |
|
1966 | + } |
|
1858 | 1967 | } |
1859 | 1968 | } |
1860 | 1969 | |
1861 | 1970 | // #3 is just a check for SSL... |
1862 | - if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) |
|
1863 | - $do_fix = true; |
|
1971 | + if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) { |
|
1972 | + $do_fix = true; |
|
1973 | + } |
|
1864 | 1974 | |
1865 | 1975 | // Okay, #4 - perhaps it's an IP address? We're gonna want to use that one, then. (assuming it's the IP or something...) |
1866 | 1976 | if (!empty($do_fix) || preg_match('~^http[s]?://(?:[\d\.:]+|\[[\d:]+\](?::\d+)?)(?:$|/)~', $detected_url) == 1) |
@@ -1894,8 +2004,9 @@ discard block |
||
1894 | 2004 | $board_info['moderators'][$k]['link'] = strtr($dummy['link'], array('"' . $oldurl => '"' . $boardurl)); |
1895 | 2005 | } |
1896 | 2006 | } |
1897 | - foreach ($context['linktree'] as $k => $dummy) |
|
1898 | - $context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl)); |
|
2007 | + foreach ($context['linktree'] as $k => $dummy) { |
|
2008 | + $context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl)); |
|
2009 | + } |
|
1899 | 2010 | } |
1900 | 2011 | } |
1901 | 2012 | // Set up the contextual user array. |
@@ -1914,16 +2025,16 @@ discard block |
||
1914 | 2025 | 'email' => $user_info['email'], |
1915 | 2026 | 'ignoreusers' => $user_info['ignoreusers'], |
1916 | 2027 | ); |
1917 | - if (!$context['user']['is_guest']) |
|
1918 | - $context['user']['name'] = $user_info['name']; |
|
1919 | - elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) |
|
1920 | - $context['user']['name'] = $txt['guest_title']; |
|
2028 | + if (!$context['user']['is_guest']) { |
|
2029 | + $context['user']['name'] = $user_info['name']; |
|
2030 | + } elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) { |
|
2031 | + $context['user']['name'] = $txt['guest_title']; |
|
2032 | + } |
|
1921 | 2033 | |
1922 | 2034 | // Determine the current smiley set. |
1923 | 2035 | $user_info['smiley_set'] = (!in_array($user_info['smiley_set'], explode(',', $modSettings['smiley_sets_known'])) && $user_info['smiley_set'] != 'none') || empty($modSettings['smiley_sets_enable']) ? (!empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default']) : $user_info['smiley_set']; |
1924 | 2036 | $context['user']['smiley_set'] = $user_info['smiley_set']; |
1925 | - } |
|
1926 | - else |
|
2037 | + } else |
|
1927 | 2038 | { |
1928 | 2039 | $context['user'] = array( |
1929 | 2040 | 'id' => -1, |
@@ -1939,18 +2050,24 @@ discard block |
||
1939 | 2050 | } |
1940 | 2051 | |
1941 | 2052 | // Some basic information... |
1942 | - if (!isset($context['html_headers'])) |
|
1943 | - $context['html_headers'] = ''; |
|
1944 | - if (!isset($context['javascript_files'])) |
|
1945 | - $context['javascript_files'] = array(); |
|
1946 | - if (!isset($context['css_files'])) |
|
1947 | - $context['css_files'] = array(); |
|
1948 | - if (!isset($context['css_header'])) |
|
1949 | - $context['css_header'] = array(); |
|
1950 | - if (!isset($context['javascript_inline'])) |
|
1951 | - $context['javascript_inline'] = array('standard' => array(), 'defer' => array()); |
|
1952 | - if (!isset($context['javascript_vars'])) |
|
1953 | - $context['javascript_vars'] = array(); |
|
2053 | + if (!isset($context['html_headers'])) { |
|
2054 | + $context['html_headers'] = ''; |
|
2055 | + } |
|
2056 | + if (!isset($context['javascript_files'])) { |
|
2057 | + $context['javascript_files'] = array(); |
|
2058 | + } |
|
2059 | + if (!isset($context['css_files'])) { |
|
2060 | + $context['css_files'] = array(); |
|
2061 | + } |
|
2062 | + if (!isset($context['css_header'])) { |
|
2063 | + $context['css_header'] = array(); |
|
2064 | + } |
|
2065 | + if (!isset($context['javascript_inline'])) { |
|
2066 | + $context['javascript_inline'] = array('standard' => array(), 'defer' => array()); |
|
2067 | + } |
|
2068 | + if (!isset($context['javascript_vars'])) { |
|
2069 | + $context['javascript_vars'] = array(); |
|
2070 | + } |
|
1954 | 2071 | |
1955 | 2072 | $context['login_url'] = (!empty($modSettings['force_ssl']) && $modSettings['force_ssl'] < 2 ? strtr($scripturl, array('http://' => 'https://')) : $scripturl) . '?action=login2'; |
1956 | 2073 | $context['menu_separator'] = !empty($settings['use_image_buttons']) ? ' ' : ' | '; |
@@ -1962,8 +2079,9 @@ discard block |
||
1962 | 2079 | $context['current_action'] = isset($_REQUEST['action']) ? $smcFunc['htmlspecialchars']($_REQUEST['action']) : null; |
1963 | 2080 | $context['current_subaction'] = isset($_REQUEST['sa']) ? $_REQUEST['sa'] : null; |
1964 | 2081 | $context['can_register'] = empty($modSettings['registration_method']) || $modSettings['registration_method'] != 3; |
1965 | - if (isset($modSettings['load_average'])) |
|
1966 | - $context['load_average'] = $modSettings['load_average']; |
|
2082 | + if (isset($modSettings['load_average'])) { |
|
2083 | + $context['load_average'] = $modSettings['load_average']; |
|
2084 | + } |
|
1967 | 2085 | |
1968 | 2086 | // Detect the browser. This is separated out because it's also used in attachment downloads |
1969 | 2087 | detectBrowser(); |
@@ -1977,8 +2095,9 @@ discard block |
||
1977 | 2095 | // This allows sticking some HTML on the page output - useful for controls. |
1978 | 2096 | $context['insert_after_template'] = ''; |
1979 | 2097 | |
1980 | - if (!isset($txt)) |
|
1981 | - $txt = array(); |
|
2098 | + if (!isset($txt)) { |
|
2099 | + $txt = array(); |
|
2100 | + } |
|
1982 | 2101 | |
1983 | 2102 | $simpleActions = array( |
1984 | 2103 | 'findmember', |
@@ -2024,9 +2143,10 @@ discard block |
||
2024 | 2143 | |
2025 | 2144 | // See if theres any extra param to check. |
2026 | 2145 | $requiresXML = false; |
2027 | - foreach ($extraParams as $key => $extra) |
|
2028 | - if (isset($_REQUEST[$extra])) |
|
2146 | + foreach ($extraParams as $key => $extra) { |
|
2147 | + if (isset($_REQUEST[$extra])) |
|
2029 | 2148 | $requiresXML = true; |
2149 | + } |
|
2030 | 2150 | |
2031 | 2151 | // Output is fully XML, so no need for the index template. |
2032 | 2152 | if (isset($_REQUEST['xml']) && (in_array($context['current_action'], $xmlActions) || $requiresXML)) |
@@ -2041,37 +2161,39 @@ discard block |
||
2041 | 2161 | { |
2042 | 2162 | loadLanguage('index+Modifications'); |
2043 | 2163 | $context['template_layers'] = array(); |
2044 | - } |
|
2045 | - |
|
2046 | - else |
|
2164 | + } else |
|
2047 | 2165 | { |
2048 | 2166 | // Custom templates to load, or just default? |
2049 | - if (isset($settings['theme_templates'])) |
|
2050 | - $templates = explode(',', $settings['theme_templates']); |
|
2051 | - else |
|
2052 | - $templates = array('index'); |
|
2167 | + if (isset($settings['theme_templates'])) { |
|
2168 | + $templates = explode(',', $settings['theme_templates']); |
|
2169 | + } else { |
|
2170 | + $templates = array('index'); |
|
2171 | + } |
|
2053 | 2172 | |
2054 | 2173 | // Load each template... |
2055 | - foreach ($templates as $template) |
|
2056 | - loadTemplate($template); |
|
2174 | + foreach ($templates as $template) { |
|
2175 | + loadTemplate($template); |
|
2176 | + } |
|
2057 | 2177 | |
2058 | 2178 | // ...and attempt to load their associated language files. |
2059 | 2179 | $required_files = implode('+', array_merge($templates, array('Modifications'))); |
2060 | 2180 | loadLanguage($required_files, '', false); |
2061 | 2181 | |
2062 | 2182 | // Custom template layers? |
2063 | - if (isset($settings['theme_layers'])) |
|
2064 | - $context['template_layers'] = explode(',', $settings['theme_layers']); |
|
2065 | - else |
|
2066 | - $context['template_layers'] = array('html', 'body'); |
|
2183 | + if (isset($settings['theme_layers'])) { |
|
2184 | + $context['template_layers'] = explode(',', $settings['theme_layers']); |
|
2185 | + } else { |
|
2186 | + $context['template_layers'] = array('html', 'body'); |
|
2187 | + } |
|
2067 | 2188 | } |
2068 | 2189 | |
2069 | 2190 | // Initialize the theme. |
2070 | 2191 | loadSubTemplate('init', 'ignore'); |
2071 | 2192 | |
2072 | 2193 | // Allow overriding the board wide time/number formats. |
2073 | - if (empty($user_settings['time_format']) && !empty($txt['time_format'])) |
|
2074 | - $user_info['time_format'] = $txt['time_format']; |
|
2194 | + if (empty($user_settings['time_format']) && !empty($txt['time_format'])) { |
|
2195 | + $user_info['time_format'] = $txt['time_format']; |
|
2196 | + } |
|
2075 | 2197 | |
2076 | 2198 | // Set the character set from the template. |
2077 | 2199 | $context['character_set'] = empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']; |
@@ -2079,12 +2201,14 @@ discard block |
||
2079 | 2201 | $context['right_to_left'] = !empty($txt['lang_rtl']); |
2080 | 2202 | |
2081 | 2203 | // Guests may still need a name. |
2082 | - if ($context['user']['is_guest'] && empty($context['user']['name'])) |
|
2083 | - $context['user']['name'] = $txt['guest_title']; |
|
2204 | + if ($context['user']['is_guest'] && empty($context['user']['name'])) { |
|
2205 | + $context['user']['name'] = $txt['guest_title']; |
|
2206 | + } |
|
2084 | 2207 | |
2085 | 2208 | // Any theme-related strings that need to be loaded? |
2086 | - if (!empty($settings['require_theme_strings'])) |
|
2087 | - loadLanguage('ThemeStrings', '', false); |
|
2209 | + if (!empty($settings['require_theme_strings'])) { |
|
2210 | + loadLanguage('ThemeStrings', '', false); |
|
2211 | + } |
|
2088 | 2212 | |
2089 | 2213 | // Make a special URL for the language. |
2090 | 2214 | $settings['lang_images_url'] = $settings['images_url'] . '/' . (!empty($txt['image_lang']) ? $txt['image_lang'] : $user_info['language']); |
@@ -2095,8 +2219,9 @@ discard block |
||
2095 | 2219 | // Here is my luvly Responsive CSS |
2096 | 2220 | loadCSSFile('responsive.css', array('force_current' => false, 'validate' => true, 'minimize' => true), 'smf_responsive'); |
2097 | 2221 | |
2098 | - if ($context['right_to_left']) |
|
2099 | - loadCSSFile('rtl.css', array(), 'smf_rtl'); |
|
2222 | + if ($context['right_to_left']) { |
|
2223 | + loadCSSFile('rtl.css', array(), 'smf_rtl'); |
|
2224 | + } |
|
2100 | 2225 | |
2101 | 2226 | // We allow theme variants, because we're cool. |
2102 | 2227 | $context['theme_variant'] = ''; |
@@ -2104,14 +2229,17 @@ discard block |
||
2104 | 2229 | if (!empty($settings['theme_variants'])) |
2105 | 2230 | { |
2106 | 2231 | // Overriding - for previews and that ilk. |
2107 | - if (!empty($_REQUEST['variant'])) |
|
2108 | - $_SESSION['id_variant'] = $_REQUEST['variant']; |
|
2232 | + if (!empty($_REQUEST['variant'])) { |
|
2233 | + $_SESSION['id_variant'] = $_REQUEST['variant']; |
|
2234 | + } |
|
2109 | 2235 | // User selection? |
2110 | - if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) |
|
2111 | - $context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : ''); |
|
2236 | + if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) { |
|
2237 | + $context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : ''); |
|
2238 | + } |
|
2112 | 2239 | // If not a user variant, select the default. |
2113 | - if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) |
|
2114 | - $context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0]; |
|
2240 | + if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) { |
|
2241 | + $context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0]; |
|
2242 | + } |
|
2115 | 2243 | |
2116 | 2244 | // Do this to keep things easier in the templates. |
2117 | 2245 | $context['theme_variant'] = '_' . $context['theme_variant']; |
@@ -2120,20 +2248,23 @@ discard block |
||
2120 | 2248 | if (!empty($context['theme_variant'])) |
2121 | 2249 | { |
2122 | 2250 | loadCSSFile('index' . $context['theme_variant'] . '.css', array(), 'smf_index' . $context['theme_variant']); |
2123 | - if ($context['right_to_left']) |
|
2124 | - loadCSSFile('rtl' . $context['theme_variant'] . '.css', array(), 'smf_rtl' . $context['theme_variant']); |
|
2251 | + if ($context['right_to_left']) { |
|
2252 | + loadCSSFile('rtl' . $context['theme_variant'] . '.css', array(), 'smf_rtl' . $context['theme_variant']); |
|
2253 | + } |
|
2125 | 2254 | } |
2126 | 2255 | } |
2127 | 2256 | |
2128 | 2257 | // Let's be compatible with old themes! |
2129 | - if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) |
|
2130 | - $context['template_layers'] = array('main'); |
|
2258 | + if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) { |
|
2259 | + $context['template_layers'] = array('main'); |
|
2260 | + } |
|
2131 | 2261 | |
2132 | 2262 | $context['tabindex'] = 1; |
2133 | 2263 | |
2134 | 2264 | // Compatibility. |
2135 | - if (!isset($settings['theme_version'])) |
|
2136 | - $modSettings['memberCount'] = $modSettings['totalMembers']; |
|
2265 | + if (!isset($settings['theme_version'])) { |
|
2266 | + $modSettings['memberCount'] = $modSettings['totalMembers']; |
|
2267 | + } |
|
2137 | 2268 | |
2138 | 2269 | // Default JS variables for use in every theme |
2139 | 2270 | $context['javascript_vars'] = array( |
@@ -2152,18 +2283,18 @@ discard block |
||
2152 | 2283 | ); |
2153 | 2284 | |
2154 | 2285 | // Add the JQuery library to the list of files to load. |
2155 | - if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') |
|
2156 | - loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2157 | - |
|
2158 | - elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') |
|
2159 | - loadJavaScriptFile('jquery-3.1.1.min.js', array('seed' => false), 'smf_jquery'); |
|
2160 | - |
|
2161 | - elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') |
|
2162 | - loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery'); |
|
2286 | + if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') { |
|
2287 | + loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2288 | + } elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') { |
|
2289 | + loadJavaScriptFile('jquery-3.1.1.min.js', array('seed' => false), 'smf_jquery'); |
|
2290 | + } elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') { |
|
2291 | + loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery'); |
|
2292 | + } |
|
2163 | 2293 | |
2164 | 2294 | // Auto loading? template_javascript() will take care of the local half of this. |
2165 | - else |
|
2166 | - loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2295 | + else { |
|
2296 | + loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2297 | + } |
|
2167 | 2298 | |
2168 | 2299 | // Queue our JQuery plugins! |
2169 | 2300 | loadJavaScriptFile('smf_jquery_plugins.js', array('minimize' => true), 'smf_jquery_plugins'); |
@@ -2186,12 +2317,12 @@ discard block |
||
2186 | 2317 | require_once($sourcedir . '/ScheduledTasks.php'); |
2187 | 2318 | |
2188 | 2319 | // What to do, what to do?! |
2189 | - if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) |
|
2190 | - AutoTask(); |
|
2191 | - else |
|
2192 | - ReduceMailQueue(); |
|
2193 | - } |
|
2194 | - else |
|
2320 | + if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) { |
|
2321 | + AutoTask(); |
|
2322 | + } else { |
|
2323 | + ReduceMailQueue(); |
|
2324 | + } |
|
2325 | + } else |
|
2195 | 2326 | { |
2196 | 2327 | $type = empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time() ? 'task' : 'mailq'; |
2197 | 2328 | $ts = $type == 'mailq' ? $modSettings['mail_next_send'] : $modSettings['next_task_time']; |
@@ -2242,8 +2373,9 @@ discard block |
||
2242 | 2373 | foreach ($theme_includes as $include) |
2243 | 2374 | { |
2244 | 2375 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
2245 | - if (file_exists($include)) |
|
2246 | - require_once($include); |
|
2376 | + if (file_exists($include)) { |
|
2377 | + require_once($include); |
|
2378 | + } |
|
2247 | 2379 | } |
2248 | 2380 | } |
2249 | 2381 | |
@@ -2273,16 +2405,19 @@ discard block |
||
2273 | 2405 | // Do any style sheets first, cause we're easy with those. |
2274 | 2406 | if (!empty($style_sheets)) |
2275 | 2407 | { |
2276 | - if (!is_array($style_sheets)) |
|
2277 | - $style_sheets = array($style_sheets); |
|
2408 | + if (!is_array($style_sheets)) { |
|
2409 | + $style_sheets = array($style_sheets); |
|
2410 | + } |
|
2278 | 2411 | |
2279 | - foreach ($style_sheets as $sheet) |
|
2280 | - loadCSSFile($sheet . '.css', array(), $sheet); |
|
2412 | + foreach ($style_sheets as $sheet) { |
|
2413 | + loadCSSFile($sheet . '.css', array(), $sheet); |
|
2414 | + } |
|
2281 | 2415 | } |
2282 | 2416 | |
2283 | 2417 | // No template to load? |
2284 | - if ($template_name === false) |
|
2285 | - return true; |
|
2418 | + if ($template_name === false) { |
|
2419 | + return true; |
|
2420 | + } |
|
2286 | 2421 | |
2287 | 2422 | $loaded = false; |
2288 | 2423 | foreach ($settings['template_dirs'] as $template_dir) |
@@ -2297,12 +2432,14 @@ discard block |
||
2297 | 2432 | |
2298 | 2433 | if ($loaded) |
2299 | 2434 | { |
2300 | - if ($db_show_debug === true) |
|
2301 | - $context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')'; |
|
2435 | + if ($db_show_debug === true) { |
|
2436 | + $context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')'; |
|
2437 | + } |
|
2302 | 2438 | |
2303 | 2439 | // If they have specified an initialization function for this template, go ahead and call it now. |
2304 | - if (function_exists('template_' . $template_name . '_init')) |
|
2305 | - call_user_func('template_' . $template_name . '_init'); |
|
2440 | + if (function_exists('template_' . $template_name . '_init')) { |
|
2441 | + call_user_func('template_' . $template_name . '_init'); |
|
2442 | + } |
|
2306 | 2443 | } |
2307 | 2444 | // Hmmm... doesn't exist?! I don't suppose the directory is wrong, is it? |
2308 | 2445 | elseif (!file_exists($settings['default_theme_dir']) && file_exists($boarddir . '/Themes/default')) |
@@ -2322,13 +2459,14 @@ discard block |
||
2322 | 2459 | loadTemplate($template_name); |
2323 | 2460 | } |
2324 | 2461 | // Cause an error otherwise. |
2325 | - elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) |
|
2326 | - fatal_lang_error('theme_template_error', 'template', array((string) $template_name)); |
|
2327 | - elseif ($fatal) |
|
2328 | - die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load Themes/default/%s.template.php!', (string) $template_name), 'template')); |
|
2329 | - else |
|
2330 | - return false; |
|
2331 | -} |
|
2462 | + elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) { |
|
2463 | + fatal_lang_error('theme_template_error', 'template', array((string) $template_name)); |
|
2464 | + } elseif ($fatal) { |
|
2465 | + die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load Themes/default/%s.template.php!', (string) $template_name), 'template')); |
|
2466 | + } else { |
|
2467 | + return false; |
|
2468 | + } |
|
2469 | + } |
|
2332 | 2470 | |
2333 | 2471 | /** |
2334 | 2472 | * Load a sub-template. |
@@ -2346,17 +2484,19 @@ discard block |
||
2346 | 2484 | { |
2347 | 2485 | global $context, $txt, $db_show_debug; |
2348 | 2486 | |
2349 | - if ($db_show_debug === true) |
|
2350 | - $context['debug']['sub_templates'][] = $sub_template_name; |
|
2487 | + if ($db_show_debug === true) { |
|
2488 | + $context['debug']['sub_templates'][] = $sub_template_name; |
|
2489 | + } |
|
2351 | 2490 | |
2352 | 2491 | // Figure out what the template function is named. |
2353 | 2492 | $theme_function = 'template_' . $sub_template_name; |
2354 | - if (function_exists($theme_function)) |
|
2355 | - $theme_function(); |
|
2356 | - elseif ($fatal === false) |
|
2357 | - fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name)); |
|
2358 | - elseif ($fatal !== 'ignore') |
|
2359 | - die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load the %s sub template!', (string) $sub_template_name), 'template')); |
|
2493 | + if (function_exists($theme_function)) { |
|
2494 | + $theme_function(); |
|
2495 | + } elseif ($fatal === false) { |
|
2496 | + fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name)); |
|
2497 | + } elseif ($fatal !== 'ignore') { |
|
2498 | + die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load the %s sub template!', (string) $sub_template_name), 'template')); |
|
2499 | + } |
|
2360 | 2500 | |
2361 | 2501 | // Are we showing debugging for templates? Just make sure not to do it before the doctype... |
2362 | 2502 | if (allowedTo('admin_forum') && isset($_REQUEST['debug']) && !in_array($sub_template_name, array('init', 'main_below')) && ob_get_length() > 0 && !isset($_REQUEST['xml'])) |
@@ -2393,8 +2533,9 @@ discard block |
||
2393 | 2533 | $params['validate'] = isset($params['validate']) ? $params['validate'] : true; |
2394 | 2534 | |
2395 | 2535 | // If this is an external file, automatically set this to false. |
2396 | - if (!empty($params['external'])) |
|
2397 | - $params['minimize'] = false; |
|
2536 | + if (!empty($params['external'])) { |
|
2537 | + $params['minimize'] = false; |
|
2538 | + } |
|
2398 | 2539 | |
2399 | 2540 | // Account for shorthand like admin.css?alp21 filenames |
2400 | 2541 | $has_seed = strpos($fileName, '.css?'); |
@@ -2411,13 +2552,10 @@ discard block |
||
2411 | 2552 | { |
2412 | 2553 | $fileUrl = $settings['default_theme_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
2413 | 2554 | $filePath = $settings['default_theme_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
2555 | + } else { |
|
2556 | + $fileUrl = false; |
|
2414 | 2557 | } |
2415 | - |
|
2416 | - else |
|
2417 | - $fileUrl = false; |
|
2418 | - } |
|
2419 | - |
|
2420 | - else |
|
2558 | + } else |
|
2421 | 2559 | { |
2422 | 2560 | $fileUrl = $settings[$themeRef . '_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
2423 | 2561 | $filePath = $settings[$themeRef . '_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
@@ -2432,12 +2570,14 @@ discard block |
||
2432 | 2570 | } |
2433 | 2571 | |
2434 | 2572 | // Add it to the array for use in the template |
2435 | - if (!empty($fileName)) |
|
2436 | - $context['css_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
2573 | + if (!empty($fileName)) { |
|
2574 | + $context['css_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
2575 | + } |
|
2437 | 2576 | |
2438 | - if (!empty($context['right_to_left']) && !empty($params['rtl'])) |
|
2439 | - loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0))); |
|
2440 | -} |
|
2577 | + if (!empty($context['right_to_left']) && !empty($params['rtl'])) { |
|
2578 | + loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0))); |
|
2579 | + } |
|
2580 | + } |
|
2441 | 2581 | |
2442 | 2582 | /** |
2443 | 2583 | * Add a block of inline css code to be executed later |
@@ -2454,8 +2594,9 @@ discard block |
||
2454 | 2594 | global $context; |
2455 | 2595 | |
2456 | 2596 | // Gotta add something... |
2457 | - if (empty($css)) |
|
2458 | - return false; |
|
2597 | + if (empty($css)) { |
|
2598 | + return false; |
|
2599 | + } |
|
2459 | 2600 | |
2460 | 2601 | $context['css_header'][] = $css; |
2461 | 2602 | } |
@@ -2490,8 +2631,9 @@ discard block |
||
2490 | 2631 | $params['validate'] = isset($params['validate']) ? $params['validate'] : true; |
2491 | 2632 | |
2492 | 2633 | // If this is an external file, automatically set this to false. |
2493 | - if (!empty($params['external'])) |
|
2494 | - $params['minimize'] = false; |
|
2634 | + if (!empty($params['external'])) { |
|
2635 | + $params['minimize'] = false; |
|
2636 | + } |
|
2495 | 2637 | |
2496 | 2638 | // Account for shorthand like admin.js?alp21 filenames |
2497 | 2639 | $has_seed = strpos($fileName, '.js?'); |
@@ -2508,16 +2650,12 @@ discard block |
||
2508 | 2650 | { |
2509 | 2651 | $fileUrl = $settings['default_theme_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
2510 | 2652 | $filePath = $settings['default_theme_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
2511 | - } |
|
2512 | - |
|
2513 | - else |
|
2653 | + } else |
|
2514 | 2654 | { |
2515 | 2655 | $fileUrl = false; |
2516 | 2656 | $filePath = false; |
2517 | 2657 | } |
2518 | - } |
|
2519 | - |
|
2520 | - else |
|
2658 | + } else |
|
2521 | 2659 | { |
2522 | 2660 | $fileUrl = $settings[$themeRef . '_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
2523 | 2661 | $filePath = $settings[$themeRef . '_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
@@ -2532,9 +2670,10 @@ discard block |
||
2532 | 2670 | } |
2533 | 2671 | |
2534 | 2672 | // Add it to the array for use in the template |
2535 | - if (!empty($fileName)) |
|
2536 | - $context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
2537 | -} |
|
2673 | + if (!empty($fileName)) { |
|
2674 | + $context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
2675 | + } |
|
2676 | + } |
|
2538 | 2677 | |
2539 | 2678 | /** |
2540 | 2679 | * Add a Javascript variable for output later (for feeding text strings and similar to JS) |
@@ -2548,9 +2687,10 @@ discard block |
||
2548 | 2687 | { |
2549 | 2688 | global $context; |
2550 | 2689 | |
2551 | - if (!empty($key) && (!empty($value) || $value === '0')) |
|
2552 | - $context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value; |
|
2553 | -} |
|
2690 | + if (!empty($key) && (!empty($value) || $value === '0')) { |
|
2691 | + $context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value; |
|
2692 | + } |
|
2693 | + } |
|
2554 | 2694 | |
2555 | 2695 | /** |
2556 | 2696 | * Add a block of inline Javascript code to be executed later |
@@ -2567,8 +2707,9 @@ discard block |
||
2567 | 2707 | { |
2568 | 2708 | global $context; |
2569 | 2709 | |
2570 | - if (empty($javascript)) |
|
2571 | - return false; |
|
2710 | + if (empty($javascript)) { |
|
2711 | + return false; |
|
2712 | + } |
|
2572 | 2713 | |
2573 | 2714 | $context['javascript_inline'][($defer === true ? 'defer' : 'standard')][] = $javascript; |
2574 | 2715 | } |
@@ -2589,15 +2730,18 @@ discard block |
||
2589 | 2730 | static $already_loaded = array(); |
2590 | 2731 | |
2591 | 2732 | // Default to the user's language. |
2592 | - if ($lang == '') |
|
2593 | - $lang = isset($user_info['language']) ? $user_info['language'] : $language; |
|
2733 | + if ($lang == '') { |
|
2734 | + $lang = isset($user_info['language']) ? $user_info['language'] : $language; |
|
2735 | + } |
|
2594 | 2736 | |
2595 | 2737 | // Do we want the English version of language file as fallback? |
2596 | - if (empty($modSettings['disable_language_fallback']) && $lang != 'english') |
|
2597 | - loadLanguage($template_name, 'english', false); |
|
2738 | + if (empty($modSettings['disable_language_fallback']) && $lang != 'english') { |
|
2739 | + loadLanguage($template_name, 'english', false); |
|
2740 | + } |
|
2598 | 2741 | |
2599 | - if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) |
|
2600 | - return $lang; |
|
2742 | + if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) { |
|
2743 | + return $lang; |
|
2744 | + } |
|
2601 | 2745 | |
2602 | 2746 | // Make sure we have $settings - if not we're in trouble and need to find it! |
2603 | 2747 | if (empty($settings['default_theme_dir'])) |
@@ -2608,8 +2752,9 @@ discard block |
||
2608 | 2752 | |
2609 | 2753 | // What theme are we in? |
2610 | 2754 | $theme_name = basename($settings['theme_url']); |
2611 | - if (empty($theme_name)) |
|
2612 | - $theme_name = 'unknown'; |
|
2755 | + if (empty($theme_name)) { |
|
2756 | + $theme_name = 'unknown'; |
|
2757 | + } |
|
2613 | 2758 | |
2614 | 2759 | // For each file open it up and write it out! |
2615 | 2760 | foreach (explode('+', $template_name) as $template) |
@@ -2688,8 +2833,9 @@ discard block |
||
2688 | 2833 | } |
2689 | 2834 | |
2690 | 2835 | // Keep track of what we're up to soldier. |
2691 | - if ($db_show_debug === true) |
|
2692 | - $context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')'; |
|
2836 | + if ($db_show_debug === true) { |
|
2837 | + $context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')'; |
|
2838 | + } |
|
2693 | 2839 | |
2694 | 2840 | // Remember what we have loaded, and in which language. |
2695 | 2841 | $already_loaded[$template_name] = $lang; |
@@ -2735,8 +2881,9 @@ discard block |
||
2735 | 2881 | ) |
2736 | 2882 | ); |
2737 | 2883 | // In the EXTREMELY unlikely event this happens, give an error message. |
2738 | - if ($smcFunc['db_num_rows']($result) == 0) |
|
2739 | - fatal_lang_error('parent_not_found', 'critical'); |
|
2884 | + if ($smcFunc['db_num_rows']($result) == 0) { |
|
2885 | + fatal_lang_error('parent_not_found', 'critical'); |
|
2886 | + } |
|
2740 | 2887 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
2741 | 2888 | { |
2742 | 2889 | if (!isset($boards[$row['id_board']])) |
@@ -2753,8 +2900,8 @@ discard block |
||
2753 | 2900 | ); |
2754 | 2901 | } |
2755 | 2902 | // If a moderator exists for this board, add that moderator for all children too. |
2756 | - if (!empty($row['id_moderator'])) |
|
2757 | - foreach ($boards as $id => $dummy) |
|
2903 | + if (!empty($row['id_moderator'])) { |
|
2904 | + foreach ($boards as $id => $dummy) |
|
2758 | 2905 | { |
2759 | 2906 | $boards[$id]['moderators'][$row['id_moderator']] = array( |
2760 | 2907 | 'id' => $row['id_moderator'], |
@@ -2762,11 +2909,12 @@ discard block |
||
2762 | 2909 | 'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'], |
2763 | 2910 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>' |
2764 | 2911 | ); |
2912 | + } |
|
2765 | 2913 | } |
2766 | 2914 | |
2767 | 2915 | // If a moderator group exists for this board, add that moderator group for all children too |
2768 | - if (!empty($row['id_moderator_group'])) |
|
2769 | - foreach ($boards as $id => $dummy) |
|
2916 | + if (!empty($row['id_moderator_group'])) { |
|
2917 | + foreach ($boards as $id => $dummy) |
|
2770 | 2918 | { |
2771 | 2919 | $boards[$id]['moderator_groups'][$row['id_moderator_group']] = array( |
2772 | 2920 | 'id' => $row['id_moderator_group'], |
@@ -2774,6 +2922,7 @@ discard block |
||
2774 | 2922 | 'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'], |
2775 | 2923 | 'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>' |
2776 | 2924 | ); |
2925 | + } |
|
2777 | 2926 | } |
2778 | 2927 | } |
2779 | 2928 | $smcFunc['db_free_result']($result); |
@@ -2800,23 +2949,27 @@ discard block |
||
2800 | 2949 | if (!$use_cache || ($context['languages'] = cache_get_data('known_languages', !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600)) == null) |
2801 | 2950 | { |
2802 | 2951 | // If we don't have our ucwords function defined yet, let's load the settings data. |
2803 | - if (empty($smcFunc['ucwords'])) |
|
2804 | - reloadSettings(); |
|
2952 | + if (empty($smcFunc['ucwords'])) { |
|
2953 | + reloadSettings(); |
|
2954 | + } |
|
2805 | 2955 | |
2806 | 2956 | // If we don't have our theme information yet, let's get it. |
2807 | - if (empty($settings['default_theme_dir'])) |
|
2808 | - loadTheme(0, false); |
|
2957 | + if (empty($settings['default_theme_dir'])) { |
|
2958 | + loadTheme(0, false); |
|
2959 | + } |
|
2809 | 2960 | |
2810 | 2961 | // Default language directories to try. |
2811 | 2962 | $language_directories = array( |
2812 | 2963 | $settings['default_theme_dir'] . '/languages', |
2813 | 2964 | ); |
2814 | - if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) |
|
2815 | - $language_directories[] = $settings['actual_theme_dir'] . '/languages'; |
|
2965 | + if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) { |
|
2966 | + $language_directories[] = $settings['actual_theme_dir'] . '/languages'; |
|
2967 | + } |
|
2816 | 2968 | |
2817 | 2969 | // We possibly have a base theme directory. |
2818 | - if (!empty($settings['base_theme_dir'])) |
|
2819 | - $language_directories[] = $settings['base_theme_dir'] . '/languages'; |
|
2970 | + if (!empty($settings['base_theme_dir'])) { |
|
2971 | + $language_directories[] = $settings['base_theme_dir'] . '/languages'; |
|
2972 | + } |
|
2820 | 2973 | |
2821 | 2974 | // Remove any duplicates. |
2822 | 2975 | $language_directories = array_unique($language_directories); |
@@ -2830,20 +2983,21 @@ discard block |
||
2830 | 2983 | foreach ($language_directories as $language_dir) |
2831 | 2984 | { |
2832 | 2985 | // Can't look in here... doesn't exist! |
2833 | - if (!file_exists($language_dir)) |
|
2834 | - continue; |
|
2986 | + if (!file_exists($language_dir)) { |
|
2987 | + continue; |
|
2988 | + } |
|
2835 | 2989 | |
2836 | 2990 | $dir = dir($language_dir); |
2837 | 2991 | while ($entry = $dir->read()) |
2838 | 2992 | { |
2839 | 2993 | // Look for the index language file... For good measure skip any "index.language-utf8.php" files |
2840 | - if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches)) |
|
2841 | - continue; |
|
2842 | - |
|
2843 | - if (!empty($langList) && !empty($langList[$matches[1]])) |
|
2844 | - $langName = $langList[$matches[1]]; |
|
2994 | + if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches)) { |
|
2995 | + continue; |
|
2996 | + } |
|
2845 | 2997 | |
2846 | - else |
|
2998 | + if (!empty($langList) && !empty($langList[$matches[1]])) { |
|
2999 | + $langName = $langList[$matches[1]]; |
|
3000 | + } else |
|
2847 | 3001 | { |
2848 | 3002 | $langName = $smcFunc['ucwords'](strtr($matches[1], array('_' => ' '))); |
2849 | 3003 | |
@@ -2884,12 +3038,14 @@ discard block |
||
2884 | 3038 | } |
2885 | 3039 | |
2886 | 3040 | // Do we need to store the lang list? |
2887 | - if (empty($langList)) |
|
2888 | - updateSettings(array('langList' => json_encode($catchLang))); |
|
3041 | + if (empty($langList)) { |
|
3042 | + updateSettings(array('langList' => json_encode($catchLang))); |
|
3043 | + } |
|
2889 | 3044 | |
2890 | 3045 | // Let's cash in on this deal. |
2891 | - if (!empty($modSettings['cache_enable'])) |
|
2892 | - cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600); |
|
3046 | + if (!empty($modSettings['cache_enable'])) { |
|
3047 | + cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600); |
|
3048 | + } |
|
2893 | 3049 | } |
2894 | 3050 | |
2895 | 3051 | return $context['languages']; |
@@ -2912,8 +3068,9 @@ discard block |
||
2912 | 3068 | global $modSettings, $options, $txt; |
2913 | 3069 | static $censor_vulgar = null, $censor_proper; |
2914 | 3070 | |
2915 | - if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') |
|
2916 | - return $text; |
|
3071 | + if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') { |
|
3072 | + return $text; |
|
3073 | + } |
|
2917 | 3074 | |
2918 | 3075 | // If they haven't yet been loaded, load them. |
2919 | 3076 | if ($censor_vulgar == null) |
@@ -2941,9 +3098,9 @@ discard block |
||
2941 | 3098 | { |
2942 | 3099 | $func = !empty($modSettings['censorIgnoreCase']) ? 'str_ireplace' : 'str_replace'; |
2943 | 3100 | $text = $func($censor_vulgar, $censor_proper, $text); |
3101 | + } else { |
|
3102 | + $text = preg_replace($censor_vulgar, $censor_proper, $text); |
|
2944 | 3103 | } |
2945 | - else |
|
2946 | - $text = preg_replace($censor_vulgar, $censor_proper, $text); |
|
2947 | 3104 | |
2948 | 3105 | return $text; |
2949 | 3106 | } |
@@ -2969,38 +3126,42 @@ discard block |
||
2969 | 3126 | @ini_set('track_errors', '1'); |
2970 | 3127 | |
2971 | 3128 | // Don't include the file more than once, if $once is true. |
2972 | - if ($once && in_array($filename, $templates)) |
|
2973 | - return; |
|
3129 | + if ($once && in_array($filename, $templates)) { |
|
3130 | + return; |
|
3131 | + } |
|
2974 | 3132 | // Add this file to the include list, whether $once is true or not. |
2975 | - else |
|
2976 | - $templates[] = $filename; |
|
3133 | + else { |
|
3134 | + $templates[] = $filename; |
|
3135 | + } |
|
2977 | 3136 | |
2978 | 3137 | // Are we going to use eval? |
2979 | 3138 | if (empty($modSettings['disableTemplateEval'])) |
2980 | 3139 | { |
2981 | 3140 | $file_found = file_exists($filename) && eval('?' . '>' . rtrim(file_get_contents($filename))) !== false; |
2982 | 3141 | $settings['current_include_filename'] = $filename; |
2983 | - } |
|
2984 | - else |
|
3142 | + } else |
|
2985 | 3143 | { |
2986 | 3144 | $file_found = file_exists($filename); |
2987 | 3145 | |
2988 | - if ($once && $file_found) |
|
2989 | - require_once($filename); |
|
2990 | - elseif ($file_found) |
|
2991 | - require($filename); |
|
3146 | + if ($once && $file_found) { |
|
3147 | + require_once($filename); |
|
3148 | + } elseif ($file_found) { |
|
3149 | + require($filename); |
|
3150 | + } |
|
2992 | 3151 | } |
2993 | 3152 | |
2994 | 3153 | if ($file_found !== true) |
2995 | 3154 | { |
2996 | 3155 | ob_end_clean(); |
2997 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
2998 | - @ob_start('ob_gzhandler'); |
|
2999 | - else |
|
3000 | - ob_start(); |
|
3156 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
3157 | + @ob_start('ob_gzhandler'); |
|
3158 | + } else { |
|
3159 | + ob_start(); |
|
3160 | + } |
|
3001 | 3161 | |
3002 | - if (isset($_GET['debug'])) |
|
3003 | - header('Content-Type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
3162 | + if (isset($_GET['debug'])) { |
|
3163 | + header('Content-Type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
3164 | + } |
|
3004 | 3165 | |
3005 | 3166 | // Don't cache error pages!! |
3006 | 3167 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
@@ -3019,12 +3180,13 @@ discard block |
||
3019 | 3180 | echo '<!DOCTYPE html> |
3020 | 3181 | <html', !empty($context['right_to_left']) ? ' dir="rtl"' : '', '> |
3021 | 3182 | <head>'; |
3022 | - if (isset($context['character_set'])) |
|
3023 | - echo ' |
|
3183 | + if (isset($context['character_set'])) { |
|
3184 | + echo ' |
|
3024 | 3185 | <meta charset="', $context['character_set'], '">'; |
3186 | + } |
|
3025 | 3187 | |
3026 | - if (!empty($maintenance) && !allowedTo('admin_forum')) |
|
3027 | - echo ' |
|
3188 | + if (!empty($maintenance) && !allowedTo('admin_forum')) { |
|
3189 | + echo ' |
|
3028 | 3190 | <title>', $mtitle, '</title> |
3029 | 3191 | </head> |
3030 | 3192 | <body> |
@@ -3032,8 +3194,8 @@ discard block |
||
3032 | 3194 | ', $mmessage, ' |
3033 | 3195 | </body> |
3034 | 3196 | </html>'; |
3035 | - elseif (!allowedTo('admin_forum')) |
|
3036 | - echo ' |
|
3197 | + } elseif (!allowedTo('admin_forum')) { |
|
3198 | + echo ' |
|
3037 | 3199 | <title>', $txt['template_parse_error'], '</title> |
3038 | 3200 | </head> |
3039 | 3201 | <body> |
@@ -3041,15 +3203,17 @@ discard block |
||
3041 | 3203 | ', $txt['template_parse_error_message'], ' |
3042 | 3204 | </body> |
3043 | 3205 | </html>'; |
3044 | - else |
|
3206 | + } else |
|
3045 | 3207 | { |
3046 | 3208 | require_once($sourcedir . '/Subs-Package.php'); |
3047 | 3209 | |
3048 | 3210 | $error = fetch_web_data($boardurl . strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => ''))); |
3049 | - if (empty($error) && ini_get('track_errors') && !empty($php_errormsg)) |
|
3050 | - $error = $php_errormsg; |
|
3051 | - if (empty($error)) |
|
3052 | - $error = $txt['template_parse_errmsg']; |
|
3211 | + if (empty($error) && ini_get('track_errors') && !empty($php_errormsg)) { |
|
3212 | + $error = $php_errormsg; |
|
3213 | + } |
|
3214 | + if (empty($error)) { |
|
3215 | + $error = $txt['template_parse_errmsg']; |
|
3216 | + } |
|
3053 | 3217 | |
3054 | 3218 | $error = strtr($error, array('<b>' => '<strong>', '</b>' => '</strong>')); |
3055 | 3219 | |
@@ -3060,11 +3224,12 @@ discard block |
||
3060 | 3224 | <h3>', $txt['template_parse_error'], '</h3> |
3061 | 3225 | ', sprintf($txt['template_parse_error_details'], strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => ''))); |
3062 | 3226 | |
3063 | - if (!empty($error)) |
|
3064 | - echo ' |
|
3227 | + if (!empty($error)) { |
|
3228 | + echo ' |
|
3065 | 3229 | <hr> |
3066 | 3230 | |
3067 | 3231 | <div style="margin: 0 20px;"><pre>', strtr(strtr($error, array('<strong>' . $boarddir => '<strong>...', '<strong>' . strtr($boarddir, '\\', '/') => '<strong>...')), '\\', '/'), '</pre></div>'; |
3232 | + } |
|
3068 | 3233 | |
3069 | 3234 | // I know, I know... this is VERY COMPLICATED. Still, it's good. |
3070 | 3235 | if (preg_match('~ <strong>(\d+)</strong><br( /)?' . '>$~i', $error, $match) != 0) |
@@ -3074,10 +3239,11 @@ discard block |
||
3074 | 3239 | $data2 = preg_split('~\<br( /)?\>~', $data2); |
3075 | 3240 | |
3076 | 3241 | // Fix the PHP code stuff... |
3077 | - if (!isBrowser('gecko')) |
|
3078 | - $data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2); |
|
3079 | - else |
|
3080 | - $data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2); |
|
3242 | + if (!isBrowser('gecko')) { |
|
3243 | + $data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2); |
|
3244 | + } else { |
|
3245 | + $data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2); |
|
3246 | + } |
|
3081 | 3247 | |
3082 | 3248 | // Now we get to work around a bug in PHP where it doesn't escape <br>s! |
3083 | 3249 | $j = -1; |
@@ -3085,8 +3251,9 @@ discard block |
||
3085 | 3251 | { |
3086 | 3252 | $j++; |
3087 | 3253 | |
3088 | - if (substr_count($line, '<br>') == 0) |
|
3089 | - continue; |
|
3254 | + if (substr_count($line, '<br>') == 0) { |
|
3255 | + continue; |
|
3256 | + } |
|
3090 | 3257 | |
3091 | 3258 | $n = substr_count($line, '<br>'); |
3092 | 3259 | for ($i = 0; $i < $n; $i++) |
@@ -3105,38 +3272,42 @@ discard block |
||
3105 | 3272 | // Figure out what the color coding was before... |
3106 | 3273 | $line = max($match[1] - 9, 1); |
3107 | 3274 | $last_line = ''; |
3108 | - for ($line2 = $line - 1; $line2 > 1; $line2--) |
|
3109 | - if (strpos($data2[$line2], '<') !== false) |
|
3275 | + for ($line2 = $line - 1; $line2 > 1; $line2--) { |
|
3276 | + if (strpos($data2[$line2], '<') !== false) |
|
3110 | 3277 | { |
3111 | 3278 | if (preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line2], $color_match) != 0) |
3112 | 3279 | $last_line = $color_match[1]; |
3280 | + } |
|
3113 | 3281 | break; |
3114 | 3282 | } |
3115 | 3283 | |
3116 | 3284 | // Show the relevant lines... |
3117 | 3285 | for ($n = min($match[1] + 4, count($data2) + 1); $line <= $n; $line++) |
3118 | 3286 | { |
3119 | - if ($line == $match[1]) |
|
3120 | - echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">'; |
|
3287 | + if ($line == $match[1]) { |
|
3288 | + echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">'; |
|
3289 | + } |
|
3121 | 3290 | |
3122 | 3291 | echo '<span style="color: black;">', sprintf('%' . strlen($n) . 's', $line), ':</span> '; |
3123 | - if (isset($data2[$line]) && $data2[$line] != '') |
|
3124 | - echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line]; |
|
3292 | + if (isset($data2[$line]) && $data2[$line] != '') { |
|
3293 | + echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line]; |
|
3294 | + } |
|
3125 | 3295 | |
3126 | 3296 | if (isset($data2[$line]) && preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line], $color_match) != 0) |
3127 | 3297 | { |
3128 | 3298 | $last_line = $color_match[1]; |
3129 | 3299 | echo '</', substr($last_line, 1, 4), '>'; |
3300 | + } elseif ($last_line != '' && strpos($data2[$line], '<') !== false) { |
|
3301 | + $last_line = ''; |
|
3302 | + } elseif ($last_line != '' && $data2[$line] != '') { |
|
3303 | + echo '</', substr($last_line, 1, 4), '>'; |
|
3130 | 3304 | } |
3131 | - elseif ($last_line != '' && strpos($data2[$line], '<') !== false) |
|
3132 | - $last_line = ''; |
|
3133 | - elseif ($last_line != '' && $data2[$line] != '') |
|
3134 | - echo '</', substr($last_line, 1, 4), '>'; |
|
3135 | 3305 | |
3136 | - if ($line == $match[1]) |
|
3137 | - echo '</pre></div><pre style="margin: 0;">'; |
|
3138 | - else |
|
3139 | - echo "\n"; |
|
3306 | + if ($line == $match[1]) { |
|
3307 | + echo '</pre></div><pre style="margin: 0;">'; |
|
3308 | + } else { |
|
3309 | + echo "\n"; |
|
3310 | + } |
|
3140 | 3311 | } |
3141 | 3312 | |
3142 | 3313 | echo '</pre></div>'; |
@@ -3160,8 +3331,9 @@ discard block |
||
3160 | 3331 | global $db_type, $db_name, $ssi_db_user, $ssi_db_passwd, $sourcedir, $db_prefix, $db_port; |
3161 | 3332 | |
3162 | 3333 | // Figure out what type of database we are using. |
3163 | - if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
|
3164 | - $db_type = 'mysql'; |
|
3334 | + if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) { |
|
3335 | + $db_type = 'mysql'; |
|
3336 | + } |
|
3165 | 3337 | |
3166 | 3338 | // Load the file for the database. |
3167 | 3339 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
@@ -3169,8 +3341,9 @@ discard block |
||
3169 | 3341 | $db_options = array(); |
3170 | 3342 | |
3171 | 3343 | // Add in the port if needed |
3172 | - if (!empty($db_port)) |
|
3173 | - $db_options['port'] = $db_port; |
|
3344 | + if (!empty($db_port)) { |
|
3345 | + $db_options['port'] = $db_port; |
|
3346 | + } |
|
3174 | 3347 | |
3175 | 3348 | // If we are in SSI try them first, but don't worry if it doesn't work, we have the normal username and password we can use. |
3176 | 3349 | if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd)) |
@@ -3189,13 +3362,15 @@ discard block |
||
3189 | 3362 | } |
3190 | 3363 | |
3191 | 3364 | // Safe guard here, if there isn't a valid connection lets put a stop to it. |
3192 | - if (!$db_connection) |
|
3193 | - display_db_error(); |
|
3365 | + if (!$db_connection) { |
|
3366 | + display_db_error(); |
|
3367 | + } |
|
3194 | 3368 | |
3195 | 3369 | // If in SSI mode fix up the prefix. |
3196 | - if (SMF == 'SSI') |
|
3197 | - db_fix_prefix($db_prefix, $db_name); |
|
3198 | -} |
|
3370 | + if (SMF == 'SSI') { |
|
3371 | + db_fix_prefix($db_prefix, $db_name); |
|
3372 | + } |
|
3373 | + } |
|
3199 | 3374 | |
3200 | 3375 | /** |
3201 | 3376 | * Try to load up a supported caching method. This is saved in $cacheAPI if we are not overriding it. |
@@ -3209,10 +3384,11 @@ discard block |
||
3209 | 3384 | global $sourcedir, $cacheAPI, $cache_accelerator; |
3210 | 3385 | |
3211 | 3386 | // Not overriding this and we have a cacheAPI, send it back. |
3212 | - if (empty($overrideCache) && is_object($cacheAPI)) |
|
3213 | - return $cacheAPI; |
|
3214 | - elseif (is_null($cacheAPI)) |
|
3215 | - $cacheAPI = false; |
|
3387 | + if (empty($overrideCache) && is_object($cacheAPI)) { |
|
3388 | + return $cacheAPI; |
|
3389 | + } elseif (is_null($cacheAPI)) { |
|
3390 | + $cacheAPI = false; |
|
3391 | + } |
|
3216 | 3392 | |
3217 | 3393 | // Make sure our class is in session. |
3218 | 3394 | require_once($sourcedir . '/Class-CacheAPI.php'); |
@@ -3233,8 +3409,9 @@ discard block |
||
3233 | 3409 | if (!$testAPI->isSupported()) |
3234 | 3410 | { |
3235 | 3411 | // Can we save ourselves? |
3236 | - if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') |
|
3237 | - return loadCacheAccelerator(null, false); |
|
3412 | + if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') { |
|
3413 | + return loadCacheAccelerator(null, false); |
|
3414 | + } |
|
3238 | 3415 | return false; |
3239 | 3416 | } |
3240 | 3417 | |
@@ -3246,9 +3423,9 @@ discard block |
||
3246 | 3423 | { |
3247 | 3424 | $cacheAPI = $testAPI; |
3248 | 3425 | return $cacheAPI; |
3426 | + } else { |
|
3427 | + return $testAPI; |
|
3249 | 3428 | } |
3250 | - else |
|
3251 | - return $testAPI; |
|
3252 | 3429 | } |
3253 | 3430 | } |
3254 | 3431 | |
@@ -3268,8 +3445,9 @@ discard block |
||
3268 | 3445 | |
3269 | 3446 | // @todo Why are we doing this if caching is disabled? |
3270 | 3447 | |
3271 | - if (function_exists('call_integration_hook')) |
|
3272 | - call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level)); |
|
3448 | + if (function_exists('call_integration_hook')) { |
|
3449 | + call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level)); |
|
3450 | + } |
|
3273 | 3451 | |
3274 | 3452 | /* Refresh the cache if either: |
3275 | 3453 | 1. Caching is disabled. |
@@ -3283,16 +3461,19 @@ discard block |
||
3283 | 3461 | require_once($sourcedir . '/' . $file); |
3284 | 3462 | $cache_block = call_user_func_array($function, $params); |
3285 | 3463 | |
3286 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) |
|
3287 | - cache_put_data($key, $cache_block, $cache_block['expires'] - time()); |
|
3464 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) { |
|
3465 | + cache_put_data($key, $cache_block, $cache_block['expires'] - time()); |
|
3466 | + } |
|
3288 | 3467 | } |
3289 | 3468 | |
3290 | 3469 | // Some cached data may need a freshening up after retrieval. |
3291 | - if (!empty($cache_block['post_retri_eval'])) |
|
3292 | - eval($cache_block['post_retri_eval']); |
|
3470 | + if (!empty($cache_block['post_retri_eval'])) { |
|
3471 | + eval($cache_block['post_retri_eval']); |
|
3472 | + } |
|
3293 | 3473 | |
3294 | - if (function_exists('call_integration_hook')) |
|
3295 | - call_integration_hook('post_cache_quick_get', array(&$cache_block)); |
|
3474 | + if (function_exists('call_integration_hook')) { |
|
3475 | + call_integration_hook('post_cache_quick_get', array(&$cache_block)); |
|
3476 | + } |
|
3296 | 3477 | |
3297 | 3478 | return $cache_block['data']; |
3298 | 3479 | } |
@@ -3319,8 +3500,9 @@ discard block |
||
3319 | 3500 | global $boardurl, $modSettings, $cache_enable, $cacheAPI; |
3320 | 3501 | global $cache_hits, $cache_count, $db_show_debug; |
3321 | 3502 | |
3322 | - if (empty($cache_enable) || empty($cacheAPI)) |
|
3323 | - return; |
|
3503 | + if (empty($cache_enable) || empty($cacheAPI)) { |
|
3504 | + return; |
|
3505 | + } |
|
3324 | 3506 | |
3325 | 3507 | $cache_count = isset($cache_count) ? $cache_count + 1 : 1; |
3326 | 3508 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -3333,12 +3515,14 @@ discard block |
||
3333 | 3515 | $value = $value === null ? null : json_encode($value); |
3334 | 3516 | $cacheAPI->putData($key, $value, $ttl); |
3335 | 3517 | |
3336 | - if (function_exists('call_integration_hook')) |
|
3337 | - call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl)); |
|
3518 | + if (function_exists('call_integration_hook')) { |
|
3519 | + call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl)); |
|
3520 | + } |
|
3338 | 3521 | |
3339 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
3340 | - $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
3341 | -} |
|
3522 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
3523 | + $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
3524 | + } |
|
3525 | + } |
|
3342 | 3526 | |
3343 | 3527 | /** |
3344 | 3528 | * Gets the value from the cache specified by key, so long as it is not older than ttl seconds. |
@@ -3354,8 +3538,9 @@ discard block |
||
3354 | 3538 | global $boardurl, $modSettings, $cache_enable, $cacheAPI; |
3355 | 3539 | global $cache_hits, $cache_count, $cache_misses, $cache_count_misses, $db_show_debug; |
3356 | 3540 | |
3357 | - if (empty($cache_enable) || empty($cacheAPI)) |
|
3358 | - return; |
|
3541 | + if (empty($cache_enable) || empty($cacheAPI)) { |
|
3542 | + return; |
|
3543 | + } |
|
3359 | 3544 | |
3360 | 3545 | $cache_count = isset($cache_count) ? $cache_count + 1 : 1; |
3361 | 3546 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -3375,16 +3560,18 @@ discard block |
||
3375 | 3560 | |
3376 | 3561 | if (empty($value)) |
3377 | 3562 | { |
3378 | - if (!is_array($cache_misses)) |
|
3379 | - $cache_misses = array(); |
|
3563 | + if (!is_array($cache_misses)) { |
|
3564 | + $cache_misses = array(); |
|
3565 | + } |
|
3380 | 3566 | |
3381 | 3567 | $cache_count_misses = isset($cache_count_misses) ? $cache_count_misses + 1 : 1; |
3382 | 3568 | $cache_misses[$cache_count_misses] = array('k' => $original_key, 'd' => 'get'); |
3383 | 3569 | } |
3384 | 3570 | } |
3385 | 3571 | |
3386 | - if (function_exists('call_integration_hook') && isset($value)) |
|
3387 | - call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value)); |
|
3572 | + if (function_exists('call_integration_hook') && isset($value)) { |
|
3573 | + call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value)); |
|
3574 | + } |
|
3388 | 3575 | |
3389 | 3576 | return empty($value) ? null : smf_json_decode($value, true); |
3390 | 3577 | } |
@@ -3406,8 +3593,9 @@ discard block |
||
3406 | 3593 | global $cacheAPI; |
3407 | 3594 | |
3408 | 3595 | // If we can't get to the API, can't do this. |
3409 | - if (empty($cacheAPI)) |
|
3410 | - return; |
|
3596 | + if (empty($cacheAPI)) { |
|
3597 | + return; |
|
3598 | + } |
|
3411 | 3599 | |
3412 | 3600 | // Ask the API to do the heavy lifting. cleanCache also calls invalidateCache to be sure. |
3413 | 3601 | $cacheAPI->cleanCache($type); |
@@ -3432,8 +3620,9 @@ discard block |
||
3432 | 3620 | global $modSettings, $boardurl, $smcFunc, $image_proxy_enabled, $image_proxy_secret; |
3433 | 3621 | |
3434 | 3622 | // Come on! |
3435 | - if (empty($data)) |
|
3436 | - return array(); |
|
3623 | + if (empty($data)) { |
|
3624 | + return array(); |
|
3625 | + } |
|
3437 | 3626 | |
3438 | 3627 | // Set a nice default var. |
3439 | 3628 | $image = ''; |
@@ -3441,11 +3630,11 @@ discard block |
||
3441 | 3630 | // Gravatar has been set as mandatory! |
3442 | 3631 | if (!empty($modSettings['gravatarOverride'])) |
3443 | 3632 | { |
3444 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) |
|
3445 | - $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3446 | - |
|
3447 | - else if (!empty($data['email'])) |
|
3448 | - $image = get_gravatar_url($data['email']); |
|
3633 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) { |
|
3634 | + $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3635 | + } else if (!empty($data['email'])) { |
|
3636 | + $image = get_gravatar_url($data['email']); |
|
3637 | + } |
|
3449 | 3638 | } |
3450 | 3639 | |
3451 | 3640 | // Look if the user has a gravatar field or has set an external url as avatar. |
@@ -3457,54 +3646,60 @@ discard block |
||
3457 | 3646 | // Gravatar. |
3458 | 3647 | if (stristr($data['avatar'], 'gravatar://')) |
3459 | 3648 | { |
3460 | - if ($data['avatar'] == 'gravatar://') |
|
3461 | - $image = get_gravatar_url($data['email']); |
|
3462 | - |
|
3463 | - elseif (!empty($modSettings['gravatarAllowExtraEmail'])) |
|
3464 | - $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3649 | + if ($data['avatar'] == 'gravatar://') { |
|
3650 | + $image = get_gravatar_url($data['email']); |
|
3651 | + } elseif (!empty($modSettings['gravatarAllowExtraEmail'])) { |
|
3652 | + $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3653 | + } |
|
3465 | 3654 | } |
3466 | 3655 | |
3467 | 3656 | // External url. |
3468 | 3657 | else |
3469 | 3658 | { |
3470 | 3659 | // Using ssl? |
3471 | - if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false) |
|
3472 | - $image = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($data['avatar']) . '&hash=' . md5($data['avatar'] . $image_proxy_secret); |
|
3660 | + if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false) { |
|
3661 | + $image = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($data['avatar']) . '&hash=' . md5($data['avatar'] . $image_proxy_secret); |
|
3662 | + } |
|
3473 | 3663 | |
3474 | 3664 | // Just a plain external url. |
3475 | - else |
|
3476 | - $image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar']; |
|
3665 | + else { |
|
3666 | + $image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar']; |
|
3667 | + } |
|
3477 | 3668 | } |
3478 | 3669 | } |
3479 | 3670 | |
3480 | 3671 | // Perhaps this user has an attachment as avatar... |
3481 | - else if (!empty($data['filename'])) |
|
3482 | - $image = $modSettings['custom_avatar_url'] . '/' . $data['filename']; |
|
3672 | + else if (!empty($data['filename'])) { |
|
3673 | + $image = $modSettings['custom_avatar_url'] . '/' . $data['filename']; |
|
3674 | + } |
|
3483 | 3675 | |
3484 | 3676 | // Right... no avatar... use our default image. |
3485 | - else |
|
3486 | - $image = $modSettings['avatar_url'] . '/default.png'; |
|
3677 | + else { |
|
3678 | + $image = $modSettings['avatar_url'] . '/default.png'; |
|
3679 | + } |
|
3487 | 3680 | } |
3488 | 3681 | |
3489 | 3682 | call_integration_hook('integrate_set_avatar_data', array(&$image, &$data)); |
3490 | 3683 | |
3491 | 3684 | // At this point in time $image has to be filled unless you chose to force gravatar and the user doesn't have the needed data to retrieve it... thus a check for !empty() is still needed. |
3492 | - if (!empty($image)) |
|
3493 | - return array( |
|
3685 | + if (!empty($image)) { |
|
3686 | + return array( |
|
3494 | 3687 | 'name' => !empty($data['avatar']) ? $data['avatar'] : '', |
3495 | 3688 | 'image' => '<img class="avatar" src="' . $image . '" />', |
3496 | 3689 | 'href' => $image, |
3497 | 3690 | 'url' => $image, |
3498 | 3691 | ); |
3692 | + } |
|
3499 | 3693 | |
3500 | 3694 | // Fallback to make life easier for everyone... |
3501 | - else |
|
3502 | - return array( |
|
3695 | + else { |
|
3696 | + return array( |
|
3503 | 3697 | 'name' => '', |
3504 | 3698 | 'image' => '', |
3505 | 3699 | 'href' => '', |
3506 | 3700 | 'url' => '', |
3507 | 3701 | ); |
3508 | -} |
|
3702 | + } |
|
3703 | + } |
|
3509 | 3704 | |
3510 | 3705 | ?> |
3511 | 3706 | \ No newline at end of file |
@@ -2262,9 +2262,9 @@ discard block |
||
2262 | 2262 | * |
2263 | 2263 | * @uses the template_include() function to include the file. |
2264 | 2264 | * @param string $template_name The name of the template to load |
2265 | - * @param array|string $style_sheets The name of a single stylesheet or an array of names of stylesheets to load |
|
2265 | + * @param string $style_sheets The name of a single stylesheet or an array of names of stylesheets to load |
|
2266 | 2266 | * @param bool $fatal If true, dies with an error message if the template cannot be found |
2267 | - * @return boolean Whether or not the template was loaded |
|
2267 | + * @return boolean|null Whether or not the template was loaded |
|
2268 | 2268 | */ |
2269 | 2269 | function loadTemplate($template_name, $style_sheets = array(), $fatal = true) |
2270 | 2270 | { |
@@ -2447,7 +2447,7 @@ discard block |
||
2447 | 2447 | * - all code added with this function is added to the same <style> tag so do make sure your css is valid! |
2448 | 2448 | * |
2449 | 2449 | * @param string $css Some css code |
2450 | - * @return void|bool Adds the CSS to the $context['css_header'] array or returns if no CSS is specified |
|
2450 | + * @return false|null Adds the CSS to the $context['css_header'] array or returns if no CSS is specified |
|
2451 | 2451 | */ |
2452 | 2452 | function addInlineCss($css) |
2453 | 2453 | { |
@@ -2463,7 +2463,7 @@ discard block |
||
2463 | 2463 | /** |
2464 | 2464 | * Add a Javascript file for output later |
2465 | 2465 | * |
2466 | - * @param string $filename The name of the file to load |
|
2466 | + * @param string $fileName The name of the file to load |
|
2467 | 2467 | * @param array $params An array of parameter info |
2468 | 2468 | * Keys are the following: |
2469 | 2469 | * - ['external'] (true/false): define if the file is a externally located file. Needs to be set to true if you are loading an external file |
@@ -2561,7 +2561,7 @@ discard block |
||
2561 | 2561 | * |
2562 | 2562 | * @param string $javascript Some JS code |
2563 | 2563 | * @param bool $defer Whether the script should load in <head> or before the closing <html> tag |
2564 | - * @return void|bool Adds the code to one of the $context['javascript_inline'] arrays or returns if no JS was specified |
|
2564 | + * @return false|null Adds the code to one of the $context['javascript_inline'] arrays or returns if no JS was specified |
|
2565 | 2565 | */ |
2566 | 2566 | function addInlineJavaScript($javascript, $defer = false) |
2567 | 2567 | { |