/**
 * Redirect the user - transparently, storing a message that will be shown on their destination page.
 *
 * @param  tempcode		Title to display on redirect page
 * @param  mixed			Destination URL (may be Tempcode)
 * @param  mixed			Message to show (may be Tempcode)
 * @param  boolean		For intermediatory hops, don't mark so as to read status messages - save them up for the next hop (which will not be intermediatory)
 * @param  ID_TEXT		Code of message type to show
 * @set    warn inform fatal
 * @return tempcode		Redirection message (likely to not actually be seen due to instant redirection)
 */
function _redirect_screen($title, $url, $text, $intermediatory_hop = false, $msg_type = 'inform')
{
    if (is_object($url)) {
        $url = $url->evaluate();
    }
    global $FORCE_META_REFRESH, $ATTACHED_MESSAGES_RAW;
    $special_page_type = get_param('special_page_type', 'view');
    if ($special_page_type == 'view' && $GLOBALS['NON_PAGE_SCRIPT'] == 0 && !headers_sent() && !$FORCE_META_REFRESH) {
        foreach ($ATTACHED_MESSAGES_RAW as $message) {
            $GLOBALS['SITE_DB']->query_insert('messages_to_render', array('r_session_id' => get_session_id(), 'r_message' => is_object($message[0]) ? $message[0]->evaluate() : escape_html($message[0]), 'r_type' => $message[1], 'r_time' => time()));
        }
        $_message = is_object($text) ? $text->evaluate() : escape_html($text);
        if ($_message != '' && (count($ATTACHED_MESSAGES_RAW) == 0 || $_message != do_lang('SUCCESS') && $_message != do_lang('REDIRECTING'))) {
            $GLOBALS['SITE_DB']->query_insert('messages_to_render', array('r_session_id' => get_session_id(), 'r_message' => $_message, 'r_type' => $msg_type, 'r_time' => time()));
        }
        if (!$intermediatory_hop) {
            $hash_pos = strpos($url, '#');
            if ($hash_pos !== false) {
                $hash_bit = substr($url, $hash_pos);
                $url = substr($url, 0, $hash_pos);
            } else {
                $hash_bit = '';
            }
            $url .= (strpos($url, '?') === false ? '?' : '&') . 'redirected=1' . $hash_bit;
        }
    }
    require_code('site2');
    assign_refresh($url, 0.0);
    return do_template('REDIRECT_SCREEN', array('_GUID' => '44ce3d1ffc6536b299ed0944e8ca7253', 'URL' => $url, 'TITLE' => $title, 'TEXT' => $text));
}
Exemplo n.º 2
0
destrictify();
require_code('twitter');
require_lang('twitter');
$title = get_page_title('TWITTER_OAUTH');
$api_key = get_option('twitter_api_key', true);
$api_secret = get_option('twitter_api_secret', true);
if (is_null($api_key)) {
    require_code('database_action');
    add_config_option('TWITTER_API_KEY', 'twitter_api_key', 'line', 'return \'\';', 'FEATURE', 'TWITTER_SYNDICATION');
    add_config_option('TWITTER_API_SECRET', 'twitter_api_secret', 'line', 'return \'\';', 'FEATURE', 'TWITTER_SYNDICATION');
    $api_key = '';
    $api_secret = '';
}
if ($api_key == '' || $api_secret == '') {
    $config_url = build_url(array('page' => 'admin_config', 'type' => 'category', 'id' => 'FEATURE', 'redirect' => get_self_url(true)), '_SELF', NULL, false, false, false, 'group_TWITTER_SYNDICATION');
    require_code('site2');
    assign_refresh($config_url, 0.0);
    $echo = do_template('REDIRECT_SCREEN', array('URL' => $config_url, 'TITLE' => $title, 'TEXT' => do_lang_tempcode('TWITTER_SETUP_FIRST')));
    $echo->evaluate_echo();
    return;
}
require_code('hooks/systems/syndication/twitter');
$ob = new Hook_Syndication_twitter();
$result = $ob->auth_set(NULL, get_self_url(false, false, array('oauth_in_progress' => 1)));
if ($result) {
    $out = do_lang_tempcode('TWITTER_OAUTH_SUCCESS');
} else {
    $out = do_lang_tempcode('SOME_ERRORS_OCCURRED');
}
$title->evaluate_echo();
$out->evaluate_echo();
Exemplo n.º 3
0
 /**
  * The UI to show a video.
  *
  * @param  ?string		Alternate category name to use (NULL: use standard one). This is useful if you are overriding this code to show images in virtual galleries.
  * @param  ?tempcode		Breadcrumbs (NULL: derive in this function).
  * @return tempcode		The UI
  */
 function show_video($category_name = NULL, $tree = NULL)
 {
     $id = get_param_integer('id');
     if (get_param_integer('ajax', 0) == 1) {
         header('Content-type: text/xml');
     }
     list($sort, $sort_backwards, $sql_suffix_images, $sql_suffix_videos) = $this->get_sort_order();
     if (addon_installed('awards')) {
         require_code('awards');
         $awards = find_awards_for('video', strval($id));
     } else {
         $awards = array();
     }
     // Pic up some info
     $rows = $GLOBALS['SITE_DB']->query_select('videos', array('*'), array('id' => $id), '', 1);
     if (!array_key_exists(0, $rows)) {
         return warn_screen(get_page_title('ERROR_OCCURRED'), do_lang_tempcode('MISSING_RESOURCE'));
     }
     $myrow = $rows[0];
     $url = $myrow['url'];
     if (url_is_local($url)) {
         $url = get_custom_base_url() . '/' . $url;
     }
     $cat = $myrow['cat'];
     $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=galleries&filter=' . urlencode($cat);
     if (get_value('no_individual_gallery_view') === '1' && $GLOBALS['SITE_DB']->query_value('galleries', 'flow_mode_interface', array('name' => $cat)) == '1') {
         require_code('site2');
         assign_refresh(build_url(array('page' => '_SELF', 'type' => 'misc', 'id' => $cat, 'probe_id' => $id, 'probe_type' => 'video'), '_SELF'), 0.0);
     }
     $true_category_name = get_translated_text($GLOBALS['SITE_DB']->query_value('galleries', 'fullname', array('name' => $cat)));
     if (is_null($category_name)) {
         $category_name = $true_category_name;
     }
     if (get_param_integer('slideshow', 0) == 1) {
         $title = get_page_title('VIEW_SLIDESHOW', true, array(escape_html($category_name)));
         global $EXTRA_HEAD;
         $EXTRA_HEAD->attach('<meta name="robots" content="noindex" />');
         // XHTMLXHTML
     } else {
         $title = get_page_title(get_translated_text($myrow['title']) == '' ? 'VIEW_VIDEO' : '_VIEW_VIDEO', true, array(escape_html(get_translated_text($myrow['title']))), NULL, $awards);
     }
     $root = get_param('root', 'root');
     seo_meta_load_for('video', strval($id));
     $thumb_url = $myrow['thumb_url'];
     if (url_is_local($thumb_url)) {
         $thumb_url = get_custom_base_url() . '/' . $thumb_url;
     }
     if (!has_category_access(get_member(), 'galleries', $cat)) {
         access_denied('CATEGORY_ACCESS');
     }
     // Views
     if (get_db_type() != 'xml') {
         $myrow['video_views']++;
         $GLOBALS['SITE_DB']->query_update('videos', array('video_views' => $myrow['video_views']), array('id' => $id), '', 1, NULL, false, true);
     }
     list($rating_details, $comment_details, $trackback_details) = embed_feedback_systems('videos', strval($id), $myrow['allow_rating'], $myrow['allow_comments'], $myrow['allow_trackbacks'], $myrow['validated'], $myrow['submitter'], build_url(array('page' => '_SELF', 'type' => 'video', 'id' => $id), '_SELF', NULL, false, false, true), get_translated_text($myrow['title']) == '' ? do_lang('VIEW_VIDEO_IN', $true_category_name) : get_translated_text($myrow['title']), get_value('comment_forum__videos'));
     // Validation
     if ($myrow['validated'] == 0) {
         if (!has_specific_permission(get_member(), 'jump_to_unvalidated')) {
             access_denied('SPECIFIC_PERMISSION', 'jump_to_unvalidated');
         }
         $warning_details = do_template('WARNING_TABLE', array('_GUID' => 'b32faacba974e648a67e5e91ffd3d8e5', 'WARNING' => do_lang_tempcode(get_param_integer('redirected', 0) == 1 ? 'UNVALIDATED_TEXT_NON_DIRECT' : 'UNVALIDATED_TEXT')));
     } else {
         $warning_details = new ocp_tempcode();
     }
     // Comments
     $comments = get_translated_tempcode($myrow['comments']);
     if (has_actual_page_access(NULL, 'cms_galleries', NULL, NULL) && has_edit_permission('mid', get_member(), $myrow['submitter'], 'cms_galleries', array('galleries', $cat))) {
         $edit_url = build_url(array('page' => 'cms_galleries', 'type' => '_ev', 'id' => $id), get_module_zone('cms_galleries'));
     } else {
         $edit_url = new ocp_tempcode();
     }
     $add_date = get_timezoned_date($myrow['add_date']);
     $edit_date = is_null($myrow['edit_date']) ? '' : get_timezoned_date($myrow['edit_date']);
     // Video HTML
     $video = show_gallery_media($url, $thumb_url, $myrow['video_width'], $myrow['video_height'], $myrow['video_length']);
     $extension = get_file_extension($url);
     require_code('mime_types');
     $mime_type = get_mime_type($extension);
     list($n, $x, $nav) = $this->build_set_navigation(db_string_equal_to('cat', $cat), '', $category_name, $id, $root, 'video', get_param_integer('slideshow', 0), get_param_integer('wide_high', 0), get_param_integer('start', 0), get_param_integer('max', get_default_gallery_max()), $cat, $sort, $sort_backwards, $sql_suffix_images, $sql_suffix_videos, get_param('select', '*'), get_param('video_select', '*'));
     $member_id = get_member_id_from_gallery_name($cat, NULL, true);
     if (get_forum_type() == 'ocf') {
         require_code('ocf_members');
         require_code('ocf_members2');
     }
     $member_details = is_null($member_id) || get_forum_type() != 'ocf' ? new ocp_tempcode() : ocf_show_member_box($member_id);
     $video_details = show_video_details($myrow);
     if (is_null($tree)) {
         $tree = gallery_breadcrumbs($cat, $root, false, get_module_zone('galleries'));
     }
     breadcrumb_add_segment($tree, do_lang_tempcode('VIEW_VIDEO'));
     $GLOBALS['META_DATA'] += array('created' => date('Y-m-d', $myrow['add_date']), 'creator' => $GLOBALS['FORUM_DRIVER']->get_username($myrow['submitter']), 'publisher' => '', 'modified' => is_null($myrow['edit_date']) ? '' : date('Y-m-d', $myrow['edit_date']), 'type' => 'Video', 'title' => get_translated_text($myrow['title']), 'identifier' => '_SEARCH:galleries:video:' . strval($id), 'description' => get_translated_text($myrow['comments']), 'image' => $thumb_url, 'video' => $url, 'video:height' => strval($myrow['video_height']), 'video:width' => strval($myrow['video_width']), 'video:type' => $mime_type);
     return do_template('GALLERY_ENTRY_SCREEN', array('_GUID' => '91e231906ed899513ec2db8a2974dddf', 'MEDIA_TYPE' => 'video', 'E_TITLE' => get_translated_text($myrow['title']), 'CAT' => $cat, 'SLIDESHOW' => get_param_integer('slideshow', 0) == 1, 'TRUE_GALLERY_TITLE' => $true_category_name, 'GALLERY_TITLE' => $category_name, 'MEMBER_ID' => is_null($member_id) ? '' : strval($member_id), 'ID' => strval($id), 'TAGS' => get_loaded_tags('videos'), 'TITLE' => $title, 'SUBMITTER' => strval($myrow['submitter']), 'URL' => $url, 'VIDEO_DETAILS' => $video_details, 'MEMBER_DETAILS' => $member_details, 'X' => integer_format($x), 'N' => integer_format($n), 'VIEWS' => integer_format($myrow['video_views']), 'ADD_DATE_RAW' => strval($myrow['add_date']), 'EDIT_DATE_RAW' => is_null($myrow['edit_date']) ? '' : strval($myrow['edit_date']), 'ADD_DATE' => $add_date, 'EDIT_DATE' => $edit_date, 'RATING_DETAILS' => $rating_details, 'TRACKBACK_DETAILS' => $trackback_details, 'COMMENT_DETAILS' => $comment_details, 'EDIT_URL' => $edit_url, 'NAV' => $nav, 'COMMENTS' => $comments, 'VIDEO' => $video, 'WARNING_DETAILS' => $warning_details));
 }
