/**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     require_lang('messaging');
     require_code('feedback');
     $to = array_key_exists('param', $map) ? $map['param'] : get_option('staff_address');
     $post = post_param('post', '');
     if (post_param_integer('_comment_form_post', 0) == 1 && $post != '') {
         if (addon_installed('captcha')) {
             if (get_option('captcha_on_feedback') == '1') {
                 require_code('captcha');
                 enforce_captcha();
             }
         }
         $message = new ocp_tempcode();
         /*Used to be written out here*/
         attach_message(do_lang_tempcode('MESSAGE_SENT'), 'inform');
         require_code('mail');
         $email_from = trim(post_param('email', $GLOBALS['FORUM_DRIVER']->get_member_email_address(get_member())));
         mail_wrap(post_param('title'), $post, array($to), NULL, $email_from, $GLOBALS['FORUM_DRIVER']->get_username(get_member()), 3, NULL, false, get_member());
         if ($email_from != '') {
             mail_wrap(do_lang('YOUR_MESSAGE_WAS_SENT_SUBJECT', post_param('title')), do_lang('YOUR_MESSAGE_WAS_SENT_BODY', $post), array($email_from), NULL, '', '', 3, NULL, false, get_member());
         }
     } else {
         $message = new ocp_tempcode();
     }
     $box_title = array_key_exists('title', $map) ? $map['title'] : do_lang('CONTACT_US');
     $private = array_key_exists('private', $map) && $map['private'] == '1';
     $em = $GLOBALS['FORUM_DRIVER']->get_emoticon_chooser();
     require_javascript('javascript_editing');
     $comcode_help = build_url(array('page' => 'userguide_comcode'), get_comcode_zone('userguide_comcode', false));
     require_javascript('javascript_validation');
     $comment_url = get_self_url();
     $email_optional = array_key_exists('email_optional', $map) ? intval($map['email_optional']) == 1 : true;
     if (addon_installed('captcha')) {
         require_code('captcha');
         $use_captcha = get_option('captcha_on_feedback') == '1' && use_captcha();
         if ($use_captcha) {
             generate_captcha();
         }
     } else {
         $use_captcha = false;
     }
     $comment_details = do_template('COMMENTS_POSTING_FORM', array('JOIN_BITS' => '', 'FIRST_POST_URL' => '', 'FIRST_POST' => '', 'USE_CAPTCHA' => $use_captcha, 'EMAIL_OPTIONAL' => $email_optional, 'POST_WARNING' => '', 'COMMENT_TEXT' => '', 'GET_EMAIL' => !$private, 'GET_TITLE' => !$private, 'EM' => $em, 'DISPLAY' => 'block', 'TITLE' => $box_title, 'COMMENT_URL' => $comment_url));
     $out = do_template('BLOCK_MAIN_CONTACT_SIMPLE', array('_GUID' => '298a357f442f440c6b42e58d6717e57c', 'EMAIL_OPTIONAL' => true, 'COMMENT_DETAILS' => $comment_details, 'MESSAGE' => $message));
     return $out;
 }
示例#2
0
 /**
  * Get a form for posting.
  *
  * @param  ID_TEXT		The content type of what this posting will be for
  * @param  ID_TEXT		The content ID of what this posting will be for
  * @param  boolean		Whether to accept reviews
  * @param  tempcode		URL where form submit will go
  * @param  ?string		The default post to use (NULL: standard courtesy warning)
  * @return tempcode		Posting form
  */
 function get_posting_form($type, $id, $allow_reviews, $post_url, $post_warning)
 {
     require_lang('comcode');
     require_javascript('javascript_editing');
     require_javascript('javascript_validation');
     require_javascript('javascript_swfupload');
     require_css('swfupload');
     $em = $GLOBALS['FORUM_DRIVER']->get_emoticon_chooser();
     $comment_text = get_option('comment_text');
     if (is_null($post_warning)) {
         $post_warning = do_lang('POST_WARNING');
     }
     if (addon_installed('captcha')) {
         require_code('captcha');
         $use_captcha = use_captcha();
         if ($use_captcha) {
             generate_captcha();
         }
     } else {
         $use_captcha = false;
     }
     $title = do_lang_tempcode($allow_reviews ? 'POST_REVIEW' : 'MAKE_COMMENT');
     $join_bits = new ocp_tempcode();
     if (is_guest()) {
         $redirect = get_self_url(true, true);
         $login_url = build_url(array('page' => 'login', 'type' => 'misc', 'redirect' => $redirect), get_module_zone('login'));
         $join_url = $GLOBALS['FORUM_DRIVER']->join_url();
         $join_bits = do_template('JOIN_OR_LOGIN', array('LOGIN_URL' => $login_url, 'JOIN_URL' => $join_url));
     }
     $reviews_rating_criteria = array();
     foreach ($this->reviews_rating_criteria as $review_title) {
         $reviews_rating_criteria[] = array('REVIEW_TITLE' => $review_title);
     }
     if ($this->is_threaded) {
         $post_warning = do_lang('THREADED_REPLY_NOTICE', $post_warning);
     }
     return do_template('COMMENTS_POSTING_FORM', array('_GUID' => 'c87025f81ee64c885f0ac545efa5f16c', 'EXPAND_TYPE' => 'contract', 'FIRST_POST_URL' => '', 'FIRST_POST' => '', 'JOIN_BITS' => $join_bits, 'REVIEWS' => $allow_reviews, 'TYPE' => $type, 'ID' => $id, 'REVIEW_RATING_CRITERIA' => $reviews_rating_criteria, 'USE_CAPTCHA' => $use_captcha, 'GET_EMAIL' => false, 'EMAIL_OPTIONAL' => true, 'GET_TITLE' => true, 'POST_WARNING' => $post_warning, 'COMMENT_TEXT' => $comment_text, 'EM' => $em, 'DISPLAY' => 'block', 'COMMENT_URL' => $post_url, 'TITLE' => $title));
 }
