/** * Returns a map with an icon and multiplicity parameter (that may be NULL). * * @param ?IP An IP address (used to check against bots) (NULL: no IP). * @param TIME A timestamp (used to check for logged sent emails). * @param ?string A user agent (used to check against phones) (NULL: no user agent). * @param ?string News ticker news (NULL: no news ticker news). * @return array Map with an icon and multiplicity parameter. */ function rain_get_special_icons($ip_address, $timestamp, $user_agent = NULL, $news = NULL) { $icon = NULL; $tooltip = ''; $multiplicity = 1; $bot = get_bot_type(); if (!is_null($bot)) { $icon = 'searchengine-icon'; $tooltip = do_lang('RTEV_BOT'); } else { if (!is_null($user_agent) && is_mobile($user_agent)) { $icon = 'phone-icon'; $tooltip = do_lang('RTEV_PHONE'); } else { $mails_sent = $GLOBALS['SITE_DB']->query_value('logged_mail_messages', 'COUNT(*)', array('m_date_and_time' => $timestamp)); if ($mails_sent > 0) { $multiplicity = $mails_sent; $icon = 'email-icon'; $tooltip = do_lang('RTEV_EMAILS', integer_format($multiplicity)); } elseif (!is_null($news)) { $icon = 'news-icon'; $tooltip = do_lang('RTEV_NEWS'); } } } return array('SPECIAL_ICON' => $icon, 'SPECIAL_TOOLTIP' => $tooltip, 'MULTIPLICITY' => strval(min(20, $multiplicity))); }
/** * See's if the current browser matches some special property code. Assumes users are keeping up on newish browsers (except for IE users, who are 6+) * * @param string The property code * @set android ios wysiwyg windows mac linux odd_os mobile opera ie_decent ie_new ie ie_old gecko konqueror safari odd_browser has_artificial_monopoly has_fanboys quirk__internalised_list_indent quirk__quirk__list_indent_in_ul_instead_of_li chrome ie5 ie6 ie7+ ie8+ ie9+ bot * @return boolean Whether there is a match */ function browser_matches($code) { global $BROWSER_MATCHES_CACHE; if (isset($BROWSER_MATCHES_CACHE[$code])) { return $BROWSER_MATCHES_CACHE[$code]; } $browser = strtolower(ocp_srv('HTTP_USER_AGENT')); $os = strtolower(ocp_srv('HTTP_UA_OS')) . ' ' . $browser; $is_opera = strpos($browser, 'opera') !== false; $is_konqueror = strpos($browser, 'konqueror') !== false; $is_safari = strpos($browser, 'applewebkit') !== false; $is_chrome = strpos($browser, 'chrome/') !== false; $is_gecko = strpos($browser, 'gecko') !== false && !$is_opera && !$is_konqueror && !$is_safari; $is_ie = (strpos($browser, 'msie') !== false || strpos($browser, 'trident') !== false) && !$is_opera; $is_ie_old = (strpos($browser, 'msie 6') !== false || strpos($browser, 'msie 5') !== false) && $is_ie; $is_ie_decent = !$is_ie_old && strpos($browser, 'msie 7') === false && $is_ie; $is_ie5 = strpos($browser, 'msie 5') !== false && $is_ie; $is_ie6 = strpos($browser, 'msie 6') !== false && $is_ie; $is_ie7 = strpos($browser, 'msie 7') !== false && $is_ie; $is_ie8 = strpos($browser, 'msie 8') !== false && $is_ie; $is_ie9 = strpos($browser, 'msie 8') === false && $is_ie_decent; $is_ie_new = !$is_ie_old && $is_ie; $is_iceweasel = strpos($browser, 'iceweasel') !== false; switch ($code) { case 'bot': $BROWSER_MATCHES_CACHE[$code] = !is_null(get_bot_type()); return $BROWSER_MATCHES_CACHE[$code]; case 'android': $BROWSER_MATCHES_CACHE[$code] = strpos($browser, 'android') !== false; return $BROWSER_MATCHES_CACHE[$code]; case 'ios': $BROWSER_MATCHES_CACHE[$code] = strpos($browser, 'iphone') !== false || strpos($browser, 'ipad') !== false; return $BROWSER_MATCHES_CACHE[$code]; case 'true_xhtml': $BROWSER_MATCHES_CACHE[$code] = $is_opera || $is_konqueror || $is_safari || $is_gecko; return $BROWSER_MATCHES_CACHE[$code]; case 'wysiwyg': if (get_option('wysiwyg') == '0' || is_mobile() || strpos($os, 'ipad') !== false) { $BROWSER_MATCHES_CACHE[$code] = false; return false; } $BROWSER_MATCHES_CACHE[$code] = true; // As of ocPortal 5.1, using CKEditor return $BROWSER_MATCHES_CACHE[$code]; case 'windows': $BROWSER_MATCHES_CACHE[$code] = strpos($os, 'windows') !== false || strpos($os, 'win32') !== false; return $BROWSER_MATCHES_CACHE[$code]; case 'mac': $BROWSER_MATCHES_CACHE[$code] = strpos($os, 'mac') !== false; return $BROWSER_MATCHES_CACHE[$code]; case 'linux': $BROWSER_MATCHES_CACHE[$code] = strpos($os, 'linux') !== false; return $BROWSER_MATCHES_CACHE[$code]; case 'odd_os': $BROWSER_MATCHES_CACHE[$code] = strpos($os, 'windows') === false && strpos($os, 'mac') === false && strpos($os, 'linux') === false; return $BROWSER_MATCHES_CACHE[$code]; case 'mobile': $BROWSER_MATCHES_CACHE[$code] = is_mobile(); return $BROWSER_MATCHES_CACHE[$code]; case 'opera': $BROWSER_MATCHES_CACHE[$code] = $is_opera; return $BROWSER_MATCHES_CACHE[$code]; case 'ie': $BROWSER_MATCHES_CACHE[$code] = $is_ie; return $BROWSER_MATCHES_CACHE[$code]; case 'ie5': $BROWSER_MATCHES_CACHE[$code] = $is_ie5; return $BROWSER_MATCHES_CACHE[$code]; case 'ie6': case 'ie_old': $BROWSER_MATCHES_CACHE[$code] = $is_ie_old; return $BROWSER_MATCHES_CACHE[$code]; case 'ie7': $BROWSER_MATCHES_CACHE[$code] = $is_ie7; return $BROWSER_MATCHES_CACHE[$code]; case 'ie8': $BROWSER_MATCHES_CACHE[$code] = $is_ie8; return $BROWSER_MATCHES_CACHE[$code]; case 'ie7+': case 'ie_new': $BROWSER_MATCHES_CACHE[$code] = $is_ie_new; return $BROWSER_MATCHES_CACHE[$code]; case 'ie8+': case 'ie_decent': $BROWSER_MATCHES_CACHE[$code] = $is_ie_decent; return $BROWSER_MATCHES_CACHE[$code]; case 'ie9+': $BROWSER_MATCHES_CACHE[$code] = $is_ie9; return $BROWSER_MATCHES_CACHE[$code]; case 'has_artificial_monopoly': $BROWSER_MATCHES_CACHE[$code] = $is_ie; return $BROWSER_MATCHES_CACHE[$code]; case 'has_fanboys': $BROWSER_MATCHES_CACHE[$code] = $is_gecko; // change to Chrome? return $BROWSER_MATCHES_CACHE[$code]; case 'no_multi_wysiwyg': $BROWSER_MATCHES_CACHE[$code] = false; //$is_gecko; once once needed, but Firefox is much more stable now return $BROWSER_MATCHES_CACHE[$code]; case 'chrome': $BROWSER_MATCHES_CACHE[$code] = $is_chrome; return $BROWSER_MATCHES_CACHE[$code]; case 'gecko': $BROWSER_MATCHES_CACHE[$code] = $is_gecko; return $BROWSER_MATCHES_CACHE[$code]; case 'konqueror': $BROWSER_MATCHES_CACHE[$code] = $is_konqueror; return $BROWSER_MATCHES_CACHE[$code]; case 'safari': $BROWSER_MATCHES_CACHE[$code] = $is_safari; return $BROWSER_MATCHES_CACHE[$code]; case 'odd_browser': $BROWSER_MATCHES_CACHE[$code] = !$is_opera && !$is_konqueror && !$is_safari && !$is_gecko && !$is_ie; return $BROWSER_MATCHES_CACHE[$code]; case 'quirk__internalised_list_indent': $BROWSER_MATCHES_CACHE[$code] = $is_gecko; return $BROWSER_MATCHES_CACHE[$code]; case 'quirk__list_indent_in_ul_instead_of_li': $BROWSER_MATCHES_CACHE[$code] = $is_opera; return $BROWSER_MATCHES_CACHE[$code]; case 'itunes': $BROWSER_MATCHES_CACHE[$code] = strpos($browser, 'itunes') !== false; return $BROWSER_MATCHES_CACHE[$code]; } // Should never get here return false; }
/** * Render a topic row (i.e. a row in a forum or results view), from given details (from ocf_get_topic_array). * * @param array The details (array containing: last_post_id, id, modifiers, emoticon, first_member_id, first_username, first_post, num_posts, num_views). * @param boolean Whether the viewing member has the facility to mark off topics (send as false if there are no actions for them to perform). * @param boolean Whether the topic is a Private Topic. * @param ?string The forum name (NULL: do not show the forum name). * @return tempcode The topic row. */ function ocf_render_topic($topic, $has_topic_marking, $pt = false, $show_forum = NULL) { if (array_key_exists('last_post_id', $topic) && !is_null($topic['last_post_id'])) { $last_post_url = build_url(array('page' => 'topicview', 'id' => $topic['last_post_id'], 'type' => 'findpost'), get_module_zone('topicview')); $last_post_url->attach('#post_' . strval($topic['last_post_id'])); if (!is_null($topic['last_member_id'])) { if ($topic['last_member_id'] != $GLOBALS['OCF_DRIVER']->get_guest_id()) { //$colour=get_group_colour(ocf_get_member_primary_group($topic['last_member_id'])); $poster = do_template('OCF_USER_MEMBER', array('USERNAME' => $topic['last_username'], 'PROFILE_URL' => $GLOBALS['OCF_DRIVER']->member_profile_url($topic['last_member_id'], false, true))); } else { $poster = protect_from_escaping(escape_html($topic['last_username'] == '' ? do_lang('SYSTEM') : $topic['last_username'])); } } else { $poster = do_lang_tempcode('NA'); } $last_post = do_template('OCF_FORUM_TOPIC_ROW_LAST_POST', array('_GUID' => '6aa8d0f4024ae12bf94b68b74faae7cf', 'ID' => strval($topic['id']), 'DATE_RAW' => strval($topic['last_time']), 'DATE' => $topic['last_time_string'], 'POSTER' => $poster, 'LAST_URL' => $last_post_url)); } else { $last_post = do_lang_tempcode('NA_EM'); } $map = array('page' => 'topicview', 'id' => $topic['id']); if (array_key_exists('forum_id', $topic) && is_null(get_bot_type()) && get_param_integer('start', 0) != 0) { $map['kfs' . strval($topic['forum_id'])] = get_param_integer('start', 0); } $url = build_url($map, get_module_zone('topicview')); // Modifiers $topic_row_links = new ocp_tempcode(); $modifiers = $topic['modifiers']; if (in_array('unread', $modifiers)) { $first_unread_url = build_url(array('page' => 'topicview', 'id' => $topic['id'], 'type' => 'first_unread'), get_module_zone('topicview')); $first_unread_url->attach('#first_unread'); $topic_row_links->attach(do_template('OCF_TOPIC_ROW_LINK', array('_GUID' => '6f52881ed999f4c543c9d8573b37fa48', 'URL' => $first_unread_url, 'IMG' => 'unread', 'ALT' => do_lang_tempcode('JUMP_TO_FIRST_UNREAD')))); } $topic_row_modifiers = new ocp_tempcode(); foreach ($modifiers as $modifier) { if ($modifier != 'unread') { $topic_row_modifiers->attach(do_template('OCF_TOPIC_ROW_MODIFIER', array('_GUID' => 'fbcb8791b571187fd699aa6796c3f401', 'IMG' => $modifier, 'ALT' => do_lang_tempcode('MODIFIER_' . $modifier)))); } } // Emoticon if ($topic['emoticon'] != '') { $emoticon = do_template('OCF_TOPIC_EMOTICON', array('_GUID' => 'dfbe0e4a11b3caa4d2da298ff23ca221', 'EMOTICON' => $topic['emoticon'])); } else { $emoticon = do_template('OCF_TOPIC_EMOTICON_NONE'); } if ($topic['first_member_id'] != $GLOBALS['OCF_DRIVER']->get_guest_id()) { $poster_profile_url = $GLOBALS['OCF_DRIVER']->member_profile_url($topic['first_member_id'], false, true); //$colour=get_group_colour(ocf_get_member_primary_group($topic['first_member_id'])); $poster = do_template('OCF_USER_MEMBER', array('PROFILE_URL' => $poster_profile_url, 'USERNAME' => $topic['first_username'])); } else { $poster = make_string_tempcode(escape_html($topic['first_username'])); } if ($pt) { $with = $topic['pt_from'] == $topic['first_member_id'] ? $topic['pt_to'] : $topic['pt_from']; $with_username = $GLOBALS['OCF_DRIVER']->get_username($with); if (is_null($with_username)) { $with_username = do_lang('UNKNOWN'); } $colour = get_group_colour(ocf_get_member_primary_group($with)); $b = do_template('OCF_USER_MEMBER', array('COLOUR' => $colour, 'PROFILE_URL' => $GLOBALS['OCF_DRIVER']->member_profile_url($with, false, true), 'USERNAME' => $with_username)); $poster = do_template('OCF_PT_BETWEEN', array('_GUID' => '619cd7076c4baf7b26cb3149694af929', 'A' => $poster, 'B' => $b)); } // Marker $marker = new ocp_tempcode(); if ($has_topic_marking) { $marker = do_template('OCF_TOPIC_MARKER', array('_GUID' => '62ff977640d3d4270cf333edab42a18f', 'ID' => strval($topic['id']))); } // Title $title = $topic['first_title']; // Page jump $max = intval(get_option('forum_posts_per_page')); require_code('templates_result_launcher'); $pages = results_launcher(do_lang_tempcode('NAMED_TOPIC', escape_html($title)), 'topicview', $topic['id'], $max, $topic['num_posts'], 'view', 5); // Tpl $post = $topic['first_post']; if (!is_null($show_forum)) { $hover = do_lang_tempcode('FORUM_AND_TIME_HOVER', escape_html($show_forum), escape_html(get_timezoned_date($topic['first_time']))); $breadcrumbs = ocf_forum_breadcrumbs($topic['forum_id'], NULL, NULL, false); } else { $hover = protect_from_escaping(is_null($topic['first_time']) ? '' : escape_html(get_timezoned_date($topic['first_time']))); $breadcrumbs = new ocp_tempcode(); } return do_template('OCF_FORUM_TOPIC_ROW', array('_GUID' => '1aca672272132f390c9ec23eebe0d171', 'BREADCRUMBS' => $breadcrumbs, 'RAW_TIME' => is_null($topic['first_time']) ? '' : strval($topic['first_time']), 'UNREAD' => in_array('unread', $modifiers), 'ID' => strval($topic['id']), 'HOVER' => $hover, 'PAGES' => $pages, 'MARKER' => $marker, 'TOPIC_ROW_LINKS' => $topic_row_links, 'TOPIC_ROW_MODIFIERS' => $topic_row_modifiers, 'POST' => $post, 'EMOTICON' => $emoticon, 'DESCRIPTION' => $topic['description'], 'URL' => $url, 'TITLE' => $title, 'POSTER' => $poster, 'NUM_POSTS' => integer_format($topic['num_posts']), 'NUM_VIEWS' => integer_format($topic['num_views']), 'LAST_POST' => $last_post)); }
/** * 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_topicview'); require_css('ocf'); global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'max'; $NON_CANONICAL_PARAMS[] = 'start'; $NON_CANONICAL_PARAMS[] = 'threaded'; $start = get_param_integer('start', 0); $default_max = intval(get_option('forum_posts_per_page')); $max = get_param_integer('max', $default_max); if ($max == 0) { $max = $default_max; } if ($max == 0) { $max = 1; } if ($max > 30 && !has_specific_permission(get_member(), 'remove_page_split')) { $max = $default_max; } $first_unread_id = -1; global $NON_CANONICAL_PARAMS; foreach (array_keys($_GET) as $key) { if (substr($key, 0, 3) == 'kfs') { $NON_CANONICAL_PARAMS[] = $key; } } $type = get_param('type', 'misc'); $id = get_param_integer('id', NULL); if (is_guest() && is_null($id)) { access_denied('NOT_AS_GUEST'); } if ($type == 'findpost') { $post_id = get_param_integer('id'); $redirect = find_post_id_url($post_id); require_code('site2'); assign_refresh($redirect, 0.0); return do_template('REDIRECT_SCREEN', array('_GUID' => '76e6d34c20a4f5284119827e41c7752f', 'URL' => $redirect, 'TITLE' => get_page_title('VIEW_TOPIC'), 'TEXT' => do_lang_tempcode('REDIRECTING'))); } else { if ($type == 'first_unread') { $redirect = find_first_unread_url($id); require_code('site2'); assign_refresh($redirect, 0.0); return do_template('REDIRECT_SCREEN', array('_GUID' => '12c5d16f60e8c4df03536d9a7a932528', 'URL' => $redirect, 'TITLE' => get_page_title('VIEW_TOPIC'), 'TEXT' => do_lang_tempcode('REDIRECTING'))); } } if (!is_null($id)) { $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=ocf_topicview&filter=' . strval($id); } $view_poll_results = get_param_integer('view_poll_results', 0); // Mark as read if (!is_null($id)) { if (!is_guest()) { $GLOBALS['FORUM_DB']->query_delete('f_read_logs', array('l_member_id' => get_member(), 'l_topic_id' => $id), '', 1); $GLOBALS['FORUM_DB']->query_insert('f_read_logs', array('l_member_id' => get_member(), 'l_topic_id' => $id, 'l_time' => time()), false, true); // race condition } $GLOBALS['FORUM_DB']->query('UPDATE ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_topics SET t_num_views=(t_num_views+1) WHERE id=' . strval((int) $id), 1, NULL, true); } // Load up topic info $topic_info = ocf_read_in_topic($id, $start, $max, $view_poll_results == 1); $GLOBALS['META_DATA'] += $topic_info['meta_data']; global $SEO_TITLE; $SEO_TITLE = do_lang('_VIEW_TOPIC', $topic_info['title']); // Render posts according to whether threaded or not $threaded = $topic_info['is_threaded'] == 1; $may_reply = array_key_exists('may_reply', $topic_info) && ($topic_info['is_open'] || array_key_exists('may_post_closed', $topic_info)); if (!$threaded) { $GLOBALS['META_DATA']['description'] = $topic_info['description']; // Poster detail hooks $hooks = find_all_hooks('modules', 'topicview'); $hook_objects = array(); foreach (array_keys($hooks) as $hook) { require_code('hooks/modules/topicview/' . filter_naughty_harsh($hook)); $object = object_factory('Hook_' . filter_naughty_harsh($hook), true); if (is_null($object)) { continue; } $hook_objects[$hook] = $object; } // Render non-threaded $posts = new ocp_tempcode(); $replied = false; if (is_null($topic_info['forum_id'])) { decache('side_ocf_personal_topics', array(get_member())); decache('_new_pp', array(get_member())); } $second_poster = $topic_info['first_poster']; foreach ($topic_info['posts'] as $array_id => $_postdetails) { if ($array_id == 0) { $description = $topic_info['description']; } else { $description = NULL; } if ($_postdetails['poster'] == get_member()) { $replied = true; } if ($array_id == 1 && $start == 0 || $array_id == 0 && $start != 0) { $second_poster = $_postdetails['poster']; } if (array_key_exists('last_edit_time', $_postdetails)) { $last_edited = do_template('OCF_TOPIC_POST_LAST_EDITED', array('_GUID' => '77a28e8bc3cf2ec2211aafdb5ba192bf', 'LAST_EDIT_DATE_RAW' => is_null($_postdetails['last_edit_time']) ? '' : strval($_postdetails['last_edit_time']), 'LAST_EDIT_DATE' => $_postdetails['last_edit_time_string'], 'LAST_EDIT_PROFILE_URL' => $GLOBALS['FORUM_DRIVER']->member_profile_url($_postdetails['last_edit_by'], false, true), 'LAST_EDIT_USERNAME' => $_postdetails['last_edit_by_username'])); } else { $last_edited = new ocp_tempcode(); } $last_edited_raw = array_key_exists('last_edit_time', $_postdetails) ? is_null($_postdetails['last_edit_time']) ? '' : strval($_postdetails['last_edit_time']) : '0'; $is_spacer_post = $_postdetails['is_spacer_post']; // Post buttons $buttons = new ocp_tempcode(); if (!$is_spacer_post) { $buttons = ocf_render_post_buttons($topic_info, $_postdetails, $may_reply); } // Avatar if (array_key_exists('poster_avatar', $_postdetails) && $_postdetails['poster_avatar'] != '') { $post_avatar = do_template('OCF_TOPIC_POST_AVATAR', array('_GUID' => 'd647ada9c11d56eedc0ff7894d33e83c', 'AVATAR' => $_postdetails['poster_avatar'])); } else { $post_avatar = new ocp_tempcode(); } // Rank images $rank_images = new ocp_tempcode(); if (!$is_spacer_post) { $posters_groups = $GLOBALS['FORUM_DRIVER']->get_members_groups($_postdetails['poster'], true); foreach ($posters_groups as $group) { $rank_image = ocf_get_group_property($group, 'rank_image'); $group_leader = ocf_get_group_property($group, 'group_leader'); $group_name = ocf_get_group_name($group); $rank_image_pri_only = ocf_get_group_property($group, 'rank_image_pri_only'); if ($rank_image != '' && ($rank_image_pri_only == 0 || $group == $GLOBALS['FORUM_DRIVER']->get_member_row_field($_postdetails['poster'], 'm_primary_group'))) { $rank_images->attach(do_template('OCF_RANK_IMAGE', array('_GUID' => '0ff7855482b901be95591964d4212c44', 'GROUP_NAME' => $group_name, 'USERNAME' => $GLOBALS['FORUM_DRIVER']->get_username($_postdetails['poster']), 'IMG' => $rank_image, 'IS_LEADER' => $group_leader == $_postdetails['poster']))); } } } // Poster details if (!$is_spacer_post) { if (!is_guest($_postdetails['poster'])) { require_code('ocf_members2'); $poster_details = ocf_show_member_box($_postdetails, false, $hooks, $hook_objects, false); } else { $custom_fields = new ocp_tempcode(); if (array_key_exists('ip_address', $_postdetails)) { $custom_fields->attach(do_template('OCF_TOPIC_POST_CUSTOM_FIELD', array('_GUID' => 'd85be094dff0d039a64120d6f8f381bb', 'NAME' => do_lang_tempcode('IP_ADDRESS'), 'VALUE' => $_postdetails['ip_address']))); $poster_details = do_template('OCF_GUEST_DETAILS', array('_GUID' => 'e43534acaf598008602e8da8f9725f38', 'CUSTOM_FIELDS' => $custom_fields)); } else { $poster_details = new ocp_tempcode(); } } } else { $poster_details = new ocp_tempcode(); } if (!is_guest($_postdetails['poster'])) { $poster = do_template('OCF_POSTER_MEMBER', array('_GUID' => 'dbbed1850b6c01a6c9601d85c6aee43f', 'ONLINE' => member_is_online($_postdetails['poster']), 'ID' => strval($_postdetails['poster']), 'POSTER_DETAILS' => $poster_details, 'PROFILE_URL' => $GLOBALS['FORUM_DRIVER']->member_profile_url($_postdetails['poster'], false, true), 'POSTER_USERNAME' => $_postdetails['poster_username'], 'HIGHLIGHT_NAME' => array_key_exists('poster_highlighted_name', $_postdetails) ? strval($_postdetails['poster_highlighted_name']) : NULL)); } else { $ip_link = array_key_exists('ip_address', $_postdetails) && has_actual_page_access(get_member(), 'admin_lookup') ? build_url(array('page' => 'admin_lookup', 'param' => $_postdetails['ip_address']), get_module_zone('admin_lookup')) : new ocp_tempcode(); $poster = do_template('OCF_POSTER_GUEST', array('_GUID' => '36a8e550222cdac5165ef8f722be3def', 'IP_LINK' => $ip_link, 'POSTER_DETAILS' => $poster_details, 'POSTER_USERNAME' => $_postdetails['poster_username'])); } // Signature $signature = new ocp_tempcode(); if (array_key_exists('signature', $_postdetails) && !$_postdetails['signature']->is_empty()) { $signature = $_postdetails['signature']; } $post_title = $_postdetails['title']; $first_unread = $_postdetails['id'] == $first_unread_id || $first_unread_id < 0 && $array_id == count($topic_info['posts']) - 1 ? do_template('OCF_TOPIC_FIRST_UNREAD') : new ocp_tempcode(); $unvalidated = $_postdetails['validated'] == 0 ? do_lang_tempcode('UNVALIDATED') : new ocp_tempcode(); $post_url = $GLOBALS['FORUM_DRIVER']->post_url($_postdetails['id'], is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']), true); if (array_key_exists('intended_solely_for', $_postdetails) && $_postdetails['intended_solely_for'] == get_member()) { decache('side_ocf_personal_topics', array(get_member())); decache('_new_pp', array(get_member())); } $emphasis = ocf_get_post_emphasis($_postdetails); require_code('feedback'); if (!array_key_exists('intended_solely_for', $_postdetails)) { actualise_rating(true, 'post', strval($_postdetails['id']), get_self_url(), $_postdetails['title']); $rating = display_rating(get_self_url(), $_postdetails['title'], 'post', strval($_postdetails['id']), 'RATING_INLINE_DYNAMIC', $_postdetails['poster']); } else { $rating = new ocp_tempcode(); } $rendered_post = do_template('OCF_TOPIC_POST', array('_GUID' => 'sacd09wekfofpw2f', 'ID' => $is_spacer_post ? '' : strval($_postdetails['id']), 'TOPIC_FIRST_POST_ID' => is_null($topic_info['first_post_id']) ? '' : strval($topic_info['first_post_id']), 'TOPIC_FIRST_POSTER' => is_null($topic_info['first_poster']) ? '' : strval($topic_info['first_poster']), 'POST_ID' => $is_spacer_post ? '' : (get_value('seq_post_ids') === '1' ? strval($start + $array_id + 1) : strval($_postdetails['id'])), 'URL' => $post_url, 'CLASS' => $_postdetails['is_emphasised'] ? 'ocf_post_emphasis' : (array_key_exists('intended_solely_for', $_postdetails) ? 'ocf_post_personal' : ''), 'EMPHASIS' => $emphasis, 'FIRST_UNREAD' => $first_unread, 'POSTER_TITLE' => $is_spacer_post ? '' : $_postdetails['poster_title'], 'POST_TITLE' => $post_title, 'POST_DATE_RAW' => strval($_postdetails['time']), 'POST_DATE' => $_postdetails['time_string'], 'POST' => $_postdetails['post'], 'TOPIC_ID' => is_null($id) ? '' : strval($id), 'LAST_EDITED_RAW' => $last_edited_raw, 'LAST_EDITED' => $last_edited, 'POSTER_ID' => strval($_postdetails['poster']), 'POSTER' => $is_spacer_post ? '' : $poster, 'POSTER_DETAILS' => $poster_details, 'POST_AVATAR' => $post_avatar, 'RANK_IMAGES' => $rank_images, 'BUTTONS' => $buttons, 'SIGNATURE' => $signature, 'UNVALIDATED' => $unvalidated, 'DESCRIPTION' => $description, 'RATING' => $rating)); $posts->attach($rendered_post); } $serialized_options = mixed(); $hash = mixed(); } else { require_code('topics'); $threaded_topic_ob = new OCP_Topic(); // Load some settings into the renderer $threaded_topic_ob->first_post_id = $topic_info['first_post_id']; $threaded_topic_ob->topic_description = $topic_info['description']; $threaded_topic_ob->topic_description_link = $topic_info['description_link']; $threaded_topic_ob->topic_title = $topic_info['title']; $threaded_topic_ob->topic_info = $topic_info; // Other settings we need $max_thread_depth = intval(get_option('max_thread_depth')); $num_to_show_limit = get_param_integer('max_comments', intval(get_option('comments_to_show_in_thread'))); // Load posts $threaded_topic_ob->load_from_topic($id, $num_to_show_limit, $start, false, NULL, true); $threaded_topic_ob->is_threaded = true; // Render posts list($posts, $serialized_options, $hash) = $threaded_topic_ob->render_posts($num_to_show_limit, $max_thread_depth, $may_reply, $topic_info['first_poster'], array(), $topic_info['forum_id'], NULL, false); $GLOBALS['META_DATA']['description'] = $threaded_topic_ob->topic_description; // Get other gathered details $replied = $threaded_topic_ob->replied; if (!is_null($threaded_topic_ob->topic_title)) { // Updated topic title $topic_info['title'] = $threaded_topic_ob->topic_title; } $topic_info['max_rows'] = $threaded_topic_ob->total_posts; $second_poster = $GLOBALS['FORUM_DRIVER']->get_guest_id(); // No definitive post orders } // Buttons for topic as whole $button_array = array(); if (!is_null($id)) { if (get_value('no_threaded_buttons') !== '1') { if ($threaded) { $view_as_linear_url = get_self_url(false, false, array('threaded' => 0)); $button_array[] = array('immediate' => true, 'title' => do_lang_tempcode('VIEW_AS_LINEAR'), 'url' => $view_as_linear_url, 'img' => 'linear'); } else { $view_as_threaded_url = get_self_url(false, false, array('threaded' => 1)); $button_array[] = array('immediate' => true, 'title' => do_lang_tempcode('VIEW_AS_THREADED'), 'url' => $view_as_threaded_url, 'img' => 'threaded'); } } if (!is_guest()) { $too_old = $topic_info['last_time'] < time() - 60 * 60 * 24 * intval(get_option('post_history_days')); if (get_value('disable_mark_topic_unread') !== '1' && !$too_old) { $map = array('page' => 'topics', 'type' => 'mark_unread_topic', 'id' => $id); $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1); if ($test != -1 && $test != 0) { $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test; } $test = get_param_integer('threaded', -1); if ($test != -1) { $map['threaded'] = $test; } $mark_unread_url = build_url($map, get_module_zone('topics')); $button_array[] = array('immediate' => true, 'title' => do_lang_tempcode('MARK_UNREAD'), 'url' => $mark_unread_url, 'img' => 'mark_unread'); } } if ($may_reply && is_null(get_bot_type())) { $reply_prevented = false; // "Staff-only" reply for support tickets if ($GLOBALS['FORUM_DRIVER']->is_staff(get_member()) && addon_installed('tickets')) { require_code('tickets'); if (is_ticket_forum($topic_info['forum_id'])) { if (is_guest($second_poster)) { $reply_prevented = true; } require_lang('tickets'); $map = array('page' => 'topics', 'type' => 'new_post', 'id' => $id, 'intended_solely_for' => $GLOBALS['FORUM_DRIVER']->get_guest_id()); $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1); if ($test != -1 && $test != 0) { $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test; } $test = get_param_integer('threaded', -1); if ($test != -1) { $map['threaded'] = $test; } $new_post_url = build_url($map, get_module_zone('topics')); $button_array[] = array('immediate' => false, 'rel' => 'add', 'title' => do_lang_tempcode('TICKET_STAFF_ONLY_REPLY'), 'url' => $new_post_url, 'img' => 'staff_only_reply'); } } if (!$reply_prevented) { if ($topic_info['is_threaded'] == 0) { $map = array('page' => 'topics', 'type' => 'new_post', 'id' => $id); $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1); if ($test != -1 && $test != 0) { $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test; } $test = get_param_integer('threaded', -1); if ($test != -1) { $map['threaded'] = $test; } $new_post_url = build_url($map, get_module_zone('topics')); $button_array[] = array('immediate' => false, 'rel' => 'add', 'title' => do_lang_tempcode($topic_info['is_open'] ? 'REPLY' : 'CLOSED'), 'url' => $new_post_url, 'img' => $topic_info['is_open'] ? 'reply' : 'closed'); } } else { unset($topic_info['may_use_quick_reply']); } } elseif ((is_null($topic_info['forum_id']) || has_specific_permission(get_member(), 'submit_lowrange_content', 'topics', array('forums', $topic_info['forum_id']))) && $topic_info['last_poster'] == get_member() && !is_guest() && ocf_may_edit_post_by(get_member(), $topic_info['forum_id'])) { $map = array('page' => 'topics', 'type' => 'edit_post', 'id' => $topic_info['last_post_id']); $test = get_param_integer('kfs' . strval($topic_info['forum_id']), -1); if ($test != -1 && $test != 0) { $map['kfs' . strval($topic_info['forum_id'])] = $test; } $test = get_param_integer('threaded', -1); if ($test != -1) { $map['threaded'] = $test; } $new_post_url = build_url($map, get_module_zone('topics')); $button_array[] = array('immediate' => false, 'rel' => 'edit', 'title' => do_lang_tempcode('LAST_POST'), 'url' => $new_post_url, 'img' => 'amend'); } if (!is_null($topic_info['forum_id'])) { if (get_value('disable_add_topic_btn_in_topic') !== '1') { if (ocf_may_post_topic($topic_info['forum_id'], get_member())) { $new_topic_url = build_url(array('page' => 'topics', 'type' => 'new_topic', 'id' => $topic_info['forum_id']), get_module_zone('topics')); $button_array[] = array('immediate' => false, 'rel' => 'add', 'title' => do_lang_tempcode('ADD_TOPIC'), 'url' => $new_topic_url, 'img' => 'new_topic'); } } } else { $invite_url = build_url(array('page' => 'topics', 'type' => 'invite_member', 'id' => $id), get_module_zone('topics')); $button_array[] = array('immediate' => false, 'title' => do_lang_tempcode('INVITE_MEMBER_TO_PT'), 'url' => $invite_url, 'img' => 'invite_member'); } } $buttons = ocf_screen_button_wrap($button_array); // Poll if (array_key_exists('poll', $topic_info)) { $_poll = $topic_info['poll']; $voted_already = $_poll['voted_already']; $poll_results = array_key_exists(0, $_poll['answers']) && array_key_exists('num_votes', $_poll['answers'][0]); $answers = new ocp_tempcode(); $real_button = false; if ($_poll['is_open']) { if ($poll_results) { $button = new ocp_tempcode(); } elseif ($_poll['requires_reply'] && !$replied) { $button = do_lang_tempcode('POLL_REQUIRES_REPLY'); } else { if (!has_specific_permission(get_member(), 'vote_in_polls') || is_guest()) { $button = do_lang_tempcode('VOTE_DENIED'); } else { if (!is_null($voted_already)) { $button = do_lang_tempcode('NOVOTE'); } else { require_lang('polls'); $map = array('page' => 'topicview', 'id' => $id, 'view_poll_results' => 1, 'start' => $start == 0 ? NULL : $start, 'max' => $max == $default_max ? NULL : $max); $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1); if ($test != -1 && $test != 0) { $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test; } $test = get_param_integer('threaded', -1); if ($test != -1) { $map['threaded'] = $test; } $results_url = build_url($map, get_module_zone('topics')); $button = do_template('OCF_TOPIC_POLL_BUTTON', array('_GUID' => '94b932fd01028df8f67bb5864d9235f9', 'RESULTS_URL' => $results_url)); $real_button = true; } } } } else { $button = do_lang_tempcode('TOPIC_POLL_CLOSED'); } foreach ($_poll['answers'] as $answer) { if ($poll_results && ($_poll['requires_reply'] == 0 || $replied)) { $num_votes = $answer['num_votes']; $total_votes = $_poll['total_votes']; if ($total_votes != 0) { $width = intval(round(70.0 * floatval($num_votes) / floatval($total_votes))); } else { $width = 0; } $answer_tpl = do_template('OCF_TOPIC_POLL_ANSWER_RESULTS', array('_GUID' => 'b32f4c526e147abf20ca0d668e40d515', 'ID' => strval($_poll['id']), 'NUM_VOTES' => integer_format($num_votes), 'WIDTH' => strval($width), 'ANSWER' => $answer['answer'], 'I' => strval($answer['id']))); } else { $answer_tpl = do_template('OCF_TOPIC_POLL_ANSWER' . ($_poll['maximum_selections'] == 1 ? '_RADIO' : ''), array('REAL_BUTTON' => $real_button, 'ID' => strval($_poll['id']), 'ANSWER' => $answer['answer'], 'I' => strval($answer['id']))); } $answers->attach($answer_tpl); } $map = array('page' => 'topics', 'type' => 'vote_poll', 'id' => $id, 'start' => $start == 0 ? NULL : $start, 'max' => $max == $default_max ? NULL : $max); $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1); if ($test != -1 && $test != 0) { $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test; } $test = get_param_integer('threaded', -1); if ($test != -1) { $map['threaded'] = $test; } $vote_url = build_url($map, get_module_zone('topics')); if ($_poll['is_private']) { $private = paragraph(do_lang_tempcode('TOPIC_POLL_IS_PRIVATE'), 'dfgsdgdsgs'); } else { $private = new ocp_tempcode(); } if ($_poll['maximum_selections'] > 1) { $num_choices = paragraph($_poll['minimum_selections'] == $_poll['maximum_selections'] ? do_lang_tempcode('POLL_NOT_ENOUGH_ERROR_2', integer_format($_poll['minimum_selections'])) : do_lang_tempcode('POLL_NOT_ENOUGH_ERROR', integer_format($_poll['minimum_selections']), integer_format($_poll['maximum_selections'])), 'dsfsdfsdfs'); } else { $num_choices = new ocp_tempcode(); } $poll = do_template('OCF_TOPIC_POLL' . ($poll_results ? '_VIEW_RESULTS' : ''), array('ID' => strval($_poll['id']), 'NUM_CHOICES' => $num_choices, 'PRIVATE' => $private, 'QUESTION' => $_poll['question'], 'ANSWERS' => $answers, 'REAL_BUTTON' => $real_button, 'BUTTON' => $button, 'VOTE_URL' => $vote_url, 'MINIMUM_SELECTIONS' => integer_format($_poll['minimum_selections']), 'MAXIMUM_SELECTIONS' => integer_format($_poll['maximum_selections']))); } else { $poll = new ocp_tempcode(); } // Forum nav tree if (!is_null($topic_info['forum_id'])) { $tree = ocf_forum_breadcrumbs($topic_info['forum_id'], NULL, NULL, false); } else { $tree = new ocp_tempcode(); $tree->attach(hyperlink(build_url(array('page' => 'members'), get_module_zone('members')), do_lang_tempcode('MEMBERS'), false, false, do_lang_tempcode('GO_BACKWARDS_TO', do_lang_tempcode('MEMBERS')), NULL, NULL, 'up')); $tree->attach(do_template('BREADCRUMB_ESCAPED')); if (has_specific_permission(get_member(), 'view_other_pt')) { $of_member = $topic_info['pt_from'] == get_member() ? $topic_info['pt_from'] : $topic_info['pt_to']; } else { $of_member = get_member(); } $of_username = $GLOBALS['FORUM_DRIVER']->get_username($of_member); if (is_null($of_username)) { $of_username = do_lang('UNKNOWN'); } $personal_topic_url = build_url(array('page' => 'members', 'type' => 'view', 'id' => $of_member), get_module_zone('members'), NULL, true, false, false, 'tab__pts'); $tree->attach(hyperlink($personal_topic_url, do_lang_tempcode('MEMBER_PROFILE', escape_html($of_username)), false, false, do_lang_tempcode('GO_BACKWARDS_TO', do_lang_tempcode('MEMBERS')), NULL, NULL, 'up')); } // Quick reply if (array_key_exists('may_use_quick_reply', $topic_info) && $may_reply && !is_null($id)) { $map = array('page' => 'topics', 'type' => '_add_reply', 'topic_id' => $id); $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1); if ($test != -1 && $test != 0) { $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test; } $test = get_param_integer('threaded', -1); if ($test != -1) { $map['threaded'] = $test; } $_post_url = build_url($map, get_module_zone('topics')); $post_url = $_post_url->evaluate(); $map = array('page' => 'topics', 'type' => 'new_post', 'id' => $id); if ($test != -1 && $test != 0) { $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test; } $more_url = build_url($map, get_module_zone('topics')); $_postdetails = array_key_exists('first_post', $topic_info) ? get_translated_tempcode($topic_info['first_post'], $GLOBALS['FORUM_DB']) : new ocp_tempcode(); $first_post = $_postdetails; $first_post_url = $GLOBALS['FORUM_DRIVER']->post_url($topic_info['first_post_id'], is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']), true); $display = 'block'; $expand_type = 'contract'; if ($topic_info['max_rows'] > $start + $max) { $display = 'none'; $expand_type = 'expand'; } $em = $GLOBALS['FORUM_DRIVER']->get_emoticon_chooser(); require_javascript('javascript_editing'); require_javascript('javascript_validation'); if (addon_installed('captcha')) { require_code('captcha'); $use_captcha = use_captcha(); if ($use_captcha) { generate_captcha(); } } else { $use_captcha = false; } $post_warning = ''; if ($topic_info['is_really_threaded'] == 1) { $post_warning = do_lang('THREADED_REPLY_NOTICE', $post_warning); } $quick_reply = do_template('COMMENTS_POSTING_FORM', array('_GUID' => '4c532620f3eb68d9cc820b18265792d7', 'JOIN_BITS' => '', 'USE_CAPTCHA' => $use_captcha, 'GET_EMAIL' => false, 'EMAIL_OPTIONAL' => true, 'GET_TITLE' => false, 'POST_WARNING' => $post_warning, 'COMMENT_TEXT' => '', 'EM' => $em, 'EXPAND_TYPE' => $expand_type, 'DISPLAY' => $display, 'FIRST_POST_URL' => $first_post_url, 'FIRST_POST' => $first_post, 'MORE_URL' => $more_url, 'COMMENT_URL' => $post_url, 'TITLE' => do_lang_tempcode('QUICK_REPLY'), 'SUBMIT_NAME' => do_lang_tempcode('MAKE_POST'))); } else { $quick_reply = new ocp_tempcode(); } $action_url = build_url(array('page' => 'topics', 'id' => $id), get_module_zone('topics')); if (!is_null($id)) { // Moderation options $moderator_actions = ''; if (is_null($topic_info['forum_id'])) { $moderator_actions .= '<option value="categorise_pts">' . do_lang('_CATEGORISE_PTS') . '</option>'; } if (array_key_exists('may_multi_moderate', $topic_info) && array_key_exists('forum_id', $topic_info)) { $multi_moderations = ocf_list_multi_moderations($topic_info['forum_id']); if (count($multi_moderations) != 0) { $moderator_actions .= '<optgroup label="' . do_lang('MULTI_MODERATIONS') . '">'; foreach ($multi_moderations as $mm_id => $mm_name) { $moderator_actions .= '<option value="mm_' . strval($mm_id) . '">' . $mm_name . '</option>'; } $moderator_actions .= '</optgroup>'; } } if (array_key_exists('may_move_topic', $topic_info)) { $moderator_actions .= '<option value="move_topic">' . do_lang('MOVE_TOPIC') . '</option>'; } if (array_key_exists('may_edit_topic', $topic_info)) { $moderator_actions .= '<option value="edit_topic">' . do_lang('EDIT_TOPIC') . '</option>'; } if (array_key_exists('may_delete_topic', $topic_info)) { $moderator_actions .= '<option value="delete_topic">' . do_lang('DELETE_TOPIC') . '</option>'; } if (array_key_exists('may_pin_topic', $topic_info)) { $moderator_actions .= '<option value="pin_topic">' . do_lang('PIN_TOPIC') . '</option>'; } if (array_key_exists('may_unpin_topic', $topic_info)) { $moderator_actions .= '<option value="unpin_topic">' . do_lang('UNPIN_TOPIC') . '</option>'; } if (array_key_exists('may_sink_topic', $topic_info)) { $moderator_actions .= '<option value="sink_topic">' . do_lang('SINK_TOPIC') . '</option>'; } if (array_key_exists('may_unsink_topic', $topic_info)) { $moderator_actions .= '<option value="unsink_topic">' . do_lang('UNSINK_TOPIC') . '</option>'; } if (array_key_exists('may_cascade_topic', $topic_info)) { $moderator_actions .= '<option value="cascade_topic">' . do_lang('CASCADE_TOPIC') . '</option>'; } if (array_key_exists('may_uncascade_topic', $topic_info)) { $moderator_actions .= '<option value="uncascade_topic">' . do_lang('UNCASCADE_TOPIC') . '</option>'; } if (array_key_exists('may_open_topic', $topic_info)) { $moderator_actions .= '<option value="open_topic">' . do_lang('OPEN_TOPIC') . '</option>'; } if (array_key_exists('may_close_topic', $topic_info)) { $moderator_actions .= '<option value="close_topic">' . do_lang('CLOSE_TOPIC') . '</option>'; } if (array_key_exists('may_edit_poll', $topic_info)) { $moderator_actions .= '<option value="edit_poll">' . do_lang('EDIT_TOPIC_POLL') . '</option>'; } if (array_key_exists('may_delete_poll', $topic_info)) { $moderator_actions .= '<option value="delete_poll">' . do_lang('DELETE_TOPIC_POLL') . '</option>'; } if (array_key_exists('may_attach_poll', $topic_info)) { $moderator_actions .= '<option value="add_poll">' . do_lang('ADD_TOPIC_POLL') . '</option>'; } if (has_specific_permission(get_member(), 'view_content_history') && $GLOBALS['FORUM_DB']->query_value('f_post_history', 'COUNT(*)', array('h_topic_id' => $id)) != 0) { $moderator_actions .= '<option value="topic_history">' . do_lang('POST_HISTORY') . '</option>'; } if (array_key_exists('may_make_personal', $topic_info) && !is_null($topic_info['forum_id'])) { $moderator_actions .= '<option value="make_personal">' . do_lang('MAKE_PERSONAL') . '</option>'; } if ($GLOBALS['XSS_DETECT']) { ocp_mark_as_escaped($moderator_actions); } // Marked post actions $map = array('page' => 'topics', 'id' => $id); $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1); if ($test != -1 && $test != 0) { $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test; } $test = get_param_integer('threaded', -1); if ($test != -1) { $map['threaded'] = $test; } $action_url = build_url($map, get_module_zone('topics'), NULL, false, true); $marked_post_actions = ''; if (array_key_exists('may_move_posts', $topic_info)) { $marked_post_actions .= '<option value="move_posts_a">' . do_lang('MERGE_POSTS') . '</option>'; $marked_post_actions .= '<option value="move_posts_b">' . do_lang('SPLIT_POSTS') . '</option>'; } if (array_key_exists('may_delete_posts', $topic_info)) { $marked_post_actions .= '<option value="delete_posts">' . do_lang('DELETE_POSTS') . '</option>'; } if (array_key_exists('may_validate_posts', $topic_info)) { $marked_post_actions .= '<option value="validate_posts">' . do_lang('VALIDATE_POSTS') . '</option>'; } if (get_value('disable_multi_quote') !== '1') { if ($may_reply) { $marked_post_actions .= '<option value="new_post">' . do_lang('QUOTE_POSTS') . '</option>'; } } if ($GLOBALS['XSS_DETECT']) { ocp_mark_as_escaped($marked_post_actions); } } else { $moderator_actions = ''; $marked_post_actions = ''; } $max_rows = $topic_info['max_rows']; if ($max_rows > $max && !$threaded) { require_code('templates_results_browser'); $results_browser = results_browser(do_lang_tempcode('FORUM_POSTS'), $id, $start, 'start', $max, 'max', $max_rows, NULL, 'misc', true, false, 7, array(10, 20, 30)); } else { $results_browser = new ocp_tempcode(); } // Members viewing this topic $members = is_null($id) ? array() : get_members_viewing('topicview', '', strval($id), true); $num_guests = 0; $num_members = 0; if (is_null($members)) { $members_viewing = new ocp_tempcode(); } else { $members_viewing = new ocp_tempcode(); foreach ($members as $member_id => $at_details) { $username = $at_details['mt_cache_username']; if (is_guest($member_id)) { $num_guests++; } else { $num_members++; $profile_url = $GLOBALS['FORUM_DRIVER']->member_profile_url($member_id, false, true); $map = array('PROFILE_URL' => $profile_url, 'USERNAME' => $username); if (has_specific_permission(get_member(), 'show_user_browsing') || in_array($at_details['the_page'], array('topics', 'topicview')) && $at_details['the_id'] == strval($id)) { $map['AT'] = escape_html($at_details['the_title']); } $map['COLOUR'] = get_group_colour(ocf_get_member_primary_group($member_id)); $members_viewing->attach(do_template('OCF_USER_MEMBER', $map)); } } if ($members_viewing->is_empty()) { $members_viewing = do_lang_tempcode('NONE_EM'); } } if (!is_null($id)) { breadcrumb_add_segment($tree, do_lang_tempcode(is_null($topic_info['forum_id']) ? 'VIEW_PERSONAL_TOPIC' : 'VIEW_TOPIC')); } if (is_null($id)) { $root_forum_name = $GLOBALS['FORUM_DB']->query_value('f_forums', 'f_name', array('id' => db_get_first_id())); $tree = hyperlink(build_url(array('page' => 'forumview', 'id' => db_get_first_id()), get_module_zone('forumview')), escape_html($root_forum_name), false, false, do_lang('GO_BACKWARDS_TO')); breadcrumb_add_segment($tree, do_lang('INLINE_PERSONAL_POSTS')); } if ($topic_info['validated'] == 0) { $warning_details = do_template('WARNING_TABLE', array('WARNING' => do_lang_tempcode(get_param_integer('redirected', 0) == 1 ? 'UNVALIDATED_TEXT_NON_DIRECT' : 'UNVALIDATED_TEXT'))); } else { $warning_details = new ocp_tempcode(); } $topic_tpl = do_template('OCF_TOPIC_WRAP', array('_GUID' => 'bb201d5d59559e5e2bd60e7cf2e6f7e9', 'SERIALIZED_OPTIONS' => $serialized_options, 'HASH' => $hash, 'ID' => strval($id), 'TITLE' => $topic_info['title'], 'MAY_DOUBLE_POST' => has_specific_permission(get_member(), 'double_post'), 'LAST_POSTER' => array_key_exists('last_poster', $topic_info) ? is_null($topic_info['last_poster']) ? '' : strval($topic_info['last_poster']) : '', 'WARNING_DETAILS' => $warning_details, 'MAX' => strval($max), 'MAY_CHANGE_MAX' => array_key_exists('may_change_max', $topic_info), 'ACTION_URL' => $action_url, 'NUM_GUESTS' => integer_format($num_guests), 'NUM_MEMBERS' => integer_format($num_members), 'MEMBERS_VIEWING' => $members_viewing, 'RESULTS_BROWSER' => $results_browser, 'MODERATOR_ACTIONS' => $moderator_actions, 'MARKED_POST_ACTIONS' => $marked_post_actions, 'QUICK_REPLY' => $quick_reply, 'TREE' => $tree, 'POLL' => $poll, 'SCREEN_BUTTONS' => $buttons, 'POSTS' => $posts, 'THREADED' => $threaded)); if (is_null($id)) { $title = get_page_title('INLINE_PERSONAL_POSTS'); } else { if (is_null($topic_info['forum_id'])) { $title = get_page_title(do_lang_tempcode('NAMED_PERSONAL_TOPIC', escape_html($topic_info['title'])), false, NULL, do_lang_tempcode('READING_PERSONAL_TOPIC')); } else { if (addon_installed('awards')) { require_code('awards'); $awards = find_awards_for('topic', strval($id)); } else { $awards = array(); } $title = get_page_title(do_lang_tempcode('NAMED_TOPIC', escape_html($topic_info['title'])), false, NULL, NULL, $awards); } } return ocf_wrapper($title, $topic_tpl, true, false, $topic_info['forum_id']); }
/** * Log statistics for the page view. * * @param string The string to the page file * @param integer The time taken for page loading in milliseconds */ function log_stats($string, $pg_time) { if (!addon_installed('stats')) { return; } if (get_option('site_closed') == '1' && get_option('no_stats_when_closed', true) === '1') { return; } if (get_option('super_logging') == '1' || get_param('track', NULL) !== NULL) { $get = substr(flatten_slashed_array($_GET), 0, 255); $post2 = $_POST; unset($post2['password']); unset($post2['password_confirm']); unset($post2['decrypt']); $post = flatten_slashed_array($post2); } else { $get = ''; $post = ''; } $page = $string; $ip = get_ip_address(); $member = get_member(); if (is_guest($member)) { $member = -get_session_id(); } $time = time(); $referer = substr(ocp_srv('HTTP_REFERER'), 0, 255); $browser = substr(get_browser_string(), 0, 255); $os = substr(get_os_string(), 0, 255); if ($os === NULL) { $os = ''; } if (get_option('no_bot_stats', true) === '1' && (strpos(strtolower($browser), 'http:') !== false || strpos(strtolower($browser), 'bot') !== false || get_bot_type() !== NULL)) { return; } $GLOBALS['SITE_DB']->query_insert('stats', array('access_denied_counter' => 0, 'browser' => $browser, 'operating_system' => $os, 'the_page' => $page, 'ip' => $ip, 'the_user' => $member, 'date_and_time' => $time, 'referer' => $referer, 'get' => $get, 'post' => $post, 'milliseconds' => intval($pg_time * 1000)), false, true); if (mt_rand(0, 1000) == 1) { $GLOBALS['SITE_DB']->query('DELETE FROM ' . get_table_prefix() . 'stats WHERE date_and_time<' . strval(time() - 60 * 60 * 24 * intval(get_option('stats_store_time')))); } global $SITE_INFO; if (isset($SITE_INFO['throttle_bandwidth_views_per_meg'])) { set_value('page_views', strval(intval(get_value('page_views')) + 1)); } }
/** * Make sure that the given URL contains a session if cookies are disabled. * NB: This is used for login redirection. It had to add the session id into the redirect url. * * @param URLPATH The URL to enforce results in session persistence for the user * @return URLPATH The fixed URL (potentially nothing was done, depending on cookies) */ function enforce_sessioned_url($url) { if (!has_cookies() && is_null(get_bot_type())) { require_code('users_inactive_occasionals'); return _enforce_sessioned_url($url); } return $url; }
/** * Build and return a proper URL, from the $vars array. * Note: URL parameters should always be in lower case (one of the coding standards) * * @param array A map of parameter names to parameter values. Values may be strings or integers, or NULL. NULL indicates "skip this". 'page' cannot be NULL. * @param ID_TEXT The zone the URL is pointing to. YOU SHOULD NEVER HARD CODE THIS- USE '_SEARCH', '_SELF' (if you're self-referencing your own page) or the output of get_module_zone. * @param ?array Variables to explicitly not put in the URL (perhaps because we have $keep_all set, or we are blocking certain keep_ values). The format is of a map where the keys are the names, and the values are 1. (NULL: don't skip any) * @param boolean Whether to keep all non-skipped parameters that were in the current URL, in this URL * @param boolean Whether to avoid mod_rewrite (sometimes essential so we can assume the standard URL parameter addition scheme in templates) * @param boolean Whether to skip actually putting on keep_ parameters (rarely will this skipping be desirable) * @param string Hash portion of the URL (blank: none). * @return string The URL in string format. */ function _build_url($vars, $zone_name = '', $skip = NULL, $keep_all = false, $avoid_remap = false, $skip_keep = false, $hash = '') { global $HAS_KEEP_IN_URL, $USE_REWRITE_PARAMS, $CACHE_BOT_TYPE; // Build up our URL base $url = get_base_url(is_page_https($zone_name, isset($vars['page']) ? $vars['page'] : ''), $zone_name); $url .= '/'; // For bots we explicitly unset skippable injected 'keep_' params because it bloats the crawl-space if ($CACHE_BOT_TYPE !== NULL && get_bot_type() !== NULL) { foreach ($vars as $key => $val) { if ($key == 'redirect' || $key == 'root') { unset($vars[$key]); } if (substr($key, 0, 5) == 'keep_' && skippable_keep($key, $val)) { unset($vars[$key]); } } } // Things we need to keep in the url $keep_actual = array(); if ($HAS_KEEP_IN_URL === NULL || $HAS_KEEP_IN_URL || $keep_all) { $mc = get_magic_quotes_gpc(); $keep_cant_use = array(); $HAS_KEEP_IN_URL = false; foreach ($_GET as $key => $val) { if (!is_string($val)) { continue; } $is_keep = false; $appears_keep = $key[0] == 'k' && substr($key, 0, 5) == 'keep_'; if ($appears_keep) { if (!$skip_keep && !skippable_keep($key, $val)) { $is_keep = true; } $HAS_KEEP_IN_URL = true; } if (($keep_all && !$appears_keep || $is_keep) && !array_key_exists($key, $vars) && !isset($skip[$key])) { if ($mc) { $val = stripslashes($val); } if ($is_keep) { $keep_actual[$key] = $val; } else { $vars[$key] = $val; } } elseif ($is_keep) { if ($mc) { $val = stripslashes($val); } $keep_cant_use[$key] = $val; } } $vars += $keep_actual; } global $URL_MONIKERS_ENABLED; if ($URL_MONIKERS_ENABLED === NULL) { $URL_MONIKERS_ENABLED = url_monikers_enabled(); } if ($URL_MONIKERS_ENABLED) { $test = find_id_moniker($vars); if ($test !== NULL) { $vars['id'] = $test; } } // We either use mod_rewrite, or return a standard parameterisation if ($USE_REWRITE_PARAMS === NULL || $avoid_remap) { $use_rewrite_params = can_try_mod_rewrite($avoid_remap); if (!$avoid_remap) { $USE_REWRITE_PARAMS = $use_rewrite_params; } } else { $use_rewrite_params = $USE_REWRITE_PARAMS; } $test_rewrite = NULL; if ($use_rewrite_params) { $test_rewrite = _url_rewrite_params($zone_name, $vars, count($keep_actual) > 0); } else { $test_rewrite = NULL; } if ($test_rewrite === NULL) { $url .= 'index.php'; // Fix sort order if (isset($vars['id'])) { $_vars = $vars; unset($_vars['id']); $vars = array('id' => $vars['id']) + $_vars; } if (isset($vars['type'])) { $_vars = $vars; unset($_vars['type']); $vars = array('type' => $vars['type']) + $_vars; } if (isset($vars['page'])) { $_vars = $vars; unset($_vars['page']); $vars = array('page' => $vars['page']) + $_vars; } // Build up the URL string $symbol = '?'; foreach ($vars as $key => $val) { if ($val === NULL) { continue; } // NULL means skip if ($val === SELF_REDIRECT) { $val = get_self_url(true, true); } // Add in $url .= $symbol . $key . '=' . (is_integer($val) ? strval($val) : urlencode($val)); $symbol = '&'; } } else { $url .= $test_rewrite; } // Done return $url . $hash; }
/** * Get buttons for showing under a post. * * @param array Map of topic info. * @param array Map of post info. * @param boolean Whether the current member may reply to the topic * @return tempcode The buttons. */ function ocf_render_post_buttons($topic_info, $_postdetails, $may_reply) { require_lang('ocf'); require_code('ocf_members2'); $buttons = new ocp_tempcode(); if (array_key_exists('may_validate_posts', $topic_info) && ($topic_info['validated'] == 0 && $_postdetails['id'] == $topic_info['first_post_id'] || $_postdetails['validated'] == 0)) { $map = array('page' => 'topics', 'type' => 'validate_post', 'id' => $_postdetails['id']); $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1); if ($test != -1 && $test != 0) { $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test; } $test = get_param_integer('threaded', -1); if ($test != -1) { $map['threaded'] = $test; } $action_url = build_url($map, get_module_zone('topics')); $_title = do_lang_tempcode('VALIDATE_POST'); $_title->attach(do_lang_tempcode('ID_NUM', strval($_postdetails['id']))); $buttons->attach(do_template('SCREEN_ITEM_BUTTON', array('_GUID' => '712fdaee35f378e37b007f3a73246690', 'REL' => 'validate', 'IMMEDIATE' => true, 'IMG' => 'validate', 'TITLE' => $_title, 'URL' => $action_url))); } if ($may_reply && is_null(get_bot_type())) { $map = array('page' => 'topics', 'type' => 'new_post', 'id' => $_postdetails['topic_id'], 'parent_id' => $_postdetails['id']); if ($topic_info['is_threaded'] == 0) { $map['quote'] = $_postdetails['id']; } if (array_key_exists('intended_solely_for', $_postdetails)) { $map['intended_solely_for'] = $_postdetails['poster']; } $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1); if ($test != -1 && $test != 0) { $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test; } $test = get_param_integer('threaded', -1); if ($test != -1) { $map['threaded'] = $test; } $action_url = build_url($map, get_module_zone('topics')); $_title = do_lang_tempcode($topic_info['is_threaded'] == 1 ? 'REPLY' : 'QUOTE_POST'); $_title->attach(do_lang_tempcode('ID_NUM', strval($_postdetails['id']))); $javascript = NULL; if (array_key_exists('message_comcode', $_postdetails) && !is_null($_postdetails['message_comcode']) && strlen($_postdetails['message_comcode']) < 1024 * 10 && array_key_exists('may_use_quick_reply', $topic_info) && !array_key_exists('intended_solely_for', $map)) { $javascript = 'return topic_reply(' . ($topic_info['is_threaded'] ? 'true' : 'false') . ',this,\'' . strval($_postdetails['id']) . '\',\'' . addslashes($_postdetails['poster_username']) . '\',\'' . str_replace(chr(10), '\\n', addslashes($_postdetails['message_comcode'])) . '\',\'' . str_replace(chr(10), '\\n', addslashes($topic_info['is_threaded'] == 0 ? '' : strip_comcode($_postdetails['message_comcode']))) . '\');'; } $buttons->attach(do_template('SCREEN_ITEM_BUTTON', array('_GUID' => 'fc13d12cfe58324d78befec29a663b4f', 'REL' => 'add reply', 'IMMEDIATE' => false, 'IMG' => $topic_info['is_threaded'] == 1 ? 'reply' : 'quote', 'TITLE' => $_title, 'URL' => $action_url, 'JAVASCRIPT' => $javascript))); } if (addon_installed('points') && !is_guest() && !is_guest($_postdetails['poster']) && has_specific_permission($_postdetails['poster'], 'use_points')) { $action_url = build_url(array('page' => 'points', 'type' => 'member', 'id' => $_postdetails['poster']), get_module_zone('points')); $_title = do_lang_tempcode('POINTS_THANKS'); $buttons->attach(do_template('SCREEN_ITEM_BUTTON', array('_GUID' => 'a66f98cb4d56bd0d64e9ecc44d357141', 'IMMEDIATE' => false, 'IMG' => 'points', 'TITLE' => $_title, 'URL' => $action_url))); } if (array_key_exists('may_pt_members', $topic_info) && $may_reply && $_postdetails['poster'] != get_member() && $_postdetails['poster'] != $GLOBALS['OCF_DRIVER']->get_guest_id() && ocf_may_whisper($_postdetails['poster']) && get_option('overt_whisper_suggestion') == '1') { $whisper_type = get_value('no_inline_pp_advertise') === '1' ? 'new_pt' : 'whisper'; $action_url = build_url(array('page' => 'topics', 'type' => $whisper_type, 'id' => $_postdetails['topic_id'], 'quote' => $_postdetails['id'], 'intended_solely_for' => $_postdetails['poster']), get_module_zone('topics')); $_title = do_lang_tempcode('WHISPER'); $_title->attach(do_lang_tempcode('ID_NUM', strval($_postdetails['id']))); $buttons->attach(do_template('SCREEN_ITEM_BUTTON', array('_GUID' => 'fb1c74bae9c553dc160ade85adf289b5', 'REL' => 'add reply contact', 'IMMEDIATE' => false, 'IMG' => get_value('no_inline_pp_advertise') === '1' ? 'send_message' : 'whisper', 'TITLE' => $_title, 'URL' => $action_url))); } if (array_key_exists('may_report_posts', $topic_info) && addon_installed('ocf_reported_posts') && is_null(get_bot_type())) { $action_url = build_url(array('page' => 'topics', 'type' => 'report_post', 'id' => $_postdetails['id']), get_module_zone('topics')); $_title = do_lang_tempcode('REPORT_POST'); $_title->attach(do_lang_tempcode('ID_NUM', strval($_postdetails['id']))); $buttons->attach(do_template('SCREEN_ITEM_BUTTON', array('_GUID' => 'f81cbe84f524b4ed9e089c6e89a7c717', 'REL' => 'report', 'IMMEDIATE' => false, 'IMG' => 'report_post', 'TITLE' => $_title, 'URL' => $action_url, 'JAVASCRIPT' => 'return open_link_as_overlay(this,null,\'100%\');'))); } if (array_key_exists('may_edit', $_postdetails)) { $map = array('page' => 'topics', 'type' => 'edit_post', 'id' => $_postdetails['id']); $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1); if ($test != -1 && $test != 0) { $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test; } $test = get_param_integer('threaded', -1); if ($test != -1) { $map['threaded'] = $test; } $edit_url = build_url($map, get_module_zone('topics')); $_title = do_lang_tempcode('EDIT_POST'); $_title->attach(do_lang_tempcode('ID_NUM', strval($_postdetails['id']))); $buttons->attach(do_template('SCREEN_ITEM_BUTTON', array('_GUID' => 'f341cfc94b3d705437d43e89f572bff6', 'REL' => 'edit', 'IMMEDIATE' => false, 'IMG' => 'edit', 'TITLE' => $_title, 'URL' => $edit_url))); } if (array_key_exists('may_delete', $_postdetails)) { $map = array('page' => 'topics', 'type' => 'delete_post', 'id' => $_postdetails['id']); $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1); if ($test != -1 && $test != 0) { $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test; } $test = get_param_integer('threaded', -1); if ($test != -1) { $map['threaded'] = $test; } $delete_url = build_url($map, get_module_zone('topics')); $_title = do_lang_tempcode('DELETE_POST'); $_title->attach(do_lang_tempcode('ID_NUM', strval($_postdetails['id']))); $buttons->attach(do_template('SCREEN_ITEM_BUTTON', array('_GUID' => '8bf6d098ddc217eef75718464dc03d41', 'REL' => 'delete', 'IMMEDIATE' => false, 'IMG' => 'delete', 'TITLE' => $_title, 'URL' => $delete_url))); } if (array_key_exists('may_warn_members', $topic_info) && $_postdetails['poster'] != $GLOBALS['OCF_DRIVER']->get_guest_id() && addon_installed('ocf_warnings')) { $redir_url = get_self_url(true); $redir_url .= '#post_' . strval($_postdetails['id']); $action_url = build_url(array('page' => 'warnings', 'type' => 'ad', 'id' => $_postdetails['poster'], 'post_id' => $_postdetails['id'], 'redirect' => $redir_url), get_module_zone('warnings')); $_title = do_lang_tempcode('WARN_MEMBER'); $_title->attach(do_lang_tempcode('ID_NUM', strval($_postdetails['id']))); $buttons->attach(do_template('SCREEN_ITEM_BUTTON', array('_GUID' => '2698c51b06a72773ac7135bbfe791318', 'IMMEDIATE' => false, 'IMG' => 'punish', 'TITLE' => $_title, 'URL' => $action_url))); } if (has_specific_permission(get_member(), 'view_content_history') && $_postdetails['has_history']) { $action_url = build_url(array('page' => 'admin_ocf_history', 'type' => 'misc', 'post_id' => $_postdetails['id']), 'adminzone'); $_title = do_lang_tempcode('POST_HISTORY'); $_title->attach(do_lang_tempcode('ID_NUM', strval($_postdetails['id']))); $buttons->attach(do_template('SCREEN_ITEM_BUTTON', array('_GUID' => 'a66f98cb4d56bd0d64e9ecc44d357141', 'REL' => 'history', 'IMMEDIATE' => false, 'IMG' => 'history', 'TITLE' => $_title, 'URL' => $action_url))); } return $buttons; }
/** * Standard code module initialisation function. */ function init__global2() { global $BOOTSTRAPPING, $CHECKING_SAFEMODE, $BAD_WORD_CHARS, $FIXED_WORD_CHARS, $FIXED_WORD_CHARS_HTML, $BROWSER_DECACHEING, $CHARSET, $TEMP_CHARSET, $RELATIVE_PATH, $CURRENTLY_HTTPS, $RUNNING_SCRIPT_CACHE, $SERVER_TIMEZONE, $HAS_SET_ERROR_HANDLER, $DYING_BADLY, $XSS_DETECT, $SITE_INFO, $JAVASCRIPTS, $JAVASCRIPT, $CSSS, $IN_MINIKERNEL_VERSION, $EXITING, $FILE_BASE, $MOBILE, $CACHE_TEMPLATES, $BASE_URL_HTTP, $BASE_URL_HTTPS, $WORDS_TO_FILTER, $FIELD_RESTRICTIONS, $VALID_ENCODING, $CONVERTED_ENCODING, $MICRO_BOOTUP, $MICRO_AJAX_BOOTUP, $QUERY_LOG, $_CREATED_FILES, $CURRENT_SHARE_USER, $CACHE_FIND_SCRIPT; if (str_replace(array('on', 'true', 'yes'), array('1', '1', '1'), strtolower(ini_get('output_buffering'))) == '1') { @ob_end_clean(); } if (array_key_exists('HTTP_X_REWRITE_URL', $_SERVER)) { foreach ($_GET as $key => $val) { if ($key[0] == '?') { unset($_GET[$key]); $_GET[substr($key, 1)] = $val; } } $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL']; } elseif (!array_key_exists('REQUEST_URI', $_SERVER) && !array_key_exists('REQUEST_URI', $_ENV)) { $_SERVER['REQUEST_URI'] = $_SERVER['PHP_SELF']; $first = true; foreach ($_GET as $key => $val) { $_SERVER['REQUEST_URI'] .= $first ? '?' : '&'; $_SERVER['REQUEST_URI'] .= urlencode($key) . '=' . urlencode($val); $first = false; } } if (array_key_exists('SCRIPT_FILENAME', $_SERVER) && !array_key_exists('PHP_SELF', $_SERVER)) { $_SERVER['PHP_SELF'] = $_SERVER['SCRIPT_FILENAME']; } elseif (array_key_exists('SCRIPT_NAME', $_SERVER) && defined('HIPHOP_PHP')) { $_SERVER['PHP_SELF'] = $_SERVER['SCRIPT_NAME']; } @header('Expires: Mon, 20 Dec 1998 01:00:00 GMT'); @header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); @header('Cache-Control: no-cache, max-age=0'); @header('Pragma: no-cache'); // for proxies, and also IE if (is_file('closed.html') && get_param_integer('keep_force_open', 0) == 0) { if (strpos($_SERVER['PHP_SELF'], 'upgrader.php') === false && strpos($_SERVER['PHP_SELF'], 'execute_temp.php') === false && (!isset($SITE_INFO['no_extra_closed_file']) || $SITE_INFO['no_extra_closed_file'] == '0')) { if (@strpos($_SERVER['SERVER_SOFTWARE'], 'IIS') === false) { header('HTTP/1.0 503 Service Temporarily Unavailable'); } header('Location: ' . (is_file($RELATIVE_PATH . 'closed.html') ? 'closed.html' : '../closed.html')); exit; } } // Cover up holes in old PHP versions functionality if (!function_exists('str_word_count')) { /** * Isolate the words in the input string. * * @param string String to count words in * @param integer The format * @set 0 1 2 * @return mixed Typically a list - the words of the input string */ function str_word_count($input, $format = 0) { //count words $pattern = "/[^(\\w|\\d|\\'|\"|\\.|\\!|\\?|;|,|\\|\\/|\\-\\-|:|\\&|@)]+/"; $all_words = trim(preg_replace($pattern, ' ', $input)); $a = array(); $pos = 0; while (true) { $old_pos = $pos; $pos = strpos($all_words, ' ', $pos); if ($pos === false) { $a[$old_pos] = substr($all_words, $old_pos); break; } $a[$old_pos] = substr($all_words, $old_pos, $pos - $old_pos); } if ($format == 0) { return count($a); } return $a; } } if (!function_exists('html_entity_decode')) { /** * Decode the HTML entitity encoded input string. * * @param string The text to decode * @param integer The quote style code * @param ?string Character set to decode to (NULL: default) * @return string The decoded text */ function html_entity_decode($input, $quote_style, $charset = NULL) { unset($quote_style); unset($charset); /* // NB:   does not go to <space>. It's not something you use with html escaping, it's for hard-space-formatting. URL's don't contain spaces, but that's due to URL escaping (%20) $replace_array=array( '&'=>'&', '>'=>'>', '<'=>'<', '''=>'\'', '"'=>'"', ); foreach ($replace_array as $from=>$to) { $input=str_replace($from,$to,$input); } return $input;*/ $trans_tbl = get_html_translation_table(HTML_ENTITIES); $trans_tbl = array_flip($trans_tbl); return strtr($input, $trans_tbl); } } if (version_compare(phpversion(), '4.3.0') >= 0) { if (!function_exists('unichrm_hex')) { /** * Convert a unicode character number to a unicode string. Callback for preg_replace. * * @param array Regular expression match array. * @return ~string Converted data (false: could not convert). */ function unichrm_hex($matches) { return unichr(hexdec($matches[1])); } } if (!function_exists('unichrm')) { /** * Convert a unicode character number to a unicode string. Callback for preg_replace. * * @param array Regular expression match array. * @return ~string Converted data (false: could not convert). */ function unichrm($matches) { return unichr(intval($matches[1])); } } if (!function_exists('unichr')) { /** * Convert a unicode character number to a HTML-entity enabled string, using lower ASCII characters where possible. * * @param integer Character number. * @return ~string Converted data (false: could not convert). */ function unichr($c) { if ($c <= 0x7f) { return chr($c); } else { return '#&' . strval($c) . ';'; } } } } $BOOTSTRAPPING = 1; $CHECKING_SAFEMODE = false; $BAD_WORD_CHARS = array(chr(128), chr(130), chr(131), chr(132), chr(133), chr(134), chr(135), chr(136), chr(137), chr(138), chr(139), chr(140), chr(142), chr(145), chr(146), chr(147), chr(148), chr(149), chr(150), chr(151), chr(152), chr(153), chr(154), chr(155), chr(156), chr(158), chr(159)); $FIXED_WORD_CHARS = array('(EUR-)', ',', '{f.}', '"', '...', '-|-', '=|=', '^', '{%o}', '{~S}', '<', 'CE', '{~Z}', "'", "'", '"', '"', '-', '-', '--', '~', '(TM)', '{~s}', '>', 'ce', '{~z}', '{.Y.}'); // some of these are Comcode shortcuts. We can't use entities as we can't assume we're converting into Comcode. $FIXED_WORD_CHARS_HTML = array('€', '‚', 'ƒ', '„', '…', '†', '‡', 'ˆ', '‰', 'Š', '‹', 'Œ', 'Ž', "‘", "’", '“', '”', '•', '–', '—', '˜', '™', 'š', '›', 'œ', 'ž', 'Ÿ'); $RUNNING_SCRIPT_CACHE = array(); $BROWSER_DECACHEING = NULL; $CHARSET = NULL; $TEMP_CHARSET = NULL; $CURRENTLY_HTTPS = NULL; $CACHE_FIND_SCRIPT = array(); error_reporting(E_ALL); @ini_set('html_errors', '1'); @ini_set('docref_root', 'http://www.php.net/manual/en/'); @ini_set('docref_ext', '.php'); $SERVER_TIMEZONE = function_exists('date_default_timezone_get') ? @date_default_timezone_get() : ini_get('date.timezone'); @ini_set('date.timezone', 'UTC'); if (function_exists('date_default_timezone_set')) { date_default_timezone_set('UTC'); } // Needed for HPHP $HAS_SET_ERROR_HANDLER = false; $DYING_BADLY = false; // If ocPortal is bailing out uncontrollably, setting this will make sure the error hander does not try and suppress $XSS_DETECT = function_exists('ocp_mark_as_escaped'); $GLOBALS['DEBUG_MODE'] = (!array_key_exists('debug_mode', $SITE_INFO) || $SITE_INFO['debug_mode'] == '1') && (is_dir(get_file_base() . '/.svn') || is_dir(get_file_base() . '/.git') || function_exists('ocp_mark_as_escaped')) && (!array_key_exists('keep_no_debug_mode', $_GET) || $_GET['keep_no_debug_mode'] == '0'); $GLOBALS['SEMI_DEBUG_MODE'] = (!array_key_exists('debug_mode', $SITE_INFO) || $SITE_INFO['debug_mode'] == '1') && (is_dir(get_file_base() . '/.svn') || is_dir(get_file_base() . '/.git') || function_exists('ocp_mark_as_escaped')); if (function_exists('set_time_limit')) { @set_time_limit(60); } if ($GLOBALS['DEBUG_MODE']) { if (function_exists('set_time_limit')) { @set_time_limit(10); } @ini_set('ocproducts.type_strictness', '1'); @ini_set('ocproducts.xss_detect', '1'); } if ($GLOBALS['DEBUG_MODE']) { require_code('developer_tools'); } $JAVASCRIPTS = array('javascript' => 1, 'javascript_thumbnails' => 1); if ($GLOBALS['CURRENT_SHARE_USER'] !== NULL || get_domain() == 'myocp.com') { $JAVASCRIPTS['javascript_ajax'] = 1; } $CSSS = array('no_cache' => 1, 'global' => 1); // Try and make the PHP environment as we need it if (function_exists('set_magic_quotes_runtime')) { @set_magic_quotes_runtime(0); } // @'d because it's deprecated and PHP 5.3 may give an error @ini_set('auto_detect_line_endings', '0'); @ini_set('include_path', ''); @ini_set('default_socket_timeout', '60'); @ini_set('allow_url_fopen', '0'); @ini_set('suhosin.executor.disable_emodifier', '1'); // Extra security if suhosin is available @ini_set('suhosin.executor.multiheader', '1'); // Extra security if suhosin is available @ini_set('suhosin.executor.disable_eval', '0'); @ini_set('suhosin.executor.eval.whitelist', ''); @ini_set('suhosin.executor.func.whitelist', ''); // Load most basic config $IN_MINIKERNEL_VERSION = 0; $EXITING = 0; if (array_key_exists('use_ocf', $_GET) && running_script('upgrader')) { $SITE_INFO['forum_type'] = 'ocf'; $SITE_INFO['ocf_table_prefix'] = $SITE_INFO['table_prefix']; } $CACHE_TEMPLATES = true; // The URL to our install (no trailing /) $BASE_URL_HTTP = NULL; $BASE_URL_HTTPS = NULL; $WORDS_TO_FILTER = NULL; $FIELD_RESTRICTIONS = NULL; $VALID_ENCODING = false; $CONVERTED_ENCODING = false; if (!isset($MICRO_BOOTUP)) { $MICRO_BOOTUP = 0; } if (!isset($MICRO_AJAX_BOOTUP)) { $MICRO_AJAX_BOOTUP = 0; } require_code_no_override('version'); if ($MICRO_BOOTUP == 0 && $MICRO_AJAX_BOOTUP == 0) { //@header('X-Powered-By: ocPortal '.ocp_version_full().' (PHP '.phpversion().')'); @header('X-Powered-By: ocPortal'); // Better to keep it vague, for security reasons $QUERY_LOG = false; if (isset($_REQUEST['special_page_type']) && $_REQUEST['special_page_type'] == 'query') { $QUERY_LOG = true; } } // Most critical things require_code('support'); // A lot of support code is present in this srand(make_seed()); mt_srand(make_seed()); if ($MICRO_BOOTUP == 0 && $MICRO_AJAX_BOOTUP == 0) { if (running_script('index') && count($_POST) == 0) { $bot_type = get_bot_type(); if ($bot_type !== NULL && isset($SITE_INFO['fast_spider_cache']) && $SITE_INFO['fast_spider_cache'] != '0') { fast_spider_cache(true); } } } require_code('caches'); // Recently taken out of 'support' so makes sense to load it here require_code('database'); // There's nothing without the database if ((!isset($SITE_INFO['known_suexec']) || $SITE_INFO['known_suexec'] == '0') && !is_writable_wrap(get_file_base() . '/.htaccess')) { require_code('support2'); if (ip_banned(get_ip_address())) { critical_error('BANNED'); } } if (running_script('messages') && get_param('action', 'new') == 'new' && get_param_integer('routine_refresh', 0) == 0) { require_code('chat_poller'); chat_poller(); } if ($MICRO_BOOTUP == 0) { load_user_stuff(); } // For any kind of niceness we need these. The order is chosen for complex dependency reasons - don't mess with it if ($MICRO_AJAX_BOOTUP == 0) { require_code('themes'); // Output needs to know about themes require_code('templates'); // So that we can do error templates require_code('tempcode'); // Output is done with tempcode if ($MICRO_BOOTUP == 0) { require_code('comcode'); // Much output goes through comcode } } require_code('zones'); // Zone is needed because zones are where all ocPortal pages reside require_code('config'); // Config is needed for much active stuff if (get_option('collapse_user_zones', true) === '1' && $RELATIVE_PATH == 'site') { get_base_url(); /*force calculation first*/ $RELATIVE_PATH = ''; } require_code('users'); // Users are important due to permissions if ($MICRO_BOOTUP == 0 && $MICRO_AJAX_BOOTUP == 0) { if (running_script('index') && count($_POST) == 0) { if (isset($SITE_INFO['any_guest_cached_too']) && $SITE_INFO['any_guest_cached_too'] == '1' && is_guest(NULL, true)) { fast_spider_cache(false); } } } $CACHE_TEMPLATES = (get_option('is_on_template_cache') == '1' || get_param_integer('keep_cache', 0) == 1 || get_param_integer('cache', 0) == 1) && get_param_integer('keep_cache', NULL) !== 0 && get_param_integer('cache', NULL) !== 0; if ($MICRO_AJAX_BOOTUP == 0) { require_code('temporal'); // Date/time functions require_code('files'); // Contains fix_permissions, needed for 'lang' require_code('lang'); // So that we can do language stuff (e.g. errors) convert_data_encodings(); if ($MICRO_BOOTUP == 0) { require_code('permissions'); // So we can check access } } // At this point we can display errors nicely $GLOBALS['SUPPRESS_ERROR_DEATH'] = false; set_error_handler('ocportal_error_handler'); if (function_exists('error_get_last')) { register_shutdown_function('catch_fatal_errors'); } $HAS_SET_ERROR_HANDLER = true; if ($MICRO_BOOTUP == 0) { if (method_exists($GLOBALS['FORUM_DRIVER'], 'forum_layer_initialise')) { $GLOBALS['FORUM_DRIVER']->forum_layer_initialise(); } } if ($MICRO_AJAX_BOOTUP == 0) { $JAVASCRIPT = new ocp_tempcode(); } if ($MICRO_BOOTUP == 0) { if ($IN_MINIKERNEL_VERSION != 1 && $MICRO_AJAX_BOOTUP == 0) { has_cookies(); // Will determine at early point whether we have cookie support get_num_users_site(); // Will kill site if there are too many users } } require_code('urls'); // URL building is crucial @header('Content-type: text/html; charset=' . get_charset()); if ($MICRO_AJAX_BOOTUP == 0 && $MICRO_BOOTUP == 0) { // Before anything gets outputted handle_logins(); require_code('site'); // This powers the site (top level page generation) // Are we installed? get_option('site_name'); } // Our logging (change false to true for temporarily changing it so staff get logging) if (get_option('log_php_errors') == '1') { @ini_set('log_errors', '1'); if (addon_installed('errorlog')) { @ini_set('error_log', get_custom_file_base() . '/data_custom/errorlog.php'); } } if ($MICRO_BOOTUP == 0 && $MICRO_AJAX_BOOTUP == 0 && (get_option('display_php_errors') == '1' || running_script('upgrader') || has_specific_permission(get_member(), 'see_php_errors'))) { @ini_set('display_errors', '1'); } elseif (!$GLOBALS['DEBUG_MODE']) { @ini_set('display_errors', '0'); } // G-zip? @ini_set('zlib.output_compression', get_option('gzip_output') == '1' ? 'On' : 'Off'); if (function_exists('setlocale') && $MICRO_AJAX_BOOTUP == 0) { $locales = explode(',', do_lang('locale')); setlocale(LC_ALL, $locales[0]); @setlocale(LC_ALL, $locales); unset($locales); } if ($MICRO_AJAX_BOOTUP == 0 && $MICRO_BOOTUP == 0 && (!isset($SITE_INFO['no_installer_checks']) || $SITE_INFO['no_installer_checks'] == '0')) { if (is_file(get_file_base() . '/install.php') && !is_file(get_file_base() . '/install_ok') && running_script('index')) { warn_exit(do_lang_tempcode('MUST_DELETE_INSTALLER')); } } if ($MICRO_AJAX_BOOTUP == 0 && $MICRO_BOOTUP == 0) { $changed_base_url = !array_key_exists('base_url', $SITE_INFO) && get_long_value('last_base_url') !== get_base_url(false); if (running_script('index') && (is_browser_decacheing() || $changed_base_url)) { require_code('view_modes'); erase_tempcode_cache(); erase_cached_templates(!$changed_base_url); erase_comcode_cache(); erase_cached_language(); persistant_cache_empty(); if ($changed_base_url) { require_lang('zones'); require_code('zones3'); erase_comcode_page_cache(); set_long_value('last_base_url', get_base_url(false)); } } if (has_zone_access(get_member(), 'adminzone')) { $JAVASCRIPTS['javascript_staff'] = 1; $JAVASCRIPTS['javascript_ajax'] = 1; if (addon_installed('occle')) { $JAVASCRIPTS['javascript_button_occle'] = 1; } } if (addon_installed('realtime_rain') && get_option('bottom_show_realtime_rain_button', true) === '1') { $JAVASCRIPTS['javascript_button_realtime_rain'] = 1; } } /*ocp_memory_profile('startup'); $func=get_defined_functions(); print_r($func['user']);*/ if (tacit_https() || is_page_https(get_zone_name(), get_page_name())) { @header('Cache-Control: private'); @header('Pragma: private'); } $BOOTSTRAPPING = 0; if ($GLOBALS['SEMI_DEBUG_MODE'] && $MICRO_AJAX_BOOTUP == 0) { if ($GLOBALS['SEMI_DEBUG_MODE']) { /*if ((mt_rand(0,2)==1) && ($GLOBALS['DEBUG_MODE']) && (running_script('index'))) We know this works now, so let's stop messing up our development speed { require_code('view_modes'); erase_cached_templates(true); // Stop anything trying to read a template cache item (E.g. CSS, JS) that might not exist! }*/ if (strpos(ocp_srv('HTTP_REFERER'), ocp_srv('HTTP_HOST')) !== false && strpos(ocp_srv('HTTP_REFERER'), 'keep_devtest') !== false && !running_script('attachment') && !running_script('upgrader') && strpos(ocp_srv('HTTP_REFERER'), 'login') === false && is_null(get_param('keep_devtest', NULL))) { $_GET['keep_devtest'] = '1'; fatal_exit('URL not constructed properly: development mode in use but keep_devtest was not specified. This indicates that links have been made without build_url (in PHP) or keep_stub (in Javascript). Whilst not fatal this time, failure to use these functions can cause problems when your site goes live. See the ocPortal codebook for more details.'); } else { $_GET['keep_devtest'] = '1'; } } if (browser_matches('true_xhtml') && get_value('html5') !== '1' && get_value('html5') !== '_true' && get_param_integer('keep_no_xhtml', 0) == 0 && !running_script('upgrader')) { @header('Content-type: application/xhtml+xml; charset=' . get_charset()); } if (isset($_CREATED_FILES)) { /** * Run after-tests for debug mode, to make sure coding standards are met. */ function debug_mode_aftertests() { global $_CREATED_FILES, $_MODIFIED_FILES; // Use the info from ocProduct's custom PHP version to make sure that all files that were created/modified got synched as they should have been. foreach ($_CREATED_FILES as $file) { if (substr($file, 0, strlen(get_file_base())) == get_file_base() && substr($file, -4) != '.log' && basename($file) != 'permissioncheckslog.php') { @exit(escape_html('File not permission-synched: ' . $file)); } } foreach ($_MODIFIED_FILES as $file) { if (strpos($file, '_cache') === false && substr($file, 0, strlen(get_file_base())) == get_file_base() && substr($file, -4) != '.log' && basename($file) != 'permissioncheckslog.php') { @exit(escape_html('File not change-synched: ' . $file)); } } global $TITLE_CALLED, $SCREEN_TEMPLATE_CALLED, $EXITING; if (is_null($SCREEN_TEMPLATE_CALLED) && $EXITING == 0 && strpos(ocp_srv('PHP_SELF'), 'index.php') !== false) { @exit(escape_html('No screen template called.')); } if (!$TITLE_CALLED && (is_null($SCREEN_TEMPLATE_CALLED) || $SCREEN_TEMPLATE_CALLED != '') && $EXITING == 0 && strpos(ocp_srv('PHP_SELF'), 'index.php') !== false) { @exit(escape_html('No title used on screen.')); } } register_shutdown_function('debug_mode_aftertests'); } if (ocp_srv('SCRIPT_FILENAME') != '' && $GLOBALS['DEBUG_MODE'] && strpos(ocp_srv('SCRIPT_FILENAME'), 'data_custom') === false) { if (@strlen(file_get_contents(ocp_srv('SCRIPT_FILENAME'), FILE_TEXT)) > 4500) { fatal_exit('Entry scripts (front controllers) should not be shoved full of code.'); } } } // FirePHP console support, only for administrators if ((get_param_integer('keep_firephp', 0) == 1 || get_param_integer('keep_queries', 0) == 1) && ($GLOBALS['FORUM_DRIVER']->is_super_admin(get_member()) || $GLOBALS['IS_ACTUALLY_ADMIN'])) { require_code('firephp'); } $default_memory_limit = get_value('memory_limit'); if (is_null($default_memory_limit) || $default_memory_limit == '' || $default_memory_limit == '0' || $default_memory_limit == '-1') { $default_memory_limit = '64M'; } @ini_set('memory_limit', $default_memory_limit); if (isset($GLOBALS['FORUM_DRIVER']) && $GLOBALS['FORUM_DRIVER']->is_super_admin(get_member())) { if (get_param_integer('keep_avoid_memory_limit', 0) == 1) { disable_php_memory_limit(); } $memory_test = get_param_integer('keep_memory_limit_test', 0); if ($memory_test != 0 && $memory_test <= 32) { @ini_set('memory_limit', strval($memory_test) . 'M'); } } if (get_option('sitewide_im', true) === '1' && running_script('index') && get_param('type', 'misc', true) != 'room') { require_code('chat'); enter_chat_lobby(); } // Startup hooks if (!running_script('upgrader')) { $startup_hooks = find_all_hooks('systems', 'startup'); foreach (array_keys($startup_hooks) as $hook) { require_code('hooks/systems/startup/' . filter_naughty_harsh($hook)); $ob = object_factory('Hook_startup_' . filter_naughty_harsh($hook), true); if ($ob === NULL) { continue; } $ob->run($MICRO_BOOTUP, $MICRO_AJAX_BOOTUP, 0); } if ($CURRENT_SHARE_USER !== NULL && float_to_raw_string(ocp_version_number()) != get_value('version')) { require_code('upgrade'); clear_caches_2(); version_specific(); upgrade_modules(); ocf_upgrade(); } } }
/** * Request that CRON loads up a block's caching in the background. * * @param ID_TEXT The codename of the block * @param ?array Parameters to call up block with if we have to defer caching (NULL: none) * @param boolean Whether we are cacheing Tempcode (needs special care) */ function request_via_cron($codename, $map, $tempcode) { global $TEMPCODE_SETGET; $map = array('c_theme' => $GLOBALS['FORUM_DRIVER']->get_theme(), 'c_lang' => user_lang(), 'c_codename' => $codename, 'c_map' => serialize($map), 'c_timezone' => get_users_timezone(get_member()), 'c_is_bot' => is_null(get_bot_type()) ? 0 : 1, 'c_in_panel' => (array_key_exists('in_panel', $TEMPCODE_SETGET) ? $TEMPCODE_SETGET['in_panel'] : '_false') == '_true' ? 1 : 0, 'c_interlock' => (array_key_exists('interlock', $TEMPCODE_SETGET) ? $TEMPCODE_SETGET['interlock'] : '_false') == '_true' ? 1 : 0, 'c_store_as_tempcode' => $tempcode ? 1 : 0); if (is_null($GLOBALS['SITE_DB']->query_value_null_ok('cron_caching_requests', 'id', $map))) { $GLOBALS['SITE_DB']->query_insert('cron_caching_requests', $map); } }
/** * Set the session ID of the user. * * @param integer The session ID * @param boolean Whether this is a guest session (guest sessions will use persistent cookies) */ function set_session_id($id, $guest_session = false) { // Save cookie $timeout = $guest_session ? time() + 60 * 60 * max(1, intval(get_option('session_expiry_time'))) : NULL; $test = @setcookie('ocp_session', strval($id), $timeout, get_cookie_path()); // Set a session cookie with our session ID. We only use sessions for secure browser-session login... the database and url's do the rest $_COOKIE['ocp_session'] = strval($id); // So we remember for this page view // If we really have to, store in URL if ((!has_cookies() || !$test) && is_null(get_bot_type())) { $_GET['keep_session'] = strval($id); } if ($id != get_session_id()) { decache('side_users_online'); } }
/** * Takes a string which is a PHP expression over $map (parameter map), and returns a derived identifier. * We see if we have something cached by looking for a matching identifier. * * @param mixed PHP expression over $map (the parameter map of the block) OR a call_user_func specifier that will return a result (which will be used if cacheing is really very important, even for Hip Hop PHP) * @param ?array The block parameter map (NULL: no parameters) * @return ?LONG_TEXT The derived cache identifier (NULL: the identifier is CURRENTLY null meaning cannot be cached) */ function do_block_get_cache_identifier($cache_on, $map) { $_cache_identifier = array(); if (is_array($cache_on)) { $_cache_identifier = call_user_func($cache_on[0], $map); } else { if ($cache_on != '' && !defined('HIPHOP_PHP')) { $_cache_on = eval('return ' . $cache_on . ';'); // NB: This uses $map, as $map is referenced inside $cache_on if ($_cache_on === NULL) { return NULL; } foreach ($_cache_on as $on) { $_cache_identifier[] = $on; } } elseif (defined('HIPHOP_PHP')) { return NULL; } } $_cache_identifier[] = get_users_timezone(get_member()); $_cache_identifier[] = get_bot_type() === NULL; global $TEMPCODE_SETGET; $_cache_identifier[] = isset($TEMPCODE_SETGET['in_panel']) ? $TEMPCODE_SETGET['in_panel'] : '0'; $_cache_identifier[] = isset($TEMPCODE_SETGET['interlock']) ? $TEMPCODE_SETGET['interlock'] : '0'; $cache_identifier = serialize($_cache_identifier); return $cache_identifier; }
/** * String to tack onto URL to keep 'keep_' parameters * * @param array Parameters passed to the symbol (0=whether this starts off the query string, 1=force session append even if it's also available a session cookie e.g. when put into download manager) * @return string The result. */ function keep_symbol($param) { $value = ''; $get_vars = $_GET; if (isset($param[1]) && $param[1] == '1' && is_null(get_bot_type()) && !array_key_exists('keep_session', $get_vars)) { $get_vars['keep_session'] = strval(get_session_id()); } if (count($get_vars) > 0) { $first = false; if (isset($param[0]) && $param[0] == '1') { $first = true; } foreach ($get_vars as $key => $val) { if (!is_string($key)) { $key = strval($key); } if (get_magic_quotes_gpc() && is_string($val)) { $val = stripslashes($val); } if (substr($key, 0, 5) == 'keep_' && strpos($key, '_expand_') === false && (!skippable_keep($key, $val) || $key == 'keep_session' && is_null(get_bot_type()) && isset($param[1]) && $param[1] == '1') && is_string($val)) { $value .= ($first ? '?' : '&') . urlencode($key) . '=' . ocp_url_encode($val); $first = false; } } } return $value; }