Calendar.php 19 KB

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