示例#1
0
function category_read()
{
    global $admintpl, $language, $STYLEURL, $CURUSER, $STYLEPATH, $btit_settings;
    $admintpl->set("language", $language);
    $cres = genrelist();
    for ($i = 0; $i < count($cres); $i++) {
        $cres[$i]["frm_number"] = "form" . $i;
        $cres[$i]["name"] = unesc($cres[$i]["name"]);
        $cres[$i]["image"] = "<img src=\"{$STYLEURL}/images/categories/" . $cres[$i]["image"] . "\" alt=\"\" border=\"0\" />";
        $cres[$i]["smf_select"] = get_forum_list($cres[$i]["forumid"], $cres[$i]["id"]);
    }
    $admintpl->set("categories", $cres);
    unset($cres);
}
示例#2
0
function get_forum_list($page = 1)
{
    if (!($db = db::get())) {
        return false;
    }
    if (!is_numeric($page)) {
        return false;
    }
    $offset = calculate_page_offset($page, 10);
    $forums_array = array();
    $sql = "SELECT SQL_CALC_FOUND_ROWS CONCAT(FORUMS.DATABASE_NAME, '`.`', FORUMS.WEBTAG, '_') AS PREFIX, ";
    $sql .= "FORUM_SETTINGS_NAME.SVALUE AS FORUM_NAME, FORUM_SETTINGS_DESC.SVALUE AS FORUM_DESC, ";
    $sql .= "FORUMS.FID, FORUMS.WEBTAG, FORUMS.ACCESS_LEVEL FROM FORUMS ";
    $sql .= "LEFT JOIN FORUM_SETTINGS FORUM_SETTINGS_NAME ON (FORUM_SETTINGS_NAME.FID = FORUMS.FID AND FORUM_SETTINGS_NAME.SNAME = 'forum_name') ";
    $sql .= "LEFT JOIN FORUM_SETTINGS FORUM_SETTINGS_DESC ON (FORUM_SETTINGS_DESC.FID = FORUMS.FID AND FORUM_SETTINGS_DESC.SNAME = 'forum_desc') ";
    $sql .= "WHERE FORUMS.ACCESS_LEVEL > -1 AND FORUMS.ACCESS_LEVEL < 3 ORDER BY FORUMS.FID LIMIT {$offset}, 10";
    if (!($result = $db->query($sql))) {
        return false;
    }
    $sql = "SELECT FOUND_ROWS() AS ROW_COUNT";
    if (!($result_count = $db->query($sql))) {
        return false;
    }
    list($forums_count) = $result_count->fetch_row();
    if ($result->num_rows == 0 && $forums_count > 0 && $page > 1) {
        return get_forum_list($page - 1);
    }
    while ($forum_data = $result->fetch_assoc()) {
        if (!isset($forum_data['FORUM_NAME']) || strlen(trim($forum_data['FORUM_NAME'])) < 1) {
            $forum_data['FORUM_NAME'] = "A Beehive Forum";
        }
        if (!isset($forum_data['FORUM_DESC']) || strlen(trim($forum_data['FORUM_DESC'])) < 1) {
            $forum_data['FORUM_DESC'] = "";
        }
        $sql = "SELECT COUNT(PID) AS POST_COUNT FROM `{$forum_data['PREFIX']}POST` POST ";
        if (!($result_post_count = $db->query($sql))) {
            return false;
        }
        $forum_post_data = $result_post_count->fetch_assoc();
        if (!isset($forum_post_data['POST_COUNT']) || is_null($forum_post_data['POST_COUNT'])) {
            $forum_data['MESSAGES'] = 0;
        } else {
            $forum_data['MESSAGES'] = $forum_post_data['POST_COUNT'];
        }
        $forums_array[] = $forum_data;
    }
    return array('forums_array' => $forums_array, 'forums_count' => $forums_count);
}
示例#3
0
文件: index.php 项目: rhertzog/lcs
    }
    if ('exMvDownCat' == $cmd) {
        move_down_category($catId);
    }
    if ('exMvUpForum' == $cmd) {
        move_up_forum($forumId);
    }
    if ('exMvDownForum' == $cmd) {
        move_down_forum($forumId);
    }
}
//end of admin commands
//load category and forum lists
$categories = get_category_list();
$total_categories = count($categories);
$forum_list = get_forum_list();
if (claro_is_user_authenticated()) {
    $userGroupList = get_user_group_list(claro_get_current_user_id());
    $userGroupList = array_keys($userGroupList);
    $tutorGroupList = get_tutor_group_list(claro_get_current_user_id());
} else {
    $userGroupList = array();
    $tutorGroupList = array();
}
//add javascript control for "dangerous" commands (delete-empty)
$htmlHeadXtra[] = "<script type=\"text/javascript\">\n    function confirm_delete(name)\n    {\n       if(confirm('" . clean_str_for_javascript(get_lang('Are you sure to delete')) . " ' + name + ' ?'))\n       {return true;}\n       else\n       {return false;}\n    }\n    \n    function confirm_empty(name)\n    {\n       if(confirm('" . clean_str_for_javascript(get_lang('Delete all messages of')) . " ' + name + ' ?'))\n       {return true;}\n       else\n       {return false;}\n    }\n    </script>";
//prepare display
$nameTools = get_lang('Forums');
$pagetype = 'index';
$helpUrl = $is_allowedToEdit ? get_help_page_url('blockForumsHelp', 'CLFRM') : null;
$toolList = disp_forum_toolbar_array($pagetype, 0, 0, 0);
function make_forum_drop_down_box()
{
    global $db, $userdata;
    $forums_row = get_forum_list();
    $forum_list = "<select name=\"forum_top\">";
    $forum_list .= "<option value=\"-1\" selected=\"selected\">All</option>";
    for ($i = 1; $i < count($forums_row) + 1; $i++) {
        if (isset($forums_row[$i]) && $forums_row[$i]['auth_view']) {
            $forum_list .= "<option value=\"" . $i . "\">" . strip_tags(id_to_value($i, 'forum')) . "</option>";
        }
    }
    $forum_list .= "</select>";
    return $forum_list;
}
示例#5
0
	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('posting');

				$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
					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,
						'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']))
				{
					$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(
					'S_MCP_REPORT'			=> true,
					'S_CLOSE_ACTION'		=> $this->u_action . '&amp;p=' . $post_id . '&amp;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&amp;f={$post_info['forum_id']}&amp;p={$post_info['post_id']}") : '',
					'U_MCP_APPROVE'				=> append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&amp;mode=approve_details&amp;f=' . $post_info['forum_id'] . '&amp;p=' . $post_id),
					'U_MCP_REPORT'				=> append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&amp;mode=report_details&amp;f=' . $post_info['forum_id'] . '&amp;p=' . $post_id),
					'U_MCP_REPORTER_NOTES'		=> append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&amp;mode=user_notes&amp;u=' . $report['user_id']),
					'U_MCP_USER_NOTES'			=> append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&amp;mode=user_notes&amp;u=' . $post_info['user_id']),
					'U_MCP_WARN_REPORTER'		=> ($auth->acl_get('m_warn')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&amp;mode=warn_user&amp;u=' . $report['user_id']) : '',
					'U_MCP_WARN_USER'			=> ($auth->acl_get('m_warn')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&amp;mode=warn_user&amp;u=' . $post_info['user_id']) : '',
					'U_VIEW_POST'				=> append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $post_info['forum_id'] . '&amp;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'] . '&amp;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', 'NEW_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']) ? '&amp;mode=reports' : '&amp;mode=reports_closed') . '&amp;start=' . $start . '&amp;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 . '&amp;r=' . $report_id . '&amp;p=' . $post_id . '&amp;f=' . $forum_id . '&amp;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);

				if ($topic_id && $forum_id)
				{
					$topic_info = get_topic_data(array($topic_id));

					if (!sizeof($topic_info))
					{
						trigger_error('TOPIC_NOT_EXIST');
					}

					$topic_info = $topic_info[$topic_id];
					$forum_id = $topic_info['forum_id'];
				}
				else if ($topic_id && !$forum_id)
				{
					$topic_id = 0;
				}

				$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('&nbsp; &nbsp;', $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 t.topic_last_post_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) . "
						$report_state
						AND r.post_id = p.post_id
						" . (($sort_order_sql[0] == 'u') ? 'AND u.user_id = p.poster_id' : '') . '
						' . (($sort_order_sql[0] == 'r') ? 'AND ru.user_id = p.poster_id' : '') . '
						' . (($topic_id) ? 'AND p.topic_id = ' . $topic_id : '') . "
						AND t.topic_id = p.topic_id
						$limit_time_sql
					ORDER 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
						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'] . '&amp;p=' . $row['post_id']) . '#p' . $row['post_id'],
							'U_VIEW_DETAILS'			=> append_sid("{$phpbb_root_path}mcp.$phpEx", "i=reports&amp;start=$start&amp;mode=report_details&amp;f={$row['forum_id']}&amp;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 . "&amp;f=$forum_id&amp;t=$topic_id&amp;st=$sort_days&amp;sk=$sort_key&amp;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;
		}
	}
