Blame Extras/phpBB/3.0.4/includes/ucp/ucp_activate.php

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