|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
*
|
|
|
ef5584 |
* @package ucp
|
|
|
ef5584 |
* @version $Id: ucp_activate.php 9067 2008-11-21 13:21:53Z Kellanved $
|
|
|
ef5584 |
* @copyright (c) 2005 phpBB Group
|
|
|
ef5584 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
|
|
ef5584 |
*
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* @ignore
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
if (!defined('IN_PHPBB'))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
exit;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* ucp_activate
|
|
|
ef5584 |
* User activation
|
|
|
ef5584 |
* @package ucp
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
class ucp_activate
|
|
|
ef5584 |
{
|
|
|
ef5584 |
var $u_action;
|
|
|
ef5584 |
|
|
|
ef5584 |
function main($id, $mode)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
global $config, $phpbb_root_path, $phpEx;
|
|
|
ef5584 |
global $db, $user, $auth, $template;
|
|
|
ef5584 |
|
|
|
ef5584 |
$user_id = request_var('u', 0);
|
|
|
ef5584 |
$key = request_var('k', '');
|
|
|
ef5584 |
|
|
|
ef5584 |
$sql = 'SELECT user_id, username, user_type, user_email, user_newpasswd, user_lang, user_notify_type, user_actkey, user_inactive_reason
|
|
|
ef5584 |
FROM ' . USERS_TABLE . "
|
|
|
ef5584 |
WHERE user_id = $user_id";
|
|
|
ef5584 |
$result = $db->sql_query($sql);
|
|
|
ef5584 |
$user_row = $db->sql_fetchrow($result);
|
|
|
ef5584 |
$db->sql_freeresult($result);
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!$user_row)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error('NO_USER');
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($user_row['user_type'] <> USER_INACTIVE && !$user_row['user_newpasswd'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx"));
|
|
|
ef5584 |
trigger_error('ALREADY_ACTIVATED');
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if (($user_row['user_inactive_reason'] == INACTIVE_MANUAL) || $user_row['user_actkey'] != $key)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error('WRONG_ACTIVATION');
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$update_password = ($user_row['user_newpasswd']) ? true : false;
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($update_password)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$sql_ary = array(
|
|
|
ef5584 |
'user_actkey' => '',
|
|
|
ef5584 |
'user_password' => $user_row['user_newpasswd'],
|
|
|
ef5584 |
'user_newpasswd' => '',
|
|
|
ef5584 |
'user_pass_convert' => 0,
|
|
|
ef5584 |
'user_login_attempts' => 0,
|
|
|
ef5584 |
);
|
|
|
ef5584 |
|
|
|
ef5584 |
$sql = 'UPDATE ' . USERS_TABLE . '
|
|
|
ef5584 |
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
|
|
|
ef5584 |
WHERE user_id = ' . $user_row['user_id'];
|
|
|
ef5584 |
$db->sql_query($sql);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!$update_password)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
include_once($phpbb_root_path . 'includes/functions_user.' . $phpEx);
|
|
|
ef5584 |
|
|
|
ef5584 |
user_active_flip('activate', $user_row['user_id']);
|
|
|
ef5584 |
|
|
|
ef5584 |
$sql = 'UPDATE ' . USERS_TABLE . "
|
|
|
ef5584 |
SET user_actkey = ''
|
|
|
ef5584 |
WHERE user_id = {$user_row['user_id']}";
|
|
|
ef5584 |
$db->sql_query($sql);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($config['require_activation'] == USER_ACTIVATION_ADMIN && !$update_password)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
|
|
|
ef5584 |
|
|
|
ef5584 |
$messenger = new messenger(false);
|
|
|
ef5584 |
|
|
|
ef5584 |
$messenger->template('admin_welcome_activated', $user_row['user_lang']);
|
|
|
ef5584 |
|
|
|
ef5584 |
$messenger->to($user_row['user_email'], $user_row['username']);
|
|
|
ef5584 |
|
|
|
ef5584 |
$messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']);
|
|
|
ef5584 |
$messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']);
|
|
|
ef5584 |
$messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']);
|
|
|
ef5584 |
$messenger->headers('X-AntiAbuse: User IP - ' . $user->ip);
|
|
|
ef5584 |
|
|
|
ef5584 |
$messenger->assign_vars(array(
|
|
|
ef5584 |
'USERNAME' => htmlspecialchars_decode($user_row['username']))
|
|
|
ef5584 |
);
|
|
|
ef5584 |
|
|
|
ef5584 |
$messenger->send($user_row['user_notify_type']);
|
|
|
ef5584 |
|
|
|
ef5584 |
$message = 'ACCOUNT_ACTIVE_ADMIN';
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if (!$update_password)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$message = ($user_row['user_inactive_reason'] == INACTIVE_PROFILE) ? 'ACCOUNT_ACTIVE_PROFILE' : 'ACCOUNT_ACTIVE';
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$message = 'PASSWORD_ACTIVATED';
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx"));
|
|
|
ef5584 |
trigger_error($user->lang[$message]);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
?>
|