public function __construct($sTable)
 {
     parent::__construct();
     $oUserModel = new UserCoreModel();
     $sMail = $this->httpRequest->post('mail');
     if (!($iProfileId = $oUserModel->getId($sMail, null, $sTable))) {
         sleep(1);
         // Security against brute-force attack to avoid drowning the server and the database
         \PFBC\Form::setError('form_forgot_password', t('Oops, this "%0%" is not associated with any %site_name% account. Please, make sure that you entered the e-mail address used in creating your account.', escape(substr($sMail, 0, PH7_MAX_EMAIL_LENGTH))));
     } else {
         $oUserModel->setNewHashValidation($iProfileId, Various::genRnd(), $sTable);
         (new UserCore())->clearReadProfileCache($iProfileId, $sTable);
         // Clean the profile data (for the new hash)
         $oData = $oUserModel->readProfile($iProfileId, $sTable);
         /** We place the text outside of Uri::get() otherwise special characters will be deleted and the parameters passed in the url will be unusable thereafter. **/
         $sResetUrl = Uri::get('lost-password', 'main', 'reset', $this->httpRequest->get('mod')) . PH7_SH . $oData->email . PH7_SH . $oData->hashValidation;
         $this->view->content = t('Hello %0%!<br />Somebody (from the IP address %1%) has requested a new password for their account.', $oData->username, Ip::get()) . '<br />' . t('If you requested for this, click on the link below, otherwise ignore this email and your password will remain unchanged.') . '<br /><a href="' . $sResetUrl . '">' . $sResetUrl . '</a>';
         $sMessageHtml = $this->view->parseMail(PH7_PATH_SYS . 'global/' . PH7_VIEWS . PH7_TPL_NAME . '/mail/sys/mod/lost-password/confirm-lost-password.tpl', $oData->email);
         $aInfo = ['to' => $oData->email, 'subject' => t('Request for new password - %site_name%')];
         unset($oData);
         if (!(new Mail())->send($aInfo, $sMessageHtml)) {
             \PFBC\Form::setError('form_forgot_password', Form::errorSendingEmail());
         } else {
             \PFBC\Form::setSuccess('form_forgot_password', t('Successfully requested a new password, email sent!'));
         }
     }
     unset($oUserModel);
 }
 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 function __construct()
 {
     parent::__construct();
     $oSubscriptionModel = new SubscriptionModel();
     $sEmail = $this->httpRequest->post('email');
     $sName = $this->httpRequest->post('name');
     $bIsSubscriber = (new ExistsCoreModel())->email($sEmail, 'Subscribers');
     switch ($this->httpRequest->post('direction')) {
         case 'subscrire':
             if (!$bIsSubscriber) {
                 $aData = ['name' => $sName, 'email' => $sEmail, 'current_date' => (new CDateTime())->get()->dateTime('Y-m-d H:i:s'), 'ip' => Ip::get(), 'hash_validation' => Various::genRnd(), 'active' => '0', 'affiliated_id' => (int) (new Cookie())->get(AffiliateCore::COOKIE_NAME)];
                 $sActivateLink = Uri::get('newsletter', 'home', 'activate') . PH7_SH . $aData['email'] . PH7_SH . $aData['hash_validation'];
                 $this->view->content = t('Hi %0%!', $aData['name']) . '<br />' . t("Welcome to %site_name%'s Subscription!") . '<br />' . t('Activation link: %0%.', '<a href="' . $sActivateLink . '">' . $sActivateLink . '</a>');
                 $this->view->footer = t('You are receiving this mail because we received an application for registration with the email "%0%" has been provided in the form of %site_name% (%site_url%).', $aData['email']) . '<br />' . t('If you think someone has used your email address without your knowledge to create an account on %site_name%, please contact us using our contact form available on our website.');
                 $sMessageHtml = $this->view->parseMail(PH7_PATH_SYS . 'global/' . PH7_VIEWS . PH7_TPL_NAME . '/mail/sys/mod/newsletter/registration.tpl', $sEmail);
                 $aInfo = ['subject' => t('Confirm you email address!'), 'to' => $sEmail];
                 if ((new Mail())->send($aInfo, $sMessageHtml)) {
                     \PFBC\Form::setSuccess('form_subscription', t('Please activate your subscription by clicking the activation link you received by email. If you can not find the email, please look in your SPAM FOLDER and mark as not spam.'));
                     $oSubscriptionModel->add($aData);
                 } else {
                     \PFBC\Form::setError('form_subscription', Form::errorSendingEmail());
                 }
             } else {
                 \PFBC\Form::setError('form_subscription', t('Oops! You are already subscribed to our newsletter.'));
             }
             break;
         case 'unsubscribe':
             if ($bIsSubscriber) {
                 $oSubscriptionModel->unsubscribe($sEmail);
                 \PFBC\Form::setSuccess('form_subscription', t('Your subscription was successfully canceled.'));
             } else {
                 \PFBC\Form::setError('form_subscription', t('We have not found any subscriber with the email address.'));
             }
             break;
         default:
             Framework\Http\Http::setHeadersByCode(400);
             exit('Bad Request Error!');
     }
     unset($oSubscriptionModel);
 }
 public function __construct($sTable)
 {
     parent::__construct();
     $sMail = $this->httpRequest->post('mail');
     if (!(new ExistsCoreModel())->email($sMail, $sTable)) {
         \PFBC\Form::setError('form_resend_activation', t('Oops, this "%0%" is not associated with any %site_name% account. Please, make sure that you entered the e-mail address used in creating your account.', escape(substr($sMail, 0, PH7_MAX_EMAIL_LENGTH))));
     } else {
         if (!($mHash = (new UserCoreModel())->getHashValidation($sMail))) {
             \PFBC\Form::setError('form_resend_activation', t('Oops! Your account is already activated.'));
         } else {
             $sMod = $sTable == 'Affiliates' ? 'affiliate' : 'user';
             $sActivateLink = Uri::get($sMod, 'account', 'activate') . PH7_SH . $mHash->email . PH7_SH . $mHash->hashValidation;
             $this->view->content = t('Welcome to %site_name%, %0%!', $mHash->firstName) . '<br />' . t('Hello %0% - We are proud to welcome you as a member of %site_name%!', $mHash->firstName) . '<br />' . t('Your hash validation is <em>"%0%"</em>.', '<a href="' . $sActivateLink . '">' . $sActivateLink . '</a>') . '<br />' . t('Please save the following information for future refenrence:') . '<br /><em>' . t('Email: ') . $mHash->email . '.<br />' . t('Username: '******'.<br />' . t('Password: ***** (This field is hidden to protect against theft of your account).') . '.</em>';
             $this->view->footer = t('You are receiving this mail because we received an application for registration with the email "%0%" has been provided in the form of %site_name% (%site_url%).', $mHash->email) . '<br />' . t('If you think someone has used your email address without your knowledge to create an account on %site_name%, please contact us using our contact form available on our website.');
             $sMessageHtml = $this->view->parseMail(PH7_PATH_SYS . 'global/' . PH7_VIEWS . PH7_TPL_NAME . '/mail/sys/core/resend_activation.tpl', $mHash->email);
             $aInfo = ['to' => $mHash->email, 'subject' => t('Your new password - %site_name%')];
             if (!(new Mail())->send($aInfo, $sMessageHtml)) {
                 \PFBC\Form::setError('form_resend_activation', Form::errorSendingEmail());
             } else {
                 \PFBC\Form::setSuccess('form_resend_activation', t('Your hash validation has been emailed to you.'));
             }
         }
     }
 }
 public function __construct()
 {
     parent::__construct();
     $aTo = explode(',', $this->httpRequest->post('to'));
     if (count($aTo) > 10) {
         \PFBC\Form::setError('form_invite', t('To prevent spam, you cannot put more than 10 email addresses at a time.'));
     } else {
         foreach ($aTo as $sMail) {
             if (!(new Validate())->email($sMail)) {
                 \PFBC\Form::setError('form_invite', t('One or more email addresses are invalid!'));
             } else {
                 $this->view->content = t('Hello!<br />You have received a privilege on the invitation from your friend on the new platform to meet new generation - %site_name%') . '<br />' . '<strong><a href="' . Uri::get('user', 'signup', 'step1', '?ref=invitation') . '">' . t('Get exclusive privilege to join your friend is waiting for you!') . '</a></strong><br />' . t('Message left by your friend:') . '<br />"<em>' . $this->httpRequest->post('message') . '</em>"';
                 $this->view->footer = t('You are receiving this message because "%0%" you know has entered your email address in the form of invitation of friends to our site. This is not spam!', $this->httpRequest->post('first_name'));
                 $sMessageHtml = $this->view->parseMail(PH7_PATH_SYS . 'global/' . PH7_VIEWS . PH7_TPL_NAME . '/mail/sys/mod/invite/invitation.tpl', $sMail);
                 $aInfo = ['to' => $sMail, 'subject' => t('Privilege on the invitation from your friend for the new generation community platform - %site_name%')];
                 if (!(new Mail())->send($aInfo, $sMessageHtml)) {
                     \PFBC\Form::setError('form_invite', Form::errorSendingEmail());
                 } else {
                     \PFBC\Form::setSuccess('form_invite', t('Cool! We have sent that.'));
                 }
             }
         }
     }
 }