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

