phpBB
Statistics
| Revision:

root / tags / milestone_3 / phpBB / ucp.php

History | View | Annotate | Download (5.6 kB)

1 4950 psotfx
<?php
2 5114 acydburn
/**
3 5114 acydburn
*
4 5114 acydburn
* @package ucp
5 5114 acydburn
* @version $Id$
6 5114 acydburn
* @copyright (c) 2005 phpBB Group
7 5114 acydburn
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
8 5114 acydburn
*
9 5114 acydburn
*/
10 3075 thefinn
11 5114 acydburn
/**
12 5114 acydburn
*/
13 3075 thefinn
define('IN_PHPBB', true);
14 3075 thefinn
$phpbb_root_path = './';
15 4473 psotfx
$phpEx = substr(strrchr(__FILE__, '.'), 1);
16 5254 acydburn
require($phpbb_root_path . 'common.'.$phpEx);
17 5254 acydburn
require($phpbb_root_path . 'includes/functions_user.'.$phpEx);
18 5254 acydburn
require($phpbb_root_path . 'includes/functions_module.'.$phpEx);
19 4906 acydburn
20 4950 psotfx
// Basic parameter data
21 5254 acydburn
$id         = request_var('i', '');
22 4950 psotfx
$mode        = request_var('mode', '');
23 4950 psotfx
24 4950 psotfx
if ($mode == 'login' || $mode == 'logout')
25 4906 acydburn
{
26 4906 acydburn
        define('IN_LOGIN', true);
27 4906 acydburn
}
28 3075 thefinn
29 4950 psotfx
// Start session management
30 5254 acydburn
$user->session_begin();
31 4950 psotfx
$auth->acl($user->data);
32 4950 psotfx
$user->setup('ucp');
33 4950 psotfx
34 5254 acydburn
$module = new p_master();
35 4950 psotfx
36 4020 psotfx
// Basic "global" modes
37 4003 psotfx
switch ($mode)
38 4003 psotfx
{
39 4003 psotfx
        case 'activate':
40 5254 acydburn
                $module->load('ucp', 'activate');
41 5254 acydburn
                $module->display($user->lang['UCP_ACTIVATE']);
42 4603 psotfx
                redirect("index.$phpEx$SID");
43 3650 psotfx
44 5254 acydburn
        break;
45 5254 acydburn
46 5114 acydburn
        case 'resend_act':
47 5254 acydburn
                $module->load('ucp', 'resend');
48 5254 acydburn
                $module->display($user->lang['UCP_RESEND']);
49 5254 acydburn
        break;
50 5114 acydburn
51 4583 psotfx
        case 'sendpassword':
52 5254 acydburn
                $module->load('ucp', 'remind');
53 5254 acydburn
                $module->display($user->lang['UCP_REMIND']);
54 5254 acydburn
        break;
55 4020 psotfx
56 4003 psotfx
        case 'register':
57 5117 acydburn
                if ($user->data['is_registered'] || isset($_REQUEST['not_agreed']))
58 4003 psotfx
                {
59 3431 thefinn
                        redirect("index.$phpEx$SID");
60 4003 psotfx
                }
61 3650 psotfx
62 5254 acydburn
                $module->load('ucp', 'register');
63 5254 acydburn
                $module->display($user->lang['UCP_REGISTER']);
64 5254 acydburn
        break;
65 3650 psotfx
66 4020 psotfx
        case 'confirm':
67 4020 psotfx
68 5254 acydburn
                $module->load('ucp', 'confirm');
69 5254 acydburn
                exit;
70 5254 acydburn
        break;
71 5254 acydburn
72 4003 psotfx
        case 'login':
73 5117 acydburn
                if ($user->data['is_registered'])
74 4003 psotfx
                {
75 3650 psotfx
                        redirect("index.$phpEx$SID");
76 4003 psotfx
                }
77 3650 psotfx
78 4970 psotfx
                login_box("index.$phpEx$SID");
79 4003 psotfx
                break;
80 4003 psotfx
81 4003 psotfx
        case 'logout':
82 4003 psotfx
                if ($user->data['user_id'] != ANONYMOUS)
83 4003 psotfx
                {
84 5175 psotfx
                        $user->session_kill();
85 4003 psotfx
                }
86 4003 psotfx
87 4970 psotfx
                meta_refresh(3, "index.$phpEx$SID");
88 4768 psotfx
89 5254 acydburn
                $message = $user->lang['LOGOUT_REDIRECT'] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . "{$phpbb_root_path}index.$phpEx$SID" . '">', '</a> ');
