1 | <?php
|
---|
2 | /**
|
---|
3 | *
|
---|
4 | * @package ucp
|
---|
5 | * @version $Id$
|
---|
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 | * ucp_activate
|
---|
21 | * User activation
|
---|
22 | * @package ucp
|
---|
23 | */
|
---|
24 | class ucp_activate
|
---|
25 | {
|
---|
26 | var $u_action;
|
---|
27 |
|
---|
28 | function main($id, $mode)
|
---|
29 | {
|
---|
30 | global $config, $phpbb_root_path, $phpEx;
|
---|
31 | global $db, $user, $auth, $template;
|
---|
32 |
|
---|
33 | $user_id = request_var('u', 0);
|
---|
34 | $key = request_var('k', '');
|
---|
35 |
|
---|
36 | $sql = 'SELECT user_id, username, user_type, user_email, user_newpasswd, user_lang, user_notify_type, user_actkey, user_inactive_reason
|
---|
37 | FROM ' . USERS_TABLE . "
|
---|
38 | WHERE user_id = $user_id";
|
---|
39 | $result = $db->sql_query($sql);
|
---|
40 | $user_row = $db->sql_fetchrow($result);
|
---|
41 | $db->sql_freeresult($result);
|
---|
42 |
|
---|
43 | if (!$user_row)
|
---|
44 | {
|
---|
45 | trigger_error('NO_USER');
|
---|
46 | }
|
---|
47 |
|
---|
48 | if ($user_row['user_type'] <> USER_INACTIVE && !$user_row['user_newpasswd'])
|
---|
49 | {
|
---|
50 | meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx"));
|
---|
51 | trigger_error('ALREADY_ACTIVATED');
|
---|
52 | }
|
---|
53 |
|
---|
54 | if (($user_row['user_inactive_reason'] == INACTIVE_MANUAL) || $user_row['user_actkey'] != $key)
|
---|
55 | {
|
---|
56 | trigger_error('WRONG_ACTIVATION');
|
---|
57 | }
|
---|
58 |
|
---|
59 | // Do not allow activating by non administrators when admin activation is on
|
---|
60 | // Only activation type the user should be able to do is INACTIVE_REMIND
|
---|
61 | // or activate a new password which is not an activation state :@
|
---|
62 | if (!$user_row['user_newpasswd'] && $user_row['user_inactive_reason'] != INACTIVE_REMIND && $config['require_activation'] == USER_ACTIVATION_ADMIN && !$auth->acl_get('a_user'))
|
---|
63 | {
|
---|
64 | if (!$user->data['is_registered'])
|
---|
65 | {
|
---|
66 | login_box('', $user->lang['NO_AUTH_OPERATION']);
|
---|
67 | }
|
---|
68 | trigger_error('NO_AUTH_OPERATION');
|
---|
69 | }
|
---|
70 |
|
---|
71 | $update_password = ($user_row['user_newpasswd']) ? true : false;
|
---|
72 |
|
---|
73 | if ($update_password)
|
---|
74 | {
|
---|
75 | $sql_ary = array(
|
---|
76 | 'user_actkey' => '',
|
---|
77 | 'user_password' => $user_row['user_newpasswd'],
|
---|
78 | 'user_newpasswd' => '',
|
---|
79 | 'user_pass_convert' => 0,
|
---|
80 | 'user_login_attempts' => 0,
|
---|
81 | );
|
---|
82 |
|
---|
83 | $sql = 'UPDATE ' . USERS_TABLE . '
|
---|
84 | SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
|
---|
85 | WHERE user_id = ' . $user_row['user_id'];
|
---|
86 | $db->sql_query($sql);
|
---|
87 |
|
---|
88 | add_log('user', $user_row['user_id'], 'LOG_USER_NEW_PASSWORD', $user_row['username']);
|
---|
89 | }
|
---|
90 |
|
---|
91 | if (!$update_password)
|
---|
92 | {
|
---|
93 | include_once($phpbb_root_path . 'includes/functions_user.' . $phpEx);
|
---|
94 |
|
---|
95 | user_active_flip('activate', $user_row['user_id']);
|
---|
96 |
|
---|
97 | $sql = 'UPDATE ' . USERS_TABLE . "
|
---|
98 | SET user_actkey = ''
|
---|
99 | WHERE user_id = {$user_row['user_id']}";
|
---|
100 | $db->sql_query($sql);
|
---|
101 | }
|
---|
102 |
|
---|
103 | if ($config['require_activation'] == USER_ACTIVATION_ADMIN && !$update_password)
|
---|
104 | {
|
---|
105 | include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
|
---|
106 |
|
---|
107 | $messenger = new messenger(false);
|
---|
108 |
|
---|
109 | $messenger->template('admin_welcome_activated', $user_row['user_lang']);
|
---|
110 |
|
---|
111 | $messenger->to($user_row['user_email'], $user_row['username']);
|
---|
112 |
|
---|
113 | $messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']);
|
---|
114 | $messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']);
|
---|
115 | $messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']);
|
---|
116 | $messenger->headers('X-AntiAbuse: User IP - ' . $user->ip);
|
---|
117 |
|
---|
118 | $messenger->assign_vars(array(
|
---|
119 | 'USERNAME' => htmlspecialchars_decode($user_row['username']))
|
---|
120 | );
|
---|
121 |
|
---|
122 | $messenger->send($user_row['user_notify_type']);
|
---|
123 |
|
---|
124 | $message = 'ACCOUNT_ACTIVE_ADMIN';
|
---|
125 | }
|
---|
126 | else
|
---|
127 | {
|
---|
128 | if (!$update_password)
|
---|
129 | {
|
---|
130 | $message = ($user_row['user_inactive_reason'] == INACTIVE_PROFILE) ? 'ACCOUNT_ACTIVE_PROFILE' : 'ACCOUNT_ACTIVE';
|
---|
131 | }
|
---|
132 | else
|
---|
133 | {
|
---|
134 | $message = 'PASSWORD_ACTIVATED';
|
---|
135 | }
|
---|
136 | }
|
---|
137 |
|
---|
138 | meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx"));
|
---|
139 | trigger_error($user->lang[$message]);
|
---|
140 | }
|
---|
141 | }
|
---|
142 |
|
---|
143 | ?>
|
---|