示例#3
0
 /**
  * The UI for recommending the site.
  *
  * @return tempcode	The UI.
  */
 function gui()
 {
     require_code('form_templates');
     global $EXTRA_HEAD;
     $EXTRA_HEAD->attach('<meta name="robots" content="noindex" />');
     // XHTMLXHTML
     global $NON_CANONICAL_PARAMS;
     $NON_CANONICAL_PARAMS[] = 'page_title';
     $NON_CANONICAL_PARAMS[] = 'subject';
     $NON_CANONICAL_PARAMS[] = 's_message';
     $NON_CANONICAL_PARAMS[] = 'from';
     $NON_CANONICAL_PARAMS[] = 'title';
     $NON_CANONICAL_PARAMS[] = 'ocp';
     $page_title = get_param('page_title', NULL, true);
     $submit_name = !is_null($page_title) ? make_string_tempcode($page_title) : do_lang_tempcode('SEND');
     $post_url = build_url(array('page' => '_SELF', 'type' => 'actual'), '_SELF', NULL, true);
     $hidden = new ocp_tempcode();
     $name = post_param('name', is_guest() ? '' : $GLOBALS['FORUM_DRIVER']->get_username(get_member()));
     $recommender_email_address = post_param('recommender_email_address', $GLOBALS['FORUM_DRIVER']->get_member_email_address(get_member()));
     $fields = new ocp_tempcode();
     $fields->attach(form_input_line(do_lang_tempcode('YOUR_NAME'), '', 'name', $name, true));
     $fields->attach(form_input_email(do_lang_tempcode('YOUR_EMAIL_ADDRESS'), '', 'recommender_email_address', $recommender_email_address, true));
     $already = array();
     foreach ($_POST as $key => $email_address) {
         if (substr($key, 0, 14) != 'email_address_') {
             continue;
         }
         if (get_magic_quotes_gpc()) {
             $email_address = stripslashes($email_address);
         }
         $already[] = $email_address;
     }
     if (is_guest()) {
         $fields->attach(form_input_email(do_lang_tempcode('FRIEND_EMAIL_ADDRESS'), '', 'email_address_0', array_key_exists(0, $already) ? $already[0] : '', true));
     } else {
         $fields->attach(form_input_line_multi(do_lang_tempcode('FRIEND_EMAIL_ADDRESS'), do_lang_tempcode('THEIR_ADDRESS'), 'email_address_', $already, 1, NULL, 'email'));
     }
     if (may_use_invites() && get_forum_type() == 'ocf' && !is_guest()) {
         $invites = get_num_invites(get_member());
         if ($invites > 0) {
             require_lang('ocf');
             $invite = count($_POST) == 0 ? true : post_param_integer('invite', 0) == 1;
             $fields->attach(form_input_tick(do_lang_tempcode('USE_INVITE'), do_lang_tempcode('USE_INVITE_DESCRIPTION', $GLOBALS['FORUM_DRIVER']->is_super_admin(get_member()) ? do_lang('NA_EM') : integer_format($invites)), 'invite', $invite));
         }
     }
     $message = post_param('message', NULL);
     $subject = get_param('subject', do_lang('RECOMMEND_MEMBER_SUBJECT', get_site_name()), true);
     if (is_null($message)) {
         $message = get_param('s_message', '', true);
         if ($message == '') {
             $from = get_param('from', NULL, true);
             if (!is_null($from)) {
                 $resource_title = get_param('title', '', true);
                 if ($resource_title == '') {
                     $downloaded_at_link = http_download_file($from, 3000, false);
                     if (is_string($downloaded_at_link)) {
                         $matches = array();
                         if (preg_match('#\\s*<title[^>]*\\s*>\\s*(.*)\\s*\\s*<\\s*/title\\s*>#mi', $downloaded_at_link, $matches) != 0) {
                             $resource_title = trim(str_replace('&ndash;', '-', str_replace('&mdash;', '-', @html_entity_decode($matches[1], ENT_QUOTES, get_charset()))));
                             $resource_title = preg_replace('#^' . str_replace('#', '\\#', preg_quote(get_site_name())) . ' - #', '', $resource_title);
                             $resource_title = preg_replace('#\\s+[^\\d\\s][^\\d\\s]?[^\\d\\s]?\\s+' . str_replace('#', '\\#', preg_quote(get_site_name())) . '$#i', '', $resource_title);
                         }
                     }
                 }
                 if ($resource_title == '') {
                     $resource_title = do_lang('THIS');
                     // Could not find at all, so say 'this'
                 } else {
                     $subject = get_param('subject', do_lang('RECOMMEND_MEMBER_SUBJECT_SPECIFIC', get_site_name(), $resource_title), true);
                 }
                 $message = do_lang('FOUND_THIS_ON', get_site_name(), comcode_escape($from), comcode_escape($resource_title));
             }
         }
         if (get_param_integer('ocp', 0) == 1) {
             $message = do_lang('RECOMMEND_OCPORTAL');
         }
     }
     $text = is_null($page_title) ? do_lang_tempcode('RECOMMEND_SITE_TEXT') : new ocp_tempcode();
     if (!is_null(get_param('from', NULL, true))) {
         if (is_null($page_title)) {
             $title = get_page_title('RECOMMEND_LINK');
         } else {
             $title = get_page_title($page_title, false);
         }
         $submit_name = do_lang_tempcode('SEND');
         $text = do_lang_tempcode('RECOMMEND_AUTO_TEXT', get_site_name());
         $need_message = true;
     } else {
         if (is_null($page_title)) {
             $title = get_page_title('_RECOMMEND_SITE', true, array(escape_html(get_site_name())));
         } else {
             $title = get_page_title($page_title, false);
         }
         $hidden->attach(form_input_hidden('wrap_message', '1'));
         $need_message = false;
     }
     //add an upload CSV contacts file field
     $_help_url = build_url(array('page' => 'recommend_help'), get_page_zone('recommend_help'));
     $help_url = $_help_url->evaluate();
     if (get_value('disable_csv_recommend') !== '1' && !is_guest()) {
         $fields->attach(form_input_upload(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('UPLOAD')), do_lang_tempcode('DESCRIPTION_UPLOAD_CSV_FILE', escape_html($help_url)), 'upload', false, NULL, NULL, false));
     }
     handle_max_file_size($hidden);
     $fields->attach(form_input_line(do_lang_tempcode('SUBJECT'), '', 'subject', $subject, true));
     $fields->attach(form_input_text_comcode(do_lang_tempcode('MESSAGE'), do_lang_tempcode('RECOMMEND_SUP_MESSAGE'), 'message', $message, $need_message));
     if (addon_installed('captcha')) {
         require_code('captcha');
         if (use_captcha()) {
             $fields->attach(form_input_captcha());
             $text->attach(' ');
             $text->attach(do_lang_tempcode('FORM_TIME_SECURITY'));
         }
     }
     $hidden->attach(form_input_hidden('comcode__message', '1'));
     if (get_value('disable_csv_recommend') !== '1' && !is_guest()) {
         $javascript = 'standardAlternateFields(\'upload\',\'email_address_0\');';
     } else {
         $javascript = '';
     }
     $javascript .= function_exists('captcha_ajax_check') ? captcha_ajax_check() : '';
     return do_template('FORM_SCREEN', array('_GUID' => '08a538ca8d78597b0417f464758a59fd', 'JAVASCRIPT' => $javascript, 'SKIP_VALIDATION' => true, 'TITLE' => $title, 'HIDDEN' => $hidden, 'FIELDS' => $fields, 'URL' => $post_url, 'SUBMIT_NAME' => $submit_name, 'TEXT' => $text));
 }
示例#4
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']);
 }