90 4768 psotfx
                trigger_error($message);
91 4003 psotfx
                break;
92 4904 acydburn
93 5114 acydburn
        case 'terms_of_use':
94 5114 acydburn
        case 'privacy_statement':
95 5114 acydburn
                break;
96 5114 acydburn
97 4904 acydburn
        case 'delete_cookies':
98 4904 acydburn
                // Delete Cookies with dynamic names (do NOT delete poll cookies)
99 4912 acydburn
                if (confirm_box(true))
100 4904 acydburn
                {
101 4912 acydburn
                        $set_time = time() - 31536000;
102 4912 acydburn
                        foreach ($_COOKIE as $cookie_name => $cookie_data)
103 4904 acydburn
                        {
104 4912 acydburn
                                $cookie_name = str_replace($config['cookie_name'] . '_', '', $cookie_name);
105 4984 acydburn
                                if (strpos($cookie_name, '_poll') === false)
106 4912 acydburn
                                {
107 4912 acydburn
                                        $user->set_cookie($cookie_name, '', $set_time);
108 4912 acydburn
                                }
109 4904 acydburn
                        }
110 4912 acydburn
                        $user->set_cookie('track', '', $set_time);
111 5183 psotfx
                        $user->set_cookie('u', '', $set_time);
112 5183 psotfx
                        $user->set_cookie('k', '', $set_time);
113 4912 acydburn
                        $user->set_cookie('sid', '', $set_time);
114 4904 acydburn
115 4912 acydburn
                        // We destroy the session here, the user will be logged out nevertheless
116 5199 acydburn
                        $user->session_kill();
117 4904 acydburn
118 4915 acydburn
                        meta_refresh(3, "{$phpbb_root_path}index.$phpEx$SID");
119 4904 acydburn
120 4915 acydburn
                        $message = $user->lang['COOKIES_DELETED'] . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], "<a href=\"{$phpbb_root_path}index.$phpEx$SID\">", '</a>');
121 4912 acydburn
                        trigger_error($message);
122 4912 acydburn
                }
123 4912 acydburn
                else
124 4912 acydburn
                {
125 4912 acydburn
                        confirm_box(false, 'DELETE_COOKIES', '');
126 4912 acydburn
                }
127 4915 acydburn
                redirect("index.$phpEx$SID");
128 4904 acydburn
                break;
129 3431 thefinn
}
130 3075 thefinn
131 4003 psotfx
// Only registered users can go beyond this point
132 5117 acydburn
if (!$user->data['is_registered'])
133 4003 psotfx
{
134 5117 acydburn
        if ($user->data['is_bot'])
135 4903 acydburn
        {
136 4915 acydburn
                redirect("index.$phpEx$SID");
137 4903 acydburn
        }
138 4950 psotfx
139 4970 psotfx
        login_box('', $user->lang['LOGIN_EXPLAIN_UCP']);
140 4003 psotfx
}
141 3650 psotfx
142 3650 psotfx
143 4522 psotfx
// Output listing of friends online
144 4768 psotfx
$update_time = $config['load_online_time'] * 60;
145 4768 psotfx
146 4974 psotfx
$sql = 'SELECT DISTINCT u.user_id, u.username, MAX(s.session_time) as online_time, MIN(s.session_viewonline) AS viewonline
147 4950 psotfx
        FROM ((' . ZEBRA_TABLE . ' z
148 4522 psotfx
        LEFT JOIN ' . SESSIONS_TABLE . ' s ON s.session_user_id = z.zebra_id), ' . USERS_TABLE . ' u)
149 4950 psotfx
        WHERE z.user_id = ' . $user->data['user_id'] . '
150 4950 psotfx
                AND z.friend = 1
151 4950 psotfx
                AND u.user_id = z.zebra_id
152 4522 psotfx
        GROUP BY z.zebra_id';
