@@ -1,9 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | // Try to handle it with the upper level index.php. (it should know what to do.) |
4 | -if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) |
|
4 | +if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) { |
|
5 | 5 | include (dirname(dirname(__FILE__)) . '/index.php'); |
6 | -else |
|
6 | +} else { |
|
7 | 7 | exit; |
8 | +} |
|
8 | 9 | |
9 | 10 | ?> |
10 | 11 | \ No newline at end of file |
@@ -1,9 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | // Try to handle it with the upper level index.php. (it should know what to do.) |
4 | -if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) |
|
4 | +if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) { |
|
5 | 5 | include (dirname(dirname(__FILE__)) . '/index.php'); |
6 | -else |
|
6 | +} else { |
|
7 | 7 | exit; |
8 | +} |
|
8 | 9 | |
9 | 10 | ?> |
10 | 11 | \ No newline at end of file |
@@ -12,7 +12,8 @@ |
||
12 | 12 | header('Location: ' . $boardurl); |
13 | 13 | } |
14 | 14 | // Can't find it... just forget it. |
15 | -else |
|
15 | +else { |
|
16 | 16 | exit; |
17 | +} |
|
17 | 18 | |
18 | 19 | ?> |
19 | 20 | \ No newline at end of file |
@@ -12,7 +12,8 @@ |
||
12 | 12 | header('Location: ' . $boardurl); |
13 | 13 | } |
14 | 14 | // Can't find it... just forget it. |
15 | -else |
|
15 | +else { |
|
16 | 16 | exit; |
17 | +} |
|
17 | 18 | |
18 | 19 | ?> |
19 | 20 | \ No newline at end of file |
@@ -12,7 +12,8 @@ |
||
12 | 12 | header('Location: ' . $boardurl); |
13 | 13 | } |
14 | 14 | // Can't find it... just forget it. |
15 | -else |
|
15 | +else { |
|
16 | 16 | exit; |
17 | +} |
|
17 | 18 | |
18 | 19 | ?> |
19 | 20 | \ No newline at end of file |
@@ -51,11 +51,13 @@ discard block |
||
51 | 51 | <p>'; |
52 | 52 | |
53 | 53 | // Show just numbers...? |
54 | - if ($settings['display_who_viewing'] == 1) |
|
55 | - echo count($context['view_members']), ' ', count($context['view_members']) == 1 ? $txt['who_member'] : $txt['members']; |
|
54 | + if ($settings['display_who_viewing'] == 1) { |
|
55 | + echo count($context['view_members']), ' ', count($context['view_members']) == 1 ? $txt['who_member'] : $txt['members']; |
|
56 | + } |
|
56 | 57 | // Or show the actual people viewing the topic? |
57 | - else |
|
58 | - echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . ((empty($context['view_num_hidden']) || $context['can_moderate_forum']) ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')'); |
|
58 | + else { |
|
59 | + echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . ((empty($context['view_num_hidden']) || $context['can_moderate_forum']) ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')'); |
|
60 | + } |
|
59 | 61 | |
60 | 62 | // Now show how many guests are here too. |
61 | 63 | echo $txt['who_and'], $context['view_num_guests'], ' ', $context['view_num_guests'] == 1 ? $txt['guest'] : $txt['guests'], $txt['who_viewing_topic'], ' |
@@ -93,10 +95,11 @@ discard block |
||
93 | 95 | <dt class="', $option['voted_this'] ? ' voted' : '', '">', $option['option'], '</dt> |
94 | 96 | <dd class="statsbar', $option['voted_this'] ? ' voted' : '', '">'; |
95 | 97 | |
96 | - if ($context['allow_results_view']) |
|
97 | - echo ' |
|
98 | + if ($context['allow_results_view']) { |
|
99 | + echo ' |
|
98 | 100 | ', $option['bar_ndt'], ' |
99 | 101 | <span class="percentage">', $option['votes'], ' (', $option['percent'], '%)</span>'; |
102 | + } |
|
100 | 103 | |
101 | 104 | echo ' |
102 | 105 | </dd>'; |
@@ -105,9 +108,10 @@ discard block |
||
105 | 108 | echo ' |
106 | 109 | </dl>'; |
107 | 110 | |
108 | - if ($context['allow_results_view']) |
|
109 | - echo ' |
|
111 | + if ($context['allow_results_view']) { |
|
112 | + echo ' |
|
110 | 113 | <p><strong>', $txt['poll_total_voters'], ':</strong> ', $context['poll']['total_votes'], '</p>'; |
114 | + } |
|
111 | 115 | } |
112 | 116 | // They are allowed to vote! Go to it! |
113 | 117 | else |
@@ -116,17 +120,19 @@ discard block |
||
116 | 120 | <form action="', $scripturl, '?action=vote;topic=', $context['current_topic'], '.', $context['start'], ';poll=', $context['poll']['id'], '" method="post" accept-charset="', $context['character_set'], '">'; |
117 | 121 | |
118 | 122 | // Show a warning if they are allowed more than one option. |
119 | - if ($context['poll']['allowed_warning']) |
|
120 | - echo ' |
|
123 | + if ($context['poll']['allowed_warning']) { |
|
124 | + echo ' |
|
121 | 125 | <p class="smallpadding">', $context['poll']['allowed_warning'], '</p>'; |
126 | + } |
|
122 | 127 | |
123 | 128 | echo ' |
124 | 129 | <ul class="options">'; |
125 | 130 | |
126 | 131 | // Show each option with its button - a radio likely. |
127 | - foreach ($context['poll']['options'] as $option) |
|
128 | - echo ' |
|
132 | + foreach ($context['poll']['options'] as $option) { |
|
133 | + echo ' |
|
129 | 134 | <li>', $option['vote_button'], ' <label for="', $option['id'], '">', $option['option'], '</label></li>'; |
135 | + } |
|
130 | 136 | |
131 | 137 | echo ' |
132 | 138 | </ul> |
@@ -138,9 +144,10 @@ discard block |
||
138 | 144 | } |
139 | 145 | |
140 | 146 | // Is the clock ticking? |
141 | - if (!empty($context['poll']['expire_time'])) |
|
142 | - echo ' |
|
147 | + if (!empty($context['poll']['expire_time'])) { |
|
148 | + echo ' |
|
143 | 149 | <p><strong>', ($context['poll']['is_expired'] ? $txt['poll_expired_on'] : $txt['poll_expires_on']), ':</strong> ', $context['poll']['expire_time'], '</p>'; |
150 | + } |
|
144 | 151 | |
145 | 152 | echo ' |
146 | 153 | </div> |
@@ -170,11 +177,13 @@ discard block |
||
170 | 177 | <li> |
171 | 178 | <b class="event_title"><a href="', $scripturl, '?action=calendar;event=', $event['id'], '">', $event['title'], '</a></b>'; |
172 | 179 | |
173 | - if ($event['can_edit']) |
|
174 | - echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>'; |
|
180 | + if ($event['can_edit']) { |
|
181 | + echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>'; |
|
182 | + } |
|
175 | 183 | |
176 | - if ($event['can_export']) |
|
177 | - echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>'; |
|
184 | + if ($event['can_export']) { |
|
185 | + echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>'; |
|
186 | + } |
|
178 | 187 | |
179 | 188 | echo ' |
180 | 189 | <br>'; |
@@ -182,14 +191,14 @@ discard block |
||
182 | 191 | if (!empty($event['allday'])) |
183 | 192 | { |
184 | 193 | echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), '</time>', ($event['start_date'] != $event['end_date']) ? ' – <time datetime="' . $event['end_iso_gmdate'] . '">' . trim($event['end_date_local']) . '</time>' : ''; |
185 | - } |
|
186 | - else |
|
194 | + } else |
|
187 | 195 | { |
188 | 196 | // Display event info relative to user's local timezone |
189 | 197 | echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), ', ', trim($event['start_time_local']), '</time> – <time datetime="' . $event['end_iso_gmdate'] . '">'; |
190 | 198 | |
191 | - if ($event['start_date_local'] != $event['end_date_local']) |
|
192 | - echo trim($event['end_date_local']) . ', '; |
|
199 | + if ($event['start_date_local'] != $event['end_date_local']) { |
|
200 | + echo trim($event['end_date_local']) . ', '; |
|
201 | + } |
|
193 | 202 | |
194 | 203 | echo trim($event['end_time_local']); |
195 | 204 | |
@@ -198,23 +207,27 @@ discard block |
||
198 | 207 | { |
199 | 208 | echo '</time> (<time datetime="' . $event['start_iso_gmdate'] . '">'; |
200 | 209 | |
201 | - if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig']) |
|
202 | - echo trim($event['start_date_orig']), ', '; |
|
210 | + if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig']) { |
|
211 | + echo trim($event['start_date_orig']), ', '; |
|
212 | + } |
|
203 | 213 | |
204 | 214 | echo trim($event['start_time_orig']), '</time> – <time datetime="' . $event['end_iso_gmdate'] . '">'; |
205 | 215 | |
206 | - if ($event['start_date_orig'] != $event['end_date_orig']) |
|
207 | - echo trim($event['end_date_orig']) . ', '; |
|
216 | + if ($event['start_date_orig'] != $event['end_date_orig']) { |
|
217 | + echo trim($event['end_date_orig']) . ', '; |
|
218 | + } |
|
208 | 219 | |
209 | 220 | echo trim($event['end_time_orig']), ' ', $event['tz_abbrev'], '</time>)'; |
210 | 221 | } |
211 | 222 | // Event is scheduled in the user's own timezone? Let 'em know, just to avoid confusion |
212 | - else |
|
213 | - echo ' ', $event['tz_abbrev'], '</time>'; |
|
223 | + else { |
|
224 | + echo ' ', $event['tz_abbrev'], '</time>'; |
|
225 | + } |
|
214 | 226 | } |
215 | 227 | |
216 | - if (!empty($event['location'])) |
|
217 | - echo '<br>', $event['location']; |
|
228 | + if (!empty($event['location'])) { |
|
229 | + echo '<br>', $event['location']; |
|
230 | + } |
|
218 | 231 | |
219 | 232 | echo ' |
220 | 233 | </li>'; |
@@ -252,8 +265,9 @@ discard block |
||
252 | 265 | $context['removableMessageIDs'] = array(); |
253 | 266 | |
254 | 267 | // Get all the messages... |
255 | - while ($message = $context['get_message']()) |
|
256 | - template_single_post($message); |
|
268 | + while ($message = $context['get_message']()) { |
|
269 | + template_single_post($message); |
|
270 | + } |
|
257 | 271 | |
258 | 272 | echo ' |
259 | 273 | </form> |
@@ -290,8 +304,9 @@ discard block |
||
290 | 304 | <div id="display_jump_to"> </div>'; |
291 | 305 | |
292 | 306 | // Show quickreply |
293 | - if ($context['can_reply']) |
|
294 | - template_quickreply(); |
|
307 | + if ($context['can_reply']) { |
|
308 | + template_quickreply(); |
|
309 | + } |
|
295 | 310 | |
296 | 311 | // User action pop on mobile screen (or actually small screen), this uses responsive css does not check mobile device. |
297 | 312 | echo ' |
@@ -304,8 +319,8 @@ discard block |
||
304 | 319 | </div>'; |
305 | 320 | |
306 | 321 | // Show the moderation button & pop only if user can moderate |
307 | - if ($context['can_moderate_forum'] || $context['user']['is_mod']) |
|
308 | - echo ' |
|
322 | + if ($context['can_moderate_forum'] || $context['user']['is_mod']) { |
|
323 | + echo ' |
|
309 | 324 | <div id="mobile_moderation" class="popup_container"> |
310 | 325 | <div class="popup_window description"> |
311 | 326 | <div class="popup_heading">', $txt['mobile_moderation'],' |
@@ -315,6 +330,7 @@ discard block |
||
315 | 330 | </div> |
316 | 331 | </div> |
317 | 332 | </div>'; |
333 | + } |
|
318 | 334 | |
319 | 335 | echo ' |
320 | 336 | <script>'; |
@@ -438,9 +454,10 @@ discard block |
||
438 | 454 | }); |
439 | 455 | }'; |
440 | 456 | |
441 | - if (!empty($context['ignoredMsgs'])) |
|
442 | - echo ' |
|
457 | + if (!empty($context['ignoredMsgs'])) { |
|
458 | + echo ' |
|
443 | 459 | ignore_toggles([', implode(', ', $context['ignoredMsgs']), '], ', JavaScriptEscape($txt['show_ignore_user_post']), ');'; |
460 | + } |
|
444 | 461 | |
445 | 462 | echo ' |
446 | 463 | </script>'; |
@@ -457,8 +474,9 @@ discard block |
||
457 | 474 | |
458 | 475 | $ignoring = false; |
459 | 476 | |
460 | - if ($message['can_remove']) |
|
461 | - $context['removableMessageIDs'][] = $message['id']; |
|
477 | + if ($message['can_remove']) { |
|
478 | + $context['removableMessageIDs'][] = $message['id']; |
|
479 | + } |
|
462 | 480 | |
463 | 481 | // Are we ignoring this message? |
464 | 482 | if (!empty($message['is_ignored'])) |
@@ -484,9 +502,10 @@ discard block |
||
484 | 502 | <div class="custom_fields_above_member"> |
485 | 503 | <ul class="nolist">'; |
486 | 504 | |
487 | - foreach ($message['custom_fields']['above_member'] as $custom) |
|
488 | - echo ' |
|
505 | + foreach ($message['custom_fields']['above_member'] as $custom) { |
|
506 | + echo ' |
|
489 | 507 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
508 | + } |
|
490 | 509 | |
491 | 510 | echo ' |
492 | 511 | </ul> |
@@ -497,9 +516,10 @@ discard block |
||
497 | 516 | <h4>'; |
498 | 517 | |
499 | 518 | // Show online and offline buttons? |
500 | - if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest']) |
|
501 | - echo ' |
|
519 | + if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest']) { |
|
520 | + echo ' |
|
502 | 521 | ', $context['can_send_pm'] ? '<a href="' . $message['member']['online']['href'] . '" title="' . $message['member']['online']['label'] . '">' : '', '<span class="' . ($message['member']['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $message['member']['online']['text'] . '"></span>', $context['can_send_pm'] ? '</a>' : ''; |
522 | + } |
|
503 | 523 | |
504 | 524 | |
505 | 525 | // Show a link to the member's profile. |
@@ -512,51 +532,59 @@ discard block |
||
512 | 532 | |
513 | 533 | |
514 | 534 | // Show the user's avatar. |
515 | - if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) |
|
516 | - echo ' |
|
535 | + if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) { |
|
536 | + echo ' |
|
517 | 537 | <li class="avatar"> |
518 | 538 | <a href="', $message['member']['href'], '">', $message['member']['avatar']['image'], '</a> |
519 | 539 | </li>'; |
540 | + } |
|
520 | 541 | |
521 | 542 | // Are there any custom fields below the avatar? |
522 | - if (!empty($message['custom_fields']['below_avatar'])) |
|
523 | - foreach ($message['custom_fields']['below_avatar'] as $custom) |
|
543 | + if (!empty($message['custom_fields']['below_avatar'])) { |
|
544 | + foreach ($message['custom_fields']['below_avatar'] as $custom) |
|
524 | 545 | echo ' |
525 | 546 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
547 | + } |
|
526 | 548 | |
527 | 549 | // Show the post group icons, but not for guests. |
528 | - if (!$message['member']['is_guest']) |
|
529 | - echo ' |
|
550 | + if (!$message['member']['is_guest']) { |
|
551 | + echo ' |
|
530 | 552 | <li class="icons">', $message['member']['group_icons'], '</li>'; |
553 | + } |
|
531 | 554 | |
532 | 555 | // Show the member's primary group (like 'Administrator') if they have one. |
533 | - if (!empty($message['member']['group'])) |
|
534 | - echo ' |
|
556 | + if (!empty($message['member']['group'])) { |
|
557 | + echo ' |
|
535 | 558 | <li class="membergroup">', $message['member']['group'], '</li>'; |
559 | + } |
|
536 | 560 | |
537 | 561 | // Show the member's custom title, if they have one. |
538 | - if (!empty($message['member']['title'])) |
|
539 | - echo ' |
|
562 | + if (!empty($message['member']['title'])) { |
|
563 | + echo ' |
|
540 | 564 | <li class="title">', $message['member']['title'], '</li>'; |
565 | + } |
|
541 | 566 | |
542 | 567 | // Don't show these things for guests. |
543 | 568 | if (!$message['member']['is_guest']) |
544 | 569 | { |
545 | 570 | |
546 | 571 | // Show the post group if and only if they have no other group or the option is on, and they are in a post group. |
547 | - if ((empty($modSettings['hide_post_group']) || empty($message['member']['group'])) && !empty($message['member']['post_group'])) |
|
548 | - echo ' |
|
572 | + if ((empty($modSettings['hide_post_group']) || empty($message['member']['group'])) && !empty($message['member']['post_group'])) { |
|
573 | + echo ' |
|
549 | 574 | <li class="postgroup">', $message['member']['post_group'], '</li>'; |
575 | + } |
|
550 | 576 | |
551 | 577 | // Show how many posts they have made. |
552 | - if (!isset($context['disabled_fields']['posts'])) |
|
553 | - echo ' |
|
578 | + if (!isset($context['disabled_fields']['posts'])) { |
|
579 | + echo ' |
|
554 | 580 | <li class="postcount">', $txt['member_postcount'], ': ', $message['member']['posts'], '</li>'; |
581 | + } |
|
555 | 582 | |
556 | 583 | // Show their personal text? |
557 | - if (!empty($modSettings['show_blurb']) && !empty($message['member']['blurb'])) |
|
558 | - echo ' |
|
584 | + if (!empty($modSettings['show_blurb']) && !empty($message['member']['blurb'])) { |
|
585 | + echo ' |
|
559 | 586 | <li class="blurb">', $message['member']['blurb'], '</li>'; |
587 | + } |
|
560 | 588 | |
561 | 589 | // Any custom fields to show as icons? |
562 | 590 | if (!empty($message['custom_fields']['icons'])) |
@@ -565,9 +593,10 @@ discard block |
||
565 | 593 | <li class="im_icons"> |
566 | 594 | <ol>'; |
567 | 595 | |
568 | - foreach ($message['custom_fields']['icons'] as $custom) |
|
569 | - echo ' |
|
596 | + foreach ($message['custom_fields']['icons'] as $custom) { |
|
597 | + echo ' |
|
570 | 598 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
599 | + } |
|
571 | 600 | |
572 | 601 | echo ' |
573 | 602 | </ol> |
@@ -582,19 +611,22 @@ discard block |
||
582 | 611 | <ol class="profile_icons">'; |
583 | 612 | |
584 | 613 | // Don't show an icon if they haven't specified a website. |
585 | - if (!empty($message['member']['website']['url']) && !isset($context['disabled_fields']['website'])) |
|
586 | - echo ' |
|
614 | + if (!empty($message['member']['website']['url']) && !isset($context['disabled_fields']['website'])) { |
|
615 | + echo ' |
|
587 | 616 | <li><a href="', $message['member']['website']['url'], '" title="' . $message['member']['website']['title'] . '" target="_blank" class="new_win">', ($settings['use_image_buttons'] ? '<span class="generic_icons www centericon" title="' . $message['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>'; |
617 | + } |
|
588 | 618 | |
589 | 619 | // Since we know this person isn't a guest, you *can* message them. |
590 | - if ($context['can_send_pm']) |
|
591 | - echo ' |
|
620 | + if ($context['can_send_pm']) { |
|
621 | + echo ' |
|
592 | 622 | <li><a href="', $scripturl, '?action=pm;sa=send;u=', $message['member']['id'], '" title="', $message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline'], '">', $settings['use_image_buttons'] ? '<span class="generic_icons im_' . ($message['member']['online']['is_online'] ? 'on' : 'off') . ' centericon" title="' . ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']) . '"></span> ' : ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']), '</a></li>'; |
623 | + } |
|
593 | 624 | |
594 | 625 | // Show the email if necessary |
595 | - if (!empty($message['member']['email']) && $message['member']['show_email']) |
|
596 | - echo ' |
|
626 | + if (!empty($message['member']['email']) && $message['member']['show_email']) { |
|
627 | + echo ' |
|
597 | 628 | <li class="email"><a href="mailto:' . $message['member']['email'] . '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a></li>'; |
629 | + } |
|
598 | 630 | |
599 | 631 | echo ' |
600 | 632 | </ol> |
@@ -602,48 +634,56 @@ discard block |
||
602 | 634 | } |
603 | 635 | |
604 | 636 | // Any custom fields for standard placement? |
605 | - if (!empty($message['custom_fields']['standard'])) |
|
606 | - foreach ($message['custom_fields']['standard'] as $custom) |
|
637 | + if (!empty($message['custom_fields']['standard'])) { |
|
638 | + foreach ($message['custom_fields']['standard'] as $custom) |
|
607 | 639 | echo ' |
608 | 640 | <li class="custom ', $custom['col_name'] ,'">', $custom['title'], ': ', $custom['value'], '</li>'; |
641 | + } |
|
609 | 642 | |
610 | 643 | } |
611 | 644 | // Otherwise, show the guest's email. |
612 | - elseif (!empty($message['member']['email']) && $message['member']['show_email']) |
|
613 | - echo ' |
|
645 | + elseif (!empty($message['member']['email']) && $message['member']['show_email']) { |
|
646 | + echo ' |
|
614 | 647 | <li class="email"><a href="mailto:' . $message['member']['email'] . '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a></li>'; |
648 | + } |
|
615 | 649 | |
616 | 650 | // Show the IP to this user for this post - because you can moderate? |
617 | - if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip'])) |
|
618 | - echo ' |
|
651 | + if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip'])) { |
|
652 | + echo ' |
|
619 | 653 | <li class="poster_ip"><a href="', $scripturl, '?action=', !empty($message['member']['is_guest']) ? 'trackip' : 'profile;area=tracking;sa=ip;u=' . $message['member']['id'], ';searchip=', $message['member']['ip'], '">', $message['member']['ip'], '</a> <a href="', $scripturl, '?action=helpadmin;help=see_admin_ip" onclick="return reqOverlayDiv(this.href);" class="help">(?)</a></li>'; |
654 | + } |
|
620 | 655 | |
621 | 656 | // Or, should we show it because this is you? |
622 | - elseif ($message['can_see_ip']) |
|
623 | - echo ' |
|
657 | + elseif ($message['can_see_ip']) { |
|
658 | + echo ' |
|
624 | 659 | <li class="poster_ip"><a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $message['member']['ip'], '</a></li>'; |
660 | + } |
|
625 | 661 | |
626 | 662 | // Okay, are you at least logged in? Then we can show something about why IPs are logged... |
627 | - elseif (!$context['user']['is_guest']) |
|
628 | - echo ' |
|
663 | + elseif (!$context['user']['is_guest']) { |
|
664 | + echo ' |
|
629 | 665 | <li class="poster_ip"><a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $txt['logged'], '</a></li>'; |
666 | + } |
|
630 | 667 | |
631 | 668 | // Otherwise, you see NOTHING! |
632 | - else |
|
633 | - echo ' |
|
669 | + else { |
|
670 | + echo ' |
|
634 | 671 | <li class="poster_ip">', $txt['logged'], '</li>'; |
672 | + } |
|
635 | 673 | |
636 | 674 | // Are we showing the warning status? |
637 | 675 | // Don't show these things for guests. |
638 | - if (!$message['member']['is_guest'] && $message['member']['can_see_warning']) |
|
639 | - echo ' |
|
676 | + if (!$message['member']['is_guest'] && $message['member']['can_see_warning']) { |
|
677 | + echo ' |
|
640 | 678 | <li class="warning">', $context['can_issue_warning'] ? '<a href="' . $scripturl . '?action=profile;area=issuewarning;u=' . $message['member']['id'] . '">' : '', '<span class="generic_icons warning_', $message['member']['warning_status'], '"></span> ', $context['can_issue_warning'] ? '</a>' : '', '<span class="warn_', $message['member']['warning_status'], '">', $txt['warn_' . $message['member']['warning_status']], '</span></li>'; |
679 | + } |
|
641 | 680 | |
642 | 681 | // Are there any custom fields to show at the bottom of the poster info? |
643 | - if (!empty($message['custom_fields']['bottom_poster'])) |
|
644 | - foreach ($message['custom_fields']['bottom_poster'] as $custom) |
|
682 | + if (!empty($message['custom_fields']['bottom_poster'])) { |
|
683 | + foreach ($message['custom_fields']['bottom_poster'] as $custom) |
|
645 | 684 | echo ' |
646 | 685 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
686 | + } |
|
647 | 687 | |
648 | 688 | // Poster info ends. |
649 | 689 | echo ' |
@@ -672,9 +712,10 @@ discard block |
||
672 | 712 | echo ' |
673 | 713 | <span class="smalltext modified" id="modified_', $message['id'], '">'; |
674 | 714 | |
675 | - if (!empty($modSettings['show_modify']) && !empty($message['modified']['name'])) |
|
676 | - echo |
|
715 | + if (!empty($modSettings['show_modify']) && !empty($message['modified']['name'])) { |
|
716 | + echo |
|
677 | 717 | $message['modified']['last_edit_text']; |
718 | + } |
|
678 | 719 | |
679 | 720 | echo ' |
680 | 721 | </span>'; |
@@ -685,22 +726,24 @@ discard block |
||
685 | 726 | </div>'; |
686 | 727 | |
687 | 728 | // Ignoring this user? Hide the post. |
688 | - if ($ignoring) |
|
689 | - echo ' |
|
729 | + if ($ignoring) { |
|
730 | + echo ' |
|
690 | 731 | <div id="msg_', $message['id'], '_ignored_prompt"> |
691 | 732 | ', $txt['ignoring_user'], ' |
692 | 733 | <a href="#" id="msg_', $message['id'], '_ignored_link" style="display: none;">', $txt['show_ignore_user_post'], '</a> |
693 | 734 | </div>'; |
735 | + } |
|
694 | 736 | |
695 | 737 | // Show the post itself, finally! |
696 | 738 | echo ' |
697 | 739 | <div class="post">'; |
698 | 740 | |
699 | - if (!$message['approved'] && $message['member']['id'] != 0 && $message['member']['id'] == $context['user']['id']) |
|
700 | - echo ' |
|
741 | + if (!$message['approved'] && $message['member']['id'] != 0 && $message['member']['id'] == $context['user']['id']) { |
|
742 | + echo ' |
|
701 | 743 | <div class="approve_post"> |
702 | 744 | ', $txt['post_awaiting_approval'], ' |
703 | 745 | </div>'; |
746 | + } |
|
704 | 747 | echo ' |
705 | 748 | <div class="inner" data-msgid="', $message['id'], '" id="msg_', $message['id'], '"', $ignoring ? ' style="display:none;"' : '', '>', $message['body'], '</div> |
706 | 749 | </div>'; |
@@ -717,9 +760,9 @@ discard block |
||
717 | 760 | foreach ($message['attachment'] as $attachment) |
718 | 761 | { |
719 | 762 | // Do we want this attachment to not be showed here? |
720 | - if (!empty($modSettings['dont_show_attach_under_post']) && !empty($context['show_attach_under_post'][$attachment['id']])) |
|
721 | - continue; |
|
722 | - elseif (!$div_output) |
|
763 | + if (!empty($modSettings['dont_show_attach_under_post']) && !empty($context['show_attach_under_post'][$attachment['id']])) { |
|
764 | + continue; |
|
765 | + } elseif (!$div_output) |
|
723 | 766 | { |
724 | 767 | $div_output = true; |
725 | 768 | |
@@ -735,9 +778,10 @@ discard block |
||
735 | 778 | <fieldset> |
736 | 779 | <legend>', $txt['attach_awaiting_approve']; |
737 | 780 | |
738 | - if ($context['can_approve']) |
|
739 | - echo ' |
|
781 | + if ($context['can_approve']) { |
|
782 | + echo ' |
|
740 | 783 | [<a href="', $scripturl, '?action=attachapprove;sa=all;mid=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve_all'], '</a>]'; |
784 | + } |
|
741 | 785 | |
742 | 786 | echo ' |
743 | 787 | </legend>'; |
@@ -751,12 +795,13 @@ discard block |
||
751 | 795 | echo ' |
752 | 796 | <div class="attachments_top">'; |
753 | 797 | |
754 | - if ($attachment['thumbnail']['has_thumb']) |
|
755 | - echo ' |
|
798 | + if ($attachment['thumbnail']['has_thumb']) { |
|
799 | + echo ' |
|
756 | 800 | <a href="', $attachment['href'], ';image" id="link_', $attachment['id'], '" onclick="', $attachment['thumbnail']['javascript'], '"><img src="', $attachment['thumbnail']['href'], '" alt="" id="thumb_', $attachment['id'], '" class="atc_img"></a>'; |
757 | - else |
|
758 | - echo ' |
|
801 | + } else { |
|
802 | + echo ' |
|
759 | 803 | <img src="' . $attachment['href'] . ';image" alt="" width="' . $attachment['width'] . '" height="' . $attachment['height'] . '" class="atc_img">'; |
804 | + } |
|
760 | 805 | |
761 | 806 | echo ' |
762 | 807 | </div>'; |
@@ -766,9 +811,10 @@ discard block |
||
766 | 811 | <div class="attachments_bot"> |
767 | 812 | <a href="' . $attachment['href'] . '"><img src="' . $settings['images_url'] . '/icons/clip.png" class="centericon" alt="*"> ' . $attachment['name'] . '</a> '; |
768 | 813 | |
769 | - if (!$attachment['is_approved'] && $context['can_approve']) |
|
770 | - echo ' |
|
814 | + if (!$attachment['is_approved'] && $context['can_approve']) { |
|
815 | + echo ' |
|
771 | 816 | [<a href="', $scripturl, '?action=attachapprove;sa=approve;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve'], '</a>] | [<a href="', $scripturl, '?action=attachapprove;sa=reject;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['delete'], '</a>] '; |
817 | + } |
|
772 | 818 | echo ' |
773 | 819 | <br>', $attachment['size'], ($attachment['is_image'] ? ', ' . $attachment['real_width'] . 'x' . $attachment['real_height'] . '<br>' . sprintf($txt['attach_viewed'], $attachment['downloads']) : '<br>' . sprintf($txt['attach_downloaded'], $attachment['downloads'])), ' |
774 | 820 | </div>'; |
@@ -777,33 +823,38 @@ discard block |
||
777 | 823 | </div>'; |
778 | 824 | |
779 | 825 | // Next attachment line ? |
780 | - if (++$i % $attachments_per_line === 0) |
|
781 | - echo ' |
|
826 | + if (++$i % $attachments_per_line === 0) { |
|
827 | + echo ' |
|
782 | 828 | <br>'; |
829 | + } |
|
783 | 830 | } |
784 | 831 | |
785 | 832 | // If we had unapproved attachments clean up. |
786 | - if ($last_approved_state == 0) |
|
787 | - echo ' |
|
833 | + if ($last_approved_state == 0) { |
|
834 | + echo ' |
|
788 | 835 | </fieldset>'; |
836 | + } |
|
789 | 837 | |
790 | 838 | // Only do this if we output a div above - otherwise it'll break things |
791 | - if ($div_output) |
|
792 | - echo ' |
|
839 | + if ($div_output) { |
|
840 | + echo ' |
|
793 | 841 | </div>'; |
842 | + } |
|
794 | 843 | } |
795 | 844 | |
796 | 845 | // And stuff below the attachments. |
797 | - if ($context['can_report_moderator'] || !empty($context['can_see_likes']) || !empty($context['can_like']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) |
|
798 | - echo ' |
|
846 | + if ($context['can_report_moderator'] || !empty($context['can_see_likes']) || !empty($context['can_like']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) { |
|
847 | + echo ' |
|
799 | 848 | <div class="under_message">'; |
849 | + } |
|
800 | 850 | |
801 | 851 | // Maybe they want to report this post to the moderator(s)? |
802 | - if ($context['can_report_moderator']) |
|
803 | - echo ' |
|
852 | + if ($context['can_report_moderator']) { |
|
853 | + echo ' |
|
804 | 854 | <ul class="floatright smalltext"> |
805 | 855 | <li class="report_link"><a href="', $scripturl, '?action=reporttm;topic=', $context['current_topic'], '.', $message['counter'], ';msg=', $message['id'], '">', $txt['report_to_mod'], '</a></li> |
806 | 856 | </ul>'; |
857 | + } |
|
807 | 858 | |
808 | 859 | // What about likes? |
809 | 860 | if (!empty($modSettings['enable_likes'])) |
@@ -844,78 +895,91 @@ discard block |
||
844 | 895 | <ul class="quickbuttons">'; |
845 | 896 | |
846 | 897 | // Can they quote? if so they can select and quote as well! |
847 | - if ($context['can_quote']) |
|
848 | - echo ' |
|
898 | + if ($context['can_quote']) { |
|
899 | + echo ' |
|
849 | 900 | <li><a href="', $scripturl, '?action=post;quote=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], ';last_msg=', $context['topic_last_message'], '" onclick="return oQuickReply.quote(', $message['id'], ');"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li> |
850 | 901 | <li style="display:none;" id="quoteSelected_', $message['id'], '"><a href="javascript:void(0)"><span class="generic_icons quote_selected"></span>', $txt['quote_selected_action'] ,'</a></li>'; |
902 | + } |
|
851 | 903 | |
852 | 904 | // Can the user modify the contents of this post? Show the modify inline image. |
853 | - if ($message['can_modify']) |
|
854 | - echo ' |
|
905 | + if ($message['can_modify']) { |
|
906 | + echo ' |
|
855 | 907 | <li class="quick_edit"><a title="', $txt['modify_msg'], '" class="modifybutton" id="modify_button_', $message['id'], '" onclick="oQuickModify.modifyMsg(\'', $message['id'], '\', \'', !empty($modSettings['toggle_subject']), '\')"><span class="generic_icons quick_edit_button"></span>', $txt['quick_edit'], '</a></li>'; |
908 | + } |
|
856 | 909 | |
857 | - if ($message['can_approve'] || $message['can_unapprove'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) |
|
858 | - echo ' |
|
910 | + if ($message['can_approve'] || $message['can_unapprove'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) { |
|
911 | + echo ' |
|
859 | 912 | <li class="post_options">', $txt['post_options']; |
913 | + } |
|
860 | 914 | |
861 | 915 | echo ' |
862 | 916 | <ul>'; |
863 | 917 | |
864 | 918 | // Can the user modify the contents of this post? |
865 | - if ($message['can_modify']) |
|
866 | - echo ' |
|
919 | + if ($message['can_modify']) { |
|
920 | + echo ' |
|
867 | 921 | <li><a href="', $scripturl, '?action=post;msg=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], '"><span class="generic_icons modify_button"></span>', $txt['modify'], '</a></li>'; |
922 | + } |
|
868 | 923 | |
869 | 924 | // How about... even... remove it entirely?! |
870 | - if ($context['can_delete'] && ($context['topic_first_message'] == $message['id'])) |
|
871 | - echo ' |
|
925 | + if ($context['can_delete'] && ($context['topic_first_message'] == $message['id'])) { |
|
926 | + echo ' |
|
872 | 927 | <li><a href="', $scripturl, '?action=removetopic2;topic=', $context['current_topic'], '.', $context['start'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['are_sure_remove_topic'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove_topic'],'</a></li>'; |
873 | - elseif ($message['can_remove'] && ($context['topic_first_message'] != $message['id'])) |
|
874 | - echo ' |
|
928 | + } elseif ($message['can_remove'] && ($context['topic_first_message'] != $message['id'])) { |
|
929 | + echo ' |
|
875 | 930 | <li><a href="', $scripturl, '?action=deletemsg;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message_question'] ,'" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>'; |
931 | + } |
|
876 | 932 | |
877 | 933 | // What about splitting it off the rest of the topic? |
878 | - if ($context['can_split'] && !empty($context['real_num_replies'])) |
|
879 | - echo ' |
|
934 | + if ($context['can_split'] && !empty($context['real_num_replies'])) { |
|
935 | + echo ' |
|
880 | 936 | <li><a href="', $scripturl, '?action=splittopics;topic=', $context['current_topic'], '.0;at=', $message['id'], '"><span class="generic_icons split_button"></span>', $txt['split'], '</a></li>'; |
937 | + } |
|
881 | 938 | |
882 | 939 | // Can we issue a warning because of this post? Remember, we can't give guests warnings. |
883 | - if ($context['can_issue_warning'] && !$message['is_message_author'] && !$message['member']['is_guest']) |
|
884 | - echo ' |
|
940 | + if ($context['can_issue_warning'] && !$message['is_message_author'] && !$message['member']['is_guest']) { |
|
941 | + echo ' |
|
885 | 942 | <li><a href="', $scripturl, '?action=profile;area=issuewarning;u=', $message['member']['id'], ';msg=', $message['id'], '"><span class="generic_icons warn_button"></span>', $txt['issue_warning'], '</a></li>'; |
943 | + } |
|
886 | 944 | |
887 | 945 | // Can we restore topics? |
888 | - if ($context['can_restore_msg']) |
|
889 | - echo ' |
|
946 | + if ($context['can_restore_msg']) { |
|
947 | + echo ' |
|
890 | 948 | <li><a href="', $scripturl, '?action=restoretopic;msgs=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons restore_button"></span>', $txt['restore_message'], '</a></li>'; |
949 | + } |
|
891 | 950 | |
892 | 951 | // Maybe we can approve it, maybe we should? |
893 | - if ($message['can_approve']) |
|
894 | - echo ' |
|
952 | + if ($message['can_approve']) { |
|
953 | + echo ' |
|
895 | 954 | <li><a href="', $scripturl, '?action=moderate;area=postmod;sa=approve;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons approve_button"></span>', $txt['approve'], '</a></li>'; |
955 | + } |
|
896 | 956 | |
897 | 957 | // Maybe we can unapprove it? |
898 | - if ($message['can_unapprove']) |
|
899 | - echo ' |
|
958 | + if ($message['can_unapprove']) { |
|
959 | + echo ' |
|
900 | 960 | <li><a href="', $scripturl, '?action=moderate;area=postmod;sa=approve;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons unapprove_button"></span>', $txt['unapprove'], '</a></li>'; |
961 | + } |
|
901 | 962 | |
902 | 963 | echo ' |
903 | 964 | </ul> |
904 | 965 | </li>'; |
905 | 966 | |
906 | 967 | // Show a checkbox for quick moderation? |
907 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $message['can_remove']) |
|
908 | - echo ' |
|
968 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $message['can_remove']) { |
|
969 | + echo ' |
|
909 | 970 | <li style="display: none;" id="in_topic_mod_check_', $message['id'], '"></li>'; |
971 | + } |
|
910 | 972 | |
911 | - if ($message['can_approve'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) |
|
912 | - echo ' |
|
973 | + if ($message['can_approve'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) { |
|
974 | + echo ' |
|
913 | 975 | </ul>'; |
976 | + } |
|
914 | 977 | } |
915 | 978 | |
916 | - if ($context['can_report_moderator'] || !empty($context['can_see_likes']) || !empty($context['can_like']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) |
|
917 | - echo ' |
|
979 | + if ($context['can_report_moderator'] || !empty($context['can_see_likes']) || !empty($context['can_like']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) { |
|
980 | + echo ' |
|
918 | 981 | </div>'; |
982 | + } |
|
919 | 983 | |
920 | 984 | echo ' |
921 | 985 | </div> |
@@ -928,9 +992,10 @@ discard block |
||
928 | 992 | <div class="custom_fields_above_signature"> |
929 | 993 | <ul class="nolist">'; |
930 | 994 | |
931 | - foreach ($message['custom_fields']['above_signature'] as $custom) |
|
932 | - echo ' |
|
995 | + foreach ($message['custom_fields']['above_signature'] as $custom) { |
|
996 | + echo ' |
|
933 | 997 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
998 | + } |
|
934 | 999 | |
935 | 1000 | echo ' |
936 | 1001 | </ul> |
@@ -938,9 +1003,10 @@ discard block |
||
938 | 1003 | } |
939 | 1004 | |
940 | 1005 | // Show the member's signature? |
941 | - if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) |
|
942 | - echo ' |
|
1006 | + if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) { |
|
1007 | + echo ' |
|
943 | 1008 | <div class="signature" id="msg_', $message['id'], '_signature"', $ignoring ? ' style="display:none;"' : '', '>', $message['member']['signature'], '</div>'; |
1009 | + } |
|
944 | 1010 | |
945 | 1011 | |
946 | 1012 | // Are there any custom profile fields for below the signature? |
@@ -950,9 +1016,10 @@ discard block |
||
950 | 1016 | <div class="custom_fields_below_signature"> |
951 | 1017 | <ul class="nolist">'; |
952 | 1018 | |
953 | - foreach ($message['custom_fields']['below_signature'] as $custom) |
|
954 | - echo ' |
|
1019 | + foreach ($message['custom_fields']['below_signature'] as $custom) { |
|
1020 | + echo ' |
|
955 | 1021 | <li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>'; |
1022 | + } |
|
956 | 1023 | |
957 | 1024 | echo ' |
958 | 1025 | </ul> |
@@ -1000,8 +1067,8 @@ discard block |
||
1000 | 1067 | <input type="hidden" name="seqnum" value="', $context['form_sequence_number'], '">'; |
1001 | 1068 | |
1002 | 1069 | // Guests just need more. |
1003 | - if ($context['user']['is_guest']) |
|
1004 | - echo ' |
|
1070 | + if ($context['user']['is_guest']) { |
|
1071 | + echo ' |
|
1005 | 1072 | <dl id="post_header"> |
1006 | 1073 | <dt> |
1007 | 1074 | ', $txt['name'], ': |
@@ -1016,6 +1083,7 @@ discard block |
||
1016 | 1083 | <input type="email" name="email" size="25" value="', $context['email'], '" tabindex="', $context['tabindex']++, '" class="input_text" required> |
1017 | 1084 | </dd> |
1018 | 1085 | </dl>'; |
1086 | + } |
|
1019 | 1087 | |
1020 | 1088 | echo ' |
1021 | 1089 | ', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message'), ' |
@@ -1063,8 +1131,8 @@ discard block |
||
1063 | 1131 | <br class="clear">'; |
1064 | 1132 | |
1065 | 1133 | // draft autosave available and the user has it enabled? |
1066 | - if (!empty($context['drafts_autosave'])) |
|
1067 | - echo ' |
|
1134 | + if (!empty($context['drafts_autosave'])) { |
|
1135 | + echo ' |
|
1068 | 1136 | <script> |
1069 | 1137 | var oDraftAutoSave = new smf_DraftAutoSave({ |
1070 | 1138 | sSelf: \'oDraftAutoSave\', |
@@ -1076,10 +1144,12 @@ discard block |
||
1076 | 1144 | iFreq: ', (empty($modSettings['masterAutoSaveDraftsDelay']) ? 60000 : $modSettings['masterAutoSaveDraftsDelay'] * 1000), ' |
1077 | 1145 | }); |
1078 | 1146 | </script>'; |
1147 | + } |
|
1079 | 1148 | |
1080 | - if ($context['show_spellchecking']) |
|
1081 | - echo ' |
|
1149 | + if ($context['show_spellchecking']) { |
|
1150 | + echo ' |
|
1082 | 1151 | <form action="', $scripturl, '?action=spellcheck" method="post" accept-charset="', $context['character_set'], '" name="spell_form" id="spell_form" target="spellWindow"><input type="hidden" name="spellstring" value=""></form>'; |
1152 | + } |
|
1083 | 1153 | |
1084 | 1154 | echo ' |
1085 | 1155 | <script> |
@@ -240,8 +240,8 @@ |
||
240 | 240 | $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
241 | 241 | |
242 | 242 | $js_time_string = str_replace( |
243 | - array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
|
244 | - array('H', 'G', 'h', 'g', 'i', 'A', 'a', 'h:i:s A', 'H:i', 's', 'H:i:s', 'H:i:s'), |
|
243 | + array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
|
244 | + array('H', 'G', 'h', 'g', 'i', 'A', 'a', 'h:i:s A', 'H:i', 's', 'H:i:s', 'H:i:s'), |
|
245 | 245 | $time_string |
246 | 246 | ); |
247 | 247 |
@@ -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 | * Show the calendar. |
@@ -47,12 +48,14 @@ discard block |
||
47 | 48 | 'post' => 'CalendarPost', |
48 | 49 | ); |
49 | 50 | |
50 | - if (isset($_GET['sa']) && isset($subActions[$_GET['sa']])) |
|
51 | - return call_helper($subActions[$_GET['sa']]); |
|
51 | + if (isset($_GET['sa']) && isset($subActions[$_GET['sa']])) { |
|
52 | + return call_helper($subActions[$_GET['sa']]); |
|
53 | + } |
|
52 | 54 | |
53 | 55 | // You can't do anything if the calendar is off. |
54 | - if (empty($modSettings['cal_enabled'])) |
|
55 | - fatal_lang_error('calendar_off', false); |
|
56 | + if (empty($modSettings['cal_enabled'])) { |
|
57 | + fatal_lang_error('calendar_off', false); |
|
58 | + } |
|
56 | 59 | |
57 | 60 | // This is gonna be needed... |
58 | 61 | loadTemplate('Calendar'); |
@@ -97,8 +100,9 @@ discard block |
||
97 | 100 | $context['view_week'] = isset($_GET['viewweek']); |
98 | 101 | |
99 | 102 | // Don't let search engines index weekly calendar pages. |
100 | - if ($context['view_week']) |
|
101 | - $context['robot_no_index'] = true; |
|
103 | + if ($context['view_week']) { |
|
104 | + $context['robot_no_index'] = true; |
|
105 | + } |
|
102 | 106 | |
103 | 107 | // Get the current day of month... |
104 | 108 | require_once($sourcedir . '/Subs-Calendar.php'); |
@@ -112,17 +116,20 @@ discard block |
||
112 | 116 | ); |
113 | 117 | |
114 | 118 | // Make sure the year and month are in valid ranges. |
115 | - if ($curPage['month'] < 1 || $curPage['month'] > 12) |
|
116 | - fatal_lang_error('invalid_month', false); |
|
117 | - if ($curPage['year'] < $modSettings['cal_minyear'] || $curPage['year'] > $modSettings['cal_maxyear']) |
|
118 | - fatal_lang_error('invalid_year', false); |
|
119 | + if ($curPage['month'] < 1 || $curPage['month'] > 12) { |
|
120 | + fatal_lang_error('invalid_month', false); |
|
121 | + } |
|
122 | + if ($curPage['year'] < $modSettings['cal_minyear'] || $curPage['year'] > $modSettings['cal_maxyear']) { |
|
123 | + fatal_lang_error('invalid_year', false); |
|
124 | + } |
|
119 | 125 | // If we have a day clean that too. |
120 | 126 | if ($context['view_week']) |
121 | 127 | { |
122 | 128 | // Note $isValid is -1 < PHP 5.1 |
123 | 129 | $isValid = mktime(0, 0, 0, $curPage['month'], $curPage['day'], $curPage['year']); |
124 | - if ($curPage['day'] > 31 || !$isValid || $isValid == -1) |
|
125 | - fatal_lang_error('invalid_day', false); |
|
130 | + if ($curPage['day'] > 31 || !$isValid || $isValid == -1) { |
|
131 | + fatal_lang_error('invalid_day', false); |
|
132 | + } |
|
126 | 133 | } |
127 | 134 | |
128 | 135 | // Load all the context information needed to show the calendar grid. |
@@ -144,21 +151,24 @@ discard block |
||
144 | 151 | ); |
145 | 152 | |
146 | 153 | // Load up the main view. |
147 | - if ($context['view_week']) |
|
148 | - $context['calendar_grid_main'] = getCalendarWeek($curPage['month'], $curPage['year'], $curPage['day'], $calendarOptions); |
|
149 | - else |
|
150 | - $context['calendar_grid_main'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions); |
|
154 | + if ($context['view_week']) { |
|
155 | + $context['calendar_grid_main'] = getCalendarWeek($curPage['month'], $curPage['year'], $curPage['day'], $calendarOptions); |
|
156 | + } else { |
|
157 | + $context['calendar_grid_main'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions); |
|
158 | + } |
|
151 | 159 | |
152 | 160 | // Load up the previous and next months. |
153 | 161 | $context['calendar_grid_current'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions); |
154 | 162 | |
155 | 163 | // Only show previous month if it isn't pre-January of the min-year |
156 | - if ($context['calendar_grid_current']['previous_calendar']['year'] > $modSettings['cal_minyear'] || $curPage['month'] != 1) |
|
157 | - $context['calendar_grid_prev'] = getCalendarGrid($context['calendar_grid_current']['previous_calendar']['month'], $context['calendar_grid_current']['previous_calendar']['year'], $calendarOptions, true); |
|
164 | + if ($context['calendar_grid_current']['previous_calendar']['year'] > $modSettings['cal_minyear'] || $curPage['month'] != 1) { |
|
165 | + $context['calendar_grid_prev'] = getCalendarGrid($context['calendar_grid_current']['previous_calendar']['month'], $context['calendar_grid_current']['previous_calendar']['year'], $calendarOptions, true); |
|
166 | + } |
|
158 | 167 | |
159 | 168 | // Only show next month if it isn't post-December of the max-year |
160 | - if ($context['calendar_grid_current']['next_calendar']['year'] < $modSettings['cal_maxyear'] || $curPage['month'] != 12) |
|
161 | - $context['calendar_grid_next'] = getCalendarGrid($context['calendar_grid_current']['next_calendar']['month'], $context['calendar_grid_current']['next_calendar']['year'], $calendarOptions); |
|
169 | + if ($context['calendar_grid_current']['next_calendar']['year'] < $modSettings['cal_maxyear'] || $curPage['month'] != 12) { |
|
170 | + $context['calendar_grid_next'] = getCalendarGrid($context['calendar_grid_current']['next_calendar']['month'], $context['calendar_grid_current']['next_calendar']['year'], $calendarOptions); |
|
171 | + } |
|
162 | 172 | |
163 | 173 | // Basic template stuff. |
164 | 174 | $context['allow_calendar_event'] = allowedTo('calendar_post'); |
@@ -191,17 +201,19 @@ discard block |
||
191 | 201 | 'name' => $txt['months'][$context['current_month']] . ' ' . $context['current_year'] |
192 | 202 | ); |
193 | 203 | // If applicable, add the current week to the linktree. |
194 | - if ($context['view_week']) |
|
195 | - $context['linktree'][] = array( |
|
204 | + if ($context['view_week']) { |
|
205 | + $context['linktree'][] = array( |
|
196 | 206 | 'url' => $scripturl . '?action=calendar;viewweek;year=' . $context['current_year'] . ';month=' . $context['current_month'] . ';day=' . $context['current_day'], |
197 | 207 | 'name' => $context['calendar_grid_main']['week_title'], |
198 | 208 | ); |
209 | + } |
|
199 | 210 | |
200 | 211 | // Build the calendar button array. |
201 | 212 | $context['calendar_buttons'] = array(); |
202 | 213 | |
203 | - if ($context['can_post']) |
|
204 | - $context['calendar_buttons']['post_event'] = array('text' => 'calendar_post_event', 'image' => 'calendarpe.png', 'url' => $scripturl . '?action=calendar;sa=post;month=' . $context['current_month'] . ';year=' . $context['current_year'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
214 | + if ($context['can_post']) { |
|
215 | + $context['calendar_buttons']['post_event'] = array('text' => 'calendar_post_event', 'image' => 'calendarpe.png', 'url' => $scripturl . '?action=calendar;sa=post;month=' . $context['current_month'] . ';year=' . $context['current_year'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
216 | + } |
|
205 | 217 | |
206 | 218 | // Allow mods to add additional buttons here |
207 | 219 | call_integration_hook('integrate_calendar_buttons'); |
@@ -230,14 +242,16 @@ discard block |
||
230 | 242 | require_once($sourcedir . '/Subs.php'); |
231 | 243 | |
232 | 244 | // Cast this for safety... |
233 | - if (isset($_REQUEST['eventid'])) |
|
234 | - $_REQUEST['eventid'] = (int) $_REQUEST['eventid']; |
|
245 | + if (isset($_REQUEST['eventid'])) { |
|
246 | + $_REQUEST['eventid'] = (int) $_REQUEST['eventid']; |
|
247 | + } |
|
235 | 248 | |
236 | 249 | // We want a fairly compact version of the time, but as close as possible to the user's settings. |
237 | - if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
238 | - $time_string = '%k:%M'; |
|
239 | - else |
|
240 | - $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
250 | + if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
251 | + $time_string = '%k:%M'; |
|
252 | + } else { |
|
253 | + $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
254 | + } |
|
241 | 255 | |
242 | 256 | $js_time_string = str_replace( |
243 | 257 | array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
@@ -251,12 +265,14 @@ discard block |
||
251 | 265 | checkSession(); |
252 | 266 | |
253 | 267 | // Validate the post... |
254 | - if (!isset($_POST['link_to_board'])) |
|
255 | - validateEventPost(); |
|
268 | + if (!isset($_POST['link_to_board'])) { |
|
269 | + validateEventPost(); |
|
270 | + } |
|
256 | 271 | |
257 | 272 | // If you're not allowed to edit any events, you have to be the poster. |
258 | - if ($_REQUEST['eventid'] > 0 && !allowedTo('calendar_edit_any')) |
|
259 | - isAllowedTo('calendar_edit_' . (!empty($user_info['id']) && getEventPoster($_REQUEST['eventid']) == $user_info['id'] ? 'own' : 'any')); |
|
273 | + if ($_REQUEST['eventid'] > 0 && !allowedTo('calendar_edit_any')) { |
|
274 | + isAllowedTo('calendar_edit_' . (!empty($user_info['id']) && getEventPoster($_REQUEST['eventid']) == $user_info['id'] ? 'own' : 'any')); |
|
275 | + } |
|
260 | 276 | |
261 | 277 | // New - and directing? |
262 | 278 | if (isset($_POST['link_to_board']) || empty($modSettings['cal_allow_unlinked'])) |
@@ -279,8 +295,9 @@ discard block |
||
279 | 295 | } |
280 | 296 | |
281 | 297 | // Deleting... |
282 | - elseif (isset($_REQUEST['deleteevent'])) |
|
283 | - removeEvent($_REQUEST['eventid']); |
|
298 | + elseif (isset($_REQUEST['deleteevent'])) { |
|
299 | + removeEvent($_REQUEST['eventid']); |
|
300 | + } |
|
284 | 301 | |
285 | 302 | // ... or just update it? |
286 | 303 | else |
@@ -302,14 +319,12 @@ discard block |
||
302 | 319 | $d = date_parse($_POST['start_date']); |
303 | 320 | $year = $d['year']; |
304 | 321 | $month = $d['month']; |
305 | - } |
|
306 | - elseif (isset($_POST['start_datetime'])) |
|
322 | + } elseif (isset($_POST['start_datetime'])) |
|
307 | 323 | { |
308 | 324 | $d = date_parse($_POST['start_datetime']); |
309 | 325 | $year = $d['year']; |
310 | 326 | $month = $d['month']; |
311 | - } |
|
312 | - else |
|
327 | + } else |
|
313 | 328 | { |
314 | 329 | $today = getdate(); |
315 | 330 | $year = isset($_POST['year']) ? $_POST['year'] : $today['year']; |
@@ -342,13 +357,13 @@ discard block |
||
342 | 357 | $context['event'] = array_merge($context['event'], $eventDatetimes); |
343 | 358 | |
344 | 359 | $context['event']['last_day'] = (int) strftime('%d', mktime(0, 0, 0, $context['event']['month'] == 12 ? 1 : $context['event']['month'] + 1, 0, $context['event']['month'] == 12 ? $context['event']['year'] + 1 : $context['event']['year'])); |
345 | - } |
|
346 | - else |
|
360 | + } else |
|
347 | 361 | { |
348 | 362 | $context['event'] = getEventProperties($_REQUEST['eventid']); |
349 | 363 | |
350 | - if ($context['event'] === false) |
|
351 | - fatal_lang_error('no_access', false); |
|
364 | + if ($context['event'] === false) { |
|
365 | + fatal_lang_error('no_access', false); |
|
366 | + } |
|
352 | 367 | |
353 | 368 | // If it has a board, then they should be editing it within the topic. |
354 | 369 | if (!empty($context['event']['topic']['id']) && !empty($context['event']['topic']['first_msg'])) |
@@ -359,10 +374,11 @@ discard block |
||
359 | 374 | } |
360 | 375 | |
361 | 376 | // Make sure the user is allowed to edit this event. |
362 | - if ($context['event']['member'] != $user_info['id']) |
|
363 | - isAllowedTo('calendar_edit_any'); |
|
364 | - elseif (!allowedTo('calendar_edit_any')) |
|
365 | - isAllowedTo('calendar_edit_own'); |
|
377 | + if ($context['event']['member'] != $user_info['id']) { |
|
378 | + isAllowedTo('calendar_edit_any'); |
|
379 | + } elseif (!allowedTo('calendar_edit_any')) { |
|
380 | + isAllowedTo('calendar_edit_own'); |
|
381 | + } |
|
366 | 382 | } |
367 | 383 | |
368 | 384 | // An all day event? Set up some nice defaults in case the user wants to change that |
@@ -396,8 +412,7 @@ discard block |
||
396 | 412 | { |
397 | 413 | // You can post new events but can't link them to anything... |
398 | 414 | $context['event']['categories'] = array(); |
399 | - } |
|
400 | - else |
|
415 | + } else |
|
401 | 416 | { |
402 | 417 | // Load the list of boards and categories in the context. |
403 | 418 | require_once($sourcedir . '/Subs-MessageIndex.php'); |
@@ -484,12 +499,14 @@ discard block |
||
484 | 499 | global $smcFunc, $sourcedir, $forum_version, $modSettings, $webmaster_email, $mbname; |
485 | 500 | |
486 | 501 | // You can't export if the calendar export feature is off. |
487 | - if (empty($modSettings['cal_export'])) |
|
488 | - fatal_lang_error('calendar_export_off', false); |
|
502 | + if (empty($modSettings['cal_export'])) { |
|
503 | + fatal_lang_error('calendar_export_off', false); |
|
504 | + } |
|
489 | 505 | |
490 | 506 | // Goes without saying that this is required. |
491 | - if (!isset($_REQUEST['eventid'])) |
|
492 | - fatal_lang_error('no_access', false); |
|
507 | + if (!isset($_REQUEST['eventid'])) { |
|
508 | + fatal_lang_error('no_access', false); |
|
509 | + } |
|
493 | 510 | |
494 | 511 | // This is kinda wanted. |
495 | 512 | require_once($sourcedir . '/Subs-Calendar.php'); |
@@ -497,15 +514,17 @@ discard block |
||
497 | 514 | // Load up the event in question and check it exists. |
498 | 515 | $event = getEventProperties($_REQUEST['eventid']); |
499 | 516 | |
500 | - if ($event === false) |
|
501 | - fatal_lang_error('no_access', false); |
|
517 | + if ($event === false) { |
|
518 | + fatal_lang_error('no_access', false); |
|
519 | + } |
|
502 | 520 | |
503 | 521 | // Check the title isn't too long - iCal requires some formatting if so. |
504 | 522 | $title = str_split($event['title'], 30); |
505 | 523 | foreach ($title as $id => $line) |
506 | 524 | { |
507 | - if ($id != 0) |
|
508 | - $title[$id] = ' ' . $title[$id]; |
|
525 | + if ($id != 0) { |
|
526 | + $title[$id] = ' ' . $title[$id]; |
|
527 | + } |
|
509 | 528 | $title[$id] .= "\n"; |
510 | 529 | } |
511 | 530 | |
@@ -518,8 +537,7 @@ discard block |
||
518 | 537 | { |
519 | 538 | $datestart = date_format($start_date, 'Ymd\THis'); |
520 | 539 | $dateend = date_format($end_date, 'Ymd\THis'); |
521 | - } |
|
522 | - else |
|
540 | + } else |
|
523 | 541 | { |
524 | 542 | $datestart = date_format($start_date, 'Ymd'); |
525 | 543 | |
@@ -540,15 +558,18 @@ discard block |
||
540 | 558 | $filecontents .= 'DTSTART' . (!empty($event['start_time']) ? ';TZID=' . $event['tz'] : ';VALUE=DATE') . ':' . $datestart . "\n"; |
541 | 559 | |
542 | 560 | // event has a duration |
543 | - if ($event['start_iso_gmdate'] != $event['end_iso_gmdate']) |
|
544 | - $filecontents .= 'DTEND' . (!empty($event['end_time']) ? ';TZID=' . $event['tz'] : ';VALUE=DATE') . ':' . $dateend . "\n"; |
|
561 | + if ($event['start_iso_gmdate'] != $event['end_iso_gmdate']) { |
|
562 | + $filecontents .= 'DTEND' . (!empty($event['end_time']) ? ';TZID=' . $event['tz'] : ';VALUE=DATE') . ':' . $dateend . "\n"; |
|
563 | + } |
|
545 | 564 | |
546 | 565 | // event has changed? advance the sequence for this UID |
547 | - if ($event['sequence'] > 0) |
|
548 | - $filecontents .= 'SEQUENCE:' . $event['sequence'] . "\n"; |
|
566 | + if ($event['sequence'] > 0) { |
|
567 | + $filecontents .= 'SEQUENCE:' . $event['sequence'] . "\n"; |
|
568 | + } |
|
549 | 569 | |
550 | - if (!empty($event['location'])) |
|
551 | - $filecontents .= 'LOCATION:' . str_replace(',', '\,', $event['location']) . "\n"; |
|
570 | + if (!empty($event['location'])) { |
|
571 | + $filecontents .= 'LOCATION:' . str_replace(',', '\,', $event['location']) . "\n"; |
|
572 | + } |
|
552 | 573 | |
553 | 574 | $filecontents .= 'SUMMARY:' . implode('', $title); |
554 | 575 | $filecontents .= 'UID:' . $event['eventid'] . '@' . str_replace(' ', '-', $mbname) . "\n"; |
@@ -557,23 +578,26 @@ discard block |
||
557 | 578 | |
558 | 579 | // Send some standard headers. |
559 | 580 | ob_end_clean(); |
560 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
561 | - @ob_start('ob_gzhandler'); |
|
562 | - else |
|
563 | - ob_start(); |
|
581 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
582 | + @ob_start('ob_gzhandler'); |
|
583 | + } else { |
|
584 | + ob_start(); |
|
585 | + } |
|
564 | 586 | |
565 | 587 | // Send the file headers |
566 | 588 | header('Pragma: '); |
567 | 589 | header('Cache-Control: no-cache'); |
568 | - if (!isBrowser('gecko')) |
|
569 | - header('Content-Transfer-Encoding: binary'); |
|
590 | + if (!isBrowser('gecko')) { |
|
591 | + header('Content-Transfer-Encoding: binary'); |
|
592 | + } |
|
570 | 593 | header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT'); |
571 | 594 | header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . 'GMT'); |
572 | 595 | header('Accept-Ranges: bytes'); |
573 | 596 | header('Connection: close'); |
574 | 597 | header('Content-Disposition: attachment; filename="' . $event['title'] . '.ics"'); |
575 | - if (empty($modSettings['enableCompressedOutput'])) |
|
576 | - header('Content-Length: ' . $smcFunc['strlen']($filecontents)); |
|
598 | + if (empty($modSettings['enableCompressedOutput'])) { |
|
599 | + header('Content-Length: ' . $smcFunc['strlen']($filecontents)); |
|
600 | + } |
|
577 | 601 | |
578 | 602 | // This is a calendar item! |
579 | 603 | header('Content-Type: text/calendar'); |
@@ -612,20 +636,17 @@ discard block |
||
612 | 636 | $context['sub_template'] = 'bcd'; |
613 | 637 | $context['linktree'][] = array('url' => $scripturl . '?action=clock;bcd', 'name' => 'BCD'); |
614 | 638 | $context['clockicons'] = safe_unserialize(base64_decode('YTo2OntzOjI6ImgxIjthOjI6e2k6MDtpOjI7aToxO2k6MTt9czoyOiJoMiI7YTo0OntpOjA7aTo4O2k6MTtpOjQ7aToyO2k6MjtpOjM7aToxO31zOjI6Im0xIjthOjM6e2k6MDtpOjQ7aToxO2k6MjtpOjI7aToxO31zOjI6Im0yIjthOjQ6e2k6MDtpOjg7aToxO2k6NDtpOjI7aToyO2k6MztpOjE7fXM6MjoiczEiO2E6Mzp7aTowO2k6NDtpOjE7aToyO2k6MjtpOjE7fXM6MjoiczIiO2E6NDp7aTowO2k6ODtpOjE7aTo0O2k6MjtpOjI7aTozO2k6MTt9fQ==')); |
615 | - } |
|
616 | - elseif (!$omfg && !isset($_REQUEST['time'])) |
|
639 | + } elseif (!$omfg && !isset($_REQUEST['time'])) |
|
617 | 640 | { |
618 | 641 | $context['sub_template'] = 'hms'; |
619 | 642 | $context['linktree'][] = array('url' => $scripturl . '?action=clock', 'name' => 'Binary'); |
620 | 643 | $context['clockicons'] = safe_unserialize(base64_decode('YTozOntzOjE6ImgiO2E6NTp7aTowO2k6MTY7aToxO2k6ODtpOjI7aTo0O2k6MztpOjI7aTo0O2k6MTt9czoxOiJtIjthOjY6e2k6MDtpOjMyO2k6MTtpOjE2O2k6MjtpOjg7aTozO2k6NDtpOjQ7aToyO2k6NTtpOjE7fXM6MToicyI7YTo2OntpOjA7aTozMjtpOjE7aToxNjtpOjI7aTo4O2k6MztpOjQ7aTo0O2k6MjtpOjU7aToxO319')); |
621 | - } |
|
622 | - elseif ($omfg) |
|
644 | + } elseif ($omfg) |
|
623 | 645 | { |
624 | 646 | $context['sub_template'] = 'omfg'; |
625 | 647 | $context['linktree'][] = array('url' => $scripturl . '?action=clock;omfg', 'name' => 'OMFG'); |
626 | 648 | $context['clockicons'] = safe_unserialize(base64_decode('YTo2OntzOjQ6InllYXIiO2E6Nzp7aTowO2k6NjQ7aToxO2k6MzI7aToyO2k6MTY7aTozO2k6ODtpOjQ7aTo0O2k6NTtpOjI7aTo2O2k6MTt9czo1OiJtb250aCI7YTo0OntpOjA7aTo4O2k6MTtpOjQ7aToyO2k6MjtpOjM7aToxO31zOjM6ImRheSI7YTo1OntpOjA7aToxNjtpOjE7aTo4O2k6MjtpOjQ7aTozO2k6MjtpOjQ7aToxO31zOjQ6ImhvdXIiO2E6NTp7aTowO2k6MTY7aToxO2k6ODtpOjI7aTo0O2k6MztpOjI7aTo0O2k6MTt9czozOiJtaW4iO2E6Njp7aTowO2k6MzI7aToxO2k6MTY7aToyO2k6ODtpOjM7aTo0O2k6NDtpOjI7aTo1O2k6MTt9czozOiJzZWMiO2E6Njp7aTowO2k6MzI7aToxO2k6MTY7aToyO2k6ODtpOjM7aTo0O2k6NDtpOjI7aTo1O2k6MTt9fQ==')); |
627 | - } |
|
628 | - elseif (isset($_REQUEST['time'])) |
|
649 | + } elseif (isset($_REQUEST['time'])) |
|
629 | 650 | { |
630 | 651 | $context['sub_template'] = 'thetime'; |
631 | 652 | $time = getdate($_REQUEST['time'] == 'now' ? time() : (int) $_REQUEST['time']); |
@@ -685,12 +706,13 @@ discard block |
||
685 | 706 | ), |
686 | 707 | ); |
687 | 708 | |
688 | - foreach ($context['clockicons'] as $t => $vs) |
|
689 | - foreach ($vs as $v => $dumb) |
|
709 | + foreach ($context['clockicons'] as $t => $vs) { |
|
710 | + foreach ($vs as $v => $dumb) |
|
690 | 711 | { |
691 | 712 | if ($$t >= $v) |
692 | 713 | { |
693 | 714 | $$t -= $v; |
715 | + } |
|
694 | 716 | $context['clockicons'][$t][$v] = true; |
695 | 717 | } |
696 | 718 | } |
@@ -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 | * Maps the implementations in this file (smf_db_function_name) |
@@ -33,8 +34,8 @@ discard block |
||
33 | 34 | global $smcFunc, $mysql_set_mode; |
34 | 35 | |
35 | 36 | // Map some database specific functions, only do this once. |
36 | - if (!isset($smcFunc['db_fetch_assoc']) || $smcFunc['db_fetch_assoc'] != 'mysql_fetch_assoc') |
|
37 | - $smcFunc += array( |
|
37 | + if (!isset($smcFunc['db_fetch_assoc']) || $smcFunc['db_fetch_assoc'] != 'mysql_fetch_assoc') { |
|
38 | + $smcFunc += array( |
|
38 | 39 | 'db_query' => 'smf_db_query', |
39 | 40 | 'db_quote' => 'smf_db_quote', |
40 | 41 | 'db_fetch_assoc' => 'mysql_fetch_assoc', |
@@ -58,36 +59,42 @@ discard block |
||
58 | 59 | 'db_escape_wildcard_string' => 'smf_db_escape_wildcard_string', |
59 | 60 | 'db_is_resource' => 'is_resource', |
60 | 61 | ); |
62 | + } |
|
61 | 63 | |
62 | - if (!empty($db_options['port'])) |
|
63 | - $db_server .= ':' . $db_options['port']; |
|
64 | + if (!empty($db_options['port'])) { |
|
65 | + $db_server .= ':' . $db_options['port']; |
|
66 | + } |
|
64 | 67 | |
65 | 68 | $flags = 2; //#define CLIENT_FOUND_ROWS 2 /* Found instead of affected rows */ |
66 | 69 | |
67 | - if (!empty($db_options['persist'])) |
|
68 | - $connection = @mysql_pconnect($db_server, $db_user, $db_passwd, $flags); |
|
69 | - else |
|
70 | - $connection = @mysql_connect($db_server, $db_user, $db_passwd, false, $flags); |
|
70 | + if (!empty($db_options['persist'])) { |
|
71 | + $connection = @mysql_pconnect($db_server, $db_user, $db_passwd, $flags); |
|
72 | + } else { |
|
73 | + $connection = @mysql_connect($db_server, $db_user, $db_passwd, false, $flags); |
|
74 | + } |
|
71 | 75 | |
72 | 76 | // Something's wrong, show an error if its fatal (which we assume it is) |
73 | 77 | if (!$connection) |
74 | 78 | { |
75 | - if (!empty($db_options['non_fatal'])) |
|
76 | - return null; |
|
77 | - else |
|
78 | - display_db_error(); |
|
79 | + if (!empty($db_options['non_fatal'])) { |
|
80 | + return null; |
|
81 | + } else { |
|
82 | + display_db_error(); |
|
83 | + } |
|
79 | 84 | } |
80 | 85 | |
81 | 86 | // Select the database, unless told not to |
82 | - if (empty($db_options['dont_select_db']) && !@mysql_select_db($db_name, $connection) && empty($db_options['non_fatal'])) |
|
83 | - display_db_error(); |
|
87 | + if (empty($db_options['dont_select_db']) && !@mysql_select_db($db_name, $connection) && empty($db_options['non_fatal'])) { |
|
88 | + display_db_error(); |
|
89 | + } |
|
84 | 90 | |
85 | 91 | // This makes it possible to have SMF automatically change the sql_mode and autocommit if needed. |
86 | - if (isset($mysql_set_mode) && $mysql_set_mode === true) |
|
87 | - $smcFunc['db_query']('', 'SET sql_mode = \'\', AUTOCOMMIT = 1', |
|
92 | + if (isset($mysql_set_mode) && $mysql_set_mode === true) { |
|
93 | + $smcFunc['db_query']('', 'SET sql_mode = \'\', AUTOCOMMIT = 1', |
|
88 | 94 | array(), |
89 | 95 | false |
90 | 96 | ); |
97 | + } |
|
91 | 98 | |
92 | 99 | return $connection; |
93 | 100 | } |
@@ -134,37 +141,46 @@ discard block |
||
134 | 141 | list ($values, $connection) = $db_callback; |
135 | 142 | |
136 | 143 | // Connection gone??? This should *never* happen at this point, yet it does :'( |
137 | - if (!is_resource($connection)) |
|
138 | - display_db_error(); |
|
144 | + if (!is_resource($connection)) { |
|
145 | + display_db_error(); |
|
146 | + } |
|
139 | 147 | |
140 | - if ($matches[1] === 'db_prefix') |
|
141 | - return $db_prefix; |
|
148 | + if ($matches[1] === 'db_prefix') { |
|
149 | + return $db_prefix; |
|
150 | + } |
|
142 | 151 | |
143 | - if ($matches[1] === 'query_see_board') |
|
144 | - return $user_info['query_see_board']; |
|
152 | + if ($matches[1] === 'query_see_board') { |
|
153 | + return $user_info['query_see_board']; |
|
154 | + } |
|
145 | 155 | |
146 | - if ($matches[1] === 'query_wanna_see_board') |
|
147 | - return $user_info['query_wanna_see_board']; |
|
156 | + if ($matches[1] === 'query_wanna_see_board') { |
|
157 | + return $user_info['query_wanna_see_board']; |
|
158 | + } |
|
148 | 159 | |
149 | - if ($matches[1] === 'empty') |
|
150 | - return '\'\''; |
|
160 | + if ($matches[1] === 'empty') { |
|
161 | + return '\'\''; |
|
162 | + } |
|
151 | 163 | |
152 | - if (!isset($matches[2])) |
|
153 | - smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__); |
|
164 | + if (!isset($matches[2])) { |
|
165 | + smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__); |
|
166 | + } |
|
154 | 167 | |
155 | - if ($matches[1] === 'literal') |
|
156 | - return '\'' . mysql_real_escape_string($matches[2], $connection) . '\''; |
|
168 | + if ($matches[1] === 'literal') { |
|
169 | + return '\'' . mysql_real_escape_string($matches[2], $connection) . '\''; |
|
170 | + } |
|
157 | 171 | |
158 | - if (!isset($values[$matches[2]])) |
|
159 | - smf_db_error_backtrace('The database value you\'re trying to insert does not exist: ' . (isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($matches[2]) : htmlspecialchars($matches[2])), '', E_USER_ERROR, __FILE__, __LINE__); |
|
172 | + if (!isset($values[$matches[2]])) { |
|
173 | + smf_db_error_backtrace('The database value you\'re trying to insert does not exist: ' . (isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($matches[2]) : htmlspecialchars($matches[2])), '', E_USER_ERROR, __FILE__, __LINE__); |
|
174 | + } |
|
160 | 175 | |
161 | 176 | $replacement = $values[$matches[2]]; |
162 | 177 | |
163 | 178 | switch ($matches[1]) |
164 | 179 | { |
165 | 180 | case 'int': |
166 | - if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement) |
|
167 | - smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
181 | + if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement) { |
|
182 | + smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
183 | + } |
|
168 | 184 | return (string) (int) $replacement; |
169 | 185 | break; |
170 | 186 | |
@@ -176,56 +192,63 @@ discard block |
||
176 | 192 | case 'array_int': |
177 | 193 | if (is_array($replacement)) |
178 | 194 | { |
179 | - if (empty($replacement)) |
|
180 | - smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
195 | + if (empty($replacement)) { |
|
196 | + smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
197 | + } |
|
181 | 198 | |
182 | 199 | foreach ($replacement as $key => $value) |
183 | 200 | { |
184 | - if (!is_numeric($value) || (string) $value !== (string) (int) $value) |
|
185 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
201 | + if (!is_numeric($value) || (string) $value !== (string) (int) $value) { |
|
202 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
203 | + } |
|
186 | 204 | |
187 | 205 | $replacement[$key] = (string) (int) $value; |
188 | 206 | } |
189 | 207 | |
190 | 208 | return implode(', ', $replacement); |
209 | + } else { |
|
210 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
191 | 211 | } |
192 | - else |
|
193 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
194 | 212 | |
195 | 213 | break; |
196 | 214 | |
197 | 215 | case 'array_string': |
198 | 216 | if (is_array($replacement)) |
199 | 217 | { |
200 | - if (empty($replacement)) |
|
201 | - smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
218 | + if (empty($replacement)) { |
|
219 | + smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
220 | + } |
|
202 | 221 | |
203 | - foreach ($replacement as $key => $value) |
|
204 | - $replacement[$key] = sprintf('\'%1$s\'', mysql_real_escape_string($value, $connection)); |
|
222 | + foreach ($replacement as $key => $value) { |
|
223 | + $replacement[$key] = sprintf('\'%1$s\'', mysql_real_escape_string($value, $connection)); |
|
224 | + } |
|
205 | 225 | |
206 | 226 | return implode(', ', $replacement); |
227 | + } else { |
|
228 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
207 | 229 | } |
208 | - else |
|
209 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
210 | 230 | break; |
211 | 231 | |
212 | 232 | case 'date': |
213 | - if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) |
|
214 | - return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]); |
|
215 | - else |
|
216 | - smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
233 | + if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) { |
|
234 | + return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]); |
|
235 | + } else { |
|
236 | + smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
237 | + } |
|
217 | 238 | break; |
218 | 239 | |
219 | 240 | case 'time': |
220 | - if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1) |
|
221 | - return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]); |
|
222 | - else |
|
223 | - smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
241 | + if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1) { |
|
242 | + return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]); |
|
243 | + } else { |
|
244 | + smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
245 | + } |
|
224 | 246 | break; |
225 | 247 | |
226 | 248 | case 'float': |
227 | - if (!is_numeric($replacement)) |
|
228 | - smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
249 | + if (!is_numeric($replacement)) { |
|
250 | + smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
251 | + } |
|
229 | 252 | return (string) (float) $replacement; |
230 | 253 | break; |
231 | 254 | |
@@ -239,32 +262,37 @@ discard block |
||
239 | 262 | break; |
240 | 263 | |
241 | 264 | case 'inet': |
242 | - if ($replacement == 'null' || $replacement == '') |
|
243 | - return 'null'; |
|
244 | - if (!isValidIP($replacement)) |
|
245 | - smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
265 | + if ($replacement == 'null' || $replacement == '') { |
|
266 | + return 'null'; |
|
267 | + } |
|
268 | + if (!isValidIP($replacement)) { |
|
269 | + smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
270 | + } |
|
246 | 271 | //we don't use the native support of mysql > 5.6.2 |
247 | 272 | return sprintf('unhex(\'%1$s\')', bin2hex(inet_pton($replacement))); |
248 | 273 | |
249 | 274 | case 'array_inet': |
250 | 275 | if (is_array($replacement)) |
251 | 276 | { |
252 | - if (empty($replacement)) |
|
253 | - smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
277 | + if (empty($replacement)) { |
|
278 | + smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
279 | + } |
|
254 | 280 | |
255 | 281 | foreach ($replacement as $key => $value) |
256 | 282 | { |
257 | - if ($replacement == 'null' || $replacement == '') |
|
258 | - $replacement[$key] = 'null'; |
|
259 | - if (!isValidIP($value)) |
|
260 | - smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
283 | + if ($replacement == 'null' || $replacement == '') { |
|
284 | + $replacement[$key] = 'null'; |
|
285 | + } |
|
286 | + if (!isValidIP($value)) { |
|
287 | + smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
288 | + } |
|
261 | 289 | $replacement[$key] = sprintf('unhex(\'%1$s\')', bin2hex(inet_pton($value))); |
262 | 290 | } |
263 | 291 | |
264 | 292 | return implode(', ', $replacement); |
293 | + } else { |
|
294 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
265 | 295 | } |
266 | - else |
|
267 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
268 | 296 | break; |
269 | 297 | |
270 | 298 | default: |
@@ -335,18 +363,20 @@ discard block |
||
335 | 363 | // One more query.... |
336 | 364 | $db_count = !isset($db_count) ? 1 : $db_count + 1; |
337 | 365 | |
338 | - if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override'])) |
|
339 | - smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__); |
|
366 | + if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override'])) { |
|
367 | + smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__); |
|
368 | + } |
|
340 | 369 | |
341 | 370 | // Use "ORDER BY null" to prevent Mysql doing filesorts for Group By clauses without an Order By |
342 | 371 | if (strpos($db_string, 'GROUP BY') !== false && strpos($db_string, 'ORDER BY') === false && preg_match('~^\s+SELECT~i', $db_string)) |
343 | 372 | { |
344 | 373 | // Add before LIMIT |
345 | - if ($pos = strpos($db_string, 'LIMIT ')) |
|
346 | - $db_string = substr($db_string, 0, $pos) . "\t\t\tORDER BY null\n" . substr($db_string, $pos, strlen($db_string)); |
|
347 | - else |
|
348 | - // Append it. |
|
374 | + if ($pos = strpos($db_string, 'LIMIT ')) { |
|
375 | + $db_string = substr($db_string, 0, $pos) . "\t\t\tORDER BY null\n" . substr($db_string, $pos, strlen($db_string)); |
|
376 | + } else { |
|
377 | + // Append it. |
|
349 | 378 | $db_string .= "\n\t\t\tORDER BY null"; |
379 | + } |
|
350 | 380 | } |
351 | 381 | |
352 | 382 | if (empty($db_values['security_override']) && (!empty($db_values) || strpos($db_string, '{db_prefix}') !== false)) |
@@ -368,8 +398,9 @@ discard block |
||
368 | 398 | list ($file, $line) = smf_db_error_backtrace('', '', 'return', __FILE__, __LINE__); |
369 | 399 | |
370 | 400 | // Initialize $db_cache if not already initialized. |
371 | - if (!isset($db_cache)) |
|
372 | - $db_cache = array(); |
|
401 | + if (!isset($db_cache)) { |
|
402 | + $db_cache = array(); |
|
403 | + } |
|
373 | 404 | |
374 | 405 | if (!empty($_SESSION['debug_redirect'])) |
375 | 406 | { |
@@ -395,17 +426,18 @@ discard block |
||
395 | 426 | while (true) |
396 | 427 | { |
397 | 428 | $pos = strpos($db_string, '\'', $pos + 1); |
398 | - if ($pos === false) |
|
399 | - break; |
|
429 | + if ($pos === false) { |
|
430 | + break; |
|
431 | + } |
|
400 | 432 | $clean .= substr($db_string, $old_pos, $pos - $old_pos); |
401 | 433 | |
402 | 434 | while (true) |
403 | 435 | { |
404 | 436 | $pos1 = strpos($db_string, '\'', $pos + 1); |
405 | 437 | $pos2 = strpos($db_string, '\\', $pos + 1); |
406 | - if ($pos1 === false) |
|
407 | - break; |
|
408 | - elseif ($pos2 === false || $pos2 > $pos1) |
|
438 | + if ($pos1 === false) { |
|
439 | + break; |
|
440 | + } elseif ($pos2 === false || $pos2 > $pos1) |
|
409 | 441 | { |
410 | 442 | $pos = $pos1; |
411 | 443 | break; |
@@ -421,29 +453,35 @@ discard block |
||
421 | 453 | $clean = trim(strtolower(preg_replace($allowed_comments_from, $allowed_comments_to, $clean))); |
422 | 454 | |
423 | 455 | // Comments? We don't use comments in our queries, we leave 'em outside! |
424 | - if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false) |
|
425 | - $fail = true; |
|
456 | + if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false) { |
|
457 | + $fail = true; |
|
458 | + } |
|
426 | 459 | // Trying to change passwords, slow us down, or something? |
427 | - elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0) |
|
428 | - $fail = true; |
|
429 | - elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0) |
|
430 | - $fail = true; |
|
460 | + elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0) { |
|
461 | + $fail = true; |
|
462 | + } elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0) { |
|
463 | + $fail = true; |
|
464 | + } |
|
431 | 465 | |
432 | - if (!empty($fail) && function_exists('log_error')) |
|
433 | - smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__); |
|
466 | + if (!empty($fail) && function_exists('log_error')) { |
|
467 | + smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__); |
|
468 | + } |
|
434 | 469 | } |
435 | 470 | |
436 | - if (empty($db_unbuffered)) |
|
437 | - $ret = @mysql_query($db_string, $connection); |
|
438 | - else |
|
439 | - $ret = @mysql_unbuffered_query($db_string, $connection); |
|
471 | + if (empty($db_unbuffered)) { |
|
472 | + $ret = @mysql_query($db_string, $connection); |
|
473 | + } else { |
|
474 | + $ret = @mysql_unbuffered_query($db_string, $connection); |
|
475 | + } |
|
440 | 476 | |
441 | - if ($ret === false && empty($db_values['db_error_skip'])) |
|
442 | - $ret = smf_db_error($db_string, $connection); |
|
477 | + if ($ret === false && empty($db_values['db_error_skip'])) { |
|
478 | + $ret = smf_db_error($db_string, $connection); |
|
479 | + } |
|
443 | 480 | |
444 | 481 | // Debugging. |
445 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
446 | - $db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
482 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
483 | + $db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
484 | + } |
|
447 | 485 | |
448 | 486 | return $ret; |
449 | 487 | } |
@@ -492,12 +530,13 @@ discard block |
||
492 | 530 | // Decide which connection to use |
493 | 531 | $connection = $connection === null ? $db_connection : $connection; |
494 | 532 | |
495 | - if ($type == 'begin') |
|
496 | - return @mysql_query('BEGIN', $connection); |
|
497 | - elseif ($type == 'rollback') |
|
498 | - return @mysql_query('ROLLBACK', $connection); |
|
499 | - elseif ($type == 'commit') |
|
500 | - return @mysql_query('COMMIT', $connection); |
|
533 | + if ($type == 'begin') { |
|
534 | + return @mysql_query('BEGIN', $connection); |
|
535 | + } elseif ($type == 'rollback') { |
|
536 | + return @mysql_query('ROLLBACK', $connection); |
|
537 | + } elseif ($type == 'commit') { |
|
538 | + return @mysql_query('COMMIT', $connection); |
|
539 | + } |
|
501 | 540 | |
502 | 541 | return false; |
503 | 542 | } |
@@ -537,8 +576,9 @@ discard block |
||
537 | 576 | // 2013: Lost connection to server during query. |
538 | 577 | |
539 | 578 | // Log the error. |
540 | - if ($query_errno != 1213 && $query_errno != 1205 && function_exists('log_error')) |
|
541 | - log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n$db_string" : ''), 'database', $file, $line); |
|
579 | + if ($query_errno != 1213 && $query_errno != 1205 && function_exists('log_error')) { |
|
580 | + log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n$db_string" : ''), 'database', $file, $line); |
|
581 | + } |
|
542 | 582 | |
543 | 583 | // Database error auto fixing ;). |
544 | 584 | if (function_exists('cache_get_data') && (!isset($modSettings['autoFixDatabase']) || $modSettings['autoFixDatabase'] == '1')) |
@@ -547,8 +587,9 @@ discard block |
||
547 | 587 | $old_cache = @$modSettings['cache_enable']; |
548 | 588 | $modSettings['cache_enable'] = '1'; |
549 | 589 | |
550 | - if (($temp = cache_get_data('db_last_error', 600)) !== null) |
|
551 | - $db_last_error = max(@$db_last_error, $temp); |
|
590 | + if (($temp = cache_get_data('db_last_error', 600)) !== null) { |
|
591 | + $db_last_error = max(@$db_last_error, $temp); |
|
592 | + } |
|
552 | 593 | |
553 | 594 | if (@$db_last_error < time() - 3600 * 24 * 3) |
554 | 595 | { |
@@ -564,8 +605,9 @@ discard block |
||
564 | 605 | foreach ($tables as $table) |
565 | 606 | { |
566 | 607 | // Now, it's still theoretically possible this could be an injection. So backtick it! |
567 | - if (trim($table) != '') |
|
568 | - $fix_tables[] = '`' . strtr(trim($table), array('`' => '')) . '`'; |
|
608 | + if (trim($table) != '') { |
|
609 | + $fix_tables[] = '`' . strtr(trim($table), array('`' => '')) . '`'; |
|
610 | + } |
|
569 | 611 | } |
570 | 612 | } |
571 | 613 | |
@@ -574,8 +616,9 @@ discard block |
||
574 | 616 | // Table crashed. Let's try to fix it. |
575 | 617 | elseif ($query_errno == 1016) |
576 | 618 | { |
577 | - if (preg_match('~\'([^\.\']+)~', $query_error, $match) != 0) |
|
578 | - $fix_tables = array('`' . $match[1] . '`'); |
|
619 | + if (preg_match('~\'([^\.\']+)~', $query_error, $match) != 0) { |
|
620 | + $fix_tables = array('`' . $match[1] . '`'); |
|
621 | + } |
|
579 | 622 | } |
580 | 623 | // Indexes crashed. Should be easy to fix! |
581 | 624 | elseif ($query_errno == 1034 || $query_errno == 1035) |
@@ -594,13 +637,15 @@ discard block |
||
594 | 637 | |
595 | 638 | // Make a note of the REPAIR... |
596 | 639 | cache_put_data('db_last_error', time(), 600); |
597 | - if (($temp = cache_get_data('db_last_error', 600)) === null) |
|
598 | - updateSettingsFile(array('db_last_error' => time())); |
|
640 | + if (($temp = cache_get_data('db_last_error', 600)) === null) { |
|
641 | + updateSettingsFile(array('db_last_error' => time())); |
|
642 | + } |
|
599 | 643 | |
600 | 644 | // Attempt to find and repair the broken table. |
601 | - foreach ($fix_tables as $table) |
|
602 | - $smcFunc['db_query']('', " |
|
645 | + foreach ($fix_tables as $table) { |
|
646 | + $smcFunc['db_query']('', " |
|
603 | 647 | REPAIR TABLE $table", false, false); |
648 | + } |
|
604 | 649 | |
605 | 650 | // And send off an email! |
606 | 651 | sendmail($webmaster_email, $txt['database_error'], $txt['tried_to_repair'], null, 'dberror'); |
@@ -609,11 +654,12 @@ discard block |
||
609 | 654 | |
610 | 655 | // Try the query again...? |
611 | 656 | $ret = $smcFunc['db_query']('', $db_string, false, false); |
612 | - if ($ret !== false) |
|
613 | - return $ret; |
|
657 | + if ($ret !== false) { |
|
658 | + return $ret; |
|
659 | + } |
|
660 | + } else { |
|
661 | + $modSettings['cache_enable'] = $old_cache; |
|
614 | 662 | } |
615 | - else |
|
616 | - $modSettings['cache_enable'] = $old_cache; |
|
617 | 663 | |
618 | 664 | // Check for the "lost connection" or "deadlock found" errors - and try it just one more time. |
619 | 665 | if (in_array($query_errno, array(1205, 1213, 2006, 2013))) |
@@ -623,22 +669,25 @@ discard block |
||
623 | 669 | // Are we in SSI mode? If so try that username and password first |
624 | 670 | if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd)) |
625 | 671 | { |
626 | - if (empty($db_persist)) |
|
627 | - $db_connection = @mysql_connect($db_server, $ssi_db_user, $ssi_db_passwd); |
|
628 | - else |
|
629 | - $db_connection = @mysql_pconnect($db_server, $ssi_db_user, $ssi_db_passwd); |
|
672 | + if (empty($db_persist)) { |
|
673 | + $db_connection = @mysql_connect($db_server, $ssi_db_user, $ssi_db_passwd); |
|
674 | + } else { |
|
675 | + $db_connection = @mysql_pconnect($db_server, $ssi_db_user, $ssi_db_passwd); |
|
676 | + } |
|
630 | 677 | } |
631 | 678 | // Fall back to the regular username and password if need be |
632 | 679 | if (!$db_connection) |
633 | 680 | { |
634 | - if (empty($db_persist)) |
|
635 | - $db_connection = @mysql_connect($db_server, $db_user, $db_passwd); |
|
636 | - else |
|
637 | - $db_connection = @mysql_pconnect($db_server, $db_user, $db_passwd); |
|
681 | + if (empty($db_persist)) { |
|
682 | + $db_connection = @mysql_connect($db_server, $db_user, $db_passwd); |
|
683 | + } else { |
|
684 | + $db_connection = @mysql_pconnect($db_server, $db_user, $db_passwd); |
|
685 | + } |
|
638 | 686 | } |
639 | 687 | |
640 | - if (!$db_connection || !@mysql_select_db($db_name, $db_connection)) |
|
641 | - $db_connection = false; |
|
688 | + if (!$db_connection || !@mysql_select_db($db_name, $db_connection)) { |
|
689 | + $db_connection = false; |
|
690 | + } |
|
642 | 691 | } |
643 | 692 | |
644 | 693 | if ($db_connection) |
@@ -649,24 +698,27 @@ discard block |
||
649 | 698 | $ret = $smcFunc['db_query']('', $db_string, false, false); |
650 | 699 | |
651 | 700 | $new_errno = mysql_errno($db_connection); |
652 | - if ($ret !== false || in_array($new_errno, array(1205, 1213))) |
|
653 | - break; |
|
701 | + if ($ret !== false || in_array($new_errno, array(1205, 1213))) { |
|
702 | + break; |
|
703 | + } |
|
654 | 704 | } |
655 | 705 | |
656 | 706 | // If it failed again, shucks to be you... we're not trying it over and over. |
657 | - if ($ret !== false) |
|
658 | - return $ret; |
|
707 | + if ($ret !== false) { |
|
708 | + return $ret; |
|
709 | + } |
|
659 | 710 | } |
660 | 711 | } |
661 | 712 | // Are they out of space, perhaps? |
662 | 713 | elseif ($query_errno == 1030 && (strpos($query_error, ' -1 ') !== false || strpos($query_error, ' 28 ') !== false || strpos($query_error, ' 12 ') !== false)) |
663 | 714 | { |
664 | - if (!isset($txt)) |
|
665 | - $query_error .= ' - check database storage space.'; |
|
666 | - else |
|
715 | + if (!isset($txt)) { |
|
716 | + $query_error .= ' - check database storage space.'; |
|
717 | + } else |
|
667 | 718 | { |
668 | - if (!isset($txt['mysql_error_space'])) |
|
669 | - loadLanguage('Errors'); |
|
719 | + if (!isset($txt['mysql_error_space'])) { |
|
720 | + loadLanguage('Errors'); |
|
721 | + } |
|
670 | 722 | |
671 | 723 | $query_error .= !isset($txt['mysql_error_space']) ? ' - check database storage space.' : $txt['mysql_error_space']; |
672 | 724 | } |
@@ -674,15 +726,17 @@ discard block |
||
674 | 726 | } |
675 | 727 | |
676 | 728 | // Nothing's defined yet... just die with it. |
677 | - if (empty($context) || empty($txt)) |
|
678 | - die($query_error); |
|
729 | + if (empty($context) || empty($txt)) { |
|
730 | + die($query_error); |
|
731 | + } |
|
679 | 732 | |
680 | 733 | // Show an error message, if possible. |
681 | 734 | $context['error_title'] = $txt['database_error']; |
682 | - if (allowedTo('admin_forum')) |
|
683 | - $context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line; |
|
684 | - else |
|
685 | - $context['error_message'] = $txt['try_again']; |
|
735 | + if (allowedTo('admin_forum')) { |
|
736 | + $context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line; |
|
737 | + } else { |
|
738 | + $context['error_message'] = $txt['try_again']; |
|
739 | + } |
|
686 | 740 | |
687 | 741 | if (allowedTo('admin_forum') && isset($db_show_debug) && $db_show_debug === true) |
688 | 742 | { |
@@ -711,25 +765,28 @@ discard block |
||
711 | 765 | $connection = $connection === null ? $db_connection : $connection; |
712 | 766 | |
713 | 767 | // With nothing to insert, simply return. |
714 | - if (empty($data)) |
|
715 | - return; |
|
768 | + if (empty($data)) { |
|
769 | + return; |
|
770 | + } |
|
716 | 771 | |
717 | 772 | // Replace the prefix holder with the actual prefix. |
718 | 773 | $table = str_replace('{db_prefix}', $db_prefix, $table); |
719 | 774 | |
720 | 775 | // Inserting data as a single row can be done as a single array. |
721 | - if (!is_array($data[array_rand($data)])) |
|
722 | - $data = array($data); |
|
776 | + if (!is_array($data[array_rand($data)])) { |
|
777 | + $data = array($data); |
|
778 | + } |
|
723 | 779 | |
724 | 780 | // Create the mold for a single row insert. |
725 | 781 | $insertData = '('; |
726 | 782 | foreach ($columns as $columnName => $type) |
727 | 783 | { |
728 | 784 | // Are we restricting the length? |
729 | - if (strpos($type, 'string-') !== false) |
|
730 | - $insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName); |
|
731 | - else |
|
732 | - $insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName); |
|
785 | + if (strpos($type, 'string-') !== false) { |
|
786 | + $insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName); |
|
787 | + } else { |
|
788 | + $insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName); |
|
789 | + } |
|
733 | 790 | } |
734 | 791 | $insertData = substr($insertData, 0, -2) . ')'; |
735 | 792 | |
@@ -738,8 +795,9 @@ discard block |
||
738 | 795 | |
739 | 796 | // Here's where the variables are injected to the query. |
740 | 797 | $insertRows = array(); |
741 | - foreach ($data as $dataRow) |
|
742 | - $insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection); |
|
798 | + foreach ($data as $dataRow) { |
|
799 | + $insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection); |
|
800 | + } |
|
743 | 801 | |
744 | 802 | // Determine the method of insertion. |
745 | 803 | $queryTitle = $method == 'replace' ? 'REPLACE' : ($method == 'ignore' ? 'INSERT IGNORE' : 'INSERT'); |
@@ -770,8 +828,9 @@ discard block |
||
770 | 828 | */ |
771 | 829 | function smf_db_error_backtrace($error_message, $log_message = '', $error_type = false, $file = null, $line = null) |
772 | 830 | { |
773 | - if (empty($log_message)) |
|
774 | - $log_message = $error_message; |
|
831 | + if (empty($log_message)) { |
|
832 | + $log_message = $error_message; |
|
833 | + } |
|
775 | 834 | |
776 | 835 | foreach (debug_backtrace() as $step) |
777 | 836 | { |
@@ -790,12 +849,14 @@ discard block |
||
790 | 849 | } |
791 | 850 | |
792 | 851 | // A special case - we want the file and line numbers for debugging. |
793 | - if ($error_type == 'return') |
|
794 | - return array($file, $line); |
|
852 | + if ($error_type == 'return') { |
|
853 | + return array($file, $line); |
|
854 | + } |
|
795 | 855 | |
796 | 856 | // Is always a critical error. |
797 | - if (function_exists('log_error')) |
|
798 | - log_error($log_message, 'critical', $file, $line); |
|
857 | + if (function_exists('log_error')) { |
|
858 | + log_error($log_message, 'critical', $file, $line); |
|
859 | + } |
|
799 | 860 | |
800 | 861 | if (function_exists('fatal_error')) |
801 | 862 | { |
@@ -803,12 +864,12 @@ discard block |
||
803 | 864 | |
804 | 865 | // Cannot continue... |
805 | 866 | exit; |
867 | + } elseif ($error_type) { |
|
868 | + trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type); |
|
869 | + } else { |
|
870 | + trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : '')); |
|
871 | + } |
|
806 | 872 | } |
807 | - elseif ($error_type) |
|
808 | - trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type); |
|
809 | - else |
|
810 | - trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : '')); |
|
811 | -} |
|
812 | 873 | |
813 | 874 | /** |
814 | 875 | * Escape the LIKE wildcards so that they match the character and not the wildcard. |
@@ -825,10 +886,11 @@ discard block |
||
825 | 886 | '\\' => '\\\\', |
826 | 887 | ); |
827 | 888 | |
828 | - if ($translate_human_wildcards) |
|
829 | - $replacements += array( |
|
889 | + if ($translate_human_wildcards) { |
|
890 | + $replacements += array( |
|
830 | 891 | '*' => '%', |
831 | 892 | ); |
893 | + } |
|
832 | 894 | |
833 | 895 | return strtr($string, $replacements); |
834 | 896 | } |
@@ -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 | * Get all birthdays within the given time range. |
@@ -61,10 +62,11 @@ discard block |
||
61 | 62 | $bday = array(); |
62 | 63 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
63 | 64 | { |
64 | - if ($year_low != $year_high) |
|
65 | - $age_year = substr($row['birthdate'], 5) < substr($high_date, 5) ? $year_high : $year_low; |
|
66 | - else |
|
67 | - $age_year = $year_low; |
|
65 | + if ($year_low != $year_high) { |
|
66 | + $age_year = substr($row['birthdate'], 5) < substr($high_date, 5) ? $year_high : $year_low; |
|
67 | + } else { |
|
68 | + $age_year = $year_low; |
|
69 | + } |
|
68 | 70 | |
69 | 71 | $bday[$age_year . substr($row['birthdate'], 4)][] = array( |
70 | 72 | 'id' => $row['id_member'], |
@@ -76,8 +78,9 @@ discard block |
||
76 | 78 | $smcFunc['db_free_result']($result); |
77 | 79 | |
78 | 80 | // Set is_last, so the themes know when to stop placing separators. |
79 | - foreach ($bday as $mday => $array) |
|
80 | - $bday[$mday][count($array) - 1]['is_last'] = true; |
|
81 | + foreach ($bday as $mday => $array) { |
|
82 | + $bday[$mday][count($array) - 1]['is_last'] = true; |
|
83 | + } |
|
81 | 84 | |
82 | 85 | return $bday; |
83 | 86 | } |
@@ -125,8 +128,9 @@ discard block |
||
125 | 128 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
126 | 129 | { |
127 | 130 | // If the attached topic is not approved then for the moment pretend it doesn't exist |
128 | - if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved']) |
|
129 | - continue; |
|
131 | + if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved']) { |
|
132 | + continue; |
|
133 | + } |
|
130 | 134 | |
131 | 135 | // Force a censor of the title - as often these are used by others. |
132 | 136 | censorText($row['title'], $use_permissions ? false : true); |
@@ -137,8 +141,9 @@ discard block |
||
137 | 141 | list($start, $end, $allday, $span, $tz_abbrev) = buildEventDatetimes($row); |
138 | 142 | |
139 | 143 | // Sanity check |
140 | - if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) |
|
141 | - continue; |
|
144 | + if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) { |
|
145 | + continue; |
|
146 | + } |
|
142 | 147 | |
143 | 148 | // Get set up for the loop |
144 | 149 | $start_object = date_create($row['start_date'] . (!$allday ? ' ' . $row['start_time'] : ''), timezone_open($tz)); |
@@ -202,8 +207,8 @@ discard block |
||
202 | 207 | ); |
203 | 208 | |
204 | 209 | // If we're using permissions (calendar pages?) then just ouput normal contextual style information. |
205 | - if ($use_permissions) |
|
206 | - $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
210 | + if ($use_permissions) { |
|
211 | + $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
207 | 212 | 'href' => $row['id_board'] == 0 ? '' : $scripturl . '?topic=' . $row['id_topic'] . '.0', |
208 | 213 | 'link' => $row['id_board'] == 0 ? $row['title'] : '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['title'] . '</a>', |
209 | 214 | 'can_edit' => allowedTo('calendar_edit_any') || ($row['id_member'] == $user_info['id'] && allowedTo('calendar_edit_own')), |
@@ -211,9 +216,10 @@ discard block |
||
211 | 216 | 'can_export' => !empty($modSettings['cal_export']) ? true : false, |
212 | 217 | 'export_href' => $scripturl . '?action=calendar;sa=ical;eventid=' . $row['id_event'] . ';' . $context['session_var'] . '=' . $context['session_id'], |
213 | 218 | )); |
219 | + } |
|
214 | 220 | // Otherwise, this is going to be cached and the VIEWER'S permissions should apply... just put together some info. |
215 | - else |
|
216 | - $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
221 | + else { |
|
222 | + $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
217 | 223 | 'href' => $row['id_topic'] == 0 ? '' : $scripturl . '?topic=' . $row['id_topic'] . '.0', |
218 | 224 | 'link' => $row['id_topic'] == 0 ? $row['title'] : '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['title'] . '</a>', |
219 | 225 | 'can_edit' => false, |
@@ -223,6 +229,7 @@ discard block |
||
223 | 229 | 'poster' => $row['id_member'], |
224 | 230 | 'allowed_groups' => explode(',', $row['member_groups']), |
225 | 231 | )); |
232 | + } |
|
226 | 233 | |
227 | 234 | date_add($cal_date, date_interval_create_from_date_string('1 day')); |
228 | 235 | } |
@@ -232,8 +239,9 @@ discard block |
||
232 | 239 | // If we're doing normal contextual data, go through and make things clear to the templates ;). |
233 | 240 | if ($use_permissions) |
234 | 241 | { |
235 | - foreach ($events as $mday => $array) |
|
236 | - $events[$mday][count($array) - 1]['is_last'] = true; |
|
242 | + foreach ($events as $mday => $array) { |
|
243 | + $events[$mday][count($array) - 1]['is_last'] = true; |
|
244 | + } |
|
237 | 245 | } |
238 | 246 | |
239 | 247 | return $events; |
@@ -251,11 +259,12 @@ discard block |
||
251 | 259 | global $smcFunc; |
252 | 260 | |
253 | 261 | // Get the lowest and highest dates for "all years". |
254 | - if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) |
|
255 | - $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec} |
|
262 | + if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) { |
|
263 | + $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec} |
|
256 | 264 | OR event_date BETWEEN {date:all_year_jan} AND {date:all_year_high}'; |
257 | - else |
|
258 | - $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}'; |
|
265 | + } else { |
|
266 | + $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}'; |
|
267 | + } |
|
259 | 268 | |
260 | 269 | // Find some holidays... ;). |
261 | 270 | $result = $smcFunc['db_query']('', ' |
@@ -275,10 +284,11 @@ discard block |
||
275 | 284 | $holidays = array(); |
276 | 285 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
277 | 286 | { |
278 | - if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) |
|
279 | - $event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4); |
|
280 | - else |
|
281 | - $event_year = substr($low_date, 0, 4); |
|
287 | + if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) { |
|
288 | + $event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4); |
|
289 | + } else { |
|
290 | + $event_year = substr($low_date, 0, 4); |
|
291 | + } |
|
282 | 292 | |
283 | 293 | $holidays[$event_year . substr($row['event_date'], 4)][] = $row['title']; |
284 | 294 | } |
@@ -302,10 +312,12 @@ discard block |
||
302 | 312 | isAllowedTo('calendar_post'); |
303 | 313 | |
304 | 314 | // No board? No topic?!? |
305 | - if (empty($board)) |
|
306 | - fatal_lang_error('missing_board_id', false); |
|
307 | - if (empty($topic)) |
|
308 | - fatal_lang_error('missing_topic_id', false); |
|
315 | + if (empty($board)) { |
|
316 | + fatal_lang_error('missing_board_id', false); |
|
317 | + } |
|
318 | + if (empty($topic)) { |
|
319 | + fatal_lang_error('missing_topic_id', false); |
|
320 | + } |
|
309 | 321 | |
310 | 322 | // Administrator, Moderator, or owner. Period. |
311 | 323 | if (!allowedTo('admin_forum') && !allowedTo('moderate_board')) |
@@ -323,12 +335,14 @@ discard block |
||
323 | 335 | if ($row = $smcFunc['db_fetch_assoc']($result)) |
324 | 336 | { |
325 | 337 | // Not the owner of the topic. |
326 | - if ($row['id_member_started'] != $user_info['id']) |
|
327 | - fatal_lang_error('not_your_topic', 'user'); |
|
338 | + if ($row['id_member_started'] != $user_info['id']) { |
|
339 | + fatal_lang_error('not_your_topic', 'user'); |
|
340 | + } |
|
328 | 341 | } |
329 | 342 | // Topic/Board doesn't exist..... |
330 | - else |
|
331 | - fatal_lang_error('calendar_no_topic', 'general'); |
|
343 | + else { |
|
344 | + fatal_lang_error('calendar_no_topic', 'general'); |
|
345 | + } |
|
332 | 346 | $smcFunc['db_free_result']($result); |
333 | 347 | } |
334 | 348 | } |
@@ -416,14 +430,16 @@ discard block |
||
416 | 430 | if (!empty($calendarOptions['start_day'])) |
417 | 431 | { |
418 | 432 | $nShift -= $calendarOptions['start_day']; |
419 | - if ($nShift < 0) |
|
420 | - $nShift = 7 + $nShift; |
|
433 | + if ($nShift < 0) { |
|
434 | + $nShift = 7 + $nShift; |
|
435 | + } |
|
421 | 436 | } |
422 | 437 | |
423 | 438 | // Number of rows required to fit the month. |
424 | 439 | $nRows = floor(($month_info['last_day']['day_of_month'] + $nShift) / 7); |
425 | - if (($month_info['last_day']['day_of_month'] + $nShift) % 7) |
|
426 | - $nRows++; |
|
440 | + if (($month_info['last_day']['day_of_month'] + $nShift) % 7) { |
|
441 | + $nRows++; |
|
442 | + } |
|
427 | 443 | |
428 | 444 | // Fetch the arrays for birthdays, posted events, and holidays. |
429 | 445 | $bday = $calendarOptions['show_birthdays'] ? getBirthdayRange($month_info['first_day']['date'], $month_info['last_day']['date']) : array(); |
@@ -436,8 +452,9 @@ discard block |
||
436 | 452 | { |
437 | 453 | $calendarGrid['week_days'][] = $count; |
438 | 454 | $count++; |
439 | - if ($count == 7) |
|
440 | - $count = 0; |
|
455 | + if ($count == 7) { |
|
456 | + $count = 0; |
|
457 | + } |
|
441 | 458 | } |
442 | 459 | |
443 | 460 | // Iterate through each week. |
@@ -454,8 +471,9 @@ discard block |
||
454 | 471 | { |
455 | 472 | $nDay = ($nRow * 7) + $nCol - $nShift + 1; |
456 | 473 | |
457 | - if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month']) |
|
458 | - $nDay = 0; |
|
474 | + if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month']) { |
|
475 | + $nDay = 0; |
|
476 | + } |
|
459 | 477 | |
460 | 478 | $date = sprintf('%04d-%02d-%02d', $year, $month, $nDay); |
461 | 479 | |
@@ -473,8 +491,9 @@ discard block |
||
473 | 491 | } |
474 | 492 | |
475 | 493 | // What is the last day of the month? |
476 | - if ($is_previous === true) |
|
477 | - $calendarGrid['last_of_month'] = $month_info['last_day']['day_of_month']; |
|
494 | + if ($is_previous === true) { |
|
495 | + $calendarGrid['last_of_month'] = $month_info['last_day']['day_of_month']; |
|
496 | + } |
|
478 | 497 | |
479 | 498 | // We'll use the shift in the template. |
480 | 499 | $calendarGrid['shift'] = $nShift; |
@@ -508,8 +527,9 @@ discard block |
||
508 | 527 | { |
509 | 528 | // Here we offset accordingly to get things to the real start of a week. |
510 | 529 | $date_diff = $day_of_week - $calendarOptions['start_day']; |
511 | - if ($date_diff < 0) |
|
512 | - $date_diff += 7; |
|
530 | + if ($date_diff < 0) { |
|
531 | + $date_diff += 7; |
|
532 | + } |
|
513 | 533 | $new_timestamp = mktime(0, 0, 0, $month, $day, $year) - $date_diff * 86400; |
514 | 534 | $day = (int) strftime('%d', $new_timestamp); |
515 | 535 | $month = (int) strftime('%m', $new_timestamp); |
@@ -660,8 +680,9 @@ discard block |
||
660 | 680 | // Holidays between now and now + days. |
661 | 681 | for ($i = $now; $i < $now + $days_for_index; $i += 86400) |
662 | 682 | { |
663 | - if (isset($cached_data['holidays'][strftime('%Y-%m-%d', $i)])) |
|
664 | - $return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][strftime('%Y-%m-%d', $i)]); |
|
683 | + if (isset($cached_data['holidays'][strftime('%Y-%m-%d', $i)])) { |
|
684 | + $return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][strftime('%Y-%m-%d', $i)]); |
|
685 | + } |
|
665 | 686 | } |
666 | 687 | |
667 | 688 | // Happy Birthday, guys and gals! |
@@ -670,8 +691,9 @@ discard block |
||
670 | 691 | $loop_date = strftime('%Y-%m-%d', $i); |
671 | 692 | if (isset($cached_data['birthdays'][$loop_date])) |
672 | 693 | { |
673 | - foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy) |
|
674 | - $cached_data['birthdays'][strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date']; |
|
694 | + foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy) { |
|
695 | + $cached_data['birthdays'][strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date']; |
|
696 | + } |
|
675 | 697 | $return_data['calendar_birthdays'] = array_merge($return_data['calendar_birthdays'], $cached_data['birthdays'][$loop_date]); |
676 | 698 | } |
677 | 699 | } |
@@ -683,8 +705,9 @@ discard block |
||
683 | 705 | $loop_date = strftime('%Y-%m-%d', $i); |
684 | 706 | |
685 | 707 | // No events today? Check the next day. |
686 | - if (empty($cached_data['events'][$loop_date])) |
|
687 | - continue; |
|
708 | + if (empty($cached_data['events'][$loop_date])) { |
|
709 | + continue; |
|
710 | + } |
|
688 | 711 | |
689 | 712 | // Loop through all events to add a few last-minute values. |
690 | 713 | foreach ($cached_data['events'][$loop_date] as $ev => $event) |
@@ -697,9 +720,9 @@ discard block |
||
697 | 720 | { |
698 | 721 | unset($cached_data['events'][$loop_date][$ev]); |
699 | 722 | continue; |
723 | + } else { |
|
724 | + $duplicates[$this_event['topic'] . $this_event['title']] = true; |
|
700 | 725 | } |
701 | - else |
|
702 | - $duplicates[$this_event['topic'] . $this_event['title']] = true; |
|
703 | 726 | |
704 | 727 | // Might be set to true afterwards, depending on the permissions. |
705 | 728 | $this_event['can_edit'] = false; |
@@ -707,15 +730,18 @@ discard block |
||
707 | 730 | $this_event['date'] = $loop_date; |
708 | 731 | } |
709 | 732 | |
710 | - if (!empty($cached_data['events'][$loop_date])) |
|
711 | - $return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]); |
|
733 | + if (!empty($cached_data['events'][$loop_date])) { |
|
734 | + $return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]); |
|
735 | + } |
|
712 | 736 | } |
713 | 737 | |
714 | 738 | // Mark the last item so that a list separator can be used in the template. |
715 | - for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++) |
|
716 | - $return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]); |
|
717 | - for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++) |
|
718 | - $return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]); |
|
739 | + for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++) { |
|
740 | + $return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]); |
|
741 | + } |
|
742 | + for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++) { |
|
743 | + $return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]); |
|
744 | + } |
|
719 | 745 | |
720 | 746 | return array( |
721 | 747 | 'data' => $return_data, |
@@ -763,37 +789,46 @@ discard block |
||
763 | 789 | if (isset($_POST['start_date'])) |
764 | 790 | { |
765 | 791 | $d = date_parse($_POST['start_date']); |
766 | - if (!empty($d['error_count']) || !empty($d['warning_count'])) |
|
767 | - fatal_lang_error('invalid_date', false); |
|
768 | - if (empty($d['year'])) |
|
769 | - fatal_lang_error('event_year_missing', false); |
|
770 | - if (empty($d['month'])) |
|
771 | - fatal_lang_error('event_month_missing', false); |
|
772 | - } |
|
773 | - elseif (isset($_POST['start_datetime'])) |
|
792 | + if (!empty($d['error_count']) || !empty($d['warning_count'])) { |
|
793 | + fatal_lang_error('invalid_date', false); |
|
794 | + } |
|
795 | + if (empty($d['year'])) { |
|
796 | + fatal_lang_error('event_year_missing', false); |
|
797 | + } |
|
798 | + if (empty($d['month'])) { |
|
799 | + fatal_lang_error('event_month_missing', false); |
|
800 | + } |
|
801 | + } elseif (isset($_POST['start_datetime'])) |
|
774 | 802 | { |
775 | 803 | $d = date_parse($_POST['start_datetime']); |
776 | - if (!empty($d['error_count']) || !empty($d['warning_count'])) |
|
777 | - fatal_lang_error('invalid_date', false); |
|
778 | - if (empty($d['year'])) |
|
779 | - fatal_lang_error('event_year_missing', false); |
|
780 | - if (empty($d['month'])) |
|
781 | - fatal_lang_error('event_month_missing', false); |
|
804 | + if (!empty($d['error_count']) || !empty($d['warning_count'])) { |
|
805 | + fatal_lang_error('invalid_date', false); |
|
806 | + } |
|
807 | + if (empty($d['year'])) { |
|
808 | + fatal_lang_error('event_year_missing', false); |
|
809 | + } |
|
810 | + if (empty($d['month'])) { |
|
811 | + fatal_lang_error('event_month_missing', false); |
|
812 | + } |
|
782 | 813 | } |
783 | 814 | // The 2.0 way |
784 | 815 | else |
785 | 816 | { |
786 | 817 | // No month? No year? |
787 | - if (!isset($_POST['month'])) |
|
788 | - fatal_lang_error('event_month_missing', false); |
|
789 | - if (!isset($_POST['year'])) |
|
790 | - fatal_lang_error('event_year_missing', false); |
|
818 | + if (!isset($_POST['month'])) { |
|
819 | + fatal_lang_error('event_month_missing', false); |
|
820 | + } |
|
821 | + if (!isset($_POST['year'])) { |
|
822 | + fatal_lang_error('event_year_missing', false); |
|
823 | + } |
|
791 | 824 | |
792 | 825 | // Check the month and year... |
793 | - if ($_POST['month'] < 1 || $_POST['month'] > 12) |
|
794 | - fatal_lang_error('invalid_month', false); |
|
795 | - if ($_POST['year'] < $modSettings['cal_minyear'] || $_POST['year'] > $modSettings['cal_maxyear']) |
|
796 | - fatal_lang_error('invalid_year', false); |
|
826 | + if ($_POST['month'] < 1 || $_POST['month'] > 12) { |
|
827 | + fatal_lang_error('invalid_month', false); |
|
828 | + } |
|
829 | + if ($_POST['year'] < $modSettings['cal_minyear'] || $_POST['year'] > $modSettings['cal_maxyear']) { |
|
830 | + fatal_lang_error('invalid_year', false); |
|
831 | + } |
|
797 | 832 | } |
798 | 833 | } |
799 | 834 | |
@@ -803,8 +838,9 @@ discard block |
||
803 | 838 | // If they want to us to calculate an end date, make sure it will fit in an acceptable range. |
804 | 839 | if (isset($_POST['span'])) |
805 | 840 | { |
806 | - if (($_POST['span'] < 1) || (!empty($modSettings['cal_maxspan']) && $_POST['span'] > $modSettings['cal_maxspan'])) |
|
807 | - fatal_lang_error('invalid_days_numb', false); |
|
841 | + if (($_POST['span'] < 1) || (!empty($modSettings['cal_maxspan']) && $_POST['span'] > $modSettings['cal_maxspan'])) { |
|
842 | + fatal_lang_error('invalid_days_numb', false); |
|
843 | + } |
|
808 | 844 | } |
809 | 845 | |
810 | 846 | // There is no need to validate the following values if we are just deleting the event. |
@@ -814,24 +850,29 @@ discard block |
||
814 | 850 | if (empty($_POST['start_date']) && empty($_POST['start_datetime'])) |
815 | 851 | { |
816 | 852 | // No day? |
817 | - if (!isset($_POST['day'])) |
|
818 | - fatal_lang_error('event_day_missing', false); |
|
853 | + if (!isset($_POST['day'])) { |
|
854 | + fatal_lang_error('event_day_missing', false); |
|
855 | + } |
|
819 | 856 | |
820 | 857 | // Bad day? |
821 | - if (!checkdate($_POST['month'], $_POST['day'], $_POST['year'])) |
|
822 | - fatal_lang_error('invalid_date', false); |
|
858 | + if (!checkdate($_POST['month'], $_POST['day'], $_POST['year'])) { |
|
859 | + fatal_lang_error('invalid_date', false); |
|
860 | + } |
|
823 | 861 | } |
824 | 862 | |
825 | - if (!isset($_POST['evtitle']) && !isset($_POST['subject'])) |
|
826 | - fatal_lang_error('event_title_missing', false); |
|
827 | - elseif (!isset($_POST['evtitle'])) |
|
828 | - $_POST['evtitle'] = $_POST['subject']; |
|
863 | + if (!isset($_POST['evtitle']) && !isset($_POST['subject'])) { |
|
864 | + fatal_lang_error('event_title_missing', false); |
|
865 | + } elseif (!isset($_POST['evtitle'])) { |
|
866 | + $_POST['evtitle'] = $_POST['subject']; |
|
867 | + } |
|
829 | 868 | |
830 | 869 | // No title? |
831 | - if ($smcFunc['htmltrim']($_POST['evtitle']) === '') |
|
832 | - fatal_lang_error('no_event_title', false); |
|
833 | - if ($smcFunc['strlen']($_POST['evtitle']) > 100) |
|
834 | - $_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100); |
|
870 | + if ($smcFunc['htmltrim']($_POST['evtitle']) === '') { |
|
871 | + fatal_lang_error('no_event_title', false); |
|
872 | + } |
|
873 | + if ($smcFunc['strlen']($_POST['evtitle']) > 100) { |
|
874 | + $_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100); |
|
875 | + } |
|
835 | 876 | $_POST['evtitle'] = str_replace(';', '', $_POST['evtitle']); |
836 | 877 | } |
837 | 878 | } |
@@ -858,8 +899,9 @@ discard block |
||
858 | 899 | ); |
859 | 900 | |
860 | 901 | // No results, return false. |
861 | - if ($smcFunc['db_num_rows'] === 0) |
|
862 | - return false; |
|
902 | + if ($smcFunc['db_num_rows'] === 0) { |
|
903 | + return false; |
|
904 | + } |
|
863 | 905 | |
864 | 906 | // Grab the results and return. |
865 | 907 | list ($poster) = $smcFunc['db_fetch_row']($request); |
@@ -995,8 +1037,9 @@ discard block |
||
995 | 1037 | call_integration_hook('integrate_modify_event', array($event_id, &$eventOptions, &$event_columns, &$event_parameters)); |
996 | 1038 | |
997 | 1039 | $column_clauses = array(); |
998 | - foreach ($event_columns as $col => $crit) |
|
999 | - $column_clauses[] = $col . ' = ' . $crit; |
|
1040 | + foreach ($event_columns as $col => $crit) { |
|
1041 | + $column_clauses[] = $col . ' = ' . $crit; |
|
1042 | + } |
|
1000 | 1043 | |
1001 | 1044 | $smcFunc['db_query']('', ' |
1002 | 1045 | UPDATE {db_prefix}calendar |
@@ -1081,8 +1124,9 @@ discard block |
||
1081 | 1124 | ); |
1082 | 1125 | |
1083 | 1126 | // If nothing returned, we are in poo, poo. |
1084 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
1085 | - return false; |
|
1127 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
1128 | + return false; |
|
1129 | + } |
|
1086 | 1130 | |
1087 | 1131 | $row = $smcFunc['db_fetch_assoc']($request); |
1088 | 1132 | $smcFunc['db_free_result']($request); |
@@ -1090,8 +1134,9 @@ discard block |
||
1090 | 1134 | list($start, $end, $allday, $span, $tz_abbrev) = buildEventDatetimes($row); |
1091 | 1135 | |
1092 | 1136 | // Sanity check |
1093 | - if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) |
|
1094 | - return false; |
|
1137 | + if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) { |
|
1138 | + return false; |
|
1139 | + } |
|
1095 | 1140 | |
1096 | 1141 | $return_value = array( |
1097 | 1142 | 'boards' => array(), |
@@ -1161,10 +1206,11 @@ discard block |
||
1161 | 1206 | $allday = isset($_REQUEST['allday']) ? 1 : (isset($_REQUEST['start_time']) ? 0 : 1); |
1162 | 1207 | $span = isset($_REQUEST['span']) && filter_var($_REQUEST['span'], FILTER_VALIDATE_INT, array('options' => array('min_range' => 0))) ? $_REQUEST['span'] : 1; |
1163 | 1208 | |
1164 | - if (!empty($_REQUEST['tz']) && in_array($_REQUEST['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
1165 | - $tz = $_REQUEST['tz']; |
|
1166 | - else |
|
1167 | - $tz = getUserTimezone(); |
|
1209 | + if (!empty($_REQUEST['tz']) && in_array($_REQUEST['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
1210 | + $tz = $_REQUEST['tz']; |
|
1211 | + } else { |
|
1212 | + $tz = getUserTimezone(); |
|
1213 | + } |
|
1168 | 1214 | |
1169 | 1215 | // Was the input given as individual parameters? |
1170 | 1216 | $start_year = isset($_REQUEST['year']) ? $_REQUEST['year'] : $today['year']; |
@@ -1275,24 +1321,27 @@ discard block |
||
1275 | 1321 | |
1276 | 1322 | // Set $span, in case we need it |
1277 | 1323 | $span = isset($eventOptions['span']) ? $eventOptions['span'] : (isset($_POST['span']) ? $_POST['span'] : 0); |
1278 | - if ($span > 0) |
|
1279 | - $span = !empty($modSettings['cal_maxspan']) ? min($modSettings['cal_maxspan'], $span - 1) : $span - 1; |
|
1324 | + if ($span > 0) { |
|
1325 | + $span = !empty($modSettings['cal_maxspan']) ? min($modSettings['cal_maxspan'], $span - 1) : $span - 1; |
|
1326 | + } |
|
1280 | 1327 | |
1281 | 1328 | // Define the timezone for this event, falling back to the default if not provided |
1282 | - if (!empty($eventOptions['tz']) && in_array($eventOptions['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
1283 | - $tz = $eventOptions['tz']; |
|
1284 | - elseif (!empty($_POST['tz']) && in_array($_POST['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
1285 | - $tz = $_POST['tz']; |
|
1286 | - else |
|
1287 | - $tz = getUserTimezone(); |
|
1329 | + if (!empty($eventOptions['tz']) && in_array($eventOptions['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
1330 | + $tz = $eventOptions['tz']; |
|
1331 | + } elseif (!empty($_POST['tz']) && in_array($_POST['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
1332 | + $tz = $_POST['tz']; |
|
1333 | + } else { |
|
1334 | + $tz = getUserTimezone(); |
|
1335 | + } |
|
1288 | 1336 | |
1289 | 1337 | // Is this supposed to be an all day event, or should it have specific start and end times? |
1290 | - if (isset($eventOptions['allday'])) |
|
1291 | - $allday = $eventOptions['allday']; |
|
1292 | - elseif (empty($_POST['allday'])) |
|
1293 | - $allday = false; |
|
1294 | - else |
|
1295 | - $allday = true; |
|
1338 | + if (isset($eventOptions['allday'])) { |
|
1339 | + $allday = $eventOptions['allday']; |
|
1340 | + } elseif (empty($_POST['allday'])) { |
|
1341 | + $allday = false; |
|
1342 | + } else { |
|
1343 | + $allday = true; |
|
1344 | + } |
|
1296 | 1345 | |
1297 | 1346 | // Input might come as individual parameters... |
1298 | 1347 | $start_year = isset($eventOptions['year']) ? $eventOptions['year'] : (isset($_POST['year']) ? $_POST['year'] : null); |
@@ -1319,10 +1368,12 @@ discard block |
||
1319 | 1368 | $end_time_string = isset($eventOptions['end_time']) ? $eventOptions['end_time'] : (isset($_POST['end_time']) ? $_POST['end_time'] : null); |
1320 | 1369 | |
1321 | 1370 | // If the date and time were given in separate strings, combine them |
1322 | - if (empty($start_string) && isset($start_date_string)) |
|
1323 | - $start_string = $start_date_string . (isset($start_time_string) ? ' ' . $start_time_string : ''); |
|
1324 | - if (empty($end_string) && isset($end_date_string)) |
|
1325 | - $end_string = $end_date_string . (isset($end_time_string) ? ' ' . $end_time_string : ''); |
|
1371 | + if (empty($start_string) && isset($start_date_string)) { |
|
1372 | + $start_string = $start_date_string . (isset($start_time_string) ? ' ' . $start_time_string : ''); |
|
1373 | + } |
|
1374 | + if (empty($end_string) && isset($end_date_string)) { |
|
1375 | + $end_string = $end_date_string . (isset($end_time_string) ? ' ' . $end_time_string : ''); |
|
1376 | + } |
|
1326 | 1377 | |
1327 | 1378 | // If some form of string input was given, override individually defined options with it |
1328 | 1379 | if (isset($start_string)) |
@@ -1413,10 +1464,11 @@ discard block |
||
1413 | 1464 | if ($start_object >= $end_object) |
1414 | 1465 | { |
1415 | 1466 | $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, $start_hour, $start_minute, $start_second) . ' ' . $tz); |
1416 | - if ($span > 0) |
|
1417 | - date_add($end_object, date_interval_create_from_date_string($span . ' days')); |
|
1418 | - else |
|
1419 | - date_add($end_object, date_interval_create_from_date_string('1 hour')); |
|
1467 | + if ($span > 0) { |
|
1468 | + date_add($end_object, date_interval_create_from_date_string($span . ' days')); |
|
1469 | + } else { |
|
1470 | + date_add($end_object, date_interval_create_from_date_string('1 hour')); |
|
1471 | + } |
|
1420 | 1472 | } |
1421 | 1473 | |
1422 | 1474 | // Is $end_object too late? |
@@ -1430,9 +1482,9 @@ discard block |
||
1430 | 1482 | { |
1431 | 1483 | $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, $start_hour, $start_minute, $start_second) . ' ' . $tz); |
1432 | 1484 | date_add($end_object, date_interval_create_from_date_string($modSettings['cal_maxspan'] . ' days')); |
1485 | + } else { |
|
1486 | + $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, '11', '59', '59') . ' ' . $tz); |
|
1433 | 1487 | } |
1434 | - else |
|
1435 | - $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, '11', '59', '59') . ' ' . $tz); |
|
1436 | 1488 | } |
1437 | 1489 | } |
1438 | 1490 | |
@@ -1445,8 +1497,7 @@ discard block |
||
1445 | 1497 | $start_time = null; |
1446 | 1498 | $end_time = null; |
1447 | 1499 | $tz = null; |
1448 | - } |
|
1449 | - else |
|
1500 | + } else |
|
1450 | 1501 | { |
1451 | 1502 | $start_time = date_format($start_object, 'H:i:s'); |
1452 | 1503 | $end_time = date_format($end_object, 'H:i:s'); |
@@ -1469,19 +1520,22 @@ discard block |
||
1469 | 1520 | require_once($sourcedir . '/Subs.php'); |
1470 | 1521 | |
1471 | 1522 | // First, try to create a better date format, ignoring the "time" elements. |
1472 | - if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
1473 | - $date_format = '%F'; |
|
1474 | - else |
|
1475 | - $date_format = $matches[0]; |
|
1523 | + if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
1524 | + $date_format = '%F'; |
|
1525 | + } else { |
|
1526 | + $date_format = $matches[0]; |
|
1527 | + } |
|
1476 | 1528 | |
1477 | - if (empty($row['timezone'])) |
|
1478 | - $row['timezone'] = getUserTimezone(); |
|
1529 | + if (empty($row['timezone'])) { |
|
1530 | + $row['timezone'] = getUserTimezone(); |
|
1531 | + } |
|
1479 | 1532 | |
1480 | 1533 | // We want a fairly compact version of the time, but as close as possible to the user's settings. |
1481 | - if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
1482 | - $time_format = '%k:%M'; |
|
1483 | - else |
|
1484 | - $time_format = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
1534 | + if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
1535 | + $time_format = '%k:%M'; |
|
1536 | + } else { |
|
1537 | + $time_format = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
1538 | + } |
|
1485 | 1539 | |
1486 | 1540 | $allday = (empty($row['start_time']) || empty($row['end_time']) || empty($row['timezone']) || !in_array($row['timezone'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) ? true : false; |
1487 | 1541 | |
@@ -1527,8 +1581,9 @@ discard block |
||
1527 | 1581 | { |
1528 | 1582 | global $smcFunc, $context, $sourcedir, $user_info; |
1529 | 1583 | |
1530 | - if (is_null($id_member) && $user_info['is_guest'] == false) |
|
1531 | - $id_member = $context['user']['id']; |
|
1584 | + if (is_null($id_member) && $user_info['is_guest'] == false) { |
|
1585 | + $id_member = $context['user']['id']; |
|
1586 | + } |
|
1532 | 1587 | |
1533 | 1588 | if (isset($id_member)) |
1534 | 1589 | { |
@@ -1544,8 +1599,9 @@ discard block |
||
1544 | 1599 | $smcFunc['db_free_result']($request); |
1545 | 1600 | } |
1546 | 1601 | |
1547 | - if (empty($timezone) || !in_array($timezone, timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
1548 | - $timezone = isset($modSettings['default_timezone']) ? $modSettings['default_timezone'] : date_default_timezone_get(); |
|
1602 | + if (empty($timezone) || !in_array($timezone, timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
1603 | + $timezone = isset($modSettings['default_timezone']) ? $modSettings['default_timezone'] : date_default_timezone_get(); |
|
1604 | + } |
|
1549 | 1605 | |
1550 | 1606 | return $timezone; |
1551 | 1607 | } |
@@ -1574,8 +1630,9 @@ discard block |
||
1574 | 1630 | ) |
1575 | 1631 | ); |
1576 | 1632 | $holidays = array(); |
1577 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1578 | - $holidays[] = $row; |
|
1633 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1634 | + $holidays[] = $row; |
|
1635 | + } |
|
1579 | 1636 | $smcFunc['db_free_result']($request); |
1580 | 1637 | |
1581 | 1638 | return $holidays; |