示例#5
0
 /**
  * The UI to contact a member.
  *
  * @return tempcode		The UI
  */
 function gui()
 {
     $member_id = get_param_integer('id');
     $username = $GLOBALS['FORUM_DRIVER']->get_username($member_id);
     if (is_null($username)) {
         warn_exit(do_lang_tempcode('USER_NO_EXIST'));
     }
     $title = get_page_title('EMAIL_MEMBER', true, array(escape_html($username)));
     global $EXTRA_HEAD;
     $EXTRA_HEAD->attach('<meta name="robots" content="noindex" />');
     // XHTMLXHTML
     $text = do_lang_tempcode('EMAIL_MEMBER_TEXT');
     $fields = new ocp_tempcode();
     require_code('form_templates');
     $fields->attach(form_input_line(do_lang_tempcode('SUBJECT'), '', 'subject', get_param('subject', '', true), true));
     $default_email = is_guest() ? '' : $GLOBALS['FORUM_DRIVER']->get_member_row_field(get_member(), 'm_email_address');
     $default_name = is_guest() ? '' : $GLOBALS['FORUM_DRIVER']->get_member_row_field(get_member(), 'm_username');
     $fields->attach(form_input_line(do_lang_tempcode('NAME'), do_lang_tempcode('_DESCRIPTION_NAME'), 'name', $default_name, true));
     $fields->attach(form_input_email(do_lang_tempcode('EMAIL_ADDRESS'), do_lang_tempcode('YOUR_ADDRESS'), 'email_address', $default_email, true));
     $fields->attach(form_input_text(do_lang_tempcode('MESSAGE'), '', 'message', get_param('message', '', true), true));
     if (addon_installed('captcha')) {
         require_code('captcha');
         if (use_captcha()) {
             $fields->attach(form_input_captcha());
             $text->attach(' ');
             $text->attach(do_lang_tempcode('FORM_TIME_SECURITY'));
         }
     }
     $size = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id, 'm_max_email_attach_size_mb');
     $hidden = new ocp_tempcode();
     if ($size != 0) {
         handle_max_file_size($hidden);
         $fields->attach(form_input_upload_multi(do_lang_tempcode('_ATTACHMENT'), do_lang_tempcode('EMAIL_ATTACHMENTS', integer_format($size)), 'attachment', false));
     }
     $submit_name = do_lang_tempcode('SEND');
     $redirect = get_param('redirect', '');
     if ($redirect == '') {
         $redirect = $GLOBALS['FORUM_DRIVER']->member_profile_url($member_id, false, true);
         if (is_object($redirect)) {
             $redirect = $redirect->evaluate();
         }
     }
     $post_url = build_url(array('page' => '_SELF', 'type' => 'actual', 'id' => $member_id, 'redirect' => $redirect), '_SELF');
     return do_template('FORM_SCREEN', array('_GUID' => 'e06557e6eceacf1f46ee930c99ac5bb5', 'TITLE' => $title, 'HIDDEN' => $hidden, 'JAVASCRIPT' => function_exists('captcha_ajax_check') ? captcha_ajax_check() : '', 'FIELDS' => $fields, 'TEXT' => $text, 'SUBMIT_NAME' => $submit_name, 'URL' => $post_url));
 }
示例#6
0
 /**
  * The UI to report a post.
  *
  * @return tempcode		The UI
  */
 function report_post()
 {
     $post_id = get_param_integer('id');
     $post_info = $GLOBALS['FORUM_DB']->query_select('f_posts', array('*'), array('id' => $post_id), '', 1);
     if (!array_key_exists(0, $post_info)) {
         warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
     }
     $topic_id = $post_info[0]['p_topic_id'];
     $topic_info = $GLOBALS['FORUM_DB']->query_select('f_topics', array('*'), array('id' => $topic_id), '', 1);
     if (!array_key_exists(0, $topic_info)) {
         warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
     }
     $this->handle_topic_breadcrumbs($topic_info[0]['t_forum_id'], $topic_id, $topic_info[0]['t_cache_first_title'], do_lang_tempcode('REPORT_POST'));
     $this->check_has_mod_access($topic_id);
     $poster = $post_info[0]['p_poster_name_if_guest'];
     $member = $poster;
     if (!is_guest($post_info[0]['p_poster'])) {
         $member = '[page type="view" id="' . strval($post_info[0]['p_poster']) . '" param="' . get_module_zone('members') . '" caption="' . $poster . '"]members[/page]';
     }
     $_postdetails = post_param('post', NULL);
     if (is_null($_postdetails)) {
         $__post = get_translated_text($post_info[0]['p_post'], $GLOBALS['FORUM_DB']);
         $post = do_template('OCF_REPORTED_POST_FCOMCODE', array('_GUID' => 'e0f65423f3cb7698d5f04431dbe52ddb', 'POST_ID' => strval($post_id), 'MEMBER' => $member, 'TOPIC_TITLE' => $topic_info[0]['t_cache_first_title'], 'POST' => $__post, 'POSTER' => $poster));
     } else {
         $post = make_string_tempcode($_postdetails);
     }
     $hidden_fields = new ocp_tempcode();
     if (!is_guest()) {
         $options = array();
         if (get_option('is_on_anonymous_posts') == '1') {
             $options[] = array(do_lang_tempcode('_MAKE_ANONYMOUS_POST'), 'anonymous', false, do_lang_tempcode('MAKE_ANONYMOUS_POST_DESCRIPTION'));
         }
         $specialisation = form_input_various_ticks($options, '');
     } else {
         $specialisation = new ocp_tempcode();
     }
     $hidden_fields->attach(form_input_hidden('forum_id', '-2'));
     $hidden_fields->attach(form_input_hidden('validated', '1'));
     $report_title = $post_info[0]['p_title'];
     if ($report_title == '') {
         $report_title = $topic_info[0]['t_cache_first_title'];
     }
     $hidden_fields->attach(form_input_hidden('title', do_lang('REPORTED_POST_TITLE', $report_title)));
     $hidden_fields->attach(form_input_hidden('o_post_id', strval($post_id)));
     $hidden_fields->attach(form_input_hidden('from_url', get_self_url(true)));
     $text = new ocp_tempcode();
     if (addon_installed('captcha')) {
         require_code('captcha');
         if (use_captcha()) {
             $specialisation->attach(form_input_captcha());
             $text->attach(paragraph(do_lang_tempcode('FORM_TIME_SECURITY')));
         }
     }
     if (addon_installed('points')) {
         $login_url = build_url(array('page' => 'login', 'type' => 'misc', 'redirect' => get_self_url(true, true)), get_module_zone('login'));
         $_login_url = escape_html($login_url->evaluate());
         if (is_guest() && (get_forum_type() != 'ocf' || has_actual_page_access(get_member(), 'join'))) {
             $text->attach(paragraph(do_lang_tempcode('NOT_LOGGED_IN_NO_CREDIT', $_login_url)));
         }
     }
     $post_url = build_url(array('page' => '_SELF', 'type' => '_add_reply'), '_SELF');
     $posting_form = get_posting_form(do_lang('REPORT_POST'), $post->evaluate(), $post_url, $hidden_fields, $specialisation, NULL, '', NULL, NULL, $this->_post_javascript() . (function_exists('captcha_ajax_check') ? captcha_ajax_check() : ''), NULL, true, false);
     $title = get_page_title('REPORT_POST');
     return do_template('POSTING_SCREEN', array('_GUID' => 'eee64757e66fed702f74fecf8d595260', 'TITLE' => $title, 'TEXT' => $text, 'POSTING_FORM' => $posting_form));
 }
