2005-11-28 18:38:49 +00:00
|
|
|
<?php
|
2007-10-05 14:36:34 +00:00
|
|
|
/**
|
2005-11-28 18:38:49 +00:00
|
|
|
*
|
|
|
|
* @package acp
|
|
|
|
* @version $Id$
|
2007-10-05 14:36:34 +00:00
|
|
|
* @copyright (c) 2005 phpBB Group
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
2005-11-28 18:38:49 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2007-10-05 14:36:34 +00:00
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
*/
|
|
|
|
if (!defined('IN_PHPBB'))
|
|
|
|
{
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2005-11-28 18:38:49 +00:00
|
|
|
/**
|
|
|
|
* @package acp
|
|
|
|
*/
|
|
|
|
class acp_logs
|
|
|
|
{
|
2006-02-18 13:54:12 +00:00
|
|
|
var $u_action;
|
|
|
|
|
2005-11-28 18:38:49 +00:00
|
|
|
function main($id, $mode)
|
|
|
|
{
|
|
|
|
global $db, $user, $auth, $template, $cache;
|
2006-06-06 20:53:46 +00:00
|
|
|
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
|
2005-11-28 18:38:49 +00:00
|
|
|
|
|
|
|
$user->add_lang('mcp');
|
|
|
|
|
|
|
|
// Set up general vars
|
|
|
|
$action = request_var('action', '');
|
|
|
|
$forum_id = request_var('f', 0);
|
2009-07-27 12:43:57 +00:00
|
|
|
$topic_id = request_var('t', 0);
|
2005-11-28 18:38:49 +00:00
|
|
|
$start = request_var('start', 0);
|
2007-05-11 12:46:46 +00:00
|
|
|
$deletemark = (!empty($_POST['delmarked'])) ? true : false;
|
|
|
|
$deleteall = (!empty($_POST['delall'])) ? true : false;
|
2005-11-28 18:38:49 +00:00
|
|
|
$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 = 'acp_logs';
|
|
|
|
$this->log_type = constant('LOG_' . strtoupper($mode));
|
|
|
|
|
|
|
|
// Delete entries if requested and able
|
|
|
|
if (($deletemark || $deleteall) && $auth->acl_get('a_clearlogs'))
|
|
|
|
{
|
2007-03-23 12:18:09 +00:00
|
|
|
if (confirm_box(true))
|
2005-11-28 18:38:49 +00:00
|
|
|
{
|
2007-03-23 12:18:09 +00:00
|
|
|
$where_sql = '';
|
|
|
|
|
|
|
|
if ($deletemark && sizeof($marked))
|
2005-11-28 18:38:49 +00:00
|
|
|
{
|
2007-03-23 12:18:09 +00:00
|
|
|
$sql_in = array();
|
|
|
|
foreach ($marked as $mark)
|
|
|
|
{
|
|
|
|
$sql_in[] = $mark;
|
|
|
|
}
|
|
|
|
$where_sql = ' AND ' . $db->sql_in_set('log_id', $sql_in);
|
|
|
|
unset($sql_in);
|
2005-11-28 18:38:49 +00:00
|
|
|
}
|
|
|
|
|
2007-03-23 12:18:09 +00:00
|
|
|
if ($where_sql || $deleteall)
|
|
|
|
{
|
|
|
|
$sql = 'DELETE FROM ' . LOG_TABLE . "
|
|
|
|
WHERE log_type = {$this->log_type}
|
|
|
|
$where_sql";
|
|
|
|
$db->sql_query($sql);
|
2005-11-28 18:38:49 +00:00
|
|
|
|
2007-03-23 12:18:09 +00:00
|
|
|
add_log('admin', 'LOG_CLEAR_' . strtoupper($mode));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
|
|
|
|
'f' => $forum_id,
|
|
|
|
'start' => $start,
|
|
|
|
'delmarked' => $deletemark,
|
|
|
|
'delall' => $deleteall,
|
|
|
|
'mark' => $marked,
|
|
|
|
'st' => $sort_days,
|
|
|
|
'sk' => $sort_key,
|
|
|
|
'sd' => $sort_dir,
|
|
|
|
'i' => $id,
|
|
|
|
'mode' => $mode,
|
|
|
|
'action' => $action))
|
|
|
|
);
|
2005-11-28 18:38:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Sorting
|
2006-03-23 19:23:52 +00:00
|
|
|
$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']);
|
2005-11-28 18:38:49 +00:00
|
|
|
$sort_by_text = array('u' => $user->lang['SORT_USERNAME'], 't' => $user->lang['SORT_DATE'], 'i' => $user->lang['SORT_IP'], 'o' => $user->lang['SORT_ACTION']);
|
2006-11-24 14:59:26 +00:00
|
|
|
$sort_by_sql = array('u' => 'u.username_clean', 't' => 'l.log_time', 'i' => 'l.log_ip', 'o' => 'l.log_operation');
|
2005-11-28 18:38:49 +00:00
|
|
|
|
|
|
|
$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');
|
|
|
|
|
2009-07-18 19:19:38 +00:00
|
|
|
$log_operation = request_var('log_operation', '');
|
2009-08-10 16:04:44 +00:00
|
|
|
$log_operation_param = !empty($log_operation) ? '&log_operation=' . urlencode(htmlspecialchars_decode($log_operation)) : '';
|
2009-07-18 19:19:38 +00:00
|
|
|
$s_lang_keys = '<option value="">' . $user->lang['SHOW_ALL_OPERATIONS'] . '</option>';
|
|
|
|
|
|
|
|
switch ($mode)
|
|
|
|
{
|
|
|
|
case 'admin':
|
|
|
|
$log_type = LOG_ADMIN;
|
|
|
|
$sql_forum = '';
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'mod':
|
|
|
|
$log_type = LOG_MOD;
|
|
|
|
|
|
|
|
if ($topic_id)
|
|
|
|
{
|
|
|
|
$sql_forum = 'AND topic_id = ' . intval($topic_id);
|
|
|
|
}
|
|
|
|
else if (is_array($forum_id))
|
|
|
|
{
|
|
|
|
$sql_forum = 'AND ' . $db->sql_in_set('forum_id', array_map('intval', $forum_id));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$sql_forum = ($forum_id) ? 'AND forum_id = ' . intval($forum_id) : '';
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'user':
|
|
|
|
$log_type = LOG_USERS;
|
|
|
|
$sql_forum = 'AND reportee_id = ' . (int) $user_id;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'users':
|
|
|
|
$log_type = LOG_USERS;
|
|
|
|
$sql_forum = '';
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'critical':
|
|
|
|
$log_type = LOG_CRITICAL;
|
|
|
|
$sql_forum = '';
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$sql = "SELECT DISTINCT log_operation
|
|
|
|
FROM " . LOG_TABLE . "
|
|
|
|
WHERE log_type = $log_type
|
|
|
|
" . (($limit_days) ? "AND log_time >= $sql_where " : ' ') .
|
|
|
|
$sql_forum;
|
|
|
|
$result = $db->sql_query($sql);
|
2009-07-26 14:54:02 +00:00
|
|
|
|
2009-07-18 19:19:38 +00:00
|
|
|
while ($row = $db->sql_fetchrow($result))
|
|
|
|
{
|
2009-07-20 00:57:18 +00:00
|
|
|
if (empty($row['log_operation']))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2009-07-26 14:54:02 +00:00
|
|
|
|
2009-07-18 19:19:38 +00:00
|
|
|
$selected = ($log_operation == $row['log_operation']) ? ' selected="selected"' : '';
|
2009-07-26 14:54:02 +00:00
|
|
|
|
|
|
|
if (isset($user->lang[$row['log_operation']]))
|
|
|
|
{
|
|
|
|
$text = htmlspecialchars(strip_tags(str_replace('<br />', ' ', $user->lang[$row['log_operation']])), ENT_COMPAT, 'UTF-8');
|
|
|
|
|
|
|
|
// Fill in sprintf placeholders with translated placeholder text
|
|
|
|
if (substr_count($text, '%'))
|
|
|
|
{
|
|
|
|
$text = vsprintf($text, array_fill(0, substr_count($text, '%'), $user->lang['LOGS_PLACEHOLDER']));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$text = ucfirst(str_replace('_', ' ', strtolower($row['log_operation'])));
|
|
|
|
}
|
|
|
|
|
|
|
|
$s_lang_keys .= '<option value="' . $row['log_operation'] . '"' . $selected . '>' . $text . '</option>';
|
2009-07-18 19:19:38 +00:00
|
|
|
}
|
|
|
|
$db->sql_freeresult($result);
|
|
|
|
|
2005-11-28 18:38:49 +00:00
|
|
|
$l_title = $user->lang['ACP_' . strtoupper($mode) . '_LOGS'];
|
|
|
|
$l_title_explain = $user->lang['ACP_' . strtoupper($mode) . '_LOGS_EXPLAIN'];
|
|
|
|
|
|
|
|
$this->page_title = $l_title;
|
|
|
|
|
|
|
|
// Define forum list if we're looking @ mod logs
|
|
|
|
if ($mode == 'mod')
|
|
|
|
{
|
|
|
|
$forum_box = '<option value="0">' . $user->lang['ALL_FORUMS'] . '</option>' . make_forum_select($forum_id);
|
|
|
|
|
|
|
|
$template->assign_vars(array(
|
|
|
|
'S_SHOW_FORUMS' => true,
|
|
|
|
'S_FORUM_BOX' => $forum_box)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Grab log data
|
|
|
|
$log_data = array();
|
|
|
|
$log_count = 0;
|
2009-07-18 19:19:38 +00:00
|
|
|
view_log($mode, $log_data, $log_count, $config['topics_per_page'], $start, $forum_id, 0, 0, $sql_where, $sql_sort, $log_operation);
|
2005-11-28 18:38:49 +00:00
|
|
|
|
|
|
|
$template->assign_vars(array(
|
|
|
|
'L_TITLE' => $l_title,
|
|
|
|
'L_EXPLAIN' => $l_title_explain,
|
2006-02-18 13:54:12 +00:00
|
|
|
'U_ACTION' => $this->u_action,
|
2005-11-28 18:38:49 +00:00
|
|
|
|
|
|
|
'S_ON_PAGE' => on_page($log_count, $config['topics_per_page'], $start),
|
2009-08-10 16:04:44 +00:00
|
|
|
'PAGINATION' => generate_pagination($this->u_action . "&$u_sort_param$log_operation_param", $log_count, $config['topics_per_page'], $start, true),
|
2005-11-28 18:38:49 +00:00
|
|
|
|
|
|
|
'S_LIMIT_DAYS' => $s_limit_days,
|
|
|
|
'S_SORT_KEY' => $s_sort_key,
|
|
|
|
'S_SORT_DIR' => $s_sort_dir,
|
2009-07-18 19:19:38 +00:00
|
|
|
'S_LANG_KEYS' => $s_lang_keys,
|
2005-11-28 18:38:49 +00:00
|
|
|
'S_CLEARLOGS' => $auth->acl_get('a_clearlogs'),
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
foreach ($log_data as $row)
|
|
|
|
{
|
|
|
|
$data = array();
|
|
|
|
|
2005-11-30 17:48:06 +00:00
|
|
|
$checks = array('viewtopic', 'viewlogs', 'viewforum');
|
|
|
|
foreach ($checks as $check)
|
2005-11-28 18:38:49 +00:00
|
|
|
{
|
|
|
|
if (isset($row[$check]) && $row[$check])
|
|
|
|
{
|
|
|
|
$data[] = '<a href="' . $row[$check] . '">' . $user->lang['LOGVIEW_' . strtoupper($check)] . '</a>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$template->assign_block_vars('log', array(
|
2006-11-24 14:59:26 +00:00
|
|
|
'USERNAME' => $row['username_full'],
|
|
|
|
'REPORTEE_USERNAME' => ($row['reportee_username'] && $row['user_id'] != $row['reportee_id']) ? $row['reportee_username_full'] : '',
|
2006-04-26 18:10:57 +00:00
|
|
|
|
|
|
|
'IP' => $row['ip'],
|
|
|
|
'DATE' => $user->format_date($row['time']),
|
|
|
|
'ACTION' => $row['action'],
|
|
|
|
'DATA' => (sizeof($data)) ? implode(' | ', $data) : '',
|
|
|
|
'ID' => $row['id'],
|
2005-11-28 18:38:49 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|