2003-05-19 15:23:04 +00:00
|
|
|
<?php
|
2005-04-09 12:26:45 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @package ucp
|
|
|
|
* @version $Id$
|
|
|
|
* @copyright (c) 2005 phpBB Group
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ucp_activate
|
|
|
|
* User activation
|
2006-06-13 21:06:29 +00:00
|
|
|
* @package ucp
|
2005-04-09 12:26:45 +00:00
|
|
|
*/
|
2005-10-04 21:31:35 +00:00
|
|
|
class ucp_activate
|
2003-05-19 15:23:04 +00:00
|
|
|
{
|
2006-06-11 18:13:52 +00:00
|
|
|
var $u_action;
|
|
|
|
|
2005-10-04 21:31:35 +00:00
|
|
|
function main($id, $mode)
|
2003-05-19 15:23:04 +00:00
|
|
|
{
|
2006-06-11 18:13:52 +00:00
|
|
|
global $config, $phpbb_root_path, $phpEx;
|
|
|
|
global $db, $user, $auth, $template;
|
2003-05-19 15:23:04 +00:00
|
|
|
|
2003-10-15 17:43:07 +00:00
|
|
|
$user_id = request_var('u', 0);
|
|
|
|
$key = request_var('k', '');
|
2003-09-08 12:42:32 +00:00
|
|
|
|
2003-10-15 17:43:07 +00:00
|
|
|
$sql = 'SELECT user_id, username, user_type, user_email, user_newpasswd, user_lang, user_notify_type, user_actkey
|
2003-09-08 12:42:32 +00:00
|
|
|
FROM ' . USERS_TABLE . "
|
|
|
|
WHERE user_id = $user_id";
|
2003-05-19 15:23:04 +00:00
|
|
|
$result = $db->sql_query($sql);
|
2006-06-11 18:13:52 +00:00
|
|
|
$user_row = $db->sql_fetchrow($result);
|
2006-05-27 16:24:21 +00:00
|
|
|
$db->sql_freeresult($result);
|
2003-05-19 15:23:04 +00:00
|
|
|
|
2006-06-11 18:13:52 +00:00
|
|
|
if (!$user_row)
|
2003-05-19 15:23:04 +00:00
|
|
|
{
|
2006-06-11 18:13:52 +00:00
|
|
|
trigger_error('NO_USER');
|
2003-10-15 17:43:07 +00:00
|
|
|
}
|
|
|
|
|
2006-06-11 18:13:52 +00:00
|
|
|
if ($user_row['user_type'] <> USER_INACTIVE && !$user_row['user_newpasswd'])
|
2003-10-15 17:43:07 +00:00
|
|
|
{
|
2006-06-06 20:53:46 +00:00
|
|
|
meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx"));
|
2006-06-11 18:13:52 +00:00
|
|
|
trigger_error('ALREADY_ACTIVATED');
|
2003-10-15 17:43:07 +00:00
|
|
|
}
|
2006-06-11 18:13:52 +00:00
|
|
|
|
|
|
|
if ($user_row['user_actkey'] != $key)
|
2003-10-15 17:43:07 +00:00
|
|
|
{
|
2006-06-11 18:13:52 +00:00
|
|
|
trigger_error('WRONG_ACTIVATION');
|
2003-10-15 17:43:07 +00:00
|
|
|
}
|
|
|
|
|
2006-06-11 18:13:52 +00:00
|
|
|
$update_password = ($user_row['user_newpasswd']) ? true : false;
|
2003-10-15 17:43:07 +00:00
|
|
|
|
2004-10-13 19:30:02 +00:00
|
|
|
if ($update_password)
|
|
|
|
{
|
2005-01-29 11:29:35 +00:00
|
|
|
$sql_ary = array(
|
|
|
|
'user_type' => USER_NORMAL,
|
|
|
|
'user_actkey' => '',
|
2006-06-11 18:13:52 +00:00
|
|
|
'user_password' => $user_row['user_newpasswd'],
|
2004-10-13 19:30:02 +00:00
|
|
|
'user_newpasswd' => ''
|
|
|
|
);
|
2006-06-11 18:13:52 +00:00
|
|
|
|
|
|
|
$sql = 'UPDATE ' . USERS_TABLE . '
|
|
|
|
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
|
|
|
|
WHERE user_id = ' . $user_row['user_id'];
|
|
|
|
$db->sql_query($sql);
|
2004-10-13 19:30:02 +00:00
|
|
|
}
|
|
|
|
|
2005-01-29 11:29:35 +00:00
|
|
|
if (!$update_password)
|
|
|
|
{
|
2006-06-11 18:13:52 +00:00
|
|
|
include_once($phpbb_root_path . 'includes/functions_user.' . $phpEx);
|
|
|
|
|
2005-01-29 11:29:35 +00:00
|
|
|
// Now we need to demote the user from the inactive group and add him to the registered group
|
2006-06-11 18:13:52 +00:00
|
|
|
user_active_flip($user_row['user_id'], $user_row['user_type'], '', $user_row['username'], true);
|
2005-01-29 11:29:35 +00:00
|
|
|
|
2006-06-11 18:13:52 +00:00
|
|
|
// Update last username
|
|
|
|
update_last_username();
|
|
|
|
set_config('num_users', $config['num_users'] + 1, true);
|
2005-01-29 11:29:35 +00:00
|
|
|
}
|
2003-10-15 17:43:07 +00:00
|
|
|
|
2004-10-13 19:30:02 +00:00
|
|
|
if ($config['require_activation'] == USER_ACTIVATION_ADMIN && !$update_password)
|
2003-10-15 17:43:07 +00:00
|
|
|
{
|
2006-06-11 18:13:52 +00:00
|
|
|
include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
|
2003-10-15 17:43:07 +00:00
|
|
|
|
2006-06-11 18:13:52 +00:00
|
|
|
$messenger = new messenger(false);
|
2003-10-15 17:43:07 +00:00
|
|
|
|
2006-06-11 18:13:52 +00:00
|
|
|
$messenger->template('admin_welcome_activated', $user_row['user_lang']);
|
2003-10-15 17:43:07 +00:00
|
|
|
|
2004-10-13 19:30:02 +00:00
|
|
|
$messenger->replyto($config['board_contact']);
|
2006-06-11 18:13:52 +00:00
|
|
|
$messenger->to($user_row['user_email'], $user_row['username']);
|
2003-10-15 17:43:07 +00:00
|
|
|
|
|
|
|
$messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']);
|
|
|
|
$messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']);
|
|
|
|
$messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']);
|
|
|
|
$messenger->headers('X-AntiAbuse: User IP - ' . $user->ip);
|
|
|
|
|
|
|
|
$messenger->assign_vars(array(
|
|
|
|
'SITENAME' => $config['sitename'],
|
2006-06-11 18:13:52 +00:00
|
|
|
'USERNAME' => html_entity_decode($user_row['username']),
|
2004-10-13 19:30:02 +00:00
|
|
|
|
2003-10-15 17:43:07 +00:00
|
|
|
'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']))
|
|
|
|
);
|
|
|
|
|
2006-06-11 18:13:52 +00:00
|
|
|
$messenger->send($user_row['user_notify_type']);
|
2003-10-15 17:43:07 +00:00
|
|
|
|
|
|
|
$message = 'ACCOUNT_ACTIVE_ADMIN';
|
2003-05-19 15:23:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-10-13 19:30:02 +00:00
|
|
|
$message = (!$update_password) ? 'ACCOUNT_ACTIVE' : 'PASSWORD_ACTIVATED';
|
2003-05-19 15:23:04 +00:00
|
|
|
}
|
2003-10-15 17:43:07 +00:00
|
|
|
|
2006-06-06 20:53:46 +00:00
|
|
|
meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx"));
|
2003-10-15 17:43:07 +00:00
|
|
|
trigger_error($user->lang[$message]);
|
2003-05-19 15:23:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|