示例#7
0
 /**
  * The UI to either show an existing ticket and allow a reply, or to start a new ticket.
  *
  * @return tempcode		The UI
  */
 function do_ticket()
 {
     require_lang('comcode');
     $id = get_param('id', NULL);
     if ($id == '') {
         $id = NULL;
     }
     if (!is_null($id)) {
         $_temp = explode('_', $id);
         if (!isset($_temp[1])) {
             warn_exit(do_lang_tempcode('INTERNAL_ERROR'));
         }
         // Normal topic, not a ticket!
         $ticket_owner = intval($_temp[0]);
         $ticket_id = $_temp[1];
         if (is_guest()) {
             access_denied('NOT_AS_GUEST');
         }
         $this->check_id($id);
     } else {
         $ticket_owner = get_member();
         $ticket_id = uniqid('', true);
     }
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('SUPPORT_TICKETS'))));
     $poster = '';
     $new = true;
     $serialized_options = mixed();
     $hash = mixed();
     if (!is_guest() || is_null($id)) {
         $member = get_member();
         $new = is_null($id);
         $num_to_show_limit = get_param_integer('max_comments', intval(get_option('comments_to_show_in_thread')));
         $start = get_param_integer('start_comments', 0);
         if ($new) {
             $id = strval($member) . '_' . $ticket_id;
             $title = get_page_title('ADD_TICKET');
         } else {
             $ticket_type = $GLOBALS['SITE_DB']->query_value_null_ok('tickets', 'ticket_type', array('ticket_id' => $id));
             $ticket_type_text = get_translated_text($ticket_type);
             $ticket_type_details = get_ticket_type($ticket_type);
             $forum = 1;
             $topic_id = 1;
             $_ticket_type = 1;
             // These will be returned by reference
             $_comments = get_ticket_posts($id, $forum, $topic_id, $_ticket_type, $start, $num_to_show_limit);
             $_comments_all = get_ticket_posts($id, $forum, $topic_id, $_ticket_type);
             if (!is_array($_comments) || !array_key_exists(0, $_comments)) {
                 warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
             }
             $ticket_title = $_comments[0]['title'];
             if ($ticket_title == '') {
                 $ticket_title = do_lang('UNKNOWN');
             }
             $title = get_page_title('_VIEW_SUPPORT_TICKET', true, array(escape_html($ticket_title), escape_html($ticket_type_text)));
             breadcrumb_set_self($ticket_title);
         }
         $ticket_page_text = comcode_to_tempcode(get_option('ticket_text'), NULL, true);
         $staff_details = new ocp_tempcode();
         $types = $this->build_types_list(get_param('default', ''));
         $results_browser = NULL;
         if (!$new) {
             require_code('templates_internalise_screen');
             $test_tpl = internalise_own_screen($title, 30, $_comments_all);
             if (is_object($test_tpl)) {
                 return $test_tpl;
             }
             if (is_null($_comments)) {
                 warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
             }
             if (has_specific_permission(get_member(), 'support_operator')) {
                 $staff_details = make_string_tempcode($GLOBALS['FORUM_DRIVER']->topic_url($topic_id, escape_html(get_option('ticket_forum_name'))));
             } else {
                 $staff_details = new ocp_tempcode();
             }
             require_code('topics');
             $renderer = new OCP_Topic();
             $renderer->_inject_posts_for_scoring_algorithm($_comments);
             $renderer->topic_id = $topic_id;
             // Posts
             $max_thread_depth = get_param_integer('max_thread_depth', intval(get_option('max_thread_depth')));
             list($comments, $serialized_options, $hash) = $renderer->render_posts($num_to_show_limit, $max_thread_depth, true, $ticket_owner, array(), $forum);
             // Pagination
             if (!$renderer->is_threaded) {
                 if (count($_comments_all) > $num_to_show_limit) {
                     require_code('templates_results_browser');
                     $results_browser = results_browser(do_lang_tempcode('COMMENTS'), NULL, $start, 'start_comments', $num_to_show_limit, 'max_comments', count($_comments_all), NULL, NULL, true);
                 }
             }
             $GLOBALS['META_DATA'] += array('created' => date('Y-m-d', $_comments[0]['date']), 'creator' => $GLOBALS['FORUM_DRIVER']->get_username($_comments[0]['user']), 'publisher' => '', 'modified' => '', 'type' => 'Support ticket', 'title' => $_comments[0]['title'], 'identifier' => '_SEARCH:tickets:ticket:' . $id, 'description' => '', 'image' => find_theme_image('bigicons/tickets'));
             // "Staff only reply" tickbox
             if (get_forum_type() == 'ocf' && $GLOBALS['FORUM_DRIVER']->is_staff(get_member())) {
                 require_code('form_templates');
                 $staff_only = form_input_tick(do_lang('TICKET_STAFF_ONLY'), do_lang('TICKET_STAFF_ONLY_DESCRIPTION'), 'staff_only', false);
             } else {
                 $staff_only = new ocp_tempcode();
             }
         } else {
             $comments = new ocp_tempcode();
             $staff_only = new ocp_tempcode();
             $ticket_type_details = get_ticket_type(NULL);
         }
         if ($poster == '' || $GLOBALS['FORUM_DRIVER']->get_guest_id() != intval($poster)) {
             $em = $GLOBALS['FORUM_DRIVER']->get_emoticon_chooser();
             require_javascript('javascript_editing');
             require_javascript('javascript_validation');
             require_javascript('javascript_posting');
             require_javascript('javascript_swfupload');
             require_css('swfupload');
             require_code('form_templates');
             list($attachments, $attach_size_field) = get_forum_type() == 'ocf' ? get_attachments('post') : array(NULL, NULL);
             if (addon_installed('captcha')) {
                 require_code('captcha');
                 $use_captcha = get_option('captcha_on_feedback') == '1' && use_captcha();
                 if ($use_captcha) {
                     generate_captcha();
                 }
             } else {
                 $use_captcha = false;
             }
             $comment_form = do_template('COMMENTS_POSTING_FORM', array('_GUID' => 'aaa32620f3eb68d9cc820b18265792d7', 'JOIN_BITS' => '', 'FIRST_POST_URL' => '', 'FIRST_POST' => '', 'USE_CAPTCHA' => $use_captcha, 'ATTACHMENTS' => $attachments, 'ATTACH_SIZE_FIELD' => $attach_size_field, 'POST_WARNING' => '', 'COMMENT_TEXT' => '', 'GET_EMAIL' => is_guest(), 'EMAIL_OPTIONAL' => is_guest() && $ticket_type_details['guest_emails_mandatory'], 'GET_TITLE' => true, 'EM' => $em, 'DISPLAY' => 'block', 'COMMENT_URL' => '', 'SUBMIT_NAME' => do_lang_tempcode('MAKE_POST'), 'TITLE' => do_lang_tempcode($new ? 'CREATE_TICKET_MAKE_POST' : 'MAKE_POST')));
         } else {
             $comment_form = new ocp_tempcode();
         }
         $post_url = build_url(array('page' => '_SELF', 'id' => $id, 'type' => 'post', 'redirect' => get_param('redirect', NULL)), '_SELF');
         require_code('form_templates');
         require_code('feedback');
         list($warning_details, $ping_url) = handle_conflict_resolution(NULL, true);
         $other_tickets = new ocp_tempcode();
         $our_topic = NULL;
         if (!is_guest($ticket_owner)) {
             $tickets_of_member = get_tickets($ticket_owner, NULL, true);
             if (!is_null($tickets_of_member)) {
                 foreach ($tickets_of_member as $topic) {
                     $ticket_id = extract_topic_identifier($topic['description']);
                     if ($id != $ticket_id) {
                         $url = build_url(array('page' => '_SELF', 'type' => 'ticket', 'id' => $ticket_id), '_SELF');
                         $_title = $topic['firsttitle'];
                         $date = get_timezoned_date($topic['lasttime']);
                         $ticket_owner_name = $GLOBALS['FORUM_DRIVER']->get_username($ticket_owner);
                         if (is_null($ticket_owner_name)) {
                             $profile_link = '';
                         } else {
                             $profile_link = $GLOBALS['FORUM_DRIVER']->member_profile_url($ticket_owner, false, true);
                         }
                         $last_poster = $topic['lastusername'];
                         $unclosed = !$GLOBALS['FORUM_DRIVER']->is_staff($topic['lastmemberid']);
                         $params = array('NUM_POSTS' => integer_format($topic['num'] - 1), 'CLOSED' => strval($topic['closed']), 'URL' => $url, 'TITLE' => $_title, 'DATE' => $date, 'DATE_RAW' => strval($topic['lasttime']), 'PROFILE_LINK' => $profile_link, 'LAST_POSTER' => $last_poster, 'UNCLOSED' => $unclosed);
                         $other_tickets->attach(do_template('SUPPORT_TICKET_LINK', $params));
                     } else {
                         $our_topic = $topic;
                     }
                 }
             }
         }
         $toggle_ticket_closed_url = NULL;
         if (get_forum_type() == 'ocf' && !$new) {
             $toggle_ticket_closed_url = build_url(array('page' => '_SELF', 'type' => 'toggle_ticket_closed', 'id' => $id), '_SELF');
         }
         $map = array('page' => '_SELF', 'type' => 'ticket');
         if (get_param('default', '') != '') {
             $map['default'] = get_param('default');
         }
         $add_ticket_url = build_url($map, '_SELF');
         return do_template('SUPPORT_TICKET_SCREEN', array('_GUID' => 'd21a9d161008c6c44fe7309a14be2c5b', 'SERIALIZED_OPTIONS' => $serialized_options, 'HASH' => $hash, 'TOGGLE_TICKET_CLOSED_URL' => $toggle_ticket_closed_url, 'CLOSED' => is_null($our_topic) ? '0' : strval($our_topic['closed']), 'OTHER_TICKETS' => $other_tickets, 'USERNAME' => $GLOBALS['FORUM_DRIVER']->get_username($ticket_owner), 'PING_URL' => $ping_url, 'WARNING_DETAILS' => $warning_details, 'NEW' => $new, 'TICKET_PAGE_TEXT' => $ticket_page_text, 'TYPES' => $types, 'STAFF_ONLY' => $staff_only, 'POSTER' => $poster, 'TITLE' => $title, 'COMMENTS' => $comments, 'COMMENT_FORM' => $comment_form, 'STAFF_DETAILS' => $staff_details, 'URL' => $post_url, 'ADD_TICKET_URL' => $add_ticket_url, 'RESULTS_BROWSER' => $results_browser));
     } else {
         return inform_screen(get_page_title('ADD_TICKET'), do_lang_tempcode('SUCCESS'));
     }
 }
