|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
*
|
|
|
ef5584 |
* @package mcp
|
|
|
ef5584 |
* @version $Id: mcp_logs.php 9029 2008-10-18 18:44:41Z toonarmy $
|
|
|
ef5584 |
* @copyright (c) 2005 phpBB Group
|
|
|
ef5584 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
|
|
ef5584 |
*
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* @ignore
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
if (!defined('IN_PHPBB'))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
exit;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* mcp_logs
|
|
|
ef5584 |
* Handling warning the users
|
|
|
ef5584 |
* @package mcp
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
class mcp_logs
|
|
|
ef5584 |
{
|
|
|
ef5584 |
var $u_action;
|
|
|
ef5584 |
var $p_master;
|
|
|
ef5584 |
|
|
|
ef5584 |
function mcp_logs(&$p_master)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$this->p_master = &$p_master;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
function main($id, $mode)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
global $auth, $db, $user, $template;
|
|
|
ef5584 |
global $config, $phpbb_root_path, $phpEx;
|
|
|
ef5584 |
|
|
|
ef5584 |
$user->add_lang('acp/common');
|
|
|
ef5584 |
|
|
|
ef5584 |
$action = request_var('action', array('' => ''));
|
|
|
ef5584 |
|
|
|
ef5584 |
if (is_array($action))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
list($action, ) = each($action);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$action = request_var('action', '');
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// Set up general vars
|
|
|
ef5584 |
$start = request_var('start', 0);
|
|
|
ef5584 |
$deletemark = ($action == 'del_marked') ? true : false;
|
|
|
ef5584 |
$deleteall = ($action == 'del_all') ? true : false;
|
|
|
ef5584 |
$marked = request_var('mark', array(0));
|
|
|
ef5584 |
|
|
|
ef5584 |
// Sort keys
|
|
|
ef5584 |
$sort_days = request_var('st', 0);
|
|
|
ef5584 |
$sort_key = request_var('sk', 't');
|
|
|
ef5584 |
$sort_dir = request_var('sd', 'd');
|
|
|
ef5584 |
|
|
|
ef5584 |
$this->tpl_name = 'mcp_logs';
|
|
|
ef5584 |
$this->page_title = 'MCP_LOGS';
|
|
|
ef5584 |
|
|
|
ef5584 |
$forum_list = array_values(array_intersect(get_forum_list('f_read'), get_forum_list('m_')));
|
|
|
ef5584 |
$forum_list[] = 0;
|
|
|
ef5584 |
|
|
|
ef5584 |
$forum_id = $topic_id = 0;
|
|
|
ef5584 |
|
|
|
ef5584 |
switch ($mode)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
case 'front':
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
|
|
|
ef5584 |
case 'forum_logs':
|
|
|
ef5584 |
$forum_id = request_var('f', 0);
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!in_array($forum_id, $forum_list))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error('NOT_AUTHORISED');
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$forum_list = array($forum_id);
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
|
|
|
ef5584 |
case 'topic_logs':
|
|
|
ef5584 |
$topic_id = request_var('t', 0);
|
|
|
ef5584 |
|
|
|
ef5584 |
$sql = 'SELECT forum_id
|
|
|
ef5584 |
FROM ' . TOPICS_TABLE . '
|
|
|
ef5584 |
WHERE topic_id = ' . $topic_id;
|
|
|
ef5584 |
$result = $db->sql_query($sql);
|
|
|
ef5584 |
$forum_id = (int) $db->sql_fetchfield('forum_id');
|
|
|
ef5584 |
$db->sql_freeresult($result);
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!in_array($forum_id, $forum_list))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error('NOT_AUTHORISED');
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$forum_list = array($forum_id);
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// Delete entries if requested and able
|
|
|
ef5584 |
if (($deletemark || $deleteall) && $auth->acl_get('a_clearlogs'))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if (confirm_box(true))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if ($deletemark && sizeof($marked))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$sql = 'DELETE FROM ' . LOG_TABLE . '
|
|
|
ef5584 |
WHERE log_type = ' . LOG_MOD . '
|
|
|
ef5584 |
AND ' . $db->sql_in_set('forum_id', $forum_list) . '
|
|
|
ef5584 |
AND ' . $db->sql_in_set('log_id', $marked);
|
|
|
ef5584 |
$db->sql_query($sql);
|
|
|
ef5584 |
|
|
|
ef5584 |
add_log('admin', 'LOG_CLEAR_MOD');
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else if ($deleteall)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$sql = 'DELETE FROM ' . LOG_TABLE . '
|
|
|
ef5584 |
WHERE log_type = ' . LOG_MOD . '
|
|
|
ef5584 |
AND ' . $db->sql_in_set('forum_id', $forum_list);
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($mode == 'topic_logs')
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$sql .= ' AND topic_id = ' . $topic_id;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
$db->sql_query($sql);
|
|
|
ef5584 |
|
|
|
ef5584 |
add_log('admin', 'LOG_CLEAR_MOD');
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
|
|
|
ef5584 |
'f' => $forum_id,
|
|
|
ef5584 |
't' => $topic_id,
|
|
|
ef5584 |
'start' => $start,
|
|
|
ef5584 |
'delmarked' => $deletemark,
|
|
|
ef5584 |
'delall' => $deleteall,
|
|
|
ef5584 |
'mark' => $marked,
|
|
|
ef5584 |
'st' => $sort_days,
|
|
|
ef5584 |
'sk' => $sort_key,
|
|
|
ef5584 |
'sd' => $sort_dir,
|
|
|
ef5584 |
'i' => $id,
|
|
|
ef5584 |
'mode' => $mode,
|
|
|
ef5584 |
'action' => request_var('action', array('' => ''))))
|
|
|
ef5584 |
);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// Sorting
|
|
|
ef5584 |
$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']);
|
|
|
ef5584 |
$sort_by_text = array('u' => $user->lang['SORT_USERNAME'], 't' => $user->lang['SORT_DATE'], 'i' => $user->lang['SORT_IP'], 'o' => $user->lang['SORT_ACTION']);
|
|
|
ef5584 |
$sort_by_sql = array('u' => 'u.username_clean', 't' => 'l.log_time', 'i' => 'l.log_ip', 'o' => 'l.log_operation');
|
|
|
ef5584 |
|
|
|
ef5584 |
$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
|
|
|
ef5584 |
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);
|
|
|
ef5584 |
|
|
|
ef5584 |
// Define where and sort sql for use in displaying logs
|
|
|
ef5584 |
$sql_where = ($sort_days) ? (time() - ($sort_days * 86400)) : 0;
|
|
|
ef5584 |
$sql_sort = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC');
|
|
|
ef5584 |
|
|
|
ef5584 |
// Grab log data
|
|
|
ef5584 |
$log_data = array();
|
|
|
ef5584 |
$log_count = 0;
|
|
|
ef5584 |
view_log('mod', $log_data, $log_count, $config['topics_per_page'], $start, $forum_list, $topic_id, 0, $sql_where, $sql_sort);
|
|
|
ef5584 |
|
|
|
ef5584 |
$template->assign_vars(array(
|
|
|
ef5584 |
'PAGE_NUMBER' => on_page($log_count, $config['topics_per_page'], $start),
|
|
|
ef5584 |
'TOTAL' => ($log_count == 1) ? $user->lang['TOTAL_LOG'] : sprintf($user->lang['TOTAL_LOGS'], $log_count),
|
|
|
ef5584 |
'PAGINATION' => generate_pagination($this->u_action . "&$u_sort_param", $log_count, $config['topics_per_page'], $start),
|
|
|
ef5584 |
|
|
|
ef5584 |
'L_TITLE' => $user->lang['MCP_LOGS'],
|
|
|
ef5584 |
|
|
|
ef5584 |
'U_POST_ACTION' => $this->u_action,
|
|
|
ef5584 |
'S_CLEAR_ALLOWED' => ($auth->acl_get('a_clearlogs')) ? true : false,
|
|
|
ef5584 |
'S_SELECT_SORT_DIR' => $s_sort_dir,
|
|
|
ef5584 |
'S_SELECT_SORT_KEY' => $s_sort_key,
|
|
|
ef5584 |
'S_SELECT_SORT_DAYS' => $s_limit_days,
|
|
|
ef5584 |
'S_LOGS' => ($log_count > 0),
|
|
|
ef5584 |
)
|
|
|
ef5584 |
);
|
|
|
ef5584 |
|
|
|
ef5584 |
foreach ($log_data as $row)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$data = array();
|
|
|
ef5584 |
|
|
|
ef5584 |
$checks = array('viewtopic', 'viewforum');
|
|
|
ef5584 |
foreach ($checks as $check)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if (isset($row[$check]) && $row[$check])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$data[] = '' . $user->lang['LOGVIEW_' . strtoupper($check)] . '';
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$template->assign_block_vars('log', array(
|
|
|
ef5584 |
'USERNAME' => $row['username_full'],
|
|
|
ef5584 |
'IP' => $row['ip'],
|
|
|
ef5584 |
'DATE' => $user->format_date($row['time']),
|
|
|
ef5584 |
'ACTION' => $row['action'],
|
|
|
ef5584 |
'DATA' => (sizeof($data)) ? implode(' | ', $data) : '',
|
|
|
ef5584 |
'ID' => $row['id'],
|
|
|
ef5584 |
)
|
|
|
ef5584 |
);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
?>
|