2003-05-19 15:23:04 +00:00
|
|
|
<?php
|
2007-10-05 14:36:34 +00:00
|
|
|
/**
|
2005-04-09 12:26:45 +00:00
|
|
|
*
|
|
|
|
* @package ucp
|
|
|
|
* @version $Id$
|
2007-10-05 14:36:34 +00:00
|
|
|
* @copyright (c) 2005 phpBB Group
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
2005-04-09 12:26:45 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2007-10-05 14:36:34 +00:00
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
*/
|
|
|
|
if (!defined('IN_PHPBB'))
|
|
|
|
{
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2005-04-09 12:26:45 +00:00
|
|
|
/**
|
|
|
|
* ucp_remind
|
|
|
|
* Sending password reminders
|
2006-06-13 21:06:29 +00:00
|
|
|
* @package ucp
|
2005-04-09 12:26:45 +00:00
|
|
|
*/
|
2005-10-04 21:31:35 +00:00
|
|
|
class ucp_remind
|
2003-05-19 15:23:04 +00:00
|
|
|
{
|
2006-06-06 20:53:46 +00:00
|
|
|
var $u_action;
|
|
|
|
|
2005-10-04 21:31:35 +00:00
|
|
|
function main($id, $mode)
|
2003-05-19 15:23:04 +00:00
|
|
|
{
|
2006-06-11 18:13:52 +00:00
|
|
|
global $config, $phpbb_root_path, $phpEx;
|
|
|
|
global $db, $user, $auth, $template;
|
2003-05-19 15:23:04 +00:00
|
|
|
|
2006-10-20 13:48:44 +00:00
|
|
|
$username = request_var('username', '', true);
|
2006-11-21 18:15:53 +00:00
|
|
|
$email = strtolower(request_var('email', ''));
|
2006-06-11 18:13:52 +00:00
|
|
|
$submit = (isset($_POST['submit'])) ? true : false;
|
2003-10-12 11:59:23 +00:00
|
|
|
|
|
|
|
if ($submit)
|
2003-05-19 15:23:04 +00:00
|
|
|
{
|
2008-10-06 14:04:33 +00:00
|
|
|
$sql = 'SELECT user_id, username, user_permissions, user_email, user_jabber, user_notify_type, user_type, user_lang, user_inactive_reason
|
2003-09-08 12:42:32 +00:00
|
|
|
FROM ' . USERS_TABLE . "
|
2009-08-28 09:26:43 +00:00
|
|
|
WHERE user_email_hash = '" . $db->sql_escape(phpbb_email_hash($email)) . "'
|
2006-10-13 22:10:18 +00:00
|
|
|
AND username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'";
|
2004-10-13 19:30:02 +00:00
|
|
|
$result = $db->sql_query($sql);
|
2006-06-11 18:13:52 +00:00
|
|
|
$user_row = $db->sql_fetchrow($result);
|
|
|
|
$db->sql_freeresult($result);
|
2003-10-12 15:29:18 +00:00
|
|
|
|
2006-06-11 18:13:52 +00:00
|
|
|
if (!$user_row)
|
2003-05-19 15:23:04 +00:00
|
|
|
{
|
2004-10-13 19:30:02 +00:00
|
|
|
trigger_error('NO_EMAIL_USER');
|
2003-05-19 15:23:04 +00:00
|
|
|
}
|
2003-10-12 15:29:18 +00:00
|
|
|
|
2007-04-01 16:42:10 +00:00
|
|
|
if ($user_row['user_type'] == USER_IGNORE)
|
|
|
|
{
|
|
|
|
trigger_error('NO_USER');
|
|
|
|
}
|
|
|
|
|
2006-06-11 18:13:52 +00:00
|
|
|
if ($user_row['user_type'] == USER_INACTIVE)
|
2003-10-12 15:29:18 +00:00
|
|
|
{
|
2007-04-01 16:42:10 +00:00
|
|
|
if ($user_row['user_inactive_reason'] == INACTIVE_MANUAL)
|
|
|
|
{
|
|
|
|
trigger_error('ACCOUNT_DEACTIVATED');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
trigger_error('ACCOUNT_NOT_ACTIVATED');
|
|
|
|
}
|
2003-10-12 15:29:18 +00:00
|
|
|
}
|
|
|
|
|
2008-10-06 14:04:33 +00:00
|
|
|
// Check users permissions
|
|
|
|
$auth2 = new auth();
|
|
|
|
$auth2->acl($user_row);
|
|
|
|
|
|
|
|
if (!$auth2->acl_get('u_chgpasswd'))
|
|
|
|
{
|
|
|
|
trigger_error('NO_AUTH_PASSWORD_REMINDER');
|
|
|
|
}
|
|
|
|
|
2003-10-12 15:29:18 +00:00
|
|
|
$server_url = generate_board_url();
|
|
|
|
|
2010-02-07 00:20:46 +00:00
|
|
|
// Make password at least 8 characters long, make it longer if admin wants to.
|
|
|
|
// gen_rand_string() however has a limit of 12 or 13.
|
2010-05-17 09:40:32 +02:00
|
|
|
$user_password = gen_rand_string_friendly(max(8, mt_rand((int) $config['min_pass_chars'], (int) $config['max_pass_chars'])));
|
2010-02-07 00:20:46 +00:00
|
|
|
|
|
|
|
// For the activation key a random length between 6 and 10 will do.
|
2010-05-17 08:54:51 +02:00
|
|
|
$user_actkey = gen_rand_string(mt_rand(6, 10));
|
2003-10-12 15:29:18 +00:00
|
|
|
|
|
|
|
$sql = 'UPDATE ' . USERS_TABLE . "
|
2007-10-04 18:50:25 +00:00
|
|
|
SET user_newpasswd = '" . $db->sql_escape(phpbb_hash($user_password)) . "', user_actkey = '" . $db->sql_escape($user_actkey) . "'
|
2006-06-11 18:13:52 +00:00
|
|
|
WHERE user_id = " . $user_row['user_id'];
|
2003-10-12 15:29:18 +00:00
|
|
|
$db->sql_query($sql);
|
|
|
|
|
2006-06-11 18:13:52 +00:00
|
|
|
include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
|
2003-10-12 15:29:18 +00:00
|
|
|
|
2006-06-11 18:13:52 +00:00
|
|
|
$messenger = new messenger(false);
|
2003-10-12 15:29:18 +00:00
|
|
|
|
2006-06-20 19:00:30 +00:00
|
|
|
$messenger->template('user_activate_passwd', $user_row['user_lang']);
|
2003-10-12 15:29:18 +00:00
|
|
|
|
2006-06-11 18:13:52 +00:00
|
|
|
$messenger->to($user_row['user_email'], $user_row['username']);
|
|
|
|
$messenger->im($user_row['user_jabber'], $user_row['username']);
|
2003-10-12 15:29:18 +00:00
|
|
|
|
|
|
|
$messenger->assign_vars(array(
|
2006-11-03 21:05:25 +00:00
|
|
|
'USERNAME' => htmlspecialchars_decode($user_row['username']),
|
|
|
|
'PASSWORD' => htmlspecialchars_decode($user_password),
|
2006-06-11 18:13:52 +00:00
|
|
|
'U_ACTIVATE' => "$server_url/ucp.$phpEx?mode=activate&u={$user_row['user_id']}&k=$user_actkey")
|
2003-10-12 15:29:18 +00:00
|
|
|
);
|
|
|
|
|
2006-06-11 18:13:52 +00:00
|
|
|
$messenger->send($user_row['user_notify_type']);
|
2003-10-12 15:29:18 +00:00
|
|
|
|
2006-06-06 20:53:46 +00:00
|
|
|
meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx"));
|
2003-10-12 15:29:18 +00:00
|
|
|
|
2007-01-26 16:09:51 +00:00
|
|
|
$message = $user->lang['PASSWORD_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a>');
|
2003-10-12 15:29:18 +00:00
|
|
|
trigger_error($message);
|
2003-05-19 15:23:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$template->assign_vars(array(
|
2006-06-11 18:13:52 +00:00
|
|
|
'USERNAME' => $username,
|
|
|
|
'EMAIL' => $email,
|
|
|
|
'S_PROFILE_ACTION' => append_sid($phpbb_root_path . 'ucp.' . $phpEx, 'mode=sendpassword'))
|
2003-05-19 15:23:04 +00:00
|
|
|
);
|
2003-10-12 15:29:18 +00:00
|
|
|
|
2005-10-04 21:31:35 +00:00
|
|
|
$this->tpl_name = 'ucp_remind';
|
2006-06-12 22:16:27 +00:00
|
|
|
$this->page_title = 'UCP_REMIND';
|
2003-05-19 15:23:04 +00:00
|
|
|
}
|
|
|
|
}
|