示例#6
0
/**
* sorting in mcp
*
* @param string $where_sql should either be WHERE (default if ommited) or end with AND or OR
*
* $mode reports and reports_closed: the $where parameters uses aliases p for posts table and r for report table
* $mode unapproved_posts: the $where parameters uses aliases p for posts table and t for topic table
*/
function mcp_sorting($mode, &$sort_days, &$sort_key, &$sort_dir, &$sort_by_sql, &$sort_order_sql, &$total, $forum_id = 0, $topic_id = 0, $where_sql = 'WHERE')
{
    global $db, $user, $auth, $template;
    $sort_days = request_var('st', 0);
    $min_time = $sort_days ? time() - $sort_days * 86400 : 0;
    switch ($mode) {
        case 'viewforum':
            $type = 'topics';
            $default_key = 't';
            $default_dir = 'd';
            $sql = 'SELECT COUNT(topic_id) AS total
				FROM ' . TOPICS_TABLE . "\n\t\t\t\t{$where_sql} forum_id = {$forum_id}\n\t\t\t\t\tAND topic_type NOT IN (" . POST_ANNOUNCE . ', ' . POST_GLOBAL . ")\n\t\t\t\t\tAND topic_last_post_time >= {$min_time}";
            if (!$auth->acl_get('m_approve', $forum_id)) {
                $sql .= 'AND topic_approved = 1';
            }
            break;
        case 'viewtopic':
            $type = 'posts';
            $default_key = 't';
            $default_dir = 'a';
            $sql = 'SELECT COUNT(post_id) AS total
				FROM ' . POSTS_TABLE . "\n\t\t\t\t{$where_sql} topic_id = {$topic_id}\n\t\t\t\t\tAND post_time >= {$min_time}";
            if (!$auth->acl_get('m_approve', $forum_id)) {
                $sql .= 'AND post_approved = 1';
            }
            break;
        case 'unapproved_posts':
            $type = 'posts';
            $default_key = 't';
            $default_dir = 'd';
            $where_sql .= $topic_id ? ' p.topic_id = ' . $topic_id . ' AND' : '';
            $sql = 'SELECT COUNT(p.post_id) AS total
				FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t\n\t\t\t\t{$where_sql} " . $db->sql_in_set('p.forum_id', $forum_id ? array($forum_id) : array_intersect(get_forum_list('f_read'), get_forum_list('m_approve'))) . '
					AND p.post_approved = 0
					AND t.topic_id = p.topic_id
					AND t.topic_first_post_id <> p.post_id';
            if ($min_time) {
                $sql .= ' AND post_time >= ' . $min_time;
            }
            break;
        case 'unapproved_topics':
            $type = 'topics';
            $default_key = 't';
            $default_dir = 'd';
            $sql = 'SELECT COUNT(topic_id) AS total
				FROM ' . TOPICS_TABLE . "\n\t\t\t\t{$where_sql} " . $db->sql_in_set('forum_id', $forum_id ? array($forum_id) : array_intersect(get_forum_list('f_read'), get_forum_list('m_approve'))) . '
					AND topic_approved = 0';
            if ($min_time) {
                $sql .= ' AND topic_time >= ' . $min_time;
            }
            break;
        case 'pm_reports':
        case 'pm_reports_closed':
        case 'reports':
        case 'reports_closed':
            $pm = strpos($mode, 'pm_') === 0 ? true : false;
            $type = $pm ? 'pm_reports' : 'reports';
            $default_key = 't';
            $default_dir = 'd';
            $limit_time_sql = $min_time ? "AND r.report_time >= {$min_time}" : '';
            if ($topic_id) {
                $where_sql .= ' p.topic_id = ' . $topic_id . ' AND ';
            } else {
                if ($forum_id) {
                    $where_sql .= ' p.forum_id = ' . $forum_id . ' AND ';
                } else {
                    if (!$pm) {
                        $where_sql .= ' ' . $db->sql_in_set('p.forum_id', get_forum_list(array('!f_read', '!m_report')), true, true) . ' AND ';
                    }
                }
            }
            if ($mode == 'reports' || $mode == 'pm_reports') {
                $where_sql .= ' r.report_closed = 0 AND ';
            } else {
                $where_sql .= ' r.report_closed = 1 AND ';
            }
            if ($pm) {
                $sql = 'SELECT COUNT(r.report_id) AS total
					FROM ' . REPORTS_TABLE . ' r, ' . PRIVMSGS_TABLE . " p\n\t\t\t\t\t{$where_sql} r.post_id = 0\n\t\t\t\t\t\tAND p.msg_id = r.pm_id\n\t\t\t\t\t\t{$limit_time_sql}";
            } else {
                $sql = 'SELECT COUNT(r.report_id) AS total
				FROM ' . REPORTS_TABLE . ' r, ' . POSTS_TABLE . " p\n\t\t\t\t\t{$where_sql} r.pm_id = 0\n\t\t\t\t\tAND p.post_id = r.post_id\n\t\t\t\t\t{$limit_time_sql}";
            }
            break;
        case 'viewlogs':
            $type = 'logs';
            $default_key = 't';
            $default_dir = 'd';
            $sql = 'SELECT COUNT(log_id) AS total
				FROM ' . LOG_TABLE . "\n\t\t\t\t{$where_sql} " . $db->sql_in_set('forum_id', $forum_id ? array($forum_id) : array_intersect(get_forum_list('f_read'), get_forum_list('m_'))) . '
					AND log_time >= ' . $min_time . '
					AND log_type = ' . LOG_MOD;
            break;
    }
    $sort_key = request_var('sk', $default_key);
    $sort_dir = request_var('sd', $default_dir);
    $sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']);
    switch ($type) {
        case 'topics':
            $limit_days = array(0 => $user->lang['ALL_TOPICS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
            $sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 'tt' => $user->lang['TOPIC_TIME'], 'r' => $user->lang['REPLIES'], 's' => $user->lang['SUBJECT'], 'v' => $user->lang['VIEWS']);
            $sort_by_sql = array('a' => 't.topic_first_poster_name', 't' => 't.topic_last_post_time', 'tt' => 't.topic_time', 'r' => $auth->acl_get('m_approve', $forum_id) ? 't.topic_replies_real' : 't.topic_replies', 's' => 't.topic_title', 'v' => 't.topic_views');
            $limit_time_sql = $min_time ? "AND t.topic_last_post_time >= {$min_time}" : '';
            break;
        case 'posts':
            $limit_days = array(0 => $user->lang['ALL_POSTS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
            $sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']);
            $sort_by_sql = array('a' => 'u.username_clean', 't' => 'p.post_time', 's' => 'p.post_subject');
            $limit_time_sql = $min_time ? "AND p.post_time >= {$min_time}" : '';
            break;
        case 'reports':
            $limit_days = array(0 => $user->lang['ALL_REPORTS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
            $sort_by_text = array('a' => $user->lang['AUTHOR'], 'r' => $user->lang['REPORTER'], 'p' => $user->lang['POST_TIME'], 't' => $user->lang['REPORT_TIME'], 's' => $user->lang['SUBJECT']);
            $sort_by_sql = array('a' => 'u.username_clean', 'r' => 'ru.username', 'p' => 'p.post_time', 't' => 'r.report_time', 's' => 'p.post_subject');
            break;
        case 'pm_reports':
            $limit_days = array(0 => $user->lang['ALL_REPORTS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
            $sort_by_text = array('a' => $user->lang['AUTHOR'], 'r' => $user->lang['REPORTER'], 'p' => $user->lang['POST_TIME'], 't' => $user->lang['REPORT_TIME'], 's' => $user->lang['SUBJECT']);
            $sort_by_sql = array('a' => 'u.username_clean', 'r' => 'ru.username', 'p' => 'p.message_time', 't' => 'r.report_time', 's' => 'p.message_subject');
            break;
        case 'logs':
            $limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
            $sort_by_text = array('u' => $user->lang['SORT_USERNAME'], 't' => $user->lang['SORT_DATE'], 'i' => $user->lang['SORT_IP'], 'o' => $user->lang['SORT_ACTION']);
            $sort_by_sql = array('u' => 'u.username_clean', 't' => 'l.log_time', 'i' => 'l.log_ip', 'o' => 'l.log_operation');
            $limit_time_sql = $min_time ? "AND l.log_time >= {$min_time}" : '';
            break;
    }
    if (!isset($sort_by_sql[$sort_key])) {
        $sort_key = $default_key;
    }
    $sort_order_sql = $sort_by_sql[$sort_key] . ' ' . ($sort_dir == 'd' ? 'DESC' : 'ASC');
    $s_limit_days = $s_sort_key = $s_sort_dir = $sort_url = '';
    gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $sort_url);
    $template->assign_vars(array('S_SELECT_SORT_DIR' => $s_sort_dir, 'S_SELECT_SORT_KEY' => $s_sort_key, 'S_SELECT_SORT_DAYS' => $s_limit_days));
    if ($sort_days && $mode != 'viewlogs' || in_array($mode, array('reports', 'unapproved_topics', 'unapproved_posts')) || $where_sql != 'WHERE') {
        $result = $db->sql_query($sql);
        $total = (int) $db->sql_fetchfield('total');
        $db->sql_freeresult($result);
    } else {
        $total = -1;
    }
}
示例#7
0
    function main($id, $mode)
    {
        global $auth, $db, $user, $template;
        global $config, $phpbb_root_path, $phpEx;
        $user->add_lang('acp/common');
        //-- mod start : Garage ----------------------------------------------------------------------------------------------------
        //-- add
        $user->add_lang('acp/garage');
        //-- mod finish : Garage ---------------------------------------------------------------------------------------------------
        $action = request_var('action', array('' => ''));
        if (is_array($action)) {
            list($action, ) = each($action);
        } else {
            $action = request_var('action', '');
        }
        // Set up general vars
        $start = request_var('start', 0);
        $deletemark = $action == 'del_marked' ? true : false;
        $deleteall = $action == 'del_all' ? true : false;
        $marked = request_var('mark', array(0));
        // Sort keys
        $sort_days = request_var('st', 0);
        $sort_key = request_var('sk', 't');
        $sort_dir = request_var('sd', 'd');
        $this->tpl_name = 'mcp_logs';
        $this->page_title = 'MCP_LOGS';
        $forum_list = array_values(array_intersect(get_forum_list('f_read'), get_forum_list('m_')));
        $forum_list[] = 0;
        $forum_id = $topic_id = 0;
        switch ($mode) {
            case 'front':
                break;
            case 'forum_logs':
                $forum_id = request_var('f', 0);
                if (!in_array($forum_id, $forum_list)) {
                    trigger_error('NOT_AUTHORISED');
                }
                $forum_list = array($forum_id);
                break;
            case 'topic_logs':
                $topic_id = request_var('t', 0);
                $sql = 'SELECT forum_id
					FROM ' . TOPICS_TABLE . '
					WHERE topic_id = ' . $topic_id;
                $result = $db->sql_query($sql);
                $forum_id = (int) $db->sql_fetchfield('forum_id');
                $db->sql_freeresult($result);
                if (!in_array($forum_id, $forum_list)) {
                    trigger_error('NOT_AUTHORISED');
                }
                $forum_list = array($forum_id);
                break;
        }
        // Delete entries if requested and able
        if (($deletemark || $deleteall) && $auth->acl_get('a_clearlogs')) {
            if (confirm_box(true)) {
                if ($deletemark && sizeof($marked)) {
                    $sql = 'DELETE FROM ' . LOG_TABLE . '
						WHERE log_type = ' . LOG_MOD . '
							AND ' . $db->sql_in_set('forum_id', $forum_list) . '
							AND ' . $db->sql_in_set('log_id', $marked);
                    $db->sql_query($sql);
                    add_log('admin', 'LOG_CLEAR_MOD');
                } else {
                    if ($deleteall) {
                        $sql = 'DELETE FROM ' . LOG_TABLE . '
						WHERE log_type = ' . LOG_MOD . '
							AND ' . $db->sql_in_set('forum_id', $forum_list);
                        if ($mode == 'topic_logs') {
                            $sql .= ' AND topic_id = ' . $topic_id;
                        }
                        $db->sql_query($sql);
                        add_log('admin', 'LOG_CLEAR_MOD');
                    }
                }
            } else {
                confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array('f' => $forum_id, 't' => $topic_id, 'start' => $start, 'delmarked' => $deletemark, 'delall' => $deleteall, 'mark' => $marked, 'st' => $sort_days, 'sk' => $sort_key, 'sd' => $sort_dir, 'i' => $id, 'mode' => $mode, 'action' => request_var('action', array('' => '')))));
            }
        }
        // Sorting
        $limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
        $sort_by_text = array('u' => $user->lang['SORT_USERNAME'], 't' => $user->lang['SORT_DATE'], 'i' => $user->lang['SORT_IP'], 'o' => $user->lang['SORT_ACTION']);
        $sort_by_sql = array('u' => 'u.username_clean', 't' => 'l.log_time', 'i' => 'l.log_ip', 'o' => 'l.log_operation');
        $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
        gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
        // Define where and sort sql for use in displaying logs
        $sql_where = $sort_days ? time() - $sort_days * 86400 : 0;
        $sql_sort = $sort_by_sql[$sort_key] . ' ' . ($sort_dir == 'd' ? 'DESC' : 'ASC');
        // Grab log data
        $log_data = array();
        $log_count = 0;
        view_log('mod', $log_data, $log_count, $config['topics_per_page'], $start, $forum_list, $topic_id, 0, $sql_where, $sql_sort);
        $template->assign_vars(array('PAGE_NUMBER' => on_page($log_count, $config['topics_per_page'], $start), 'TOTAL' => $log_count == 1 ? $user->lang['TOTAL_LOG'] : sprintf($user->lang['TOTAL_LOGS'], $log_count), 'PAGINATION' => generate_pagination($this->u_action . "&amp;{$u_sort_param}", $log_count, $config['topics_per_page'], $start), 'L_TITLE' => $user->lang['MCP_LOGS'], 'U_POST_ACTION' => $this->u_action, 'S_CLEAR_ALLOWED' => $auth->acl_get('a_clearlogs') ? true : false, 'S_SELECT_SORT_DIR' => $s_sort_dir, 'S_SELECT_SORT_KEY' => $s_sort_key, 'S_SELECT_SORT_DAYS' => $s_limit_days, 'S_LOGS' => $log_count > 0));
        foreach ($log_data as $row) {
            $data = array();
            $checks = array('viewtopic', 'viewforum');
            foreach ($checks as $check) {
                if (isset($row[$check]) && $row[$check]) {
                    $data[] = '<a href="' . $row[$check] . '">' . $user->lang['LOGVIEW_' . strtoupper($check)] . '</a>';
                }
            }
            $template->assign_block_vars('log', array('USERNAME' => $row['username_full'], 'IP' => $row['ip'], 'DATE' => $user->format_date($row['time']), 'ACTION' => $row['action'], 'DATA' => sizeof($data) ? implode(' | ', $data) : '', 'ID' => $row['id']));
        }
    }
示例#8
0
文件: mcp_queue.php 项目: html/PI
    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_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, 'queue', $mode);
                } else {
                    disapprove_post($post_id_list, 'queue', $mode);
                }
                break;
        }
        switch ($mode) {
            case 'approve_details':
                $this->tpl_name = 'mcp_post';
                $user->add_lang(array('posting', 'viewtopic'));
                $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', true);
                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']));
                }
                $extensions = $attachments = $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));
                        }
                    }
                }
                $post_url = append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $post_info['forum_id'] . '&amp;p=' . $post_info['post_id'] . '#p' . $post_info['post_id']);
                $topic_url = append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $post_info['forum_id'] . '&amp;t=' . $post_info['topic_id']);
                $template->assign_vars(array('S_MCP_QUEUE' => true, 'U_APPROVE_ACTION' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i=queue&amp;p={$post_id}&amp;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&amp;f={$post_info['forum_id']}&amp;p={$post_info['post_id']}") : '', 'U_MCP_APPROVE' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue&amp;mode=approve_details&amp;f=' . $post_info['forum_id'] . '&amp;p=' . $post_id), 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=reports&amp;mode=report_details&amp;f=' . $post_info['forum_id'] . '&amp;p=' . $post_id), 'U_MCP_USER_NOTES' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=notes&amp;mode=user_notes&amp;u=' . $post_info['user_id']), 'U_MCP_WARN_USER' => $auth->acl_get('m_warn') ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=warn&amp;mode=warn_user&amp;u=' . $post_info['user_id']) : '', 'U_VIEW_POST' => $post_url, 'U_VIEW_TOPIC' => $topic_url, 'MINI_POST_IMG' => $post_unread ? $user->img('icon_post_target_unread', 'NEW_POST') : $user->img('icon_post_target', 'POST'), 'RETURN_QUEUE' => sprintf($user->lang['RETURN_QUEUE'], '<a href="' . append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue' . ($topic_id ? '&amp;mode=unapproved_topics' : '&amp;mode=unapproved_posts')) . "&amp;start={$start}\">", '</a>'), 'RETURN_POST' => sprintf($user->lang['RETURN_POST'], '<a href="' . $post_url . '">', '</a>'), 'RETURN_TOPIC_SIMPLE' => sprintf($user->lang['RETURN_TOPIC_SIMPLE'], '<a href="' . $topic_url . '">', '</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']), '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']) ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue&amp;mode=approve_details&amp;f=' . $post_info['forum_id'] . '&amp;p=' . $post_id . '&amp;lookup=' . $post_info['poster_ip']) . '#ip' : ''));
                break;
            case 'unapproved_topics':
            case 'unapproved_posts':
                $user->add_lang(array('viewtopic', 'viewforum'));
                $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('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);
                $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_approve as $k => $forum_data) {
                    if (!isset($forum_list_read[$forum_data['forum_id']])) {
                        unset($forum_list_approve[$k]);
                    }
                }
                unset($forum_list_read);
                if (!$forum_id) {
                    $forum_list = array();
                    foreach ($forum_list_approve as $row) {
                        $forum_list[] = $row['forum_id'];
                    }
                    if (!sizeof($forum_list)) {
                        trigger_error('NOT_MODERATOR');
                    }
                    $global_id = $forum_list[0];
                    $forum_list = implode(', ', $forum_list);
                    $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);
                } 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"' : '') . '>' . str_repeat('&nbsp; &nbsp;', $row['padding']) . $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_subject, p.post_username, p.poster_id, p.post_time, u.username, u.username_clean, u.user_colour
							FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . ' u
							WHERE ' . $db->sql_in_set('p.post_id', $post_ids) . '
								AND t.topic_id = p.topic_id
								AND u.user_id = p.poster_id
							ORDER BY ' . $sort_order_sql;
                        $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_title AS post_subject, 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, t.topic_first_poster_colour AS user_colour
						FROM ' . TOPICS_TABLE . " t\n\t\t\t\t\t\tWHERE forum_id IN (0, {$forum_list})\n\t\t\t\t\t\t\tAND topic_approved = 0\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 ' . $db->sql_in_set('forum_id', $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) {
                    $global_topic = $row['forum_id'] ? false : true;
                    if ($global_topic) {
                        $row['forum_id'] = $global_id;
                    }
                    if (empty($row['post_username'])) {
                        $row['post_username'] = $user->lang['GUEST'];
                    }
                    $template->assign_block_vars('postrow', array('U_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $row['forum_id'] . '&amp;t=' . $row['topic_id']), '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'] . '&amp;p=' . $row['post_id']) . ($mode == 'unapproved_posts' ? '#p' . $row['post_id'] : ''), 'U_VIEW_DETAILS' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i=queue&amp;start={$start}&amp;mode=approve_details&amp;f={$row['forum_id']}&amp;p={$row['post_id']}" . ($mode == 'unapproved_topics' ? "&amp;t={$row['topic_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']), 'POST_ID' => $row['post_id'], 'FORUM_NAME' => !$global_topic ? $forum_names[$row['forum_id']] : $user->lang['GLOBAL_ANNOUNCEMENT'], 'POST_SUBJECT' => $row['post_subject'], 'TOPIC_TITLE' => $row['topic_title'], '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')), 'S_TOPICS' => $mode == 'unapproved_posts' ? false : true, 'PAGINATION' => generate_pagination($this->u_action . "&amp;f={$forum_id}&amp;st={$sort_days}&amp;sk={$sort_key}&amp;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 == 1 ? $mode == 'unapproved_posts' ? $user->lang['VIEW_TOPIC_POST'] : $user->lang['VIEW_FORUM_TOPIC'] : sprintf($mode == 'unapproved_posts' ? $user->lang['VIEW_TOPIC_POSTS'] : $user->lang['VIEW_FORUM_TOPICS'], $total)));
                $this->tpl_name = 'mcp_queue';
                break;
        }
    }
示例#9
0
/**
* sorting in mcp
*
* @param string $where_sql should either be WHERE (default if ommited) or end with AND or OR
*
* $mode reports and reports_closed: the $where parameters uses aliases p for posts table and r for report table
* $mode unapproved_posts: the $where parameters uses aliases p for posts table and t for topic table
*/
function phpbb_mcp_sorting($mode, &$sort_days, &$sort_key, &$sort_dir, &$sort_by_sql, &$sort_order_sql, &$total, $forum_id = 0, $topic_id = 0, $where_sql = 'WHERE')
{
    global $db, $user, $auth, $template, $phpbb_dispatcher;
    $sort_days = request_var('st', 0);
    $min_time = $sort_days ? time() - $sort_days * 86400 : 0;
    switch ($mode) {
        case 'viewforum':
            $type = 'topics';
            $default_key = 't';
            $default_dir = 'd';
            $sql = 'SELECT COUNT(topic_id) AS total
				FROM ' . TOPICS_TABLE . "\n\t\t\t\t{$where_sql} forum_id = {$forum_id}\n\t\t\t\t\tAND topic_type NOT IN (" . POST_ANNOUNCE . ', ' . POST_GLOBAL . ")\n\t\t\t\t\tAND topic_last_post_time >= {$min_time}";
            if (!$auth->acl_get('m_approve', $forum_id)) {
                $sql .= 'AND topic_visibility = ' . ITEM_APPROVED;
            }
            break;
        case 'viewtopic':
            $type = 'posts';
            $default_key = 't';
            $default_dir = 'a';
            $sql = 'SELECT COUNT(post_id) AS total
				FROM ' . POSTS_TABLE . "\n\t\t\t\t{$where_sql} topic_id = {$topic_id}\n\t\t\t\t\tAND post_time >= {$min_time}";
            if (!$auth->acl_get('m_approve', $forum_id)) {
                $sql .= 'AND post_visibility = ' . ITEM_APPROVED;
            }
            break;
        case 'unapproved_posts':
        case 'deleted_posts':
            $visibility_const = $mode == 'unapproved_posts' ? array(ITEM_UNAPPROVED, ITEM_REAPPROVE) : ITEM_DELETED;
            $type = 'posts';
            $default_key = 't';
            $default_dir = 'd';
            $where_sql .= $topic_id ? ' p.topic_id = ' . $topic_id . ' AND' : '';
            $sql = 'SELECT COUNT(p.post_id) AS total
				FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t\n\t\t\t\t{$where_sql} " . $db->sql_in_set('p.forum_id', $forum_id ? array($forum_id) : array_intersect(get_forum_list('f_read'), get_forum_list('m_approve'))) . '
					AND ' . $db->sql_in_set('p.post_visibility', $visibility_const) . '
					AND t.topic_id = p.topic_id
					AND t.topic_visibility <> p.post_visibility';
            if ($min_time) {
                $sql .= ' AND post_time >= ' . $min_time;
            }
            break;
        case 'unapproved_topics':
        case 'deleted_topics':
            $visibility_const = $mode == 'unapproved_topics' ? array(ITEM_UNAPPROVED, ITEM_REAPPROVE) : ITEM_DELETED;
            $type = 'topics';
            $default_key = 't';
            $default_dir = 'd';
            $sql = 'SELECT COUNT(topic_id) AS total
				FROM ' . TOPICS_TABLE . "\n\t\t\t\t{$where_sql} " . $db->sql_in_set('forum_id', $forum_id ? array($forum_id) : array_intersect(get_forum_list('f_read'), get_forum_list('m_approve'))) . '
					AND ' . $db->sql_in_set('topic_visibility', $visibility_const);
            if ($min_time) {
                $sql .= ' AND topic_time >= ' . $min_time;
            }
            break;
        case 'pm_reports':
        case 'pm_reports_closed':
        case 'reports':
        case 'reports_closed':
            $pm = strpos($mode, 'pm_') === 0 ? true : false;
            $type = $pm ? 'pm_reports' : 'reports';
            $default_key = 't';
            $default_dir = 'd';
            $limit_time_sql = $min_time ? "AND r.report_time >= {$min_time}" : '';
            if ($topic_id) {
                $where_sql .= ' p.topic_id = ' . $topic_id . ' AND ';
            } else {
                if ($forum_id) {
                    $where_sql .= ' p.forum_id = ' . $forum_id . ' AND ';
                } else {
                    if (!$pm) {
                        $where_sql .= ' ' . $db->sql_in_set('p.forum_id', get_forum_list(array('!f_read', '!m_report')), true, true) . ' AND ';
                    }
                }
            }
            if ($mode == 'reports' || $mode == 'pm_reports') {
                $where_sql .= ' r.report_closed = 0 AND ';
            } else {
                $where_sql .= ' r.report_closed = 1 AND ';
            }
            if ($pm) {
                $sql = 'SELECT COUNT(r.report_id) AS total
					FROM ' . REPORTS_TABLE . ' r, ' . PRIVMSGS_TABLE . " p\n\t\t\t\t\t{$where_sql} r.post_id = 0\n\t\t\t\t\t\tAND p.msg_id = r.pm_id\n\t\t\t\t\t\t{$limit_time_sql}";
            } else {
                $sql = 'SELECT COUNT(r.report_id) AS total
					FROM ' . REPORTS_TABLE . ' r, ' . POSTS_TABLE . " p\n\t\t\t\t\t{$where_sql} r.pm_id = 0\n\t\t\t\t\t\tAND p.post_id = r.post_id\n\t\t\t\t\t\t{$limit_time_sql}";
            }
            break;
        case 'viewlogs':
            $type = 'logs';
            $default_key = 't';
            $default_dir = 'd';
            $sql = 'SELECT COUNT(log_id) AS total
				FROM ' . LOG_TABLE . "\n\t\t\t\t{$where_sql} " . $db->sql_in_set('forum_id', $forum_id ? array($forum_id) : array_intersect(get_forum_list('f_read'), get_forum_list('m_'))) . '
					AND log_time >= ' . $min_time . '
					AND log_type = ' . LOG_MOD;
            break;
    }
    $sort_key = request_var('sk', $default_key);
    $sort_dir = request_var('sd', $default_dir);
    $sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']);
    switch ($type) {
        case 'topics':
            $limit_days = array(0 => $user->lang['ALL_TOPICS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
            $sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 'tt' => $user->lang['TOPIC_TIME'], 'r' => $user->lang['REPLIES'], 's' => $user->lang['SUBJECT'], 'v' => $user->lang['VIEWS']);
            $sort_by_sql = array('a' => 't.topic_first_poster_name', 't' => array('t.topic_last_post_time', 't.topic_last_post_id'), 'tt' => 't.topic_time', 'r' => $auth->acl_get('m_approve', $forum_id) ? 't.topic_posts_approved + t.topic_posts_unapproved + t.topic_posts_softdeleted' : 't.topic_posts_approved', 's' => 't.topic_title', 'v' => 't.topic_views');
            $limit_time_sql = $min_time ? "AND t.topic_last_post_time >= {$min_time}" : '';
            break;
        case 'posts':
            $limit_days = array(0 => $user->lang['ALL_POSTS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
            $sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']);
            $sort_by_sql = array('a' => 'u.username_clean', 't' => array('p.post_time', 'p.post_id'), 's' => 'p.post_subject');
            $limit_time_sql = $min_time ? "AND p.post_time >= {$min_time}" : '';
            break;
        case 'reports':
            $limit_days = array(0 => $user->lang['ALL_REPORTS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
            $sort_by_text = array('a' => $user->lang['AUTHOR'], 'r' => $user->lang['REPORTER'], 'p' => $user->lang['POST_TIME'], 't' => $user->lang['REPORT_TIME'], 's' => $user->lang['SUBJECT']);
            $sort_by_sql = array('a' => 'u.username_clean', 'r' => 'ru.username', 'p' => array('p.post_time', 'p.post_id'), 't' => 'r.report_time', 's' => 'p.post_subject');
            break;
        case 'pm_reports':
            $limit_days = array(0 => $user->lang['ALL_REPORTS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
            $sort_by_text = array('a' => $user->lang['AUTHOR'], 'r' => $user->lang['REPORTER'], 'p' => $user->lang['POST_TIME'], 't' => $user->lang['REPORT_TIME'], 's' => $user->lang['SUBJECT']);
            $sort_by_sql = array('a' => 'u.username_clean', 'r' => 'ru.username', 'p' => 'p.message_time', 't' => 'r.report_time', 's' => 'p.message_subject');
            break;
        case 'logs':
            $limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
            $sort_by_text = array('u' => $user->lang['SORT_USERNAME'], 't' => $user->lang['SORT_DATE'], 'i' => $user->lang['SORT_IP'], 'o' => $user->lang['SORT_ACTION']);
            $sort_by_sql = array('u' => 'u.username_clean', 't' => 'l.log_time', 'i' => 'l.log_ip', 'o' => 'l.log_operation');
            $limit_time_sql = $min_time ? "AND l.log_time >= {$min_time}" : '';
            break;
    }
    // Default total to -1 to allow editing by the event
    $total = -1;
    /**
     * This event allows you to control the SQL query used to get the total number
     * of reports the user can access.
     *
     * This total is used for the pagination and for displaying the total number
     * of reports to the user
     *
     *
     * @event core.mcp_sorting_query_before
     * @var	string	sql					The current SQL search string
     * @var	string	mode				An id related to the module(s) the user is viewing
     * @var	string	type				Which kind of information is this being used for displaying. Posts, topics, etc...
     * @var	int		forum_id			The forum id of the posts the user is trying to access, if not 0
     * @var	int		topic_id			The topic id of the posts the user is trying to access, if not 0
     * @var	int		sort_days			The max age of the oldest report to be shown, in days
     * @var	string	sort_key			The way the user has decided to sort the data.
     *									The valid values must be in the keys of the sort_by_* variables
     * @var	string	sort_dir			Either 'd' for "DESC" or 'a' for 'ASC' in the SQL query
     * @var	int		limit_days			The possible max ages of the oldest report for the user to choose, in days.
     * @var	array	sort_by_sql			SQL text (values) for the possible names of the ways of sorting data (keys).
     * @var	array	sort_by_text		Language text (values) for the possible names of the ways of sorting data (keys).
     * @var	int		min_time			Integer with the minimum post time that the user is searching for
     * @var	int		limit_time_sql		Time limiting options used in the SQL query.
     * @var	int		total				The total number of reports that exist. Only set if you want to override the result
     * @var	string	where_sql			Extra information included in the WHERE clause. It must end with "WHERE" or "AND" or "OR".
     *									Set to "WHERE" and set total above -1 to override the total value
     * @since 3.1.4-RC1
     */
    $vars = array('sql', 'mode', 'type', 'forum_id', 'topic_id', 'sort_days', 'sort_key', 'sort_dir', 'limit_days', 'sort_by_sql', 'sort_by_text', 'min_time', 'limit_time_sql', 'total', 'where_sql');
    extract($phpbb_dispatcher->trigger_event('core.mcp_sorting_query_before', compact($vars)));
    if (!isset($sort_by_sql[$sort_key])) {
        $sort_key = $default_key;
    }
    $direction = $sort_dir == 'd' ? 'DESC' : 'ASC';
    if (is_array($sort_by_sql[$sort_key])) {
        $sort_order_sql = implode(' ' . $direction . ', ', $sort_by_sql[$sort_key]) . ' ' . $direction;
    } else {
        $sort_order_sql = $sort_by_sql[$sort_key] . ' ' . $direction;
    }
    $s_limit_days = $s_sort_key = $s_sort_dir = $sort_url = '';
    gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $sort_url);
    $template->assign_vars(array('S_SELECT_SORT_DIR' => $s_sort_dir, 'S_SELECT_SORT_KEY' => $s_sort_key, 'S_SELECT_SORT_DAYS' => $s_limit_days));
    if ($sort_days && $mode != 'viewlogs' || in_array($mode, array('reports', 'unapproved_topics', 'unapproved_posts', 'deleted_topics', 'deleted_posts')) || $where_sql != 'WHERE') {
        $result = $db->sql_query($sql);
        $total = (int) $db->sql_fetchfield('total');
        $db->sql_freeresult($result);
    } else {
        if ($total < -1) {
            $total = -1;
        }
    }
}
 /**
  * Returns a single resquested topic.
  * @param array $args must contain 'resID' key with the resource identifier of the requested resource
  * @throws InvalidArgumentException if one of the paramaters is missing
  * @webservice{/module/MOBILE/CLANN/getSingleResource/cidReq/resId}
  * @ws_arg{Method,getSingleResource}
  * @ws_arg{cidReq,SYSCODE of requested cours}
  * @ws_arg{resID,Resource Id of requested resource}
  * @return announce object (can be null if not visible for the current user)
  */
 function getSingleResource($args)
 {
     $resourceId = isset($args['resID']) ? $args['resID'] : null;
     $cid = claro_get_current_course_id();
     if ($cid == null || $resourceId == null) {
         throw new InvalidArgumentException('Missing cid or resourceId argument!');
     }
     FromKernel::uses('forum.lib');
     $claroNotification = Claroline::getInstance()->notification;
     $date = $claroNotification->getLastActionBeforeLoginDate(claro_get_current_user_id());
     $d = new DateTime($date);
     $d->sub(new DateInterval('PT1M'));
     $item = null;
     foreach (get_forum_list() as $forum) {
         if ($forum['forum_id'] == $resourceID) {
             $item = $forum;
             break;
         }
     }
     if ($item) {
         $item['resourceId'] = $item['forum_id'];
         $item['title'] = $item['forum_name'];
         foreach (get_category_list as $cat) {
             if ($cat['cat_id'] == $item['cat_id']) {
                 $item['cat_title'] = $cat['cat_title'];
                 $item['cat_order'] = $cat['cat_order'];
                 break;
             }
         }
         $item['topics'] = array();
         $topics = new topicLister($item['forum_id'], 0, $item['forum_topics']);
         foreach ($topics->get_topic_list() as $topic) {
             $topic['resourceId'] = $topic['topic_id'];
             $topic['title'] = $topic['topic_title'];
             $topic['poster_firstname'] = $topic['prenom'];
             $topic['poster_lastname'] = $topic['nom'];
             $topic['date'] = $topic['topic_time'];
             $topic['posts'] = array();
             $posts = new postLister($topic['topic_id'], 0, $topic['topic_replies'] + 1);
             foreach ($posts->get_post_list() as $post) {
                 $notified = $claroNotification->isANotifiedRessource($cid, $date, claro_get_current_user_id(), claro_get_current_group_id(), get_tool_id_from_module_label('CLFRM'), $item['forum_id'] . '-' . $topic['topic_id'] . '-' . $post['post_id'], false);
                 $post['notifiedDate'] = $notified ? $date : $post['post_time'];
                 $post['seenDate'] = $d->format('Y-m-d H:i');
                 $post['post_text'] = trim(strip_tags($post['post_text']));
                 $post['resourceId'] = $post['post_id'];
                 $post['date'] = $post['post_time'];
                 unset($post['post_id']);
                 unset($post['topic_id']);
                 unset($post['forum_id']);
                 unset($post['poster_id']);
                 unset($post['post_time']);
                 unset($post['poster_ip']);
                 $topic['posts'][] = $post;
             }
             unset($topic['topic_id']);
             unset($topic['topic_title']);
             unset($topic['topic_poster']);
             unset($topic['topic_time']);
             unset($topic['topic_replies']);
             unset($topic['topic_last_post_id']);
             unset($topic['forum_id']);
             unset($topic['topic_notify']);
             unset($topic['nom']);
             unset($topic['prenom']);
             unset($topic['post_time']);
             $item['topics'][] = $topic;
         }
         unset($item['forum_id']);
         unset($item['forum_name']);
         unset($item['forum_moderator']);
         unset($item['forum_topics']);
         unset($item['forum_posts']);
         unset($item['forum_last_post_id']);
         unset($item['forum_type']);
         unset($item['group_id']);
         unset($item['poster_id']);
         unset($item['post_time']);
         return $item;
     } else {
         throw new RuntimeException('Resource not found', 404);
     }
 }
示例#11
0
define('SECTION_PLUGINNAME', 'forum');
define('SECTION_PAGE', 'index');
require dirname(dirname(dirname(__FILE__))) . '/init.php';
require_once 'group.php';
safe_require('interaction', 'forum');
require_once 'pieforms/pieform.php';
require_once get_config('docroot') . 'interaction/lib.php';
$groupid = param_integer('group');
define('GROUP', $groupid);
$group = group_current_group();
$membership = group_user_access($groupid);
if (!$membership && !$group->public) {
    throw new GroupAccessDeniedException(get_string('cantviewforums', 'interaction.forum'));
}
define('TITLE', $group->name . ' - ' . get_string('nameplural', 'interaction.forum'));
$forums = get_forum_list($group->id, $USER->get('id'));
if ($forums) {
    // query gets a new forum object for every moderator of that forum
    // this combines all moderators together into one object per forum
    $count = count($forums);
    for ($i = 0; $i < $count; $i++) {
        $forums[$i]->moderators = array();
        if ($forums[$i]->moderator) {
            $forums[$i]->moderators[] = $forums[$i]->moderator;
        }
        $temp = $i;
        while (isset($forums[$i + 1]) && $forums[$i + 1]->id == $forums[$temp]->id) {
            $i++;
            $forums[$temp]->moderators[] = $forums[$i]->moderator;
            unset($forums[$i]);
        }
示例#12
0
    echo "                  </td>\n";
    echo "                </tr>\n";
    echo "                <tr>\n";
    echo "                  <td align=\"left\">&nbsp;</td>\n";
    echo "                </tr>\n";
    echo "              </table>\n";
    echo "            </td>\n";
    echo "          </tr>\n";
    echo "        </table>\n";
    echo "      </td>\n";
    echo "    </tr>\n";
    echo "  </table>\n";
    echo "</form>\n";
    echo "</div>\n";
} else {
    $forums_array = get_forum_list($page);
    echo "<h1>", gettext("My Forums"), "</h1>\n";
    if (isset($forums_array['forums_array']) && sizeof($forums_array['forums_array']) < 1) {
        html_display_warning_msg(gettext("There are no forums of the selected type available. Please select a different type."), '70%', 'center');
    }
    echo "<br />\n";
    echo "<div align=\"center\">\n";
    echo "<form accept-charset=\"utf-8\" name=\"prefs\" action=\"forums.php\" method=\"post\" target=\"_self\">\n";
    echo "  ", form_input_hidden("webtag", htmlentities_array($webtag)), "\n";
    echo "  ", form_input_hidden("page", htmlentities_array($page)), "\n";
    echo "  ", form_input_hidden("webtag_search", htmlentities_array($webtag_search)), "\n";
    echo "  <table cellpadding=\"0\" cellspacing=\"0\" width=\"70%\">\n";
    echo "    <tr>\n";
    echo "      <td align=\"left\">\n";
    echo "        <table class=\"box\" width=\"100%\">\n";
    echo "          <tr>\n";
示例#13
0
        $_CLASS['core_template']->assign_array(array('S_MCP_QUEUE' => true, 'S_APPROVE_ACTION' => generate_link("forums&amp;file=mcp&amp;i=queue&amp;p={$post_id}&amp;f={$forum_id}"), 'S_CAN_VIEWIP' => $_CLASS['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'], 'U_EDIT' => $_CLASS['auth']->acl_get('m_edit', $post_info['forum_id']) ? generate_link("forums&amp;file=posting&amp;mode=edit&amp;f={$post_info['forum_id']}&amp;p={$post_info['post_id']}") : '', 'U_MCP_APPROVE' => generate_link('forums&amp;file=mcp&amp;i=queue&amp;mode=approve_details&amp;f=' . $post_info['forum_id'] . '&amp;p=' . $post_id), 'U_MCP_REPORT' => generate_link('forums&amp;file=mcp&amp;i=reports&amp;mode=report_details&amp;f=' . $post_info['forum_id'] . '&amp;p=' . $post_id), 'U_MCP_USER_NOTES' => generate_link('forums&amp;file=mcp&amp;i=notes&amp;mode=user_notes&amp;u=' . $post_info['user_id']), 'U_MCP_WARN_USER' => $_CLASS['auth']->acl_get('m_warn') ? generate_link('forums&amp;file=mcp&amp;i=warn&amp;mode=warn_user&amp;u=' . $post_info['user_id']) : '', 'U_VIEW_POST' => generate_link('forums&amp;file=viewtopic&amp;p=' . $post_info['post_id'] . '#p' . $post_info['post_id']), 'U_VIEW_PROFILE' => generate_link('members_list&amp;mode=viewprofile&amp;u=' . $post_info['user_id']), 'U_VIEW_TOPIC' => generate_link('forums&amp;file=viewtopic&amp;t=' . $post_info['topic_id']), 'RETURN_QUEUE' => sprintf($_CLASS['core_user']->get_lang('RETURN_QUEUE'), '<a href="' . generate_link('forums&amp;file=mcp&amp;i=queue' . ($topic_id ? '&amp;mode=unapproved_topics' : '&amp;mode=unapproved_posts')) . "&amp;start={$start}\">", '</a>'), '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' => $post_info['post_text'], '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']));
        $_CLASS['core_display']->display($_CLASS['core_user']->get_lang('MCP_QUEUE'), 'modules/forums/mcp_post.html');
        break;
    case 'unapproved_topics':
    case 'unapproved_posts':
        $forum_info = array();
        $topic_id = get_variable('t', 'REQUEST', false, 'int');
        if ($topic_id) {
            $topic_info = get_topic_data(array($topic_id));
            if (empty($topic_info[$topic_id])) {
                trigger_error('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_FORUMS_TABLE . "\n\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 {
/**
 * This hook displays moderator messages to moderators
 *
 * @param hook_moderator_needed $hook
 * @return void
 */
function hook_moderator_needed(&$hook)
{
    global $auth, $cache, $db, $template, $user, $phpEx, $phpbb_root_path;
    if ($auth->acl_getf_global('m_')) {
        $allow = false;
        // needed language
        $user->add_lang('mods/moderator_needed');
        if ($auth->acl_getf_global('m_approve') || $auth->acl_getf_global('m_report')) {
            if (!function_exists('get_forum_list')) {
                include $phpbb_root_path . 'includes/functions_admin.' . $phpEx;
            }
            // we need global announcements which don't have any forum id assigned to them
            $global_forum = array(0);
            // we first need to know what the user is authed for
            // user with auth approve and auth report
            if ($auth->acl_getf_global('m_approve') && $auth->acl_getf_global('m_report')) {
                $forum_list = array_unique(array_merge(get_forum_list('m_approve'), get_forum_list('m_report'), $global_forum));
                // we wants it all and we wants it now..if we're authed
                $sql_where = ' WHERE ' . $db->sql_in_set('forum_id', $forum_list) . ' AND (post_reported = 1 or post_approved = 0)';
                $allow = true;
            } elseif ($auth->acl_getf_global('m_approve')) {
                $forum_list = array_unique(array_merge(get_forum_list('m_approve'), $global_forum));
                // just posts waiting for approval please
                $sql_where = ' WHERE ' . $db->sql_in_set('forum_id', $forum_list) . ' AND post_approved = 0';
                $allow = true;
            } elseif ($auth->acl_getf_global('m_report')) {
                $forum_list = array_unique(array_merge(get_forum_list('m_report'), $global_forum));
                // just posts that have been reported thanks
                $sql_where = ' WHERE ' . $db->sql_in_set('forum_id', $forum_list) . ' AND post_reported = 1';
                $allow = true;
            }
            if ($allow) {
                // initialize some variables
                $reported_posts_count = $unapproved_posts_count = $unapproved_topics_count = 0;
                // first build an array of topics waiting to be approved
                // but a user still has to have the correct auths
                if ($auth->acl_getf_global('m_approve')) {
                    $sql = 'SELECT topic_first_post_id
								FROM ' . TOPICS_TABLE . '
							WHERE ' . $db->sql_in_set('forum_id', get_forum_list('m_approve')) . ' AND topic_approved = 0';
                    $result = $db->sql_query($sql);
                    $unapproved_topics_array = array();
                    while ($row = $db->sql_fetchrow($result)) {
                        $unapproved_topics_array[] = (int) $row['topic_first_post_id'];
                        // count up the unapproved topics
                        $unapproved_topics_count++;
                    }
                    $db->sql_freeresult($result);
                    // we're going to change the sql parameters so as not to include these topics
                    if (sizeof($unapproved_topics_array)) {
                        $sql_where .= ' AND ' . $db->sql_in_set('post_id', $unapproved_topics_array, true);
                    }
                }
                // now all others
                $sql = 'SELECT post_reported, post_approved
							FROM ' . POSTS_TABLE . $sql_where;
                $result = $db->sql_query($sql);
                while ($row = $db->sql_fetchrow($result)) {
                    // count the reported posts
                    if ($row['post_reported']) {
                        $reported_posts_count++;
                    }
                    // count the unapproved posts
                    if (!$row['post_approved']) {
                        $unapproved_posts_count++;
                    }
                }
                $db->sql_freeresult($result);
                // we gots us some data
                if ($reported_posts_count || $unapproved_posts_count || $unapproved_topics_count) {
                    // reported posts
                    $l_reported_posts_count = $reported_posts_count ? $reported_posts_count == 1 ? $user->lang['MODERATOR_NEEDED_REPORTED_POST'] : $user->lang['MODERATOR_NEEDED_REPORTED_POSTS'] : '';
                    $total_reported_posts = sprintf($l_reported_posts_count, $reported_posts_count);
                    // unapproved topics
                    $l_unapproved_topics_count = $unapproved_topics_count ? $unapproved_topics_count == 1 ? $user->lang['MODERATOR_NEEDED_APPROVE_TOPIC'] : $user->lang['MODERATOR_NEEDED_APPROVE_TOPICS'] : '';
                    $total_unapproved_topics = sprintf($l_unapproved_topics_count, $unapproved_topics_count);
                    // unapproved posts
                    $l_unapproved_posts_count = $unapproved_posts_count ? $unapproved_posts_count == 1 ? $user->lang['MODERATOR_NEEDED_APPROVE_POST'] : $user->lang['MODERATOR_NEEDED_APPROVE_POSTS'] : '';
                    $total_unapproved_posts = sprintf($l_unapproved_posts_count, $unapproved_posts_count);
                    // what good is the data if we can't see it?
                    // Dump the data to the template engine
                    $template->assign_vars(array('TOTAL_MODERATOR_REPORTS' => $total_reported_posts, 'TOTAL_MODERATOR_POSTS' => $total_unapproved_posts, 'TOTAL_MODERATOR_TOPICS' => $total_unapproved_topics, 'U_MODERATOR_REPORTS' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=reports&amp;mode=reports', true, $user->session_id), 'U_MODERATOR_APPROVE_POSTS' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue&amp;mode=unapproved_posts', true, $user->session_id), 'U_MODERATOR_APPROVE_TOPICS' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue&amp;mode=unapproved_topics', true, $user->session_id)));
                }
            }
        }
        $reported_pms = 0;
        // cache for five minutes
        if (($reported_pms = $cache->get('_reported_pms')) === false) {
            $sql = 'SELECT COUNT(msg_id) AS pms_count 
				FROM ' . PRIVMSGS_TABLE . '
				WHERE message_reported = 1';
            $result = $db->sql_query($sql);
            $reported_pms = (int) $db->sql_fetchfield('pms_count');
            $db->sql_freeresult($result);
            // cache this data for 5 minutes, this improves performance
            $cache->put('_reported_pms', $reported_pms, 300);
        }
        if ($reported_pms) {
            // reported pms
            $l_reported_pms_count = $reported_pms ? $reported_pms == 1 ? $user->lang['MODERATOR_NEEDED_REPORTED_PM'] : $user->lang['MODERATOR_NEEDED_REPORTED_PMS'] : '';
            $total_reported_pms = sprintf($l_reported_pms_count, $reported_pms);
            $template->assign_vars(array('TOTAL_MODERATOR_PMS' => $total_reported_pms, 'U_MODERATOR_PMS' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=pm_reports&amp;mode=pm_reports', true, $user->session_id)));
        }
    } else {
        return;
    }
}
示例#15
0
function mcp_sorting($mode, &$sort_days, &$sort_key, &$sort_dir, &$sort_by_sql, &$sort_order_sql, &$total, $forum_id = 0, $topic_id = 0, $where_sql = 'WHERE')
{
    global $_CLASS;
    $sort_days = request_var('sort_days', 0);
    $min_time = $sort_days ? $_CLASS['core_user']->time - $sort_days * 86400 : 0;
    switch ($mode) {
        case 'viewforum':
            $type = 'topics';
            $default_key = 't';
            $default_dir = 'd';
            $sql = 'SELECT COUNT(topic_id) AS total
				FROM ' . FORUMS_TOPICS_TABLE . "\n\t\t\t\t{$where_sql} forum_id = {$forum_id}\n\t\t\t\t\tAND topic_type NOT IN (" . POST_ANNOUNCE . ', ' . POST_GLOBAL . ")\n\t\t\t\t\tAND topic_last_post_time >= {$min_time}";
            if (!$_CLASS['auth']->acl_get('m_approve', $forum_id)) {
                $sql .= 'AND topic_approved = 1';
            }
            break;
        case 'viewtopic':
            $type = 'posts';
            $default_key = 't';
            $default_dir = 'a';
            $sql = 'SELECT COUNT(post_id) AS total
				FROM ' . FORUMS_POSTS_TABLE . "\n\t\t\t\t{$where_sql} topic_id = {$topic_id}\n\t\t\t\t\tAND post_time >= {$min_time}";
            if (!$_CLASS['auth']->acl_get('m_approve', $forum_id)) {
                $sql .= 'AND post_approved = 1';
            }
            break;
        case 'unapproved_posts':
            $type = 'posts';
            $default_key = 't';
            $default_dir = 'd';
            $sql = 'SELECT COUNT(post_id) AS total
				FROM ' . FORUMS_POSTS_TABLE . "\n\t\t\t\t{$where_sql} forum_id IN (" . ($forum_id ? $forum_id : implode(', ', get_forum_list('m_approve'))) . ')
					AND post_approved = 0
					AND post_time >= ' . $min_time;
            break;
        case 'unapproved_topics':
            $type = 'topics';
            $default_key = 't';
            $default_dir = 'd';
            $sql = 'SELECT COUNT(topic_id) AS total
				FROM ' . FORUMS_TOPICS_TABLE . "\n\t\t\t\t{$where_sql} forum_id IN (" . ($forum_id ? $forum_id : implode(', ', get_forum_list('m_approve'))) . ')
					AND topic_approved = 0
					AND topic_time >= ' . $min_time;
            break;
        case 'reports':
            $type = 'reports';
            $default_key = 'p';
            $default_dir = 'd';
            $limit_time_sql = $min_time ? "AND r.report_time >= {$min_time}" : '';
            if ($topic_id) {
                $where_sql .= ' p.topic_id = ' . $topic_id;
            } else {
                if ($forum_id) {
                    $where_sql .= ' p.forum_id = ' . $forum_id;
                } else {
                    $where_sql .= ' p.forum_id IN (' . implode(', ', get_forum_list('m_')) . ')';
                }
            }
            $sql = 'SELECT COUNT(r.report_id) AS total
				FROM ' . FORUMS_REPORTS_TABLE . ' r, ' . FORUMS_POSTS_TABLE . " p\n\t\t\t\t{$where_sql}\n\t\t\t\t\tAND p.post_id = r.post_id\n\t\t\t\t\t{$limit_time_sql}";
            break;
        case 'viewlogs':
            $type = 'logs';
            $default_key = 't';
            $default_dir = 'd';
            $sql = 'SELECT COUNT(log_id) AS total
				FROM ' . FORUMS_LOG_TABLE . "\n\t\t\t\t{$where_sql} forum_id IN (" . ($forum_id ? $forum_id : implode(', ', get_forum_list('m_'))) . ')
					AND log_time >= ' . $min_time . ' 
					AND log_type = ' . LOG_MOD;
            break;
    }
    $sort_key = request_var('sk', $default_key);
    $sort_dir = request_var('sd', $default_dir);
    $sort_dir_text = array('a' => $_CLASS['core_user']->lang['ASCENDING'], 'd' => $_CLASS['core_user']->lang['DESCENDING']);
    switch ($type) {
        case 'topics':
            $limit_days = array(0 => $_CLASS['core_user']->lang['ALL_TOPICS'], 1 => $_CLASS['core_user']->lang['1_DAY'], 7 => $_CLASS['core_user']->lang['7_DAYS'], 14 => $_CLASS['core_user']->lang['2_WEEKS'], 30 => $_CLASS['core_user']->lang['1_MONTH'], 90 => $_CLASS['core_user']->lang['3_MONTHS'], 180 => $_CLASS['core_user']->lang['6_MONTHS'], 364 => $_CLASS['core_user']->lang['1_YEAR']);
            $sort_by_text = array('a' => $_CLASS['core_user']->lang['AUTHOR'], 't' => $_CLASS['core_user']->lang['POST_TIME'], 'tt' => $_CLASS['core_user']->lang['TOPIC_TIME'], 'r' => $_CLASS['core_user']->lang['REPLIES'], 's' => $_CLASS['core_user']->lang['SUBJECT'], 'v' => $_CLASS['core_user']->lang['VIEWS']);
            $sort_by_sql = array('a' => 't.topic_first_poster_name', 't' => 't.topic_last_post_time', 'tt' => 't.topic_time', 'r' => $_CLASS['auth']->acl_get('m_approve', $forum_id) ? 't.topic_replies_real' : 't.topic_replies', 's' => 't.topic_title', 'v' => 't.topic_views');
            $limit_time_sql = $min_time ? "AND t.topic_last_post_time >= {$min_time}" : '';
            break;
        case 'posts':
            $limit_days = array(0 => $_CLASS['core_user']->lang['ALL_POSTS'], 1 => $_CLASS['core_user']->lang['1_DAY'], 7 => $_CLASS['core_user']->lang['7_DAYS'], 14 => $_CLASS['core_user']->lang['2_WEEKS'], 30 => $_CLASS['core_user']->lang['1_MONTH'], 90 => $_CLASS['core_user']->lang['3_MONTHS'], 180 => $_CLASS['core_user']->lang['6_MONTHS'], 364 => $_CLASS['core_user']->lang['1_YEAR']);
            $sort_by_text = array('a' => $_CLASS['core_user']->lang['AUTHOR'], 't' => $_CLASS['core_user']->lang['POST_TIME'], 's' => $_CLASS['core_user']->lang['SUBJECT']);
            $sort_by_sql = array('a' => 'u.username', 't' => 'p.post_id', 's' => 'p.post_subject');
            $limit_time_sql = $min_time ? "AND p.post_time >= {$min_time}" : '';
            break;
        case 'reports':
            $limit_days = array(0 => $_CLASS['core_user']->lang['ALL_REPORTS'], 1 => $_CLASS['core_user']->lang['1_DAY'], 7 => $_CLASS['core_user']->lang['7_DAYS'], 14 => $_CLASS['core_user']->lang['2_WEEKS'], 30 => $_CLASS['core_user']->lang['1_MONTH'], 90 => $_CLASS['core_user']->lang['3_MONTHS'], 180 => $_CLASS['core_user']->lang['6_MONTHS'], 364 => $_CLASS['core_user']->lang['1_YEAR']);
            $sort_by_text = array('p' => $_CLASS['core_user']->lang['REPORT_PRIORITY'], 'r' => $_CLASS['core_user']->lang['REPORTER'], 't' => $_CLASS['core_user']->lang['REPORT_TIME']);
            $sort_by_sql = array('p' => 'rr.reason_priority', 'r' => 'u.username', 't' => 'r.report_time');
            break;
        case 'logs':
            $limit_days = array(0 => $_CLASS['core_user']->lang['ALL_ENTRIES'], 1 => $_CLASS['core_user']->lang['1_DAY'], 7 => $_CLASS['core_user']->lang['7_DAYS'], 14 => $_CLASS['core_user']->lang['2_WEEKS'], 30 => $_CLASS['core_user']->lang['1_MONTH'], 90 => $_CLASS['core_user']->lang['3_MONTHS'], 180 => $_CLASS['core_user']->lang['6_MONTHS'], 364 => $_CLASS['core_user']->lang['1_YEAR']);
            $sort_by_text = array('u' => $_CLASS['core_user']->lang['SORT_USERNAME'], 't' => $_CLASS['core_user']->lang['SORT_DATE'], 'i' => $_CLASS['core_user']->lang['SORT_IP'], 'o' => $_CLASS['core_user']->lang['SORT_ACTION']);
            $sort_by_sql = array('u' => 'l.user_id', 't' => 'l.log_time', 'i' => 'l.log_ip', 'o' => 'l.log_operation');
            $limit_time_sql = $min_time ? "AND l.log_time >= {$min_time}" : '';
            break;
    }
    $sort_order_sql = $sort_by_sql[$sort_key] . ' ' . ($sort_dir == 'd' ? 'DESC' : 'ASC');
    $s_limit_days = $s_sort_key = $s_sort_dir = $sort_url = '';
    gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $sort_url);
    $_CLASS['core_template']->assign_array(array('S_SELECT_SORT_DIR' => $s_sort_dir, 'S_SELECT_SORT_KEY' => $s_sort_key, 'S_SELECT_SORT_DAYS' => $s_limit_days));
    if ($sort_days && $mode != 'viewlogs' || $mode == 'reports' || $where_sql != 'WHERE') {
        $result = $_CLASS['core_db']->query($sql);
        $total = ($row = $_CLASS['core_db']->fetch_row_assoc($result)) ? $row['total'] : 0;
    } else {
        $total = -1;
    }
}
示例#16
0
    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&amp;file=mcp&amp;i=queue&amp;p={$post_id}&amp;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&amp;mode=viewprofile&amp;u=' . $post_info['user_id']), 'U_MCP_USERNOTES' => generate_link('Forums&amp;file=mcp&amp;i=notes&amp;mode=user_notes&amp;u=' . $post_info['user_id']), 'U_MCP_WARNINGS' => generate_link('Forums&amp;file=mcp&amp;i=warnings&amp;mode=view_user&amp;u=' . $post_info['user_id']), 'U_EDIT' => $_CLASS['auth']->acl_get('m_edit', $post_info['forum_id']) ? generate_link("Forums&amp;file=posting&amp;mode=edit&amp;f={$post_info['forum_id']}&amp;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&amp;file=viewforum&amp;f=' . $row['forum_id']), 'U_VIEWTOPIC' => generate_link('Forums&amp;file=viewtopic&amp;f=' . $row['forum_id'] . '&amp;p=' . $row['post_id'] . ($mode == 'unapproved_posts' ? '#' . $row['post_id'] : '')), 'U_VIEW_DETAILS' => generate_link("Forums&amp;file=mcp&amp;i=queue&amp;start={$start}&amp;mode=approve_details&amp;f={$forum_id}&amp;p={$row['post_id']}"), 'U_VIEWPROFILE' => $row['poster_id'] != ANONYMOUS ? generate_link("Members_List&amp;mode=viewprofile&amp;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;
        }
    }
示例#17
0
    public function main($id, $mode)
    {
        global $auth, $db, $user, $template, $cache, $request;
        global $config, $phpbb_root_path, $phpEx, $action, $phpbb_container;
        global $phpbb_dispatcher;
        include_once $phpbb_root_path . 'includes/functions_posting.' . $phpEx;
        $forum_id = $request->variable('f', 0);
        $start = $request->variable('start', 0);
        $this->page_title = 'MCP_QUEUE';
        switch ($action) {
            case 'approve':
            case 'restore':
                include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
                $post_id_list = $request->variable('post_id_list', array(0));
                $topic_id_list = $request->variable('topic_id_list', array(0));
                if (!empty($post_id_list)) {
                    self::approve_posts($action, $post_id_list, 'queue', $mode);
                } else {
                    if (!empty($topic_id_list)) {
                        self::approve_topics($action, $topic_id_list, 'queue', $mode);
                    } else {
                        trigger_error('NO_POST_SELECTED');
                    }
                }
                break;
            case 'delete':
                $post_id_list = $request->variable('post_id_list', array(0));
                $topic_id_list = $request->variable('topic_id_list', array(0));
                if (!empty($post_id_list)) {
                    if (!function_exists('mcp_delete_post')) {
                        global $phpbb_root_path, $phpEx;
                        include $phpbb_root_path . 'includes/mcp/mcp_main.' . $phpEx;
                    }
                    mcp_delete_post($post_id_list, false, '', $action);
                } else {
                    if (!empty($topic_id_list)) {
                        if (!function_exists('mcp_delete_topic')) {
                            global $phpbb_root_path, $phpEx;
                            include $phpbb_root_path . 'includes/mcp/mcp_main.' . $phpEx;
                        }
                        mcp_delete_topic($topic_id_list, false, '', $action);
                    } else {
                        trigger_error('NO_POST_SELECTED');
                    }
                }
                break;
            case 'disapprove':
                $post_id_list = $request->variable('post_id_list', array(0));
                $topic_id_list = $request->variable('topic_id_list', array(0));
                if (!empty($topic_id_list) && $mode == 'deleted_topics') {
                    if (!function_exists('mcp_delete_topics')) {
                        global $phpbb_root_path, $phpEx;
                        include $phpbb_root_path . 'includes/mcp/mcp_main.' . $phpEx;
                    }
                    mcp_delete_topic($topic_id_list, false, '', 'disapprove');
                    return;
                }
                if (!class_exists('messenger')) {
                    include $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
                }
                if (!empty($topic_id_list)) {
                    $post_visibility = $mode == 'deleted_topics' ? ITEM_DELETED : array(ITEM_UNAPPROVED, ITEM_REAPPROVE);
                    $sql = 'SELECT post_id
						FROM ' . POSTS_TABLE . '
						WHERE ' . $db->sql_in_set('post_visibility', $post_visibility) . '
							AND ' . $db->sql_in_set('topic_id', $topic_id_list);
                    $result = $db->sql_query($sql);
                    $post_id_list = array();
                    while ($row = $db->sql_fetchrow($result)) {
                        $post_id_list[] = (int) $row['post_id'];
                    }
                    $db->sql_freeresult($result);
                }
                if (!empty($post_id_list)) {
                    self::disapprove_posts($post_id_list, 'queue', $mode);
                } else {
                    trigger_error('NO_POST_SELECTED');
                }
                break;
        }
        switch ($mode) {
            case 'approve_details':
                $this->tpl_name = 'mcp_post';
                $user->add_lang(array('posting', 'viewtopic'));
                $post_id = $request->variable('p', 0);
                $topic_id = $request->variable('t', 0);
                /* @var $phpbb_notifications \phpbb\notification\manager */
                $phpbb_notifications = $phpbb_container->get('notification_manager');
                if ($topic_id) {
                    $topic_info = phpbb_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'];
                        $phpbb_notifications->mark_notifications('topic_in_queue', $topic_id, $user->data['user_id']);
                    } else {
                        $topic_id = 0;
                    }
                }
                $phpbb_notifications->mark_notifications('post_in_queue', $post_id, $user->data['user_id']);
                $post_info = phpbb_get_post_data(array($post_id), 'm_approve', true);
                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, 'S_BBCODE_ALLOWED' => $post_info['enable_bbcode'], 'TOPIC_TITLE' => $post_info['topic_title']));
                }
                $extensions = $attachments = $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
                $parse_flags = ($post_info['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES;
                $message = generate_text_for_display($post_info['post_text'], $post_info['bbcode_uid'], $post_info['bbcode_bitfield'], $parse_flags, false);
                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));
                        }
                    }
                }
                // Deleting information
                if ($post_info['post_visibility'] == ITEM_DELETED && $post_info['post_delete_user']) {
                    // User having deleted the post also being the post author?
                    if (!$post_info['post_delete_user'] || $post_info['post_delete_user'] == $post_info['poster_id']) {
                        $display_username = get_username_string('full', $post_info['poster_id'], $post_info['username'], $post_info['user_colour'], $post_info['post_username']);
                    } else {
                        $sql = 'SELECT u.user_id, u.username, u.user_colour
							FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u
							WHERE p.post_id =  ' . $post_info['post_id'] . '
								AND p.post_delete_user = u.user_id';
                        $result = $db->sql_query($sql);
                        $post_delete_userinfo = $db->sql_fetchrow($result);
                        $db->sql_freeresult($result);
                        $display_username = get_username_string('full', $post_info['post_delete_user'], $post_delete_userinfo['username'], $post_delete_userinfo['user_colour']);
                    }
                    $l_deleted_by = $user->lang('DELETED_INFORMATION', $display_username, $user->format_date($post_info['post_delete_time'], false, true));
                } else {
                    $l_deleted_by = '';
                }
                $post_url = append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $post_info['forum_id'] . '&amp;p=' . $post_info['post_id'] . '#p' . $post_info['post_id']);
                $topic_url = append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $post_info['forum_id'] . '&amp;t=' . $post_info['topic_id']);
                $template->assign_vars(array('S_MCP_QUEUE' => true, 'U_APPROVE_ACTION' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i=queue&amp;p={$post_id}&amp;f={$forum_id}"), 'S_CAN_DELETE_POST' => $auth->acl_get('m_delete', $post_info['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_visibility'] == ITEM_UNAPPROVED || $post_info['post_visibility'] == ITEM_REAPPROVE, 'S_POST_LOCKED' => $post_info['post_edit_locked'], 'S_USER_NOTES' => true, 'S_POST_DELETED' => $post_info['post_visibility'] == ITEM_DELETED, 'DELETED_MESSAGE' => $l_deleted_by, 'DELETE_REASON' => $post_info['post_delete_reason'], 'U_EDIT' => $auth->acl_get('m_edit', $post_info['forum_id']) ? append_sid("{$phpbb_root_path}posting.{$phpEx}", "mode=edit&amp;f={$post_info['forum_id']}&amp;p={$post_info['post_id']}") : '', 'U_MCP_APPROVE' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue&amp;mode=approve_details&amp;f=' . $post_info['forum_id'] . '&amp;p=' . $post_id), 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=reports&amp;mode=report_details&amp;f=' . $post_info['forum_id'] . '&amp;p=' . $post_id), 'U_MCP_USER_NOTES' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=notes&amp;mode=user_notes&amp;u=' . $post_info['user_id']), 'U_MCP_WARN_USER' => $auth->acl_get('m_warn') ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=warn&amp;mode=warn_user&amp;u=' . $post_info['user_id']) : '', 'U_VIEW_POST' => $post_url, 'U_VIEW_TOPIC' => $topic_url, 'MINI_POST_IMG' => $post_unread ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'), 'RETURN_QUEUE' => sprintf($user->lang['RETURN_QUEUE'], '<a href="' . append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue' . ($topic_id ? '&amp;mode=unapproved_topics' : '&amp;mode=unapproved_posts')) . '&amp;start=' . $start . '">', '</a>'), 'RETURN_POST' => sprintf($user->lang['RETURN_POST'], '<a href="' . $post_url . '">', '</a>'), 'RETURN_TOPIC_SIMPLE' => sprintf($user->lang['RETURN_TOPIC_SIMPLE'], '<a href="' . $topic_url . '">', '</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']), '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->variable('lookup', '') ? @gethostbyaddr($post_info['poster_ip']) : '', 'POST_ID' => $post_info['post_id'], 'S_FIRST_POST' => $post_info['topic_first_post_id'] == $post_id, 'U_LOOKUP_IP' => $auth->acl_get('m_info', $post_info['forum_id']) ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue&amp;mode=approve_details&amp;f=' . $post_info['forum_id'] . '&amp;p=' . $post_id . '&amp;lookup=' . $post_info['poster_ip']) . '#ip' : ''));
                break;
            case 'unapproved_topics':
            case 'unapproved_posts':
            case 'deleted_topics':
            case 'deleted_posts':
                $m_perm = 'm_approve';
                $is_topics = $mode == 'unapproved_topics' || $mode == 'deleted_topics' ? true : false;
                $is_restore = $mode == 'deleted_posts' || $mode == 'deleted_topics' ? true : false;
                $visibility_const = !$is_restore ? array(ITEM_UNAPPROVED, ITEM_REAPPROVE) : ITEM_DELETED;
                $user->add_lang(array('viewtopic', 'viewforum'));
                $topic_id = $request->variable('t', 0);
                $forum_info = array();
                /* @var $pagination \phpbb\pagination */
                $pagination = $phpbb_container->get('pagination');
                if ($topic_id) {
                    $topic_info = phpbb_get_topic_data(array($topic_id));
                    if (!sizeof($topic_info)) {
                        trigger_error('TOPIC_NOT_EXIST');
                    }
                    $topic_info = $topic_info[$topic_id];
                    $forum_id = $topic_info['forum_id'];
                }
                $forum_list_approve = get_forum_list($m_perm, 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_approve as $k => $forum_data) {
                    if (!isset($forum_list_read[$forum_data['forum_id']])) {
                        unset($forum_list_approve[$k]);
                    }
                }
                unset($forum_list_read);
                if (!$forum_id) {
                    $forum_list = array();
                    foreach ($forum_list_approve as $row) {
                        $forum_list[] = $row['forum_id'];
                    }
                    if (!sizeof($forum_list)) {
                        trigger_error('NOT_MODERATOR');
                    }
                    $sql = 'SELECT SUM(forum_topics_approved) 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_approved'] = (int) $db->sql_fetchfield('sum_forum_topics');
                    $db->sql_freeresult($result);
                } else {
                    $forum_info = phpbb_get_forum_data(array($forum_id), $m_perm);
                    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"' : '') . '>' . $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"' : '') . '>' . str_repeat('&nbsp; &nbsp;', $row['padding']) . truncate_string($row['forum_name'], 30, 255, false, $user->lang['ELLIPSIS']) . '</option>';
                }
                $sort_days = $total = 0;
                $sort_key = $sort_dir = '';
                $sort_by_sql = $sort_order_sql = array();
                phpbb_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_approved'] : $total;
                $limit_time_sql = $sort_days ? 'AND t.topic_last_post_time >= ' . (time() - $sort_days * 86400) : '';
                $forum_names = array();
                if (!$is_topics) {
                    $sql = 'SELECT p.post_id
						FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t' . ($sort_order_sql[0] == 'u' ? ', ' . USERS_TABLE . ' u' : '') . '
						WHERE ' . $db->sql_in_set('p.forum_id', $forum_list) . '
							AND ' . $db->sql_in_set('p.post_visibility', $visibility_const) . '
							' . ($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_visibility <> p.post_visibility\n\t\t\t\t\t\t\t\tOR t.topic_delete_user = 0)\n\t\t\t\t\t\t\t{$limit_time_sql}\n\t\t\t\t\t\tORDER BY {$sort_order_sql}";
                    /**
                     * Alter sql query to get posts in queue to be accepted
                     *
                     * @event core.mcp_queue_get_posts_query_before
                     * @var	string	sql						Associative array with the query to be executed
                     * @var	array	forum_list				List of forums that contain the posts
                     * @var	int		visibility_const		Integer with one of the possible ITEM_* constant values
                     * @var	int		topic_id				If topic_id not equal to 0, the topic id to filter the posts to display
                     * @var	string	limit_time_sql			String with the SQL code to limit the time interval of the post (Note: May be empty string)
                     * @var	string	sort_order_sql			String with the ORDER BY SQL code used in this query
                     * @since 3.1.0-RC3
                     */
                    $vars = array('sql', 'forum_list', 'visibility_const', 'topic_id', 'limit_time_sql', 'sort_order_sql');
                    extract($phpbb_dispatcher->trigger_event('core.mcp_queue_get_posts_query_before', compact($vars)));
                    $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_subject, p.post_username, p.poster_id, p.post_time, p.post_attachment, u.username, u.username_clean, u.user_colour
							FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . ' u
							WHERE ' . $db->sql_in_set('p.post_id', $post_ids) . '
								AND t.topic_id = p.topic_id
								AND u.user_id = p.poster_id
							ORDER BY ' . $sort_order_sql;
                        $result = $db->sql_query($sql);
                        $post_data = $rowset = array();
                        while ($row = $db->sql_fetchrow($result)) {
                            $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_title AS post_subject, t.topic_time AS post_time, t.topic_poster AS poster_id, t.topic_first_post_id AS post_id, t.topic_attachment AS post_attachment, t.topic_first_poster_name AS username, t.topic_first_poster_colour AS user_colour
						FROM ' . TOPICS_TABLE . ' t
						WHERE ' . $db->sql_in_set('forum_id', $forum_list) . '
							AND  ' . $db->sql_in_set('topic_visibility', $visibility_const) . "\n\t\t\t\t\t\t\tAND topic_delete_user <> 0\n\t\t\t\t\t\t\t{$limit_time_sql}\n\t\t\t\t\t\tORDER BY {$sort_order_sql}";
                    /**
                     * Alter sql query to get information on all topics in the list of forums provided.
                     *
                     * @event core.mcp_queue_get_posts_for_topics_query_before
                     * @var	string	sql						String with the query to be executed
                     * @var	array	forum_list				List of forums that contain the posts
                     * @var	int		visibility_const		Integer with one of the possible ITEM_* constant values
                     * @var	int		topic_id				topic_id in the page request
                     * @var	string	limit_time_sql			String with the SQL code to limit the time interval of the post (Note: May be empty string)
                     * @var	string	sort_order_sql			String with the ORDER BY SQL code used in this query
                     * @since 3.1.0-RC3
                     */
                    $vars = array('sql', 'forum_list', 'visibility_const', 'topic_id', 'limit_time_sql', 'sort_order_sql');
                    extract($phpbb_dispatcher->trigger_event('core.mcp_queue_get_posts_for_topics_query_before', compact($vars)));
                    $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start);
                    $rowset = array();
                    while ($row = $db->sql_fetchrow($result)) {
                        $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 ' . $db->sql_in_set('forum_id', $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 (empty($row['post_username'])) {
                        $row['post_username'] = $row['username'] ?: $user->lang['GUEST'];
                    }
                    $template->assign_block_vars('postrow', array('U_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $row['forum_id'] . '&amp;t=' . $row['topic_id']), 'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $row['forum_id']), 'U_VIEWPOST' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $row['forum_id'] . '&amp;p=' . $row['post_id']) . ($mode == 'unapproved_posts' ? '#p' . $row['post_id'] : ''), 'U_VIEW_DETAILS' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i=queue&amp;start={$start}&amp;mode=approve_details&amp;f={$row['forum_id']}&amp;p={$row['post_id']}" . ($mode == 'unapproved_topics' ? "&amp;t={$row['topic_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']), 'POST_ID' => $row['post_id'], 'TOPIC_ID' => $row['topic_id'], 'FORUM_NAME' => $forum_names[$row['forum_id']], 'POST_SUBJECT' => $row['post_subject'] != '' ? $row['post_subject'] : $user->lang['NO_SUBJECT'], 'TOPIC_TITLE' => $row['topic_title'], 'POST_TIME' => $user->format_date($row['post_time']), 'ATTACH_ICON_IMG' => $auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id']) && $row['post_attachment'] ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : ''));
                }
                unset($rowset, $forum_names);
                $base_url = $this->u_action . "&amp;f={$forum_id}&amp;st={$sort_days}&amp;sk={$sort_key}&amp;sd={$sort_dir}";
                $pagination->generate_template_pagination($base_url, 'pagination', 'start', $total, $config['topics_per_page'], $start);
                // Now display the page
                $template->assign_vars(array('L_DISPLAY_ITEMS' => !$is_topics ? $user->lang['DISPLAY_POSTS'] : $user->lang['DISPLAY_TOPICS'], 'L_EXPLAIN' => $user->lang['MCP_QUEUE_' . strtoupper($mode) . '_EXPLAIN'], 'L_TITLE' => $user->lang['MCP_QUEUE_' . strtoupper($mode)], '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')), 'S_TOPICS' => $is_topics, 'S_RESTORE' => $is_restore, 'TOPIC_ID' => $topic_id, 'TOTAL' => $user->lang(!$is_topics ? 'VIEW_TOPIC_POSTS' : 'VIEW_FORUM_TOPICS', (int) $total)));
                $this->tpl_name = 'mcp_queue';
                break;
        }
    }
