/**
  * Execute the action
  */
 public function execute()
 {
     // set busy file
     $this->setBusyFile();
     // send all queued e-mails
     foreach (BackendMailer::getQueuedMailIds() as $id) {
         BackendMailer::send($id);
     }
     // remove busy file
     $this->clearBusyFile();
 }
 /**
  * Execute the action
  *
  * @return	void
  */
 public function execute()
 {
     // set busy file
     $this->setBusyFile();
     // get all queued mails
     $queuedMailIds = BackendMailer::getQueuedMailIds();
     // any mails to send?
     if (!empty($queuedMailIds)) {
         // loop mails & send them
         foreach ($queuedMailIds as $id) {
             BackendMailer::send($id);
         }
     }
     // remove busy file
     $this->clearBusyFile();
 }
Example #3
0
 /**
  * Execute the actions
  */
 public function execute()
 {
     parent::execute();
     //--Get all the addresses
     $addresses = BackendAddressesModel::getAllAddresses(1);
     foreach ($addresses as &$address) {
         $address = BackendAddressesModel::get($address['id']);
         foreach ($address as &$row) {
             $row = $row == "" ? "-" : $row;
         }
     }
     foreach ($addresses as $address) {
         set_time_limit(10);
         if (filter_var($address['email'], FILTER_VALIDATE_EMAIL) && $address['send_mail'] == 0) {
             //--Send mail for the address
             BackendMailer::addEmail("Nieuwe website Namev.be met uw eigen bedrijfs-pagina", BACKEND_MODULE_PATH . '/layout/templates/mails/send_email.tpl', $address, '*****@*****.**', $address['company']);
             //								BackendMailer::addEmail("Nieuwe website Namev.be met uw eigen bedrijfs-pagina", BACKEND_MODULE_PATH . '/layout/templates/mails/send_email.tpl', $address, '*****@*****.**', $address['company']);
             //				BackendMailer::addEmail("Nieuwe website Namev.be met uw eigen bedrijfs-pagina", BACKEND_MODULE_PATH . '/layout/templates/mails/send_email.tpl', $address, $address['email'], $address['company']);
             BackendModel::getContainer()->get('database')->update('addresses', array("send_mail" => 1), 'id = ?', (int) $address['id']);
             die;
         }
     }
     //--Update the address row when e-mail is send
 }
