예제 #1
0
파일: reset.php 프로젝트: sinfocol/gwf3
function ttr2_request(WC_Challenge $chall, GWF_Form $form)
{
    if (false !== ($errors = $form->validate($chall))) {
        return $errors;
    }
    # Generate reset token
    $sid = GWF_Session::getSessSID();
    $email = $form->getVar('email');
    $token = ttr2_random(16);
    if (!TTR2_Tokens::insertToken($sid, $email, $token)) {
        return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
    }
    # If it's your own real mail, even send it for the lulz :)
    if ($email === GWF_User::getStaticOrGuest()->getValidMail()) {
        ttr2_mail_me($chall, $email, $token);
    }
    return GWF_HTML::message($chall->lang('title'), $chall->lang('msg_mail_sent'));
}