示例#18
0
 /**
  * Generate sitemap(s) and an index
  *
  * @return bool
  */
 public function generate()
 {
     // check that the sitemaps directory exists and create it if it doesn't
     check_dir_exists($this->directory, true);
     // this is used by PluginInteractionForum::get_active_topics
     $USER = new User();
     // create a new sitemap
     $this->create_sitemap();
     // get a list of public groups
     $publicgroups = get_records_select_array('group', 'public = 1 AND deleted = 0');
     if (!empty($publicgroups)) {
         foreach ($publicgroups as $group) {
             if (isset($group->mtime) && $this->check_date($group->mtime)) {
                 // each group gets a url entry
                 $groupurl = group_homepage_url($group);
                 $groupurl = utf8_encode(htmlspecialchars($groupurl, ENT_QUOTES, 'UTF-8'));
                 $grouplastmod = format_date(strtotime($group->mtime), 'strftimew3cdate');
                 $this->add_url($groupurl, $grouplastmod);
             }
             // build a list of forums in each public group
             $forums = get_forum_list($group->id);
             $forumids = array();
             foreach ($forums as $forum) {
                 $forumids[] = $forum->id;
             }
             // active topics within the specified forums (public only)
             $activetopics = PluginInteractionForum::get_active_topics(0, 0, 0, $forumids);
             foreach ($activetopics['data'] as $topic) {
                 if (isset($topic->mtime) && $this->check_date($topic->mtime) || isset($topic->ctime) && $this->check_date($topic->ctime)) {
                     $forumurl = get_config('wwwroot') . 'interaction/forum/topic.php?id=' . $topic->id;
                     $forumurl = utf8_encode(htmlspecialchars($forumurl, ENT_QUOTES, 'UTF-8'));
                     // mtime will be set if the last post has been edited
                     if (isset($topic->mtime) && strtotime($topic->mtime) !== FALSE) {
                         $forumlastmod = format_date(strtotime($topic->mtime), 'strftimew3cdate');
                     } else {
                         $forumlastmod = format_date(strtotime($topic->ctime), 'strftimew3cdate');
                     }
                     $this->add_url($forumurl, $forumlastmod);
                 }
             }
         }
     }
     // views shared with the public
     // grouphomepage type views are handled above
     $types = array('portfolio');
     $views = View::view_search(null, null, null, null, null, 0, true, null, $types);
     if (!empty($views->data)) {
         foreach ($views->data as $view) {
             if (isset($view['mtime']) && $this->check_date($view['mtime'])) {
                 $viewurl = utf8_encode(htmlspecialchars($view['fullurl'], ENT_QUOTES, 'UTF-8'));
                 $viewlastmod = format_date(strtotime($view['mtime']), 'strftimew3cdate');
                 $this->add_url($viewurl, $viewlastmod);
             }
         }
     }
     // add the urlset and print the xml out
     // only if the urlset has any children
     if ($this->currenturlset->hasChildNodes()) {
         $this->save_sitemap(true);
     }
     return true;
 }
