source: forum/includes/ucp/ucp_activate.php@ 400

Last change on this file since 400 was 400, checked in by george, 16 years ago
  • Přidáno: Nové forum phpBB 3.
File size: 3.1 KB
Line 
1<?php
2/**
3*
4* @package ucp
5* @version $Id: ucp_activate.php 9067 2008-11-21 13:21:53Z Kellanved $
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*/
14if (!defined('IN_PHPBB'))
15{
16 exit;
17}
18
19/**
20* ucp_activate
21* User activation
22* @package ucp
23*/
24class 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 $update_password = ($user_row['user_newpasswd']) ? true : false;
60
61 if ($update_password)
62 {
63 $sql_ary = array(
64 'user_actkey' => '',
65 'user_password' => $user_row['user_newpasswd'],
66 'user_newpasswd' => '',
67 'user_pass_convert' => 0,
68 'user_login_attempts' => 0,
69 );
70
71 $sql = 'UPDATE ' . USERS_TABLE . '
72 SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
73 WHERE user_id = ' . $user_row['user_id'];
74 $db->sql_query($sql);
75 }
76
77 if (!$update_password)
78 {
79 include_once($phpbb_root_path . 'includes/functions_user.' . $phpEx);
80
81 user_active_flip('activate', $user_row['user_id']);
82
83 $sql = 'UPDATE ' . USERS_TABLE . "
84 SET user_actkey = ''
85 WHERE user_id = {$user_row['user_id']}";
86 $db->sql_query($sql);
87 }
88
89 if ($config['require_activation'] == USER_ACTIVATION_ADMIN && !$update_password)
90 {
91 include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
92
93 $messenger = new messenger(false);
94
95 $messenger->template('admin_welcome_activated', $user_row['user_lang']);
96
97 $messenger->to($user_row['user_email'], $user_row['username']);
98
99 $messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']);
100 $messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']);
101 $messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']);
102 $messenger->headers('X-AntiAbuse: User IP - ' . $user->ip);
103
104 $messenger->assign_vars(array(
105 'USERNAME' => htmlspecialchars_decode($user_row['username']))
106 );
107
108 $messenger->send($user_row['user_notify_type']);
109
110 $message = 'ACCOUNT_ACTIVE_ADMIN';
111 }
112 else
113 {
114 if (!$update_password)
115 {
116 $message = ($user_row['user_inactive_reason'] == INACTIVE_PROFILE) ? 'ACCOUNT_ACTIVE_PROFILE' : 'ACCOUNT_ACTIVE';
117 }
118 else
119 {
120 $message = 'PASSWORD_ACTIVATED';
121 }
122 }
123
124 meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx"));
125 trigger_error($user->lang[$message]);
126 }
127}
128
129?>
Note: See TracBrowser for help on using the repository browser.