Exemplo n.º 4
0
/**
 * Add comments to the specified resource.
 *
 * @param  boolean		Whether this resource allows comments (if not, this function does nothing - but it's nice to move out this common logic into the shared function)
 * @param  ID_TEXT		The type (download, etc) that this commenting is for
 * @param  ID_TEXT		The ID of the type that this commenting is for
 * @param  mixed			The URL to where the commenting will pass back to (to put into the comment topic header) (URLPATH or Tempcode)
 * @param  ?string		The title to where the commenting will pass back to (to put into the comment topic header) (NULL: don't know, but not first post so not important)
 * @param  ?string		The name of the forum to use (NULL: default comment forum)
 * @param  boolean		Whether to not require a captcha
 * @param  ?BINARY		Whether the post is validated (NULL: unknown, find whether it needs to be marked unvalidated initially). This only works with the OCF driver (hence is the last parameter).
 * @param  boolean		Whether to force allowance
 * @param  boolean		Whether to skip a success message
 * @param  boolean		Whether posts made should not be shared
 * @return boolean		Whether a hidden post has been made
 */
function actualise_post_comment($allow_comments, $content_type, $content_id, $content_url, $content_title, $forum = NULL, $avoid_captcha = false, $validated = NULL, $explicit_allow = false, $no_success_message = false, $private = false)
{
    if (!$explicit_allow) {
        if (get_option('is_on_comments') == '0' || !$allow_comments) {
            return false;
        }
        if (!has_specific_permission(get_member(), 'comment', get_page_name())) {
            return false;
        }
    }
    if (running_script('preview')) {
        return false;
    }
    $forum_tie = get_option('is_on_strong_forum_tie') == '1';
    if (addon_installed('captcha')) {
        if (array_key_exists('post', $_POST) && $_POST['post'] != '' && !$avoid_captcha) {
            require_code('captcha');
            enforce_captcha();
        }
    }
    $post_title = post_param('title', NULL);
    if (is_null($post_title) && !$forum_tie) {
        return false;
    }
    $post = post_param('post', NULL);
    if ($post == do_lang('POST_WARNING')) {
        $post = '';
    }
    if ($post == do_lang('THREADED_REPLY_NOTICE', do_lang('POST_WARNING'))) {
        $post = '';
    }
    if ($post == '' && $post_title !== '') {
        $post = $post_title;
        $post_title = '';
    }
    if ($post === '') {
        warn_exit(do_lang_tempcode('NO_PARAMETER_SENT', 'post'));
    }
    if (is_null($post)) {
        $post = '';
    }
    $email = trim(post_param('email', ''));
    if ($email != '') {
        $body = '> ' . str_replace(chr(10), chr(10) . '> ', $post);
        if (substr($body, -2) == '> ') {
            $body = substr($body, 0, strlen($body) - 2);
        }
        if (get_page_name() != 'tickets') {
            $post .= '[staff_note]';
        }
        $post .= "\n\n" . '[email subject="Re: ' . comcode_escape($post_title) . ' [' . get_site_name() . ']" body="' . comcode_escape($body) . '"]' . $email . '[/email]' . "\n\n";
        if (get_page_name() != 'tickets') {
            $post .= '[/staff_note]';
        }
    }
    $content_title = strip_comcode($content_title);
    if (is_null($forum)) {
        $forum = get_option('comments_forum_name');
    }
    $content_url_flat = is_object($content_url) ? $content_url->evaluate() : $content_url;
    $_parent_id = post_param('parent_id', '');
    $parent_id = $_parent_id == '' ? NULL : intval($_parent_id);
    $poster_name_if_guest = post_param('poster_name_if_guest', '');
    list($topic_id, $is_hidden) = $GLOBALS['FORUM_DRIVER']->make_post_forum_topic($forum, $content_type . '_' . $content_id, get_member(), $post_title, $post, $content_title, do_lang('COMMENT'), $content_url_flat, NULL, NULL, $validated, $explicit_allow ? 1 : NULL, $explicit_allow, $poster_name_if_guest, $parent_id, false, !$private && $post != '' ? 'comment_posted' : NULL, !$private && $post != '' ? $content_type . '_' . $content_id : NULL);
    if (!is_null($topic_id)) {
        if (!is_integer($forum)) {
            $forum_id = $GLOBALS['FORUM_DRIVER']->forum_id_from_name($forum);
        } else {
            $forum_id = (int) $forum;
        }
        if (get_forum_type() == 'ocf' && !is_null($GLOBALS['LAST_POST_ID'])) {
            $extra_review_ratings = array();
            global $REVIEWS_STRUCTURE;
            if (array_key_exists($content_type, $REVIEWS_STRUCTURE)) {
                $reviews_rating_criteria = $REVIEWS_STRUCTURE[$content_type];
            } else {
                $reviews_rating_criteria[] = '';
            }
            foreach ($reviews_rating_criteria as $rating_type) {
                // Has there actually been any rating?
                $rating = post_param_integer('review_rating__' . fix_id($rating_type), NULL);
                if (!is_null($rating)) {
                    if ($rating > 10 || $rating < 1) {
                        log_hack_attack_and_exit('VOTE_CHEAT');
                    }
                    $GLOBALS['SITE_DB']->query_insert('review_supplement', array('r_topic_id' => $GLOBALS['LAST_TOPIC_ID'], 'r_post_id' => $GLOBALS['LAST_POST_ID'], 'r_rating_type' => $rating_type, 'r_rating_for_type' => $content_type, 'r_rating_for_id' => $content_id, 'r_rating' => $rating));
                }
            }
        }
    }
    if (!$private && $post != '') {
        list(, $submitter, , $safe_content_url, $cma_info) = get_details_behind_feedback_code($content_type, $content_id);
        $content_type_title = $content_type;
        if (!is_null($cma_info) && isset($cma_info['content_type_label'])) {
            $content_type_title = do_lang($cma_info['content_type_label']);
        }
        // Notification
        require_code('notifications');
        $username = $GLOBALS['FORUM_DRIVER']->get_username(get_member());
        $subject = do_lang('NEW_COMMENT_SUBJECT', get_site_name(), $content_title == '' ? ocp_mb_strtolower($content_type_title) : $content_title, array($post_title, $username), get_site_default_lang());
        $username = $GLOBALS['FORUM_DRIVER']->get_username(get_member());
        $message_raw = do_lang('NEW_COMMENT_BODY', comcode_escape(get_site_name()), comcode_escape($content_title == '' ? ocp_mb_strtolower($content_type_title) : $content_title), array($post_title == '' ? do_lang('NO_SUBJECT') : $post_title, post_param('post'), comcode_escape($content_url_flat), comcode_escape($username)), get_site_default_lang());
        dispatch_notification('comment_posted', $content_type . '_' . $content_id, $subject, $message_raw);
        // Is the user gonna automatically enable notifications for this?
        if (get_forum_type() == 'ocf') {
            $auto_monitor_contrib_content = $GLOBALS['OCF_DRIVER']->get_member_row_field(get_member(), 'm_auto_monitor_contrib_content');
            if ($auto_monitor_contrib_content == 1) {
                enable_notifications('comment_posted', $content_type . '_' . $content_id);
            }
        }
        // Activity
        $real_content_type = convert_ocportal_type_codes('feedback_type_code', $content_type, 'cma_hook');
        if (may_view_content_behind_feedback_code($GLOBALS['FORUM_DRIVER']->get_guest_id(), $real_content_type, $content_id)) {
            if (is_null($submitter)) {
                $submitter = $GLOBALS['FORUM_DRIVER']->get_guest_id();
            }
            $activity_type = is_null($submitter) || is_guest($submitter) ? '_ADDED_COMMENT_ON' : 'ADDED_COMMENT_ON';
            if ($content_title == '') {
                syndicate_described_activity($activity_type . '_UNTITLED', ocp_mb_strtolower($content_type_title), $content_type_title, '', url_to_pagelink(is_object($safe_content_url) ? $safe_content_url->evaluate() : $safe_content_url), '', '', convert_ocportal_type_codes('feedback_type_code', $content_type, 'addon_name'), 1, NULL, false, $submitter);
            } else {
                syndicate_described_activity($activity_type, $content_title, ocp_mb_strtolower($content_type_title), $content_type_title, url_to_pagelink(is_object($safe_content_url) ? $safe_content_url->evaluate() : $safe_content_url), '', '', convert_ocportal_type_codes('feedback_type_code', $content_type, 'addon_name'), 1, NULL, false, $submitter);
            }
        }
    }
    if ($post != '' && $forum_tie && !$no_success_message) {
        require_code('site2');
        assign_refresh($GLOBALS['FORUM_DRIVER']->topic_url($GLOBALS['FORUM_DRIVER']->find_topic_id_for_topic_identifier($forum, $content_type . '_' . $content_id), $forum), 0.0);
    }
    if ($post != '' && !$no_success_message) {
        attach_message(do_lang_tempcode('SUCCESS'));
    }
    return $is_hidden;
}
Exemplo n.º 5
0
 /**
  * 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']);
 }
Exemplo n.º 6
0
 /**
  * Redirect to the code_editor script.
  *
  * @return tempcode		The UI
  */
 function code_editor()
 {
     $title = get_page_title('CODE_EDITOR');
     require_code('site2');
     assign_refresh(get_base_url() . '/code_editor.php', 0.0);
     return do_template('REDIRECT_SCREEN', array('URL' => get_base_url() . '/code_editor.php', 'TITLE' => $title, 'TEXT' => do_lang_tempcode('REDIRECTING')));
 }