示例#19
0
    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&amp;p={$post_id}&amp;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&amp;f={$post_info['forum_id']}&amp;p={$post_info['post_id']}") : '', 'U_MCP_APPROVE' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue&amp;mode=approve_details&amp;f=' . $post_info['forum_id'] . '&amp;p=' . $post_id), 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=reports&amp;mode=report_details&amp;f=' . $post_info['forum_id'] . '&amp;p=' . $post_id), 'U_MCP_USER_NOTES' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=notes&amp;mode=user_notes&amp;u=' . $post_info['user_id']), 'U_MCP_WARN_USER' => $auth->acl_getf_global('m_warn') ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=warn&amp;mode=warn_user&amp;u=' . $post_info['user_id']) : '', 'U_VIEW_PROFILE' => $post_info['user_id'] != ANONYMOUS ? append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=viewprofile&amp;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 ? '&amp;mode=unapproved_topics' : '&amp;mode=unapproved_posts')) . "&amp;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'] . '&amp;p=' . $row['post_id']) . ($mode == 'unapproved_posts' ? '#p' . $row['post_id'] : ''), 'U_VIEW_DETAILS' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i=queue&amp;start={$start}&amp;mode=approve_details&amp;f={$row['forum_id']}&amp;p={$row['post_id']}" . ($mode == 'unapproved_topics' ? "&amp;t={$row['topic_id']}" : '')), 'U_VIEWPROFILE' => $row['poster_id'] != ANONYMOUS ? append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=viewprofile&amp;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 . "&amp;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;
        }
    }
