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

443 by dcoles
Added Forum application along with unmodifed version of phpBB3 "Olympus" 3.0.0
1
<?php
2
/**
3
*
4
* @package ucp
5
* @version $Id: ucp_activate.php,v 1.29 2007/10/19 13:10:01 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
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_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
			);
69
70
			$sql = 'UPDATE ' . USERS_TABLE . '
71
				SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
72
				WHERE user_id = ' . $user_row['user_id'];
73
			$db->sql_query($sql);
74
		}
75
76
		if (!$update_password)
77
		{
78
			include_once($phpbb_root_path . 'includes/functions_user.' . $phpEx);
79
80
			user_active_flip('activate', $user_row['user_id']);
81
82
			$sql = 'UPDATE ' . USERS_TABLE . "
83
				SET user_actkey = ''
84
				WHERE user_id = {$user_row['user_id']}";
85
			$db->sql_query($sql);
86
		}
87
88
		if ($config['require_activation'] == USER_ACTIVATION_ADMIN && !$update_password)
89
		{
90
			include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
91
92
			$messenger = new messenger(false);
93
94
			$messenger->template('admin_welcome_activated', $user_row['user_lang']);
95
96
			$messenger->to($user_row['user_email'], $user_row['username']);
97
98
			$messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']);
99
			$messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']);
100
			$messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']);
101
			$messenger->headers('X-AntiAbuse: User IP - ' . $user->ip);
102
103
			$messenger->assign_vars(array(
104
				'USERNAME'	=> htmlspecialchars_decode($user_row['username']))
105
			);
106
107
			$messenger->send($user_row['user_notify_type']);
108
109
			$message = 'ACCOUNT_ACTIVE_ADMIN';
110
		}
111
		else
112
		{
113
			if (!$update_password)
114
			{
115
				$message = ($user_row['user_inactive_reason'] == INACTIVE_PROFILE) ? 'ACCOUNT_ACTIVE_PROFILE' : 'ACCOUNT_ACTIVE';
116
			}
117
			else
118
			{
119
				$message = 'PASSWORD_ACTIVATED';
120
			}
121
		}
122
123
		meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx"));
124
		trigger_error($user->lang[$message]);
125
	}
126
}
127
128
?>