Blame Extras/phpBB/3.0.4/includes/acp/acp_logs.php

4c79b5
4c79b5
/**
4c79b5
*
4c79b5
* @package acp
4c79b5
* @version $Id: acp_logs.php 8479 2008-03-29 00:22:48Z naderman $
4c79b5
* @copyright (c) 2005 phpBB Group
4c79b5
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
4c79b5
*
4c79b5
*/
4c79b5
4c79b5
/**
4c79b5
* @ignore
4c79b5
*/
4c79b5
if (!defined('IN_PHPBB'))
4c79b5
{
4c79b5
	exit;
4c79b5
}
4c79b5
4c79b5
/**
4c79b5
* @package acp
4c79b5
*/
4c79b5
class acp_logs
4c79b5
{
4c79b5
	var $u_action;
4c79b5
4c79b5
	function main($id, $mode)
4c79b5
	{
4c79b5
		global $db, $user, $auth, $template, $cache;
4c79b5
		global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
4c79b5
4c79b5
		$user->add_lang('mcp');
4c79b5
4c79b5
		// Set up general vars
4c79b5
		$action		= request_var('action', '');
4c79b5
		$forum_id	= request_var('f', 0);
4c79b5
		$start		= request_var('start', 0);
4c79b5
		$deletemark = (!empty($_POST['delmarked'])) ? true : false;
4c79b5
		$deleteall	= (!empty($_POST['delall'])) ? true : false;
4c79b5
		$marked		= request_var('mark', array(0));
4c79b5
4c79b5
		// Sort keys
4c79b5
		$sort_days	= request_var('st', 0);
4c79b5
		$sort_key	= request_var('sk', 't');
4c79b5
		$sort_dir	= request_var('sd', 'd');
4c79b5
4c79b5
		$this->tpl_name = 'acp_logs';
4c79b5
		$this->log_type = constant('LOG_' . strtoupper($mode));
4c79b5
4c79b5
		// Delete entries if requested and able
4c79b5
		if (($deletemark || $deleteall) && $auth->acl_get('a_clearlogs'))
4c79b5
		{
4c79b5
			if (confirm_box(true))
4c79b5
			{
4c79b5
				$where_sql = '';
4c79b5
4c79b5
				if ($deletemark && sizeof($marked))
4c79b5
				{
4c79b5
					$sql_in = array();
4c79b5
					foreach ($marked as $mark)
4c79b5
					{
4c79b5
						$sql_in[] = $mark;
4c79b5
					}
4c79b5
					$where_sql = ' AND ' . $db->sql_in_set('log_id', $sql_in);
4c79b5
					unset($sql_in);
4c79b5
				}
4c79b5
4c79b5
				if ($where_sql || $deleteall)
4c79b5
				{
4c79b5
					$sql = 'DELETE FROM ' . LOG_TABLE . "
4c79b5
						WHERE log_type = {$this->log_type}
4c79b5
						$where_sql";
4c79b5
					$db->sql_query($sql);
4c79b5
4c79b5
					add_log('admin', 'LOG_CLEAR_' . strtoupper($mode));
4c79b5
				}
4c79b5
			}
4c79b5
			else
4c79b5
			{
4c79b5
				confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
4c79b5
					'f'			=> $forum_id,
4c79b5
					'start'		=> $start,
4c79b5
					'delmarked'	=> $deletemark,
4c79b5
					'delall'	=> $deleteall,
4c79b5
					'mark'		=> $marked,
4c79b5
					'st'		=> $sort_days,
4c79b5
					'sk'		=> $sort_key,
4c79b5
					'sd'		=> $sort_dir,
4c79b5
					'i'			=> $id,
4c79b5
					'mode'		=> $mode,
4c79b5
					'action'	=> $action))
4c79b5
				);
4c79b5
			}
4c79b5
		}
4c79b5
4c79b5
		// Sorting
4c79b5
		$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']);
4c79b5
		$sort_by_text = array('u' => $user->lang['SORT_USERNAME'], 't' => $user->lang['SORT_DATE'], 'i' => $user->lang['SORT_IP'], 'o' => $user->lang['SORT_ACTION']);