示例#20
0
文件: mcp_logs.php 项目: phpbb/phpbb
    function main($id, $mode)
    {
        global $auth, $db, $user, $template, $request;
        global $config, $phpbb_container, $phpbb_log;
        $user->add_lang('acp/common');
        $action = $request->variable('action', array('' => ''));
        if (is_array($action)) {
            list($action, ) = each($action);
        } else {
            $action = $request->variable('action', '');
        }
        // Set up general vars
        $start = $request->variable('start', 0);
        $deletemark = $action == 'del_marked' ? true : false;
        $deleteall = $action == 'del_all' ? true : false;
        $marked = $request->variable('mark', array(0));
        // Sort keys
        $sort_days = $request->variable('st', 0);
        $sort_key = $request->variable('sk', 't');
        $sort_dir = $request->variable('sd', 'd');
        $this->tpl_name = 'mcp_logs';
        $this->page_title = 'MCP_LOGS';
        /* @var $pagination \phpbb\pagination */
        $pagination = $phpbb_container->get('pagination');
        $forum_list = array_values(array_intersect(get_forum_list('f_read'), get_forum_list('m_')));
        $forum_list[] = 0;
        $forum_id = $topic_id = 0;
        switch ($mode) {
            case 'front':
                break;
            case 'forum_logs':
                $forum_id = $request->variable('f', 0);
                if (!in_array($forum_id, $forum_list)) {
                    send_status_line(403, 'Forbidden');
                    trigger_error('NOT_AUTHORISED');
                }
                $forum_list = array($forum_id);
                break;
            case 'topic_logs':
                $topic_id = $request->variable('t', 0);
                $sql = 'SELECT forum_id
					FROM ' . TOPICS_TABLE . '
					WHERE topic_id = ' . $topic_id;
                $result = $db->sql_query($sql);
                $forum_id = (int) $db->sql_fetchfield('forum_id');
                $db->sql_freeresult($result);
                if (!in_array($forum_id, $forum_list)) {
                    send_status_line(403, 'Forbidden');
                    trigger_error('NOT_AUTHORISED');
                }
                $forum_list = array($forum_id);
                break;
        }
        // Delete entries if requested and able
        if (($deletemark || $deleteall) && $auth->acl_get('a_clearlogs')) {
            if (confirm_box(true)) {
                if ($deletemark && sizeof($marked)) {
                    $conditions = array('forum_id' => array('IN' => $forum_list), 'log_id' => array('IN' => $marked));
                    $phpbb_log->delete('mod', $conditions);
                } else {
                    if ($deleteall) {
                        $keywords = $request->variable('keywords', '', true);
                        $conditions = array('forum_id' => array('IN' => $forum_list), 'keywords' => $keywords);
                        if ($sort_days) {
                            $conditions['log_time'] = array('>=', time() - $sort_days * 86400);
                        }
                        if ($mode == 'topic_logs') {
                            $conditions['topic_id'] = $topic_id;
                        }
                        $phpbb_log->delete('mod', $conditions);
                    }
                }
            } else {
                confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array('f' => $forum_id, 't' => $topic_id, 'start' => $start, 'delmarked' => $deletemark, 'delall' => $deleteall, 'mark' => $marked, 'st' => $sort_days, 'sk' => $sort_key, 'sd' => $sort_dir, 'i' => $id, 'mode' => $mode, 'action' => $request->variable('action', array('' => '')))));
            }
        }
        // Sorting
        $limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
        $sort_by_text = array('u' => $user->lang['SORT_USERNAME'], 't' => $user->lang['SORT_DATE'], 'i' => $user->lang['SORT_IP'], 'o' => $user->lang['SORT_ACTION']);
        $sort_by_sql = array('u' => 'u.username_clean', 't' => 'l.log_time', 'i' => 'l.log_ip', 'o' => 'l.log_operation');
        $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
        gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
        // Define where and sort sql for use in displaying logs
        $sql_where = $sort_days ? time() - $sort_days * 86400 : 0;
        $sql_sort = $sort_by_sql[$sort_key] . ' ' . ($sort_dir == 'd' ? 'DESC' : 'ASC');
        $keywords = $request->variable('keywords', '', true);
        $keywords_param = !empty($keywords) ? '&amp;keywords=' . urlencode(htmlspecialchars_decode($keywords)) : '';
        // Grab log data
        $log_data = array();
        $log_count = 0;
        $start = view_log('mod', $log_data, $log_count, $config['topics_per_page'], $start, $forum_list, $topic_id, 0, $sql_where, $sql_sort, $keywords);
        $base_url = $this->u_action . "&amp;{$u_sort_param}{$keywords_param}";
        $pagination->generate_template_pagination($base_url, 'pagination', 'start', $log_count, $config['topics_per_page'], $start);
        $template->assign_vars(array('TOTAL' => $user->lang('TOTAL_LOGS', (int) $log_count), 'L_TITLE' => $user->lang['MCP_LOGS'], 'U_POST_ACTION' => $this->u_action . "&amp;{$u_sort_param}{$keywords_param}&amp;start={$start}", 'S_CLEAR_ALLOWED' => $auth->acl_get('a_clearlogs') ? true : false, 'S_SELECT_SORT_DIR' => $s_sort_dir, 'S_SELECT_SORT_KEY' => $s_sort_key, 'S_SELECT_SORT_DAYS' => $s_limit_days, 'S_LOGS' => $log_count > 0, 'S_KEYWORDS' => $keywords));
        foreach ($log_data as $row) {
            $data = array();
            $checks = array('viewpost', 'viewtopic', 'viewforum');
            foreach ($checks as $check) {
                if (isset($row[$check]) && $row[$check]) {
                    $data[] = '<a href="' . $row[$check] . '">' . $user->lang['LOGVIEW_' . strtoupper($check)] . '</a>';
                }
            }
            $template->assign_block_vars('log', array('USERNAME' => $row['username_full'], 'IP' => $row['ip'], 'DATE' => $user->format_date($row['time']), 'ACTION' => $row['action'], 'DATA' => sizeof($data) ? implode(' | ', $data) : '', 'ID' => $row['id']));
        }
    }
