/** * Standard modular run function. * * @return tempcode Results */ function run() { if (get_forum_type() != 'ocf') { return new ocp_tempcode(); } else { ocf_require_all_forum_stuff(); } if (function_exists('set_time_limit')) { @set_time_limit(0); } require_code('ocf_posts_action'); require_code('ocf_posts_action2'); // Members $start = 0; do { $members = $GLOBALS['FORUM_DB']->query_select('f_members', array('id'), NULL, '', 500, $start); foreach ($members as $member) { ocf_force_update_member_post_count($member['id']); $num_warnings = $GLOBALS['FORUM_DB']->query_value('f_warnings', 'COUNT(*)', array('w_member_id' => $member['id'], 'w_is_warning' => 1)); $GLOBALS['FORUM_DB']->query_update('f_members', array('m_cache_warnings' => $num_warnings), array('id' => $member['id']), '', 1); } $start += 500; } while (array_key_exists(0, $members)); return new ocp_tempcode(); }
/** * Standard aed_module run_start. * * @param ID_TEXT The type of module execution * @return tempcode The output of the run */ function run_start($type) { $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/forums'; $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_forums'; $this->add_one_label = do_lang_tempcode('ADD_FORUM'); $this->edit_this_label = do_lang_tempcode('EDIT_THIS_FORUM'); $this->edit_one_label = do_lang_tempcode('EDIT_FORUM'); global $C_TITLE; $C_TITLE = NULL; if (get_forum_type() != 'ocf') { warn_exit(do_lang_tempcode('NO_OCF')); } else { ocf_require_all_forum_stuff(); } require_code('ocf_forums_action'); require_code('ocf_forums_action2'); require_code('ocf_forums2'); require_css('ocf'); load_up_all_module_category_permissions($GLOBALS['FORUM_DRIVER']->get_guest_id(), 'forums'); if ($type == 'misc') { return $this->misc(); } if ($type == 'reorder') { return $this->reorder(); } return new ocp_tempcode(); }
/** * 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 (get_forum_type() != 'ocf') { return array(); } return array(array('setup', 'notifications', array('admin_notifications', array('type' => 'misc'), get_module_zone('admin_notifications')), do_lang_tempcode('NOTIFICATIONS_LOCKDOWN'), 'DOC_NOTIFICATIONS')); }
/** * Standard modular run function. * * @return tempcode The result of execution. */ function run() { if (get_forum_type() != 'ocf') { warn_exit(do_lang_tempcode('NO_OCF')); } else { ocf_require_all_forum_stuff(); } require_code('ocf_forumview'); if (is_guest()) { access_denied('NOT_AS_GUEST'); } require_css('ocf'); $type = get_param('type', 'misc'); if ($type == 'misc') { list($title, $content) = $this->new_posts(); } elseif ($type == 'unread') { list($title, $content) = $this->unread_topics(); } elseif ($type == 'recently_read') { list($title, $content) = $this->recently_read(); } else { $title = new ocp_tempcode(); $content = new ocp_tempcode(); } $ret = ocf_wrapper($title, do_template('OCF_VFORUM', array('_GUID' => '8dca548982d65500ab1800ceec2ddc61', 'CONTENT' => $content))); return $ret; }
/** * 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('ldap')) { return array(); } return array(get_forum_type() != 'ocf' ? NULL : array('security', 'ldap', array('admin_ocf_ldap', array('type' => 'misc'), get_module_zone('admin_ocf_ldap')), do_lang_tempcode('LDAP'), 'DOC_LDAP')); }
/** * Gets the default value for the config option. * * @return ?string The default value (NULL: option is disabled) */ function get_default() { if (get_forum_type() != 'ocf') { return NULL; } return '1'; }
/** * Standard aed_module run_start. * * @param ID_TEXT The type of module execution * @return tempcode The output of the run */ function run_start($type) { $GLOBALS['NO_DB_SCOPE_CHECK'] = true; $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/customprofilefields'; $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_adv_members'; if (get_forum_type() != 'ocf') { warn_exit(do_lang_tempcode('NO_OCF')); } else { ocf_require_all_forum_stuff(); } require_code('ocf_members_action'); require_code('ocf_members_action2'); require_lang('fields'); require_lang('ocf'); $this->add_one_label = do_lang_tempcode('ADD_CUSTOM_PROFILE_FIELD'); $this->edit_this_label = do_lang_tempcode('EDIT_THIS_CUSTOM_PROFILE_FIELD'); $this->edit_one_label = do_lang_tempcode('EDIT_CUSTOM_PROFILE_FIELD'); if ($type == 'misc') { return $this->misc(); } if ($type == 'stats') { return $this->stats(); } if ($type == '_stats') { return $this->_stats(); } return new ocp_tempcode(); }
/** * Standard modular run function for OcCLE hooks. * * @param array The options with which the command was called * @param array The parameters with which the command was called * @param array A reference to the OcCLE filesystem object * @return ~array Array of stdcommand, stdhtml, stdout, and stderr responses (false: error) */ function run($options, $parameters, &$occle_fs) { if (array_key_exists('h', $options) || array_key_exists('help', $options)) { return array('', do_command_help('ban_member', array('h', 'u'), array(true, true)), '', ''); } else { if (get_forum_type() != 'ocf') { return array('', '', '', do_lang('NO_OCF')); } if (!array_key_exists(0, $parameters)) { return array('', '', '', do_lang('MISSING_PARAM', '1', 'ban_member')); } require_code('ocf_members_action'); require_code('ocf_members_action2'); require_lang('ocf'); if (is_numeric($parameters[0])) { $member_id = $parameters[0]; } else { $member_id = $GLOBALS['FORUM_DRIVER']->get_member_from_username($parameters[0]); } if (is_null($member_id)) { return array('', '', '', do_lang('USER_NO_EXIST')); } if (array_key_exists('u', $options) || array_key_exists('unban', $options)) { ocf_unban_member($member_id); } else { ocf_ban_member($member_id); } return array('', '', do_lang('SUCCESS'), ''); } }
/** * Standard modular info function for award hooks. Provides information to allow task reporting, randomisation, and add-screen linking, to function. * * @return ?array Map of award content-type info (NULL: disabled). */ function info() { if (get_forum_type() != 'ocf') { return NULL; } $info = array(); $info['connection'] = $GLOBALS['FORUM_DB']; $info['table'] = 'f_topics'; $info['date_field'] = 't_cache_first_time'; $info['id_field'] = 'id'; $info['add_url'] = ''; $info['category_field'] = 't_forum_id'; $info['category_type'] = 'forums'; $info['parent_spec__table_name'] = 'f_forums'; $info['parent_spec__parent_name'] = 'f_parent_forum'; $info['parent_spec__field_name'] = 'id'; $info['parent_field_name'] = 't_forum_id'; $info['submitter_field'] = 't_cache_first_member_id'; $info['id_is_string'] = false; require_lang('ocf'); $info['title'] = do_lang_tempcode('SPECIFIC_FORUM_TOPICS'); $info['validated_field'] = 't_validated'; $info['category_is_string'] = false; $info['archive_url'] = build_url(array('page' => 'forumview'), get_module_zone('forumview')); $info['cms_page'] = 'topics'; $info['views_field'] = 't_num_views'; $info['supports_custom_fields'] = true; return $info; }
/** * Standard modular run function for search results. * * @param string Search string * @param boolean Whether to only do a META (tags) search * @param ID_TEXT Order direction * @param integer Start position in total results * @param integer Maximum results to return in total * @param boolean Whether only to search titles (as opposed to both titles and content) * @param string Where clause that selects the content according to the main search string (SQL query fragment) (blank: full-text search) * @param SHORT_TEXT Username/Author to match for * @param ?MEMBER Member-ID to match for (NULL: unknown) * @param TIME Cutoff date * @param string The sort type (gets remapped to a field in this function) * @set title add_date * @param integer Limit to this number of results * @param string What kind of boolean search to do * @set or and * @param string Where constraints known by the main search code (SQL query fragment) * @param string Comma-separated list of categories to search under * @param boolean Whether it is a boolean search * @return array List of maps (template, orderer) */ function run($content, $only_search_meta, $direction, $max, $start, $only_titles, $content_where, $author, $author_id, $cutoff, $sort, $limit_to, $boolean_operator, $where_clause, $search_under, $boolean_search) { unset($limit_to); if (get_forum_type() != 'ocf') { return array(); } $remapped_orderer = ''; switch ($sort) { case 'title': $remapped_orderer = 'g_name'; break; } require_lang('ocf'); // Calculate our where clause (search) $sq = build_search_submitter_clauses('g_group_leader', $author_id, $author); if (is_null($sq)) { return array(); } else { $where_clause .= $sq; } $where_clause .= ' AND '; $where_clause .= 'g_hidden=0 AND g_is_private_club=1'; // Calculate and perform query $rows = get_search_rows(NULL, NULL, $content, $boolean_search, $boolean_operator, $only_search_meta, $direction, $max, $start, $only_titles, 'f_groups r', array('!', 'r.g_name', 'r.g_title'), $where_clause, $content_where, $remapped_orderer, 'r.*'); $out = array(); foreach ($rows as $i => $row) { $out[$i]['data'] = $row; unset($rows[$i]); if ($remapped_orderer != '' && array_key_exists($remapped_orderer, $row)) { $out[$i]['orderer'] = $row[$remapped_orderer]; } } return $out; }
/** * Get what we need to get attachments in a form-field interface. * * @param ID_TEXT The name of the field attachments are for * @return array A pair: the attachments UI (tempcode), the hidden attachment field */ function get_attachments($posting_field_name) { $image_types = str_replace(',', ', ', get_option('valid_images')); require_lang('javascript'); require_javascript('javascript_swfupload'); require_css('swfupload'); require_code('files2'); $max_attach_size = get_max_file_size(get_member(), $GLOBALS['SITE_DB']); $attach_size_field = form_input_hidden('MAX_FILE_SIZE', strval($max_attach_size)); $num_attachments = post_param_integer('num_attachments', has_js() ? 1 : 3); $attachments = new ocp_tempcode(); for ($i = 1; $i <= $num_attachments; $i++) { $attachments->attach(do_template('ATTACHMENT', array('_GUID' => 'c3b38ca70cbd1c5f9cf91bcae9ed1134', 'POSTING_FIELD_NAME' => $posting_field_name, 'I' => strval($i)))); } if (get_forum_type() == 'ocf') { require_code('ocf_groups'); require_lang('ocf'); $max_attachments = ocf_get_member_best_group_property(get_member(), 'max_attachments_per_post'); } else { $max_attachments = 100; } $attachment_template = do_template('ATTACHMENT', array('_GUID' => 'c3b38ca70cbd1c5f9cf91bcae9ed11dsds', 'POSTING_FIELD_NAME' => $posting_field_name, 'I' => '__num_attachments__')); $attachments = do_template('ATTACHMENTS', array('_GUID' => '054921e7c09412be479676759accf222', 'POSTING_FIELD_NAME' => $posting_field_name, 'ATTACHMENT_TEMPLATE' => $attachment_template, 'IMAGE_TYPES' => $image_types, 'ATTACHMENTS' => $attachments, 'MAX_ATTACHMENTS' => strval($max_attachments), 'NUM_ATTACHMENTS' => strval($num_attachments))); return array($attachments, $attach_size_field); }
/** * 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; }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { unset($map); require_lang('custom_comcode'); $tags = array(); $wmap = array('tag_enabled' => 1); if (!has_specific_permission(get_member(), 'comcode_dangerous')) { $wmap['tag_dangerous_tag'] = 0; } $tags = array_merge($tags, $GLOBALS['SITE_DB']->query_select('custom_comcode', array('tag_title', 'tag_description', 'tag_example', 'tag_parameters', 'tag_replace', 'tag_tag', 'tag_dangerous_tag', 'tag_block_tag', 'tag_textual_tag'), $wmap)); if (isset($GLOBALS['FORUM_DB']) && $GLOBALS['FORUM_DB']->connection_write != $GLOBALS['SITE_DB']->connection_write && get_forum_type() == 'ocf') { $tags = array_merge($tags, $GLOBALS['FORUM_DB']->query_select('custom_comcode', array('tag_title', 'tag_description', 'tag_example', 'tag_parameters', 'tag_replace', 'tag_tag', 'tag_dangerous_tag', 'tag_block_tag', 'tag_textual_tag'), $wmap)); } // From Comcode hooks $hooks = find_all_hooks('systems', 'comcode'); foreach (array_keys($hooks) as $hook) { require_code('hooks/systems/comcode/' . filter_naughty_harsh($hook)); $object = object_factory('Hook_comcode_' . filter_naughty_harsh($hook), true); $tags[] = $object->get_tag(); } if (!array_key_exists(0, $tags)) { return paragraph(do_lang_tempcode('NONE_EM'), '', 'nothing_here'); } $content = new ocp_tempcode(); foreach ($tags as $tag) { $content->attach(do_template('CUSTOM_COMCODE_TAG_ROW', array('_GUID' => '28c257f5d0c596aa828fd9556b0df4a9', 'TITLE' => is_string($tag['tag_title']) ? $tag['tag_title'] : get_translated_text($tag['tag_title']), 'DESCRIPTION' => is_string($tag['tag_description']) ? $tag['tag_description'] : get_translated_text($tag['tag_description']), 'EXAMPLE' => $tag['tag_example']))); } return do_template('BLOCK_MAIN_CUSTOM_COMCODE_TAGS', array('_GUID' => 'b8d3436e6e5fe679ae9b0a368e607610', 'TAGS' => $content)); }
/** * Add ocPortal's strictness, after finishing with third-party code. To be run optionally at some point after destrictify(). */ function restrictify() { global $_CREATED_FILES, $_MODIFIED_FILES; // Reset functions if (isset($_CREATED_FILES)) { $_CREATED_FILES = array(); } if (isset($_MODIFIED_FILES)) { $_MODIFIED_FILES = array(); } // Put back strictness error_reporting(E_ALL); if (function_exists('set_time_limit')) { @set_time_limit(25); } if (get_forum_type() == 'ocf') { $GLOBALS['SITE_DB']->query('SET sql_mode=STRICT_ALL_TABLES', NULL, NULL, true); } if ($GLOBALS['DEBUG_MODE']) { @ini_set('ocproducts.type_strictness', '1'); global $PREVIOUS_XSS_STATE; //safe_ini_set('ocproducts.xss_detect',array_pop($PREVIOUS_XSS_STATE)); We don't maintain this in v8, since we increased checking strength but are not fixing all the new false-positives. Real issues are found in v9 and back-ported. } @ini_set('include_path', ''); @ini_set('allow_url_fopen', '0'); @ini_set('suhosin.executor.disable_emodifier', '1'); @ini_set('suhosin.executor.multiheader', '1'); $GLOBALS['NO_DB_SCOPE_CHECK'] = false; //$GLOBALS['NO_QUERY_LIMIT']=false; Leave off, may have been set elsewhere than destrictify(); }
/** * 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)); }
/** * Standard aed_module run_start. * * @param ID_TEXT The type of module execution * @return tempcode The output of the run */ function run_start($type) { $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/emoticons'; $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_emoticons'; $this->add_one_label = do_lang_tempcode('ADD_EMOTICON'); $this->edit_this_label = do_lang_tempcode('EDIT_THIS_EMOTICON'); $this->edit_one_label = do_lang_tempcode('EDIT_EMOTICON'); require_lang('dearchive'); require_code('images'); if (get_forum_type() != 'ocf') { warn_exit(do_lang_tempcode('NO_OCF')); } else { ocf_require_all_forum_stuff(); } require_code('ocf_general_action'); require_code('ocf_general_action2'); if ($type == 'ad') { require_javascript('javascript_ajax'); $script = find_script('snippet'); $this->javascript = "\n\t\t\t\tvar form=document.getElementById('main_form');\n\t\t\t\tform.old_submit=form.onsubmit;\n\t\t\t\tform.onsubmit=function()\n\t\t\t\t\t{\n\t\t\t\t\t\tdocument.getElementById('submit_button').disabled=true;\n\t\t\t\t\t\tvar url='" . addslashes($script) . "?snippet=exists_emoticon&name='+window.encodeURIComponent(form.elements['code'].value);\n\t\t\t\t\t\tif (!do_ajax_field_test(url))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdocument.getElementById('submit_button').disabled=false;\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdocument.getElementById('submit_button').disabled=false;\n\t\t\t\t\t\tif (typeof form.old_submit!='undefined' && form.old_submit) return form.old_submit();\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t};\n\t\t\t"; } if ($type == 'misc') { return $this->misc(); } if ($type == 'import') { return $this->import(); } if ($type == '_import') { return $this->_import(); } return new ocp_tempcode(); }
/** * Standard modular run function for CRON hooks. Searches for tasks to perform. */ function run() { if (get_forum_type() != 'ocf') { return; } $time = time(); $last_time = intval(get_value('last_confirm_reminder_time')); if ($last_time > time() - 24 * 60 * 60 * 2) { return; } set_value('last_confirm_reminder_time', strval($time)); require_code('mail'); require_lang('ocf'); $GLOBALS['NO_DB_SCOPE_CHECK'] = true; $rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'f_members WHERE ' . db_string_not_equal_to('m_validated_email_confirm_code', '') . ' AND m_join_time>' . strval($last_time)); $GLOBALS['NO_DB_SCOPE_CHECK'] = false; foreach ($rows as $row) { $coppa = get_option('is_on_coppa') == '1' && utctime_to_usertime(time() - mktime(0, 0, 0, $row['m_dob_month'], $row['m_dob_day'], $row['m_dob_year'])) / 31536000.0 < 13.0; if (!$coppa) { $zone = get_module_zone('join'); if ($zone != '') { $zone .= '/'; } $url = get_base_url() . '/' . $zone . 'index.php?page=join&type=step4&email=' . rawurlencode($row['m_email_address']) . '&code=' . $row['m_validated_email_confirm_code']; $url_simple = get_base_url() . '/' . $zone . 'index.php?page=join&type=step4'; $message = do_lang('OCF_SIGNUP_TEXT', comcode_escape(get_site_name()), comcode_escape($url), array($url_simple, $row['m_email_address'], strval($row['m_validated_email_confirm_code'])), $row['m_language']); mail_wrap(do_lang('CONFIRM_EMAIL_SUBJECT', get_site_name(), NULL, NULL, $row['m_language']), $message, array($row['m_email_address']), $row['m_username']); } } }
/** * Standard actualisation stage of pointstore item purchase. * * @return tempcode The UI */ function action_done() { $class = str_replace('hook_pointstore_', '', strtolower(get_class($this))); if (get_option('is_on_' . $class . '_buy') == '0' || get_forum_type() != 'ocf') { return new ocp_tempcode(); } if ($GLOBALS['FORUM_DRIVER']->get_member_row_field(get_member(), 'm_highlighted_name') == 1) { warn_exit(do_lang_tempcode('_ALREADY_HAVE')); } $title = get_page_title('NAME_HIGHLIGHTING'); post_param_integer('confirm'); // To make sure we're not being passed by a GET // Check points $cost = intval(get_option($class)); $points_left = available_points(get_member()); 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))); } // Actuate $GLOBALS['FORUM_DB']->query_update('f_members', array('m_highlighted_name' => 1), array('id' => get_member()), '', 1); require_code('points2'); charge_member(get_member(), $cost, do_lang('NAME_HIGHLIGHTING')); $GLOBALS['SITE_DB']->query_insert('sales', array('date_and_time' => time(), 'memberid' => get_member(), 'purchasetype' => 'NAME_HIGHLIGHTING', 'details' => '', 'details2' => '')); // Show message $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF'); return redirect_screen($title, $url, do_lang_tempcode('ORDER_GENERAL_DONE')); }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { unset($map); if (get_forum_type() != 'ocf') { return new ocp_tempcode(); } if (is_guest()) { return new ocp_tempcode(); } require_css('side_blocks'); ocf_require_all_forum_stuff(); require_code('ocf_notifications'); // Only show what's new in week. Some forums may want to tweak this, but forums themselves only mark unread topics for a week. $rows = ocf_get_pp_rows(); // if (count($rows)==0) return new ocp_tempcode(); require_lang('ocf'); $out = new ocp_tempcode(); foreach ($rows as $topic) { $topic_url = build_url(array('page' => 'topicview', 'id' => $topic['id'], 'type' => 'findpost'), get_module_zone('topicview')); $topic_url->attach('#post_' . strval($topic['id'])); $title = $topic['t_cache_first_title']; $date = get_timezoned_date($topic['t_cache_last_time'], true); $username = $topic['t_cache_last_username']; $member_link = $GLOBALS['OCF_DRIVER']->member_profile_url($topic['t_cache_last_member_id'], false, true); $num_posts = $topic['t_cache_num_posts']; $out->attach(do_template('TOPIC_LIST', array('_GUID' => '55ae21a9f8d67ba6237c118a18b9657b', 'USER_LINK' => $member_link, 'TOPIC_LINK' => $topic_url, 'TITLE' => $title, 'DATE' => $date, 'DATE_RAW' => strval($topic['t_cache_last_time']), 'USERNAME' => $username, 'NUM_POSTS' => integer_format($num_posts)))); } $send_url = build_url(array('page' => 'topics', 'type' => 'new_pt', 'redirect' => SELF_REDIRECT), get_module_zone('topics')); if (!ocf_may_make_personal_topic()) { $send_url = new ocp_tempcode(); } $view_url = build_url(array('page' => 'members', 'type' => 'view', 'id' => get_member()), get_module_zone('members'), NULL, true, false, false, 'tab__pts'); return do_template('BLOCK_SIDE_OCF_PERSONAL_TOPICS', array('_GUID' => '9376cd47884a78f3d1914c176b67ee28', 'SEND_URL' => $send_url, 'VIEW_URL' => $view_url, 'CONTENT' => $out, 'FORUM_NAME' => do_lang_tempcode('PERSONAL_TOPICS'))); }
/** * 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 info function. * * @return ?array Map of module info (NULL: module is disabled). */ function info() { if (get_forum_type() != 'ocf') { return NULL; } require_lang('stats'); return array(array('demographics' => 'DEMOGRAPHICS'), array('statistics_demographics', array('_SELF', array('type' => 'demographics'), '_SELF'), do_lang('DEMOGRAPHICS'), 'DESCRIPTION_DEMOGRAPHICS')); }
/** * Standard modular run function for attachment hooks. They see if permission to an attachment of an ID relating to this content is present for the current member. * * @param ID_TEXT The ID * @param object The database connection to check on * @return boolean Whether there is permission */ function run($id, $connection) { if (get_forum_type() != 'ocf') { return false; } // Shouldn't be here, but maybe it's left over somehow return true; }
/** * Standard modular info function. * * @return ?array Map of module info (NULL: module is disabled). */ function info() { if (get_forum_type() != 'ocf') { return NULL; } require_lang('stats'); return array(array('posting_rates' => 'POSTING_RATES'), array('statistics_posting_rates', array('_SELF', array('type' => 'posting_rates'), '_SELF'), do_lang('POSTING_RATES'), 'DESCRIPTION_POSTING_RATES')); }
/** * Standard modular run function for search results. * * @param string Search string * @param boolean Whether to only do a META (tags) search * @param ID_TEXT Order direction * @param integer Start position in total results * @param integer Maximum results to return in total * @param boolean Whether only to search titles (as opposed to both titles and content) * @param string Where clause that selects the content according to the main search string (SQL query fragment) (blank: full-text search) * @param SHORT_TEXT Username/Author to match for * @param ?MEMBER Member-ID to match for (NULL: unknown) * @param TIME Cutoff date * @param string The sort type (gets remapped to a field in this function) * @set title add_date * @param integer Limit to this number of results * @param string What kind of boolean search to do * @set or and * @param string Where constraints known by the main search code (SQL query fragment) * @param string Comma-separated list of categories to search under * @param boolean Whether it is a boolean search * @return array List of maps (template, orderer) */ function run($content, $only_search_meta, $direction, $max, $start, $only_titles, $content_where, $author, $author_id, $cutoff, $sort, $limit_to, $boolean_operator, $where_clause, $search_under, $boolean_search) { unset($limit_to); if (get_forum_type() != 'ocf') { return array(); } if (get_member() == $GLOBALS['OCF_DRIVER']->get_guest_id()) { return array(); } require_code('ocf_forums'); require_code('ocf_posts'); require_css('ocf'); $remapped_orderer = ''; switch ($sort) { case 'title': $remapped_orderer = 'p_title'; break; case 'add_date': $remapped_orderer = 'p_time'; break; } require_lang('ocf'); // Calculate our where clause (search) $where_clause .= ' AND '; $where_clause .= 't_forum_id IS NULL AND (t_pt_from=' . strval((int) get_member()) . ' OR t_pt_to=' . strval((int) get_member()) . ')'; $sq = build_search_submitter_clauses('p_poster', $author_id, $author); if (is_null($sq)) { return array(); } else { $where_clause .= $sq; } if (!is_null($cutoff)) { $where_clause .= ' AND '; $where_clause .= 'p_time>' . strval($cutoff); } if (get_param_integer('option_ocf_posts_starter', 0) == 1) { $where_clause .= ' AND '; $where_clause .= 's.t_cache_first_post_id=r.id'; } if (!has_specific_permission(get_member(), 'see_unvalidated')) { $where_clause .= ' AND '; $where_clause .= 'p_validated=1'; } // Calculate and perform query $rows = get_search_rows(NULL, NULL, $content, $boolean_search, $boolean_operator, $only_search_meta, $direction, $max, $start, $only_titles, 'f_posts r LEFT JOIN ' . get_table_prefix() . 'f_topics s ON r.p_topic_id=s.id', array('!', 'r.p_post'), $where_clause, $content_where, $remapped_orderer, 'r.*', array('r.p_title')); $out = array(); foreach ($rows as $i => $row) { $out[$i]['data'] = $row; unset($rows[$i]); if ($remapped_orderer != '' && array_key_exists($remapped_orderer, $row)) { $out[$i]['orderer'] = $row[$remapped_orderer]; } elseif (substr($remapped_orderer, 0, 7) == '_rating') { $out[$i]['orderer'] = $row['compound_rating']; } } return $out; }
/** * Standard modular entry-point finder function. * * @return ?array A map of entry points (type-code=>language-code) (NULL: disabled). */ function get_entry_points() { if (get_forum_type() == 'ocf') { return array(); } if (is_guest()) { return array(); } return array('misc' => 'NOTIFICATIONS'); }
/** * Give error if OCF-joining is not possible on this site. */ function check_joining_allowed() { if (get_forum_type() != 'ocf') { warn_exit(do_lang_tempcode('NO_OCF')); } global $LDAP_CONNECTION; if (!is_null($LDAP_CONNECTION) && get_option('ldap_allow_joining', true) === '0') { warn_exit(do_lang_tempcode('JOIN_DISALLOW')); } }
/** * Standard code module initialisation function. */ function init__zones() { global $CACHE_ON, $CLASS_CACHE; $CACHE_ON = NULL; $CLASS_CACHE = array(); global $ARB_COUNTER; $ARB_COUNTER = 1; global $DO_NOT_CACHE_THIS; $DO_NOT_CACHE_THIS = false; global $MODULES_ZONES, $MODULES_ZONES_DEFAULT; $MODULES_ZONES = function_exists('persistant_cache_get') ? persistant_cache_get('MODULES_ZONES') : NULL; global $SITE_INFO; $hardcoded = isset($SITE_INFO['hardcode_common_module_zones']) && $SITE_INFO['hardcode_common_module_zones'] == '1'; if (get_forum_type() == 'ocf') { if ($hardcoded) { $MODULES_ZONES_DEFAULT = array('forumview' => 'forum', 'topicview' => 'forum', 'topics' => 'forum', 'vforums' => 'forum', 'points' => get_option('collapse_user_zones') == '1' ? '' : 'site', 'members' => get_option('collapse_user_zones') == '1' ? '' : 'site', 'catalogues' => get_option('collapse_user_zones') == '1' ? '' : 'site', 'join' => '', 'login' => '', 'recommend' => ''); } else { $MODULES_ZONES_DEFAULT = array('join' => '', 'login' => ''); } } else { $MODULES_ZONES_DEFAULT = array('join' => ''); } global $VIRTUALISED_ZONES; $VIRTUALISED_ZONES = NULL; if (is_null($MODULES_ZONES)) { foreach ($MODULES_ZONES_DEFAULT as $key => $val) { if (!$hardcoded && !is_file(get_file_base() . '/' . $val . '/pages/modules/' . $key . '.php')) { unset($MODULES_ZONES_DEFAULT[$key]); } } $MODULES_ZONES = $MODULES_ZONES_DEFAULT; } global $ALL_ZONES, $ALL_ZONES_TITLED; $ALL_ZONES = NULL; $ALL_ZONES_TITLED = NULL; global $MODULE_INSTALLED_CACHE; $MODULE_INSTALLED_CACHE = array(); global $HOOKS_CACHE; $HOOKS_CACHE = function_exists('persistant_cache_get') ? persistant_cache_get('HOOKS') : array(); if ($HOOKS_CACHE === NULL) { $HOOKS_CACHE = array(); } define('FIND_ALL_PAGES__PERFORMANT', 0); define('FIND_ALL_PAGES__NEWEST', 1); define('FIND_ALL_PAGES__ALL', 2); global $BLOCKS_AT_CACHE; $BLOCKS_AT_CACHE = function_exists('persistant_cache_get') ? persistant_cache_get('BLOCKS_AT') : array(); if ($BLOCKS_AT_CACHE === NULL) { $BLOCKS_AT_CACHE = array(); } }
/** * Standard modular run function for realtime-rain hooks. * * @param TIME Start of time range. * @param TIME End of time range. * @return array A list of template parameter sets for rendering a 'drop'. */ function run($from, $to) { $drops = array(); if (has_actual_page_access(get_member(), 'admin_ocf_join') && get_forum_type() == 'ocf') { $rows = $GLOBALS['FORUM_DB']->query('SELECT i_email_address,i_inviter AS member_id,i_time AS timestamp FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_invites WHERE i_time BETWEEN ' . strval($from) . ' AND ' . strval($to)); foreach ($rows as $row) { $timestamp = $row['timestamp']; $member_id = $row['member_id']; $invited_member = $GLOBALS['FORUM_DB']->query_value_null_ok('f_members', 'id', array('m_email_address' => $row['i_email_address'])); $drops[] = rain_get_special_icons(NULL, $timestamp) + array('TYPE' => 'recommend', 'FROM_MEMBER_ID' => strval($member_id), 'TO_MEMBER_ID' => is_null($invited_member) ? '' : strval($invited_member), 'TITLE' => do_lang('RECOMMEND_SITE'), 'IMAGE' => is_guest($member_id) ? find_theme_image('recommend') : $GLOBALS['FORUM_DRIVER']->get_member_avatar_url($member_id), 'TIMESTAMP' => strval($timestamp), 'RELATIVE_TIMESTAMP' => strval($timestamp - $from), 'TICKER_TEXT' => NULL, 'URL' => build_url(array('page' => 'points', 'type' => 'member', 'id' => $member_id), '_SEARCH'), 'IS_POSITIVE' => true, 'IS_NEGATIVE' => false, 'FROM_ID' => 'member_' . strval($member_id), 'TO_ID' => is_null($invited_member) ? '' : 'member_' . strval($invited_member), 'GROUP_ID' => NULL); } } return $drops; }
/** * 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('ocf_forum')) { return NULL; } if (get_forum_type() != 'ocf') { return NULL; } if (!has_actual_page_access(get_member(), 'forumview')) { return NULL; } $filters = ocfilter_to_sqlfragment($_filters, 'p_topic_id', 'f_forums', 'f_parent_forum', 'p_cache_forum_id', 'id', true, true, $GLOBALS['FORUM_DB']); $cutoff = max($cutoff, time() - 60 * 60 * 24 * 60); if (!is_guest()) { $filters .= ' AND (p_poster<>' . strval(get_member()) . ')'; } $rows = $GLOBALS['FORUM_DB']->query('SELECT * FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_posts WHERE p_time>' . strval($cutoff) . (!has_specific_permission(get_member(), 'see_unvalidated') ? ' AND p_validated=1 ' : '') . ' AND ' . $filters . ' ORDER BY p_time DESC,id DESC', $max); $categories = list_to_map('id', $GLOBALS['FORUM_DB']->query('SELECT id,t_cache_first_title,t_pt_from,t_pt_to FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_topics WHERE t_cache_last_time>' . strval((int) $cutoff))); $content = new ocp_tempcode(); foreach ($rows as $row) { if (!array_key_exists($row['p_topic_id'], $categories)) { continue; } $category = $categories[$row['p_topic_id']]['t_cache_first_title']; if ((!is_null($row['p_cache_forum_id']) || $categories[$row['p_topic_id']]['t_pt_from'] == get_member() || $categories[$row['p_topic_id']]['t_pt_to'] == get_member()) && (is_null($row['p_intended_solely_for']) || $row['p_intended_solely_for'] == get_member()) && has_category_access(get_member(), 'forums', strval($row['p_cache_forum_id']))) { $id = strval($row['id']); $author = $row['p_poster_name_if_guest']; $news_date = date($date_string, $row['p_time']); $edit_date = is_null($row['p_last_edit_time']) ? '' : date($date_string, $row['p_last_edit_time']); if ($edit_date == $news_date) { $edit_date = ''; } $news_title = xmlentities($row['p_title']); $_summary = get_translated_tempcode($row['p_post'], $GLOBALS['FORUM_DB']); $summary = xmlentities($_summary->evaluate()); $news = ''; $category_raw = strval($row['p_topic_id']); $view_url = build_url(array('page' => 'topicview', 'type' => 'findpost', 'id' => $row['id']), get_module_zone('forumview'), NULL, false, false, true); if ($prefix == 'RSS_') { $if_comments = do_template('RSS_ENTRY_COMMENTS', array('_GUID' => 'ed06bc8f174a5427e1789820666fdd81', 'COMMENT_URL' => $view_url, 'ID' => strval($row['p_topic_id']))); } else { $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('ocf'); return array($content, do_lang('FORUM_TOPICS')); }
/** * 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() { // Forum moderation if (!has_no_forum()) { $status = do_template('BLOCK_MAIN_STAFF_CHECKLIST_ITEM_STATUS_NA'); if (get_forum_type() == 'ocf') { $url = build_url(array('page' => 'vforums', 'type' => 'unread'), get_module_zone('vforums')); } else { $url = make_string_tempcode(get_forum_base_url()); } $tpl = do_template('BLOCK_MAIN_STAFF_CHECKLIST_ITEM', array('_GUID' => 'a2cdfc2ea5db2d8c13a4d9eafa9b644b', 'URL' => '', 'STATUS' => $status, 'TASK' => urlise_lang(do_lang('NAG_FORUMS'), $url), 'INFO' => '')); return array(array($tpl, NULL, NULL, NULL)); } return array(); }