示例#8
0
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     require_code('feedback');
     require_javascript('javascript_validation');
     $is_occle_talking = ocp_srv('HTTP_USER_AGENT') == 'ocPortal' && ocp_srv('HTTP_HOST') == 'ocportal.com';
     $self_url = get_self_url();
     $self_title = get_page_name();
     $type = 'block_main_feedback';
     $id = array_key_exists('param', $map) ? $map['param'] : '';
     $out = new ocp_tempcode();
     if (post_param_integer('_comment_form_post', 0) == 1) {
         if (!has_no_forum()) {
             $hidden = actualise_post_comment(true, $type, $id, $self_url, $self_title, array_key_exists('forum', $map) ? $map['forum'] : NULL, $is_occle_talking || get_option('captcha_on_feedback') == '0', 1, false, true, true);
             if (array_key_exists('title', $_POST)) {
                 $redirect = get_param('redirect', NULL);
                 if (!is_null($redirect)) {
                     $redirect_screen = redirect_screen(get_page_title('_FEEDBACK'), $redirect, do_lang_tempcode('FEEDBACK_THANKYOU'));
                     @ob_end_clean();
                     $echo = globalise($redirect_screen, NULL, '', true);
                     $echo->evaluate_echo();
                     exit;
                 } else {
                     attach_message(do_lang_tempcode('SUCCESS'), 'inform');
                 }
             }
         } else {
             $post = post_param('post', '');
             $title = post_param('title', '');
             if ($post != '') {
                 require_code('notifications');
                 dispatch_notification('new_feedback', $type, do_lang('NEW_FEEDBACK_SUBJECT', $title, NULL, NULL, get_site_default_lang()), do_lang('NEW_FEEDBACK_MESSAGE', $post, NULL, NULL, get_site_default_lang()));
                 $email_from = trim(post_param('email', $GLOBALS['FORUM_DRIVER']->get_member_email_address(get_member())));
                 if ($email_from != '') {
                     require_code('mail');
                     mail_wrap(do_lang('YOUR_MESSAGE_WAS_SENT_SUBJECT', $title), do_lang('YOUR_MESSAGE_WAS_SENT_BODY', $post), array($email_from), NULL, '', '', 3, NULL, false, get_member());
                 }
             }
         }
     }
     // Comment posts
     $forum = get_option('comments_forum_name');
     $count = 0;
     $_comments = $GLOBALS['FORUM_DRIVER']->get_forum_topic_posts($GLOBALS['FORUM_DRIVER']->find_topic_id_for_topic_identifier($forum, $type . '_' . $id), $count);
     if ($_comments !== -1) {
         $em = $GLOBALS['FORUM_DRIVER']->get_emoticon_chooser();
         require_javascript('javascript_editing');
         $comcode_help = build_url(array('page' => 'userguide_comcode'), get_comcode_zone('userguide_comcode', false));
         require_javascript('javascript_validation');
         $comment_url = get_self_url();
         if (addon_installed('captcha')) {
             require_code('captcha');
             $use_captcha = !$is_occle_talking && get_option('captcha_on_feedback') == '1' && use_captcha();
             if ($use_captcha) {
                 generate_captcha();
             }
         } else {
             $use_captcha = false;
         }
         $comment_details = do_template('COMMENTS_POSTING_FORM', array('_GUID' => '4ca32620f3eb68d9cc820b18265792d7', 'JOIN_BITS' => '', 'FIRST_POST_URL' => '', 'FIRST_POST' => '', 'USE_CAPTCHA' => $use_captcha, 'POST_WARNING' => get_param('post_warning', ''), 'COMMENT_TEXT' => '', 'GET_EMAIL' => false, 'EMAIL_OPTIONAL' => true, 'GET_TITLE' => true, 'EM' => $em, 'DISPLAY' => 'block', 'COMMENT_URL' => $comment_url, 'TITLE' => do_lang_tempcode('FEEDBACK')));
     } else {
         $comment_details = new ocp_tempcode();
     }
     $out->attach($comment_details);
     return $out;
 }
