/** * Standard modular run function for do_next_menu hooks. They find links to put on standard navigation menus of the system. * * @param boolean Whether to look deep into the database (or whatever else might be time-intensive) for links * @return array Array of links and where to show */ function run($exhaustive = false) { if (!addon_installed('catalogues')) { return array(); } $ret = array(); if (has_specific_permission(get_member(), 'submit_cat_highrange_content', 'cms_catalogues')) { $ret[] = array('cms', 'catalogues', array('cms_catalogues', array('type' => 'misc'), get_module_zone('cms_catalogues')), do_lang_tempcode('ITEMS_HERE', do_lang_tempcode('CATALOGUES'), make_string_tempcode(escape_html(integer_format($GLOBALS['SITE_DB']->query_value_null_ok('catalogues', 'COUNT(*)', NULL, '', true))))), 'DOC_CATALOGUES'); } if ($exhaustive) { $catalogues = $GLOBALS['SITE_DB']->query_select('catalogues', array('c_name', 'c_title', 'c_description', 'c_ecommerce'), NULL, '', 10, NULL, true); if (!is_null($catalogues)) { $ret2 = array(); foreach ($catalogues as $row) { if (substr($row['c_name'], 0, 1) == '_') { continue; } if ($row['c_ecommerce'] == 0 || addon_installed('shopping')) { if (has_submit_permission('mid', get_member(), get_ip_address(), 'cms_catalogues', array('catalogues_catalogue', $row['c_name']))) { $ret2[] = array('cms', 'of_catalogues', array('cms_catalogues', array('type' => 'misc', 'catalogue_name' => $row['c_name']), get_module_zone('cms_catalogues')), do_lang_tempcode('ITEMS_HERE', escape_html(get_translated_text($row['c_title'])), escape_html(integer_format($GLOBALS['SITE_DB']->query_value_null_ok('catalogue_entries', 'COUNT(*)', array('c_name' => $row['c_name']), '', true)))), get_translated_text($row['c_description'])); } } } if (count($ret2) < 10) { $ret = array_merge($ret, $ret2); } } } return $ret; }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { require_lang('amazon'); if (!array_key_exists('associates_id', $map)) { return do_lang_tempcode('NO_PARAMETER_SENT', 'associates_id'); } if (!array_key_exists('product_line', $map)) { return do_lang_tempcode('NO_PARAMETER_SENT', 'product_line'); } if (!array_key_exists('subject_keywords', $map)) { return do_lang_tempcode('NO_PARAMETER_SENT', 'subject_keywords'); } if (!array_key_exists('items_number', $map)) { return do_lang_tempcode('NO_PARAMETER_SENT', 'items_number'); } $associates_id = $map['associates_id']; //'we4u-20';// $product_line = $map['product_line']; $subject_keywords = preg_replace('#\\s#', '+', $map['subject_keywords']); $n = isset($map['items_number']) && intval($map['items_number']) > 0 ? $map['items_number'] : 3; $out = ''; for ($i = 0; $i < $n; $i++) { $out .= '<iframe src="http://rcm.amazon.com/e/cm?lt1=_blank&t=' . escape_html($associates_id) . '&o=1&p=8&l=st1&mode=' . escape_html($product_line) . '&search=' . $subject_keywords . '&t1=_blank&lc1=00FFFF&bg1=FFFFFF&f=ifr" marginwidth="0" marginheight="0" width="120px" height="240" border="0" frameborder="0" style="width: 120px; border:none;" scrolling="no"></iframe><br /><br />'; } return do_template('BLOCK_SIDE_AMAZON_AFFILIATES', array('TITLE' => do_lang_tempcode('BLOCK_AMAZON_AFFILIATE_SALES_TITLE'), 'CONTENT' => $out, 'ASSOCIATES_ID' => $associates_id, 'PRODUCT_LINE' => $product_line, 'SUBJECT_KEYWORDS' => $subject_keywords)); }
/** * Check a post would be valid. * * @param LONG_TEXT The post. * @param ?AUTO_LINK The ID of the topic the post would be in (NULL: don't check with regard to any particular topic). * @param ?MEMBER The poster (NULL: current member). * @return ?array Row of the existing post if a double post (single row map-element in a list of rows) (NULL: not a double post). */ function ocf_check_post($post, $topic_id = NULL, $poster = NULL) { if (is_null($poster)) { $poster = get_member(); } require_code('comcode_check'); check_comcode($post, NULL, false, NULL, true); if (strlen($post) == 0) { warn_exit(do_lang_tempcode('POST_TOO_SHORT')); } require_code('ocf_groups'); if (strlen($post) > ocf_get_member_best_group_property($poster, 'max_post_length_comcode')) { warn_exit(make_string_tempcode(escape_html(do_lang('_POST_TOO_LONG')))); } if (!is_null($topic_id)) { if (running_script('stress_test_loader')) { return NULL; } // Check this isn't the same as the last post here $last_posts = $GLOBALS['FORUM_DB']->query_select('f_posts', array('p_post', 'p_poster', 'p_ip_address'), array('p_topic_id' => $topic_id), 'ORDER BY p_time DESC,id DESC', 1); if (array_key_exists(0, $last_posts)) { if ($last_posts[0]['p_poster'] == $GLOBALS['OCF_DRIVER']->get_guest_id() && get_ip_address() != $last_posts[0]['p_ip_address']) { $last_posts[0]['p_poster'] = -1; } if ($last_posts[0]['p_poster'] == $poster && get_translated_text($last_posts[0]['p_post'], $GLOBALS['FORUM_DB']) == $post && get_param_integer('keep_debug_notifications', 0) != 1) { warn_exit(do_lang_tempcode('DOUBLE_POST_PREVENTED')); } } return $last_posts; } return NULL; }
/** * Standard modular render function for profile tabs edit hooks. * * @param MEMBER The ID of the member who is being viewed * @param MEMBER The ID of the member who is doing the viewing * @param boolean Whether to leave the tab contents NULL, if tis hook supports it, so that AJAX can load it later * @return ?array A tuple: The tab title, the tab body text (may be blank), the tab fields, extra Javascript (may be blank) the suggested tab order, hidden fields (optional) (NULL: if $leave_to_ajax_if_possible was set) */ function render_tab($member_id_of, $member_id_viewing, $leave_to_ajax_if_possible = false) { $title = do_lang_tempcode('DELETE_MEMBER'); $order = 200; // Actualiser $delete_account = post_param_integer('delete', 0); if ($delete_account == 1) { if (is_guest($member_id_of)) { warn_exit(do_lang_tempcode('INTERNAL_ERROR')); } ocf_delete_member($member_id_of); inform_exit(do_lang_tempcode('SUCCESS')); } if ($leave_to_ajax_if_possible) { return NULL; } // UI fields $username = $GLOBALS['FORUM_DRIVER']->get_username($member_id_of); $text = do_lang_tempcode('_DELETE_MEMBER' . ($member_id_of == get_member() ? '_SUICIDAL' : ''), escape_html($username)); $fields = new ocp_tempcode(); require_code('form_templates'); $fields->attach(form_input_tick(do_lang_tempcode('DELETE'), do_lang_tempcode('DESCRIPTION_DELETE'), 'delete', false)); $javascript = ''; return array($title, $fields, $text, $javascript, $order); }
/** * 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))); }
/** * Top level function to (re)generate a Sitemap (xml file, Google-style). */ function sitemaps_build() { $GLOBALS['NO_QUERY_LIMIT'] = true; $path = get_custom_file_base() . '/ocp_sitemap.xml'; if (!file_exists($path)) { if (!is_writable_wrap(dirname($path))) { warn_exit(do_lang_tempcode('WRITE_ERROR_CREATE', escape_html('/'))); } } else { if (!is_writable_wrap($path)) { warn_exit(do_lang_tempcode('WRITE_ERROR', escape_html('ocp_sitemap.xml'))); } } // Runs via a callback mechanism, so we don't need to load an arbitrary complex structure into memory. sitemaps_xml_initialise($path); spawn_page_crawl('pagelink_to_sitemapsxml', $GLOBALS['FORUM_DRIVER']->get_guest_id(), NULL, DEPTH__ENTRIES); sitemaps_xml_finished(); // Ping search engines if (get_option('auto_submit_sitemap') == '1') { $ping = true; $base_url = get_base_url(); $not_local = substr($base_url, 0, 16) != 'http://localhost' && substr($base_url, 0, 16) != 'http://127.0.0.1' && substr($base_url, 0, 15) != 'http://192.168.' && substr($base_url, 0, 10) != 'http://10.'; if ($ping && get_option('site_closed') == '0' && $not_local) { // Submit to search engines $services = array('http://www.google.com/webmasters/tools/ping?sitemap=', 'http://submissions.ask.com/ping?sitemap=', 'http://www.bing.com/webmaster/ping.aspx?siteMap=', 'http://search.yahooapis.com/SiteExplorerService/V1/updateNotification?appid=SitemapWriter&url='); foreach ($services as $service) { http_download_file($service . urlencode(get_custom_base_url() . '/ocp_sitemap.xml'), NULL, 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('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)); }
/** * 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 (is_object($ev)) { return $ev; } return escape_html($ev); }
/** * 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')); }
/** * Standard modular run function for preview hooks. * * @return array A pair: The preview, the updated post Comcode */ function run() { if (!has_specific_permission(get_member(), 'comcode_dangerous')) { exit; } require_code('zones2'); require_code('zones3'); $bparameters = ''; $bparameters_xml = ''; $block = post_param('block'); $parameters = get_block_parameters($block); $parameters[] = 'failsafe'; $parameters[] = 'cache'; $parameters[] = 'quick_cache'; foreach ($parameters as $parameter) { $value = post_param($parameter, NULL); if (is_null($value)) { if (post_param_integer('tick_on_form__' . $parameter, NULL) === NULL) { continue; } // If not on form, continue, otherwise must be 0 $value = '0'; } if ($value != '' && ($parameter != 'failsafe' || $value == '1') && ($parameter != 'cache' || $value != block_cache_default($block)) && ($parameter != 'quick_cache' || $value == '1')) { $bparameters .= ' ' . $parameter . '="' . str_replace('"', '\\"', $value) . '"'; $bparameters_xml = '<blockParam key="' . escape_html($parameter) . '" val="' . escape_html($value) . '" />'; } } $comcode = '[block' . $bparameters . ']' . $block . '[/block]'; $preview = comcode_to_tempcode($comcode); return array($preview, NULL); }
/** * 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 for snippet hooks. Generates XHTML to insert into a page using AJAX. * * @return tempcode The snippet */ function run() { $sup = get_param('block_map_sup', '', true); $_map = get_param('block_map', false, true); if ($sup != '') { $_map .= ',' . $sup; } require_code('blocks'); $map = block_params_str_to_arr($_map); if (!array_key_exists('block', $map)) { return new ocp_tempcode(); } $auth_key = get_param_integer('auth_key'); // Check permissions $test = $GLOBALS['SITE_DB']->query_value_null_ok('temp_block_permissions', 'p_block_constraints', array('p_session_id' => get_session_id(), 'id' => $auth_key)); if (is_null($test) || !block_signature_check(block_params_str_to_arr($test), $map)) { require_lang('permissions'); return paragraph(do_lang_tempcode('ACCESS_DENIED__ACCESS_DENIED', escape_html($map['block']))); } // Cleanup $GLOBALS['SITE_DB']->query('DELETE FROM ' . get_table_prefix() . 'temp_block_permissions WHERE p_time<' . strval(time() - 60 * 60 * intval(get_option('session_expiry_time')))); // Return block snippet global $CSSS, $JAVASCRIPTS; $CSSS = array(); $JAVASCRIPTS = array(); $out = new ocp_tempcode(); $out->attach(symbol_tempcode('CSS_TEMPCODE')); $out->attach(symbol_tempcode('JS_TEMPCODE')); $out->attach(do_block($map['block'], $map)); return $out; }
/** * Standard modular run function for do_next_menu hooks. They find links to put on standard navigation menus of the system. * * @return array Array of links and where to show */ function run() { if (!addon_installed('chat')) { return array(); } return array(array('cms', 'chatrooms', array('cms_chat', array('type' => 'misc'), get_module_zone('cms_chat')), do_lang_tempcode('ITEMS_HERE', do_lang_tempcode('ROOMS'), make_string_tempcode(escape_html(integer_format($GLOBALS['SITE_DB']->query_value_null_ok('chat_rooms', 'COUNT(*)', NULL, '', true))))), 'DOC_CHAT'), array('structure', 'chatrooms', array('admin_chat', array('type' => 'misc'), get_module_zone('admin_chat')), do_lang_tempcode('ROOMS'), 'DOC_CHAT')); }
/** * 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)); }
/** * 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 (is_object($ev)) { return $ev; } return make_string_tempcode(nl2br(escape_html($ev))); }
/** * Standard modular run function for do_next_menu hooks. They find links to put on standard navigation menus of the system. * * @return array Array of links and where to show */ function run() { if (!addon_installed('calendar')) { return array(); } return array(array('cms', 'calendar', array('cms_calendar', array('type' => 'misc'), get_module_zone('cms_calendar')), do_lang_tempcode('ITEMS_HERE', do_lang_tempcode('CALENDAR'), make_string_tempcode(escape_html(integer_format($GLOBALS['SITE_DB']->query_value_null_ok('calendar_events', 'COUNT(*)', NULL, '', true))))), 'DOC_CALENDAR')); }
/** * Get list of staff contextual actions. * * @return string The list */ function get_staff_actions_list() { require_lang('lang'); $list = array('view' => do_lang_tempcode('SCREEN_DEV_TOOLS')); $list += array('spacer_1' => do_lang_tempcode('THEME'), 'show_edit_links' => do_lang_tempcode('TEMPLATES_WITH_EDIT_LINKS'), 'show_markers' => do_lang_tempcode('TEMPLATES_WITH_HTML_COMMENT_MARKERS'), 'tree' => do_lang_tempcode('TEMPLATE_TREE'), 'templates' => do_lang_tempcode('TEMPLATES'), 'theme_images' => do_lang_tempcode('THEME_IMAGE_EDITING'), 'code' => do_lang_tempcode('VALIDATION'), 'site_tree' => do_lang_tempcode('FIND_IN_SITE_TREE')); require_code('lang2'); $list += array('spacer_2' => do_lang_tempcode('LANGUAGE')); $all_langs = multi_lang() ? find_all_langs() : array(user_lang() => 'lang_custom'); $tcode = do_lang('lang:TRANSLATE_CODE'); foreach (array_keys($all_langs) as $lang) { $list += array('lang_' . $lang => $tcode . (count($all_langs) == 1 ? '' : ': ' . lookup_language_full_name($lang))); } if (multi_lang()) { $tcontent = do_lang('TRANSLATE_CONTENT'); foreach (array_keys($all_langs) as $lang) { $list['lang_content_' . $lang] = $tcontent . ': ' . lookup_language_full_name($lang); } } $list += array('spacer_3' => do_lang_tempcode('DEVELOPMENT_VIEWS'), 'query' => do_lang_tempcode('VIEW_PAGE_QUERIES'), 'ide_linkage' => do_lang_tempcode('IDE_LINKAGE')); if (function_exists('xdebug_enable')) { $list['profile'] = do_lang_tempcode('PROFILING'); } if (function_exists('memory_get_usage')) { $list['memory'] = do_lang_tempcode('_MEMORY_USAGE'); } $special_page_type = get_param('special_page_type', 'view'); $staff_actions = ''; foreach ($list as $name => $text) { $disabled = $name[0] == 's' && substr($name, 0, 7) == 'spacer_'; $staff_actions .= '<option ' . ($disabled ? 'disabled="disabled" ' : '') . ($name == $special_page_type ? 'selected="selected" ' : '') . 'value="' . escape_html($name) . '">' . (is_object($text) ? $text->evaluate() : escape_html($text)) . '</option>'; // XHTMLXHTML //$staff_actions.=static_evaluate_tempcode(form_input_list_entry($name,($name==$special_page_type),$text,false,$disabled)); } return $staff_actions; }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { unset($map); $forum = get_forum_type(); $out = new ocp_tempcode(); if ($forum != 'none') { // Standard welcome back vs into greeting $member = get_member(); if (is_guest($member)) { $redirect = get_self_url(true, true); $login_url = build_url(array('page' => 'login', 'type' => 'misc', 'redirect' => $redirect), get_module_zone('login')); $join_url = $GLOBALS['FORUM_DRIVER']->join_url(); $join_bits = do_template('JOIN_OR_LOGIN', array('LOGIN_URL' => $login_url, 'JOIN_URL' => $join_url)); $p = do_lang_tempcode('WELCOME', $join_bits); $out->attach(paragraph($p, 'hhrt4dsgdsgd')); } else { $out->attach(paragraph(do_lang_tempcode('WELCOME_BACK', escape_html($GLOBALS['FORUM_DRIVER']->get_username($member))), 'gfgdf9gjd')); } } $message = get_option('welcome_message'); if (has_actual_page_access(get_member(), 'admin_config')) { if ($message != '') { $message .= ' [[page="_SEARCH:admin_config:category:SITE#group_GENERAL"]' . do_lang('EDIT') . '[/page]]'; } } $out->attach(comcode_to_tempcode($message, NULL, true)); return $out; }
/** * 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 (is_object($ev)) { return $ev; } return escape_html(preg_replace('#^0*#', '', $ev)); }
/** * Standard modular run function for do_next_menu hooks. They find links to put on standard navigation menus of the system. * * @return array Array of links and where to show */ function run() { if (!addon_installed('quizzes')) { return array(); } return array(array('usage', 'quiz', array('admin_quiz', array('type' => 'misc'), get_module_zone('admin_quiz')), do_lang_tempcode('QUIZZES'), 'DOC_QUIZZES'), array('cms', 'quiz', array('cms_quiz', array('type' => 'misc'), get_module_zone('cms_quiz')), do_lang_tempcode('ITEMS_HERE', do_lang_tempcode('QUIZZES'), make_string_tempcode(escape_html(integer_format($GLOBALS['SITE_DB']->query_value_null_ok('quizzes', 'COUNT(*)', NULL, '', true))))), 'DOC_QUIZZES')); }
/** * 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 do_next_menu hooks. They find links to put on standard navigation menus of the system. * * @return array Array of links and where to show */ function run() { if (!addon_installed('galleries')) { return array(); } return array(array('cms', 'galleries', array('cms_galleries', array('type' => 'misc'), get_module_zone('cms_galleries')), do_lang_tempcode('ITEMS_HERE', do_lang_tempcode('GALLERIES'), make_string_tempcode(escape_html(integer_format($GLOBALS['SITE_DB']->query_value_null_ok('images', 'COUNT(*)', NULL, '', true) + $GLOBALS['SITE_DB']->query_value_null_ok('videos', 'COUNT(*)', NULL, '', true))))), 'DOC_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'); 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. * * @return tempcode Results */ function run() { $out = new ocp_tempcode(); $tables = $GLOBALS['SITE_DB']->query_select('db_meta', array('DISTINCT m_table')); if (count($GLOBALS['SITE_DB']->connection_write) > 4) { $GLOBALS['SITE_DB']->connection_write = call_user_func_array(array($GLOBALS['SITE_DB']->static_ob, 'db_get_connection'), $GLOBALS['SITE_DB']->connection_write); _general_db_init(); } list($db, $db_name) = $GLOBALS['SITE_DB']->connection_write; mysql_select_db($db_name, $db); foreach ($tables as $table) { if ($table['m_table'] == 'sessions') { continue; } // HEAP, so can't be repaired $table = get_table_prefix() . $table['m_table']; // Check/Repair $result = mysql_query('CHECK TABLE ' . $table . ' FAST', $db); echo mysql_error($db); mysql_data_seek($result, mysql_num_rows($result) - 1); $status_row = mysql_fetch_assoc($result); if ($status_row['Msg_type'] != 'status') { $out->attach(paragraph(do_lang_tempcode('TABLE_ERROR', escape_html($table), escape_html($status_row['Msg_type']), array(escape_html($status_row['Msg_text']))), 'dfsdgdsgfgd')); $result2 = mysql_query('REPAIR TABLE ' . $table, $db); mysql_data_seek($result2, mysql_num_rows($result2) - 1); $status_row_2 = mysql_fetch_assoc($result2); $out->attach(paragraph(do_lang_tempcode('TABLE_FIXED', escape_html($table), escape_html($status_row_2['Msg_type']), array(escape_html($status_row_2['Msg_text']))), 'dfsdfgdst4')); } // Optimise mysql_unbuffered_query('OPTIMIZE TABLE ' . $table, $db); } return $out; }
/** * 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 for do_next_menu hooks. They find links to put on standard navigation menus of the system. * * @return array Array of links and where to show */ function run() { // TODO: Make workflows register itself in the addon registry //if (!addon_installed('workflows')) return array(); require_lang('workflows'); return array(array('cms', 'workflows', array('admin_workflow', array('type' => 'misc'), get_module_zone('admin_workflow')), do_lang_tempcode('ITEMS_HERE', do_lang_tempcode('WORKFLOWS'), make_string_tempcode(escape_html(integer_format($GLOBALS['SITE_DB']->query_value('workflow_requirements', 'COUNT(DISTINCT workflow_name)'))))), 'DOC_WORKFLOWS')); }
/** * Standard modular run function for do_next_menu hooks. They find links to put on standard navigation menus of the system. * * @return array Array of links and where to show */ function run() { if (!addon_installed('downloads')) { return array(); } return array(array('cms', 'downloads', array('cms_downloads', array('type' => 'misc'), get_module_zone('cms_downloads')), do_lang_tempcode('ITEMS_HERE', do_lang_tempcode('SECTION_DOWNLOADS'), make_string_tempcode(escape_html(integer_format($GLOBALS['SITE_DB']->query_value_null_ok('download_downloads', 'COUNT(*)', NULL, '', true))))), 'DOC_DOWNLOADS')); }
function auth_set($member_id, $oauth_url) { require_lang('twitter'); require_code('twitter'); $api_key = get_option('twitter_api_key', true); $api_secret = get_option('twitter_api_secret', true); $twitter = new Twitter($api_key, $api_secret); if (get_param_integer('oauth_in_progress', 0) == 0) { $response = $twitter->oAuthRequestToken($oauth_url->evaluate()); $twitter->oAuthAuthorize($response['oauth_token']); exit; } $response = $twitter->oAuthAccessToken(get_param('oauth_token'), get_param('oauth_verifier')); if (!isset($response['oauth_token'])) { attach_message(do_lang_tempcode('TWITTER_OAUTH_FAIL', escape_html($response['message'])), 'warn'); return false; } $save_to = 'twitter_oauth_token'; if (!is_null($member_id)) { $save_to .= '__' . strval($member_id); } set_long_value($save_to, $response['oauth_token']); $save_to = 'twitter_oauth_token_secret'; if (!is_null($member_id)) { $save_to .= '__' . strval($member_id); } set_long_value($save_to, $response['oauth_token_secret']); return true; }
/** * Standard modular render function for profile tab hooks. * * @param MEMBER The ID of the member who is being viewed * @param MEMBER The ID of the member who is doing the viewing * @param boolean Whether to leave the tab contents NULL, if tis hook supports it, so that AJAX can load it later * @return array A triple: The tab title, the tab contents, the suggested tab order */ function render_tab($member_id_of, $member_id_viewing, $leave_to_ajax_if_possible = false) { $title = do_lang_tempcode('MODULE_TRANS_NAME_warnings'); $order = 80; if ($leave_to_ajax_if_possible) { return array($title, NULL, $order); } require_lang('ocf'); require_css('ocf'); $warnings = new ocp_tempcode(); $rows = $GLOBALS['FORUM_DB']->query_select('f_warnings', array('*'), array('w_member_id' => $member_id_of, 'w_is_warning' => 1)); foreach ($rows as $row) { $warning_by = $GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($row['w_by']); $date = get_timezoned_date($row['w_time']); if ($row['w_explanation'] == '') { $row['w_explanation'] = '?'; } else { $row['w_explanation'] = str_replace(chr(10), ' ', $row['w_explanation']); } $row['w_explanation_orig'] = $row['w_explanation']; if (strlen($row['w_explanation']) > 30) { $row['w_explanation'] = substr($row['w_explanation'], 0, 27) . '...'; } $explanation = hyperlink(build_url(array('page' => 'warnings', 'type' => '_ed', 'id' => $row['id'], 'redirect' => get_self_url(true)), get_module_zone('warnings')), $row['w_explanation'], false, true, $row['w_explanation_orig']); $warnings->attach(paragraph(do_lang_tempcode('MEMBER_WARNING', $explanation, $warning_by, array(make_string_tempcode(escape_html($date)))), 'treyerhy34y')); } $content = do_template('OCF_MEMBER_PROFILE_WARNINGS', array('MEMBER_ID' => strval($member_id_of), 'WARNINGS' => $warnings)); return array($title, $content, $order); }
/** * Output an inventory screen. * * @param MEMBER The member the inventory is of * @return tempcode Interface */ function output_inventory_screen($member_id) { if (is_null($member_id) || $member_id == -1) { $member_id = get_member(); } $pic = ''; $avatar = ''; if ($member_id > $GLOBALS['FORUM_DRIVER']->get_guest_id()) { $username = $GLOBALS['FORUM_DRIVER']->get_username($member_id); if (is_null($username)) { $username = do_lang('UNKNOWN'); } if (method_exists($GLOBALS['FORUM_DRIVER'], 'get_member_photo_url')) { $pic = $GLOBALS['FORUM_DRIVER']->get_member_photo_url($member_id); } if (method_exists($GLOBALS['FORUM_DRIVER'], 'get_member_avatar_url')) { $avatar = $GLOBALS['FORUM_DRIVER']->get_member_avatar_url($member_id); } } else { $username = $GLOBALS['SITE_DB']->query_value('w_realms', 'troll_name', array('id' => -$member_id - 1)); } $title = get_page_title('W_INVENTORY_OF', true, array(escape_html($username))); $health = $GLOBALS['SITE_DB']->query_value('w_members', 'health', array('id' => $member_id)); $rows = $GLOBALS['SITE_DB']->query_select('w_inventory', array('*'), array('item_owner' => $member_id)); $inventory = new ocp_tempcode(); foreach ($rows as $myrow) { $item_rows = $GLOBALS['SITE_DB']->query_select('w_itemdef', array('*'), array('name' => $myrow['item_name'])); if (!array_key_exists(0, $item_rows)) { continue; } $item_row = $item_rows[0]; $pic_url = $item_row['picture_url']; if (url_is_local($pic_url) && $pic_url != '') { $pic_url = get_custom_base_url() . '/' . str_replace(' ', '%20', $pic_url); } $description = $item_row['description']; $bribable = $item_row['bribable']; $healthy = $item_row['healthy']; $width = ''; if ($pic_url != '') { $ext = strtolower(substr($pic_url, strlen($pic_url) - 4)); $mypic = false; if ($ext == 'jpeg' || $ext == '.jpg') { $mypic = @imagecreatefromjpeg($pic_url); } if ($ext == '.png') { $mypic = @imagecreatefrompng($pic_url); } if (function_exists('imagecreatefromgif') && $ext == '.gif') { $mypic = @imagecreatefromgif($pic_url); } if ($mypic === false || imagesx($mypic) > 200) { $width = 'width: 200px'; } } $inventory->attach(do_template('W_INVENTORY_ITEM', array('_GUID' => '6850866532d2e5a65ca1b74f5ed8e49a', 'HEALTHY' => $healthy == 1, 'BRIBABLE' => $bribable == 1, 'WIDTH' => $width, 'PIC_URL' => $pic_url, 'ITEM_NAME' => $myrow['item_name'], 'DESCRIPTION' => $description, 'ITEM_COUNT' => integer_format($myrow['item_count'])))); } return do_template('W_INVENTORY_SCREEN', array('_GUID' => '74dd29919831eb75212b9805511fdca8', 'TITLE' => $title, 'USERNAME' => $username, 'HEALTH' => integer_format($health), 'AVATAR' => $avatar, 'PIC' => $pic, 'INVENTORY' => $inventory)); }