<?php if (!defined('IN_AJAX')) { die(basename(__FILE__)); } global $user, $lang; $post_id = (int) @$this->request['post_id']; $topic_id = (int) @$this->request['topic_id']; if (!$post_id) { $post_id = DB()->fetch_row("SELECT topic_first_post_id FROM " . BB_TOPICS . " WHERE topic_id = {$topic_id}", 'topic_first_post_id'); } $sql = "\n\tSELECT\n\t p.*,\n\t h.post_html, IF(h.post_html IS NULL, pt.post_text, NULL) AS post_text,\n\t f.auth_read\n\tFROM " . BB_POSTS . " p\n\tINNER JOIN " . BB_POSTS_TEXT . " pt ON(pt.post_id = p.post_id)\n\t LEFT JOIN " . BB_POSTS_HTML . " h ON(h.post_id = pt.post_id)\n\tINNER JOIN " . BB_FORUMS . " f ON(f.forum_id = p.forum_id)\n\tWHERE\n\t p.post_id = {$post_id}\n\tLIMIT 1\n"; if (!($post_data = DB()->fetch_row($sql))) { $this->ajax_die($lang['TOPIC_POST_NOT_EXIST']); } // Auth check if ($post_data['auth_read'] == AUTH_REG) { if (IS_GUEST) { $this->ajax_die($lang['NEED_TO_LOGIN_FIRST']); } } elseif ($post_data['auth_read'] != AUTH_ALL) { $is_auth = auth(AUTH_READ, $post_data['forum_id'], $user->data, $post_data); if (!$is_auth['auth_read']) { $this->ajax_die($lang['TOPIC_POST_NOT_EXIST']); } } $this->response['post_id'] = $post_id; $this->response['topic_id'] = $topic_id; $this->response['post_html'] = get_parsed_post($post_data);
$poster = $postrow[$i]['post_username']; } // Buttons $pm_btn = $profile_btn = $delpost_btn = $edit_btn = $ip_btn = $quote_btn = ''; if ($poster_id != GUEST_UID) { $profile_btn = true; $pm_btn = true; } if ($poster_id != BOT_UID) { $quote_btn = true; $edit_btn = $userdata['user_id'] == $poster_id && $is_auth['auth_edit'] || $is_auth['auth_mod']; $ip_btn = $is_auth['auth_mod'] || IS_MOD; } $delpost_btn = $post_id != $t_data['topic_first_post_id'] && ($is_auth['auth_mod'] || $userdata['user_id'] == $poster_id && $is_auth['auth_delete'] && $t_data['topic_last_post_id'] == $post_id && $postrow[$i]['post_time'] + 3600 * 3 > TIMENOW); // Parse message and sig $message = get_parsed_post($postrow[$i]); $user_sig = $bb_cfg['allow_sig'] && !$user->opt_js['h_sig'] && $postrow[$i]['user_sig'] ? $postrow[$i]['user_sig'] : ''; if (bf($postrow[$i]['user_opt'], 'user_opt', 'dis_sig')) { $user_sig = $lang['SIGNATURE_DISABLE']; } elseif ($user_sig) { $user_sig = bbcode2html($user_sig); } // Replace naughty words if (count($orig_word)) { if ($user_sig) { $user_sig = str_replace('\\"', '"', substr(@preg_replace('#(\\>(((?>([^><]+|(?R)))*)\\<))#se', "@preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $user_sig . '<'), 1, -1)); } $message = str_replace('\\"', '"', substr(@preg_replace('#(\\>(((?>([^><]+|(?R)))*)\\<))#se', "@preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $message . '<'), 1, -1)); } // Replace newlines (we use this rather than nl2br because till recently it wasn't XHTML compliant) if ($user_sig) {
$notify_user = bf($userdata['user_opt'], 'user_opt', 'user_notify'); if (!IS_GUEST && $mode != 'newtopic' && !$notify_user) { $notify_user = (int) DB()->fetch_row("SELECT topic_id FROM " . BB_TOPICS_WATCH . " WHERE topic_id = {$topic_id} AND user_id = " . $userdata['user_id']); } } $update_post_time = !empty($_POST['update_post_time']); execute_posting_attachment_handling(); // если за время пока вы писали ответ, в топике появились новые сообщения, перед тем как ваше сообщение будет отправлено, выводится предупреждение с обзором этих сообщений $topic_has_new_posts = false; if (!IS_GUEST && $mode != 'newtopic' && ($submit || $preview || $mode == 'quote' || $mode == 'reply') && isset($_COOKIE[COOKIE_TOPIC])) { if ($topic_last_read = max(intval(@$tracking_topics[$topic_id]), intval(@$tracking_forums[$forum_id]))) { $sql = "SELECT p.*, pt.post_text, u.username, u.user_rank\n\t\t\tFROM " . BB_POSTS . " p, " . BB_POSTS_TEXT . " pt, " . BB_USERS . " u\n\t\t\tWHERE p.topic_id = " . (int) $topic_id . "\n\t\t\t\tAND u.user_id = p.poster_id\n\t\t\t\tAND pt.post_id = p.post_id\n\t\t\t\tAND p.post_time > {$topic_last_read}\n\t\t\tORDER BY p.post_time\n\t\t\tLIMIT " . $bb_cfg['posts_per_page']; if ($rowset = DB()->fetch_rowset($sql)) { $topic_has_new_posts = true; foreach ($rowset as $i => $row) { $template->assign_block_vars('new_posts', array('ROW_CLASS' => !($i % 2) ? 'row1' : 'row2', 'POSTER' => profile_url($row), 'POSTER_NAME_JS' => addslashes($row['username']), 'POST_DATE' => bb_date($row['post_time'], $bb_cfg['post_date_format']), 'MESSAGE' => get_parsed_post($row))); } $template->assign_vars(array('TPL_SHOW_NEW_POSTS' => true)); set_tracks(COOKIE_TOPIC, $tracking_topics, $topic_id); unset($rowset); } } } // -------------------- // What shall we do? // if (($delete || $mode == 'delete') && !$confirm) { if (isset($_POST['cancel'])) { redirect(POST_URL . "{$post_id}#{$post_id}"); } //
function topic_review($topic_id) { global $bb_cfg, $template; // Fetch posts data $review_posts = DB()->fetch_rowset("\n\t\tSELECT\n\t\t\tp.*, h.post_html, IF(h.post_html IS NULL, pt.post_text, NULL) AS post_text,\n\t\t\tIF(p.poster_id = " . GUEST_UID . ", p.post_username, u.username) AS username, u.user_rank\n\t\tFROM " . BB_POSTS . " p\n\t\tLEFT JOIN " . BB_USERS . " u ON(u.user_id = p.poster_id)\n\t\tLEFT JOIN " . BB_POSTS_TEXT . " pt ON(pt.post_id = p.post_id)\n\t\tLEFT JOIN " . BB_POSTS_HTML . " h ON(h.post_id = p.post_id)\n\t\tWHERE p.topic_id = " . (int) $topic_id . "\n\t\tORDER BY p.post_time DESC\n\t\tLIMIT " . $bb_cfg['posts_per_page'] . "\n\t"); // Topic posts block foreach ($review_posts as $i => $post) { $template->assign_block_vars('review', array('ROW_CLASS' => !($i % 2) ? 'row1' : 'row2', 'POSTER' => profile_url($post), 'POSTER_NAME_JS' => addslashes($post['username']), 'POST_DATE' => bb_date($post['post_time'], $bb_cfg['post_date_format']), 'MESSAGE' => get_parsed_post($post))); } $template->assign_vars(array('TPL_TOPIC_REVIEW' => (bool) $review_posts)); }
foreach ($sorted_rows as $topic_id => $topic_posts) { // Topic title block $first_post = $topic_posts[0]; $topic_id = (int) $topic_id; $forum_id = (int) $first_post['forum_id']; $is_unread_t = is_unread($first_post['topic_last_post_time'], $topic_id, $forum_id); $topic_title = $first_post['topic_title']; if (count($orig_word)) { $topic_title = preg_replace($orig_word, $replacement_word, $topic_title); } $template->assign_block_vars('t', array('FORUM_ID' => $forum_id, 'FORUM_NAME' => $forum_name_html[$forum_id], 'TOPIC_ID' => $topic_id, 'TOPIC_TITLE' => $topic_title, 'TOPIC_ICON' => get_topic_icon($first_post, $is_unread_t))); $quote_btn = true; $edit_btn = $delpost_btn = $ip_btn = IS_AM; // Topic posts block foreach ($topic_posts as $row_num => $post) { $message = get_parsed_post($post); if (count($orig_word)) { $message = preg_replace($orig_word, $replacement_word, $message); } $template->assign_block_vars('t.p', array('ROW_NUM' => $row_num, 'POSTER_ID' => $post['poster_id'], 'POSTER' => profile_url($post), 'POST_ID' => $post['post_id'], 'POST_DATE' => bb_date($post['post_time'], $bb_cfg['post_date_format']), 'IS_UNREAD' => is_unread($post['post_time'], $topic_id, $forum_id), 'MESSAGE' => $message, 'POSTED_AFTER' => '', 'QUOTE' => $quote_btn, 'EDIT' => $edit_btn, 'DELETE' => $delpost_btn, 'IP' => $ip_btn)); $curr_new_track_val = !empty($new_tracks[$topic_id]) ? $new_tracks[$topic_id] : 0; $new_tracks[$topic_id] = max($curr_new_track_val, $post['post_time']); } } set_tracks(COOKIE_TOPIC, $tracking_topics, $new_tracks); } else { $order = $order_opt[$order_val]['sql']; $sort = $sort_opt[$sort_val]['sql']; $per_page = $bb_cfg['topics_per_page']; $display_as_val = $as_topics; // Run initial search for topic_ids