1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/includes/ucp/ucp_remind.php Wed Mar 07 16:41:10 2012 +0400
1.3 @@ -0,0 +1,126 @@
1.4 +<?php
1.5 +/**
1.6 +*
1.7 +* @package ucp
1.8 +* @version $Id$
1.9 +* @copyright (c) 2005 phpBB Group
1.10 +* @license http://opensource.org/licenses/gpl-license.php GNU Public License
1.11 +*
1.12 +*/
1.13 +
1.14 +/**
1.15 +* @ignore
1.16 +*/
1.17 +if (!defined('IN_PHPBB'))
1.18 +{
1.19 + exit;
1.20 +}
1.21 +
1.22 +/**
1.23 +* ucp_remind
1.24 +* Sending password reminders
1.25 +* @package ucp
1.26 +*/
1.27 +class ucp_remind
1.28 +{
1.29 + var $u_action;
1.30 +
1.31 + function main($id, $mode)
1.32 + {
1.33 + global $config, $phpbb_root_path, $phpEx;
1.34 + global $db, $user, $auth, $template;
1.35 +
1.36 + $username = request_var('username', '', true);
1.37 + $email = strtolower(request_var('email', ''));
1.38 + $submit = (isset($_POST['submit'])) ? true : false;
1.39 +
1.40 + if ($submit)
1.41 + {
1.42 + $sql = 'SELECT user_id, username, user_permissions, user_email, user_jabber, user_notify_type, user_type, user_lang, user_inactive_reason
1.43 + FROM ' . USERS_TABLE . "
1.44 + WHERE user_email_hash = '" . $db->sql_escape(phpbb_email_hash($email)) . "'
1.45 + AND username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'";
1.46 + $result = $db->sql_query($sql);
1.47 + $user_row = $db->sql_fetchrow($result);
1.48 + $db->sql_freeresult($result);
1.49 +
1.50 + if (!$user_row)
1.51 + {
1.52 + trigger_error('NO_EMAIL_USER');
1.53 + }
1.54 +
1.55 + if ($user_row['user_type'] == USER_IGNORE)
1.56 + {
1.57 + trigger_error('NO_USER');
1.58 + }
1.59 +
1.60 + if ($user_row['user_type'] == USER_INACTIVE)
1.61 + {
1.62 + if ($user_row['user_inactive_reason'] == INACTIVE_MANUAL)
1.63 + {
1.64 + trigger_error('ACCOUNT_DEACTIVATED');
1.65 + }
1.66 + else
1.67 + {
1.68 + trigger_error('ACCOUNT_NOT_ACTIVATED');
1.69 + }
1.70 + }
1.71 +
1.72 + // Check users permissions
1.73 + $auth2 = new auth();
1.74 + $auth2->acl($user_row);
1.75 +
1.76 + if (!$auth2->acl_get('u_chgpasswd'))
1.77 + {
1.78 + trigger_error('NO_AUTH_PASSWORD_REMINDER');
1.79 + }
1.80 +
1.81 + $server_url = generate_board_url();
1.82 +
1.83 + // Make password at least 8 characters long, make it longer if admin wants to.
1.84 + // gen_rand_string() however has a limit of 12 or 13.
1.85 + $user_password = gen_rand_string_friendly(max(8, mt_rand((int) $config['min_pass_chars'], (int) $config['max_pass_chars'])));
1.86 +
1.87 + // For the activation key a random length between 6 and 10 will do.
1.88 + $user_actkey = gen_rand_string(mt_rand(6, 10));
1.89 +
1.90 + $sql = 'UPDATE ' . USERS_TABLE . "
1.91 + SET user_newpasswd = '" . $db->sql_escape(phpbb_hash($user_password)) . "', user_actkey = '" . $db->sql_escape($user_actkey) . "'
1.92 + WHERE user_id = " . $user_row['user_id'];
1.93 + $db->sql_query($sql);
1.94 +
1.95 + include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
1.96 +
1.97 + $messenger = new messenger(false);
1.98 +
1.99 + $messenger->template('user_activate_passwd', $user_row['user_lang']);
1.100 +
1.101 + $messenger->to($user_row['user_email'], $user_row['username']);
1.102 + $messenger->im($user_row['user_jabber'], $user_row['username']);
1.103 +
1.104 + $messenger->assign_vars(array(
1.105 + 'USERNAME' => htmlspecialchars_decode($user_row['username']),
1.106 + 'PASSWORD' => htmlspecialchars_decode($user_password),
1.107 + 'U_ACTIVATE' => "$server_url/ucp.$phpEx?mode=activate&u={$user_row['user_id']}&k=$user_actkey")
1.108 + );
1.109 +
1.110 + $messenger->send($user_row['user_notify_type']);
1.111 +
1.112 + meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx"));
1.113 +
1.114 + $message = $user->lang['PASSWORD_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a>');
1.115 + trigger_error($message);
1.116 + }
1.117 +
1.118 + $template->assign_vars(array(
1.119 + 'USERNAME' => $username,
1.120 + 'EMAIL' => $email,
1.121 + 'S_PROFILE_ACTION' => append_sid($phpbb_root_path . 'ucp.' . $phpEx, 'mode=sendpassword'))
1.122 + );
1.123 +
1.124 + $this->tpl_name = 'ucp_remind';
1.125 + $this->page_title = 'UCP_REMIND';
1.126 + }
1.127 +}
1.128 +
1.129 +?>
1.130 \ No newline at end of file