示例#9
0
/**
 * Get code to do an AJAX check of the CAPTCHA.
 *
 * @return string			Javascript code.
 */
function captcha_ajax_check()
{
    if (!use_captcha()) {
        return '';
    }
    require_javascript('javascript_ajax');
    $script = find_script('snippet');
    return "\n\t\tvar form=document.getElementById('main_form');\n\t\tif (!form) form=document.getElementById('posting_form');\n\t\tform.old_submit_b=form.onsubmit;\n\t\tform.onsubmit=function()\n\t\t\t{\n\t\t\t\tdocument.getElementById('submit_button').disabled=true;\n\t\t\t\tvar url='" . addslashes($script) . "?snippet=captcha_wrong&name='+window.encodeURIComponent(form.elements['security_image'].value);\n\t\t\t\tif (!do_ajax_field_test(url))\n\t\t\t\t{\n\t\t\t\t\tdocument.getElementById('captcha').src+='&'; // Force it to reload latest captcha\n\t\t\t\t\tdocument.getElementById('submit_button').disabled=false;\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tdocument.getElementById('submit_button').disabled=false;\n\t\t\t\tif (typeof form.old_submit_b!='undefined' && form.old_submit_b) return form.old_submit_b();\n\t\t\t\treturn true;\n\t\t\t};\n\t";
}
 /**
  * Get a preview(s) of a (group of) template(s), as a full standalone piece of HTML in Tempcode format.
  * Uses sources/lorem.php functions to place appropriate stock-text. Should not hard-code things, as the code is intended to be declaritive.
  * Assumptions: You can assume all Lang/CSS/Javascript files in this addon have been pre-required.
  *
  * @return array			Array of previews, each is Tempcode. Normally we have just one preview, but occasionally it is good to test templates are flexible (e.g. if they use IF_EMPTY, we can test with and without blank data).
  */
 function tpl_preview__comments_wrapper()
 {
     $review_titles = array();
     $review_titles[] = array('REVIEW_TITLE' => lorem_phrase(), 'REVIEW_RATING' => make_string_tempcode(float_format(10.0)));
     $comments = new ocp_tempcode();
     foreach (placeholder_array() as $i => $comment) {
         $map = array('INDIVIDUAL_REVIEW_RATINGS' => array(), 'HIGHLIGHT' => $i == 1, 'TITLE' => lorem_word(), 'TIME_RAW' => placeholder_number(), 'TIME' => placeholder_time(), 'POSTER_ID' => placeholder_id(), 'POSTER_URL' => placeholder_url(), 'POSTER_NAME' => lorem_word(), 'POSTER' => NULL, 'POSTER_DETAILS' => new ocp_tempcode(), 'ID' => placeholder_id() . strval($i), 'POST' => lorem_phrase(), 'POST_COMCODE' => lorem_phrase(), 'CHILDREN' => lorem_phrase(), 'OTHER_IDS' => array(placeholder_id()), 'RATING' => new ocp_tempcode(), 'EMPHASIS' => new ocp_tempcode(), 'BUTTONS' => new ocp_tempcode(), 'LAST_EDITED_RAW' => '', 'LAST_EDITED' => new ocp_tempcode(), 'UNVALIDATED' => new ocp_tempcode(), 'TOPIC_ID' => placeholder_id(), 'IS_SPACER_POST' => false, 'NUM_TO_SHOW_LIMIT' => placeholder_number());
         $comments->attach(do_lorem_template('POST', $map));
         do_lorem_template('POST_CHILD_LOAD_LINK', $map);
         // INCLUDE'd in above, but test set needs to see it run direct
     }
     if (addon_installed('captcha')) {
         require_code('captcha');
         $use_captcha = use_captcha();
     } else {
         $use_captcha = false;
     }
     $form = do_lorem_template('COMMENTS_POSTING_FORM', array('FIRST_POST_URL' => '', 'JOIN_BITS' => lorem_phrase_html(), 'FIRST_POST' => lorem_paragraph_html(), 'TYPE' => 'downloads', 'ID' => placeholder_id(), 'REVIEW_RATING_CRITERIA' => $review_titles, 'USE_CAPTCHA' => $use_captcha, 'GET_EMAIL' => false, 'EMAIL_OPTIONAL' => true, 'GET_TITLE' => true, 'POST_WARNING' => do_lang('POST_WARNING'), 'COMMENT_TEXT' => get_option('comment_text'), 'EM' => placeholder_emoticon_chooser(), 'DISPLAY' => 'block', 'COMMENT_URL' => placeholder_url(), 'TITLE' => lorem_word(), 'MAKE_POST' => true, 'CREATE_TICKET_MAKE_POST' => true));
     $out = do_lorem_template('COMMENTS_WRAPPER', array('TYPE' => lorem_phrase(), 'ID' => placeholder_id(), 'REVIEW_RATING_CRITERIA' => $review_titles, 'AUTHORISED_FORUM_LINK' => placeholder_url(), 'FORM' => $form, 'COMMENTS' => $comments));
     $out->attach(do_lorem_template('COMMENT_AJAX_HANDLER', array('OPTIONS' => lorem_phrase(), 'HASH' => lorem_phrase())));
     return array(lorem_globalise($out, NULL, '', true));
 }