Exemplo n.º 7
0
 /**
  * The actualiser for logging in.
  *
  * @return tempcode	The UI.
  */
 function login_after()
 {
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('_LOGIN'))));
     $username = trim(post_param('login_username'));
     $feedback = $GLOBALS['FORUM_DRIVER']->forum_authorise_login($username, NULL, apply_forum_driver_md5_variant(trim(post_param('password')), $username), trim(post_param('password')));
     $id = $feedback['id'];
     if (!is_null($id)) {
         $title = get_page_title('LOGGED_IN');
         $url = enforce_sessioned_url(either_param('redirect'));
         //set_session_id(get_session_id()); // Just in case something earlier set it to a pre-logged-in one     Not needed
         if (count($_POST) <= 4) {
             require_code('site2');
             assign_refresh($url, 0.0);
             $post = new ocp_tempcode();
             $refresh = new ocp_tempcode();
         } else {
             $post = build_keep_post_fields(array('redirect', 'redirect_passon'));
             $redirect_passon = post_param('redirect_passon', NULL);
             if (!is_null($redirect_passon)) {
                 $post->attach(form_input_hidden('redirect', $redirect_passon));
             }
             $refresh = do_template('JS_REFRESH', array('_GUID' => 'c7d2f9e7a2cc637f3cf9ac4d1cf97eca', 'FORM_NAME' => 'redir_form'));
         }
         decache('side_users_online');
         return do_template('LOGIN_REDIRECT_SCREEN', array('_GUID' => '82e056de9150bbed185120eac3571f40', 'REFRESH' => $refresh, 'TITLE' => $title, 'TEXT' => do_lang_tempcode('_LOGIN_TEXT'), 'URL' => $url, 'POST' => $post));
     } else {
         get_page_title('USER_LOGIN_ERROR');
         $text = $feedback['error'];
         attach_message($text, 'warn');
         if (get_forum_type() == 'ocf') {
             require_lang('ocf');
             $forgotten_link = build_url(array('page' => 'lostpassword'), get_module_zone('lostpassword'));
             $extra = do_lang_tempcode('IF_FORGOTTEN_PASSWORD', escape_html($forgotten_link->evaluate()));
             attach_message($extra, 'inform');
         }
         return $this->login_before();
     }
 }
