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

« back to all changes in this revision

Viewing changes to www/php/phpBB3/ucp.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 ucp
5
 
* @version $Id: ucp.php,v 1.93 2007/10/05 14:30:07 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
 
define('IN_PHPBB', true);
15
 
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
16
 
$phpEx = substr(strrchr(__FILE__, '.'), 1);
17
 
require($phpbb_root_path . 'common.' . $phpEx);
18
 
require($phpbb_root_path . 'includes/functions_user.' . $phpEx);
19
 
require($phpbb_root_path . 'includes/functions_module.' . $phpEx);
20
 
 
21
 
// Basic parameter data
22
 
$id     = request_var('i', '');
23
 
$mode   = request_var('mode', '');
24
 
 
25
 
if ($mode == 'login' || $mode == 'logout' || $mode == 'confirm')
26
 
{
27
 
        define('IN_LOGIN', true);
28
 
}
29
 
 
30
 
// Start session management
31
 
$user->session_begin();
32
 
$auth->acl($user->data);
33
 
$user->setup('ucp');
34
 
 
35
 
// Setting a variable to let the style designer know where he is...
36
 
$template->assign_var('S_IN_UCP', true);
37
 
 
38
 
$module = new p_master();
39
 
 
40
 
// Basic "global" modes
41
 
switch ($mode)
42
 
