2
0

Calendar.php 21 KB

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