Exemplo n.º 8
0
 /**
  * The UI for the zone editor.
  *
  * @return tempcode		The UI
  */
 function _editor()
 {
     $id = get_param('id', '');
     // '' needed for short URLs
     if ($id == '/') {
         $id = '';
     }
     $GLOBALS['EXTRA_HEAD']->attach(make_string_tempcode('<base target="_blank" />'));
     $nice_zone_name = $id == '' ? do_lang('_WELCOME') : $id;
     $title = get_page_title('_ZONE_EDITOR', true, array(escape_html($nice_zone_name)));
     $lang = choose_language($title, true);
     if (is_object($lang)) {
         return $lang;
     }
     require_javascript('javascript_zone_editor');
     require_javascript('javascript_ajax');
     require_javascript('javascript_more');
     require_javascript('javascript_posting');
     require_javascript('javascript_editing');
     require_javascript('javascript_validation');
     require_code('form_templates');
     require_lang('comcode');
     if (!has_js()) {
         // Send them to the page permissions screen
         $url = build_url(array('page' => '_SELF', 'type' => 'edit'), '_SELF');
         require_code('site2');
         assign_refresh($url, 5.0);
         return do_template('REDIRECT_SCREEN', array('_GUID' => '20ed5fa100b87756a77c48988ef856ae', 'URL' => $url, 'TITLE' => $title, 'TEXT' => do_lang_tempcode('NO_JS_ADVANCED_SCREEN_ZONE_EDITOR')));
     }
     // After completion prep/relay
     $_default_redirect = build_url(array('page' => ''), $id);
     $default_redirect = $_default_redirect->evaluate();
     $post_url = build_url(array('page' => '_SELF', 'type' => '__editor', 'lang' => $lang, 'redirect' => get_param('redirect', $default_redirect), 'id' => $id), '_SELF');
     // Zone editing stuff
     $rows = $GLOBALS['SITE_DB']->query_select('zones', array('*'), array('zone_name' => $id), '', 1);
     if (!array_key_exists(0, $rows)) {
         warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
     }
     $row = $rows[0];
     $header_text = get_translated_text($row['zone_header_text'], NULL, $lang);
     $default_page = $row['zone_default_page'];
     list($fields, , ) = $this->get_form_fields(true, get_translated_text($row['zone_title'], NULL, $lang), $default_page, $header_text, $row['zone_theme'], $row['zone_wide'], $row['zone_require_session'], $row['zone_displayed_in_menu'], $id);
     // Page editing stuff
     $editor = array();
     foreach (array('panel_left', $default_page, 'panel_right') as $i => $for) {
         $page_info = _request_page($for, $id, NULL, $lang);
         if ($page_info === false) {
             $page_info = array('COMCODE_CUSTOM', $id, $for, $lang);
         }
         $is_comcode = false;
         $redirecting_to = NULL;
         $current_for = $for;
         $pure = false;
         switch ($page_info[0]) {
             case 'COMCODE_CUSTOM_PURE':
                 $pure = true;
             case 'COMCODE':
             case 'COMCODE_CUSTOM':
                 $is_comcode = true;
                 $type = do_lang_tempcode('COMCODE_PAGE');
                 break;
             case 'HTML':
             case 'HTML_CUSTOM':
                 $type = protect_from_escaping(escape_html('HTML'));
                 break;
             case 'MODULES':
             case 'MODULES_CUSTOM':
                 $type = do_lang_tempcode('MODULE');
                 break;
             case 'MINIMODULES':
             case 'MINIMODULES_CUSTOM':
                 $type = do_lang_tempcode('MINIMODULE');
                 break;
             case 'REDIRECT':
                 $type = do_lang_tempcode('REDIRECT_PAGE_TO', escape_html($page_info[1]['r_to_zone']), escape_html($page_info[1]['r_to_page']));
                 $redirecting_to = $page_info[1]['r_to_zone'];
                 $current_for = $page_info[1]['r_to_page'];
                 $page_info = _request_page($current_for, $redirecting_to, NULL, $lang);
                 if ($page_info !== false) {
                     switch ($page_info[0]) {
                         case 'COMCODE_CUSTOM_PURE':
                             $pure = true;
                         case 'COMCODE':
                         case 'COMCODE_CUSTOM':
                             $is_comcode = true;
                             break;
                     }
                 }
                 break;
             default:
                 $type = do_lang_tempcode('UNKNOWN');
                 break;
         }
         $class = '';
         $w = false;
         $current_zone = is_null($redirecting_to) ? $id : $redirecting_to;
         $default_parsed = NULL;
         if ($is_comcode) {
             $fullpath = zone_black_magic_filterer(($page_info[0] == 'comcode' || $pure ? get_file_base() : get_custom_file_base()) . '/' . $current_zone . '/pages/' . strtolower($page_info[0]) . '/' . $lang . '/' . $current_for . '.txt');
             if (!file_exists($fullpath)) {
                 $fullpath = zone_black_magic_filterer(($page_info[0] == 'comcode' || $pure ? get_file_base() : get_custom_file_base()) . '/' . $current_zone . '/pages/' . strtolower($page_info[0]) . '/' . get_site_default_lang() . '/' . $current_for . '.txt');
             }
             if (file_exists($fullpath)) {
                 $comcode = file_get_contents($fullpath, FILE_TEXT);
                 $default_parsed = comcode_to_tempcode($comcode, NULL, false, 60, NULL, NULL, true);
             } else {
                 $comcode = '';
             }
             $edit_url = build_url(array('page' => 'cms_comcode_pages', 'type' => '_ed', 'page_link' => $current_zone . ':' . $current_for), get_module_zone('cms_comcode_pages'));
             // WYSIWYG?
             require_javascript('javascript_editing');
             $w = has_js() && (browser_matches('wysiwyg') && strpos($comcode, '{$,page hint: no_wysiwyg}') === false);
             global $JAVASCRIPT, $WYSIWYG_ATTACHED;
             if (!$WYSIWYG_ATTACHED) {
                 $JAVASCRIPT->attach(do_template('HTML_EDIT'));
             }
             $WYSIWYG_ATTACHED = true;
             if ($w) {
                 @header('Content-type: text/html; charset=' . get_charset());
                 $class .= ' wysiwyg';
             }
         } else {
             $comcode = NULL;
             $edit_url = new ocp_tempcode();
         }
         $field_name = 'edit_' . $for . '_textarea';
         if ($i == 1) {
             $settings = $fields;
             $comcode_editor = get_comcode_editor($field_name);
         } else {
             $settings = NULL;
             $button = 'block';
             $comcode_editor = new ocp_tempcode();
             $comcode_editor->attach(do_template('COMCODE_EDITOR_BUTTON', array('_GUID' => '0acc5dcf299325d0cf55871923148a54', 'DIVIDER' => false, 'FIELD_NAME' => $field_name, 'TITLE' => do_lang_tempcode('INPUT_COMCODE_' . $button), 'B' => $button)));
             $button = 'comcode';
             $comcode_editor->attach(do_template('COMCODE_EDITOR_BUTTON', array('_GUID' => '1acc5dcf299325d0cf55871923148a54', 'DIVIDER' => false, 'FIELD_NAME' => $field_name, 'TITLE' => do_lang_tempcode('INPUT_COMCODE_' . $button), 'B' => $button)));
         }
         global $TEMPCODE_SETGET;
         if ($for == $default_page) {
             $TEMPCODE_SETGET['in_panel'] = '0';
         } else {
             $TEMPCODE_SETGET['in_panel'] = '1';
         }
         $preview = substr($page_info[0], 0, 6) == 'MODULE' ? NULL : request_page($for, false, $id, NULL, true);
         if (!is_null($preview)) {
             $_preview = $preview->evaluate();
             if (!$is_comcode || strpos($comcode, '<') !== false) {
                 require_code('xhtml');
                 $_preview = xhtmlise_html($_preview, true);
                 // Fix potential errors by passing it through our XHTML fixer functions
             } else {
                 $new = $_preview;
                 if (preg_replace('#\\s+#', '', $new) != preg_replace('#\\s+#', '', $_preview)) {
                     $_preview = $new;
                     $_preview .= do_lang('BROKEN_XHTML_FIXED');
                 }
             }
         } else {
             $_preview = NULL;
         }
         $is_panel = substr($for, 0, 6) == 'panel_';
         require_code('zones3');
         $zone_list = $for == $current_for ? nice_get_zones($redirecting_to, array($id)) : new ocp_tempcode();
         $editor[$for] = static_evaluate_tempcode(do_template('ZONE_EDITOR_PANEL', array('_GUID' => 'f32ac84fe18b90497acd4afa27698bf0', 'DEFAULT_PARSED' => $default_parsed, 'CLASS' => $class, 'CURRENT_ZONE' => $current_zone, 'ZONES' => $zone_list, 'COMCODE' => $comcode, 'PREVIEW' => $_preview, 'ZONE' => $id, 'ID' => $for, 'IS_PANEL' => $is_panel, 'TYPE' => $type, 'EDIT_URL' => $edit_url, 'SETTINGS' => $settings, 'COMCODE_EDITOR' => $comcode_editor)));
     }
     breadcrumb_set_parents(array(array('_SELF:_SELF:editor', do_lang_tempcode('CHOOSE'))));
     breadcrumb_set_self($nice_zone_name);
     list($warning_details, $ping_url) = handle_conflict_resolution($id);
     $GLOBALS['HELPER_PANEL_PIC'] = '';
     $GLOBALS['HELPER_PANEL_TUTORIAL'] = '';
     $GLOBALS['HELPER_PANEL_TEXT'] = '';
     return do_template('ZONE_EDITOR_SCREEN', array('_GUID' => '3cb1aab6b16444484e82d22f2c8f1e9a', 'ID' => $id, 'LANG' => $lang, 'PING_URL' => $ping_url, 'WARNING_DETAILS' => $warning_details, 'TITLE' => $title, 'URL' => $post_url, 'LEFT_EDITOR' => $editor['panel_left'], 'RIGHT_EDITOR' => $editor['panel_right'], 'MIDDLE_EDITOR' => $editor[$default_page]));
 }