4c79b5
		$sort_by_sql = array('u' => 'u.username_clean', 't' => 'l.log_time', 'i' => 'l.log_ip', 'o' => 'l.log_operation');
4c79b5
4c79b5
		$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
4c79b5
		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);
4c79b5
4c79b5
		// Define where and sort sql for use in displaying logs
4c79b5
		$sql_where = ($sort_days) ? (time() - ($sort_days * 86400)) : 0;
4c79b5
		$sql_sort = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC');
4c79b5
4c79b5
		$l_title = $user->lang['ACP_' . strtoupper($mode) . '_LOGS'];
4c79b5
		$l_title_explain = $user->lang['ACP_' . strtoupper($mode) . '_LOGS_EXPLAIN'];
4c79b5
4c79b5
		$this->page_title = $l_title;
4c79b5
4c79b5
		// Define forum list if we're looking @ mod logs
4c79b5
		if ($mode == 'mod')
4c79b5
		{
4c79b5
			$forum_box = '<option value="0">' . $user->lang['ALL_FORUMS'] . '</option>' . make_forum_select($forum_id);
4c79b5
			
4c79b5
			$template->assign_vars(array(
4c79b5
				'S_SHOW_FORUMS'			=> true,
4c79b5
				'S_FORUM_BOX'			=> $forum_box)
4c79b5
			);
4c79b5
		}
4c79b5
4c79b5
		// Grab log data
4c79b5
		$log_data = array();
4c79b5
		$log_count = 0;
4c79b5
		view_log($mode, $log_data, $log_count, $config['topics_per_page'], $start, $forum_id, 0, 0, $sql_where, $sql_sort);
4c79b5
4c79b5
		$template->assign_vars(array(
4c79b5
			'L_TITLE'		=> $l_title,
4c79b5
			'L_EXPLAIN'		=> $l_title_explain,
4c79b5
			'U_ACTION'		=> $this->u_action,
4c79b5
4c79b5
			'S_ON_PAGE'		=> on_page($log_count, $config['topics_per_page'], $start),
4c79b5
			'PAGINATION'	=> generate_pagination($this->u_action . "&$u_sort_param", $log_count, $config['topics_per_page'], $start, true),
4c79b5
4c79b5
			'S_LIMIT_DAYS'	=> $s_limit_days,
4c79b5
			'S_SORT_KEY'	=> $s_sort_key,
4c79b5
			'S_SORT_DIR'	=> $s_sort_dir,
4c79b5
			'S_CLEARLOGS'	=> $auth->acl_get('a_clearlogs'),
4c79b5
			)
4c79b5
		);
4c79b5
4c79b5
		foreach ($log_data as $row)
4c79b5
		{
4c79b5
			$data = array();
4c79b5
				
4c79b5
			$checks = array('viewtopic', 'viewlogs', 'viewforum');
4c79b5
			foreach ($checks as $check)
4c79b5
			{
4c79b5
				if (isset($row[$check]) && $row[$check])
4c79b5
				{
4c79b5
					$data[] = '' . $user->lang['LOGVIEW_' . strtoupper($check)] . '';
4c79b5
				}
4c79b5
			}
4c79b5
4c79b5
			$template->assign_block_vars('log', array(
4c79b5
				'USERNAME'			=> $row['username_full'],
4c79b5
				'REPORTEE_USERNAME'	=> ($row['reportee_username'] && $row['user_id'] != $row['reportee_id']) ? $row['reportee_username_full'] : '',
4c79b5
4c79b5
				'IP'				=> $row['ip'],
4c79b5
				'DATE'				=> $user->format_date($row['time']),
4c79b5
				'ACTION'			=> $row['action'],
4c79b5
				'DATA'				=> (sizeof($data)) ? implode(' | ', $data) : '',
4c79b5
				'ID'				=> $row['id'],
4c79b5
				)
4c79b5
			);
4c79b5
		}
4c79b5
	}
4c79b5
}
4c79b5
4c79b5
?>