Exemple #1
0
 public function index()
 {
     if (isset($_POST['feedback'])) {
         if ($this->validate()) {
             $mb = '<table><tr><td>Message from:</td><td>' . $_POST['name'] . '</td></tr>';
             $mb .= '<tr><td>Email:</td><td>' . $_POST['email'] . '</td></tr>';
             $mb .= '<tr><td>Phone:</td><td>' . $_POST['phone'] . '</td></tr>';
             $mb .= '<tr><td>Message:</td><td>' . $_POST['message'] . '</td></tr></table>';
             if ($this->engine->sendMail(EMAIL, 'system@' . $this->engine->host, 'System mailer', 'Feedback', $mb)) {
                 $_SESSION['msg'] = 'sent';
             } else {
                 $_SESSION['msg'] = 'message_fail';
             }
             $this->engine->url->redirect($this->engine->url->full);
         } else {
             $_SESSION['msg'] = 'empty_vars';
         }
     }
     $this->engine->ERROR_404 = FALSE;
     $this->engine->document->setTitle($this->params['title_' . $_SESSION['lang']]);
     $this->engine->document->setKeywords($this->params['kw_' . $_SESSION['lang']]);
     $this->engine->document->setDescription($this->params['descr_' . $_SESSION['lang']]);
     if ((bool) $this->params['captcha_required']) {
         $captcha = new QCaptcha();
         $this->data['captcha'] = $captcha->getContent();
         $_SESSION['captcha'] = $captcha->getCode();
         unset($captcha);
     }
     if (isset($_SESSION['msg'])) {
         if ($_SESSION['msg'] == 'sent') {
             $this->data['text_message'] = $this->params['sent_' . $_SESSION['lang']];
             $this->data['class_message'] = 'success';
         } elseif ($_SESSION['msg'] == 'message_fail') {
             $this->data['text_message'] = $this->params['message_fail_' . $_SESSION['lang']];
             $this->data['class_message'] = 'error';
         } elseif ($_SESSION['msg'] == 'empty_vars') {
             $this->data['text_message'] = $this->params['empty_vars_' . $_SESSION['lang']];
             $this->data['class_message'] = 'error';
         }
         unset($_SESSION['msg']);
     }
     $this->data['name'] = isset($_POST['name']) ? htmlspecialchars($_POST['name']) : '';
     $this->data['phone'] = isset($_POST['phone']) ? htmlspecialchars($_POST['phone']) : '';
     $this->data['email'] = isset($_POST['email']) ? htmlspecialchars($_POST['email']) : '';
     $this->data['message'] = isset($_POST['message']) ? htmlspecialchars($_POST['message']) : '';
     $this->data['info'] = $this->params['info_' . $_SESSION['lang']];
     $this->data['caption'] = $this->params['caption_' . $_SESSION['lang']];
     $this->data['send'] = $this->params['send_' . $_SESSION['lang']];
     $this->data['email_placeholder'] = $this->params['email_placeholder_' . $_SESSION['lang']];
     $this->data['name_placeholder'] = $this->params['name_placeholder_' . $_SESSION['lang']];
     $this->data['phone_placeholder'] = $this->params['phone_placeholder_' . $_SESSION['lang']];
     $this->data['message_placeholder'] = $this->params['message_placeholder_' . $_SESSION['lang']];
     $this->template = TEMPLATE . 'template/modules/feedback.tpl';
 }
Exemple #2
0
 private function publicReloadCaptcha()
 {
     $captcha = new QCaptcha();
     $_SESSION['captcha'] = $captcha->getCode();
     die(json_encode($captcha->getContent()));
 }