Exemplo n.º 9
0
 /**
  * Standard modular run function.
  *
  * @return tempcode	The result of execution.
  */
 function run()
 {
     require_javascript('javascript_realtime_rain');
     require_javascript('javascript_ajax');
     require_javascript('javascript_more');
     require_lang('realtime_rain');
     require_css('realtime_rain');
     $title = get_page_title('REALTIME_RAIN');
     if (!has_js()) {
         // Send them to the page permissions screen
         $url = build_url(array('page' => 'admin_stats', 'type' => 'misc'), '_SELF');
         require_code('site2');
         assign_refresh($url, 5.0);
         return do_template('REDIRECT_SCREEN', array('URL' => $url, 'TITLE' => $title, 'TEXT' => do_lang_tempcode('NO_JS_REALTIME')));
     }
     $GLOBALS['TEMPCODE_SETGET']['chrome_frame'] = make_string_tempcode('1');
     if (browser_matches('ie6')) {
         attach_message(do_lang_tempcode('IE_OLD_PLEASE_UPGRADE'), 'warn');
     }
     if (!has_js()) {
         // Send them to the stats screen
         $url = build_url(array('page' => 'admin_stats', 'type' => 'misc'), '_SELF');
         require_code('site2');
         assign_refresh($url, 5.0);
         return do_template('REDIRECT_SCREEN', array('URL' => $url, 'TITLE' => $title, 'TEXT' => do_lang_tempcode('NO_JS_ADVANCED_SCREEN_REALTIME_RAIN')));
     }
     $min_time = $GLOBALS['SITE_DB']->query_value('stats', 'MIN(date_and_time)');
     if (is_null($min_time)) {
         $min_time = time();
     }
     return do_template('REALTIME_RAIN_OVERLAY', array('MIN_TIME' => strval($min_time)));
 }