示例#21
0
文件: mcp_front.php 项目: jvinhit/php
/**
* MCP Front Panel
*/
function mcp_front_view($id, $mode, $action)
{
    global $phpEx, $phpbb_root_path, $config;
    global $template, $db, $user, $auth, $module;
    // Latest 5 unapproved
    if ($module->loaded('queue')) {
        $forum_list = array_values(array_intersect(get_forum_list('f_read'), get_forum_list('m_approve')));
        $post_list = array();
        $forum_names = array();
        $forum_id = request_var('f', 0);
        $template->assign_var('S_SHOW_UNAPPROVED', !empty($forum_list) ? true : false);
        if (!empty($forum_list)) {
            $sql = 'SELECT COUNT(post_id) AS total
				FROM ' . POSTS_TABLE . '
				WHERE forum_id IN (0, ' . implode(', ', $forum_list) . ')
					AND post_approved = 0';
            $result = $db->sql_query($sql);
            $total = (int) $db->sql_fetchfield('total');
            $db->sql_freeresult($result);
            if ($total) {
                $global_id = $forum_list[0];
                $sql = 'SELECT forum_id, forum_name
					FROM ' . FORUMS_TABLE . '
					WHERE ' . $db->sql_in_set('forum_id', $forum_list);
                $result = $db->sql_query($sql);
                while ($row = $db->sql_fetchrow($result)) {
                    $forum_names[$row['forum_id']] = $row['forum_name'];
                }
                $db->sql_freeresult($result);
                $sql = 'SELECT post_id
					FROM ' . POSTS_TABLE . '
					WHERE forum_id IN (0, ' . implode(', ', $forum_list) . ')
						AND post_approved = 0
					ORDER BY post_time DESC';
                $result = $db->sql_query_limit($sql, 5);
                while ($row = $db->sql_fetchrow($result)) {
                    $post_list[] = $row['post_id'];
                }
                $db->sql_freeresult($result);
                if (empty($post_list)) {
                    $total = 0;
                }
            }
            if ($total) {
                $sql = 'SELECT p.post_id, p.post_subject, p.post_time, p.poster_id, p.post_username, u.username, u.username_clean, u.user_colour, t.topic_id, t.topic_title, t.topic_first_post_id, p.forum_id
					FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . ' u
					WHERE ' . $db->sql_in_set('p.post_id', $post_list) . '
						AND t.topic_id = p.topic_id
						AND p.poster_id = u.user_id
					ORDER BY p.post_time DESC';
                $result = $db->sql_query($sql);
                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('unapproved', array('U_POST_DETAILS' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue&amp;mode=approve_details&amp;f=' . $row['forum_id'] . '&amp;p=' . $row['post_id']), 'U_MCP_FORUM' => !$global_topic ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=main&amp;mode=forum_view&amp;f=' . $row['forum_id']) : '', 'U_MCP_TOPIC' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=main&amp;mode=topic_view&amp;f=' . $row['forum_id'] . '&amp;t=' . $row['topic_id']), 'U_FORUM' => !$global_topic ? append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $row['forum_id']) : '', 'U_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $row['forum_id'] . '&amp;t=' . $row['topic_id']), 'AUTHOR_FULL' => get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour']), 'AUTHOR' => get_username_string('username', $row['poster_id'], $row['username'], $row['user_colour']), 'AUTHOR_COLOUR' => get_username_string('colour', $row['poster_id'], $row['username'], $row['user_colour']), 'U_AUTHOR' => get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour']), 'FORUM_NAME' => !$global_topic ? $forum_names[$row['forum_id']] : $user->lang['GLOBAL_ANNOUNCEMENT'], 'POST_ID' => $row['post_id'], 'TOPIC_TITLE' => $row['topic_title'], 'SUBJECT' => $row['post_subject'] ? $row['post_subject'] : $user->lang['NO_SUBJECT'], 'POST_TIME' => $user->format_date($row['post_time'])));
                }
                $db->sql_freeresult($result);
            }
            $template->assign_vars(array('S_MCP_QUEUE_ACTION' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i=queue")));
            if ($total == 0) {
                $template->assign_vars(array('L_UNAPPROVED_TOTAL' => $user->lang['UNAPPROVED_POSTS_ZERO_TOTAL'], 'S_HAS_UNAPPROVED_POSTS' => false));
            } else {
                $template->assign_vars(array('L_UNAPPROVED_TOTAL' => $total == 1 ? $user->lang['UNAPPROVED_POST_TOTAL'] : sprintf($user->lang['UNAPPROVED_POSTS_TOTAL'], $total), 'S_HAS_UNAPPROVED_POSTS' => true));
            }
        }
    }
    // Latest 5 reported
    if ($module->loaded('reports')) {
        $forum_list = array_values(array_intersect(get_forum_list('f_read'), get_forum_list('m_report')));
        $template->assign_var('S_SHOW_REPORTS', !empty($forum_list) ? true : false);
        if (!empty($forum_list)) {
            $sql = 'SELECT COUNT(r.report_id) AS total
				FROM ' . REPORTS_TABLE . ' r, ' . POSTS_TABLE . ' p
				WHERE r.post_id = p.post_id
					AND r.report_closed = 0
					AND p.forum_id IN (0, ' . implode(', ', $forum_list) . ')';
            $result = $db->sql_query($sql);
            $total = (int) $db->sql_fetchfield('total');
            $db->sql_freeresult($result);
            if ($total) {
                $global_id = $forum_list[0];
                $sql = $db->sql_build_query('SELECT', array('SELECT' => 'r.report_time, p.post_id, p.post_subject, p.post_time, u.username, u.username_clean, u.user_colour, u.user_id, u2.username as author_name, u2.username_clean as author_name_clean, u2.user_colour as author_colour, u2.user_id as author_id, t.topic_id, t.topic_title, f.forum_id, f.forum_name', 'FROM' => array(REPORTS_TABLE => 'r', REPORTS_REASONS_TABLE => 'rr', TOPICS_TABLE => 't', USERS_TABLE => array('u', 'u2'), POSTS_TABLE => 'p'), 'LEFT_JOIN' => array(array('FROM' => array(FORUMS_TABLE => 'f'), 'ON' => 'f.forum_id = p.forum_id')), 'WHERE' => 'r.post_id = p.post_id
						AND r.report_closed = 0
						AND r.reason_id = rr.reason_id
						AND p.topic_id = t.topic_id
						AND r.user_id = u.user_id
						AND p.poster_id = u2.user_id
						AND p.forum_id IN (0, ' . implode(', ', $forum_list) . ')', 'ORDER_BY' => 'p.post_time DESC'));
                $result = $db->sql_query_limit($sql, 5);
                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('report', array('U_POST_DETAILS' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'f=' . $row['forum_id'] . '&amp;p=' . $row['post_id'] . "&amp;i=reports&amp;mode=report_details"), 'U_MCP_FORUM' => !$global_topic ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'f=' . $row['forum_id'] . "&amp;i={$id}&amp;mode=forum_view") : '', 'U_MCP_TOPIC' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'f=' . $row['forum_id'] . '&amp;t=' . $row['topic_id'] . "&amp;i={$id}&amp;mode=topic_view"), 'U_FORUM' => !$global_topic ? append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $row['forum_id']) : '', 'U_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $row['forum_id'] . '&amp;t=' . $row['topic_id']), 'REPORTER_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'REPORTER' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']), 'REPORTER_COLOUR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), 'U_REPORTER' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']), 'AUTHOR_FULL' => get_username_string('full', $row['author_id'], $row['author_name'], $row['author_colour']), 'AUTHOR' => get_username_string('username', $row['author_id'], $row['author_name'], $row['author_colour']), 'AUTHOR_COLOUR' => get_username_string('colour', $row['author_id'], $row['author_name'], $row['author_colour']), 'U_AUTHOR' => get_username_string('profile', $row['author_id'], $row['author_name'], $row['author_colour']), 'FORUM_NAME' => !$global_topic ? $row['forum_name'] : $user->lang['GLOBAL_ANNOUNCEMENT'], 'TOPIC_TITLE' => $row['topic_title'], 'SUBJECT' => $row['post_subject'] ? $row['post_subject'] : $user->lang['NO_SUBJECT'], 'REPORT_TIME' => $user->format_date($row['report_time']), 'POST_TIME' => $user->format_date($row['post_time'])));
                }
            }
            if ($total == 0) {
                $template->assign_vars(array('L_REPORTS_TOTAL' => $user->lang['REPORTS_ZERO_TOTAL'], 'S_HAS_REPORTS' => false));
            } else {
                $template->assign_vars(array('L_REPORTS_TOTAL' => $total == 1 ? $user->lang['REPORT_TOTAL'] : sprintf($user->lang['REPORTS_TOTAL'], $total), 'S_HAS_REPORTS' => true));
            }
        }
    }
    // Latest 5 logs
    if ($module->loaded('logs')) {
        $forum_list = array_values(array_intersect(get_forum_list('f_read'), get_forum_list('m_')));
        if (!empty($forum_list)) {
            // Add forum_id 0 for global announcements
            $forum_list[] = 0;
            $log_count = 0;
            $log = array();
            view_log('mod', $log, $log_count, 5, 0, $forum_list);
            foreach ($log as $row) {
                $template->assign_block_vars('log', array('USERNAME' => $row['username_full'], 'IP' => $row['ip'], 'TIME' => $user->format_date($row['time']), 'ACTION' => $row['action'], 'U_VIEW_TOPIC' => !empty($row['viewtopic']) ? $row['viewtopic'] : '', 'U_VIEWLOGS' => !empty($row['viewlogs']) ? $row['viewlogs'] : ''));
            }
        }
        $template->assign_vars(array('S_SHOW_LOGS' => !empty($forum_list) ? true : false, 'S_HAS_LOGS' => !empty($log) ? true : false));
    }
    $template->assign_var('S_MCP_ACTION', append_sid("{$phpbb_root_path}mcp.{$phpEx}"));
    make_jumpbox(append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=main&amp;mode=forum_view'), 0, false, 'm_', true);
}
示例#22
0
 function make_forum_drop_down_box()
 {
     global $db, $user;
     $forums_row = get_forum_list();
     $forum_list = '<select name="forum_top">';
     $forum_list .= '<option value="-1" selected="selected">All</option>';
     for ($i = 1; $i < sizeof($forums_row) + 1; $i++) {
         if (isset($forums_row[$i]) && $forums_row[$i]['auth_view']) {
             $forum_list .= '<option value="' . $i . '">' . strip_tags(id_to_value($i, 'forum')) . '</option>';
         }
     }
     $forum_list .= '</select>';
     return $forum_list;
 }
