Chris@76
|
1 <?php
|
Chris@76
|
2
|
Chris@76
|
3 /**
|
Chris@76
|
4 * Simple Machines Forum (SMF)
|
Chris@76
|
5 *
|
Chris@76
|
6 * @package SMF
|
Chris@76
|
7 * @author Simple Machines http://www.simplemachines.org
|
Chris@76
|
8 * @copyright 2011 Simple Machines
|
Chris@76
|
9 * @license http://www.simplemachines.org/about/smf/license.php BSD
|
Chris@76
|
10 *
|
Chris@76
|
11 * @version 2.0
|
Chris@76
|
12 */
|
Chris@76
|
13
|
Chris@76
|
14 // Original module by Aaron O'Neil - aaron@mud-master.com
|
Chris@76
|
15
|
Chris@76
|
16 if (!defined('SMF'))
|
Chris@76
|
17 die('Hacking attempt...');
|
Chris@76
|
18
|
Chris@76
|
19 /* This file has only one real task... showing the calendar. Posting is done
|
Chris@76
|
20 in Post.php - this just has the following functions:
|
Chris@76
|
21
|
Chris@76
|
22 void CalendarMain()
|
Chris@76
|
23 - loads the specified month's events, holidays, and birthdays.
|
Chris@76
|
24 - requires the calendar_view permission.
|
Chris@76
|
25 - depends on the cal_enabled setting, and many of the other cal_
|
Chris@76
|
26 settings.
|
Chris@76
|
27 - uses the calendar_start_day theme option. (Monday/Sunday)
|
Chris@76
|
28 - uses the main sub template in the Calendar template.
|
Chris@76
|
29 - goes to the month and year passed in 'month' and 'year' by
|
Chris@76
|
30 get or post.
|
Chris@76
|
31 - accessed through ?action=calendar.
|
Chris@76
|
32
|
Chris@76
|
33 void CalendarPost()
|
Chris@76
|
34 - processes posting/editing/deleting a calendar event.
|
Chris@76
|
35 - calls Post() function if event is linked to a post.
|
Chris@76
|
36 - calls insertEvent() to insert the event if not linked to post.
|
Chris@76
|
37 - requires the calendar_post permission to use.
|
Chris@76
|
38 - uses the event_post sub template in the Calendar template.
|
Chris@76
|
39 - is accessed with ?action=calendar;sa=post.
|
Chris@76
|
40
|
Chris@76
|
41 void iCalDownload()
|
Chris@76
|
42 - offers up a download of an event in iCal 2.0 format.
|
Chris@76
|
43 */
|
Chris@76
|
44
|
Chris@76
|
45 // Show the calendar.
|
Chris@76
|
46 function CalendarMain()
|
Chris@76
|
47 {
|
Chris@76
|
48 global $txt, $context, $modSettings, $scripturl, $options, $sourcedir;
|
Chris@76
|
49
|
Chris@76
|
50 // Permissions, permissions, permissions.
|
Chris@76
|
51 isAllowedTo('calendar_view');
|
Chris@76
|
52
|
Chris@76
|
53 // Doing something other than calendar viewing?
|
Chris@76
|
54 $subActions = array(
|
Chris@76
|
55 'ical' => 'iCalDownload',
|
Chris@76
|
56 'post' => 'CalendarPost',
|
Chris@76
|
57 );
|
Chris@76
|
58
|
Chris@76
|
59 if (isset($_GET['sa']) && isset($subActions[$_GET['sa']]) && !WIRELESS)
|
Chris@76
|
60 return $subActions[$_GET['sa']]();
|
Chris@76
|
61
|
Chris@76
|
62 // This is gonna be needed...
|
Chris@76
|
63 loadTemplate('Calendar');
|
Chris@76
|
64
|
Chris@76
|
65 // You can't do anything if the calendar is off.
|
Chris@76
|
66 if (empty($modSettings['cal_enabled']))
|
Chris@76
|
67 fatal_lang_error('calendar_off', false);
|
Chris@76
|
68
|
Chris@76
|
69 // Set the page title to mention the calendar ;).
|
Chris@76
|
70 $context['page_title'] = $txt['calendar'];
|
Chris@76
|
71
|
Chris@76
|
72 // Is this a week view?
|
Chris@76
|
73 $context['view_week'] = isset($_GET['viewweek']);
|
Chris@76
|
74
|
Chris@76
|
75 // Don't let search engines index weekly calendar pages.
|
Chris@76
|
76 if ($context['view_week'])
|
Chris@76
|
77 $context['robot_no_index'] = true;
|
Chris@76
|
78
|
Chris@76
|
79 // Get the current day of month...
|
Chris@76
|
80 require_once($sourcedir . '/Subs-Calendar.php');
|
Chris@76
|
81 $today = getTodayInfo();
|
Chris@76
|
82
|
Chris@76
|
83 // If the month and year are not passed in, use today's date as a starting point.
|
Chris@76
|
84 $curPage = array(
|
Chris@76
|
85 'day' => isset($_REQUEST['day']) ? (int) $_REQUEST['day'] : $today['day'],
|
Chris@76
|
86 'month' => isset($_REQUEST['month']) ? (int) $_REQUEST['month'] : $today['month'],
|
Chris@76
|
87 'year' => isset($_REQUEST['year']) ? (int) $_REQUEST['year'] : $today['year']
|
Chris@76
|
88 );
|
Chris@76
|
89
|
Chris@76
|
90 // Make sure the year and month are in valid ranges.
|
Chris@76
|
91 if ($curPage['month'] < 1 || $curPage['month'] > 12)
|
Chris@76
|
92 fatal_lang_error('invalid_month', false);
|
Chris@76
|
93 if ($curPage['year'] < $modSettings['cal_minyear'] || $curPage['year'] > $modSettings['cal_maxyear'])
|
Chris@76
|
94 fatal_lang_error('invalid_year', false);
|
Chris@76
|
95 // If we have a day clean that too.
|
Chris@76
|
96 if ($context['view_week'])
|
Chris@76
|
97 {
|
Chris@76
|
98 // Note $isValid is -1 < PHP 5.1
|
Chris@76
|
99 $isValid = mktime(0, 0, 0, $curPage['month'], $curPage['day'], $curPage['year']);
|
Chris@76
|
100 if ($curPage['day'] > 31 || !$isValid || $isValid == -1)
|
Chris@76
|
101 fatal_lang_error('invalid_day', false);
|
Chris@76
|
102 }
|
Chris@76
|
103
|
Chris@76
|
104 // Load all the context information needed to show the calendar grid.
|
Chris@76
|
105 $calendarOptions = array(
|
Chris@76
|
106 'start_day' => !empty($options['calendar_start_day']) ? $options['calendar_start_day'] : 0,
|
Chris@76
|
107 'show_birthdays' => in_array($modSettings['cal_showbdays'], array(1, 2)),
|
Chris@76
|
108 'show_events' => in_array($modSettings['cal_showevents'], array(1, 2)),
|
Chris@76
|
109 'show_holidays' => in_array($modSettings['cal_showholidays'], array(1, 2)),
|
Chris@76
|
110 'show_week_num' => true,
|
Chris@76
|
111 'short_day_titles' => false,
|
Chris@76
|
112 'show_next_prev' => true,
|
Chris@76
|
113 'show_week_links' => true,
|
Chris@76
|
114 'size' => 'large',
|
Chris@76
|
115 );
|
Chris@76
|
116
|
Chris@76
|
117 // Load up the main view.
|
Chris@76
|
118 if ($context['view_week'])
|
Chris@76
|
119 $context['calendar_grid_main'] = getCalendarWeek($curPage['month'], $curPage['year'], $curPage['day'], $calendarOptions);
|
Chris@76
|
120 else
|
Chris@76
|
121 $context['calendar_grid_main'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions);
|
Chris@76
|
122
|
Chris@76
|
123 // Load up the previous and next months.
|
Chris@76
|
124 $calendarOptions['show_birthdays'] = $calendarOptions['show_events'] = $calendarOptions['show_holidays'] = false;
|
Chris@76
|
125 $calendarOptions['short_day_titles'] = true;
|
Chris@76
|
126 $calendarOptions['show_next_prev'] = false;
|
Chris@76
|
127 $calendarOptions['show_week_links'] = false;
|
Chris@76
|
128 $calendarOptions['size'] = 'small';
|
Chris@76
|
129 $context['calendar_grid_current'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions);
|
Chris@76
|
130 // Only show previous month if it isn't pre-January of the min-year
|
Chris@76
|
131 if ($context['calendar_grid_current']['previous_calendar']['year'] > $modSettings['cal_minyear'] || $curPage['month'] != 1)
|
Chris@76
|
132 $context['calendar_grid_prev'] = getCalendarGrid($context['calendar_grid_current']['previous_calendar']['month'], $context['calendar_grid_current']['previous_calendar']['year'], $calendarOptions);
|
Chris@76
|
133 // Only show next month if it isn't post-December of the max-year
|
Chris@76
|
134 if ($context['calendar_grid_current']['next_calendar']['year'] < $modSettings['cal_maxyear'] || $curPage['month'] != 12)
|
Chris@76
|
135 $context['calendar_grid_next'] = getCalendarGrid($context['calendar_grid_current']['next_calendar']['month'], $context['calendar_grid_current']['next_calendar']['year'], $calendarOptions);
|
Chris@76
|
136
|
Chris@76
|
137 // Basic template stuff.
|
Chris@76
|
138 $context['can_post'] = allowedTo('calendar_post');
|
Chris@76
|
139 $context['current_day'] = $curPage['day'];
|
Chris@76
|
140 $context['current_month'] = $curPage['month'];
|
Chris@76
|
141 $context['current_year'] = $curPage['year'];
|
Chris@76
|
142 $context['show_all_birthdays'] = isset($_GET['showbd']);
|
Chris@76
|
143
|
Chris@76
|
144 // Set the page title to mention the month or week, too
|
Chris@76
|
145 $context['page_title'] .= ' - ' . ($context['view_week'] ? sprintf($txt['calendar_week_title'], $context['calendar_grid_main']['week_number'], ($context['calendar_grid_main']['week_number'] == 53 ? $context['current_year'] - 1 : $context['current_year'])) : $txt['months'][$context['current_month']] . ' ' . $context['current_year']);
|
Chris@76
|
146
|
Chris@76
|
147 // Load up the linktree!
|
Chris@76
|
148 $context['linktree'][] = array(
|
Chris@76
|
149 'url' => $scripturl . '?action=calendar',
|
Chris@76
|
150 'name' => $txt['calendar']
|
Chris@76
|
151 );
|
Chris@76
|
152 // Add the current month to the linktree.
|
Chris@76
|
153 $context['linktree'][] = array(
|
Chris@76
|
154 'url' => $scripturl . '?action=calendar;year=' . $context['current_year'] . ';month=' . $context['current_month'],
|
Chris@76
|
155 'name' => $txt['months'][$context['current_month']] . ' ' . $context['current_year']
|
Chris@76
|
156 );
|
Chris@76
|
157 // If applicable, add the current week to the linktree.
|
Chris@76
|
158 if ($context['view_week'])
|
Chris@76
|
159 $context['linktree'][] = array(
|
Chris@76
|
160 'url' => $scripturl . '?action=calendar;viewweek;year=' . $context['current_year'] . ';month=' . $context['current_month'] . ';day=' . $context['current_day'],
|
Chris@76
|
161 'name' => $txt['calendar_week'] . ' ' . $context['calendar_grid_main']['week_number']
|
Chris@76
|
162 );
|
Chris@76
|
163 }
|
Chris@76
|
164
|
Chris@76
|
165 function CalendarPost()
|
Chris@76
|
166 {
|
Chris@76
|
167 global $context, $txt, $user_info, $sourcedir, $scripturl;
|
Chris@76
|
168 global $modSettings, $topic, $smcFunc;
|
Chris@76
|
169
|
Chris@76
|
170 // Well - can they?
|
Chris@76
|
171 isAllowedTo('calendar_post');
|
Chris@76
|
172
|
Chris@76
|
173 // We need this for all kinds of useful functions.
|
Chris@76
|
174 require_once($sourcedir . '/Subs-Calendar.php');
|
Chris@76
|
175
|
Chris@76
|
176 // Cast this for safety...
|
Chris@76
|
177 if (isset($_REQUEST['eventid']))
|
Chris@76
|
178 $_REQUEST['eventid'] = (int) $_REQUEST['eventid'];
|
Chris@76
|
179
|
Chris@76
|
180 // Submitting?
|
Chris@76
|
181 if (isset($_POST[$context['session_var']], $_REQUEST['eventid']))
|
Chris@76
|
182 {
|
Chris@76
|
183 checkSession();
|
Chris@76
|
184
|
Chris@76
|
185 // Validate the post...
|
Chris@76
|
186 if (!isset($_POST['link_to_board']))
|
Chris@76
|
187 validateEventPost();
|
Chris@76
|
188
|
Chris@76
|
189 // If you're not allowed to edit any events, you have to be the poster.
|
Chris@76
|
190 if ($_REQUEST['eventid'] > 0 && !allowedTo('calendar_edit_any'))
|
Chris@76
|
191 isAllowedTo('calendar_edit_' . (!empty($user_info['id']) && getEventPoster($_REQUEST['eventid']) == $user_info['id'] ? 'own' : 'any'));
|
Chris@76
|
192
|
Chris@76
|
193 // New - and directing?
|
Chris@76
|
194 if ($_REQUEST['eventid'] == -1 && isset($_POST['link_to_board']))
|
Chris@76
|
195 {
|
Chris@76
|
196 $_REQUEST['calendar'] = 1;
|
Chris@76
|
197 require_once($sourcedir . '/Post.php');
|
Chris@76
|
198 return Post();
|
Chris@76
|
199 }
|
Chris@76
|
200 // New...
|
Chris@76
|
201 elseif ($_REQUEST['eventid'] == -1)
|
Chris@76
|
202 {
|
Chris@76
|
203 $eventOptions = array(
|
Chris@76
|
204 'board' => 0,
|
Chris@76
|
205 'topic' => 0,
|
Chris@76
|
206 'title' => substr($_REQUEST['evtitle'], 0, 60),
|
Chris@76
|
207 'member' => $user_info['id'],
|
Chris@76
|
208 'start_date' => sprintf('%04d-%02d-%02d', $_POST['year'], $_POST['month'], $_POST['day']),
|
Chris@76
|
209 'span' => isset($_POST['span']) && $_POST['span'] > 0 ? min((int) $modSettings['cal_maxspan'], (int) $_POST['span'] - 1) : 0,
|
Chris@76
|
210 );
|
Chris@76
|
211 insertEvent($eventOptions);
|
Chris@76
|
212 }
|
Chris@76
|
213
|
Chris@76
|
214 // Deleting...
|
Chris@76
|
215 elseif (isset($_REQUEST['deleteevent']))
|
Chris@76
|
216 removeEvent($_REQUEST['eventid']);
|
Chris@76
|
217
|
Chris@76
|
218 // ... or just update it?
|
Chris@76
|
219 else
|
Chris@76
|
220 {
|
Chris@76
|
221 $eventOptions = array(
|
Chris@76
|
222 'title' => substr($_REQUEST['evtitle'], 0, 60),
|
Chris@76
|
223 'span' => empty($modSettings['cal_allowspan']) || empty($_POST['span']) || $_POST['span'] == 1 || empty($modSettings['cal_maxspan']) || $_POST['span'] > $modSettings['cal_maxspan'] ? 0 : min((int) $modSettings['cal_maxspan'], (int) $_POST['span'] - 1),
|
Chris@76
|
224 'start_date' => strftime('%Y-%m-%d', mktime(0, 0, 0, (int) $_REQUEST['month'], (int) $_REQUEST['day'], (int) $_REQUEST['year'])),
|
Chris@76
|
225 );
|
Chris@76
|
226
|
Chris@76
|
227 modifyEvent($_REQUEST['eventid'], $eventOptions);
|
Chris@76
|
228 }
|
Chris@76
|
229
|
Chris@76
|
230 updateSettings(array(
|
Chris@76
|
231 'calendar_updated' => time(),
|
Chris@76
|
232 ));
|
Chris@76
|
233
|
Chris@76
|
234 // No point hanging around here now...
|
Chris@76
|
235 redirectexit($scripturl . '?action=calendar;month=' . $_POST['month'] . ';year=' . $_POST['year']);
|
Chris@76
|
236 }
|
Chris@76
|
237
|
Chris@76
|
238 // If we are not enabled... we are not enabled.
|
Chris@76
|
239 if (empty($modSettings['cal_allow_unlinked']) && empty($_REQUEST['eventid']))
|
Chris@76
|
240 {
|
Chris@76
|
241 $_REQUEST['calendar'] = 1;
|
Chris@76
|
242 require_once($sourcedir . '/Post.php');
|
Chris@76
|
243 return Post();
|
Chris@76
|
244 }
|
Chris@76
|
245
|
Chris@76
|
246 // New?
|
Chris@76
|
247 if (!isset($_REQUEST['eventid']))
|
Chris@76
|
248 {
|
Chris@76
|
249 $today = getdate();
|
Chris@76
|
250
|
Chris@76
|
251 $context['event'] = array(
|
Chris@76
|
252 'boards' => array(),
|
Chris@76
|
253 'board' => 0,
|
Chris@76
|
254 'new' => 1,
|
Chris@76
|
255 'eventid' => -1,
|
Chris@76
|
256 'year' => isset($_REQUEST['year']) ? $_REQUEST['year'] : $today['year'],
|
Chris@76
|
257 'month' => isset($_REQUEST['month']) ? $_REQUEST['month'] : $today['mon'],
|
Chris@76
|
258 'day' => isset($_REQUEST['day']) ? $_REQUEST['day'] : $today['mday'],
|
Chris@76
|
259 'title' => '',
|
Chris@76
|
260 'span' => 1,
|
Chris@76
|
261 );
|
Chris@76
|
262 $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']));
|
Chris@76
|
263
|
Chris@76
|
264 // Get list of boards that can be posted in.
|
Chris@76
|
265 $boards = boardsAllowedTo('post_new');
|
Chris@76
|
266 if (empty($boards))
|
Chris@76
|
267 fatal_lang_error('cannot_post_new', 'permission');
|
Chris@76
|
268
|
Chris@76
|
269 // Load the list of boards and categories in the context.
|
Chris@76
|
270 require_once($sourcedir . '/Subs-MessageIndex.php');
|
Chris@76
|
271 $boardListOptions = array(
|
Chris@76
|
272 'included_boards' => in_array(0, $boards) ? null : $boards,
|
Chris@76
|
273 'not_redirection' => true,
|
Chris@76
|
274 'use_permissions' => true,
|
Chris@76
|
275 'selected_board' => $modSettings['cal_defaultboard'],
|
Chris@76
|
276 );
|
Chris@76
|
277 $context['event']['categories'] = getBoardList($boardListOptions);
|
Chris@76
|
278 }
|
Chris@76
|
279 else
|
Chris@76
|
280 {
|
Chris@76
|
281 $context['event'] = getEventProperties($_REQUEST['eventid']);
|
Chris@76
|
282
|
Chris@76
|
283 if ($context['event'] === false)
|
Chris@76
|
284 fatal_lang_error('no_access', false);
|
Chris@76
|
285
|
Chris@76
|
286 // If it has a board, then they should be editing it within the topic.
|
Chris@76
|
287 if (!empty($context['event']['topic']['id']) && !empty($context['event']['topic']['first_msg']))
|
Chris@76
|
288 {
|
Chris@76
|
289 // We load the board up, for a check on the board access rights...
|
Chris@76
|
290 $topic = $context['event']['topic']['id'];
|
Chris@76
|
291 loadBoard();
|
Chris@76
|
292 }
|
Chris@76
|
293
|
Chris@76
|
294 // Make sure the user is allowed to edit this event.
|
Chris@76
|
295 if ($context['event']['member'] != $user_info['id'])
|
Chris@76
|
296 isAllowedTo('calendar_edit_any');
|
Chris@76
|
297 elseif (!allowedTo('calendar_edit_any'))
|
Chris@76
|
298 isAllowedTo('calendar_edit_own');
|
Chris@76
|
299 }
|
Chris@76
|
300
|
Chris@76
|
301 // Template, sub template, etc.
|
Chris@76
|
302 loadTemplate('Calendar');
|
Chris@76
|
303 $context['sub_template'] = 'event_post';
|
Chris@76
|
304
|
Chris@76
|
305 $context['page_title'] = isset($_REQUEST['eventid']) ? $txt['calendar_edit'] : $txt['calendar_post_event'];
|
Chris@76
|
306 $context['linktree'][] = array(
|
Chris@76
|
307 'name' => $context['page_title'],
|
Chris@76
|
308 );
|
Chris@76
|
309 }
|
Chris@76
|
310
|
Chris@76
|
311 function iCalDownload()
|
Chris@76
|
312 {
|
Chris@76
|
313 global $smcFunc, $sourcedir, $forum_version, $context, $modSettings;
|
Chris@76
|
314
|
Chris@76
|
315 // Goes without saying that this is required.
|
Chris@76
|
316 if (!isset($_REQUEST['eventid']))
|
Chris@76
|
317 fatal_lang_error('no_access', false);
|
Chris@76
|
318
|
Chris@76
|
319 // This is kinda wanted.
|
Chris@76
|
320 require_once($sourcedir . '/Subs-Calendar.php');
|
Chris@76
|
321
|
Chris@76
|
322 // Load up the event in question and check it exists.
|
Chris@76
|
323 $event = getEventProperties($_REQUEST['eventid']);
|
Chris@76
|
324
|
Chris@76
|
325 if ($event === false)
|
Chris@76
|
326 fatal_lang_error('no_access', false);
|
Chris@76
|
327
|
Chris@76
|
328 // Check the title isn't too long - iCal requires some formatting if so.
|
Chris@76
|
329 $title = str_split($event['title'], 30);
|
Chris@76
|
330 foreach ($title as $id => $line)
|
Chris@76
|
331 {
|
Chris@76
|
332 if ($id != 0)
|
Chris@76
|
333 $title[$id] = ' ' . $title[$id];
|
Chris@76
|
334 $title[$id] .= "\n";
|
Chris@76
|
335 }
|
Chris@76
|
336
|
Chris@76
|
337 // Format the date.
|
Chris@76
|
338 $date = $event['year'] . '-' . ($event['month'] < 10 ? '0' . $event['month'] : $event['month']) . '-' . ($event['day'] < 10 ? '0' . $event['day'] : $event['day']) . 'T';
|
Chris@76
|
339 $date .= '1200:00:00Z';
|
Chris@76
|
340
|
Chris@76
|
341 // This is what we will be sending later.
|
Chris@76
|
342 $filecontents = '';
|
Chris@76
|
343 $filecontents .= 'BEGIN:VCALENDAR' . "\n";
|
Chris@76
|
344 $filecontents .= 'VERSION:2.0' . "\n";
|
Chris@76
|
345 $filecontents .= 'PRODID:-//SimpleMachines//SMF ' . (empty($forum_version) ? 1.0 : strtr($forum_version, array('SMF ' => ''))) . '//EN' . "\n";
|
Chris@76
|
346 $filecontents .= 'BEGIN:VEVENT' . "\n";
|
Chris@76
|
347 $filecontents .= 'DTSTART:' . $date . "\n";
|
Chris@76
|
348 $filecontents .= 'DTEND:' . $date . "\n";
|
Chris@76
|
349 $filecontents .= 'SUMMARY:' . implode('', $title);
|
Chris@76
|
350 $filecontents .= 'END:VEVENT' . "\n";
|
Chris@76
|
351 $filecontents .= 'END:VCALENDAR';
|
Chris@76
|
352
|
Chris@76
|
353 // Send some standard headers.
|
Chris@76
|
354 ob_end_clean();
|
Chris@76
|
355 if (!empty($modSettings['enableCompressedOutput']))
|
Chris@76
|
356 @ob_start('ob_gzhandler');
|
Chris@76
|
357 else
|
Chris@76
|
358 ob_start();
|
Chris@76
|
359
|
Chris@76
|
360 // Send the file headers
|
Chris@76
|
361 header('Pragma: ');
|
Chris@76
|
362 header('Cache-Control: no-cache');
|
Chris@76
|
363 if (!$context['browser']['is_gecko'])
|
Chris@76
|
364 header('Content-Transfer-Encoding: binary');
|
Chris@76
|
365 header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT');
|
Chris@76
|
366 header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . 'GMT');
|
Chris@76
|
367 header('Accept-Ranges: bytes');
|
Chris@76
|
368 header('Connection: close');
|
Chris@76
|
369 header('Content-Disposition: attachment; filename=' . $event['title'] . '.ics');
|
Chris@76
|
370
|
Chris@76
|
371 // How big is it?
|
Chris@76
|
372 if (empty($modSettings['enableCompressedOutput']))
|
Chris@76
|
373 header('Content-Length: ' . $smcFunc['strlen']($filecontents));
|
Chris@76
|
374
|
Chris@76
|
375 // This is a calendar item!
|
Chris@76
|
376 header('Content-Type: text/calendar');
|
Chris@76
|
377
|
Chris@76
|
378 // Chuck out the card.
|
Chris@76
|
379 echo $filecontents;
|
Chris@76
|
380
|
Chris@76
|
381 // Off we pop - lovely!
|
Chris@76
|
382 obExit(false);
|
Chris@76
|
383 }
|
Chris@76
|
384
|
Chris@76
|
385 // This is not the code you are looking for.
|
Chris@76
|
386 function clock()
|
Chris@76
|
387 {
|
Chris@76
|
388 global $settings, $context;
|
Chris@76
|
389 $context['onimg'] = $settings['images_url'] . '/bbc/bbc_bg.gif';
|
Chris@76
|
390 $context['offimg'] = $settings['images_url'] . '/bbc/bbc_hoverbg.gif';
|
Chris@76
|
391
|
Chris@76
|
392 $context['page_title'] = 'Anyone know what time it is?';
|
Chris@76
|
393 $context['robot_no_index'] = true;
|
Chris@76
|
394
|
Chris@76
|
395 $omfg = isset($_REQUEST['omfg']);
|
Chris@76
|
396 $bcd = !isset($_REQUEST['rb']) && !isset($_REQUEST['omfg']) && !isset($_REQUEST['time']);
|
Chris@76
|
397
|
Chris@76
|
398 loadTemplate('Calendar');
|
Chris@76
|
399
|
Chris@76
|
400 if ($bcd && !$omfg)
|
Chris@76
|
401 {
|
Chris@76
|
402 $context['sub_template'] = 'bcd';
|
Chris@76
|
403 $context['clockicons'] = unserialize(base64_decode('YTo2OntzOjI6ImgxIjthOjI6e2k6MDtpOjI7aToxO2k6MTt9czoyOiJoMiI7YTo0OntpOjA7aTo4O2k6MTtpOjQ7aToyO2k6MjtpOjM7aToxO31zOjI6Im0xIjthOjM6e2k6MDtpOjQ7aToxO2k6MjtpOjI7aToxO31zOjI6Im0yIjthOjQ6e2k6MDtpOjg7aToxO2k6NDtpOjI7aToyO2k6MztpOjE7fXM6MjoiczEiO2E6Mzp7aTowO2k6NDtpOjE7aToyO2k6MjtpOjE7fXM6MjoiczIiO2E6NDp7aTowO2k6ODtpOjE7aTo0O2k6MjtpOjI7aTozO2k6MTt9fQ=='));
|
Chris@76
|
404 }
|
Chris@76
|
405 elseif (!$omfg && !isset($_REQUEST['time']))
|
Chris@76
|
406 {
|
Chris@76
|
407 $context['sub_template'] = 'hms';
|
Chris@76
|
408 $context['clockicons'] = unserialize(base64_decode('YTozOntzOjE6ImgiO2E6NTp7aTowO2k6MTY7aToxO2k6ODtpOjI7aTo0O2k6MztpOjI7aTo0O2k6MTt9czoxOiJtIjthOjY6e2k6MDtpOjMyO2k6MTtpOjE2O2k6MjtpOjg7aTozO2k6NDtpOjQ7aToyO2k6NTtpOjE7fXM6MToicyI7YTo2OntpOjA7aTozMjtpOjE7aToxNjtpOjI7aTo4O2k6MztpOjQ7aTo0O2k6MjtpOjU7aToxO319'));
|
Chris@76
|
409 }
|
Chris@76
|
410 elseif ($omfg)
|
Chris@76
|
411 {
|
Chris@76
|
412 $context['sub_template'] = 'omfg';
|
Chris@76
|
413 $context['clockicons'] = unserialize(base64_decode('YTo2OntzOjQ6InllYXIiO2E6Nzp7aTowO2k6NjQ7aToxO2k6MzI7aToyO2k6MTY7aTozO2k6ODtpOjQ7aTo0O2k6NTtpOjI7aTo2O2k6MTt9czo1OiJtb250aCI7YTo0OntpOjA7aTo4O2k6MTtpOjQ7aToyO2k6MjtpOjM7aToxO31zOjM6ImRheSI7YTo1OntpOjA7aToxNjtpOjE7aTo4O2k6MjtpOjQ7aTozO2k6MjtpOjQ7aToxO31zOjQ6ImhvdXIiO2E6NTp7aTowO2k6MTY7aToxO2k6ODtpOjI7aTo0O2k6MztpOjI7aTo0O2k6MTt9czozOiJtaW4iO2E6Njp7aTowO2k6MzI7aToxO2k6MTY7aToyO2k6ODtpOjM7aTo0O2k6NDtpOjI7aTo1O2k6MTt9czozOiJzZWMiO2E6Njp7aTowO2k6MzI7aToxO2k6MTY7aToyO2k6ODtpOjM7aTo0O2k6NDtpOjI7aTo1O2k6MTt9fQ=='));
|
Chris@76
|
414 }
|
Chris@76
|
415 elseif (isset($_REQUEST['time']))
|
Chris@76
|
416 {
|
Chris@76
|
417 $context['sub_template'] = 'thetime';
|
Chris@76
|
418 $time = getdate($_REQUEST['time'] == 'now' ? time() : (int) $_REQUEST['time']);
|
Chris@76
|
419
|
Chris@76
|
420 $context['clockicons'] = array(
|
Chris@76
|
421 'year' => array(
|
Chris@76
|
422 64 => false,
|
Chris@76
|
423 32 => false,
|
Chris@76
|
424 16 => false,
|
Chris@76
|
425 8 => false,
|
Chris@76
|
426 4 => false,
|
Chris@76
|
427 2 => false,
|
Chris@76
|
428 1 => false
|
Chris@76
|
429 ),
|
Chris@76
|
430 'month' => array(
|
Chris@76
|
431 8 => false,
|
Chris@76
|
432 4 => false,
|
Chris@76
|
433 2 => false,
|
Chris@76
|
434 1 => false
|
Chris@76
|
435 ),
|
Chris@76
|
436 'day' => array(
|
Chris@76
|
437 16 => false,
|
Chris@76
|
438 4 => false,
|
Chris@76
|
439 8 => false,
|
Chris@76
|
440 2 => false,
|
Chris@76
|
441 1 => false
|
Chris@76
|
442 ),
|
Chris@76
|
443 'hour' => array(
|
Chris@76
|
444 32 => false,
|
Chris@76
|
445 16 => false,
|
Chris@76
|
446 8 => false,
|
Chris@76
|
447 4 => false,
|
Chris@76
|
448 2 => false,
|
Chris@76
|
449 1 => false
|
Chris@76
|
450 ),
|
Chris@76
|
451 'min' => array(
|
Chris@76
|
452 32 => false,
|
Chris@76
|
453 16 => false,
|
Chris@76
|
454 8 => false,
|
Chris@76
|
455 4 => false,
|
Chris@76
|
456 2 => false,
|
Chris@76
|
457 1 => false
|
Chris@76
|
458 ),
|
Chris@76
|
459 'sec' => array(
|
Chris@76
|
460 32 => false,
|
Chris@76
|
461 16 => false,
|
Chris@76
|
462 8 => false,
|
Chris@76
|
463 4 => false,
|
Chris@76
|
464 2 => false,
|
Chris@76
|
465 1 => false
|
Chris@76
|
466 ),
|
Chris@76
|
467 );
|
Chris@76
|
468
|
Chris@76
|
469 $year = $time['year'] % 100;
|
Chris@76
|
470 $month = $time['mon'];
|
Chris@76
|
471 $day = $time['mday'];
|
Chris@76
|
472 $hour = $time['hours'];
|
Chris@76
|
473 $min = $time['minutes'];
|
Chris@76
|
474 $sec = $time['seconds'];
|
Chris@76
|
475
|
Chris@76
|
476 foreach ($context['clockicons'] as $t => $vs)
|
Chris@76
|
477 foreach ($vs as $v => $dumb)
|
Chris@76
|
478 {
|
Chris@76
|
479 if ($$t >= $v)
|
Chris@76
|
480 {
|
Chris@76
|
481 $$t -= $v;
|
Chris@76
|
482 $context['clockicons'][$t][$v] = true;
|
Chris@76
|
483 }
|
Chris@76
|
484 }
|
Chris@76
|
485 }
|
Chris@76
|
486 }
|
Chris@76
|
487 ?> |