Exemplo n.º 10
0
 /**
  * Redirect to a screen suitable for celebrating a members birthday (existing topic, if possible).
  *
  * @return tempcode		The UI
  */
 function birthday()
 {
     $id = get_param('id');
     $topic_id = $GLOBALS['FORUM_DB']->query_value_null_ok_full('SELECT id FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_topics WHERE t_cache_first_time>' . strval(time() - 60 * 60 * 24 * 3) . ' AND ' . db_string_equal_to('t_cache_first_title', do_lang('HAPPY_BIRTHDAY_PERSON', $id)));
     if (!is_null($topic_id)) {
         $title = get_page_title('REDIRECTING');
         $url = $GLOBALS['FORUM_DRIVER']->topic_url($topic_id);
         require_code('site2');
         assign_refresh($url, 0.0);
         return do_template('REDIRECT_SCREEN', array('_GUID' => 'f457a6d28fd6e494662e5b82e80e9fa2', 'URL' => $url, 'TITLE' => $title, 'TEXT' => do_lang_tempcode('REDIRECTING_TO_BIRTHDAY_TOPIC')));
     }
     $_POST['title'] = do_lang('HAPPY_BIRTHDAY_PERSON', $id);
     if (get_magic_quotes_gpc()) {
         $_POST['title'] = addslashes($_POST['title']);
     }
     $forum_id = $GLOBALS['FORUM_DB']->query_value_null_ok('f_forums', 'id', array('f_name' => get_option('main_forum_name')));
     if (is_null($forum_id)) {
         $forum_id = db_get_first_id();
     }
     $_GET['id'] = strval($forum_id);
     return $this->new_topic(false, NULL, file_exists(get_file_base() . '/themes/default/images/emoticons/index.html') ? 'emoticons/birthday' : 'ocf_emoticons/birthday');
 }
