Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 92 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
acp_logs | |
0.00% |
0 / 90 |
|
0.00% |
0 / 1 |
462 | |
0.00% |
0 / 1 |
main | |
0.00% |
0 / 90 |
|
0.00% |
0 / 1 |
462 |
1 | <?php |
2 | /** |
3 | * |
4 | * This file is part of the phpBB Forum Software package. |
5 | * |
6 | * @copyright (c) phpBB Limited <https://www.phpbb.com> |
7 | * @license GNU General Public License, version 2 (GPL-2.0) |
8 | * |
9 | * For full copyright and license information, please see |
10 | * the docs/CREDITS.txt file. |
11 | * |
12 | */ |
13 | |
14 | /** |
15 | * @ignore |
16 | */ |
17 | if (!defined('IN_PHPBB')) |
18 | { |
19 | exit; |
20 | } |
21 | |
22 | class acp_logs |
23 | { |
24 | public $u_action; |
25 | |
26 | function main($id, $mode) |
27 | { |
28 | global $user, $auth, $template, $phpbb_container; |
29 | global $config; |
30 | global $request; |
31 | |
32 | $user->add_lang('mcp'); |
33 | |
34 | // Set up general vars |
35 | $action = $request->variable('action', ''); |
36 | $forum_id = $request->variable('f', 0); |
37 | $start = $request->variable('start', 0); |
38 | $deletemark = $request->variable('delmarked', false, false, \phpbb\request\request_interface::POST); |
39 | $deleteall = $request->variable('delall', false, false, \phpbb\request\request_interface::POST); |
40 | $marked = $request->variable('mark', array(0)); |
41 | |
42 | // Sort keys |
43 | $sort_days = $request->variable('st', 0); |
44 | $sort_key = $request->variable('sk', 't'); |
45 | $sort_dir = $request->variable('sd', 'd'); |
46 | |
47 | $this->tpl_name = 'acp_logs'; |
48 | |
49 | /* @var $pagination \phpbb\pagination */ |
50 | $pagination = $phpbb_container->get('pagination'); |
51 | |
52 | // Delete entries if requested and able |
53 | if (($deleteall || ($deletemark && count($marked))) && $auth->acl_get('a_clearlogs')) |
54 | { |
55 | if (confirm_box(true)) |
56 | { |
57 | $conditions = array(); |
58 | |
59 | if ($deletemark && count($marked)) |
60 | { |
61 | $conditions['log_id'] = array('IN' => $marked); |
62 | } |
63 | |
64 | if ($deleteall) |
65 | { |
66 | if ($sort_days) |
67 | { |
68 | $conditions['log_time'] = array('>=', time() - ($sort_days * 86400)); |
69 | } |
70 | |
71 | $keywords = $request->variable('keywords', '', true); |
72 | $conditions['keywords'] = $keywords; |
73 | } |
74 | |
75 | /* @var $phpbb_log \phpbb\log\log_interface */ |
76 | $phpbb_log = $phpbb_container->get('log'); |
77 | $phpbb_log->delete($mode, $conditions); |
78 | } |
79 | else |
80 | { |
81 | confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( |
82 | 'f' => $forum_id, |
83 | 'start' => $start, |
84 | 'delmarked' => $deletemark, |
85 | 'delall' => $deleteall, |
86 | 'mark' => $marked, |
87 | 'st' => $sort_days, |
88 | 'sk' => $sort_key, |
89 | 'sd' => $sort_dir, |
90 | 'i' => $id, |
91 | 'mode' => $mode, |
92 | 'action' => $action)) |
93 | ); |
94 | } |
95 | } |
96 | |
97 | // Sorting |
98 | $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']); |
99 | $sort_by_text = array('u' => $user->lang['SORT_USERNAME'], 't' => $user->lang['SORT_DATE'], 'i' => $user->lang['SORT_IP'], 'o' => $user->lang['SORT_ACTION']); |
100 | $sort_by_sql = array('u' => 'u.username_clean', 't' => 'l.log_time', 'i' => 'l.log_ip', 'o' => 'l.log_operation'); |
101 | |
102 | $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; |
103 | 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); |
104 | |
105 | // Define where and sort sql for use in displaying logs |
106 | $sql_where = ($sort_days) ? (time() - ($sort_days * 86400)) : 0; |
107 | $sql_sort = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC'); |
108 | |
109 | $keywords = $request->variable('keywords', '', true); |
110 | $keywords_param = !empty($keywords) ? '&keywords=' . urlencode(html_entity_decode($keywords, ENT_COMPAT)) : ''; |
111 | |
112 | $l_title = $user->lang['ACP_' . strtoupper($mode) . '_LOGS']; |
113 | $l_title_explain = $user->lang['ACP_' . strtoupper($mode) . '_LOGS_EXPLAIN']; |
114 | |
115 | $this->page_title = $l_title; |
116 | |
117 | // Define forum list if we're looking @ mod logs |
118 | if ($mode == 'mod') |
119 | { |
120 | $forum_box = '<option value="0">' . $user->lang['ALL_FORUMS'] . '</option>' . make_forum_select($forum_id); |
121 | |
122 | $template->assign_vars(array( |
123 | 'S_SHOW_FORUMS' => true, |
124 | 'S_FORUM_BOX' => $forum_box) |
125 | ); |
126 | } |
127 | |
128 | // Grab log data |
129 | $log_data = array(); |
130 | $log_count = 0; |
131 | $start = view_log($mode, $log_data, $log_count, $config['topics_per_page'], $start, $forum_id, 0, 0, $sql_where, $sql_sort, $keywords); |
132 | |
133 | $base_url = $this->u_action . "&$u_sort_param$keywords_param"; |
134 | $pagination->generate_template_pagination($base_url, 'pagination', 'start', $log_count, $config['topics_per_page'], $start); |
135 | |
136 | $template->assign_vars(array( |
137 | 'L_TITLE' => $l_title, |
138 | 'L_EXPLAIN' => $l_title_explain, |
139 | 'U_ACTION' => $this->u_action . "&$u_sort_param$keywords_param&start=$start", |
140 | |
141 | 'S_LIMIT_DAYS' => $s_limit_days, |
142 | 'S_SORT_KEY' => $s_sort_key, |
143 | 'S_SORT_DIR' => $s_sort_dir, |
144 | 'S_CLEARLOGS' => $auth->acl_get('a_clearlogs'), |
145 | 'S_KEYWORDS' => $keywords, |
146 | ) |
147 | ); |
148 | |
149 | foreach ($log_data as $row) |
150 | { |
151 | $data = array(); |
152 | |
153 | $checks = array('viewpost', 'viewtopic', 'viewlogs', 'viewforum'); |
154 | foreach ($checks as $check) |
155 | { |
156 | if (isset($row[$check]) && $row[$check]) |
157 | { |
158 | $data[] = '<a href="' . $row[$check] . '">' . $user->lang['LOGVIEW_' . strtoupper($check)] . '</a>'; |
159 | } |
160 | } |
161 | |
162 | $template->assign_block_vars('log', array( |
163 | 'USERNAME' => $row['username_full'], |
164 | 'REPORTEE_USERNAME' => ($row['reportee_username'] && $row['user_id'] != $row['reportee_id']) ? $row['reportee_username_full'] : '', |
165 | |
166 | 'IP' => $row['ip'], |
167 | 'DATE' => $user->format_date($row['time']), |
168 | 'ACTION' => $row['action'], |
169 | 'DATA' => (count($data)) ? implode(' | ', $data) : '', |
170 | 'ID' => $row['id'], |
171 | ) |
172 | ); |
173 | } |
174 | } |
175 | } |