示例#11
0
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     require_lang('messaging');
     require_code('feedback');
     $type = array_key_exists('param', $map) ? $map['param'] : do_lang('GENERAL');
     $id = uniqid('', true);
     $_self_url = build_url(array('page' => 'admin_messaging', 'type' => 'view', 'id' => $id, 'message_type' => $type), get_module_zone('admin_messaging'));
     $self_url = $_self_url->evaluate();
     $self_title = post_param('title', do_lang('CONTACT_US_MESSAGING'));
     $post = post_param('post', '');
     $title = post_param('title', '');
     $box_title = array_key_exists('title', $map) ? $map['title'] : do_lang('CONTACT_US');
     if (post_param_integer('_comment_form_post', 0) == 1 && $post != '') {
         $message = new ocp_tempcode();
         /*Used to be written out here*/
         attach_message(do_lang_tempcode('MESSAGE_SENT'), 'inform');
         // Check CAPTCHA
         if (addon_installed('captcha') && get_option('captcha_on_feedback') == '1') {
             require_code('captcha');
             enforce_captcha();
         }
         // Handle notifications
         require_code('notifications');
         $notification_subject = do_lang('CONTACT_US_NOTIFICATION_SUBJECT', $title, NULL, NULL, get_site_default_lang());
         $notification_message = do_lang('CONTACT_US_NOTIFICATION_MESSAGE', comcode_escape(get_site_name()), comcode_escape($GLOBALS['FORUM_DRIVER']->get_username(get_member())), array($post, comcode_escape($type)), get_site_default_lang());
         dispatch_notification('messaging', $type . '_' . $id, $notification_subject, $notification_message, NULL, NULL, 3, true);
         // Send standard confirmation email to current user
         $email_from = trim(post_param('email', $GLOBALS['FORUM_DRIVER']->get_member_email_address(get_member())));
         if ($email_from != '') {
             require_code('mail');
             mail_wrap(do_lang('YOUR_MESSAGE_WAS_SENT_SUBJECT', $title), do_lang('YOUR_MESSAGE_WAS_SENT_BODY', $post), array($email_from), NULL, '', '', 3, NULL, false, get_member());
         }
         decache('main_staff_checklist');
     } else {
         $message = new ocp_tempcode();
     }
     if (!has_no_forum()) {
         // Comment posts
         $forum = get_option('messaging_forum_name');
         $count = 0;
         $_comments = $GLOBALS['FORUM_DRIVER']->get_forum_topic_posts($GLOBALS['FORUM_DRIVER']->find_topic_id_for_topic_identifier($forum, $type . '_' . $id), $count);
         if ($_comments !== -1) {
             $em = $GLOBALS['FORUM_DRIVER']->get_emoticon_chooser();
             require_javascript('javascript_editing');
             $comcode_help = build_url(array('page' => 'userguide_comcode'), get_comcode_zone('userguide_comcode', false));
             require_javascript('javascript_validation');
             $comment_url = get_self_url();
             $email_optional = array_key_exists('email_optional', $map) ? intval($map['email_optional']) == 1 : true;
             if (addon_installed('captcha')) {
                 require_code('captcha');
                 $use_captcha = get_option('captcha_on_feedback') == '1' && use_captcha();
                 if ($use_captcha) {
                     generate_captcha();
                 }
             } else {
                 $use_captcha = false;
             }
             $comment_details = do_template('COMMENTS_POSTING_FORM', array('JOIN_BITS' => '', 'FIRST_POST_URL' => '', 'FIRST_POST' => '', 'USE_CAPTCHA' => $use_captcha, 'EMAIL_OPTIONAL' => $email_optional, 'POST_WARNING' => '', 'COMMENT_TEXT' => '', 'GET_EMAIL' => true, 'GET_TITLE' => true, 'EM' => $em, 'DISPLAY' => 'block', 'COMMENT_URL' => $comment_url, 'TITLE' => $box_title));
             $notifications_enabled = NULL;
             $notification_change_url = NULL;
             if (has_actual_page_access(get_member(), 'admin_messaging')) {
                 require_code('notifications');
                 $notifications_enabled = notifications_enabled('messaging', 'type', get_member());
             }
             $out = do_template('BLOCK_MAIN_CONTACT_US', array('_GUID' => 'fd269dce5ff984ee558e9052fa0150b0', 'COMMENT_DETAILS' => $comment_details, 'MESSAGE' => $message, 'NOTIFICATIONS_ENABLED' => $notifications_enabled, 'TYPE' => $type));
         } else {
             $out = new ocp_tempcode();
         }
     } else {
         $out = new ocp_tempcode();
     }
     return $out;
 }
示例#12
0
 function form()
 {
     $title = get_page_title('REPORT_CONTENT');
     require_code('form_templates');
     $url = get_param('url', false, true);
     $content_type = get_param('content_type');
     // Equates to a content_meta_aware hook
     $content_id = get_param('content_id');
     require_code('content');
     if (!is_null($GLOBALS['SITE_DB']->query_value_null_ok('reported_content', 'r_counts', array('r_session_id' => get_session_id(), 'r_content_type' => $content_type, 'r_content_id' => $content_id)))) {
         warn_exit(do_lang_tempcode('ALREADY_REPORTED_CONTENT'));
     }
     list($content_title, $poster_id, ) = content_get_details($content_type, $content_id);
     if ($content_title == '') {
         $content_title = $content_type . ' #' . $content_id;
     }
     $poster = $GLOBALS['FORUM_DRIVER']->get_username($poster_id);
     // Show form with input field and CAPTCHA, like forum's report post...
     $member = $poster;
     if (!is_guest($poster_id)) {
         $member = '[page type="view" id="' . strval($poster_id) . '" param="' . get_module_zone('members') . '" caption="' . $poster . '"]members[/page]';
     }
     $hidden_fields = build_keep_form_fields('', true);
     $text = paragraph(do_lang_tempcode('DESCRIPTION_REPORT_CONTENT', escape_html($content_title), escape_html(integer_format(intval(get_option('reported_times'))))));
     $specialisation = new ocp_tempcode();
     if (!is_guest()) {
         $options = array();
         if (get_option('is_on_anonymous_posts') == '1') {
             $options[] = array(do_lang_tempcode('_MAKE_ANONYMOUS_POST'), 'anonymous', false, do_lang_tempcode('MAKE_ANONYMOUS_POST_DESCRIPTION'));
         }
         $specialisation = form_input_various_ticks($options, '');
     } else {
         $specialisation = new ocp_tempcode();
     }
     if (addon_installed('captcha')) {
         require_code('captcha');
         if (use_captcha()) {
             $specialisation->attach(form_input_captcha());
             $text->attach(paragraph(do_lang_tempcode('FORM_TIME_SECURITY')));
         }
     }
     if (addon_installed('points')) {
         $login_url = build_url(array('page' => 'login', 'type' => 'misc', 'redirect' => get_self_url(true, true)), get_module_zone('login'));
         $_login_url = escape_html($login_url->evaluate());
         if (is_guest() && (get_forum_type() != 'ocf' || has_actual_page_access(get_member(), 'join'))) {
             $text->attach(paragraph(do_lang_tempcode('NOT_LOGGED_IN_NO_CREDIT', $_login_url)));
         }
     }
     $post_url = build_url(array('page' => '_SELF', 'type' => 'actual'), '_SELF');
     $post = do_template('REPORTED_CONTENT_FCOMCODE', array('URL' => $url, 'CONTENT_ID' => $content_id, 'MEMBER' => $member, 'CONTENT_TITLE' => $content_title, 'POSTER' => $poster));
     $posting_form = get_posting_form(do_lang('REPORT_CONTENT'), $post->evaluate(), $post_url, $hidden_fields, $specialisation, NULL, '', NULL, NULL, NULL, NULL, true, false);
     return do_template('POSTING_SCREEN', array('TITLE' => $title, 'JAVASCRIPT' => function_exists('captcha_ajax_check') ? captcha_ajax_check() : '', 'TEXT' => $text, 'POSTING_FORM' => $posting_form));
 }
