/** * Standard modular run function for snippet hooks. Generates XHTML to insert into a page using AJAX. * * @return tempcode The snippet */ function run() { $type = get_param('type'); if (!has_zone_access(get_member(), 'adminzone')) { return new ocp_tempcode(); } decache('main_staff_checklist'); require_lang('staff_checklist'); switch ($type) { case 'add': $recurinterval = get_param_integer('recurinterval', 0); $task_title = get_param('tasktitle', false, true); $id = $GLOBALS['SITE_DB']->query_insert('customtasks', array('tasktitle' => $task_title, 'datetimeadded' => time(), 'recurinterval' => $recurinterval, 'recurevery' => get_param('recurevery'), 'taskisdone' => NULL), true); require_code('notifications'); $subject = do_lang('CT_NOTIFICATION_MAIL_SUBJECT', get_site_name(), $task_title); $mail = do_lang('CT_NOTIFICATION_MAIL', comcode_escape(get_site_name()), comcode_escape($task_title)); dispatch_notification('checklist_task', NULL, $subject, $mail); return do_template('BLOCK_MAIN_STAFF_CHECKLIST_CUSTOM_TASK', array('TASKTITLE' => comcode_to_tempcode(get_param('tasktitle', false, true)), 'DATETIMEADDED' => display_time_period(time()), 'RECURINTERVAL' => $recurinterval == 0 ? '' : integer_format($recurinterval), 'RECUREVERY' => get_param('recurevery'), 'TASKDONE' => 'not_completed', 'ID' => strval($id))); case 'delete': $GLOBALS['SITE_DB']->query_delete('customtasks', array('id' => get_param_integer('id')), '', 1); break; case 'mark_done': $GLOBALS['SITE_DB']->query_update('customtasks', array('taskisdone' => time()), array('id' => get_param_integer('id')), '', 1); break; case 'mark_undone': $GLOBALS['SITE_DB']->query_update('customtasks', array('taskisdone' => NULL), array('id' => get_param_integer('id')), '', 1); break; } return new ocp_tempcode(); }
/** * Standard modular run function. * * @return tempcode Results */ function run() { $dbs_bak = $GLOBALS['NO_DB_SCOPE_CHECK']; $GLOBALS['NO_DB_SCOPE_CHECK'] = true; // Find known paths $known_urls = array(); $urlpaths = $GLOBALS['SITE_DB']->query_select('db_meta', array('m_name', 'm_table'), array('m_type' => 'URLPATH')); $base_url = get_custom_base_url(); foreach ($urlpaths as $urlpath) { $ofs = $GLOBALS['SITE_DB']->query_select($urlpath['m_table'], array($urlpath['m_name'])); foreach ($ofs as $of) { $url = $of[$urlpath['m_name']]; if (url_is_local($url)) { $known_urls[rawurldecode($url)] = 1; } else { if (substr($url, 0, strlen($base_url)) == $base_url) { $known_urls[substr($url, strlen($base_url) + 1)] = 1; } } } } $all_files = $this->do_dir('uploads'); $orphaned = array(); foreach ($all_files as $file) { if (!array_key_exists($file, $known_urls)) { $orphaned[] = array('URL' => get_custom_base_url() . '/' . str_replace('%2F', '/', rawurlencode($file))); } } $GLOBALS['NO_DB_SCOPE_CHECK'] = $dbs_bak; return do_template('CLEANUP_ORPHANED_UPLOADS', array('_GUID' => '21049d738f67554cff0891d343c02ad3', 'FOUND' => $orphaned)); }
/** * Standard modular run function for RSS hooks. * * @param string A list of categories we accept from * @param TIME Cutoff time, before which we do not show results from * @param string Prefix that represents the template set we use * @set RSS_ ATOM_ * @param string The standard format of date to use for the syndication type represented in the prefix * @param integer The maximum number of entries to return, ordering by date * @return ?array A pair: The main syndication section, and a title (NULL: error) */ function run($_filters, $cutoff, $prefix, $date_string, $max) { if (!addon_installed('cedi')) { return NULL; } if (!has_actual_page_access(get_member(), 'cedi')) { return NULL; } $filters = ocfilter_to_sqlfragment($_filters, 'id', 'seedy_children', 'parent_id', 'parent_id', 'child_id'); $content = new ocp_tempcode(); $rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'seedy_pages WHERE ' . $filters . ' AND add_date>' . strval((int) $cutoff) . ' ORDER BY add_date DESC', $max); foreach ($rows as $row) { $id = strval($row['id']); if (!has_category_access(get_member(), 'seedy_page', strval($row['id']))) { continue; } $author = ''; $news_date = date($date_string, $row['add_date']); $edit_date = ''; $news_title = xmlentities(escape_html(get_translated_text($row['title']))); $_summary = get_translated_tempcode($row['description']); $summary = xmlentities($_summary->evaluate()); $news = ''; $category = ''; $category_raw = ''; $view_url = build_url(array('page' => 'cedi', 'type' => 'misc', 'id' => $row['id'] == db_get_first_id() ? NULL : $row['id']), get_module_zone('cedi'), NULL, false, false, true); $if_comments = new ocp_tempcode(); $content->attach(do_template($prefix . 'ENTRY', array('VIEW_URL' => $view_url, 'SUMMARY' => $summary, 'EDIT_DATE' => $edit_date, 'IF_COMMENTS' => $if_comments, 'TITLE' => $news_title, 'CATEGORY_RAW' => $category_raw, 'CATEGORY' => $category, 'AUTHOR' => $author, 'ID' => $id, 'NEWS' => $news, 'DATE' => $news_date))); } require_lang('cedi'); return array($content, do_lang('CEDI_PAGES')); }
/** * Redirect the user - transparently, storing a message that will be shown on their destination page. * * @param tempcode Title to display on redirect page * @param mixed Destination URL (may be Tempcode) * @param mixed Message to show (may be Tempcode) * @param boolean For intermediatory hops, don't mark so as to read status messages - save them up for the next hop (which will not be intermediatory) * @param ID_TEXT Code of message type to show * @set warn inform fatal * @return tempcode Redirection message (likely to not actually be seen due to instant redirection) */ function _redirect_screen($title, $url, $text, $intermediatory_hop = false, $msg_type = 'inform') { if (is_object($url)) { $url = $url->evaluate(); } global $FORCE_META_REFRESH, $ATTACHED_MESSAGES_RAW; $special_page_type = get_param('special_page_type', 'view'); if ($special_page_type == 'view' && $GLOBALS['NON_PAGE_SCRIPT'] == 0 && !headers_sent() && !$FORCE_META_REFRESH) { foreach ($ATTACHED_MESSAGES_RAW as $message) { $GLOBALS['SITE_DB']->query_insert('messages_to_render', array('r_session_id' => get_session_id(), 'r_message' => is_object($message[0]) ? $message[0]->evaluate() : escape_html($message[0]), 'r_type' => $message[1], 'r_time' => time())); } $_message = is_object($text) ? $text->evaluate() : escape_html($text); if ($_message != '' && (count($ATTACHED_MESSAGES_RAW) == 0 || $_message != do_lang('SUCCESS') && $_message != do_lang('REDIRECTING'))) { $GLOBALS['SITE_DB']->query_insert('messages_to_render', array('r_session_id' => get_session_id(), 'r_message' => $_message, 'r_type' => $msg_type, 'r_time' => time())); } if (!$intermediatory_hop) { $hash_pos = strpos($url, '#'); if ($hash_pos !== false) { $hash_bit = substr($url, $hash_pos); $url = substr($url, 0, $hash_pos); } else { $hash_bit = ''; } $url .= (strpos($url, '?') === false ? '?' : '&') . 'redirected=1' . $hash_bit; } } require_code('site2'); assign_refresh($url, 0.0); return do_template('REDIRECT_SCREEN', array('_GUID' => '44ce3d1ffc6536b299ed0944e8ca7253', 'URL' => $url, 'TITLE' => $title, 'TEXT' => $text)); }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { require_lang('chat'); require_css('side_blocks'); $room_id = array_key_exists('param', $map) ? intval($map['param']) : NULL; $num_messages = array_key_exists('max', $map) ? intval($map['max']) : 5; if (is_null($room_id)) { $room_id = $GLOBALS['SITE_DB']->query_value_null_ok('chat_rooms', 'MIN(id)', array('is_im' => 0)); if (is_null($room_id)) { return new ocp_tempcode(); } } $room_check = $GLOBALS['SITE_DB']->query_select('chat_rooms', array('*'), array('id' => $room_id), '', 1); if (!array_key_exists(0, $room_check)) { return new ocp_tempcode(); } require_code('chat'); if (!check_chatroom_access($room_check[0], true)) { global $DO_NOT_CACHE_THIS; // We don't cache against access, so we have a problem and can't cache $DO_NOT_CACHE_THIS = true; return new ocp_tempcode(); } $content = NULL; if (get_value('no_frames') === '1') { $content = shoutbox_script(true, $room_id, $num_messages); } return do_template('BLOCK_SIDE_SHOUTBOX_IFRAME', array('CONTENT' => $content, 'ROOM_ID' => strval($room_id), 'NUM_MESSAGES' => strval($num_messages))); }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { require_lang('google_search'); $out = new ocp_tempcode(); //return do_template('BLOCK_MAIN_GOOGLE_SEARCH_REULTS',array('TITLE'=>do_lang_tempcode('BLOCK_GOOGLE_TITLE'),'CONTENT'=>$out)); return do_template('BLOCK_MAIN_GOOGLE_SEARCH_REULTS', array('TITLE' => '', 'CONTENT' => $out)); }
/** * Standard modular run function. * * @return tempcode The result of execution. */ function run() { require_lang('leader_board'); require_code('points'); require_css('points'); $title = get_page_title('POINT_LEADERBOARD'); $start_date = intval(get_option('leaderboard_start_date')); $weeks = $GLOBALS['SITE_DB']->query('SELECT DISTINCT date_and_time FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'leader_board WHERE date_and_time>=' . strval($start_date) . ' ORDER BY date_and_time DESC'); if (count($weeks) == 0) { warn_exit(do_lang_tempcode('NO_ENTRIES')); } $first_week = $weeks[count($weeks) - 1]['date_and_time']; $weeks = collapse_1d_complexity('date_and_time', $weeks); $out = new ocp_tempcode(); foreach ($weeks as $week) { $rows = collapse_2d_complexity('lb_member', 'lb_points', $GLOBALS['SITE_DB']->query_select('leader_board', array('lb_member', 'lb_points'), array('date_and_time' => $week))); $week_tpl = new ocp_tempcode(); foreach ($rows as $member => $points) { $points_url = build_url(array('page' => 'points', 'type' => 'member', 'id' => $member), get_module_zone('points')); $profile_url = $GLOBALS['FORUM_DRIVER']->member_profile_url($member, false, true); $name = $GLOBALS['FORUM_DRIVER']->get_username($member); if (is_null($name)) { $name = do_lang('UNKNOWN'); } $week_tpl->attach(do_template('POINTS_LEADERBOARD_ROW', array('_GUID' => '6d323b4b5abea0e82a14cb4745c4af4f', 'POINTS_URL' => $points_url, 'PROFILE_URL' => $profile_url, 'POINTS' => integer_format($points), 'NAME' => $name, 'ID' => strval($member)))); } $nice_week = intval(($week - $first_week) / (7 * 24 * 60 * 60) + 1); $out->attach(do_template('POINTS_LEADERBOARD_WEEK', array('_GUID' => '3a0f71bf20f9098e5711e85cf25f6549', 'WEEK' => integer_format($nice_week), 'ROWS' => $week_tpl))); } return do_template('POINTS_LEADERBOARD_SCREEN', array('_GUID' => 'bab5f7b661435b83800532d3eebd0d54', 'TITLE' => $title, 'WEEKS' => $out)); }
/** * Standard modular run function for RSS hooks. * * @param string A list of categories we accept from * @param TIME Cutoff time, before which we do not show results from * @param string Prefix that represents the template set we use * @set RSS_ ATOM_ * @param string The standard format of date to use for the syndication type represented in the prefix * @param integer The maximum number of entries to return, ordering by date * @return ?array A pair: The main syndication section, and a title (NULL: error) */ function run($_filters, $cutoff, $prefix, $date_string, $max) { require_lang('activities'); require_code('activities'); list(, $whereville) = find_activities(get_member(), $_filters == '' ? 'all' : 'some_members', $_filters == '' ? NULL : array_map('intval', explode(',', $_filters))); $rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . get_table_prefix() . 'activities WHERE (' . $whereville . ') AND a_time>' . strval($cutoff) . ' ORDER BY a_time DESC', $max, 0); $content = new ocp_tempcode(); foreach ($rows as $row) { $id = strval($row['id']); $author = $GLOBALS['FORUM_DRIVER']->get_username($row['a_member_id']); if (is_null($author)) { $author = do_lang('UNKNOWN'); } $news_date = date($date_string, $row['a_time']); $edit_date = ''; list($_title, ) = render_activity($row); $news_title = xmlentities($_title->evaluate()); $summary = xmlentities(''); $news = ''; $category = ''; $category_raw = ''; $view_url = build_url(array('page' => 'members', 'type' => 'view', 'id' => $row['a_member_id']), get_module_zone('members'), NULL, false, false, true); $if_comments = new ocp_tempcode(); $content->attach(do_template($prefix . 'ENTRY', array('VIEW_URL' => $view_url, 'SUMMARY' => $summary, 'EDIT_DATE' => $edit_date, 'IF_COMMENTS' => $if_comments, 'TITLE' => $news_title, 'CATEGORY_RAW' => $category_raw, 'CATEGORY' => $category, 'AUTHOR' => $author, 'ID' => $id, 'NEWS' => $news, 'DATE' => $news_date))); } return array($content, do_lang('ACTIVITIES_TITLE')); }
/** * Standard interface stage of pointstore item purchase. * * @return tempcode The UI */ function action() { $class = str_replace('hook_pointstore_', '', strtolower(get_class($this))); if (get_option('is_on_' . $class . '_buy') == '0') { return new ocp_tempcode(); } $title = get_page_title('TOPIC_PINNING'); $cost = intval(get_option($class)); $next_url = build_url(array('page' => '_SELF', 'type' => 'action_done', 'id' => $class), '_SELF'); $points_left = available_points(get_member()); // Check points if ($points_left < $cost && !has_specific_permission(get_member(), 'give_points_self')) { return warn_screen($title, do_lang_tempcode('_CANT_AFFORD', integer_format($cost), integer_format($points_left))); } require_code('form_templates'); $fields = new ocp_tempcode(); if (get_forum_type() == 'ocf') { $fields->attach(form_input_tree_list(do_lang_tempcode('FORUM_TOPIC'), '', 'select_topic_id', NULL, 'choose_forum_topic', array(), false)); $fields->attach(form_input_integer(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('FORUM_TOPIC')), do_lang_tempcode('DESCRIPTION_FORUM_TOPIC_ID'), 'manual_topic_id', NULL, false)); } else { $fields->attach(form_input_integer(do_lang_tempcode('FORUM_TOPIC'), do_lang_tempcode('ENTER_TOPIC_ID_MANUALLY'), 'manual_topic_id', NULL, false)); } $text = do_lang_tempcode('PIN_TOPIC_A', integer_format($cost), integer_format($points_left - $cost)); return do_template('FORM_SCREEN', array('_GUID' => '8cabf882d5cbe4d354cc6efbcf92ebf9', 'TITLE' => $title, 'TEXT' => $text, 'URL' => $next_url, 'FIELDS' => $fields, 'HIDDEN' => '', 'SUBMIT_NAME' => do_lang_tempcode('PURCHASE'), 'JAVASCRIPT' => 'standardAlternateFields(\'select_topic_id\',\'manual_topic_id\');')); }
/** * Standard modular run function. * * @return tempcode The result of execution. */ function run() { if (!addon_installed('calendar')) { return new ocp_tempcode(); } require_lang('calendar'); $bits = new ocp_tempcode(); if (get_option('calendar_show_stats_count_events', true) == '1') { $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('KEY' => do_lang_tempcode('EVENTS'), 'VALUE' => integer_format($GLOBALS['SITE_DB']->query_value('calendar_events', 'COUNT(*)'))))); } if (get_option('calendar_show_stats_count_events_this_week', true) == '1') { require_code('calendar'); $events = calendar_matches($GLOBALS['FORUM_DRIVER']->get_guest_id(), true, utctime_to_usertime(time()), utctime_to_usertime(time() + 60 * 60 * 24 * 7)); $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('KEY' => do_lang_tempcode('EVENTS_THIS_WEEK'), 'VALUE' => integer_format(count($events))))); } if (get_option('calendar_show_stats_count_events_this_month', true) == '1') { require_code('calendar'); $events = calendar_matches($GLOBALS['FORUM_DRIVER']->get_guest_id(), true, utctime_to_usertime(time()), utctime_to_usertime(time() + 60 * 60 * 24 * 31)); $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('KEY' => do_lang_tempcode('EVENTS_THIS_MONTH'), 'VALUE' => integer_format(count($events))))); } if (get_option('calendar_show_stats_count_events_this_year', true) == '1') { require_code('calendar'); $events = calendar_matches($GLOBALS['FORUM_DRIVER']->get_guest_id(), true, utctime_to_usertime(time()), utctime_to_usertime(time() + 60 * 60 * 24 * 365)); $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('KEY' => do_lang_tempcode('EVENTS_THIS_YEAR'), 'VALUE' => integer_format(count($events))))); } if ($bits->is_empty()) { return new ocp_tempcode(); } $section = do_template('BLOCK_SIDE_STATS_SECTION', array('SECTION' => do_lang_tempcode('CALENDAR'), 'CONTENT' => $bits)); return $section; }
/** * Standard modular run function for OcCLE notification hooks. * * @param ?integer The "current" time on which to base queries (NULL: now) * @return ~array Array of section, type and message responses (false: nothing) */ function run($timestamp = NULL) { if (!addon_installed('chat')) { return false; } if (!is_null(get_value('occle_watched_chatroom'))) { require_lang('chat'); if (is_null($timestamp)) { $timestamp = time(); } $room = intval(get_value('occle_watched_chatroom')); $room_messages = $GLOBALS['SITE_DB']->query('SELECT COUNT(*) AS cnt FROM ' . get_table_prefix() . 'chat_messages WHERE room_id=' . strval($room) . ' AND date_and_time>=' . strval((int) $timestamp)); if (!array_key_exists(0, $room_messages)) { return false; } if ($room_messages[0]['cnt'] > 0) { $rooms = array(); $messages = $room_messages[0]['cnt']; $room_data = $GLOBALS['SITE_DB']->query_value_null_ok('chat_rooms', 'room_name', array('id' => $room)); if (is_null($room_data)) { return false; } // Selected room deleted $rooms[$room_data] = build_url(array('page' => 'chat', 'type' => 'room', 'id' => $room), get_module_zone('chat')); return array(do_lang('SECTION_CHAT'), do_lang('NEW_MESSAGES'), do_template('OCCLE_CHAT_NOTIFICATION', array('MESSAGE_COUNT' => integer_format($messages), 'ROOMS' => $rooms))); } else { return false; } } else { return false; } }
/** * Standard modular run function. * * @return array An array of tuples: The task row to show, the number of seconds until it is due (or NULL if not on a timer), the number of things to sort out (or NULL if not on a queue), The name of the config option that controls the schedule (or NULL if no option). */ function run() { if (!addon_installed('iotds')) { return array(); } if (get_option('iotd_update_time') == '') { return array(); } require_lang('iotds'); $date = $GLOBALS['SITE_DB']->query_value_null_ok('iotd', 'date_and_time', array('is_current' => 1)); $limit_hours = intval(get_option('iotd_update_time')); $seconds_ago = mixed(); if (!is_null($date)) { $seconds_ago = time() - $date; $status = $seconds_ago > $limit_hours * 60 * 60 ? 0 : 1; } else { $status = 0; } $_status = $status == 0 ? do_template('BLOCK_MAIN_STAFF_CHECKLIST_ITEM_STATUS_0') : do_template('BLOCK_MAIN_STAFF_CHECKLIST_ITEM_STATUS_1'); $config_row = $GLOBALS['SITE_DB']->query_select('config', array('the_page', 'section'), array('the_name' => 'iotd_update_time'), '', 1); if (array_key_exists(0, $config_row)) { $_config_url = build_url(array('page' => 'admin_config', 'type' => 'category', 'id' => $config_row[0]['the_page']), get_module_zone('admin_config')); $config_url = $_config_url->evaluate(); $config_url .= '#group_' . $config_row[0]['section']; } else { $config_url = NULL; } $url = build_url(array('page' => 'cms_iotds', 'type' => 'ed'), get_module_zone('cms_iotds')); $num_queue = $this->get_num_iotd_queue(); list($info, $seconds_due_in) = staff_checklist_time_ago_and_due($seconds_ago, $limit_hours); $info->attach(do_lang_tempcode('NUM_QUEUE', integer_format($num_queue))); $tpl = do_template('BLOCK_MAIN_STAFF_CHECKLIST_ITEM', array('_GUID' => '5c55aed7bedca565c8aa553548b88e64', 'CONFIG_URL' => $config_url, 'URL' => $url, 'STATUS' => $_status, 'TASK' => do_lang_tempcode('PT_choose_iotd'), 'INFO' => $info)); return array(array($tpl, $seconds_due_in, NULL, 'iotd_update_time')); }
/** * Standard modular run function. * * @return array An array of tuples: The task row to show, the number of seconds until it is due (or NULL if not on a timer), the number of things to sort out (or NULL if not on a queue), The name of the config option that controls the schedule (or NULL if no option). */ function run() { if (!addon_installed('backup')) { return array(); } if (get_option('backup_time', true) == '') { return array(); } $limit_hours = intval(get_option('backup_time', true)); require_lang('backups'); $date = intval(get_value('last_backup')); $seconds_ago = mixed(); if ($date != 0) { $seconds_ago = time() - $date; $status = intval($seconds_ago) > $limit_hours * 60 * 60 ? 0 : 1; } else { $status = 0; } $_status = $status == 0 ? do_template('BLOCK_MAIN_STAFF_CHECKLIST_ITEM_STATUS_0') : do_template('BLOCK_MAIN_STAFF_CHECKLIST_ITEM_STATUS_1'); $config_row = $GLOBALS['SITE_DB']->query_select('config', array('the_page', 'section'), array('the_name' => 'backup_time'), '', 1); if (array_key_exists(0, $config_row)) { $_config_url = build_url(array('page' => 'admin_config', 'type' => 'category', 'id' => $config_row[0]['the_page']), get_module_zone('admin_config')); $config_url = $_config_url->evaluate(); $config_url .= '#group_' . $config_row[0]['section']; } else { $config_url = NULL; } $url = build_url(array('page' => 'admin_backup', 'type' => 'misc'), 'adminzone'); list($info, $seconds_due_in) = staff_checklist_time_ago_and_due($seconds_ago, $limit_hours); $tpl = do_template('BLOCK_MAIN_STAFF_CHECKLIST_ITEM', array('_GUID' => '432685ec6c9f7548ce8b488b6ce00030', 'CONFIG_URL' => $config_url, 'URL' => $url, 'STATUS' => $_status, 'TASK' => do_lang_tempcode('BACKUP'), 'INFO' => $info)); return array(array($tpl, $seconds_due_in, NULL, 'backup_time')); }
/** * Standard modular run function for award hooks. Renders a content box for an award/randomisation. * * @param array The database row for the content * @param ID_TEXT The zone to display in * @return tempcode Results */ function run($row, $zone) { unset($zone); require_code('ocf_groups'); $url = build_url(array('page' => 'groups', 'type' => 'view', 'id' => $row['id']), get_module_zone('groups')); return put_in_standard_box(do_template('SIMPLE_PREVIEW_BOX', array('SUMMARY' => get_translated_text($row['g_name'], $GLOBALS['FORUM_DB']), 'URL' => $url)), ocf_get_group_name($row['id'])); }
/** * Standard modular run function. * * @return array An array of tuples: The task row to show, the number of seconds until it is due (or NULL if not on a timer), the number of things to sort out (or NULL if not on a queue), The name of the config option that controls the schedule (or NULL if no option). */ function run() { if (!addon_installed('ocf_forum')) { return array(); } if (get_forum_type() != 'ocf') { return array(); } require_lang('ocf_config'); $forum_id = $GLOBALS['FORUM_DRIVER']->forum_id_from_name(get_option('reported_posts_forum')); if (is_null($forum_id)) { return array(); } $where = 't_forum_id=' . strval($forum_id) . ' AND t_is_open=1'; $query = 'SELECT COUNT(*) FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_topics WHERE ' . $where; $outstanding = $GLOBALS['FORUM_DB']->query_value_null_ok_full($query); if ($outstanding > 0) { $status = do_template('BLOCK_MAIN_STAFF_CHECKLIST_ITEM_STATUS_0', array('_GUID' => 'e578142633c6f3d37776e82a869deb91')); } else { $status = do_template('BLOCK_MAIN_STAFF_CHECKLIST_ITEM_STATUS_1', array('_GUID' => 'f578142633c6f3d37776e82a869deb91')); } $url = $GLOBALS['FORUM_DRIVER']->forum_url($forum_id); $tpl = do_template('BLOCK_MAIN_STAFF_CHECKLIST_ITEM', array('URL' => $url, 'STATUS' => $status, 'TASK' => do_lang_tempcode('REPORTED_POSTS_FORUM'), 'INFO' => do_lang_tempcode('NUM_QUEUE', escape_html(integer_format($outstanding))))); return array(array($tpl, NULL, $outstanding, NULL)); }
/** * Get a netlink block / direct to a netlink site. * * @param URLPATH The URL we grab our netlink from. If this is not blank, instead of getting a netlink block, we direct to a netlink site. * @return tempcode The netlink block */ function do_netlink($redir_url = '') { header('Content-type: text/plain; charset=' . get_charset()); // If we are redirecting if ($redir_url != '') { if (strpos($redir_url, chr(10)) !== false || strpos($redir_url, chr(13)) !== false) { log_hack_attack_and_exit('HEADER_SPLIT_HACK'); } header('Location: ' . $redir_url); exit; } // Ok we're displaying a netlink, which will be dumped right into the body of the reading site // - this isn't actually a weburl that is actually displayed, its loaded by ocPortal and embedded-inline // For all the names in our network require_code('textfiles'); $lines = explode(chr(10), read_text_file('netlink', NULL, true)); if (count($lines) == 0) { return new ocp_tempcode(); } $content = new ocp_tempcode(); foreach ($lines as $line) { $parts = explode('=', $line, 2); if (count($parts) != 2) { continue; } $name = rtrim($parts[0]); $url = trim($parts[1]); // Are we looking at the source site in the network? $selected = strtolower($url) == strtolower(get_param('source', '')); $content->attach(form_input_list_entry(base64_encode($url), $selected, $name)); } return do_template('NETLINK', array('_GUID' => '180321222dc5dc99a231597c803f0726', 'CONTENT' => $content)); }
/** * Standard modular run function. * * @return tempcode The result of execution. */ function run() { if (!addon_installed('downloads')) { return new ocp_tempcode(); } require_lang('downloads'); require_code('downloads_stats'); $bits = new ocp_tempcode(); if (get_option('downloads_show_stats_count_total', true) == '1') { $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('_GUID' => 'ff2bd884d88ddc8c5a81cff897f99a5a', 'KEY' => do_lang_tempcode('COUNT_TOTAL'), 'VALUE' => integer_format(get_num_archive_downloads())))); } if (get_option('downloads_show_stats_count_archive', true) == '1') { $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('_GUID' => '3d221f2145581a3af51c8948f28b7ac7', 'KEY' => do_lang_tempcode('COUNT_ARCHIVE'), 'VALUE' => get_download_archive_size()))); } if (get_option('downloads_show_stats_count_downloads', true) == '1') { $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('_GUID' => '47c544ef053f9be47e2c48c3a694da1c', 'KEY' => do_lang_tempcode('COUNT_DOWNLOADS'), 'VALUE' => integer_format(get_num_downloads_downloaded())))); } if (get_option('downloads_show_stats_count_bandwidth', true) == '1') { $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('_GUID' => 'b2589ae83652953ece220267043d75c9', 'KEY' => do_lang_tempcode('COUNT_BANDWIDTH'), 'VALUE' => clean_file_size(get_download_bandwidth())))); } if ($bits->is_empty()) { return new ocp_tempcode(); } $files = do_template('BLOCK_SIDE_STATS_SECTION', array('_GUID' => '99ae3f35b3e5eda18901e97ac385d99c', 'SECTION' => do_lang_tempcode('SECTION_DOWNLOADS'), 'CONTENT' => $bits)); return $files; }
/** * Get a splurghified version of the specified item. * * @param string The name of what the key we want to reference is in our array of maps (e.g. 'id') * @param array A row of maps for data we are splurghing; this is probably just the result of $GLOBALS['SITE_DB']->query_select * @param URLPATH The stub that links will be passed through * @param ID_TEXT The page name we will be saving customised HTML under * @param TIME The time we did our last change to the data being splurghed (so it can see if we can simply decache instead of deriving) * @param ?AUTO_LINK The ID that is at the root of our tree (NULL: db_get_first_id) * @return string A string of HTML that represents our splurghing (will desplurgh in the users browser) */ function splurgh_master_build($key_name, $map, $url_stub, $_cache_file, $last_change_time, $first_id = NULL) { if (is_null($first_id)) { $first_id = db_get_first_id(); } if (!array_key_exists($first_id, $map)) { return ''; } if (!has_js()) { warn_exit(do_lang_tempcode('MSG_JS_NEEDED')); } require_javascript('javascript_splurgh'); if (is_browser_decacheing()) { $last_change_time = time(); } $cache_file = zone_black_magic_filterer(get_custom_file_base() . '/' . get_zone_name() . '/pages/html_custom/' . filter_naughty(user_lang()) . '/' . filter_naughty($_cache_file) . '.htm'); if (!file_exists($cache_file) || is_browser_decacheing() || filesize($cache_file) == 0 || $last_change_time > filemtime($cache_file)) { $myfile = @fopen($cache_file, 'wt'); if ($myfile === false) { intelligent_write_error($cache_file); } $fulltable = array(); $splurgh = _splurgh_do_node($map, $first_id, '', $fulltable, 0); $page = do_template('SPLURGH', array('_GUID' => '8775edfc5a386fdf2cec69b0fc889952', 'KEY_NAME' => $key_name, 'URL_STUB' => $url_stub, 'SPLURGH' => str_replace('"', '\'', $splurgh))); $ev = $page->evaluate(); if (fwrite($myfile, $ev) < strlen($ev)) { warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE')); } fclose($myfile); fix_permissions($cache_file); sync_file($cache_file); return $ev; } return file_get_contents($cache_file, FILE_TEXT); }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { $url = array_key_exists('param', $map) ? $map['param'] : 'http://ocportal.com/backend.php?type=rss&mode=news&filter=16,17,18,19,20'; // http://channel9.msdn.com/Feeds/RSS/ require_code('rss'); $rss = new rss($url); if (!is_null($rss->error)) { return paragraph($rss->error, 'gfgrtyhyyfhd'); } global $NEWS_CATS; $NEWS_CATS = $GLOBALS['SITE_DB']->query_select('news_categories', array('*'), array('nc_owner' => NULL)); $NEWS_CATS = list_to_map('id', $NEWS_CATS); $_postdetailss = array(); // Now for the actual stream contents $max = array_key_exists('max_entries', $map) ? intval($map['max_entries']) : 10; $content = new ocp_tempcode(); foreach ($rss->gleamed_items as $i => $item) { if ($i >= $max) { break; } if (array_key_exists('full_url', $item)) { $full_url = $item['full_url']; } elseif (array_key_exists('guid', $item)) { $full_url = $item['guid']; } elseif (array_key_exists('comment_url', $item)) { $full_url = $item['comment_url']; } else { $full_url = ''; } $_title = $item['title']; $date = array_key_exists('clean_add_date', $item) ? get_timezoned_date($item['clean_add_date']) : array_key_exists('add_date', $item) ? $item['add_date'] : ''; $_postdetailss[] = array('DATE' => $date, 'FULL_URL' => $full_url, 'NEWS_TITLE' => $_title); } return do_template('BLOCK_BOTTOM_NEWS', array('_GUID' => '0fc123199c4d4b7af5a26706271b1f4f', 'POSTS' => $_postdetailss)); }
/** * Standard modular run function for RSS hooks. * * @param string A list of categories we accept from * @param TIME Cutoff time, before which we do not show results from * @param string Prefix that represents the template set we use * @set RSS_ ATOM_ * @param string The standard format of date to use for the syndication type represented in the prefix * @param integer The maximum number of entries to return, ordering by date * @return ?array A pair: The main syndication section, and a title (NULL: error) */ function run($_filters, $cutoff, $prefix, $date_string, $max) { if (!addon_installed('galleries')) { return NULL; } if (!has_actual_page_access(get_member(), 'galleries')) { return NULL; } $filters_1 = ocfilter_to_sqlfragment($_filters, 'name', 'galleries', 'parent_id', 'name', 'name', false, false); // Note that the parameters are fiddled here so that category-set and record-set are the same, yet SQL is returned to deal in an entirely different record-set (entries' record-set) $filters = ocfilter_to_sqlfragment($_filters, 'cat', 'galleries', 'parent_id', 'cat', 'name', false, false); // Note that the parameters are fiddled here so that category-set and record-set are the same, yet SQL is returned to deal in an entirely different record-set (entries' record-set) require_lang('galleries'); $content = new ocp_tempcode(); $_galleries = array(); if ($GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . get_table_prefix() . 'galleries WHERE ' . $filters_1) < 3000) { $_galleries = $GLOBALS['SITE_DB']->query('SELECT fullname,name FROM ' . get_table_prefix() . 'galleries WHERE ' . $filters_1); foreach ($_galleries as $i => $_gallery) { $_galleries[$i]['text_original'] = get_translated_text($_gallery['fullname']); } } $galleries = collapse_2d_complexity('name', 'text_original', $_galleries); $rows1 = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'videos WHERE add_date>' . strval((int) $cutoff) . ' AND ' . $filters . (!has_specific_permission(get_member(), 'see_unvalidated') ? ' AND validated=1 ' : '') . ' ORDER BY add_date DESC', $max); $rows2 = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'images WHERE add_date>' . strval((int) $cutoff) . ' AND ' . $filters . (!has_specific_permission(get_member(), 'see_unvalidated') ? ' AND validated=1 ' : '') . ' ORDER BY add_date DESC', $max); $rows = array_merge($rows1, $rows2); foreach ($rows as $row) { $id = strval($row['id']); $author = $GLOBALS['FORUM_DRIVER']->get_username($row['submitter']); if (is_null($author)) { $author = ''; } $news_date = date($date_string, $row['add_date']); $edit_date = is_null($row['edit_date']) ? '' : date($date_string, $row['edit_date']); $news_title = xmlentities(do_lang('THIS_WITH_SIMPLE', array_key_exists('video_views', $row) ? do_lang('VIDEO') : do_lang('IMAGE'), strval($row['id']))); $_summary = get_translated_tempcode($row['comments']); $summary = xmlentities($_summary->evaluate()); $news = ''; if (!array_key_exists($row['cat'], $galleries)) { $_fullname = $GLOBALS['SITE_DB']->query_value_null_ok('galleries', 'fullname', array('name' => $row['cat'])); if (is_null($_fullname)) { continue; } $galleries[$row['cat']] = get_translated_text($_fullname); } $category = $galleries[$row['cat']]; $category_raw = $row['cat']; $view_url = build_url(array('page' => 'galleries', 'type' => array_key_exists('video_views', $row) ? 'video' : 'image', 'id' => $row['id']), get_module_zone('galleries'), NULL, false, false, true); if ($prefix == 'RSS_' && get_option('is_on_comments') == '1' && $row['allow_comments'] >= '1') { $if_comments = do_template('RSS_ENTRY_COMMENTS', array('_GUID' => '65dc0cec8c75f565c58c95fa1667aa1e', 'COMMENT_URL' => $view_url, 'ID' => strval($row['id']))); } else { $if_comments = new ocp_tempcode(); } require_code('images'); $enclosure_url = ensure_thumbnail($row['url'], $row['thumb_url'], 'galleries', array_key_exists('video_views', $row) ? 'videos' : 'images', $row['id']); list($enclosure_length, $enclosure_type) = get_enclosure_details($row['url'], $enclosure_url); $content->attach(do_template($prefix . 'ENTRY', array('ENCLOSURE_URL' => $enclosure_url, 'ENCLOSURE_LENGTH' => $enclosure_length, 'ENCLOSURE_TYPE' => $enclosure_type, 'VIEW_URL' => $view_url, 'SUMMARY' => $summary, 'EDIT_DATE' => $edit_date, 'IF_COMMENTS' => $if_comments, 'TITLE' => $news_title, 'CATEGORY_RAW' => $category_raw, 'CATEGORY' => $category, 'AUTHOR' => $author, 'ID' => $id, 'NEWS' => $news, 'DATE' => $news_date))); } require_lang('galleries'); return array($content, do_lang('GALLERIES')); }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { require_code('downloads'); require_css('downloads'); require_lang('downloads'); $zone = array_key_exists('zone', $map) ? $map['zone'] : get_module_zone('downloads'); global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'max'; $max = get_param_integer('max', 10); if ($max < 1) { $max = 1; } $start = get_param_integer('start', 0); $rows = $GLOBALS['SITE_DB']->query_select('download_downloads', array('*'), array('validated' => 1), 'ORDER BY num_downloads DESC', $max, $start); $content = new ocp_tempcode(); foreach ($rows as $i => $row) { if ($i != 0) { $content->attach(do_template('BLOCK_SEPARATOR')); } $content->attach(get_download_html($row, true, true, $zone)); } $page_num = intval(floor(floatval($start) / floatval($max))) + 1; $count = $GLOBALS['SITE_DB']->query_value('download_downloads', 'COUNT(*)', array('validated' => 1)); $num_pages = intval(ceil(floatval($count) / floatval($max))); if ($num_pages == 0) { $page_num = 0; } $previous_url = $start == 0 ? new ocp_tempcode() : build_url(array('page' => '_SELF', 'start' => $start - $max), '_SELF'); $next_url = $page_num == $num_pages ? new ocp_tempcode() : build_url(array('page' => '_SELF', 'start' => $start + $max), '_SELF'); $browse = do_template('NEXT_BROWSER_BROWSE_NEXT', array('_GUID' => '15ca70ec400629f67edefa869fb1f1a8', 'NEXT_LINK' => $next_url, 'PREVIOUS_LINK' => $previous_url, 'PAGE_NUM' => integer_format($page_num), 'NUM_PAGES' => integer_format($num_pages))); return do_template('BLOCK_MAIN_DOWNLOAD_TEASE', array('_GUID' => 'a164e33c0b4ace4bae945c39f2f00ca9', 'CONTENT' => $content, 'BROWSE' => $browse)); }
/** * Standard modular run function. * * @return array An array of tuples: The task row to show, the number of seconds until it is due (or NULL if not on a timer), the number of things to sort out (or NULL if not on a queue), The name of the config option that controls the schedule (or NULL if no option). */ function run() { if (!addon_installed('tickets')) { return array(); } require_lang('tickets'); require_code('tickets'); require_code('tickets2'); $outstanding = 0; $tickets = get_tickets(get_member(), NULL, false, true); if (!is_null($tickets)) { foreach ($tickets as $topic) { if ($topic['closed'] == 0) { $outstanding++; } } } if ($outstanding > 0) { $status = do_template('BLOCK_MAIN_STAFF_CHECKLIST_ITEM_STATUS_0', array('_GUID' => 'g578142633c6f3d37776e82a869deb91')); } else { $status = do_template('BLOCK_MAIN_STAFF_CHECKLIST_ITEM_STATUS_1', array('_GUID' => 'h578142633c6f3d37776e82a869deb91')); } $url = build_url(array('page' => 'tickets', 'type' => 'misc'), get_module_zone('tickets')); $tpl = do_template('BLOCK_MAIN_STAFF_CHECKLIST_ITEM', array('URL' => $url, 'STATUS' => $status, 'TASK' => do_lang_tempcode('SUPPORT_TICKETS'), 'INFO' => do_lang_tempcode('NUM_QUEUE', escape_html(integer_format($outstanding))))); return array(array($tpl, NULL, $outstanding, NULL)); }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { require_code('downloads'); require_css('downloads'); require_lang('downloads'); require_code('ocfiltering'); $number = array_key_exists('param', $map) ? intval($map['param']) : 10; $filter = array_key_exists('filter', $map) ? $map['filter'] : '*'; $zone = array_key_exists('zone', $map) ? $map['zone'] : get_module_zone('downloads'); $sql_filter = ocfilter_to_sqlfragment($filter, 'p.category_id', 'download_categories', 'parent_id', 'p.category_id', 'id'); // Note that the parameters are fiddled here so that category-set and record-set are the same, yet SQL is returned to deal in an entirely different record-set (entries' record-set) $rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . get_table_prefix() . 'download_downloads p WHERE validated=1 AND (' . $sql_filter . ') ORDER BY add_date DESC', $number); $title = do_lang_tempcode('RECENT', make_string_tempcode(integer_format($number)), do_lang_tempcode('SECTION_DOWNLOADS')); if (array_key_exists('title', $map) && $map['title'] != '') { $title = protect_from_escaping(escape_html($map['title'])); } $out = new ocp_tempcode(); foreach ($rows as $i => $row) { if ($i != 0) { $out->attach(do_template('BLOCK_SEPARATOR')); } $out->attach(get_download_html($row, true, true, $zone)); } if ($out->is_empty()) { if (has_actual_page_access(NULL, 'cms_downloads', NULL, NULL) && has_submit_permission('mid', get_member(), get_ip_address(), 'cms_downloads')) { $submit_url = build_url(array('page' => 'cms_downloads', 'type' => 'ad', 'redirect' => SELF_REDIRECT), get_module_zone('cms_downloads')); } else { $submit_url = new ocp_tempcode(); } return do_template('BLOCK_NO_ENTRIES', array('_GUID' => '74399763a51102bdd6e6d92c2c11354f', 'HIGH' => false, 'TITLE' => $title, 'MESSAGE' => do_lang_tempcode('NO_DOWNLOADS_YET'), 'ADD_NAME' => do_lang_tempcode('ADD_DOWNLOAD'), 'SUBMIT_URL' => $submit_url)); } return do_template('BLOCK_MAIN_RECENT_DOWNLOADS', array('_GUID' => '257fa1b83d1b6fe3acbceb2b618e6d7f', 'TITLE' => $title, 'CONTENT' => $out, 'NUMBER' => integer_format($number))); }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { unset($map); require_css('side_blocks'); $langs = nice_get_langs(user_lang()); return do_template('BLOCK_SIDE_LANGUAGE', array('_GUID' => '5dd7dd434722d7fd958773bd08e838c7', 'LANGS' => $langs)); }
/** * Run the loader, to load up field-restrictions from the XML file. * * @param string The default breadcrumbs * @param string The breadcrumb XML data */ function go($current_breadcrumbs, $data) { $this->tag_stack = array(); $this->attribute_stack = array(); $this->substitution_current_match_key = NULL; $this->substitution_current_label = NULL; $this->links = array(); $this->substitutions = array(); $breadcrumb_tpl = do_template('BREADCRUMB_ESCAPED'); $this->breadcrumb_tpl = $breadcrumb_tpl->evaluate(); $this->current_breadcrumbs = $current_breadcrumbs; // Create and setup our parser $xml_parser = @xml_parser_create(); if ($xml_parser === false) { return; // PHP5 default build on windows comes with this function disabled, so we need to be able to escape on error } xml_set_object($xml_parser, $this); @xml_parser_set_option($xml_parser, XML_OPTION_TARGET_ENCODING, get_charset()); @xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, 0); xml_set_element_handler($xml_parser, 'startElement', 'endElement'); xml_set_character_data_handler($xml_parser, 'startText'); // Run the parser if (@xml_parse($xml_parser, $data, true) == 0) { attach_message('breadcrumbs.xml: ' . xml_error_string(xml_get_error_code($xml_parser)), 'warn'); return; } @xml_parser_free($xml_parser); }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { require_code('catalogues'); require_lang('catalogues'); require_css('catalogues'); $number = array_key_exists('param', $map) ? intval($map['param']) : 10; $catalogue = array_key_exists('catalogue', $map) ? $map['catalogue'] : 'faqs'; $zone = array_key_exists('zone', $map) ? $map['zone'] : get_module_zone('catalogues'); $root = array_key_exists('root', $map) && $map['root'] != '' ? intval($map['root']) : NULL; $catalogues = $GLOBALS['SITE_DB']->query_select('catalogues', array('*'), array('c_name' => $catalogue), '', 1); if (!array_key_exists(0, $catalogues)) { return do_lang_tempcode('MISSING_RESOURCE', escape_html($catalogue)); } $catalogue_row = $catalogues[0]; $entries = $GLOBALS['SITE_DB']->query_select('catalogue_entries', array('*'), array('c_name' => $catalogue, 'ce_validated' => 1), 'ORDER BY ce_add_date DESC', $number); $tpl_set = $catalogue; $display_type = array_key_exists('display_type', $map) ? intval($map['display_type']) : NULL; list($content, , ) = get_catalogue_category_entry_buildup(db_get_first_id(), $catalogue, $catalogue_row, 'SEARCH', $tpl_set, $number, 0, NULL, $root, $display_type, false, $entries); $catalogue_title = get_translated_text($catalogue_row['c_title']); if ($content->is_empty()) { if (has_actual_page_access(NULL, 'cms_catalogues', NULL, NULL) && has_submit_permission('mid', get_member(), get_ip_address(), 'cms_catalogues')) { $submit_url = build_url(array('page' => 'cms_catalogues', 'type' => 'add_entry', 'catalogue_name' => $catalogue, 'redirect' => SELF_REDIRECT), get_module_zone('cms_catalogues')); } else { $submit_url = new ocp_tempcode(); } return do_template('BLOCK_NO_ENTRIES', array('HIGH' => false, 'TITLE' => do_lang_tempcode('RECENT', escape_html(integer_format($number)), escape_html($catalogue_title)), 'MESSAGE' => do_lang_tempcode('NO_ENTRIES'), 'ADD_NAME' => do_lang_tempcode('CATALOGUE_GENERIC_ADD', escape_html($catalogue_title)), 'SUBMIT_URL' => $submit_url)); } return do_template('BLOCK_MAIN_RECENT_CC_ENTRIES', array('_GUID' => 'a57fa1b83d1b6fe3acbceb2b618e6d7f', 'CATALOGUE_TITLE' => $catalogue_title, 'CATALOGUE' => $catalogue, 'CONTENT' => $content, 'NUMBER' => integer_format($number))); }
/** * Standard modular run function. * * @return array An array of tuples: The task row to show, the number of seconds until it is due (or NULL if not on a timer), the number of things to sort out (or NULL if not on a queue), The name of the config option that controls the schedule (or NULL if no option). */ function run() { if (!addon_installed('flagrant')) { return array(); } require_lang('flagrant'); $rows = $GLOBALS['SITE_DB']->query_select('text', array('activation_time', 'days'), array('active_now' => 1), '', NULL, NULL, true); if (is_null($rows)) { return array(); } $seconds_due_in = mixed(); if (array_key_exists(0, $rows)) { $activation_time = $rows[0]['activation_time']; $days = $rows[0]['days']; $date = $activation_time + $days * 24 * 60 * 60; $seconds_due_in = $date - time(); $status = $seconds_due_in <= 0 ? 0 : 1; } else { $status = 1; } $_status = $status == 0 ? do_template('BLOCK_MAIN_STAFF_CHECKLIST_ITEM_STATUS_0') : do_template('BLOCK_MAIN_STAFF_CHECKLIST_ITEM_STATUS_1'); $url = build_url(array('page' => 'admin_flagrant', 'type' => 'misc'), 'adminzone'); $num_queue = $this->get_num_flagrant_queue(); list($info, $seconds_due_in) = staff_checklist_time_ago_and_due($seconds_due_in); $info->attach(do_lang_tempcode('NUM_QUEUE', escape_html(integer_format($num_queue)))); $tpl = do_template('BLOCK_MAIN_STAFF_CHECKLIST_ITEM', array('_GUID' => '820e0e3cd80754dc7dfd9a0d05a43ec0', 'URL' => $url, 'STATUS' => $_status, 'TASK' => do_lang_tempcode('CHOOSE_FLAGRANT'), 'INFO' => $info)); return array(array($tpl, $seconds_due_in, NULL, NULL)); }
/** * Standard modular run function. * * @param MEMBER The ID of the member we are getting detail hooks for * @return ?tempcode Results (NULL: no action) */ function run($member_id) { global $OCWORLD_MEMBER_CACHE; if (!isset($OCWORLD_MEMBER_CACHE)) { $OCWORLD_MEMBER_CACHE = array(); } if (array_key_exists($member_id, $OCWORLD_MEMBER_CACHE)) { return $OCWORLD_MEMBER_CACHE[$member_id]; } $zone = get_page_zone('ocworld', false); if (is_null($zone)) { return NULL; } if (!has_zone_access(get_member(), $zone)) { return NULL; } $rows = $GLOBALS['SITE_DB']->query_select('w_members m LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'w_realms r ON m.location_realm=r.id', array('*'), array('m.id' => $member_id), '', 1, 0, true); if (!is_null($rows) && array_key_exists(0, $rows)) { $row = $rows[0]; $room = $GLOBALS['SITE_DB']->query_value_null_ok('w_rooms', 'name', array('location_x' => $row['location_x'], 'location_y' => $row['location_y'], 'location_realm' => $row['location_realm'])); if (is_null($room)) { return NULL; } require_lang('ocworld'); $a = do_template('OCF_TOPIC_POST_CUSTOM_FIELD', array('_GUID' => '3d36d5ae8bcb66d59a0676200571fb1a', 'NAME' => do_lang_tempcode('_W_ROOM'), 'VALUE' => do_lang_tempcode('W_ROOM_COORD', escape_html($room), strval($row['location_realm']), array(strval($row['location_x']), strval($row['location_y']))))); $b = do_template('OCF_TOPIC_POST_CUSTOM_FIELD', array('_GUID' => '72c62771f7796d69d1f1a616c2591206', 'NAME' => do_lang_tempcode('_W_REALM'), 'VALUE' => $row['name'])); $a->attach($b); $OCWORLD_MEMBER_CACHE[$member_id] = $a; return $a; } return NULL; }
/** * Standard modular run function for preview hooks. * * @return array A pair: The preview, the updated post Comcode */ function run() { require_code('uploads'); $urls = get_url('', 'file', 'uploads/iotds', 0, OCP_UPLOAD_IMAGE, true, '', 'file2'); if ($urls[0] == '') { if (!is_null(post_param_integer('id', NULL))) { $rows = $GLOBALS['SITE_DB']->query_select('iotds', array('url', 'thumb_url'), array('id' => post_param_integer('id')), '', 1); $urls = $rows[0]; $url = $urls['url']; $thumb_url = $urls['thumb_url']; } else { warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN_UPLOAD')); } } else { $url = $urls[0]; $thumb_url = $urls[1]; } $caption = comcode_to_tempcode(post_param('caption', '')); $title = comcode_to_tempcode(post_param('title', '')); require_code('images'); $thumb = do_image_thumb(url_is_local($thumb_url) ? get_custom_base_url() . '/' . $thumb_url : $thumb_url, $caption, true); $url = url_is_local($url) ? get_custom_base_url() . '/' . $url : $url; $preview = do_template('IOTD', array('ID' => '', 'IMAGE_URL' => $url, 'SUBMITTER' => strval(get_member()), 'VIEW_URL' => $url, 'IMAGE' => $thumb, 'CAPTION' => $title)); return array($preview, NULL); }
/** * Convert a field value to something renderable. * * @param array The field details * @param mixed The raw value * @return mixed Rendered field (tempcode or string) */ function render_field_value($field, $ev) { if ($ev == '') { return new ocp_tempcode(); } return do_template('HYPERLINK_EMAIL', array('_GUID' => 'f074c9a299fb3b1836a5a76270378666', 'VALUE' => $ev)); }