addInput('username', 'text', '用户名', '', function($username, &$vdata) { if (!validateUsername($username)) { return '用户名不合法'; } $vdata['user'] = queryUser($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}密码找回功能,请进入下面的链接重设您的密码:

$url

{$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('

邮件发送失败,请重试

'); } else { becomeMsgPage('

邮件发送成功

'); } }; $forgot_form->submit_button_config['align'] = 'offset'; $forgot_form->runAtServer(); ?>

请输入需要找回密码的用户名:

printHTML(); ?>