5
* @version $Id: mcp_logs.php,v 1.24 2007/10/05 14:36:33 acydburn Exp $
6
* @copyright (c) 2005 phpBB Group
7
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
14
if (!defined('IN_PHPBB'))
21
* Handling warning the users
29
function mcp_logs(&$p_master)
31
$this->p_master = &$p_master;
34
function main($id, $mode)
36
global $auth, $db, $user, $template;
37
global $config, $phpbb_root_path, $phpEx;
39
$user->add_lang('acp/common');
41
$action = request_var('action', array('' => ''));
43
if (is_array($action))
45
list($action, ) = each($action);
49
$action = request_var('action', '');
52
// Set up general vars
53
$start = request_var('start', 0);
54
$deletemark = ($action == 'del_marked') ? true : false;
55
$deleteall = ($action == 'del_all') ? true : false;
56
$marked = request_var('mark', array(0));
59
$sort_days = request_var('st', 0);
60
$sort_key = request_var('sk', 't');
61
$sort_dir = request_var('sd', 'd');
63
$this->tpl_name = 'mcp_logs';
64
$this->page_title = 'MCP_LOGS';
66
$forum_list = get_forum_list('m_');
69
$forum_id = $topic_id = 0;
77
$forum_id = request_var('f', 0);
79
if (!in_array($forum_id, $forum_list))
81
trigger_error('NOT_AUTHORISED');
84
$forum_list = array($forum_id);
88
$topic_id = request_var('t', 0);
90
$sql = 'SELECT forum_id
91
FROM ' . TOPICS_TABLE . '
92
WHERE topic_id = ' . $topic_id;
93
$result = $db->sql_query($sql);
94
$forum_id = (int) $db->sql_fetchfield('forum_id');
95
$db->sql_freeresult($result);
97
if (!in_array($forum_id, $forum_list))
99
trigger_error('NOT_AUTHORISED');
102
$forum_list = array($forum_id);
106
// Delete entries if requested and able
107
if (($deletemark || $deleteall) && $auth->acl_get('a_clearlogs'))
109
if (confirm_box(true))
111
if ($deletemark && sizeof($marked))
113
$sql = 'DELETE FROM ' . LOG_TABLE . '
114
WHERE log_type = ' . LOG_MOD . '
115
AND ' . $db->sql_in_set('forum_id', $forum_list) . '
116
AND ' . $db->sql_in_set('log_id', $marked);
117
$db->sql_query($sql);
119
add_log('admin', 'LOG_CLEAR_MOD');
123
$sql = 'DELETE FROM ' . LOG_TABLE . '
124
WHERE log_type = ' . LOG_MOD . '
125
AND ' . $db->sql_in_set('forum_id', $forum_list);
127
if ($mode == 'topic_logs')
129
$sql .= ' AND topic_id = ' . $topic_id;
131
$db->sql_query($sql);
133
add_log('admin', 'LOG_CLEAR_MOD');
138
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
142
'delmarked' => $deletemark,
143
'delall' => $deleteall,
150
'action' => request_var('action', array('' => ''))))
156
$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']);
157
$sort_by_text = array('u' => $user->lang['SORT_USERNAME'], 't' => $user->lang['SORT_DATE'], 'i' => $user->lang['SORT_IP'], 'o' => $user->lang['SORT_ACTION']);
158
$sort_by_sql = array('u' => 'u.username_clean', 't' => 'l.log_time', 'i' => 'l.log_ip', 'o' => 'l.log_operation');
160
$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
161
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);
163
// Define where and sort sql for use in displaying logs
164
$sql_where = ($sort_days) ? (time() - ($sort_days * 86400)) : 0;
165
$sql_sort = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC');
170
view_log('mod', $log_data, $log_count, $config['topics_per_page'], $start, $forum_list, $topic_id, 0, $sql_where, $sql_sort);
172
$template->assign_vars(array(
173
'PAGE_NUMBER' => on_page($log_count, $config['topics_per_page'], $start),
174
'TOTAL' => ($log_count == 1) ? $user->lang['TOTAL_LOG'] : sprintf($user->lang['TOTAL_LOGS'], $log_count),
175
'PAGINATION' => generate_pagination($this->u_action . "&$u_sort_param", $log_count, $config['topics_per_page'], $start),
177
'L_TITLE' => $user->lang['MCP_LOGS'],
179
'U_POST_ACTION' => $this->u_action,
180
'S_CLEAR_ALLOWED' => ($auth->acl_get('a_clearlogs')) ? true : false,
181
'S_SELECT_SORT_DIR' => $s_sort_dir,
182
'S_SELECT_SORT_KEY' => $s_sort_key,
183
'S_SELECT_SORT_DAYS' => $s_limit_days,
184
'S_LOGS' => ($log_count > 0),
188
foreach ($log_data as $row)
192
$checks = array('viewtopic', 'viewforum');
193
foreach ($checks as $check)
195
if (isset($row[$check]) && $row[$check])
197
$data[] = '<a href="' . $row[$check] . '">' . $user->lang['LOGVIEW_' . strtoupper($check)] . '</a>';
201
$template->assign_block_vars('log', array(
202
'USERNAME' => $row['username_full'],
204
'DATE' => $user->format_date($row['time']),
205
'ACTION' => $row['action'],
206
'DATA' => (sizeof($data)) ? implode(' | ', $data) : '',
b'\\ No newline at end of file'