{
43
 
        case 'activate':
44
 
                $module->load('ucp', 'activate');
45
 
                $module->display($user->lang['UCP_ACTIVATE']);
46
 
 
47
 
                redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
48
 
        break;
49
 
 
50
 
        case 'resend_act':
51
 
                $module->load('ucp', 'resend');
52
 
                $module->display($user->lang['UCP_RESEND']);
53
 
        break;
54
 
 
55
 
        case 'sendpassword':
56
 
                $module->load('ucp', 'remind');
57
 
                $module->display($user->lang['UCP_REMIND']);
58
 
        break;
59
 
 
60
 
        case 'register':
61
 
                if ($user->data['is_registered'] || isset($_REQUEST['not_agreed']))
62
 
                {
63
 
                        redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
64
 
                }
65
 
 
66
 
                $module->load('ucp', 'register');
67
 
                $module->display($user->lang['REGISTER']);
68
 
        break;
69
 
 
70
 
        case 'confirm':
71
 
                $module->load('ucp', 'confirm');
72
 
                exit_handler();
73
 
        break;
74
 
 
75
 
        case 'login':
76
 
                if ($user->data['is_registered'])
77
 
                {
78
 
                        redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
79
 
                }
80
 
 
81
 
                login_box(request_var('redirect', "index.$phpEx"));
82
 
        break;
83
 
 
84
 
        case 'logout':
85
 
                if ($user->data['user_id'] != ANONYMOUS && isset($_GET['sid']) && !is_array($_GET['sid']) && $_GET['sid'] === $user->session_id)
86
 
                {
87
 
                        $user->session_kill();
88
 
                        $user->session_begin();
89
 
                        $message = $user->lang['LOGOUT_REDIRECT'];
90
 
                }
91
 
                else
92
 
                {
93
 
                        $message = ($user->data['user_id'] == ANONYMOUS) ? $user->lang['LOGOUT_REDIRECT'] : $user->lang['LOGOUT_FAILED'];
94
 
                }
95
 
                meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx"));
96
 
        
97
 
                $message = $message . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a> ');
98
 
                trigger_error($message);
99
 
 
100
 
        break;
101
 
 
102
 
        case 'terms':
103
 
        case 'privacy':
104
 
 
105
 
                $message = ($mode == 'terms') ? 'TERMS_OF_USE_CONTENT' : 'PRIVACY_POLICY';
106
 
                $title = ($mode == 'terms') ? 'TERMS_USE' : 'PRIVACY';
107
 
 
108
 
                if (empty($user->lang[$message]))
109
 
                {
110
 
                        if ($user->data['is_registered'])
111
 
                        {
112
 
                                redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
113
 
                        }
114
 
 
115
 
                        login_box();
116
 
                }
117
 
 
118
 
                $template->set_filenames(array(
119
 
                        'body'          => 'ucp_agreement.html')
120
 
                );
121
 
 
122
 
                // Disable online list
123
 
                page_header($user->lang[$title], false);
124
 
 
125
 
                $template->assign_vars(array(
126
 
                        'S_AGREEMENT'                   => true,
127
 
                        'AGREEMENT_TITLE'               => $user->lang[$title],
128
 
                        'AGREEMENT_TEXT'                => sprintf($user->lang[$message], $config['sitename'], generate_board_url()),
129
 
                        'U_BACK'                                => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'),
130
 
                        'L_BACK'                                => $user->lang['BACK_TO_LOGIN'])
131
 
                );
132
 
 
133
 
                page_footer();
134
 
 
135
 
        break;
136
 
 
137
 
        case 'delete_cookies':
138
 
                
139
 
                // Delete Cookies with dynamic names (do NOT delete poll cookies)
140
 
                if (confirm_box(true))
141
 
                {
142
 
                        $set_time = time() - 31536000;
143
 
 
144
 
                        foreach ($_COOKIE as $cookie_name => $cookie_data)
145
 
                        {
146
 
                                $cookie_name = str_replace($config['cookie_name'] . '_', '', $cookie_name);
147
 
 
148
 
                                // Polls are stored as {cookie_name}_poll_{topic_id}, cookie_name_ got removed, therefore checking for poll_
149
 
                                if (strpos($cookie_name, 'poll_') !== 0)
150
 
                                {
151
 
                                        $user->set_cookie($cookie_name, '', $set_time);
152
 
                                }
153
 
                        }
154
 
 
155
 
                        $user->set_cookie('track', '', $set_time);
156
 
                        $user->set_cookie('u', '', $set_time);
157
 
                        $user->set_cookie('k', '', $set_time);
158
 
                        $user->set_cookie('sid', '', $set_time);
159
 
 
160
 
                        // We destroy the session here, the user will be logged out nevertheless
161
 
                        $user->session_kill();
162
 
                        $user->session_begin();
163
 
 
164
 
                        meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx"));
165
 
 
166
 
                        $message = $user->lang['COOKIES_DELETED'] . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a>');
167
 
                        trigger_error($message);
168
 
                }
169
 
                else
170
 
                {
171
 
                        confirm_box(false, 'DELETE_COOKIES', '');
172
 
                }
173
 
 
174
 
                redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
175
 
 
176
 
        break;
177
 
 
178
 
        case 'switch_perm':
179
 
 
180
 
                $user_id = request_var('u', 0);
181
 
 
182
 
                $sql = 'SELECT *
183
 
                        FROM ' . USERS_TABLE . '
184
 
                        WHERE user_id = ' . (int) $user_id;
185
 
                $result = $db->sql_query($sql);
186
 
                $user_row = $db->sql_fetchrow($result);
187
 
                $db->sql_freeresult($result);
188
 
 
189
 
                if (!$auth->acl_get('a_switchperm') || !$user_row || $user_id == $user->data['user_id'])
190
 
                {
191
 
                        redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
192
 
                }
193
 
 
194
 
                include($phpbb_root_path . 'includes/acp/auth.' . $phpEx);
195
 
 
196
 
                $auth_admin = new auth_admin();
197
 
                if (!$auth_admin->ghost_permissions($user_id, $user->data['user_id']))
198
 
                {
199
 
                        redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
200
 
                }
201
 
 
202
 
                add_log('admin', 'LOG_ACL_TRANSFER_PERMISSIONS', $user_row['username']);
203
 
 
204
 
                $message = sprintf($user->lang['PERMISSIONS_TRANSFERRED'], $user_row['username']) . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a>');
205
 
                trigger_error($message);
206
 
 
207
 
        break;
208
 
 
209
 
        case 'restore_perm':
210
 
 
211
 
                if (!$user->data['user_perm_from'] || !$auth->acl_get('a_switchperm'))
212
 
                {
213
 
                        redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
214
 
                }
215
 
 
216
 
                $auth->acl_cache($user->data);
217
 
 
218
 
                $sql = 'UPDATE ' . USERS_TABLE . "
219
 
                        SET user_perm_from = 0
220
 
                        WHERE user_id = " . $user->data['user_id'];
221
 
                $db->sql_query($sql);
222
 
 
223
 
                $sql = 'SELECT username
224
 
                        FROM ' . USERS_TABLE . '
225
 
                        WHERE user_id = ' . $user->data['user_perm_from'];
226
 
                $result = $db->sql_query($sql);
227
 
                $username = $db->sql_fetchfield('username');
228
 
                $db->sql_freeresult($result);
229
 
 
230
 
                add_log('admin', 'LOG_ACL_RESTORE_PERMISSIONS', $username);
231
 
 
232
 
                $message = $user->lang['PERMISSIONS_RESTORED'] . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a>');
233
 
                trigger_error($message);
234
 
 
235
 
        break;
236
 
}
237
 
 
238
 
