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
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @package ucp
|
|
|
|
* ucp_activate
|
|
|
|
* User activation
|
|
|
|
*/
|
2005-10-04 21:31:35 +00:00
|
|
|
class ucp_activate
|
2003-05-19 15:23:04 +00:00
|
|
|
{
|
2005-10-04 21:31:35 +00:00
|
|
|
function main($id, $mode)
|
2003-05-19 15:23:04 +00:00
|
|
|
{
|
2004-02-21 12:47:35 +00:00
|
|
|
global $config, $db, $user, $auth, $SID, $template, $phpbb_root_path, $phpEx;
|
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-05-27 16:24:21 +00:00
|
|
|
$row = $db->sql_fetchrow($result);
|
|
|
|
$db->sql_freeresult($result);
|
2003-05-19 15:23:04 +00:00
|
|
|
|
2006-05-27 16:24:21 +00:00
|
|
|
if (!$row)
|
2003-05-19 15:23:04 +00:00
|
|
|
{
|
2003-10-15 17:43:07 +00:00
|
|
|
trigger_error($user->lang['NO_USER']);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($row['user_type'] <> USER_INACTIVE && !$row['user_newpasswd'])
|
|
|
|
{
|
|
|
|
meta_refresh(3, "index.$phpEx$SID");
|
|
|
|
trigger_error($user->lang['ALREADY_ACTIVATED']);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($row['user_actkey'] != $key)
|
|
|
|
{
|
|
|
|
trigger_error($user->lang['WRONG_ACTIVATION']);
|
|
|
|
}
|
|
|
|
|
2004-10-13 19:30:02 +00:00
|
|
|
$update_password = ($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' => '',
|
2004-10-13 19:30:02 +00:00
|
|
|
'user_password' => $row['user_newpasswd'],
|
|
|
|
'user_newpasswd' => ''
|
|
|
|
);
|
2005-01-29 11:29:35 +00:00
|
|
|
|
|
|
|
$sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
|
|
|
|
WHERE user_id = ' . $row['user_id'];
|
|
|
|
$result = $db->sql_query($sql);
|
2004-10-13 19:30:02 +00:00
|
|
|
}
|
|
|
|
|
2005-01-29 11:29:35 +00:00
|
|
|
// TODO: check for group membership after password update... active_flip there too
|
|
|
|
if (!$update_password)
|
|
|
|
{
|
|
|
|
// Now we need to demote the user from the inactive group and add him to the registered group
|
|
|
|
|
|
|
|
include_once($phpbb_root_path . 'includes/functions_user.' . $phpEx);
|
2006-05-27 16:24:21 +00:00
|
|
|
user_active_flip($row['user_id'], $row['user_type'], '', $row['username'], 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
|
|
|
{
|
|
|
|
include_once($phpbb_root_path . 'includes/functions_messenger.'.$phpEx);
|
|
|
|
|
|
|
|
$messenger = new messenger();
|
|
|
|
|
|
|
|
$messenger->template('admin_welcome_activated', $row['user_lang']);
|
|
|
|
|
2004-10-13 19:30:02 +00:00
|
|
|
$messenger->replyto($config['board_contact']);
|
2003-10-15 17:43:07 +00:00
|
|
|
$messenger->to($row['user_email'], $row['username']);
|
|
|
|
|
|
|
|
$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-05-20 18:39:35 +00:00
|
|
|
'USERNAME' => html_entity_decode($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']))
|
|
|
|
);
|
|
|
|
|
|
|
|
$messenger->send($row['user_notify_type']);
|
2005-04-09 12:26:45 +00:00
|
|
|
$messenger->save_queue();
|
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
|
|
|
|
2004-10-13 19:30:02 +00:00
|
|
|
if (!$update_password)
|
2003-10-15 17:43:07 +00:00
|
|
|
{
|
|
|
|
set_config('newest_user_id', $row['user_id']);
|
|
|
|
set_config('newest_username', $row['username']);
|
2005-11-20 18:58:34 +00:00
|
|
|
set_config('num_users', $config['num_users'] + 1, true);
|
2003-10-15 17:43:07 +00:00
|
|
|
}
|
|
|
|
|
2004-05-26 20:16:20 +00:00
|
|
|
meta_refresh(3, "{$phpbb_root_path}index.$phpEx$SID");
|
2003-10-15 17:43:07 +00:00
|
|
|
trigger_error($user->lang[$message]);
|
2003-05-19 15:23:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|