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

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

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