Calendar.php 20 KB

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