Exemplo n.º 11
0
 /**
  * The UI to for the permissions-tree-editor (advanced substitute for the combination of the page permissions screen and various other structure/content-attached screens).
  *
  * @return tempcode		The UI
  */
 function tree_editor()
 {
     $title = get_page_title('PERMISSIONS_TREE');
     if (!has_js()) {
         // Send them to the page permissions screen
         $url = build_url(array('page' => '_SELF', 'type' => 'page'), '_SELF');
         require_code('site2');
         assign_refresh($url, 5.0);
         return do_template('REDIRECT_SCREEN', array('_GUID' => 'a376167acf6d0f5ac80ca743a2c728d9', 'URL' => $url, 'TITLE' => $title, 'TEXT' => do_lang_tempcode('NO_JS_ADVANCED_SCREEN_PERMISSIONS')));
     }
     require_javascript('javascript_ajax');
     require_javascript('javascript_tree_list');
     require_javascript('javascript_more');
     require_code('form_templates');
     $groups = new ocp_tempcode();
     $admin_groups = $GLOBALS['FORUM_DRIVER']->get_super_admin_groups();
     $all_groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true);
     $initial_group = NULL;
     foreach ($all_groups as $id => $group_name) {
         if (is_null($initial_group)) {
             $initial_group = $group_name;
         }
         if (!in_array($id, $admin_groups)) {
             $groups->attach(form_input_list_entry(strval($id), $id == $GLOBALS['FORUM_DRIVER']->get_guest_group(), $group_name));
         }
     }
     $css_path = get_custom_file_base() . '/themes/' . $GLOBALS['FORUM_DRIVER']->get_theme() . '/templates_cached/' . user_lang() . '/global.css';
     $color = 'FF00FF';
     if (file_exists($css_path)) {
         $tmp_file = file_get_contents($css_path);
         $matches = array();
         if (preg_match('#\\nth[\\s,][^\\}]*\\sbackground-color:\\s*\\#([\\dA-Fa-f]*);#sU', $tmp_file, $matches) != 0) {
             $color = $matches[1];
         }
     }
     // Standard editing matrix
     // NB: For permissions tree editor, default access is shown as -1 in editor for clarity (because the parent permissions are easily findable which implies the default access would mean something else which would confuse [+ this would be hard to do due to the dynamicness of the interface])
     require_code('permissions2');
     $editor = get_permissions_matrix('', array(), array(), array(), array(), true);
     return do_template('PERMISSIONS_TREE_EDITOR_SCREEN', array('_GUID' => '08bb679a7cfab45c0c29b5393666dd57', 'USERGROUPS' => $all_groups, 'TITLE' => $title, 'INITIAL_GROUP' => $initial_group, 'COLOR' => $color, 'GROUPS' => $groups, 'EDITOR' => $editor));
 }
Exemplo n.º 12
0
 /**
  * The UI for the site-tree editor.
  *
  * @return tempcode		The UI
  */
 function site_tree()
 {
     $title = get_page_title('SITE_TREE_EDITOR');
     if (!has_js()) {
         // Send them to the page permissions screen
         $url = build_url(array('page' => '_SELF', 'type' => 'page'), '_SELF');
         require_code('site2');
         assign_refresh($url, 5.0);
         return do_template('REDIRECT_SCREEN', array('_GUID' => 'a801d4cb71aa0c680eff4469e29cf4c7', 'URL' => $url, 'TITLE' => $title, 'TEXT' => do_lang_tempcode('NO_JS_ADVANCED_SCREEN_SITE_TREE')));
     }
     if (count($GLOBALS['SITE_DB']->query_value('zones', 'COUNT(*)')) >= 300) {
         attach_message(do_lang_tempcode('TOO_MUCH_CHOOSE__ALPHABETICAL', escape_html(integer_format(50))), 'warn');
     }
     require_javascript('javascript_ajax');
     require_javascript('javascript_more');
     require_javascript('javascript_tree_list');
     require_javascript('javascript_dragdrop');
     require_javascript('javascript_site_tree_editor');
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('PAGES'))));
     return do_template('SITE_TREE_EDITOR_SCREEN', array('_GUID' => '2d42cb71e03d31c855a6b6467d2082d2', 'TITLE' => $title));
 }
