addInput('username', 'text', '用户名', '',
function($username, &$vdata) {
if (!validateUsername($username)) {
return '用户名不合法';
}
$vdata['user'] = UOJUser::query($username);
if (!$vdata['user']) {
return '该用户不存在';
}
return '';
},
null
);
$forgot_form->handle = function(&$vdata) {
$user = $vdata['user'];
$password = $user["password"];
$oj_name = UOJConfig::$data['profile']['oj-name'];
$oj_name_short = UOJConfig::$data['profile']['oj-name-short'];
$sufs = base64url_encode($user['username'] . "." . md5($user['username'] . "+" . $password));
$url = HTML::url("/reset-password", array('params' => array('p' => $sufs)));
$html = <<
{$user['username']}您好,
您刚刚启用了{$oj_name_short}密码找回功能,请进入下面的链接重设您的密码:
{$oj_name}
EOD; $mailer = UOJMail::noreply(); $mailer->addAddress($user['email'], $user['username']); $mailer->Subject = $oj_name_short."密码找回"; $mailer->msgHTML($html); if (!$mailer->send()) { error_log($mailer->ErrorInfo); becomeMsgPage('