@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 3 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('Hacking attempt...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * SQLite Cache API class |
@@ -153,8 +154,7 @@ discard block |
||
153 | 154 | if (is_null($dir) || !is_writable($dir)) |
154 | 155 | { |
155 | 156 | $this->cachedir = $cachedir_sqlite; |
156 | - } |
|
157 | - else |
|
157 | + } else |
|
158 | 158 | { |
159 | 159 | $this->cachedir = $dir; |
160 | 160 | } |
@@ -63,26 +63,31 @@ discard block |
||
63 | 63 | */ |
64 | 64 | public function checkRequest() |
65 | 65 | { |
66 | - if (!$this->enabled) |
|
67 | - return false; |
|
66 | + if (!$this->enabled) { |
|
67 | + return false; |
|
68 | + } |
|
68 | 69 | |
69 | 70 | // Try to create the image cache directory if it doesn't exist |
70 | - if (!file_exists($this->cache)) |
|
71 | - if (!mkdir($this->cache) || !copy(dirname($this->cache) . '/index.php', $this->cache . '/index.php')) |
|
71 | + if (!file_exists($this->cache)) { |
|
72 | + if (!mkdir($this->cache) || !copy(dirname($this->cache) . '/index.php', $this->cache . '/index.php')) |
|
72 | 73 | return false; |
74 | + } |
|
73 | 75 | |
74 | - if (empty($_GET['hash']) || empty($_GET['request'])) |
|
75 | - return false; |
|
76 | + if (empty($_GET['hash']) || empty($_GET['request'])) { |
|
77 | + return false; |
|
78 | + } |
|
76 | 79 | |
77 | 80 | $hash = $_GET['hash']; |
78 | 81 | $request = $_GET['request']; |
79 | 82 | |
80 | - if (md5($request . $this->secret) != $hash) |
|
81 | - return false; |
|
83 | + if (md5($request . $this->secret) != $hash) { |
|
84 | + return false; |
|
85 | + } |
|
82 | 86 | |
83 | 87 | // Attempt to cache the request if it doesn't exist |
84 | - if (!$this->isCached($request)) |
|
85 | - return $this->cacheImage($request); |
|
88 | + if (!$this->isCached($request)) { |
|
89 | + return $this->cacheImage($request); |
|
90 | + } |
|
86 | 91 | |
87 | 92 | return true; |
88 | 93 | } |
@@ -103,19 +108,22 @@ discard block |
||
103 | 108 | if (!$cached || time() - $cached['time'] > (5 * 86400)) |
104 | 109 | { |
105 | 110 | @unlink($cached_file); |
106 | - if ($this->checkRequest()) |
|
107 | - $this->serve(); |
|
111 | + if ($this->checkRequest()) { |
|
112 | + $this->serve(); |
|
113 | + } |
|
108 | 114 | redirectexit($request); |
109 | 115 | } |
110 | 116 | |
111 | 117 | // Right, image not cached? Simply redirect, then. |
112 | - if (!$this->checkRequest()) |
|
113 | - redirectexit($request); |
|
118 | + if (!$this->checkRequest()) { |
|
119 | + redirectexit($request); |
|
120 | + } |
|
114 | 121 | |
115 | 122 | // Make sure we're serving an image |
116 | 123 | $contentParts = explode('/', !empty($cached['content_type']) ? $cached['content_type'] : ''); |
117 | - if ($contentParts[0] != 'image') |
|
118 | - exit; |
|
124 | + if ($contentParts[0] != 'image') { |
|
125 | + exit; |
|
126 | + } |
|
119 | 127 | |
120 | 128 | header('Content-type: ' . $cached['content_type']); |
121 | 129 | header('Content-length: ' . $cached['size']); |
@@ -161,19 +169,22 @@ discard block |
||
161 | 169 | $request = $curl->get_url_data($request); |
162 | 170 | $response = $request->result(); |
163 | 171 | |
164 | - if (empty($response)) |
|
165 | - return false; |
|
172 | + if (empty($response)) { |
|
173 | + return false; |
|
174 | + } |
|
166 | 175 | |
167 | 176 | $headers = $response['headers']; |
168 | 177 | |
169 | 178 | // Make sure the url is returning an image |
170 | 179 | $contentParts = explode('/', !empty($headers['content-type']) ? $headers['content-type'] : ''); |
171 | - if ($contentParts[0] != 'image') |
|
172 | - return false; |
|
180 | + if ($contentParts[0] != 'image') { |
|
181 | + return false; |
|
182 | + } |
|
173 | 183 | |
174 | 184 | // Validate the filesize |
175 | - if ($response['size'] > ($this->maxSize * 1024)) |
|
176 | - return false; |
|
185 | + if ($response['size'] > ($this->maxSize * 1024)) { |
|
186 | + return false; |
|
187 | + } |
|
177 | 188 | |
178 | 189 | return file_put_contents($dest, json_encode(array( |
179 | 190 | 'content_type' => $headers['content-type'], |
@@ -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'], |
@@ -78,8 +80,9 @@ discard block |
||
78 | 80 | ksort($bday); |
79 | 81 | |
80 | 82 | // Set is_last, so the themes know when to stop placing separators. |
81 | - foreach ($bday as $mday => $array) |
|
82 | - $bday[$mday][count($array) - 1]['is_last'] = true; |
|
83 | + foreach ($bday as $mday => $array) { |
|
84 | + $bday[$mday][count($array) - 1]['is_last'] = true; |
|
85 | + } |
|
83 | 86 | |
84 | 87 | return $bday; |
85 | 88 | } |
@@ -127,8 +130,9 @@ discard block |
||
127 | 130 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
128 | 131 | { |
129 | 132 | // If the attached topic is not approved then for the moment pretend it doesn't exist |
130 | - if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved']) |
|
131 | - continue; |
|
133 | + if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved']) { |
|
134 | + continue; |
|
135 | + } |
|
132 | 136 | |
133 | 137 | // Force a censor of the title - as often these are used by others. |
134 | 138 | censorText($row['title'], $use_permissions ? false : true); |
@@ -137,8 +141,9 @@ discard block |
||
137 | 141 | list($start, $end, $allday, $span, $tz, $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 | ksort($events); |
@@ -253,11 +261,12 @@ discard block |
||
253 | 261 | global $smcFunc; |
254 | 262 | |
255 | 263 | // Get the lowest and highest dates for "all years". |
256 | - if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) |
|
257 | - $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec} |
|
264 | + if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) { |
|
265 | + $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec} |
|
258 | 266 | OR event_date BETWEEN {date:all_year_jan} AND {date:all_year_high}'; |
259 | - else |
|
260 | - $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}'; |
|
267 | + } else { |
|
268 | + $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}'; |
|
269 | + } |
|
261 | 270 | |
262 | 271 | // Find some holidays... ;). |
263 | 272 | $result = $smcFunc['db_query']('', ' |
@@ -277,10 +286,11 @@ discard block |
||
277 | 286 | $holidays = array(); |
278 | 287 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
279 | 288 | { |
280 | - if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) |
|
281 | - $event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4); |
|
282 | - else |
|
283 | - $event_year = substr($low_date, 0, 4); |
|
289 | + if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) { |
|
290 | + $event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4); |
|
291 | + } else { |
|
292 | + $event_year = substr($low_date, 0, 4); |
|
293 | + } |
|
284 | 294 | |
285 | 295 | $holidays[$event_year . substr($row['event_date'], 4)][] = $row['title']; |
286 | 296 | } |
@@ -306,10 +316,12 @@ discard block |
||
306 | 316 | isAllowedTo('calendar_post'); |
307 | 317 | |
308 | 318 | // No board? No topic?!? |
309 | - if (empty($board)) |
|
310 | - fatal_lang_error('missing_board_id', false); |
|
311 | - if (empty($topic)) |
|
312 | - fatal_lang_error('missing_topic_id', false); |
|
319 | + if (empty($board)) { |
|
320 | + fatal_lang_error('missing_board_id', false); |
|
321 | + } |
|
322 | + if (empty($topic)) { |
|
323 | + fatal_lang_error('missing_topic_id', false); |
|
324 | + } |
|
313 | 325 | |
314 | 326 | // Administrator, Moderator, or owner. Period. |
315 | 327 | if (!allowedTo('admin_forum') && !allowedTo('moderate_board')) |
@@ -327,12 +339,14 @@ discard block |
||
327 | 339 | if ($row = $smcFunc['db_fetch_assoc']($result)) |
328 | 340 | { |
329 | 341 | // Not the owner of the topic. |
330 | - if ($row['id_member_started'] != $user_info['id']) |
|
331 | - fatal_lang_error('not_your_topic', 'user'); |
|
342 | + if ($row['id_member_started'] != $user_info['id']) { |
|
343 | + fatal_lang_error('not_your_topic', 'user'); |
|
344 | + } |
|
332 | 345 | } |
333 | 346 | // Topic/Board doesn't exist..... |
334 | - else |
|
335 | - fatal_lang_error('calendar_no_topic', 'general'); |
|
347 | + else { |
|
348 | + fatal_lang_error('calendar_no_topic', 'general'); |
|
349 | + } |
|
336 | 350 | $smcFunc['db_free_result']($result); |
337 | 351 | } |
338 | 352 | } |
@@ -420,14 +434,16 @@ discard block |
||
420 | 434 | if (!empty($calendarOptions['start_day'])) |
421 | 435 | { |
422 | 436 | $nShift -= $calendarOptions['start_day']; |
423 | - if ($nShift < 0) |
|
424 | - $nShift = 7 + $nShift; |
|
437 | + if ($nShift < 0) { |
|
438 | + $nShift = 7 + $nShift; |
|
439 | + } |
|
425 | 440 | } |
426 | 441 | |
427 | 442 | // Number of rows required to fit the month. |
428 | 443 | $nRows = floor(($month_info['last_day']['day_of_month'] + $nShift) / 7); |
429 | - if (($month_info['last_day']['day_of_month'] + $nShift) % 7) |
|
430 | - $nRows++; |
|
444 | + if (($month_info['last_day']['day_of_month'] + $nShift) % 7) { |
|
445 | + $nRows++; |
|
446 | + } |
|
431 | 447 | |
432 | 448 | // Fetch the arrays for birthdays, posted events, and holidays. |
433 | 449 | $bday = $calendarOptions['show_birthdays'] ? getBirthdayRange($month_info['first_day']['date'], $month_info['last_day']['date']) : array(); |
@@ -440,8 +456,9 @@ discard block |
||
440 | 456 | { |
441 | 457 | $calendarGrid['week_days'][] = $count; |
442 | 458 | $count++; |
443 | - if ($count == 7) |
|
444 | - $count = 0; |
|
459 | + if ($count == 7) { |
|
460 | + $count = 0; |
|
461 | + } |
|
445 | 462 | } |
446 | 463 | |
447 | 464 | // Iterate through each week. |
@@ -458,8 +475,9 @@ discard block |
||
458 | 475 | { |
459 | 476 | $nDay = ($nRow * 7) + $nCol - $nShift + 1; |
460 | 477 | |
461 | - if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month']) |
|
462 | - $nDay = 0; |
|
478 | + if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month']) { |
|
479 | + $nDay = 0; |
|
480 | + } |
|
463 | 481 | |
464 | 482 | $date = sprintf('%04d-%02d-%02d', $year, $month, $nDay); |
465 | 483 | |
@@ -477,8 +495,9 @@ discard block |
||
477 | 495 | } |
478 | 496 | |
479 | 497 | // What is the last day of the month? |
480 | - if ($is_previous === true) |
|
481 | - $calendarGrid['last_of_month'] = $month_info['last_day']['day_of_month']; |
|
498 | + if ($is_previous === true) { |
|
499 | + $calendarGrid['last_of_month'] = $month_info['last_day']['day_of_month']; |
|
500 | + } |
|
482 | 501 | |
483 | 502 | // We'll use the shift in the template. |
484 | 503 | $calendarGrid['shift'] = $nShift; |
@@ -512,8 +531,9 @@ discard block |
||
512 | 531 | { |
513 | 532 | // Here we offset accordingly to get things to the real start of a week. |
514 | 533 | $date_diff = $day_of_week - $calendarOptions['start_day']; |
515 | - if ($date_diff < 0) |
|
516 | - $date_diff += 7; |
|
534 | + if ($date_diff < 0) { |
|
535 | + $date_diff += 7; |
|
536 | + } |
|
517 | 537 | $new_timestamp = mktime(0, 0, 0, $month, $day, $year) - $date_diff * 86400; |
518 | 538 | $day = (int) strftime('%d', $new_timestamp); |
519 | 539 | $month = (int) strftime('%m', $new_timestamp); |
@@ -643,18 +663,20 @@ discard block |
||
643 | 663 | { |
644 | 664 | foreach ($date_events as $event_key => $event_val) |
645 | 665 | { |
646 | - if (in_array($event_val['id'], $temp)) |
|
647 | - unset($calendarGrid['events'][$date][$event_key]); |
|
648 | - else |
|
649 | - $temp[] = $event_val['id']; |
|
666 | + if (in_array($event_val['id'], $temp)) { |
|
667 | + unset($calendarGrid['events'][$date][$event_key]); |
|
668 | + } else { |
|
669 | + $temp[] = $event_val['id']; |
|
670 | + } |
|
650 | 671 | } |
651 | 672 | } |
652 | 673 | |
653 | 674 | // Give birthdays and holidays a friendly format, without the year |
654 | - if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
655 | - $date_format = '%b %d'; |
|
656 | - else |
|
657 | - $date_format = str_replace(array('%Y', '%y', '%G', '%g', '%C', '%c', '%D'), array('', '', '', '', '', '%b %d', '%m/%d'), $matches[0]); |
|
675 | + if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
676 | + $date_format = '%b %d'; |
|
677 | + } else { |
|
678 | + $date_format = str_replace(array('%Y', '%y', '%G', '%g', '%C', '%c', '%D'), array('', '', '', '', '', '%b %d', '%m/%d'), $matches[0]); |
|
679 | + } |
|
658 | 680 | |
659 | 681 | foreach (array('birthdays', 'holidays') as $type) |
660 | 682 | { |
@@ -762,8 +784,9 @@ discard block |
||
762 | 784 | // Holidays between now and now + days. |
763 | 785 | for ($i = $now; $i < $now + $days_for_index; $i += 86400) |
764 | 786 | { |
765 | - if (isset($cached_data['holidays'][strftime('%Y-%m-%d', $i)])) |
|
766 | - $return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][strftime('%Y-%m-%d', $i)]); |
|
787 | + if (isset($cached_data['holidays'][strftime('%Y-%m-%d', $i)])) { |
|
788 | + $return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][strftime('%Y-%m-%d', $i)]); |
|
789 | + } |
|
767 | 790 | } |
768 | 791 | |
769 | 792 | // Happy Birthday, guys and gals! |
@@ -772,8 +795,9 @@ discard block |
||
772 | 795 | $loop_date = strftime('%Y-%m-%d', $i); |
773 | 796 | if (isset($cached_data['birthdays'][$loop_date])) |
774 | 797 | { |
775 | - foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy) |
|
776 | - $cached_data['birthdays'][strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date']; |
|
798 | + foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy) { |
|
799 | + $cached_data['birthdays'][strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date']; |
|
800 | + } |
|
777 | 801 | $return_data['calendar_birthdays'] = array_merge($return_data['calendar_birthdays'], $cached_data['birthdays'][$loop_date]); |
778 | 802 | } |
779 | 803 | } |
@@ -785,8 +809,9 @@ discard block |
||
785 | 809 | $loop_date = strftime('%Y-%m-%d', $i); |
786 | 810 | |
787 | 811 | // No events today? Check the next day. |
788 | - if (empty($cached_data['events'][$loop_date])) |
|
789 | - continue; |
|
812 | + if (empty($cached_data['events'][$loop_date])) { |
|
813 | + continue; |
|
814 | + } |
|
790 | 815 | |
791 | 816 | // Loop through all events to add a few last-minute values. |
792 | 817 | foreach ($cached_data['events'][$loop_date] as $ev => $event) |
@@ -799,9 +824,9 @@ discard block |
||
799 | 824 | { |
800 | 825 | unset($cached_data['events'][$loop_date][$ev]); |
801 | 826 | continue; |
827 | + } else { |
|
828 | + $duplicates[$this_event['topic'] . $this_event['title']] = true; |
|
802 | 829 | } |
803 | - else |
|
804 | - $duplicates[$this_event['topic'] . $this_event['title']] = true; |
|
805 | 830 | |
806 | 831 | // Might be set to true afterwards, depending on the permissions. |
807 | 832 | $this_event['can_edit'] = false; |
@@ -809,15 +834,18 @@ discard block |
||
809 | 834 | $this_event['date'] = $loop_date; |
810 | 835 | } |
811 | 836 | |
812 | - if (!empty($cached_data['events'][$loop_date])) |
|
813 | - $return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]); |
|
837 | + if (!empty($cached_data['events'][$loop_date])) { |
|
838 | + $return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]); |
|
839 | + } |
|
814 | 840 | } |
815 | 841 | |
816 | 842 | // Mark the last item so that a list separator can be used in the template. |
817 | - for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++) |
|
818 | - $return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]); |
|
819 | - for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++) |
|
820 | - $return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]); |
|
843 | + for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++) { |
|
844 | + $return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]); |
|
845 | + } |
|
846 | + for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++) { |
|
847 | + $return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]); |
|
848 | + } |
|
821 | 849 | |
822 | 850 | return array( |
823 | 851 | 'data' => $return_data, |
@@ -865,37 +893,46 @@ discard block |
||
865 | 893 | if (isset($_POST['start_date'])) |
866 | 894 | { |
867 | 895 | $d = date_parse($_POST['start_date']); |
868 | - if (!empty($d['error_count']) || !empty($d['warning_count'])) |
|
869 | - fatal_lang_error('invalid_date', false); |
|
870 | - if (empty($d['year'])) |
|
871 | - fatal_lang_error('event_year_missing', false); |
|
872 | - if (empty($d['month'])) |
|
873 | - fatal_lang_error('event_month_missing', false); |
|
874 | - } |
|
875 | - elseif (isset($_POST['start_datetime'])) |
|
896 | + if (!empty($d['error_count']) || !empty($d['warning_count'])) { |
|
897 | + fatal_lang_error('invalid_date', false); |
|
898 | + } |
|
899 | + if (empty($d['year'])) { |
|
900 | + fatal_lang_error('event_year_missing', false); |
|
901 | + } |
|
902 | + if (empty($d['month'])) { |
|
903 | + fatal_lang_error('event_month_missing', false); |
|
904 | + } |
|
905 | + } elseif (isset($_POST['start_datetime'])) |
|
876 | 906 | { |
877 | 907 | $d = date_parse($_POST['start_datetime']); |
878 | - if (!empty($d['error_count']) || !empty($d['warning_count'])) |
|
879 | - fatal_lang_error('invalid_date', false); |
|
880 | - if (empty($d['year'])) |
|
881 | - fatal_lang_error('event_year_missing', false); |
|
882 | - if (empty($d['month'])) |
|
883 | - fatal_lang_error('event_month_missing', false); |
|
908 | + if (!empty($d['error_count']) || !empty($d['warning_count'])) { |
|
909 | + fatal_lang_error('invalid_date', false); |
|
910 | + } |
|
911 | + if (empty($d['year'])) { |
|
912 | + fatal_lang_error('event_year_missing', false); |
|
913 | + } |
|
914 | + if (empty($d['month'])) { |
|
915 | + fatal_lang_error('event_month_missing', false); |
|
916 | + } |
|
884 | 917 | } |
885 | 918 | // The 2.0 way |
886 | 919 | else |
887 | 920 | { |
888 | 921 | // No month? No year? |
889 | - if (!isset($_POST['month'])) |
|
890 | - fatal_lang_error('event_month_missing', false); |
|
891 | - if (!isset($_POST['year'])) |
|
892 | - fatal_lang_error('event_year_missing', false); |
|
922 | + if (!isset($_POST['month'])) { |
|
923 | + fatal_lang_error('event_month_missing', false); |
|
924 | + } |
|
925 | + if (!isset($_POST['year'])) { |
|
926 | + fatal_lang_error('event_year_missing', false); |
|
927 | + } |
|
893 | 928 | |
894 | 929 | // Check the month and year... |
895 | - if ($_POST['month'] < 1 || $_POST['month'] > 12) |
|
896 | - fatal_lang_error('invalid_month', false); |
|
897 | - if ($_POST['year'] < $modSettings['cal_minyear'] || $_POST['year'] > $modSettings['cal_maxyear']) |
|
898 | - fatal_lang_error('invalid_year', false); |
|
930 | + if ($_POST['month'] < 1 || $_POST['month'] > 12) { |
|
931 | + fatal_lang_error('invalid_month', false); |
|
932 | + } |
|
933 | + if ($_POST['year'] < $modSettings['cal_minyear'] || $_POST['year'] > $modSettings['cal_maxyear']) { |
|
934 | + fatal_lang_error('invalid_year', false); |
|
935 | + } |
|
899 | 936 | } |
900 | 937 | } |
901 | 938 | |
@@ -905,8 +942,9 @@ discard block |
||
905 | 942 | // If they want to us to calculate an end date, make sure it will fit in an acceptable range. |
906 | 943 | if (isset($_POST['span'])) |
907 | 944 | { |
908 | - if (($_POST['span'] < 1) || (!empty($modSettings['cal_maxspan']) && $_POST['span'] > $modSettings['cal_maxspan'])) |
|
909 | - fatal_lang_error('invalid_days_numb', false); |
|
945 | + if (($_POST['span'] < 1) || (!empty($modSettings['cal_maxspan']) && $_POST['span'] > $modSettings['cal_maxspan'])) { |
|
946 | + fatal_lang_error('invalid_days_numb', false); |
|
947 | + } |
|
910 | 948 | } |
911 | 949 | |
912 | 950 | // There is no need to validate the following values if we are just deleting the event. |
@@ -916,24 +954,29 @@ discard block |
||
916 | 954 | if (empty($_POST['start_date']) && empty($_POST['start_datetime'])) |
917 | 955 | { |
918 | 956 | // No day? |
919 | - if (!isset($_POST['day'])) |
|
920 | - fatal_lang_error('event_day_missing', false); |
|
957 | + if (!isset($_POST['day'])) { |
|
958 | + fatal_lang_error('event_day_missing', false); |
|
959 | + } |
|
921 | 960 | |
922 | 961 | // Bad day? |
923 | - if (!checkdate($_POST['month'], $_POST['day'], $_POST['year'])) |
|
924 | - fatal_lang_error('invalid_date', false); |
|
962 | + if (!checkdate($_POST['month'], $_POST['day'], $_POST['year'])) { |
|
963 | + fatal_lang_error('invalid_date', false); |
|
964 | + } |
|
925 | 965 | } |
926 | 966 | |
927 | - if (!isset($_POST['evtitle']) && !isset($_POST['subject'])) |
|
928 | - fatal_lang_error('event_title_missing', false); |
|
929 | - elseif (!isset($_POST['evtitle'])) |
|
930 | - $_POST['evtitle'] = $_POST['subject']; |
|
967 | + if (!isset($_POST['evtitle']) && !isset($_POST['subject'])) { |
|
968 | + fatal_lang_error('event_title_missing', false); |
|
969 | + } elseif (!isset($_POST['evtitle'])) { |
|
970 | + $_POST['evtitle'] = $_POST['subject']; |
|
971 | + } |
|
931 | 972 | |
932 | 973 | // No title? |
933 | - if ($smcFunc['htmltrim']($_POST['evtitle']) === '') |
|
934 | - fatal_lang_error('no_event_title', false); |
|
935 | - if ($smcFunc['strlen']($_POST['evtitle']) > 100) |
|
936 | - $_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100); |
|
974 | + if ($smcFunc['htmltrim']($_POST['evtitle']) === '') { |
|
975 | + fatal_lang_error('no_event_title', false); |
|
976 | + } |
|
977 | + if ($smcFunc['strlen']($_POST['evtitle']) > 100) { |
|
978 | + $_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100); |
|
979 | + } |
|
937 | 980 | $_POST['evtitle'] = str_replace(';', '', $_POST['evtitle']); |
938 | 981 | } |
939 | 982 | } |
@@ -960,8 +1003,9 @@ discard block |
||
960 | 1003 | ); |
961 | 1004 | |
962 | 1005 | // No results, return false. |
963 | - if ($smcFunc['db_num_rows'] === 0) |
|
964 | - return false; |
|
1006 | + if ($smcFunc['db_num_rows'] === 0) { |
|
1007 | + return false; |
|
1008 | + } |
|
965 | 1009 | |
966 | 1010 | // Grab the results and return. |
967 | 1011 | list ($poster) = $smcFunc['db_fetch_row']($request); |
@@ -1095,8 +1139,9 @@ discard block |
||
1095 | 1139 | call_integration_hook('integrate_modify_event', array($event_id, &$eventOptions, &$event_columns, &$event_parameters)); |
1096 | 1140 | |
1097 | 1141 | $column_clauses = array(); |
1098 | - foreach ($event_columns as $col => $crit) |
|
1099 | - $column_clauses[] = $col . ' = ' . $crit; |
|
1142 | + foreach ($event_columns as $col => $crit) { |
|
1143 | + $column_clauses[] = $col . ' = ' . $crit; |
|
1144 | + } |
|
1100 | 1145 | |
1101 | 1146 | $smcFunc['db_query']('', ' |
1102 | 1147 | UPDATE {db_prefix}calendar |
@@ -1181,8 +1226,9 @@ discard block |
||
1181 | 1226 | ); |
1182 | 1227 | |
1183 | 1228 | // If nothing returned, we are in poo, poo. |
1184 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
1185 | - return false; |
|
1229 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
1230 | + return false; |
|
1231 | + } |
|
1186 | 1232 | |
1187 | 1233 | $row = $smcFunc['db_fetch_assoc']($request); |
1188 | 1234 | $smcFunc['db_free_result']($request); |
@@ -1190,8 +1236,9 @@ discard block |
||
1190 | 1236 | list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row); |
1191 | 1237 | |
1192 | 1238 | // Sanity check |
1193 | - if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) |
|
1194 | - return false; |
|
1239 | + if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) { |
|
1240 | + return false; |
|
1241 | + } |
|
1195 | 1242 | |
1196 | 1243 | $return_value = array( |
1197 | 1244 | 'boards' => array(), |
@@ -1328,24 +1375,27 @@ discard block |
||
1328 | 1375 | |
1329 | 1376 | // Set $span, in case we need it |
1330 | 1377 | $span = isset($eventOptions['span']) ? $eventOptions['span'] : (isset($_POST['span']) ? $_POST['span'] : 0); |
1331 | - if ($span > 0) |
|
1332 | - $span = !empty($modSettings['cal_maxspan']) ? min($modSettings['cal_maxspan'], $span - 1) : $span - 1; |
|
1378 | + if ($span > 0) { |
|
1379 | + $span = !empty($modSettings['cal_maxspan']) ? min($modSettings['cal_maxspan'], $span - 1) : $span - 1; |
|
1380 | + } |
|
1333 | 1381 | |
1334 | 1382 | // Define the timezone for this event, falling back to the default if not provided |
1335 | - if (!empty($eventOptions['tz']) && in_array($eventOptions['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
1336 | - $tz = $eventOptions['tz']; |
|
1337 | - elseif (!empty($_POST['tz']) && in_array($_POST['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
1338 | - $tz = $_POST['tz']; |
|
1339 | - else |
|
1340 | - $tz = getUserTimezone(); |
|
1383 | + if (!empty($eventOptions['tz']) && in_array($eventOptions['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
1384 | + $tz = $eventOptions['tz']; |
|
1385 | + } elseif (!empty($_POST['tz']) && in_array($_POST['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
1386 | + $tz = $_POST['tz']; |
|
1387 | + } else { |
|
1388 | + $tz = getUserTimezone(); |
|
1389 | + } |
|
1341 | 1390 | |
1342 | 1391 | // Is this supposed to be an all day event, or should it have specific start and end times? |
1343 | - if (isset($eventOptions['allday'])) |
|
1344 | - $allday = $eventOptions['allday']; |
|
1345 | - elseif (empty($_POST['allday'])) |
|
1346 | - $allday = false; |
|
1347 | - else |
|
1348 | - $allday = true; |
|
1392 | + if (isset($eventOptions['allday'])) { |
|
1393 | + $allday = $eventOptions['allday']; |
|
1394 | + } elseif (empty($_POST['allday'])) { |
|
1395 | + $allday = false; |
|
1396 | + } else { |
|
1397 | + $allday = true; |
|
1398 | + } |
|
1349 | 1399 | |
1350 | 1400 | // Input might come as individual parameters... |
1351 | 1401 | $start_year = isset($eventOptions['year']) ? $eventOptions['year'] : (isset($_POST['year']) ? $_POST['year'] : null); |
@@ -1372,10 +1422,12 @@ discard block |
||
1372 | 1422 | $end_time_string = isset($eventOptions['end_time']) ? $eventOptions['end_time'] : (isset($_POST['end_time']) ? $_POST['end_time'] : null); |
1373 | 1423 | |
1374 | 1424 | // If the date and time were given in separate strings, combine them |
1375 | - if (empty($start_string) && isset($start_date_string)) |
|
1376 | - $start_string = $start_date_string . (isset($start_time_string) ? ' ' . $start_time_string : ''); |
|
1377 | - if (empty($end_string) && isset($end_date_string)) |
|
1378 | - $end_string = $end_date_string . (isset($end_time_string) ? ' ' . $end_time_string : ''); |
|
1425 | + if (empty($start_string) && isset($start_date_string)) { |
|
1426 | + $start_string = $start_date_string . (isset($start_time_string) ? ' ' . $start_time_string : ''); |
|
1427 | + } |
|
1428 | + if (empty($end_string) && isset($end_date_string)) { |
|
1429 | + $end_string = $end_date_string . (isset($end_time_string) ? ' ' . $end_time_string : ''); |
|
1430 | + } |
|
1379 | 1431 | |
1380 | 1432 | // If some form of string input was given, override individually defined options with it |
1381 | 1433 | if (isset($start_string)) |
@@ -1466,10 +1518,11 @@ discard block |
||
1466 | 1518 | if ($start_object >= $end_object) |
1467 | 1519 | { |
1468 | 1520 | $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, $start_hour, $start_minute, $start_second) . ' ' . $tz); |
1469 | - if ($span > 0) |
|
1470 | - date_add($end_object, date_interval_create_from_date_string($span . ' days')); |
|
1471 | - else |
|
1472 | - date_add($end_object, date_interval_create_from_date_string('1 hour')); |
|
1521 | + if ($span > 0) { |
|
1522 | + date_add($end_object, date_interval_create_from_date_string($span . ' days')); |
|
1523 | + } else { |
|
1524 | + date_add($end_object, date_interval_create_from_date_string('1 hour')); |
|
1525 | + } |
|
1473 | 1526 | } |
1474 | 1527 | |
1475 | 1528 | // Is $end_object too late? |
@@ -1482,9 +1535,9 @@ discard block |
||
1482 | 1535 | { |
1483 | 1536 | $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, $start_hour, $start_minute, $start_second) . ' ' . $tz); |
1484 | 1537 | date_add($end_object, date_interval_create_from_date_string($modSettings['cal_maxspan'] . ' days')); |
1538 | + } else { |
|
1539 | + $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, '11', '59', '59') . ' ' . $tz); |
|
1485 | 1540 | } |
1486 | - else |
|
1487 | - $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, '11', '59', '59') . ' ' . $tz); |
|
1488 | 1541 | } |
1489 | 1542 | } |
1490 | 1543 | |
@@ -1497,8 +1550,7 @@ discard block |
||
1497 | 1550 | $start_time = null; |
1498 | 1551 | $end_time = null; |
1499 | 1552 | $tz = null; |
1500 | - } |
|
1501 | - else |
|
1553 | + } else |
|
1502 | 1554 | { |
1503 | 1555 | $start_time = date_format($start_object, 'H:i:s'); |
1504 | 1556 | $end_time = date_format($end_object, 'H:i:s'); |
@@ -1519,16 +1571,18 @@ discard block |
||
1519 | 1571 | require_once($sourcedir . '/Subs.php'); |
1520 | 1572 | |
1521 | 1573 | // First, try to create a better date format, ignoring the "time" elements. |
1522 | - if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
1523 | - $date_format = '%F'; |
|
1524 | - else |
|
1525 | - $date_format = $matches[0]; |
|
1574 | + if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
1575 | + $date_format = '%F'; |
|
1576 | + } else { |
|
1577 | + $date_format = $matches[0]; |
|
1578 | + } |
|
1526 | 1579 | |
1527 | 1580 | // We want a fairly compact version of the time, but as close as possible to the user's settings. |
1528 | - if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
1529 | - $time_format = '%k:%M'; |
|
1530 | - else |
|
1531 | - $time_format = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
1581 | + if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
1582 | + $time_format = '%k:%M'; |
|
1583 | + } else { |
|
1584 | + $time_format = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
1585 | + } |
|
1532 | 1586 | |
1533 | 1587 | // Should this be an all day event? |
1534 | 1588 | $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; |
@@ -1537,8 +1591,9 @@ discard block |
||
1537 | 1591 | $span = 1 + date_interval_format(date_diff(date_create($row['start_date']), date_create($row['end_date'])), '%d'); |
1538 | 1592 | |
1539 | 1593 | // We need to have a defined timezone in the steps below |
1540 | - if (empty($row['timezone'])) |
|
1541 | - $row['timezone'] = getUserTimezone(); |
|
1594 | + if (empty($row['timezone'])) { |
|
1595 | + $row['timezone'] = getUserTimezone(); |
|
1596 | + } |
|
1542 | 1597 | |
1543 | 1598 | // Get most of the standard date information for the start and end datetimes |
1544 | 1599 | $start = date_parse($row['start_date'] . (!$allday ? ' ' . $row['start_time'] : '')); |
@@ -1582,8 +1637,9 @@ discard block |
||
1582 | 1637 | $tz_location = timezone_location_get(timezone_open($row['timezone'])); |
1583 | 1638 | |
1584 | 1639 | // Kazakstan |
1585 | - if ($tz_location['country_code'] == 'KZ') |
|
1586 | - $tz_abbrev = str_replace(array('+05', '+06'), array('AQTT', 'ALMT'), $tz_abbrev); |
|
1640 | + if ($tz_location['country_code'] == 'KZ') { |
|
1641 | + $tz_abbrev = str_replace(array('+05', '+06'), array('AQTT', 'ALMT'), $tz_abbrev); |
|
1642 | + } |
|
1587 | 1643 | |
1588 | 1644 | // Russia likes to experiment with time zones |
1589 | 1645 | if ($tz_location['country_code'] == 'RU') |
@@ -1594,8 +1650,9 @@ discard block |
||
1594 | 1650 | } |
1595 | 1651 | |
1596 | 1652 | // Still no good? We'll just mark it as a UTC offset |
1597 | - if (strspn($tz_abbrev, '+-') > 0) |
|
1598 | - $tz_abbrev = 'UTC' . $tz_abbrev; |
|
1653 | + if (strspn($tz_abbrev, '+-') > 0) { |
|
1654 | + $tz_abbrev = 'UTC' . $tz_abbrev; |
|
1655 | + } |
|
1599 | 1656 | } |
1600 | 1657 | |
1601 | 1658 | return array($start, $end, $allday, $span, $tz, $tz_abbrev); |
@@ -1611,8 +1668,9 @@ discard block |
||
1611 | 1668 | { |
1612 | 1669 | global $smcFunc, $context, $sourcedir, $user_info, $modSettings; |
1613 | 1670 | |
1614 | - if (is_null($id_member) && $user_info['is_guest'] == false) |
|
1615 | - $id_member = $context['user']['id']; |
|
1671 | + if (is_null($id_member) && $user_info['is_guest'] == false) { |
|
1672 | + $id_member = $context['user']['id']; |
|
1673 | + } |
|
1616 | 1674 | |
1617 | 1675 | if (isset($id_member)) |
1618 | 1676 | { |
@@ -1628,8 +1686,9 @@ discard block |
||
1628 | 1686 | $smcFunc['db_free_result']($request); |
1629 | 1687 | } |
1630 | 1688 | |
1631 | - if (empty($timezone) || !in_array($timezone, timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
1632 | - $timezone = isset($modSettings['default_timezone']) ? $modSettings['default_timezone'] : date_default_timezone_get(); |
|
1689 | + if (empty($timezone) || !in_array($timezone, timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
1690 | + $timezone = isset($modSettings['default_timezone']) ? $modSettings['default_timezone'] : date_default_timezone_get(); |
|
1691 | + } |
|
1633 | 1692 | |
1634 | 1693 | return $timezone; |
1635 | 1694 | } |
@@ -1658,8 +1717,9 @@ discard block |
||
1658 | 1717 | ) |
1659 | 1718 | ); |
1660 | 1719 | $holidays = array(); |
1661 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1662 | - $holidays[] = $row; |
|
1720 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1721 | + $holidays[] = $row; |
|
1722 | + } |
|
1663 | 1723 | $smcFunc['db_free_result']($request); |
1664 | 1724 | |
1665 | 1725 | return $holidays; |
@@ -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'); |
@@ -80,8 +83,9 @@ discard block |
||
80 | 83 | $_REQUEST['month'] = (int) $_REQUEST['month']; |
81 | 84 | |
82 | 85 | // We want month view. |
83 | - if (empty($_GET['viewmonth'])) |
|
84 | - $_GET['viewmonth'] = true; |
|
86 | + if (empty($_GET['viewmonth'])) { |
|
87 | + $_GET['viewmonth'] = true; |
|
88 | + } |
|
85 | 89 | |
86 | 90 | // And we definitely don't want weekly view. |
87 | 91 | unset ($_GET['viewweek']); |
@@ -98,22 +102,25 @@ discard block |
||
98 | 102 | $context['page_title'] = $txt['calendar']; |
99 | 103 | |
100 | 104 | // Ensure a default view is defined |
101 | - if (empty($modSettings['calendar_default_view'])) |
|
102 | - $modSettings['calendar_default_view'] = 'view_list'; |
|
105 | + if (empty($modSettings['calendar_default_view'])) { |
|
106 | + $modSettings['calendar_default_view'] = 'view_list'; |
|
107 | + } |
|
103 | 108 | |
104 | 109 | // What view do we want? |
105 | - if (isset($_GET['viewweek'])) |
|
106 | - $context['calendar_view'] = 'view_week'; |
|
107 | - elseif (isset($_GET['viewmonth'])) |
|
108 | - $context['calendar_view'] = 'view_month'; |
|
109 | - elseif (isset($_GET['viewlist'])) |
|
110 | - $context['calendar_view'] = 'view_list'; |
|
111 | - else |
|
112 | - $context['calendar_view'] = $modSettings['calendar_default_view']; |
|
110 | + if (isset($_GET['viewweek'])) { |
|
111 | + $context['calendar_view'] = 'view_week'; |
|
112 | + } elseif (isset($_GET['viewmonth'])) { |
|
113 | + $context['calendar_view'] = 'view_month'; |
|
114 | + } elseif (isset($_GET['viewlist'])) { |
|
115 | + $context['calendar_view'] = 'view_list'; |
|
116 | + } else { |
|
117 | + $context['calendar_view'] = $modSettings['calendar_default_view']; |
|
118 | + } |
|
113 | 119 | |
114 | 120 | // Don't let search engines index the non-default calendar pages |
115 | - if ($context['calendar_view'] !== $modSettings['calendar_default_view']) |
|
116 | - $context['robot_no_index'] = true; |
|
121 | + if ($context['calendar_view'] !== $modSettings['calendar_default_view']) { |
|
122 | + $context['robot_no_index'] = true; |
|
123 | + } |
|
117 | 124 | |
118 | 125 | // Get the current day of month... |
119 | 126 | require_once($sourcedir . '/Subs-Calendar.php'); |
@@ -174,16 +181,19 @@ discard block |
||
174 | 181 | ); |
175 | 182 | |
176 | 183 | // Make sure the year and month are in valid ranges. |
177 | - if ($curPage['month'] < 1 || $curPage['month'] > 12) |
|
178 | - fatal_lang_error('invalid_month', false); |
|
179 | - if ($curPage['year'] < $modSettings['cal_minyear'] || $curPage['year'] > $modSettings['cal_maxyear']) |
|
180 | - fatal_lang_error('invalid_year', false); |
|
184 | + if ($curPage['month'] < 1 || $curPage['month'] > 12) { |
|
185 | + fatal_lang_error('invalid_month', false); |
|
186 | + } |
|
187 | + if ($curPage['year'] < $modSettings['cal_minyear'] || $curPage['year'] > $modSettings['cal_maxyear']) { |
|
188 | + fatal_lang_error('invalid_year', false); |
|
189 | + } |
|
181 | 190 | // If we have a day clean that too. |
182 | 191 | if ($context['calendar_view'] != 'view_month') |
183 | 192 | { |
184 | 193 | $isValid = checkdate($curPage['month'], $curPage['day'], $curPage['year']); |
185 | - if (!$isValid) |
|
186 | - fatal_lang_error('invalid_day', false); |
|
194 | + if (!$isValid) { |
|
195 | + fatal_lang_error('invalid_day', false); |
|
196 | + } |
|
187 | 197 | } |
188 | 198 | |
189 | 199 | // Load all the context information needed to show the calendar grid. |
@@ -205,23 +215,26 @@ discard block |
||
205 | 215 | ); |
206 | 216 | |
207 | 217 | // Load up the main view. |
208 | - if ($context['calendar_view'] == 'view_list') |
|
209 | - $context['calendar_grid_main'] = getCalendarList($curPage['start_date'], $curPage['end_date'], $calendarOptions); |
|
210 | - elseif ($context['calendar_view'] == 'view_week') |
|
211 | - $context['calendar_grid_main'] = getCalendarWeek($curPage['month'], $curPage['year'], $curPage['day'], $calendarOptions); |
|
212 | - else |
|
213 | - $context['calendar_grid_main'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions); |
|
218 | + if ($context['calendar_view'] == 'view_list') { |
|
219 | + $context['calendar_grid_main'] = getCalendarList($curPage['start_date'], $curPage['end_date'], $calendarOptions); |
|
220 | + } elseif ($context['calendar_view'] == 'view_week') { |
|
221 | + $context['calendar_grid_main'] = getCalendarWeek($curPage['month'], $curPage['year'], $curPage['day'], $calendarOptions); |
|
222 | + } else { |
|
223 | + $context['calendar_grid_main'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions); |
|
224 | + } |
|
214 | 225 | |
215 | 226 | // Load up the previous and next months. |
216 | 227 | $context['calendar_grid_current'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions); |
217 | 228 | |
218 | 229 | // Only show previous month if it isn't pre-January of the min-year |
219 | - if ($context['calendar_grid_current']['previous_calendar']['year'] > $modSettings['cal_minyear'] || $curPage['month'] != 1) |
|
220 | - $context['calendar_grid_prev'] = getCalendarGrid($context['calendar_grid_current']['previous_calendar']['month'], $context['calendar_grid_current']['previous_calendar']['year'], $calendarOptions, true); |
|
230 | + if ($context['calendar_grid_current']['previous_calendar']['year'] > $modSettings['cal_minyear'] || $curPage['month'] != 1) { |
|
231 | + $context['calendar_grid_prev'] = getCalendarGrid($context['calendar_grid_current']['previous_calendar']['month'], $context['calendar_grid_current']['previous_calendar']['year'], $calendarOptions, true); |
|
232 | + } |
|
221 | 233 | |
222 | 234 | // Only show next month if it isn't post-December of the max-year |
223 | - if ($context['calendar_grid_current']['next_calendar']['year'] < $modSettings['cal_maxyear'] || $curPage['month'] != 12) |
|
224 | - $context['calendar_grid_next'] = getCalendarGrid($context['calendar_grid_current']['next_calendar']['month'], $context['calendar_grid_current']['next_calendar']['year'], $calendarOptions); |
|
235 | + if ($context['calendar_grid_current']['next_calendar']['year'] < $modSettings['cal_maxyear'] || $curPage['month'] != 12) { |
|
236 | + $context['calendar_grid_next'] = getCalendarGrid($context['calendar_grid_current']['next_calendar']['month'], $context['calendar_grid_current']['next_calendar']['year'], $calendarOptions); |
|
237 | + } |
|
225 | 238 | |
226 | 239 | // Basic template stuff. |
227 | 240 | $context['allow_calendar_event'] = allowedTo('calendar_post'); |
@@ -241,8 +254,9 @@ discard block |
||
241 | 254 | $context['blocks_disabled'] = !empty($modSettings['cal_disable_prev_next']) ? 1 : 0; |
242 | 255 | |
243 | 256 | // Set the page title to mention the month or week, too |
244 | - if ($context['calendar_view'] != 'view_list') |
|
245 | - $context['page_title'] .= ' - ' . ($context['calendar_view'] == 'view_week' ? $context['calendar_grid_main']['week_title'] : $txt['months'][$context['current_month']] . ' ' . $context['current_year']); |
|
257 | + if ($context['calendar_view'] != 'view_list') { |
|
258 | + $context['page_title'] .= ' - ' . ($context['calendar_view'] == 'view_week' ? $context['calendar_grid_main']['week_title'] : $txt['months'][$context['current_month']] . ' ' . $context['current_year']); |
|
259 | + } |
|
246 | 260 | |
247 | 261 | // Load up the linktree! |
248 | 262 | $context['linktree'][] = array( |
@@ -255,17 +269,19 @@ discard block |
||
255 | 269 | 'name' => $txt['months'][$context['current_month']] . ' ' . $context['current_year'] |
256 | 270 | ); |
257 | 271 | // If applicable, add the current week to the linktree. |
258 | - if ($context['calendar_view'] == 'view_week') |
|
259 | - $context['linktree'][] = array( |
|
272 | + if ($context['calendar_view'] == 'view_week') { |
|
273 | + $context['linktree'][] = array( |
|
260 | 274 | 'url' => $scripturl . '?action=calendar;viewweek;year=' . $context['current_year'] . ';month=' . $context['current_month'] . ';day=' . $context['current_day'], |
261 | 275 | 'name' => $context['calendar_grid_main']['week_title'], |
262 | 276 | ); |
277 | + } |
|
263 | 278 | |
264 | 279 | // Build the calendar button array. |
265 | 280 | $context['calendar_buttons'] = array(); |
266 | 281 | |
267 | - if ($context['can_post']) |
|
268 | - $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']); |
|
282 | + if ($context['can_post']) { |
|
283 | + $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']); |
|
284 | + } |
|
269 | 285 | |
270 | 286 | // Allow mods to add additional buttons here |
271 | 287 | call_integration_hook('integrate_calendar_buttons'); |
@@ -294,14 +310,16 @@ discard block |
||
294 | 310 | require_once($sourcedir . '/Subs.php'); |
295 | 311 | |
296 | 312 | // Cast this for safety... |
297 | - if (isset($_REQUEST['eventid'])) |
|
298 | - $_REQUEST['eventid'] = (int) $_REQUEST['eventid']; |
|
313 | + if (isset($_REQUEST['eventid'])) { |
|
314 | + $_REQUEST['eventid'] = (int) $_REQUEST['eventid']; |
|
315 | + } |
|
299 | 316 | |
300 | 317 | // We want a fairly compact version of the time, but as close as possible to the user's settings. |
301 | - if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
302 | - $time_string = '%k:%M'; |
|
303 | - else |
|
304 | - $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
318 | + if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
319 | + $time_string = '%k:%M'; |
|
320 | + } else { |
|
321 | + $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
322 | + } |
|
305 | 323 | |
306 | 324 | $js_time_string = str_replace( |
307 | 325 | array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
@@ -315,12 +333,14 @@ discard block |
||
315 | 333 | checkSession(); |
316 | 334 | |
317 | 335 | // Validate the post... |
318 | - if (!isset($_POST['link_to_board'])) |
|
319 | - validateEventPost(); |
|
336 | + if (!isset($_POST['link_to_board'])) { |
|
337 | + validateEventPost(); |
|
338 | + } |
|
320 | 339 | |
321 | 340 | // If you're not allowed to edit any events, you have to be the poster. |
322 | - if ($_REQUEST['eventid'] > 0 && !allowedTo('calendar_edit_any')) |
|
323 | - isAllowedTo('calendar_edit_' . (!empty($user_info['id']) && getEventPoster($_REQUEST['eventid']) == $user_info['id'] ? 'own' : 'any')); |
|
341 | + if ($_REQUEST['eventid'] > 0 && !allowedTo('calendar_edit_any')) { |
|
342 | + isAllowedTo('calendar_edit_' . (!empty($user_info['id']) && getEventPoster($_REQUEST['eventid']) == $user_info['id'] ? 'own' : 'any')); |
|
343 | + } |
|
324 | 344 | |
325 | 345 | // New - and directing? |
326 | 346 | if (isset($_POST['link_to_board']) || empty($modSettings['cal_allow_unlinked'])) |
@@ -343,8 +363,9 @@ discard block |
||
343 | 363 | } |
344 | 364 | |
345 | 365 | // Deleting... |
346 | - elseif (isset($_REQUEST['deleteevent'])) |
|
347 | - removeEvent($_REQUEST['eventid']); |
|
366 | + elseif (isset($_REQUEST['deleteevent'])) { |
|
367 | + removeEvent($_REQUEST['eventid']); |
|
368 | + } |
|
348 | 369 | |
349 | 370 | // ... or just update it? |
350 | 371 | else |
@@ -366,14 +387,12 @@ discard block |
||
366 | 387 | $d = date_parse($_POST['start_date']); |
367 | 388 | $year = $d['year']; |
368 | 389 | $month = $d['month']; |
369 | - } |
|
370 | - elseif (isset($_POST['start_datetime'])) |
|
390 | + } elseif (isset($_POST['start_datetime'])) |
|
371 | 391 | { |
372 | 392 | $d = date_parse($_POST['start_datetime']); |
373 | 393 | $year = $d['year']; |
374 | 394 | $month = $d['month']; |
375 | - } |
|
376 | - else |
|
395 | + } else |
|
377 | 396 | { |
378 | 397 | $today = getdate(); |
379 | 398 | $year = isset($_POST['year']) ? $_POST['year'] : $today['year']; |
@@ -406,13 +425,13 @@ discard block |
||
406 | 425 | $context['event'] = array_merge($context['event'], $eventDatetimes); |
407 | 426 | |
408 | 427 | $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'])); |
409 | - } |
|
410 | - else |
|
428 | + } else |
|
411 | 429 | { |
412 | 430 | $context['event'] = getEventProperties($_REQUEST['eventid']); |
413 | 431 | |
414 | - if ($context['event'] === false) |
|
415 | - fatal_lang_error('no_access', false); |
|
432 | + if ($context['event'] === false) { |
|
433 | + fatal_lang_error('no_access', false); |
|
434 | + } |
|
416 | 435 | |
417 | 436 | // If it has a board, then they should be editing it within the topic. |
418 | 437 | if (!empty($context['event']['topic']['id']) && !empty($context['event']['topic']['first_msg'])) |
@@ -423,10 +442,11 @@ discard block |
||
423 | 442 | } |
424 | 443 | |
425 | 444 | // Make sure the user is allowed to edit this event. |
426 | - if ($context['event']['member'] != $user_info['id']) |
|
427 | - isAllowedTo('calendar_edit_any'); |
|
428 | - elseif (!allowedTo('calendar_edit_any')) |
|
429 | - isAllowedTo('calendar_edit_own'); |
|
445 | + if ($context['event']['member'] != $user_info['id']) { |
|
446 | + isAllowedTo('calendar_edit_any'); |
|
447 | + } elseif (!allowedTo('calendar_edit_any')) { |
|
448 | + isAllowedTo('calendar_edit_own'); |
|
449 | + } |
|
430 | 450 | } |
431 | 451 | |
432 | 452 | // An all day event? Set up some nice defaults in case the user wants to change that |
@@ -460,8 +480,7 @@ discard block |
||
460 | 480 | { |
461 | 481 | // You can post new events but can't link them to anything... |
462 | 482 | $context['event']['categories'] = array(); |
463 | - } |
|
464 | - else |
|
483 | + } else |
|
465 | 484 | { |
466 | 485 | // Load the list of boards and categories in the context. |
467 | 486 | require_once($sourcedir . '/Subs-MessageIndex.php'); |
@@ -548,12 +567,14 @@ discard block |
||
548 | 567 | global $smcFunc, $sourcedir, $forum_version, $modSettings, $webmaster_email, $mbname; |
549 | 568 | |
550 | 569 | // You can't export if the calendar export feature is off. |
551 | - if (empty($modSettings['cal_export'])) |
|
552 | - fatal_lang_error('calendar_export_off', false); |
|
570 | + if (empty($modSettings['cal_export'])) { |
|
571 | + fatal_lang_error('calendar_export_off', false); |
|
572 | + } |
|
553 | 573 | |
554 | 574 | // Goes without saying that this is required. |
555 | - if (!isset($_REQUEST['eventid'])) |
|
556 | - fatal_lang_error('no_access', false); |
|
575 | + if (!isset($_REQUEST['eventid'])) { |
|
576 | + fatal_lang_error('no_access', false); |
|
577 | + } |
|
557 | 578 | |
558 | 579 | // This is kinda wanted. |
559 | 580 | require_once($sourcedir . '/Subs-Calendar.php'); |
@@ -561,15 +582,17 @@ discard block |
||
561 | 582 | // Load up the event in question and check it exists. |
562 | 583 | $event = getEventProperties($_REQUEST['eventid']); |
563 | 584 | |
564 | - if ($event === false) |
|
565 | - fatal_lang_error('no_access', false); |
|
585 | + if ($event === false) { |
|
586 | + fatal_lang_error('no_access', false); |
|
587 | + } |
|
566 | 588 | |
567 | 589 | // Check the title isn't too long - iCal requires some formatting if so. |
568 | 590 | $title = str_split($event['title'], 30); |
569 | 591 | foreach ($title as $id => $line) |
570 | 592 | { |
571 | - if ($id != 0) |
|
572 | - $title[$id] = ' ' . $title[$id]; |
|
593 | + if ($id != 0) { |
|
594 | + $title[$id] = ' ' . $title[$id]; |
|
595 | + } |
|
573 | 596 | $title[$id] .= "\n"; |
574 | 597 | } |
575 | 598 | |
@@ -582,8 +605,7 @@ discard block |
||
582 | 605 | { |
583 | 606 | $datestart = date_format($start_date, 'Ymd\THis'); |
584 | 607 | $dateend = date_format($end_date, 'Ymd\THis'); |
585 | - } |
|
586 | - else |
|
608 | + } else |
|
587 | 609 | { |
588 | 610 | $datestart = date_format($start_date, 'Ymd'); |
589 | 611 | |
@@ -604,15 +626,18 @@ discard block |
||
604 | 626 | $filecontents .= 'DTSTART' . (!empty($event['start_time']) ? ';TZID=' . $event['tz'] : ';VALUE=DATE') . ':' . $datestart . "\n"; |
605 | 627 | |
606 | 628 | // event has a duration |
607 | - if ($event['start_iso_gmdate'] != $event['end_iso_gmdate']) |
|
608 | - $filecontents .= 'DTEND' . (!empty($event['end_time']) ? ';TZID=' . $event['tz'] : ';VALUE=DATE') . ':' . $dateend . "\n"; |
|
629 | + if ($event['start_iso_gmdate'] != $event['end_iso_gmdate']) { |
|
630 | + $filecontents .= 'DTEND' . (!empty($event['end_time']) ? ';TZID=' . $event['tz'] : ';VALUE=DATE') . ':' . $dateend . "\n"; |
|
631 | + } |
|
609 | 632 | |
610 | 633 | // event has changed? advance the sequence for this UID |
611 | - if ($event['sequence'] > 0) |
|
612 | - $filecontents .= 'SEQUENCE:' . $event['sequence'] . "\n"; |
|
634 | + if ($event['sequence'] > 0) { |
|
635 | + $filecontents .= 'SEQUENCE:' . $event['sequence'] . "\n"; |
|
636 | + } |
|
613 | 637 | |
614 | - if (!empty($event['location'])) |
|
615 | - $filecontents .= 'LOCATION:' . str_replace(',', '\,', $event['location']) . "\n"; |
|
638 | + if (!empty($event['location'])) { |
|
639 | + $filecontents .= 'LOCATION:' . str_replace(',', '\,', $event['location']) . "\n"; |
|
640 | + } |
|
616 | 641 | |
617 | 642 | $filecontents .= 'SUMMARY:' . implode('', $title); |
618 | 643 | $filecontents .= 'UID:' . $event['eventid'] . '@' . str_replace(' ', '-', $mbname) . "\n"; |
@@ -621,23 +646,26 @@ discard block |
||
621 | 646 | |
622 | 647 | // Send some standard headers. |
623 | 648 | ob_end_clean(); |
624 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
625 | - @ob_start('ob_gzhandler'); |
|
626 | - else |
|
627 | - ob_start(); |
|
649 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
650 | + @ob_start('ob_gzhandler'); |
|
651 | + } else { |
|
652 | + ob_start(); |
|
653 | + } |
|
628 | 654 | |
629 | 655 | // Send the file headers |
630 | 656 | header('Pragma: '); |
631 | 657 | header('Cache-Control: no-cache'); |
632 | - if (!isBrowser('gecko')) |
|
633 | - header('Content-Transfer-Encoding: binary'); |
|
658 | + if (!isBrowser('gecko')) { |
|
659 | + header('Content-Transfer-Encoding: binary'); |
|
660 | + } |
|
634 | 661 | header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT'); |
635 | 662 | header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . 'GMT'); |
636 | 663 | header('Accept-Ranges: bytes'); |
637 | 664 | header('Connection: close'); |
638 | 665 | header('Content-Disposition: attachment; filename="' . $event['title'] . '.ics"'); |
639 | - if (empty($modSettings['enableCompressedOutput'])) |
|
640 | - header('Content-Length: ' . $smcFunc['strlen']($filecontents)); |
|
666 | + if (empty($modSettings['enableCompressedOutput'])) { |
|
667 | + header('Content-Length: ' . $smcFunc['strlen']($filecontents)); |
|
668 | + } |
|
641 | 669 | |
642 | 670 | // This is a calendar item! |
643 | 671 | header('Content-Type: text/calendar'); |
@@ -676,20 +704,17 @@ discard block |
||
676 | 704 | $context['sub_template'] = 'bcd'; |
677 | 705 | $context['linktree'][] = array('url' => $scripturl . '?action=clock;bcd', 'name' => 'BCD'); |
678 | 706 | $context['clockicons'] = safe_unserialize(base64_decode('YTo2OntzOjI6ImgxIjthOjI6e2k6MDtpOjI7aToxO2k6MTt9czoyOiJoMiI7YTo0OntpOjA7aTo4O2k6MTtpOjQ7aToyO2k6MjtpOjM7aToxO31zOjI6Im0xIjthOjM6e2k6MDtpOjQ7aToxO2k6MjtpOjI7aToxO31zOjI6Im0yIjthOjQ6e2k6MDtpOjg7aToxO2k6NDtpOjI7aToyO2k6MztpOjE7fXM6MjoiczEiO2E6Mzp7aTowO2k6NDtpOjE7aToyO2k6MjtpOjE7fXM6MjoiczIiO2E6NDp7aTowO2k6ODtpOjE7aTo0O2k6MjtpOjI7aTozO2k6MTt9fQ==')); |
679 | - } |
|
680 | - elseif (!$omfg && !isset($_REQUEST['time'])) |
|
707 | + } elseif (!$omfg && !isset($_REQUEST['time'])) |
|
681 | 708 | { |
682 | 709 | $context['sub_template'] = 'hms'; |
683 | 710 | $context['linktree'][] = array('url' => $scripturl . '?action=clock', 'name' => 'Binary'); |
684 | 711 | $context['clockicons'] = safe_unserialize(base64_decode('YTozOntzOjE6ImgiO2E6NTp7aTowO2k6MTY7aToxO2k6ODtpOjI7aTo0O2k6MztpOjI7aTo0O2k6MTt9czoxOiJtIjthOjY6e2k6MDtpOjMyO2k6MTtpOjE2O2k6MjtpOjg7aTozO2k6NDtpOjQ7aToyO2k6NTtpOjE7fXM6MToicyI7YTo2OntpOjA7aTozMjtpOjE7aToxNjtpOjI7aTo4O2k6MztpOjQ7aTo0O2k6MjtpOjU7aToxO319')); |
685 | - } |
|
686 | - elseif ($omfg) |
|
712 | + } elseif ($omfg) |
|
687 | 713 | { |
688 | 714 | $context['sub_template'] = 'omfg'; |
689 | 715 | $context['linktree'][] = array('url' => $scripturl . '?action=clock;omfg', 'name' => 'OMFG'); |
690 | 716 | $context['clockicons'] = safe_unserialize(base64_decode('YTo2OntzOjQ6InllYXIiO2E6Nzp7aTowO2k6NjQ7aToxO2k6MzI7aToyO2k6MTY7aTozO2k6ODtpOjQ7aTo0O2k6NTtpOjI7aTo2O2k6MTt9czo1OiJtb250aCI7YTo0OntpOjA7aTo4O2k6MTtpOjQ7aToyO2k6MjtpOjM7aToxO31zOjM6ImRheSI7YTo1OntpOjA7aToxNjtpOjE7aTo4O2k6MjtpOjQ7aTozO2k6MjtpOjQ7aToxO31zOjQ6ImhvdXIiO2E6NTp7aTowO2k6MTY7aToxO2k6ODtpOjI7aTo0O2k6MztpOjI7aTo0O2k6MTt9czozOiJtaW4iO2E6Njp7aTowO2k6MzI7aToxO2k6MTY7aToyO2k6ODtpOjM7aTo0O2k6NDtpOjI7aTo1O2k6MTt9czozOiJzZWMiO2E6Njp7aTowO2k6MzI7aToxO2k6MTY7aToyO2k6ODtpOjM7aTo0O2k6NDtpOjI7aTo1O2k6MTt9fQ==')); |
691 | - } |
|
692 | - elseif (isset($_REQUEST['time'])) |
|
717 | + } elseif (isset($_REQUEST['time'])) |
|
693 | 718 | { |
694 | 719 | $context['sub_template'] = 'thetime'; |
695 | 720 | $time = getdate($_REQUEST['time'] == 'now' ? time() : (int) $_REQUEST['time']); |
@@ -749,12 +774,13 @@ discard block |
||
749 | 774 | ), |
750 | 775 | ); |
751 | 776 | |
752 | - foreach ($context['clockicons'] as $t => $vs) |
|
753 | - foreach ($vs as $v => $dumb) |
|
777 | + foreach ($context['clockicons'] as $t => $vs) { |
|
778 | + foreach ($vs as $v => $dumb) |
|
754 | 779 | { |
755 | 780 | if ($$t >= $v) |
756 | 781 | { |
757 | 782 | $$t -= $v; |
783 | + } |
|
758 | 784 | $context['clockicons'][$t][$v] = true; |
759 | 785 | } |
760 | 786 | } |
@@ -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 |
@@ -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 |
@@ -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 |