Exemple #3
0
 public function index()
 {
     $this->engine->ERROR_404 = FALSE;
     if (!isset($_GET['action'])) {
         $_GET['action'] = '';
     }
     if ($_GET['action'] == 'register') {
         if ($this->engine->user->logged) {
             $this->engine->url->redirect($this->engine->url->link('route=account'));
         }
         if (isset($_POST['register'])) {
             if ((bool) $this->params['captcha_required'] && $_SESSION['captcha'] == $_POST['captcha'] || !(bool) $this->params['captcha_required']) {
                 $result = $this->register($_POST['name'], $_POST['email'], $_POST['password']);
                 if ($result === true) {
                     $_SESSION['msg'] = 'success';
                     $this->engine->url->redirect($this->engine->url->full);
                 } else {
                     $_SESSION['msg'] = 'fail';
                     $this->data['text_message'] = $result;
                 }
             } else {
                 $_SESSION['msg'] = 'captcha_not_valid';
             }
         }
         $this->engine->document->setTitle($this->params['title_registration_' . $_SESSION['lang']]);
         if ((bool) $this->params['captcha_required']) {
             $captcha = new QCaptcha();
             $this->data['captcha'] = $captcha->getContent();
             $_SESSION['captcha'] = $captcha->getCode();
             unset($captcha);
         }
         $this->data['caption'] = $this->params['title_registration_' . $_SESSION['lang']];
         $this->data['placeholder_name'] = $this->params['placeholder_name_' . $_SESSION['lang']];
         $this->data['placeholder_email'] = $this->params['placeholder_email_' . $_SESSION['lang']];
         $this->data['placeholder_password'] = $this->params['placeholder_password_' . $_SESSION['lang']];
         $this->data['confirm'] = $this->params['confirm_' . $_SESSION['lang']];
         $this->data['agree'] = sprintf(html_entity_decode($this->params['agree_' . $_SESSION['lang']]), htmlspecialchars($this->engine->url->link($this->params['agreement'])));
         $this->data['password_not_valid'] = $this->params['not_valid_password_' . $_SESSION['lang']];
         $this->data['name'] = isset($_POST['name']) ? htmlspecialchars($_POST['name']) : '';
         $this->data['password'] = isset($_POST['password']) ? htmlspecialchars($_POST['password']) : '';
         $this->data['email'] = isset($_POST['email']) ? htmlspecialchars($_POST['email']) : '';
         $template = 'template/account/register.tpl';
         if (isset($_SESSION['msg'])) {
             if ($_SESSION['msg'] == 'success') {
                 $this->data['caption'] = $this->params['registration_finished_' . $_SESSION['lang']];
                 $this->data['text'] = $this->params['additional_text_' . $_SESSION['lang']];
                 $template = 'template/common/success.tpl';
             } elseif ($_SESSION['msg'] == 'fail') {
                 $this->data['class_message'] = 'error';
             } elseif ($_SESSION['msg'] == 'captcha_not_valid') {
                 $this->data['text_message'] = $this->params['not_valid_captcha_' . $_SESSION['lang']];
                 $this->data['class_message'] = 'error';
             }
             unset($_SESSION['msg']);
         }
     } elseif ($_GET['action'] == 'confirm') {
         if ($this->engine->user->logged) {
             $this->engine->url->redirect($this->engine->url->link('route=account'));
         }
         if (!isset($_GET['confirm_key']) || $_GET['confirm_key'] == '') {
             $this->engine->url->redirect($this->engine->url->link('route=home'));
         }
         $this->confirm($_GET['confirm_key']);
         $this->engine->document->setTitle($this->params['account_confirmed_' . $_SESSION['lang']]);
         $this->data['caption'] = $this->params['account_confirmed_' . $_SESSION['lang']];
         $this->data['text'] = '';
         $template = 'template/common/success.tpl';
     } elseif ($_GET['action'] == 'restore') {
         if ($this->engine->user->logged) {
             $this->engine->url->redirect($this->engine->url->link('route=account'));
         }
         if (!isset($_GET['confirm_key']) || $_GET['confirm_key'] == '') {
             $this->engine->url->redirect($this->engine->url->link('route=home'));
         }
         $this->engine->document->setTitle($this->params['restore_password_' . $_SESSION['lang']]);
         $this->data['caption'] = $this->params['restore_password_' . $_SESSION['lang']];
         $this->data['new_pass'] = $this->params['new_pass_' . $_SESSION['lang']];
         $this->data['confirm'] = $this->params['confirm_' . $_SESSION['lang']];
         if (isset($_POST['password'])) {
             $email = $this->restore($_GET['confirm_key'], $_POST['password']);
             if ($email !== false) {
                 $this->engine->user->login($email, $_POST['password']);
             }
             $this->engine->url->redirect($this->engine->url->link('route=account'));
         }
         $template = 'template/account/restore.tpl';
     } elseif ($_GET['action'] == 'login') {
         if ($this->engine->user->logged) {
             $this->engine->url->redirect($this->engine->url->link('route=account'));
         }
         $this->engine->document->setTitle($this->params['title_login_' . $_SESSION['lang']]);
         $this->data['caption'] = $this->params['title_login_' . $_SESSION['lang']];
         $this->data['placeholder_email'] = $this->params['placeholder_email_' . $_SESSION['lang']];
         $this->data['placeholder_password'] = $this->params['placeholder_password_' . $_SESSION['lang']];
         $this->data['log_in'] = $this->params['log_in_' . $_SESSION['lang']];
         $this->data['password_not_valid'] = $this->params['not_valid_password_' . $_SESSION['lang']];
         $this->data['remember_me'] = $this->params['remember_me_' . $_SESSION['lang']];
         $this->data['data_incorrect'] = $this->params['data_incorrect_' . $_SESSION['lang']];
         $this->data['email_not_confirmed'] = $this->params['email_not_confirmed_' . $_SESSION['lang']];
         $this->data['login_success'] = $this->params['login_success_' . $_SESSION['lang']];
         $this->data['unknown_error'] = $this->params['unknown_error_' . $_SESSION['lang']];
         $this->data['restore_password'] = $this->params['restore_password_' . $_SESSION['lang']];
         $this->data['instructions_sent'] = $this->params['instructions_sent_' . $_SESSION['lang']];
         $this->data['confirm'] = $this->params['confirm_' . $_SESSION['lang']];
         $this->data['password'] = isset($_POST['password']) ? htmlspecialchars($_POST['password']) : '';
         $this->data['email'] = isset($_POST['email']) ? htmlspecialchars($_POST['email']) : '';
         $template = 'template/account/login.tpl';
     } elseif ($_GET['action'] == 'logout') {
         if ($this->engine->user->logged) {
             $this->engine->user->logout();
         }
         $this->engine->url->redirect($this->engine->url->link('route=home'));
     } else {
         if (!$this->engine->user->logged) {
             $this->engine->url->redirect($this->engine->url->link('route=account', 'action=login'));
         }
         $this->engine->document->setTitle($this->params['title_account_' . $_SESSION['lang']]);
         $user_data = $this->engine->user->getData();
         $this->data['caption'] = $this->params['title_account_' . $_SESSION['lang']];
         $this->data['placeholder_name'] = $this->params['placeholder_name_' . $_SESSION['lang']];
         $this->data['placeholder_email'] = $this->params['placeholder_email_' . $_SESSION['lang']];
         $this->data['old_pass'] = $this->params['old_pass_' . $_SESSION['lang']];
         $this->data['new_pass'] = $this->params['new_pass_' . $_SESSION['lang']];
         $this->data['save'] = $this->params['save_' . $_SESSION['lang']];
         $this->data['confirm'] = $this->params['confirm_' . $_SESSION['lang']];
         $this->data['log_out'] = $this->params['log_out_' . $_SESSION['lang']];
         $this->data['change_my_pass'] = $this->params['change_my_pass_' . $_SESSION['lang']];
         $this->data['cancel'] = $this->params['cancel_' . $_SESSION['lang']];
         $this->data['login_success'] = $this->params['login_success_' . $_SESSION['lang']];
         $this->data['data_incorrect'] = $this->params['data_incorrect_' . $_SESSION['lang']];
         $this->data['unknown_error'] = $this->params['unknown_error_' . $_SESSION['lang']];
         $this->data['changes_applied'] = $this->params['changes_applied_' . $_SESSION['lang']];
         $this->data['name'] = $user_data['name'];
         $this->data['email'] = $user_data['email'];
         $this->data['photo'] = resizeImage($user_data['photo'], 150, 150);
         $template = 'template/account/account.tpl';
     }
     $this->template = TEMPLATE . $template;
 }