153 3591 thefinn
$result = $db->sql_query($sql);
154 3431 thefinn
155 3650 psotfx
while ($row = $db->sql_fetchrow($result))
156 3591 thefinn
{
157 4522 psotfx
        $which = (time() - $update_time < $row['online_time']) ? 'online' : 'offline';
158 3996 psotfx
159 4522 psotfx
        $template->assign_block_vars("friends_{$which}", array(
160 5138 acydburn
                'U_PROFILE'        => "{$phpbb_root_path}memberlist.$phpEx$SID&amp;mode=viewprofile&amp;u=" . $row['user_id'],
161 4950 psotfx
162 4883 acydburn
                'USER_ID'        => $row['user_id'],
163 4522 psotfx
                'USERNAME'        => $row['username'])
164 3650 psotfx
        );
165 3591 thefinn
}
166 3650 psotfx
$db->sql_freeresult($result);
167 3591 thefinn
168 4883 acydburn
// Output PM_TO box if message composing
169 4891 acydburn
if ($mode == 'compose' && request_var('action', '') != 'edit')
170 4883 acydburn
{
171 4883 acydburn
        if ($config['allow_mass_pm'])
172 4883 acydburn
        {
173 4950 psotfx
                $sql = 'SELECT group_id, group_name, group_type
174 4950 psotfx
                        FROM ' . GROUPS_TABLE . '
175 4883 acydburn
                        WHERE group_type NOT IN (' . GROUP_HIDDEN . ', ' . GROUP_CLOSED . ')
176 4883 acydburn
                                AND group_receive_pm = 1
177 4883 acydburn
                        ORDER BY group_type DESC';
178 4883 acydburn
                $result = $db->sql_query($sql);
179 3591 thefinn
180 4883 acydburn
                $group_options = '';
181 4883 acydburn
                while ($row = $db->sql_fetchrow($result))
182 4883 acydburn
                {
183 4883 acydburn
                        $group_options .= '<option' . (($row['group_type'] == GROUP_SPECIAL) ? ' class="blue"' : '') . ' value="' . $row['group_id'] . '">' . (($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']) . '</option>';
184 4883 acydburn
                }
185 4883 acydburn
                $db->sql_freeresult($result);
186 4883 acydburn
        }
187 4883 acydburn
188 4883 acydburn
        $template->assign_vars(array(
189 4883 acydburn
                'S_SHOW_PM_BOX'                => true,
190 4883 acydburn
                'S_ALLOW_MASS_PM'        => ($config['allow_mass_pm']),
191 4883 acydburn
                'S_GROUP_OPTIONS'        => ($config['allow_mass_pm']) ? $group_options : '',
192 4883 acydburn
                'U_SEARCH_USER'                => "{$phpbb_root_path}memberlist.$phpEx$SID&amp;mode=searchuser&amp;form=post&amp;field=username_list")
193 4883 acydburn
        );
194 4883 acydburn
}
195 4883 acydburn
196 4522 psotfx
// Instantiate module system and generate list of available modules
197 5254 acydburn
$module->list_modules('ucp');
198 4522 psotfx
199 5254 acydburn
// Select the active module
200 5254 acydburn
$module->set_active($id, $mode);
201 5254 acydburn
202 4522 psotfx
// Load and execute the relevant module
203 5254 acydburn
$module->load_active();
204 4522 psotfx
205 5254 acydburn
// Assign data to the template engine for the list of modules
206 5254 acydburn
$module->assign_tpl_vars("ucp.$phpEx$SID");
207 5254 acydburn
208 5254 acydburn
// Generate the page
209 5254 acydburn
page_header($user->lang['UCP_MAIN']);
210 5254 acydburn
211 5254 acydburn
$template->set_filenames(array(
212 5254 acydburn
        'body' => $module->get_tpl_name())
213 5254 acydburn
);
214 5254 acydburn
215 5254 acydburn
page_footer();
216 5254 acydburn
217 5254 acydburn
/* Language override function for 'main' module
218 5254 acydburn
function main($mode, $langname)
219 5254 acydburn
{
220 5254 acydburn
        if ($mode == 'front')
221 5254 acydburn
        {
222 5254 acydburn
                return 'Frontpanel';
223 5254 acydburn
        }
224 5254 acydburn
}
225 5254 acydburn
*/
226 5254 acydburn
227 3075 thefinn
?>