/** * Strip BBCodes, tags and links from text * * @param string $message Message text * @return string Cleaned message text * @access protected */ protected function remove_markup($message) { $message = smiley_text($message, true); // display smileys as text :) $message = $this->strip_bbcode_contents($message); static $patterns = array(); if (empty($patterns)) { // RegEx patterns based on Topic Text Hover Mod by RMcGirr83 $patterns = array('#<!-- [lmw] --><a class="postlink[^>]*>(.*<\\/a[^>]*>)?<!-- [lmw] -->#Usi', '#<[^>]*>(.*<[^>]*>)?#Usi', '#\\[/?[^\\[\\]]+\\]#mi', '#(http|https|ftp|mailto)(:|\\&\\#58;)\\/\\/[^\\s]+#i', '#"#', '#[ \\t]{2,}#'); } return trim(preg_replace($patterns, ' ', $message)); }
function bbcode_strip($text) { static $RegEx = array(); static $bbcode_strip = 'flash'; // Save the smileys - show them as text :) $text = smiley_text($text, true); $text = str_replace(' ... ', '', $text); // remove ' ... ' from shortened urls so they can be stripped too if (empty($RegEx)) { $RegEx = array('#<[^>]*>(.*<[^>]*>)?#Usi', '#\\[(' . $bbcode_strip . ')[^\\[\\]]+\\].*\\[/(' . $bbcode_strip . ')[^\\[\\]]+\\]#Usi', '#\\[/?[^\\[\\]]+\\]#mi', '#(http|https|ftp|mailto)(:|\\&\\#58;)\\/\\/[^\\s]+#i', '#[\\s]+#'); } return trim(preg_replace($RegEx, ' ', $text)); }
/** * Trim and clean text * * @param string $message Message text * @param int $length The length to trim text to * * @return string Trimmed message text */ public function trim_text($message, $length) { // display smileys as text :) $message = smiley_text($message, true); /** @var tools\tool_interface $tool Run text through trim tools to strip out bbcodes and other markup */ foreach ($this->tools as $tool) { $message = $tool->set_text($message)->run(); } if (utf8_strlen($message) <= $length) { return $this->tp_nl2br($message); } // trim the text to the last whitespace character before the cut-off $message = preg_replace('/\\s+?(\\S+)?$/', '', utf8_substr($message, 0, $length)); return $this->tp_nl2br($message) . '...'; }
if ($config['load_user_activity']) { display_user_activity($member); } // Do the relevant calculations $memberdays = max(1, round((time() - $member['user_regdate']) / 86400)); $posts_per_day = $member['user_posts'] / $memberdays; $percentage = $config['num_posts'] ? min(100, $member['user_posts'] / $config['num_posts'] * 100) : 0; if ($member['user_sig']) { $member['user_sig'] = censor_text($member['user_sig']); if ($member['user_sig_bbcode_bitfield']) { include_once $phpbb_root_path . 'includes/bbcode.' . $phpEx; $bbcode = new bbcode(); $bbcode->bbcode_second_pass($member['user_sig'], $member['user_sig_bbcode_uid'], $member['user_sig_bbcode_bitfield']); } $member['user_sig'] = bbcode_nl2br($member['user_sig']); $member['user_sig'] = smiley_text($member['user_sig']); } $poster_avatar = get_user_avatar($member['user_avatar'], $member['user_avatar_type'], $member['user_avatar_width'], $member['user_avatar_height']); $template->assign_vars(show_profile($member)); // Custom Profile Fields $profile_fields = array(); if ($config['load_cpf_viewprofile']) { include_once $phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx; $cp = new custom_profile(); $profile_fields = $cp->generate_profile_fields_template('grab', $user_id); $profile_fields = isset($profile_fields[$user_id]) ? $cp->generate_profile_fields_template('show', false, $profile_fields[$user_id]) : array(); } // We need to check if the module 'zebra' is accessible $zebra_enabled = false; if ($user->data['user_id'] != $user_id && $user->data['is_registered']) { include_once $phpbb_root_path . 'includes/functions_module.' . $phpEx;
function get_forum_func($xmlrpc_params) { global $db, $auth, $user, $config, $mobiquo_config, $phpbb_home; $params = php_xmlrpc_decode($xmlrpc_params); $return_description = isset($params[0]) ? $params[0] : false; if (isset($params[1])) { $fid = intval($params[1]); $forum_filter = " WHERE f.parent_id = '{$fid}'"; $root_forum_id = $fid; } else { $forum_filter = ''; $root_forum_id = 0; } $user_watch_array = array(); if ($user->data['is_registered']) { $sql = "SELECT notify_status,forum_id FROM " . FORUMS_WATCH_TABLE . " WHERE user_id = '" . $user->data['user_id'] . "'"; $result_watch = $db->sql_query($sql); while ($row_watch = $db->sql_fetchrow($result_watch)) { if (isset($row_watch['notify_status']) && !is_null($row_watch['notify_status']) && $row_watch['notify_status'] !== '') { $user_watch_array[] = $row_watch['forum_id']; } } } $forum_rows = array(); $forum_rows[$root_forum_id] = array('forum_id' => $root_forum_id, 'parent_id' => -1, 'child' => array()); $forum_hide_forum_arr = !empty($mobiquo_config['hide_forum_id']) ? $mobiquo_config['hide_forum_id'] : array(); $sql = 'SELECT f.* FROM ' . FORUMS_TABLE . ' f ' . $forum_filter . ' ORDER BY f.left_id ASC'; $result = $db->sql_query($sql, 600); while ($row = $db->sql_fetchrow($result)) { $forum_id = $row['forum_id']; if ($row['forum_type'] == FORUM_CAT && $row['left_id'] + 1 == $row['right_id']) { // Non-postable forum with no subforums, don't display continue; } if (in_array($row['forum_id'], $forum_hide_forum_arr)) { continue; } elseif (in_array($row['parent_id'], $forum_hide_forum_arr)) { array_push($forum_hide_forum_arr, $row['forum_id']); continue; } // Skip branch if (isset($right_id)) { if ($row['left_id'] < $right_id) { continue; } unset($right_id); } if (!$auth->acl_get('f_list', $forum_id) || isset($mobiquo_config['hide_forum_id']) && in_array($forum_id, $mobiquo_config['hide_forum_id'])) { // if the user does not have permissions to list this forum, skip everything until next branch $right_id = $row['right_id']; continue; } $row['unread_count'] = 0; if ($user->data['is_registered'] && ($config['email_enable'] || $config['jab_enable']) && $config['allow_forum_notify'] && $row['forum_type'] == FORUM_POST && $auth->acl_get('f_subscribe', $forum_id)) { $row['can_subscribe'] = true; $row['is_subscribed'] = in_array($row['forum_id'], $user_watch_array) ? true : false; } else { $row['can_subscribe'] = false; $row['is_subscribed'] = false; } $forum_rows[$forum_id] = $row; } $db->sql_freeresult($result); $fids = array(-1); foreach ($forum_rows as $id => $value) { if (!in_array($value['parent_id'], $fids)) { unset($forum_rows[$id]); } else { if ($value['left_id'] > $value['right_id']) { unset($forum_rows[$id]); } else { $fids[] = $id; } } } while (empty($forum_rows[$root_forum_id]['child']) && count($forum_rows) > 1) { $current_parent_id = -1; $leaves_forum = array(); foreach ($forum_rows as $row) { $row_parent_id = $row['parent_id']; if ($row_parent_id != $current_parent_id) { if (isset($leaves_forum[$row_parent_id])) { $leaves_forum[$row_parent_id] = array(); } else { if (isset($leaves_forum[$forum_rows[$row_parent_id]['parent_id']])) { $leaves_forum[$forum_rows[$row_parent_id]['parent_id']] = array(); } $leaves_forum[$row_parent_id][] = $row['forum_id']; } $current_parent_id = $row_parent_id; } else { if ($row_parent_id == $current_parent_id) { if (!empty($leaves_forum[$row_parent_id])) { $leaves_forum[$row_parent_id][] = $row['forum_id']; } } } } foreach ($leaves_forum as $node_forum_id => $leaves) { foreach ($leaves as $forum_id) { $forum =& $forum_rows[$forum_id]; if (function_exists('get_unread_topics')) { $unread_count = count(get_unread_topics(false, "AND t.forum_id = {$forum_id}")); } else { $unread_count = count(tt_get_unread_topics(false, "AND t.forum_id = {$forum_id}")); } $forum['unread_count'] += $unread_count; if ($forum['unread_count']) { $forum_rows[$forum['parent_id']]['unread_count'] += $forum['unread_count']; } $forum_type = $forum['forum_link'] ? 'link' : ($forum['forum_type'] != FORUM_POST ? 'category' : 'forum'); if ($logo_icon_name = tp_get_forum_icon($forum_id, $forum_type, $forum['forum_status'], $forum['unread_count'])) { $logo_url = $phpbb_home . $config['tapatalkdir'] . '/forum_icons/' . $logo_icon_name; } else { if ($forum['forum_image']) { if (preg_match('#^https?://#i', $forum['forum_image'])) { $logo_url = $forum['forum_image']; } else { $logo_url = $phpbb_home . $forum['forum_image']; } } else { $logo_url = ''; } } $xmlrpc_forum = array('forum_id' => new xmlrpcval($forum_id), 'forum_name' => new xmlrpcval(basic_clean($forum['forum_name']), 'base64'), 'parent_id' => new xmlrpcval($node_forum_id), 'logo_url' => new xmlrpcval($logo_url), 'url' => new xmlrpcval($forum['forum_link'])); if ($forum['unread_count']) { $xmlrpc_forum['unread_count'] = new xmlrpcval($forum['unread_count'], 'int'); } if ($forum['unread_count']) { $xmlrpc_forum['new_post'] = new xmlrpcval(true, 'boolean'); } if ($forum['forum_password']) { $xmlrpc_forum['is_protected'] = new xmlrpcval(true, 'boolean'); } if (!empty($forum['can_subscribe'])) { $xmlrpc_forum['can_subscribe'] = new xmlrpcval(true, 'boolean'); } else { $xmlrpc_forum['can_subscribe'] = new xmlrpcval(false, 'boolean'); } if (!empty($forum['is_subscribed'])) { $xmlrpc_forum['is_subscribed'] = new xmlrpcval(true, 'boolean'); } else { $xmlrpc_forum['is_subscribed'] = new xmlrpcval(false, 'boolean'); } if ($forum['forum_type'] != FORUM_POST) { $xmlrpc_forum['sub_only'] = new xmlrpcval(true, 'boolean'); } if ($return_description) { $description = smiley_text($forum['forum_desc'], true); $description = generate_text_for_display($description, $forum['forum_desc_uid'], $forum['forum_desc_bitfield'], $forum['forum_desc_options']); $description = preg_replace('/<br *?\\/?>/i', "\n", $description); $xmlrpc_forum['description'] = new xmlrpcval(basic_clean($description), 'base64'); } if (isset($forum['child'])) { $xmlrpc_forum['child'] = new xmlrpcval($forum['child'], 'array'); } $forum_rows[$node_forum_id]['child'][] = new xmlrpcval($xmlrpc_forum, 'struct'); unset($forum_rows[$forum_id]); } } } $response = new xmlrpcval($forum_rows[$root_forum_id]['child'], 'array'); return new xmlrpcresp($response); }
function main($id, $mode) { global $auth, $db, $user, $template, $cache; global $config, $phpbb_root_path, $phpEx, $action; include_once $phpbb_root_path . 'includes/functions_posting.' . $phpEx; $forum_id = request_var('f', 0); $start = request_var('start', 0); $this->page_title = 'MCP_REPORTS'; switch ($action) { case 'close': case 'delete': include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx; $report_id_list = request_var('report_id_list', array(0)); if (!sizeof($report_id_list)) { trigger_error('NO_REPORT_SELECTED'); } close_report($report_id_list, $mode, $action); break; } switch ($mode) { case 'report_details': $user->add_lang(array('posting', 'viewforum', 'viewtopic')); $post_id = request_var('p', 0); // closed reports are accessed by report id $report_id = request_var('r', 0); $sql = 'SELECT r.post_id, r.user_id, r.report_id, r.report_closed, report_time, r.report_text, rr.reason_title, rr.reason_description, u.username, u.username_clean, u.user_colour FROM ' . REPORTS_TABLE . ' r, ' . REPORTS_REASONS_TABLE . ' rr, ' . USERS_TABLE . ' u WHERE ' . ($report_id ? 'r.report_id = ' . $report_id : "r.post_id = {$post_id}") . ' AND rr.reason_id = r.reason_id AND r.user_id = u.user_id AND r.pm_id = 0 ORDER BY report_closed ASC'; $result = $db->sql_query_limit($sql, 1); $report = $db->sql_fetchrow($result); $db->sql_freeresult($result); if (!$report) { trigger_error('NO_REPORT'); } if (!$report_id && $report['report_closed']) { trigger_error('REPORT_CLOSED'); } $post_id = $report['post_id']; $report_id = $report['report_id']; $post_info = get_post_data(array($post_id), 'm_report', true); if (!sizeof($post_info)) { trigger_error('NO_REPORT_SELECTED'); } $post_info = $post_info[$post_id]; $reason = array('title' => $report['reason_title'], 'description' => $report['reason_description']); if (isset($user->lang['report_reasons']['TITLE'][strtoupper($reason['title'])]) && isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($reason['title'])])) { $reason['description'] = $user->lang['report_reasons']['DESCRIPTION'][strtoupper($reason['title'])]; $reason['title'] = $user->lang['report_reasons']['TITLE'][strtoupper($reason['title'])]; } if (topic_review($post_info['topic_id'], $post_info['forum_id'], 'topic_review', 0, false)) { $template->assign_vars(array('S_TOPIC_REVIEW' => true, 'S_BBCODE_ALLOWED' => $post_info['enable_bbcode'], 'TOPIC_TITLE' => $post_info['topic_title'])); } $topic_tracking_info = $extensions = $attachments = array(); // Get topic tracking info if ($config['load_db_lastread']) { $tmp_topic_data = array($post_info['topic_id'] => $post_info); $topic_tracking_info = get_topic_tracking($post_info['forum_id'], $post_info['topic_id'], $tmp_topic_data, array($post_info['forum_id'] => $post_info['forum_mark_time'])); unset($tmp_topic_data); } else { $topic_tracking_info = get_complete_topic_tracking($post_info['forum_id'], $post_info['topic_id']); } $post_unread = isset($topic_tracking_info[$post_info['topic_id']]) && $post_info['post_time'] > $topic_tracking_info[$post_info['topic_id']] ? true : false; // Process message, leave it uncensored $message = $post_info['post_text']; if ($post_info['bbcode_bitfield']) { include_once $phpbb_root_path . 'includes/bbcode.' . $phpEx; $bbcode = new bbcode($post_info['bbcode_bitfield']); $bbcode->bbcode_second_pass($message, $post_info['bbcode_uid'], $post_info['bbcode_bitfield']); } $message = bbcode_nl2br($message); $message = smiley_text($message); if ($post_info['post_attachment'] && $auth->acl_get('u_download') && $auth->acl_get('f_download', $post_info['forum_id'])) { $sql = 'SELECT * FROM ' . ATTACHMENTS_TABLE . ' WHERE post_msg_id = ' . $post_id . ' AND in_message = 0 ORDER BY filetime DESC'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $attachments[] = $row; } $db->sql_freeresult($result); if (sizeof($attachments)) { $update_count = array(); parse_attachments($post_info['forum_id'], $message, $attachments, $update_count); } // Display not already displayed Attachments for this post, we already parsed them. ;) if (!empty($attachments)) { $template->assign_var('S_HAS_ATTACHMENTS', true); foreach ($attachments as $attachment) { $template->assign_block_vars('attachment', array('DISPLAY_ATTACHMENT' => $attachment)); } } } $template->assign_vars(array('S_MCP_REPORT' => true, 'S_CLOSE_ACTION' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=reports&mode=report_details&f=' . $post_info['forum_id'] . '&p=' . $post_id), 'S_CAN_VIEWIP' => $auth->acl_get('m_info', $post_info['forum_id']), 'S_POST_REPORTED' => $post_info['post_reported'], 'S_POST_UNAPPROVED' => !$post_info['post_approved'], 'S_POST_LOCKED' => $post_info['post_edit_locked'], 'S_USER_NOTES' => true, 'U_EDIT' => $auth->acl_get('m_edit', $post_info['forum_id']) ? append_sid("{$phpbb_root_path}posting.{$phpEx}", "mode=edit&f={$post_info['forum_id']}&p={$post_info['post_id']}") : '', 'U_MCP_APPROVE' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue&mode=approve_details&f=' . $post_info['forum_id'] . '&p=' . $post_id), 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=reports&mode=report_details&f=' . $post_info['forum_id'] . '&p=' . $post_id), 'U_MCP_REPORTER_NOTES' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=notes&mode=user_notes&u=' . $report['user_id']), 'U_MCP_USER_NOTES' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=notes&mode=user_notes&u=' . $post_info['user_id']), 'U_MCP_WARN_REPORTER' => $auth->acl_get('m_warn') ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=warn&mode=warn_user&u=' . $report['user_id']) : '', 'U_MCP_WARN_USER' => $auth->acl_get('m_warn') ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=warn&mode=warn_user&u=' . $post_info['user_id']) : '', 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $post_info['forum_id']), 'U_VIEW_POST' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $post_info['forum_id'] . '&p=' . $post_info['post_id'] . '#p' . $post_info['post_id']), 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $post_info['forum_id'] . '&t=' . $post_info['topic_id']), 'EDIT_IMG' => $user->img('icon_post_edit', $user->lang['EDIT_POST']), 'MINI_POST_IMG' => $post_unread ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'), 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', $user->lang['POST_UNAPPROVED']), 'RETURN_REPORTS' => sprintf($user->lang['RETURN_REPORTS'], '<a href="' . append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=reports' . ($post_info['post_reported'] ? '&mode=reports' : '&mode=reports_closed') . '&start=' . $start . '&f=' . $post_info['forum_id']) . '">', '</a>'), 'REPORTED_IMG' => $user->img('icon_topic_reported', $user->lang['POST_REPORTED']), 'REPORT_DATE' => $user->format_date($report['report_time']), 'REPORT_ID' => $report_id, 'REPORT_REASON_TITLE' => $reason['title'], 'REPORT_REASON_DESCRIPTION' => $reason['description'], 'REPORT_TEXT' => $report['report_text'], 'POST_AUTHOR_FULL' => get_username_string('full', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), 'POST_AUTHOR_COLOUR' => get_username_string('colour', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), 'POST_AUTHOR' => get_username_string('username', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), 'U_POST_AUTHOR' => get_username_string('profile', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), 'REPORTER_FULL' => get_username_string('full', $report['user_id'], $report['username'], $report['user_colour']), 'REPORTER_COLOUR' => get_username_string('colour', $report['user_id'], $report['username'], $report['user_colour']), 'REPORTER_NAME' => get_username_string('username', $report['user_id'], $report['username'], $report['user_colour']), 'U_VIEW_REPORTER_PROFILE' => get_username_string('profile', $report['user_id'], $report['username'], $report['user_colour']), 'POST_PREVIEW' => $message, 'POST_SUBJECT' => $post_info['post_subject'] ? $post_info['post_subject'] : $user->lang['NO_SUBJECT'], 'POST_DATE' => $user->format_date($post_info['post_time']), 'POST_IP' => $post_info['poster_ip'], 'POST_IPADDR' => $auth->acl_get('m_info', $post_info['forum_id']) && request_var('lookup', '') ? @gethostbyaddr($post_info['poster_ip']) : '', 'POST_ID' => $post_info['post_id'], 'U_LOOKUP_IP' => $auth->acl_get('m_info', $post_info['forum_id']) ? $this->u_action . '&r=' . $report_id . '&p=' . $post_id . '&f=' . $forum_id . '&lookup=' . $post_info['poster_ip'] . '#ip' : '')); $this->tpl_name = 'mcp_post'; break; case 'reports': case 'reports_closed': $topic_id = request_var('t', 0); $forum_info = array(); $forum_list_reports = get_forum_list('m_report', false, true); $forum_list_read = array_flip(get_forum_list('f_read', true, true)); // Flipped so we can isset() the forum IDs // Remove forums we cannot read foreach ($forum_list_reports as $k => $forum_data) { if (!isset($forum_list_read[$forum_data['forum_id']])) { unset($forum_list_reports[$k]); } } unset($forum_list_read); if ($topic_id) { $topic_info = get_topic_data(array($topic_id)); if (!sizeof($topic_info)) { trigger_error('TOPIC_NOT_EXIST'); } if ($forum_id != $topic_info[$topic_id]['forum_id']) { $topic_id = 0; } else { $topic_info = $topic_info[$topic_id]; $forum_id = (int) $topic_info['forum_id']; } } $forum_list = array(); if (!$forum_id) { foreach ($forum_list_reports as $row) { $forum_list[] = $row['forum_id']; } if (!sizeof($forum_list)) { trigger_error('NOT_MODERATOR'); } $global_id = $forum_list[0]; $sql = 'SELECT SUM(forum_topics) as sum_forum_topics FROM ' . FORUMS_TABLE . ' WHERE ' . $db->sql_in_set('forum_id', $forum_list); $result = $db->sql_query($sql); $forum_info['forum_topics'] = (int) $db->sql_fetchfield('sum_forum_topics'); $db->sql_freeresult($result); } else { $forum_info = get_forum_data(array($forum_id), 'm_report'); if (!sizeof($forum_info)) { trigger_error('NOT_MODERATOR'); } $forum_info = $forum_info[$forum_id]; $forum_list = array($forum_id); $global_id = $forum_id; } $forum_list[] = 0; $forum_data = array(); $forum_options = '<option value="0"' . ($forum_id == 0 ? ' selected="selected"' : '') . '>' . $user->lang['ALL_FORUMS'] . '</option>'; foreach ($forum_list_reports as $row) { $forum_options .= '<option value="' . $row['forum_id'] . '"' . ($forum_id == $row['forum_id'] ? ' selected="selected"' : '') . '>' . str_repeat(' ', $row['padding']) . $row['forum_name'] . '</option>'; $forum_data[$row['forum_id']] = $row; } unset($forum_list_reports); $sort_days = $total = 0; $sort_key = $sort_dir = ''; $sort_by_sql = $sort_order_sql = array(); mcp_sorting($mode, $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $forum_id, $topic_id); $forum_topics = $total == -1 ? $forum_info['forum_topics'] : $total; $limit_time_sql = $sort_days ? 'AND r.report_time >= ' . (time() - $sort_days * 86400) : ''; if ($mode == 'reports') { $report_state = 'AND p.post_reported = 1 AND r.report_closed = 0'; } else { $report_state = 'AND r.report_closed = 1'; } $sql = 'SELECT r.report_id FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . REPORTS_TABLE . ' r ' . ($sort_order_sql[0] == 'u' ? ', ' . USERS_TABLE . ' u' : '') . ($sort_order_sql[0] == 'r' ? ', ' . USERS_TABLE . ' ru' : '') . ' WHERE ' . $db->sql_in_set('p.forum_id', $forum_list) . "\n\t\t\t\t\t\t{$report_state}\n\t\t\t\t\t\tAND r.post_id = p.post_id\n\t\t\t\t\t\t" . ($sort_order_sql[0] == 'u' ? 'AND u.user_id = p.poster_id' : '') . ' ' . ($sort_order_sql[0] == 'r' ? 'AND ru.user_id = r.user_id' : '') . ' ' . ($topic_id ? 'AND p.topic_id = ' . $topic_id : '') . "\n\t\t\t\t\t\tAND t.topic_id = p.topic_id\n\t\t\t\t\t\tAND r.pm_id = 0\n\t\t\t\t\t\t{$limit_time_sql}\n\t\t\t\t\tORDER BY {$sort_order_sql}"; $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); $i = 0; $report_ids = array(); while ($row = $db->sql_fetchrow($result)) { $report_ids[] = $row['report_id']; $row_num[$row['report_id']] = $i++; } $db->sql_freeresult($result); if (sizeof($report_ids)) { $sql = 'SELECT t.forum_id, t.topic_id, t.topic_title, p.post_id, p.post_subject, p.post_username, p.poster_id, p.post_time, u.username, u.username_clean, u.user_colour, r.user_id as reporter_id, ru.username as reporter_name, ru.user_colour as reporter_colour, r.report_time, r.report_id FROM ' . REPORTS_TABLE . ' r, ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . ' u, ' . USERS_TABLE . ' ru WHERE ' . $db->sql_in_set('r.report_id', $report_ids) . ' AND t.topic_id = p.topic_id AND r.post_id = p.post_id AND u.user_id = p.poster_id AND ru.user_id = r.user_id AND r.pm_id = 0 ORDER BY ' . $sort_order_sql; $result = $db->sql_query($sql); $report_data = $rowset = array(); while ($row = $db->sql_fetchrow($result)) { $global_topic = $row['forum_id'] ? false : true; if ($global_topic) { $row['forum_id'] = $global_id; } $template->assign_block_vars('postrow', array('U_VIEWFORUM' => !$global_topic ? append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $row['forum_id']) : '', 'U_VIEWPOST' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $row['forum_id'] . '&p=' . $row['post_id']) . '#p' . $row['post_id'], 'U_VIEW_DETAILS' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i=reports&start={$start}&mode=report_details&f={$row['forum_id']}&r={$row['report_id']}"), 'POST_AUTHOR_FULL' => get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_AUTHOR_COLOUR' => get_username_string('colour', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_AUTHOR' => get_username_string('username', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'U_POST_AUTHOR' => get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'REPORTER_FULL' => get_username_string('full', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), 'REPORTER_COLOUR' => get_username_string('colour', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), 'REPORTER' => get_username_string('username', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), 'U_REPORTER' => get_username_string('profile', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), 'FORUM_NAME' => !$global_topic ? $forum_data[$row['forum_id']]['forum_name'] : $user->lang['GLOBAL_ANNOUNCEMENT'], 'POST_ID' => $row['post_id'], 'POST_SUBJECT' => $row['post_subject'] ? $row['post_subject'] : $user->lang['NO_SUBJECT'], 'POST_TIME' => $user->format_date($row['post_time']), 'REPORT_ID' => $row['report_id'], 'REPORT_TIME' => $user->format_date($row['report_time']), 'TOPIC_TITLE' => $row['topic_title'])); } $db->sql_freeresult($result); unset($report_ids, $row); } // Now display the page $template->assign_vars(array('L_EXPLAIN' => $mode == 'reports' ? $user->lang['MCP_REPORTS_OPEN_EXPLAIN'] : $user->lang['MCP_REPORTS_CLOSED_EXPLAIN'], 'L_TITLE' => $mode == 'reports' ? $user->lang['MCP_REPORTS_OPEN'] : $user->lang['MCP_REPORTS_CLOSED'], 'L_ONLY_TOPIC' => $topic_id ? sprintf($user->lang['ONLY_TOPIC'], $topic_info['topic_title']) : '', 'S_MCP_ACTION' => $this->u_action, 'S_FORUM_OPTIONS' => $forum_options, 'S_CLOSED' => $mode == 'reports_closed' ? true : false, 'PAGINATION' => generate_pagination($this->u_action . "&f={$forum_id}&t={$topic_id}&st={$sort_days}&sk={$sort_key}&sd={$sort_dir}", $total, $config['topics_per_page'], $start), 'PAGE_NUMBER' => on_page($total, $config['topics_per_page'], $start), 'TOPIC_ID' => $topic_id, 'TOTAL' => $total, 'TOTAL_REPORTS' => $total == 1 ? $user->lang['LIST_REPORT'] : sprintf($user->lang['LIST_REPORTS'], $total))); $this->tpl_name = 'mcp_reports'; break; } }
/** * Handles warning the user when the warning is for a specific post */ function mcp_warn_post_view($action) { global $phpEx, $phpbb_root_path, $config; global $template, $db, $user, $auth; $post_id = request_var('p', 0); $forum_id = request_var('f', 0); $notify = (isset($_REQUEST['notify_user'])) ? true : false; $warning = utf8_normalize_nfc(request_var('warning', '', true)); $sql = 'SELECT u.*, p.* FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . " u WHERE post_id = $post_id AND u.user_id = p.poster_id"; $result = $db->sql_query($sql); $user_row = $db->sql_fetchrow($result); $db->sql_freeresult($result); if (!$user_row) { trigger_error('NO_POST'); } // There is no point issuing a warning to ignored users (ie anonymous and bots) if ($user_row['user_type'] == USER_IGNORE) { trigger_error('CANNOT_WARN_ANONYMOUS'); } // Prevent someone from warning themselves if ($user_row['user_id'] == $user->data['user_id']) { trigger_error('CANNOT_WARN_SELF'); } // Check if there is already a warning for this post to prevent multiple // warnings for the same offence $sql = 'SELECT post_id FROM ' . WARNINGS_TABLE . " WHERE post_id = $post_id"; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); if ($row) { trigger_error('ALREADY_WARNED'); } $user_id = $user_row['user_id']; if (strpos($this->u_action, "&f=$forum_id&p=$post_id") === false) { $this->p_master->adjust_url("&f=$forum_id&p=$post_id"); $this->u_action .= "&f=$forum_id&p=$post_id"; } if ($warning && $action == 'add_warning') { if (check_form_key('mcp_warn')) { add_warning($user_row, $warning, $notify, $post_id); $msg = $user->lang['USER_WARNING_ADDED']; } else { $msg = $user->lang['FORM_INVALID']; } $redirect = append_sid("{$phpbb_root_path}mcp.$phpEx", "i=notes&mode=user_notes&u=$user_id"); meta_refresh(2, $redirect); trigger_error($user->lang['USER_WARNING_ADDED'] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>')); } // OK, they didn't submit a warning so lets build the page for them to do so // We want to make the message available here as a reminder // Parse the message and subject $message = censor_text($user_row['post_text']); // Second parse bbcode here if ($user_row['bbcode_bitfield']) { include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx); $bbcode = new bbcode($user_row['bbcode_bitfield']); $bbcode->bbcode_second_pass($message, $user_row['bbcode_uid'], $user_row['bbcode_bitfield']); } $message = bbcode_nl2br($message); $message = smiley_text($message); // Generate the appropriate user information for the user we are looking at if (!function_exists('get_user_avatar')) { include($phpbb_root_path . 'includes/functions_display.' . $phpEx); } $rank_title = $rank_img = ''; $avatar_img = get_user_avatar($user_row['user_avatar'], $user_row['user_avatar_type'], $user_row['user_avatar_width'], $user_row['user_avatar_height']); $template->assign_vars(array( 'U_POST_ACTION' => $this->u_action, 'POST' => $message, 'USERNAME' => $user_row['username'], 'USER_COLOR' => (!empty($user_row['user_colour'])) ? $user_row['user_colour'] : '', 'RANK_TITLE' => $rank_title, 'JOINED' => $user->format_date($user_row['user_regdate']), 'POSTS' => ($user_row['user_posts']) ? $user_row['user_posts'] : 0, 'WARNINGS' => ($user_row['user_warnings']) ? $user_row['user_warnings'] : 0, 'AVATAR_IMG' => $avatar_img, 'RANK_IMG' => $rank_img, 'L_WARNING_POST_DEFAULT' => sprintf($user->lang['WARNING_POST_DEFAULT'], generate_board_url() . "/viewtopic.$phpEx?f=$forum_id&p=$post_id#p$post_id"), )); }
if ($row['display_text_only']) { // now find context for the searched words $row['post_text'] = get_context($row['post_text'], array_filter(explode('|', $hilit), 'strlen'), $return_chars); $row['post_text'] = bbcode_nl2br($row['post_text']); } else { // Second parse bbcode here if ($row['bbcode_bitfield']) { $bbcode->bbcode_second_pass($row['post_text'], $row['bbcode_uid'], $row['bbcode_bitfield']); } $row['post_text'] = bbcode_nl2br($row['post_text']); $row['post_text'] = smiley_text($row['post_text']); if (!empty($attachments[$row['post_id']])) { parse_attachments($forum_id, $row['post_text'], $attachments[$row['post_id']], $update_count); // we only display inline attachments unset($attachments[$row['post_id']]); } } if ($hilit) { // post highlighting $row['post_text'] = preg_replace('#(?!<.*)(?<!\w)(' . $hilit . ')(?!\w|[^<>]*(?:</s(?:cript|tyle))?>)#is', '<span class="posthilit">$1</span>', $row['post_text']); $row['post_subject'] = preg_replace('#(?!<.*)(?<!\w)(' . $hilit . ')(?!\w|[^<>]*(?:</s(?:cript|tyle))?>)#is', '<span class="posthilit">$1</span>', $row['post_subject']);
/** * For display of custom parsed text on user-facing pages * Expects $text to be the value directly from the database (stored value) */ function generate_text_for_display($text, $uid, $bitfield, $flags, $censor_text = true) { static $bbcode; global $phpbb_dispatcher; if ($text === '') { return ''; } /** * Use this event to modify the text before it is parsed * * @event core.modify_text_for_display_before * @var string text The text to parse * @var string uid The BBCode UID * @var string bitfield The BBCode Bitfield * @var int flags The BBCode Flags * @var bool censor_text Whether or not to apply word censors * @since 3.1.0-a1 */ $vars = array('text', 'uid', 'bitfield', 'flags', 'censor_text'); extract($phpbb_dispatcher->trigger_event('core.modify_text_for_display_before', compact($vars))); if ($censor_text) { $text = censor_text($text); } // Parse bbcode if bbcode uid stored and bbcode enabled if ($uid && $flags & OPTION_FLAG_BBCODE) { if (!class_exists('bbcode')) { global $phpbb_root_path, $phpEx; include $phpbb_root_path . 'includes/bbcode.' . $phpEx; } if (empty($bbcode)) { $bbcode = new bbcode($bitfield); } else { $bbcode->bbcode($bitfield); } $bbcode->bbcode_second_pass($text, $uid); } $text = bbcode_nl2br($text); $text = smiley_text($text, !($flags & OPTION_FLAG_SMILIES)); /** * Use this event to modify the text after it is parsed * * @event core.modify_text_for_display_after * @var string text The text to parse * @var string uid The BBCode UID * @var string bitfield The BBCode Bitfield * @var int flags The BBCode Flags * @since 3.1.0-a1 */ $vars = array('text', 'uid', 'bitfield', 'flags'); extract($phpbb_dispatcher->trigger_event('core.modify_text_for_display_after', compact($vars))); return $text; }
function main($id, $mode) { global $auth, $db, $user, $template; global $config, $phpbb_root_path, $phpEx, $action; include_once $phpbb_root_path . 'includes/functions_posting.' . $phpEx; $forum_id = request_var('f', 0); $start = request_var('start', 0); $this->page_title = 'MCP_QUEUE'; switch ($action) { case 'approve': case 'disapprove': include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx; $post_id_list = request_var('post_id_list', array(0)); if (!sizeof($post_id_list)) { trigger_error('NO_POST_SELECTED'); } if ($action == 'approve') { approve_post($post_id_list, $mode); } else { disapprove_post($post_id_list, $mode); } break; } switch ($mode) { case 'approve_details': $user->add_lang('posting'); $post_id = request_var('p', 0); $topic_id = request_var('t', 0); if ($topic_id) { $topic_info = get_topic_data(array($topic_id), 'm_approve'); if (isset($topic_info[$topic_id]['topic_first_post_id'])) { $post_id = (int) $topic_info[$topic_id]['topic_first_post_id']; } else { $topic_id = 0; } } $post_info = get_post_data(array($post_id), 'm_approve'); if (!sizeof($post_info)) { trigger_error('NO_POST_SELECTED'); } $post_info = $post_info[$post_id]; if ($post_info['topic_first_post_id'] != $post_id && topic_review($post_info['topic_id'], $post_info['forum_id'], 'topic_review', 0, false)) { $template->assign_vars(array('S_TOPIC_REVIEW' => true, 'TOPIC_TITLE' => $post_info['topic_title'])); } // Set some vars if ($post_info['user_id'] == ANONYMOUS) { $poster = $post_info['post_username'] ? $post_info['post_username'] : $user->lang['GUEST']; } $poster = $post_info['user_colour'] ? '<span style="color:#' . $post_info['user_colour'] . '">' . $post_info['username'] . '</span>' : $post_info['username']; // Process message, leave it uncensored $message = $post_info['post_text']; if ($post_info['bbcode_bitfield']) { include_once $phpbb_root_path . 'includes/bbcode.' . $phpEx; $bbcode = new bbcode($post_info['bbcode_bitfield']); $bbcode->bbcode_second_pass($message, $post_info['bbcode_uid'], $post_info['bbcode_bitfield']); } $message = smiley_text($message); $template->assign_vars(array('S_MCP_QUEUE' => true, 'S_APPROVE_ACTION' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i=queue&p={$post_id}&f={$forum_id}"), 'S_CAN_VIEWIP' => $auth->acl_get('m_info', $post_info['forum_id']), 'S_POST_REPORTED' => $post_info['post_reported'], 'S_POST_UNAPPROVED' => !$post_info['post_approved'], 'S_POST_LOCKED' => $post_info['post_edit_locked'], 'S_USER_NOTES' => true, 'U_EDIT' => $auth->acl_get('m_edit', $post_info['forum_id']) ? append_sid("{$phpbb_root_path}posting.{$phpEx}", "mode=edit&f={$post_info['forum_id']}&p={$post_info['post_id']}") : '', 'U_MCP_APPROVE' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue&mode=approve_details&f=' . $post_info['forum_id'] . '&p=' . $post_id), 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=reports&mode=report_details&f=' . $post_info['forum_id'] . '&p=' . $post_id), 'U_MCP_USER_NOTES' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=notes&mode=user_notes&u=' . $post_info['user_id']), 'U_MCP_WARN_USER' => $auth->acl_getf_global('m_warn') ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=warn&mode=warn_user&u=' . $post_info['user_id']) : '', 'U_VIEW_PROFILE' => $post_info['user_id'] != ANONYMOUS ? append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=viewprofile&u=' . $post_info['user_id']) : '', 'RETURN_QUEUE' => sprintf($user->lang['RETURN_QUEUE'], '<a href="' . append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue' . ($topic_id ? '&mode=unapproved_topics' : '&mode=unapproved_posts')) . "&start={$start}\">", '</a>'), 'REPORTED_IMG' => $user->img('icon_reported', $user->lang['POST_REPORTED']), 'UNAPPROVED_IMG' => $user->img('icon_unapproved', $user->lang['POST_UNAPPROVED']), 'EDIT_IMG' => $user->img('btn_edit', $user->lang['EDIT_POST']), 'POSTER_NAME' => $poster, 'POST_PREVIEW' => $message, 'POST_SUBJECT' => $post_info['post_subject'], 'POST_DATE' => $user->format_date($post_info['post_time']), 'POST_IP' => $post_info['poster_ip'], 'POST_IPADDR' => @gethostbyaddr($post_info['poster_ip']), 'POST_ID' => $post_info['post_id'])); $this->tpl_name = 'mcp_post'; break; case 'unapproved_topics': case 'unapproved_posts': $topic_id = request_var('t', 0); $forum_info = array(); if ($topic_id) { $topic_info = get_topic_data(array($topic_id)); if (!sizeof($topic_info)) { trigger_error($user->lang['TOPIC_NOT_EXIST']); } $topic_info = $topic_info[$topic_id]; $forum_id = $topic_info['forum_id']; } $forum_list_approve = get_forum_list('m_approve', false, true); if (!$forum_id) { $forum_list = array(); foreach ($forum_list_approve as $row) { $forum_list[] = $row['forum_id']; } if (!($forum_list = implode(', ', $forum_list))) { trigger_error('NOT_MODERATOR'); } $sql = 'SELECT SUM(forum_topics) as sum_forum_topics FROM ' . FORUMS_TABLE . "\n\t\t\t\t\t\tWHERE forum_id IN (0, {$forum_list})"; $result = $db->sql_query($sql); $forum_info['forum_topics'] = (int) $db->sql_fetchfield('sum_forum_topics'); $db->sql_freeresult($result); $global_id = $forum_list[0]; } else { $forum_info = get_forum_data(array($forum_id), 'm_approve'); if (!sizeof($forum_info)) { trigger_error('NOT_MODERATOR'); } $forum_info = $forum_info[$forum_id]; $forum_list = $forum_id; $global_id = $forum_id; } $forum_options = '<option value="0"' . ($forum_id == 0 ? ' selected="selected"' : '') . '>' . $user->lang['ALL_FORUMS'] . '</option>'; foreach ($forum_list_approve as $row) { $forum_options .= '<option value="' . $row['forum_id'] . '"' . ($forum_id == $row['forum_id'] ? ' selected="selected"' : '') . '>' . $row['forum_name'] . '</option>'; } $sort_days = $total = 0; $sort_key = $sort_dir = ''; $sort_by_sql = $sort_order_sql = array(); mcp_sorting($mode, $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $forum_id, $topic_id); $forum_topics = $total == -1 ? $forum_info['forum_topics'] : $total; $limit_time_sql = $sort_days ? 'AND t.topic_last_post_time >= ' . (time() - $sort_days * 86400) : ''; $forum_names = array(); if ($mode == 'unapproved_posts') { $sql = 'SELECT p.post_id FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t' . ($sort_order_sql[0] == 'u' ? ', ' . USERS_TABLE . ' u' : '') . "\n\t\t\t\t\t\tWHERE p.forum_id IN (0, {$forum_list})\n\t\t\t\t\t\t\tAND p.post_approved = 0\n\t\t\t\t\t\t\t" . ($sort_order_sql[0] == 'u' ? 'AND u.user_id = p.poster_id' : '') . ' ' . ($topic_id ? 'AND p.topic_id = ' . $topic_id : '') . "\n\t\t\t\t\t\t\tAND t.topic_id = p.topic_id\n\t\t\t\t\t\t\tAND t.topic_first_post_id <> p.post_id\n\t\t\t\t\t\t\t{$limit_time_sql}\n\t\t\t\t\t\tORDER BY {$sort_order_sql}"; $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); $i = 0; $post_ids = array(); while ($row = $db->sql_fetchrow($result)) { $post_ids[] = $row['post_id']; $row_num[$row['post_id']] = $i++; } $db->sql_freeresult($result); if (sizeof($post_ids)) { $sql = 'SELECT t.topic_id, t.topic_title, t.forum_id, p.post_id, p.post_username, p.poster_id, p.post_time, u.username FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . " u\n\t\t\t\t\t\t\tWHERE p.post_id IN (" . implode(', ', $post_ids) . ")\n\t\t\t\t\t\t\t\tAND t.topic_id = p.topic_id\n\t\t\t\t\t\t\t\tAND u.user_id = p.poster_id"; $result = $db->sql_query($sql); $post_data = $rowset = array(); while ($row = $db->sql_fetchrow($result)) { if ($row['forum_id']) { $forum_names[] = $row['forum_id']; } $post_data[$row['post_id']] = $row; } $db->sql_freeresult($result); foreach ($post_ids as $post_id) { $rowset[] = $post_data[$post_id]; } unset($post_data, $post_ids); } else { $rowset = array(); } } else { $sql = 'SELECT t.forum_id, t.topic_id, t.topic_title, t.topic_time AS post_time, t.topic_poster AS poster_id, t.topic_first_post_id AS post_id, t.topic_first_poster_name AS username FROM ' . TOPICS_TABLE . " t\n\t\t\t\t\t\tWHERE topic_approved = 0\n\t\t\t\t\t\t\tAND forum_id IN (0, {$forum_list})\n\t\t\t\t\t\t\t{$limit_time_sql}\n\t\t\t\t\t\tORDER BY {$sort_order_sql}"; $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); $rowset = array(); while ($row = $db->sql_fetchrow($result)) { if ($row['forum_id']) { $forum_names[] = $row['forum_id']; } $rowset[] = $row; } $db->sql_freeresult($result); } if (sizeof($forum_names)) { // Select the names for the forum_ids $sql = 'SELECT forum_id, forum_name FROM ' . FORUMS_TABLE . ' WHERE forum_id IN (' . implode(',', $forum_names) . ')'; $result = $db->sql_query($sql, 3600); $forum_names = array(); while ($row = $db->sql_fetchrow($result)) { $forum_names[$row['forum_id']] = $row['forum_name']; } $db->sql_freeresult($result); } foreach ($rowset as $row) { if ($row['poster_id'] == ANONYMOUS) { $poster = !empty($row['post_username']) ? $row['post_username'] : $user->lang['GUEST']; } else { $poster = $row['username']; } $global_topic = $row['forum_id'] ? false : true; if ($global_topic) { $row['forum_id'] = $global_id; } $template->assign_block_vars('postrow', array('U_VIEWFORUM' => !$global_topic ? append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $row['forum_id']) : '', 'U_VIEWTOPIC' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $row['forum_id'] . '&p=' . $row['post_id']) . ($mode == 'unapproved_posts' ? '#p' . $row['post_id'] : ''), 'U_VIEW_DETAILS' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i=queue&start={$start}&mode=approve_details&f={$row['forum_id']}&p={$row['post_id']}" . ($mode == 'unapproved_topics' ? "&t={$row['topic_id']}" : '')), 'U_VIEWPROFILE' => $row['poster_id'] != ANONYMOUS ? append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=viewprofile&u=' . $row['poster_id']) : '', 'POST_ID' => $row['post_id'], 'FORUM_NAME' => !$global_topic ? $forum_names[$row['forum_id']] : $user->lang['GLOBAL_ANNOUNCEMENT'], 'TOPIC_TITLE' => $row['topic_title'], 'POSTER' => $poster, 'POST_TIME' => $user->format_date($row['post_time']))); } unset($rowset, $forum_names); // Now display the page $template->assign_vars(array('L_DISPLAY_ITEMS' => $mode == 'unapproved_posts' ? $user->lang['DISPLAY_POSTS'] : $user->lang['DISPLAY_TOPICS'], 'L_EXPLAIN' => $mode == 'unapproved_posts' ? $user->lang['MCP_QUEUE_UNAPPROVED_POSTS_EXPLAIN'] : $user->lang['MCP_QUEUE_UNAPPROVED_TOPICS_EXPLAIN'], 'L_TITLE' => $mode == 'unapproved_posts' ? $user->lang['MCP_QUEUE_UNAPPROVED_POSTS'] : $user->lang['MCP_QUEUE_UNAPPROVED_TOPICS'], 'L_ONLY_TOPIC' => $topic_id ? sprintf($user->lang['ONLY_TOPIC'], $topic_info['topic_title']) : '', 'S_FORUM_OPTIONS' => $forum_options, 'S_MCP_ACTION' => build_url(array('t', 'f', 'sd', 'st', 'sk')), 'PAGINATION' => generate_pagination($this->u_action . "&f={$forum_id}", $total, $config['topics_per_page'], $start), 'PAGE_NUMBER' => on_page($total, $config['topics_per_page'], $start), 'TOPIC_ID' => $topic_id, 'TOTAL' => $total)); $this->tpl_name = 'mcp_queue'; break; } }
{ $power = $row['karma_action'] . $row['karma_power']; } $poster_id = $row['poster_id']; $comment = censor_text($row['comment_text']); // Parse bbcode if ($row['bbcode_bitfield']) { $bbcode = new bbcode(base64_encode($row['bbcode_bitfield'])); $bbcode->bbcode_second_pass($comment, $row['bbcode_uid'], $row['bbcode_bitfield']); } $comment = bbcode_nl2br($comment); $comment = smiley_text($comment, !$config['allow_smilies']); if ($karmamod->user_level != 'admin' && (($karmamod->config['anonym_increase'] && $row['karma_action'] == '+') || ($karmamod->config['anonym_decrease'] && $row['karma_action'] == '-'))) { $author_full = $user->lang['KARMA_NOTIFY_HIDDEN_SENDER']; $author_colour = $user->lang['KARMA_NOTIFY_HIDDEN_SENDER']; $author = $user->lang['KARMA_NOTIFY_HIDDEN_SENDER']; $u_author = ''; } else { $author_full = get_username_string('full', $poster_id, $row['username'], $row['user_colour']); $author_colour = get_username_string('colour', $poster_id, $row['username'], $row['user_colour']); $author = get_username_string('username', $poster_id, $row['username'], $row['user_colour']); $u_author = get_username_string('profile', $poster_id, $row['username'], $row['user_colour']); }
function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id = 0, $show_quote_button = true) { global $_CLASS, $bbcode, $config; // Go ahead and pull all data for this topic $sql = 'SELECT u.username, u.user_id, p.post_id, p.post_username, p.post_subject, p.post_text, p.enable_smilies, p.bbcode_uid, p.bbcode_bitfield, p.post_time FROM ' . FORUMS_POSTS_TABLE . ' p, ' . USERS_TABLE . " u\n\t\tWHERE p.topic_id = {$topic_id}\n\t\t\tAND p.poster_id = u.user_id\n\t\t\t" . (!$_CLASS['auth']->acl_get('m_approve', $forum_id) ? 'AND p.post_approved = 1' : '') . ' ' . ($mode == 'post_review' ? " AND p.post_id > {$cur_post_id}" : '') . ' ORDER BY p.post_time DESC'; $result = $_CLASS['core_db']->query_limit($sql, $config['posts_per_page']); if (!($row = $_CLASS['core_db']->fetch_row_assoc($result))) { return false; } $bbcode_bitfield = 0; do { $rowset[] = $row; $bbcode_bitfield |= $row['bbcode_bitfield']; } while ($row = $_CLASS['core_db']->fetch_row_assoc($result)); $_CLASS['core_db']->free_result($result); // Instantiate BBCode class if (!isset($bbcode) && $bbcode_bitfield) { require_once SITE_FILE_ROOT . 'includes/forums/bbcode.php'; $bbcode = new bbcode($bbcode_bitfield); } foreach ($rowset as $i => $row) { $poster_id = $row['user_id']; $poster = $row['username']; // Handle anon users posting with usernames if ($poster_id == ANONYMOUS && $row['post_username']) { $poster = $row['post_username']; $poster_rank = $_CLASS['core_user']->lang['GUEST']; } $post_subject = $row['post_subject']; $message = $row['post_text']; if ($row['bbcode_bitfield']) { $bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']); } $message = smiley_text($message, !$row['enable_smilies']); $post_subject = censor_text($post_subject); $message = censor_text($message); $_CLASS['core_template']->assign_vars_array($mode . '_row', array('POSTER_NAME' => $poster, 'POST_SUBJECT' => $post_subject, 'MINI_POST_IMG' => $_CLASS['core_user']->img('icon_post', $_CLASS['core_user']->lang['POST']), 'POST_DATE' => $_CLASS['core_user']->format_date($row['post_time']), 'MESSAGE' => str_replace("\n", '<br />', $message), 'U_POST_ID' => $row['post_id'], 'U_MINI_POST' => generate_link('Forums&file=viewtopic&p=' . $row['post_id'] . '#' . $row['post_id']), 'U_MCP_DETAILS' => $_CLASS['auth']->acl_get('m_', $forum_id) ? generate_link('Forums&file=mcp&mode=post_details&p=' . $row['post_id']) : '', 'U_QUOTE' => $show_quote_button && $_CLASS['auth']->acl_get('f_quote', $forum_id) ? 'javascript:addquote(' . $row['post_id'] . ", '" . str_replace("'", "\\'", $poster) . "')" : '')); unset($rowset[$i]); } if ($mode == 'topic_review') { $_CLASS['core_template']->assign('QUOTE_IMG', $_CLASS['core_user']->img('btn_quote', $_CLASS['core_user']->lang['REPLY_WITH_QUOTE'])); } return true; }
/** * prepares the preview announcement text */ function announcement_post($where_sql, $order, $gotopost) { global $db, $auth, $user, $template; global $phpbb_root_path, $phpEx, $config; if (!class_exists('bbcode')) { include $phpbb_root_path . 'includes/bbcode.' . $phpEx; } $bbcode_bitfield = ''; $sql = 'SELECT * FROM ' . POSTS_TABLE . " \n\t\t\t{$where_sql}\n\t\tORDER BY post_id {$order}"; $result = $db->sql_query_limit($sql, 1, 0); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); if ($row['post_attachment']) { $sql = 'SELECT * FROM ' . ATTACHMENTS_TABLE . ' WHERE ' . $db->sql_in_set('post_msg_id', $row['post_id']) . ' AND in_message = 0 ORDER BY filetime DESC, post_msg_id ASC'; $result = $db->sql_query($sql); while ($row2 = $db->sql_fetchrow($result)) { $attachments[$row2['post_msg_id']][] = $row2; } $db->sql_freeresult($result); } // Parse the message and subject $message = censor_text($row['post_text']); // Define the global bbcode bitfield, will be used to load bbcodes $bbcode_bitfield = $bbcode_bitfield | base64_decode($row['bbcode_bitfield']); // Instantiate BBCode if need be if ($bbcode_bitfield !== '') { $bbcode = new bbcode(base64_encode($bbcode_bitfield)); } // Second parse bbcode here //if ($row['bbcode_bitfield']) //{ if (!function_exists('Markdown')) { global $phpbb_root_path, $phpEx; include $phpbb_root_path . 'includes/markdown.' . $phpEx; } $message = Markdown($message); //$bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']); //} //$message = bbcode_nl2br($message); $message = smiley_text($message); if (!empty($attachments[$row['post_id']])) { parse_attachments($row['forum_id'], $message, $attachments[$row['post_id']], $update_count); } // Display not already displayed Attachments for this post, we already parsed them. ;) if (!empty($attachments[$row['post_id']])) { foreach ($attachments[$row['post_id']] as $attachment) { $template->assign_block_vars('announcement_attachments', array('DISPLAY_ATTACHMENTS' => $attachment)); } } // Assign index specific vars $template->assign_vars(array('S_HASATTACHMENTS' => !empty($attachments[$row['post_id']]) ? true : false, 'U_ANNOUNCEMENT_GOTOPOST' => $gotopost ? append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'p=' . $row['post_id']) . '#p' . $row['post_id'] : '')); return $message; }
function mcp_queue($id, $mode, $url) { global $_CLASS, $site_file_root, $config; $forum_id = request_var('f', 0); $start = request_var('start', 0); switch ($mode) { case 'approve': case 'disapprove': require_once $site_file_root . 'includes/forums/functions_messenger.php'; require_once $site_file_root . 'includes/forums/functions_posting.php'; $post_id_list = request_var('post_id_list', array(0)); if (!sizeof($post_id_list)) { trigger_error('NO_POST_SELECTED'); } if ($mode == 'approve') { approve_post($post_id_list); } else { disapprove_post($post_id_list); } break; case 'approve_details': $_CLASS['core_user']->add_lang('posting'); require_once $site_file_root . 'includes/forums/functions_posting.php'; $post_id = request_var('p', 0); $topic_id = request_var('t', 0); if ($topic_id) { $topic_info = get_topic_data(array($topic_id), 'm_approve'); $post_id = (int) $topic_info[$topic_id]['topic_first_post_id']; } $post_info = get_post_data(array($post_id), 'm_approve'); if (!sizeof($post_info)) { trigger_error('NO_POST_SELECTED'); } $post_info = $post_info[$post_id]; if ($post_info['topic_first_post_id'] != $post_id && topic_review($post_info['topic_id'], $post_info['forum_id'], 'topic_review', 0, false)) { $_CLASS['core_template']->assign_array(array('S_TOPIC_REVIEW' => true, 'TOPIC_TITLE' => $post_info['topic_title'])); } // Set some vars $poster = $post_info['user_colour'] ? '<span style="color:#' . $post_info['user_colour'] . '">' . $post_info['username'] . '</span>' : $post_info['username']; // Process message, leave it uncensored $message = $post_info['post_text']; if ($post_info['bbcode_bitfield']) { require_once $site_file_root . 'includes/forums/bbcode.php'; $bbcode = new bbcode($post_info['bbcode_bitfield']); $bbcode->bbcode_second_pass($message, $post_info['bbcode_uid'], $post_info['bbcode_bitfield']); } $message = smiley_text($message); $_CLASS['core_template']->assign_array(array('S_MCP_QUEUE' => true, 'S_APPROVE_ACTION' => generate_link("Forums&file=mcp&i=queue&p={$post_id}&f={$forum_id}"), 'S_CAN_VIEWIP' => $_CLASS['auth']->acl_get('m_ip', $post_info['forum_id']), 'S_POST_REPORTED' => $post_info['post_reported'], 'S_POST_UNAPPROVED' => !$post_info['post_approved'], 'S_POST_LOCKED' => $post_info['post_edit_locked'], 'S_USER_WARNINGS' => $post_info['user_warnings'] ? true : false, 'U_VIEW_PROFILE' => generate_link('Members_List&mode=viewprofile&u=' . $post_info['user_id']), 'U_MCP_USERNOTES' => generate_link('Forums&file=mcp&i=notes&mode=user_notes&u=' . $post_info['user_id']), 'U_MCP_WARNINGS' => generate_link('Forums&file=mcp&i=warnings&mode=view_user&u=' . $post_info['user_id']), 'U_EDIT' => $_CLASS['auth']->acl_get('m_edit', $post_info['forum_id']) ? generate_link("Forums&file=posting&mode=edit&f={$post_info['forum_id']}&p={$post_info['post_id']}") : '', 'REPORTED_IMG' => $_CLASS['core_user']->img('icon_reported', $_CLASS['core_user']->lang['POST_REPORTED']), 'UNAPPROVED_IMG' => $_CLASS['core_user']->img('icon_unapproved', $_CLASS['core_user']->lang['POST_UNAPPROVED']), 'EDIT_IMG' => $_CLASS['core_user']->img('btn_edit', $_CLASS['core_user']->lang['EDIT_POST']), 'POSTER_NAME' => $poster, 'POST_PREVIEW' => $message, 'POST_SUBJECT' => $post_info['post_subject'], 'POST_DATE' => $_CLASS['core_user']->format_date($post_info['post_time']), 'POST_IP' => $post_info['poster_ip'], 'POST_IPADDR' => @gethostbyaddr($post_info['poster_ip']), 'POST_ID' => $post_info['post_id'])); $this->display($_CLASS['core_user']->lang['MCP_QUEUE'], 'mcp_post.html'); break; case 'unapproved_topics': case 'unapproved_posts': $forum_info = array(); $forum_list_approve = get_forum_list('m_approve', false, true); if (!$forum_id) { $forum_list = array(); foreach ($forum_list_approve as $row) { $forum_list[] = $row['forum_id']; } if (!($forum_list = implode(', ', $forum_list))) { trigger_error('NOT_MODERATOR'); } $sql = 'SELECT SUM(forum_topics) as sum_forum_topics FROM ' . FORUMS_FORUMS_TABLE . "\n\t\t\t\t\t\tWHERE forum_id IN ({$forum_list})"; $result = $_CLASS['core_db']->query($sql); $row = $_CLASS['core_db']->fetch_row_assoc($result); $_CLASS['core_db']->free_result($result); $forum_info['forum_topics'] = (int) $row['sum_forum_topics']; } else { $forum_info = get_forum_data(array($forum_id), 'm_approve'); if (!sizeof($forum_info)) { trigger_error('NOT_MODERATOR'); } $forum_info = $forum_info[$forum_id]; $forum_list = $forum_id; } $forum_options = '<option value="0"' . ($forum_id == 0 ? ' selected="selected"' : '') . '>' . $_CLASS['core_user']->lang['ALL_FORUMS'] . '</option>'; foreach ($forum_list_approve as $row) { $forum_options .= '<option value="' . $row['forum_id'] . '"' . ($forum_id == $row['forum_id'] ? ' selected="selected"' : '') . '>' . $row['forum_name'] . '</option>'; } mcp_sorting($mode, $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $forum_id); $forum_topics = $total == -1 ? $forum_info['forum_topics'] : $total; $limit_time_sql = $sort_days ? 'AND t.topic_last_post_time >= ' . (time() - $sort_days * 86400) : ''; if ($mode == 'unapproved_posts') { $sql = 'SELECT p.post_id FROM ' . FORUMS_POSTS_TABLE . ' p, ' . FORUMS_TOPICS_TABLE . ' t' . ($sort_order_sql[0] == 'u' ? ', ' . USERS_TABLE . ' u' : '') . "\n\t\t\t\t\t\tWHERE p.forum_id IN ({$forum_list})\n\t\t\t\t\t\t\tAND p.post_approved = 0\n\t\t\t\t\t\t\t" . ($sort_order_sql[0] == 'u' ? 'AND u.user_id = p.poster_id' : '') . "\n\t\t\t\t\t\t\tAND t.topic_id = p.topic_id\n\t\t\t\t\t\t\tAND t.topic_first_post_id <> p.post_id\n\t\t\t\t\t\tORDER BY {$sort_order_sql}"; $result = $_CLASS['core_db']->query_limit($sql, $config['topics_per_page'], $start); $i = 0; $post_ids = array(); while ($row = $_CLASS['core_db']->fetch_row_assoc($result)) { $post_ids[] = $row['post_id']; $row_num[$row['post_id']] = $i++; } if (sizeof($post_ids)) { $sql = 'SELECT f.forum_id, f.forum_name, t.topic_id, t.topic_title, p.post_id, p.post_username, p.poster_id, p.post_time, u.username FROM ' . FORUMS_POSTS_TABLE . ' p, ' . FORUMS_FORUMS_TABLE . ' f, ' . FORUMS_TOPICS_TABLE . ' t, ' . USERS_TABLE . " u\n\t\t\t\t\t\t\tWHERE p.post_id IN (" . implode(', ', $post_ids) . ")\n\t\t\t\t\t\t\t\tAND t.topic_id = p.topic_id\n\t\t\t\t\t\t\t\tAND f.forum_id = p.forum_id\n\t\t\t\t\t\t\t\tAND u.user_id = p.poster_id"; $result = $_CLASS['core_db']->query($sql); $post_data = $rowset = array(); while ($row = $_CLASS['core_db']->fetch_row_assoc($result)) { $post_data[$row['post_id']] = $row; } $_CLASS['core_db']->free_result($result); foreach ($post_ids as $post_id) { $rowset[] = $post_data[$post_id]; } unset($post_data, $post_ids); } else { $rowset = array(); } } else { $sql = 'SELECT f.forum_id, f.forum_name, t.topic_id, t.topic_title, t.topic_time AS post_time, t.topic_poster AS poster_id, t.topic_first_post_id AS post_id, t.topic_first_poster_name AS username FROM ' . FORUMS_TOPICS_TABLE . ' t, ' . FORUMS_FORUMS_TABLE . " f\n\t\t\t\t\t\tWHERE t.topic_approved = 0\n\t\t\t\t\t\t\tAND t.forum_id IN ({$forum_list})\n\t\t\t\t\t\t\tAND f.forum_id = t.forum_id\n\t\t\t\t\t\tORDER BY {$sort_order_sql}"; $result = $_CLASS['core_db']->query_limit($sql, $config['topics_per_page'], $start); $rowset = array(); while ($row = $_CLASS['core_db']->fetch_row_assoc($result)) { $rowset[] = $row; } $_CLASS['core_db']->free_result($result); } foreach ($rowset as $row) { if ($row['poster_id'] == ANONYMOUS) { $poster = !empty($row['post_username']) ? $row['post_username'] : $_CLASS['core_user']->lang['GUEST']; } else { $poster = $row['username']; } $s_checkbox = '<input type="checkbox" name="post_id_list[]" value="' . $row['post_id'] . '" />'; $_CLASS['core_template']->assign_vars_array('postrow', array('U_VIEWFORUM' => generate_link('Forums&file=viewforum&f=' . $row['forum_id']), 'U_VIEWTOPIC' => generate_link('Forums&file=viewtopic&f=' . $row['forum_id'] . '&p=' . $row['post_id'] . ($mode == 'unapproved_posts' ? '#' . $row['post_id'] : '')), 'U_VIEW_DETAILS' => generate_link("Forums&file=mcp&i=queue&start={$start}&mode=approve_details&f={$forum_id}&p={$row['post_id']}"), 'U_VIEWPROFILE' => $row['poster_id'] != ANONYMOUS ? generate_link("Members_List&mode=viewprofile&u={$row['poster_id']}") : '', 'FORUM_NAME' => $row['forum_name'], 'TOPIC_TITLE' => $row['topic_title'], 'POSTER' => $poster, 'POST_TIME' => $_CLASS['core_user']->format_date($row['post_time']), 'S_CHECKBOX' => $s_checkbox)); } unset($rowset); // Now display the page $_CLASS['core_template']->assign_array(array('L_DISPLAY_ITEMS' => $mode == 'unapproved_posts' ? $_CLASS['core_user']->lang['DISPLAY_POSTS'] : $_CLASS['core_user']->lang['DISPLAY_TOPICS'], 'S_FORUM_OPTIONS' => $forum_options)); $this->display($_CLASS['core_user']->lang['MCP_QUEUE'], 'mcp_queue.html'); break; } }
function save_raw_post_func($xmlrpc_params) { global $db, $auth, $user, $config, $template, $cache, $phpEx, $phpbb_root_path, $phpbb_home; $user->setup('posting'); include $phpbb_root_path . 'includes/message_parser.' . $phpEx; $params = php_xmlrpc_decode($xmlrpc_params); $submit = true; $preview = false; $refresh = false; $mode = 'edit'; // get post information from parameters $post_id = intval($params[0]); $post_title = $params[1]; $post_content = $params[2]; $GLOBALS['return_html'] = isset($params[3]) ? $params[3] : false; $post_data = array(); $sql = 'SELECT p.*, t.*, f.*, u.username FROM ' . POSTS_TABLE . ' p LEFT JOIN ' . TOPICS_TABLE . ' t ON (p.topic_id = t.topic_id) LEFT JOIN ' . FORUMS_TABLE . ' f ON (t.forum_id = f.forum_id OR (t.topic_type = ' . POST_GLOBAL . ' AND f.forum_type = ' . FORUM_POST . ')) LEFT JOIN ' . USERS_TABLE . ' u ON (p.poster_id = u.user_id)' . "\r\r\n WHERE p.post_id = {$post_id}"; $result = $db->sql_query_limit($sql, 1); $post_data = $db->sql_fetchrow($result); $db->sql_freeresult($result); if (!$post_data) { trigger_error('NO_POST'); } // Use post_row values in favor of submitted ones... $forum_id = (int) $post_data['forum_id']; $topic_id = (int) $post_data['topic_id']; $post_id = (int) $post_id; // Need to login to passworded forum first? if ($post_data['forum_password'] && !check_forum_password($forum_id)) { trigger_error('LOGIN_FORUM'); } // Is the user able to read within this forum? if (!$auth->acl_get('f_read', $forum_id)) { trigger_error('USER_CANNOT_READ'); } // Permission to do the action asked? if (!($user->data['is_registered'] && $auth->acl_gets('f_edit', 'm_edit', $forum_id))) { trigger_error('USER_CANNOT_EDIT'); } // Forum/Topic locked? if (($post_data['forum_status'] == ITEM_LOCKED || isset($post_data['topic_status']) && $post_data['topic_status'] == ITEM_LOCKED) && !$auth->acl_get('m_edit', $forum_id)) { trigger_error($post_data['forum_status'] == ITEM_LOCKED ? 'FORUM_LOCKED' : 'TOPIC_LOCKED'); } // Can we edit this post ... if we're a moderator with rights then always yes // else it depends on editing times, lock status and if we're the correct user if (!$auth->acl_get('m_edit', $forum_id)) { if ($user->data['user_id'] != $post_data['poster_id']) { trigger_error('USER_CANNOT_EDIT'); } if (!($post_data['post_time'] > time() - $config['edit_time'] * 60 || !$config['edit_time'])) { trigger_error('CANNOT_EDIT_TIME'); } if ($post_data['post_edit_locked']) { trigger_error('CANNOT_EDIT_POST_LOCKED'); } } // Determine some vars if (isset($post_data['poster_id']) && $post_data['poster_id'] == ANONYMOUS) { $post_data['quote_username'] = !empty($post_data['post_username']) ? $post_data['post_username'] : $user->lang['GUEST']; } else { $post_data['quote_username'] = isset($post_data['username']) ? $post_data['username'] : ''; } $post_data['post_edit_locked'] = isset($post_data['post_edit_locked']) ? (int) $post_data['post_edit_locked'] : 0; $post_data['post_subject'] = in_array($mode, array('quote', 'edit')) ? $post_data['post_subject'] : (isset($post_data['topic_title']) ? $post_data['topic_title'] : ''); $post_data['topic_time_limit'] = isset($post_data['topic_time_limit']) ? $post_data['topic_time_limit'] ? (int) $post_data['topic_time_limit'] / 86400 : (int) $post_data['topic_time_limit'] : 0; $post_data['poll_length'] = !empty($post_data['poll_length']) ? (int) $post_data['poll_length'] / 86400 : 0; $post_data['poll_start'] = !empty($post_data['poll_start']) ? (int) $post_data['poll_start'] : 0; $post_data['icon_id'] = !isset($post_data['icon_id']) || in_array($mode, array('quote', 'reply')) ? 0 : (int) $post_data['icon_id']; $post_data['poll_options'] = array(); // Get Poll Data if ($post_data['poll_start']) { $sql = 'SELECT poll_option_text FROM ' . POLL_OPTIONS_TABLE . "\r\r\n WHERE topic_id = {$topic_id}\r\r\n ORDER BY poll_option_id"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $post_data['poll_options'][] = trim($row['poll_option_text']); } $db->sql_freeresult($result); } $orig_poll_options_size = sizeof($post_data['poll_options']); $message_parser = new parse_message(); if (isset($post_data['post_text'])) { $message_parser->message =& $post_data['post_text']; unset($post_data['post_text']); } // Set some default variables $uninit = array('post_attachment' => 0, 'poster_id' => $user->data['user_id'], 'enable_magic_url' => 0, 'topic_status' => 0, 'topic_type' => POST_NORMAL, 'post_subject' => '', 'topic_title' => '', 'post_time' => 0, 'post_edit_reason' => '', 'notify_set' => 0); foreach ($uninit as $var_name => $default_value) { if (!isset($post_data[$var_name])) { $post_data[$var_name] = $default_value; } } unset($uninit); // Always check if the submitted attachment data is valid and belongs to the user. // Further down (especially in submit_post()) we do not check this again. $message_parser->get_submitted_attachment_data($post_data['poster_id']); if ($post_data['post_attachment'] && !$refresh && !$preview && $mode == 'edit') { // Do not change to SELECT * $sql = 'SELECT attach_id, is_orphan, attach_comment, real_filename FROM ' . ATTACHMENTS_TABLE . "\r\r\n WHERE post_msg_id = {$post_id}\r\r\n AND in_message = 0\r\r\n AND is_orphan = 0\r\r\n ORDER BY filetime DESC"; $result = $db->sql_query($sql); $message_parser->attachment_data = array_merge($message_parser->attachment_data, $db->sql_fetchrowset($result)); $db->sql_freeresult($result); } if ($post_data['poster_id'] == ANONYMOUS) { $post_data['username'] = $mode == 'quote' || $mode == 'edit' ? trim($post_data['post_username']) : ''; } else { $post_data['username'] = $mode == 'quote' || $mode == 'edit' ? trim($post_data['username']) : ''; } $post_data['enable_urls'] = $post_data['enable_magic_url']; $post_data['enable_magic_url'] = $post_data['drafts'] = false; $check_value = ($post_data['enable_bbcode'] + 1 << 8) + ($post_data['enable_smilies'] + 1 << 4) + ($post_data['enable_urls'] + 1 << 2) + ($post_data['enable_sig'] + 1 << 1); // Check if user is watching this topic /*if ($mode != 'post' && $config['allow_topic_notify'] && $user->data['is_registered']) { $sql = 'SELECT topic_id FROM ' . TOPICS_WATCH_TABLE . ' WHERE topic_id = ' . $topic_id . ' AND user_id = ' . $user->data['user_id']; $result = $db->sql_query($sql); $post_data['notify_set'] = (int) $db->sql_fetchfield('topic_id'); $db->sql_freeresult($result); }*/ // Do we want to edit our post ? if ($post_data['bbcode_uid']) { $message_parser->bbcode_uid = $post_data['bbcode_uid']; } // HTML, BBCode, Smilies, Images and Flash status $bbcode_status = $config['allow_bbcode'] && $auth->acl_get('f_bbcode', $forum_id) ? true : false; $smilies_status = $bbcode_status && $config['allow_smilies'] && $auth->acl_get('f_smilies', $forum_id) ? true : false; $img_status = $bbcode_status && $auth->acl_get('f_img', $forum_id) ? true : false; $url_status = $config['allow_post_links'] ? true : false; $flash_status = $bbcode_status && $auth->acl_get('f_flash', $forum_id) && $config['allow_post_flash'] ? true : false; $quote_status = $auth->acl_get('f_reply', $forum_id) ? true : false; $solved_captcha = false; $post_data['topic_cur_post_id'] = request_var('topic_cur_post_id', 0); $post_data['post_subject'] = utf8_normalize_nfc($post_title); $message_parser->message = utf8_normalize_nfc(htmlspecialchars($post_content)); $post_data['username'] = utf8_normalize_nfc(request_var('username', $post_data['username'], true)); $post_data['post_edit_reason'] = !empty($_POST['edit_reason']) && $mode == 'edit' && $auth->acl_get('m_edit', $forum_id) ? utf8_normalize_nfc(request_var('edit_reason', '', true)) : ''; $post_data['orig_topic_type'] = $post_data['topic_type']; $post_data['topic_type'] = request_var('topic_type', $mode != 'post' ? (int) $post_data['topic_type'] : POST_NORMAL); $post_data['topic_time_limit'] = request_var('topic_time_limit', $mode != 'post' ? (int) $post_data['topic_time_limit'] : 0); $post_data['icon_id'] = request_var('icon', 0); $post_data['enable_bbcode'] = !$bbcode_status || isset($_POST['disable_bbcode']) ? false : true; $post_data['enable_smilies'] = !$smilies_status || isset($_POST['disable_smilies']) ? false : true; $post_data['enable_urls'] = isset($_POST['disable_magic_url']) ? 0 : 1; $post_data['enable_sig'] = !$config['allow_sig'] || !$auth->acl_get('f_sigs', $forum_id) || !$auth->acl_get('u_sig') ? false : ($user->data['is_registered'] ? true : false); if ($config['allow_topic_notify'] && $user->data['is_registered']) { $notify = isset($_POST['notify']) ? true : false; } else { $notify = false; } $topic_lock = isset($_POST['lock_topic']) ? true : $post_data['topic_status']; $post_lock = isset($_POST['lock_post']) ? true : $post_data['post_edit_locked']; $poll_delete = isset($_POST['poll_delete']) ? true : false; $status_switch = ($post_data['enable_bbcode'] + 1 << 8) + ($post_data['enable_smilies'] + 1 << 4) + ($post_data['enable_urls'] + 1 << 2) + ($post_data['enable_sig'] + 1 << 1); $status_switch = $status_switch != $check_value; //$post_data['poll_title'] = utf8_normalize_nfc(request_var('poll_title', '', true)); //$post_data['poll_length'] = request_var('poll_length', 0); //$post_data['poll_option_text'] = utf8_normalize_nfc(request_var('poll_option_text', '', true)); $post_data['poll_option_text'] = implode("\n", $post_data['poll_options']); //$post_data['poll_max_options'] = request_var('poll_max_options', 1); //$post_data['poll_vote_change'] = ($auth->acl_get('f_votechg', $forum_id) && isset($_POST['poll_vote_change'])) ? 1 : 0; // Parse Attachments - before checksum is calculated $message_parser->parse_attachments('fileupload', $mode, $forum_id, $submit, $preview, $refresh); // Grab md5 'checksum' of new message $message_md5 = md5($message_parser->message); // Check checksum ... don't re-parse message if the same $update_message = $mode != 'edit' || $message_md5 != $post_data['post_checksum'] || $status_switch || strlen($post_data['bbcode_uid']) < BBCODE_UID_LEN ? true : false; // Parse message if ($update_message) { if (sizeof($message_parser->warn_msg)) { trigger_error(join("\n", $message_parser->warn_msg)); } $message_parser->parse($post_data['enable_bbcode'], $config['allow_post_links'] ? $post_data['enable_urls'] : false, $post_data['enable_smilies'], $img_status, $flash_status, $quote_status, $config['allow_post_links']); } else { $message_parser->bbcode_bitfield = $post_data['bbcode_bitfield']; } // Validate username if ($post_data['username'] && !$user->data['is_registered'] || $mode == 'edit' && $post_data['poster_id'] == ANONYMOUS && $post_data['username'] && $post_data['post_username'] && $post_data['post_username'] != $post_data['username']) { include $phpbb_root_path . 'includes/functions_user.' . $phpEx; if (($result = validate_username($post_data['username'], !empty($post_data['post_username']) ? $post_data['post_username'] : '')) !== false) { $user->add_lang('ucp'); trigger_error($result . '_USERNAME'); } } // Parse subject if (utf8_clean_string($post_data['post_subject']) === '' && $post_data['topic_first_post_id'] == $post_id) { trigger_error('EMPTY_SUBJECT'); } $post_data['poll_last_vote'] = isset($post_data['poll_last_vote']) ? $post_data['poll_last_vote'] : 0; if ($post_data['poll_option_text'] && $post_id == $post_data['topic_first_post_id'] && $auth->acl_get('f_poll', $forum_id)) { $poll = array('poll_title' => $post_data['poll_title'], 'poll_length' => $post_data['poll_length'], 'poll_max_options' => $post_data['poll_max_options'], 'poll_option_text' => $post_data['poll_option_text'], 'poll_start' => $post_data['poll_start'], 'poll_last_vote' => $post_data['poll_last_vote'], 'poll_vote_change' => $post_data['poll_vote_change'], 'enable_bbcode' => $post_data['enable_bbcode'], 'enable_urls' => $post_data['enable_urls'], 'enable_smilies' => $post_data['enable_smilies'], 'img_status' => $img_status); $message_parser->parse_poll($poll); $post_data['poll_options'] = isset($poll['poll_options']) ? $poll['poll_options'] : ''; $post_data['poll_title'] = isset($poll['poll_title']) ? $poll['poll_title'] : ''; } else { $poll = array(); } // Check topic type if ($post_data['topic_type'] != POST_NORMAL && $post_data['topic_first_post_id'] == $post_id) { switch ($post_data['topic_type']) { case POST_GLOBAL: case POST_ANNOUNCE: $auth_option = 'f_announce'; break; case POST_STICKY: $auth_option = 'f_sticky'; break; default: $auth_option = ''; break; } if (!$auth->acl_get($auth_option, $forum_id)) { // There is a special case where a user edits his post whereby the topic type got changed by an admin/mod. // Another case would be a mod not having sticky permissions for example but edit permissions. // To prevent non-authed users messing around with the topic type we reset it to the original one. $post_data['topic_type'] = $post_data['orig_topic_type']; } } // DNSBL check if ($config['check_dnsbl']) { if (($dnsbl = $user->check_dnsbl('post')) !== false) { trigger_error(sprintf($user->lang['IP_BLACKLISTED'], $user->ip, $dnsbl[1])); } } // Check if we want to de-globalize the topic... and ask for new forum if ($post_data['topic_type'] != POST_GLOBAL) { $sql = 'SELECT topic_type, forum_id FROM ' . TOPICS_TABLE . "\r\r\n WHERE topic_id = {$topic_id}"; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); if ($row && !$row['forum_id'] && $row['topic_type'] == POST_GLOBAL) { $to_forum_id = request_var('to_forum_id', 0); if ($to_forum_id) { $sql = 'SELECT forum_type FROM ' . FORUMS_TABLE . ' WHERE forum_id = ' . $to_forum_id; $result = $db->sql_query($sql); $forum_type = (int) $db->sql_fetchfield('forum_type'); $db->sql_freeresult($result); if ($forum_type != FORUM_POST || !$auth->acl_get('f_post', $to_forum_id)) { $to_forum_id = 0; } } if (!$to_forum_id) { include_once $phpbb_root_path . 'includes/functions_admin.' . $phpEx; $template->assign_vars(array('S_FORUM_SELECT' => make_forum_select(false, false, false, true, true, true), 'S_UNGLOBALISE' => true)); $submit = false; $refresh = true; } else { if (!$auth->acl_get('f_post', $to_forum_id)) { // This will only be triggered if the user tried to trick the forum. trigger_error('NOT_AUTHORISED'); } $forum_id = $to_forum_id; } } } // Lock/Unlock Topic $change_topic_status = $post_data['topic_status']; $perm_lock_unlock = $auth->acl_get('m_lock', $forum_id) || $auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && !empty($post_data['topic_poster']) && $user->data['user_id'] == $post_data['topic_poster'] && $post_data['topic_status'] == ITEM_UNLOCKED ? true : false; if ($post_data['topic_status'] == ITEM_LOCKED && !$topic_lock && $perm_lock_unlock) { $change_topic_status = ITEM_UNLOCKED; } else { if ($post_data['topic_status'] == ITEM_UNLOCKED && $topic_lock && $perm_lock_unlock) { $change_topic_status = ITEM_LOCKED; } } if ($change_topic_status != $post_data['topic_status']) { $sql = 'UPDATE ' . TOPICS_TABLE . "\r\r\n SET topic_status = {$change_topic_status}\r\r\n WHERE topic_id = {$topic_id}\r\r\n AND topic_moved_id = 0"; $db->sql_query($sql); $user_lock = $auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $post_data['topic_poster'] ? 'USER_' : ''; add_log('mod', $forum_id, $topic_id, 'LOG_' . $user_lock . ($change_topic_status == ITEM_LOCKED ? 'LOCK' : 'UNLOCK'), $post_data['topic_title']); } // Lock/Unlock Post Edit if ($mode == 'edit' && $post_data['post_edit_locked'] == ITEM_LOCKED && !$post_lock && $auth->acl_get('m_edit', $forum_id)) { $post_data['post_edit_locked'] = ITEM_UNLOCKED; } else { if ($mode == 'edit' && $post_data['post_edit_locked'] == ITEM_UNLOCKED && $post_lock && $auth->acl_get('m_edit', $forum_id)) { $post_data['post_edit_locked'] = ITEM_LOCKED; } } $data = array('topic_title' => empty($post_data['topic_title']) ? $post_data['post_subject'] : $post_data['topic_title'], 'topic_first_post_id' => isset($post_data['topic_first_post_id']) ? (int) $post_data['topic_first_post_id'] : 0, 'topic_last_post_id' => isset($post_data['topic_last_post_id']) ? (int) $post_data['topic_last_post_id'] : 0, 'topic_time_limit' => (int) $post_data['topic_time_limit'], 'topic_attachment' => isset($post_data['topic_attachment']) ? (int) $post_data['topic_attachment'] : 0, 'post_id' => (int) $post_id, 'topic_id' => (int) $topic_id, 'forum_id' => (int) $forum_id, 'icon_id' => (int) $post_data['icon_id'], 'poster_id' => (int) $post_data['poster_id'], 'enable_sig' => (bool) $post_data['enable_sig'], 'enable_bbcode' => (bool) $post_data['enable_bbcode'], 'enable_smilies' => (bool) $post_data['enable_smilies'], 'enable_urls' => (bool) $post_data['enable_urls'], 'enable_indexing' => (bool) $post_data['enable_indexing'], 'message_md5' => (string) $message_md5, 'post_time' => isset($post_data['post_time']) ? (int) $post_data['post_time'] : time(), 'post_checksum' => isset($post_data['post_checksum']) ? (string) $post_data['post_checksum'] : '', 'post_edit_reason' => $post_data['post_edit_reason'], 'post_edit_user' => $mode == 'edit' ? $user->data['user_id'] : (isset($post_data['post_edit_user']) ? (int) $post_data['post_edit_user'] : 0), 'forum_parents' => $post_data['forum_parents'], 'forum_name' => $post_data['forum_name'], 'notify' => $notify, 'poster_ip' => isset($post_data['poster_ip']) ? $post_data['poster_ip'] : $user->ip, 'post_edit_locked' => (int) $post_data['post_edit_locked'], 'bbcode_bitfield' => $message_parser->bbcode_bitfield, 'bbcode_uid' => $message_parser->bbcode_uid, 'message' => $message_parser->message, 'attachment_data' => $message_parser->attachment_data, 'filename_data' => $message_parser->filename_data, 'topic_approved' => isset($post_data['topic_approved']) ? $post_data['topic_approved'] : false, 'post_approved' => isset($post_data['post_approved']) ? $post_data['post_approved'] : false); $data['topic_replies_real'] = $post_data['topic_replies_real']; $data['topic_replies'] = $post_data['topic_replies']; include $phpbb_root_path . 'includes/functions_posting.' . $phpEx; $cwd = getcwd(); chdir('../'); $redirect_url = submit_post($mode, $post_data['post_subject'], $post_data['username'], $post_data['topic_type'], $poll, $data, $update_message); chdir($cwd); // Check the permissions for post approval, as well as the queue trigger where users are put on approval with a post count lower than specified. Moderators are not affected. $approved = true; if (($config['enable_queue_trigger'] && $user->data['user_posts'] < $config['queue_trigger_posts'] || !$auth->acl_get('f_noapprove', $data['forum_id'])) && !$auth->acl_get('m_approve', $data['forum_id'])) { $approved = false; } $reply_success = false; $post_id = ''; if ($redirect_url) { preg_match('/&p=(\\d+)/', $redirect_url, $matches); $post_id = $matches[1]; $reply_success = true; // get new post_content $message = censor_text($data['message']); $quote_wrote_string = $user->lang['WROTE']; $message = str_replace('[/quote:' . $data['bbcode_uid'] . ']', '[/quote]', $message); $message = preg_replace('/\\[quote(?:="(.*?)")?:' . $data['bbcode_uid'] . '\\]/ise', "'[quote]' . ('\$1' ? '\$1' . ' {$quote_wrote_string}:\n' : '\n')", $message); $blocks = preg_split('/(\\[\\/?quote\\])/i', $message, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); $quote_level = 0; $message = ''; foreach ($blocks as $block) { if ($block == '[quote]') { if ($quote_level == 0) { $message .= $block; } $quote_level++; } else { if ($block == '[/quote]') { if ($quote_level <= 1) { $message .= $block; } if ($quote_level >= 1) { $quote_level--; } } else { if ($quote_level <= 1) { $message .= $block; } } } } $message = preg_replace('/\\[(youtube|video|googlevideo|gvideo):' . $data['bbcode_uid'] . '\\](.*?)\\[\\/\\1:' . $data['bbcode_uid'] . '\\]/sie', "video_bbcode_format('\$1', '\$2')", $message); $message = preg_replace('/\\[(BBvideo)[\\d, ]+:' . $row['bbcode_uid'] . '\\](.*?)\\[\\/\\1:' . $row['bbcode_uid'] . '\\]/si', "[url=\$2]YouTube Video[/url]", $message); $message = preg_replace('/\\[(spoil|spoiler):' . $row['bbcode_uid'] . '\\](.*?)\\[\\/\\1:' . $row['bbcode_uid'] . '\\]/si', "[spoiler]\$2[/spoiler]", $message); $message = preg_replace('/\\[b:' . $data['bbcode_uid'] . '\\](.*?)\\[\\/b:' . $data['bbcode_uid'] . '\\]/si', '[b]$1[/b]', $message); $message = preg_replace('/\\[i:' . $data['bbcode_uid'] . '\\](.*?)\\[\\/i:' . $data['bbcode_uid'] . '\\]/si', '[i]$1[/i]', $message); $message = preg_replace('/\\[u:' . $data['bbcode_uid'] . '\\](.*?)\\[\\/u:' . $data['bbcode_uid'] . '\\]/si', '[u]$1[/u]', $message); $message = preg_replace('/\\[color=#(\\w{6}):' . $data['bbcode_uid'] . '\\](.*?)\\[\\/color:' . $data['bbcode_uid'] . '\\]/si', '[color=#$1]$2[/color]', $message); // Second parse bbcode here if ($data['bbcode_bitfield']) { $bbcode = new bbcode(base64_encode($data['bbcode_bitfield'])); $bbcode->bbcode_second_pass($message, $data['bbcode_uid'], $data['bbcode_bitfield']); } $message = bbcode_nl2br($message); $message = smiley_text($message); if (!empty($data['attachment_data'])) { parse_attachments($forum_id, $message, $data['attachment_data'], $update_count); } $updated_post_title = html_entity_decode(strip_tags(censor_text($data['topic_title'])), ENT_QUOTES, 'UTF-8'); } $xmlrpc_reply_topic = new xmlrpcval(array('result' => new xmlrpcval($reply_success, 'boolean'), 'state' => new xmlrpcval($approved ? 0 : 1, 'int'), 'post_title' => new xmlrpcval($updated_post_title, 'base64'), 'post_content' => new xmlrpcval(post_html_clean($message), 'base64')), 'struct'); return new xmlrpcresp($xmlrpc_reply_topic); }
function message_history($msg_id, $user_id, $message_row, $folder) { global $config, $site_file_root, $_CLASS, $bbcode; // Get History Messages (could be newer) $sql = 'SELECT t.*, p.*, u.* FROM ' . FORUMS_PRIVMSGS_TABLE . ' p, ' . FORUMS_PRIVMSGS_TO_TABLE . ' t, ' . USERS_TABLE . ' u WHERE t.msg_id = p.msg_id AND p.author_id = u.user_id AND t.folder_id <> ' . PRIVMSGS_NO_BOX . "\n\t\t\tAND t.user_id = {$user_id}"; if (!$message_row['root_level']) { $sql .= " AND (p.root_level = {$msg_id} OR (p.root_level = 0 AND p.msg_id = {$msg_id}))"; } else { $sql .= " AND (p.root_level = " . $message_row['root_level'] . ' OR p.msg_id = ' . $message_row['root_level'] . ')'; } $sql .= ' ORDER BY p.message_time '; $sort_dir = !empty($_CLASS['core_user']->data['user_sortby_dir']) ? $_CLASS['core_user']->data['user_sortby_dir'] : 'd'; $sql .= $sort_dir == 'd' ? 'ASC' : 'DESC'; $result = $_CLASS['core_db']->query($sql); if (!($row = $_CLASS['core_db']->fetch_row_assoc($result))) { return false; } $rowset = array(); $bbcode_bitfield = 0; $folder_url = 'Control_Panel&i=pm&folder='; $title = $sort_dir == 'd' ? $row['message_subject'] : ''; do { $folder_id = (int) $row['folder_id']; $row['folder'][] = isset($folder[$folder_id]) ? '<a href="' . generate_link($folder_url . $folder_id) . '">' . $folder[$folder_id]['folder_name'] . '</a>' : $_CLASS['core_user']->lang['UNKOWN_FOLDER']; if (isset($rowset[$row['msg_id']])) { $rowset[$row['msg_id']]['folder'][] = isset($folder[$folder_id]) ? '<a href="' . generate_link($folder_url . $folder_id) . '">' . $folder[$folder_id]['folder_name'] . '</a>' : $_CLASS['core_user']->lang['UNKOWN_FOLDER']; } else { $rowset[$row['msg_id']] = $row; $bbcode_bitfield |= $row['bbcode_bitfield']; } } while ($row = $_CLASS['core_db']->fetch_row_assoc($result)); $_CLASS['core_db']->free_result($result); $title = $sort_dir == 'a' ? $row['message_subject'] : $title; if (sizeof($rowset) == 1) { return false; } // Instantiate BBCode class if (!isset($bbcode) && $bbcode_bitfield) { if (!class_exists('bbcode')) { require $site_file_root . 'includes/forums/bbcode.php'; } $bbcode = new bbcode($bbcode_bitfield); } $title = censor_text($title); $url = 'Control_Panel&i=pm'; $next_history_pm = $previous_history_pm = $prev_id = 0; foreach ($rowset as $id => $row) { $author_id = $row['author_id']; $author = $row['username']; $folder_id = (int) $row['folder_id']; $subject = $row['message_subject']; $message = $row['message_text']; if ($row['bbcode_bitfield']) { $bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']); } $message = smiley_text($message, !$row['enable_smilies']); $subject = censor_text($subject); $message = censor_text($message); if ($id == $msg_id) { $next_history_pm = next($rowset); $next_history_pm = sizeof($next_history_pm) ? (int) $next_history_pm['msg_id'] : 0; $previous_history_pm = $prev_id; } $_CLASS['core_template']->assign_vars_array('history_row', array('AUTHOR_NAME' => $author, 'SUBJECT' => $subject, 'SENT_DATE' => $_CLASS['core_user']->format_date($row['message_time']), 'MESSAGE' => str_replace("\n", '<br />', $message), 'FOLDER' => implode(', ', $row['folder']), 'S_CURRENT_MSG' => $row['msg_id'] == $msg_id, 'U_MSG_ID' => $row['msg_id'], 'U_VIEW_MESSAGE' => generate_link("{$url}&f={$folder_id}&p=" . $row['msg_id']), 'U_AUTHOR_PROFILE' => generate_link('Members_List&mode=viewprofile&u=' . $author_id), 'U_QUOTE' => $_CLASS['auth']->acl_get('u_sendpm') && $author_id != $_CLASS['core_user']->data['user_id'] ? generate_link("{$url}&mode=compose&action=quote&f=" . $folder_id . "&p=" . $row['msg_id']) : '', 'U_POST_REPLY_PM' => $author_id != $_CLASS['core_user']->data['user_id'] && $_CLASS['auth']->acl_get('u_sendpm') ? generate_link("{$url}&mode=compose&action=reply&f={$folder_id}&p=" . $row['msg_id']) : '')); unset($rowset[$id]); $prev_id = $id; } $_CLASS['core_template']->assign(array('QUOTE_IMG' => $_CLASS['core_user']->img('btn_quote', $_CLASS['core_user']->lang['REPLY_WITH_QUOTE']), 'TITLE' => $title, 'U_VIEW_NEXT_HISTORY' => generate_link("{$url}&p=" . ($next_history_pm ? $next_history_pm : $msg_id)), 'U_VIEW_PREVIOUS_HISTORY' => generate_link("{$url}&p=" . ($previous_history_pm ? $previous_history_pm : $msg_id)))); return true; }
$user_cache[$poster_id]['sig'] = censor_text($user_cache[$poster_id]['sig']); if ($user_cache[$poster_id]['sig_bbcode_bitfield']) { $bbcode->bbcode_second_pass($user_cache[$poster_id]['sig'], $user_cache[$poster_id]['sig_bbcode_uid'], $user_cache[$poster_id]['sig_bbcode_bitfield']); } $user_cache[$poster_id]['sig'] = bbcode_nl2br($user_cache[$poster_id]['sig']); $user_cache[$poster_id]['sig'] = smiley_text($user_cache[$poster_id]['sig']); $user_cache[$poster_id]['sig_parsed'] = true; } // Parse the message and subject $message = censor_text($row['post_text']); // Second parse bbcode here if ($row['bbcode_bitfield']) { $bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']); } $message = bbcode_nl2br($message); $message = smiley_text($message); if (!empty($attachments[$row['post_id']])) { parse_attachments($forum_id, $message, $attachments[$row['post_id']], $update_count); } // Replace naughty words such as farty pants $row['post_subject'] = censor_text($row['post_subject']); // Highlight active words (primarily for search) if ($highlight_match) { $message = preg_replace('#(?!<.*)(?<!\\w)(' . $highlight_match . ')(?!\\w|[^<>]*(?:</s(?:cript|tyle))?>)#is', '<span class="posthilit">\\1</span>', $message); $row['post_subject'] = preg_replace('#(?!<.*)(?<!\\w)(' . $highlight_match . ')(?!\\w|[^<>]*(?:</s(?:cript|tyle))?>)#is', '<span class="posthilit">\\1</span>', $row['post_subject']); } // Editing information if ($row['post_edit_count'] && $config['display_last_edited'] || $row['post_edit_reason']) { // Get usernames for all following posts if not already stored if (!sizeof($post_edit_list) && ($row['post_edit_reason'] || $row['post_edit_user'] && !isset($user_cache[$row['post_edit_user']]))) { // Remove all post_ids already parsed (we do not have to check them)
/** * View private message */ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row) { global $user, $template, $auth, $db, $cache; global $phpbb_root_path, $phpEx, $config; $user->add_lang(array('viewtopic', 'memberlist')); $msg_id = (int) $msg_id; $folder_id = (int) $folder_id; $author_id = (int) $message_row['author_id']; $view = request_var('view', ''); // Not able to view message, it was deleted by the sender if ($message_row['pm_deleted']) { $meta_info = append_sid("{$phpbb_root_path}ucp.{$phpEx}", "i=pm&folder={$folder_id}"); $message = $user->lang['NO_AUTH_READ_REMOVED_MESSAGE']; $message .= '<br /><br />' . sprintf($user->lang['RETURN_FOLDER'], '<a href="' . $meta_info . '">', '</a>'); trigger_error($message); } // Do not allow hold messages to be seen if ($folder_id == PRIVMSGS_HOLD_BOX) { trigger_error('NO_AUTH_READ_HOLD_MESSAGE'); } // Grab icons $icons = $cache->obtain_icons(); $bbcode = false; // Instantiate BBCode if need be if ($message_row['bbcode_bitfield']) { include $phpbb_root_path . 'includes/bbcode.' . $phpEx; $bbcode = new bbcode($message_row['bbcode_bitfield']); } // Assign TO/BCC Addresses to template write_pm_addresses(array('to' => $message_row['to_address'], 'bcc' => $message_row['bcc_address']), $author_id); $user_info = get_user_information($author_id, $message_row); // Parse the message and subject $message = censor_text($message_row['message_text']); // Second parse bbcode here if ($message_row['bbcode_bitfield']) { $bbcode->bbcode_second_pass($message, $message_row['bbcode_uid'], $message_row['bbcode_bitfield']); } // Always process smilies after parsing bbcodes $message = bbcode_nl2br($message); $message = smiley_text($message); // Replace naughty words such as farty pants $message_row['message_subject'] = censor_text($message_row['message_subject']); // Editing information if ($message_row['message_edit_count'] && $config['display_last_edited']) { $l_edit_time_total = $message_row['message_edit_count'] == 1 ? $user->lang['EDITED_TIME_TOTAL'] : $user->lang['EDITED_TIMES_TOTAL']; $l_edited_by = '<br /><br />' . sprintf($l_edit_time_total, !$message_row['message_edit_user'] ? $message_row['username'] : $message_row['message_edit_user'], $user->format_date($message_row['message_edit_time'], false, true), $message_row['message_edit_count']); } else { $l_edited_by = ''; } // Pull attachment data $display_notice = false; $attachments = array(); if ($message_row['message_attachment'] && $config['allow_pm_attach']) { if ($auth->acl_get('u_pm_download')) { $sql = 'SELECT * FROM ' . ATTACHMENTS_TABLE . "\n\t\t\t\tWHERE post_msg_id = {$msg_id}\n\t\t\t\t\tAND in_message = 1\n\t\t\t\tORDER BY filetime DESC, post_msg_id ASC"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $attachments[] = $row; } $db->sql_freeresult($result); // No attachments exist, but message table thinks they do so go ahead and reset attach flags if (!sizeof($attachments)) { $sql = 'UPDATE ' . PRIVMSGS_TABLE . "\n\t\t\t\t\tSET message_attachment = 0\n\t\t\t\t\tWHERE msg_id = {$msg_id}"; $db->sql_query($sql); } } else { $display_notice = true; } } // Assign inline attachments if (!empty($attachments)) { $update_count = array(); parse_attachments(false, $message, $attachments, $update_count); // Update the attachment download counts if (sizeof($update_count)) { $sql = 'UPDATE ' . ATTACHMENTS_TABLE . ' SET download_count = download_count + 1 WHERE ' . $db->sql_in_set('attach_id', array_unique($update_count)); $db->sql_query($sql); } } $user_info['sig'] = ''; $signature = $message_row['enable_sig'] && $config['allow_sig'] && $auth->acl_get('u_sig') && $user->optionget('viewsigs') ? $user_info['user_sig'] : ''; // End signature parsing, only if needed if ($signature) { $signature = censor_text($signature); if ($user_info['user_sig_bbcode_bitfield']) { if ($bbcode === false) { include $phpbb_root_path . 'includes/bbcode.' . $phpEx; $bbcode = new bbcode($user_info['user_sig_bbcode_bitfield']); } $bbcode->bbcode_second_pass($signature, $user_info['user_sig_bbcode_uid'], $user_info['user_sig_bbcode_bitfield']); } $signature = bbcode_nl2br($signature); $signature = smiley_text($signature); } $url = append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=pm'); // Number of "to" recipients $num_recipients = (int) preg_match_all('/:?(u|g)_([0-9]+):?/', $message_row['to_address'], $match); $template->assign_vars(array('MESSAGE_AUTHOR_FULL' => get_username_string('full', $author_id, $user_info['username'], $user_info['user_colour'], $user_info['username']), 'MESSAGE_AUTHOR_COLOUR' => get_username_string('colour', $author_id, $user_info['username'], $user_info['user_colour'], $user_info['username']), 'MESSAGE_AUTHOR' => get_username_string('username', $author_id, $user_info['username'], $user_info['user_colour'], $user_info['username']), 'U_MESSAGE_AUTHOR' => get_username_string('profile', $author_id, $user_info['username'], $user_info['user_colour'], $user_info['username']), 'RANK_TITLE' => $user_info['rank_title'], 'RANK_IMG' => $user_info['rank_image'], 'AUTHOR_AVATAR' => isset($user_info['avatar']) ? $user_info['avatar'] : '', 'AUTHOR_JOINED' => $user->format_date($user_info['user_regdate']), 'AUTHOR_POSTS' => (int) $user_info['user_posts'], 'AUTHOR_FROM' => !empty($user_info['user_from']) ? $user_info['user_from'] : '', 'ONLINE_IMG' => !$config['load_onlinetrack'] ? '' : (isset($user_info['online']) && $user_info['online'] ? $user->img('icon_user_online', $user->lang['ONLINE']) : $user->img('icon_user_offline', $user->lang['OFFLINE'])), 'S_ONLINE' => !$config['load_onlinetrack'] ? false : (isset($user_info['online']) && $user_info['online'] ? true : false), 'DELETE_IMG' => $user->img('icon_post_delete', $user->lang['DELETE_MESSAGE']), 'INFO_IMG' => $user->img('icon_post_info', $user->lang['VIEW_PM_INFO']), 'PROFILE_IMG' => $user->img('icon_user_profile', $user->lang['READ_PROFILE']), 'EMAIL_IMG' => $user->img('icon_contact_email', $user->lang['SEND_EMAIL']), 'QUOTE_IMG' => $user->img('icon_post_quote', $user->lang['POST_QUOTE_PM']), 'REPLY_IMG' => $user->img('button_pm_reply', $user->lang['POST_REPLY_PM']), 'REPORT_IMG' => $user->img('icon_post_report', 'REPORT_PM'), 'EDIT_IMG' => $user->img('icon_post_edit', $user->lang['POST_EDIT_PM']), 'MINI_POST_IMG' => $user->img('icon_post_target', $user->lang['PM']), 'SENT_DATE' => $view == 'print' ? $user->format_date($message_row['message_time'], false, true) : $user->format_date($message_row['message_time']), 'SUBJECT' => $message_row['message_subject'], 'MESSAGE' => $message, 'SIGNATURE' => $message_row['enable_sig'] ? $signature : '', 'EDITED_MESSAGE' => $l_edited_by, 'MESSAGE_ID' => $message_row['msg_id'], 'U_PM' => $config['allow_privmsg'] && $auth->acl_get('u_sendpm') && ($user_info['user_allow_pm'] || $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=pm&mode=compose&u=' . $author_id) : '', 'U_WWW' => !empty($user_info['user_website']) ? $user_info['user_website'] : '', 'U_ICQ' => $user_info['user_icq'] ? 'http://www.icq.com/people/webmsg.php?to=' . urlencode($user_info['user_icq']) : '', 'U_AIM' => $user_info['user_aim'] && $auth->acl_get('u_sendim') ? append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=contact&action=aim&u=' . $author_id) : '', 'U_YIM' => $user_info['user_yim'] ? 'http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($user_info['user_yim']) . '&.src=pg' : '', 'U_MSN' => $user_info['user_msnm'] && $auth->acl_get('u_sendim') ? append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=contact&action=msnm&u=' . $author_id) : '', 'U_JABBER' => $user_info['user_jabber'] && $auth->acl_get('u_sendim') ? append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=contact&action=jabber&u=' . $author_id) : '', 'U_DELETE' => $auth->acl_get('u_pm_delete') ? "{$url}&mode=compose&action=delete&f={$folder_id}&p=" . $message_row['msg_id'] : '', 'U_EMAIL' => $user_info['email'], 'U_REPORT' => $config['allow_pm_report'] ? append_sid("{$phpbb_root_path}report.{$phpEx}", "pm=" . $message_row['msg_id']) : '', 'U_QUOTE' => $auth->acl_get('u_sendpm') && $author_id != ANONYMOUS ? "{$url}&mode=compose&action=quote&f={$folder_id}&p=" . $message_row['msg_id'] : '', 'U_EDIT' => ($message_row['message_time'] > time() - $config['pm_edit_time'] * 60 || !$config['pm_edit_time']) && $folder_id == PRIVMSGS_OUTBOX && $auth->acl_get('u_pm_edit') ? "{$url}&mode=compose&action=edit&f={$folder_id}&p=" . $message_row['msg_id'] : '', 'U_POST_REPLY_PM' => $auth->acl_get('u_sendpm') && $author_id != ANONYMOUS ? "{$url}&mode=compose&action=reply&f={$folder_id}&p=" . $message_row['msg_id'] : '', 'U_POST_REPLY_ALL' => $auth->acl_get('u_sendpm') && $author_id != ANONYMOUS ? "{$url}&mode=compose&action=reply&f={$folder_id}&reply_to_all=1&p=" . $message_row['msg_id'] : '', 'U_PREVIOUS_PM' => "{$url}&f={$folder_id}&p=" . $message_row['msg_id'] . "&view=previous", 'U_NEXT_PM' => "{$url}&f={$folder_id}&p=" . $message_row['msg_id'] . "&view=next", 'U_PM_ACTION' => $url . '&mode=compose&f=' . $folder_id . '&p=' . $message_row['msg_id'], 'S_HAS_ATTACHMENTS' => sizeof($attachments) ? true : false, 'S_DISPLAY_NOTICE' => $display_notice && $message_row['message_attachment'], 'S_AUTHOR_DELETED' => $author_id == ANONYMOUS ? true : false, 'S_SPECIAL_FOLDER' => in_array($folder_id, array(PRIVMSGS_NO_BOX, PRIVMSGS_OUTBOX)), 'S_PM_RECIPIENTS' => $num_recipients, 'U_PRINT_PM' => $config['print_pm'] && $auth->acl_get('u_pm_printpm') ? "{$url}&f={$folder_id}&p=" . $message_row['msg_id'] . "&view=print" : '', 'U_FORWARD_PM' => $config['forward_pm'] && $auth->acl_get('u_sendpm') && $auth->acl_get('u_pm_forward') ? "{$url}&mode=compose&action=forward&f={$folder_id}&p=" . $message_row['msg_id'] : '')); // Display not already displayed Attachments for this post, we already parsed them. ;) if (isset($attachments) && sizeof($attachments)) { foreach ($attachments as $attachment) { $template->assign_block_vars('attachment', array('DISPLAY_ATTACHMENT' => $attachment)); } } if (!isset($_REQUEST['view']) || $_REQUEST['view'] != 'print') { // Message History if (message_history($msg_id, $user->data['user_id'], $message_row, $folder)) { $template->assign_var('S_DISPLAY_HISTORY', true); } } }
/** * Handling actions in post details screen */ function mcp_post_details($id, $mode, $action) { global $phpEx, $phpbb_root_path, $config; global $template, $db, $user, $auth, $cache; $user->add_lang('posting'); $post_id = request_var('p', 0); $start = request_var('start', 0); // Get post data $post_info = get_post_data(array($post_id), false, true); add_form_key('mcp_post_details'); if (!sizeof($post_info)) { trigger_error('POST_NOT_EXIST'); } $post_info = $post_info[$post_id]; $url = append_sid("{$phpbb_root_path}mcp.{$phpEx}?" . extra_url()); switch ($action) { case 'whois': if ($auth->acl_get('m_info', $post_info['forum_id'])) { $ip = request_var('ip', ''); include $phpbb_root_path . 'includes/functions_user.' . $phpEx; $template->assign_vars(array('RETURN_POST' => sprintf($user->lang['RETURN_POST'], '<a href="' . append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i={$id}&mode={$mode}&p={$post_id}") . '">', '</a>'), 'U_RETURN_POST' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i={$id}&mode={$mode}&p={$post_id}"), 'L_RETURN_POST' => sprintf($user->lang['RETURN_POST'], '', ''), 'WHOIS' => user_ipwhois($ip))); } // We're done with the whois page so return return; break; case 'chgposter': case 'chgposter_ip': if ($action == 'chgposter') { $username = request_var('username', '', true); $sql_where = "username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'"; } else { $new_user_id = request_var('u', 0); $sql_where = 'user_id = ' . $new_user_id; } $sql = 'SELECT * FROM ' . USERS_TABLE . ' WHERE ' . $sql_where; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); if (!$row) { trigger_error('NO_USER'); } if ($auth->acl_get('m_chgposter', $post_info['forum_id'])) { if (check_form_key('mcp_post_details')) { change_poster($post_info, $row); } else { trigger_error('FORM_INVALID'); } } break; } // Set some vars $users_ary = $usernames_ary = array(); $attachments = $extensions = array(); $post_id = $post_info['post_id']; $topic_tracking_info = array(); // Get topic tracking info if ($config['load_db_lastread']) { $tmp_topic_data = array($post_info['topic_id'] => $post_info); $topic_tracking_info = get_topic_tracking($post_info['forum_id'], $post_info['topic_id'], $tmp_topic_data, array($post_info['forum_id'] => $post_info['forum_mark_time'])); unset($tmp_topic_data); } else { $topic_tracking_info = get_complete_topic_tracking($post_info['forum_id'], $post_info['topic_id']); } $post_unread = isset($topic_tracking_info[$post_info['topic_id']]) && $post_info['post_time'] > $topic_tracking_info[$post_info['topic_id']] ? true : false; // Process message, leave it uncensored $message = $post_info['post_text']; if ($post_info['bbcode_bitfield']) { include_once $phpbb_root_path . 'includes/bbcode.' . $phpEx; $bbcode = new bbcode($post_info['bbcode_bitfield']); $bbcode->bbcode_second_pass($message, $post_info['bbcode_uid'], $post_info['bbcode_bitfield']); } $message = bbcode_nl2br($message); $message = smiley_text($message); if ($post_info['post_attachment'] && $auth->acl_get('u_download') && $auth->acl_get('f_download', $post_info['forum_id'])) { $extensions = $cache->obtain_attach_extensions($post_info['forum_id']); $sql = 'SELECT * FROM ' . ATTACHMENTS_TABLE . ' WHERE post_msg_id = ' . $post_id . ' AND in_message = 0 ORDER BY filetime DESC, post_msg_id ASC'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $attachments[] = $row; } $db->sql_freeresult($result); if (sizeof($attachments)) { $update_count = array(); parse_attachments($post_info['forum_id'], $message, $attachments, $update_count); } // Display not already displayed Attachments for this post, we already parsed them. ;) if (!empty($attachments)) { $template->assign_var('S_HAS_ATTACHMENTS', true); foreach ($attachments as $attachment) { $template->assign_block_vars('attachment', array('DISPLAY_ATTACHMENT' => $attachment)); } } } $template->assign_vars(array('U_MCP_ACTION' => "{$url}&i=main&quickmod=1&mode=post_details", 'U_POST_ACTION' => "{$url}&i={$id}&mode=post_details", 'U_APPROVE_ACTION' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i=queue&p={$post_id}&f={$post_info['forum_id']}"), 'S_CAN_VIEWIP' => $auth->acl_get('m_info', $post_info['forum_id']), 'S_CAN_CHGPOSTER' => $auth->acl_get('m_chgposter', $post_info['forum_id']), 'S_CAN_LOCK_POST' => $auth->acl_get('m_lock', $post_info['forum_id']), 'S_CAN_DELETE_POST' => $auth->acl_get('m_delete', $post_info['forum_id']), 'S_POST_REPORTED' => $post_info['post_reported'] ? true : false, 'S_POST_UNAPPROVED' => !$post_info['post_approved'] ? true : false, 'S_POST_LOCKED' => $post_info['post_edit_locked'] ? true : false, 'S_USER_NOTES' => true, 'S_CLEAR_ALLOWED' => $auth->acl_get('a_clearlogs') ? true : false, 'U_EDIT' => $auth->acl_get('m_edit', $post_info['forum_id']) ? append_sid("{$phpbb_root_path}posting.{$phpEx}", "mode=edit&f={$post_info['forum_id']}&p={$post_info['post_id']}") : '', 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=searchuser&form=mcp_chgposter&field=username&select_single=true'), 'U_MCP_APPROVE' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue&mode=approve_details&f=' . $post_info['forum_id'] . '&p=' . $post_id), 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=reports&mode=report_details&f=' . $post_info['forum_id'] . '&p=' . $post_id), 'U_MCP_USER_NOTES' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=notes&mode=user_notes&u=' . $post_info['user_id']), 'U_MCP_WARN_USER' => $auth->acl_get('m_warn') ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=warn&mode=warn_user&u=' . $post_info['user_id']) : '', 'U_VIEW_POST' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $post_info['forum_id'] . '&p=' . $post_info['post_id'] . '#p' . $post_info['post_id']), 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $post_info['forum_id'] . '&t=' . $post_info['topic_id']), 'MINI_POST_IMG' => $post_unread ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'), 'RETURN_TOPIC' => sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "f={$post_info['forum_id']}&p={$post_id}") . "#p{$post_id}\">", '</a>'), 'RETURN_FORUM' => sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.{$phpEx}", "f={$post_info['forum_id']}&start={$start}") . '">', '</a>'), 'REPORTED_IMG' => $user->img('icon_topic_reported', $user->lang['POST_REPORTED']), 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', $user->lang['POST_UNAPPROVED']), 'EDIT_IMG' => $user->img('icon_post_edit', $user->lang['EDIT_POST']), 'SEARCH_IMG' => $user->img('icon_user_search', $user->lang['SEARCH']), 'POST_AUTHOR_FULL' => get_username_string('full', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), 'POST_AUTHOR_COLOUR' => get_username_string('colour', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), 'POST_AUTHOR' => get_username_string('username', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), 'U_POST_AUTHOR' => get_username_string('profile', $post_info['user_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']), 'POST_PREVIEW' => $message, 'POST_SUBJECT' => $post_info['post_subject'], 'POST_DATE' => $user->format_date($post_info['post_time']), 'POST_IP' => $post_info['poster_ip'], 'POST_IPADDR' => $auth->acl_get('m_info', $post_info['forum_id']) && request_var('lookup', '') ? @gethostbyaddr($post_info['poster_ip']) : '', 'POST_ID' => $post_info['post_id'], 'U_LOOKUP_IP' => $auth->acl_get('m_info', $post_info['forum_id']) ? "{$url}&i={$id}&mode={$mode}&lookup={$post_info['poster_ip']}#ip" : '', 'U_WHOIS' => $auth->acl_get('m_info', $post_info['forum_id']) ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i={$id}&mode={$mode}&action=whois&p={$post_id}&ip={$post_info['poster_ip']}") : '')); // Get User Notes $log_data = array(); $log_count = false; view_log('user', $log_data, $log_count, $config['posts_per_page'], 0, 0, 0, $post_info['user_id']); if (!empty($log_data)) { $template->assign_var('S_USER_NOTES', true); foreach ($log_data as $row) { $template->assign_block_vars('usernotes', array('REPORT_BY' => $row['username_full'], 'REPORT_AT' => $user->format_date($row['time']), 'ACTION' => $row['action'], 'ID' => $row['id'])); } } // Get Reports if ($auth->acl_get('m_report', $post_info['forum_id'])) { $sql = 'SELECT r.*, re.*, u.user_id, u.username FROM ' . REPORTS_TABLE . ' r, ' . USERS_TABLE . ' u, ' . REPORTS_REASONS_TABLE . " re\n\t\t\tWHERE r.post_id = {$post_id}\n\t\t\t\tAND r.reason_id = re.reason_id\n\t\t\t\tAND u.user_id = r.user_id\n\t\t\tORDER BY r.report_time DESC"; $result = $db->sql_query($sql); if ($row = $db->sql_fetchrow($result)) { $template->assign_var('S_SHOW_REPORTS', true); do { // If the reason is defined within the language file, we will use the localized version, else just use the database entry... if (isset($user->lang['report_reasons']['TITLE'][strtoupper($row['reason_title'])]) && isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])])) { $row['reson_description'] = $user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])]; $row['reason_title'] = $user->lang['report_reasons']['TITLE'][strtoupper($row['reason_title'])]; } $template->assign_block_vars('reports', array('REPORT_ID' => $row['report_id'], 'REASON_TITLE' => $row['reason_title'], 'REASON_DESC' => $row['reason_description'], 'REPORTER' => $row['user_id'] != ANONYMOUS ? $row['username'] : $user->lang['GUEST'], 'U_REPORTER' => $row['user_id'] != ANONYMOUS ? append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=viewprofile&u=' . $row['user_id']) : '', 'USER_NOTIFY' => $row['user_notify'] ? true : false, 'REPORT_TIME' => $user->format_date($row['report_time']), 'REPORT_TEXT' => bbcode_nl2br(trim($row['report_text'])))); } while ($row = $db->sql_fetchrow($result)); } $db->sql_freeresult($result); } // Get IP if ($auth->acl_get('m_info', $post_info['forum_id'])) { $rdns_ip_num = request_var('rdns', ''); if ($rdns_ip_num != 'all') { $template->assign_vars(array('U_LOOKUP_ALL' => "{$url}&i=main&mode=post_details&rdns=all")); } // Get other users who've posted under this IP $sql = 'SELECT poster_id, COUNT(poster_id) as postings FROM ' . POSTS_TABLE . "\n\t\t\tWHERE poster_ip = '" . $db->sql_escape($post_info['poster_ip']) . "'\n\t\t\tGROUP BY poster_id\n\t\t\tORDER BY postings DESC"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { // Fill the user select list with users who have posted under this IP if ($row['poster_id'] != $post_info['poster_id']) { $users_ary[$row['poster_id']] = $row; } } $db->sql_freeresult($result); if (sizeof($users_ary)) { // Get the usernames $sql = 'SELECT user_id, username FROM ' . USERS_TABLE . ' WHERE ' . $db->sql_in_set('user_id', array_keys($users_ary)); $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $users_ary[$row['user_id']]['username'] = $row['username']; $usernames_ary[utf8_clean_string($row['username'])] = $users_ary[$row['user_id']]; } $db->sql_freeresult($result); foreach ($users_ary as $user_id => $user_row) { $template->assign_block_vars('userrow', array('USERNAME' => $user_id == ANONYMOUS ? $user->lang['GUEST'] : $user_row['username'], 'NUM_POSTS' => $user_row['postings'], 'L_POST_S' => $user_row['postings'] == 1 ? $user->lang['POST'] : $user->lang['POSTS'], 'U_PROFILE' => $user_id == ANONYMOUS ? '' : append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=viewprofile&u=' . $user_id), 'U_SEARCHPOSTS' => append_sid("{$phpbb_root_path}search.{$phpEx}", 'author_id=' . $user_id . '&sr=topics'))); } } // Get other IP's this user has posted under // A compound index on poster_id, poster_ip (posts table) would help speed up this query a lot, // but the extra size is only valuable if there are persons having more than a thousands posts. // This is better left to the really really big forums. $sql = 'SELECT poster_ip, COUNT(poster_ip) AS postings FROM ' . POSTS_TABLE . ' WHERE poster_id = ' . $post_info['poster_id'] . "\n\t\t\tGROUP BY poster_ip\n\t\t\tORDER BY postings DESC"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $hostname = ($rdns_ip_num == $row['poster_ip'] || $rdns_ip_num == 'all') && $row['poster_ip'] ? @gethostbyaddr($row['poster_ip']) : ''; $template->assign_block_vars('iprow', array('IP' => $row['poster_ip'], 'HOSTNAME' => $hostname, 'NUM_POSTS' => $row['postings'], 'L_POST_S' => $row['postings'] == 1 ? $user->lang['POST'] : $user->lang['POSTS'], 'U_LOOKUP_IP' => $rdns_ip_num == $row['poster_ip'] || $rdns_ip_num == 'all' ? '' : "{$url}&i={$id}&mode=post_details&rdns={$row['poster_ip']}#ip", 'U_WHOIS' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i={$id}&mode={$mode}&action=whois&p={$post_id}&ip={$row['poster_ip']}"))); } $db->sql_freeresult($result); $user_select = ''; if (sizeof($usernames_ary)) { ksort($usernames_ary); foreach ($usernames_ary as $row) { $user_select .= '<option value="' . $row['poster_id'] . '">' . $row['username'] . "</option>\n"; } } $template->assign_var('S_USER_SELECT', $user_select); } }
/** * Formatting text for display */ function format_display($allow_bbcode, $allow_magic_url, $allow_smilies, $update_this_message = true) { global $src_dispatcher; // If false, then the parsed message get returned but internal message not processed. if (!$update_this_message) { $tmp_message = $this->message; $return_message =& $this->message; } if ($this->message_status == 'plain') { // Force updating message - of course. $this->parse($allow_bbcode, $allow_magic_url, $allow_smilies, $this->allow_img_bbcode, $this->allow_flash_bbcode, $this->allow_quote_bbcode, $this->allow_url_bbcode, true); } // Replace naughty words such as farty pants $this->message = censor_text($this->message); // Parse BBcode if ($allow_bbcode) { $this->bbcode_cache_init(); // We are giving those parameters to be able to use the bbcode class on its own $this->bbcode_second_pass($this->message, $this->bbcode_uid); } $this->message = bbcode_nl2br($this->message); $this->message = smiley_text($this->message, !$allow_smilies); $text = $this->message; $uid = $this->bbcode_uid; /** * Event to modify the text after it is parsed * * @event core.modify_format_display_text_after * @var string text The message text to parse * @var string uid The bbcode uid * @var bool allow_bbcode Do we allow bbcodes * @var bool allow_magic_url Do we allow magic urls * @var bool allow_smilies Do we allow smilies * @var bool update_this_message Do we update the internal message * with the parsed result * @since 3.1.0-a3 */ $vars = array('text', 'uid', 'allow_bbcode', 'allow_magic_url', 'allow_smilies', 'update_this_message'); extract($src_dispatcher->trigger_event('core.modify_format_display_text_after', compact($vars))); $this->message = $text; $this->bbcode_uid = $uid; if (!$update_this_message) { unset($this->message); $this->message = $tmp_message; return $return_message; } $this->message_status = 'display'; return false; }
/** * Parse template variables for module * * @param int $module_id Module ID * @param string $type Module type (center or side) * * @return string HTML filename */ protected function parse_template($module_id, $type = '') { $this->user->add_lang('viewtopic'); // check if we need to include the bbcode class if (!class_exists('bbcode')) { include $this->phpbb_root_path . 'includes/bbcode.' . $this->php_ext; } $view = $this->request->variable('view', ''); $update = $this->request->variable('update', false); $poll_view = $this->request->variable('polls', ''); $poll_view_ar = strpos($poll_view, ',') !== false ? explode(',', $poll_view) : ($poll_view != '' ? array($poll_view) : array()); if ($update && $this->config['board3_poll_allow_vote_' . $module_id]) { $up_topic_id = $this->request->variable('t', 0); $up_forum_id = $this->request->variable('f', 0); $voted_id = $this->request->variable('vote_id', array('' => 0)); $cur_voted_id = array(); if ($this->user->data['is_registered']) { $sql = 'SELECT poll_option_id FROM ' . POLL_VOTES_TABLE . ' WHERE topic_id = ' . (int) $up_topic_id . ' AND vote_user_id = ' . (int) $this->user->data['user_id']; $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { $cur_voted_id[] = $row['poll_option_id']; } $this->db->sql_freeresult($result); } else { // Cookie based guest tracking ... I don't like this but hum ho // it's oft requested. This relies on "nice" users who don't feel // the need to delete cookies to mess with results. if ($this->request->is_set($this->config['cookie_name'] . '_poll_' . $up_topic_id, \phpbb\request\request_interface::COOKIE)) { $cur_voted_id = explode(',', $this->request->variable($this->config['cookie_name'] . '_poll_' . $up_topic_id, '', true, \phpbb\request\request_interface::COOKIE)); $cur_voted_id = array_map('intval', $cur_voted_id); } } $sql = 'SELECT t.poll_length, t.poll_start, t.poll_vote_change, t.topic_status, f.forum_status, t.poll_max_options FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . " f\n\t\t\t\tWHERE t.forum_id = f.forum_id\n\t\t\t\t\tAND t.topic_id = " . (int) $up_topic_id . "\n\t\t\t\t\tAND t.forum_id = " . (int) $up_forum_id; $result = $this->db->sql_query_limit($sql, 1); $topic_data = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); $s_can_up_vote = (!sizeof($cur_voted_id) && $this->auth->acl_get('f_vote', $up_forum_id) || $this->auth->acl_get('f_votechg', $up_forum_id) && $topic_data['poll_vote_change']) && ($topic_data['poll_length'] != 0 && $topic_data['poll_start'] + $topic_data['poll_length'] > time() || $topic_data['poll_length'] == 0) && $topic_data['topic_status'] != ITEM_LOCKED && $topic_data['forum_status'] != ITEM_LOCKED ? true : false; if ($s_can_up_vote) { $redirect_url = $this->modules_helper->route('board3_portal_controller'); if (!sizeof($voted_id) || sizeof($voted_id) > $topic_data['poll_max_options'] || in_array(VOTE_CONVERTED, $cur_voted_id)) { meta_refresh(5, $redirect_url); if (!sizeof($voted_id)) { $message = 'NO_VOTE_OPTION'; } else { if (sizeof($voted_id) > $topic_data['poll_max_options']) { $message = 'TOO_MANY_VOTE_OPTIONS'; } else { $message = 'VOTE_CONVERTED'; } } $message = $this->user->lang[$message] . '<br /><br />' . sprintf($this->user->lang['RETURN_PORTAL'], '<a href="' . $redirect_url . '">', '</a>'); trigger_error($message); } foreach ($voted_id as $option) { if (in_array($option, $cur_voted_id)) { continue; } $sql = 'UPDATE ' . POLL_OPTIONS_TABLE . ' SET poll_option_total = poll_option_total + 1 WHERE poll_option_id = ' . (int) $option . ' AND topic_id = ' . (int) $up_topic_id; $this->db->sql_query($sql); if ($this->user->data['is_registered']) { $sql_ary = array('topic_id' => (int) $up_topic_id, 'poll_option_id' => (int) $option, 'vote_user_id' => (int) $this->user->data['user_id'], 'vote_user_ip' => (string) $this->user->ip); $sql = 'INSERT INTO ' . POLL_VOTES_TABLE . ' ' . $this->db->sql_build_array('INSERT', $sql_ary); $this->db->sql_query($sql); } } foreach ($cur_voted_id as $option) { if (!in_array($option, $voted_id)) { $sql = 'UPDATE ' . POLL_OPTIONS_TABLE . ' SET poll_option_total = poll_option_total - 1 WHERE poll_option_id = ' . (int) $option . ' AND topic_id = ' . (int) $up_topic_id; $this->db->sql_query($sql); if ($this->user->data['is_registered']) { $sql = 'DELETE FROM ' . POLL_VOTES_TABLE . ' WHERE topic_id = ' . (int) $up_topic_id . ' AND poll_option_id = ' . (int) $option . ' AND vote_user_id = ' . (int) $this->user->data['user_id']; $this->db->sql_query($sql); } } } if ($this->user->data['user_id'] == ANONYMOUS && !$this->user->data['is_bot']) { $this->user->set_cookie('poll_' . $up_topic_id, implode(',', $voted_id), time() + 31536000); } $sql = 'UPDATE ' . TOPICS_TABLE . ' SET poll_last_vote = ' . time() . ' WHERE topic_id = ' . (int) $up_topic_id; //, topic_last_post_time = ' . time() . " -- for bumping topics with new votes, ignore for now $this->db->sql_query($sql); meta_refresh(5, $redirect_url); trigger_error($this->user->lang['VOTE_SUBMITTED'] . '<br /><br />' . sprintf($this->user->lang['RETURN_PORTAL'], '<a href="' . $redirect_url . '">', '</a>')); } } $poll_forums = false; // Get readable forums $forum_list = array_unique(array_keys($this->auth->acl_getf('f_read', true))); if ($this->config['board3_poll_topic_id_' . $module_id] !== '') { $poll_forums_config = explode(',', $this->config['board3_poll_topic_id_' . $module_id]); if ($this->config['board3_poll_exclude_id_' . $module_id]) { $forum_list = array_unique(array_diff($forum_list, $poll_forums_config)); } else { $forum_list = array_unique(array_intersect($poll_forums_config, $forum_list)); } } $where = ''; if (sizeof($forum_list)) { $poll_forums = true; $where = 'AND ' . $this->db->sql_in_set('t.forum_id', $forum_list); } if ($this->config['board3_poll_hide_' . $module_id]) { $portal_poll_hide = 'AND (t.poll_start + t.poll_length > ' . time() . ' OR t.poll_length = 0)'; } else { $portal_poll_hide = ''; } if ($poll_forums === true) { $sql = 'SELECT t.poll_title, t.poll_start, t.topic_id, t.topic_first_post_id, t.forum_id, t.poll_length, t.poll_vote_change, t.poll_max_options, t.topic_status, f.forum_status, p.bbcode_bitfield, p.bbcode_uid FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p, ' . FORUMS_TABLE . " f\n\t\t\t\tWHERE t.forum_id = f.forum_id\n\t\t\t\t\tAND t.topic_visibility = 1\n\t\t\t\t\tAND t.poll_start > 0\n\t\t\t\t\t{$where}\n\t\t\t\t\tAND t.topic_moved_id = 0\n\t\t\t\t\tAND p.post_id = t.topic_first_post_id\n\t\t\t\t\t{$portal_poll_hide}\n\t\t\t\tORDER BY t.poll_start DESC"; $limit = isset($this->config['board3_poll_limit_' . $module_id]) ? $this->config['board3_poll_limit_' . $module_id] : 3; $result = $this->db->sql_query_limit($sql, $limit); $has_poll = false; if ($result) { while ($data = $this->db->sql_fetchrow($result)) { $has_poll = true; $poll_has_options = false; $topic_id = (int) $data['topic_id']; $forum_id = (int) $data['forum_id']; $cur_voted_id = array(); if ($this->config['board3_poll_allow_vote_' . $module_id]) { if ($this->user->data['is_registered']) { $vote_sql = 'SELECT poll_option_id FROM ' . POLL_VOTES_TABLE . ' WHERE topic_id = ' . (int) $topic_id . ' AND vote_user_id = ' . (int) $this->user->data['user_id']; $vote_result = $this->db->sql_query($vote_sql); while ($row = $this->db->sql_fetchrow($vote_result)) { $cur_voted_id[] = $row['poll_option_id']; } $this->db->sql_freeresult($vote_result); } else { // Cookie based guest tracking ... I don't like this but hum ho // it's oft requested. This relies on "nice" users who don't feel // the need to delete cookies to mess with results. if ($this->request->is_set($this->config['cookie_name'] . '_poll_' . $topic_id, \phpbb\request\request_interface::COOKIE)) { $cur_voted_id = explode(',', $this->request->variable($this->config['cookie_name'] . '_poll_' . $topic_id, 0, false, true)); $cur_voted_id = array_map('intval', $cur_voted_id); } } $s_can_vote = (!sizeof($cur_voted_id) && $this->auth->acl_get('f_vote', $forum_id) || $this->auth->acl_get('f_votechg', $forum_id) && $data['poll_vote_change']) && ($data['poll_length'] != 0 && $data['poll_start'] + $data['poll_length'] > time() || $data['poll_length'] == 0) && $data['topic_status'] != ITEM_LOCKED && $data['forum_status'] != ITEM_LOCKED ? true : false; } else { $s_can_vote = false; } $s_display_results = !$s_can_vote || $s_can_vote && sizeof($cur_voted_id) || $view == 'viewpoll' && in_array($topic_id, $poll_view_ar) ? true : false; $poll_sql = 'SELECT po.poll_option_id, po.poll_option_text, po.poll_option_total FROM ' . POLL_OPTIONS_TABLE . ' po WHERE po.topic_id = ' . (int) $topic_id . ' ORDER BY po.poll_option_id'; $poll_result = $this->db->sql_query($poll_sql); $poll_total_votes = 0; $poll_data = array(); if ($poll_result) { while ($polls_data = $this->db->sql_fetchrow($poll_result)) { $poll_has_options = true; $poll_data[] = $polls_data; $poll_total_votes += $polls_data['poll_option_total']; } } $this->db->sql_freeresult($poll_result); $make_poll_view = array(); if (in_array($topic_id, $poll_view_ar) === false) { $make_poll_view[] = $topic_id; $make_poll_view = array_merge($poll_view_ar, $make_poll_view); } $poll_view_str = urlencode(implode(',', $make_poll_view)); $portalpoll_url = $this->modules_helper->route('board3_portal_controller') . "?polls={$poll_view_str}"; $portalvote_url = $this->modules_helper->route('board3_portal_controller') . "?f={$forum_id}&t={$topic_id}"; $viewtopic_url = append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", "f={$forum_id}&t={$topic_id}"); $poll_end = $data['poll_length'] + $data['poll_start']; // Parse BBCode title if ($data['bbcode_bitfield']) { $poll_bbcode = new \bbcode(); } else { $poll_bbcode = false; } $data['poll_title'] = censor_text($data['poll_title']); if ($poll_bbcode !== false) { $poll_bbcode->bbcode_second_pass($data['poll_title'], $data['bbcode_uid'], $data['bbcode_bitfield']); } $data['poll_title'] = bbcode_nl2br($data['poll_title']); $data['poll_title'] = smiley_text($data['poll_title']); unset($poll_bbcode); $this->template->assign_block_vars($type !== '' ? 'poll_' . $type : 'poll', array('S_POLL_HAS_OPTIONS' => $poll_has_options, 'POLL_QUESTION' => $data['poll_title'], 'U_POLL_TOPIC' => append_sid($this->phpbb_root_path . 'viewtopic.' . $this->php_ext, 't=' . $topic_id . '&f=' . $forum_id), 'POLL_LENGTH' => $data['poll_length'], 'TOPIC_ID' => $topic_id, 'TOTAL_VOTES' => $poll_total_votes, 'L_MAX_VOTES' => $this->user->lang('MAX_OPTIONS_SELECT', $data['poll_max_options']), 'L_POLL_LENGTH' => $data['poll_length'] ? sprintf($this->user->lang[$poll_end > time() ? 'POLL_RUN_TILL' : 'POLL_ENDED_AT'], $this->user->format_date($poll_end)) : '', 'S_CAN_VOTE' => $s_can_vote, 'S_DISPLAY_RESULTS' => $s_display_results, 'S_IS_MULTI_CHOICE' => $data['poll_max_options'] > 1 ? true : false, 'S_POLL_ACTION' => $portalvote_url, 'U_VIEW_RESULTS' => $portalpoll_url . '&view=viewpoll#viewpoll', 'U_VIEW_TOPIC' => $viewtopic_url)); foreach ($poll_data as $pd) { $option_pct = $poll_total_votes > 0 ? $pd['poll_option_total'] / $poll_total_votes : 0; $option_pct_txt = sprintf("%.1d%%", round($option_pct * 100)); // Parse BBCode option text if ($data['bbcode_bitfield']) { $poll_bbcode = new \bbcode(); } else { $poll_bbcode = false; } $pd['poll_option_text'] = censor_text($pd['poll_option_text']); if ($poll_bbcode !== false) { $poll_bbcode->bbcode_second_pass($pd['poll_option_text'], $data['bbcode_uid'], $data['bbcode_bitfield']); } $pd['poll_option_text'] = bbcode_nl2br($pd['poll_option_text']); $pd['poll_option_text'] = smiley_text($pd['poll_option_text']); unset($poll_bbcode); $this->template->assign_block_vars(($type !== '' ? 'poll_' . $type : 'poll') . '.poll_option', array('POLL_OPTION_ID' => $pd['poll_option_id'], 'POLL_OPTION_CAPTION' => $pd['poll_option_text'], 'POLL_OPTION_RESULT' => $pd['poll_option_total'], 'POLL_OPTION_PERCENT' => $option_pct_txt, 'POLL_OPTION_PCT' => round($option_pct * 100), 'POLL_OPTION_IMG' => $this->user->img('poll_center', $option_pct_txt, round($option_pct * 35) . 'px'), 'POLL_OPTION_VOTED' => in_array($pd['poll_option_id'], $cur_voted_id) ? true : false)); } } } $this->db->sql_freeresult($result); $this->template->assign_vars(array('S_HAS_POLL' => $has_poll, 'POLL_LEFT_CAP_IMG' => $this->user->img('poll_left'), 'POLL_RIGHT_CAP_IMG' => $this->user->img('poll_right'))); } return ($type !== '' ? 'poll_' . $type : 'poll_center') . '.html'; }
/** * For display of custom parsed text on user-facing pages * Expects $text to be the value directly from the database (stored value) */ function generate_text_for_display($text, $uid, $bitfield, $flags) { static $bbcode; if (!$text) { return ''; } $text = censor_text($text); // Parse bbcode if bbcode uid stored and bbcode enabled if ($uid && $flags & OPTION_FLAG_BBCODE) { if (!class_exists('bbcode')) { global $phpbb_root_path, $phpEx; include $phpbb_root_path . 'includes/bbcode.' . $phpEx; } if (empty($bbcode)) { $bbcode = new bbcode($bitfield); } else { $bbcode->bbcode($bitfield); } $bbcode->bbcode_second_pass($text, $uid); } $text = bbcode_nl2br($text); $text = smiley_text($text, !($flags & OPTION_FLAG_SMILIES)); return $text; }
/** * Fetch news processing */ function phpbb_fetch_news($forum_from, $number_of_posts, $text_length, $time, $type, $start = 0) { global $db, $config, $portal_config, $phpbb_root_path, $auth, $user, $bbcode_bitfield, $mode, $forum_id, $forum_status; $posts = array(); $post_time = $time == 0 ? '' : 'AND t.topic_time > ' . (time() - $time * 86400); $forum_from = strpos($forum_from, ',') !== FALSE ? explode(',', $forum_from) : ($forum_from != '' ? array($forum_from) : array()); $str_where = ''; $topic_icons = array(0); $have_icons = 0; $allow_access = array_unique(array_keys($auth->acl_getf('f_read', true))); if (sizeof($allow_access)) { if (sizeof($forum_from)) { foreach ($allow_access as $acc_id) { if (in_array($acc_id, $forum_from)) { $str_where .= "t.forum_id = {$acc_id} OR "; if (!isset($gobal_f)) { $global_f = $acc_id; } } } } else { foreach ($allow_access as $acc_id) { $str_where .= "t.forum_id = {$acc_id} OR "; if (!isset($gobal_f)) { $global_f = $acc_id; } } } if (utf8_strlen($str_where) > 0) { switch ($type) { case "announcements": $topic_type = '(( t.topic_type = ' . POST_ANNOUNCE . ') OR ( t.topic_type = ' . POST_GLOBAL . '))'; $str_where = utf8_strlen($str_where) > 0 ? 'AND (t.forum_id = 0 OR ' . substr($str_where, 0, -4) . ')' : ''; $user_link = 't.topic_poster = u.user_id'; $post_link = 't.topic_first_post_id = p.post_id'; $topic_order = 't.topic_time DESC'; break; case "news": $topic_type = '(( t.topic_type = ' . POST_NORMAL . ') OR ( t.topic_type = ' . POST_STICKY . '))'; $str_where = strlen($str_where) > 0 ? 'AND (' . trim(substr($str_where, 0, -4)) . ')' : ''; if ($portal_config['portal_news_show_last_post'] == true) { $user_link = 't.topic_last_poster_id = u.user_id'; $post_link = 't.topic_last_post_id = p.post_id'; $topic_order = 't.topic_last_post_id DESC'; } else { $user_link = 't.topic_poster = u.user_id'; $post_link = 't.topic_first_post_id = p.post_id'; $topic_order = 't.topic_time DESC'; } break; case "news_all": $topic_type = '( t.topic_type <> ' . POST_ANNOUNCE . ' ) AND ( t.topic_type <> ' . POST_GLOBAL . ')'; $str_where = strlen($str_where) > 0 ? 'AND (' . trim(substr($str_where, 0, -4)) . ')' : ''; if ($portal_config['portal_news_show_last_post'] == true) { $user_link = 't.topic_last_poster_id = u.user_id'; $post_link = 't.topic_last_post_id = p.post_id'; $topic_order = 't.topic_last_post_id DESC'; } else { $user_link = 't.topic_poster = u.user_id'; $post_link = 't.topic_first_post_id = p.post_id'; $topic_order = 't.topic_time DESC'; } break; } $sql_array = array('SELECT' => 't.forum_id, t.poll_title, t.topic_approved, t.topic_attachment, t.topic_id, t.topic_last_post_id, t.topic_last_post_time, t.topic_last_poster_name, t.topic_last_poster_id, t.topic_last_poster_colour, t.topic_moved_id, t.icon_id, t.topic_poster, t.topic_replies, t.topic_replies_real, t.topic_status, t.topic_time, t.topic_title, t.topic_type, t.topic_views, t.topic_first_post_id, u.user_colour, u.user_id, u.user_rank, u.user_type, u.username, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_magic_url, p.enable_smilies, p.post_approved, p.post_attachment, p.post_id, p.post_subject, p.post_text, p.post_time, f.enable_icons, f.forum_name', 'FROM' => array(TOPICS_TABLE => 't'), 'LEFT_JOIN' => array(array('FROM' => array(USERS_TABLE => 'u'), 'ON' => $user_link), array('FROM' => array(FORUMS_TABLE => 'f'), 'ON' => 't.forum_id=f.forum_id'), array('FROM' => array(POSTS_TABLE => 'p'), 'ON' => $post_link)), 'WHERE' => $topic_type . ' ' . $post_time . ' AND t.topic_status <> ' . ITEM_MOVED . ' AND t.topic_approved = 1 AND t.topic_moved_id = 0 ' . $str_where, 'ORDER_BY' => $topic_order); $sql_array['LEFT_JOIN'][] = array('FROM' => array(TOPICS_POSTED_TABLE => 'tp'), 'ON' => 'tp.topic_id = t.topic_id AND tp.user_id = ' . $user->data['user_id']); $sql_array['SELECT'] .= ', tp.topic_posted'; $sql = $db->sql_build_query('SELECT', $sql_array); if ($number_of_posts != 0) { $result = $db->sql_query_limit($sql, $number_of_posts, $start); } else { $result = $db->sql_query($sql); } // Instantiate BBCode if need be if ($bbcode_bitfield !== '') { $phpEx = substr(strrchr(__FILE__, '.'), 1); include_once $phpbb_root_path . 'includes/bbcode.' . $phpEx; $bbcode = new bbcode(base64_encode($bbcode_bitfield)); } $i = 0; while ($row = $db->sql_fetchrow($result)) { $attachments = array(); if ($config['allow_attachments']) { // Pull attachment data $sql2 = 'SELECT * FROM ' . ATTACHMENTS_TABLE . ' WHERE post_msg_id = ' . $row['post_id'] . ' AND in_message = 0 ORDER BY filetime DESC'; $result2 = $db->sql_query($sql2); while ($row2 = $db->sql_fetchrow($result2)) { $attachments[] = $row2; } $db->sql_freeresult($result2); } if ($row['user_id'] != ANONYMOUS && $row['user_colour']) { $row['username'] = '******' . $row['user_colour'] . '">' . $row['username'] . '</b> '; } $posts[$i]['bbcode_uid'] = $row['bbcode_uid']; $len_check = $row['post_text']; if ($text_length != 0 && utf8_strlen($len_check) > $text_length) { $message = utf8_substr($len_check, 0, $text_length); $message = str_replace("\n", '<br/> ', $message); $message .= ' ...'; $posts[$i]['striped'] = true; } else { $message = censor_text(str_replace("\n", '<br/> ', $row['post_text'])); } if ($auth->acl_get('f_html', $row['forum_id'])) { $message = preg_replace('#<!\\-\\-(.*?)\\-\\->#is', '', $message); // Remove Comments from post content } // Second parse bbcode here if ($row['bbcode_bitfield']) { $bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']); } if (!empty($attachments)) { parse_attachments($row['forum_id'], $message, $attachments, $update_count); } if ($portal_config['portal_acronyms_allow'] = 1) { $phpEx = substr(strrchr(__FILE__, '.'), 1); include_once $phpbb_root_path . 'portal/includes/functions_acronym.' . $phpEx; $message = acronym_pass($message); } // dgTopic Thumb MOD - Added --> if ($row['topic_attachment']) { $sql2 = 'SELECT topic_first_post_id FROM ' . TOPICS_TABLE . ' WHERE topic_id = ' . $row['topic_id']; $dgresult_one_check_postid = $db->sql_query_limit($sql2, 1); $dgrow_one_check_postid = (int) $db->sql_fetchfield('topic_first_post_id'); $db->sql_freeresult($dgresult_one_check_postid); $sql2 = 'SELECT post_attachment FROM ' . POSTS_TABLE . ' WHERE post_id = ' . $dgrow_one_check_postid; $dgresult_one_postid_confirmed = $db->sql_query_limit($sql2, 1); $dgrow_one_postid_confirmed = (int) $db->sql_fetchfield('post_attachment'); $db->sql_freeresult($dgresult_one_postid_confirmed); $sql2 = 'SELECT post_attachment FROM ' . POSTS_TABLE . ' WHERE post_id = ' . $dgrow_one_check_postid; $dgresult_one = $db->sql_query_limit($sql2, 1); $dgrow_one = (int) $db->sql_fetchfield('post_attachment'); $db->sql_freeresult($dgresult_one); $sql2 = 'SELECT forum_topics_thumb_choice FROM ' . FORUMS_TABLE . ' WHERE forum_id =' . $row['forum_id']; $result2 = $db->sql_query_limit($sql2, 1); $rowchoice = (int) $db->sql_fetchfield('forum_topics_thumb_choice'); $topic_thumb_choice = $rowchoice; $db->sql_freeresult($result2); if ($dgrow_one == 1 && $topic_thumb_choice == 1) { $dgrow_one = 1; } else { $dgrow_one = 0; } if ($dgrow_one) { $posts[$i]['dgrow_one'] = 1; $sql2 = 'SELECT physical_filename FROM ' . ATTACHMENTS_TABLE . ' WHERE topic_id = ' . $row['topic_id']; $dgresult_two = $db->sql_query_limit($sql2, 1); $physical_thumb_name = $db->sql_fetchfield('physical_filename'); $db->sql_freeresult($dgresult_two); $sql2 = 'SELECT extension FROM ' . ATTACHMENTS_TABLE . ' WHERE topic_id =' . $row['topic_id']; $dgresult_last = $db->sql_query_limit($sql2, 1); $extension_name = $db->sql_fetchfield('extension'); $db->sql_freeresult($dgresult_last); $sql2 = 'SELECT attach_id FROM ' . ATTACHMENTS_TABLE . ' WHERE topic_id =' . $row['topic_id']; $dgresult_last = $db->sql_query_limit($sql2, 1); $attach_id = $db->sql_fetchfield('attach_id'); $db->sql_freeresult($dgresult_last); $topic_thumb_filename = $phpbb_root_path . 'download/file.php' . '?id=' . $attach_id . '&t=' . 2 . '&sid=' . $physical_thumb_name; } else { $posts[$i]['dgrow_one'] = 0; } } // dgTopic Thumb MOD - END --> $posts[$i]['topic_thumb_filename'] = $topic_thumb_filename; $message = smiley_text($message); // Always process smilies after parsing bbcodes $posts[$i] = array_merge($posts[$i], array('attachment' => $row['topic_attachment'] ? true : false, 'attachments' => !empty($attachments) ? $attachments : array(), 'bbcode_bitfield' => $row['bbcode_bitfield'], 'bbcode_uid' => $row['bbcode_uid'], 'enable_bbcode' => $row['enable_bbcode'], 'enable_magic_url' => $row['enable_magic_url'], 'enable_smilies' => $row['enable_smilies'], 'forum_id' => $row['forum_id'], 'forum_name' => $row['forum_name'], 'icon_id' => $row['icon_id'], 'poll_title' => $row['poll_title'] != '' ? true : false, 'post_approved' => $row['post_approved'], 'post_attachment' => !empty($attachments) ? $attachments : array(), 'post_id' => $row['post_id'], 'post_msg_id' => $row['post_msg_id'], 'post_subject' => $row['post_subject'], 'post_text' => $message, 'post_time' => $user->format_date($row['post_time']), 'real_filename' => $row['real_filename'], 'topic_approved' => $row['topic_approved'], 'topic_attachment' => $row['topic_attachment'], 'topic_first_post_id' => $row['topic_first_post_id'], 'topic_id' => $row['topic_id'], 'topic_last_post_id' => $row['topic_last_post_id'], 'topic_last_post_time' => $row['topic_last_post_time'], 'topic_poster' => $row['topic_poster'], 'topic_posted' => isset($row['topic_posted']) && $row['topic_posted'] ? true : false, 'topic_replies' => $row['topic_replies'], 'topic_replies_real' => $row['topic_replies_real'], 'topic_status' => $row['topic_status'], 'topic_time' => $user->format_date($row['post_time']), 'topic_title' => $row['topic_title'], 'topic_type' => $row['topic_type'], 'topic_views' => $row['topic_views'], 'user_colour' => $row['user_colour'], 'user_id' => $row['user_id'], 'user_rank' => $row['user_rank'], 'user_type' => $row['user_type'], 'username' => $row['username'], 'username_full' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $row['post_username']), 'username_full_last' => get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour'], $row['topic_last_poster_name']))); $posts[$i]['global_id'] = $global_f; $i++; } } } return $posts; }
/** * Enter description here... * * @param string $content * @param int $uid * @param int $bitfield * @return string **/ function generate_content( $content, $uid, $bitfield, $attach_list, $post_id, $forum_id ) { global $text_limit, $show_text, $board_url; global $user, $config, $phpbb_root_path, $phpEx; if ( $show_text && !empty($content) ) { // Remove Comments from smiles $content = smiley_text($content); // Truncates post text ? $content = generate_truncate_content($content, $text_limit, $uid, false ); // Prepare some bbcodes for better parsing $content = preg_replace("#\[quote(=".*?")?:$uid\]\s*(.*?)\s*\[/quote:$uid\]#si", "[quote$1:$uid]<br />$2<br />[/quote:$uid]", $content); /* Just remember : Never use it ! * Commented out so I do not make the same error twice. $content = html_entity_decode($content); */ // Parse it! $content = generate_text_for_display($content, $uid, $bitfield, 7); // Fix smilies $content = str_replace('{SMILIES_PATH}/', "{$phpbb_root_path}{$config['smilies_path']}/", $content); // Relative Path to Absolute path, Windows style $content = str_replace('./', "$board_url/", $content); // Fix some spaces $content = bbcode_nl2br($content); // Remove "Select all" link and mouse events $content = str_replace('<a href="#" onclick="selectCode(this); return false;">' .$user->lang['SELECT_ALL_CODE'] . '</a>', '', $content); $content = preg_replace('#(onkeypress|onclick)="(.*?)"#si', '', $content); // Remove Comments from post content $content = preg_replace('#<!-- ([lmwe]) -->(.*?)<!-- ([lmwe]) -->#si', '$2', $content); // Remove embed Windows Media Streams $content = preg_replace( '#<\!--\[if \!IE\]>-->([^[]+)<\!--<!\[endif\]-->#si', '', $content); // Remove embed and objects // Use (<|<) and (>|>) because can be contained into [code][/code] $content = preg_replace( '#(<|<)(object|embed)(.*?) (value|src)=(.*?) ([^[]+)(object|embed)(>|>)#si',' <a href=$5 target="_blank"><strong>$2</strong></a> ',$content); // Remove some specials html tag, because somewhere there are a mod to allow html tags ;) // Use (<|<) and (>|>) because can be contained into [code][/code] $content = preg_replace( '#(<|<)script([^[]+)script(>|>)#si', ' <strong>Script</strong> ', $content); $content = preg_replace( '#(<|<)iframe([^[]+)iframe(>|>)#si', ' <strong>Iframe</strong> ', $content); // Resize images ? if ( $config['rss_image_size'] ) { $content = preg_replace('#<img.*?src=\"(.*?)\" alt=(.*?)/>#ise', "check_rss_imagesize( '$1' )", $content); } /* Convert special HTML entities back to characters * Some languages will need it * Commented out so I do not loose the code. $content = htmlspecialchars_decode($content); */ // Other control characters $content = preg_replace('#(?:[\x00-\x1F\x7F]+|(?:\xC2[\x80-\x9F])+)#', '', $content); // Pull attachment data if (sizeof($attach_list)) { global $auth, $db; $attachments = $update_count = array(); $attachments['post_id'][] = $post_id; // Pull attachment data if ($auth->acl_get('u_download') && $auth->acl_get('f_download', $forum_id)) { $attachments = array(); $sql = 'SELECT * FROM ' . ATTACHMENTS_TABLE . ' WHERE ' . $db->sql_in_set('post_msg_id', $attach_list) . ' AND in_message = 0 ORDER BY filetime DESC, post_msg_id ASC'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $attachments[$row['post_msg_id']][] = $row; } $db->sql_freeresult($result); } // Attach in-line parse_attachments($forum_id, $content, $attachments[$post_id], $update_count); // Display not already displayed Attachments for this post, we already parsed them. ;) if ( !empty($attachments[$post_id]) ) { $attachment_data = ''; foreach ($attachments[$post_id] as $attachment) { $attachment_data .= $attachment; } $content .= '<br /><br />' . $user->lang['ATTACHMENTS'] . $attachment_data; } } else { // Remove attachments [ia] $content = preg_replace('#<div class="(inline-attachment|attachtitle)">(.*?)<!-- ia(.*?) -->(.*?)<!-- ia(.*?) -->(.*?)</div>#si','',$content); } } /* Just remember : Never use it ! * Commented out so I do not make the same error twice. $content = htmlspecialchars($content); */ return $content; }
/** * View topic in MCP */ function mcp_topic_view($id, $mode, $action) { global $phpEx, $phpbb_root_path, $config; global $template, $db, $user, $auth, $cache; $url = append_sid("{$phpbb_root_path}mcp.{$phpEx}?" . extra_url()); $user->add_lang('viewtopic'); $topic_id = request_var('t', 0); $topic_info = get_topic_data(array($topic_id), false, true); if (!sizeof($topic_info)) { trigger_error('TOPIC_NOT_EXIST'); } $topic_info = $topic_info[$topic_id]; // Set up some vars $icon_id = request_var('icon', 0); $subject = utf8_normalize_nfc(request_var('subject', '', true)); $start = request_var('start', 0); $sort_days_old = request_var('st_old', 0); $forum_id = request_var('f', 0); $to_topic_id = request_var('to_topic_id', 0); $to_forum_id = request_var('to_forum_id', 0); $sort = isset($_POST['sort']) ? true : false; $submitted_id_list = request_var('post_ids', array(0)); $checked_ids = $post_id_list = request_var('post_id_list', array(0)); // Resync Topic? if ($action == 'resync') { if (!function_exists('mcp_resync_topics')) { include $phpbb_root_path . 'includes/mcp/mcp_forum.' . $phpEx; } mcp_resync_topics(array($topic_id)); } // Split Topic? if ($action == 'split_all' || $action == 'split_beyond') { if (!$sort) { split_topic($action, $topic_id, $to_forum_id, $subject); } $action = 'split'; } // Merge Posts? if ($action == 'merge_posts') { if (!$sort) { merge_posts($topic_id, $to_topic_id); } $action = 'merge'; } if ($action == 'split' && !$subject) { $subject = $topic_info['topic_title']; } // Approve posts? if ($action == 'approve' && $auth->acl_get('m_approve', $topic_info['forum_id'])) { include $phpbb_root_path . 'includes/mcp/mcp_queue.' . $phpEx; include_once $phpbb_root_path . 'includes/functions_posting.' . $phpEx; include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx; if (!sizeof($post_id_list)) { trigger_error('NO_POST_SELECTED'); } if (!$sort) { approve_post($post_id_list, $id, $mode); } } // Jumpbox, sort selects and that kind of things make_jumpbox($url . "&i={$id}&mode=forum_view", $topic_info['forum_id'], false, 'm_', true); $where_sql = $action == 'reports' ? 'WHERE post_reported = 1 AND ' : 'WHERE'; $sort_days = $total = 0; $sort_key = $sort_dir = ''; $sort_by_sql = $sort_order_sql = array(); mcp_sorting('viewtopic', $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $topic_info['forum_id'], $topic_id, $where_sql); $limit_time_sql = $sort_days ? 'AND p.post_time >= ' . (time() - $sort_days * 86400) : ''; if ($total == -1) { if ($auth->acl_get('m_approve', $topic_info['forum_id'])) { $total = $topic_info['topic_replies_real'] + 1; } else { $total = $topic_info['topic_replies'] + 1; } } $posts_per_page = max(0, request_var('posts_per_page', intval($config['posts_per_page']))); if ($posts_per_page == 0) { $posts_per_page = $total; } if (!empty($sort_days_old) && $sort_days_old != $sort_days || $total <= $posts_per_page) { $start = 0; } // Make sure $start is set to the last page if it exceeds the amount if ($start < 0 || $start >= $total) { $start = $start < 0 ? 0 : floor(($total - 1) / $posts_per_page) * $posts_per_page; } $sql = 'SELECT u.username, u.username_clean, u.user_colour, p.* FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u WHERE ' . ($action == 'reports' ? 'p.post_reported = 1 AND ' : '') . ' p.topic_id = ' . $topic_id . ' ' . (!$auth->acl_get('m_approve', $topic_info['forum_id']) ? ' AND p.post_approved = 1 ' : '') . ' AND p.poster_id = u.user_id ' . $limit_time_sql . ' ORDER BY ' . $sort_order_sql; $result = $db->sql_query_limit($sql, $posts_per_page, $start); $rowset = $post_id_list = array(); $bbcode_bitfield = ''; while ($row = $db->sql_fetchrow($result)) { $rowset[] = $row; $post_id_list[] = $row['post_id']; $bbcode_bitfield = $bbcode_bitfield | base64_decode($row['bbcode_bitfield']); } $db->sql_freeresult($result); if ($bbcode_bitfield !== '') { include_once $phpbb_root_path . 'includes/bbcode.' . $phpEx; $bbcode = new bbcode(base64_encode($bbcode_bitfield)); } $topic_tracking_info = array(); // Get topic tracking info if ($config['load_db_lastread']) { $tmp_topic_data = array($topic_id => $topic_info); $topic_tracking_info = get_topic_tracking($topic_info['forum_id'], $topic_id, $tmp_topic_data, array($topic_info['forum_id'] => $topic_info['forum_mark_time'])); unset($tmp_topic_data); } else { $topic_tracking_info = get_complete_topic_tracking($topic_info['forum_id'], $topic_id); } $has_unapproved_posts = false; // Grab extensions $extensions = $attachments = array(); if ($topic_info['topic_attachment'] && sizeof($post_id_list)) { $extensions = $cache->obtain_attach_extensions($topic_info['forum_id']); // Get attachments... if ($auth->acl_get('u_download') && $auth->acl_get('f_download', $topic_info['forum_id'])) { $sql = 'SELECT * FROM ' . ATTACHMENTS_TABLE . ' WHERE ' . $db->sql_in_set('post_msg_id', $post_id_list) . ' AND in_message = 0 ORDER BY filetime DESC, post_msg_id ASC'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $attachments[$row['post_msg_id']][] = $row; } $db->sql_freeresult($result); } } foreach ($rowset as $i => $row) { $message = $row['post_text']; $post_subject = $row['post_subject'] != '' ? $row['post_subject'] : $topic_info['topic_title']; if ($row['bbcode_bitfield']) { $bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']); } $message = bbcode_nl2br($message); $message = smiley_text($message); if (!empty($attachments[$row['post_id']])) { $update_count = array(); parse_attachments($topic_info['forum_id'], $message, $attachments[$row['post_id']], $update_count); } if (!$row['post_approved']) { $has_unapproved_posts = true; } $post_unread = isset($topic_tracking_info[$topic_id]) && $row['post_time'] > $topic_tracking_info[$topic_id] ? true : false; $template->assign_block_vars('postrow', array('POST_AUTHOR_FULL' => get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_AUTHOR_COLOUR' => get_username_string('colour', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_AUTHOR' => get_username_string('username', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'U_POST_AUTHOR' => get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour'], $row['post_username']), 'POST_DATE' => $user->format_date($row['post_time']), 'POST_SUBJECT' => $post_subject, 'MESSAGE' => $message, 'POST_ID' => $row['post_id'], 'RETURN_TOPIC' => sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 't=' . $topic_id) . '">', '</a>'), 'MINI_POST_IMG' => $post_unread ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'), 'S_POST_REPORTED' => $row['post_reported'] && $auth->acl_get('m_report', $topic_info['forum_id']), 'S_POST_UNAPPROVED' => !$row['post_approved'] && $auth->acl_get('m_approve', $topic_info['forum_id']), 'S_CHECKED' => $submitted_id_list && !in_array(intval($row['post_id']), $submitted_id_list) || in_array(intval($row['post_id']), $checked_ids) ? true : false, 'S_HAS_ATTACHMENTS' => !empty($attachments[$row['post_id']]) ? true : false, 'U_POST_DETAILS' => "{$url}&i={$id}&p={$row['post_id']}&mode=post_details" . ($forum_id ? "&f={$forum_id}" : ''), 'U_MCP_APPROVE' => $auth->acl_get('m_approve', $topic_info['forum_id']) ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue&mode=approve_details&f=' . $topic_info['forum_id'] . '&p=' . $row['post_id']) : '', 'U_MCP_REPORT' => $auth->acl_get('m_report', $topic_info['forum_id']) ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=reports&mode=report_details&f=' . $topic_info['forum_id'] . '&p=' . $row['post_id']) : '')); // Display not already displayed Attachments for this post, we already parsed them. ;) if (!empty($attachments[$row['post_id']])) { foreach ($attachments[$row['post_id']] as $attachment) { $template->assign_block_vars('postrow.attachment', array('DISPLAY_ATTACHMENT' => $attachment)); } } unset($rowset[$i]); } // Display topic icons for split topic $s_topic_icons = false; if ($auth->acl_gets('m_split', 'm_merge', (int) $topic_info['forum_id'])) { include_once $phpbb_root_path . 'includes/functions_posting.' . $phpEx; $s_topic_icons = posting_gen_topic_icons('', $icon_id); // Has the user selected a topic for merge? if ($to_topic_id) { $to_topic_info = get_topic_data(array($to_topic_id), 'm_merge'); if (!sizeof($to_topic_info)) { $to_topic_id = 0; } else { $to_topic_info = $to_topic_info[$to_topic_id]; if (!$to_topic_info['enable_icons'] || $auth->acl_get('!f_icons', $topic_info['forum_id'])) { $s_topic_icons = false; } } } } $s_hidden_fields = build_hidden_fields(array('st_old' => $sort_days, 'post_ids' => $post_id_list)); $template->assign_vars(array('TOPIC_TITLE' => $topic_info['topic_title'], 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $topic_info['forum_id'] . '&t=' . $topic_info['topic_id']), 'TO_TOPIC_ID' => $to_topic_id, 'TO_TOPIC_INFO' => $to_topic_id ? sprintf($user->lang['YOU_SELECTED_TOPIC'], $to_topic_id, '<a href="' . append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $to_topic_info['forum_id'] . '&t=' . $to_topic_id) . '">' . $to_topic_info['topic_title'] . '</a>') : '', 'SPLIT_SUBJECT' => $subject, 'POSTS_PER_PAGE' => $posts_per_page, 'ACTION' => $action, 'REPORTED_IMG' => $user->img('icon_topic_reported', 'POST_REPORTED'), 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'POST_UNAPPROVED'), 'INFO_IMG' => $user->img('icon_post_info', 'VIEW_INFO'), 'S_MCP_ACTION' => "{$url}&i={$id}&mode={$mode}&action={$action}&start={$start}", 'S_FORUM_SELECT' => $to_forum_id ? make_forum_select($to_forum_id, false, false, true, true, true) : make_forum_select($topic_info['forum_id'], false, false, true, true, true), 'S_CAN_SPLIT' => $auth->acl_get('m_split', $topic_info['forum_id']) ? true : false, 'S_CAN_MERGE' => $auth->acl_get('m_merge', $topic_info['forum_id']) ? true : false, 'S_CAN_DELETE' => $auth->acl_get('m_delete', $topic_info['forum_id']) ? true : false, 'S_CAN_APPROVE' => $has_unapproved_posts && $auth->acl_get('m_approve', $topic_info['forum_id']) ? true : false, 'S_CAN_LOCK' => $auth->acl_get('m_lock', $topic_info['forum_id']) ? true : false, 'S_CAN_REPORT' => $auth->acl_get('m_report', $topic_info['forum_id']) ? true : false, 'S_CAN_SYNC' => $auth->acl_get('m_', $topic_info['forum_id']), 'S_REPORT_VIEW' => $action == 'reports' ? true : false, 'S_MERGE_VIEW' => $action == 'merge' ? true : false, 'S_SPLIT_VIEW' => $action == 'split' ? true : false, 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_SHOW_TOPIC_ICONS' => $s_topic_icons, 'S_TOPIC_ICON' => $icon_id, 'U_SELECT_TOPIC' => "{$url}&i={$id}&mode=forum_view&action=merge_select" . ($forum_id ? "&f={$forum_id}" : ''), 'RETURN_TOPIC' => sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "f={$topic_info['forum_id']}&t={$topic_info['topic_id']}&start={$start}") . '">', '</a>'), 'RETURN_FORUM' => sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.{$phpEx}", "f={$topic_info['forum_id']}&start={$start}") . '">', '</a>'), 'PAGE_NUMBER' => on_page($total, $posts_per_page, $start), 'PAGINATION' => !$posts_per_page ? '' : generate_pagination(append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i={$id}&t={$topic_info['topic_id']}&mode={$mode}&action={$action}&to_topic_id={$to_topic_id}&posts_per_page={$posts_per_page}&st={$sort_days}&sk={$sort_key}&sd={$sort_dir}"), $total, $posts_per_page, $start), 'TOTAL_POSTS' => $total == 1 ? $user->lang['VIEW_TOPIC_POST'] : sprintf($user->lang['VIEW_TOPIC_POSTS'], $total))); }
/** * Topic Review */ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id = 0, $show_quote_button = true) { global $user, $auth, $db, $template, $bbcode, $cache; global $config, $phpbb_root_path, $phpEx; // Go ahead and pull all data for this topic $sql = 'SELECT p.post_id FROM ' . POSTS_TABLE . ' p' . "\n\t\tWHERE p.topic_id = {$topic_id}\n\t\t\t" . (!$auth->acl_get('m_approve', $forum_id) ? 'AND p.post_approved = 1' : '') . ' ' . ($mode == 'post_review' ? " AND p.post_id > {$cur_post_id}" : '') . ' ' . ($mode == 'post_review_edit' ? " AND p.post_id = {$cur_post_id}" : '') . ' ORDER BY p.post_time '; $sql .= $mode == 'post_review' ? 'ASC' : 'DESC'; $result = $db->sql_query_limit($sql, $config['posts_per_page']); $post_list = array(); while ($row = $db->sql_fetchrow($result)) { $post_list[] = $row['post_id']; } $db->sql_freeresult($result); if (!sizeof($post_list)) { return false; } // Handle 'post_review_edit' like 'post_review' from now on if ($mode == 'post_review_edit') { $mode = 'post_review'; } $sql = $db->sql_build_query('SELECT', array('SELECT' => 'u.username, u.user_id, u.user_colour, p.*, z.friend, z.foe', 'FROM' => array(USERS_TABLE => 'u', POSTS_TABLE => 'p'), 'LEFT_JOIN' => array(array('FROM' => array(ZEBRA_TABLE => 'z'), 'ON' => 'z.user_id = ' . $user->data['user_id'] . ' AND z.zebra_id = p.poster_id')), 'WHERE' => $db->sql_in_set('p.post_id', $post_list) . ' AND u.user_id = p.poster_id')); $result = $db->sql_query($sql); $bbcode_bitfield = ''; $rowset = array(); $has_attachments = false; while ($row = $db->sql_fetchrow($result)) { $rowset[$row['post_id']] = $row; $bbcode_bitfield = $bbcode_bitfield | base64_decode($row['bbcode_bitfield']); if ($row['post_attachment']) { $has_attachments = true; } } $db->sql_freeresult($result); // Instantiate BBCode class if (!isset($bbcode) && $bbcode_bitfield !== '') { include_once $phpbb_root_path . 'includes/bbcode.' . $phpEx; $bbcode = new bbcode(base64_encode($bbcode_bitfield)); } // Grab extensions $extensions = $attachments = array(); if ($has_attachments && $auth->acl_get('u_download') && $auth->acl_get('f_download', $forum_id)) { $extensions = $cache->obtain_attach_extensions($forum_id); // Get attachments... $sql = 'SELECT * FROM ' . ATTACHMENTS_TABLE . ' WHERE ' . $db->sql_in_set('post_msg_id', $post_list) . ' AND in_message = 0 ORDER BY filetime DESC, post_msg_id ASC'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $attachments[$row['post_msg_id']][] = $row; } $db->sql_freeresult($result); } for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) { // A non-existing rowset only happens if there was no user present for the entered poster_id // This could be a broken posts table. if (!isset($rowset[$post_list[$i]])) { continue; } $row =& $rowset[$post_list[$i]]; $poster_id = $row['user_id']; $post_subject = $row['post_subject']; $message = censor_text($row['post_text']); $decoded_message = false; if ($show_quote_button && $auth->acl_get('f_reply', $forum_id)) { $decoded_message = $message; decode_message($decoded_message, $row['bbcode_uid']); $decoded_message = bbcode_nl2br($decoded_message); } if ($row['bbcode_bitfield']) { $bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']); } $message = bbcode_nl2br($message); $message = smiley_text($message, !$row['enable_smilies']); if (!empty($attachments[$row['post_id']])) { $update_count = array(); parse_attachments($forum_id, $message, $attachments[$row['post_id']], $update_count); } $post_subject = censor_text($post_subject); $post_anchor = $mode == 'post_review' ? 'ppr' . $row['post_id'] : 'pr' . $row['post_id']; $u_show_post = append_sid($phpbb_root_path . 'viewtopic.' . $phpEx, "f={$forum_id}&t={$topic_id}&p={$row['post_id']}&view=show#p{$row['post_id']}"); $template->assign_block_vars($mode . '_row', array('POST_AUTHOR_FULL' => get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), 'POST_AUTHOR_COLOUR' => get_username_string('colour', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), 'POST_AUTHOR' => get_username_string('username', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), 'U_POST_AUTHOR' => get_username_string('profile', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), 'S_HAS_ATTACHMENTS' => !empty($attachments[$row['post_id']]) ? true : false, 'S_FRIEND' => $row['friend'] ? true : false, 'S_IGNORE_POST' => $row['foe'] ? true : false, 'L_IGNORE_POST' => $row['foe'] ? sprintf($user->lang['POST_BY_FOE'], get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), "<a href=\"{$u_show_post}\" onclick=\"dE('{$post_anchor}', 1); return false;\">", '</a>') : '', 'POST_SUBJECT' => $post_subject, 'MINI_POST_IMG' => $user->img('icon_post_target', $user->lang['POST']), 'POST_DATE' => $user->format_date($row['post_time']), 'MESSAGE' => $message, 'DECODED_MESSAGE' => $decoded_message, 'POST_ID' => $row['post_id'], 'U_MINI_POST' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'p=' . $row['post_id']) . '#p' . $row['post_id'], 'U_MCP_DETAILS' => $auth->acl_get('m_info', $forum_id) ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=main&mode=post_details&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '', 'POSTER_QUOTE' => $show_quote_button && $auth->acl_get('f_reply', $forum_id) ? addslashes(get_username_string('username', $poster_id, $row['username'], $row['user_colour'], $row['post_username'])) : '')); // Display not already displayed Attachments for this post, we already parsed them. ;) if (!empty($attachments[$row['post_id']])) { foreach ($attachments[$row['post_id']] as $attachment) { $template->assign_block_vars($mode . '_row.attachment', array('DISPLAY_ATTACHMENT' => $attachment)); } } unset($rowset[$post_list[$i]]); } if ($mode == 'topic_review') { $template->assign_var('QUOTE_IMG', $user->img('icon_post_quote', $user->lang['REPLY_WITH_QUOTE'])); } return true; }
/** * Display Message History */ function message_history($msg_id, $user_id, $message_row, $folder, $in_post_mode = false) { global $db, $user, $config, $template, $phpbb_root_path, $phpEx, $auth, $bbcode; // Get History Messages (could be newer) $sql = 'SELECT t.*, p.*, u.* FROM ' . PRIVMSGS_TABLE . ' p, ' . PRIVMSGS_TO_TABLE . ' t, ' . USERS_TABLE . ' u WHERE t.msg_id = p.msg_id AND p.author_id = u.user_id AND t.folder_id NOT IN (' . PRIVMSGS_NO_BOX . ', ' . PRIVMSGS_HOLD_BOX . ")\n\t\t\tAND t.user_id = {$user_id}"; if (!$message_row['root_level']) { $sql .= " AND (p.root_level = {$msg_id} OR (p.root_level = 0 AND p.msg_id = {$msg_id}))"; } else { $sql .= " AND (p.root_level = " . $message_row['root_level'] . ' OR p.msg_id = ' . $message_row['root_level'] . ')'; } $sql .= ' ORDER BY p.message_time DESC'; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); if (!$row) { $db->sql_freeresult($result); return false; } $rowset = array(); $bbcode_bitfield = ''; $folder_url = append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=pm') . '&folder='; do { $folder_id = (int) $row['folder_id']; $row['folder'][] = isset($folder[$folder_id]) ? '<a href="' . $folder_url . $folder_id . '">' . $folder[$folder_id]['folder_name'] . '</a>' : $user->lang['UNKNOWN_FOLDER']; if (isset($rowset[$row['msg_id']])) { $rowset[$row['msg_id']]['folder'][] = isset($folder[$folder_id]) ? '<a href="' . $folder_url . $folder_id . '">' . $folder[$folder_id]['folder_name'] . '</a>' : $user->lang['UNKNOWN_FOLDER']; } else { $rowset[$row['msg_id']] = $row; $bbcode_bitfield = $bbcode_bitfield | base64_decode($row['bbcode_bitfield']); } } while ($row = $db->sql_fetchrow($result)); $db->sql_freeresult($result); $title = $row['message_subject']; if (sizeof($rowset) == 1 && !$in_post_mode) { return false; } // Instantiate BBCode class if ((empty($bbcode) || $bbcode === false) && $bbcode_bitfield !== '') { if (!class_exists('bbcode')) { include $phpbb_root_path . 'includes/bbcode.' . $phpEx; } $bbcode = new bbcode(base64_encode($bbcode_bitfield)); } $title = censor_text($title); $url = append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'i=pm'); $next_history_pm = $previous_history_pm = $prev_id = 0; foreach ($rowset as $id => $row) { $author_id = $row['author_id']; $folder_id = (int) $row['folder_id']; $subject = $row['message_subject']; $message = $row['message_text']; $message = censor_text($message); $decoded_message = false; if ($in_post_mode && $auth->acl_get('u_sendpm') && $author_id != ANONYMOUS && $author_id != $user->data['user_id']) { $decoded_message = $message; decode_message($decoded_message, $row['bbcode_uid']); $decoded_message = bbcode_nl2br($decoded_message); } if ($row['bbcode_bitfield']) { $bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']); } $message = bbcode_nl2br($message); $message = smiley_text($message, !$row['enable_smilies']); $subject = censor_text($subject); if ($id == $msg_id) { $next_history_pm = next($rowset); $next_history_pm = sizeof($next_history_pm) ? (int) $next_history_pm['msg_id'] : 0; $previous_history_pm = $prev_id; } $template->assign_block_vars('history_row', array('MESSAGE_AUTHOR_QUOTE' => $decoded_message ? addslashes(get_username_string('username', $author_id, $row['username'], $row['user_colour'], $row['username'])) : '', 'MESSAGE_AUTHOR_FULL' => get_username_string('full', $author_id, $row['username'], $row['user_colour'], $row['username']), 'MESSAGE_AUTHOR_COLOUR' => get_username_string('colour', $author_id, $row['username'], $row['user_colour'], $row['username']), 'MESSAGE_AUTHOR' => get_username_string('username', $author_id, $row['username'], $row['user_colour'], $row['username']), 'U_MESSAGE_AUTHOR' => get_username_string('profile', $author_id, $row['username'], $row['user_colour'], $row['username']), 'SUBJECT' => $subject, 'SENT_DATE' => $user->format_date($row['message_time']), 'MESSAGE' => $message, 'FOLDER' => implode(', ', $row['folder']), 'DECODED_MESSAGE' => $decoded_message, 'S_CURRENT_MSG' => $row['msg_id'] == $msg_id, 'S_AUTHOR_DELETED' => $author_id == ANONYMOUS ? true : false, 'S_IN_POST_MODE' => $in_post_mode, 'MSG_ID' => $row['msg_id'], 'U_VIEW_MESSAGE' => "{$url}&f={$folder_id}&p=" . $row['msg_id'], 'U_QUOTE' => !$in_post_mode && $auth->acl_get('u_sendpm') && $author_id != ANONYMOUS && $author_id != $user->data['user_id'] ? "{$url}&mode=compose&action=quote&f=" . $folder_id . "&p=" . $row['msg_id'] : '', 'U_POST_REPLY_PM' => $author_id != $user->data['user_id'] && $author_id != ANONYMOUS && $auth->acl_get('u_sendpm') ? "{$url}&mode=compose&action=reply&f={$folder_id}&p=" . $row['msg_id'] : '')); unset($rowset[$id]); $prev_id = $id; } $template->assign_vars(array('QUOTE_IMG' => $user->img('icon_post_quote', $user->lang['REPLY_WITH_QUOTE']), 'HISTORY_TITLE' => $title, 'U_VIEW_NEXT_HISTORY' => $next_history_pm ? "{$url}&p=" . $next_history_pm : '', 'U_VIEW_PREVIOUS_HISTORY' => $previous_history_pm ? "{$url}&p=" . $previous_history_pm : '')); return true; }
function reply_post_func($xmlrpc_params) { global $db, $auth, $user, $config, $phpbb_root_path, $phpEx, $mobiquo_config, $phpbb_home; require_once 'include/emoji.php'; $user->setup('posting'); if (!$user->data['is_registered']) { trigger_error('LOGIN_EXPLAIN_POST'); } $params = php_xmlrpc_decode($xmlrpc_params); // get parameters $forum_id = isset($params[0]) ? intval($params[0]) : ''; $topic_id = isset($params[1]) ? intval($params[1]) : ''; $subject = isset($params[2]) ? $params[2] : ''; $text_body = isset($params[3]) ? $params[3] : ''; $text_body = emoji_unified_to_names($text_body); $attach_list = isset($params[4]) ? $params[4] : array(); $_POST['attachment_data'] = isset($params[5]) && $params[5] ? unserialize(base64_decode($params[5])) : array(); $GLOBALS['return_html'] = isset($params[6]) ? $params[6] : false; if (!$topic_id) { trigger_error('NO_TOPIC'); } if (utf8_clean_string($text_body) === '') { trigger_error('TOO_FEW_CHARS'); } $post_data = array(); $current_time = time(); // get topic data $sql = 'SELECT * FROM ' . TOPICS_TABLE . ' WHERE topic_id = ' . $topic_id; $result = $db->sql_query($sql); $post_data = $db->sql_fetchrow($result); $db->sql_freeresult($result); // get forum data $sql = 'SELECT * FROM ' . FORUMS_TABLE . "\n WHERE forum_type = " . FORUM_POST . ($post_data['forum_id'] ? "\n AND forum_id = '{$post_data['forum_id']}' " : ''); $result = $db->sql_query_limit($sql, 1); $forum_data = $db->sql_fetchrow($result); $db->sql_freeresult($result); $post_data = array_merge($post_data, $forum_data); if (!$post_data) { trigger_error('NO_TOPIC'); } // Use post_row values in favor of submitted ones... $forum_id = !empty($post_data['forum_id']) ? (int) $post_data['forum_id'] : (int) $forum_id; $topic_id = !empty($post_data['topic_id']) ? (int) $post_data['topic_id'] : (int) $topic_id; // Need to login to passworded forum first? if ($post_data['forum_password'] && !check_forum_password($forum_id)) { trigger_error('LOGIN_FORUM'); } // Check permissions if ($user->data['is_bot']) { trigger_error('NOT_AUTHORISED'); } // Is the user able to read within this forum? if (!$auth->acl_get('f_read', $forum_id)) { if ($user->data['user_id'] != ANONYMOUS) { trigger_error('USER_CANNOT_READ'); } trigger_error('LOGIN_EXPLAIN_POST'); } // Permission to do the reply if (!$auth->acl_get('f_reply', $forum_id)) { if ($user->data['user_id'] != ANONYMOUS) { trigger_error('USER_CANNOT_REPLY'); } trigger_error('LOGIN_EXPLAIN_POST'); } // Is the user able to post within this forum? if ($post_data['forum_type'] != FORUM_POST) { trigger_error('USER_CANNOT_FORUM_POST'); } // Forum/Topic locked? if (($post_data['forum_status'] == ITEM_LOCKED || isset($post_data['topic_status']) && $post_data['topic_status'] == ITEM_LOCKED) && !$auth->acl_get('m_edit', $forum_id)) { trigger_error($post_data['forum_status'] == ITEM_LOCKED ? 'FORUM_LOCKED' : 'TOPIC_LOCKED'); } $subject = (strpos($subject, 'Re: ') !== 0 ? 'Re: ' : '') . ($subject ? $subject : censor_text($post_data['topic_title'])); $post_data['post_edit_locked'] = isset($post_data['post_edit_locked']) ? (int) $post_data['post_edit_locked'] : 0; $post_data['post_subject'] = isset($post_data['topic_title']) ? $post_data['topic_title'] : ''; $post_data['topic_time_limit'] = isset($post_data['topic_time_limit']) ? $post_data['topic_time_limit'] ? (int) $post_data['topic_time_limit'] / 86400 : (int) $post_data['topic_time_limit'] : 0; $post_data['poll_length'] = !empty($post_data['poll_length']) ? (int) $post_data['poll_length'] / 86400 : 0; $post_data['poll_start'] = !empty($post_data['poll_start']) ? (int) $post_data['poll_start'] : 0; $post_data['icon_id'] = 0; $post_data['poll_options'] = array(); // Get Poll Data if ($post_data['poll_start']) { $sql = 'SELECT poll_option_text FROM ' . POLL_OPTIONS_TABLE . "\n WHERE topic_id = {$topic_id}\n ORDER BY poll_option_id"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $post_data['poll_options'][] = trim($row['poll_option_text']); } $db->sql_freeresult($result); } $orig_poll_options_size = sizeof($post_data['poll_options']); include $phpbb_root_path . 'includes/message_parser.' . $phpEx; $message_parser = new parse_message(); // Set some default variables $uninit = array('post_attachment' => 0, 'poster_id' => $user->data['user_id'], 'enable_magic_url' => 0, 'topic_status' => 0, 'topic_type' => POST_NORMAL, 'post_subject' => '', 'topic_title' => '', 'post_time' => 0, 'post_edit_reason' => '', 'notify_set' => 0); foreach ($uninit as $var_name => $default_value) { if (!isset($post_data[$var_name])) { $post_data[$var_name] = $default_value; } } unset($uninit); // Always check if the submitted attachment data is valid and belongs to the user. // Further down (especially in submit_post()) we do not check this again. $message_parser->get_submitted_attachment_data($post_data['poster_id']); $post_data['username'] = ''; $post_data['enable_urls'] = $post_data['enable_magic_url']; $post_data['enable_sig'] = $config['allow_sig'] && $user->optionget('attachsig') ? true : false; $post_data['enable_smilies'] = $config['allow_smilies'] && $user->optionget('smilies') ? true : false; $post_data['enable_bbcode'] = $config['allow_bbcode'] && $user->optionget('bbcode') ? true : false; $post_data['enable_urls'] = true; $post_data['enable_magic_url'] = $post_data['drafts'] = false; $check_value = ($post_data['enable_bbcode'] + 1 << 8) + ($post_data['enable_smilies'] + 1 << 4) + ($post_data['enable_urls'] + 1 << 2) + ($post_data['enable_sig'] + 1 << 1); // Check if user is watching this topic if ($config['allow_topic_notify'] && $user->data['is_registered']) { $sql = 'SELECT topic_id FROM ' . TOPICS_WATCH_TABLE . ' WHERE topic_id = ' . $topic_id . ' AND user_id = ' . $user->data['user_id']; $result = $db->sql_query($sql); $post_data['notify_set'] = (int) $db->sql_fetchfield('topic_id'); $db->sql_freeresult($result); } // HTML, BBCode, Smilies, Images and Flash status $bbcode_status = $config['allow_bbcode'] && $auth->acl_get('f_bbcode', $forum_id) ? true : false; $smilies_status = $bbcode_status && $config['allow_smilies'] && $auth->acl_get('f_smilies', $forum_id) ? true : false; $img_status = $bbcode_status && $auth->acl_get('f_img', $forum_id) ? true : false; $url_status = $config['allow_post_links'] ? true : false; $flash_status = $bbcode_status && $auth->acl_get('f_flash', $forum_id) && $config['allow_post_flash'] ? true : false; $quote_status = $auth->acl_get('f_reply', $forum_id) ? true : false; $post_data['topic_cur_post_id'] = request_var('topic_cur_post_id', 0); $post_data['post_subject'] = utf8_normalize_nfc($subject); $message_parser->message = utf8_normalize_nfc(htmlspecialchars($text_body)); $post_data['username'] = utf8_normalize_nfc(request_var('username', $post_data['username'], true)); $post_data['post_edit_reason'] = ''; $post_data['orig_topic_type'] = $post_data['topic_type']; $post_data['topic_type'] = request_var('topic_type', (int) $post_data['topic_type']); $post_data['topic_time_limit'] = request_var('topic_time_limit', (int) $post_data['topic_time_limit']); $post_data['icon_id'] = request_var('icon', 0); $post_data['enable_bbcode'] = !$bbcode_status || isset($_POST['disable_bbcode']) ? false : true; $post_data['enable_smilies'] = !$smilies_status || isset($_POST['disable_smilies']) ? false : true; $post_data['enable_urls'] = isset($_POST['disable_magic_url']) ? 0 : 1; $post_data['enable_sig'] = !$config['allow_sig'] || !$auth->acl_get('f_sigs', $forum_id) || !$auth->acl_get('u_sig') ? false : ($user->data['is_registered'] ? true : false); if ($config['allow_topic_notify'] && $user->data['is_registered']) { $notify = !$post_data['notify_set'] ? $user->data['user_notify'] : $post_data['notify_set'] ? true : false; } else { $notify = false; } $post_data['poll_title'] = utf8_normalize_nfc(request_var('poll_title', '', true)); $post_data['poll_length'] = request_var('poll_length', 0); $post_data['poll_option_text'] = utf8_normalize_nfc(request_var('poll_option_text', '', true)); $post_data['poll_max_options'] = request_var('poll_max_options', 1); $post_data['poll_vote_change'] = $auth->acl_get('f_votechg', $forum_id) && isset($_POST['poll_vote_change']) ? 1 : 0; // Parse Attachments - before checksum is calculated $message_parser->parse_attachments('fileupload', 'reply', $forum_id, true, false, false); // Grab md5 'checksum' of new message $message_md5 = md5($message_parser->message); // Check checksum ... don't re-parse message if the same if (sizeof($message_parser->warn_msg)) { trigger_error(join("\n", $message_parser->warn_msg)); } $message_parser->parse($post_data['enable_bbcode'], $config['allow_post_links'] ? $post_data['enable_urls'] : false, $post_data['enable_smilies'], $img_status, $flash_status, $quote_status, $config['allow_post_links']); if ($config['flood_interval'] && !$auth->acl_get('f_ignoreflood', $forum_id)) { // Flood check $last_post_time = 0; if ($user->data['is_registered']) { $last_post_time = $user->data['user_lastpost_time']; } else { $sql = 'SELECT post_time AS last_post_time FROM ' . POSTS_TABLE . "\n WHERE poster_ip = '" . $user->ip . "'\n AND post_time > " . ($current_time - $config['flood_interval']); $result = $db->sql_query_limit($sql, 1); if ($row = $db->sql_fetchrow($result)) { $last_post_time = $row['last_post_time']; } $db->sql_freeresult($result); } if ($last_post_time && $current_time - $last_post_time < intval($config['flood_interval'])) { trigger_error('FLOOD_ERROR'); } } // Validate username if ($post_data['username'] && !$user->data['is_registered']) { include $phpbb_root_path . 'includes/functions_user.' . $phpEx; if (($result = validate_username($post_data['username'], !empty($post_data['post_username']) ? $post_data['post_username'] : '')) !== false) { $user->add_lang('ucp'); trigger_error($result . '_USERNAME'); } } $post_data['poll_last_vote'] = isset($post_data['poll_last_vote']) ? $post_data['poll_last_vote'] : 0; $poll = array(); // if (sizeof($message_parser->warn_msg)) // { // return get_error(); // } // DNSBL check if ($config['check_dnsbl'] && $mobiquo_config['check_dnsbl']) { if (($dnsbl = $user->check_dnsbl('post')) !== false) { trigger_error(sprintf($user->lang['IP_BLACKLISTED'], $user->ip, $dnsbl[1])); } } // Store message, sync counters $data = array('topic_title' => empty($post_data['topic_title']) ? $post_data['post_subject'] : $post_data['topic_title'], 'topic_first_post_id' => isset($post_data['topic_first_post_id']) ? (int) $post_data['topic_first_post_id'] : 0, 'topic_last_post_id' => isset($post_data['topic_last_post_id']) ? (int) $post_data['topic_last_post_id'] : 0, 'topic_time_limit' => (int) $post_data['topic_time_limit'], 'topic_attachment' => isset($post_data['topic_attachment']) ? (int) $post_data['topic_attachment'] : 0, 'post_id' => 0, 'topic_id' => (int) $topic_id, 'forum_id' => (int) $forum_id, 'icon_id' => (int) $post_data['icon_id'], 'poster_id' => (int) $post_data['poster_id'], 'enable_sig' => (bool) $post_data['enable_sig'], 'enable_bbcode' => (bool) $post_data['enable_bbcode'], 'enable_smilies' => (bool) $post_data['enable_smilies'], 'enable_urls' => (bool) $post_data['enable_urls'], 'enable_indexing' => (bool) $post_data['enable_indexing'], 'message_md5' => (string) $message_md5, 'post_time' => isset($post_data['post_time']) ? (int) $post_data['post_time'] : $current_time, 'post_checksum' => isset($post_data['post_checksum']) ? (string) $post_data['post_checksum'] : '', 'post_edit_reason' => $post_data['post_edit_reason'], 'post_edit_user' => isset($post_data['post_edit_user']) ? (int) $post_data['post_edit_user'] : 0, 'forum_parents' => $post_data['forum_parents'], 'forum_name' => $post_data['forum_name'], 'notify' => $notify, 'notify_set' => $post_data['notify_set'], 'poster_ip' => isset($post_data['poster_ip']) ? $post_data['poster_ip'] : $user->ip, 'post_edit_locked' => (int) $post_data['post_edit_locked'], 'bbcode_bitfield' => $message_parser->bbcode_bitfield, 'bbcode_uid' => $message_parser->bbcode_uid, 'message' => $message_parser->message, 'attachment_data' => $message_parser->attachment_data, 'filename_data' => $message_parser->filename_data, 'topic_approved' => isset($post_data['topic_approved']) ? $post_data['topic_approved'] : false, 'post_approved' => isset($post_data['post_approved']) ? $post_data['post_approved'] : false, 'post_expire_time' => -1); include $phpbb_root_path . 'includes/functions_posting.' . $phpEx; $update_message = true; $cwd = getcwd(); chdir('../'); $phpbb_root_path_tmp = $phpbb_root_path; $phpbb_root_path = './'; $redirect_url = submit_post('reply', $post_data['post_subject'], $post_data['username'], $post_data['topic_type'], $poll, $data, $update_message); chdir($cwd); $phpbb_root_path = $phpbb_root_path_tmp; // Check the permissions for post approval, as well as the queue trigger where users are put on approval with a post count lower than specified. Moderators are not affected. $approved = true; if (($config['enable_queue_trigger'] && $user->data['user_posts'] < $config['queue_trigger_posts'] || !$auth->acl_get('f_noapprove', $data['forum_id'])) && !$auth->acl_get('m_approve', $data['forum_id'])) { $approved = false; } $reply_success = false; $post_id = ''; if ($redirect_url) { preg_match('/&p=(\\d+)/', $redirect_url, $matches); $post_id = $matches[1]; $reply_success = true; // get new post_content $message = censor_text($data['message']); $quote_wrote_string = $user->lang['WROTE']; $message = str_replace('[/quote:' . $data['bbcode_uid'] . ']', '[/quote]', $message); $message = preg_replace('/\\[quote(?:="(.*?)")?:' . $data['bbcode_uid'] . '\\]/ise', "'[quote]' . ('\$1' ? '\$1' . ' {$quote_wrote_string}:\n' : '\n')", $message); $blocks = preg_split('/(\\[\\/?quote\\])/i', $message, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); $quote_level = 0; $message = ''; foreach ($blocks as $block) { if ($block == '[quote]') { if ($quote_level == 0) { $message .= $block; } $quote_level++; } else { if ($block == '[/quote]') { if ($quote_level <= 1) { $message .= $block; } if ($quote_level >= 1) { $quote_level--; } } else { if ($quote_level <= 1) { $message .= $block; } } } } $message = preg_replace('/\\[(youtube|video|googlevideo|gvideo):' . $data['bbcode_uid'] . '\\](.*?)\\[\\/\\1:' . $data['bbcode_uid'] . '\\]/sie', "video_bbcode_format('\$1', '\$2')", $message); $message = preg_replace('/\\[(BBvideo)[\\d, ]+:' . $row['bbcode_uid'] . '\\](.*?)\\[\\/\\1:' . $row['bbcode_uid'] . '\\]/si', "[url=\$2]YouTube Video[/url]", $message); $message = preg_replace('/\\[(spoil|spoiler):' . $row['bbcode_uid'] . '\\](.*?)\\[\\/\\1:' . $row['bbcode_uid'] . '\\]/si', "[spoiler]\$2[/spoiler]", $message); $message = preg_replace('/\\[b:' . $data['bbcode_uid'] . '\\](.*?)\\[\\/b:' . $data['bbcode_uid'] . '\\]/si', '[b]$1[/b]', $message); $message = preg_replace('/\\[i:' . $data['bbcode_uid'] . '\\](.*?)\\[\\/i:' . $data['bbcode_uid'] . '\\]/si', '[i]$1[/i]', $message); $message = preg_replace('/\\[u:' . $data['bbcode_uid'] . '\\](.*?)\\[\\/u:' . $data['bbcode_uid'] . '\\]/si', '[u]$1[/u]', $message); $message = preg_replace('/\\[color=#(\\w{6}):' . $data['bbcode_uid'] . '\\](.*?)\\[\\/color:' . $data['bbcode_uid'] . '\\]/si', '[color=#$1]$2[/color]', $message); // Second parse bbcode here if ($data['bbcode_bitfield']) { $bbcode = new bbcode(base64_encode($data['bbcode_bitfield'])); $bbcode->bbcode_second_pass($message, $data['bbcode_uid'], $data['bbcode_bitfield']); } $message = bbcode_nl2br($message); $message = smiley_text($message); if (!empty($data['attachment_data'])) { parse_attachments($forum_id, $message, $data['attachment_data'], $update_count); } $updated_post_title = html_entity_decode(strip_tags(censor_text($data['topic_title'])), ENT_QUOTES, 'UTF-8'); $edit_allowed = $auth->acl_get('m_edit', $forum_id) || $auth->acl_get('f_edit', $forum_id) && !$data['post_edit_locked'] && ($data['post_time'] > time() - $config['edit_time'] * 60 || !$config['edit_time']); $delete_allowed = $auth->acl_get('m_delete', $forum_id) || $auth->acl_get('f_delete', $forum_id) && ($data['post_time'] > time() - $config['delete_time'] * 60 || !$config['delete_time']) && !$data['post_edit_locked']; $attachments = array(); if (sizeof($attach_list) && sizeof($data['attachment_data'])) { $sql = 'SELECT * FROM ' . ATTACHMENTS_TABLE . ' WHERE ' . $db->sql_in_set('attach_id', $attach_list) . ' AND in_message = 0 ORDER BY filetime DESC'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $attachment_by_id[$row['attach_id']] = $row; } $db->sql_freeresult($result); foreach ($data['attachment_data'] as $attachment) { if (preg_match('/<img src=\\".*?(\\/download\\/file.php\\?id=(\\d+).*?)\\"/is', $attachment, $matches)) { $file_url = html_entity_decode($phpbb_home . $matches[1]); $attach_id = $matches[2]; unset($matches); $xmlrpc_attachment = new xmlrpcval(array('filename' => new xmlrpcval($attachment_by_id[$attach_id]['real_filename'], 'base64'), 'filesize' => new xmlrpcval($attachment_by_id[$attach_id]['filesize'], 'int'), 'content_type' => new xmlrpcval('image'), 'thumbnail_url' => new xmlrpcval(''), 'url' => new xmlrpcval($file_url)), 'struct'); $attachments[] = $xmlrpc_attachment; } } } } $xmlrpc_reply_topic = new xmlrpcval(array('result' => new xmlrpcval($reply_success, 'boolean'), 'post_id' => new xmlrpcval($post_id, 'string'), 'state' => new xmlrpcval($approved ? 0 : 1, 'int'), 'post_title' => new xmlrpcval($updated_post_title, 'base64'), 'post_content' => new xmlrpcval(post_html_clean($message), 'base64'), 'post_author_name' => new xmlrpcval(html_entity_decode($user->data['username']), 'base64'), 'is_online' => new xmlrpcval(true, 'boolean'), 'can_edit' => new xmlrpcval($edit_allowed, 'boolean'), 'icon_url' => new xmlrpcval($user->optionget('viewavatars') ? get_user_avatar_url($user->data['user_avatar'], $user->data['user_avatar_type']) : ''), 'post_time' => new xmlrpcval(mobiquo_iso8601_encode($current_time), 'dateTime.iso8601'), 'can_delete' => new xmlrpcval($delete_allowed, 'boolean'), 'allow_smilies' => new xmlrpcval($data['enable_smilies'] ? true : false, 'boolean'), 'attachments' => new xmlrpcval($attachments, 'array')), 'struct'); return new xmlrpcresp($xmlrpc_reply_topic); }
/** * Formatting text for display */ function format_display($allow_bbcode, $allow_magic_url, $allow_smilies, $update_this_message = true) { // If false, then the parsed message get returned but internal message not processed. if (!$update_this_message) { $tmp_message = $this->message; $return_message =& $this->message; } if ($this->message_status == 'plain') { // Force updating message - of course. $this->parse($allow_bbcode, $allow_magic_url, $allow_smilies, $this->allow_img_bbcode, $this->allow_flash_bbcode, $this->allow_quote_bbcode, $this->allow_url_bbcode, true); } // Replace naughty words such as farty pants $this->message = censor_text($this->message); // Parse BBcode if ($allow_bbcode) { $this->bbcode_cache_init(); // We are giving those parameters to be able to use the bbcode class on its own $this->bbcode_second_pass($this->message, $this->bbcode_uid); } $this->message = bbcode_nl2br($this->message); $this->message = smiley_text($this->message, !$allow_smilies); if (!$update_this_message) { unset($this->message); $this->message = $tmp_message; return $return_message; } $this->message_status = 'display'; return false; }
function main($id, $mode) { global $auth, $db, $user, $template, $cache; global $config, $phpbb_root_path, $phpEx, $action; include_once $phpbb_root_path . 'includes/functions_posting.' . $phpEx; include_once $phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx; $start = request_var('start', 0); $this->page_title = 'MCP_PM_REPORTS'; switch ($action) { case 'close': case 'delete': include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx; $report_id_list = request_var('report_id_list', array(0)); if (!sizeof($report_id_list)) { trigger_error('NO_REPORT_SELECTED'); } if (!function_exists('close_report')) { include $phpbb_root_path . 'includes/mcp/mcp_reports.' . $phpEx; } close_report($report_id_list, $mode, $action, true); break; } switch ($mode) { case 'pm_report_details': $user->add_lang(array('posting', 'viewforum', 'viewtopic', 'ucp')); $report_id = request_var('r', 0); $sql = 'SELECT r.pm_id, r.user_id, r.report_id, r.report_closed, report_time, r.report_text, rr.reason_title, rr.reason_description, u.username, u.username_clean, u.user_colour FROM ' . REPORTS_TABLE . ' r, ' . REPORTS_REASONS_TABLE . ' rr, ' . USERS_TABLE . ' u WHERE r.report_id = ' . $report_id . ' AND rr.reason_id = r.reason_id AND r.user_id = u.user_id AND r.post_id = 0 ORDER BY report_closed ASC'; $result = $db->sql_query_limit($sql, 1); $report = $db->sql_fetchrow($result); $db->sql_freeresult($result); if (!$report_id || !$report) { trigger_error('NO_REPORT'); } $pm_id = $report['pm_id']; $report_id = $report['report_id']; $pm_info = get_pm_data(array($pm_id)); if (!sizeof($pm_info)) { trigger_error('NO_REPORT_SELECTED'); } $pm_info = $pm_info[$pm_id]; write_pm_addresses(array('to' => $pm_info['to_address'], 'bcc' => $pm_info['bcc_address']), (int) $pm_info['author_id']); $reason = array('title' => $report['reason_title'], 'description' => $report['reason_description']); if (isset($user->lang['report_reasons']['TITLE'][strtoupper($reason['title'])]) && isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($reason['title'])])) { $reason['description'] = $user->lang['report_reasons']['DESCRIPTION'][strtoupper($reason['title'])]; $reason['title'] = $user->lang['report_reasons']['TITLE'][strtoupper($reason['title'])]; } // Process message, leave it uncensored $message = $pm_info['message_text']; if ($pm_info['bbcode_bitfield']) { include_once $phpbb_root_path . 'includes/bbcode.' . $phpEx; $bbcode = new bbcode($pm_info['bbcode_bitfield']); $bbcode->bbcode_second_pass($message, $pm_info['bbcode_uid'], $pm_info['bbcode_bitfield']); } $message = bbcode_nl2br($message); $message = smiley_text($message); if ($pm_info['message_attachment'] && $auth->acl_get('u_pm_download')) { $sql = 'SELECT * FROM ' . ATTACHMENTS_TABLE . ' WHERE post_msg_id = ' . $pm_id . ' AND in_message = 1 ORDER BY filetime DESC'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $attachments[] = $row; } $db->sql_freeresult($result); if (sizeof($attachments)) { $update_count = array(); parse_attachments(0, $message, $attachments, $update_count); } // Display not already displayed Attachments for this post, we already parsed them. ;) if (!empty($attachments)) { $template->assign_var('S_HAS_ATTACHMENTS', true); foreach ($attachments as $attachment) { $template->assign_block_vars('attachment', array('DISPLAY_ATTACHMENT' => $attachment)); } } } $template->assign_vars(array('S_MCP_REPORT' => true, 'S_PM' => true, 'S_CLOSE_ACTION' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=pm_reports&mode=pm_report_details&r=' . $report_id), 'S_CAN_VIEWIP' => $auth->acl_getf_global('m_info'), 'S_POST_REPORTED' => $pm_info['message_reported'], 'S_USER_NOTES' => true, 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=pm_reports&mode=pm_report_details&r=' . $report_id), 'U_MCP_REPORTER_NOTES' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=notes&mode=user_notes&u=' . $report['user_id']), 'U_MCP_USER_NOTES' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=notes&mode=user_notes&u=' . $pm_info['author_id']), 'U_MCP_WARN_REPORTER' => $auth->acl_get('m_warn') ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=warn&mode=warn_user&u=' . $report['user_id']) : '', 'U_MCP_WARN_USER' => $auth->acl_get('m_warn') ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=warn&mode=warn_user&u=' . $pm_info['author_id']) : '', 'EDIT_IMG' => $user->img('icon_post_edit', $user->lang['EDIT_POST']), 'MINI_POST_IMG' => $user->img('icon_post_target', 'POST'), 'RETURN_REPORTS' => sprintf($user->lang['RETURN_REPORTS'], '<a href="' . append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=pm_reports' . ($pm_info['message_reported'] ? '&mode=pm_reports' : '&mode=pm_reports_closed') . '&start=' . $start) . '">', '</a>'), 'REPORTED_IMG' => $user->img('icon_topic_reported', $user->lang['POST_REPORTED']), 'REPORT_DATE' => $user->format_date($report['report_time']), 'REPORT_ID' => $report_id, 'REPORT_REASON_TITLE' => $reason['title'], 'REPORT_REASON_DESCRIPTION' => $reason['description'], 'REPORT_TEXT' => $report['report_text'], 'POST_AUTHOR_FULL' => get_username_string('full', $pm_info['author_id'], $pm_info['username'], $pm_info['user_colour']), 'POST_AUTHOR_COLOUR' => get_username_string('colour', $pm_info['author_id'], $pm_info['username'], $pm_info['user_colour']), 'POST_AUTHOR' => get_username_string('username', $pm_info['author_id'], $pm_info['username'], $pm_info['user_colour']), 'U_POST_AUTHOR' => get_username_string('profile', $pm_info['author_id'], $pm_info['username'], $pm_info['user_colour']), 'REPORTER_FULL' => get_username_string('full', $report['user_id'], $report['username'], $report['user_colour']), 'REPORTER_COLOUR' => get_username_string('colour', $report['user_id'], $report['username'], $report['user_colour']), 'REPORTER_NAME' => get_username_string('username', $report['user_id'], $report['username'], $report['user_colour']), 'U_VIEW_REPORTER_PROFILE' => get_username_string('profile', $report['user_id'], $report['username'], $report['user_colour']), 'POST_PREVIEW' => $message, 'POST_SUBJECT' => $pm_info['message_subject'] ? $pm_info['message_subject'] : $user->lang['NO_SUBJECT'], 'POST_DATE' => $user->format_date($pm_info['message_time']), 'POST_IP' => $pm_info['author_ip'], 'POST_IPADDR' => $auth->acl_getf_global('m_info') && request_var('lookup', '') ? @gethostbyaddr($pm_info['author_ip']) : '', 'POST_ID' => $pm_info['msg_id'], 'U_LOOKUP_IP' => $auth->acl_getf_global('m_info') ? $this->u_action . '&r=' . $report_id . '&pm=' . $pm_id . '&lookup=' . $pm_info['author_ip'] . '#ip' : '')); $this->tpl_name = 'mcp_post'; break; case 'pm_reports': case 'pm_reports_closed': $user->add_lang(array('ucp')); $sort_days = $total = 0; $sort_key = $sort_dir = ''; $sort_by_sql = $sort_order_sql = array(); mcp_sorting($mode, $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total); $limit_time_sql = $sort_days ? 'AND r.report_time >= ' . (time() - $sort_days * 86400) : ''; if ($mode == 'pm_reports') { $report_state = 'p.message_reported = 1 AND r.report_closed = 0'; } else { $report_state = 'r.report_closed = 1'; } $sql = 'SELECT r.report_id FROM ' . PRIVMSGS_TABLE . ' p, ' . REPORTS_TABLE . ' r ' . ($sort_order_sql[0] == 'u' ? ', ' . USERS_TABLE . ' u' : '') . ($sort_order_sql[0] == 'r' ? ', ' . USERS_TABLE . ' ru' : '') . "\n\t\t\t\t\tWHERE {$report_state}\n\t\t\t\t\t\tAND r.pm_id = p.msg_id\n\t\t\t\t\t\t" . ($sort_order_sql[0] == 'u' ? 'AND u.user_id = p.author_id' : '') . ' ' . ($sort_order_sql[0] == 'r' ? 'AND ru.user_id = r.user_id' : '') . "\n\t\t\t\t\t\tAND r.post_id = 0\n\t\t\t\t\t\t{$limit_time_sql}\n\t\t\t\t\tORDER BY {$sort_order_sql}"; $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); $i = 0; $report_ids = array(); while ($row = $db->sql_fetchrow($result)) { $report_ids[] = $row['report_id']; $row_num[$row['report_id']] = $i++; } $db->sql_freeresult($result); if (sizeof($report_ids)) { $sql = 'SELECT p.*, u.username, u.username_clean, u.user_colour, r.user_id as reporter_id, ru.username as reporter_name, ru.user_colour as reporter_colour, r.report_time, r.report_id FROM ' . REPORTS_TABLE . ' r, ' . PRIVMSGS_TABLE . ' p, ' . USERS_TABLE . ' u, ' . USERS_TABLE . ' ru WHERE ' . $db->sql_in_set('r.report_id', $report_ids) . "\n\t\t\t\t\t\t\tAND r.pm_id = p.msg_id\n\t\t\t\t\t\t\tAND p.author_id = u.user_id\n\t\t\t\t\t\t\tAND ru.user_id = r.user_id\n\t\t\t\t\t\tORDER BY {$sort_order_sql}"; $result = $db->sql_query($sql); $pm_list = $pm_by_id = array(); while ($row = $db->sql_fetchrow($result)) { $pm_by_id[(int) $row['msg_id']] = $row; $pm_list[] = (int) $row['msg_id']; } $db->sql_freeresult($result); if (sizeof($pm_list)) { $address_list = get_recipient_strings($pm_by_id); foreach ($pm_list as $message_id) { $row = $pm_by_id[$message_id]; $template->assign_block_vars('postrow', array('U_VIEW_DETAILS' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i=pm_reports&mode=pm_report_details&r={$row['report_id']}"), 'PM_AUTHOR_FULL' => get_username_string('full', $row['author_id'], $row['username'], $row['user_colour']), 'PM_AUTHOR_COLOUR' => get_username_string('colour', $row['author_id'], $row['username'], $row['user_colour']), 'PM_AUTHOR' => get_username_string('username', $row['author_id'], $row['username'], $row['user_colour']), 'U_PM_AUTHOR' => get_username_string('profile', $row['author_id'], $row['username'], $row['user_colour']), 'REPORTER_FULL' => get_username_string('full', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), 'REPORTER_COLOUR' => get_username_string('colour', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), 'REPORTER' => get_username_string('username', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), 'U_REPORTER' => get_username_string('profile', $row['reporter_id'], $row['reporter_name'], $row['reporter_colour']), 'PM_SUBJECT' => $row['message_subject'] ? $row['message_subject'] : $user->lang['NO_SUBJECT'], 'PM_TIME' => $user->format_date($row['message_time']), 'REPORT_ID' => $row['report_id'], 'REPORT_TIME' => $user->format_date($row['report_time']), 'RECIPIENTS' => implode(', ', $address_list[$row['msg_id']]))); } } } // Now display the page $template->assign_vars(array('L_EXPLAIN' => $mode == 'pm_reports' ? $user->lang['MCP_PM_REPORTS_OPEN_EXPLAIN'] : $user->lang['MCP_PM_REPORTS_CLOSED_EXPLAIN'], 'L_TITLE' => $mode == 'pm_reports' ? $user->lang['MCP_PM_REPORTS_OPEN'] : $user->lang['MCP_PM_REPORTS_CLOSED'], 'S_PM' => true, 'S_MCP_ACTION' => $this->u_action, 'S_CLOSED' => $mode == 'pm_reports_closed' ? true : false, 'PAGINATION' => generate_pagination($this->u_action . "&st={$sort_days}&sk={$sort_key}&sd={$sort_dir}", $total, $config['topics_per_page'], $start), 'PAGE_NUMBER' => on_page($total, $config['topics_per_page'], $start), 'TOTAL' => $total, 'TOTAL_REPORTS' => $total == 1 ? $user->lang['LIST_REPORT'] : sprintf($user->lang['LIST_REPORTS'], $total))); $this->tpl_name = 'mcp_reports'; break; } }