Blame Identity/Webenv/phpBB/3.0.4/includes/ucp/ucp_remind.php

ef5584
ef5584
/**
ef5584
*
ef5584
* @package ucp
ef5584
* @version $Id: ucp_remind.php 8977 2008-10-06 14:04:33Z acydburn $
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_remind
ef5584
* Sending password reminders
ef5584
* @package ucp
ef5584
*/
ef5584
class ucp_remind
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
		$username	= request_var('username', '', true);
ef5584
		$email		= strtolower(request_var('email', ''));
ef5584
		$submit		= (isset($_POST['submit'])) ? true : false;
ef5584
ef5584
		if ($submit)
ef5584
		{
ef5584
			$sql = 'SELECT user_id, username, user_permissions, user_email, user_jabber, user_notify_type, user_type, user_lang, user_inactive_reason
ef5584
				FROM ' . USERS_TABLE . "
ef5584
				WHERE user_email = '" . $db->sql_escape($email) . "'
ef5584
					AND username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'";
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_EMAIL_USER');
ef5584
			}
ef5584
ef5584
			if ($user_row['user_type'] == USER_IGNORE)
ef5584
			{
ef5584
				trigger_error('NO_USER');
ef5584
			}
ef5584
ef5584
			if ($user_row['user_type'] == USER_INACTIVE)
ef5584
			{
ef5584
				if ($user_row['user_inactive_reason'] == INACTIVE_MANUAL)
ef5584
				{
ef5584
					trigger_error('ACCOUNT_DEACTIVATED');
ef5584
				}
ef5584
				else
ef5584
				{
ef5584
					trigger_error('ACCOUNT_NOT_ACTIVATED');
ef5584
				}
ef5584
			}
ef5584
ef5584
			// Check users permissions
ef5584
			$auth2 = new auth();
ef5584
			$auth2->acl($user_row);
ef5584
ef5584
			if (!$auth2->acl_get('u_chgpasswd'))
ef5584
			{
ef5584
				trigger_error('NO_AUTH_PASSWORD_REMINDER');
ef5584
			}
ef5584
ef5584
			$server_url = generate_board_url();
ef5584
ef5584
			$key_len = 54 - strlen($server_url);
ef5584
			$key_len = max(6, $key_len); // we want at least 6
ef5584
			$key_len = ($config['max_pass_chars']) ? min($key_len, $config['max_pass_chars']) : $key_len; // we want at most $config['max_pass_chars']
ef5584
			$user_actkey = substr(gen_rand_string(10), 0, $key_len);
ef5584
			$user_password = gen_rand_string(8);
ef5584
ef5584
			$sql = 'UPDATE ' . USERS_TABLE . "
ef5584
				SET user_newpasswd = '" . $db->sql_escape(phpbb_hash($user_password)) . "', user_actkey = '" . $db->sql_escape($user_actkey) . "'
ef5584
				WHERE user_id = " . $user_row['user_id'];
ef5584
			$db->sql_query($sql);
ef5584
ef5584
			include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
ef5584
ef5584
			$messenger = new messenger(false);
ef5584
ef5584
			$messenger->template('user_activate_passwd', $user_row['user_lang']);
ef5584
ef5584
			$messenger->to($user_row['user_email'], $user_row['username']);
ef5584
			$messenger->im($user_row['user_jabber'], $user_row['username']);
ef5584
ef5584
			$messenger->assign_vars(array(
ef5584
				'USERNAME'		=> htmlspecialchars_decode($user_row['username']),
ef5584
				'PASSWORD'		=> htmlspecialchars_decode($user_password),
ef5584
				'U_ACTIVATE'	=> "$server_url/ucp.$phpEx?mode=activate&u={$user_row['user_id']}&k=$user_actkey")
ef5584
			);
ef5584
ef5584
			$messenger->send($user_row['user_notify_type']);
ef5584
ef5584
			meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx"));
ef5584
ef5584
			$message = $user->lang['PASSWORD_UPDATED'] . '

' . sprintf($user->lang['RETURN_INDEX'], '', '');
ef5584
			trigger_error($message);
ef5584
		}
ef5584
ef5584
		$template->assign_vars(array(
ef5584
			'USERNAME'			=> $username,
ef5584
			'EMAIL'				=> $email,
ef5584
			'S_PROFILE_ACTION'	=> append_sid($phpbb_root_path . 'ucp.' . $phpEx, 'mode=sendpassword'))
ef5584
		);
ef5584
ef5584
		$this->tpl_name = 'ucp_remind';
ef5584
		$this->page_title = 'UCP_REMIND';
ef5584
	}
ef5584
}
ef5584
ef5584
?>