示例#23
0
/**
* MCP Front Panel
*/
function mcp_front_view($id, $mode, $action)
{
    global $phpEx, $phpbb_root_path, $config;
    global $template, $db, $user, $auth, $module;
    global $phpbb_dispatcher;
    // Latest 5 unapproved
    if ($module->loaded('queue')) {
        $forum_list = array_values(array_intersect(get_forum_list('f_read'), get_forum_list('m_approve')));
        $post_list = array();
        $forum_names = array();
        $forum_id = request_var('f', 0);
        $template->assign_var('S_SHOW_UNAPPROVED', !empty($forum_list) ? true : false);
        if (!empty($forum_list)) {
            $sql_ary = array('SELECT' => 'COUNT(post_id) AS total', 'FROM' => array(POSTS_TABLE => 'p'), 'WHERE' => $db->sql_in_set('p.forum_id', $forum_list) . '
					AND ' . $db->sql_in_set('p.post_visibility', array(ITEM_UNAPPROVED, ITEM_REAPPROVE)));
            /**
             * Allow altering the query to get the number of unapproved posts
             *
             * @event core.mcp_front_queue_unapproved_total_before
             * @var	int		sql_ary						Query to get the total number of unapproved posts
             * @var	array	forum_list					List of forums to look for unapproved posts
             * @since 3.1.5-RC1
             */
            $vars = array('sql_ary', 'forum_list');
            extract($phpbb_dispatcher->trigger_event('core.mcp_front_queue_unapproved_total_before', compact($vars)));
            $sql = $db->sql_build_query('SELECT', $sql_ary);
            $result = $db->sql_query($sql);
            $total = (int) $db->sql_fetchfield('total');
            $db->sql_freeresult($result);
            if ($total) {
                $sql = 'SELECT forum_id, forum_name
					FROM ' . FORUMS_TABLE . '
					WHERE ' . $db->sql_in_set('forum_id', $forum_list);
                $result = $db->sql_query($sql);
                while ($row = $db->sql_fetchrow($result)) {
                    $forum_names[$row['forum_id']] = $row['forum_name'];
                }
                $db->sql_freeresult($result);
                $sql = 'SELECT post_id
					FROM ' . POSTS_TABLE . '
					WHERE ' . $db->sql_in_set('forum_id', $forum_list) . '
						AND ' . $db->sql_in_set('post_visibility', array(ITEM_UNAPPROVED, ITEM_REAPPROVE)) . '
					ORDER BY post_time DESC, post_id DESC';
                $result = $db->sql_query_limit($sql, 5);
                while ($row = $db->sql_fetchrow($result)) {
                    $post_list[] = $row['post_id'];
                }
                $db->sql_freeresult($result);
                if (empty($post_list)) {
                    $total = 0;
                }
            }
            /**
             * Alter list of posts and total as required
             *
             * @event core.mcp_front_view_queue_postid_list_after
             * @var	int		total						Number of unapproved posts
             * @var	array	post_list					List of unapproved posts
             * @var	array	forum_list					List of forums that contain the posts
             * @var	array	forum_names					Associative array with forum_id as key and it's corresponding forum_name as value
             * @since 3.1.0-RC3
             */
            $vars = array('total', 'post_list', 'forum_list', 'forum_names');
            extract($phpbb_dispatcher->trigger_event('core.mcp_front_view_queue_postid_list_after', compact($vars)));
            if ($total) {
                $sql = 'SELECT p.post_id, p.post_subject, p.post_time, p.post_attachment, p.poster_id, p.post_username, u.username, u.username_clean, u.user_colour, t.topic_id, t.topic_title, t.topic_first_post_id, p.forum_id
					FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . ' u
					WHERE ' . $db->sql_in_set('p.post_id', $post_list) . '
						AND t.topic_id = p.topic_id
						AND p.poster_id = u.user_id
					ORDER BY p.post_time DESC, p.post_id DESC';
                $result = $db->sql_query($sql);
                while ($row = $db->sql_fetchrow($result)) {
                    $template->assign_block_vars('unapproved', array('U_POST_DETAILS' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue&amp;mode=approve_details&amp;f=' . $row['forum_id'] . '&amp;p=' . $row['post_id']), 'U_MCP_FORUM' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=main&amp;mode=forum_view&amp;f=' . $row['forum_id']), 'U_MCP_TOPIC' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=main&amp;mode=topic_view&amp;f=' . $row['forum_id'] . '&amp;t=' . $row['topic_id']), 'U_FORUM' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $row['forum_id']), 'U_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $row['forum_id'] . '&amp;t=' . $row['topic_id']), 'AUTHOR_FULL' => get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour']), 'AUTHOR' => get_username_string('username', $row['poster_id'], $row['username'], $row['user_colour']), 'AUTHOR_COLOUR' => get_username_string('colour', $row['poster_id'], $row['username'], $row['user_colour']), 'U_AUTHOR' => get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour']), 'FORUM_NAME' => $forum_names[$row['forum_id']], 'POST_ID' => $row['post_id'], 'TOPIC_TITLE' => $row['topic_title'], 'SUBJECT' => $row['post_subject'] ? $row['post_subject'] : $user->lang['NO_SUBJECT'], 'POST_TIME' => $user->format_date($row['post_time']), 'ATTACH_ICON_IMG' => $auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id']) && $row['post_attachment'] ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : ''));
                }
                $db->sql_freeresult($result);
            }
            $s_hidden_fields = build_hidden_fields(array('redirect' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=main' . ($forum_id ? '&amp;f=' . $forum_id : ''))));
            $template->assign_vars(array('S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_MCP_QUEUE_ACTION' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i=queue"), 'L_UNAPPROVED_TOTAL' => $user->lang('UNAPPROVED_POSTS_TOTAL', (int) $total), 'S_HAS_UNAPPROVED_POSTS' => $total != 0));
        }
    }
    // Latest 5 reported
    if ($module->loaded('reports')) {
        $forum_list = array_values(array_intersect(get_forum_list('f_read'), get_forum_list('m_report')));
        $template->assign_var('S_SHOW_REPORTS', !empty($forum_list) ? true : false);
        if (!empty($forum_list)) {
            $sql = 'SELECT COUNT(r.report_id) AS total
				FROM ' . REPORTS_TABLE . ' r, ' . POSTS_TABLE . ' p
				WHERE r.post_id = p.post_id
					AND r.pm_id = 0
					AND r.report_closed = 0
					AND ' . $db->sql_in_set('p.forum_id', $forum_list);
            /**
             * Alter sql query to count the number of reported posts
             *
             * @event core.mcp_front_reports_count_query_before
             * @var	int		sql				The query string used to get the number of reports that exist
             * @var	array	forum_list		List of forums that contain the posts
             * @since 3.1.5-RC1
             */
            $vars = array('sql', 'forum_list');
            extract($phpbb_dispatcher->trigger_event('core.mcp_front_reports_count_query_before', compact($vars)));
            $result = $db->sql_query($sql);
            $total = (int) $db->sql_fetchfield('total');
            $db->sql_freeresult($result);
            if ($total) {
                $sql_ary = array('SELECT' => 'r.report_time, p.post_id, p.post_subject, p.post_time, p.post_attachment, u.username, u.username_clean, u.user_colour, u.user_id, u2.username as author_name, u2.username_clean as author_name_clean, u2.user_colour as author_colour, u2.user_id as author_id, t.topic_id, t.topic_title, f.forum_id, f.forum_name', 'FROM' => array(REPORTS_TABLE => 'r', REPORTS_REASONS_TABLE => 'rr', TOPICS_TABLE => 't', USERS_TABLE => array('u', 'u2'), POSTS_TABLE => 'p'), 'LEFT_JOIN' => array(array('FROM' => array(FORUMS_TABLE => 'f'), 'ON' => 'f.forum_id = p.forum_id')), 'WHERE' => 'r.post_id = p.post_id
						AND r.pm_id = 0
						AND r.report_closed = 0
						AND r.reason_id = rr.reason_id
						AND p.topic_id = t.topic_id
						AND r.user_id = u.user_id
						AND p.poster_id = u2.user_id
						AND ' . $db->sql_in_set('p.forum_id', $forum_list), 'ORDER_BY' => 'p.post_time DESC, p.post_id DESC');
                /**
                 * Alter sql query to get latest reported posts
                 *
                 * @event core.mcp_front_reports_listing_query_before
                 * @var	int		sql_ary						Associative array with the query to be executed
                 * @var	array	forum_list					List of forums that contain the posts
                 * @since 3.1.0-RC3
                 */
                $vars = array('sql_ary', 'forum_list');
                extract($phpbb_dispatcher->trigger_event('core.mcp_front_reports_listing_query_before', compact($vars)));
                $sql = $db->sql_build_query('SELECT', $sql_ary);
                $result = $db->sql_query_limit($sql, 5);
                while ($row = $db->sql_fetchrow($result)) {
                    $template->assign_block_vars('report', array('U_POST_DETAILS' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'f=' . $row['forum_id'] . '&amp;p=' . $row['post_id'] . "&amp;i=reports&amp;mode=report_details"), 'U_MCP_FORUM' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'f=' . $row['forum_id'] . "&amp;i={$id}&amp;mode=forum_view"), 'U_MCP_TOPIC' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'f=' . $row['forum_id'] . '&amp;t=' . $row['topic_id'] . "&amp;i={$id}&amp;mode=topic_view"), 'U_FORUM' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $row['forum_id']), 'U_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $row['forum_id'] . '&amp;t=' . $row['topic_id']), 'REPORTER_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'REPORTER' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']), 'REPORTER_COLOUR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), 'U_REPORTER' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']), 'AUTHOR_FULL' => get_username_string('full', $row['author_id'], $row['author_name'], $row['author_colour']), 'AUTHOR' => get_username_string('username', $row['author_id'], $row['author_name'], $row['author_colour']), 'AUTHOR_COLOUR' => get_username_string('colour', $row['author_id'], $row['author_name'], $row['author_colour']), 'U_AUTHOR' => get_username_string('profile', $row['author_id'], $row['author_name'], $row['author_colour']), 'FORUM_NAME' => $row['forum_name'], 'TOPIC_TITLE' => $row['topic_title'], 'SUBJECT' => $row['post_subject'] ? $row['post_subject'] : $user->lang['NO_SUBJECT'], 'REPORT_TIME' => $user->format_date($row['report_time']), 'POST_TIME' => $user->format_date($row['post_time']), 'ATTACH_ICON_IMG' => $auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id']) && $row['post_attachment'] ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : ''));
                }
                $db->sql_freeresult($result);
            }
            $template->assign_vars(array('L_REPORTS_TOTAL' => $user->lang('REPORTS_TOTAL', (int) $total), 'S_HAS_REPORTS' => $total != 0));
        }
    }
    // Latest 5 reported PMs
    if ($module->loaded('pm_reports') && $auth->acl_get('m_pm_report')) {
        $template->assign_var('S_SHOW_PM_REPORTS', true);
        $user->add_lang(array('ucp'));
        $sql = 'SELECT COUNT(r.report_id) AS total
			FROM ' . REPORTS_TABLE . ' r, ' . PRIVMSGS_TABLE . ' p
			WHERE r.post_id = 0
				AND r.pm_id = p.msg_id
				AND r.report_closed = 0';
        $result = $db->sql_query($sql);
        $total = (int) $db->sql_fetchfield('total');
        $db->sql_freeresult($result);
        if ($total) {
            include $phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx;
            $sql_ary = array('SELECT' => 'r.report_id, r.report_time, p.msg_id, p.message_subject, p.message_time, p.to_address, p.bcc_address, p.message_attachment, u.username, u.username_clean, u.user_colour, u.user_id, u2.username as author_name, u2.username_clean as author_name_clean, u2.user_colour as author_colour, u2.user_id as author_id', 'FROM' => array(REPORTS_TABLE => 'r', REPORTS_REASONS_TABLE => 'rr', USERS_TABLE => array('u', 'u2'), PRIVMSGS_TABLE => 'p'), 'WHERE' => 'r.pm_id = p.msg_id
					AND r.post_id = 0
					AND r.report_closed = 0
					AND r.reason_id = rr.reason_id
					AND r.user_id = u.user_id
					AND p.author_id = u2.user_id', 'ORDER_BY' => 'p.message_time DESC');
            $sql = $db->sql_build_query('SELECT', $sql_ary);
            $result = $db->sql_query_limit($sql, 5);
            $pm_by_id = $pm_list = 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);
            $address_list = get_recipient_strings($pm_by_id);
            foreach ($pm_list as $message_id) {
                $row = $pm_by_id[$message_id];
                $template->assign_block_vars('pm_report', array('U_PM_DETAILS' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'r=' . $row['report_id'] . "&amp;i=pm_reports&amp;mode=pm_report_details"), 'REPORTER_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'REPORTER' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']), 'REPORTER_COLOUR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), 'U_REPORTER' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']), 'PM_AUTHOR_FULL' => get_username_string('full', $row['author_id'], $row['author_name'], $row['author_colour']), 'PM_AUTHOR' => get_username_string('username', $row['author_id'], $row['author_name'], $row['author_colour']), 'PM_AUTHOR_COLOUR' => get_username_string('colour', $row['author_id'], $row['author_name'], $row['author_colour']), 'U_PM_AUTHOR' => get_username_string('profile', $row['author_id'], $row['author_name'], $row['author_colour']), 'PM_SUBJECT' => $row['message_subject'], 'REPORT_TIME' => $user->format_date($row['report_time']), 'PM_TIME' => $user->format_date($row['message_time']), 'RECIPIENTS' => implode(', ', $address_list[$row['msg_id']]), 'ATTACH_ICON_IMG' => $auth->acl_get('u_download') && $row['message_attachment'] ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : ''));
            }
        }
        $template->assign_vars(array('L_PM_REPORTS_TOTAL' => $user->lang('PM_REPORTS_TOTAL', (int) $total), 'S_HAS_PM_REPORTS' => $total != 0));
    }
    // Latest 5 logs
    if ($module->loaded('logs')) {
        $forum_list = array_values(array_intersect(get_forum_list('f_read'), get_forum_list('m_')));
        if (!empty($forum_list)) {
            $log_count = false;
            $log = array();
            view_log('mod', $log, $log_count, 5, 0, $forum_list);
            foreach ($log as $row) {
                $template->assign_block_vars('log', array('USERNAME' => $row['username_full'], 'IP' => $row['ip'], 'TIME' => $user->format_date($row['time']), 'ACTION' => $row['action'], 'U_VIEW_TOPIC' => !empty($row['viewtopic']) ? $row['viewtopic'] : '', 'U_VIEWLOGS' => !empty($row['viewlogs']) ? $row['viewlogs'] : ''));
            }
        }
        $template->assign_vars(array('S_SHOW_LOGS' => !empty($forum_list) ? true : false, 'S_HAS_LOGS' => !empty($log) ? true : false));
    }
    $template->assign_var('S_MCP_ACTION', append_sid("{$phpbb_root_path}mcp.{$phpEx}"));
    make_jumpbox(append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=main&amp;mode=forum_view'), 0, false, 'm_', true);
}
示例#24
0
	if ($total == 0)
	{
		$_CLASS['core_template']->assign_array(array(
			'L_REPORTS_TOTAL'	=>	$_CLASS['core_user']->lang['REPORTS_ZERO_TOTAL'],
			'S_HAS_REPORTS'		=>	false)
		);
	}
	else
	{
		$_CLASS['core_template']->assign_array(array(
			'L_REPORTS_TOTAL'	=> ($total == 1) ? $_CLASS['core_user']->lang['REPORT_TOTAL'] : sprintf($_CLASS['core_user']->lang['REPORTS_TOTAL'], $total),
			'S_HAS_REPORTS'		=> true)
		);
	}
}
*/
$forum_list_log = get_forum_list(array('m_', 'a_general'));
// Add forum_id 0 for global announcements
$forum_list_log[] = 0;
$log_count = 0;
$log = array();
view_log('mod', $log, $log_count, 5, 0, $forum_list_log);
foreach ($log as $row) {
    $_CLASS['core_template']->assign_vars_array('log', array('USERNAME' => $row['username'], 'IP' => $row['ip'], 'TIME' => $_CLASS['core_user']->format_date($row['time']), 'ACTION' => $row['action'], 'U_VIEWTOPIC' => $row['viewtopic'], 'U_VIEWLOGS' => $row['viewlogs']));
}
$_CLASS['core_template']->assign_array(array('S_SHOW_LOGS' => true, 'S_HAS_LOGS' => !empty($log)));
$_CLASS['core_template']->assign('S_MCP_ACTION', generate_link($url));
make_jumpbox(generate_link($url . '&amp;mode=forum_view'), 0, false, 'm_');
page_header();
$_CLASS['core_display']->display($_CLASS['core_user']->get_lang('MCP'), 'modules/Forums/mcp_front.html');
示例#25
0
    function main($id, $mode)
    {
        global $auth, $db, $user, $template, $cache;
        global $config, $phpbb_root_path, $phpEx, $action, $phpbb_container, $phpbb_dispatcher;
        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, r.reported_post_text, r.reported_post_uid, r.reported_post_bitfield, r.reported_post_enable_magic_url, r.reported_post_enable_smilies, r.reported_post_enable_bbcode, 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');
                }
                $phpbb_notifications = $phpbb_container->get('notification_manager');
                $phpbb_notifications->mark_notifications_read('notification.type.report_post', $post_id, $user->data['user_id']);
                if (!$report_id && $report['report_closed']) {
                    trigger_error('REPORT_CLOSED');
                }
                $post_id = $report['post_id'];
                $report_id = $report['report_id'];
                $parse_post_flags = $report['reported_post_enable_bbcode'] ? OPTION_FLAG_BBCODE : 0;
                $parse_post_flags += $report['reported_post_enable_smilies'] ? OPTION_FLAG_SMILIES : 0;
                $parse_post_flags += $report['reported_post_enable_magic_url'] ? OPTION_FLAG_LINKS : 0;
                $post_info = phpbb_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'], 'REPORTED_POST_ID' => $post_id));
                }
                $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;
                $message = generate_text_for_display($report['reported_post_text'], $report['reported_post_uid'], $report['reported_post_bitfield'], $parse_post_flags, false);
                $report['report_text'] = make_clickable(bbcode_nl2br($report['report_text']));
                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
							AND filetime <= ' . (int) $report['report_time'] . '
						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&amp;mode=report_details&amp;f=' . $post_info['forum_id'] . '&amp;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_visibility'] == ITEM_UNAPPROVED || $post_info['post_visibility'] == ITEM_REAPPROVE, 'S_POST_LOCKED' => $post_info['post_edit_locked'], 'S_REPORT_CLOSED' => $report['report_closed'], 'S_USER_NOTES' => true, 'U_EDIT' => $auth->acl_get('m_edit', $post_info['forum_id']) ? append_sid("{$phpbb_root_path}posting.{$phpEx}", "mode=edit&amp;f={$post_info['forum_id']}&amp;p={$post_info['post_id']}") : '', 'U_MCP_APPROVE' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue&amp;mode=approve_details&amp;f=' . $post_info['forum_id'] . '&amp;p=' . $post_id), 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=reports&amp;mode=report_details&amp;f=' . $post_info['forum_id'] . '&amp;p=' . $post_id), 'U_MCP_REPORTER_NOTES' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=notes&amp;mode=user_notes&amp;u=' . $report['user_id']), 'U_MCP_USER_NOTES' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=notes&amp;mode=user_notes&amp;u=' . $post_info['user_id']), 'U_MCP_WARN_REPORTER' => $auth->acl_get('m_warn') ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=warn&amp;mode=warn_user&amp;u=' . $report['user_id']) : '', 'U_MCP_WARN_USER' => $auth->acl_get('m_warn') ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=warn&amp;mode=warn_user&amp;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'] . '&amp;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'] . '&amp;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'] ? '&amp;mode=reports' : '&amp;mode=reports_closed') . '&amp;start=' . $start . '&amp;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 . '&amp;r=' . $report_id . '&amp;p=' . $post_id . '&amp;f=' . $forum_id . '&amp;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 = phpbb_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_approved) 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_approved'] = (int) $db->sql_fetchfield('sum_forum_topics');
                    $db->sql_freeresult($result);
                } else {
                    $forum_info = phpbb_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);
                }
                $forum_list[] = 0;
                $forum_data = array();
                $pagination = $phpbb_container->get('pagination');
                $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('&nbsp; &nbsp;', $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();
                phpbb_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_approved'] : $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}";
                /**
                 * Alter sql query to get report id of all reports for requested forum and topic or just forum
                 *
                 * @event core.mcp_reports_get_reports_query_before
                 * @var	string	sql						String with the query to be executed
                 * @var	array	forum_list				List of forums that contain the posts
                 * @var	int		topic_id				topic_id in the page request
                 * @var	string	limit_time_sql			String with the SQL code to limit the time interval of the post (Note: May be empty string)
                 * @var	string	sort_order_sql			String with the ORDER BY SQL code used in this query
                 * @since 3.1.0-RC4
                 */
                $vars = array('sql', 'forum_list', 'topic_id', 'limit_time_sql', 'sort_order_sql');
                extract($phpbb_dispatcher->trigger_event('core.mcp_reports_get_reports_query_before', compact($vars)));
                $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, p.post_attachment, 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)) {
                        $template->assign_block_vars('postrow', array('U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $row['forum_id']), 'U_VIEWPOST' => append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $row['forum_id'] . '&amp;p=' . $row['post_id']) . '#p' . $row['post_id'], 'U_VIEW_DETAILS' => append_sid("{$phpbb_root_path}mcp.{$phpEx}", "i=reports&amp;start={$start}&amp;mode=report_details&amp;f={$row['forum_id']}&amp;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' => $forum_data[$row['forum_id']]['forum_name'], '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'], 'ATTACH_ICON_IMG' => $auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id']) && $row['post_attachment'] ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : ''));
                    }
                    $db->sql_freeresult($result);
                    unset($report_ids, $row);
                }
                $base_url = $this->u_action . "&amp;f={$forum_id}&amp;t={$topic_id}&amp;st={$sort_days}&amp;sk={$sort_key}&amp;sd={$sort_dir}";
                $pagination->generate_template_pagination($base_url, 'pagination', 'start', $total, $config['topics_per_page'], $start);
                // 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, 'TOPIC_ID' => $topic_id, 'TOTAL' => $total, 'TOTAL_REPORTS' => $user->lang('LIST_REPORTS', (int) $total)));
                $this->tpl_name = 'mcp_reports';
                break;
        }
    }