Example #4
0
 /**
  * Validate the forms
  */
 private function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         $txtEmail = $this->frm->getField('backend_email');
         $txtPassword = $this->frm->getField('backend_password');
         // required fields
         if (!$txtEmail->isFilled() || !$txtPassword->isFilled()) {
             // add error
             $this->frm->addError('fields required');
             // show error
             $this->tpl->assign('hasError', true);
         }
         // invalid form-token?
         if ($this->frm->getToken() != $this->frm->getField('form_token')->getValue()) {
             // set a correct header, so bots understand they can't mess with us.
             if (!headers_sent()) {
                 header('400 Bad Request', true, 400);
             }
         }
         // all fields are ok?
         if ($txtEmail->isFilled() && $txtPassword->isFilled() && $this->frm->getToken() == $this->frm->getField('form_token')->getValue()) {
             // try to login the user
             if (!BackendAuthentication::loginUser($txtEmail->getValue(), $txtPassword->getValue())) {
                 // add error
                 $this->frm->addError('invalid login');
                 // store attempt in session
                 $current = SpoonSession::exists('backend_login_attempts') ? (int) SpoonSession::get('backend_login_attempts') : 0;
                 // increment and store
                 SpoonSession::set('backend_login_attempts', ++$current);
                 // show error
                 $this->tpl->assign('hasError', true);
             }
         }
         // check sessions
         if (SpoonSession::exists('backend_login_attempts') && (int) SpoonSession::get('backend_login_attempts') >= 5) {
             // get previous attempt
             $previousAttempt = SpoonSession::exists('backend_last_attempt') ? SpoonSession::get('backend_last_attempt') : time();
             // calculate timeout
             $timeout = 5 * (SpoonSession::get('backend_login_attempts') - 4);
             // too soon!
             if (time() < $previousAttempt + $timeout) {
                 // sleep untill the user can login again
                 sleep($timeout);
                 // set a correct header, so bots understand they can't mess with us.
                 if (!headers_sent()) {
                     header('503 Service Unavailable', true, 503);
                 }
             } else {
                 // increment and store
                 SpoonSession::set('backend_last_attempt', time());
             }
             // too many attempts
             $this->frm->addEditor('too many attempts');
             // show error
             $this->tpl->assign('hasTooManyAttemps', true);
             $this->tpl->assign('hasError', false);
         }
         // no errors in the form?
         if ($this->frm->isCorrect()) {
             // cleanup sessions
             SpoonSession::delete('backend_login_attempts');
             SpoonSession::delete('backend_last_attempt');
             // create filter with modules which may not be displayed
             $filter = array('authentication', 'error', 'core');
             // get all modules
             $modules = array_diff(BackendModel::getModules(), $filter);
             // loop through modules and break on first allowed module
             foreach ($modules as $module) {
                 if (BackendAuthentication::isAllowedModule($module)) {
                     break;
                 }
             }
             // redirect to the correct URL (URL the user was looking for or fallback)
             $this->redirect($this->getParameter('querystring', 'string', BackendModel::createUrlForAction(null, $module)));
         }
     }
     // is the form submitted
     if ($this->frmForgotPassword->isSubmitted()) {
         // backend email
         $email = $this->frmForgotPassword->getField('backend_email_forgot')->getValue();
         // required fields
         if ($this->frmForgotPassword->getField('backend_email_forgot')->isEmail(BL::err('EmailIsInvalid'))) {
             // check if there is a user with the given emailaddress
             if (!BackendUsersModel::existsEmail($email)) {
                 $this->frmForgotPassword->getField('backend_email_forgot')->addError(BL::err('EmailIsUnknown'));
             }
         }
         // no errors in the form?
         if ($this->frmForgotPassword->isCorrect()) {
             // generate the key for the reset link and fetch the user ID for this email
             $key = BackendAuthentication::getEncryptedString($email, uniqid());
             // insert the key and the timestamp into the user settings
             $userId = BackendUsersModel::getIdByEmail($email);
             $user = new BackendUser($userId);
             $user->setSetting('reset_password_key', $key);
             $user->setSetting('reset_password_timestamp', time());
             // variables to parse in the e-mail
             $variables['resetLink'] = SITE_URL . BackendModel::createURLForAction('reset_password') . '&email=' . $email . '&key=' . $key;
             // send e-mail to user
             BackendMailer::addEmail(SpoonFilter::ucfirst(BL::msg('ResetYourPasswordMailSubject')), BACKEND_MODULE_PATH . '/layout/templates/mails/reset_password.tpl', $variables, $email);
             // clear post-values
             $_POST['backend_email_forgot'] = '';
             // show success message
             $this->tpl->assign('isForgotPasswordSuccess', true);
             // show form
             $this->tpl->assign('showForm', true);
         } else {
             $this->tpl->assign('showForm', true);
         }
     }
 }
Example #5
0
 /**
  * Validate the form for step 4
  *
  * @return	void
  */
 private function validateFormForStep4()
 {
     // is the form submitted?
     if ($this->frm->isSubmitted()) {
         // cleanup the submitted fields, ignore fields that were added by hackers
         $this->frm->cleanupFields();
         // shorten fields
         $txtEmail = $this->frm->getField('email');
         $txtSendOnDate = $this->frm->getField('send_on_date');
         $txtSendOnTime = $this->frm->getField('send_on_time');
         // validation
         if ($txtEmail->isFilled(BL::err('FieldIsRequired'))) {
             $txtEmail->isEmail(BL::err('EmailIsInvalid'));
         }
         $txtSendOnDate->isValid(BL::err('DateIsInvalid'));
         $txtSendOnTime->isValid(BL::err('TimeIsInvalid'));
         // no errors?
         if ($this->frm->isCorrect()) {
             /*
             	the actual sending of a mailing happens in ajax/send_mailing.php
             	This, however, is the point where a preview is sent to a specific address.
             */
             // set from email
             $fromEmail = empty($this->record['from_email']) ? BackendModel::getModuleSetting($this->getModule(), 'from_email') : $this->record['from_email'];
             $fromName = empty($this->record['from_name']) ? BackendModel::getModuleSetting($this->getModule(), 'from_name') : $this->record['from_name'];
             $replyToEmail = empty($this->record['reply_to_email']) ? BackendModel::getModuleSetting($this->getModule(), 'reply_to_email') : $this->record['reply_to_email'];
             // build URL
             $url = BackendModel::createURLForAction('edit') . '&amp;id=' . $this->id . '&amp;step=4';
             $subject = '[TEST] ' . $this->record['subject'];
             $HTML = $this->record['data']['full_content_html'];
             $plainText = !empty($this->record['content_plain']) ? $this->record['content_plain'] : null;
             // send mail
             BackendMailer::addEmail($subject, $HTML, null, $txtEmail->getValue(), null, $fromEmail, $fromName, $replyToEmail, null, false, null, true, $plainText);
             // send the preview
             $this->redirect($url . '&amp;report=preview-sent&amp;var=' . $txtEmail->getValue());
         }
     }
 }