Update code_sniffer build.xml file to be executable on our system
[phpbb.git] / phpBB / modules / acp / acp_logs.php
blobff847d36b5cb611bcdfc82940d9a403c7aa20ed3
1 <?php
2 /**
4 * @package acp
5 * @version $Id$
6 * @copyright (c) 2005 phpBB Group
7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
9 */
11 /**
12 * @ignore
14 if (!defined('IN_PHPBB'))
16 exit;
19 /**
20 * @package acp
22 class acp_logs
24 var $u_action;
26 function main($id, $mode)
28 phpbb::$user->add_lang('mcp');
30 // Set up general vars
31 $action = request_var('action', '');
32 $forum_id = request_var('f', 0);
33 $start = request_var('start', 0);
34 $deletemark = phpbb_request::variable('delmarked', false, false, phpbb_request::POST);
35 $deleteall = phpbb_request::variable('delall', false, false, phpbb_request::POST);
36 $marked = request_var('mark', array(0));
38 // Sort keys
39 $sort_days = request_var('st', 0);
40 $sort_key = request_var('sk', 't');
41 $sort_dir = request_var('sd', 'd');
43 $this->tpl_name = 'acp_logs';
44 $this->log_type = constant('LOG_' . strtoupper($mode));
46 // Delete entries if requested and able
47 if (($deletemark || $deleteall) && phpbb::$acl->acl_get('a_clearlogs'))
49 if (confirm_box(true))
51 $where_sql = '';
53 if ($deletemark && sizeof($marked))
55 $sql_in = array();
56 foreach ($marked as $mark)
58 $sql_in[] = $mark;
60 $where_sql = ' AND ' . phpbb::$db->sql_in_set('log_id', $sql_in);
61 unset($sql_in);
64 if ($where_sql || $deleteall)
66 $sql = 'DELETE FROM ' . LOG_TABLE . "
67 WHERE log_type = {$this->log_type}
68 $where_sql";
69 phpbb::$db->sql_query($sql);
71 add_log('admin', 'LOG_CLEAR_' . strtoupper($mode));
74 else
76 confirm_box(false, phpbb::$user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
77 'f' => $forum_id,
78 'start' => $start,
79 'delmarked' => $deletemark,
80 'delall' => $deleteall,
81 'mark' => $marked,
82 'st' => $sort_days,
83 'sk' => $sort_key,
84 'sd' => $sort_dir,
85 'i' => $id,
86 'mode' => $mode,
87 'action' => $action))
92 // Sorting
93 $limit_days = array(0 => phpbb::$user->lang['ALL_ENTRIES'], 1 => phpbb::$user->lang['1_DAY'], 7 => phpbb::$user->lang['7_DAYS'], 14 => phpbb::$user->lang['2_WEEKS'], 30 => phpbb::$user->lang['1_MONTH'], 90 => phpbb::$user->lang['3_MONTHS'], 180 => phpbb::$user->lang['6_MONTHS'], 365 => phpbb::$user->lang['1_YEAR']);
94 $sort_by_text = array('u' => phpbb::$user->lang['SORT_USERNAME'], 't' => phpbb::$user->lang['SORT_DATE'], 'i' => phpbb::$user->lang['SORT_IP'], 'o' => phpbb::$user->lang['SORT_ACTION']);
95 $sort_by_sql = array('u' => 'u.username_clean', 't' => 'l.log_time', 'i' => 'l.log_ip', 'o' => 'l.log_operation');
97 $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
98 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);
100 // Define where and sort sql for use in displaying logs
101 $sql_where = ($sort_days) ? (time() - ($sort_days * 86400)) : 0;
102 $sql_sort = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC');
104 $l_title = phpbb::$user->lang['ACP_' . strtoupper($mode) . '_LOGS'];
105 $l_title_explain = phpbb::$user->lang['ACP_' . strtoupper($mode) . '_LOGS_EXPLAIN'];
107 $this->page_title = $l_title;
109 // Define forum list if we're looking @ mod logs
110 if ($mode == 'mod')
112 $forum_box = '<option value="0">' . phpbb::$user->lang['ALL_FORUMS'] . '</option>' . make_forum_select($forum_id);
114 phpbb::$template->assign_vars(array(
115 'S_SHOW_FORUMS' => true,
116 'S_FORUM_BOX' => $forum_box,
120 // Grab log data
121 $log_data = array();
122 $log_count = 0;
123 view_log($mode, $log_data, $log_count, phpbb::$config['topics_per_page'], $start, $forum_id, 0, 0, $sql_where, $sql_sort);
125 phpbb::$template->assign_vars(array(
126 'L_TITLE' => $l_title,
127 'L_EXPLAIN' => $l_title_explain,
128 'U_ACTION' => $this->u_action,
130 'S_ON_PAGE' => on_page($log_count, phpbb::$config['topics_per_page'], $start),
131 'PAGINATION' => generate_pagination($this->u_action . "&amp;$u_sort_param", $log_count, phpbb::$config['topics_per_page'], $start, true),
133 'S_LIMIT_DAYS' => $s_limit_days,
134 'S_SORT_KEY' => $s_sort_key,
135 'S_SORT_DIR' => $s_sort_dir,
136 'S_CLEARLOGS' => phpbb::$acl->acl_get('a_clearlogs'),
139 foreach ($log_data as $row)
141 $data = array();
143 $checks = array('viewtopic', 'viewlogs', 'viewforum');
144 foreach ($checks as $check)
146 if (isset($row[$check]) && $row[$check])
148 $data[] = '<a href="' . $row[$check] . '">' . phpbb::$user->lang['LOGVIEW_' . strtoupper($check)] . '</a>';
152 phpbb::$template->assign_block_vars('log', array(
153 'USERNAME' => $row['username_full'],
154 'REPORTEE_USERNAME' => ($row['reportee_username'] && $row['user_id'] != $row['reportee_id']) ? $row['reportee_username_full'] : '',
156 'IP' => $row['ip'],
157 'DATE' => phpbb::$user->format_date($row['time']),
158 'ACTION' => $row['action'],
159 'DATA' => (sizeof($data)) ? implode(' | ', $data) : '',
160 'ID' => $row['id'],