示例#13
0
/**
 * Get the join form.
 *
 * @param  tempcode		URL to direct to
 * @param  boolean		Whether to handle CAPTCHA (if enabled at all)
 * @param  boolean		Whether to ask for intro messages (if enabled at all)
 * @param  boolean		Whether to check for invites (if enabled at all)
 * @param  boolean		Whether to check email-address restrictions (if enabled at all)
 * @return array			A tuple: Necessary Javascript code, the form
 */
function ocf_join_form($url, $captcha_if_enabled = true, $intro_message_if_enabled = true, $invites_if_enabled = true, $one_per_email_address_if_enabled = true)
{
    ocf_require_all_forum_stuff();
    require_css('ocf');
    require_code('ocf_members_action');
    require_code('ocf_members_action2');
    require_code('form_templates');
    $hidden = new ocp_tempcode();
    $hidden->attach(build_keep_post_fields());
    $groups = ocf_get_all_default_groups(true);
    $primary_group = either_param_integer('primary_group', NULL);
    if ($primary_group !== NULL && !in_array($primary_group, $groups)) {
        // Check security
        $test = $GLOBALS['FORUM_DB']->query_value('f_groups', 'g_is_presented_at_install', array('id' => $primary_group));
        if ($test == 1) {
            $groups = ocf_get_all_default_groups(false);
            $hidden = form_input_hidden('primary_group', strval($primary_group));
            $groups[] = $primary_group;
        }
    }
    list($fields, $_hidden) = ocf_get_member_fields(true, NULL, $groups);
    $hidden->attach($_hidden);
    if ($intro_message_if_enabled) {
        $forum_id = get_option('intro_forum_id');
        if ($forum_id != '') {
            $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('INTRODUCE_YOURSELF'))));
            $fields->attach(form_input_line(do_lang_tempcode('TITLE'), '', 'intro_title', do_lang('INTRO_POST_DEFAULT', '___'), false));
            $fields->attach(form_input_text_comcode(do_lang_tempcode('POST_COMMENT'), do_lang_tempcode('DESCRIPTION_INTRO_POST'), 'intro_post', '', false));
        }
    }
    $text = do_lang_tempcode('ENTER_PROFILE_DETAILS');
    if ($captcha_if_enabled) {
        if (addon_installed('captcha')) {
            require_code('captcha');
            if (use_captcha()) {
                $fields->attach(form_input_captcha());
                $text->attach(' ');
                $text->attach(do_lang_tempcode('FORM_TIME_SECURITY'));
            }
        }
    }
    $submit_name = do_lang_tempcode('PROCEED');
    require_javascript('javascript_ajax');
    $script = find_script('username_check');
    $javascript = "\n\t\tvar form=document.getElementById('username').form;\n\t\tform.elements['username'].onchange=function()\n\t\t{\n\t\t\tif (form.elements['intro_title'])\n\t\t\t\tform.elements['intro_title'].value='" . addslashes(do_lang('INTRO_POST_DEFAULT')) . "'.replace(/\\{1\\}/g,form.elements['username'].value);\n\t\t}\n\t\tform.old_submit=form.onsubmit;\n\t\tform.onsubmit=function()\n\t\t\t{\n\t\t\t\tif ((form.elements['email_address_confirm']) && (form.elements['email_address_confirm'].value!=form.elements['email_address'].value))\n\t\t\t\t{\n\t\t\t\t\twindow.fauxmodal_alert('" . php_addslashes(do_lang('EMAIL_ADDRESS_MISMATCH')) . "');\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tif ((form.elements['password_confirm']) && (form.elements['password_confirm'].value!=form.elements['password'].value))\n\t\t\t\t{\n\t\t\t\t\twindow.fauxmodal_alert('" . php_addslashes(do_lang('PASSWORD_MISMATCH')) . "');\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tdocument.getElementById('submit_button').disabled=true;\n\t\t\t\tvar url='" . addslashes($script) . "?username='******'username'].value);\n\t\t\t\tif (!do_ajax_field_test(url,'password='******'password'].value)))\n\t\t\t\t{\n\t\t\t\t\tdocument.getElementById('submit_button').disabled=false;\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t";
    $script = find_script('snippet');
    if ($invites_if_enabled) {
        if (get_option('is_on_invites') == '1') {
            $javascript .= "\n\t\t\t\t\turl='" . addslashes($script) . "?snippet=invite_missing&name='+window.encodeURIComponent(form.elements['email_address'].value);\n\t\t\t\t\tif (!do_ajax_field_test(url))\n\t\t\t\t\t{\n\t\t\t\t\t\tdocument.getElementById('submit_button').disabled=false;\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t";
        }
    }
    if ($one_per_email_address_if_enabled) {
        if (get_option('one_per_email_address') == '1') {
            $javascript .= "\n\t\t\t\t\turl='" . addslashes($script) . "?snippet=email_exists&name='+window.encodeURIComponent(form.elements['email_address'].value);\n\t\t\t\t\tif (!do_ajax_field_test(url))\n\t\t\t\t\t{\n\t\t\t\t\t\tdocument.getElementById('submit_button').disabled=false;\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t";
        }
    }
    if ($captcha_if_enabled) {
        if (addon_installed('captcha')) {
            require_code('captcha');
            if (use_captcha()) {
                $javascript .= "\n\t\t\t\t\t\turl='" . addslashes($script) . "?snippet=captcha_wrong&name='+window.encodeURIComponent(form.elements['security_image'].value);\n\t\t\t\t\t\tif (!do_ajax_field_test(url))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdocument.getElementById('submit_button').disabled=false;\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t";
            }
        }
    }
    $javascript .= "\n\t\t\t\tdocument.getElementById('submit_button').disabled=false;\n\t\t\t\tif (typeof form.old_submit!='undefined' && form.old_submit) return form.old_submit();\n\t\t\t\treturn true;\n\t\t\t};\n\t";
    $form = do_template('FORM', array('TEXT' => '', 'HIDDEN' => $hidden, 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name, 'URL' => $url));
    return array($javascript, $form);
}