// Only registered users can go beyond this point
239
 
if (!$user->data['is_registered'])
240
 
{
241
 
        if ($user->data['is_bot'])
242
 
        {
243
 
                redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
244
 
        }
245
 
 
246
 
        login_box('', $user->lang['LOGIN_EXPLAIN_UCP']);
247
 
}
248
 
 
249
 
// Instantiate module system and generate list of available modules
250
 
$module->list_modules('ucp');
251
 
 
252
 
// Check if the zebra module is set
253
 
if ($module->is_active('zebra', 'friends'))
254
 
{
255
 
        // Output listing of friends online
256
 
        $update_time = $config['load_online_time'] * 60;
257
 
 
258
 
        $sql = $db->sql_build_query('SELECT_DISTINCT', array(
259
 
                'SELECT'        => 'u.user_id, u.username, u.username_clean, u.user_colour, MAX(s.session_time) as online_time, MIN(s.session_viewonline) AS viewonline',
260
 
 
261
 
                'FROM'          => array(
262
 
                        USERS_TABLE             => 'u',
263
 
                        ZEBRA_TABLE             => 'z'
264
 
                ),
265
 
 
266
 
                'LEFT_JOIN'     => array(
267
 
                        array(
268
 
                                'FROM'  => array(SESSIONS_TABLE => 's'),
269
 
                                'ON'    => 's.session_user_id = z.zebra_id'
270
 
                        )
271
 
                ),
272
 
 
273
 
                'WHERE'         => 'z.user_id = ' . $user->data['user_id'] . '
274
 
                        AND z.friend = 1
275
 
                        AND u.user_id = z.zebra_id',
276
 
 
277
 
                'GROUP_BY'      => 'z.zebra_id, u.user_id, u.username_clean, u.user_colour, u.username',
278
 
 
279
 
                'ORDER_BY'      => 'u.username_clean ASC',
280
 
        ));
281
 
 
282
 
        $result = $db->sql_query($sql);
283
 
 
284
 
        while ($row = $db->sql_fetchrow($result))
285
 
        {
286
 
                $which = (time() - $update_time < $row['online_time'] && ($row['viewonline'] || $auth->acl_get('u_viewonline'))) ? 'online' : 'offline';
287
 
 
288
 
                $template->assign_block_vars("friends_{$which}", array(
289
 
                        'USER_ID'               => $row['user_id'],
290
 
 
291
 
                        'U_PROFILE'             => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']),
292
 
                        'USER_COLOUR'   => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']),
293
 
                        'USERNAME'              => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']),
294
 
                        'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']))
295
 
                );
296
 
        }
297
 
        $db->sql_freeresult($result);
298
 
}
299
 
 
300
 
// Do not display subscribed topics/forums if not allowed
301
 
if (!$config['allow_topic_notify'] && !$config['allow_forum_notify'])
302
 
{
303
 
        $module->set_display('main', 'subscribed', false);
304
 
}
305
 
 
306
 
// Select the active module
307
 
$module->set_active($id, $mode);
308
 
 
309
 
// Load and execute the relevant module
310
 
$module->load_active();
311
 
 
312
 
// Assign data to the template engine for the list of modules
313
 
$module->assign_tpl_vars(append_sid("{$phpbb_root_path}ucp.$phpEx"));
314
 
 
315
 
// Generate the page, do not display/query online list
316
 
$module->display($module->get_page_title(), false);
317
 
 
318
 
/**
319
 
* Function for assigning a template var if the zebra module got included
320
 
*/
321
 
function _module_zebra($mode, &$module_row)
322
 
{
323
 
        global $template;
324
 
 
325
 
        $template->assign_var('S_ZEBRA_ENABLED', true);
326
 
 
327
 
        if ($mode == 'friends')
328
 
        {
329
 
                $template->assign_var('S_ZEBRA_FRIENDS_ENABLED', true);
330
 
        }
331
 
 
332
 
        if ($mode == 'foes')
333
 
        {
334
 
                $template->assign_var('S_ZEBRA_FOES_ENABLED', true);
335
 
        }
336
 
}
337
 
 
338
 
?>
 
 
b'\\ No newline at end of file'