public function reset($sMod = '', $sMail = '', $sHash = '') { $this->checkMod($sMod); $sTable = VariousModel::convertModToTable($sMod); if (!(new UserCoreModel())->checkHashValidation($sMail, $sHash, $sTable)) { Header::redirect($this->registry->site_url, t('Oops! Email or hash is invalid.'), 'error'); } else { $sNewPassword = Various::genRndWord(8, 40); (new UserCoreModel())->changePassword($sMail, $sNewPassword, $sTable); $this->view->content = t('Hello!<br />Your password has been changed to <em>"%0%"</em>.<br />Please change it next time you login.', $sNewPassword); $sMessageHtml = $this->view->parseMail(PH7_PATH_SYS . 'global/' . PH7_VIEWS . PH7_TPL_NAME . '/mail/sys/mod/lost-password/recover_password.tpl', $sMail); $aInfo = ['to' => $sMail, 'subject' => t('Your new password - %site_name%')]; if (!(new Mail())->send($aInfo, $sMessageHtml)) { Header::redirect($this->registry->site_url, Form::errorSendingEmail(), 'error'); } else { Header::redirect($this->registry->site_url, t('Your new password has been emailed to you.')); } } }
public static function display() { $sTable = Various::convertModToTable((new Http())->get('mod')); if (isset($_POST['submit_forgot_password'])) { if (\PFBC\Form::isValid($_POST['submit_forgot_password'])) { new ForgotPasswordFormProcess($sTable); } Framework\Url\HeaderUrl::redirect(); } $oForm = new \PFBC\Form('form_forgot_password', 500); $oForm->configure(array('action' => '')); $oForm->addElement(new \PFBC\Element\Hidden('submit_forgot_password', 'form_forgot_password')); $oForm->addElement(new \PFBC\Element\Token('forgot_password')); $oForm->addElement(new \PFBC\Element\Email(t('Your Email:'), 'mail', array('id' => 'email', 'onblur' => 'CValid(this.value, this.id,\'user\',\'' . $sTable . '\')', 'required' => 1))); $oForm->addElement(new \PFBC\Element\HTMLExternal('<span class="input_error email"></span>')); $oForm->addElement(new \PFBC\Element\CCaptcha(t('Captcha:'), 'captcha', array('id' => 'ccaptcha', 'onkeyup' => 'CValid(this.value, this.id)', 'description' => t('Enter the code above:')))); $oForm->addElement(new \PFBC\Element\HTMLExternal('<span class="input_error ccaptcha"></span>')); $oForm->addElement(new \PFBC\Element\Button(t('Generate a new password!'), 'submit', array('icon' => 'key'))); $oForm->addElement(new \PFBC\Element\HTMLExternal('<script src="' . PH7_URL_STATIC . PH7_JS . 'validate.js"></script>')); $oForm->render(); }
/** * Message and Redirection for Activate Account. * * @param string $sEmail * @param string $sHash * @param object \PH7\Framework\Config\Config $oConfig * @param object \PH7\Framework\Registry\Registry $oRegistry * @param string $sMod (user, affiliate, newsletter). Default 'user' * @return void */ public function activateAccount($sEmail, $sHash, Framework\Config\Config $oConfig, Framework\Registry\Registry $oRegistry, $sMod = 'user') { $sTable = Framework\Mvc\Model\Engine\Util\Various::convertModToTable($sMod); $sRedirectLoginUrl = $sMod == 'newsletter' ? PH7_URL_ROOT : ($sMod == 'affiliate' ? Uri::get('affiliate', 'home', 'login') : Uri::get('user', 'main', 'login')); $sRedirectIndexUrl = $sMod == 'newsletter' ? PH7_URL_ROOT : ($sMod == 'affiliate' ? Uri::get('affiliate', 'home', 'index') : Uri::get('user', 'main', 'index')); $sSuccessMsg = $sMod == 'newsletter' ? t('Your subscription to our newsletters has been successfully validated!') : t('Your account has been successfully validated. You can now login!'); if (isset($sEmail, $sHash)) { $oUserModel = new AffiliateCoreModel(); if ($oUserModel->validateAccount($sEmail, $sHash, $sTable)) { $iId = $oUserModel->getId($sEmail, null, $sTable); if ($sMod != 'newsletter') { $this->clearReadProfileCache($iId, $sTable); } /** Update the Affiliate Commission **/ $iAffId = $oUserModel->getAffiliatedId($iId); AffiliateCore::updateJoinCom($iAffId, $oConfig, $oRegistry); Header::redirect($sRedirectLoginUrl, $sSuccessMsg); } else { Header::redirect($sRedirectLoginUrl, t('Oops! The URL is either invalid or you already have activated your account.'), 'error'); } unset($oUserModel); } else { Header::redirect($sRedirectIndexUrl, t('Invalid approach, please use the link that has been send to your email.'), 'error'); } }