~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to www/php/phpBB3/includes/mcp/mcp_logs.php

  • Committer: William Grant
  • Date: 2009-02-23 23:47:02 UTC
  • mfrom: (1099.1.211 new-dispatch)
  • Revision ID: grantw@unimelb.edu.au-20090223234702-db4b1llly46ignwo
Merge from lp:~ivle-dev/ivle/new-dispatch.

Pretty much everything changes. Reread the setup docs. Backup your databases.
Every file is now in a different installed location, the configuration system
is rewritten, the dispatch system is rewritten, URLs are different, the
database is different, worksheets and exercises are no longer on the
filesystem, we use a templating engine, jail service protocols are rewritten,
we don't repeat ourselves, we have authorization rewritten, phpBB is gone,
and probably lots of other things that I cannot remember.

This is certainly the biggest commit I have ever made, and hopefully
the largest I ever will.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php
2
 
/**
3
 
*
4
 
* @package mcp
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
8
 
*
9
 
*/
10
 
 
11
 
/**
12
 
* @ignore
13
 
*/
14
 
if (!defined('IN_PHPBB'))
15
 
{
16
 
        exit;
17
 
}
18
 
 
19
 
/**
20
 
* mcp_logs
21
 
* Handling warning the users
22
 
* @package mcp
23
 
*/
24
 
class mcp_logs
25
 
{
26
 
        var $u_action;
27
 
        var $p_master;
28
 
 
29
 
        function mcp_logs(&$p_master)
30
 
        {
31
 
                $this->p_master = &$p_master;
32
 
        }
33
 
 
34
 
        function main($id, $mode)
35
 
        {
36
 
                global $auth, $db, $user, $template;
37
 
                global $config, $phpbb_root_path, $phpEx;
38
 
 
39
 
                $user->add_lang('acp/common');
40
 
 
41
 
                $action = request_var('action', array('' => ''));
42
 
 
43
 
                if (is_array($action))
44
 
                {
45
 
                        list($action, ) = each($action);
46
 
                }
47
 
                else
48
 
                {
49
 
                        $action = request_var('action', '');
50
 
                }
51
 
 
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));
57
 
 
58
 
                // Sort keys
59
 
                $sort_days      = request_var('st', 0);
60
 
                $sort_key       = request_var('sk', 't');
61
 
                $sort_dir       = request_var('sd', 'd');
62
 
 
63
 
                $this->tpl_name = 'mcp_logs';
64
 
                $this->page_title = 'MCP_LOGS';
65
 
 
66
 
                $forum_list = get_forum_list('m_');
67
 
                $forum_list[] = 0;
68
 
 
69
 
                $forum_id = $topic_id = 0;
70
 
 
71
 
                switch ($mode)
72
 
                {
73
 
                        case 'front':
74
 
                        break;
75
 
 
76
 
                        case 'forum_logs':
77
 
                                $forum_id = request_var('f', 0);
78
 
 
79
 
                                if (!in_array($forum_id, $forum_list))
80
 
                                {
81
 
                                        trigger_error('NOT_AUTHORISED');
82
 
                                }
83
 
 
84
 
                                $forum_list = array($forum_id);
85
 
                        break;
86
 
 
87
 
                        case 'topic_logs':
88
 
                                $topic_id = request_var('t', 0);
89
 
 
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);
96
 
 
97
 
                                if (!in_array($forum_id, $forum_list))
98
 
                                {
99
 
                                        trigger_error('NOT_AUTHORISED');
100
 
                                }
101
 
 
102
 
                                $forum_list = array($forum_id);
103
 
                        break;
104
 
                }
105
 
 
106
 
                // Delete entries if requested and able
107
 
                if (($deletemark || $deleteall) && $auth->acl_get('a_clearlogs'))
108
 
                {
109
 
                        if (confirm_box(true))
110
 
                        {
111
 
                                if ($deletemark && sizeof($marked))
112
 
                                {
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);
118
 
 
119
 
                                        add_log('admin', 'LOG_CLEAR_MOD');
120
 
                                }
121
 
                                else if ($deleteall)
122
 
                                {
123
 
                                        $sql = 'DELETE FROM ' . LOG_TABLE . '
124
 
                                                WHERE log_type = ' . LOG_MOD . '
125
 
                                                        AND ' . $db->sql_in_set('forum_id', $forum_list);
126
 
 
127
 
                                        if ($mode == 'topic_logs')
128
 
                                        {
129
 
                                                $sql .= ' AND topic_id = ' . $topic_id;
130
 
                                        }
131
 
                                        $db->sql_query($sql);
132
 
 
133
 
                                        add_log('admin', 'LOG_CLEAR_MOD');
134
 
                                }
135
 
                        }
136
 
                        else
137
 
                        {
138
 
                                confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
139
 
                                        'f'                     => $forum_id,
140
 
                                        't'                     => $topic_id,
141
 
                                        'start'         => $start,
142
 
                                        'delmarked'     => $deletemark,
143
 
                                        'delall'        => $deleteall,
144
 
                                        'mark'          => $marked,
145
 
                                        'st'            => $sort_days,
146
 
                                        'sk'            => $sort_key,
147
 
                                        'sd'            => $sort_dir,
148
 
                                        'i'                     => $id,
149
 
                                        'mode'          => $mode,
150
 
                                        'action'        => request_var('action', array('' => ''))))
151
 
                                );
152
 
                        }
153
 
                }
154
 
 
155
 
                // Sorting
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');
159
 
 
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);
162
 
 
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');
166
 
 
167
 
                // Grab log data
168
 
                $log_data = array();
169
 
                $log_count = 0;
170
 
                view_log('mod', $log_data, $log_count, $config['topics_per_page'], $start, $forum_list, $topic_id, 0, $sql_where, $sql_sort);
171
 
 
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 . "&amp;$u_sort_param", $log_count, $config['topics_per_page'], $start),
176
 
 
177
 
                        'L_TITLE'                       => $user->lang['MCP_LOGS'],
178
 
 
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),
185
 
                        )
186
 
                );
187
 
 
188
 
                foreach ($log_data as $row)
189
 
                {
190
 
                        $data = array();
191
 
                                
192
 
                        $checks = array('viewtopic', 'viewforum');
193
 
                        foreach ($checks as $check)
194
 
                        {
195
 
                                if (isset($row[$check]) && $row[$check])
196
 
                                {
197
 
                                        $data[] = '<a href="' . $row[$check] . '">' . $user->lang['LOGVIEW_' . strtoupper($check)] . '</a>';
198
 
                                }
199
 
                        }
200
 
 
201
 
                        $template->assign_block_vars('log', array(
202
 
                                'USERNAME'              => $row['username_full'],
203
 
                                'IP'                    => $row['ip'],
204
 
                                'DATE'                  => $user->format_date($row['time']),
205
 
                                'ACTION'                => $row['action'],
206
 
                                'DATA'                  => (sizeof($data)) ? implode(' | ', $data) : '',
207
 
                                'ID'                    => $row['id'],
208
 
                                )
209
 
                        );
210
 
                }
211
 
        }
212
 
}
213
 
 
214
 
?>
 
 
b'\\ No newline at end of file'