示例#26
0
function light_draw_my_forums()
{
    $webtag = get_webtag();
    forum_check_webtag_available($webtag);
    if (isset($_GET['page']) && is_numeric($_GET['page'])) {
        $page = $_GET['page'];
    } else {
        $page = 1;
    }
    if (isset($_GET['webtag_error']) && strlen(trim($_GET['webtag_error'])) > 0) {
        light_html_display_error_msg(gettext("Invalid forum or forum is not available"));
    }
    if (session::logged_in()) {
        $forums_array = get_my_forums(FORUMS_SHOW_ALL, $page);
        if (isset($forums_array['forums_array']) && sizeof($forums_array['forums_array']) > 0) {
            foreach ($forums_array['forums_array'] as $forum) {
                echo "<div class=\"forum\">\n";
                echo "<h3><a href=\"lthread_list.php?webtag={$forum['WEBTAG']}\">{$forum['FORUM_NAME']}</a></h3>\n";
                echo "<div class=\"forum_inner\">\n";
                echo "<div class=\"forum_info\">", $forum['FORUM_DESC'], "</div>";
                echo "<ul>\n";
                echo "<li>\n";
                echo "<span class=\"forum_messages\">";
                if (isset($forum['UNREAD_TO_ME']) && $forum['UNREAD_TO_ME'] > 0) {
                    if (isset($forum['UNREAD_MESSAGES']) && is_numeric($forum['UNREAD_MESSAGES']) && $forum['UNREAD_MESSAGES'] > 0) {
                        echo sprintf(gettext("%s Unread Messages"), format_number($forum['UNREAD_MESSAGES'])), " (", sprintf(gettext("%s Unread &quot;To: Me&quot;"), format_number($forum['UNREAD_TO_ME'])), ")\n";
                    } else {
                        echo sprintf(gettext("%s Unread &quot;To: Me&quot;"), format_number($forum['UNREAD_TO_ME']));
                    }
                } else {
                    if (isset($forum['UNREAD_MESSAGES']) && is_numeric($forum['UNREAD_MESSAGES']) && $forum['UNREAD_MESSAGES'] > 0) {
                        echo sprintf(gettext("%s Unread Messages"), format_number($forum['UNREAD_MESSAGES']));
                    } else {
                        echo gettext("No Unread Messages");
                    }
                }
                echo "</span>\n";
                echo "</li>\n";
                echo "<li>";
                if (isset($forum['LAST_VISIT']) && $forum['LAST_VISIT'] > 0) {
                    echo "<span class=\"forum_last_visit\">", gettext("Last Visited"), ": ", format_date_time($forum['LAST_VISIT']), "</span>\n";
                } else {
                    echo "<span class=\"forum_last_visit\">", gettext("Last Visited"), ": ", gettext("Never"), "</span>\n";
                }
                echo "</li>\n";
                echo "</ul>\n";
                echo "</div>\n";
                echo "</div>\n";
            }
            html_page_links("lforums.php?webtag={$webtag}", $page, $forums_array['forums_count'], 10);
        } else {
            echo "<h3>", gettext("There are no forums available. Please login to view your forums."), "</h3>\n";
        }
    } else {
        $forums_array = get_forum_list($page);
        if (isset($forums_array['forums_array']) && sizeof($forums_array['forums_array']) > 0) {
            foreach ($forums_array['forums_array'] as $forum) {
                echo "<div class=\"forum\">\n";
                echo "<h3><a href=\"lthread_list.php?webtag={$forum['WEBTAG']}\">{$forum['FORUM_NAME']}</a></h3>\n";
                echo "<div class=\"forum_inner\">\n";
                echo "<div class=\"forum_info\">", $forum['FORUM_DESC'], "</div>";
                echo "<ul>\n";
                echo "<li>\n";
                echo "<span class=\"forum_messages\">", format_number($forum['MESSAGES']), " ", gettext("Messages"), "</span>\n";
                echo "</li>\n";
                echo "</ul>\n";
                echo "</div>\n";
                echo "</div>\n";
            }
            html_page_links("lforums.php?webtag={$webtag}", $page, $forums_array['forums_count'], 10);
        } else {
            echo "<h3>", gettext("There are no forums available. Please login to view your forums."), "</h3>\n";
        }
    }
}