Exemplo n.º 13
0
 /**
  * Install geolocation data.
  *
  * @return tempcode		The UI, showing the result of the installation
  */
 function install_geolocation_data()
 {
     $title = get_page_title('INSTALL_GEOLOCATION_DATA');
     $GLOBALS['NO_QUERY_LIMIT'] = true;
     $last = 104295 - 1;
     // Index of the last line in the IP_Country.txt file
     $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/installgeolocationdata';
     $test = $GLOBALS['SITE_DB']->query_value('ip_country', 'COUNT(*)');
     if ($test >= $last) {
         $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF');
         return redirect_screen($title, $url, do_lang_tempcode('SUCCESS'));
     }
     //We need to read in IP_Country.txt, line-by-line, for x lines
     $lines = get_param_integer('lines', 2000);
     $position = get_param_integer('position', 0);
     $i = 0;
     if ($position == 0) {
         $GLOBALS['SITE_DB']->query_delete('ip_country');
     }
     $path = get_file_base() . '/data/modules/admin_stats/IP_Country.txt';
     $file = @fopen($path, 'rt');
     if ($file === false) {
         warn_exit(do_lang_tempcode('READ_ERROR', escape_html($path)));
     }
     $to_insert = array('begin_num' => array(), 'end_num' => array(), 'country' => array());
     while (!feof($file) && $i < $position + $lines) {
         $data = fgets($file, 1024);
         if ($data === false) {
             break;
         }
         if ($i >= $position) {
             $_data = explode(',', $data);
             if (count($_data) == 3) {
                 $to_insert['begin_num'][] = $_data[0];
                 // FUDGEFUDGE. Intentionally passes in as strings, to workaround problem in PHP integer sizes (can't store unsigned data type)
                 $to_insert['end_num'][] = $_data[1];
                 $to_insert['country'][] = substr($_data[2], 0, 2);
                 if (count($to_insert['begin_num']) == 100) {
                     $GLOBALS['SITE_DB']->query_insert('ip_country', $to_insert);
                     $to_insert = array('begin_num' => array(), 'end_num' => array(), 'country' => array());
                 }
             }
         }
         $i++;
     }
     fclose($file);
     fix_permissions($path);
     if (count($to_insert['begin_num']) != 0) {
         $GLOBALS['SITE_DB']->query_insert('ip_country', $to_insert);
     }
     if ($i >= $last) {
         $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF');
         return redirect_screen($title, $url, do_lang_tempcode('SUCCESS'));
     }
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('SITE_STATISTICS'))));
     global $FORCE_META_REFRESH;
     $FORCE_META_REFRESH = true;
     require_code('site2');
     assign_refresh(build_url(array('page' => '_SELF', 'type' => 'install_data', 'lines' => $lines, 'position' => $position + $lines), 'adminzone'), $position == 0 ? 1.0 : 0.0);
     return inform_screen($title, do_lang_tempcode('INSTALLING_GEOLOCATION_DATA'));
 }
Exemplo n.º 14
0
 /**
  * The actualiser to set sound effects.
  *
  * @return tempcode		The UI
  */
 function _set_effects()
 {
     $title = get_page_title('CHAT_SET_EFFECTS');
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('CHAT_LOBBY'))));
     require_code('uploads');
     // Find all our suffixes to check for
     $buddy_count = $GLOBALS['SITE_DB']->query_value('chat_buddies', 'COUNT(*)', array('member_likes' => get_member()));
     $suffixes = array();
     if ($buddy_count < 200) {
         $buddies = $GLOBALS['SITE_DB']->query_select('chat_buddies', array('member_liked'), array('member_likes' => get_member()));
         $suffixes = array('');
         foreach ($buddies as $buddy) {
             if (is_null($GLOBALS['FORUM_DRIVER']->get_username($buddy['member_liked']))) {
                 continue;
             }
             $suffixes[] = '_' . strval($buddy['member_liked']);
         }
     }
     $current_settings = collapse_2d_complexity('s_effect_id', 's_url', $GLOBALS['SITE_DB']->query_select('chat_sound_effects', array('s_url', 's_effect_id'), array('s_member' => get_member())));
     // Process data
     foreach ($suffixes as $suffix) {
         $effects = get_effect_set($suffix != '');
         foreach ($effects as $effect) {
             if (is_null($effect)) {
                 continue;
             }
             if (post_param('select_' . $effect . $suffix) == '-1' && is_null(post_param('hidFileID_upload_' . $effect . $suffix, NULL)) && isset($_FILES['upload_' . $effect . $suffix]) && !is_uploaded_file($_FILES['upload_' . $effect . $suffix]['tmp_name'])) {
                 $url = '-1';
             } else {
                 $url_bits = get_url('select_' . $effect . $suffix, 'upload_' . $effect . $suffix, 'uploads/personal_sound_effects', 0, OCP_UPLOAD_MP3);
                 $url = $url_bits[0];
             }
             // Delete existing upload, if appropriate
             if (array_key_exists($effect . $suffix, $current_settings) && substr($current_settings[$effect . $suffix], 0, 31) == 'uploads/personal_sound_effects/' && $current_settings[$effect . $suffix] != $url) {
                 @unlink(get_custom_file_base() . '/' . filter_naughty($current_settings[$effect . $suffix]));
             }
             // Delete existing setting
             $GLOBALS['SITE_DB']->query_delete('chat_sound_effects', array('s_member' => get_member(), 's_effect_id' => $effect . $suffix));
             if ($url != '-1') {
                 // Add new setting
                 $GLOBALS['SITE_DB']->query_insert('chat_sound_effects', array('s_member' => get_member(), 's_effect_id' => $effect . $suffix, 's_url' => $url));
             }
         }
     }
     $redirect = post_param('redirect', NULL);
     if (is_null($redirect)) {
         return inform_screen($title, do_lang_tempcode('SUCCESS'));
     } else {
         require_code('site2');
         assign_refresh($redirect, 0.0);
         return do_template('REDIRECT_SCREEN', array('_GUID' => '6bcc5c60f9b75e9dca719a5db8d24491', 'URL' => $redirect, 'TITLE' => $title, 'TEXT' => do_lang_tempcode('SUCCESS')));
     }
 }